From 527a6edb3ef6cc698efb3ddfb41279541fee0602 Mon Sep 17 00:00:00 2001 From: Raymond Lu Date: Thu, 9 Aug 2012 15:24:56 -0500 Subject: [svn-r22655] Dectris project - I changed the rank of the offset for H5PSIdirect_write from RANK+1 to RANK. But internally, it expands to RANK+1 as the library requires it to terminate with a zero. Tested on koala. --- perform/dectris_perf.c | 4 ++-- src/H5Dio.c | 19 ++++++++++++++----- test/dectris_tst.c | 2 +- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/perform/dectris_perf.c b/perform/dectris_perf.c index cf0580c..abaa92f 100644 --- a/perform/dectris_perf.c +++ b/perform/dectris_perf.c @@ -261,7 +261,7 @@ test_direct_write_uncompressed_data(hid_t fapl_id) int i; unsigned filter_mask = 0; - hsize_t offset[RANK+1] = {0, 0, 0, 0}; + hsize_t offset[RANK] = {0, 0, 0}; struct timeval timeval_start; @@ -326,7 +326,7 @@ test_direct_write_compressed_data(hid_t fapl_id) int i; unsigned filter_mask = 0; - hsize_t offset[RANK+1] = {0, 0, 0, 0}; + hsize_t offset[RANK] = {0, 0, 0}; struct timeval timeval_start; diff --git a/src/H5Dio.c b/src/H5Dio.c index b55a263..845f4e9 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -291,6 +291,7 @@ H5PSIdirect_write(hid_t dset_id, hid_t dxpl_id, unsigned filters, hsize_t *offse H5D_t *dset = NULL; int ndims; hsize_t *dims = NULL; + hsize_t *internal_offset = NULL; int i; herr_t ret_value = SUCCEED; /* Return value */ @@ -319,21 +320,29 @@ H5PSIdirect_write(hid_t dset_id, hid_t dxpl_id, unsigned filters, hsize_t *offse if(NULL == (dims = (hsize_t *)H5MM_malloc(ndims*sizeof(hsize_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for dimensions") + if(NULL == (internal_offset = (hsize_t *)H5MM_malloc((ndims+1)*sizeof(hsize_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for offset") + if(H5S_get_simple_extent_dims(dset->shared->space, dims, NULL) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't retrieve dataspace extent dims") - /* Make sure the offset doesn't exceed the dataset's dimensions */ - for(i=0; i dims[i]) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "offset exceeds dimensions of dataset") - /* Make sure the offset fall right on a chunk's boundary */ - for(i=0; ishared->layout.u.chunk.dim[i]) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "offset doesn't fall on chunks's boundary") + + internal_offset[i] = offset[i]; + } + /* The library's chunking code requires the offset terminates with a zero */ + internal_offset[ndims] = 0; + /* write raw data */ - if(H5D__chunk_direct_write(dset, dxpl_id, filters, offset, data_size, buf) < 0) + if(H5D__chunk_direct_write(dset, dxpl_id, filters, internal_offset, data_size, buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data") done: diff --git a/test/dectris_tst.c b/test/dectris_tst.c index 56d58ab..ccc4310 100644 --- a/test/dectris_tst.c +++ b/test/dectris_tst.c @@ -58,7 +58,7 @@ main (void) unsigned filter_mask = 0; int direct_buf[CHUNK_NX][CHUNK_NY]; int check_chunk[CHUNK_NX][CHUNK_NY]; - hsize_t offset[3] = {0, 0, 0}; + hsize_t offset[2] = {0, 0}; size_t buf_size = CHUNK_NX*CHUNK_NY*sizeof(int); const Bytef *z_src = (const Bytef*)(direct_buf); -- cgit v0.12