diff options
author | tradke <tradke@94b1c47f-dcfd-45ef-a468-0854c0e9e350> | 2001-12-28 21:22:44 +0000 |
---|---|---|
committer | tradke <tradke@94b1c47f-dcfd-45ef-a468-0854c0e9e350> | 2001-12-28 21:22:44 +0000 |
commit | 76fbba7e6738c8fddaa2cbf53f7efc4145ea418c (patch) | |
tree | f564b7412a16626a8ac21b3ce58467721439a214 /src/Output2D.c | |
parent | e8a192a59474eca8d7964f8d7954dc1ab1cb7b90 (diff) |
Fixed return code of I/O methods.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOASCII/trunk@93 94b1c47f-dcfd-45ef-a468-0854c0e9e350
Diffstat (limited to 'src/Output2D.c')
-rw-r--r-- | src/Output2D.c | 91 |
1 files changed, 61 insertions, 30 deletions
diff --git a/src/Output2D.c b/src/Output2D.c index 94a4f20..5c31fe1 100644 --- a/src/Output2D.c +++ b/src/Output2D.c @@ -2,12 +2,12 @@ @file Output2D.c @date Thu May 11 2000 @author Thomas Radke - @desc + @desc Functions to deal with 2D ASCII output of variables - @enddesc + @enddesc @version $Id$ @@*/ - + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -25,7 +25,9 @@ CCTK_FILEVERSION(CactusBase_IOASCII_Output2D_c) /*#define IOASCII_DEBUG 1*/ -/* prototypes of routines defined in this source file */ +/******************************************************************** + ******************** Internal Routines ************************ + ********************************************************************/ static int CheckOutputVar (int vindex); static void CheckSteerableParameters (asciiioGH *myGH); static void SetOutputFlag (int vindex, const char *optstring, void *arg); @@ -46,10 +48,16 @@ static void SetOutputFlag (int vindex, const char *optstring, void *arg); @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 IOASCII_Output2DGH (const cGH *GH) { - int vindex; + int vindex, retval; asciiioGH *myGH; const char *name; @@ -66,7 +74,7 @@ int IOASCII_Output2DGH (const cGH *GH) } /* Loop over all variables */ - for (vindex = 0; vindex < CCTK_NumVars (); vindex++) + for (vindex = retval = 0; vindex < CCTK_NumVars (); vindex++) { /* Check if this variable should be output */ @@ -85,16 +93,17 @@ int IOASCII_Output2DGH (const cGH *GH) printf (" On iteration %d\n", GH->cctk_iteration); printf (" Last output iteration was = %d\n", myGH->out2D_last[vindex]); #endif - - /* Make the IO call */ - IOASCII_Write2D (GH, vindex, name); - - /* Register GF as having 2D output this iteration */ - myGH->out2D_last[vindex] = GH->cctk_iteration; + /* Make the IO call */ + if (IOASCII_Write2D (GH, vindex, name) == 0) + { + /* Register GF as having 2D output this iteration */ + myGH->out2D_last[vindex] = GH->cctk_iteration; + retval++; + } } /* end of loop over all variables */ - return (0); + return (retval); } @@ -124,10 +133,16 @@ int IOASCII_Output2DGH (const cGH *GH) @vtype const char * @vio in @endvar + + @returntype int + @returndesc + return code of @seeroutine IOASCII_Write2D, or<BR> + -1 if variable cannot be output by IOASCII_2D + @endreturndesc @@*/ int IOASCII_Output2DVarAs (const cGH *GH, const char *fullname, const char *alias) { - int vindex; + int vindex, retval; vindex = CCTK_VarIndex (fullname); @@ -139,12 +154,13 @@ int IOASCII_Output2DVarAs (const cGH *GH, const char *fullname, const char *alia printf (" Index = %d\n", vindex); #endif + retval = -1; if (CheckOutputVar (vindex) == 0) { - IOASCII_Write2D (GH, vindex, alias); + retval = IOASCII_Write2D (GH, vindex, alias); } - return (0); + return (retval); } @@ -152,10 +168,10 @@ int IOASCII_Output2DVarAs (const cGH *GH, const char *fullname, const char *alia @routine IOASCII_TimeFor2D @date Sat March 6 1999 @author Gabrielle Allen - @desc + @desc Decides if it is time to output a variable using the IOASCII 2D output method - @enddesc + @enddesc @var GH @vdesc Pointer to CCTK GH @@ -167,6 +183,12 @@ int IOASCII_Output2DVarAs (const cGH *GH, const char *fullname, const char *alia @vtype int @vio in @endvar + + @returntype int + @returndesc + 1 if output should take place at this iteration, or<BR> + 0 if not + @endreturndesc @@*/ int IOASCII_TimeFor2D (const cGH *GH, int vindex) { @@ -190,7 +212,7 @@ int IOASCII_TimeFor2D (const cGH *GH, int vindex) } /* Check if this variable should be output */ - if (myGH->do_out2D[vindex] && (GH->cctk_iteration % myGH->out2D_every == 0)) + if (myGH->do_out2D[vindex] && (GH->cctk_iteration % myGH->out2D_every == 0)) { /* Check if variable wasn't already output this iteration */ if (myGH->out2D_last[vindex] == GH->cctk_iteration) @@ -231,16 +253,22 @@ int IOASCII_TimeFor2D (const cGH *GH, int vindex) @vtype int @vio in @endvar + + @returntype int + @returndesc + return code of @seeroutine IOASCII_Write2D + @endreturndesc @@*/ int IOASCII_TriggerOutput2D (const cGH *GH, int vindex) { + int retval; const char *var; asciiioGH *myGH; /* get GH extensions for IOASCII */ myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII"); - + var = CCTK_VarName (vindex); /* Do the 2D output */ @@ -249,13 +277,16 @@ int IOASCII_TriggerOutput2D (const cGH *GH, int vindex) printf (" Index = %d\n", vindex); printf (" Variable = -%s-\n", var); #endif - - IOASCII_Write2D (GH, vindex, var); - - /* Register variables as having 2D output this iteration */ - myGH->out2D_last[vindex] = GH->cctk_iteration; - - return (0); + + retval = IOASCII_Write2D (GH, vindex, var); + + if (retval == 0) + { + /* Register variables as having 2D output this iteration */ + myGH->out2D_last[vindex] = GH->cctk_iteration; + } + + return (retval); } @@ -292,7 +323,7 @@ static void CheckSteerableParameters (asciiioGH *myGH) /* re-parse the 'out2D_vars' parameter if it was changed */ times_set = CCTK_ParameterQueryTimesSet ("out2D_vars", CCTK_THORNSTRING); - if (times_set != out2D_vars_lastset) + if (times_set != out2D_vars_lastset) { num_vars = CCTK_NumVars (); memset (myGH->do_out2D, 0, num_vars); @@ -325,7 +356,7 @@ static void CheckSteerableParameters (asciiioGH *myGH) CCTK_INFO (msg); free (msg); } - } + } /* Save the last setting of 'out2D_vars' parameter */ out2D_vars_lastset = times_set; @@ -369,7 +400,7 @@ static int CheckOutputVar (int vindex) } -/* callback for CCTK_TraverseString() to set the output flag +/* callback for CCTK_TraverseString() to set the output flag for the given variable */ static void SetOutputFlag (int vindex, const char *optstring, void *arg) { |