From a5d7feeaab6b0403614556138cfe14ac7bae0a52 Mon Sep 17 00:00:00 2001 From: tradke Date: Thu, 21 Sep 2000 13:27:24 +0000 Subject: Removed ioGH.h from include list. Use CCTK_TraverseString() to parse the output strings. git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOBasic/trunk@69 b589c3ab-70e8-4b4d-a09f-cba2dd200880 --- src/Output.c | 63 ++++++++++++++++++++++++++++----------------------- src/OutputInfo.c | 69 ++++++++++++++++++++++++++++++++------------------------ 2 files changed, 75 insertions(+), 57 deletions(-) diff --git a/src/Output.c b/src/Output.c index 05541f9..1e286a7 100644 --- a/src/Output.c +++ b/src/Output.c @@ -15,13 +15,13 @@ #include "cctk.h" #include "cctk_Parameters.h" -#include "CactusBase/IOUtil/src/ioGH.h" #include "iobasicGH.h" /* function prototypes */ int IOBasic_TimeForOutput (cGH *GH, int index); static void CheckSteerableParameters (iobasicGH *myGH); +static void SetOutputFlag (int index, const char *optstring, void *arg); /*@@ @@ -184,8 +184,8 @@ int IOBasic_OutputVarAs (cGH *GH, const char *fullname, const char *alias) int IOBasic_TimeForOutput (cGH *GH, int index) { int return_type; - int grouptype; iobasicGH *myGH; + char *fullname; /* Default is do not do output */ @@ -202,23 +202,17 @@ int IOBasic_TimeForOutput (cGH *GH, int index) return (0); } - grouptype = CCTK_GroupTypeFromVarI (index); - - /* Check this GF should be output */ - if (myGH->do_outScalar [index] - && (grouptype == GROUP_GF || grouptype == GROUP_SCALAR) - && (GH->cctk_iteration % myGH->outScalar_every == 0)) + /* Check if this variable should be output */ + if (myGH->do_outScalar [index] && + (GH->cctk_iteration % myGH->outScalar_every) == 0) { - - /* Check GF not already output this iteration */ + /* Check if variable wasn't already output this iteration */ if (myGH->outScalar_last [index] == GH->cctk_iteration) { - char *fullname = CCTK_FullName (index); - - + fullname = CCTK_FullName (index); CCTK_VWarn (5, __LINE__, __FILE__, CCTK_THORNSTRING, - "Already done Scalar output for variable '%s' in current " - "iteration (probably via triggers)", fullname); + "Already done IOBasic scalar output for '%s' in " + "current iteration (probably via triggers)", fullname); free (fullname); } else @@ -289,11 +283,12 @@ int IOBasic_TriggerOutput (cGH *GH, int index) /**************************** local functions ******************************/ +/* check if steerable parameters have changed */ static void CheckSteerableParameters (iobasicGH *myGH) { DECLARE_CCTK_PARAMETERS - const cParamData *paramdata; - static int outScalar_vars_lastset = 0; + int times_set; + static int outScalar_vars_lastset = -1; /* How often to output */ @@ -303,21 +298,33 @@ static void CheckSteerableParameters (iobasicGH *myGH) myGH->outScalar_every = outScalar_every; } - /* Check the 'outScalar_vars' parameter */ - paramdata = CCTK_ParameterData ("outScalar_vars", CCTK_THORNSTRING); - if (! paramdata) - { - CCTK_WARN (1, "Couldn't get info on parameter 'outScalar_vars'"); - return; - } - /* re-parse the 'outScalar_vars' parameter if it was changed */ - if (paramdata->n_set != outScalar_vars_lastset) + times_set = CCTK_ParameterQueryTimesSet ("outScalar_vars", CCTK_THORNSTRING); + if (times_set != outScalar_vars_lastset) { - IOUtil_ParseVarsForOutput (outScalar_vars, myGH->do_outScalar); + memset (myGH->do_outScalar, 0, CCTK_NumVars ()); + CCTK_TraverseString (outScalar_vars, SetOutputFlag, myGH->do_outScalar, + CCTK_GROUP_OR_VAR); /* Save the last setting of 'outScalar_vars' parameter */ - outScalar_vars_lastset = paramdata->n_set; + outScalar_vars_lastset = times_set; } } + + +/* 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); + } +} diff --git a/src/OutputInfo.c b/src/OutputInfo.c index b077375..2847554 100644 --- a/src/OutputInfo.c +++ b/src/OutputInfo.c @@ -7,7 +7,7 @@ @enddesc @@*/ -/*#define IO_DEBUG*/ +/*#define IO_DEBUG 1*/ #include #include @@ -16,7 +16,6 @@ #include "cctk.h" #include "cctk_Parameters.h" -#include "CactusBase/IOUtil/src/ioGH.h" #include "iobasicGH.h" @@ -27,9 +26,12 @@ ((x) == 0.0) || \ (fabs(x) < DECIMAL_TOOBIG)) +/* function prototypes */ +static void SetOutputFlag (int index, const char *optstring, void *arg); + /* static variables */ -static int print_header = 0; -static int outInfo_vars_lastset = 0; +static int print_header = 1; +static int outInfo_vars_lastset = -1; /*@@ @@ -57,9 +59,9 @@ int IOBasic_OutputInfoGH (cGH *GH) int i; int ierr1; int ierr2; + int times_set; const char *varname; iobasicGH *myGH; - const cParamData *paramdata; /* Get the GH extensions for IOBasic */ @@ -79,24 +81,20 @@ int IOBasic_OutputInfoGH (cGH *GH) return (0); } - /* Check the 'outInfo_vars' parameter */ - paramdata = CCTK_ParameterData ("outInfo_vars", CCTK_THORNSTRING); - if (! paramdata) - { - CCTK_WARN (1, "Couldn't get info on parameter 'outInfo_vars'"); - return (0); - } - /* re-parse the 'outInfo_vars' parameter if it was changed and also print a header */ - if (paramdata->n_set != outInfo_vars_lastset) + times_set = CCTK_ParameterQueryTimesSet ("outInfo_vars", CCTK_THORNSTRING); + if (times_set != outInfo_vars_lastset) { int do_outInfo; - IOUtil_ParseVarsForOutput (outInfo_vars, myGH->do_outInfo); + + memset (myGH->do_outInfo, 0, CCTK_NumVars ()); + CCTK_TraverseString (outInfo_vars, SetOutputFlag, myGH->do_outInfo, + CCTK_GROUP_OR_VAR); /* Save the last setting of 'outInfo_vars' parameter */ - outInfo_vars_lastset = paramdata->n_set; + outInfo_vars_lastset = times_set; do_outInfo = 0; for (i = 0; i < CCTK_NumVars (); i++) @@ -264,8 +262,8 @@ int IOBasic_TimeForInfo (cGH *GH, int index) { DECLARE_CCTK_PARAMETERS int retval; + int times_set; iobasicGH *myGH; - const cParamData *paramdata; /* Default is do not do output */ @@ -287,22 +285,17 @@ int IOBasic_TimeForInfo (cGH *GH, int index) return (0); } - /* Check the 'outInfo_vars' parameter */ - paramdata = CCTK_ParameterData ("outInfo_vars", CCTK_THORNSTRING); - if (! paramdata) - { - CCTK_WARN (1, "Couldn't get info on parameter 'outInfo_vars'"); - return (0); - } - /* re-parse the 'outInfo_vars' parameter if it was changed and also print a header */ - if (paramdata->n_set != outInfo_vars_lastset) + times_set = CCTK_ParameterQueryTimesSet ("outInfo_vars", CCTK_THORNSTRING); + if (times_set != outInfo_vars_lastset) { - IOUtil_ParseVarsForOutput (outInfo_vars, myGH->do_outInfo); + memset (myGH->do_outInfo, 0, CCTK_NumVars ()); + CCTK_TraverseString (outInfo_vars, SetOutputFlag, myGH->do_outInfo, + CCTK_GROUP_OR_VAR); /* Save the last setting of 'outInfo_vars' parameter */ - outInfo_vars_lastset = paramdata->n_set; + outInfo_vars_lastset = times_set; print_header = 1; } @@ -319,7 +312,7 @@ int IOBasic_TimeForInfo (cGH *GH, int index) CCTK_VWarn (5, __LINE__, __FILE__, CCTK_THORNSTRING, - "Already done Info output for variable '%s' in current " + "Already done Info output for '%s' in current " "iteration (probably via triggers)", fullname); free (fullname); } @@ -384,3 +377,21 @@ int IOBasic_TriggerOutputInfo (cGH *GH, int index) return 0; } + + +/**************************** local functions ******************************/ +/* 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); + } +} -- cgit v1.2.3