diff options
Diffstat (limited to 'Carpet/CarpetSlab/src/slab.cc')
-rw-r--r-- | Carpet/CarpetSlab/src/slab.cc | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/Carpet/CarpetSlab/src/slab.cc b/Carpet/CarpetSlab/src/slab.cc index ff2ee5cfa..d50ee25a1 100644 --- a/Carpet/CarpetSlab/src/slab.cc +++ b/Carpet/CarpetSlab/src/slab.cc @@ -4,6 +4,7 @@ #include <stdlib.h> #include <string.h> +#include <algorithm> #include <vector> #include "cctk.h" @@ -32,6 +33,7 @@ extern "C" { namespace CarpetSlab { + using namespace std; using namespace Carpet; @@ -132,7 +134,7 @@ namespace CarpetSlab { // Check extent for (int dd=0; dd<hdim; ++dd) { - assert (origin[dirs[dd]-1] + length[dd] <= sizes[dirs[dd]]); + assert (origin[dirs[dd]-1] + length[dd] <= sizes[dirs[dd]-1]); } // Get insider information about variable @@ -154,6 +156,17 @@ namespace CarpetSlab { // Determine own rank const int rank = CCTK_MyProc(cgh); + // Sanity check + // (if this fails, someone requested an insane number of grid points) + { + int max = INT_MAX; + for (int dd=0; dd<dim; ++dd) { + assert (length[dd] >= 0 && length[dd] <= max); + if (length[dd] > 0) max /= length[dd]; + } + assert (typesize <= max); + } + // Calculate global size int totalsize = 1; for (int dd=0; dd<hdim; ++dd) { |