summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNeil Fortner <nfortne2@hdfgroup.org>2013-02-08 16:49:21 (GMT)
committerNeil Fortner <nfortne2@hdfgroup.org>2013-02-08 16:49:21 (GMT)
commit692fa69934553e34a7166fd919b90309bc4ecb23 (patch)
treee040dd69a95938a9de499ac6582ce5ac8aab1079 /src
parent386f73823af1fbe6bd39e9bce3c247c183ae56c1 (diff)
downloadhdf5-692fa69934553e34a7166fd919b90309bc4ecb23.zip
hdf5-692fa69934553e34a7166fd919b90309bc4ecb23.tar.gz
hdf5-692fa69934553e34a7166fd919b90309bc4ecb23.tar.bz2
[svn-r23237] Purpose: Implement H5Dscatter and H5Dgather
Description: Adds 2 new API functions, H5Dscatter and H5Dgather. H5Dscatter retrieves data from a specified callback function and scatters it into a selection, defined by a supplied dataspace, within a supplied memory buffer. H5Dgather gathers data from a selection within a supplied memory buffer and passes it in a contiguous form to a supplied callback function. Added tests for these functions Tested: jam, ostrich, koala (h5committest); ummon
Diffstat (limited to 'src')
-rw-r--r--src/H5Dscatgath.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/H5Dscatgath.c b/src/H5Dscatgath.c
index 74d6749..60a8800 100644
--- a/src/H5Dscatgath.c
+++ b/src/H5Dscatgath.c
@@ -1048,8 +1048,6 @@ H5Dgather(hid_t src_space_id, void *src_buf, hid_t type_id, size_t dst_buf_size,
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "destination buffer size is 0")
if(dst_buf == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination buffer provided")
- if(op == NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid callback function pointer")
/* Fill the DXPL cache values for later use */
if(H5D__get_dxpl_cache(H5P_DATASET_XFER_DEFAULT, &dxpl_cache) < 0)
@@ -1068,6 +1066,11 @@ H5Dgather(hid_t src_space_id, void *src_buf, hid_t type_id, size_t dst_buf_size,
if((nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(src_space)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get number of elements in selection")
+ /* If dst_buf is not large enough to hold all the elements, make sure there
+ * is a callback */
+ if(((size_t)nelmts > dst_buf_nelmts) && (op == NULL))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback supplied and destination buffer too small")
+
/* Initialize selection iterator */
if(H5S_select_iter_init(&iter, src_space, type_size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize selection iterator information")
@@ -1081,10 +1084,11 @@ H5Dgather(hid_t src_space_id, void *src_buf, hid_t type_id, size_t dst_buf_size,
HDassert(nelmts_gathered == MIN(dst_buf_nelmts, (size_t)nelmts));
/* Make callback to process dst_buf */
- if(op(dst_buf, nelmts_gathered * type_size, op_data) < 0)
+ if(op && op(dst_buf, nelmts_gathered * type_size, op_data) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CALLBACK, FAIL, "callback operator returned failure")
nelmts -= (hssize_t)nelmts_gathered;
+ HDassert(op || (nelmts == 0));
} /* end while */
done: