aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@94b1c47f-dcfd-45ef-a468-0854c0e9e350>2004-06-09 10:42:22 +0000
committertradke <tradke@94b1c47f-dcfd-45ef-a468-0854c0e9e350>2004-06-09 10:42:22 +0000
commit38ada55f16de8da0d3532fc87ba8e2fd68f96639 (patch)
tree1b3b8199333d24727db6563bc9aa0cc860c84ea8
parent3974284b1f5cfa807114302e57fdb5a5aa4acbb7 (diff)
After setup, do an initial I/O parameter parsing and warn/stop on parsing errors
(depending on IO::strict_io_parameter_check). You will also need to update CactusBase/IOUtil. git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOASCII/trunk@180 94b1c47f-dcfd-45ef-a468-0854c0e9e350
-rw-r--r--interface.ccl2
-rw-r--r--src/Output1D.c37
-rw-r--r--src/Output2D.c37
-rw-r--r--src/Output3D.c37
-rw-r--r--src/Startup.c74
-rw-r--r--src/ioASCIIGH.h7
6 files changed, 133 insertions, 61 deletions
diff --git a/interface.ccl b/interface.ccl
index d64f0e4..d0cbb25 100644
--- a/interface.ccl
+++ b/interface.ccl
@@ -4,7 +4,7 @@
implements: IOASCII
### FIXME: need private inheritance in order to be implementation-compatible
### with CarpetIOASCII
-#inherits: CoordBase IO
+#inherits: IO
CCTK_INT FUNCTION \
Hyperslab_GetList (CCTK_POINTER_TO_CONST IN cctkGH, \
diff --git a/src/Output1D.c b/src/Output1D.c
index 34f3477..9e3b538 100644
--- a/src/Output1D.c
+++ b/src/Output1D.c
@@ -26,7 +26,6 @@ CCTK_FILEVERSION(CactusBase_IOASCII_Output1D_c)
******************** Internal Routines ************************
********************************************************************/
static int CheckOutputVar (int vindex);
-static void CheckSteerableParameters (asciiioGH *myGH);
static void SetOutputFlag (int vindex, const char *optstring, void *arg);
@@ -165,7 +164,7 @@ int IOASCII_TimeFor1D (const cGH *GH, int vindex)
myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII");
- CheckSteerableParameters (myGH);
+ IOASCII_CheckSteerableParameters1D (myGH);
/* check if this variable should be output */
retval = myGH->out1D_every[vindex] > 0 &&
@@ -232,9 +231,22 @@ int IOASCII_TriggerOutput1D (const cGH *GH, int vindex)
}
-/**************************** local functions ******************************/
-/* check if steerable parameters have changed */
-static void CheckSteerableParameters (asciiioGH *myGH)
+/*@@
+ @routine IOASCII_CheckSteerableParameters1D
+ @date Tue 8 June 2004
+ @author Thomas Radke
+ @desc
+ Check if steerable IOASCII 1D parameters have changed
+ @enddesc
+ @calls CCTK_TraverseString
+
+ @var myGH
+ @vdesc Pointer to IOASCII GH
+ @vtype asciiioGH *
+ @vio inout
+ @endvar
+@@*/
+void IOASCII_CheckSteerableParameters1D (asciiioGH *myGH)
{
int i, num_vars;
char *fullname, *msg;
@@ -250,12 +262,12 @@ static void CheckSteerableParameters (asciiioGH *myGH)
{
if (myGH->out1D_every_default > 0)
{
- CCTK_VInfo (CCTK_THORNSTRING, "IOASCII_1D: Periodic output every %d "
+ CCTK_VInfo (CCTK_THORNSTRING, "Periodic 1D output every %d "
"iterations", myGH->out1D_every_default);
}
else
{
- CCTK_INFO ("IOASCII_1D: Periodic output turned off");
+ CCTK_INFO ("Periodic 1D output turned off");
}
}
@@ -264,7 +276,12 @@ static void CheckSteerableParameters (asciiioGH *myGH)
{
num_vars = CCTK_NumVars ();
memset (myGH->out1D_every, 0, num_vars * sizeof (CCTK_INT));
- CCTK_TraverseString (out1D_vars, SetOutputFlag, myGH, CCTK_GROUP_OR_VAR);
+ if (CCTK_TraverseString (out1D_vars, SetOutputFlag, myGH,
+ CCTK_GROUP_OR_VAR) < 0)
+ {
+ CCTK_WARN (myGH->stop_on_parse_errors ? 0 : 1,
+ "error while parsing parameter 'IOASCII::out1D_vars'");
+ }
if (myGH->out1D_every_default == i || ! CCTK_Equals (verbose, "none"))
{
@@ -276,7 +293,7 @@ static void CheckSteerableParameters (asciiioGH *myGH)
fullname = CCTK_FullName (i);
if (! msg)
{
- Util_asprintf (&msg, "IOASCII_1D: Periodic output requested for "
+ Util_asprintf (&msg, "Periodic 1D output requested for "
"'%s'", fullname);
}
else
@@ -300,6 +317,7 @@ static void CheckSteerableParameters (asciiioGH *myGH)
}
+/**************************** local functions ******************************/
/* check if this variable can be output (static conditions) */
static int CheckOutputVar (int vindex)
{
@@ -338,6 +356,7 @@ static void SetOutputFlag (int vindex, const char *optstring, void *arg)
if (optstring)
{
IOUtil_ParseOutputFrequency ("1D IOASCII", "IOASCII::out1D_vars",
+ myGH->stop_on_parse_errors,
vindex, optstring,
&myGH->out1D_every[vindex]);
}
diff --git a/src/Output2D.c b/src/Output2D.c
index 8ef97a7..1771cc2 100644
--- a/src/Output2D.c
+++ b/src/Output2D.c
@@ -26,7 +26,6 @@ CCTK_FILEVERSION(CactusBase_IOASCII_Output2D_c)
******************** Internal Routines ************************
********************************************************************/
static int CheckOutputVar (int vindex);
-static void CheckSteerableParameters (asciiioGH *myGH);
static void SetOutputFlag (int vindex, const char *optstring, void *arg);
@@ -165,7 +164,7 @@ int IOASCII_TimeFor2D (const cGH *GH, int vindex)
myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII");
- CheckSteerableParameters (myGH);
+ IOASCII_CheckSteerableParameters2D (myGH);
/* check if this variable should be output */
retval = myGH->out2D_every[vindex] > 0 &&
@@ -233,9 +232,22 @@ int IOASCII_TriggerOutput2D (const cGH *GH, int vindex)
}
-/**************************** local functions ******************************/
-/* check if steerable parameters have changed */
-static void CheckSteerableParameters (asciiioGH *myGH)
+/*@@
+ @routine IOASCII_CheckSteerableParameters2D
+ @date Tue 8 June 2004
+ @author Thomas Radke
+ @desc
+ Check if steerable IOASCII 2D parameters have changed
+ @enddesc
+ @calls CCTK_TraverseString
+
+ @var myGH
+ @vdesc Pointer to IOASCII GH
+ @vtype asciiioGH *
+ @vio inout
+ @endvar
+@@*/
+void IOASCII_CheckSteerableParameters2D (asciiioGH *myGH)
{
int i, num_vars;
char *fullname, *msg;
@@ -251,12 +263,12 @@ static void CheckSteerableParameters (asciiioGH *myGH)
{
if (myGH->out2D_every_default > 0)
{
- CCTK_VInfo (CCTK_THORNSTRING, "IOASCII_2D: Periodic output every %d "
+ CCTK_VInfo (CCTK_THORNSTRING, "Periodic 2D output every %d "
"iterations", myGH->out2D_every_default);
}
else
{
- CCTK_INFO ("IOASCII_2D: Periodic output turned off");
+ CCTK_INFO ("Periodic 2D output turned off");
}
}
@@ -265,7 +277,12 @@ static void CheckSteerableParameters (asciiioGH *myGH)
{
num_vars = CCTK_NumVars ();
memset (myGH->out2D_every, 0, num_vars * sizeof (CCTK_INT));
- CCTK_TraverseString (out2D_vars, SetOutputFlag, myGH, CCTK_GROUP_OR_VAR);
+ if (CCTK_TraverseString (out2D_vars, SetOutputFlag, myGH,
+ CCTK_GROUP_OR_VAR) < 0)
+ {
+ CCTK_WARN (myGH->stop_on_parse_errors ? 0 : 1,
+ "error while parsing parameter 'IOASCII::out2D_vars'");
+ }
if (myGH->out2D_every_default == i || ! CCTK_Equals (verbose, "none"))
{
@@ -277,7 +294,7 @@ static void CheckSteerableParameters (asciiioGH *myGH)
fullname = CCTK_FullName (i);
if (! msg)
{
- Util_asprintf (&msg, "IOASCII_2D: Periodic output requested for "
+ Util_asprintf (&msg, "Periodic 2D output requested for "
"'%s'", fullname);
}
else
@@ -301,6 +318,7 @@ static void CheckSteerableParameters (asciiioGH *myGH)
}
+/**************************** local functions ******************************/
/* check if this variable can be output (static conditions) */
static int CheckOutputVar (int vindex)
{
@@ -350,6 +368,7 @@ static void SetOutputFlag (int vindex, const char *optstring, void *arg)
if (optstring)
{
IOUtil_ParseOutputFrequency ("2D IOASCII", "IOASCII::out2D_vars",
+ myGH->stop_on_parse_errors,
vindex, optstring,
&myGH->out2D_every[vindex]);
}
diff --git a/src/Output3D.c b/src/Output3D.c
index 1532fa5..84d6d94 100644
--- a/src/Output3D.c
+++ b/src/Output3D.c
@@ -26,7 +26,6 @@ CCTK_FILEVERSION(CactusBase_IOASCII_Output3D_c)
******************** Internal Routines ************************
********************************************************************/
static int CheckOutputVar (int vindex);
-static void CheckSteerableParameters (asciiioGH *myGH);
static void SetOutputFlag (int vindex, const char *optstring, void *arg);
@@ -165,7 +164,7 @@ int IOASCII_TimeFor3D (const cGH *GH, int vindex)
myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII");
- CheckSteerableParameters (myGH);
+ IOASCII_CheckSteerableParameters3D (myGH);
/* check if this variable should be output */
retval = myGH->out3D_every[vindex] > 0 &&
@@ -233,9 +232,22 @@ int IOASCII_TriggerOutput3D (const cGH *GH, int vindex)
}
-/**************************** local functions ******************************/
-/* check if steerable parameters have changed */
-static void CheckSteerableParameters (asciiioGH *myGH)
+/*@@
+ @routine IOASCII_CheckSteerableParameters3D
+ @date Tue 8 June 2004
+ @author Thomas Radke
+ @desc
+ Check if steerable IOASCII 3D parameters have changed
+ @enddesc
+ @calls CCTK_TraverseString
+
+ @var myGH
+ @vdesc Pointer to IOASCII GH
+ @vtype asciiioGH *
+ @vio inout
+ @endvar
+@@*/
+void IOASCII_CheckSteerableParameters3D (asciiioGH *myGH)
{
int i, num_vars;
char *fullname, *msg;
@@ -251,12 +263,12 @@ static void CheckSteerableParameters (asciiioGH *myGH)
{
if (myGH->out3D_every_default > 0)
{
- CCTK_VInfo (CCTK_THORNSTRING, "IOASCII_3D: Periodic output every %d "
+ CCTK_VInfo (CCTK_THORNSTRING, "Periodic 3D output every %d "
"iterations", myGH->out3D_every_default);
}
else
{
- CCTK_INFO ("IOASCII_3D: Periodic output turned off");
+ CCTK_INFO ("Periodic 3D output turned off");
}
}
@@ -265,7 +277,12 @@ static void CheckSteerableParameters (asciiioGH *myGH)
{
num_vars = CCTK_NumVars ();
memset (myGH->out3D_every, 0, num_vars * sizeof (CCTK_INT));
- CCTK_TraverseString (out3D_vars, SetOutputFlag, myGH, CCTK_GROUP_OR_VAR);
+ if (CCTK_TraverseString (out3D_vars, SetOutputFlag, myGH,
+ CCTK_GROUP_OR_VAR) < 0)
+ {
+ CCTK_WARN (myGH->stop_on_parse_errors ? 0 : 1,
+ "error while parsing parameter 'IOASCII::out3D_vars'");
+ }
if (myGH->out3D_every_default == i || ! CCTK_Equals (verbose, "none"))
{
@@ -277,7 +294,7 @@ static void CheckSteerableParameters (asciiioGH *myGH)
fullname = CCTK_FullName (i);
if (! msg)
{
- Util_asprintf (&msg, "IOASCII_3D: Periodic output requested for "
+ Util_asprintf (&msg, "Periodic 3D output requested for "
"'%s'", fullname);
}
else
@@ -301,6 +318,7 @@ static void CheckSteerableParameters (asciiioGH *myGH)
}
+/**************************** local functions ******************************/
/* check if this variable can be output (static conditions) */
static int CheckOutputVar (int vindex)
{
@@ -351,6 +369,7 @@ static void SetOutputFlag (int vindex, const char *optstring, void *arg)
if (optstring)
{
IOUtil_ParseOutputFrequency ("3D IOASCII", "IOASCII::out3D_vars",
+ myGH->stop_on_parse_errors,
vindex, optstring,
&myGH->out3D_every[vindex]);
}
diff --git a/src/Startup.c b/src/Startup.c
index 1f27d98..1a02ef4 100644
--- a/src/Startup.c
+++ b/src/Startup.c
@@ -2,9 +2,9 @@
@file Startup.c
@date Sat Feb 6 1999
@author Gabrielle Allen
- @desc
+ @desc
Startup routines for IOASCII.
- @enddesc
+ @enddesc
@version $Id$
@@*/
@@ -26,7 +26,7 @@ CCTK_FILEVERSION(CactusBase_IOASCII_Startup_c)
/********************************************************************
******************** Macro Definitions ************************
********************************************************************/
-#define CREATE_OUTDIR(method, dir) \
+#define CREATE_OUTDIR(dim, dir) \
{ \
const char *_dir = dir; \
\
@@ -53,13 +53,13 @@ CCTK_FILEVERSION(CactusBase_IOASCII_Startup_c)
if (i < 0) \
{ \
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, \
- "IOASCII_SetupGH: Problem creating %s output " \
- "directory '%s'", method, myGH->dir); \
+ "IOASCII_SetupGH: Problem creating directory '%s' " \
+ "for %dD output", myGH->dir, dim); \
} \
else if (i >= 0 && CCTK_Equals (verbose, "full")) \
{ \
- CCTK_VInfo (CCTK_THORNSTRING, "%s: Output to directory '%s'", \
- method, myGH->dir); \
+ CCTK_VInfo (CCTK_THORNSTRING, "%dD output to directory '%s'", \
+ dim, myGH->dir); \
} \
}
@@ -80,11 +80,11 @@ static void *IOASCII_SetupGH (tFleshConfig *config, int conv_level, cGH *GH);
@routine IOASCII_Startup
@date Sat Feb 6 1999
@author Gabrielle Allen
- @desc
+ @desc
The startup registration routine for IOASCII.
Registers the GH extensions needed for IOASCII
along with its setup routine.
- @enddesc
+ @enddesc
@calls CCTK_RegisterGHExtension
CCTK_RegisterGHExtensionSetupGH
@@*/
@@ -102,9 +102,9 @@ void IOASCII_Startup (void)
@routine IOASCII_SetupGH
@date Sat Feb 6 1999
@author Gabrielle Allen
- @desc
+ @desc
Allocates and sets up IOASCII's GH extension structure
- @enddesc
+ @enddesc
@calls CCTK_RegisterIOMethod
CCTK_RegisterIOMethodOutputGH
@@ -180,25 +180,6 @@ static void *IOASCII_SetupGH (tFleshConfig *config, int conv_level, cGH *GH)
CCTK_RegisterIOMethodTriggerOutput (i, IOASCII_TriggerOutput3D);
}
- if (! CCTK_Equals (verbose, "none"))
- {
- CCTK_INFO ("I/O Method 'IOASCII_1D' registered");
- CCTK_INFO ("IOASCII_1D: Output of 1D lines of grid functions/arrays "
- "to ASCII files");
- if (maxdim >= 2)
- {
- CCTK_INFO ("I/O Method 'IOASCII_2D' registered");
- CCTK_INFO ("IOASCII_2D: Output of 2D planes of grid functions/arrays "
- "to ASCII files");
- }
- if (maxdim >= 3)
- {
- CCTK_INFO ("I/O Method 'IOASCII_3D' registered");
- CCTK_INFO ("IOASCII_3D: Output of 3D grid functions/arrays "
- "to ASCII files");
- }
- }
-
numvars = CCTK_NumVars ();
myGH->out1D_every = malloc (numvars * sizeof (CCTK_INT));
myGH->out2D_every = malloc (numvars * sizeof (CCTK_INT));
@@ -225,10 +206,37 @@ static void *IOASCII_SetupGH (tFleshConfig *config, int conv_level, cGH *GH)
myGH->fileList_2D = NULL;
myGH->fileList_3D = NULL;
+ myGH->stop_on_parse_errors = strict_io_parameter_check;
+ if (! CCTK_Equals (verbose, "none"))
+ {
+ CCTK_INFO ("I/O Method 'IOASCII_1D' registered: output of 1D lines of grid "
+ "functions/arrays to ASCII files");
+ }
+ IOASCII_CheckSteerableParameters1D (myGH);
+ if (maxdim >= 2)
+ {
+ if (! CCTK_Equals (verbose, "none"))
+ {
+ CCTK_INFO ("I/O Method 'IOASCII_2D' registered: output of 2D planes of "
+ "grid functions/arrays to ASCII files");
+ }
+ IOASCII_CheckSteerableParameters2D (myGH);
+ }
+ if (maxdim >= 3)
+ {
+ if (! CCTK_Equals (verbose, "none"))
+ {
+ CCTK_INFO ("I/O Method 'IOASCII_3D' registered: output of 3D grid "
+ "functions/arrays to ASCII files");
+ }
+ IOASCII_CheckSteerableParameters3D (myGH);
+ }
+ myGH->stop_on_parse_errors = 0;
+
/* make sure all output directories exist */
- CREATE_OUTDIR ("IOASCII_1D", out1D_dir);
- CREATE_OUTDIR ("IOASCII_2D", out2D_dir);
- CREATE_OUTDIR ("IOASCII_3D", out3D_dir);
+ CREATE_OUTDIR (1, out1D_dir);
+ CREATE_OUTDIR (2, out2D_dir);
+ CREATE_OUTDIR (3, out3D_dir);
return (myGH);
}
diff --git a/src/ioASCIIGH.h b/src/ioASCIIGH.h
index abb2f9e..a244454 100644
--- a/src/ioASCIIGH.h
+++ b/src/ioASCIIGH.h
@@ -45,6 +45,9 @@ typedef struct IOASCIIGH
sp2xyz[maxdim][perpendicular direction] */
int **sp2xyz;
+ /* stop on I/O parameter parsing errors ? */
+ int stop_on_parse_errors;
+
} asciiioGH;
@@ -67,6 +70,10 @@ int IOASCII_Write1D (const cGH *GH, int vindex, const char *alias);
int IOASCII_Write2D (const cGH *GH, int vindex, const char *alias);
int IOASCII_Write3D (const cGH *GH, int vindex, const char *alias);
+void IOASCII_CheckSteerableParameters1D (asciiioGH *myGH);
+void IOASCII_CheckSteerableParameters2D (asciiioGH *myGH);
+void IOASCII_CheckSteerableParameters3D (asciiioGH *myGH);
+
#ifdef __cplusplus
} // extern "C"
#endif