aboutsummaryrefslogtreecommitdiff
path: root/src/Output1D.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/Output1D.c')
-rw-r--r--src/Output1D.c77
1 files changed, 33 insertions, 44 deletions
diff --git a/src/Output1D.c b/src/Output1D.c
index 8c18aed..4610b02 100644
--- a/src/Output1D.c
+++ b/src/Output1D.c
@@ -67,12 +67,6 @@ int IOASCII_Output1DGH (const cGH *GH)
CheckSteerableParameters (myGH);
- /* Return if no output is required */
- if (myGH->out1D_every <= 0)
- {
- return (0);
- }
-
/* Loop over all variables */
for (vindex = retval = 0; vindex < CCTK_NumVars (); vindex++)
{
@@ -204,15 +198,9 @@ int IOASCII_TimeFor1D (const cGH *GH, int vindex)
CheckSteerableParameters (myGH);
- /* return if no output requested */
- if (myGH->out1D_every <= 0)
- {
- return (0);
- }
-
/* Check if this variable should be output */
- if (myGH->do_out1D[vindex] &&
- GH->cctk_iteration % myGH->out1D_every == 0)
+ if (myGH->out1D_every[vindex] > 0 &&
+ GH->cctk_iteration % myGH->out1D_every[vindex] == 0)
{
/* Check if this variable wasn't already output this iteration */
if (myGH->out1D_last[vindex] == GH->cctk_iteration)
@@ -293,28 +281,22 @@ int IOASCII_TriggerOutput1D (const cGH *GH, int vindex)
/* check if steerable parameters have changed */
static void CheckSteerableParameters (asciiioGH *myGH)
{
- int i, num_vars, out_old, times_set;
+ int i, num_vars;
char *fullname, *msg;
- static int out1D_vars_lastset = -1;
DECLARE_CCTK_PARAMETERS
- out_old = myGH->out1D_every;
-
/* How often to output */
- myGH->out1D_every = out_every > 0 ? out_every : -1;
- if (out1D_every > 0)
- {
- myGH->out1D_every = out1D_every;
- }
+ i = myGH->out1D_every_default;
+ myGH->out1D_every_default = out1D_every > 0 ? out1D_every : out_every;
/* Report if frequency changed */
- if (myGH->out1D_every != out_old && ! CCTK_Equals (newverbose, "none"))
+ if (myGH->out1D_every_default != i && ! CCTK_Equals (newverbose, "none"))
{
- if (myGH->out1D_every > 0)
+ if (myGH->out1D_every_default > 0)
{
CCTK_VInfo (CCTK_THORNSTRING, "IOASCII_1D: Periodic output every %d "
- "iterations", myGH->out1D_every);
+ "iterations", myGH->out1D_every_default);
}
else
{
@@ -323,20 +305,18 @@ static void CheckSteerableParameters (asciiioGH *myGH)
}
/* re-parse the 'out1D_vars' parameter if it was changed */
- times_set = CCTK_ParameterQueryTimesSet ("out1D_vars", CCTK_THORNSTRING);
- if (times_set != out1D_vars_lastset)
+ if (strcmp (out1D_vars, myGH->out1D_vars) || myGH->out1D_every_default != i)
{
num_vars = CCTK_NumVars ();
- memset (myGH->do_out1D, 0, num_vars);
- CCTK_TraverseString (out1D_vars, SetOutputFlag, myGH->do_out1D,
- CCTK_GROUP_OR_VAR);
+ memset (myGH->out1D_every, 0, num_vars * sizeof (int));
+ CCTK_TraverseString (out1D_vars, SetOutputFlag, myGH, CCTK_GROUP_OR_VAR);
- if (! CCTK_Equals (newverbose, "none"))
+ if (myGH->out1D_every_default == i || ! CCTK_Equals (newverbose, "none"))
{
msg = NULL;
for (i = 0; i < num_vars; i++)
{
- if (myGH->do_out1D[i])
+ if (myGH->out1D_every[i] > 0)
{
fullname = CCTK_FullName (i);
if (! msg)
@@ -359,9 +339,9 @@ static void CheckSteerableParameters (asciiioGH *myGH)
}
/* Save the last setting of 'out1D_vars' parameter */
- out1D_vars_lastset = times_set;
+ free (myGH->out1D_vars);
+ myGH->out1D_vars = strdup (out1D_vars);
}
-
}
@@ -393,18 +373,27 @@ static int CheckOutputVar (int vindex)
for the given variable */
static void SetOutputFlag (int vindex, const char *optstring, void *arg)
{
- char *flags = (char *) arg;
+ char *endptr;
+ asciiioGH *myGH = (asciiioGH *) arg;
if (CheckOutputVar (vindex) == 0)
{
- flags[vindex] = 1;
- }
-
- if (optstring)
- {
- CCTK_VWarn (5, __LINE__, __FILE__, CCTK_THORNSTRING,
- "SetOutputFlag: Optional string '%s' in variable name ignored",
- optstring);
+ myGH->out1D_every[vindex] = myGH->out1D_every_default;
+ if (optstring)
+ {
+ endptr = "error";
+ if (strncmp ("out_every=", optstring, 10) == 0)
+ {
+ myGH->out1D_every[vindex] = strtol (optstring + 10, &endptr, 10);
+ }
+ if (endptr && *endptr)
+ {
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "SetOutputFlag: Optional string '%s' could not be parsed",
+ optstring);
+ myGH->out1D_every[vindex] = 0;
+ }
+ }
}
}