aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrhaas <rhaas@6a38eb6e-646e-4a02-a296-d141613ad6c4>2014-01-13 17:14:23 +0000
committerrhaas <rhaas@6a38eb6e-646e-4a02-a296-d141613ad6c4>2014-01-13 17:14:23 +0000
commitff27813018d94001fc5c120c8401df61fa157268 (patch)
treef7d342e9a39b16a981161e292cc1f1d62731b159
parentc1bb3b4f29eee773e3f42a5076905e37670594f9 (diff)
check that variables have storage
This patch checks for storage in the upper layer boundary apply routine. All bc that need more than a single timelevel check for the existence of more timelevels themselves. Before if one accidentally selected a variable for a flat boundary condition (with thorn Boundary) without storage, this would lead to a segfault. git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/Boundary/trunk@323 6a38eb6e-646e-4a02-a296-d141613ad6c4
-rw-r--r--src/Boundary.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/Boundary.c b/src/Boundary.c
index e4be3e2..2c499f2 100644
--- a/src/Boundary.c
+++ b/src/Boundary.c
@@ -1085,6 +1085,30 @@ void Boundary_ApplyPhysicalBCs(CCTK_ARGUMENTS)
"returned %d", err);
}
+ /* check that all variables have storage at least on the current level
+ * individual boundary conditions (eg static) may check for more */
+ err = 0;
+ for (int i=0; i<num_vars; i++)
+ {
+ if (CCTK_VarDataPtrI(cctkGH, 0, vars[i])==NULL)
+ {
+ char *fullname = CCTK_FullName(vars[i]);
+ CCTK_VWarn(CCTK_WARN_ALERT, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Boundary_ApplyPhysicalBCs: variable \"%s\" has no storage "
+ "when attempting to apply boundary condition \"%s\".",
+ fullname, current_bcdata->bc_name);
+ err += 1;
+ free(fullname);
+ }
+ }
+ if (err)
+ {
+ CCTK_VError(__LINE__, __FILE__, CCTK_THORNSTRING,
+ "Boundary_ApplyPhysicalBCs: boundary conditions were "
+ "requested for %d variables that do not have storage",
+ err);
+ }
+
/* Apply bc to vi */
#ifdef DEBUG
printf("Boundary_ApplyPhysicalBCs: Attempting to call boundary condition\n"