diff options
author | tradke <tradke@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2005-10-24 13:46:03 +0000 |
---|---|---|
committer | tradke <tradke@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2005-10-24 13:46:03 +0000 |
commit | 023b6e12a846844b444cd189cd8b27db53861774 (patch) | |
tree | 2e887a0e0d2dde15e1ec2fb8d897b0d2a97b9ad0 /src/main | |
parent | 9f8245728e5967f6bd1df5b215783b8133b52273 (diff) |
Apply patch http://www.cactuscode.org/old/pipermail/patches/2005-October/000112.html:
Check if there is more than one assignment to a
parameter in the parfile and will print a warning with line number
information in such a case. It checks both for multiple parameter
assignments of the same or a different value.
Depending on the parameter checking level (as set via the command line
option '-parameter-level {strict|normal|relaxed}') the flesh will also
abort the run after printing the warning in the following two cases:
* the parameter level is "normal" (which is the default) or "strict"
and there are multiple assignments of different values
* the parameter level is "strict" and there are multiple assignments
of the same value
git-svn-id: http://svn.cactuscode.org/flesh/trunk@4188 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/Parameters.c | 40 | ||||
-rw-r--r-- | src/main/SetParams.c | 79 |
2 files changed, 87 insertions, 32 deletions
diff --git a/src/main/Parameters.c b/src/main/Parameters.c index 696a4520..9b4bf289 100644 --- a/src/main/Parameters.c +++ b/src/main/Parameters.c @@ -516,20 +516,23 @@ void CCTKi_ParameterAccumulatorBase(const char *thorn, @returntype int @returndesc - 0 for success, or<br> + 0 for success, or<br> return code of @seeroutine ParameterSet, or<br> - -1 if parameter is out of range<br> - -2 if parameter was not found<br> - -3 if trying to steer a non-steerable parameter<br> - -6 if not a valid integer or float<br> - -7 if tried to set an accumulator parameter directly<br> - -8 if tried to set an accumulator parameter directly<br> - -9 if final value of accumulator out of range<br> + -1 if parameter is out of range<br> + -2 if parameter was not found<br> + -3 if trying to steer a non-steerable parameter<br> + -6 if not a valid integer or float<br> + -7 if tried to set an accumulator parameter directly<br> + -8 if tried to set an accumulator parameter directly<br> + -9 if final value of accumulator out of range<br> + -10 if parameter has already been set to a different value<br> + -11 if parameter has already been set to the same value<br> @endreturndesc @@*/ int CCTK_ParameterSet (const char *name, const char *thorn, const char *value) { int retval; + char *old_value, *new_value; t_param *param; param = ParameterFind (name, thorn, SCOPE_ANY); @@ -586,8 +589,29 @@ int CCTK_ParameterSet (const char *name, const char *thorn, const char *value) } else { + if (cctk_parameter_set_mask == PARAMETER_RECOVERY_PRE && + param->props->n_set > 0) + { + old_value = CCTK_ParameterValString (param->props->name, + param->props->thorn); + } + retval = ParameterSet (param, value); + /* check if a parameter is set more than once in a parfile */ + if (cctk_parameter_set_mask == PARAMETER_RECOVERY_PRE && + param->props->n_set > 0) + { + if (retval == 0) + { + new_value = CCTK_ParameterValString (param->props->name, + param->props->thorn); + retval = strcmp (old_value, new_value) ? -10 : -11; + } + free (old_value); + free (new_value); + } + /* register another set operation */ param->props->n_set++; } diff --git a/src/main/SetParams.c b/src/main/SetParams.c index 8c089d6b..c6f184f1 100644 --- a/src/main/SetParams.c +++ b/src/main/SetParams.c @@ -157,7 +157,7 @@ int CCTKi_SetParameter (const char *parameter, const char *value, int lineno) CCTK_VWarn (1, __LINE__, __FILE__, "Cactus", "Major error in parameter file '%s' line %d: " "Parameter '%s' is not " - "associated with an active thorn", + "associated with an active thorn", parfile, lineno, parameter); num_0errors++; } @@ -166,7 +166,7 @@ int CCTKi_SetParameter (const char *parameter, const char *value, int lineno) CCTK_VWarn (1, __LINE__, __FILE__, "Cactus", "Minor error in parameter file '%s' line %d: " "Parameter '%s' is not " - "associated with an active thorn", + "associated with an active thorn", parfile, lineno, parameter); num_1errors++; } @@ -177,10 +177,10 @@ int CCTKi_SetParameter (const char *parameter, const char *value, int lineno) CCTK_VWarn (1, __LINE__, __FILE__, "Cactus", "Major error in parameter file '%s' line %d: " "Error setting parameter '%s' " - "'%s' is not a valid number", + "'%s' is not a valid number", parfile, lineno, parameter, value); num_0errors++; - } + } else if (retval == -7) { /* Tried to set an accumulator parameter directly */ @@ -189,7 +189,7 @@ int CCTKi_SetParameter (const char *parameter, const char *value, int lineno) CCTK_VWarn (1, __LINE__, __FILE__, "Cactus", "Major error in parameter file '%s' line %d: " "Parameter '%s' is an " - "accumulator parameter; it cannot be set directly", + "accumulator parameter; it cannot be set directly", parfile, lineno, parameter); num_0errors++; } @@ -198,7 +198,7 @@ int CCTKi_SetParameter (const char *parameter, const char *value, int lineno) CCTK_VWarn (1, __LINE__, __FILE__, "Cactus", "Minor error in parameter file '%s' line %d: " "Parameter '%s' is an " - "accumulator parameter; it cannot be set directly", + "accumulator parameter; it cannot be set directly", parfile, lineno, parameter); num_1errors++; } @@ -211,7 +211,7 @@ int CCTKi_SetParameter (const char *parameter, const char *value, int lineno) CCTK_VWarn (1, __LINE__, __FILE__, "Cactus", "Major error in parameter file '%s' line %d: " "Parameter '%s' is an " - "array base parameter; please use %s[<number>]", + "array base parameter; please use %s[<number>]", parfile, lineno, parameter, parameter); num_0errors++; } @@ -220,20 +220,50 @@ int CCTKi_SetParameter (const char *parameter, const char *value, int lineno) CCTK_VWarn (1, __LINE__, __FILE__, "Cactus", "Minor error in parameter file '%s' line %d: " "Parameter '%s' is an " - "array base parameter; please use %s[<number>]", + "array base parameter; please use %s[<number>]", parfile, lineno, parameter, parameter); num_1errors++; } } - else if (retval == -9) + else if (retval == -10) { - /* Parameter adds to an accumulator and that value would be out of range. */ - CCTK_VWarn (1, __LINE__, __FILE__, "Cactus", - "Major error in parameter file '%s' line %d: " - "Range error setting parameter " - "'%s' to '%s' - out of range in accumulator", - parfile, lineno, parameter, value); - num_0errors++; + /* parameter has already been set to a different value in the parfile */ + if (parameter_check == CCTK_PARAMETER_RELAXED) + { + CCTK_VWarn (1, __LINE__, __FILE__, "Cactus", + "Minor error in parameter file '%s' line %d: " + "Parameter '%s' has already been set to a different value " + "before", parfile, lineno, parameter); + num_1errors++; + } + else + { + CCTK_VWarn (1, __LINE__, __FILE__, "Cactus", + "Major error in parameter file '%s' line %d: " + "Parameter '%s' has already been set to a different value " + "before", parfile, lineno, parameter); + num_0errors++; + } + } + else if (retval == -11) + { + /* parameter has already been set to the same value in the parfile */ + if (parameter_check != CCTK_PARAMETER_STRICT) + { + CCTK_VWarn (1, __LINE__, __FILE__, "Cactus", + "Minor error in parameter file '%s' line %d: " + "Parameter '%s' has already been set to the same value " + "before", parfile, lineno, parameter); + num_1errors++; + } + else + { + CCTK_VWarn (1, __LINE__, __FILE__, "Cactus", + "Major error in parameter file '%s' line %d: " + "Parameter '%s' has already been set to the same value " + "before", parfile, lineno, parameter); + num_0errors++; + } } return (retval); @@ -310,14 +340,15 @@ int CCTKi_NumParameterFileErrors (int level) @returntype int @returndesc - 0 = success,<BR> - -9 = final value of accumulator out of range<br> - -6 = not a valid integer or float<br> - -5 = thorn/imp not active,<BR> - -4 = tried to set parameter in two different thorns,<BR> - -3 = tried to steer nonsteerable parameter,<BR> - -2 = parameter not defined in the active thorn,<BR> - -1 = parameter out of range + 0 = success,<BR> + -10 = parameter is set more than once in the parfile<BR> + -9 = final value of accumulator out of range<br> + -6 = not a valid integer or float<br> + -5 = thorn/imp not active,<BR> + -4 = tried to set parameter in two different thorns,<BR> + -3 = tried to steer nonsteerable parameter,<BR> + -2 = parameter not defined in the active thorn,<BR> + -1 = parameter out of range @endreturndesc @@*/ static int ReallySetParameter(const char *parameter, const char *value) |