diff options
author | tradke <tradke@ebee0441-1374-4afa-a3b5-247f3ba15b9a> | 2000-02-25 17:12:57 +0000 |
---|---|---|
committer | tradke <tradke@ebee0441-1374-4afa-a3b5-247f3ba15b9a> | 2000-02-25 17:12:57 +0000 |
commit | 0e96493692789d2492379290fdbf2e4a7e72aceb (patch) | |
tree | c662ec7528fd06bda4482ae58a6669cfdf046175 | |
parent | 5c5bb01905900966cc2aef4c9ba424694a63194b (diff) |
More stuff for steering parameters.
Thomas
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOFlexIO/trunk@94 ebee0441-1374-4afa-a3b5-247f3ba15b9a
-rw-r--r-- | src/Output2D.c | 60 | ||||
-rw-r--r-- | src/Output3D.c | 60 | ||||
-rw-r--r-- | src/ioFlexGH.h | 13 |
3 files changed, 82 insertions, 51 deletions
diff --git a/src/Output2D.c b/src/Output2D.c index 735ae5f..efb1366 100644 --- a/src/Output2D.c +++ b/src/Output2D.c @@ -21,9 +21,10 @@ #include "ioFlexGH.h" -/* local function prototypes */ +/* function prototypes */ int IOFlexIO_Output2DVarAs (cGH *GH, const char *var, const char *alias); int IOFlexIO_TimeFor2D (cGH *GH, int index); +static void CheckSteerableParameters (flexioGH *myGH); /*@@ @@ -52,32 +53,15 @@ int IOFlexIO_Output2DGH (cGH *GH) flexioGH *myGH; const char *name; char *fullname; - cParamData *paramdata; - static int out2D_vars_lastset = 0; /* Get the GH extension for IOFlexIO */ myGH = (flexioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOFlexIO")]; - if (myGH->out2D_every <= 0) - return (0); + CheckSteerableParameters (myGH); - /* Check the 'out2D_vars' parameter */ - paramdata = CCTK_ParameterData ("out2D_vars", CCTK_THORNSTRING); - if (! paramdata) - { - CCTK_WARN (2, "Couldn't get info on parameter 'out2D_vars'"); + if (myGH->out2D_every <= 0) return (0); - } - - /* re-parse the 'out2D_vars' parameter if it was changed */ - if (paramdata->n_set != out2D_vars_lastset) - { - ParseVarsForOutput (out2D_vars, myGH->do_out2D); - - /* Save the last setting of 'out2D_vars' parameter */ - out2D_vars_lastset = paramdata->n_set; - } /* Loop over all variables */ for (i = 0; i < CCTK_NumVars (); i++) { @@ -196,6 +180,8 @@ int IOFlexIO_TimeFor2D (cGH *GH, int index) /* Get the GH extension for IOUtil and IOFlexIO */ myGH = (flexioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOFlexIO")]; + CheckSteerableParameters (myGH); + /* Check this GF should be output */ if (! (CCTK_GroupTypeFromVarI (index) == GROUP_GF && myGH->do_out2D [index] && GH->cctk_iteration % myGH->out2D_every == 0)) @@ -263,5 +249,37 @@ int IOFlexIO_TriggerOutput2D (cGH *GH, int index) return (0); - +} + + +/**************************** local functions ******************************/ +static void CheckSteerableParameters (flexioGH *myGH) +{ + DECLARE_CCTK_PARAMETERS + cParamData *paramdata; + static int out2D_vars_lastset = 0; + + + /* How often to output */ + myGH->out2D_every = out_every > 0 ? out_every : -1; + if (out2D_every > 0) + myGH->out2D_every = out2D_every; + + /* Check the 'out2D_vars' parameter */ + paramdata = CCTK_ParameterData ("out2D_vars", CCTK_THORNSTRING); + if (! paramdata) + { + CCTK_WARN (1, "Couldn't get info on parameter 'out2D_vars'"); + return; + } + + /* re-parse the 'out2D_vars' parameter if it was changed */ + if (paramdata->n_set != out2D_vars_lastset) + { + ParseVarsForOutput (out2D_vars, myGH->do_out2D); + + /* Save the last setting of 'out2D_vars' parameter */ + out2D_vars_lastset = paramdata->n_set; + } + } diff --git a/src/Output3D.c b/src/Output3D.c index 7d0bec8..bcaca3f 100644 --- a/src/Output3D.c +++ b/src/Output3D.c @@ -21,9 +21,10 @@ #include "CactusBase/IOUtil/src/ioGH.h" #include "ioFlexGH.h" -/* local function prototypes */ +/* function prototypes */ int IOFlexIO_Output3DVarAs (cGH *GH, const char *var, const char *alias); int IOFlexIO_TimeFor3D (cGH *GH, int index); +static void CheckSteerableParameters (flexioGH *myGH); /*@@ @@ -52,32 +53,15 @@ int IOFlexIO_Output3DGH (cGH *GH) flexioGH *myGH; const char *name; char *fullname; - cParamData *paramdata; - static int out3D_vars_lastset = 0; /* Get the GH extension for IOFlexIO */ myGH = (flexioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOFlexIO")]; - if (myGH->out3D_every <= 0) - return (0); + CheckSteerableParameters (myGH); - /* Check the 'out3D_vars' parameter */ - paramdata = CCTK_ParameterData ("out3D_vars", CCTK_THORNSTRING); - if (! paramdata) - { - CCTK_WARN (3, "Couldn't get info on parameter 'out3D_vars'"); + if (myGH->out3D_every <= 0) return (0); - } - - /* re-parse the 'out3D_vars' parameter if it was changed */ - if (paramdata->n_set != out3D_vars_lastset) - { - ParseVarsForOutput (out3D_vars, myGH->do_out3D); - - /* Save the last setting of 'out3D_vars' parameter */ - out3D_vars_lastset = paramdata->n_set; - } /* Loop over all variables */ for (i = 0; i < CCTK_NumVars (); i++) { @@ -194,6 +178,8 @@ int IOFlexIO_TimeFor3D (cGH *GH, int index) /* Get the GH extension for IOFlexIO */ myGH = (flexioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOFlexIO")]; + CheckSteerableParameters (myGH); + /* Check this var should be output */ if (! (myGH->do_out3D [index] && GH->cctk_iteration % myGH->out3D_every == 0)) return (0); @@ -260,5 +246,37 @@ int IOFlexIO_TriggerOutput3D (cGH *GH, int index) return (0); - +} + + +/**************************** local functions ******************************/ +static void CheckSteerableParameters (flexioGH *myGH) +{ + DECLARE_CCTK_PARAMETERS + cParamData *paramdata; + static int out3D_vars_lastset = 0; + + + /* How often to output */ + myGH->out3D_every = out_every > 0 ? out_every : -1; + if (out3D_every > 0) + myGH->out3D_every = out3D_every; + + /* Check the 'out3D_vars' parameter */ + paramdata = CCTK_ParameterData ("out3D_vars", CCTK_THORNSTRING); + if (! paramdata) + { + CCTK_WARN (1, "Couldn't get info on parameter 'out3D_vars'"); + return; + } + + /* re-parse the 'out3D_vars' parameter if it was changed */ + if (paramdata->n_set != out3D_vars_lastset) + { + ParseVarsForOutput (out3D_vars, myGH->do_out3D); + + /* Save the last setting of 'out3D_vars' parameter */ + out3D_vars_lastset = paramdata->n_set; + } + } diff --git a/src/ioFlexGH.h b/src/ioFlexGH.h index cbc1614..ee0b947 100644 --- a/src/ioFlexGH.h +++ b/src/ioFlexGH.h @@ -60,15 +60,10 @@ \ int error_code = fn_call; \ \ - if (error_code < 0) { \ - char *msg = (char*) malloc(strlen(__FILE__) + strlen(#fn_call) + 160);\ - \ - sprintf (msg, \ - "IEEEIO call %s returned error code %d, file %s, line %d\n", \ - #fn_call, error_code, __FILE__, __LINE__); \ - CCTK_WARN (1, msg); \ - free (msg); \ - } \ + if (error_code < 0) \ + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, \ + "IEEEIO call '%s' returned error code %d\n", \ + #fn_call, error_code); \ } while (0) |