diff options
author | tradke <tradke@94b1c47f-dcfd-45ef-a468-0854c0e9e350> | 2000-09-21 13:31:31 +0000 |
---|---|---|
committer | tradke <tradke@94b1c47f-dcfd-45ef-a468-0854c0e9e350> | 2000-09-21 13:31:31 +0000 |
commit | e14a88126cbb2f8f9e2770272d9b1fb7b02c821f (patch) | |
tree | 60f69c38d1e0536880139622cb7b13276502c3b2 /src | |
parent | f20f4213f484a18ff8fad38f0228d01fda4d48e3 (diff) |
Include ioutil_AdvertisedFiles.h and ioutil_CheckpointRecovery.h
instead of ioGH.h.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOASCII/trunk@24 94b1c47f-dcfd-45ef-a468-0854c0e9e350
Diffstat (limited to 'src')
-rw-r--r-- | src/Write1D.c | 65 | ||||
-rw-r--r-- | src/Write2D.c | 48 |
2 files changed, 58 insertions, 55 deletions
diff --git a/src/Write1D.c b/src/Write1D.c index 48ad403..ff79e93 100644 --- a/src/Write1D.c +++ b/src/Write1D.c @@ -48,8 +48,9 @@ #include "cctk.h" #include "cctk_Parameters.h" -#include "CactusBase/IOUtil/src/ioGH.h" #include "CactusPUGH/PUGHSlab/src/PUGHSlab.h" +#include "CactusBase/IOUtil/src/ioutil_AdvertisedFiles.h" +#include "CactusBase/IOUtil/src/ioutil_CheckpointRecovery.h" #include "ioASCIIGH.h" /* the rcs ID and its dummy function to use it */ @@ -77,7 +78,7 @@ CCTK_FILEVERSION(CactusBase_IOASCII_Write1D_c) { \ for (i = 0; i < hsize; i++) \ fprintf (file, format, \ - (double) (i), \ + (double) i, \ (c_type) cctk_extract_fn (typed_data [i])); \ } \ } @@ -123,7 +124,6 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias) { DECLARE_CCTK_PARAMETERS asciiioGH *myGH; /* IOASCII extension handle */ - ioGH *ioUtilGH; /* IOUtil extension handle */ int Do_it [4]; /* flags indicating actual work */ int coord_index [3]; /* x,y,z coordinate variable indices */ int is_cubic; /* true if variable lives on cubic grid */ @@ -139,25 +139,26 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias) const char *data_fmt_real; /* data format string for float types */ FILE *file [8]; /* fds for x,y,z,d output (also COMPLEX)*/ + /* get the variable's group information */ groupindex = CCTK_GroupIndexFromVarI (index); CCTK_GroupData (groupindex, &groupinfo); - /* check if variable is of dimension 3 and has storage assigned */ + /* check if variable has storage assigned */ if (! CCTK_QueryGroupStorageI (GH, groupindex)) { char *fullname = CCTK_FullName (index); + CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, - "IOASCII_Write1D: No IOASCII_1D output for '%s' (no storage)", fullname); + "IOASCII_Write1D: No IOASCII_1D output for '%s' (no storage)", + fullname); free (fullname); return; } - /* Get the handles for IOUtil and IOASCII extensions */ - ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")]; - myGH = (asciiioGH *) GH->extensions - [CCTK_GHExtensionHandle ("IOASCII")]; + /* Get the handle for IOASCII extensions */ + myGH = (asciiioGH *) GH->extensions[CCTK_GHExtensionHandle ("IOASCII")]; /* see what slices should be output */ Do_it [0] = out1D_x && groupinfo.dim >= 1; @@ -196,39 +197,27 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias) { if (CCTK_Equals (out_style, "gnuplot")) { - header_fmt = "\n\n#Time = %f\n"; - } - else - { - header_fmt = "\n\n\"Time = %f\n"; - } - if (groupinfo.grouptype == CCTK_GF) - { - data_fmt_int = "%f\t\t%d\n"; - data_fmt_real = "%f\t\t%.13f\n"; + header_fmt = "\n\n#Time = %f\n"; } else { - data_fmt_int = "%d\t\t%d\n"; - data_fmt_real = "%f\t\t%.13f\n"; + header_fmt = "\n\n\"Time = %f\n"; } + data_fmt_int = "%f\t\t%d\n"; + data_fmt_real = "%f\t\t%.13f\n"; } else { if (CCTK_Equals (out_style, "gnuplot")) - header_fmt = "\n\n#Time = %e\n"; - else - header_fmt = "\n\n\"Time = %e\n"; - if (groupinfo.grouptype == CCTK_GF) { - data_fmt_int = "%e\t\t%d\n"; - data_fmt_real = "%e\t\t%.13e\n"; + header_fmt = "\n\n#Time = %e\n"; } else { - data_fmt_int = "%d\n"; - data_fmt_real = "%.13e\n"; + header_fmt = "\n\n\"Time = %e\n"; } + data_fmt_int = "%e\t\t%d\n"; + data_fmt_real = "%e\t\t%.13e\n"; } #ifdef DEBUG_IOASCII @@ -289,10 +278,14 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias) { /* if restart from recovery, all existing files are opened in append mode */ - if (ioUtilGH->recovered) + if (IOUtil_RestartFromRecovery (GH)) + { openmode = stat (filename, &fileinfo) == 0 ? "a" : "w"; + } else + { openmode = "w"; + } /* just store a non-NULL pointer in database */ StoreNamedData (&myGH->filenameList1D, filename, (void *) 1); @@ -313,7 +306,7 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias) /* advertise new files for downloading */ if (*openmode == 'w') { - IOUtil_AdvertisedFileDesc_t advertisedFile; + ioAdvertisedFileDesc advertisedFile; advertisedFile.slice = (char *) extensions [i]; @@ -379,7 +372,9 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias) /* get the current time level */ timelevel = CCTK_NumTimeLevelsFromVarI (index) - 1; if (timelevel > 0) + { timelevel--; + } /* OK so actually do the I/O in each direction */ for (dir = 0; dir < 4; dir++) @@ -397,7 +392,9 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias) /* skip empty slices */ if (! Do_it [dir]) + { continue; + } if (groupinfo.grouptype == CCTK_GF) { @@ -416,7 +413,9 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias) /* get the current time level for the coordinates */ coord_timelevel = CCTK_NumTimeLevelsFromVarI (coord_index [dir]) - 1; if (coord_timelevel > 0) + { coord_timelevel--; + } if (Hyperslab_GetHyperslab (GH, 0, coord_index [dir], coord_timelevel, 1, origin, directions, @@ -461,7 +460,9 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias) /* set the direction vector for the 1D line */ for (i = 0; i < 3; i++) + { directions [i] = (dir == i || dir == 3) ? 1 : 0; + } /* no coordinates are needed for arrays */ coord_data = NULL; @@ -478,7 +479,9 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias) "variable '%s'", fullname); free (fullname); if (coord_data) + { free (coord_data); + } continue; } 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++) { |