summaryrefslogtreecommitdiffstats
path: root/tools/src/h5repack
diff options
context:
space:
mode:
Diffstat (limited to 'tools/src/h5repack')
-rw-r--r--tools/src/h5repack/CMakeLists.txt4
-rw-r--r--tools/src/h5repack/Makefile.in62
-rw-r--r--tools/src/h5repack/h5repack.c154
-rw-r--r--tools/src/h5repack/h5repack.h38
-rw-r--r--tools/src/h5repack/h5repack_copy.c401
-rw-r--r--tools/src/h5repack/h5repack_filters.c84
-rw-r--r--tools/src/h5repack/h5repack_main.c194
-rw-r--r--tools/src/h5repack/h5repack_opttable.c44
-rw-r--r--tools/src/h5repack/h5repack_parse.c4
-rw-r--r--tools/src/h5repack/h5repack_refs.c218
-rw-r--r--tools/src/h5repack/h5repack_verify.c160
11 files changed, 754 insertions, 609 deletions
diff --git a/tools/src/h5repack/CMakeLists.txt b/tools/src/h5repack/CMakeLists.txt
index 4a1430e..a4aa1ef 100644
--- a/tools/src/h5repack/CMakeLists.txt
+++ b/tools/src/h5repack/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.10)
+cmake_minimum_required (VERSION 3.12)
project (HDF5_TOOLS_SRC_H5REPACK C)
# --------------------------------------------------------------------
@@ -17,6 +17,7 @@ set (REPACK_COMMON_SOURCES
if (NOT ONLY_SHARED_LIBS)
add_executable (h5repack ${REPACK_COMMON_SOURCES} ${HDF5_TOOLS_SRC_H5REPACK_SOURCE_DIR}/h5repack_main.c)
target_include_directories (h5repack PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5repack PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5repack STATIC)
target_link_libraries (h5repack PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
set_target_properties (h5repack PROPERTIES FOLDER tools)
@@ -28,6 +29,7 @@ endif ()
if (BUILD_SHARED_LIBS)
add_executable (h5repack-shared ${REPACK_COMMON_SOURCES} ${HDF5_TOOLS_SRC_H5REPACK_SOURCE_DIR}/h5repack_main.c)
target_include_directories (h5repack-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5repack-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5repack-shared SHARED)
target_link_libraries (h5repack-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
set_target_properties (h5repack-shared PROPERTIES FOLDER tools)
diff --git a/tools/src/h5repack/Makefile.in b/tools/src/h5repack/Makefile.in
index a3a12c5..743ddee 100644
--- a/tools/src/h5repack/Makefile.in
+++ b/tools/src/h5repack/Makefile.in
@@ -426,15 +426,15 @@ AMTAR = @AMTAR@
# H5_CFLAGS holds flags that should be used when building hdf5,
# but which should not be exported to h5cc for building other programs.
-# AM_CFLAGS is an automake construct which should be used by Makefiles
+# AM_CFLAGS is an automake construct which should be used by Makefiles
# instead of CFLAGS, as CFLAGS is reserved solely for the user to define.
# This applies to FCFLAGS, CXXFLAGS, CPPFLAGS, and LDFLAGS as well.
-AM_CFLAGS = @AM_CFLAGS@ @H5_CFLAGS@
+AM_CFLAGS = @AM_CFLAGS@ @H5_CFLAGS@ @H5_ECFLAGS@
# Include src, test, and tools/lib directories
AM_CPPFLAGS = @AM_CPPFLAGS@ @H5_CPPFLAGS@ -I$(top_srcdir)/src \
-I$(top_srcdir)/test -I$(top_srcdir)/tools/lib
-AM_CXXFLAGS = @AM_CXXFLAGS@ @H5_CXXFLAGS@
+AM_CXXFLAGS = @AM_CXXFLAGS@ @H5_CXXFLAGS@ @H5_ECXXFLAGS@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AM_FCFLAGS = @AM_FCFLAGS@ @H5_FCFLAGS@
AM_JAVACFLAGS = @AM_JAVACFLAGS@
@@ -454,6 +454,7 @@ CC = @CC@
CCDEPMODE = @CCDEPMODE@
CC_VERSION = @CC_VERSION@
CFLAGS = @CFLAGS@
+CLANG_SANITIZE_CHECKS = @CLANG_SANITIZE_CHECKS@
CODESTACK = @CODESTACK@
CONFIG_DATE = @CONFIG_DATE@
CONFIG_MODE = @CONFIG_MODE@
@@ -470,6 +471,7 @@ DEFAULT_API_VERSION = @DEFAULT_API_VERSION@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DEPRECATED_SYMBOLS = @DEPRECATED_SYMBOLS@
+DESIRED_FILE_LOCKING = @DESIRED_FILE_LOCKING@
DEV_WARNINGS = @DEV_WARNINGS@
DIRECT_VFD = @DIRECT_VFD@
DLLTOOL = @DLLTOOL@
@@ -506,8 +508,11 @@ H5_CFLAGS = @H5_CFLAGS@
H5_CLASSPATH = @H5_CLASSPATH@
H5_CPPFLAGS = @H5_CPPFLAGS@
H5_CXXFLAGS = @H5_CXXFLAGS@
+H5_ECFLAGS = @H5_ECFLAGS@
+H5_ECXXFLAGS = @H5_ECXXFLAGS@
H5_FCFLAGS = @H5_FCFLAGS@
H5_FORTRAN_SHARED = @H5_FORTRAN_SHARED@
+H5_IS_DARWIN = @H5_IS_DARWIN@
H5_JAVACFLAGS = @H5_JAVACFLAGS@
H5_JAVAFLAGS = @H5_JAVAFLAGS@
H5_JNIFLAGS = @H5_JNIFLAGS@
@@ -530,6 +535,7 @@ HL = @HL@
HL_FOR = @HL_FOR@
HSIZE_T = @HSIZE_T@
HSSIZE_T = @HSSIZE_T@
+IGNORE_DISABLED_FILE_LOCKS = @IGNORE_DISABLED_FILE_LOCKS@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -566,6 +572,7 @@ MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MEMORYALLOCSANITYCHECK = @MEMORYALLOCSANITYCHECK@
+MIRROR_VFD = @MIRROR_VFD@
MKDIR_P = @MKDIR_P@
MPE = @MPE@
NM = @NM@
@@ -625,6 +632,7 @@ TIME = @TIME@
TR = @TR@
TRACE_API = @TRACE_API@
UNAME_INFO = @UNAME_INFO@
+USE_FILE_LOCKING = @USE_FILE_LOCKING@
USE_FILTER_DEFLATE = @USE_FILTER_DEFLATE@
USE_FILTER_SZIP = @USE_FILTER_SZIP@
USINGMEMCHECKER = @USINGMEMCHECKER@
@@ -660,6 +668,7 @@ docdir = $(exec_prefix)/doc
dvidir = @dvidir@
enable_shared = @enable_shared@
enable_static = @enable_static@
+examplesdir = @examplesdir@
exec_prefix = @exec_prefix@
fortran_linux_linker_option = @fortran_linux_linker_option@
host = @host@
@@ -716,15 +725,15 @@ LIBH5_HL = $(top_builddir)/hl/src/libhdf5_hl.la
LIBH5F_HL = $(top_builddir)/hl/fortran/src/libhdf5hl_fortran.la
LIBH5CPP_HL = $(top_builddir)/hl/c++/src/libhdf5_hl_cpp.la
-# Note that in svn revision 19400 the '/' after DESTDIR in H5* variables below
-# has been removed. According to the official description of DESTDIR by Gnu at
-# http://www.gnu.org/prep/standards/html_node/DESTDIR.html, DESTDIR is
-# prepended to the normal and complete install path that it precedes for the
-# purpose of installing in a temporary directory which is useful for building
-# rpms and other packages. The '/' after ${DESTDIR} will be followed by another
-# '/' at the beginning of the normal install path. When DESTDIR is empty the
-# path then begins with '//', which is incorrect and causes problems at least for
-# Cygwin.
+# Note that in svn revision 19400 the '/' after DESTDIR in H5* variables below
+# has been removed. According to the official description of DESTDIR by Gnu at
+# http://www.gnu.org/prep/standards/html_node/DESTDIR.html, DESTDIR is
+# prepended to the normal and complete install path that it precedes for the
+# purpose of installing in a temporary directory which is useful for building
+# rpms and other packages. The '/' after ${DESTDIR} will be followed by another
+# '/' at the beginning of the normal install path. When DESTDIR is empty the
+# path then begins with '//', which is incorrect and causes problems at least for
+# Cygwin.
# Scripts used to build examples
# If only shared libraries have been installed, have h5cc build examples with
@@ -772,7 +781,7 @@ LIB = $(lib_LIBRARIES) $(lib_LTLIBRARIES) $(noinst_LIBRARIES) \
PROGS = $(bin_PROGRAMS) $(bin_SCRIPTS) $(noinst_PROGRAMS) $(noinst_SCRIPTS) \
$(EXTRA_PROG)
-chk_TESTS = $(check_PROGRAMS) $(check_SCRIPTS) $(EXTRA_TEST)
+chk_TESTS = $(check_PROGRAMS) $(check_SCRIPTS) $(EXTRA_TEST)
TEST_EXTENSIONS = .sh
SH_LOG_COMPILER = $(SHELL)
AM_SH_LOG_FLAGS =
@@ -1392,28 +1401,37 @@ $(TEST_PROG_CHKEXE) $(TEST_PROG_PARA_CHKEXE) dummy.chkexe_:
echo "============================" > $${log}; \
fi; \
if test "X$(FORTRAN_API)" = "Xyes"; then \
- echo "Fortran API: Testing $(HDF5_DRIVER) $${tname} $(TEST_FLAGS)"; \
+ echo "Fortran API: Testing $${tname} $(TEST_FLAGS)"; \
if test -n "$(REALTIMEOUTPUT)"; then \
- echo "Fortran API: $(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" | tee -a $${log}; \
+ echo "Fortran API: Test log for $${tname} $(TEST_FLAGS)" | tee -a $${log}; \
else \
- echo "Fortran API: $(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" >> $${log}; \
+ echo "Fortran API: Test log for $${tname} $(TEST_FLAGS)" >> $${log}; \
fi; \
elif test "X$(CXX_API)" = "Xyes"; then \
- echo "C++ API: Testing $(HDF5_DRIVER) $${tname} $(TEST_FLAGS)"; \
+ echo "C++ API: Testing $${tname} $(TEST_FLAGS)"; \
if test -n "$(REALTIMEOUTPUT)"; then \
- echo "C++ API: $(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" | tee -a $${log};\
+ echo "C++ API: Test log for $${tname} $(TEST_FLAGS)" | tee -a $${log};\
else \
- echo "C++ API: $(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" >> $${log};\
+ echo "C++ API: Test log for $${tname} $(TEST_FLAGS)" >> $${log};\
fi; \
else \
- echo "Testing $(HDF5_DRIVER) $${tname} $(TEST_FLAGS)"; \
+ echo "Testing: $${tname} $(TEST_FLAGS)"; \
if test -n "$(REALTIMEOUTPUT)"; then \
- echo "$(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" | tee -a $${log}; \
+ echo "Test log for $${tname} $(TEST_FLAGS)" | tee -a $${log}; \
else \
- echo "$(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" >> $${log}; \
+ echo "Test log for $${tname} $(TEST_FLAGS)" >> $${log}; \
fi; \
fi; \
if test -n "$(REALTIMEOUTPUT)"; then \
+ if test -n "$(HDF5_DRIVER)"; then \
+ echo "Virtual file driver (VFD): $(HDF5_DRIVER)" | tee -a $${log}; \
+ fi; \
+ else \
+ if test -n "$(HDF5_DRIVER)"; then \
+ echo "Virtual file driver (VFD): $(HDF5_DRIVER)" >> $${log}; \
+ fi; \
+ fi; \
+ if test -n "$(REALTIMEOUTPUT)"; then \
echo "============================" | tee -a $${log}; \
else \
echo "============================" >> $${log}; \
diff --git a/tools/src/h5repack/h5repack.c b/tools/src/h5repack/h5repack.c
index 0183cbf..77f2272 100644
--- a/tools/src/h5repack/h5repack.c
+++ b/tools/src/h5repack/h5repack.c
@@ -79,6 +79,8 @@ h5repack_init(pack_opt_t *options, int verbose, hbool_t latest)
options->layout_g = H5D_LAYOUT_ERROR;
options->low_bound = H5F_LIBVER_EARLIEST;
options->high_bound = H5F_LIBVER_LATEST;
+ options->fin_fapl = H5P_DEFAULT;
+ options->fout_fapl = H5P_DEFAULT;
for (n = 0; n < H5_REPACK_MAX_NFILTERS; n++) {
options->filter_g[n].filtn = -1;
@@ -225,10 +227,10 @@ copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, t
named_dt_t *dt = *named_dt_head_p; /* Stack pointer */
named_dt_t *dt_ret = NULL; /* Datatype to return */
H5O_info_t oinfo; /* Object info of input dtype */
- hid_t ret_value = -1; /* The identifier of the named dtype in the out file */
+ hid_t ret_value = H5I_INVALID_HID;
if (H5Oget_info2(type_in, &oinfo, H5O_INFO_BASIC) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Oget_info failed");
+ H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "H5Oget_info failed");
if (*named_dt_head_p) {
/* Stack already exists, search for the datatype */
@@ -244,13 +246,13 @@ copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, t
if (travt->objs[i].type == H5TRAV_TYPE_NAMED_DATATYPE) {
/* Push onto the stack */
if (NULL == (dt = (named_dt_t *)HDmalloc(sizeof(named_dt_t))))
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "buffer allocation failed failed");
+ H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "buffer allocation failed failed");
dt->next = *named_dt_head_p;
*named_dt_head_p = dt;
/* Update the address and id */
dt->addr_in = travt->objs[i].objno;
- dt->id_out = -1;
+ dt->id_out = H5I_INVALID_HID;
/* Check if this type is the one requested */
if (oinfo.addr == dt->addr_in) {
@@ -266,13 +268,13 @@ copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, t
if (!dt_ret) {
/* Push the new datatype onto the stack */
if (NULL == (dt_ret = (named_dt_t *)HDmalloc(sizeof(named_dt_t))))
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "buffer allocation failed failed");
+ H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "buffer allocation failed failed");
dt_ret->next = *named_dt_head_p;
*named_dt_head_p = dt_ret;
/* Update the address and id */
dt_ret->addr_in = oinfo.addr;
- dt_ret->id_out = -1;
+ dt_ret->id_out = H5I_INVALID_HID;
} /* end if requested datatype not found */
/* If the requested datatype does not yet exist in the output file, copy it
@@ -284,9 +286,9 @@ copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, t
else
dt_ret->id_out = H5Tcopy(type_in);
if (dt_ret->id_out < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_native_type-H5Tcopy failed");
+ H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "H5Tget_native_type-H5Tcopy failed");
if (H5Tcommit_anon(fidout, dt_ret->id_out, H5P_DEFAULT, H5P_DEFAULT) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tcommit_anon failed");
+ H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "H5Tcommit_anon failed");
} /* end if named datatype not yet in output file */
/* Set return value */
@@ -296,7 +298,7 @@ copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, t
* to close it. (TODO: fix scope envy)
*/
if (H5Iinc_ref(ret_value) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Iinc_ref failed");
+ H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "H5Iinc_ref failed");
done:
return ret_value;
@@ -312,12 +314,12 @@ int
named_datatype_free(named_dt_t **named_dt_head_p, int ignore_err)
{
named_dt_t *dt = *named_dt_head_p;
- int ret_value = -1;
+ int ret_value = -1;
while (dt) {
/* Pop the datatype off the stack and free it */
if (H5Tclose(dt->id_out) < 0 && !ignore_err)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
dt = dt->next;
HDfree(*named_dt_head_p);
*named_dt_head_p = dt;
@@ -343,12 +345,11 @@ done:
int
copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_t *travt, pack_opt_t *options)
{
- int ret_value = 0;
- hid_t attr_id = -1; /* attr ID */
- hid_t attr_out = -1; /* attr ID */
- hid_t space_id = -1; /* space ID */
- hid_t ftype_id = -1; /* file type ID */
- hid_t wtype_id = -1; /* read/write type ID */
+ hid_t attr_id = H5I_INVALID_HID; /* attr ID */
+ hid_t attr_out = H5I_INVALID_HID; /* attr ID */
+ hid_t space_id = H5I_INVALID_HID; /* space ID */
+ hid_t ftype_id = H5I_INVALID_HID; /* file type ID */
+ hid_t wtype_id = H5I_INVALID_HID; /* read/write type ID */
size_t msize; /* size of type */
void *buf = NULL; /* data buffer */
hsize_t nelmts; /* number of elements in dataset */
@@ -361,9 +362,10 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_
unsigned u;
hbool_t is_ref = 0;
H5T_class_t type_class = -1;
+ int ret_value = 0;
if (H5Oget_info2(loc_in, &oinfo, H5O_INFO_NUM_ATTRS) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Oget_info failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Oget_info failed");
/*-------------------------------------------------------------------------
* copy all attributes
@@ -372,33 +374,33 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_
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)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aopen_by_idx failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Aopen_by_idx failed");
if (H5Aget_name(attr_id, (size_t) 255, name) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
/* get the file datatype */
if ((ftype_id = H5Aget_type(attr_id)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_type failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Aget_type failed");
/* Check if the datatype is committed */
if ((is_named = H5Tcommitted(ftype_id)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tcommitted failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Tcommitted failed");
if (is_named && travt) {
- hid_t fidout = -1;
+ hid_t fidout = H5I_INVALID_HID;
/* Create out file id */
if ((fidout = H5Iget_file_id(loc_out)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Iget_file_id failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Iget_file_id failed");
/* Copy named dt */
if ((wtype_id = copy_named_datatype(ftype_id, fidout, named_dt_head_p, travt, options)) < 0) {
H5Fclose(fidout);
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_named_datatype failed");
+ H5TOOLS_GOTO_ERROR((-1), "copy_named_datatype failed");
}
if (H5Fclose(fidout) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Fclose failed");
} /* end if datatype is committed and we have a traversal table */
else {
if (options->use_native == 1)
@@ -409,18 +411,18 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_
/* get the dataspace handle */
if ((space_id = H5Aget_space(attr_id)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_space failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Aget_space failed");
/* get dimensions */
if ((rank = H5Sget_simple_extent_dims(space_id, dims, NULL)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_dims failed");
nelmts = 1;
for (j = 0; j < rank; j++)
nelmts *= dims[j];
if ((msize = H5Tget_size(wtype_id)) == 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Tget_size failed");
/*---------------------------------------------------------------------
* object references are a special case. We cannot just copy the
@@ -432,12 +434,12 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_
type_class = H5Tget_class(wtype_id);
is_ref = (type_class == H5T_REFERENCE);
if (type_class == H5T_VLEN || type_class == H5T_ARRAY) {
- hid_t base_type = -1;
+ hid_t base_type = H5I_INVALID_HID;
base_type = H5Tget_super(ftype_id);
is_ref = (is_ref || (H5Tget_class(base_type) == H5T_REFERENCE));
if (H5Tclose(base_type) < 0)
- H5TOOLS_INFO(H5E_tools_min_id_g, "H5Tclose base_type failed");
+ H5TOOLS_ERROR((-1), "H5Tclose base_type failed");
} /* end if type_class is variable length or array */
if (type_class == H5T_COMPOUND) {
@@ -447,7 +449,7 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_
hid_t mtid = H5Tget_member_type(wtype_id, (unsigned)j);
H5T_class_t mtclass = H5Tget_class(mtid);
if (H5Tclose(mtid) < 0)
- H5TOOLS_INFO(H5E_tools_min_id_g, "H5Tclose mtid failed");
+ H5TOOLS_ERROR((-1), "H5Tclose mtid failed");
if (mtclass == H5T_REFERENCE) {
is_ref = 1;
@@ -464,10 +466,10 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_
buf = (void *)HDmalloc((size_t)(nelmts * msize));
if (buf == NULL) {
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDmalloc failed");
+ H5TOOLS_GOTO_ERROR((-1), "HDmalloc failed");
} /* end if */
if (H5Aread(attr_id, wtype_id, buf) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aread failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Aread failed");
/*-----------------------------------------------------------------
* copy
@@ -475,13 +477,13 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_
*/
if ((attr_out = H5Acreate2(loc_out, name, wtype_id, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Acreate2 failed on ,%s>", name);
+ H5TOOLS_GOTO_ERROR((-1), "H5Acreate2 failed on ,%s>", name);
if (H5Awrite(attr_out, wtype_id, buf) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Awrite failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Awrite failed");
/*close*/
if (H5Aclose(attr_out) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Aclose failed");
/* Check if we have VL data and string in the attribute's datatype that must
* be reclaimed */
@@ -499,17 +501,17 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_
*---------------------------------------------------------------------
*/
if (H5Sclose(space_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed");
- space_id = -1;
+ H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed");
+ space_id = H5I_INVALID_HID;
if (H5Tclose(wtype_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
- wtype_id = -1;
+ H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
+ wtype_id = H5I_INVALID_HID;
if (H5Tclose(ftype_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
- ftype_id = -1;
+ H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
+ ftype_id = H5I_INVALID_HID;
if (H5Aclose(attr_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aclose failed");
- attr_id = -1;
+ H5TOOLS_GOTO_ERROR((-1), "H5Aclose failed");
+ attr_id = H5I_INVALID_HID;
} /* for u (each attribute) */
done:
@@ -520,6 +522,8 @@ done:
*/
if (TRUE == h5tools_detect_vlen(wtype_id))
H5Dvlen_reclaim(wtype_id, space_id, H5P_DEFAULT, buf);
+
+ /* Free buf */
HDfree(buf);
}
@@ -544,10 +548,10 @@ done:
static int
check_options(pack_opt_t *options)
{
- int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
unsigned int i;
int k, j, has_cp = 0, has_ck = 0;
char slayout[30];
+ int ret_value = 0;
/*-------------------------------------------------------------------------
* Objects to layout
@@ -571,10 +575,11 @@ check_options(pack_opt_t *options)
break;
case H5D_LAYOUT_ERROR:
case H5D_NLAYOUTS:
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "invalid layout");
+ H5TOOLS_GOTO_ERROR((-1), "invalid layout");
+ break;
default:
strcpy(slayout, "invalid layout\n");
- HGOTO_DONE(FAIL);
+ H5TOOLS_GOTO_DONE((-1));
}
HDprintf(" Apply %s layout to all", slayout);
if (H5D_CHUNKED == options->layout_g) {
@@ -609,7 +614,7 @@ check_options(pack_opt_t *options)
} /* end for each object in options */
if (options->all_layout == 1 && has_ck)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "invalid chunking input: 'all' option is present with other objects");
+ H5TOOLS_GOTO_ERROR((-1), "invalid chunking input: 'all' option is present with other objects");
/*-------------------------------------------------------------------------
* Objects to filter
@@ -667,7 +672,7 @@ check_options(pack_opt_t *options)
} /* end for each object in options table */
if (options->all_filter == 1 && has_cp)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "invalid compression input: 'all' option is present with other objects");
+ H5TOOLS_GOTO_ERROR((-1), "invalid compression input: 'all' option is present with other objects");
/*-------------------------------------------------------------------------
* Check options for the latest format
@@ -675,14 +680,14 @@ check_options(pack_opt_t *options)
*/
if (options->grp_compact < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "invalid maximum number of links to store as header messages");
+ H5TOOLS_GOTO_ERROR((-1), "invalid maximum number of links to store as header messages");
if (options->grp_indexed < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "invalid minimum number of links to store in the indexed format");
+ H5TOOLS_GOTO_ERROR((-1), "invalid minimum number of links to store in the indexed format");
if (options->grp_indexed > options->grp_compact)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "minimum indexed size is greater than the maximum compact size");
+ H5TOOLS_GOTO_ERROR((-1), "minimum indexed size is greater than the maximum compact size");
for (i = 0; i < 8; i++)
if (options->msg_size[i] < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "invalid shared message size");
+ H5TOOLS_GOTO_ERROR((-1), "invalid shared message size");
/*------------------------------------------------------------------------
* Verify new user userblock options; file name must be present
@@ -696,7 +701,7 @@ check_options(pack_opt_t *options)
}
if (options->ublock_filename == NULL && options->ublock_size != 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file name missing for user block", options->ublock_filename);
+ H5TOOLS_GOTO_ERROR((-1), "file name missing for user block", options->ublock_filename);
/*------------------------------------------------------------------------
* Verify alignment options; threshold is zero default but alignment not
@@ -704,7 +709,7 @@ check_options(pack_opt_t *options)
*/
if (options->alignment == 0 && options->threshold != 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "alignment for H5Pset_alignment missing");
+ H5TOOLS_GOTO_ERROR((-1), "alignment for H5Pset_alignment missing");
done:
return ret_value;
@@ -722,24 +727,25 @@ done:
static int
check_objects(const char* fname, pack_opt_t *options)
{
- hid_t fid = -1;
- hid_t did = -1;
- hid_t sid = -1;
+ hid_t fid = H5I_INVALID_HID;
+ hid_t did = H5I_INVALID_HID;
+ hid_t sid = H5I_INVALID_HID;
unsigned int i;
- int ifil;
+ int ifil;
trav_table_t *travt = NULL;
- int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
+ int ret_value = 0;
/* nothing to do */
if (options->op_tbl->nelems == 0)
- HGOTO_DONE(0);
+ H5TOOLS_GOTO_DONE(0);
/*-------------------------------------------------------------------------
* open the file
*-------------------------------------------------------------------------
*/
- if ((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, 0)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5tools_fopen failed <%s>: %s", fname, H5FOPENERROR);
+ if ((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, options->fin_fapl,
+ (options->fin_fapl == H5P_DEFAULT) ? FALSE : TRUE, NULL, 0)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fname, H5FOPENERROR);
/*-------------------------------------------------------------------------
* get the list of objects in the file
@@ -753,7 +759,7 @@ check_objects(const char* fname, pack_opt_t *options)
/* get the list of objects in the file */
if (h5trav_gettable(fid, travt) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5trav_gettable failed");
+ H5TOOLS_GOTO_ERROR((-1), "h5trav_gettable failed");
/*-------------------------------------------------------------------------
* compare with user supplied list
@@ -772,14 +778,14 @@ check_objects(const char* fname, pack_opt_t *options)
/* the input object names are present in the file and are valid */
if (h5trav_getindext(name, travt) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "%s Could not find <%s> in file <%s>. Exiting...\n",
+ H5TOOLS_GOTO_ERROR((-1), "%s Could not find <%s> in file <%s>. Exiting...\n",
(options->verbose ? "\n" : ""), name, fname);
if (options->verbose)
HDprintf("...Found\n");
for (ifil = 0; ifil < obj.nfilters; ifil++) {
if (obj.filter[ifil].filtn < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "invalid filter");
+ H5TOOLS_GOTO_ERROR((-1), "invalid filter");
/* check for extra filter conditions */
switch (obj.filter[ifil].filtn) {
/* chunk size must be smaller than pixels per block */
@@ -798,25 +804,25 @@ check_objects(const char* fname, pack_opt_t *options)
}
else {
if ((did = H5Dopen2(fid, name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed");
if ((sid = H5Dget_space(did)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed");
if ((rank = H5Sget_simple_extent_ndims(sid)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_ndims failed");
HDmemset(dims, 0, sizeof dims);
if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_dims failed");
for (j = 0; j < rank; j++)
csize *= dims[j];
if (H5Sclose(sid) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed");
if (H5Dclose(did) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed");
}
if (csize < ppb) {
HDprintf(" <warning: SZIP settings, chunk size is smaller than pixels per block>\n");
- HGOTO_DONE(0);
+ H5TOOLS_GOTO_DONE(0);
}
} /* end case SZIP */
break;
diff --git a/tools/src/h5repack/h5repack.h b/tools/src/h5repack/h5repack.h
index a0e0387..a8207b5 100644
--- a/tools/src/h5repack/h5repack.h
+++ b/tools/src/h5repack/h5repack.h
@@ -101,23 +101,27 @@ typedef struct {
/* all the above, ready to go to the hrepack call */
typedef struct {
- pack_opttbl_t *op_tbl; /*table with all -c and -f options */
- int all_layout; /*apply the layout to all objects */
- int all_filter; /*apply the filter to all objects */
+ pack_opttbl_t *op_tbl; /* table with all -c and -f options */
+ int all_layout; /* apply the layout to all objects */
+ int all_filter; /* apply the filter to all objects */
filter_info_t filter_g[H5_REPACK_MAX_NFILTERS]; /*global filter array for the ALL case */
- int n_filter_g; /*number of global filters */
- chunk_info_t chunk_g; /*global chunk INFO for the ALL case */
- H5D_layout_t layout_g; /*global layout information for the ALL case */
- int verbose; /*verbose mode */
- hsize_t min_comp; /*minimum size to compress, in bytes */
- int use_native; /*use a native type in write */
- hbool_t latest; /*pack file with the latest file format */
- H5F_libver_t low_bound; /* The file's low bound as in H5Fset_libver_bounds() */
- H5F_libver_t high_bound; /* The file's high bound as in H5Fset_libver_bounds() */
- int grp_compact; /* Set the maximum number of links to store as header messages in the group */
- int grp_indexed; /* Set the minimum number of links to store in the indexed format */
- int msg_size[8]; /* Minimum size of shared messages: dataspace,
- datatype, fill value, filter pipleline, attribute */
+ int n_filter_g; /* number of global filters */
+ chunk_info_t chunk_g; /* global chunk INFO for the ALL case */
+ H5D_layout_t layout_g; /* global layout information for the ALL case */
+ int verbose; /* verbose mode */
+ hbool_t merge; /* Merge external file. */
+ hbool_t prune; /* Don't follow external file. */
+ hsize_t min_comp; /* minimum size to compress, in bytes */
+ int use_native; /* use a native type in write */
+ hbool_t latest; /* pack file with the latest file format */
+ H5F_libver_t low_bound; /* The file's low bound as in H5Fset_libver_bounds() */
+ H5F_libver_t high_bound; /* The file's high bound as in H5Fset_libver_bounds() */
+ hid_t fin_fapl; /* FAPL to use for opening the input file */
+ hid_t fout_fapl; /* FAPL to use for opening/creating the output file */
+ int grp_compact; /* Set the maximum number of links to store as header messages in the group */
+ int grp_indexed; /* Set the minimum number of links to store in the indexed format */
+ int msg_size[8]; /* Minimum size of shared messages: dataspace,
+ datatype, fill value, filter pipleline, attribute */
const char *ublock_filename; /* user block file name */
hsize_t ublock_size; /* user block size */
hsize_t meta_block_size; /* metadata aggregation block size (for H5Pset_meta_block_size) */
@@ -151,7 +155,7 @@ int h5repack_addlayout(const char* str, pack_opt_t *options);
int h5repack_init(pack_opt_t *options, int verbose, hbool_t latest);
int h5repack_end(pack_opt_t *options);
int h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options);
-int h5repack_cmp_pl(const char *fname1, const char *fname2);
+int h5repack_cmp_pl(const char *fname1, hid_t fname1_fapl, const char *fname2, hid_t fname2_fapl);
/* Note: The below copy_named_datatype(), named_datatype_free(), copy_attr()
* and struct named_dt_t were located in h5repack_copy.c as static prior to
diff --git a/tools/src/h5repack/h5repack_copy.c b/tools/src/h5repack/h5repack_copy.c
index f6409e3..4d330d1 100644
--- a/tools/src/h5repack/h5repack_copy.c
+++ b/tools/src/h5repack/h5repack_copy.c
@@ -61,14 +61,12 @@ static void print_user_block(const char *filename, hid_t fid);
int
copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
{
- int ret_value = 0;
- hid_t fidin = -1;
- hid_t fidout = -1;
- hid_t fcpl_in = -1; /* file creation property list ID for input file */
- hid_t grp_in = -1; /* group ID */
- hid_t gcpl_in = -1; /* group creation property list */
+ hid_t fidin = H5I_INVALID_HID;
+ hid_t fidout = H5I_INVALID_HID;
+ hid_t fcpl_in = H5I_INVALID_HID; /* file creation property list ID for input file */
+ hid_t grp_in = H5I_INVALID_HID; /* group ID */
+ hid_t gcpl_in = H5I_INVALID_HID; /* group creation property list */
hid_t fcpl = H5P_DEFAULT; /* file creation property list ID */
- hid_t fapl = H5P_DEFAULT; /* file access property list ID */
trav_table_t *travt = NULL;
hsize_t ub_size = 0; /* size of user block */
H5F_fspace_strategy_t set_strategy; /* Strategy to be set in outupt file */
@@ -80,65 +78,69 @@ copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
hsize_t in_threshold; /* Free-space section threshold from input file */
hsize_t in_pagesize; /* File space page size from input file */
unsigned crt_order_flags; /* group creation order flag */
+ int ret_value = 0;
/*-------------------------------------------------------------------------
* open input file
*-------------------------------------------------------------------------
*/
- if ((fidin = h5tools_fopen(fnamein, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t) 0)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5tools_fopen failed <%s>: %s", fnamein, H5FOPENERROR);
+ if ((fidin = h5tools_fopen(fnamein, H5F_ACC_RDONLY, options->fin_fapl,
+ (options->fin_fapl == H5P_DEFAULT) ? FALSE : TRUE, NULL, (size_t) 0)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fnamein, H5FOPENERROR);
/* get user block size and file space strategy/persist/threshold */
{
if ((fcpl_in = H5Fget_create_plist(fidin)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fget_create_plist failed to retrieve file creation property list");
+ H5TOOLS_GOTO_ERROR((-1), "H5Fget_create_plist failed to retrieve file creation property list");
if (H5Pget_userblock(fcpl_in, &ub_size) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_userblock failed to retrieve userblock size");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pget_userblock failed to retrieve userblock size");
/* If the -S option is not set, get "strategy" from the input file */
if(H5Pget_file_space_strategy(fcpl_in, &in_strategy, &in_persist, &in_threshold) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_file_space_strategy failed to retrieve file space strategy");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pget_file_space_strategy failed to retrieve file space strategy");
/* If the -G option is not set, get "pagesize" from the input file */
if(H5Pget_file_space_page_size(fcpl_in, &in_pagesize) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_file_space_page_size failed to retrieve file space threshold");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pget_file_space_page_size failed to retrieve file space threshold");
/* open root group */
if ((grp_in = H5Gopen2(fidin, "/", H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gopen2 failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Gopen2 failed");
/* get root group creation property list */
if ((gcpl_in = H5Gget_create_plist(grp_in)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gget_create_plist failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Gget_create_plist failed");
/* query and set the group creation properties */
if (H5Pget_link_creation_order(gcpl_in, &crt_order_flags) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_link_creation_order failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pget_link_creation_order failed");
if (H5Pclose(fcpl_in) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed to close property list");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed to close property list");
}
if(options->latest)
options->low_bound = options->high_bound = H5F_LIBVER_LATEST;
+
/* Create file access property list */
- if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed to create file access property list");
+ if (options->fout_fapl == H5P_DEFAULT)
+ if ((options->fout_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed to create file access property list");
/* It can be default, latest or other settings by users */
- if(H5Pset_libver_bounds(fapl, options->low_bound, options->high_bound) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_libver_bounds failed to set format version bounds");
+ if(H5Pset_libver_bounds(options->fout_fapl, options->low_bound, options->high_bound) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_libver_bounds failed to set format version bounds");
/* Check if we need to create a non-default file creation property list */
if (options->low_bound >= H5F_LIBVER_V18 || ub_size > 0) {
/* Create file creation property list */
if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed to create a file creation property list");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed to create a file creation property list");
if (ub_size > 0)
if (H5Pset_userblock(fcpl, ub_size) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_userblock failed to set non-default userblock size");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_userblock failed to set non-default userblock size");
if (options->low_bound >= H5F_LIBVER_V18) {
unsigned i = 0, nindex = 0, mesg_type_flags[5], min_mesg_sizes[5];
@@ -146,7 +148,7 @@ copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
/* Adjust group creation parameters for root group */
/* (So that it is created in "dense storage" form) */
if (H5Pset_link_phase_change(fcpl, (unsigned) options->grp_compact, (unsigned) options->grp_indexed) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_link_phase_change failed to adjust group creation parameters for root group");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_link_phase_change failed to adjust group creation parameters for root group");
for (i = 0; i < 5; i++) {
if (options->msg_size[i] > 0) {
@@ -182,12 +184,12 @@ copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
if (nindex > 0) {
if (H5Pset_shared_mesg_nindexes(fcpl, nindex) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_shared_mesg_nindexes failed to set the number of shared object header message indexes");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_shared_mesg_nindexes failed to set the number of shared object header message indexes");
/* msg_size[0]=dataspace, 1=datatype, 2=file value, 3=filter pipleline, 4=attribute */
for (i = 0; i < (nindex - 1); i++)
if (H5Pset_shared_mesg_index(fcpl, i, mesg_type_flags[i], min_mesg_sizes[i]) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_shared_mesg_index failed to configure the specified shared object header message index");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_shared_mesg_index failed to configure the specified shared object header message index");
} /* if (nindex>0) */
} /* end if */
@@ -205,11 +207,11 @@ print_user_block(fnamein, fidin);
if (fcpl == H5P_DEFAULT)
/* create a file creation property list */
if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed to create a file creation property list");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed to create a file creation property list");
/* set user block size */
if (H5Pset_userblock(fcpl, options->ublock_size) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_userblock failed to set userblock size");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_userblock failed to set userblock size");
}
/*-------------------------------------------------------------------------
@@ -218,13 +220,13 @@ print_user_block(fnamein, fidin);
*/
if (options->alignment > 0) {
/* either use the FAPL already created or create a new one */
- if (fapl == H5P_DEFAULT)
+ if (options->fout_fapl == H5P_DEFAULT)
/* create a file access property list */
- if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed to create file access property list");
+ if ((options->fout_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed to create file access property list");
- if (H5Pset_alignment(fapl, options->threshold, options->alignment) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_alignment failed to set alignment");
+ if (H5Pset_alignment(options->fout_fapl, options->threshold, options->alignment) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_alignment failed to set alignment");
}
/*-------------------------------------------------------------------------
@@ -233,13 +235,13 @@ print_user_block(fnamein, fidin);
*/
if (options->meta_block_size > 0) {
/* either use the FAPL already created or create a new one */
- if (fapl == H5P_DEFAULT)
+ if (options->fout_fapl == H5P_DEFAULT)
/* create a file access property list */
- if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed to create file access property list");
+ if ((options->fout_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed to create file access property list");
- if (H5Pset_meta_block_size(fapl, options->meta_block_size) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_meta_block_size failed to set metadata block size");
+ if (H5Pset_meta_block_size(options->fout_fapl, options->meta_block_size) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_meta_block_size failed to set metadata block size");
}
/*-------------------------------------------------------------------------
@@ -251,10 +253,10 @@ print_user_block(fnamein, fidin);
if (fcpl == H5P_DEFAULT)
/* create a file creation property list */
if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed to create a file creation property list");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed to create a file creation property list");
if(H5Pset_link_creation_order(fcpl, crt_order_flags ) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_link_creation_order failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_link_creation_order failed");
/* Set file space info to those from input file */
set_strategy = in_strategy;
@@ -279,7 +281,7 @@ print_user_block(fnamein, fidin);
/* Set file space information as specified */
if(H5Pset_file_space_strategy(fcpl, set_strategy, set_persist, set_threshold) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_file_space_strategy failed to set file space strategy");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_file_space_strategy failed to set file space strategy");
if(options->fs_pagesize == -1) /* A "0" file space page size is specified by user */
set_pagesize = (hsize_t)0;
@@ -288,7 +290,7 @@ print_user_block(fnamein, fidin);
if(set_pagesize != FS_PAGESIZE_DEF) /* Set non-default file space page size as specified */
if(H5Pset_file_space_page_size(fcpl, set_pagesize) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_file_space_page_size failed to set file space page size");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_file_space_page_size failed to set file space page size");
/*-------------------------------------------------------------------------
* create the output file
@@ -297,8 +299,8 @@ print_user_block(fnamein, fidin);
if (options->verbose)
HDprintf("Making new file ...\n");
- if ((fidout = H5Fcreate(fnameout, H5F_ACC_TRUNC, fcpl, fapl)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fcreate could not create file <%s>:", fnameout);
+ if ((fidout = H5Fcreate(fnameout, H5F_ACC_TRUNC, fcpl, options->fout_fapl)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Fcreate could not create file <%s>:", fnameout);
/*-------------------------------------------------------------------------
* write a new user block if requested
@@ -306,7 +308,7 @@ print_user_block(fnamein, fidin);
*/
if (options->ublock_size > 0)
if (copy_user_block(options->ublock_filename, fnameout, options->ublock_size) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not copy user block. Exiting...");
+ H5TOOLS_GOTO_ERROR((-1), "Could not copy user block. Exiting...");
/*-------------------------------------------------------------------------
* get list of objects
@@ -321,14 +323,14 @@ print_user_block(fnamein, fidin);
if (travt) {
/* get the list of objects in the file */
if (h5trav_gettable(fidin, travt) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5trav_gettable failed");
+ H5TOOLS_GOTO_ERROR((-1), "h5trav_gettable failed");
/*-------------------------------------------------------------------------
* do the copy
*-------------------------------------------------------------------------
*/
if (do_copy_objects(fidin, fidout, travt, options) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "do_copy_objects from <%s> could not copy data to <%s>", fnamein, fnameout);
+ H5TOOLS_GOTO_ERROR((-1), "do_copy_objects from <%s> could not copy data to <%s>", fnamein, fnameout);
/*-------------------------------------------------------------------------
* do the copy of referenced objects
@@ -336,7 +338,7 @@ print_user_block(fnamein, fidin);
*-------------------------------------------------------------------------
*/
if (do_copy_refobjs(fidin, fidout, travt, options) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "do_copy_refobjs from <%s> could not copy data to <%s>", fnamein, fnameout);
+ H5TOOLS_GOTO_ERROR((-1), "do_copy_refobjs from <%s> could not copy data to <%s>", fnamein, fnameout);
}
/*-------------------------------------------------------------------------
@@ -346,13 +348,12 @@ print_user_block(fnamein, fidin);
if (ub_size > 0 && options->ublock_size == 0)
if (copy_user_block(fnamein, fnameout, ub_size) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not copy user block. Exiting...");
+ H5TOOLS_GOTO_ERROR((-1), "Could not copy user block. Exiting...");
done:
H5E_BEGIN_TRY {
H5Pclose(fcpl_in);
H5Pclose(gcpl_in);
- H5Pclose(fapl);
H5Pclose(fcpl);
H5Gclose(grp_in);
H5Fclose(fidin);
@@ -402,7 +403,6 @@ int
get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[],
size_t size_datum, hsize_t dims_hslab[], hsize_t * hslab_nbytes_p)
{
- int ret_value = 0;
int k;
H5D_layout_t dset_layout;
int rank_chunk;
@@ -413,6 +413,7 @@ get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[],
hsize_t chunk_dims_map[H5S_MAX_RANK]; /* mapped chunk dimentions */
hsize_t hs_dims_map[H5S_MAX_RANK]; /* mapped hyperslab dimentions */
hsize_t hslab_nbytes; /* size of hyperslab in byte */
+ int ret_value = 0;
/* init to set as size of a data element */
hslab_nbytes = size_datum;
@@ -425,7 +426,7 @@ get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[],
/* get chunk dims */
rank_chunk = H5Pget_chunk(dcpl_id, rank_dset, dims_chunk);
if (rank_chunk < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_chunk failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pget_chunk failed");
for (k = rank_dset; k > 0; --k)
size_chunk *= dims_chunk[k - 1];
@@ -487,7 +488,7 @@ get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[],
hslab_nbytes *= dims_hslab[k - 1];
if (hslab_nbytes <= 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "calculate total size for the hyperslab failed");
+ H5TOOLS_GOTO_ERROR((-1), "calculate total size for the hyperslab failed");
}
}
}
@@ -511,7 +512,7 @@ get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[],
hslab_nbytes *= dims_hslab[k - 1];
if (hslab_nbytes <= 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "calculate total size for the hyperslab failed");
+ H5TOOLS_GOTO_ERROR((-1), "calculate total size for the hyperslab failed");
}
}
@@ -580,20 +581,21 @@ int
do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
pack_opt_t *options) /* repack options */
{
- int ret_value = 0;
- 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_in = -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 */
+ hid_t grp_in = H5I_INVALID_HID; /* group ID */
+ hid_t grp_out = H5I_INVALID_HID; /* group ID */
+ hid_t dset_in = H5I_INVALID_HID; /* read dataset ID */
+ hid_t dset_out = H5I_INVALID_HID; /* write dataset ID */
+ hid_t gcpl_in = H5I_INVALID_HID; /* group creation property list */
+ hid_t gcpl_out = H5I_INVALID_HID; /* group creation property list */
+ hid_t type_in = H5I_INVALID_HID; /* named type ID */
+ hid_t type_out = H5I_INVALID_HID; /* named type ID */
+ hid_t dcpl_in = H5I_INVALID_HID; /* dataset creation property list ID */
+ hid_t dcpl_out = H5I_INVALID_HID; /* dataset creation property list ID */
+ hid_t f_space_id = H5I_INVALID_HID; /* file space ID */
+ hid_t ftype_id = H5I_INVALID_HID; /* file type ID */
+ hid_t wtype_id = H5I_INVALID_HID; /* read/write type ID */
+ hid_t ocpl_id = H5I_INVALID_HID; /* property to pass copy options */
+ hid_t lcpl_id = H5I_INVALID_HID; /* link creation property list */
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 */
@@ -610,6 +612,7 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
int req_filter; /* there was a request for a filter */
int req_obj_layout = 0; /* request layout to current object */
unsigned crt_order_flags; /* group creation order flag */
+ h5tool_link_info_t linkinfo;
unsigned i;
unsigned u;
int ifil;
@@ -617,6 +620,10 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
htri_t is_named;
hbool_t limit_maxdims;
hsize_t size_dset;
+ int ret_value = 0;
+
+ /* init linkinfo struct */
+ HDmemset(&linkinfo, 0, sizeof(h5tool_link_info_t));
/*-------------------------------------------------------------------------
* copy the supplied object list
@@ -649,22 +656,22 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
/* open input group */
if ((grp_in = H5Gopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gopen2 failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Gopen2 failed");
/* get input group creation property list */
if ((gcpl_in = H5Gget_create_plist(grp_in)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gget_create_plist failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Gget_create_plist failed");
/* query and set the group creation properties */
if (H5Pget_link_creation_order(gcpl_in, &crt_order_flags) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_link_creation_order failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pget_link_creation_order failed");
/* set up group creation property list */
if ((gcpl_out = H5Pcreate(H5P_GROUP_CREATE)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed");
if (H5Pset_link_creation_order(gcpl_out, crt_order_flags) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_link_creation_order failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_link_creation_order failed");
/*-------------------------------------------------------------------------
* the root is a special case, we get an ID for the root group
@@ -673,15 +680,15 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
*/
if (HDstrcmp(travt->objs[i].name, "/") == 0) {
if ((grp_out = H5Gopen2(fidout, "/", H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gopen2 failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Gopen2 failed");
}
else {
if (options->grp_compact > 0 || options->grp_indexed > 0)
if (H5Pset_link_phase_change(gcpl_out, (unsigned) options->grp_compact, (unsigned) options->grp_indexed) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_link_phase_change failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_link_phase_change failed");
if ((grp_out = H5Gcreate2(fidout, travt->objs[i].name, H5P_DEFAULT, gcpl_out, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gcreate2 failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Gcreate2 failed");
}
/*-------------------------------------------------------------------------
@@ -689,24 +696,27 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
*-------------------------------------------------------------------------
*/
if (copy_attr(grp_in, grp_out, &named_dt_head, travt, options) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_attr failed");
+ H5TOOLS_GOTO_ERROR((-1), "copy_attr failed");
if (H5Pclose(gcpl_out) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
if (H5Pclose(gcpl_in) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
if (H5Gclose(grp_out) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Gclose failed");
if (H5Gclose(grp_in) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Gclose failed");
break;
- /*-------------------------------------------------------------------------
- * H5TRAV_TYPE_DATASET
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5TRAV_TYPE_DATASET
+ *-------------------------------------------------------------------------
+ */
case H5TRAV_TYPE_DATASET:
+ {
+ hbool_t use_h5ocopy;
+
has_filter = 0;
req_filter = 0;
@@ -740,23 +750,23 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
/* early detection of references */
if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed");
if ((ftype_id = H5Dget_type(dset_in)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_type failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_type failed");
if (H5T_REFERENCE == H5Tget_class(ftype_id))
is_ref = 1;
/* Check if the datatype is committed */
if ((is_named = H5Tcommitted(ftype_id)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tcommitted failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Tcommitted failed");
if (is_named)
if ((wtype_id = copy_named_datatype(ftype_id, fidout, &named_dt_head, travt, options)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_named_datatype failed");
+ H5TOOLS_GOTO_ERROR((-1), "copy_named_datatype failed");
if (H5Tclose(ftype_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
if (H5Dclose(dset_in) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed");
/*-------------------------------------------------------------------------
* check if we should use H5Ocopy or not
@@ -764,26 +774,27 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
* otherwise we do a copy using H5Ocopy
*-------------------------------------------------------------------------
*/
- if (options->op_tbl->nelems || options->all_filter == 1
- || options->all_layout == 1 || is_ref || is_named) {
+ use_h5ocopy = !(options->op_tbl->nelems || options->all_filter == 1
+ || options->all_layout == 1 || is_ref || is_named);
+ if (!use_h5ocopy) {
int j;
if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed");
if ((f_space_id = H5Dget_space(dset_in)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed");
if ((ftype_id = H5Dget_type(dset_in)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_type failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_type failed");
if ((dcpl_in = H5Dget_create_plist(dset_in)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed");
if ((rank = H5Sget_simple_extent_ndims(f_space_id)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_ndims failed");
HDmemset(dims, 0, sizeof dims);
if (H5Sget_simple_extent_dims(f_space_id, dims, NULL) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_dims failed");
if (H5Dget_space_status(dset_in, &space_status) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space_status failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_space_status failed");
/* If the input dataset has external storage, it must be contiguous.
* Accordingly, there would be no filter or chunk properties to preserve,
@@ -792,10 +803,10 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
*/
if (H5Pget_external_count(dcpl_in)) {
if ((dcpl_out = H5Pcreate(H5P_DATASET_CREATE)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed");
}
else if ((dcpl_out = H5Pcopy(dcpl_in)) < 0) {
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcopy failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pcopy failed");
}
nelmts = 1;
@@ -811,7 +822,7 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
}
if ((msize = H5Tget_size(wtype_id)) == 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Tget_size failed");
/* size of current dset */
size_dset = nelmts * msize;
@@ -848,7 +859,7 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
/* apply the filter */
if (apply_s)
if (apply_filters(travt->objs[i].name, rank, dims, msize, dcpl_out, options, &has_filter) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "apply_filters failed");
+ H5TOOLS_GOTO_ERROR((-1), "apply_filters failed");
/* only if layout change requested for entire file or
* individual obj */
@@ -888,13 +899,13 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
*-------------------------------------------------------------------------
*/
dset_out = H5Dcreate2(fidout, travt->objs[i].name, wtype_id, f_space_id, H5P_DEFAULT, dcpl_out, H5P_DEFAULT);
- if (dset_out == FAIL) {
- H5Epush2(H5tools_ERR_STACK_g, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_id_g, "H5Dcreate2 failed");
+ if (dset_out == H5I_INVALID_HID) {
+ H5TOOLS_INFO("H5Dcreate2 failed");
if (options->verbose)
HDprintf(" warning: could not create dataset <%s>. Applying original settings\n", travt->objs[i].name);
if ((dset_out = H5Dcreate2(fidout, travt->objs[i].name, wtype_id, f_space_id, H5P_DEFAULT, dcpl_in, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dcreate2 failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dcreate2 failed");
apply_f = 0;
} /* end if retry dataset create */
@@ -911,15 +922,15 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
if (buf != NULL) {
if(H5Dread(dset_in, wtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dread failed");
if(H5Dwrite(dset_out, wtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dwrite failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dwrite failed");
/* 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)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dvlen_reclaim failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dvlen_reclaim failed");
if (buf != NULL) { /* TODO: is buf potentially released by H5Dvlen_reclaim()? */
HDfree(buf);
@@ -946,7 +957,7 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
hsize_t zero[8]; /*vector of zeros */
int k;
H5D_layout_t dset_layout;
- hid_t dcpl_tmp = -1; /* dataset creation property list ID */
+ hid_t dcpl_tmp = H5I_INVALID_HID; /* dataset creation property list ID */
/* check if we have VL data in the dataset's datatype */
if (H5Tdetect_class(wtype_id, H5T_VLEN) == TRUE)
@@ -965,11 +976,11 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
/* get hyperslab dims and size in byte */
if (get_hyperslab(dcpl_tmp, rank, dims, p_type_nbytes, hslab_dims, &hslab_nbytes) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "get_hyperslab failed");
+ H5TOOLS_GOTO_ERROR((-1), "get_hyperslab failed");
hslab_buf = HDmalloc((size_t)hslab_nbytes);
if (hslab_buf == NULL)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "can't allocate space for hyperslab");
+ H5TOOLS_GOTO_ERROR((-1), "can't allocate space for hyperslab");
hslab_nelmts = hslab_nbytes / p_type_nbytes;
hslab_space = H5Screate_simple(1, &hslab_nelmts, NULL);
@@ -993,9 +1004,9 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
}
if (H5Sselect_hyperslab(f_space_id, H5S_SELECT_SET, hs_sel_offset, NULL, hs_sel_count, NULL) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Sselect_hyperslab failed");
if (H5Sselect_hyperslab(hslab_space, H5S_SELECT_SET, zero, NULL, &hs_select_nelmts, NULL) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Sselect_hyperslab failed");
} /* end if rank > 0 */
else {
H5Sselect_all(f_space_id);
@@ -1004,9 +1015,9 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
} /* end (else) rank == 0 */
if(H5Dread(dset_in, wtype_id, hslab_space, f_space_id, H5P_DEFAULT, hslab_buf) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dread failed");
if(H5Dwrite(dset_out, wtype_id, hslab_space, f_space_id, H5P_DEFAULT, hslab_buf) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dwrite failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dwrite failed");
/* reclaim any VL memory, if necessary */
if (vl_data)
@@ -1066,10 +1077,10 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
*-------------------------------------------------------------------------
*/
if (copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_attr failed");
+ H5TOOLS_GOTO_ERROR((-1), "copy_attr failed");
if (H5Dclose(dset_out) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed");
} /* end if not a reference */
} /* end if h5tools_canreadf (filter availability check) */
@@ -1078,64 +1089,65 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
*-------------------------------------------------------------------------
*/
if (H5Tclose(ftype_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
if (H5Tclose(wtype_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
if (H5Pclose(dcpl_in) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
if (H5Pclose(dcpl_out) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
if (H5Sclose(f_space_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed");
if (H5Dclose(dset_in) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed");
}
/*-------------------------------------------------------------------------
* We do not have request for filter/chunking; use H5Ocopy instead
*-------------------------------------------------------------------------
*/
else {
- hid_t pid = -1;
-
/* create property to pass copy options */
- if ((pid = H5Pcreate(H5P_OBJECT_COPY)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed");
+ if ((ocpl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed");
/* set options for object copy */
- if (H5Pset_copy_object(pid, H5O_COPY_WITHOUT_ATTR_FLAG) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_copy_object failed");
+ if (H5Pset_copy_object(ocpl_id, H5O_COPY_WITHOUT_ATTR_FLAG) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_copy_object failed");
if (H5Ocopy(fidin, /* Source file or group identifier */
travt->objs[i].name, /* Name of the source object to be copied */
fidout, /* Destination file or group identifier */
travt->objs[i].name, /* Name of the destination object */
- pid, /* Properties which apply to the copy */
+ ocpl_id, /* Properties which apply to the copy */
H5P_DEFAULT) < 0) /* Properties which apply to the new hard link */
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Ocopy failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Ocopy failed");
- if (H5Pclose(pid) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
+ if (H5Pclose(ocpl_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
+ ocpl_id = H5I_INVALID_HID;
/*-------------------------------------------------------------------------
* Copy attrs manually
*-------------------------------------------------------------------------
*/
if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed");
if ((dset_out = H5Dopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed");
if (copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_attr failed");
+ H5TOOLS_GOTO_ERROR((-1), "copy_attr failed");
if (H5Dclose(dset_in) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed");
if (H5Dclose(dset_out) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed");
if (options->verbose)
HDprintf(FORMAT_OBJ, "dset", travt->objs[i].name);
} /* end whether we have request for filter/chunking */
+
break;
+ } /* H5TRAV_TYPE_DATASET */
/*-------------------------------------------------------------------------
* H5TRAV_TYPE_NAMED_DATATYPE
@@ -1146,28 +1158,28 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
HDprintf(FORMAT_OBJ, "type", travt->objs[i].name);
if ((type_in = H5Topen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Topen2 failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Topen2 failed");
/* Copy the datatype anonymously */
if ((type_out = copy_named_datatype(type_in, fidout, &named_dt_head, travt, options)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_named_datatype failed");
+ H5TOOLS_GOTO_ERROR((-1), "copy_named_datatype failed");
/* Link in to group structure */
if (H5Lcreate_hard(type_out, ".", fidout, travt->objs[i].name, H5P_DEFAULT, H5P_DEFAULT) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Lcreate_hard failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Lcreate_hard failed");
/*-------------------------------------------------------------------------
* copy attrs
*-------------------------------------------------------------------------
*/
if (copy_attr(type_in, type_out, &named_dt_head, travt, options) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_attr failed");
+ H5TOOLS_GOTO_ERROR((-1), "copy_attr failed");
if (H5Tclose(type_in) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
if (H5Tclose(type_out) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
- type_out = -1; /* named datatypes stack, named_dt_head, manages allocation */
+ H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
+ type_out = H5I_INVALID_HID; /* named datatypes stack, named_dt_head, manages allocation */
break;
@@ -1184,15 +1196,65 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
if (options->verbose)
HDprintf(FORMAT_OBJ, "link", travt->objs[i].name);
- if (H5Lcopy(fidin, travt->objs[i].name, fidout, travt->objs[i].name, H5P_DEFAULT, H5P_DEFAULT) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Lcopy failed");
+ /* Check -X option. */
+ if (options->merge) {
+ if (H5tools_get_symlink_info(fidin, travt->objs[i].name, &linkinfo, 1) == 0) {
+ /* dangling link */
+ if (options->prune) {
+ HDprintf("Pruned %s.\n", travt->objs[i].name);
+ }
+ else {
+ if (H5Lcopy(fidin, travt->objs[i].name, fidout, travt->objs[i].name, H5P_DEFAULT, H5P_DEFAULT) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Lcopy failed");
+ }
+ }
+ else {
+ /* valid link */
+ /* create property to pass copy options */
+ if ((ocpl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pcreate create property failed");
- if (options->verbose)
- HDprintf(FORMAT_OBJ, "link", travt->objs[i].name);
+ /* set options for object copy */
+ if (H5Pset_copy_object(ocpl_id, H5O_COPY_EXPAND_EXT_LINK_FLAG) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_copy_object failed");
+
+ /* Create link creation property list */
+ if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) {
+ H5TOOLS_GOTO_ERROR((-1), "H5Pcreate link creation property failed");
+ }
+
+ /* Set flag for intermediate group creation */
+ if (H5Pset_create_intermediate_group(lcpl_id, TRUE) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_create_intermediate_group failed");
+
+ if (H5Ocopy(fidin, travt->objs[i].name, fidout, travt->objs[i].name, ocpl_id, lcpl_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Ocopy failed");
+
+ if (H5Pclose(lcpl_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
+
+ if (H5Pclose(ocpl_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
+ }
+
+ /* free link info path */
+ if (linkinfo.trg_path)
+ HDfree(linkinfo.trg_path);
+ linkinfo.trg_path = NULL;
+ } /* options->merge */
+ else {
+ if (options->prune) {
+ HDprintf("Pruned %s.\n", travt->objs[i].name);
+ }
+ else {
+ if (H5Lcopy(fidin, travt->objs[i].name, fidout, travt->objs[i].name, H5P_DEFAULT, H5P_DEFAULT) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Lcopy failed");
+ }
+ }
break;
default:
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Object type not found");
+ H5TOOLS_GOTO_ERROR((-1), "Object type not found");
} /* switch */
} /* end for each object to traverse */
} /* end if there are objects */
@@ -1203,17 +1265,24 @@ done:
* because of reference counting */
if (0 == ret_value && named_dt_head != NULL) {
if (named_datatype_free(&named_dt_head, 0) < 0)
- H5TOOLS_INFO(H5E_tools_min_id_g, "named_datatype_free failed");
+ H5TOOLS_ERROR((-1), "named_datatype_free failed");
}
- else
+ else {
H5E_BEGIN_TRY {
named_datatype_free(&named_dt_head, 1);
} H5E_END_TRY;
+ }
+
+ /* free link info path */
+ if (linkinfo.trg_path)
+ HDfree(linkinfo.trg_path);
H5E_BEGIN_TRY
{
H5Gclose(grp_in);
H5Gclose(grp_out);
+ H5Pclose(lcpl_id);
+ H5Pclose(ocpl_id);
H5Pclose(dcpl_in);
H5Pclose(gcpl_in);
H5Pclose(gcpl_out);
@@ -1354,16 +1423,16 @@ print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr)
static int
copy_user_block(const char *infile, const char *outfile, hsize_t size)
{
- int ret_value = 0;
int infid = -1, outfid = -1; /* File descriptors */
+ int ret_value = 0;
/* User block must be any power of 2 equal to 512 or greater (512, 1024, 2048, etc.) */
/* Open files */
if ((infid = HDopen(infile, O_RDONLY)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDopen failed input file <%s>", infile);
+ H5TOOLS_GOTO_ERROR((-1), "HDopen failed input file <%s>", infile);
if ((outfid = HDopen(outfile, O_WRONLY)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDopen failed output file <%s>", outfile);
+ H5TOOLS_GOTO_ERROR((-1), "HDopen failed output file <%s>", outfile);
/* Copy the userblock from the input file to the output file */
while (size > 0) {
@@ -1377,7 +1446,7 @@ copy_user_block(const char *infile, const char *outfile, hsize_t size)
else
nread = HDread(infid, rbuf, (size_t)size);
if (nread < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDread failed to read userblock");
+ H5TOOLS_GOTO_ERROR((-1), "HDread failed to read userblock");
/* Write buffer to destination file */
/* (compensating for interrupted writes & checking for errors, etc.) */
@@ -1390,7 +1459,7 @@ copy_user_block(const char *infile, const char *outfile, hsize_t size)
nwritten = HDwrite(outfid, wbuf, (size_t)nbytes);
} while (-1 == nwritten && EINTR == errno);
if (-1 == nwritten) /* error */
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDwrite failed");
+ H5TOOLS_GOTO_ERROR((-1), "HDwrite failed");
HDassert(nwritten > 0);
HDassert(nwritten <= nbytes);
@@ -1426,29 +1495,29 @@ static
void
print_user_block(const char *filename, hid_t fid)
{
- int ret_value = 0;
int fh = -1; /* file handle */
hsize_t ub_size; /* user block size */
hsize_t size; /* size read */
- hid_t fcpl = -1; /* file creation property list ID for HDF5 file */
+ hid_t fcpl = H5I_INVALID_HID; /* file creation property list ID for HDF5 file */
int i;
+ int ret_value = 0;
/* get user block size */
if ((fcpl = H5Fget_create_plist(fid)) < 0) {
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Fget_create_plist failed to retrieve file creation property list");
+ H5TOOLS_GOTO_ERROR((-1), "H5Fget_create_plist failed to retrieve file creation property list");
}
if (H5Pget_userblock(fcpl, &ub_size) < 0) {
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pget_userblock failed to retrieve userblock size");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pget_userblock failed to retrieve userblock size");
}
if (H5Pclose(fcpl) < 0) {
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed to close property list");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed to close property list");
}
/* open file */
if ((fh = HDopen(filename, O_RDONLY)) < 0) {
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDopen failed to open file <%s>", filename);
+ H5TOOLS_GOTO_ERROR((-1), "HDopen failed to open file <%s>", filename);
}
size = ub_size;
@@ -1472,7 +1541,7 @@ print_user_block(const char *filename, hid_t fid)
HDprintf("\n");
if (nread < 0) {
- HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "nread < 0");
+ H5TOOLS_GOTO_ERROR((-1), "nread < 0");
}
/* update size of userblock left to transfer */
diff --git a/tools/src/h5repack/h5repack_filters.c b/tools/src/h5repack/h5repack_filters.c
index 7e32def..d1179fb 100644
--- a/tools/src/h5repack/h5repack_filters.c
+++ b/tools/src/h5repack/h5repack_filters.c
@@ -36,35 +36,35 @@ static int aux_copy_obj(hid_t dcpl_id, /* dataset creation property list */
const char* name, /* object name from traverse list */
pack_info_t *objout /*OUT*/) /* info about object to filter */
{
- int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
int nfilters; /* number of filters in DCPL */
char f_objname[256]; /* filter objname */
H5D_layout_t layout;
int rank; /* rank of dataset */
hsize_t chsize[64]; /* chunk size in elements */
- int i;
- unsigned u;
+ int i;
+ unsigned u;
+ int ret_value = 0;
/* get information about input filters */
if ((nfilters = H5Pget_nfilters(dcpl_id)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_nfilters failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pget_nfilters failed");
/* copy filter_info_t structure */
for (i = 0; i < nfilters; i++) {
if ((objout->filter[i].filtn = H5Pget_filter2(dcpl_id, (unsigned) i, &objout->filter[i].filt_flag, &objout->filter[i].cd_nelmts,
objout->filter[i].cd_values, sizeof(f_objname), f_objname, NULL)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_filter2 failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pget_filter2 failed");
}
objout->nfilters = nfilters;
HDstrcpy(objout->path, name);
if ((layout = H5Pget_layout(dcpl_id)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_layout failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pget_layout failed");
objout->layout = layout;
if (layout == H5D_CHUNKED) {
if ((rank = H5Pget_chunk(dcpl_id, NELMTS(chsize), chsize/*out*/)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_chunk failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pget_chunk failed");
objout->chunk.rank = rank;
for (u = 0; u < (unsigned)rank; u++)
objout->chunk.chunk_lengths[u] = chsize[u];
@@ -238,18 +238,18 @@ int apply_filters(const char* name, /* object name from traverse list */
pack_opt_t *options, /* repack options */
int *has_filter) /* (OUT) object NAME has a filter */
{
- int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
- int nfilters; /* number of filters in DCPL */
- hsize_t chsize[64]; /* chunk size in elements */
+ int nfilters; /* number of filters in DCPL */
+ hsize_t chsize[64]; /* chunk size in elements */
H5D_layout_t layout;
- int i;
- pack_info_t obj;
- pack_info_t filtobj;
+ int i;
+ pack_info_t obj;
+ pack_info_t filtobj;
+ int ret_value = 0;
*has_filter = 0;
if (rank == 0) /* scalar dataset, do not apply */
- HGOTO_DONE(0);
+ H5TOOLS_GOTO_DONE(0);
/*-------------------------------------------------------------------------
* initialize the assigment object
@@ -263,11 +263,11 @@ int apply_filters(const char* name, /* object name from traverse list */
*-------------------------------------------------------------------------
*/
if (aux_assign_obj(name, options, &obj) == 0)
- HGOTO_DONE(0);
+ H5TOOLS_GOTO_DONE(0);
/* get information about input filters */
if ((nfilters = H5Pget_nfilters(dcpl_id)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_nfilters failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pget_nfilters failed");
/*-------------------------------------------------------------------------
@@ -279,12 +279,12 @@ int apply_filters(const char* name, /* object name from traverse list */
if (nfilters && obj.nfilters) {
*has_filter = 1;
if (H5Premove_filter(dcpl_id, H5Z_FILTER_ALL) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Premove_filter failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Premove_filter failed");
}
else if(nfilters) {
*has_filter = 1;
if (aux_copy_obj(dcpl_id, name, &filtobj) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "aux_copy_obj failed");
+ H5TOOLS_GOTO_ERROR((-1), "aux_copy_obj failed");
}
/*-------------------------------------------------------------------------
@@ -294,11 +294,11 @@ int apply_filters(const char* name, /* object name from traverse list */
*/
if (obj.layout == -1) {
if ((layout = H5Pget_layout(dcpl_id)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_layout failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pget_layout failed");
if (layout == H5D_CHUNKED) {
if ((rank = H5Pget_chunk(dcpl_id, NELMTS(chsize), chsize/*out*/)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_chunk failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pget_chunk failed");
obj.layout = H5D_CHUNKED;
obj.chunk.rank = rank;
for (i = 0; i < rank; i++)
@@ -340,7 +340,7 @@ int apply_filters(const char* name, /* object name from traverse list */
for (i = rank; i > 0; --i) {
hsize_t size = 0;
if(sm_nbytes == 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "number of bytes per stripmine must be > 0");
+ H5TOOLS_GOTO_ERROR((-1), "number of bytes per stripmine must be > 0");
size = H5TOOLS_BUFSIZE / sm_nbytes;
if (size == 0) /* datum size > H5TOOLS_BUFSIZE */
size = 1;
@@ -355,7 +355,7 @@ int apply_filters(const char* name, /* object name from traverse list */
for (i = 0; i < obj.nfilters; i++) {
if (obj.filter[i].filtn < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "invalid filter");
+ H5TOOLS_GOTO_ERROR((-1), "invalid filter");
switch (obj.filter[i].filtn) {
/*-------------------------------------------------------------------------
@@ -376,9 +376,9 @@ int apply_filters(const char* name, /* object name from traverse list */
aggression = obj.filter[i].cd_values[0];
/* set up for deflated data */
if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_chunk failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed");
if (H5Pset_deflate(dcpl_id, aggression) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_deflate failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_deflate failed");
}
break;
@@ -396,9 +396,9 @@ int apply_filters(const char* name, /* object name from traverse list */
/* set up for szip data */
if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_chunk failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed");
if (H5Pset_szip(dcpl_id, options_mask, pixels_per_block) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_szip failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_szip failed");
}
break;
@@ -408,9 +408,9 @@ int apply_filters(const char* name, /* object name from traverse list */
*/
case H5Z_FILTER_SHUFFLE:
if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_chunk failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed");
if (H5Pset_shuffle(dcpl_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_shuffle failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_shuffle failed");
break;
/*-------------------------------------------------------------------------
@@ -419,9 +419,9 @@ int apply_filters(const char* name, /* object name from traverse list */
*/
case H5Z_FILTER_FLETCHER32:
if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_chunk failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed");
if (H5Pset_fletcher32(dcpl_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_fletcher32 failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_fletcher32 failed");
break;
/*----------- -------------------------------------------------------------
* H5Z_FILTER_NBIT , NBIT compression
@@ -429,9 +429,9 @@ int apply_filters(const char* name, /* object name from traverse list */
*/
case H5Z_FILTER_NBIT:
if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_chunk failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed");
if (H5Pset_nbit(dcpl_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_nbit failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_nbit failed");
break;
/*----------- -------------------------------------------------------------
* H5Z_FILTER_SCALEOFFSET , scale+offset compression
@@ -446,19 +446,19 @@ int apply_filters(const char* name, /* object name from traverse list */
scale_factor = (int) obj.filter[i].cd_values[1];
if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_chunk failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed");
if (H5Pset_scaleoffset(dcpl_id, scale_type, scale_factor) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_scaleoffset failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_scaleoffset failed");
}
break;
default:
{
if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_chunk failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed");
if (H5Pset_filter(dcpl_id, obj.filter[i].filtn,
obj.filter[i].filt_flag, obj.filter[i].cd_nelmts,
obj.filter[i].cd_values) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_filter failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_filter failed");
}
break;
} /* switch */
@@ -469,10 +469,10 @@ int apply_filters(const char* name, /* object name from traverse list */
if (filtobj.nfilters) {
for (i = 0; i < filtobj.nfilters; i++) {
if (filtobj.filter[i].filtn < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "invalid filter");
+ H5TOOLS_GOTO_ERROR((-1), "invalid filter");
if (H5Zfilter_avail(filtobj.filter[i].filtn) <= 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "%d filter unavailable", filtobj.filter[i].filtn);
+ H5TOOLS_GOTO_ERROR((-1), "%d filter unavailable", filtobj.filter[i].filtn);
} /* for */
} /* nfilters */
@@ -484,20 +484,20 @@ int apply_filters(const char* name, /* object name from traverse list */
if (obj.layout >= 0) {
/* a layout was defined */
if (H5Pset_layout(dcpl_id, obj.layout) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_layout failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_layout failed");
if (H5D_CHUNKED == obj.layout) {
if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_chunk failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed");
}
else if (H5D_COMPACT == obj.layout) {
if (H5Pset_alloc_time(dcpl_id, H5D_ALLOC_TIME_EARLY) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_alloc_time failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_alloc_time failed");
}
/* remove filters for the H5D_CONTIGUOUS case */
else if (H5D_CONTIGUOUS == obj.layout) {
if (H5Premove_filter(dcpl_id, H5Z_FILTER_ALL) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Premove_filter failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Premove_filter failed");
}
}
diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c
index b4e1985..009755e 100644
--- a/tools/src/h5repack/h5repack_main.c
+++ b/tools/src/h5repack/h5repack_main.c
@@ -32,36 +32,38 @@ const char *outfile = NULL;
* Command-line options: The user can specify short or long-named
* parameters.
*/
-static const char *s_opts = "hVvf:l:m:e:nLj:k:c:d:s:u:b:M:t:a:i:o:S:P:T:G:q:z:E";
+static const char *s_opts = "a:b:c:d:e:f:hi:j:k:l:m:no:q:s:t:u:vz:EG:LM:P:S:T:VXW";
static struct long_options l_opts[] = {
- { "help", no_arg, 'h' },
- { "version", no_arg, 'V' },
- { "verbose", no_arg, 'v' },
+ { "alignment", require_arg, 'a' },
+ { "block", require_arg, 'b' },
+ { "compact", require_arg, 'c' },
+ { "indexed", require_arg, 'd' },
+ { "file", require_arg, 'e' },
{ "filter", require_arg, 'f' },
+ { "help", no_arg, 'h' },
+ { "infile", require_arg, 'i' }, /* for backward compability */
+ { "low", require_arg, 'j' },
+ { "high", require_arg, 'k' },
{ "layout", require_arg, 'l' },
{ "minimum", require_arg, 'm' },
- { "file", require_arg, 'e' },
{ "native", no_arg, 'n' },
- { "latest", no_arg, 'L' },
- { "low", require_arg, 'j' },
- { "high", require_arg, 'k' },
- { "compact", require_arg, 'c' },
- { "indexed", require_arg, 'd' },
+ { "outfile", require_arg, 'o' }, /* for backward compability */
+ { "sort_by", require_arg, 'q' },
{ "ssize", require_arg, 's' },
+ { "threshold", require_arg, 't' },
{ "ublock", require_arg, 'u' },
- { "block", require_arg, 'b' },
+ { "verbose", no_arg, 'v' },
+ { "sort_order", require_arg, 'z' },
+ { "enable-error-stack", no_arg, 'E' },
+ { "fs_pagesize", require_arg, 'G' },
+ { "latest", no_arg, 'L' },
{ "metadata_block_size", require_arg, 'M' },
- { "threshold", require_arg, 't' },
- { "alignment", require_arg, 'a' },
- { "infile", require_arg, 'i' }, /* for backward compability */
- { "outfile", require_arg, 'o' }, /* for backward compability */
- { "fs_strategy", require_arg, 'S' },
{ "fs_persist", require_arg, 'P' },
+ { "fs_strategy", require_arg, 'S' },
{ "fs_threshold", require_arg, 'T' },
- { "fs_pagesize", require_arg, 'G' },
- { "sort_by", require_arg, 'q' },
- { "sort_order", require_arg, 'z' },
- { "enable-error-stack", no_arg, 'E' },
+ { "version", no_arg, 'V' },
+ { "merge", no_arg, 'X' },
+ { "prune", no_arg, 'W' },
{ NULL, 0, '\0' }
};
@@ -95,6 +97,9 @@ static void usage(const char *prog) {
PRINTVALSTREAM(rawoutstream, " --high=BOUND The high bound for library release versions to use\n");
PRINTVALSTREAM(rawoutstream, " when creating objects in the file\n");
PRINTVALSTREAM(rawoutstream, " (default is H5F_LIBVER_LATEST)\n");
+ PRINTVALSTREAM(rawoutstream, " --merge Follow external soft link recursively and merge data\n");
+ PRINTVALSTREAM(rawoutstream, " --prune Do not follow external soft links and remove link\n");
+ PRINTVALSTREAM(rawoutstream, " --merge --prune Follow external link, merge data and remove dangling link\n");
PRINTVALSTREAM(rawoutstream, " -c L1, --compact=L1 Maximum number of links in header messages\n");
PRINTVALSTREAM(rawoutstream, " -d L2, --indexed=L2 Minimum number of links in the indexed format\n");
PRINTVALSTREAM(rawoutstream, " -s S[:F], --ssize=S[:F] Shared object header message minimum size\n");
@@ -279,7 +284,7 @@ int read_info(const char *filename, pack_opt_t *options)
char comp_info[1024];
FILE *fp = NULL;
char c;
- int i, rc = 1;
+ int i;
int ret_value = EXIT_SUCCESS;
if (NULL == (fp = HDfopen(filename, "r"))) {
@@ -291,6 +296,8 @@ int read_info(const char *filename, pack_opt_t *options)
/* cycle until end of file reached */
while (1) {
+ if (EOF == fscanf(fp, "%9s", stype))
+ break;
/* Info indicator must be for layout or filter */
if (HDstrcmp(stype,"-l") && HDstrcmp(stype, "-f")) {
@@ -332,7 +339,7 @@ int read_info(const char *filename, pack_opt_t *options)
if (!HDstrcmp(stype, "-l")) {
if (h5repack_addlayout(comp_info, options) == -1) {
- error_msg("could not add chunck option\n");
+ error_msg("could not add chunk option\n");
h5tools_setstatus(EXIT_FAILURE);
ret_value = EXIT_FAILURE;
goto done;
@@ -410,7 +417,7 @@ set_sort_order(const char *form)
static
int parse_command_line(int argc, const char **argv, pack_opt_t* options)
{
- int opt;
+ int bound, opt;
int ret_value = 0;
/* parse command line options */
@@ -432,13 +439,13 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
case 'h':
usage(h5tools_getprogname());
h5tools_setstatus(EXIT_SUCCESS);
- ret_value = -1;
+ ret_value = 1;
goto done;
case 'V':
print_version(h5tools_getprogname());
h5tools_setstatus(EXIT_SUCCESS);
- ret_value = -1;
+ ret_value = 1;
goto done;
case 'v':
@@ -476,9 +483,12 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
break;
case 'e':
- ret_value = read_info(opt_arg, options);
- if (ret_value < 0)
+ if ((ret_value = read_info(opt_arg, options)) < 0) {
+ error_msg("failed to read from repack options file <%s>\n", opt_arg);
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
goto done;
+ }
break;
case 'n':
@@ -490,19 +500,33 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
break;
case 'j':
- options->low_bound = (H5F_libver_t)HDatoi(opt_arg);
- if (options->low_bound < H5F_LIBVER_EARLIEST || options->low_bound > H5F_LIBVER_LATEST) {
+ bound = HDatoi(opt_arg);
+ if (bound < H5F_LIBVER_EARLIEST || bound > H5F_LIBVER_LATEST) {
error_msg("in parsing low bound\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
goto done;
}
+ options->low_bound = bound;
break;
case 'k':
- options->high_bound = (H5F_libver_t)HDatoi(opt_arg);
- if (options->high_bound < H5F_LIBVER_EARLIEST || options->high_bound > H5F_LIBVER_LATEST) {
+ bound = HDatoi(opt_arg);
+ if (bound < H5F_LIBVER_EARLIEST || bound > H5F_LIBVER_LATEST) {
error_msg("in parsing high bound\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
goto done;
}
+ options->high_bound = bound;
+ break;
+
+ case 'X':
+ options->merge = TRUE;
+ break;
+
+ case 'W':
+ options->prune = TRUE;
break;
case 'c':
@@ -621,8 +645,8 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
break;
case 'q':
- if (H5_INDEX_UNKNOWN == set_sort_by(opt_arg)) {
- error_msg(" failed to set sort by form <%s>\n", opt_arg);
+ if (H5_INDEX_UNKNOWN == (sort_by = set_sort_by(opt_arg))) {
+ error_msg("failed to set sort by form <%s>\n", opt_arg);
h5tools_setstatus(EXIT_FAILURE);
ret_value = -1;
goto done;
@@ -630,8 +654,8 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
break;
case 'z':
- if (set_sort_order(opt_arg) == H5_ITER_UNKNOWN) {
- error_msg(" failed to set sort order form <%s>\n", opt_arg);
+ if (H5_ITER_UNKNOWN == (sort_order = set_sort_order(opt_arg))) {
+ error_msg("failed to set sort order form <%s>\n", opt_arg);
h5tools_setstatus(EXIT_FAILURE);
ret_value = -1;
goto done;
@@ -649,30 +673,30 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
/* If neither -i nor -o given, get in and out files positionally */
if (0 == (has_i + has_o)) {
- if (argv[opt_ind] != NULL && argv[opt_ind + 1] != NULL) {
- infile = argv[opt_ind];
- outfile = argv[opt_ind + 1];
-
- if (!HDstrcmp(infile, outfile)) {
- error_msg("file names cannot be the same\n");
- usage(h5tools_getprogname());
- h5tools_setstatus(EXIT_FAILURE);
- ret_value = -1;
- }
- }
- else {
- error_msg("file names missing\n");
- usage(h5tools_getprogname());
- h5tools_setstatus(EXIT_FAILURE);
- ret_value = -1;
- }
- }
- else if (has_i != 1 || has_o != 1) {
- error_msg("filenames must be either both -i -o or both positional\n");
- usage(h5tools_getprogname());
- h5tools_setstatus(EXIT_FAILURE);
- ret_value = -1;
- }
+ if (argv[opt_ind] != NULL && argv[opt_ind + 1] != NULL) {
+ infile = argv[opt_ind];
+ outfile = argv[opt_ind + 1];
+
+ if (!HDstrcmp(infile, outfile)) {
+ error_msg("file names cannot be the same\n");
+ usage(h5tools_getprogname());
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
+ }
+ }
+ else {
+ error_msg("file names missing\n");
+ usage(h5tools_getprogname());
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
+ }
+ }
+ else if (has_i != 1 || has_o != 1) {
+ error_msg("filenames must be either both -i -o or both positional\n");
+ usage(h5tools_getprogname());
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
+ }
done:
return ret_value;
@@ -690,54 +714,64 @@ done:
*/
int main(int argc, const char **argv)
{
- pack_opt_t options; /*the global options */
- H5E_auto2_t func;
- H5E_auto2_t tools_func;
- void *edata;
- void *tools_edata;
+ pack_opt_t options; /*the global options */
+ int parse_ret;
HDmemset(&options, 0, sizeof(pack_opt_t));
- h5tools_setprogname(PROGRAMNAME);
- h5tools_setstatus(EXIT_SUCCESS);
-
- /* Disable error reporting */
- H5Eget_auto2(H5E_DEFAULT, &func, &edata);
- H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
-
/* Initialize h5tools lib */
h5tools_init();
- /* Disable tools error reporting */
- H5Eget_auto2(H5tools_ERR_STACK_g, &tools_func, &tools_edata);
- H5Eset_auto2(H5tools_ERR_STACK_g, NULL, NULL);
+ h5tools_setprogname(PROGRAMNAME);
+ h5tools_setstatus(EXIT_SUCCESS);
/* update hyperslab buffer size from H5TOOLS_BUFSIZE env if exist */
if (h5tools_getenv_update_hyperslab_bufsize() < 0) {
+ HDprintf("Error occurred while retrieving H5TOOLS_BUFSIZE value\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
/* initialize options */
if (h5repack_init(&options, 0, FALSE) < 0) {
+ HDprintf("Error occurred while initializing repack options\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
+
/* Initialize default indexing options */
sort_by = H5_INDEX_CRT_ORDER;
- if (parse_command_line(argc, argv, &options) < 0)
+ parse_ret = parse_command_line(argc, argv, &options);
+ if (parse_ret < 0) {
+ HDprintf("Error occurred while parsing command-line options\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+ else if (parse_ret > 0) {
+ /* Short-circuit success */
+ h5tools_setstatus(EXIT_SUCCESS);
goto done;
-
- if (enable_error_stack > 0) {
- H5Eset_auto2(H5E_DEFAULT, func, edata);
- H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata);
}
+ /* enable error reporting if command line option */
+ h5tools_error_report();
+
/* pack it */
- h5tools_setstatus(h5repack(infile, outfile, &options));
+ if (h5repack(infile, outfile, &options) < 0) {
+ HDprintf("Error occurred while repacking\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+
+ h5tools_setstatus(EXIT_SUCCESS);
done:
+ if (options.fin_fapl >= 0 && options.fin_fapl != H5P_DEFAULT)
+ H5Pclose(options.fin_fapl);
+ if (options.fout_fapl >= 0 && options.fout_fapl != H5P_DEFAULT)
+ H5Pclose(options.fout_fapl);
+
/* free tables */
h5repack_end(&options);
diff --git a/tools/src/h5repack/h5repack_opttable.c b/tools/src/h5repack/h5repack_opttable.c
index 7ab8c6e..56fc12d 100644
--- a/tools/src/h5repack/h5repack_opttable.c
+++ b/tools/src/h5repack/h5repack_opttable.c
@@ -24,7 +24,8 @@
*-------------------------------------------------------------------------
*/
-void init_packobject(pack_info_t *obj) {
+void init_packobject(pack_info_t *obj)
+{
int j, k;
HDstrcpy(obj->path, "\0");
@@ -49,11 +50,12 @@ void init_packobject(pack_info_t *obj) {
*-------------------------------------------------------------------------
*/
-static void aux_tblinsert_filter(pack_opttbl_t *table, unsigned int I, filter_info_t filt) {
+static void aux_tblinsert_filter(pack_opttbl_t *table, unsigned int I, filter_info_t filt)
+{
if (table->objs[I].nfilters < H5_REPACK_MAX_NFILTERS)
table->objs[I].filter[table->objs[I].nfilters++] = filt;
else
- H5TOOLS_INFO(H5E_tools_min_id_g, "cannot insert the filter in this object. Maximum capacity exceeded");
+ H5TOOLS_INFO("cannot insert the filter in this object. Maximum capacity exceeded");
}
/*-------------------------------------------------------------------------
@@ -64,7 +66,8 @@ static void aux_tblinsert_filter(pack_opttbl_t *table, unsigned int I, filter_in
* Return: void
*-------------------------------------------------------------------------
*/
-static void aux_tblinsert_layout(pack_opttbl_t *table, unsigned int I, pack_info_t *pack) {
+static void aux_tblinsert_layout(pack_opttbl_t *table, unsigned int I, pack_info_t *pack)
+{
int k;
table->objs[I].layout = pack->layout;
@@ -97,21 +100,23 @@ static int
aux_inctable(pack_opttbl_t *table, unsigned n_objs)
{
unsigned u;
+ int ret_value = 0;
table->size += n_objs;
table->objs = (pack_info_t*) HDrealloc(table->objs, table->size * sizeof(pack_info_t));
if (table->objs == NULL) {
- H5TOOLS_INFO(H5E_tools_min_id_g, "not enough memory for options table");
- return -1;
+ H5TOOLS_INFO("not enough memory for options table");
+ ret_value = -1;
+ }
+ else {
+ for (u = table->nelems; u < table->size; u++)
+ init_packobject(&table->objs[u]);
}
- for (u = table->nelems; u < table->size; u++)
- init_packobject(&table->objs[u]);
-
- return 0;
+ return ret_value;
}
-
+
/*-------------------------------------------------------------------------
* Function: options_table_init
*
@@ -123,28 +128,28 @@ aux_inctable(pack_opttbl_t *table, unsigned n_objs)
int options_table_init(pack_opttbl_t **tbl) {
unsigned int i;
pack_opttbl_t *table;
+ int ret_value = 0;
if (NULL == (table = (pack_opttbl_t *) HDmalloc(sizeof(pack_opttbl_t)))) {
- H5TOOLS_INFO(H5E_tools_min_id_g, "not enough memory for options table");
- return -1;
+ H5TOOLS_GOTO_ERROR((-1), "not enough memory for options table");
}
table->size = 30;
table->nelems = 0;
if (NULL == (table->objs = (pack_info_t*) HDmalloc(table->size * sizeof(pack_info_t)))) {
- H5TOOLS_INFO(H5E_tools_min_id_g, "not enough memory for options table");
HDfree(table);
- return -1;
+ H5TOOLS_GOTO_ERROR((-1), "not enough memory for options table");
}
for (i = 0; i < table->size; i++)
init_packobject(&table->objs[i]);
*tbl = table;
- return 0;
+done:
+ return ret_value;
}
-
+
/*-------------------------------------------------------------------------
* Function: options_table_free
*
@@ -174,6 +179,7 @@ options_add_layout(obj_list_t *obj_list, unsigned n_objs, pack_info_t *pack, pa
unsigned i, j, I;
unsigned added = 0;
hbool_t found = FALSE;
+ int ret_value = 0;
/* increase the size of the collection by N_OBJS if necessary */
if (table->nelems + n_objs >= table->size)
@@ -190,7 +196,7 @@ options_add_layout(obj_list_t *obj_list, unsigned n_objs, pack_info_t *pack, pa
if (HDstrcmp(obj_list[j].obj,table->objs[i].path) == 0) {
/* already chunk info inserted for this one; exit */
if (table->objs[i].chunk.rank > 0) {
- H5TOOLS_INFO(H5E_tools_min_id_g, "chunk information already inserted for <%s>\n", obj_list[j].obj);
+ H5TOOLS_INFO("chunk information already inserted for <%s>\n", obj_list[j].obj);
HDexit(EXIT_FAILURE);
}
/* insert the layout info */
@@ -237,7 +243,7 @@ options_add_layout(obj_list_t *obj_list, unsigned n_objs, pack_info_t *pack, pa
table->nelems += added;
- return 0;
+ return ret_value;
}
/*-------------------------------------------------------------------------
diff --git a/tools/src/h5repack/h5repack_parse.c b/tools/src/h5repack/h5repack_parse.c
index 03fcf0e..50ccd7a 100644
--- a/tools/src/h5repack/h5repack_parse.c
+++ b/tools/src/h5repack/h5repack_parse.c
@@ -228,7 +228,7 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
l = 0;
}
else if (f == -1) {
- filt->filt_flag = HDstrtoul(stype, NULL, 0);
+ filt->filt_flag = (unsigned)HDstrtoul(stype, NULL, 0);
f = 0;
}
else if (p == -1) {
@@ -478,7 +478,7 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
* Example:
* "AA,B,CDE:CHUNK=10X10"
*
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ * Programmer: Pedro Vicente
*
* Date: December 30, 2003
*
diff --git a/tools/src/h5repack/h5repack_refs.c b/tools/src/h5repack/h5repack_refs.c
index 7e8951f..ee17ed8 100644
--- a/tools/src/h5repack/h5repack_refs.c
+++ b/tools/src/h5repack/h5repack_refs.c
@@ -22,7 +22,7 @@
*/
static const char* MapIdToName(hid_t refobj_id,trav_table_t *travt);
-static int copy_refs_attr(hid_t loc_in, hid_t loc_out,
+static int copy_refs_attr(hid_t loc_in, hid_t loc_out,
trav_table_t *travt, hid_t fidout);
static herr_t update_ref_value(hid_t obj_id, H5R_type_t ref_type, void *ref_in,
hid_t fid_out, void *ref_out, trav_table_t *travt);
@@ -42,16 +42,15 @@ int do_copy_refobjs(hid_t fidin,
trav_table_t *travt,
pack_opt_t *options) /* repack options */
{
- int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
- hid_t grp_in = -1; /* read group ID */
- hid_t grp_out = -1; /* write group ID */
- hid_t dset_in = -1; /* read dataset ID */
- hid_t dset_out = -1; /* write dataset ID */
- hid_t type_in = -1; /* named type ID */
- hid_t dcpl_id = -1; /* dataset creation property list ID */
- hid_t space_id = -1; /* space ID */
- hid_t ftype_id = -1; /* file data type ID */
- hid_t mtype_id = -1; /* memory data type ID */
+ hid_t grp_in = H5I_INVALID_HID; /* read group ID */
+ hid_t grp_out = H5I_INVALID_HID; /* write group ID */
+ hid_t dset_in = H5I_INVALID_HID; /* read dataset ID */
+ hid_t dset_out = H5I_INVALID_HID; /* write dataset ID */
+ hid_t type_in = H5I_INVALID_HID; /* named type ID */
+ hid_t dcpl_id = H5I_INVALID_HID; /* dataset creation property list ID */
+ hid_t space_id = H5I_INVALID_HID; /* space ID */
+ hid_t ftype_id = H5I_INVALID_HID; /* file data type ID */
+ hid_t mtype_id = H5I_INVALID_HID; /* memory data type ID */
size_t msize; /* memory size of memory type */
hsize_t nelmts; /* number of elements in dataset */
int rank; /* rank of dataset */
@@ -59,6 +58,7 @@ int do_copy_refobjs(hid_t fidin,
unsigned int i, j;
int k;
named_dt_t *named_dt_head = NULL; /* Pointer to the stack of named datatypes copied */
+ int ret_value = 0;
/*-------------------------------------------------------------------------
* browse
@@ -76,18 +76,18 @@ int do_copy_refobjs(hid_t fidin,
*-------------------------------------------------------------------------
*/
if((grp_out = H5Gopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gopen2 failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Gopen2 failed");
if((grp_in = H5Gopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gopen2 failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Gopen2 failed");
if(copy_refs_attr(grp_in, grp_out, travt, fidout) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_refs_attr failed");
+ H5TOOLS_GOTO_ERROR((-1), "copy_refs_attr failed");
if(H5Gclose(grp_out) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Gclose failed");
if(H5Gclose(grp_in) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Gclose failed");
/*-------------------------------------------------------------------------
* check for hard links
@@ -104,26 +104,26 @@ int do_copy_refobjs(hid_t fidin,
*/
case H5TRAV_TYPE_DATASET:
if((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed");
if((space_id = H5Dget_space(dset_in)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed");
if((ftype_id = H5Dget_type(dset_in)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_type failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_type failed");
if((dcpl_id = H5Dget_create_plist(dset_in)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed");
if((rank = H5Sget_simple_extent_ndims(space_id)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_ndims failed");
if(H5Sget_simple_extent_dims(space_id, dims, NULL) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_dims failed");
nelmts = 1;
for(k = 0; k < rank; k++)
nelmts *= dims[k];
if((mtype_id = H5Tget_native_type(ftype_id, H5T_DIR_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_native_type failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Tget_native_type failed");
if((msize = H5Tget_size(mtype_id)) == 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Tget_size failed");
/*-------------------------------------------------------------------------
* check if the dataset creation property list has filters that
@@ -145,7 +145,7 @@ int do_copy_refobjs(hid_t fidin,
*-------------------------------------------------------------------------
*/
if(H5Tequal(mtype_id, H5T_STD_REF_OBJ)) {
- hid_t refobj_id = -1;
+ hid_t refobj_id = H5I_INVALID_HID;
hobj_ref_t *refbuf = NULL; /* buffer for object references */
hobj_ref_t *buf = NULL;
const char* refname;
@@ -159,15 +159,15 @@ int do_copy_refobjs(hid_t fidin,
buf = (hobj_ref_t *)HDmalloc((unsigned)(nelmts * msize));
if(buf==NULL) {
HDprintf("cannot read into memory\n" );
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDmalloc failed");
+ H5TOOLS_GOTO_ERROR((-1), "HDmalloc failed");
} /* end if */
if(H5Dread(dset_in, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dread failed");
refbuf = (hobj_ref_t*) HDcalloc((unsigned)nelmts, msize);
if(refbuf == NULL){
HDprintf("cannot allocate memory\n" );
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDcalloc failed");
+ H5TOOLS_GOTO_ERROR((-1), "HDcalloc failed");
} /* end if */
for(u = 0; u < nelmts; u++) {
H5E_BEGIN_TRY {
@@ -181,7 +181,7 @@ int do_copy_refobjs(hid_t fidin,
if((refname = MapIdToName(refobj_id, travt)) != NULL) {
/* create the reference, -1 parameter for objects */
if(H5Rcreate(&refbuf[u], fidout, refname, H5R_OBJECT, (hid_t)-1) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Rcreate failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Rcreate failed");
if(options->verbose) {
HDprintf(FORMAT_OBJ,"dset",travt->objs[i].name );
HDprintf("object <%s> object reference created to <%s>\n",
@@ -190,7 +190,7 @@ int do_copy_refobjs(hid_t fidin,
}
} /*refname*/
if (H5Oclose(refobj_id) < 0)
- H5TOOLS_INFO(H5E_tools_min_id_g, "H5Oclose refob failed");
+ H5TOOLS_ERROR((-1), "H5Oclose refob failed");
} /* u */
} /*nelmts*/
@@ -199,10 +199,10 @@ int do_copy_refobjs(hid_t fidin,
*-------------------------------------------------------------------------
*/
if((dset_out = H5Dcreate2(fidout, travt->objs[i].name, mtype_id, space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dcreate2 failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dcreate2 failed");
if(nelmts)
if(H5Dwrite(dset_out, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, refbuf) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dwrite failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dwrite failed");
if(buf)
HDfree(buf);
@@ -213,7 +213,7 @@ int do_copy_refobjs(hid_t fidin,
* copy attrs
*----------------------------------------------------*/
if(copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_attr failed");
+ H5TOOLS_GOTO_ERROR((-1), "copy_attr failed");
} /*H5T_STD_REF_OBJ*/
/*-------------------------------------------------------------------------
@@ -221,7 +221,7 @@ int do_copy_refobjs(hid_t fidin,
*-------------------------------------------------------------------------
*/
else if(H5Tequal(mtype_id, H5T_STD_REF_DSETREG)) {
- hid_t refobj_id = -1;
+ hid_t refobj_id = H5I_INVALID_HID;
hdset_reg_ref_t *refbuf = NULL; /* input buffer for region references */
hdset_reg_ref_t *buf = NULL; /* output buffer */
const char* refname;
@@ -235,10 +235,10 @@ int do_copy_refobjs(hid_t fidin,
buf = (hdset_reg_ref_t *)HDmalloc((unsigned)(nelmts * msize));
if(buf == NULL) {
HDprintf("cannot read into memory\n");
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDmalloc failed");
+ H5TOOLS_GOTO_ERROR((-1), "HDmalloc failed");
} /* end if */
if(H5Dread(dset_in, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dread failed");
/*-------------------------------------------------------------------------
* create output
@@ -247,7 +247,7 @@ int do_copy_refobjs(hid_t fidin,
refbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)nelmts); /*init to zero */
if(refbuf == NULL) {
HDprintf("cannot allocate memory\n");
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDcalloc failed");
+ H5TOOLS_GOTO_ERROR((-1), "HDcalloc failed");
} /* end if */
for(u = 0; u < nelmts; u++) {
@@ -260,16 +260,16 @@ int do_copy_refobjs(hid_t fidin,
* in the second traversal of the file
*/
if((refname = MapIdToName(refobj_id, travt)) != NULL) {
- hid_t region_id = -1; /* region id of the referenced dataset */
+ hid_t region_id = H5I_INVALID_HID; /* region id of the referenced dataset */
if((region_id = H5Rget_region(dset_in, H5R_DATASET_REGION, &buf[u])) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Rget_region failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Rget_region failed");
/* create the reference, we need the space_id */
if(H5Rcreate(&refbuf[u], fidout, refname, H5R_DATASET_REGION, region_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Rcreate failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Rcreate failed");
if(H5Sclose(region_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed");
if(options->verbose) {
HDprintf(FORMAT_OBJ,"dset",travt->objs[i].name );
HDprintf("object <%s> region reference created to <%s>\n",
@@ -278,7 +278,7 @@ int do_copy_refobjs(hid_t fidin,
}
} /*refname*/
if (H5Oclose(refobj_id) < 0)
- H5TOOLS_INFO(H5E_tools_min_id_g, "H5Oclose refobj_id failed");
+ H5TOOLS_ERROR((-1), "H5Oclose refobj_id failed");
} /* u */
} /*nelmts*/
@@ -287,10 +287,10 @@ int do_copy_refobjs(hid_t fidin,
*-------------------------------------------------------------------------
*/
if((dset_out = H5Dcreate2(fidout, travt->objs[i].name, mtype_id, space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dcreate2 failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dcreate2 failed");
if(nelmts)
if(H5Dwrite(dset_out, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, refbuf) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dwrite failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dwrite failed");
if(buf)
HDfree(buf);
@@ -301,7 +301,7 @@ int do_copy_refobjs(hid_t fidin,
* copy attrs
*----------------------------------------------------*/
if(copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_attr failed");
+ H5TOOLS_GOTO_ERROR((-1), "copy_attr failed");
} /* H5T_STD_REF_DSETREG */
/*-------------------------------------------------------------------------
* not references, open previously created object in 1st traversal
@@ -309,7 +309,7 @@ int do_copy_refobjs(hid_t fidin,
*/
else {
if((dset_out = H5Dopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed");
} /* end else */
/*-------------------------------------------------------------------------
@@ -317,7 +317,7 @@ int do_copy_refobjs(hid_t fidin,
*-------------------------------------------------------------------------
*/
if(copy_refs_attr(dset_in, dset_out, travt, fidout) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_refs_attr failed");
+ H5TOOLS_GOTO_ERROR((-1), "copy_refs_attr failed");
/*-------------------------------------------------------------------------
* check for hard links
@@ -328,7 +328,7 @@ int do_copy_refobjs(hid_t fidin,
H5Lcreate_hard(fidout, travt->objs[i].name, H5L_SAME_LOC, travt->objs[i].links[j].new_name, H5P_DEFAULT, H5P_DEFAULT);
if(H5Dclose(dset_out) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed");
} /*can_read*/
/*-------------------------------------------------------------------------
@@ -336,15 +336,15 @@ int do_copy_refobjs(hid_t fidin,
*-------------------------------------------------------------------------
*/
if(H5Tclose(ftype_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
if(H5Tclose(mtype_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
if(H5Pclose(dcpl_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
if(H5Sclose(space_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed");
if(H5Dclose(dset_in) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed");
break;
/*-------------------------------------------------------------------------
@@ -353,9 +353,9 @@ int do_copy_refobjs(hid_t fidin,
*/
case H5TRAV_TYPE_NAMED_DATATYPE:
if((type_in = H5Topen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Topen2 failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Topen2 failed");
if(H5Tclose(type_in) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
break;
/*-------------------------------------------------------------------------
@@ -368,7 +368,8 @@ int do_copy_refobjs(hid_t fidin,
case H5TRAV_TYPE_UNKNOWN:
case H5TRAV_TYPE_UDLINK:
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5TRAV invalid type");
+ H5TOOLS_GOTO_ERROR((-1), "H5TRAV invalid type");
+ break;
default:
break;
@@ -380,7 +381,7 @@ int do_copy_refobjs(hid_t fidin,
* in copy_attr(), so need to free.
*/
if (named_datatype_free(&named_dt_head, 0) < 0)
- H5TOOLS_INFO(H5E_tools_min_id_g, "named_datatype_free failed");
+ H5TOOLS_ERROR((-1), "named_datatype_free failed");
return ret_value;
@@ -429,12 +430,11 @@ static int copy_refs_attr(hid_t loc_in,
trav_table_t *travt,
hid_t fidout) /* for saving references */
{
- int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
- hid_t attr_id = -1; /* attr ID */
- hid_t attr_out = -1; /* attr ID */
- hid_t space_id = -1; /* space ID */
- hid_t ftype_id = -1; /* file data type ID */
- hid_t mtype_id = -1; /* memory data type ID */
+ hid_t attr_id = H5I_INVALID_HID; /* attr ID */
+ hid_t attr_out = H5I_INVALID_HID; /* attr ID */
+ hid_t space_id = H5I_INVALID_HID; /* space ID */
+ hid_t ftype_id = H5I_INVALID_HID; /* file data type ID */
+ hid_t mtype_id = H5I_INVALID_HID; /* memory data type ID */
size_t msize; /* memory size of type */
hsize_t nelmts; /* number of elements in dataset */
hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */
@@ -452,29 +452,29 @@ static int copy_refs_attr(hid_t loc_in,
unsigned *ref_comp_index = NULL;
size_t *ref_comp_size = NULL;
int ref_comp_field_n = 0;
-
+ int ret_value = 0;
if(H5Oget_info2(loc_in, &oinfo, H5O_INFO_NUM_ATTRS) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Oget_info failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Oget_info failed");
for(u = 0; u < (unsigned)oinfo.num_attrs; u++) {
is_ref = is_ref_vlen = is_ref_array = is_ref_comp = 0;
/* 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)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aopen_by_idx failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Aopen_by_idx failed");
/* get the file datatype */
if((ftype_id = H5Aget_type(attr_id)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_type failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Aget_type failed");
type_class = H5Tget_class(ftype_id);
if((mtype_id = H5Tget_native_type(ftype_id, H5T_DIR_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_native_type failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Tget_native_type failed");
if((msize = H5Tget_size(mtype_id)) == 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Tget_size failed");
is_ref = (type_class == H5T_REFERENCE);
@@ -484,7 +484,7 @@ static int copy_refs_attr(hid_t loc_in,
is_ref_vlen = (H5Tget_class(base_type) == H5T_REFERENCE);
msize = H5Tget_size(base_type);
if (H5Tclose(base_type) < 0)
- H5TOOLS_INFO(H5E_tools_min_id_g, "H5Tclose base_type failed");
+ H5TOOLS_ERROR((-1), "H5Tclose base_type failed");
}
else if(type_class == H5T_ARRAY ) {
hid_t base_type = H5Tget_super(ftype_id);
@@ -492,13 +492,13 @@ static int copy_refs_attr(hid_t loc_in,
is_ref_array = (H5Tget_class(base_type) == H5T_REFERENCE);
msize = H5Tget_size(base_type);
if (H5Tclose(base_type) < 0)
- H5TOOLS_INFO(H5E_tools_min_id_g, "H5Tclose base_type failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Tclose base_type failed");
}
else if(type_class == H5T_COMPOUND) {
int nmembers = H5Tget_nmembers(ftype_id) ;
if (nmembers < 1)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_nmembers failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Tget_nmembers failed");
ref_comp_index = (unsigned *)HDmalloc((size_t)nmembers*sizeof(unsigned));
ref_comp_size = (size_t *)HDmalloc((size_t)nmembers*sizeof(ref_comp_size));
@@ -513,7 +513,7 @@ static int copy_refs_attr(hid_t loc_in,
ref_comp_field_n++;
}
if (H5Tclose(mtid) < 0)
- H5TOOLS_INFO(H5E_tools_min_id_g, "H5Tclose mtid failed");
+ H5TOOLS_ERROR((-1), "H5Tclose mtid failed");
}
/* if compound don't contain reference type member, free the above
@@ -530,31 +530,37 @@ static int copy_refs_attr(hid_t loc_in,
ref_comp_size = NULL;
}
}
+ /* This line below needs to be moved in this loop instead of inserting outside. Otherwise,
+ ref_comp_field_n may be >0 for the next attribute, which may not be
+ the reference type and will be accidently treated as the reference type.
+ It will then cause the H5Acreate2 failed since that attribute is already created.
+ KY 2020-02-10
+ */
+ is_ref_comp = (ref_comp_field_n > 0);
}
- is_ref_comp = (ref_comp_field_n > 0);
if (!(is_ref || is_ref_vlen || is_ref_array || is_ref_comp)) {
if (H5Tclose(mtype_id) < 0)
- H5TOOLS_INFO(H5E_tools_min_id_g, "H5Tclose mtype_id failed");
+ H5TOOLS_ERROR((-1), "H5Tclose mtype_id failed");
if (H5Tclose(ftype_id) < 0)
- H5TOOLS_INFO(H5E_tools_min_id_g, "H5Tclose ftype_id failed");
+ H5TOOLS_ERROR((-1), "H5Tclose ftype_id failed");
if (H5Aclose(attr_id) < 0)
- H5TOOLS_INFO(H5E_tools_min_id_g, "H5Aclose attr_id failed");
+ H5TOOLS_ERROR((-1), "H5Aclose attr_id failed");
continue;
}
/* get name */
if(H5Aget_name(attr_id, 255, name) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_name failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Aget_name failed");
/* get the dataspace handle */
if((space_id = H5Aget_space(attr_id)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_space failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Aget_space failed");
/* get dimensions */
if((rank = H5Sget_simple_extent_dims(space_id, dims, NULL)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_dims failed");
/*-------------------------------------------------------------------------
@@ -573,7 +579,7 @@ static int copy_refs_attr(hid_t loc_in,
msize = H5Tget_size(base_type);
if (H5Tclose(base_type) < 0)
- H5TOOLS_INFO(H5E_tools_min_id_g, "H5Tclose base_type failed");
+ H5TOOLS_ERROR((-1), "H5Tclose base_type failed");
array_rank = (unsigned)H5Tget_array_ndims(mtype_id);
H5Tget_array_dims2(mtype_id, array_dims);
@@ -583,7 +589,7 @@ static int copy_refs_attr(hid_t loc_in,
}
if((attr_out = H5Acreate2(loc_out, name, ftype_id, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Acreate2 failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Acreate2 failed");
if (nelmts>0) {
/* handle object references */
@@ -591,15 +597,15 @@ static int copy_refs_attr(hid_t loc_in,
buf = (hobj_ref_t *)HDmalloc((unsigned)(nelmts * msize));
if(buf == NULL) {
HDprintf("cannot read into memory\n");
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDmalloc failed");
+ H5TOOLS_GOTO_ERROR((-1), "HDmalloc failed");
} /* end if */
if(H5Aread(attr_id, mtype_id, buf) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aread failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Aread failed");
refbuf = (hobj_ref_t *)HDcalloc((unsigned)nelmts, msize);
if(refbuf == NULL) {
HDprintf("cannot allocate memory\n");
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDcalloc failed");
+ H5TOOLS_GOTO_ERROR((-1), "HDcalloc failed");
} /* end if */
for(i = 0; i < (unsigned)nelmts; i++)
@@ -612,10 +618,10 @@ static int copy_refs_attr(hid_t loc_in,
if(buf == NULL) {
HDprintf( "cannot read into memory\n" );
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDmalloc failed");
+ H5TOOLS_GOTO_ERROR((-1), "HDmalloc failed");
} /* end if */
if(H5Aread(attr_id, mtype_id, buf) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aread failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Aread failed");
/*-------------------------------------------------------------------------
* create output
@@ -624,7 +630,7 @@ static int copy_refs_attr(hid_t loc_in,
refbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)nelmts); /*init to zero */
if(refbuf == NULL) {
HDprintf( "cannot allocate memory\n" );
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDcalloc failed");
+ H5TOOLS_GOTO_ERROR((-1), "HDcalloc failed");
} /* end if */
for(i = 0; i < (unsigned)nelmts; i++)
@@ -639,11 +645,11 @@ static int copy_refs_attr(hid_t loc_in,
if(buf == NULL) {
HDprintf( "cannot read into memory\n" );
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDmalloc failed");
+ H5TOOLS_GOTO_ERROR((-1), "HDmalloc failed");
} /* end if */
if(H5Aread(attr_id, mtype_id, buf) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aread failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Aread failed");
if (H5R_OBJ_REF_BUF_SIZE==msize) {
hobj_ref_t ref_out;
@@ -680,11 +686,11 @@ static int copy_refs_attr(hid_t loc_in,
if(buf == NULL) {
HDprintf( "cannot read into memory\n" );
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDmalloc failed");
+ H5TOOLS_GOTO_ERROR((-1), "HDmalloc failed");
} /* end if */
if(H5Aread(attr_id, mtype_id, buf) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aread failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Aread failed");
for (i=0; i<(unsigned)nelmts; i++) {
for (j=0; j<(unsigned)ref_comp_field_n; j++) {
@@ -709,7 +715,7 @@ static int copy_refs_attr(hid_t loc_in,
} /* else if (is_ref_comp) */
if(H5Awrite(attr_out, mtype_id, refbuf) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Awrite failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Awrite failed");
if (is_ref_vlen && buf)
H5Dvlen_reclaim (mtype_id, space_id, H5P_DEFAULT, buf);
@@ -739,20 +745,20 @@ static int copy_refs_attr(hid_t loc_in,
}
if(H5Aclose(attr_out) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Aclose failed");
/*-------------------------------------------------------------------------
* close
*-------------------------------------------------------------------------
*/
if(H5Tclose(ftype_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
if(H5Tclose(mtype_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
if(H5Sclose(space_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed");
if(H5Aclose(attr_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Aclose failed");
} /* for(u = 0; u < (unsigned)oinfo.num_attrs; u++) */
done:
@@ -805,7 +811,7 @@ MapIdToName(hid_t refobj_id, trav_table_t *travt)
if(ref_oinfo.addr == travt->objs[u].objno) {
ret = travt->objs[u].name;
goto out;
- } /* end if */
+ }
} /* end if */
} /* u */
@@ -822,27 +828,27 @@ out:
static herr_t update_ref_value(hid_t obj_id, H5R_type_t ref_type, void *ref_in,
hid_t fid_out, void *ref_out, trav_table_t *travt)
{
- int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
const char *ref_obj_name;
- hid_t space_id = -1;
- hid_t ref_obj_id = -1;
+ hid_t space_id = H5I_INVALID_HID;
+ hid_t ref_obj_id = H5I_INVALID_HID;
+ herr_t ret_value = SUCCEED;
ref_obj_id = H5Rdereference2(obj_id, H5P_DEFAULT, ref_type, ref_in);
if (ref_obj_id < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Rdereference2 failed");
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Rdereference2 failed");
ref_obj_name = MapIdToName(ref_obj_id, travt);
if (ref_obj_name == NULL)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "MapIdToName failed");
+ H5TOOLS_GOTO_ERROR(FAIL, "MapIdToName failed");
if (ref_type == H5R_DATASET_REGION) {
space_id = H5Rget_region(obj_id, H5R_DATASET_REGION, ref_in);
if (space_id < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Rget_region failed");
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Rget_region failed");
}
if(H5Rcreate(ref_out, fid_out, ref_obj_name, ref_type, space_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Rcreate failed");
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Rcreate failed");
done:
H5E_BEGIN_TRY {
diff --git a/tools/src/h5repack/h5repack_verify.c b/tools/src/h5repack/h5repack_verify.c
index dbe8e1a..76adc16 100644
--- a/tools/src/h5repack/h5repack_verify.c
+++ b/tools/src/h5repack/h5repack_verify.c
@@ -39,26 +39,26 @@ static int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *fil
int
h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options)
{
- int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
- hid_t fidin = -1; /* file ID for input file*/
- hid_t fidout = -1; /* file ID for output file*/
- hid_t did = -1; /* dataset ID */
- hid_t pid = -1; /* dataset creation property list ID */
- hid_t sid = -1; /* space ID */
- hid_t tid = -1; /* type ID */
+ hid_t fidin = H5I_INVALID_HID; /* file ID for input file*/
+ hid_t fidout = H5I_INVALID_HID; /* file ID for output file*/
+ hid_t did = H5I_INVALID_HID; /* dataset ID */
+ hid_t pid = H5I_INVALID_HID; /* dataset creation property list ID */
+ hid_t sid = H5I_INVALID_HID; /* space ID */
+ hid_t tid = H5I_INVALID_HID; /* type ID */
int ok = 1; /* step results */
unsigned int i;
trav_table_t *travt = NULL;
- hid_t fcpl_in = -1; /* file creation property for input file */
- hid_t fcpl_out = -1; /* file creation property for output file */
+ hid_t fcpl_in = H5I_INVALID_HID; /* file creation property for input file */
+ hid_t fcpl_out = H5I_INVALID_HID; /* file creation property for output file */
H5F_fspace_strategy_t in_strategy, out_strategy; /* file space handling strategy for in/output file */
hbool_t in_persist, out_persist; /* free-space persist status for in/output file */
hsize_t in_threshold, out_threshold; /* free-space section threshold for in/output file */
hsize_t in_pagesize, out_pagesize; /* file space page size for input/output file */
+ int ret_value = 0;
/* open the output file */
if((fidout = H5Fopen(out_fname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0 )
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fopen failed on <%s>", out_fname);
+ H5TOOLS_GOTO_ERROR((-1), "H5Fopen failed on <%s>", out_fname);
for(i = 0; i < options->op_tbl->nelems; i++) {
char *name = options->op_tbl->objs[i].path;
@@ -69,13 +69,13 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
*-------------------------------------------------------------------------
*/
if((did = H5Dopen2(fidout, name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed on <%s>", name);
+ H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed on <%s>", name);
if((sid = H5Dget_space(did)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed");
if((pid = H5Dget_create_plist(did)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed");
if((tid = H5Dget_type(did)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_type failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_type failed");
/*-------------------------------------------------------------------------
* filter check
@@ -95,14 +95,14 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
* close
*-------------------------------------------------------------------------
*/
- if(H5Pclose(pid) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
+ if (H5Pclose(pid) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
if (H5Sclose(sid) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed");
if (H5Dclose(did) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed");
if (H5Tclose(tid) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
}
/*-------------------------------------------------------------------------
@@ -118,7 +118,7 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
/* get the list of objects in the file */
if(h5trav_gettable(fidout, travt) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5trav_gettable failed");
+ H5TOOLS_GOTO_ERROR((-1), "h5trav_gettable failed");
for(i = 0; i < travt->nobjs; i++) {
char *name = travt->objs[i].name;
@@ -129,13 +129,13 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
*-------------------------------------------------------------------------
*/
if((did = H5Dopen2(fidout, name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed on <%s>", name);
+ H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed on <%s>", name);
if((sid = H5Dget_space(did)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed");
if((pid = H5Dget_create_plist(did)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed");
if((tid = H5Dget_type(did)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_type failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_type failed");
/*-------------------------------------------------------------------------
* filter check
@@ -165,13 +165,13 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
*-------------------------------------------------------------------------
*/
if (H5Pclose(pid) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
if (H5Sclose(sid) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed");
if (H5Dclose(did) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed");
if (H5Tclose(tid) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
} /* if */
} /* i */
@@ -187,32 +187,32 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
/* open the input file */
if((fidin = H5Fopen(in_fname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fopen failed on file <%s>", in_fname);
+ H5TOOLS_GOTO_ERROR((-1), "H5Fopen failed on file <%s>", in_fname);
/* Get file creation property list for input file */
if((fcpl_in = H5Fget_create_plist(fidin)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fget_create_plist failed to retrieve file creation property list");
+ H5TOOLS_GOTO_ERROR((-1), "H5Fget_create_plist failed to retrieve file creation property list");
/* Get file space info for input file */
if(H5Pget_file_space_strategy(fcpl_in, &in_strategy, &in_persist, &in_threshold) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_file_space_strategy failed to retrieve file space strategy & threshold");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pget_file_space_strategy failed to retrieve file space strategy & threshold");
/* Get file space page size for input file */
if(H5Pget_file_space_page_size(fcpl_in, &in_pagesize) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_file_space_page_size failed to retrieve file space page size");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pget_file_space_page_size failed to retrieve file space page size");
/* Output file is already opened */
/* Get file creation property list for output file */
if((fcpl_out = H5Fget_create_plist(fidout)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fget_create_plist failed to retrieve file creation property list");
+ H5TOOLS_GOTO_ERROR((-1), "H5Fget_create_plist failed to retrieve file creation property list");
/* Get file space info for output file */
if(H5Pget_file_space_strategy(fcpl_out, &out_strategy, &out_persist, &out_threshold) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_file_space_strategy failed to retrieve file space strategy & threshold");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pget_file_space_strategy failed to retrieve file space strategy & threshold");
/* Get file space page size for output file */
if(H5Pget_file_space_page_size(fcpl_out, &out_pagesize) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_file_space_page_size failed to retrieve file space page size");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pget_file_space_page_size failed to retrieve file space page size");
/*
* If -S option is set, the file space handling strategy should be set as specified.
@@ -221,11 +221,11 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
*/
if(options->fs_strategy) {
if(out_strategy != (options->fs_strategy == (H5F_fspace_strategy_t)-1 ? 0 : options->fs_strategy))
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space strategy not set as unexpected");
+ H5TOOLS_GOTO_ERROR((-1), "file space strategy not set as unexpected");
}
else {
if(out_strategy != in_strategy)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space strategy not set as unexpected");
+ H5TOOLS_GOTO_ERROR((-1), "file space strategy not set as unexpected");
}
/*
@@ -235,11 +235,11 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
*/
if(options->fs_persist) {
if(out_persist != (hbool_t)(options->fs_persist == (-1) ? FALSE : options->fs_persist))
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "free-space persist status not set as unexpected");
+ H5TOOLS_GOTO_ERROR((-1), "free-space persist status not set as unexpected");
}
else {
if(out_persist != in_persist)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "free-space persist status not set as unexpected");
+ H5TOOLS_GOTO_ERROR((-1), "free-space persist status not set as unexpected");
}
/*
@@ -249,11 +249,11 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
*/
if(options->fs_threshold) {
if(out_threshold != (hsize_t)(options->fs_threshold == (-1) ? 0 : options->fs_threshold))
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "threshold not set as unexpected");
+ H5TOOLS_GOTO_ERROR((-1), "threshold not set as unexpected");
}
else {
if(out_threshold != in_threshold)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "threshold not set as unexpected");
+ H5TOOLS_GOTO_ERROR((-1), "threshold not set as unexpected");
}
/*
@@ -263,11 +263,11 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
*/
if(options->fs_pagesize) {
if(out_pagesize != (hsize_t)(options->fs_pagesize == (-1) ? 0 : options->fs_pagesize))
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space page size not set as unexpected");
+ H5TOOLS_GOTO_ERROR((-1), "file space page size not set as unexpected");
}
else { /* "-G" is not set */
if(out_pagesize != in_pagesize)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space page size not set as unexpected");
+ H5TOOLS_GOTO_ERROR((-1), "file space page size not set as unexpected");
}
@@ -353,31 +353,31 @@ int verify_layout(hid_t pid, pack_info_t *obj)
*-------------------------------------------------------------------------
*/
-int h5repack_cmp_pl(const char *fname1, const char *fname2)
+int h5repack_cmp_pl(const char *fname1, hid_t fname1_fapl, const char *fname2, hid_t fname2_fapl)
{
- int ret_value = 1; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
- hid_t fid1 =-1; /* file ID */
- hid_t fid2 =-1; /* file ID */
- hid_t dset1 =-1; /* dataset ID */
- hid_t dset2 =-1; /* dataset ID */
- hid_t gid =-1; /* group ID */
- hid_t dcpl1 =-1; /* dataset creation property list ID */
- hid_t dcpl2 =-1; /* dataset creation property list ID */
- hid_t gcplid =-1; /* group creation property list */
+ hid_t fid1 = H5I_INVALID_HID; /* file ID */
+ hid_t fid2 = H5I_INVALID_HID; /* file ID */
+ hid_t dset1 = H5I_INVALID_HID; /* dataset ID */
+ hid_t dset2 = H5I_INVALID_HID; /* dataset ID */
+ hid_t gid = H5I_INVALID_HID; /* group ID */
+ hid_t dcpl1 = H5I_INVALID_HID; /* dataset creation property list ID */
+ hid_t dcpl2 = H5I_INVALID_HID; /* dataset creation property list ID */
+ hid_t gcplid = H5I_INVALID_HID; /* group creation property list */
unsigned crt_order_flag1; /* group creation order flag */
unsigned crt_order_flag2; /* group creation order flag */
- trav_table_t *trav = NULL;
+ trav_table_t *trav = NULL;
unsigned int i;
+ int ret_value = 1;
/*-------------------------------------------------------------------------
* open the files
*-------------------------------------------------------------------------
*/
/* Open the files */
- if ((fid1 = H5Fopen(fname1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5tools_fopen failed <%s>: %s", fname1, H5FOPENERROR);
- if ((fid2 = H5Fopen(fname2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5tools_fopen failed <%s>: %s", fname2, H5FOPENERROR);
+ if ((fid1 = h5tools_fopen(fname1, H5F_ACC_RDONLY, fname1_fapl, TRUE, NULL, 0)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fname1, H5FOPENERROR);
+ if ((fid2 = h5tools_fopen(fname2, H5F_ACC_RDONLY, fname2_fapl, TRUE, NULL, 0)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fname2, H5FOPENERROR);
/*-------------------------------------------------------------------------
* get file table list of objects
@@ -388,7 +388,7 @@ int h5repack_cmp_pl(const char *fname1, const char *fname2)
/* init table */
trav_table_init(&trav);
if(h5trav_gettable(fid1, trav) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5trav_gettable failed");
+ H5TOOLS_GOTO_ERROR((-1), "h5trav_gettable failed");
/*-------------------------------------------------------------------------
* traverse the suppplied object list
@@ -397,62 +397,62 @@ int h5repack_cmp_pl(const char *fname1, const char *fname2)
for(i = 0; i < trav->nobjs; i++) {
if(trav->objs[i].type == H5TRAV_TYPE_GROUP) {
if ((gid = H5Gopen2(fid1, trav->objs[i].name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gopen2 failed on first <%s>", trav->objs[i].name);
+ H5TOOLS_GOTO_ERROR((-1), "H5Gopen2 failed on first <%s>", trav->objs[i].name);
if ((gcplid = H5Gget_create_plist(gid)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gget_create_plist failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Gget_create_plist failed");
if (H5Pget_link_creation_order(gcplid, &crt_order_flag1) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_link_creation_order failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pget_link_creation_order failed");
if (H5Pclose(gcplid) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
if (H5Gclose(gid) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Gclose failed");
if ((gid = H5Gopen2(fid2, trav->objs[i].name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gopen2 failed on second <%s>", trav->objs[i].name);
+ H5TOOLS_GOTO_ERROR((-1), "H5Gopen2 failed on second <%s>", trav->objs[i].name);
if ((gcplid = H5Gget_create_plist(gid)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gget_create_plist failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Gget_create_plist failed");
if (H5Pget_link_creation_order(gcplid, &crt_order_flag2) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_link_creation_order failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pget_link_creation_order failed");
if (H5Pclose(gcplid) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
if (H5Gclose(gid) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Gclose failed");
if (crt_order_flag1 != crt_order_flag2)
- HGOTO_ERROR(0, H5E_tools_min_id_g, "property lists failed for <%s> are different", trav->objs[i].name);
+ H5TOOLS_GOTO_ERROR(0, "property lists failed for <%s> are different", trav->objs[i].name);
}
else if(trav->objs[i].type == H5TRAV_TYPE_DATASET) {
if((dset1 = H5Dopen2(fid1, trav->objs[i].name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed on first <%s>", trav->objs[i].name);
+ H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed on first <%s>", trav->objs[i].name);
if((dset2 = H5Dopen2(fid2, trav->objs[i].name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed on second <%s>", trav->objs[i].name);
+ H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed on second <%s>", trav->objs[i].name);
if((dcpl1 = H5Dget_create_plist(dset1)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed");
if((dcpl2 = H5Dget_create_plist(dset2)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed");
/*-------------------------------------------------------------------------
* compare the property lists
*-------------------------------------------------------------------------
*/
if((ret_value = H5Pequal(dcpl1, dcpl2)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pequal failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pequal failed");
if(ret_value == 0)
- HGOTO_ERROR(0, H5E_tools_min_id_g, "property lists failed for <%s> are different", trav->objs[i].name);
+ H5TOOLS_GOTO_ERROR(0, "property lists failed for <%s> are different", trav->objs[i].name);
/*-------------------------------------------------------------------------
* close
*-------------------------------------------------------------------------
*/
if(H5Pclose(dcpl1) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
if(H5Pclose(dcpl2) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
if(H5Dclose(dset1) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed");
if(H5Dclose(dset2) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed");
} /*if*/
} /*for*/