From 84e2701f56f2edb18e5f231ab82d2ef6b7026abe Mon Sep 17 00:00:00 2001 From: tradke Date: Fri, 28 Dec 2001 21:40:11 +0000 Subject: Fixed return codes of I/O methods. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOStreamedHDF5/trunk@76 0888f3d4-9f52-45d2-93bc-d00801ff5e46 --- src/Output.c | 67 +++++++++++++++++++++++++++++++++----------------- src/Write.c | 14 ++++++++--- src/ioStreamedHDF5GH.h | 2 +- 3 files changed, 56 insertions(+), 27 deletions(-) diff --git a/src/Output.c b/src/Output.c index 828e8e1..075ab8b 100644 --- a/src/Output.c +++ b/src/Output.c @@ -21,7 +21,9 @@ static const char *rcsid = "$Id$"; CCTK_FILEVERSION(BetaThorns_IOStreamedHDF5_Output_c) -/* function prototypes */ +/******************************************************************** + ******************** Internal Routines ************************ + ********************************************************************/ static void CheckSteerableParameters (ioStreamedHDF5GH *myGH); @@ -41,14 +43,20 @@ static void CheckSteerableParameters (ioStreamedHDF5GH *myGH); @vtype const cGH * @vio in @endvar + + @returntype int + @returndesc + the number of variables which were output at this iteration + (or 0 if it wasn't time to output yet) + @endreturndesc @@*/ int IOStreamedHDF5_OutputGH (const cGH *GH) { - DECLARE_CCTK_PARAMETERS - int vindex; + int vindex, retval; ioStreamedHDF5GH *myGH; const char *name; char *fullname; + DECLARE_CCTK_PARAMETERS /* Get the GH extension for IOStreamedHDF5 */ @@ -62,7 +70,7 @@ int IOStreamedHDF5_OutputGH (const cGH *GH) } /* Loop over all variables */ - for (vindex = 0; vindex < CCTK_NumVars (); vindex++) + for (vindex = retval = 0; vindex < CCTK_NumVars (); vindex++) { if (IOStreamedHDF5_TimeFor (GH, vindex)) @@ -78,16 +86,18 @@ int IOStreamedHDF5_OutputGH (const cGH *GH) "= ('%s' / '%s')", fullname, name); } - IOStreamedHDF5_OutputVarAs (GH, fullname, name); + if (IOStreamedHDF5_OutputVarAs (GH, fullname, name) == 0) + { + /* Register variable as having output this iteration */ + myGH->out_last[vindex] = GH->cctk_iteration; + retval++; + } free (fullname); - - /* Register variable as having output this iteration */ - myGH->out_last[vindex] = GH->cctk_iteration; } } - return (0); + return (retval); } @@ -118,13 +128,18 @@ int IOStreamedHDF5_OutputGH (const cGH *GH) @vtype const char * @vio in @endvar + + @returntype int + @returndesc + return code of @seeroutine IOStreamedHDF5_Write + @endreturndesc @@*/ int IOStreamedHDF5_OutputVarAs (const cGH *GH, const char *fullname, const char *alias) { + int vindex, retval; DECLARE_CCTK_PARAMETERS - int vindex; vindex = CCTK_VarIndex (fullname); @@ -137,9 +152,9 @@ int IOStreamedHDF5_OutputVarAs (const cGH *GH, } /* Do the output */ - IOStreamedHDF5_Write (GH, vindex, alias); + retval = IOStreamedHDF5_Write (GH, vindex, alias); - return (0); + return (retval); } @@ -226,14 +241,20 @@ int IOStreamedHDF5_TimeFor (const cGH *GH, @vtype int @vio in @endvar + + @returntype int + @returndesc + return code of @seeroutine IOStreamedHDF5_Write + @endreturndesc @@*/ int IOStreamedHDF5_TriggerOutput (const cGH *GH, int vindex) { - DECLARE_CCTK_PARAMETERS + int retval; ioStreamedHDF5GH *myGH; char *fullname; const char *varname; + DECLARE_CCTK_PARAMETERS varname = CCTK_VarName (vindex); @@ -250,18 +271,21 @@ int IOStreamedHDF5_TriggerOutput (const cGH *GH, } /* Do the output */ - IOStreamedHDF5_Write (GH, vindex, varname); + retval = IOStreamedHDF5_Write (GH, vindex, varname); - /* Register variable as having output this iteration */ - myGH->out_last[vindex] = GH->cctk_iteration; + if (retval == 0) + { + /* Register variable as having output this iteration */ + myGH->out_last[vindex] = GH->cctk_iteration; + } - return (0); + return (retval); } -/***************************************************************************/ -/* local functions */ -/***************************************************************************/ +/******************************************************************** + ******************** Internal Routines ************************ + ********************************************************************/ /*@@ @routine CheckSteerableParameters @date Mon Oct 10 2000 @@ -281,9 +305,9 @@ int IOStreamedHDF5_TriggerOutput (const cGH *GH, @@*/ static void CheckSteerableParameters (ioStreamedHDF5GH *myGH) { - DECLARE_CCTK_PARAMETERS int times_set; static int out_vars_lastset = -1; + DECLARE_CCTK_PARAMETERS /* How often to output */ @@ -302,5 +326,4 @@ static void CheckSteerableParameters (ioStreamedHDF5GH *myGH) /* Save the last setting of 'out_vars' parameter */ out_vars_lastset = times_set; } - } diff --git a/src/Write.c b/src/Write.c index 7a2ee35..56b4bc5 100644 --- a/src/Write.c +++ b/src/Write.c @@ -49,10 +49,14 @@ CCTK_FILEVERSION(BetaThorns_IOStreamedHDF5_Write_c) @vtype const char * @vio unused @endvar + + @returntype int + @returndesc + 0 for success, or
+ -1 if variable has no storage assigned + @endreturndesc @@*/ -void IOStreamedHDF5_Write (const cGH *GH, - int vindex, - const char *alias) +int IOStreamedHDF5_Write (const cGH *GH, int vindex, const char *alias) { DECLARE_CCTK_PARAMETERS int old_ioproc; @@ -75,7 +79,7 @@ void IOStreamedHDF5_Write (const cGH *GH, CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, "No IOStreamedHDF5 output for '%s' (no storage)", fullname); free (fullname); - return; + return (-1); } /* Get the handles for IO and IOStreamedHDF5 extensions */ @@ -140,4 +144,6 @@ void IOStreamedHDF5_Write (const cGH *GH, ioUtilGH->ioproc = old_ioproc; ioUtilGH->nioprocs = old_nioprocs; ioUtilGH->ioproc_every = old_ioproc_every; + + return (0); } diff --git a/src/ioStreamedHDF5GH.h b/src/ioStreamedHDF5GH.h index 1f6962d..823cfcc 100644 --- a/src/ioStreamedHDF5GH.h +++ b/src/ioStreamedHDF5GH.h @@ -57,7 +57,7 @@ int IOStreamedHDF5_OutputVarAs (const cGH *GH, const char *var, const char *alia int IOStreamedHDF5_Recover (cGH *GH, const char *basefilename, int called_from); /* other function prototypes */ -void IOStreamedHDF5_Write (const cGH *GH, int vindex, const char *alias); +int IOStreamedHDF5_Write (const cGH *GH, int vindex, const char *alias); #ifdef __cplusplus } // extern "C" -- cgit v1.2.3