diff options
author | tradke <tradke@1c20744c-e24a-42ec-9533-f5004cb800e5> | 2002-12-20 16:30:41 +0000 |
---|---|---|
committer | tradke <tradke@1c20744c-e24a-42ec-9533-f5004cb800e5> | 2002-12-20 16:30:41 +0000 |
commit | 5fa8ab688a0f28b92f48d101099d56656aa43ddc (patch) | |
tree | ea28fc84ba6b45cc9d1166eb3d9a2db5ddda335c | |
parent | 8167fc61e119d112373b19334ac54ca0d452b698 (diff) |
Include Jonathan Thornburg's changes to the local interpolator in the
LocalInterp thorn:
* add a test for the case where the array dimension is smaller than
the stencil/molecule size -- formerly this would access memory off the
end of the array (==> possible core dump on some machines, eg alphas),
now it gives an error return from the interpolator
* systematize terminology for "stencil" vs "molecule" -- now all
references are to the hybrid term "stencil/molecule"
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGHInterp/trunk@39 1c20744c-e24a-42ec-9533-f5004cb800e5
-rw-r--r-- | src/Interpolate.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/Interpolate.c b/src/Interpolate.c index 146b61c..b46cb40 100644 --- a/src/Interpolate.c +++ b/src/Interpolate.c @@ -370,7 +370,7 @@ int PUGHInterp_Interpolate (int order, /* loop over all dimensions */ for (i = 0; i < num_dims; i++) { - /* closest grid point for stencil */ + /* closest grid point for stencil/molecule */ point[i] = floor ((coord[num_dims*n + i] - origin[i]) * delta_inv[i] - 0.5 * (order - 1)); @@ -379,6 +379,12 @@ int PUGHInterp_Interpolate (int order, out_of_bounds |= point[i] < 0 || point[i]+order >= dims[i]; #endif + /* check that the stencil/molecule isn't bigger than the grid */ + if (order+1 > dims[i]) /* stencil/molecule size = order+1 */ + { + return -1; + } + /* if beyond lower bound shift the grid point to the right */ shift = point[i]; if (shift < 0) @@ -429,7 +435,7 @@ if (n == PUGHInterp_verbose_debug_n) /* put all information into a single message string for output */ msg = (char *) malloc (100 + num_dims*(10 + 4*20)); - sprintf (msg, "Interpolation stencil out of bounds at grid point [%d", + sprintf (msg, "Interpolation stencil/molecule out of bounds at grid point [%d", point[0]); for (i = 1; i < num_dims; i++) { |