diff options
Diffstat (limited to 'src/Output2D.c')
-rw-r--r-- | src/Output2D.c | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/src/Output2D.c b/src/Output2D.c index f68e99c..1bd6ad0 100644 --- a/src/Output2D.c +++ b/src/Output2D.c @@ -20,7 +20,7 @@ #include "cctk.h" #include "cctk_Parameters.h" -#include "CactusBase/IOUtil/src/ioGH.h" +#include "CactusBase/IOUtil/src/ioutil_Utils.h" #include "IOJpeg.h" @@ -29,6 +29,7 @@ int IOJpeg_TimeFor2D (cGH *GH, int index); int IOJpeg_Output2DVarAs (cGH *GH, const char *var, const char *alias); static void CheckSteerableParameters (IOJpegGH *myGH); +static void SetOutputFlag (int index, const char *optstring, void *arg); int IOJpeg_Output2DGH (cGH *GH) @@ -46,7 +47,9 @@ int IOJpeg_Output2DGH (cGH *GH) CheckSteerableParameters (myGH); if (myGH->out2D_every <= 0) + { return (0); + } /* Loop over all variables */ for (i = 0; i < CCTK_NumVars (); i++) @@ -59,8 +62,10 @@ int IOJpeg_Output2DGH (cGH *GH) fullname = CCTK_FullName (i); if (!CCTK_Equals(verbose,"no")) + { CCTK_VInfo (CCTK_THORNSTRING, "IOJpeg_Output2DGH: fullname / name = " "%s / %s", fullname, name); + } ierr=IOJpeg_Output2DVarAs (GH, fullname, name); @@ -71,7 +76,9 @@ int IOJpeg_Output2DGH (cGH *GH) } } if (!CCTK_Equals(verbose,"no")) + { CCTK_INFO("IOJpeg_Output2DGH Done"); + } return (ierr); } @@ -93,8 +100,10 @@ int IOJpeg_Output2DVarAs (cGH *GH, const char *fullname, const char *alias) } if (!CCTK_Equals(verbose,"no")) + { CCTK_VInfo (CCTK_THORNSTRING, "IOJpeg_Output2DVarAs: fullname, alias, " "index = (%s, %s, %d)", fullname, alias, index); + } /* Do the 2D output */ ierr=IOJpeg_Write2D (GH, index, alias); @@ -114,18 +123,22 @@ int IOJpeg_TimeFor2D (cGH *GH, int index) /* Check if any output was requested */ if(myGH->out2D_every <= 0) + { return (0); + } /* Check this variable should be output */ if (! (myGH->do_out2D [index] && GH->cctk_iteration % myGH->out2D_every == 0)) + { return (0); + } /* Check variable not already output this iteration */ if (myGH->out2D_last [index] == GH->cctk_iteration) { - CCTK_WARN (2, "Already done 2D output in IOJpeg"); - return (0); + CCTK_WARN (2, "Already done 2D output in IOJpeg"); + return (0); } return (1); @@ -143,8 +156,10 @@ int IOJpeg_TriggerOutput2D (cGH *GH, int index) myGH = (IOJpegGH *) GH->extensions [CCTK_GHExtensionHandle ("IOJpeg")]; if (!CCTK_Equals(verbose,"no")) + { CCTK_VInfo (CCTK_THORNSTRING, "IOJpeg_TriggerOutput2D: varname, index = " "(%s, %d)", varname, index); + } /* Do the 2D output */ ierr=IOJpeg_Write2D (GH, index, varname); @@ -167,16 +182,39 @@ static void CheckSteerableParameters (IOJpegGH *myGH) /* How often to output */ myGH->out2D_every = out_every > 0 ? out_every : -1; if (out2D_every > 0) + { myGH->out2D_every = out2D_every; + } /* re-parse the 'out2D_vars' parameter if it was changed */ out2D_vars_current_nset = CCTK_ParameterQueryTimesSet ("out2D_vars", CCTK_THORNSTRING); if (out2D_vars_current_nset != out2D_vars_lastset) { - IOUtil_ParseVarsForOutput (out2D_vars, myGH->do_out2D); + memset (myGH->do_out2D, 0, CCTK_NumVars ()); + CCTK_TraverseString (out2D_vars, SetOutputFlag, myGH->do_out2D, + CCTK_GROUP_OR_VAR); /* Save the last setting of 'out2D_vars' parameter */ out2D_vars_lastset = out2D_vars_current_nset; } } + + + + +/* callback for CCTK_TraverseString() to set the output flag + for the given variable */ +static void SetOutputFlag (int index, const char *optstring, void *arg) +{ + char *flags = (char *) arg; + + + flags[index] = 1; + + if (optstring) + { + CCTK_VWarn (5, __LINE__, __FILE__, CCTK_THORNSTRING, + "Optional string '%s' in variable name ignored", optstring); + } +} |