diff options
author | tradke <tradke@b589c3ab-70e8-4b4d-a09f-cba2dd200880> | 2000-02-01 17:21:57 +0000 |
---|---|---|
committer | tradke <tradke@b589c3ab-70e8-4b4d-a09f-cba2dd200880> | 2000-02-01 17:21:57 +0000 |
commit | cdb2f856c8dea8ef1911e4a41382a0ad5ffc431d (patch) | |
tree | ff3275ee11fd30b167863b1880b62c03cbd55447 /src | |
parent | 5983276000d1c7432ee612d5cc619a835a126cc8 (diff) |
Made 'outScalar_vars' and 'outScalar_every' steerable.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOBasic/trunk@28 b589c3ab-70e8-4b4d-a09f-cba2dd200880
Diffstat (limited to 'src')
-rw-r--r-- | src/Output.c | 146 |
1 files changed, 63 insertions, 83 deletions
diff --git a/src/Output.c b/src/Output.c index 5dbd3a6..e078907 100644 --- a/src/Output.c +++ b/src/Output.c @@ -15,6 +15,7 @@ #include "cctk.h" #include "cctk_Parameters.h" +#include "cctk_ParameterFunctions.h" #include "CactusBase/IOUtil/src/ioGH.h" #include "iobasicGH.h" @@ -22,79 +23,70 @@ int IOBasic_OutputGH (cGH *GH) { DECLARE_CCTK_PARAMETERS - int i; - int grouptype; - char *name=NULL; + int index; + char *name; iobasicGH *myGH; + t_param_prop *param_prop; + static int outScalar_vars_lastset = 0; + /* Get the GH extensions for IOBasic */ myGH = (iobasicGH *) GH->extensions [CCTK_GHExtensionHandle ("IOBasic")]; /* Return if no output is required */ if (myGH->outScalar_every <= 0) - return 0; - - /* Loop over all variables */ - for (i = 0; i < CCTK_NumVars (); i++) { + return (0); - grouptype = CCTK_GroupTypeFromVarI (i); + /* Check the 'outScalar_vars' parameter */ + param_prop = CCTK_ParameterInfo ("outScalar_vars", CCTK_THORNSTRING); + if (! param_prop) { + CCTK_WARN (3, "Couldn't get info on parameter 'outScalar_vars'"); + return (0); + } - /* Check this GF should be output */ - if (myGH->do_outScalar [i] - && (grouptype == GROUP_GF||grouptype == GROUP_SCALAR) - && (GH->cctk_iteration % myGH->outScalar_every == 0)) { + /* re-parse the 'outScalar_vars' parameter if it was changed */ + if (param_prop->n_set != outScalar_vars_lastset) + ParseVarsForOutput (outScalar_vars, myGH->do_outScalar); - /* Check GF not already output this iteration */ - if (myGH->outScalar_last [i] == GH->cctk_iteration) { - char *msg, *varname; + /* Loop over all variables */ + for (index = 0; index < CCTK_NumVars (); index++) { - varname = CCTK_VarName (i); - msg = (char *) malloc (200 * sizeof (char) + strlen (varname)); - sprintf (msg, "Already done Scalar output for '%s' on this timestep", - varname); - CCTK_WARN (2, msg); - free (msg); - } - else - { + /* Is it time for output ? */ + if (! IOBasic_TimeForOutput (GH, index)) + continue; - /* Get the variable name for this index (for filename) */ - name = CCTK_VarName(i); + /* Get the variable name for this index (for filename) */ + name = CCTK_VarName (index); #ifdef IO_DEBUG - printf("\nIn IOBasic_OutputGH\n----------------\n"); - printf(" Index = %d\n",i); - printf(" Variable = -%s-\n",name); - printf(" Last output iteration was = %d\n",myGH->outScalar_last[i]); + printf("\nIn IOBasic_OutputGH\n----------------\n"); + printf(" Index = %d\n",index); + printf(" Variable = -%s-\n",name); + printf(" Last output iteration was = %d\n",myGH->outScalar_last[index]); #endif - /* Make the IO call */ - if (grouptype == GROUP_SCALAR) - { - IOBasic_Write (GH, i, name); - } - else - { - IOBasic_WriteGF (GH, i, name); - } - - /* Register GF as having 0D output this iteration */ - myGH->outScalar_last [i] = GH->cctk_iteration; - } - } - } + /* Make the IO call */ + if (CCTK_GroupTypeFromVarI (index) == GROUP_SCALAR) + IOBasic_Write (GH, index, name); + else + IOBasic_WriteGF (GH, index, name); - return 0; + /* Register GF as having 0D output this iteration */ + myGH->outScalar_last [index] = GH->cctk_iteration; - USE_CCTK_PARAMETERS + } /* end of loop over all variables */ + return (0); + + USE_CCTK_PARAMETERS } int IOBasic_OutputVarAs (cGH *GH, const char *fullname, const char *alias) { int index; - int grouptype; + + index = CCTK_VarIndex (fullname); #ifdef IO_DEBUG @@ -104,18 +96,12 @@ int IOBasic_OutputVarAs (cGH *GH, const char *fullname, const char *alias) printf(" Index = %d\n",index); #endif - grouptype = CCTK_GroupTypeFromVarI (index); - - if (grouptype == GROUP_SCALAR) - { + if (CCTK_GroupTypeFromVarI (index) == GROUP_SCALAR) IOBasic_Write (GH, index, alias); - } else - { IOBasic_WriteGF (GH, index, alias); - } - - return 0; + + return (0); } @@ -140,7 +126,7 @@ int IOBasic_OutputVarAs (cGH *GH, const char *fullname, const char *alias) @vio in @vcomment @endvar - @var var + @var index @vdesc index of variable @vtype int @vio in @@ -148,67 +134,61 @@ int IOBasic_OutputVarAs (cGH *GH, const char *fullname, const char *alias) @endvar @@*/ -int IOBasic_TimeForOutput (cGH *GH, int var) +int IOBasic_TimeForOutput (cGH *GH, int index) { int return_type; int grouptype; iobasicGH *myGH; + /* Default is do not do output */ return_type = 0; /* Get the GH extension for IOBasic */ myGH = (iobasicGH *) GH->extensions [CCTK_GHExtensionHandle ("IOBasic")]; - grouptype = CCTK_GroupTypeFromVarI (var); + grouptype = CCTK_GroupTypeFromVarI (index); /* Check this GF should be output */ - if (myGH->do_outScalar [var] + if (myGH->do_outScalar [index] && (grouptype == GROUP_GF || grouptype == GROUP_SCALAR) && (GH->cctk_iteration % myGH->outScalar_every == 0)) { /* Check GF not already output this iteration */ - if (myGH->outScalar_last [var] == GH->cctk_iteration) + if (myGH->outScalar_last [index] == GH->cctk_iteration) CCTK_WARN (2, "Already done Scalar output in IO"); else return_type = 1; } - return return_type; + return (return_type); } -int IOBasic_TriggerOutput (cGH *GH, int variable) +int IOBasic_TriggerOutput (cGH *GH, int index) { - char *var; - int grouptype; + char *name; iobasicGH *myGH; + /* Get the GH extension for IOBasic */ myGH = (iobasicGH *) GH->extensions [CCTK_GHExtensionHandle ("IOBasic")]; - var = CCTK_VarName (variable); + name = CCTK_VarName (index); #ifdef IO_DEBUG - printf("\nIn IOBasic_TriggerOutput\n---------------------\n"); - printf(" Index = %d\n",variable); - printf(" Variable = -%s-\n",var); + printf ("\nIn IOBasic_TriggerOutput\n---------------------\n"); + printf (" Index = %d\n", index); + printf (" Variable = -%s-\n", name); #endif /* Do the Scalar output */ - - grouptype = CCTK_GroupTypeFromVarI (variable); - - if (grouptype == GROUP_SCALAR) - { - IOBasic_Write (GH, variable, var); - } + if (CCTK_GroupTypeFromVarI (index) == GROUP_SCALAR) + IOBasic_Write (GH, index, name); else - { - IOBasic_WriteGF (GH, variable, var); - } - + IOBasic_WriteGF (GH, index, name); + /* Register variable as having Scalar output this iteration */ - myGH->outScalar_last [variable] = GH->cctk_iteration; + myGH->outScalar_last [index] = GH->cctk_iteration; - return 0; + return (0); } |