From 1467cab6433118c32f1717579ad1e007fdc9bde6 Mon Sep 17 00:00:00 2001 From: tradke Date: Wed, 9 Jun 2004 10:41:23 +0000 Subject: Extended API for IOUtil_ParseOutputFrequency() and IOUtil_ParseVarsForOutput() by a flag parameter indicating whether to stop on parsing errors. Requires cvs updates of all I/O thorns using this API. git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOUtil/trunk@209 b32723a9-ab3a-4a60-88e2-2e5d99d7c17a --- src/Utils.c | 45 +++++++++++++++++++++++++++++++++------------ src/ioutil_Utils.h | 4 +++- 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/src/Utils.c b/src/Utils.c index 4d1cd1b..653130e 100644 --- a/src/Utils.c +++ b/src/Utils.c @@ -79,6 +79,12 @@ static void SetOutputVar (int vindex, const char *optstring, void *arg); @vtype const char * @vio in @endvar + @var stop_on_parse_errors + @vdesc flag indicating whether stop with a level-0 warning message + on parsing errors + @vtype int + @vio in + @endvar @var out_vars @vdesc string with list of variables and/or group names to parse @vtype const char * @@ -97,6 +103,7 @@ static void SetOutputVar (int vindex, const char *optstring, void *arg); @@*/ void IOUtil_ParseVarsForOutput (const cGH *GH, const char *method_name, const char *parameter_name, + int stop_on_parse_errors, const char *out_vars, int out_every_default, ioRequest *request_list[]) { @@ -119,7 +126,12 @@ void IOUtil_ParseVarsForOutput (const cGH *GH, const char *method_name, info.method_name = method_name; info.parameter_name = parameter_name; info.out_every_default = out_every_default; - CCTK_TraverseString (out_vars, SetOutputVar, &info, CCTK_GROUP_OR_VAR); + if (CCTK_TraverseString (out_vars, SetOutputVar, &info, CCTK_GROUP_OR_VAR)<0) + { + CCTK_VWarn (stop_on_parse_errors ? 0 : 1, + __LINE__, __FILE__, CCTK_THORNSTRING, + "error while parsing parameter '%s'", parameter_name); + } } @@ -166,7 +178,13 @@ void IOUtil_FreeIORequest (ioRequest **request) @vtype const char * @vio in @endvar - @var index + @var stop_on_parse_errors + @vdesc flag indicating whether to stop with level-0 warning message + on a parsing error + @vtype int + @vio in + @endvar + @var vindex @vdesc index of the variable to set the output frequency @vtype int @vio in @@ -176,7 +194,7 @@ void IOUtil_FreeIORequest (ioRequest **request) @vtype const char * @vio in @endvar - @var out_every + @var out_every_ptr @vdesc pointer to the variable's output frequency flag @vtype int * @vio out @@ -184,15 +202,18 @@ void IOUtil_FreeIORequest (ioRequest **request) @@*/ void IOUtil_ParseOutputFrequency (const char *method_name, const char *parameter_name, + int stop_on_parse_errors, int vindex, const char *optstring, - CCTK_INT *out_every) + CCTK_INT *out_every_ptr) { - int table, iterator; + int table, iterator, warnlevel; char key[128]; char *fullname; CCTK_INT type, nelems; + DECLARE_CCTK_PARAMETERS + warnlevel = stop_on_parse_errors ? 0 : 1; fullname = CCTK_FullName (vindex); table = Util_TableCreateFromString (optstring); if (table >= 0) @@ -201,15 +222,15 @@ void IOUtil_ParseOutputFrequency (const char *method_name, { if (type == CCTK_VARIABLE_INT && nelems == 1) { - Util_TableGetInt (table, out_every, "out_every"); + Util_TableGetInt (table, out_every_ptr, "out_every"); } else { - CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + CCTK_VWarn (warnlevel, __LINE__, __FILE__, CCTK_THORNSTRING, "Invalid value for option 'out_every' in option string " "'%s' in parameter '%s' (must be an integer)", optstring, parameter_name); - CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + CCTK_VWarn (warnlevel, __LINE__, __FILE__, CCTK_THORNSTRING, "Option will be ignored for %s output of variable '%s'", method_name, fullname); } @@ -223,11 +244,11 @@ void IOUtil_ParseOutputFrequency (const char *method_name, Util_TableItQueryKeyValueInfo (iterator, sizeof (key), key, 0, 0) > 0; Util_TableItAdvance (iterator)) { - CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + CCTK_VWarn (warnlevel, __LINE__, __FILE__, CCTK_THORNSTRING, "Found option with unrecognized key '%s' in option string " "'%s' in parameter '%s'", key, optstring, parameter_name); - CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + CCTK_VWarn (warnlevel, __LINE__, __FILE__, CCTK_THORNSTRING, "Option will be ignored for %s output of variable '%s'", method_name, fullname); } @@ -237,10 +258,10 @@ void IOUtil_ParseOutputFrequency (const char *method_name, } else { - CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + CCTK_VWarn (warnlevel, __LINE__, __FILE__, CCTK_THORNSTRING, "Couldn't parse option string '%s' in parameter '%s'", optstring, parameter_name); - CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + CCTK_VWarn (warnlevel, __LINE__, __FILE__, CCTK_THORNSTRING, "Option string will be ignored for %s output of variable '%s'", method_name, fullname); } diff --git a/src/ioutil_Utils.h b/src/ioutil_Utils.h index 349b2b3..f239c44 100644 --- a/src/ioutil_Utils.h +++ b/src/ioutil_Utils.h @@ -2,7 +2,7 @@ @header ioutil_Utils.h @date Tue 19 Sep 2000 @author Thomas Radke - @desc + @desc Function prototypes for setting up slice centers. @enddesc @version $Header$ @@ -54,12 +54,14 @@ typedef struct /* parse a given 'out_vars' parameter string */ void IOUtil_ParseVarsForOutput (const cGH *GH, const char *method_name, const char *parameter_name, + int stop_on_parse_errors, const char *out_vars, int out_every_default, ioRequest *request_list[]); /* parse a given I/O parameter option string for the 'out_every' option */ void IOUtil_ParseOutputFrequency (const char *method_name, const char *parameter_name, + int stop_on_parse_errors, int vindex, const char *optstring, CCTK_INT *out_every); -- cgit v1.2.3