aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjthorn <jthorn@df1f8a13-aa1d-4dd4-9681-27ded5b42416>2002-12-20 16:15:50 +0000
committerjthorn <jthorn@df1f8a13-aa1d-4dd4-9681-27ded5b42416>2002-12-20 16:15:50 +0000
commit51d5ff2211aa62c14f3705462966eee682c3eb18 (patch)
tree3e3b1ea874e1dbc45baccc425122e290f8fc72a8 /src
parentbd533e3e3243827a5667ab2efbeefdb85ffda30f (diff)
* 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/CactusBase/LocalInterp/trunk@123 df1f8a13-aa1d-4dd4-9681-27ded5b42416
Diffstat (limited to 'src')
-rw-r--r--src/UniformCartesian/Interpolate.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/UniformCartesian/Interpolate.c b/src/UniformCartesian/Interpolate.c
index 52b8fce..7bf9113 100644
--- a/src/UniformCartesian/Interpolate.c
+++ b/src/UniformCartesian/Interpolate.c
@@ -98,7 +98,7 @@ CCTK_FILEVERSION(CactusBase_LocalInterp_UniformCartesian_Interpolate_c)
@var point
@vdesc [MAXDIM] array of integers giving the integer grid coordinates
of the closest grid point to the interpolation point; the
- interpolation molecule/stencil is centered at this point.
+ interpolation stencil/molecule is centered at this point.
@endvar
@var dims
@@ -369,7 +369,7 @@ int LocalInterp_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));
@@ -378,6 +378,12 @@ int LocalInterp_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)
@@ -420,7 +426,8 @@ if (n == LocalInterp_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++)
{