aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@94b1c47f-dcfd-45ef-a468-0854c0e9e350>2002-05-28 14:48:46 +0000
committertradke <tradke@94b1c47f-dcfd-45ef-a468-0854c0e9e350>2002-05-28 14:48:46 +0000
commit2a224e81b3d8491dcea3ac7022c64a326cb24030 (patch)
tree5afc8bc053941bcbe0edc81c410ee82d55bd3f8a
parent89725a801685d2fb33cdf08ddc24f4dc9d9c64d2 (diff)
Allow the 'out_every' option in option strings to set the output frequency
for individual variables. You also need to update CactusBase/IOUtil now. git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOASCII/trunk@120 94b1c47f-dcfd-45ef-a468-0854c0e9e350
-rw-r--r--src/Output1D.c30
-rw-r--r--src/Output2D.c22
-rw-r--r--src/Output3D.c22
-rw-r--r--src/Startup.c6
-rw-r--r--src/ioASCIIGH.h2
5 files changed, 29 insertions, 53 deletions
diff --git a/src/Output1D.c b/src/Output1D.c
index 8bcdd3d..b0e73c5 100644
--- a/src/Output1D.c
+++ b/src/Output1D.c
@@ -14,6 +14,7 @@
#include "cctk.h"
#include "cctk_Parameters.h"
#include "util_String.h"
+#include "CactusBase/IOUtil/src/ioutil_Utils.h"
#include "ioASCIIGH.h"
/* the rcs ID and its dummy function to use it */
@@ -117,7 +118,7 @@ int IOASCII_Output1DVarAs (const cGH *GH, const char *fullname, const char *alia
retval = -1;
vindex = CCTK_VarIndex (fullname);
- if (CheckOutputVar (vindex) == 0)
+ if (CheckOutputVar (vindex))
{
retval = IOASCII_Write1D (GH, vindex, alias);
}
@@ -258,7 +259,7 @@ static void CheckSteerableParameters (asciiioGH *myGH)
if (strcmp (out1D_vars, myGH->out1D_vars) || myGH->out1D_every_default != i)
{
num_vars = CCTK_NumVars ();
- memset (myGH->out1D_every, 0, num_vars * sizeof (int));
+ memset (myGH->out1D_every, 0, num_vars * sizeof (CCTK_INT));
CCTK_TraverseString (out1D_vars, SetOutputFlag, myGH, CCTK_GROUP_OR_VAR);
if (myGH->out1D_every_default == i || ! CCTK_Equals (verbose, "none"))
@@ -305,8 +306,8 @@ static int CheckOutputVar (int vindex)
/* check the variable type */
grouptype = CCTK_GroupTypeFromVarI (vindex);
- retval = grouptype != CCTK_GF && grouptype != CCTK_ARRAY;
- if (retval)
+ retval = grouptype == CCTK_GF || grouptype == CCTK_ARRAY;
+ if (! retval)
{
fullname = CCTK_FullName (vindex);
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
@@ -323,27 +324,18 @@ static int CheckOutputVar (int vindex)
for the given variable */
static void SetOutputFlag (int vindex, const char *optstring, void *arg)
{
- char *endptr;
- asciiioGH *myGH = (asciiioGH *) arg;
+ const asciiioGH *myGH = (const asciiioGH *) arg;
- if (CheckOutputVar (vindex) == 0)
+ if (CheckOutputVar (vindex))
{
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;
- }
+ IOUtil_ParseOutputFrequency ("1D IOASCII", "IOASCII::out1D_vars",
+ vindex, optstring,
+ &myGH->out1D_every[vindex]);
}
}
}
diff --git a/src/Output2D.c b/src/Output2D.c
index 80788a7..a830e42 100644
--- a/src/Output2D.c
+++ b/src/Output2D.c
@@ -14,6 +14,7 @@
#include "cctk.h"
#include "cctk_Parameters.h"
#include "util_String.h"
+#include "CactusBase/IOUtil/src/ioutil_Utils.h"
#include "ioASCIIGH.h"
/* the rcs ID and its dummy function to use it */
@@ -258,7 +259,7 @@ static void CheckSteerableParameters (asciiioGH *myGH)
if (strcmp (out2D_vars, myGH->out2D_vars) || myGH->out2D_every_default != i)
{
num_vars = CCTK_NumVars ();
- memset (myGH->out2D_every, 0, num_vars * sizeof (int));
+ memset (myGH->out2D_every, 0, num_vars * sizeof (CCTK_INT));
CCTK_TraverseString (out2D_vars, SetOutputFlag, myGH, CCTK_GROUP_OR_VAR);
if (myGH->out2D_every_default == i || ! CCTK_Equals (verbose, "none"))
@@ -334,27 +335,18 @@ static int CheckOutputVar (int vindex)
for the given variable */
static void SetOutputFlag (int vindex, const char *optstring, void *arg)
{
- char *endptr;
- asciiioGH *myGH = (asciiioGH *) arg;
+ const asciiioGH *myGH = (const asciiioGH *) arg;
if (CheckOutputVar (vindex) == 0)
{
myGH->out2D_every[vindex] = myGH->out2D_every_default;
+
if (optstring)
{
- endptr = "error";
- if (strncmp ("out_every=", optstring, 10) == 0)
- {
- myGH->out2D_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->out2D_every[vindex] = 0;
- }
+ IOUtil_ParseOutputFrequency ("2D IOASCII", "IOASCII::out2D_vars",
+ vindex, optstring,
+ &myGH->out2D_every[vindex]);
}
}
}
diff --git a/src/Output3D.c b/src/Output3D.c
index 4cf537f..92a1119 100644
--- a/src/Output3D.c
+++ b/src/Output3D.c
@@ -14,6 +14,7 @@
#include "cctk.h"
#include "cctk_Parameters.h"
#include "util_String.h"
+#include "CactusBase/IOUtil/src/ioutil_Utils.h"
#include "ioASCIIGH.h"
/* the rcs ID and its dummy function to use it */
@@ -259,7 +260,7 @@ static void CheckSteerableParameters (asciiioGH *myGH)
if (strcmp (out3D_vars, myGH->out3D_vars) || myGH->out3D_every_default != i)
{
num_vars = CCTK_NumVars ();
- memset (myGH->out3D_every, 0, num_vars * sizeof (int));
+ memset (myGH->out3D_every, 0, num_vars * sizeof (CCTK_INT));
CCTK_TraverseString (out3D_vars, SetOutputFlag, myGH, CCTK_GROUP_OR_VAR);
if (myGH->out3D_every_default == i || ! CCTK_Equals (verbose, "none"))
@@ -336,27 +337,18 @@ static int CheckOutputVar (int vindex)
for the given variable */
static void SetOutputFlag (int vindex, const char *optstring, void *arg)
{
- char *endptr;
- asciiioGH *myGH = (asciiioGH *) arg;
+ const asciiioGH *myGH = (const asciiioGH *) arg;
if (CheckOutputVar (vindex) == 0)
{
myGH->out3D_every[vindex] = myGH->out3D_every_default;
+
if (optstring)
{
- endptr = "error";
- if (strncmp ("out_every=", optstring, 10) == 0)
- {
- myGH->out3D_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->out3D_every[vindex] = 0;
- }
+ IOUtil_ParseOutputFrequency ("3D IOASCII", "IOASCII::out3D_vars",
+ vindex, optstring,
+ &myGH->out3D_every[vindex]);
}
}
}
diff --git a/src/Startup.c b/src/Startup.c
index bee548b..3de9bea 100644
--- a/src/Startup.c
+++ b/src/Startup.c
@@ -181,9 +181,9 @@ static void *IOASCII_SetupGH (tFleshConfig *config, int conv_level, cGH *GH)
}
numvars = CCTK_NumVars ();
- myGH->out1D_every = (int *) malloc (numvars * sizeof (int));
- myGH->out2D_every = (int *) malloc (numvars * sizeof (int));
- myGH->out3D_every = (int *) malloc (numvars * sizeof (int));
+ myGH->out1D_every = (CCTK_INT *) malloc (numvars * sizeof (CCTK_INT));
+ myGH->out2D_every = (CCTK_INT *) malloc (numvars * sizeof (CCTK_INT));
+ myGH->out3D_every = (CCTK_INT *) malloc (numvars * sizeof (CCTK_INT));
myGH->out1D_last = (int *) malloc (numvars * sizeof (int));
myGH->out2D_last = (int *) malloc (numvars * sizeof (int));
myGH->out3D_last = (int *) malloc (numvars * sizeof (int));
diff --git a/src/ioASCIIGH.h b/src/ioASCIIGH.h
index 74bb44f..abb2f9e 100644
--- a/src/ioASCIIGH.h
+++ b/src/ioASCIIGH.h
@@ -23,7 +23,7 @@ typedef struct IOASCIIGH
int out1D_every_default, out2D_every_default, out3D_every_default;
/* number of times to output every variable */
- int *out1D_every, *out2D_every, *out3D_every;
+ CCTK_INT *out1D_every, *out2D_every, *out3D_every;
/* lists of variables to output */
char *out1D_vars, *out2D_vars, *out3D_vars;