#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/types.h>
#include <unistd.h>
#include "PSMILe_f2c.h"
Go to the source code of this file.
Defines | |
#define | VOLATILE volatile |
Functions/Subroutines | |
void | psmile_attach (INTEGER *psmile_rank) |
#define VOLATILE volatile |
Definition at line 16 of file psmile_attach.c.
Referenced by psmile_attach().
void psmile_attach | ( | INTEGER * | psmile_rank | ) |
Definition at line 32 of file psmile_attach.c.
References mpp_mod_oa::stderr(), and VOLATILE.
Referenced by prism_init().
00039 : 00040 00041 Integer, Intent (In) :: psmile_rank 00042 00043 Rank of PSMILe process in comm_psmile 00044 00045 00046 !RETURN VALUES: 00047 00048 !DESCRIPTION: 00049 00050 Subroutine "psmile_attach" gives the user the possibility 00051 to attach a PSMILe process with rank "psmile_rank" if 00052 the environment variable "PSMILE_ATTACH" is set to this rank. 00053 00054 !FILES USED: 00055 00056 <stdio.h> 00057 <stddef.h> 00058 <stdlib.h> 00059 <string.h> 00060 00061 "mpi.h" 00062 "PSMILe_f2c.h" 00063 00064 !REVISION HISTORY: 00065 00066 Date Programmer Description 00067 ---------- ---------- ----------- 00068 29.11.05 H. Ritzdorf created 00069 00070 //EOP 00071 00072 ---------------------------------------------------------------------- 00073 $Id: psmile_attach.c 2325 2010-04-21 15:00:07Z valcke $ 00074 $Author: valcke $ 00075 ---------------------------------------------------------------------- */ 00076 00077 { 00078 char *env = getenv ("PSMILE_ATTACH"); 00079 int rank; 00080 00081 if (env == NULL) return; 00082 00083 /* Transform character string into int */ 00084 00085 rank = strtol (env, (char **) NULL, 10); 00086 00087 if (rank == *psmile_rank) { 00088 time_t t_start, t_end; 00089 VOLATILE int attached = 0; 00090 00091 fprintf (stderr, "[%d] PSMILe_attach: ### Wait for user attach; pid %d\n", 00092 *psmile_rank, getpid ()); 00093 fflush (stderr); 00094 t_start = time(NULL); 00095 00096 while (attached == 0) { 00097 t_end = time(NULL); 00098 00099 if (t_end - t_start > 30 || t_end < t_start) { 00100 fprintf (stderr, "[%d] PSMILe_attach: ### Wait aborted since time limit exceeded\n", 00101 *psmile_rank); 00102 break; 00103 } 00104 } 00105 } 00106 } }