diff options
Diffstat (limited to 'src/Write2D.c')
-rw-r--r-- | src/Write2D.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/Write2D.c b/src/Write2D.c index 66e25f3..4c7db4d 100644 --- a/src/Write2D.c +++ b/src/Write2D.c @@ -219,23 +219,31 @@ int IOASCII_Write2D (const cGH *GH, int vindex, const char *alias) sprintf (format[2], "\t\t%%%s", out_format); /* processor 0 opens the files on the first trip through */ + fileset = NULL; myproc = CCTK_MyProc (GH); if (myproc == 0) { fileset = OpenFile (GH, fullname, alias, gdata.dim, have_coords ? coord_lower : NULL, maxdir); } - else - { - fileset = NULL; - } /* get the extents of the variable */ CCTK_GroupgshVI (GH, gdata.dim, extent_int, vindex); + /* get the total number of grid points to check for zero-sized variables */ + for (dir = 0, hsize[0] = 1; dir < gdata.dim; dir++) + { + hsize[0] *= extent_int[dir]; + } + /* now do the actual I/O looping over all directions */ for (dir = 0; dir < maxdir; dir++) { + if (hsize[0] <= 0) + { + continue; + } + /* get the directions to span the hyperslab */ if (dir == 0) { @@ -288,6 +296,7 @@ int IOASCII_Write2D (const cGH *GH, int vindex, const char *alias) continue; } + hdata[0] = hdata[1] = hdata[2]; if (myproc == 0) { /* allocate hyperslab buffers */ @@ -309,7 +318,7 @@ int IOASCII_Write2D (const cGH *GH, int vindex, const char *alias) Hyperslab_FreeMapping (mapping); /* and dump the data to file */ - if (myproc == 0 && fileset) + if (fileset) { if (num_returned_hslabs == num_requested_hslabs) { @@ -338,10 +347,7 @@ int IOASCII_Write2D (const cGH *GH, int vindex, const char *alias) /* clean up */ free (hdata[0]); - if (hdata[1]) - { - free (hdata[1]); - } + free (hdata[1]); } /* end of outputting the data by processor 0 */ |