![]() ![]() ![]() ![]() Next: Fortran Thorn Writers Up: Advanced Thorn Writing Previous: General Naming Conventions Contents
|
Data Type | Size (bytes) | Variable Type | Fortran Equivalent |
CCTK_BYTE | 1 | CCTK_VARIABLE_BYTE | integer*1 |
CCTK_INT1 | 1 | CCTK_VARIABLE_INT1 | integer*1 |
CCTK_INT2 | 2 | CCTK_VARIABLE_INT2 | integer*2 |
CCTK_INT4 | 4 | CCTK_VARIABLE_INT4 | integer*4 |
CCTK_INT8 | 8 | CCTK_VARIABLE_INT8 | integer*8 |
CCTK_REAL4 | 4 | CCTK_VARIABLE_REAL4 | real*4 |
CCTK_REAL8 | 8 | CCTK_VARIABLE_REAL8 | real*8 |
CCTK_REAL16 | 16 | CCTK_VARIABLE_REAL16 | real*16 |
CCTK_COMPLEX8 | 8 | CCTK_VARIABLE_COMPLEX8 | complex*8 |
CCTK_COMPLEX16 | 16 | CCTK_VARIABLE_COMPLEX16 | complex*16 |
CCTK_COMPLEX32 | 32 | CCTK_VARIABLE_COMPLEX32 | complex*32 |
The availability of these types, and the corresponding C data types, are platform-dependent. For each fixed-size data type, there exists a corresponding preprocessor macro HAVE_<data type>, which should be used to check whether the given CCTK data type is supported, e.g.
/* declare variable with extended-precision complex data type if available, otherwise, with default CCTK precision */ #ifdef HAVE_CCTK_COMPLEX32 CCTK_COMPLEX32 var; #else CCTK_COMPLEX var; #endif
In addition, Cactus provides three generic numeric data types which map onto the compilers' native data types used to represent integer, real, and complex values. The size for these generic types can be chosen at configuration time (see Section A2.1.2). This is to allow the code to be run easily at different precisions. Note that the effectiveness of running the code, at a lower or higher precision, depends crucially on all thorns being used making consistent use of the these generic data types:
Data Type | Variable Type | Configuration Option | |
CCTK_INT | CCTK_VARIABLE_INT | INTEGER_PRECISION | |
CCTK_REAL | CCTK_VARIABLE_REAL | REAL_PRECISION | |
CCTK_COMPLEX | CCTK_VARIABLE_COMPLEX | Same as real precision |
These variable types must be used by thorn writers to declare variables in the thorn interface files, and may be used to declare variables in the thorn routines. Note that variable declarations in thorns should obviously match the definitions in the interface files where appropriate.
A set of macros, which are interpreted by the preprocessor at compile time, to signify which data size is being used, are also provided:
Data Type | #define |
CCTK_INT1 | CCTK_INT_PRECISION_1 |
CCTK_INT2 | CCTK_INT_PRECISION_2 |
CCTK_INT4 | CCTK_INT_PRECISION_4 |
CCTK_INT8 | CCTK_INT_PRECISION_8 |
CCTK_REAL4 | CCTK_REAL_PRECISION_4 |
CCTK_REAL8 | CCTK_REAL_PRECISION_8 |
CCTK_REAL16 | CCTK_REAL_PRECISION_16 |
CCTK_COMPLEX8 | CCTK_COMPLEX_PRECISION_8 |
CCTK_COMPLEX16 | CCTK_COMPLEX_PRECISION_16 |
CCTK_COMPLEX32 | CCTK_COMPLEX_PRECISION_32 |
Cactus also provides generic data and function pointers, which can be used from either C or Fortran:
Data Type | Variable Type | C equivalent |
CCTK_POINTER | CCTK_VARIABLE_POINTER | void *data_ptr |
CCTK_POINTER_TO_CONST | CCTK_VARIABLE_POINTER_TO_CONST | const void *data_ptr |
CCTK_FPOINTER | CCTK_VARIABLE_FPOINTER | void (*fn_ptr)(void) |