SURFEX v8.1
General documentation of Surfex
ra_check.c
Go to the documentation of this file.
1 #ifdef RS6K
2 #include <sys/rset.h>
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <unistd.h>
6 #include <sys/thread.h>
7 
8 #define CHECK_PROC 1
9 #define CHECK_THREAD 2
10 #define ra_check ra_check_
11 
12 /*------ Code supplied by Will Weir------------*/
13 int ra_check(const int *check_type, int *prnt)
14 {
15  int rs;
16  int thread_num;
17  rstype_t rstype;
18  rsid_t rsid;
19  unsigned int flags;
20  rsethandle_t rset;
21 
22  pid_t mypid;
23  tid_t mytid;
24 
25  mypid=getpid();
26  mytid=thread_self();
27 
28  rset=rs_alloc(RS_EMPTY);
29 
30  if ( *check_type == CHECK_PROC )
31  {
32 /* fprintf(stderr,"ra_check: CHECK_PROC\n"); */
33  rstype=R_PROCESS;
34  rsid.at_pid=RS_MYSELF;
35  }
36  else if ( *check_type == CHECK_THREAD )
37  {
38 /* fprintf(stderr,"ra_check: CHECK_THREAD\n"); */
39  rstype=R_THREAD;
40  rsid.at_tid=RS_MYSELF;
41  thread_num=omp_get_thread_num();
42  }
43  else
44  {
45  fprintf(stderr,"ra_check: check_type $d not CHECK_PROC or CHECK_THREAD\n",*check_type);
46  return(1);
47  }
48 
49 /* rsid.at_tid=RS_MYSELF; */
50 /* rsid.at_tid=pid; */
51 /* rsid.at_pid=pid; */
52 
53  rs=ra_getrset(rstype,rsid,0,rset);
54  if ( rs < 0 ) {
55  perror("ra_check: ra_getrset error:");
56  exit(-1);
57  } else if ( rs==RS_EFFECTIVE_RSET ) {
58  if(*prnt==1) fprintf(stderr,"pid: %d thread: %d tid: %d RSET type RS_EFFECTIVE_RSET\n",mypid,thread_num,mytid);
59  }
60  else if ( rs==RS_PARTITION_RSET ) {
61  if(*prnt==1) fprintf(stderr,"pid: %d thread: %d tid: %d RSET type RS_PARTITION_RSET\n",mypid,thread_num,mytid);
62  }
63  else if ( rs==RS_DEFAULT_RSET ) {
64  if(*prnt==1) fprintf(stderr,"pid: %d thread: %d tid: %d RSET type RS_DEFAULT_RSET\n",mypid,thread_num,mytid);
65  }
66  else if ( rs==RS_THREAD_RSET ) {
67  if(*prnt==1) fprintf(stderr,"pid: %d thread: %d tid: %d RSET type RS_THREAD_RSET\n",mypid,thread_num,mytid);
68  }
69  else if ( rs==RS_THREAD_PARTITION_RSET ) {
70  if(*prnt==1) fprintf(stderr,"pid: %d thread: %d tid: %d RSET type RS_THREAD_PARTITION_RSET\n",mypid,thread_num,mytid);
71  }
72 /*--------does not work on P6----------
73  else if ( rs==RS_ADVISORY_RSET ) {
74  if(*prnt==1) fprintf(stderr,"pid: %d thread: %d tid: %d RSET type RS_ADVISORY_RSET\n",mypid,thread_num,mytid);
75  }
76 */
77  if ( rs == RS_DEFAULT_RSET ) {
78  if(*prnt==1) fprintf(stderr,"ra_check: RS_DEFAULT_RSET returning 1\n");
79  return(1);
80  } else {
81  if(*prnt==1) fprintf(stderr,"ra_check: NOT RS_DEFAULT_RSET returning 0\n");
82  return(0);
83  }
84 
85 }
86 #endif
int ra_check(const int *check_type, int *prnt)
Definition: ra_check.c:13