From feb8726f2ab8a7004de5a3a9117d91d916ca86ae Mon Sep 17 00:00:00 2001 From: tradke Date: Fri, 28 Dec 2001 21:22:52 +0000 Subject: Fixed return code of I/O methods. git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOBasic/trunk@110 b589c3ab-70e8-4b4d-a09f-cba2dd200880 --- src/OutputScalar.c | 184 +++++++++++++++++++++++++++++------------------------ 1 file changed, 102 insertions(+), 82 deletions(-) (limited to 'src/OutputScalar.c') diff --git a/src/OutputScalar.c b/src/OutputScalar.c index cee1375..663dbeb 100644 --- a/src/OutputScalar.c +++ b/src/OutputScalar.c @@ -2,11 +2,11 @@ @file Output.c @date Mon 21 September @author Gabrielle Allen - @desc + @desc Functions to deal with scalar output of grid variables - @enddesc + @enddesc @@*/ - + /* #define IOBASIC_DEBUG 1 */ #include @@ -22,7 +22,10 @@ static const char *rcsid = "$Header$"; CCTK_FILEVERSION(CactusBase_IOBasic_OutputScalar_c) -/* function prototypes */ + +/******************************************************************** + ******************** Internal Routines ************************ + ********************************************************************/ static void CheckSteerableParameters (iobasicGH *myGH); static void SetOutputFlag (int vindex, const char *optstring, void *arg); @@ -32,21 +35,27 @@ static void SetOutputFlag (int vindex, const char *optstring, void *arg); @date Sat March 6 1999 @author Gabrielle Allen @desc - Loops over all variables and outputs them if necessary + Loops over all variables and outputs them if necessary @enddesc - @calledby CCTK_OutputGH ("IOBasic") - @history - - @endhistory - @var GH - @vdesc Pointer to CCTK GH - @vtype const cGH * - @vio in + @calls IOBasic_TimeForScalarOutput + IOBasic_WriteScalarGS + IOBasic_WriteScalarGA + + @var GH + @vdesc Pointer to CCTK GH + @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 IOBasic_ScalarOutputGH (const cGH *GH) { - int vindex; + int i, vindex, retval; const char *name; iobasicGH *myGH; @@ -63,9 +72,8 @@ int IOBasic_ScalarOutputGH (const cGH *GH) } /* Loop over all variables */ - for (vindex = 0; vindex < CCTK_NumVars (); vindex++) + for (vindex = retval = 0; vindex < CCTK_NumVars (); vindex++) { - /* Is it time for output ? */ if (! IOBasic_TimeForScalarOutput (GH, vindex)) { @@ -81,23 +89,25 @@ int IOBasic_ScalarOutputGH (const cGH *GH) printf(" Variable = -%s-\n",name); printf(" Last output iteration was = %d\n",myGH->outScalar_last[vindex]); #endif - + /* Make the IO call */ if (CCTK_GroupTypeFromVarI (vindex) == CCTK_SCALAR) { - IOBasic_WriteScalarGS (GH, vindex, name); + i = IOBasic_WriteScalarGS (GH, vindex, name); } else { - IOBasic_WriteScalarGA (GH, vindex, name); + i = IOBasic_WriteScalarGA (GH, vindex, name); + } + if (i == 0) + { + /* Register GF as having 0D output this iteration */ + myGH->outScalar_last [vindex] = GH->cctk_iteration; + retval++; } - - /* Register GF as having 0D output this iteration */ - myGH->outScalar_last [vindex] = GH->cctk_iteration; - } /* end of loop over all variables */ - return (0); + return (retval); } @@ -106,31 +116,37 @@ int IOBasic_ScalarOutputGH (const cGH *GH) @date Sat March 6 1999 @author Gabrielle Allen @desc - unconditional output of a variable using the IOBasic output method + Unconditional output of a variable using IOBasic's SCALAR + output method @enddesc - @calledby IOBasic_ScalarOutputGH, CCTK_OutputVarAsByMethod ("IOBasic") - @var GH - @vdesc Pointer to CCTK GH - @vtype const cGH * - @vio in - @vcomment + @calls IOBasic_WriteScalarGS + IOBasic_WriteScalarGA + + @var GH + @vdesc Pointer to CCTK GH + @vtype const cGH * + @vio in @endvar - @var fullname - @vdesc complete name of variable to output - @vtype const char * - @vio in - @vcomment + @var fullname + @vdesc complete name of variable to output + @vtype const char * + @vio in @endvar - @var alias - @vdesc alias name of variable to output (used to generate output filename) - @vtype const char * - @vio in - @vcomment + @var alias + @vdesc alias name of variable to output (used to generate output filename) + @vtype const char * + @vio in @endvar + + @returntype int + @returndesc + return code of @seeroutine IOBasic_WriteScalarGS or + @seeroutine IOBasic_WriteScalarGA + @endreturndesc @@*/ int IOBasic_ScalarOutputVarAs (const cGH *GH, const char *fullname, const char *alias) { - int vindex; + int vindex, retval; vindex = CCTK_VarIndex (fullname); @@ -144,14 +160,14 @@ int IOBasic_ScalarOutputVarAs (const cGH *GH, const char *fullname, const char * if (CCTK_GroupTypeFromVarI (vindex) == CCTK_SCALAR) { - IOBasic_WriteScalarGS (GH, vindex, alias); + retval = IOBasic_WriteScalarGS (GH, vindex, alias); } else { - IOBasic_WriteScalarGA (GH, vindex, alias); + retval = IOBasic_WriteScalarGA (GH, vindex, alias); } - return (0); + return (retval); } @@ -159,29 +175,26 @@ int IOBasic_ScalarOutputVarAs (const cGH *GH, const char *fullname, const char * @routine IOBasic_TimeForScalarOutput @date Sat March 6 1999 @author Gabrielle Allen - @desc - Decides if it is time to output a variable using Scalar output - method - @enddesc - @calls CCTK_GHExtension - CCTK_GroupTypeFromVar - CCTK_WARN - @calledby - @history - - @endhistory - @var GH - @vdesc Pointer to CCTK GH - @vtype const cGH * - @vio in - @vcomment - @endvar - @var vindex - @vdesc index of variable - @vtype int - @vio in - @vcomment - @endvar + @desc + Decides if it is time to do Scalar output. + @enddesc + + @var GH + @vdesc Pointer to CCTK GH + @vtype const cGH * + @vio in + @endvar + @var vindex + @vdesc index of variable + @vtype int + @vio in + @endvar + + @returntype int + @returndesc + 1 if output should take place at this iteration, or
+ 0 if not + @endreturndesc @@*/ int IOBasic_TimeForScalarOutput (const cGH *GH, int vindex) { @@ -232,26 +245,30 @@ int IOBasic_TimeForScalarOutput (const cGH *GH, int vindex) @date Sat March 6 1999 @author Gabrielle Allen @desc - Triggers the output a variable using IOBasic's Scalar + Triggers the output of a variable using IOBasic's Scalar output method - method @enddesc - @calledby CCTK scheduler + @var GH @vdesc Pointer to CCTK GH @vtype const cGH * @vio in - @vcomment @endvar @var vindex @vdesc index of variable to output @vtype int @vio in - @vcomment @endvar + + @returntype int + @returndesc + return code of @seeroutine IOBasic_WriteScalarGS or + @seeroutine IOBasic_WriteScalarGA + @endreturndesc @@*/ int IOBasic_TriggerScalarOutput (const cGH *GH, int vindex) { + int retval; const char *name; iobasicGH *myGH; @@ -266,21 +283,24 @@ int IOBasic_TriggerScalarOutput (const cGH *GH, int vindex) printf (" Index = %d\n", vindex); printf (" Variable = -%s-\n", name); #endif - + /* Do the Scalar output */ if (CCTK_GroupTypeFromVarI (vindex) == CCTK_SCALAR) { - IOBasic_WriteScalarGS (GH, vindex, name); + retval = IOBasic_WriteScalarGS (GH, vindex, name); } else { - IOBasic_WriteScalarGA (GH, vindex, name); + retval = IOBasic_WriteScalarGA (GH, vindex, name); + } + + if (retval == 0) + { + /* Register variable as having Scalar output this iteration */ + myGH->outScalar_last [vindex] = GH->cctk_iteration; } - /* Register variable as having Scalar output this iteration */ - myGH->outScalar_last [vindex] = GH->cctk_iteration; - - return (0); + return (retval); } @@ -288,11 +308,11 @@ int IOBasic_TriggerScalarOutput (const cGH *GH, int vindex) /* check if steerable parameters have changed */ static void CheckSteerableParameters (iobasicGH *myGH) { - DECLARE_CCTK_PARAMETERS int i, num_vars, out_old; int times_set; char *fullname, *msg; static int outScalar_vars_lastset = -1; + DECLARE_CCTK_PARAMETERS /* How often to output */ @@ -347,7 +367,7 @@ static void CheckSteerableParameters (iobasicGH *myGH) CCTK_INFO (msg); free (msg); } - } + } /* Save the last setting of 'outScalar_vars' parameter */ outScalar_vars_lastset = times_set; -- cgit v1.2.3