aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortradke <tradke@10716dce-81a3-4424-a2c8-48026a0d3035>2002-03-22 10:23:43 +0000
committertradke <tradke@10716dce-81a3-4424-a2c8-48026a0d3035>2002-03-22 10:23:43 +0000
commit97ce339877f85d52919a69f502224811dd57e024 (patch)
treed9964d0b4b89e4ca818d865c41ab7150b6230c27 /src
parent74d880e668e0ec091e3a5b1ef9c3271c0d9b5c78 (diff)
Just syncing my local changes for the new API.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGHSlab/trunk@75 10716dce-81a3-4424-a2c8-48026a0d3035
Diffstat (limited to 'src')
-rw-r--r--src/GetHyperslab.c74
-rw-r--r--src/PUGHSlab.h3
2 files changed, 37 insertions, 40 deletions
diff --git a/src/GetHyperslab.c b/src/GetHyperslab.c
index da835f4..ad7cbd5 100644
--- a/src/GetHyperslab.c
+++ b/src/GetHyperslab.c
@@ -60,29 +60,13 @@ CCTK_INT Hyperslab_Get (const cGH *GH,
CCTK_INT hdatatype,
void *hdata)
{
- int retval;
- hslab_mapping_t *mapping;
+ CCTK_INT retval;
- if (proc >= CCTK_nProcs (GH))
- {
- return (-1);
- }
+ retval = Hyperslab_GetList (GH, mapping_handle, 1, &proc, &vindex, &timelevel,
+ &hdatatype, &hdata, NULL);
- mapping = PUGHSlabi_GetMapping (mapping_handle);
- if (mapping == NULL)
- {
- return (-2);
- }
-
- /* check mapping consistency */
- /*** FIXME ***/
-
- /* get the processor-local hyperslab */
- retval = GetLocalHyperslab (GH, mapping, proc, vindex, timelevel,
- hdatatype, hdata);
-
- return (retval);
+ return (retval == 1 ? 0 : -1);
}
@@ -93,20 +77,40 @@ CCTK_INT Hyperslab_GetList (const cGH *GH,
const CCTK_INT *vindices /* num_arrays */,
const CCTK_INT *timelevels /* num_arrays */,
const CCTK_INT *hdatatypes /* num_arrays */,
- void *const *hdata /* num_arrays */)
+ void *const *hdata /* num_arrays */,
+ CCTK_INT *retvals /* num_arrays */)
{
int i, retval;
+ int result, *result_ptr;
+ hslab_mapping_t *mapping;
+ mapping = PUGHSlabi_GetMapping (mapping_handle);
+ if (mapping == NULL)
+ {
+ return (-2);
+ }
+
+ /* check mapping consistency */
+ /*** FIXME ***/
+
+ /* check if there's any data to extract */
+ if (mapping->totals == 0)
+ {
+ return (0);
+ }
+
retval = 0;
for (i = 0; i < num_arrays; i++)
{
- if (Hyperslab_Get (GH, mapping_handle,
- procs ? procs[i] : DEFAULT_PROCESSOR,
- vindices[i],
- timelevels ? timelevels[i] : DEFAULT_TIMELEVEL,
- hdatatypes ? hdatatypes[i] : -1,
- hdata[i]) == 0)
+ /* get the processor-local hyperslab */
+ result_ptr = retvals ? &retvals[i] : &result;
+ *result_ptr = GetLocalHyperslab (GH, mapping,
+ procs ? procs[i] : DEFAULT_PROCESSOR,
+ vindices[i],
+ timelevels ? timelevels[i] : DEFAULT_TIMELEVEL,
+ hdatatypes ? hdatatypes[i] : -1, hdata[i]);
+ if (*result_ptr == 0)
{
retval++;
}
@@ -252,6 +256,10 @@ static int GetLocalHyperslab (const cGH *GH,
{
errormsg = "NULL pointer(s) passed for GH/mapping/hdata arguments";
}
+ else if (proc >= CCTK_nProcs (GH))
+ {
+ errormsg = "Invalid processor ID passed for proc argument";
+ }
else if (CCTK_GroupData (CCTK_GroupIndexFromVarI (vindex), &vinfo) < 0)
{
errormsg = "Invalid variable index given";
@@ -277,12 +285,6 @@ static int GetLocalHyperslab (const cGH *GH,
return (-1);
}
- /* check if there's any data to extract */
- if (mapping->totals == 0)
- {
- return (0);
- }
-
/* diagonals from 3D variables are treated special */
if (mapping->is_diagonal_in_3D)
{
@@ -420,9 +422,6 @@ static int GetLocalHyperslab (const cGH *GH,
/* get the byte pointer into the source array */
typed_vdata = (const char *) vdata + point[0];
-#if 0
-fprintf (stderr, "***** base vdata %p offset %d '%s'\n", vdata, point[0], CCTK_FullName (vindex));
-#endif
for (i = 1; i < vinfo.dim; i++)
{
typed_vdata += point[i] * points_per_dim[i];
@@ -438,9 +437,6 @@ fprintf (stderr, "***** base vdata %p offset %d '%s'\n", vdata, point[0], CCTK_F
}
else
{
-#if 0
-fprintf (stderr, "***** copying %d bytes from %p tp %p\n", dim0_hsize, typed_vdata, typed_hdata);
-#endif
memcpy (typed_hdata, typed_vdata, dim0_hsize);
}
}
diff --git a/src/PUGHSlab.h b/src/PUGHSlab.h
index b5640b8..6020e47 100644
--- a/src/PUGHSlab.h
+++ b/src/PUGHSlab.h
@@ -39,7 +39,8 @@ CCTK_INT Hyperslab_GetList (const cGH *GH,
const CCTK_INT *vindices /* num_arrays */,
const CCTK_INT *timelevels /* num_arrays */,
const CCTK_INT *hdatatypes /* num_arrays */,
- void *const *hdata /* num_arrays */);
+ void *const *hdata /* num_arrays */,
+ CCTK_INT *retvals /* num_arrays */);
CCTK_INT Hyperslab_DefineGlobalMappingByIndex (
const cGH *GH,
CCTK_INT vindex,