aboutsummaryrefslogtreecommitdiff
path: root/src/Utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/Utils.c')
-rw-r--r--src/Utils.c45
1 files changed, 33 insertions, 12 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);
}