aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@38c3d835-c875-442e-b0fe-21c19ce1d001>2002-05-28 14:56:07 +0000
committertradke <tradke@38c3d835-c875-442e-b0fe-21c19ce1d001>2002-05-28 14:56:07 +0000
commit3d596302cdb3a845a9cf5b4ffb3ce6218fffe2b4 (patch)
treed7ce46cc6523d3fb30c5261a51ce792c6045bccd
parent9e897d77648b19c5f0cb2146d96d8c1e663d557e (diff)
Allow the 'out_every' option in option strings to set the output frequency
for individual variables. Allow hyperslab options 'origin', 'direction', 'extent', and 'downsample' in option strings to specify hyperslab selections for individual variables. You also need to update CactusBase/IOUtil now. See the thornguide for a description and an example. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOPanda/trunk@38 38c3d835-c875-442e-b0fe-21c19ce1d001
-rw-r--r--src/Output.c83
-rw-r--r--src/Startup.c3
-rw-r--r--src/ioPandaGH.h16
3 files changed, 76 insertions, 26 deletions
diff --git a/src/Output.c b/src/Output.c
index 449d43b..0dfc9bd 100644
--- a/src/Output.c
+++ b/src/Output.c
@@ -14,6 +14,7 @@
#include "cctk.h"
#include "cctk_Parameters.h"
+#include "util_String.h"
#include "Hyperslab.h"
#include "CactusBase/IOUtil/src/ioGH.h"
#include "CactusPUGH/PUGH/src/include/pugh.h"
@@ -67,13 +68,8 @@ int IOPanda_OutputGH (const cGH *GH)
const pandaGH *myGH;
- myGH = (const pandaGH *) CCTK_GHExtension (GH, "IOPanda");
- if (myGH->out_every <= 0)
- {
- return (0);
- }
-
retval = 0;
+ myGH = (const pandaGH *) CCTK_GHExtension (GH, "IOPanda");
/* loop over all variables */
for (vindex = CCTK_NumVars () - 1; vindex >= 0; vindex--)
@@ -144,7 +140,8 @@ int IOPanda_OutputVarAs (const cGH *GH, const char *fullname, const char *alias)
oneshot = myGH->requests[vindex] == NULL;
if (oneshot)
{
- IOUtil_ParseVarsForOutput (GH, fullname, myGH->requests);
+ IOUtil_ParseVarsForOutput (GH, CCTK_THORNSTRING, "IOPanda::out_vars",
+ fullname, 1, myGH->requests);
}
/* do the output */
@@ -197,9 +194,9 @@ int IOPanda_TimeFor (const cGH *GH, int vindex)
CheckSteerableParameters (GH);
/* check if this variable should be output */
- myGH = (pandaGH *) CCTK_GHExtension (GH, "IOPanda");
- retval = myGH->out_every > 0 && myGH->requests[vindex] &&
- GH->cctk_iteration % myGH->out_every == 0;
+ myGH = (const pandaGH *) CCTK_GHExtension (GH, "IOPanda");
+ retval = myGH->requests[vindex] && myGH->requests[vindex]->out_every > 0 &&
+ GH->cctk_iteration % myGH->requests[vindex]->out_every == 0;
if (retval)
{
/* check if variable was not already output this iteration */
@@ -295,29 +292,45 @@ int IOPanda_TriggerOutput (const cGH *GH, int vindex)
@@*/
static void CheckSteerableParameters (const cGH *GH)
{
- int vindex, times_set;
+ int i, vindex, num_vars;
pandaGH *myGH;
- char *fullname;
- static int out_vars_lastset = -1;
+ char *msg, *fullname;
DECLARE_CCTK_PARAMETERS
/* how often to output */
myGH = (pandaGH *) CCTK_GHExtension (GH, "IOPanda");
- myGH->out_every = out_every >= 0 ? out_every : io_out_every;
+ i = myGH->out_every_default;
+ myGH->out_every_default = out_every >= 0 ? out_every : io_out_every;
+
+ /* report if frequency changed */
+ if (myGH->out_every_default != i && ! CCTK_Equals (verbose, "none"))
+ {
+ if (myGH->out_every_default > 0)
+ {
+ CCTK_VInfo (CCTK_THORNSTRING, "IOPanda: Periodic output every %d "
+ "iterations", myGH->out_every_default);
+ }
+ else
+ {
+ CCTK_INFO ("IOPanda: Periodic output turned off");
+ }
+ }
- /* re-parse the 'out_vars' parameter if it was changed */
- times_set = CCTK_ParameterQueryTimesSet ("out_vars", CCTK_THORNSTRING);
- if (times_set != out_vars_lastset)
+ /* re-parse the 'IOPanda::out_vars' parameter if it was changed */
+ if (strcmp (out_vars, myGH->out_vars) || myGH->out_every_default != i)
{
- IOUtil_ParseVarsForOutput (GH, out_vars, myGH->requests);
+ IOUtil_ParseVarsForOutput (GH, CCTK_THORNSTRING, "IOPanda::out_vars",
+ out_vars, myGH->out_every_default,
+ myGH->requests);
/*** FIXME: IEEEIO doesn't provide a COMPLEX datatype
so we should map CCTK_COMPLEX to two REALs here.
We have to check for this already here because if an IEEEIO file
is created and nothing is written to it, it will crash
at re-opening. ***/
- for (vindex = CCTK_NumVars () - 1; vindex >= 0; vindex--)
+ num_vars = CCTK_NumVars ();
+ for (vindex = 0; vindex < num_vars; vindex++)
{
if (! myGH->requests[vindex])
{
@@ -346,8 +359,36 @@ static void CheckSteerableParameters (const cGH *GH)
}
}
- /* save the last setting of 'out_vars' parameter */
- out_vars_lastset = times_set;
+ if (myGH->out_every_default == i || ! CCTK_Equals (verbose, "none"))
+ {
+ msg = NULL;
+ for (vindex = 0; vindex < num_vars; vindex++)
+ {
+ if (myGH->requests[vindex])
+ {
+ fullname = CCTK_FullName (vindex);
+ if (! msg)
+ {
+ Util_asprintf (&msg, "IOPanda: Periodic output requested for '%s'",
+ fullname);
+ }
+ else
+ {
+ Util_asprintf (&msg, "%s, '%s'", msg, fullname);
+ }
+ free (fullname);
+ }
+ }
+ if (msg)
+ {
+ CCTK_INFO (msg);
+ free (msg);
+ }
+ }
+
+ /* save the last setting of 'IOPanda::out_vars' parameter */
+ free (myGH->out_vars);
+ myGH->out_vars = strdup (out_vars);
}
}
diff --git a/src/Startup.c b/src/Startup.c
index 61fe3d3..178b53f 100644
--- a/src/Startup.c
+++ b/src/Startup.c
@@ -148,6 +148,9 @@ static void *SetupGH (tFleshConfig *config, int convergence_level, cGH *GH)
myGH->requests = (ioRequest **) calloc (numvars, sizeof (ioRequest *));
myGH->out_last = (int *) malloc (numvars * sizeof (int));
+ myGH->out_vars = strdup ("");
+ myGH->out_every_default = out_every - 1;
+
for (i = 0; i < numvars; i++)
{
myGH->out_last[i] = -1;
diff --git a/src/ioPandaGH.h b/src/ioPandaGH.h
index 736ca58..51017a8 100644
--- a/src/ioPandaGH.h
+++ b/src/ioPandaGH.h
@@ -22,17 +22,23 @@ extern "C"
typedef struct
{
- /* the number of times to output */
- int out_every;
+ /* default number of times to output */
+ int out_every_default;
+
+ /* number of times to output for each variable */
+ CCTK_INT *out_every;
+
+ /* the last iteration output for each variable */
+ int *out_last;
+
+ /* list of variables to output */
+ char *out_vars;
/* I/O request descriptions for all CCTK variables */
ioRequest **requests;
/* directory in which to output */
char *out_dir;
-
- /* the last iteration output for variable[i] */
- int *out_last;
} pandaGH;