aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Write2D.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/Write2D.c b/src/Write2D.c
index ee1f1bb..cf3fe35 100644
--- a/src/Write2D.c
+++ b/src/Write2D.c
@@ -35,33 +35,38 @@ CCTK_FILEVERSION(CactusBase_IOASCII_Write2D_c)
int _i, _j; \
const cctk_type *_hdata = hdata[0]; \
const CCTK_REAL *_coord[2]; \
- \
+ const int _dic = hsize[0]; \
+ const int _did = hsize[0] * (is_complex ? 2 : 1); \
\
\
_coord[0] = (const CCTK_REAL *) hdata[1]; \
_coord[1] = (const CCTK_REAL *) hdata[2]; \
- for (_j = 0; _j < hsize[1]; _j++) \
+ for (_i = 0; _i < hsize[0]; _i++) \
{ \
- for (_i = 0; _i < hsize[0]; _i++) \
+ for (_j = 0; _j < hsize[1]; _j++) \
{ \
if (_coord[0]) \
{ \
- fprintf (file, fmt, (double) *_coord[1]++, \
- (double) *_coord[0]++, (c_type) *_hdata++); \
+ fprintf (file, fmt, (double) _coord[0][_i+_dic*_j], \
+ (double) _coord[1][_i+_dic*_j], \
+ (c_type) _hdata[_i+_did*_j]); \
} \
else \
{ \
- fprintf (file, fmt, _j, _i, (c_type) *_hdata++); \
+ fprintf (file, fmt, _i, _j, (c_type) _hdata[_i+_did*_j]); \
} \
\
if (is_complex) \
{ \
- fprintf (file, format[2], (c_type) *_hdata++); \
+ fprintf (file, format[2], (c_type) _hdata[_i+1+_did*_j]); \
} \
fputc ('\n', file); \
} \
fputc ('\n', file); \
} \
+ _coord[0] += _dic*_j; \
+ _coord[1] += _dic*_j; \
+ _hdata += _did*_j; \
}