aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@10716dce-81a3-4424-a2c8-48026a0d3035>2001-12-11 21:38:09 +0000
committertradke <tradke@10716dce-81a3-4424-a2c8-48026a0d3035>2001-12-11 21:38:09 +0000
commit8d9f7d78e25eeec24403601d5f98b8b66c6601ba (patch)
treebf22e064c14ece68e4c2df52af981ae1c87bcea2
parentfbea6285fbd71db6049958f03861b6a9d76b9d93 (diff)
Allow hyperslab requests with a zero-extent. It does nothing but return 0
for the hyperslab size. Closes PR CactusPUGH/414. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGHSlab/trunk@66 10716dce-81a3-4424-a2c8-48026a0d3035
-rw-r--r--src/Hyperslab.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/Hyperslab.c b/src/Hyperslab.c
index 3a8603a..9c482e6 100644
--- a/src/Hyperslab.c
+++ b/src/Hyperslab.c
@@ -297,6 +297,28 @@ int Hyperslab_GetLocalHyperslab (const cGH *GH,
/* set the default return code */
retval = 0;
+ /* check for zero-size hyperslab */
+ totals = 1;
+ for (vdim = 0; vdim < hdim; vdim++)
+ {
+ totals *= extents[vdim];
+ }
+ if (totals == 0)
+ {
+ /* initialize output parameters to all zeros */
+ for (vdim = 0; vdim < hdim; vdim++)
+ {
+ hsize[vdim] = hsize_global[vdim] = 0;
+ if (hoffset_global)
+ {
+ hoffset_global[vdim] = 0;
+ }
+ }
+ *hdata = NULL;
+
+ return (retval);
+ }
+
/* get the info on the variable to extract a hyperslab from */
CCTK_GroupData (CCTK_GroupIndexFromVarI (vindex), &vinfo);
@@ -1088,13 +1110,9 @@ static const char *checkParameters (const cGH *GH, int vindex, int vtimelvl,
return ("NULL pointer(s) passed as parameters");
}
- /* check the extent and downsample parameters */
+ /* check the downsample parameter */
for (dim = 0; dim < hdim; dim++)
{
- if (extents[dim] == 0)
- {
- return ("Invalid hyperslab extent parameters");
- }
if (downsample_[dim] <= 0)
{
return ( "Invalid hyperslab downsample parameters");