diff options
author | tradke <tradke@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2001-07-03 12:40:54 +0000 |
---|---|---|
committer | tradke <tradke@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2001-07-03 12:40:54 +0000 |
commit | f7484d9e9f40ceff0292fe4eb3c3ef3bf7a6a0fa (patch) | |
tree | 7aa53f4f2b64121ef523da0a96af6013f897a01d /src | |
parent | e4fb30cfa8ff030b72a92f5b736952c36daffb9f (diff) |
Define CCTK_GFINDEX?D as macros for C code (as it was before) but as inline
functions for C++ code.
For CCTK_DEBUG configurations these are defined as external C functions.
Get rid of cctk_dummy_<type> pointers in the _DECLARE_CCTK_CARGUMENTS and
_USE_CCTK_CARGUMENTS macros.
git-svn-id: http://svn.cactuscode.org/flesh/trunk@2264 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src')
-rw-r--r-- | src/include/cctk.h | 182 |
1 files changed, 116 insertions, 66 deletions
diff --git a/src/include/cctk.h b/src/include/cctk.h index bbb5b039..c9364468 100644 --- a/src/include/cctk.h +++ b/src/include/cctk.h @@ -2,27 +2,26 @@ @header cctk.h @date Tue Jan 26 17:29:34 1999 @author Tom Goodale - @desc - Main include file for the CCTK. All thorns should include this... + @desc + Main include file for the CCTK. + All thorns should include this. @enddesc - @version $Header$ + @version $Header$ @@*/ #ifndef _CCTK_H_ #define _CCTK_H_ /* Grab the main configuration info. */ - #include "cctk_Config.h" /* Define which thorn the file is in */ - #include "definethisthorn.h" /* Include the constants */ - #include "cctk_Constants.h" + /* Define some stuff */ #ifdef FCODE @@ -103,10 +102,69 @@ #include "cctk_Sync.h" #include "cctk_WarnLevel.h" -#define CCTK_GFINDEX4D(GH,i,j,k,l) ((i) + (GH)->cctk_lsh[0]*( (j)+(GH)->cctk_lsh[1]*( (k)+(GH)->cctk_lsh[2]*(l) ) ) ) -#define CCTK_GFINDEX3D(GH,i,j,k) ((i) + (GH)->cctk_lsh[0]*((j)+(GH)->cctk_lsh[1]*(k))) -#define CCTK_GFINDEX2D(GH,i,j) ((i) + (GH)->cctk_lsh[0]*((j))) -#define CCTK_GFINDEX1D(GH,i) (i) + +/* + * routines/macros to compute the linear index + * of a grid funtion element from its i/j/k dimensions + * + * For C++ these are defined as inline functions, for C as macros. + * For CCTK_DEBUG these are external C routines defined in Debug.c. + */ + +#ifdef CCTK_DEBUG + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +int CCTK_GFINDEX1D (const cGH *GH, int i); +int CCTK_GFINDEX2D (const cGH *GH, int i, int j); +int CCTK_GFINDEX3D (const cGH *GH, int i, int j, int k); +int CCTK_GFINDEX4D (const cGH *GH, int i, int j, int k, int l); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#else /* CCTK_DEBUG */ + +#ifdef __cplusplus + +inline int CCTK_GFINDEX1D (const cGH *GH, int i) +{ + GH = GH; + return (i); +} + +inline int CCTK_GFINDEX2D (const cGH *GH, int i, int j) +{ + return (i + GH->cctk_lsh[0]*j); +} + +inline int CCTK_GFINDEX3D (const cGH *GH, int i, int j, int k) +{ + return (i + GH->cctk_lsh[0]*(j + GH->cctk_lsh[1]*k)); +} + +inline int CCTK_GFINDEX4D (const cGH *GH, int i, int j, int k, int l) +{ + return (i + GH->cctk_lsh[0]*(j + GH->cctk_lsh[1]*(k + GH->cctk_lsh[2] * l))); +} + +#else /* __cplusplus */ + +#define CCTK_GFINDEX1D(GH, i) (i) +#define CCTK_GFINDEX2D(GH, i, j) ((i) + (GH)->cctk_lsh[0] * ((j))) +#define CCTK_GFINDEX3D(GH, i, j, k) ((i) + (GH)->cctk_lsh[0] * \ + ((j) + (GH)->cctk_lsh[1] * (k))) +#define CCTK_GFINDEX4D(GH, i, j, k, l) ((i) + (GH)->cctk_lsh[0] * \ + ((j) + (GH)->cctk_lsh[1] * \ + ((k) + (GH)->cctk_lsh[2] * (l)))) + +#endif /* __cplusplus */ + +#endif /* CCTK_DEBUG */ #define CCTK_PRINTSEPARATOR \ @@ -114,62 +172,55 @@ #define _DECLARE_CCTK_ARGUMENTS _DECLARE_CCTK_CARGUMENTS #define _DECLARE_CCTK_CARGUMENTS \ - void *cctk_dummy_pointer;\ - CCTK_INT cctk_dummy_int;\ - CCTK_REAL cctk_dummy_real;\ - int cctk_dim=cctkGH->cctk_dim;\ - int *cctk_gsh=cctkGH->cctk_gsh;\ - int *cctk_lsh=cctkGH->cctk_lsh;\ - int *cctk_lbnd=cctkGH->cctk_lbnd;\ - int *cctk_ubnd=cctkGH->cctk_ubnd;\ - int *cctk_lssh=cctkGH->cctk_lssh;\ - int *cctk_from=cctkGH->cctk_from;\ - int *cctk_to=cctkGH->cctk_to;\ - int *cctk_bbox=cctkGH->cctk_bbox;\ - CCTK_REAL cctk_delta_time=cctkGH->cctk_delta_time;\ - CCTK_REAL cctk_time=cctkGH->cctk_time;\ - CCTK_REAL *cctk_delta_space=cctkGH->cctk_delta_space;\ - CCTK_REAL *cctk_origin_space=cctkGH->cctk_origin_space;\ - int *cctk_levfac=cctkGH->cctk_levfac;\ - int cctk_convlevel=cctkGH->cctk_convlevel;\ - int *cctk_nghostzones=cctkGH->cctk_nghostzones;\ - int cctk_iteration=cctkGH->cctk_iteration; - - -#define _USE_CCTK_CARGUMENTS\ - cctk_dummy_int=0;\ - cctk_dummy_int+=0;\ - cctk_dummy_real=0;\ - cctk_dummy_real+=0;\ - cctk_dummy_pointer=NULL;\ - cctk_dummy_pointer=(CCTK_REAL *)cctk_dummy_pointer;\ - cctk_dummy_int=cctk_dim;\ - cctk_dummy_pointer=(void *)cctk_gsh;\ - cctk_dummy_pointer=(void *)cctk_lsh;\ - cctk_dummy_pointer=(void *)cctk_lbnd;\ - cctk_dummy_pointer=(void *)cctk_ubnd;\ - cctk_dummy_pointer=(void *)cctk_lssh;\ - cctk_dummy_pointer=(void *)cctk_from;\ - cctk_dummy_pointer=(void *)cctk_to;\ - cctk_dummy_pointer=(void *)cctk_bbox;\ - cctk_dummy_real=cctk_delta_time;\ - cctk_dummy_real=cctk_time;\ - cctk_dummy_pointer=(void *)cctk_delta_space;\ - cctk_dummy_pointer=(void *)cctk_origin_space;\ - cctk_dummy_pointer=(void *)cctk_levfac;\ - cctk_dummy_int=cctk_convlevel;\ - cctk_dummy_pointer=(void *)cctk_nghostzones;\ - cctk_dummy_int=cctk_iteration; + int cctk_dim = cctkGH->cctk_dim;\ + int *cctk_gsh = cctkGH->cctk_gsh;\ + int *cctk_lsh = cctkGH->cctk_lsh;\ + int *cctk_lbnd = cctkGH->cctk_lbnd;\ + int *cctk_ubnd = cctkGH->cctk_ubnd;\ + int *cctk_lssh = cctkGH->cctk_lssh;\ + int *cctk_from = cctkGH->cctk_from;\ + int *cctk_to = cctkGH->cctk_to;\ + int *cctk_bbox = cctkGH->cctk_bbox;\ + CCTK_REAL cctk_delta_time = cctkGH->cctk_delta_time;\ + CCTK_REAL cctk_time = cctkGH->cctk_time;\ + CCTK_REAL *cctk_delta_space = cctkGH->cctk_delta_space;\ + CCTK_REAL *cctk_origin_space = cctkGH->cctk_origin_space;\ + int *cctk_levfac = cctkGH->cctk_levfac;\ + int cctk_convlevel = cctkGH->cctk_convlevel;\ + int *cctk_nghostzones = cctkGH->cctk_nghostzones;\ + int cctk_iteration = cctkGH->cctk_iteration;\ + const void *cctk_dummy_pointer; + + +#define _USE_CCTK_CARGUMENTS \ + cctk_dummy_pointer = &cctk_dim;\ + cctk_dummy_pointer = &cctk_gsh;\ + cctk_dummy_pointer = &cctk_lsh;\ + cctk_dummy_pointer = &cctk_lbnd;\ + cctk_dummy_pointer = &cctk_ubnd;\ + cctk_dummy_pointer = &cctk_lssh;\ + cctk_dummy_pointer = &cctk_from;\ + cctk_dummy_pointer = &cctk_to;\ + cctk_dummy_pointer = &cctk_bbox;\ + cctk_dummy_pointer = &cctk_delta_time;\ + cctk_dummy_pointer = &cctk_time;\ + cctk_dummy_pointer = &cctk_delta_space;\ + cctk_dummy_pointer = &cctk_origin_space;\ + cctk_dummy_pointer = &cctk_levfac;\ + cctk_dummy_pointer = &cctk_convlevel;\ + cctk_dummy_pointer = &cctk_nghostzones;\ + cctk_dummy_pointer = &cctk_iteration;\ + cctk_dummy_pointer = cctk_dummy_pointer; #define _INITIALISE_CCTK_C2F -#define _DECLARE_CCTK_C2F +#define _DECLARE_CCTK_C2F #define _PASS_CCTK_C2F(xGH) &((xGH)->cctk_dim),\ - (xGH)->cctk_gsh,(xGH)->cctk_lsh, \ - (xGH)->cctk_lbnd,(xGH)->cctk_ubnd, \ + (xGH)->cctk_gsh,(xGH)->cctk_lsh,\ + (xGH)->cctk_lbnd,(xGH)->cctk_ubnd,\ (xGH)->cctk_lssh,\ - (xGH)->cctk_from,(xGH)->cctk_to, \ + (xGH)->cctk_from,(xGH)->cctk_to,\ (xGH)->cctk_bbox,\ - &((xGH)->cctk_delta_time), \ + &((xGH)->cctk_delta_time),\ &((xGH)->cctk_time), (xGH)->cctk_delta_space,\ (xGH)->cctk_origin_space,\ (xGH)->cctk_levfac,\ @@ -188,12 +239,12 @@ int *,\ cGH * -#define CCTK_STORAGESIZE(xGH, cctk_dim, group) \ - (CCTK_QueryGroupStorage(xGH,group) ?\ - (CCTK_ArrayGroupSize(xGH, cctk_dim, group)) : &(_cctk_one)) +extern int _cctk_one; +#define CCTK_STORAGESIZE(xGH, cctk_dim, group) \ + (CCTK_QueryGroupStorage(xGH, group) ?\ + (CCTK_ArrayGroupSize(xGH, cctk_dim, group)) : &_cctk_one) -extern int _cctk_one; #define CCTK_EQUALS(a,b) (CCTK_Equals((a),(b))==1) @@ -226,4 +277,3 @@ extern int _cctk_one; #endif - |