summaryrefslogtreecommitdiffstats
path: root/tools/h5repack
diff options
context:
space:
mode:
Diffstat (limited to 'tools/h5repack')
-rw-r--r--tools/h5repack/CMakeLists.txt111
-rw-r--r--tools/h5repack/Makefile.in3
-rw-r--r--tools/h5repack/h5repack.c93
-rw-r--r--tools/h5repack/h5repack_copy.c63
-rw-r--r--tools/h5repack/h5repack_filters.c1
-rw-r--r--tools/h5repack/h5repack_verify.c1
6 files changed, 192 insertions, 80 deletions
diff --git a/tools/h5repack/CMakeLists.txt b/tools/h5repack/CMakeLists.txt
index b66020f..f24c7be 100644
--- a/tools/h5repack/CMakeLists.txt
+++ b/tools/h5repack/CMakeLists.txt
@@ -21,8 +21,7 @@ SET (REPACK_COMMON_SRCS
)
ADD_EXECUTABLE (h5repack ${REPACK_COMMON_SRCS} ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/h5repack_main.c)
-H5_NAMING (h5repack)
-TARGET_WIN_PROPERTIES (h5repack)
+H5_NAMING (h5repack ${LIB_TYPE})
TARGET_LINK_LIBRARIES (h5repack ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
SET (H5_DEP_EXECUTABLES h5repack)
@@ -38,8 +37,7 @@ IF (BUILD_TESTING)
# Add h5Repack test executables
# --------------------------------------------------------------------
ADD_EXECUTABLE (testh5repack_detect_szip ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testh5repack_detect_szip.c)
- H5_NAMING (testh5repack_detect_szip)
- TARGET_WIN_PROPERTIES (testh5repack_detect_szip)
+ H5_NAMING (testh5repack_detect_szip ${LIB_TYPE})
TARGET_LINK_LIBRARIES (testh5repack_detect_szip ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET})
ADD_TEST (NAME testh5repack_detect_szip COMMAND $<TARGET_FILE:testh5repack_detect_szip>)
@@ -57,11 +55,46 @@ IF (BUILD_TESTING)
ENDIF (HDF5_ENABLE_SZIP_SUPPORT)
ADD_EXECUTABLE (h5repacktest ${REPACK_COMMON_SRCS} ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/h5repacktst.c)
- H5_NAMING (h5repacktest)
- TARGET_WIN_PROPERTIES (h5repacktest)
+ H5_NAMING (h5repacktest ${LIB_TYPE})
TARGET_LINK_LIBRARIES (h5repacktest ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET})
ADD_TEST (NAME h5repacktest COMMAND $<TARGET_FILE:h5repacktest>)
+
+ IF (HDF5_TEST_VFD)
+
+ SET (VFD_LIST
+ sec2
+ stdio
+ core
+ split
+ multi
+ family
+ )
+
+ IF (DIRECT_VFD)
+ SET (VFD_LIST ${VFD_LIST} direct)
+ ENDIF (DIRECT_VFD)
+
+ MACRO (ADD_VFD_TEST vfdname resultcode)
+ ADD_TEST (
+ NAME VFD-${vfdname}-h5repacktest
+ COMMAND "${CMAKE_COMMAND}"
+ -D "TEST_PROGRAM=$<TARGET_FILE:h5repacktest>"
+ -D "TEST_ARGS:STRING="
+ -D "TEST_VFD:STRING=${vfdname}"
+ -D "TEST_EXPECT=${resultcode}"
+ -D "TEST_OUTPUT=h5repacktest"
+ -D "TEST_FOLDER=${PROJECT_BINARY_DIR}"
+ -P "${HDF5_RESOURCES_DIR}/vfdTest.cmake"
+ )
+ ENDMACRO (ADD_VFD_TEST)
+
+ # Run test with different Virtual File Driver
+ FOREACH (vfd ${VFD_LIST})
+ ADD_VFD_TEST (${vfd} 0)
+ ENDFOREACH (vfd ${VFD_LIST})
+
+ ENDIF (HDF5_TEST_VFD)
# --------------------------------------------------------------------
# Copy all the HDF5 files from the test directory into the source directory
@@ -225,6 +258,72 @@ IF (BUILD_TESTING)
##############################################################################
##############################################################################
+ # Remove any output file left over from previous test run
+ ADD_TEST (
+ NAME H5REPACK-clearall-objects
+ COMMAND ${CMAKE_COMMAND}
+ -E remove
+ h5repack_attr.h5.out
+ h5repack_attr.h5.out.err
+ h5repack_deflate.h5.out
+ h5repack_deflate.h5.out.err
+ h5repack_early.h5.out
+ h5repack_early.h5.out.err
+ h5repack_ext.h5.out
+ h5repack_ext.h5.out.err
+ h5repack_fill.h5.out
+ h5repack_fill.h5.out.err
+ h5repack_filters.h5.out
+ h5repack_filters.h5.out.err
+ h5repack_fletcher.h5.out
+ h5repack_fletcher.h5.out.err
+ h5repack_hlink.h5.out
+ h5repack_hlink.h5.out.err
+ h5repack_layout.h5.out
+ h5repack_layout.h5.out.err
+ h5repack_layout.h5-v.out
+ h5repack_layout.h5-v.out.err
+ h5repack_layouto.h5.out
+ h5repack_layouto.h5.out.err
+ h5repack_layout2.h5-v.out
+ h5repack_layout2.h5-v.out.err
+ h5repack_named_dtypes.h5.out
+ h5repack_named_dtypes.h5.out.err
+ h5repack_nbit.h5.out
+ h5repack_nbit.h5.out.err
+ h5repack_objs.h5.out
+ h5repack_objs.h5.out.err
+ h5repack_refs.h5.out
+ h5repack_refs.h5.out.err
+ h5repack_shuffle.h5.out
+ h5repack_shuffle.h5.out.err
+ h5repack_soffset.h5.out
+ h5repack_soffset.h5.out.err
+ h5repack_szip.h5.out
+ h5repack_szip.h5.out.err
+ h5repack_attr_out.h5
+ h5repack_deflate_out.h5
+ h5repack_early_out.h5
+ h5repack_ext_out.h5
+ h5repack_fill_out.h5
+ h5repack_filters_out.h5
+ h5repack_fletcher_out.h5
+ h5repack_hlink_out.h5
+ h5repack_layout_out.h5
+ h5repack_layouto_out.h5
+ h5repack_layout2_out.h5
+ h5repack_named_dtypes_out.h5
+ h5repack_nbit_out.h5
+ h5repack_objs_out.h5
+ h5repack_refs_out.h5
+ h5repack_shuffle_out.h5
+ h5repack_soffset_out.h5
+ h5repack_szip_out.h5
+ h5repack_ub.h5
+ h5repack_ub_out.h5
+ h5repack_attr_refs_out.h5
+ )
+
# --------------------------------------------------------------------
# test file names
# --------------------------------------------------------------------
diff --git a/tools/h5repack/Makefile.in b/tools/h5repack/Makefile.in
index b4e6b48..77b6734 100644
--- a/tools/h5repack/Makefile.in
+++ b/tools/h5repack/Makefile.in
@@ -160,6 +160,7 @@ DEFS = @DEFS@
DEPDIR = @DEPDIR@
DEPRECATED_SYMBOLS = @DEPRECATED_SYMBOLS@
DIRECT_VFD = @DIRECT_VFD@
+DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
DYNAMIC_DIRS = @DYNAMIC_DIRS@
@@ -221,6 +222,7 @@ LTLIBOBJS = @LTLIBOBJS@
LT_STATIC_EXEC = @LT_STATIC_EXEC@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
MPE = @MPE@
MPI_GET_SIZE = @MPI_GET_SIZE@
@@ -277,6 +279,7 @@ abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
diff --git a/tools/h5repack/h5repack.c b/tools/h5repack/h5repack.c
index da1fbf3..8c46638 100644
--- a/tools/h5repack/h5repack.c
+++ b/tools/h5repack/h5repack.c
@@ -407,7 +407,7 @@ int copy_attr(hid_t loc_in,
hid_t ftype_id=-1; /* file type ID */
hid_t wtype_id=-1; /* read/write type ID */
size_t msize; /* size of type */
- void *buf=NULL; /* data buffer */
+ void *buf = NULL; /* data buffer */
hsize_t nelmts; /* number of elements in dataset */
int rank; /* rank of dataset */
htri_t is_named; /* Whether the datatype is named */
@@ -424,28 +424,23 @@ int copy_attr(hid_t loc_in,
* copy all attributes
*-------------------------------------------------------------------------
*/
-
- for ( u = 0; u < (unsigned)oinfo.num_attrs; u++)
- {
- buf=NULL;
-
+ for(u = 0; u < (unsigned)oinfo.num_attrs; u++) {
/* open attribute */
if((attr_id = H5Aopen_by_idx(loc_in, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto error;
/* get name */
- if (H5Aget_name( attr_id, (size_t)255, name ) < 0)
+ if(H5Aget_name(attr_id, (size_t)255, name) < 0)
goto error;
/* get the file datatype */
- if ((ftype_id = H5Aget_type( attr_id )) < 0 )
+ if((ftype_id = H5Aget_type(attr_id)) < 0 )
goto error;
/* Check if the datatype is committed */
if((is_named = H5Tcommitted(ftype_id)) < 0)
goto error;
- if(is_named)
- {
+ if(is_named && travt) {
hid_t fidout;
/* Create out file id */
@@ -463,29 +458,27 @@ int copy_attr(hid_t loc_in,
if(H5Fclose(fidout) < 0)
goto error;
} /* end if */
+ else {
+ if(options->use_native == 1)
+ wtype_id = h5tools_get_native_type(ftype_id);
+ else
+ wtype_id = H5Tcopy(ftype_id);
+ } /* end else */
+
/* get the dataspace handle */
- if ((space_id = H5Aget_space( attr_id )) < 0 )
+ if((space_id = H5Aget_space(attr_id)) < 0)
goto error;
/* get dimensions */
- if ( (rank = H5Sget_simple_extent_dims(space_id, dims, NULL)) < 0 )
+ if((rank = H5Sget_simple_extent_dims(space_id, dims, NULL)) < 0)
goto error;
- nelmts=1;
- for (j=0; j<rank; j++)
- nelmts*=dims[j];
-
- /* wtype_id will have already been set if using a named dtype */
- if(!is_named)
- {
- if (options->use_native==1)
- wtype_id = h5tools_get_native_type(ftype_id);
- else
- wtype_id = H5Tcopy(ftype_id);
- } /* end if */
+ nelmts = 1;
+ for(j = 0; j < rank; j++)
+ nelmts *= dims[j];
- if ((msize=H5Tget_size(wtype_id))==0)
+ if((msize = H5Tget_size(wtype_id)) == 0)
goto error;
/*-------------------------------------------------------------------------
@@ -496,23 +489,20 @@ int copy_attr(hid_t loc_in,
*-------------------------------------------------------------------------
*/
- if (H5T_REFERENCE==H5Tget_class(wtype_id))
- {
+ if(H5T_REFERENCE == H5Tget_class(wtype_id)) {
;
}
- else
- {
+ else {
/*-------------------------------------------------------------------------
* read to memory
*-------------------------------------------------------------------------
*/
buf = (void *)HDmalloc((size_t)(nelmts * msize));
- if(buf == NULL)
- {
+ if(buf == NULL) {
error_msg("h5repack", "cannot read into memory\n" );
goto error;
- }
+ } /* end if */
if(H5Aread(attr_id, wtype_id, buf) < 0)
goto error;
@@ -530,10 +520,12 @@ int copy_attr(hid_t loc_in,
if(H5Aclose(attr_out) < 0)
goto error;
-
- if(buf)
- free(buf);
-
+ /* Check if we have VL data in the attribute's datatype that must
+ * be reclaimed */
+ if(TRUE == H5Tdetect_class(wtype_id, H5T_VLEN))
+ H5Dvlen_reclaim(wtype_id, space_id, H5P_DEFAULT, buf);
+ HDfree(buf);
+ buf = NULL;
} /*H5T_REFERENCE*/
@@ -545,28 +537,39 @@ int copy_attr(hid_t loc_in,
*-------------------------------------------------------------------------
*/
- if (H5Tclose(ftype_id) < 0) goto error;
- if (H5Tclose(wtype_id) < 0) goto error;
- if (H5Sclose(space_id) < 0) goto error;
- if (H5Aclose(attr_id) < 0) goto error;
-
+ if(H5Tclose(ftype_id) < 0)
+ goto error;
+ if(H5Tclose(wtype_id) < 0)
+ goto error;
+ if(H5Sclose(space_id) < 0)
+ goto error;
+ if(H5Aclose(attr_id) < 0)
+ goto error;
} /* u */
-
return 0;
error:
H5E_BEGIN_TRY {
+ if(buf) {
+ /* Check if we have VL data in the attribute's datatype that must
+ * be reclaimed */
+ if(TRUE == H5Tdetect_class(wtype_id, H5T_VLEN))
+ H5Dvlen_reclaim(wtype_id, space_id, H5P_DEFAULT, buf);
+
+ /* Free buf */
+ free(buf);
+ } /* end if */
+
H5Tclose(ftype_id);
H5Tclose(wtype_id);
H5Sclose(space_id);
H5Aclose(attr_id);
H5Aclose(attr_out);
- if (buf)
- free(buf);
} H5E_END_TRY;
+
return -1;
-}
+} /* end copy_attr() */
/*-------------------------------------------------------------------------
* Function: check_options
diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c
index 6c47cfb..f849697 100644
--- a/tools/h5repack/h5repack_copy.c
+++ b/tools/h5repack/h5repack_copy.c
@@ -543,22 +543,23 @@ int do_copy_objects(hid_t fidin,
trav_table_t *travt,
pack_opt_t *options) /* repack options */
{
- hid_t grp_in=-1; /* group ID */
- hid_t grp_out=-1; /* group ID */
- hid_t dset_in=-1; /* read dataset ID */
- hid_t dset_out=-1; /* write dataset ID */
- hid_t gcpl_in=-1; /* group creation property list */
- hid_t gcpl_out=-1; /* group creation property list */
- hid_t type_in=-1; /* named type ID */
- hid_t type_out=-1; /* named type ID */
- hid_t dcpl_id=-1; /* dataset creation property list ID */
- hid_t dcpl_out=-1; /* dataset creation property list ID */
- hid_t f_space_id=-1; /* file space ID */
- hid_t ftype_id=-1; /* file type ID */
- hid_t wtype_id=-1; /* read/write type ID */
- named_dt_t *named_dt_head=NULL; /* Pointer to the stack of named datatypes copied */
+ hid_t grp_in = -1; /* group ID */
+ hid_t grp_out = -1; /* group ID */
+ hid_t dset_in = -1; /* read dataset ID */
+ hid_t dset_out = -1; /* write dataset ID */
+ hid_t gcpl_in = -1; /* group creation property list */
+ hid_t gcpl_out = -1; /* group creation property list */
+ hid_t type_in = -1; /* named type ID */
+ hid_t type_out = -1; /* named type ID */
+ hid_t dcpl_id = -1; /* dataset creation property list ID */
+ hid_t dcpl_out = -1; /* dataset creation property list ID */
+ hid_t f_space_id = -1; /* file space ID */
+ hid_t ftype_id = -1; /* file type ID */
+ hid_t wtype_id = -1; /* read/write type ID */
+ 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 */
@@ -746,11 +747,13 @@ 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++)
- {
+ for(j = 0; j < rank; j++)
nelmts *= dims[j];
- }
/* wtype_id will have already been set if using a named dtype */
if(!is_named) {
@@ -834,20 +837,26 @@ 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 */
- if ( need < H5TOOLS_MALLOCSIZE )
+ 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);
- if (buf != NULL )
- {
- if (H5Dread(dset_in,wtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf) < 0)
+ if(buf != NULL) {
+ if(H5Dread(dset_in, wtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
goto error;
- if (H5Dwrite(dset_out,wtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf) < 0)
+ if(H5Dwrite(dset_out, wtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
goto error;
- }
+ /* Check if we have VL data in the dataset's
+ * datatype that must be reclaimed */
+ if(TRUE == H5Tdetect_class(wtype_id, H5T_VLEN))
+ if(H5Dvlen_reclaim(wtype_id, f_space_id, 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 */
@@ -949,7 +958,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
@@ -1364,7 +1373,7 @@ copy_user_block(const char *infile, const char *outfile, hsize_t size)
} /* end while */
/* Update size of userblock left to transfer */
- size -= nread;
+ size = size - (hsize_t)nread;
} /* end while */
done:
diff --git a/tools/h5repack/h5repack_filters.c b/tools/h5repack/h5repack_filters.c
index d4a3479..c7d8b1e 100644
--- a/tools/h5repack/h5repack_filters.c
+++ b/tools/h5repack/h5repack_filters.c
@@ -14,7 +14,6 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "h5repack.h"
-#include "h5test.h"
#include "h5tools.h"
/* number of members in an array */
diff --git a/tools/h5repack/h5repack_verify.c b/tools/h5repack/h5repack_verify.c
index 34c5dd6..b0ab1d1 100644
--- a/tools/h5repack/h5repack_verify.c
+++ b/tools/h5repack/h5repack_verify.c
@@ -14,7 +14,6 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "h5repack.h"
-#include "h5test.h"
#include "h5tools_utils.h"
static int verify_layout(hid_t pid, pack_info_t *obj);