-
Notifications
You must be signed in to change notification settings - Fork 3
/
macros.h
35 lines (24 loc) · 978 Bytes
/
macros.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
programming conventions and macros
*/
#define TRUE 1
#define FALSE 0
#define SQUARE(a) (((double)a) * ((double)a))
#ifndef MIN
#define MIN(x, y) (((x)<(y))?(x):(y))
#endif
#ifndef MAX
#define MAX(x, y) (((x)>(y))?(x):(y))
#endif
#define log2(x) (log(x) * INVERSE_LN_TWO)
#define TOGV(x) (((x==FALSE)?(TRUE):(FALSE)))
#define MEMERROR(x) {fprintf(stderr,"%s: memory allocation error\nexiting now.\n",x);exit(-1);}
#define PMEMERROR(x) {if(medium->comm_rank==0)fprintf(stderr,"%s: memory allocation error\nexiting now.\n",x);exit(-1);}
#define READ_ERROR(x) {fprintf(stderr,"read error file \"%s\", exiting\n",x);exit(-1);}
#define PERROR(x) {if(medium->comm_rank==0)fprintf(stderr,"ERROR: %s\n",x);exit(-1);}
#define HEADNODE if(medium->comm_rank==0)
#define RAD2DEGF(x) ((x)*RAD2DEG)
#define DEG2RADF(x) ((x)*DEG2RAD)
// numerical recipes
#define NUMREC_SWAP(a,b) {swap=(a);(a)=(b);(b)=swap;}
#define NUMREC_ISWAP(a,b) {itemp=(a);(a)=(b);(b)=itemp;}