From 50c54f5cd9648dc48090748e2859d6d76db19872 Mon Sep 17 00:00:00 2001 From: tradke Date: Wed, 9 Jun 2004 10:42:17 +0000 Subject: 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/CactusPUGHIO/IOFlexIO/trunk@326 ebee0441-1374-4afa-a3b5-247f3ba15b9a --- src/Output.c | 46 ++++++++++++++++++++-------------------------- src/Output2D.c | 31 +++++++++++++++++++++++++------ src/Startup.c | 31 +++++++++++++++++++++++-------- src/ioFlexGH.h | 6 +++++- 4 files changed, 73 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/Output.c b/src/Output.c index 4a6178d..f8698d0 100644 --- a/src/Output.c +++ b/src/Output.c @@ -22,12 +22,6 @@ static const char *rcsid = "$Header$"; CCTK_FILEVERSION(CactusPUGHIO_IOFlexIO_Output_c) -/******************************************************************** - ******************** Internal Routines ************************ - ********************************************************************/ -static void CheckSteerableParameters (const cGH *GH); - - /*@@ @routine IOFlexIO_OutputGH @date Sat March 6 1999 @@ -58,7 +52,7 @@ int IOFlexIO_OutputGH (const cGH *GH) retval = 0; - myGH = (const flexioGH *) CCTK_GHExtension (GH, "IOFlexIO"); + myGH = CCTK_GHExtension (GH, "IOFlexIO"); /* loop over all variables */ for (vindex = CCTK_NumVars () - 1; vindex >= 0; vindex--) @@ -126,12 +120,12 @@ int IOFlexIO_OutputVarAs (const cGH *GH, const char *fullname, const char*alias) } /* check whether the variable already has an I/O request entry */ - myGH = (const flexioGH *) CCTK_GHExtension (GH, "IOFlexIO"); + myGH = CCTK_GHExtension (GH, "IOFlexIO"); oneshot = myGH->requests[vindex] == NULL; if (oneshot) { IOUtil_ParseVarsForOutput (GH, CCTK_THORNSTRING, "IOFlexIO::out_vars", - fullname, 1, myGH->requests); + 0, fullname, 1, myGH->requests); } /* do the output */ @@ -155,7 +149,7 @@ int IOFlexIO_OutputVarAs (const cGH *GH, const char *fullname, const char*alias) using the IOFlexIO I/O method. @enddesc - @calls CheckSteerableParameters + @calls IOFlexIO_CheckSteerableParameters @var GH @vdesc pointer to CCTK GH @@ -178,13 +172,13 @@ int IOFlexIO_TimeFor (const cGH *GH, int vindex) { int retval; char *fullname; - const flexioGH *myGH; + flexioGH *myGH; - CheckSteerableParameters (GH); + myGH = CCTK_GHExtension (GH, "IOFlexIO"); + IOFlexIO_CheckSteerableParameters (GH, myGH); /* check if this variable should be output */ - myGH = (const flexioGH *) CCTK_GHExtension (GH, "IOFlexIO"); retval = myGH->requests[vindex] && myGH->requests[vindex]->out_every > 0 && GH->cctk_iteration % myGH->requests[vindex]->out_every == 0; if (retval) @@ -253,7 +247,7 @@ int IOFlexIO_TriggerOutput (const cGH *GH, int vindex) if (retval == 0) { /* register variable as having output this iteration */ - myGH = (const flexioGH *) CCTK_GHExtension (GH, "IOFlexIO"); + myGH = CCTK_GHExtension (GH, "IOFlexIO"); myGH->out_last[vindex] = GH->cctk_iteration; } @@ -261,11 +255,8 @@ int IOFlexIO_TriggerOutput (const cGH *GH, int vindex) } -/******************************************************************** - ******************** Internal Routines ************************ - ********************************************************************/ /*@@ - @routine CheckSteerableParameters + @routine IOFlexIO_CheckSteerableParameters @date Mon Oct 10 2000 @author Thomas Radke @desc @@ -280,17 +271,20 @@ int IOFlexIO_TriggerOutput (const cGH *GH, int vindex) @vtype const cGH * @vio in @endvar + @var myGH + @vdesc pointer to IOFlexIO GH + @vtype flexioGH * + @vio inout + @endvar @@*/ -static void CheckSteerableParameters (const cGH *GH) +void IOFlexIO_CheckSteerableParameters (const cGH *GH, flexioGH *myGH) { int i, vindex, num_vars; - flexioGH *myGH; char *fullname, *msg; DECLARE_CCTK_PARAMETERS /* how often to output */ - myGH = (flexioGH *) CCTK_GHExtension (GH, "IOFlexIO"); i = myGH->out_every_default; myGH->out_every_default = out_every >= 0 ? out_every : io_out_every; @@ -299,12 +293,12 @@ static void CheckSteerableParameters (const cGH *GH) { if (myGH->out_every_default > 0) { - CCTK_VInfo (CCTK_THORNSTRING, "IOFlexIO: Periodic output every %d " + CCTK_VInfo (CCTK_THORNSTRING, "Periodic IOFlexIO output every %d " "iterations", myGH->out_every_default); } else { - CCTK_INFO ("IOFlexIO: Periodic output turned off"); + CCTK_INFO ("Periodic IOFlexIO output turned off"); } } @@ -312,8 +306,8 @@ static void CheckSteerableParameters (const cGH *GH) if (strcmp (out_vars, myGH->out_vars) || myGH->out_every_default != i) { IOUtil_ParseVarsForOutput (GH, CCTK_THORNSTRING, "IOFlexIO::out_vars", - out_vars, myGH->out_every_default, - myGH->requests); + myGH->stop_on_parse_errors, 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. @@ -346,7 +340,7 @@ static void CheckSteerableParameters (const cGH *GH) fullname = CCTK_FullName (vindex); if (! msg) { - Util_asprintf (&msg, "IOFlexIO: Periodic output requested for '%s'", + Util_asprintf (&msg, "Periodic IOFlexIO output requested for '%s'", fullname); } else diff --git a/src/Output2D.c b/src/Output2D.c index 8d54346..4f1ee8e 100644 --- a/src/Output2D.c +++ b/src/Output2D.c @@ -22,7 +22,6 @@ CCTK_FILEVERSION(CactusPUGHIO_IOFlexIO_Output2D_c) /* prototypes of routines defined in this source file */ static int CheckOutputVar (int vindex, int warn); -static void CheckSteerableParameters (flexioGH *myGH); static void SetOutputFlag (int vindex, const char *optstring, void *arg); @@ -161,7 +160,7 @@ int IOFlexIO_TimeFor2D (const cGH *GH, int vindex) result = 0; myGH = (flexioGH *) CCTK_GHExtension (GH, "IOFlexIO"); - CheckSteerableParameters (myGH); + IOFlexIO_CheckSteerableParameters2D (myGH); /* check if this variable should be output */ if (myGH->out2D_every[vindex] > 0 && @@ -240,9 +239,22 @@ int IOFlexIO_TriggerOutput2D (const cGH *GH, int vindex) } -/**************************** local functions ******************************/ -/* check if steerable parameters have changed */ -static void CheckSteerableParameters (flexioGH *myGH) +/*@@ + @routine IOFlexIO_CheckSteerableParameters2D + @date Tue 8 June 2004 + @author Thomas Radke + @desc + Check if steerable IOFlexIO 2D parameters have changed + @enddesc + @calls CCTK_TraverseString + + @var myGH + @vdesc Pointer to IOFlexIO GH + @vtype flexioGH * + @vio inout + @endvar +@@*/ +void IOFlexIO_CheckSteerableParameters2D (flexioGH *myGH) { int i, num_vars; char *fullname, *msg; @@ -272,7 +284,12 @@ static void CheckSteerableParameters (flexioGH *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 'IOFlexIO::out2D_vars'"); + } if (myGH->out2D_every_default == i || ! CCTK_Equals (verbose, "none")) { @@ -308,6 +325,7 @@ static void CheckSteerableParameters (flexioGH *myGH) } +/**************************** local functions ******************************/ /* check if this variable can be output (static conditions) */ static int CheckOutputVar (int vindex, int warn) { @@ -344,6 +362,7 @@ static void SetOutputFlag (int vindex, const char *optstring, void *arg) if (optstring) { IOUtil_ParseOutputFrequency ("2D IOFlexIO", "IOFlexIO::out2D_vars", + myGH->stop_on_parse_errors, vindex, optstring, &myGH->out2D_every[vindex]); } diff --git a/src/Startup.c b/src/Startup.c index a11cda6..9861f3e 100644 --- a/src/Startup.c +++ b/src/Startup.c @@ -247,7 +247,7 @@ static void *SetupGH (tFleshConfig *config, int conv_level, cGH *GH) /* allocate a new GH extension structure */ numvars = CCTK_NumVars (); myGH = malloc (sizeof (flexioGH)); - myGH->requests = calloc (numvars, sizeof (ioRequest *)); + myGH->requests = calloc (numvars, sizeof (ioRequest *)); myGH->out2D_every = malloc (numvars * sizeof (CCTK_INT)); myGH->out_last = malloc (numvars * sizeof (int)); myGH->out2D_last = malloc (numvars * sizeof (int)); @@ -258,6 +258,28 @@ static void *SetupGH (tFleshConfig *config, int conv_level, cGH *GH) myGH->out2D_every_default = out2D_every - 1; myGH->last_checkpoint_iteration = -1; + for (i = 0; i < numvars; i++) + { + myGH->out2D_last[i] = myGH->out_last[i] = -1; + } + + myGH->fileList_2D = myGH->fileList = NULL; + + myGH->stop_on_parse_errors = strict_io_parameter_check; + if (! CCTK_Equals (verbose, "none")) + { + CCTK_INFO ("I/O Method 'IOFlexIO' registered: output of grid variables and " + "hyperslabs thereof to IEEEIO files"); + } + IOFlexIO_CheckSteerableParameters (GH, myGH); + if (! CCTK_Equals (verbose, "none")) + { + CCTK_INFO ("I/O Method 'IOFlexIO_2D' registered: 2D output of grid " + "functions/arrays to IEEEIO files"); + } + IOFlexIO_CheckSteerableParameters2D (myGH); + myGH->stop_on_parse_errors = 0; + /* get the names of output directories */ myGH->out2D_dir = strdup (*out2D_dir ? out2D_dir : io_out_dir); myGH->out_dir = strdup (*out_dir ? out_dir : io_out_dir); @@ -298,13 +320,6 @@ static void *SetupGH (tFleshConfig *config, int conv_level, cGH *GH) "already exists", myGH->out_dir); } - for (i = 0; i < numvars; i++) - { - myGH->out2D_last[i] = myGH->out_last[i] = -1; - } - - myGH->fileList_2D = myGH->fileList = NULL; - /* create timers if timing info was requested */ myGH->print_timing_info = print_timing_info; if (myGH->print_timing_info) diff --git a/src/ioFlexGH.h b/src/ioFlexGH.h index a92ea7e..5edf70a 100644 --- a/src/ioFlexGH.h +++ b/src/ioFlexGH.h @@ -144,6 +144,9 @@ typedef struct IOFlexIOGH /* iteration number of the last checkpoint */ int last_checkpoint_iteration; + /* stop on I/O parameter parsing errors ? */ + int stop_on_parse_errors; + } flexioGH; @@ -166,5 +169,6 @@ void IOFlexIOi_DumpParameters (const cGH *GH, int all, IOFile file); void IOFlexIOi_DumpGHExtensions (const cGH *GH, IOFile file); int IOFlexIO_Recover (cGH *GH, const char *basefilename, int called_from); int IOFlexIOi_RecoverVariables (cGH *GH, fileinfo_t *file); - +void IOFlexIO_CheckSteerableParameters (const cGH *GH, flexioGH *myGH); +void IOFlexIO_CheckSteerableParameters2D (flexioGH *myGH); #endif /* _IOFLEXIO_IOFLEXGH_H_ */ -- cgit v1.2.3