diff options
Diffstat (limited to 'src/Write2D.c')
-rw-r--r-- | src/Write2D.c | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/src/Write2D.c b/src/Write2D.c index 8ae079b..32bee3e 100644 --- a/src/Write2D.c +++ b/src/Write2D.c @@ -15,7 +15,8 @@ #include "cctk.h" #include "cctk_Parameters.h" #include "CactusPUGH/PUGHSlab/src/PUGHSlab.h" -#include "CactusBase/IOUtil/src/ioGH.h" +#include "CactusBase/IOUtil/src/ioutil_AdvertisedFiles.h" +#include "CactusBase/IOUtil/src/ioutil_CheckpointRecovery.h" #include "ioASCIIGH.h" @@ -84,7 +85,6 @@ void IOASCII_Write2D (cGH *GH, int index, const char *alias) { DECLARE_CCTK_PARAMETERS int myproc; - ioGH *ioUtilGH; asciiioGH *myGH; const char *header_fmt_string; /* header format string */ const char *data_fmt_string_int; /* data format string for int types */ @@ -97,7 +97,6 @@ void IOASCII_Write2D (cGH *GH, int index, const char *alias) int coord_index [3]; /* variable indices for xyz coordinates */ int coord_timelevel [3]; /* coordinates' current timelevels */ int origin [3]; /* the slice origin */ - const char *errormsg; /* error message string */ /* to make the compiler happy */ @@ -107,24 +106,18 @@ void IOASCII_Write2D (cGH *GH, int index, const char *alias) groupindex = CCTK_GroupIndexFromVarI (index); CCTK_GroupData (groupindex, &groupinfo); - /* check if variable is of dimension 3 and has storage assigned */ - errormsg = NULL; - if (groupinfo.dim != 3) - errormsg = "No IOASCII 2D output for '%s' (dim != 3)"; - else if (! CCTK_QueryGroupStorageI (GH, groupindex)) - errormsg = "No IOASCII 2D output for '%s' (no storage)"; - - if (errormsg) + /* check if variable has storage assigned */ + if (! CCTK_QueryGroupStorageI (GH, groupindex)) { char *fullname = CCTK_FullName (index); - CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, errormsg, fullname); + CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, + "No IOASCII 2D output for '%s' (no storage)", fullname); free (fullname); return; } - /* Get the handles for IOUtil and IOASCII extensions */ - ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")]; + /* Get the handle for IOASCII extensions */ myGH = (asciiioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOASCII")]; /* set header and data format strings */ @@ -166,7 +159,7 @@ FIXME: get rid of PUGH here /* Open/Create files */ for (dir = 0; dir < 3; dir++) { - IOUtil_AdvertisedFileDesc_t advertised_file; + ioAdvertisedFileDesc advertised_file; const char *extensions [3] = {"yz", "xz", "xy"}; #if 0 @@ -179,12 +172,16 @@ FIXME: get rid of PUGH here /* if restart from recovery, try to open an existing file ... */ fdset_2D [dir] = NULL; - if (ioUtilGH->recovered) + if (IOUtil_RestartFromRecovery (GH)) + { fdset_2D [dir] = fopen (fname, "a"); + } /* otherwise or if that failed, create a new one */ if (! fdset_2D [dir]) + { fdset_2D [dir] = fopen (fname, "w"); + } if (! fdset_2D [dir]) { CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, @@ -215,19 +212,18 @@ FIXME: get rid of PUGH here switch (groupinfo.dim) { case 1: - coord_index [0] = CCTK_CoordIndex (1,NULL,"cart1d"); + coord_index [0] = CCTK_CoordIndex (1, NULL, "cart1d"); break; case 2: - coord_index [0] = CCTK_CoordIndex (1,NULL,"cart2d"); - coord_index [1] = CCTK_CoordIndex (2,NULL,"cart2d"); + coord_index [0] = CCTK_CoordIndex (1, NULL, "cart2d"); + coord_index [1] = CCTK_CoordIndex (2, NULL, "cart2d"); case 3: - coord_index [0] = CCTK_CoordIndex (1,NULL,"cart3d"); - coord_index [1] = CCTK_CoordIndex (2,NULL,"cart3d"); - coord_index [2] = CCTK_CoordIndex (3,NULL,"cart3d"); + coord_index [0] = CCTK_CoordIndex (1, NULL, "cart3d"); + coord_index [1] = CCTK_CoordIndex (2, NULL, "cart3d"); + coord_index [2] = CCTK_CoordIndex (3, NULL, "cart3d"); break; default: - CCTK_VWarn(4,__LINE__,__FILE__,"IOASCII", - "Cannot find appropriate coordinate system"); + CCTK_WARN (4, "Cannot find appropriate coordinate system"); break; } @@ -236,13 +232,17 @@ FIXME: get rid of PUGH here { coord_timelevel [dir] = CCTK_NumTimeLevelsFromVarI (coord_index [dir]) - 1; if (coord_timelevel [dir] > 0) + { coord_timelevel [dir]--; + } } /* get the timelevel for the variable to output */ timelevel = CCTK_NumTimeLevelsFromVarI (index) - 1; if (timelevel > 0) + { timelevel--; + } for (dir = 0; dir < 3; dir++) { |