diff options
author | tradke <tradke@ebee0441-1374-4afa-a3b5-247f3ba15b9a> | 2000-09-21 13:33:37 +0000 |
---|---|---|
committer | tradke <tradke@ebee0441-1374-4afa-a3b5-247f3ba15b9a> | 2000-09-21 13:33:37 +0000 |
commit | 3c96f639a022fc135764b9e1023075c596326a6c (patch) | |
tree | bf33b1ad3bfe4636cd4c0ff0d763462569d93557 /src/Output2D.c | |
parent | 4a1419c14764f2c49c06e170dd0dec79e4e7eaae (diff) |
Removed ioGH.h from include list.
Use CCTK_TraverseString() to parse the output strings.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOFlexIO/trunk@152 ebee0441-1374-4afa-a3b5-247f3ba15b9a
Diffstat (limited to 'src/Output2D.c')
-rw-r--r-- | src/Output2D.c | 85 |
1 files changed, 67 insertions, 18 deletions
diff --git a/src/Output2D.c b/src/Output2D.c index 0aadd2c..7b2269a 100644 --- a/src/Output2D.c +++ b/src/Output2D.c @@ -17,14 +17,15 @@ #include "cctk.h" #include "cctk_Parameters.h" -#include "CactusBase/IOUtil/src/ioGH.h" #include "ioFlexGH.h" /* function prototypes */ int IOFlexIO_Output2DVarAs (cGH *GH, const char *var, const char *alias); int IOFlexIO_TimeFor2D (cGH *GH, int index); +static int CheckOutputVar (int index); static void CheckSteerableParameters (flexioGH *myGH); +static void SetOutputFlag (int index, const char *optstring, void *arg); /*@@ @@ -133,11 +134,12 @@ int IOFlexIO_Output2DVarAs (cGH *GH, const char *fullname, const char *alias) "fullname, alias, index = (%s, %s, %d)", fullname, alias,index); /* Do the 2D output */ - IOFlexIO_Write2D (GH, index, alias); + if (CheckOutputVar (index)) + { + IOFlexIO_Write2D (GH, index, alias); + } return (0); - - } @@ -188,8 +190,15 @@ int IOFlexIO_TimeFor2D (cGH *GH, int index) return (0); /* Check GF not already output this iteration */ - if (myGH->out2D_last [index] == GH->cctk_iteration) { - CCTK_WARN (2, "Already done 2D output in IOFlexIO"); + if (myGH->out2D_last [index] == GH->cctk_iteration) + { + char *fullname = CCTK_FullName (index); + + + CCTK_VWarn (5, __LINE__, __FILE__, CCTK_THORNSTRING, + "Already done 2D FlexIO output for variable '%s' in current " + "iteration (probably via triggers)", fullname); + free (fullname); return (0); } @@ -251,11 +260,12 @@ int IOFlexIO_TriggerOutput2D (cGH *GH, int index) /**************************** local functions ******************************/ +/* check if steerable parameters have changed */ static void CheckSteerableParameters (flexioGH *myGH) { DECLARE_CCTK_PARAMETERS - const cParamData *paramdata; - static int out2D_vars_lastset = 0; + int times_set; + static int out2D_vars_lastset = -1; /* How often to output */ @@ -263,21 +273,60 @@ static void CheckSteerableParameters (flexioGH *myGH) if (out2D_every > 0) myGH->out2D_every = out2D_every; - /* Check the 'out2D_vars' parameter */ - paramdata = CCTK_ParameterData ("out2D_vars", CCTK_THORNSTRING); - if (! paramdata) + /* re-parse the 'out2D_vars' parameter if it was changed */ + times_set = CCTK_ParameterQueryTimesSet ("out2D_vars", CCTK_THORNSTRING); + if (times_set != out2D_vars_lastset) { - CCTK_WARN (1, "Couldn't get info on parameter 'out2D_vars'"); - return; + 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 = times_set; } - /* re-parse the 'out2D_vars' parameter if it was changed */ - if (paramdata->n_set != out2D_vars_lastset) +} + + +/* check if this variable can be output (static conditions) */ +static int CheckOutputVar (int index) +{ + int retval; + char *fullname; + + + retval = 0; + + /* check the group dimension */ + if (CCTK_GroupDimFromVarI (index) != 3) { - IOUtil_ParseVarsForOutput (out2D_vars, myGH->do_out2D); + fullname = CCTK_FullName (index); + CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, + "No IOFlexIO 2D output for '%s' (dim != 3)", fullname); + free (fullname); + retval = -1; + } - /* Save the last setting of 'out2D_vars' parameter */ - out2D_vars_lastset = paramdata->n_set; + return (retval); +} + + +/* 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; + + + /* Check the variable type */ + if (CheckOutputVar (index) == 0) + { + flags[index] = 1; } + if (optstring) + { + CCTK_VWarn (5, __LINE__, __FILE__, CCTK_THORNSTRING, + "Optional string '%s' in variable name ignored", optstring); + } } |