aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhawke <hawke@578cdeb0-5ea1-4b81-8215-5a3b8777ee0b>2004-10-15 13:29:46 +0000
committerhawke <hawke@578cdeb0-5ea1-4b81-8215-5a3b8777ee0b>2004-10-15 13:29:46 +0000
commit7eba9943ef2bdd01f08f18124409b68b624aa65d (patch)
tree4de202e20f70b732ace6b33e0d4a43464b955a68 /src
parent34b62d04ad58ac1d0fd95186aff1213e44424856 (diff)
Tighten error checking when changing variable type. Certain no-op operations are now safe and potential segfaults caught.
Correct warning messages. Fixes PRs 1865,1866. git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/MoL/trunk@77 578cdeb0-5ea1-4b81-8215-5a3b8777ee0b
Diffstat (limited to 'src')
-rw-r--r--src/ChangeType.c128
1 files changed, 92 insertions, 36 deletions
diff --git a/src/ChangeType.c b/src/ChangeType.c
index 616382b..d5b686c 100644
--- a/src/ChangeType.c
+++ b/src/ChangeType.c
@@ -304,22 +304,11 @@ CCTK_INT MoL_ChangeToConstrained(CCTK_INT ConstrainedIndex)
}
else if (timelevs == 1)
{
- CCTK_VWarn(1,__LINE__,__FILE__,"MoL",
- "Warning whilst trying to change variable "
- "index %i to constrained.", ConstrainedIndex);
- CCTK_WARN(0, "The index passed only has a single timelevel.");
- }
-
- if (!(MoLNumConstrainedVariables < MoL_Num_Constrained_Vars))
- {
- CCTK_VWarn(1,__LINE__,__FILE__,"MoL",
- "Warning whilst trying to change variable "
- "index %i (%s) to constrained.",
- ConstrainedIndex, CCTK_VarName(ConstrainedIndex));
- CCTK_WARN(0, "When changing type there are more variables "
- "than the accumulator parameter "
- "MoL_Num_Constrained_Vars allows. Check that "
- "you are accumulating onto this parameter correctly");
+ CCTK_VInfo(CCTK_THORNSTRING,
+ "MoL will not treat variable %s as a constrained "
+ "variable at it has only one timelevel. This should "
+ "not cause problems with the evolution.\n",
+ CCTK_VarName(ConstrainedIndex));
}
for (index = 0; (index < MoLNumEvolvedVariables)&&(!vartype); index++)
@@ -358,9 +347,25 @@ CCTK_INT MoL_ChangeToConstrained(CCTK_INT ConstrainedIndex)
case MOL_UNKNOWN_VARTYPE:
{
- ConstrainedVariableIndex[MoLNumConstrainedVariables] =
- ConstrainedIndex;
- MoLNumConstrainedVariables++;
+ if (timelevs > 1)
+ {
+
+ if ( !(MoLNumConstrainedVariables < MoL_Num_Constrained_Vars))
+ {
+ CCTK_VWarn(1,__LINE__,__FILE__,"MoL",
+ "Warning whilst trying to change variable "
+ "index %i (%s) to constrained.",
+ ConstrainedIndex, CCTK_VarName(ConstrainedIndex));
+ CCTK_WARN(0, "When changing type there are more variables "
+ "than the accumulator parameter "
+ "MoL_Num_Constrained_Vars allows. Check that "
+ "you are accumulating onto this parameter correctly");
+ }
+
+ ConstrainedVariableIndex[MoLNumConstrainedVariables] =
+ ConstrainedIndex;
+ MoLNumConstrainedVariables++;
+ }
break;
}
@@ -373,9 +378,22 @@ CCTK_INT MoL_ChangeToConstrained(CCTK_INT ConstrainedIndex)
RHSVariableIndex[index] = RHSVariableIndex[index+1];
}
MoLNumEvolvedVariables--;
- ConstrainedVariableIndex[MoLNumConstrainedVariables] = ConstrainedIndex;
- MoLNumConstrainedVariables++;
-
+ if (timelevs > 1)
+ {
+ if ( !(MoLNumConstrainedVariables < MoL_Num_Constrained_Vars))
+ {
+ CCTK_VWarn(1,__LINE__,__FILE__,"MoL",
+ "Warning whilst trying to change variable "
+ "index %i (%s) to constrained.",
+ ConstrainedIndex, CCTK_VarName(ConstrainedIndex));
+ CCTK_WARN(0, "When changing type there are more variables "
+ "than the accumulator parameter "
+ "MoL_Num_Constrained_Vars allows. Check that "
+ "you are accumulating onto this parameter correctly");
+ }
+ ConstrainedVariableIndex[MoLNumConstrainedVariables] = ConstrainedIndex;
+ MoLNumConstrainedVariables++;
+ }
break;
}
@@ -393,8 +411,22 @@ CCTK_INT MoL_ChangeToConstrained(CCTK_INT ConstrainedIndex)
SandRVariableIndex[index] = SandRVariableIndex[index+1];
}
MoLNumSandRVariables--;
- ConstrainedVariableIndex[MoLNumConstrainedVariables] = ConstrainedIndex;
- MoLNumConstrainedVariables++;
+ if (timelevs > 1)
+ {
+ if ( !(MoLNumConstrainedVariables < MoL_Num_Constrained_Vars))
+ {
+ CCTK_VWarn(1,__LINE__,__FILE__,"MoL",
+ "Warning whilst trying to change variable "
+ "index %i (%s) to constrained.",
+ ConstrainedIndex, CCTK_VarName(ConstrainedIndex));
+ CCTK_WARN(0, "When changing type there are more variables "
+ "than the accumulator parameter "
+ "MoL_Num_Constrained_Vars allows. Check that "
+ "you are accumulating onto this parameter correctly");
+ }
+ ConstrainedVariableIndex[MoLNumConstrainedVariables] = ConstrainedIndex;
+ MoLNumConstrainedVariables++;
+ }
break;
}
@@ -446,18 +478,6 @@ CCTK_INT MoL_ChangeToSaveAndRestore(CCTK_INT SandRIndex)
"index %i to save and restore.", SandRIndex);
CCTK_WARN(0, "The index passed does not correspond to a GF.");
}
-
- if (!(MoLNumSandRVariables < MoL_Num_SaveAndRestore_Vars))
- {
- CCTK_VWarn(1,__LINE__,__FILE__,"MoL",
- "Warning whilst trying to change variable "
- "index %i (%s) to save and restore.",
- SandRIndex, CCTK_VarName(SandRIndex));
- CCTK_WARN(0, "When changing type there are more variables "
- "than the accumulator parameter "
- "MoL_Num_SaveAndRestore_Vars allows. Check that "
- "you are accumulating onto this parameter correctly");
- }
for (index = 0; (index < MoLNumEvolvedVariables)&&(!vartype); index++)
{
@@ -495,6 +515,18 @@ CCTK_INT MoL_ChangeToSaveAndRestore(CCTK_INT SandRIndex)
case MOL_UNKNOWN_VARTYPE:
{
+
+ if (!(MoLNumSandRVariables < MoL_Num_SaveAndRestore_Vars))
+ {
+ CCTK_VWarn(1,__LINE__,__FILE__,"MoL",
+ "Warning whilst trying to change variable "
+ "index %i (%s) to save and restore.",
+ SandRIndex, CCTK_VarName(SandRIndex));
+ CCTK_WARN(0, "When changing type there are more variables "
+ "than the accumulator parameter "
+ "MoL_Num_SaveAndRestore_Vars allows. Check that "
+ "you are accumulating onto this parameter correctly");
+ }
SandRVariableIndex[MoLNumSandRVariables] = SandRIndex;
MoLNumSandRVariables++;
break;
@@ -503,6 +535,18 @@ CCTK_INT MoL_ChangeToSaveAndRestore(CCTK_INT SandRIndex)
case MOL_EVOLVED_VARTYPE:
{
+
+ if (!(MoLNumSandRVariables < MoL_Num_SaveAndRestore_Vars))
+ {
+ CCTK_VWarn(1,__LINE__,__FILE__,"MoL",
+ "Warning whilst trying to change variable "
+ "index %i (%s) to save and restore.",
+ SandRIndex, CCTK_VarName(SandRIndex));
+ CCTK_WARN(0, "When changing type there are more variables "
+ "than the accumulator parameter "
+ "MoL_Num_SaveAndRestore_Vars allows. Check that "
+ "you are accumulating onto this parameter correctly");
+ }
for (index = usedindex; index < MoLNumEvolvedVariables - 1; index++)
{
EvolvedVariableIndex[index] = EvolvedVariableIndex[index+1];
@@ -517,6 +561,18 @@ CCTK_INT MoL_ChangeToSaveAndRestore(CCTK_INT SandRIndex)
case MOL_CONSTRAINED_VARTYPE:
{
+
+ if (!(MoLNumSandRVariables < MoL_Num_SaveAndRestore_Vars))
+ {
+ CCTK_VWarn(1,__LINE__,__FILE__,"MoL",
+ "Warning whilst trying to change variable "
+ "index %i (%s) to save and restore.",
+ SandRIndex, CCTK_VarName(SandRIndex));
+ CCTK_WARN(0, "When changing type there are more variables "
+ "than the accumulator parameter "
+ "MoL_Num_SaveAndRestore_Vars allows. Check that "
+ "you are accumulating onto this parameter correctly");
+ }
for (index = usedindex; index < MoLNumConstrainedVariables -
1;
index++)