diff options
author | tradke <tradke@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2006-09-28 13:05:28 +0000 |
---|---|---|
committer | tradke <tradke@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2006-09-28 13:05:28 +0000 |
commit | 6fd0446292d3fd23b45865554eefc42f4336287d (patch) | |
tree | 76c55596b3007a0a27057324ce31d2d8880d1466 /src/main | |
parent | 21812bd883e525f44e7260e676966b8aca84dd91 (diff) |
Fix inconsistent interpretation of CCTK_ParameterQueryTimesSet()'s return value.
The discussion on http://www.cactuscode.org/pipermail/developers/2006-August/004990.html brought up the issue of an inconsistent interpretation of CCTK_ParameterQueryTimesSet()'s return value which depends on whether this is a normal run, or one that has been recovered from a checkpoint.
The provided patch solves the problem of inconsistent behaviour of CCTK_ParameterQueryTimesSet() by fixing the code in CCTK_ParameterSet() which increments the times_set counter.
Now the counter is not incremented for recovered parameters which take the same value as before (effectively assuming this to be a no-op). In addition, non-steerable parameters which are set in the parfile but then recovered to the same value from a checkpoint will have their previous set operation unregistered.
In a recovered run, CCTK_ParameterQueryTimesSet() will now return a value larger 0 for the union of
- all parameters which have been set in the parfile
when the checkpoint was created
- all steerable parameters which have been set in the
recovery parfile
This closes PR Cactus-2056: "fix inconsistent interpretation of CCTK_ParameterQueryTimesSet()'s return value".
git-svn-id: http://svn.cactuscode.org/flesh/trunk@4374 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/Parameters.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/main/Parameters.c b/src/main/Parameters.c index cd8527ec..0c253f5a 100644 --- a/src/main/Parameters.c +++ b/src/main/Parameters.c @@ -583,6 +583,12 @@ int CCTK_ParameterSet (const char *name, const char *thorn, const char *value) thorn, name); retval = ParameterSet (param, value); } + else + { + /* unregister the previous set operation + if the restored value is the same as the one previously set */ + param->props->n_set--; + } } else { @@ -596,21 +602,28 @@ int CCTK_ParameterSet (const char *name, const char *thorn, const char *value) { retval = ParameterSet (param, value); + new_value = CCTK_ParameterValString (param->props->name, + param->props->thorn); + /* 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 (new_value); } } - /* register another set operation */ - param->props->n_set++; + /* register another set operation + if the parameter has not simply been restored to the same value */ + if (! (cctk_parameter_set_mask == PARAMETER_RECOVERY_IN && + strcmp (old_value, new_value) == 0)) + { + param->props->n_set++; + } + + free (new_value); } free (old_value); |