From f04e11298bf914d8275f1ab6b67141b66c72f94b Mon Sep 17 00:00:00 2001 From: tradke Date: Wed, 23 Jun 2004 08:57:31 +0000 Subject: Parse the 'IO::filereader_ID_vars' parameter for invalid variable/group names. git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOUtil/trunk@210 b32723a9-ab3a-4a60-88e2-2e5d99d7c17a --- src/CheckpointRecovery.c | 12 ++++++-- src/Startup.c | 75 ++++++++++++++++++++++-------------------------- src/ioGH.h | 3 +- 3 files changed, 47 insertions(+), 43 deletions(-) diff --git a/src/CheckpointRecovery.c b/src/CheckpointRecovery.c index 3055940..e1d7cb1 100644 --- a/src/CheckpointRecovery.c +++ b/src/CheckpointRecovery.c @@ -396,8 +396,12 @@ int IOUtil_RecoverVarsFromDatafiles (cGH *GH, if (CCTK_NumVars () > 0) { myGH->do_inVars = calloc (CCTK_NumVars (), sizeof (CCTK_INT)); - CCTK_TraverseString (in_vars, SetInputFlag, myGH->do_inVars, - CCTK_GROUP_OR_VAR); + if (CCTK_TraverseString (in_vars, SetInputFlag, myGH->do_inVars, + CCTK_GROUP_OR_VAR) < 0) + { + CCTK_WARN (myGH->stop_on_parse_errors ? 0 : 1, + "error while parsing parameter 'IO::filereader_ID_vars'"); + } } else { @@ -488,10 +492,14 @@ void CCTK_FCALL CCTK_FNAME (IOUtil_RecoverVarsFromDatafiles) @@*/ void IOUtil_RecoverIDFromDatafiles (cGH *GH) { + ioGH *myGH; DECLARE_CCTK_PARAMETERS + myGH = CCTK_GHExtension (GH, "IO"); + myGH->stop_on_parse_errors = strict_io_parameter_check; IOUtil_RecoverVarsFromDatafiles (GH, filereader_ID_files, filereader_ID_vars); + myGH->stop_on_parse_errors = 0; } diff --git a/src/Startup.c b/src/Startup.c index 2dc7d1c..44f82ef 100644 --- a/src/Startup.c +++ b/src/Startup.c @@ -180,7 +180,7 @@ int IOUtil_UpdateParFile (const cGH *GH) static void *SetupGH (tFleshConfig *config, int convergence_level, cGH *GH) { int i, maxdim, myproc; - ioGH *newGH; + ioGH *myGH; DECLARE_CCTK_PARAMETERS @@ -188,8 +188,8 @@ static void *SetupGH (tFleshConfig *config, int convergence_level, cGH *GH) convergence_level = convergence_level; myproc = CCTK_MyProc (GH); - newGH = (ioGH *) malloc (sizeof (ioGH)); - if (! newGH) + myGH = calloc (1, sizeof (ioGH)); + if (! myGH) { CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, "Couldn't allocate GH extension structure for IOUtil"); @@ -198,52 +198,47 @@ static void *SetupGH (tFleshConfig *config, int convergence_level, cGH *GH) if (CCTK_Equals (out_mode, "proc")) { - newGH->ioproc = myproc; - newGH->nioprocs = CCTK_nProcs (GH); - newGH->ioproc_every = 1; + myGH->ioproc = myproc; + myGH->nioprocs = CCTK_nProcs (GH); + myGH->ioproc_every = 1; } else if (CCTK_Equals (out_mode, "np")) { + myGH->ioproc_every = out_proc_every; if (out_proc_every > CCTK_nProcs (GH)) { - newGH->ioproc_every = CCTK_nProcs (GH); + myGH->ioproc_every = CCTK_nProcs (GH); CCTK_VInfo (CCTK_THORNSTRING, "Reducing 'IO::out_proc_every' to %d", - newGH->ioproc_every); - } - else - { - newGH->ioproc_every = out_proc_every; + myGH->ioproc_every); } - newGH->nioprocs = CCTK_nProcs (GH) / newGH->ioproc_every + - (CCTK_nProcs (GH) % newGH->ioproc_every ? 1 : 0); - newGH->ioproc = myproc - (myproc % newGH->ioproc_every); + myGH->nioprocs = CCTK_nProcs (GH) / myGH->ioproc_every + + (CCTK_nProcs (GH) % myGH->ioproc_every ? 1 : 0); + myGH->ioproc = myproc - (myproc % myGH->ioproc_every); } else /* IO::out_mode = "onefile" */ { - newGH->ioproc = 0; - newGH->nioprocs = 1; - newGH->ioproc_every = CCTK_nProcs (GH); + myGH->ioproc = 0; + myGH->nioprocs = 1; + myGH->ioproc_every = CCTK_nProcs (GH); } /* For now we can only have unchunked for a single output file */ + myGH->unchunked = 0; if (out_unchunked || CCTK_nProcs (GH) == 1) { - if (newGH->ioproc_every >= CCTK_nProcs (GH)) + if (myGH->ioproc_every >= CCTK_nProcs (GH)) { - newGH->unchunked = 1; + myGH->unchunked = 1; } else { CCTK_INFO ("Unchunked output not supported for multiple " "output files. Output will be chunked."); - newGH->unchunked = 0; } } - else - { - newGH->unchunked = 0; - } + + myGH->stop_on_parse_errors = 0; /* create the default output and checkpoint directories */ i = IOUtil_CreateDirectory (GH, out_dir, 0, 0); @@ -259,7 +254,7 @@ static void *SetupGH (tFleshConfig *config, int convergence_level, cGH *GH) } i = IOUtil_CreateDirectory (GH, checkpoint_dir, ! CCTK_Equals (out_mode, "onefile"), - newGH->ioproc); + myGH->ioproc); if (i < 0) { CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, @@ -277,48 +272,48 @@ static void *SetupGH (tFleshConfig *config, int convergence_level, cGH *GH) /* for now we have only parameters for the first 3 dimensions the rest is constantly initialized to 1 */ maxdim = CCTK_MaxDim (); - newGH->downsample = (int *) malloc (maxdim * sizeof (int)); + myGH->downsample = malloc (maxdim * sizeof (int)); switch (maxdim > 3 ? 3 : maxdim) { - case 3 : newGH->downsample [2] = out_downsample_z; - case 2 : newGH->downsample [1] = out_downsample_y; - case 1 : newGH->downsample [0] = out_downsample_x; + case 3 : myGH->downsample[2] = out_downsample_z; + case 2 : myGH->downsample[1] = out_downsample_y; + case 1 : myGH->downsample[0] = out_downsample_x; } for (i = 3; i < maxdim; i++) { - newGH->downsample [i] = 1; + myGH->downsample[i] = 1; } /* evaluate the 'IO::out_single_precision' parameter only if Cactus was compiled with double precision */ #ifdef SINGLE_PRECISION - newGH->out_single = 0; + myGH->out_single = 0; #else - newGH->out_single = out_single_precision; + myGH->out_single = out_single_precision; #endif /* copy the 'recovered' flag to this GH extension */ - newGH->recovered = config->recovered; + myGH->recovered = config->recovered; /* reset the flags array for the file reader */ - newGH->do_inVars = NULL; + myGH->do_inVars = NULL; /* write the parameter file if requested */ if (myproc == 0) { if (CCTK_Equals (parfile_write, "copy")) { - CopyParFile (newGH->recovered); + CopyParFile (myGH->recovered); } else if (CCTK_Equals (parfile_write, "generate")) { - GenerateParFile (newGH->recovered); + GenerateParFile (myGH->recovered); } } - return (newGH); + return (myGH); } @@ -328,7 +323,7 @@ static void *SetupGH (tFleshConfig *config, int convergence_level, cGH *GH) @author Thomas Radke @desc Copies the original parameter file to a new one in 'IO::out_dir'. - Note that the new parameter file will usually overwrite an + Note that the new parameter file will usually overwrite an existing file unless - the new parameter file is identical with the original one - this is a recovery run @@ -638,7 +633,7 @@ static int DumpParameters (FILE *outfile) /* skip the parameters which weren't explicitely set */ if (pdata->n_set > 0) { - new = (t_param_list *) malloc (sizeof (t_param_list)); + new = malloc (sizeof (t_param_list)); if (new) { new->value = CCTK_ParameterValString (pdata->name, pdata->thorn); diff --git a/src/ioGH.h b/src/ioGH.h index b3e4791..998e6bf 100644 --- a/src/ioGH.h +++ b/src/ioGH.h @@ -20,7 +20,7 @@ extern "C" /* IOUtil's GH extension structure */ typedef struct { - /* for 3D output */ + /* for full-dimensional parallel output */ int ioproc; /* the I/O processor each proc belongs to */ int nioprocs; /* total number of I/O processors */ int ioproc_every; /* output by every N'th processor */ @@ -30,6 +30,7 @@ typedef struct /* for recovery */ int recovered; /* flag indicating restart after successful recovery */ + int stop_on_parse_errors; /* stop on I/O parameter parsing errors ? */ /* for data file reader */ CCTK_INT *do_inVars; /* flags indicating to read in variable i with -- cgit v1.2.3