diff options
Diffstat (limited to 'src/Output3D.c')
-rw-r--r-- | src/Output3D.c | 88 |
1 files changed, 25 insertions, 63 deletions
diff --git a/src/Output3D.c b/src/Output3D.c index 78d8354..e31f86f 100644 --- a/src/Output3D.c +++ b/src/Output3D.c @@ -8,7 +8,6 @@ @version $Id$ @@*/ -#include <stdio.h> #include <stdlib.h> #include <string.h> @@ -21,9 +20,6 @@ static const char *rcsid = "$Id$"; CCTK_FILEVERSION(CactusBase_IOASCII_Output3D_c) -/* define this if you want debug output */ -/*#define IOASCII_DEBUG 1*/ - /******************************************************************** ******************** Internal Routines ************************ @@ -59,42 +55,28 @@ int IOASCII_Output3DGH (const cGH *GH) { int vindex, retval; asciiioGH *myGH; - const char *name; - /* Get the GH extensions for IOASCII */ myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII"); - CheckSteerableParameters (myGH); - /* Loop over all variables */ + /* loop over all variables */ for (vindex = retval = 0; vindex < CCTK_NumVars (); vindex++) { - /* Check if this variable should be output */ + /* check if this variable should be output */ if (! IOASCII_TimeFor3D (GH, vindex)) { continue; } - /* Get the variable name for this index (for filename) */ - name = CCTK_VarName (vindex); - -#ifdef IO_DEBUG - printf ("\nIn IOASCII Output3DGH\n---------------------\n"); - printf (" Index = %d\n", vindex); - printf (" Variable = -%s-\n", name); - printf (" On iteration %d\n", GH->cctk_iteration); - printf (" Last output iteration was = %d\n", myGH->out3D_last[vindex]); -#endif - - /* Make the IO call */ - if (IOASCII_Write3D (GH, vindex, name) == 0) + /* do the output */ + if (IOASCII_Write3D (GH, vindex, CCTK_VarName (vindex)) == 0) { - /* Register GF as having 3D output this iteration */ + /* register variable as having 3D output this iteration */ myGH->out3D_last[vindex] = GH->cctk_iteration; retval++; } - } /* end of loop over all variables */ + } return (retval); } @@ -138,16 +120,9 @@ int IOASCII_Output3DVarAs (const cGH *GH, const char *fullname, const char *alia int vindex, retval; + retval = -1; vindex = CCTK_VarIndex (fullname); -#ifdef IO_DEBUG - printf ("\nIn IOASCII Output3DVarAs\n-------------------\n"); - printf (" Fullname = -%s-\n", fullname); - printf (" Alias = -%s-\n", alias); - printf (" Index = %d\n", vindex); -#endif - - retval = -1; if (CheckOutputVar (vindex) == 0) { retval = IOASCII_Write3D (GH, vindex, alias); @@ -185,24 +160,22 @@ int IOASCII_Output3DVarAs (const cGH *GH, const char *fullname, const char *alia @@*/ int IOASCII_TimeFor3D (const cGH *GH, int vindex) { - int return_type; + int retval; asciiioGH *myGH; char *fullname; - /* Default is do not do output */ - return_type = 0; + /* default is not do any output */ + retval = 0; - /* Get the GH extensions for IOASCII */ myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII"); - CheckSteerableParameters (myGH); - /* Check if this variable should be output */ + /* check if this variable should be output */ if (myGH->out3D_every[vindex] > 0 && GH->cctk_iteration % myGH->out3D_every[vindex] == 0) { - /* Check if variable wasn't already output this iteration */ + /* check if variable wasn't already output this iteration */ if (myGH->out3D_last[vindex] == GH->cctk_iteration) { fullname = CCTK_FullName (vindex); @@ -213,11 +186,11 @@ int IOASCII_TimeFor3D (const cGH *GH, int vindex) } else { - return_type = 1; + retval = 1; } } - return (return_type); + return (retval); } @@ -250,27 +223,15 @@ int IOASCII_TimeFor3D (const cGH *GH, int vindex) int IOASCII_TriggerOutput3D (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 3D output */ -#ifdef IO_DEBUG - printf ("\nIn IOASCII TriggerOutput3D\n---------------------\n"); - printf (" Index = %d\n", vindex); - printf (" Variable = -%s-\n", var); -#endif - - retval = IOASCII_Write3D (GH, vindex, var); - + /* do the 3D output */ + retval = IOASCII_Write3D (GH, vindex, CCTK_VarName (vindex)); if (retval == 0) { - /* Register variables as having 3D output this iteration */ + /* register variables as having 3D output this iteration */ + myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII"); myGH->out3D_last[vindex] = GH->cctk_iteration; } @@ -287,11 +248,11 @@ static void CheckSteerableParameters (asciiioGH *myGH) DECLARE_CCTK_PARAMETERS - /* How often to output */ + /* how often to output */ i = myGH->out3D_every_default; myGH->out3D_every_default = out3D_every > 0 ? out3D_every : out_every; - /* Report if frequency changed */ + /* report if frequency changed */ if (myGH->out3D_every_default != i && ! CCTK_Equals (newverbose, "none")) { if (myGH->out3D_every_default > 0) @@ -339,7 +300,7 @@ static void CheckSteerableParameters (asciiioGH *myGH) } } - /* Save the last setting of 'out3D_vars' parameter */ + /* save the last setting of 'out3D_vars' parameter */ free (myGH->out3D_vars); myGH->out3D_vars = strdup (out3D_vars); } @@ -363,17 +324,18 @@ static int CheckOutputVar (int vindex) errormsg = NULL; if (groupinfo.dim != 3) { - errormsg = "No IOASCII 3D output for '%s' (dim != 3)"; + errormsg = "dim != 3"; } else if (groupinfo.grouptype != CCTK_GF && groupinfo.grouptype != CCTK_ARRAY) { - errormsg = "No IOASCII 3D output for '%s' (not a grid function or array)"; + errormsg = "not a grid function or array"; } if (errormsg) { fullname = CCTK_FullName (vindex); - CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, errormsg, fullname); + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + "No IOASCII 3D output for '%s': %s", fullname, errormsg); free (fullname); } |