From ff27813018d94001fc5c120c8401df61fa157268 Mon Sep 17 00:00:00 2001 From: rhaas Date: Mon, 13 Jan 2014 17:14:23 +0000 Subject: 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 --- src/Boundary.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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; ibc_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" -- cgit v1.2.3