From 6a9bdcc53491660dff1443904142e3ddf7a5eacf Mon Sep 17 00:00:00 2001 From: goodale Date: Mon, 20 May 2002 22:26:09 +0000 Subject: Give error message if tried to set an array parameter without the [number]. Tom git-svn-id: http://svn.cactuscode.org/flesh/trunk@2836 17b73243-c579-4c4c-a9d2-2d5706c11dac --- src/main/Parameters.c | 6 ++++-- src/main/SetParams.c | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main/Parameters.c b/src/main/Parameters.c index 519150ce..6633eb0a 100644 --- a/src/main/Parameters.c +++ b/src/main/Parameters.c @@ -528,6 +528,7 @@ void CCTKi_ParameterAccumulatorBase(const char *thorn, -3 if trying to steer a non-steerable parameter
-6 if not a valid integer or float
-7 if tried to set an accumulator parameter directly
+ -8 if tried to set an accumulator parameter directly
-9 if final value of accumulator out of range
@endreturndesc @@*/ @@ -546,6 +547,7 @@ int CCTK_ParameterSet (const char *name, const char *thorn, const char *value) CCTK_VWarn (1, __LINE__, __FILE__, "Cactus", "CCTK_ParameterSet: Cannot set base array parameter '%s::%s' " , thorn, name); + retval = -8; } else if(param->props->accumulator_expression) { @@ -1137,7 +1139,7 @@ static t_param *ParameterFind (const char *name, if(list) { - if(list->param->array) + if(list->param->array && array_index > -1) { if(array_index < list->param->props->array_size) { @@ -2254,7 +2256,7 @@ static void GetBaseName(const char *name, char **basename, int *array_index) else { baselen = strlen(name); - *array_index = 0; + *array_index = -1; } *basename = (char *)malloc(baselen+1); diff --git a/src/main/SetParams.c b/src/main/SetParams.c index 7d4a9e42..7e722194 100644 --- a/src/main/SetParams.c +++ b/src/main/SetParams.c @@ -175,6 +175,21 @@ int CCTKi_SetParameter (const char *parameter, const char *value, int lineno) num_1errors++; } } + else if (retval == -8) + { + /* Tried to set an array base parameter */ + CCTK_VWarn (1, __LINE__, __FILE__, "Cactus", + "In parameter file '%s' line %d: Parameter '%s' is an " + "array base parameter; please use %s[]", parfile, lineno, parameter, parameter); + if (parameter_check == CCTK_PARAMETER_STRICT) + { + num_0errors++; + } + else if (parameter_check == CCTK_PARAMETER_NORMAL) + { + num_1errors++; + } + } else if (retval == -9) { /* Parameter adds to an accumulator and that value would be out of range. */ -- cgit v1.2.3