aboutsummaryrefslogtreecommitdiff
path: root/src/GetHyperslab.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/GetHyperslab.c')
-rw-r--r--src/GetHyperslab.c134
1 files changed, 26 insertions, 108 deletions
diff --git a/src/GetHyperslab.c b/src/GetHyperslab.c
index 0c883cc..b6e0af0 100644
--- a/src/GetHyperslab.c
+++ b/src/GetHyperslab.c
@@ -39,11 +39,6 @@ static int GetLocalHyperslab (const cGH *GH,
int timelevel,
int hdatatype,
void *hdata);
-static const char *checkParameters (const cGH *GH,
- const hslab_mapping_t *mapping,
- int vindex,
- int timelevel,
- void *hdata);
/********************************************************************
******************** External Routines ************************
********************************************************************/
@@ -243,12 +238,33 @@ static int GetLocalHyperslab (const cGH *GH,
/* do some plausibility checks */
- errormsg = checkParameters (GH, mapping, vindex, timelevel, hdata);
+ errormsg = NULL;
+ if (! GH || ! mapping || (mapping->totals > 0 && ! hdata))
+ {
+ errormsg = "NULL pointer(s) passed for GH/mapping/hdata arguments";
+ }
+ else if (CCTK_GroupData (CCTK_GroupIndexFromVarI (vindex), &vinfo) < 0)
+ {
+ errormsg = "Invalid variable index given";
+ }
+ else if (timelevel < 0 || timelevel >= vinfo.numtimelevels)
+ {
+ errormsg = "Invalid timelevel given";
+ }
+ else if (vinfo.grouptype != mapping->vinfo.grouptype ||
+ vinfo.disttype != mapping->vinfo.disttype ||
+ vinfo.dim != mapping->vinfo.dim ||
+ vinfo.stagtype != mapping->vinfo.stagtype)
+ {
+ errormsg = "Group data for template variable in mapping and given variable "
+ "don't match";
+ }
/* immediately return in case of errors */
if (errormsg)
{
- CCTK_WARN (1, errormsg);
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "GetLocalHyperslab: %s", errormsg);
return (-1);
}
@@ -258,9 +274,6 @@ static int GetLocalHyperslab (const cGH *GH,
return (0);
}
- /* get the info on the variable to extract a hyperslab from */
- CCTK_GroupData (CCTK_GroupIndexFromVarI (vindex), &vinfo);
-
/* FIXME: hack for getting diagonals from 3D variables
This is calling Gerd's CollectData1D() routine which can
extract non-axis-parallel lines too but is fixed to 3D data. */
@@ -338,7 +351,7 @@ static int GetLocalHyperslab (const cGH *GH,
/* NOTE: the following code assumes startpoint[vdim] < endpoint[vdim] */
vdata = CCTK_VarDataPtrI (GH, timelevel, vindex);
- if (mapping->full_hyperslab && conversion_fn == NULL)
+ if (mapping->is_full_hyperslab && conversion_fn == NULL)
{
memcpy (hdata, vdata, mapping->totals * CCTK_VarTypeSize (vinfo.vartype));
}
@@ -414,7 +427,7 @@ static int GetLocalHyperslab (const cGH *GH,
/* get the byte pointer into the source array */
typed_vdata = (const char *) vdata + point[0];
-#if 0
+#if 1
fprintf (stderr, "***** base vdata %p offset %d '%s'\n", vdata, point[0], CCTK_FullName (vindex));
#endif
for (i = 1; i < vinfo.dim; i++)
@@ -432,7 +445,7 @@ fprintf (stderr, "***** base vdata %p offset %d '%s'\n", vdata, point[0], CCTK_F
}
else
{
-#if 0
+#if 1
fprintf (stderr, "***** copying %d bytes from %p tp %p\n", dim0_hsize, typed_vdata, typed_hdata);
#endif
memcpy (typed_hdata, typed_vdata, dim0_hsize);
@@ -476,98 +489,3 @@ fprintf (stderr, "***** copying %d bytes from %p tp %p\n", dim0_hsize, typed_vda
return (0);
}
-
-
-static const char *checkParameters (const cGH *GH,
- const hslab_mapping_t *mapping,
- int vindex,
- int timelevel,
- void *hdata)
-{
- cGroup vinfo; /* variable's group info */
-#if 0
- int i, vdim; /* looper */
- int num_directions; /* number of non-zero directions */
-#endif
-
-
- /* check the variable index and timelevel */
- if (vindex < 0 || vindex >= CCTK_NumVars ())
- {
- return ("Invalid variable index");
- }
- if (timelevel < 0 || timelevel >= CCTK_NumTimeLevelsFromVarI (vindex))
- {
- return ("Invalid timelevel");
- }
-
-#if 0
- /* check the passed pointers */
- if (! mapping->global_origin || ! directions || ! extents || ! mapping->downsample ||
- ! hdata || ! hsize)
- {
- return ("NULL pointer(s) passed as parameters");
- }
-
- /* check the extent and downsample parameters */
- for (vdim = 0; vdim < hdim; vdim++)
- {
- if (extents[vdim] == 0)
- {
- return ("Invalid hyperslab extent parameters");
- }
- if (mapping->downsample[vdim] <= 0)
- {
- return ( "Invalid hyperslab downsample parameters");
- }
- }
-#endif
-
- /* get the info on the variable to extract a hyperslab from */
- if (CCTK_GroupData (CCTK_GroupIndexFromVarI (vindex), &vinfo) < 0)
- {
- return ("Couldn't get group info");
- }
-
- /* check the variable's grouptype */
- if (vinfo.grouptype != CCTK_GF && vinfo.grouptype != CCTK_ARRAY)
- {
- return ("Invalid variable group type");
- }
-
- /* check the hyperslab dimension */
- if (mapping->hdim <= 0 || mapping->hdim > vinfo.dim)
- {
- return ("Invalid hyperslab dimension");
- }
-
-#if 0
- /* check the direction(s) of the hyperslab */
- for (i = 0; i < mapping->hdim; i++)
- {
- for (vdim = 0, num_directions = 0; vdim < vinfo.dim; vdim++)
- {
- if (directions[i * vinfo.dim + vdim])
- {
- num_directions++;
- }
- }
- if (num_directions == 0)
- {
- return ("Given direction vector is a null vector");
- }
- if (num_directions != 1)
- {
- return ("Given direction vector isn't orthogonal");
- }
- }
-#endif
-
- /* check if PUGH is active */
- if (! PUGH_pGH (GH))
- {
- return ("No GH extension for PUGH found. Did you activate thorn PUGH ?");
- }
-
- return (NULL);
-}