Afivo  0.3
cpp_macros.h
1 #ifdef __GFORTRAN__
2 #define PASTE(a) a
3 #define CONCAT(a,b) PASTE(a)b
4 #else
5 #define PASTE(a) a ## b
6 #define CONCAT(a,b) PASTE(a,b)
7 #endif
8 
9 #if NDIM == 1
10 #define DTIMES(TXT) TXT
11 #define DINDEX(TXT) TXT(1)
12 #define DSLICE(lo,hi) lo(1):hi(1)
13 #define KJI_DO(lo,hi) i = lo, hi
14 #define CLOSE_DO
15 #define IJK i
16 #define IJK_(s) CONCAT(i_,s)
17 #define DIMNAME "1d"
18 #elif NDIM == 2
19 #define DTIMES(TXT) TXT, TXT
20 #define DINDEX(TXT) TXT(1), TXT(2)
21 #define DSLICE(lo,hi) lo(1):hi(1), lo(2):hi(2)
22 #define KJI_DO(lo,hi) j = lo, hi; do i = lo, hi
23 #define CLOSE_DO end do
24 #define IJK i, j
25 #define IJK_(s) CONCAT(i_,s), CONCAT(j_,s)
26 #define DIMNAME "2d"
27 #elif NDIM == 3
28 #define DTIMES(TXT) TXT, TXT, TXT
29 #define DINDEX(TXT) TXT(1), TXT(2), TXT(3)
30 #define DSLICE(lo,hi) lo(1):hi(1), lo(2):hi(2), lo(3):hi(3)
31 #define KJI_DO(lo,hi) k = lo, hi; do j = lo, hi; do i = lo, hi
32 #define CLOSE_DO end do; end do
33 #define IJK i, j, k
34 #define IJK_(s) CONCAT(i_,s), CONCAT(j_,s), CONCAT(k_,s)
35 #define DIMNAME "3d"
36 #endif