From cd1b79599037add42d210ad445791a59d874cf3c Mon Sep 17 00:00:00 2001 From: Jonathan Kim Date: Thu, 18 Nov 2010 09:50:35 -0500 Subject: [svn-r19819] Purpose: Change to skip copying when a dataset is not allocated. Merged from hdf5 trunk r19818. Tested: jam (linux32-LE), amani (linux64-LE), heiwa (linuxppc64-BE) --- tools/h5repack/h5repack_copy.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c index d8b50b6..c8dce9f 100644 --- a/tools/h5repack/h5repack_copy.c +++ b/tools/h5repack/h5repack_copy.c @@ -515,6 +515,7 @@ int do_copy_objects(hid_t fidin, named_dt_t *named_dt_head=NULL; /* Pointer to the stack of named datatypes copied */ size_t msize; /* size of type */ hsize_t nelmts; /* number of elements in dataset */ + H5D_space_status_t *space_status; /* determines whether space has been allocated for the dataset */ int rank; /* rank of dataset */ hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */ hsize_t dsize_in; /* input dataset size before filter */ @@ -702,6 +703,10 @@ int do_copy_objects(hid_t fidin, HDmemset(dims, 0, sizeof dims); if(H5Sget_simple_extent_dims(f_space_id, dims, NULL) < 0) goto error; + + if(H5Dget_space_status(dset_in, &space_status) <0) + goto error; + nelmts = 1; for ( j = 0; j < rank; j++) { @@ -790,9 +795,11 @@ int do_copy_objects(hid_t fidin, * read/write *------------------------------------------------------------------------- */ - if (nelmts) + if (nelmts>0 && space_status!=H5D_SPACE_STATUS_NOT_ALLOCATED) { size_t need = (size_t)(nelmts*msize); /* bytes needed */ + + /* have to read the whole dataset if there is only one element in the dataset */ if ( need < H5TOOLS_MALLOCSIZE ) buf = HDmalloc(need); @@ -803,7 +810,6 @@ int do_copy_objects(hid_t fidin, if (H5Dwrite(dset_out,wtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf) < 0) goto error; } - else /* possibly not enough memory, read/write by hyperslabs */ { size_t p_type_nbytes = msize; /*size of memory type */ @@ -905,7 +911,7 @@ int do_copy_objects(hid_t fidin, sm_buf=NULL; } } /* hyperslab read */ - }/*nelmts*/ + } /* if (nelmts>0 && space_status==H5D_SPACE_STATUS_NOT_ALLOCATED) */ /*------------------------------------------------------------------------- * amount of compression used -- cgit v0.12