From 5bd25031160e9e8d0d7438a85f966d9f5988e926 Mon Sep 17 00:00:00 2001 From: tradke Date: Wed, 9 Jun 2004 10:41:29 +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/CactusIO/IOJpeg/trunk@100 eff87b29-5268-4891-90a3-a07138403961 --- src/Output.c | 49 +++++++++++++++++++++++++++++++++++-------------- src/Startup.c | 11 +++++++---- src/ioJpegGH.h | 4 ++++ 3 files changed, 46 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/Output.c b/src/Output.c index 144a74f..7241277 100644 --- a/src/Output.c +++ b/src/Output.c @@ -29,7 +29,6 @@ CCTK_FILEVERSION(CactusIO_IOJpeg_Output_c) ******************** Internal Routines ************************ ********************************************************************/ static int CheckOutputVar (int vindex); -static void CheckSteerableParameters (ioJpegGH *myGH); static void SetOutputFlag (int vindex, const char *optstring, void *arg); @@ -62,7 +61,7 @@ int IOJpeg_OutputGH (const cGH *GH) retval = 0; - myGH = (const ioJpegGH *) CCTK_GHExtension (GH, "IOJpeg"); + myGH = CCTK_GHExtension (GH, "IOJpeg"); /* loop over all variables */ for (vindex = CCTK_NumVars () - 1; vindex >= 0; vindex--) @@ -162,8 +161,8 @@ int IOJpeg_TimeFor (const cGH *GH, int vindex) ioJpegGH *myGH; - myGH = (ioJpegGH *) CCTK_GHExtension (GH, "IOJpeg"); - CheckSteerableParameters (myGH); + myGH = CCTK_GHExtension (GH, "IOJpeg"); + IOJpeg_CheckSteerableParameters (myGH); /* check if this variable should be output */ result = myGH->out_every[vindex] > 0 && @@ -222,7 +221,7 @@ int IOJpeg_TriggerOutput (const cGH *GH, int vindex) if (retval == 0) { /* register variable as having output this iteration */ - myGH = (const ioJpegGH *) CCTK_GHExtension (GH, "IOJpeg"); + myGH = CCTK_GHExtension (GH, "IOJpeg"); myGH->out_last[vindex] = GH->cctk_iteration; } @@ -230,11 +229,24 @@ int IOJpeg_TriggerOutput (const cGH *GH, int vindex) } -/******************************************************************** - ******************** Internal Routines ************************ - ********************************************************************/ -/* check if steerable parameters have changed */ -static void CheckSteerableParameters (ioJpegGH *myGH) +/*@@ + @routine IOJpeg_CheckSteerableParameters + @date Mon Oct 10 2000 + @author Thomas Radke + @desc + Checks if IOJpeg steerable parameters were changed + and does appropriate re-evaluation. + @enddesc + + @calls CCTK_TraverseString + + @var myGH + @vdesc pointer to IOJpeg grid hierarchy + @vtype ioJpegG * + @vio inout + @endvar +@@*/ +void IOJpeg_CheckSteerableParameters (ioJpegGH *myGH) { int i, num_vars; char *fullname, *msg; @@ -250,12 +262,12 @@ static void CheckSteerableParameters (ioJpegGH *myGH) { if (myGH->out_every_default > 0) { - CCTK_VInfo (CCTK_THORNSTRING, "IOJpeg: Periodic output every %d " + CCTK_VInfo (CCTK_THORNSTRING, "Periodic IOJpeg output every %d " "iterations", myGH->out_every_default); } else { - CCTK_INFO ("IOJpeg: Periodic output turned off"); + CCTK_INFO ("Periodic IOJpeg output turned off"); } } @@ -264,7 +276,12 @@ static void CheckSteerableParameters (ioJpegGH *myGH) { num_vars = CCTK_NumVars (); memset (myGH->out_every, 0, num_vars * sizeof (CCTK_INT)); - CCTK_TraverseString (out_vars, SetOutputFlag, myGH, CCTK_GROUP_OR_VAR); + if (CCTK_TraverseString (out_vars, SetOutputFlag, myGH, + CCTK_GROUP_OR_VAR) < 0) + { + CCTK_WARN (myGH->stop_on_parse_errors ? 0 : 1, + "error while parsing parameter 'IOJpeg::out_vars'"); + } if (myGH->out_every_default == i || ! CCTK_Equals (verbose, "none")) { @@ -276,7 +293,7 @@ static void CheckSteerableParameters (ioJpegGH *myGH) fullname = CCTK_FullName (i); if (! msg) { - Util_asprintf (&msg, "IOJpeg: Periodic output requested for '%s'", + Util_asprintf (&msg, "Periodic IOJpeg output requested for '%s'", fullname); } else @@ -300,6 +317,9 @@ static void CheckSteerableParameters (ioJpegGH *myGH) } +/******************************************************************** + ******************** Internal Routines ************************ + ********************************************************************/ /* check if this variable can be output (static conditions) */ static int CheckOutputVar (int vindex) { @@ -353,6 +373,7 @@ static void SetOutputFlag (int vindex, const char *optstring, void *arg) if (optstring) { IOUtil_ParseOutputFrequency (CCTK_THORNSTRING, "IOJpeg::out_vars", + myGH->stop_on_parse_errors, vindex, optstring, &myGH->out_every[vindex]); } diff --git a/src/Startup.c b/src/Startup.c index 4d1cb19..185e2a0 100644 --- a/src/Startup.c +++ b/src/Startup.c @@ -122,15 +122,18 @@ static void *SetupGH (tFleshConfig *config, int conv_level, cGH *GH) CCTK_RegisterIOMethodTimeToOutput (i, IOJpeg_TimeFor); CCTK_RegisterIOMethodTriggerOutput (i, IOJpeg_TriggerOutput); + myGH->stop_on_parse_errors = strict_io_parameter_check; if (! CCTK_Equals (verbose, "none")) { - CCTK_INFO ("I/O Method 'IOJpeg' registered"); - CCTK_INFO ("IOJpeg: Output of 2D jpeg images of grid functions/arrays"); + CCTK_INFO ("I/O Method 'IOJpeg' registered: output of 2D jpeg images of " + "grid functions/arrays"); } + IOJpeg_CheckSteerableParameters (myGH); + myGH->stop_on_parse_errors = 0; numvars = CCTK_NumVars (); - myGH->out_every = (CCTK_INT *) malloc (numvars * sizeof (CCTK_INT)); - myGH->out_last = (int *) malloc (numvars * sizeof (int)); + myGH->out_every = malloc (numvars * sizeof (CCTK_INT)); + myGH->out_last = malloc (numvars * sizeof (int)); for (i = 0; i < numvars; i++) { diff --git a/src/ioJpegGH.h b/src/ioJpegGH.h index 94c0f66..868f945 100644 --- a/src/ioJpegGH.h +++ b/src/ioJpegGH.h @@ -36,6 +36,9 @@ typedef struct IOJpegGH sp2xyz[maxdim][perpendicular direction] */ int **sp2xyz; + /* stop on I/O parameter parsing errors ? */ + int stop_on_parse_errors; + } ioJpegGH; @@ -47,6 +50,7 @@ int IOJpeg_TriggerOutput (const cGH *GH, int vindex); /* other function prototypes */ int IOJpeg_Write (const cGH *GH, CCTK_INT vindex, const char *alias); +void IOJpeg_CheckSteerableParameters (ioJpegGH *myGH); /* routines called from JPEG.c */ int WriteJPEGToFileRGB (int nx, int ny, void *data, int Quality, FILE* outfile); -- cgit v1.2.3