summaryrefslogtreecommitdiffstats
path: root/tools/src
diff options
context:
space:
mode:
Diffstat (limited to 'tools/src')
-rw-r--r--tools/src/CMakeLists.txt7
-rw-r--r--tools/src/Makefile.am4
-rw-r--r--tools/src/h5copy/CMakeLists.txt19
-rw-r--r--tools/src/h5copy/Makefile.am2
-rw-r--r--tools/src/h5copy/h5copy.c395
-rw-r--r--tools/src/h5diff/CMakeLists.txt29
-rw-r--r--tools/src/h5diff/Makefile.am2
-rw-r--r--tools/src/h5diff/h5diff_common.c1113
-rw-r--r--tools/src/h5diff/h5diff_common.h13
-rw-r--r--tools/src/h5diff/h5diff_main.c88
-rw-r--r--tools/src/h5diff/ph5diff_main.c132
-rw-r--r--tools/src/h5dump/CMakeLists.txt29
-rw-r--r--tools/src/h5dump/Makefile.am2
-rw-r--r--tools/src/h5dump/h5dump.c1757
-rw-r--r--tools/src/h5dump/h5dump.h110
-rw-r--r--tools/src/h5dump/h5dump_ddl.c1770
-rw-r--r--tools/src/h5dump/h5dump_ddl.h35
-rw-r--r--tools/src/h5dump/h5dump_defines.h63
-rw-r--r--tools/src/h5dump/h5dump_extern.h106
-rw-r--r--tools/src/h5dump/h5dump_xml.c3309
-rw-r--r--tools/src/h5dump/h5dump_xml.h24
-rw-r--r--tools/src/h5format_convert/CMakeLists.txt19
-rw-r--r--tools/src/h5format_convert/Makefile.am2
-rw-r--r--tools/src/h5format_convert/h5format_convert.c421
-rw-r--r--tools/src/h5import/CMakeLists.txt21
-rw-r--r--tools/src/h5import/Makefile.am2
-rw-r--r--tools/src/h5import/h5import.c5110
-rw-r--r--tools/src/h5import/h5import.h202
-rw-r--r--tools/src/h5jam/CMakeLists.txt23
-rw-r--r--tools/src/h5jam/Makefile.am2
-rw-r--r--tools/src/h5jam/h5jam.c397
-rw-r--r--tools/src/h5jam/h5unjam.c229
-rw-r--r--tools/src/h5ls/CMakeLists.txt21
-rw-r--r--tools/src/h5ls/Makefile.am2
-rw-r--r--tools/src/h5ls/h5ls.c2107
-rw-r--r--tools/src/h5perf/CMakeLists.txt103
-rw-r--r--tools/src/h5perf/Makefile.am63
-rw-r--r--tools/src/h5perf/perf.c796
-rw-r--r--tools/src/h5perf/pio_engine.c2745
-rw-r--r--tools/src/h5perf/pio_perf.c1717
-rw-r--r--tools/src/h5perf/pio_perf.h109
-rw-r--r--tools/src/h5perf/sio_engine.c1328
-rw-r--r--tools/src/h5perf/sio_perf.c1300
-rw-r--r--tools/src/h5perf/sio_perf.h104
-rw-r--r--tools/src/h5repack/CMakeLists.txt20
-rw-r--r--tools/src/h5repack/Makefile.am2
-rw-r--r--tools/src/h5repack/h5repack.c655
-rw-r--r--tools/src/h5repack/h5repack.h211
-rw-r--r--tools/src/h5repack/h5repack_copy.c1766
-rw-r--r--tools/src/h5repack/h5repack_filters.c389
-rw-r--r--tools/src/h5repack/h5repack_main.c876
-rw-r--r--tools/src/h5repack/h5repack_opttable.c138
-rw-r--r--tools/src/h5repack/h5repack_parse.c320
-rw-r--r--tools/src/h5repack/h5repack_refs.c732
-rw-r--r--tools/src/h5repack/h5repack_verify.c512
-rw-r--r--tools/src/h5stat/CMakeLists.txt19
-rw-r--r--tools/src/h5stat/Makefile.am2
-rw-r--r--tools/src/h5stat/h5stat.c1400
-rw-r--r--tools/src/misc/CMakeLists.txt65
-rw-r--r--tools/src/misc/Makefile.am5
-rw-r--r--tools/src/misc/h5clear.c187
-rw-r--r--tools/src/misc/h5debug.c914
-rw-r--r--tools/src/misc/h5delete.c66
-rw-r--r--tools/src/misc/h5mkgrp.c342
-rw-r--r--tools/src/misc/h5repart.c341
65 files changed, 22014 insertions, 12780 deletions
diff --git a/tools/src/CMakeLists.txt b/tools/src/CMakeLists.txt
index 757c9cd..e291f61 100644
--- a/tools/src/CMakeLists.txt
+++ b/tools/src/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.10)
+cmake_minimum_required (VERSION 3.12)
project (HDF5_TOOLS_SRC C)
#-- Add the h5diff and test executables
@@ -13,7 +13,7 @@ add_subdirectory (misc)
#-- Add the h5import and test executables
add_subdirectory (h5import)
-#-- h5Repack executables
+#-- h5repack executables
add_subdirectory (h5repack)
#-- Add the h5dump and test executables
@@ -30,3 +30,6 @@ add_subdirectory (h5dump)
#-- Add the h5format_convert and test executables
add_subdirectory (h5format_convert)
+
+#-- h5perf executables
+add_subdirectory (h5perf)
diff --git a/tools/src/Makefile.am b/tools/src/Makefile.am
index beceee5..5af7d06 100644
--- a/tools/src/Makefile.am
+++ b/tools/src/Makefile.am
@@ -6,7 +6,7 @@
# This file is part of HDF5. The full HDF5 copyright notice, including
# terms governing use, modification, and redistribution, is contained in
# the COPYING file, which can be found at the root of the source code
-# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.
+# distribution tree, or in https://www.hdfgroup.org/licenses.
# If you do not have access to either file, you may request a copy from
# help@hdfgroup.org.
##
@@ -23,6 +23,6 @@ CONFIG=ordered
# All subdirectories
SUBDIRS=h5diff h5ls h5dump misc h5import h5repack h5jam h5copy \
- h5format_convert h5stat
+ h5format_convert h5stat h5perf
include $(top_srcdir)/config/conclude.am
diff --git a/tools/src/h5copy/CMakeLists.txt b/tools/src/h5copy/CMakeLists.txt
index 85233ef..2f924a2 100644
--- a/tools/src/h5copy/CMakeLists.txt
+++ b/tools/src/h5copy/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.10)
+cmake_minimum_required (VERSION 3.12)
project (HDF5_TOOLS_SRC_H5COPY C)
# --------------------------------------------------------------------
@@ -6,7 +6,8 @@ project (HDF5_TOOLS_SRC_H5COPY C)
# --------------------------------------------------------------------
if (NOT ONLY_SHARED_LIBS)
add_executable (h5copy ${HDF5_TOOLS_SRC_H5COPY_SOURCE_DIR}/h5copy.c)
- target_include_directories (h5copy PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_include_directories (h5copy PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5copy PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5copy STATIC)
target_link_libraries (h5copy PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
set_target_properties (h5copy PROPERTIES FOLDER tools)
@@ -17,7 +18,8 @@ endif ()
if (BUILD_SHARED_LIBS)
add_executable (h5copy-shared ${HDF5_TOOLS_SRC_H5COPY_SOURCE_DIR}/h5copy.c)
- target_include_directories (h5copy-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_include_directories (h5copy-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5copy-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5copy-shared SHARED)
target_link_libraries (h5copy-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
set_target_properties (h5copy-shared PROPERTIES FOLDER tools)
@@ -26,6 +28,17 @@ if (BUILD_SHARED_LIBS)
set (H5_DEP_EXECUTABLES ${H5_DEP_EXECUTABLES} h5copy-shared)
endif ()
+#-----------------------------------------------------------------------------
+# Add Target to clang-format
+#-----------------------------------------------------------------------------
+if (HDF5_ENABLE_FORMATTERS)
+ if (NOT ONLY_SHARED_LIBS)
+ clang_format (HDF5_H5COPY_SRC_FORMAT h5copy)
+ else ()
+ clang_format (HDF5_H5COPY_SRC_FORMAT h5copy-shared)
+ endif ()
+endif ()
+
##############################################################################
##############################################################################
### I N S T A L L A T I O N ###
diff --git a/tools/src/h5copy/Makefile.am b/tools/src/h5copy/Makefile.am
index d67fafc..328c6f3 100644
--- a/tools/src/h5copy/Makefile.am
+++ b/tools/src/h5copy/Makefile.am
@@ -6,7 +6,7 @@
# This file is part of HDF5. The full HDF5 copyright notice, including
# terms governing use, modification, and redistribution, is contained in
# the COPYING file, which can be found at the root of the source code
-# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.
+# distribution tree, or in https://www.hdfgroup.org/licenses.
# If you do not have access to either file, you may request a copy from
# help@hdfgroup.org.
##
diff --git a/tools/src/h5copy/h5copy.c b/tools/src/h5copy/h5copy.c
index 9490cd9..eacd05b 100644
--- a/tools/src/h5copy/h5copy.c
+++ b/tools/src/h5copy/h5copy.c
@@ -6,7 +6,7 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -19,25 +19,23 @@
#define PROGRAMNAME "h5copy"
/* command-line options: short and long-named parameters */
-static const char *s_opts = "d:f:hi:o:ps:vVE";
-static struct long_options l_opts[] = {
- { "destination", require_arg, 'd' },
- { "flag", require_arg, 'f' },
- { "help", no_arg, 'h' },
- { "input", require_arg, 'i' },
- { "output", require_arg, 'o' },
- { "parents", no_arg, 'p' },
- { "source", require_arg, 's' },
- { "verbose", no_arg, 'v' },
- { "version", no_arg, 'V' },
- { "enable-error-stack", no_arg, 'E' },
- { NULL, 0, '\0' }
-};
-char *fname_src = NULL;
-char *fname_dst = NULL;
-char *oname_src = NULL;
-char *oname_dst = NULL;
-char *str_flag = NULL;
+static const char * s_opts = "d:f:hi:o:ps:vVE*";
+static struct h5_long_options l_opts[] = {{"destination", require_arg, 'd'},
+ {"flag", require_arg, 'f'},
+ {"help", no_arg, 'h'},
+ {"input", require_arg, 'i'},
+ {"output", require_arg, 'o'},
+ {"parents", no_arg, 'p'},
+ {"source", require_arg, 's'},
+ {"verbose", no_arg, 'v'},
+ {"version", no_arg, 'V'},
+ {"enable-error-stack", optional_arg, 'E'},
+ {NULL, 0, '\0'}};
+char * fname_src = NULL;
+char * fname_dst = NULL;
+char * oname_src = NULL;
+char * oname_dst = NULL;
+char * str_flag = NULL;
/*-------------------------------------------------------------------------
* Function: leave
@@ -71,7 +69,6 @@ leave(int ret)
HDexit(ret);
}
-
/*-------------------------------------------------------------------------
* Function: usage
*
@@ -86,7 +83,7 @@ leave(int ret)
*-------------------------------------------------------------------------
*/
static void
-usage (void)
+usage(void)
{
FLUSHSTREAM(rawoutstream);
PRINTVALSTREAM(rawoutstream, "\n");
@@ -96,31 +93,45 @@ usage (void)
PRINTVALSTREAM(rawoutstream, " -o, --output output file name\n");
PRINTVALSTREAM(rawoutstream, " -s, --source source object name\n");
PRINTVALSTREAM(rawoutstream, " -d, --destination destination object name\n");
+ PRINTVALSTREAM(rawoutstream, " ERROR\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --enable-error-stack Prints messages from the HDF5 error stack as they occur.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " Optional value 2 also prints file open errors.\n");
PRINTVALSTREAM(rawoutstream, " OPTIONS\n");
PRINTVALSTREAM(rawoutstream, " -h, --help Print a usage message and exit\n");
- PRINTVALSTREAM(rawoutstream, " -p, --parents No error if existing, make parent groups as needed\n");
+ PRINTVALSTREAM(rawoutstream,
+ " -p, --parents No error if existing, make parent groups as needed\n");
PRINTVALSTREAM(rawoutstream, " -v, --verbose Print information about OBJECTS and OPTIONS\n");
PRINTVALSTREAM(rawoutstream, " -V, --version Print version number and exit\n");
- PRINTVALSTREAM(rawoutstream, " --enable-error-stack\n");
- PRINTVALSTREAM(rawoutstream, " Prints messages from the HDF5 error stack as they occur.\n");
PRINTVALSTREAM(rawoutstream, " -f, --flag Flag type\n\n");
PRINTVALSTREAM(rawoutstream, " Flag type is one of the following strings:\n\n");
PRINTVALSTREAM(rawoutstream, " shallow Copy only immediate members for groups\n\n");
PRINTVALSTREAM(rawoutstream, " soft Expand soft links into new objects\n\n");
PRINTVALSTREAM(rawoutstream, " ext Expand external links into new objects\n\n");
- PRINTVALSTREAM(rawoutstream, " ref Copy references and any referenced objects, i.e., objects\n");
+ PRINTVALSTREAM(rawoutstream,
+ " ref Copy references and any referenced objects, i.e., objects\n");
PRINTVALSTREAM(rawoutstream, " that the references point to.\n");
- PRINTVALSTREAM(rawoutstream, " Referenced objects are copied in addition to the objects\n");
- PRINTVALSTREAM(rawoutstream, " specified on the command line and reference datasets are\n");
- PRINTVALSTREAM(rawoutstream, " populated with correct reference values. Copies of referenced\n");
- PRINTVALSTREAM(rawoutstream, " datasets outside the copy range specified on the command line\n");
- PRINTVALSTREAM(rawoutstream, " will normally have a different name from the original.\n");
- PRINTVALSTREAM(rawoutstream, " (Default:Without this option, reference value(s) in any\n");
- PRINTVALSTREAM(rawoutstream, " reference datasets are set to NULL and referenced objects are\n");
- PRINTVALSTREAM(rawoutstream, " not copied unless they are otherwise within the copy range\n");
+ PRINTVALSTREAM(rawoutstream,
+ " Referenced objects are copied in addition to the objects\n");
+ PRINTVALSTREAM(rawoutstream,
+ " specified on the command line and reference datasets are\n");
+ PRINTVALSTREAM(rawoutstream,
+ " populated with correct reference values. Copies of referenced\n");
+ PRINTVALSTREAM(rawoutstream,
+ " datasets outside the copy range specified on the command line\n");
+ PRINTVALSTREAM(rawoutstream,
+ " will normally have a different name from the original.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " (Default:Without this option, reference value(s) in any\n");
+ PRINTVALSTREAM(rawoutstream,
+ " reference datasets are set to NULL and referenced objects are\n");
+ PRINTVALSTREAM(rawoutstream,
+ " not copied unless they are otherwise within the copy range\n");
PRINTVALSTREAM(rawoutstream, " specified on the command line.)\n\n");
PRINTVALSTREAM(rawoutstream, " noattr Copy object without copying attributes\n\n");
- PRINTVALSTREAM(rawoutstream, " allflags Switches all flags from the default to the non-default setting\n\n");
+ PRINTVALSTREAM(rawoutstream,
+ " allflags Switches all flags from the default to the non-default setting\n\n");
PRINTVALSTREAM(rawoutstream, " These flag types correspond to the following API symbols\n\n");
PRINTVALSTREAM(rawoutstream, " H5O_COPY_SHALLOW_HIERARCHY_FLAG\n");
PRINTVALSTREAM(rawoutstream, " H5O_COPY_EXPAND_SOFT_LINK_FLAG\n");
@@ -130,8 +141,6 @@ usage (void)
PRINTVALSTREAM(rawoutstream, " H5O_COPY_ALL\n");
}
-
-
/*-------------------------------------------------------------------------
* Function: parse_flag
*
@@ -156,30 +165,30 @@ usage (void)
*-------------------------------------------------------------------------
*/
-
-static int parse_flag(const char* s_flag, unsigned *flag)
+static int
+parse_flag(const char *s_flag, unsigned *flag)
{
- unsigned fla=0;
+ unsigned fla = 0;
if (HDstrcmp(s_flag, "shallow") == 0) {
fla = H5O_COPY_SHALLOW_HIERARCHY_FLAG;
}
- else if (HDstrcmp(s_flag, "soft") == 0) {
+ else if (HDstrcmp(s_flag, "soft") == 0) {
fla = H5O_COPY_EXPAND_SOFT_LINK_FLAG;
}
- else if (HDstrcmp(s_flag, "ext") == 0) {
+ else if (HDstrcmp(s_flag, "ext") == 0) {
fla = H5O_COPY_EXPAND_EXT_LINK_FLAG;
}
- else if (HDstrcmp(s_flag, "ref") == 0) {
+ else if (HDstrcmp(s_flag, "ref") == 0) {
fla = H5O_COPY_EXPAND_REFERENCE_FLAG;
}
- else if (HDstrcmp(s_flag, "noattr") == 0) {
+ else if (HDstrcmp(s_flag, "noattr") == 0) {
fla = H5O_COPY_WITHOUT_ATTR_FLAG;
}
- else if (HDstrcmp(s_flag, "allflags") == 0) {
+ else if (HDstrcmp(s_flag, "allflags") == 0) {
fla = H5O_COPY_ALL;
}
- else if (HDstrcmp(s_flag, "nullmsg") == 0) {
+ else if (HDstrcmp(s_flag, "nullmsg") == 0) {
fla = H5O_COPY_PRESERVE_NULL_FLAG;
}
else {
@@ -205,270 +214,255 @@ static int parse_flag(const char* s_flag, unsigned *flag)
*/
int
-main (int argc, const char *argv[])
+main(int argc, char *argv[])
{
- int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
- H5E_auto2_t func;
- H5E_auto2_t tools_func;
- void *edata;
- void *tools_edata;
- hid_t fid_src = -1;
- hid_t fid_dst = -1;
- unsigned flag = 0;
- unsigned verbose = 0;
- unsigned parents = 0;
- hid_t ocpl_id = (-1); /* Object copy property list */
- hid_t lcpl_id = (-1); /* Link creation property list */
- int opt;
- int li_ret;
+ hid_t fid_src = H5I_INVALID_HID;
+ hid_t fid_dst = H5I_INVALID_HID;
+ unsigned flag = 0;
+ unsigned verbose = 0;
+ unsigned parents = 0;
+ hid_t ocpl_id = H5I_INVALID_HID; /* Object copy property list */
+ hid_t lcpl_id = H5I_INVALID_HID; /* Link creation property list */
+ int opt;
+ int li_ret;
h5tool_link_info_t linkinfo;
+ int ret_value = 0;
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);
-
/* init linkinfo struct */
HDmemset(&linkinfo, 0, sizeof(h5tool_link_info_t));
/* Check for no command line parameters */
- if(argc == 1) {
+ if (argc == 1) {
usage();
leave(EXIT_FAILURE);
} /* end if */
/* parse command line options */
- while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) {
+ while ((opt = H5_get_option(argc, (const char *const *)argv, s_opts, l_opts)) != EOF) {
switch ((char)opt) {
- case 'd':
- oname_dst = HDstrdup(opt_arg);
- break;
+ case 'd':
+ oname_dst = HDstrdup(H5_optarg);
+ break;
+
+ case 'f':
+ /* validate flag */
+ if (parse_flag(H5_optarg, &flag) < 0) {
+ usage();
+ leave(EXIT_FAILURE);
+ }
+ str_flag = HDstrdup(H5_optarg);
+ break;
- case 'f':
- /* validate flag */
- if (parse_flag(opt_arg, &flag) < 0) {
+ case 'h':
+ usage();
+ leave(EXIT_SUCCESS);
+ break;
+
+ case 'i':
+ fname_src = HDstrdup(H5_optarg);
+ break;
+
+ case 'o':
+ fname_dst = HDstrdup(H5_optarg);
+ break;
+
+ case 'p':
+ parents = 1;
+ break;
+
+ case 's':
+ oname_src = HDstrdup(H5_optarg);
+ break;
+
+ case 'V':
+ print_version(h5tools_getprogname());
+ leave(EXIT_SUCCESS);
+ break;
+
+ case 'v':
+ verbose = 1;
+ break;
+
+ case 'E':
+ if (H5_optarg != NULL)
+ enable_error_stack = HDatoi(H5_optarg);
+ else
+ enable_error_stack = 1;
+ break;
+
+ default:
usage();
leave(EXIT_FAILURE);
- }
- str_flag = HDstrdup(opt_arg);
- break;
-
- case 'h':
- usage();
- leave(EXIT_SUCCESS);
- break;
-
- case 'i':
- fname_src = HDstrdup(opt_arg);
- break;
-
- case 'o':
- fname_dst = HDstrdup(opt_arg);
- break;
-
- case 'p':
- parents = 1;
- break;
-
- case 's':
- oname_src = HDstrdup(opt_arg);
- break;
-
- case 'V':
- print_version(h5tools_getprogname());
- leave(EXIT_SUCCESS);
- break;
-
- case 'v':
- verbose = 1;
- break;
-
- case 'E':
- enable_error_stack = 1;
- break;
-
- default:
- usage();
- leave(EXIT_FAILURE);
}
} /* end of while */
-/*-------------------------------------------------------------------------
- * check for missing file/object names
- *-------------------------------------------------------------------------*/
+ /*-------------------------------------------------------------------------
+ * check for missing file/object names
+ *-------------------------------------------------------------------------*/
- if (fname_src==NULL) {
+ if (fname_src == NULL) {
error_msg("Input file name missing\n");
usage();
leave(EXIT_FAILURE);
}
- if (fname_dst==NULL) {
+ if (fname_dst == NULL) {
error_msg("Output file name missing\n");
usage();
leave(EXIT_FAILURE);
}
- if (oname_src==NULL) {
+ if (oname_src == NULL) {
error_msg("Source object name missing\n");
usage();
leave(EXIT_FAILURE);
}
- if (oname_dst==NULL) {
+ if (oname_dst == NULL) {
error_msg("Destination object name missing\n");
usage();
leave(EXIT_FAILURE);
}
- 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();
- /*-------------------------------------------------------------------------
- * open output file
- *-------------------------------------------------------------------------*/
+ /*-------------------------------------------------------------------------
+ * open output file
+ *-------------------------------------------------------------------------*/
/* Attempt to open an existing HDF5 file first. Need to open the dst file
before the src file just in case that the dst and src are the same file
*/
- fid_dst = h5tools_fopen(fname_dst, H5F_ACC_RDWR, H5P_DEFAULT, NULL, NULL, 0);
+ fid_dst = h5tools_fopen(fname_dst, H5F_ACC_RDWR, H5P_DEFAULT, FALSE, NULL, 0);
- /*-------------------------------------------------------------------------
- * open input file
- *-------------------------------------------------------------------------*/
+ /*-------------------------------------------------------------------------
+ * open input file
+ *-------------------------------------------------------------------------*/
- fid_src = h5tools_fopen(fname_src, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, 0);
+ fid_src = h5tools_fopen(fname_src, H5F_ACC_RDONLY, H5P_DEFAULT, FALSE, NULL, 0);
- /*-------------------------------------------------------------------------
- * test for error in opening input file
- *-------------------------------------------------------------------------*/
- if (fid_src==-1) {
+ /*-------------------------------------------------------------------------
+ * test for error in opening input file
+ *-------------------------------------------------------------------------*/
+ if (fid_src == -1) {
error_msg("Could not open input file <%s>...Exiting\n", fname_src);
leave(EXIT_FAILURE);
}
-
- /*-------------------------------------------------------------------------
- * create an output file when failed to open it
- *-------------------------------------------------------------------------*/
+ /*-------------------------------------------------------------------------
+ * create an output file when failed to open it
+ *-------------------------------------------------------------------------*/
/* If we couldn't open an existing file, try creating file */
/* (use "EXCL" instead of "TRUNC", so we don't blow away existing non-HDF5 file) */
- if(fid_dst < 0)
+ if (fid_dst < 0)
fid_dst = H5Fcreate(fname_dst, H5F_ACC_EXCL, H5P_DEFAULT, H5P_DEFAULT);
- /*-------------------------------------------------------------------------
- * test for error in opening output file
- *-------------------------------------------------------------------------*/
- if (fid_dst==-1) {
+ /*-------------------------------------------------------------------------
+ * test for error in opening output file
+ *-------------------------------------------------------------------------*/
+ if (fid_dst == -1) {
error_msg("Could not open output file <%s>...Exiting\n", fname_dst);
leave(EXIT_FAILURE);
}
- /*-------------------------------------------------------------------------
- * print some info
- *-------------------------------------------------------------------------*/
+ /*-------------------------------------------------------------------------
+ * print some info
+ *-------------------------------------------------------------------------*/
if (verbose) {
- HDprintf("Copying file <%s> and object <%s> to file <%s> and object <%s>\n",
- fname_src, oname_src, fname_dst, oname_dst);
+ HDprintf("Copying file <%s> and object <%s> to file <%s> and object <%s>\n", fname_src, oname_src,
+ fname_dst, oname_dst);
if (flag) {
HDprintf("Using %s flag\n", str_flag);
}
}
-
- /*-------------------------------------------------------------------------
- * create property lists for copy
- *-------------------------------------------------------------------------*/
+ /*-------------------------------------------------------------------------
+ * create property lists for copy
+ *-------------------------------------------------------------------------*/
/* create property to pass copy options */
- if ( (ocpl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0)
- HGOTO_ERROR(EXIT_FAILURE, H5E_tools_min_id_g, "H5Pcreate failed");
+ if ((ocpl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0)
+ H5TOOLS_GOTO_ERROR(EXIT_FAILURE, "H5Pcreate failed");
/* set options for object copy */
if (flag) {
- if ( H5Pset_copy_object(ocpl_id, flag) < 0)
- HGOTO_ERROR(EXIT_FAILURE, H5E_tools_min_id_g, "H5Pset_copy_object failed");
+ if (H5Pset_copy_object(ocpl_id, flag) < 0)
+ H5TOOLS_GOTO_ERROR(EXIT_FAILURE, "H5Pset_copy_object failed");
}
/* Create link creation property list */
- if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) {
+ if ((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) {
error_msg("Could not create link creation property list\n");
- HGOTO_ERROR(EXIT_FAILURE, H5E_tools_min_id_g, "H5Pcreate failed");
+ H5TOOLS_GOTO_ERROR(EXIT_FAILURE, "H5Pcreate failed");
} /* end if */
/* Check for creating intermediate groups */
- if(parents) {
+ if (parents) {
/* Set the intermediate group creation property */
- if(H5Pset_create_intermediate_group(lcpl_id, 1) < 0) {
+ if (H5Pset_create_intermediate_group(lcpl_id, 1) < 0) {
error_msg("Could not set property for creating parent groups\n");
- HGOTO_ERROR(EXIT_FAILURE, H5E_tools_min_id_g, "H5Pset_create_intermediate_group failed");
+ H5TOOLS_GOTO_ERROR(EXIT_FAILURE, "H5Pset_create_intermediate_group failed");
} /* end if */
/* Display some output if requested */
- if(verbose)
+ if (verbose)
HDprintf("%s: Creating parent groups\n", h5tools_getprogname());
} /* end if */
else {
/* error, if parent groups doesn't already exist in destination file */
- size_t i, len;
+ size_t i, len;
len = HDstrlen(oname_dst);
/* check if all the parents groups exist. skip root group */
for (i = 1; i < len; i++) {
- if ('/'==oname_dst[i]) {
- char *str_ptr;
+ if ('/' == oname_dst[i]) {
+ char *str_ptr;
str_ptr = (char *)HDcalloc(i + 1, sizeof(char));
HDstrncpy(str_ptr, oname_dst, i);
- str_ptr[i]='\0';
+ str_ptr[i] = '\0';
if (H5Lexists(fid_dst, str_ptr, H5P_DEFAULT) <= 0) {
error_msg("group <%s> doesn't exist. Use -p to create parent groups.\n", str_ptr);
HDfree(str_ptr);
- HGOTO_ERROR(EXIT_FAILURE, H5E_tools_min_id_g, "H5Lexists failed");
+ H5TOOLS_GOTO_ERROR(EXIT_FAILURE, "H5Lexists failed");
}
HDfree(str_ptr);
}
}
}
- /*-------------------------------------------------------------------------
- * do the copy
- *-------------------------------------------------------------------------*/
+ /*-------------------------------------------------------------------------
+ * do the copy
+ *-------------------------------------------------------------------------*/
- if(verbose)
+ if (verbose)
linkinfo.opt.msg_mode = 1;
li_ret = H5tools_get_symlink_info(fid_src, oname_src, &linkinfo, 1);
if (li_ret == 0) {
/* dangling link */
- if(H5Lcopy(fid_src, oname_src,
- fid_dst, oname_dst,
- H5P_DEFAULT, H5P_DEFAULT) < 0)
- HGOTO_ERROR(EXIT_FAILURE, H5E_tools_min_id_g, "H5Lcopy failed");
+ if (H5Lcopy(fid_src, oname_src, fid_dst, oname_dst, H5P_DEFAULT, H5P_DEFAULT) < 0)
+ H5TOOLS_GOTO_ERROR(EXIT_FAILURE, "H5Lcopy failed");
}
else {
/* valid link */
- if (H5Ocopy(fid_src, /* Source file or group identifier */
- oname_src, /* Name of the source object to be copied */
- fid_dst, /* Destination file or group identifier */
- oname_dst, /* Name of the destination object */
- ocpl_id, /* Object copy property list */
- lcpl_id)<0) /* Link creation property list */
- HGOTO_ERROR(EXIT_FAILURE, H5E_tools_min_id_g, "H5Ocopy failed");
+ if (H5Ocopy(fid_src, /* Source file or group identifier */
+ oname_src, /* Name of the source object to be copied */
+ fid_dst, /* Destination file or group identifier */
+ oname_dst, /* Name of the destination object */
+ ocpl_id, /* Object copy property list */
+ lcpl_id) < 0) /* Link creation property list */
+ H5TOOLS_GOTO_ERROR(EXIT_FAILURE, "H5Ocopy failed");
}
/* free link info path */
@@ -476,16 +470,16 @@ main (int argc, const char *argv[])
HDfree(linkinfo.trg_path);
/* close propertis */
- if(H5Pclose(ocpl_id)<0)
- HGOTO_ERROR(EXIT_FAILURE, H5E_tools_min_id_g, "H5Pclose failed");
- if(H5Pclose(lcpl_id)<0)
- HGOTO_ERROR(EXIT_FAILURE, H5E_tools_min_id_g, "H5Pclose failed");
+ if (H5Pclose(ocpl_id) < 0)
+ H5TOOLS_GOTO_ERROR(EXIT_FAILURE, "H5Pclose failed");
+ if (H5Pclose(lcpl_id) < 0)
+ H5TOOLS_GOTO_ERROR(EXIT_FAILURE, "H5Pclose failed");
/* close files */
- if (H5Fclose(fid_src)<0)
- HGOTO_ERROR(EXIT_FAILURE, H5E_tools_min_id_g, "H5Fclose failed");
- if (H5Fclose(fid_dst)<0)
- HGOTO_ERROR(EXIT_FAILURE, H5E_tools_min_id_g, "H5Fclose failed");
+ if (H5Fclose(fid_src) < 0)
+ H5TOOLS_GOTO_ERROR(EXIT_FAILURE, "H5Fclose failed");
+ if (H5Fclose(fid_dst) < 0)
+ H5TOOLS_GOTO_ERROR(EXIT_FAILURE, "H5Fclose failed");
leave(EXIT_SUCCESS);
@@ -496,13 +490,14 @@ done:
if (linkinfo.trg_path)
HDfree(linkinfo.trg_path);
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Pclose(ocpl_id);
H5Pclose(lcpl_id);
H5Fclose(fid_src);
H5Fclose(fid_dst);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
leave(ret_value);
}
-
diff --git a/tools/src/h5diff/CMakeLists.txt b/tools/src/h5diff/CMakeLists.txt
index 96ed6ad..e54b2da 100644
--- a/tools/src/h5diff/CMakeLists.txt
+++ b/tools/src/h5diff/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.10)
+cmake_minimum_required (VERSION 3.12)
project (HDF5_TOOLS_SRC_H5DIFF C)
# --------------------------------------------------------------------
@@ -8,8 +8,11 @@ if (NOT ONLY_SHARED_LIBS)
add_executable (h5diff
${HDF5_TOOLS_SRC_H5DIFF_SOURCE_DIR}/h5diff_common.c
${HDF5_TOOLS_SRC_H5DIFF_SOURCE_DIR}/h5diff_main.c
+ ${HDF5_TOOLS_SRC_H5DIFF_SOURCE_DIR}/h5diff_common.h
)
- target_include_directories (h5diff PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_include_directories (h5diff PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5diff PRIVATE "${HDF5_CMAKE_C_FLAGS}")
+ #target_compile_definitions (h5diff PRIVATE H5_TOOLS_DEBUG)
TARGET_C_PROPERTIES (h5diff STATIC)
target_link_libraries (h5diff PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
set_target_properties (h5diff PROPERTIES FOLDER tools)
@@ -21,8 +24,11 @@ if (BUILD_SHARED_LIBS)
add_executable (h5diff-shared
${HDF5_TOOLS_SRC_H5DIFF_SOURCE_DIR}/h5diff_common.c
${HDF5_TOOLS_SRC_H5DIFF_SOURCE_DIR}/h5diff_main.c
+ ${HDF5_TOOLS_SRC_H5DIFF_SOURCE_DIR}/h5diff_common.h
)
- target_include_directories (h5diff-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_include_directories (h5diff-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5diff-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}")
+ #target_compile_definitions (h5diff-shared PRIVATE H5_TOOLS_DEBUG)
TARGET_C_PROPERTIES (h5diff-shared SHARED)
target_link_libraries (h5diff-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
set_target_properties (h5diff-shared PROPERTIES FOLDER tools)
@@ -31,13 +37,25 @@ if (BUILD_SHARED_LIBS)
set (H5_DEP_EXECUTABLES ${H5_DEP_EXECUTABLES} h5diff-shared)
endif ()
+#-----------------------------------------------------------------------------
+# Add Target to clang-format
+#-----------------------------------------------------------------------------
+if (HDF5_ENABLE_FORMATTERS)
+ if (NOT ONLY_SHARED_LIBS)
+ clang_format (HDF5_H5DIFF_SRC_FORMAT h5diff)
+ else ()
+ clang_format (HDF5_H5DIFF_SRC_FORMAT h5diff-shared)
+ endif ()
+endif ()
+
if (H5_HAVE_PARALLEL)
if (NOT ONLY_SHARED_LIBS)
add_executable (ph5diff
${HDF5_TOOLS_SRC_H5DIFF_SOURCE_DIR}/h5diff_common.c
${HDF5_TOOLS_SRC_H5DIFF_SOURCE_DIR}/ph5diff_main.c
)
- target_include_directories (ph5diff PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_include_directories (ph5diff PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(ph5diff PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (ph5diff STATIC)
target_link_libraries (ph5diff PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET} "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_LIBRARIES}>")
set_target_properties (ph5diff PROPERTIES FOLDER tools)
@@ -49,7 +67,8 @@ if (H5_HAVE_PARALLEL)
${HDF5_TOOLS_SRC_H5DIFF_SOURCE_DIR}/h5diff_common.c
${HDF5_TOOLS_SRC_H5DIFF_SOURCE_DIR}/ph5diff_main.c
)
- target_include_directories (ph5diff-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_include_directories (ph5diff-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(ph5diff-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (ph5diff-shared SHARED)
target_link_libraries (ph5diff-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_LIBRARIES}>")
set_target_properties (ph5diff-shared PROPERTIES FOLDER tools)
diff --git a/tools/src/h5diff/Makefile.am b/tools/src/h5diff/Makefile.am
index 3957e59..451ad20 100644
--- a/tools/src/h5diff/Makefile.am
+++ b/tools/src/h5diff/Makefile.am
@@ -6,7 +6,7 @@
# This file is part of HDF5. The full HDF5 copyright notice, including
# terms governing use, modification, and redistribution, is contained in
# the COPYING file, which can be found at the root of the source code
-# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.
+# distribution tree, or in https://www.hdfgroup.org/licenses.
# If you do not have access to either file, you may request a copy from
# help@hdfgroup.org.
##
diff --git a/tools/src/h5diff/h5diff_common.c b/tools/src/h5diff/h5diff_common.c
index 362e3f2..2619a9d 100644
--- a/tools/src/h5diff/h5diff_common.c
+++ b/tools/src/h5diff/h5diff_common.c
@@ -6,7 +6,7 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -17,42 +17,53 @@
#include "h5tools.h"
#include "h5tools_utils.h"
-static int check_n_input(const char*);
-static int check_p_input(const char*);
-static int check_d_input(const char*);
+static int check_n_input(const char *);
+static int check_p_input(const char *);
+static int check_d_input(const char *);
/*
* Command-line options: The user can specify short or long-named
* parameters.
*/
-static const char *s_opts = "hVrv:qn:d:p:NcelxE:S";
-static struct long_options l_opts[] = {
- { "help", no_arg, 'h' },
- { "version", no_arg, 'V' },
- { "report", no_arg, 'r' },
- { "verbose", optional_arg, 'v' },
- { "quiet", no_arg, 'q' },
- { "count", require_arg, 'n' },
- { "delta", require_arg, 'd' },
- { "relative", require_arg, 'p' },
- { "nan", no_arg, 'N' },
- { "compare", no_arg, 'c' },
- { "use-system-epsilon", no_arg, 'e' },
- { "follow-symlinks", no_arg, 'l' },
- { "no-dangling-links", no_arg, 'x' },
- { "exclude-path", require_arg, 'E' },
- { "enable-error-stack", no_arg, 'S' },
- { NULL, 0, '\0' }
-};
+static const char * s_opts = "hVrv*qn:d:p:NcelxE:A:S*";
+static struct h5_long_options l_opts[] = {{"help", no_arg, 'h'},
+ {"version", no_arg, 'V'},
+ {"report", no_arg, 'r'},
+ {"verbose", optional_arg, 'v'},
+ {"quiet", no_arg, 'q'},
+ {"count", require_arg, 'n'},
+ {"delta", require_arg, 'd'},
+ {"relative", require_arg, 'p'},
+ {"nan", no_arg, 'N'},
+ {"compare", no_arg, 'c'},
+ {"use-system-epsilon", no_arg, 'e'},
+ {"follow-symlinks", no_arg, 'l'},
+ {"no-dangling-links", no_arg, 'x'},
+ {"exclude-path", require_arg, 'E'},
+ {"exclude-attribute", require_arg, 'A'},
+ {"enable-error-stack", optional_arg, 'S'},
+ {"vol-value-1", require_arg, '1'},
+ {"vol-name-1", require_arg, '2'},
+ {"vol-info-1", require_arg, '3'},
+ {"vol-value-2", require_arg, '4'},
+ {"vol-name-2", require_arg, '5'},
+ {"vol-info-2", require_arg, '6'},
+ {"vfd-value-1", require_arg, '7'},
+ {"vfd-name-1", require_arg, '8'},
+ {"vfd-info-1", require_arg, '9'},
+ {"vfd-value-2", require_arg, '0'},
+ {"vfd-name-2", require_arg, 'Y'},
+ {"vfd-info-2", require_arg, 'Z'},
+ {NULL, 0, '\0'}};
/*-------------------------------------------------------------------------
* Function: check_options
*
* Purpose: parse command line input
- *
*-------------------------------------------------------------------------
*/
-static void check_options(diff_opt_t* opts)
+static void
+check_options(diff_opt_t *opts)
{
/*--------------------------------------------------------------
* check for mutually exclusive options
@@ -61,37 +72,151 @@ static void check_options(diff_opt_t* opts)
/* check between -d , -p, --use-system-epsilon.
* These options are mutually exclusive.
*/
- if ((opts->d + opts->p + opts->use_system_epsilon) > 1) {
+ if ((opts->delta_bool + opts->percent_bool + opts->use_system_epsilon) > 1) {
HDprintf("%s error: -d, -p and --use-system-epsilon options are mutually-exclusive;\n", PROGRAMNAME);
HDprintf("use no more than one.\n");
- HDprintf("Try '-h' or '--help' option for more information or see the %s entry in the 'HDF5 Reference Manual'.\n", PROGRAMNAME);
+ HDprintf("Try '-h' or '--help' option for more information or see the %s entry in the 'HDF5 "
+ "Reference Manual'.\n",
+ PROGRAMNAME);
h5diff_exit(EXIT_FAILURE);
}
}
+/*-------------------------------------------------------------------------
+ * Function: parse_hsize_list
+ *
+ * Purpose: Parse a list of comma or space separated integers and return
+ * them in a list. The string being passed into this function
+ * should be at the start of the list you want to parse. You are
+ * responsible for freeing the array returned from here.
+ *
+ * Lists in the so-called "terse" syntax are separated by
+ * semicolons (;). The lists themselves can be separated by
+ * either commas (,) or white spaces.
+ *
+ * Return: <none>
+ *-------------------------------------------------------------------------
+ */
+static void
+parse_hsize_list(const char *h_list, subset_d *d)
+{
+ hsize_t * p_list;
+ const char * ptr;
+ unsigned int size_count = 0;
+ unsigned int i = 0;
+ unsigned int last_digit = 0;
+
+ if (!h_list || !*h_list || *h_list == ';')
+ return;
+
+ H5TOOLS_START_DEBUG(" - h_list:%s", h_list);
+ /* count how many integers do we have */
+ for (ptr = h_list; ptr && *ptr && *ptr != ';' && *ptr != ']'; ptr++)
+ if (HDisdigit(*ptr)) {
+ if (!last_digit)
+ /* the last read character wasn't a digit */
+ size_count++;
+
+ last_digit = 1;
+ }
+ else
+ last_digit = 0;
+
+ if (size_count == 0) {
+ /* there aren't any integers to read */
+ H5TOOLS_ENDDEBUG("No integers to read");
+ return;
+ }
+ H5TOOLS_DEBUG("Number integers to read=%ld", size_count);
+
+ /* allocate an array for the integers in the list */
+ if ((p_list = (hsize_t *)HDcalloc(size_count, sizeof(hsize_t))) == NULL)
+ H5TOOLS_INFO("Unable to allocate space for subset data");
+
+ for (ptr = h_list; i < size_count && ptr && *ptr && *ptr != ';' && *ptr != ']'; ptr++)
+ if (HDisdigit(*ptr)) {
+ /* we should have an integer now */
+ p_list[i++] = (hsize_t)HDstrtoull(ptr, NULL, 0);
+
+ while (HDisdigit(*ptr))
+ /* scroll to end of integer */
+ ptr++;
+ }
+ d->data = p_list;
+ d->len = size_count;
+ H5TOOLS_ENDDEBUG(" ");
+}
+
+/*-------------------------------------------------------------------------
+ * Function: parse_subset_params
+ *
+ * Purpose: Parse the so-called "terse" syntax for specifying subsetting parameters.
+ *
+ * Return: Success: struct subset_t object
+ * Failure: NULL
+ *-------------------------------------------------------------------------
+ */
+static struct subset_t *
+parse_subset_params(const char *dset)
+{
+ struct subset_t *s = NULL;
+ char * brace;
+
+ H5TOOLS_START_DEBUG(" - dset:%s", dset);
+ if ((brace = HDstrrchr(dset, '[')) != NULL) {
+ *brace++ = '\0';
+
+ s = (struct subset_t *)HDcalloc(1, sizeof(struct subset_t));
+ parse_hsize_list(brace, &s->start);
+
+ while (*brace && *brace != ';')
+ brace++;
+
+ if (*brace)
+ brace++;
+
+ parse_hsize_list(brace, &s->stride);
+
+ while (*brace && *brace != ';')
+ brace++;
+
+ if (*brace)
+ brace++;
+
+ parse_hsize_list(brace, &s->count);
+
+ while (*brace && *brace != ';')
+ brace++;
+
+ if (*brace)
+ brace++;
+
+ parse_hsize_list(brace, &s->block);
+ }
+ H5TOOLS_ENDDEBUG(" ");
+
+ return s;
+}
/*-------------------------------------------------------------------------
* Function: parse_command_line
*
* Purpose: parse command line input
- *
*-------------------------------------------------------------------------
*/
-void parse_command_line(int argc,
- const char* argv[],
- const char** fname1,
- const char** fname2,
- const char** objname1,
- const char** objname2,
- diff_opt_t* opts)
+void
+parse_command_line(int argc, const char *const *argv, const char **fname1, const char **fname2,
+ const char **objname1, const char **objname2, diff_opt_t *opts)
{
- int i;
- int opt;
+ int i;
+ int opt;
struct exclude_path_list *exclude_head, *exclude_prev, *exclude_node;
+ struct exclude_path_list *exclude_attr_head, *exclude_attr_prev, *exclude_attr_node;
+ H5TOOLS_START_DEBUG(" ");
/* process the command-line */
- memset(opts, 0, sizeof (diff_opt_t));
+ HDmemset(opts, 0, sizeof(diff_opt_t));
/* assume equal contents initially */
opts->contents = 1;
@@ -100,164 +225,254 @@ void parse_command_line(int argc,
opts->do_nans = 1;
/* not Listing objects that are not comparable */
- opts->m_list_not_cmp = 0;
+ opts->mode_list_not_cmp = 0;
/* initially no not-comparable. */
/**this is bad in mixing option with results**/
- opts->not_cmp=0;
+ opts->not_cmp = 0;
/* init for exclude-path option */
exclude_head = NULL;
+ /* init for exclude-attribute option */
+ exclude_attr_head = NULL;
+
/* parse command line options */
- while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) {
+ while ((opt = H5_get_option(argc, argv, s_opts, l_opts)) != EOF) {
switch ((char)opt) {
- default:
- usage();
- h5diff_exit(EXIT_FAILURE);
- break;
-
- case 'h':
- usage();
- h5diff_exit(EXIT_SUCCESS);
- break;
-
- case 'V':
- print_version(h5tools_getprogname());
- h5diff_exit(EXIT_SUCCESS);
- break;
-
- case 'v':
- opts->m_verbose = 1;
- /* This for loop is for handling style like
- * -v, -v1, --verbose, --verbose=1.
- */
- for (i = 1; i < argc; i++) {
- /*
- * short opt
- */
- if (!strcmp (argv[i], "-v")) { /* no arg */
- opt_ind--;
- opts->m_verbose_level = 0;
- break;
- }
- else if (!strncmp (argv[i], "-v", (size_t)2)) {
- opts->m_verbose_level = atoi(&argv[i][2]);
- break;
- }
+ default:
+ usage();
+ h5diff_exit(EXIT_FAILURE);
+ break;
- /*
- * long opt
- */
- if (!strcmp (argv[i], "--verbose")) { /* no arg */
- opts->m_verbose_level = 0;
- break;
+ case 'h':
+ usage();
+ h5diff_exit(EXIT_SUCCESS);
+ break;
+
+ case 'V':
+ print_version(h5tools_getprogname());
+ h5diff_exit(EXIT_SUCCESS);
+ break;
+
+ case 'v':
+ opts->mode_verbose = 1;
+ for (i = 1; i < argc; i++) {
+ /*
+ * special check for short opt
+ */
+ if (!strcmp(argv[i], "-v")) {
+ if (H5_optarg != NULL)
+ H5_optind--;
+ opts->mode_verbose_level = 0;
+ break;
+ }
+ else if (!strncmp(argv[i], "-v", (size_t)2)) {
+ if (H5_optarg != NULL)
+ H5_optind--;
+ opts->mode_verbose_level = atoi(&argv[i][2]);
+ break;
+ }
+ else {
+ if (H5_optarg != NULL)
+ opts->mode_verbose_level = HDatoi(H5_optarg);
+ else
+ opts->mode_verbose_level = 0;
+ }
}
- else if ( !strncmp (argv[i], "--verbose", (size_t)9) && argv[i][9]=='=') {
- opts->m_verbose_level = atoi(&argv[i][10]);
- break;
+ break;
+
+ case 'q':
+ /* use quiet mode; suppress the message "0 differences found" */
+ opts->mode_quiet = 1;
+ break;
+
+ case 'r':
+ opts->mode_report = 1;
+ break;
+
+ case 'l':
+ opts->follow_links = TRUE;
+ break;
+
+ case 'x':
+ opts->no_dangle_links = 1;
+ break;
+
+ case 'S':
+ if (H5_optarg != NULL)
+ enable_error_stack = HDatoi(H5_optarg);
+ else
+ enable_error_stack = 1;
+ break;
+
+ case 'E':
+ opts->exclude_path = 1;
+
+ /* create linked list of excluding objects */
+ if ((exclude_node = (struct exclude_path_list *)HDmalloc(sizeof(struct exclude_path_list))) ==
+ NULL) {
+ HDprintf("Error: lack of memory!\n");
+ h5diff_exit(EXIT_FAILURE);
}
- }
- break;
- case 'q':
- /* use quiet mode; supress the message "0 differences found" */
- opts->m_quiet = 1;
- break;
+ /* init */
+ exclude_node->obj_path = H5_optarg;
+ exclude_node->obj_type = H5TRAV_TYPE_UNKNOWN;
+ exclude_prev = exclude_head;
- case 'r':
- opts->m_report = 1;
- break;
+ if (NULL == exclude_head) {
+ exclude_head = exclude_node;
+ exclude_head->next = NULL;
+ }
+ else {
+ while (NULL != exclude_prev->next)
+ exclude_prev = exclude_prev->next;
- case 'l':
- opts->follow_links = TRUE;
- break;
+ exclude_node->next = NULL;
+ exclude_prev->next = exclude_node;
+ }
+ break;
- case 'x':
- opts->no_dangle_links = 1;
- break;
+ case 'A':
+ opts->exclude_attr_path = 1;
- case 'S':
- enable_error_stack = 1;
- break;
+ /* create linked list of excluding objects */
+ if ((exclude_attr_node =
+ (struct exclude_path_list *)HDmalloc(sizeof(struct exclude_path_list))) == NULL) {
+ HDprintf("Error: lack of memory!\n");
+ h5diff_exit(EXIT_FAILURE);
+ }
- case 'E':
- opts->exclude_path = 1;
+ /* init */
+ exclude_attr_node->obj_path = H5_optarg;
+ exclude_attr_node->obj_type = H5TRAV_TYPE_UNKNOWN;
+ exclude_attr_prev = exclude_attr_head;
- /* create linked list of excluding objects */
- if( (exclude_node = (struct exclude_path_list*) HDmalloc(sizeof(struct exclude_path_list))) == NULL) {
- HDprintf("Error: lack of memory!\n");
- h5diff_exit(EXIT_FAILURE);
- }
-
- /* init */
- exclude_node->obj_path = (char*)opt_arg;
- exclude_node->obj_type = H5TRAV_TYPE_UNKNOWN;
- exclude_prev = exclude_head;
-
- if (NULL == exclude_head) {
- exclude_head = exclude_node;
- exclude_head->next = NULL;
- }
- else {
- while(NULL != exclude_prev->next)
- exclude_prev=exclude_prev->next;
-
- exclude_node->next = NULL;
- exclude_prev->next = exclude_node;
- }
- break;
-
- case 'd':
- opts->d=1;
-
- if (check_d_input(opt_arg) == - 1) {
- HDprintf("<-d %s> is not a valid option\n", opt_arg);
- usage();
- h5diff_exit(EXIT_FAILURE);
- }
- opts->delta = atof(opt_arg);
-
- /* -d 0 is the same as default */
- if (H5_DBL_ABS_EQUAL(opts->delta, (double)0.0F))
- opts->d=0;
- break;
-
- case 'p':
- opts->p=1;
- if (check_p_input(opt_arg) == -1) {
- HDprintf("<-p %s> is not a valid option\n", opt_arg);
- usage();
- h5diff_exit(EXIT_FAILURE);
- }
- opts->percent = atof(opt_arg);
-
- /* -p 0 is the same as default */
- if (H5_DBL_ABS_EQUAL(opts->percent, (double)0.0F))
- opts->p = 0;
- break;
-
- case 'n':
- opts->n=1;
- if ( check_n_input(opt_arg) == -1) {
- HDprintf("<-n %s> is not a valid option\n", opt_arg);
- usage();
- h5diff_exit(EXIT_FAILURE);
- }
- opts->count = HDstrtoull(opt_arg, NULL, 0);
- break;
+ if (NULL == exclude_attr_head) {
+ exclude_attr_head = exclude_attr_node;
+ exclude_attr_head->next = NULL;
+ }
+ else {
+ while (NULL != exclude_attr_prev->next)
+ exclude_attr_prev = exclude_attr_prev->next;
- case 'N':
- opts->do_nans = 0;
- break;
+ exclude_attr_node->next = NULL;
+ exclude_attr_prev->next = exclude_attr_node;
+ }
+ break;
- case 'c':
- opts->m_list_not_cmp = 1;
- break;
+ case 'd':
+ opts->delta_bool = 1;
- case 'e':
- opts->use_system_epsilon = 1;
- break;
+ if (check_d_input(H5_optarg) == -1) {
+ HDprintf("<-d %s> is not a valid option\n", H5_optarg);
+ usage();
+ h5diff_exit(EXIT_FAILURE);
+ }
+ opts->delta = HDatof(H5_optarg);
+ /* do not check against default, the DBL_EPSILON is being replaced by user */
+ break;
+
+ case 'p':
+ opts->percent_bool = 1;
+ if (check_p_input(H5_optarg) == -1) {
+ HDprintf("<-p %s> is not a valid option\n", H5_optarg);
+ usage();
+ h5diff_exit(EXIT_FAILURE);
+ }
+ opts->percent = HDatof(H5_optarg);
+
+ /* -p 0 is the same as default */
+ if (H5_DBL_ABS_EQUAL(opts->percent, 0.0))
+ opts->percent_bool = 0;
+ break;
+
+ case 'n':
+ opts->count_bool = 1;
+ if (check_n_input(H5_optarg) == -1) {
+ HDprintf("<-n %s> is not a valid option\n", H5_optarg);
+ usage();
+ h5diff_exit(EXIT_FAILURE);
+ }
+ opts->count = HDstrtoull(H5_optarg, NULL, 0);
+ break;
+
+ case 'N':
+ opts->do_nans = 0;
+ break;
+
+ case 'c':
+ opts->mode_list_not_cmp = 1;
+ break;
+
+ case 'e':
+ opts->use_system_epsilon = 1;
+ break;
+
+ case '1':
+ opts->vol_info[0].type = VOL_BY_VALUE;
+ opts->vol_info[0].u.value = (H5VL_class_value_t)HDatoi(H5_optarg);
+ opts->custom_vol[0] = TRUE;
+ break;
+
+ case '2':
+ opts->vol_info[0].type = VOL_BY_NAME;
+ opts->vol_info[0].u.name = H5_optarg;
+ opts->custom_vol[0] = TRUE;
+ break;
+
+ case '3':
+ opts->vol_info[0].info_string = H5_optarg;
+ break;
+
+ case '4':
+ opts->vol_info[1].type = VOL_BY_VALUE;
+ opts->vol_info[1].u.value = (H5VL_class_value_t)HDatoi(H5_optarg);
+ opts->custom_vol[1] = TRUE;
+ break;
+
+ case '5':
+ opts->vol_info[1].type = VOL_BY_NAME;
+ opts->vol_info[1].u.name = H5_optarg;
+ opts->custom_vol[1] = TRUE;
+ break;
+
+ case '6':
+ opts->vol_info[1].info_string = H5_optarg;
+ break;
+
+ case '7':
+ opts->vfd_info[0].type = VFD_BY_VALUE;
+ opts->vfd_info[0].u.value = (H5FD_class_value_t)HDatoi(H5_optarg);
+ opts->custom_vfd[0] = TRUE;
+ break;
+
+ case '8':
+ opts->vfd_info[0].type = VFD_BY_NAME;
+ opts->vfd_info[0].u.name = H5_optarg;
+ opts->custom_vol[0] = TRUE;
+ break;
+
+ case '9':
+ opts->vfd_info[0].info = (const void *)H5_optarg;
+ break;
+
+ case '0':
+ opts->vfd_info[1].type = VFD_BY_VALUE;
+ opts->vfd_info[1].u.value = (H5FD_class_value_t)HDatoi(H5_optarg);
+ opts->custom_vfd[1] = TRUE;
+ break;
+
+ case 'Y':
+ opts->vfd_info[1].type = VFD_BY_NAME;
+ opts->vfd_info[1].u.name = H5_optarg;
+ opts->custom_vfd[1] = TRUE;
+ break;
+
+ case 'Z':
+ opts->vfd_info[1].info = (const void *)H5_optarg;
+ break;
}
}
@@ -268,64 +483,79 @@ void parse_command_line(int argc,
if (opts->exclude_path)
opts->exclude = exclude_head;
+ /* if exclude-attribute option is used, keep the exclude attr list */
+ if (opts->exclude_attr_path)
+ opts->exclude_attr = exclude_attr_head;
+
/* check for file names to be processed */
- if (argc <= opt_ind || argv[ opt_ind + 1 ] == NULL) {
+ if (argc <= H5_optind || argv[H5_optind + 1] == NULL) {
error_msg("missing file names\n");
usage();
h5diff_exit(EXIT_FAILURE);
}
- *fname1 = argv[ opt_ind ];
- *fname2 = argv[ opt_ind + 1 ];
- *objname1 = argv[ opt_ind + 2 ];
+ *fname1 = argv[H5_optind];
+ *fname2 = argv[H5_optind + 1];
+ *objname1 = argv[H5_optind + 2];
+ H5TOOLS_DEBUG("file1 = %s", *fname1);
+ H5TOOLS_DEBUG("file2 = %s", *fname2);
if (*objname1 == NULL) {
*objname2 = NULL;
+ H5TOOLS_ENDDEBUG("No obj names");
return;
}
+ H5TOOLS_DEBUG("objname1 = %s", *objname1);
- if (argv[ opt_ind + 3 ] != NULL) {
- *objname2 = argv[ opt_ind + 3 ];
+ if (argv[H5_optind + 3] != NULL) {
+ *objname2 = argv[H5_optind + 3];
}
else {
*objname2 = *objname1;
}
+ H5TOOLS_DEBUG("objname2 = %s", *objname2);
+
+ /*
+ * TRILABS_227 is complete except for an issue with printing indices
+ * the following calls will enable subsetting
+ */
+ opts->sset[0] = parse_subset_params(*objname1);
+ opts->sset[1] = parse_subset_params(*objname2);
+ H5TOOLS_ENDDEBUG(" ");
}
-
/*-------------------------------------------------------------------------
* Function: print_info
*
* Purpose: print several information messages after h5diff call
- *
*-------------------------------------------------------------------------
*/
+void
+print_info(diff_opt_t *opts)
+{
+ if (opts->mode_quiet || opts->err_stat)
+ return;
- void print_info(diff_opt_t* opts)
- {
- if (opts->m_quiet || opts->err_stat)
- return;
-
- if (opts->cmn_objs == 0) {
- HDprintf("No common objects found. Files are not comparable.\n");
- if (!opts->m_verbose)
- HDprintf("Use -v for a list of objects.\n");
- }
-
- if (opts->not_cmp == 1) {
- if (opts->m_list_not_cmp == 0) {
- HDprintf("--------------------------------\n");
- HDprintf("Some objects are not comparable\n");
- HDprintf("--------------------------------\n");
- if (opts->m_verbose)
- HDprintf("Use -c for a list of objects without details of differences.\n");
- else
- HDprintf("Use -c for a list of objects.\n");
- }
- }
- }
+ if (opts->cmn_objs == 0) {
+ HDprintf("No common objects found. Files are not comparable.\n");
+ if (!opts->mode_verbose)
+ HDprintf("Use -v for a list of objects.\n");
+ }
+
+ if (opts->not_cmp == 1) {
+ if (opts->mode_list_not_cmp == 0) {
+ HDprintf("--------------------------------\n");
+ HDprintf("Some objects are not comparable\n");
+ HDprintf("--------------------------------\n");
+ if (opts->mode_verbose)
+ HDprintf("Use -c for a list of objects without details of differences.\n");
+ else
+ HDprintf("Use -c for a list of objects.\n");
+ }
+ }
+}
/*-------------------------------------------------------------------------
* Function: check_n_input
@@ -333,22 +563,13 @@ void parse_command_line(int argc,
* Purpose: check for valid input
*
* Return: 1 for ok, -1 for fail
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: May 9, 2003
- *
- * Comments:
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
H5_ATTR_PURE static int
-check_n_input( const char *str )
+check_n_input(const char *str)
{
unsigned i;
- char c;
+ char c;
for (i = 0; i < HDstrlen(str); i++) {
c = str[i];
@@ -356,9 +577,8 @@ check_n_input( const char *str )
if (c < 49 || c > 57) /* ascii values between 1 and 9 */
return -1;
}
- else
- if (c < 48 || c > 57) /* 0 also */
- return -1;
+ else if (c < 48 || c > 57) /* 0 also */
+ return -1;
}
return 1;
}
@@ -369,28 +589,21 @@ check_n_input( const char *str )
* Purpose: check for a valid p option input
*
* Return: 1 for ok, -1 for fail
- *
- * Date: May 9, 2003
- *
- * Comments:
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static int
-check_p_input( const char *str )
+check_p_input(const char *str)
{
double x;
/*
- the atof return value on a hexadecimal input is different
- on some systems; we do a character check for this
- */
+ * the atof return value on a hexadecimal input is different
+ * on some systems; we do a character check for this
+ */
if (HDstrlen(str) > 2 && str[0] == '0' && str[1] == 'x')
return -1;
- x = atof(str);
+ x = HDatof(str);
if (x < 0)
return -1;
@@ -403,28 +616,21 @@ check_p_input( const char *str )
* Purpose: check for a valid d option input
*
* Return: 1 for ok, -1 for fail
- *
- * Date: November 11, 2007
- *
- * Comments:
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static int
-check_d_input( const char *str )
+check_d_input(const char *str)
{
double x;
/*
- the atof return value on a hexadecimal input is different
- on some systems; we do a character check for this
- */
+ * the atof return value on a hexadecimal input is different
+ * on some systems; we do a character check for this
+ */
if (HDstrlen(str) > 2 && str[0] == '0' && str[1] == 'x')
return -1;
- x = atof(str);
+ x = HDatof(str);
if (x < 0)
return -1;
@@ -437,159 +643,278 @@ check_d_input( const char *str )
* Purpose: print a usage message
*
* Return: void
- *
*-------------------------------------------------------------------------
*/
-void usage(void)
+void
+usage(void)
{
- PRINTVALSTREAM(rawoutstream, "usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]]\n");
- PRINTVALSTREAM(rawoutstream, " file1 File name of the first HDF5 file\n");
- PRINTVALSTREAM(rawoutstream, " file2 File name of the second HDF5 file\n");
- PRINTVALSTREAM(rawoutstream, " [obj1] Name of an HDF5 object, in absolute path\n");
- PRINTVALSTREAM(rawoutstream, " [obj2] Name of an HDF5 object, in absolute path\n");
- PRINTVALSTREAM(rawoutstream, "\n");
- PRINTVALSTREAM(rawoutstream, " OPTIONS\n");
- PRINTVALSTREAM(rawoutstream, " -h, --help\n");
- PRINTVALSTREAM(rawoutstream, " Print a usage message and exit.\n");
- PRINTVALSTREAM(rawoutstream, " -V, --version\n");
- PRINTVALSTREAM(rawoutstream, " Print version number and exit.\n");
- PRINTVALSTREAM(rawoutstream, " -r, --report\n");
- PRINTVALSTREAM(rawoutstream, " Report mode. Print differences.\n");
- PRINTVALSTREAM(rawoutstream, " -v --verbose\n");
- PRINTVALSTREAM(rawoutstream, " Verbose mode. Print differences information and list of objects.\n");
- PRINTVALSTREAM(rawoutstream, " -vN --verbose=N\n");
- PRINTVALSTREAM(rawoutstream, " Verbose mode with level. Print differences and list of objects.\n");
- PRINTVALSTREAM(rawoutstream, " Level of detail depends on value of N:\n");
- PRINTVALSTREAM(rawoutstream, " 0 : Identical to '-v' or '--verbose'.\n");
- PRINTVALSTREAM(rawoutstream, " 1 : All level 0 information plus one-line attribute\n");
- PRINTVALSTREAM(rawoutstream, " status summary.\n");
- PRINTVALSTREAM(rawoutstream, " 2 : All level 1 information plus extended attribute\n");
- PRINTVALSTREAM(rawoutstream, " status report.\n");
- PRINTVALSTREAM(rawoutstream, " -q, --quiet\n");
- PRINTVALSTREAM(rawoutstream, " Quiet mode. Do not produce output.\n");
- PRINTVALSTREAM(rawoutstream, " --enable-error-stack\n");
- PRINTVALSTREAM(rawoutstream, " Prints messages from the HDF5 error stack as they occur.\n");
- PRINTVALSTREAM(rawoutstream, " --follow-symlinks\n");
- PRINTVALSTREAM(rawoutstream, " Follow symbolic links (soft links and external links and compare the)\n");
- PRINTVALSTREAM(rawoutstream, " links' target objects.\n");
- PRINTVALSTREAM(rawoutstream, " If symbolic link(s) with the same name exist in the files being\n");
- PRINTVALSTREAM(rawoutstream, " compared, then determine whether the target of each link is an existing\n");
- PRINTVALSTREAM(rawoutstream, " object (dataset, group, or named datatype) or the link is a dangling\n");
- PRINTVALSTREAM(rawoutstream, " link (a soft or external link pointing to a target object that does\n");
- PRINTVALSTREAM(rawoutstream, " not yet exist).\n");
- PRINTVALSTREAM(rawoutstream, " - If both symbolic links are dangling links, they are treated as being\n");
- PRINTVALSTREAM(rawoutstream, " the same; by default, h5diff returns an exit code of 0.\n");
- PRINTVALSTREAM(rawoutstream, " If, however, --no-dangling-links is used with --follow-symlinks,\n");
- PRINTVALSTREAM(rawoutstream, " this situation is treated as an error and h5diff returns an\n");
- PRINTVALSTREAM(rawoutstream, " exit code of 2.\n");
- PRINTVALSTREAM(rawoutstream, " - If only one of the two links is a dangling link,they are treated as\n");
- PRINTVALSTREAM(rawoutstream, " being different and h5diff returns an exit code of 1.\n");
- PRINTVALSTREAM(rawoutstream, " If, however, --no-dangling-links is used with --follow-symlinks,\n");
- PRINTVALSTREAM(rawoutstream, " this situation is treated as an error and h5diff returns an\n");
- PRINTVALSTREAM(rawoutstream, " exit code of 2.\n");
- PRINTVALSTREAM(rawoutstream, " - If both symbolic links point to existing objects, h5diff compares the\n");
- PRINTVALSTREAM(rawoutstream, " two objects.\n");
- PRINTVALSTREAM(rawoutstream, " If any symbolic link specified in the call to h5diff does not exist,\n");
- PRINTVALSTREAM(rawoutstream, " h5diff treats it as an error and returns an exit code of 2.\n");
- PRINTVALSTREAM(rawoutstream, " --no-dangling-links\n");
- PRINTVALSTREAM(rawoutstream, " Must be used with --follow-symlinks option; otherwise, h5diff shows\n");
- PRINTVALSTREAM(rawoutstream, " error message and returns an exit code of 2.\n");
- PRINTVALSTREAM(rawoutstream, " Check for any symbolic links (soft links or external links) that do not\n");
- PRINTVALSTREAM(rawoutstream, " resolve to an existing object (dataset, group, or named datatype).\n");
- PRINTVALSTREAM(rawoutstream, " If any dangling link is found, this situation is treated as an error\n");
- PRINTVALSTREAM(rawoutstream, " and h5diff returns an exit code of 2.\n");
- PRINTVALSTREAM(rawoutstream, " -c, --compare\n");
- PRINTVALSTREAM(rawoutstream, " List objects that are not comparable\n");
- PRINTVALSTREAM(rawoutstream, " -N, --nan\n");
- PRINTVALSTREAM(rawoutstream, " Avoid NaNs detection\n");
- PRINTVALSTREAM(rawoutstream, " -n C, --count=C\n");
- PRINTVALSTREAM(rawoutstream, " Print differences up to C. C must be a positive integer.\n");
- PRINTVALSTREAM(rawoutstream, " -d D, --delta=D\n");
- PRINTVALSTREAM(rawoutstream, " Print difference if (|a-b| > D). D must be a positive number. Where a\n");
- PRINTVALSTREAM(rawoutstream, " is the data point value in file1 and b is the data point value in file2.\n");
- PRINTVALSTREAM(rawoutstream, " Can not use with '-p' or '--use-system-epsilon'.\n");
- PRINTVALSTREAM(rawoutstream, " -p R, --relative=R\n");
- PRINTVALSTREAM(rawoutstream, " Print difference if (|(a-b)/b| > R). R must be a positive number. Where a\n");
- PRINTVALSTREAM(rawoutstream, " is the data point value in file1 and b is the data point value in file2.\n");
- PRINTVALSTREAM(rawoutstream, " Can not use with '-d' or '--use-system-epsilon'.\n");
- PRINTVALSTREAM(rawoutstream, " --use-system-epsilon\n");
- PRINTVALSTREAM(rawoutstream, " Print difference if (|a-b| > EPSILON), EPSILON is system defined value. Where a\n");
- PRINTVALSTREAM(rawoutstream, " is the data point value in file1 and b is the data point value in file2.\n");
- PRINTVALSTREAM(rawoutstream, " If the system epsilon is not defined,one of the following predefined\n");
- PRINTVALSTREAM(rawoutstream, " values will be used:\n");
- PRINTVALSTREAM(rawoutstream, " FLT_EPSILON = 1.19209E-07 for floating-point type\n");
- PRINTVALSTREAM(rawoutstream, " DBL_EPSILON = 2.22045E-16 for double precision type\n");
- PRINTVALSTREAM(rawoutstream, " Can not use with '-p' or '-d'.\n");
- PRINTVALSTREAM(rawoutstream, " --exclude-path \"path\"\n");
- PRINTVALSTREAM(rawoutstream, " Exclude the specified path to an object when comparing files or groups.\n");
- PRINTVALSTREAM(rawoutstream, " If a group is excluded, all member objects will also be excluded.\n");
- PRINTVALSTREAM(rawoutstream, " The specified path is excluded wherever it occurs.\n");
- PRINTVALSTREAM(rawoutstream, " This flexibility enables the same option to exclude either objects that\n");
- PRINTVALSTREAM(rawoutstream, " exist only in one file or common objects that are known to differ.\n");
- PRINTVALSTREAM(rawoutstream, "\n");
- PRINTVALSTREAM(rawoutstream, " When comparing files, \"path\" is the absolute path to the excluded;\n");
- PRINTVALSTREAM(rawoutstream, " object; when comparing groups, \"path\" is similar to the relative\n");
- PRINTVALSTREAM(rawoutstream, " path from the group to the excluded object. This \"path\" can be\n");
- PRINTVALSTREAM(rawoutstream, " taken from the first section of the output of the --verbose option.\n");
- PRINTVALSTREAM(rawoutstream, " For example, if you are comparing the group /groupA in two files and\n");
- PRINTVALSTREAM(rawoutstream, " you want to exclude /groupA/groupB/groupC in both files, the exclude\n");
- PRINTVALSTREAM(rawoutstream, " option would read as follows:\n");
- PRINTVALSTREAM(rawoutstream, " --exclude-path \"/groupB/groupC\"\n");
- PRINTVALSTREAM(rawoutstream, "\n");
- PRINTVALSTREAM(rawoutstream, " If there are multiple paths to an object, only the specified path(s)\n");
- PRINTVALSTREAM(rawoutstream, " will be excluded; the comparison will include any path not explicitly\n");
- PRINTVALSTREAM(rawoutstream, " excluded.\n");
- PRINTVALSTREAM(rawoutstream, " This option can be used repeatedly to exclude multiple paths.\n");
- PRINTVALSTREAM(rawoutstream, "\n");
-
- PRINTVALSTREAM(rawoutstream, " Modes of output:\n");
- PRINTVALSTREAM(rawoutstream, " Default mode: print the number of differences found and where they occured\n");
- PRINTVALSTREAM(rawoutstream, " -r Report mode: print the above plus the differences\n");
- PRINTVALSTREAM(rawoutstream, " -v Verbose mode: print the above plus a list of objects and warnings\n");
- PRINTVALSTREAM(rawoutstream, " -q Quiet mode: do not print output\n");
-
- PRINTVALSTREAM(rawoutstream, "\n");
-
- PRINTVALSTREAM(rawoutstream, " File comparison:\n");
- PRINTVALSTREAM(rawoutstream, " If no objects [obj1[ obj2]] are specified, the h5diff comparison proceeds as\n");
- PRINTVALSTREAM(rawoutstream, " a comparison of the two files' root groups. That is, h5diff first compares\n");
- PRINTVALSTREAM(rawoutstream, " the names of root group members, generates a report of root group objects\n");
- PRINTVALSTREAM(rawoutstream, " that appear in only one file or in both files, and recursively compares\n");
- PRINTVALSTREAM(rawoutstream, " common objects.\n");
- PRINTVALSTREAM(rawoutstream, "\n");
-
- PRINTVALSTREAM(rawoutstream, " Object comparison:\n");
- PRINTVALSTREAM(rawoutstream, " 1) Groups\n");
- PRINTVALSTREAM(rawoutstream, " First compares the names of member objects (relative path, from the\n");
- PRINTVALSTREAM(rawoutstream, " specified group) and generates a report of objects that appear in only\n");
- PRINTVALSTREAM(rawoutstream, " one group or in both groups. Common objects are then compared recursively.\n");
- PRINTVALSTREAM(rawoutstream, " 2) Datasets\n");
- PRINTVALSTREAM(rawoutstream, " Array rank and dimensions, datatypes, and data values are compared.\n");
- PRINTVALSTREAM(rawoutstream, " 3) Datatypes\n");
- PRINTVALSTREAM(rawoutstream, " The comparison is based on the return value of H5Tequal.\n");
- PRINTVALSTREAM(rawoutstream, " 4) Symbolic links\n");
- PRINTVALSTREAM(rawoutstream, " The paths to the target objects are compared.\n");
- PRINTVALSTREAM(rawoutstream, " (The option --follow-symlinks overrides the default behavior when\n");
- PRINTVALSTREAM(rawoutstream, " symbolic links are compared.).\n");
- PRINTVALSTREAM(rawoutstream, "\n");
-
- PRINTVALSTREAM(rawoutstream, " Exit code:\n");
- PRINTVALSTREAM(rawoutstream, " 0 if no differences, 1 if differences found, 2 if error\n");
- PRINTVALSTREAM(rawoutstream, "\n");
- PRINTVALSTREAM(rawoutstream, " Examples of use:\n");
- PRINTVALSTREAM(rawoutstream, " 1) h5diff file1 file2 /g1/dset1 /g1/dset2\n");
- PRINTVALSTREAM(rawoutstream, " Compares object '/g1/dset1' in file1 with '/g1/dset2' in file2\n");
- PRINTVALSTREAM(rawoutstream, "\n");
- PRINTVALSTREAM(rawoutstream, " 2) h5diff file1 file2 /g1/dset1\n");
- PRINTVALSTREAM(rawoutstream, " Compares object '/g1/dset1' in both files\n");
- PRINTVALSTREAM(rawoutstream, "\n");
- PRINTVALSTREAM(rawoutstream, " 3) h5diff file1 file2\n");
- PRINTVALSTREAM(rawoutstream, " Compares all objects in both files\n");
- PRINTVALSTREAM(rawoutstream, "\n");
- PRINTVALSTREAM(rawoutstream, " Notes:\n");
- PRINTVALSTREAM(rawoutstream, " file1 and file2 can be the same file.\n");
- PRINTVALSTREAM(rawoutstream, " Use h5diff file1 file1 /g1/dset1 /g1/dset2 to compare\n");
- PRINTVALSTREAM(rawoutstream, " '/g1/dset1' and '/g1/dset2' in the same file\n");
- PRINTVALSTREAM(rawoutstream, "\n");
+ PRINTVALSTREAM(rawoutstream, "usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]]\n");
+ PRINTVALSTREAM(rawoutstream, " file1 File name of the first HDF5 file\n");
+ PRINTVALSTREAM(rawoutstream, " file2 File name of the second HDF5 file\n");
+ PRINTVALSTREAM(rawoutstream, " [obj1] Name of an HDF5 object, in absolute path\n");
+ PRINTVALSTREAM(rawoutstream, " [obj2] Name of an HDF5 object, in absolute path\n");
+ PRINTVALSTREAM(rawoutstream, "\n");
+ PRINTVALSTREAM(rawoutstream, " ERROR\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --enable-error-stack Prints messages from the HDF5 error stack as they occur.\n");
+ PRINTVALSTREAM(rawoutstream, " Optional value 2 also prints file open errors.\n");
+ PRINTVALSTREAM(rawoutstream, " OPTIONS\n");
+ PRINTVALSTREAM(rawoutstream, " -h, --help\n");
+ PRINTVALSTREAM(rawoutstream, " Print a usage message and exit.\n");
+ PRINTVALSTREAM(rawoutstream, " -V, --version\n");
+ PRINTVALSTREAM(rawoutstream, " Print version number and exit.\n");
+ PRINTVALSTREAM(rawoutstream, " -r, --report\n");
+ PRINTVALSTREAM(rawoutstream, " Report mode. Print differences.\n");
+ PRINTVALSTREAM(rawoutstream, " -v --verbose\n");
+ PRINTVALSTREAM(rawoutstream,
+ " Verbose mode. Print differences information and list of objects.\n");
+ PRINTVALSTREAM(rawoutstream, " -vN --verbose=N\n");
+ PRINTVALSTREAM(rawoutstream,
+ " Verbose mode with level. Print differences and list of objects.\n");
+ PRINTVALSTREAM(rawoutstream, " Level of detail depends on value of N:\n");
+ PRINTVALSTREAM(rawoutstream, " 0 : Identical to '-v' or '--verbose'.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " 1 : All level 0 information plus one-line attribute status summary.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " 2 : All level 1 information plus extended attribute status report.\n");
+ PRINTVALSTREAM(rawoutstream, " 3 : All level 2 information plus file names.\n");
+ PRINTVALSTREAM(rawoutstream, " -q, --quiet\n");
+ PRINTVALSTREAM(rawoutstream, " Quiet mode. Do not produce output.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --vol-value-1 Value (ID) of the VOL connector to use for opening the\n");
+ PRINTVALSTREAM(rawoutstream, " first HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --vol-name-1 Name of the VOL connector to use for opening the first\n");
+ PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --vol-info-1 VOL-specific info to pass to the VOL connector used for\n");
+ PRINTVALSTREAM(rawoutstream, " opening the first HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --vol-value-2 Value (ID) of the VOL connector to use for opening the\n");
+ PRINTVALSTREAM(rawoutstream, " second HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --vol-name-2 Name of the VOL connector to use for opening the second\n");
+ PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --vol-info-2 VOL-specific info to pass to the VOL connector used for\n");
+ PRINTVALSTREAM(rawoutstream, " opening the second HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --vfd-value-1 Value (ID) of the VFL driver to use for opening the\n");
+ PRINTVALSTREAM(rawoutstream, " first HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --vfd-name-1 Name of the VFL driver to use for opening the first\n");
+ PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --vfd-info-1 VFD-specific info to pass to the VFL driver used for\n");
+ PRINTVALSTREAM(rawoutstream, " opening the first HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --vfd-value-2 Value (ID) of the VFL driver to use for opening the\n");
+ PRINTVALSTREAM(rawoutstream, " second HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --vfd-name-2 Name of the VFL driver to use for opening the second\n");
+ PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --vfd-info-2 VFD-specific info to pass to the VFL driver used for\n");
+ PRINTVALSTREAM(rawoutstream, " opening the second HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream, " --follow-symlinks\n");
+ PRINTVALSTREAM(rawoutstream,
+ " Follow symbolic links (soft links and external links and compare the)\n");
+ PRINTVALSTREAM(rawoutstream, " links' target objects.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " If symbolic link(s) with the same name exist in the files being\n");
+ PRINTVALSTREAM(rawoutstream,
+ " compared, then determine whether the target of each link is an existing\n");
+ PRINTVALSTREAM(rawoutstream,
+ " object (dataset, group, or named datatype) or the link is a dangling\n");
+ PRINTVALSTREAM(rawoutstream,
+ " link (a soft or external link pointing to a target object that does\n");
+ PRINTVALSTREAM(rawoutstream, " not yet exist).\n");
+ PRINTVALSTREAM(rawoutstream,
+ " - If both symbolic links are dangling links, they are treated as being\n");
+ PRINTVALSTREAM(rawoutstream, " the same; by default, h5diff returns an exit code of 0.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " If, however, --no-dangling-links is used with --follow-symlinks,\n");
+ PRINTVALSTREAM(rawoutstream, " this situation is treated as an error and h5diff returns an\n");
+ PRINTVALSTREAM(rawoutstream, " exit code of 2.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " - If only one of the two links is a dangling link,they are treated as\n");
+ PRINTVALSTREAM(rawoutstream, " being different and h5diff returns an exit code of 1.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " If, however, --no-dangling-links is used with --follow-symlinks,\n");
+ PRINTVALSTREAM(rawoutstream, " this situation is treated as an error and h5diff returns an\n");
+ PRINTVALSTREAM(rawoutstream, " exit code of 2.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " - If both symbolic links point to existing objects, h5diff compares the\n");
+ PRINTVALSTREAM(rawoutstream, " two objects.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " If any symbolic link specified in the call to h5diff does not exist,\n");
+ PRINTVALSTREAM(rawoutstream, " h5diff treats it as an error and returns an exit code of 2.\n");
+ PRINTVALSTREAM(rawoutstream, " --no-dangling-links\n");
+ PRINTVALSTREAM(rawoutstream,
+ " Must be used with --follow-symlinks option; otherwise, h5diff shows\n");
+ PRINTVALSTREAM(rawoutstream, " error message and returns an exit code of 2.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " Check for any symbolic links (soft links or external links) that do not\n");
+ PRINTVALSTREAM(rawoutstream,
+ " resolve to an existing object (dataset, group, or named datatype).\n");
+ PRINTVALSTREAM(rawoutstream,
+ " If any dangling link is found, this situation is treated as an error\n");
+ PRINTVALSTREAM(rawoutstream, " and h5diff returns an exit code of 2.\n");
+ PRINTVALSTREAM(rawoutstream, " -c, --compare\n");
+ PRINTVALSTREAM(rawoutstream, " List objects that are not comparable\n");
+ PRINTVALSTREAM(rawoutstream, " -N, --nan\n");
+ PRINTVALSTREAM(rawoutstream, " Avoid NaNs detection\n");
+ PRINTVALSTREAM(rawoutstream, " -n C, --count=C\n");
+ PRINTVALSTREAM(rawoutstream, " Print differences up to C. C must be a positive integer.\n");
+ PRINTVALSTREAM(rawoutstream, " -d D, --delta=D\n");
+ PRINTVALSTREAM(rawoutstream,
+ " Print difference if (|a-b| > D). D must be a positive number. Where a\n");
+ PRINTVALSTREAM(rawoutstream,
+ " is the data point value in file1 and b is the data point value in file2.\n");
+ PRINTVALSTREAM(rawoutstream, " Can not use with '-p' or '--use-system-epsilon'.\n");
+ PRINTVALSTREAM(rawoutstream, " -p R, --relative=R\n");
+ PRINTVALSTREAM(rawoutstream,
+ " Print difference if (|(a-b)/b| > R). R must be a positive number. Where a\n");
+ PRINTVALSTREAM(rawoutstream,
+ " is the data point value in file1 and b is the data point value in file2.\n");
+ PRINTVALSTREAM(rawoutstream, " Can not use with '-d' or '--use-system-epsilon'.\n");
+ PRINTVALSTREAM(rawoutstream, " --use-system-epsilon\n");
+ PRINTVALSTREAM(
+ rawoutstream,
+ " Print difference if (|a-b| > EPSILON), EPSILON is system defined value. Where a\n");
+ PRINTVALSTREAM(rawoutstream,
+ " is the data point value in file1 and b is the data point value in file2.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " If the system epsilon is not defined,one of the following predefined\n");
+ PRINTVALSTREAM(rawoutstream, " values will be used:\n");
+ PRINTVALSTREAM(rawoutstream, " FLT_EPSILON = 1.19209E-07 for floating-point type\n");
+ PRINTVALSTREAM(rawoutstream, " DBL_EPSILON = 2.22045E-16 for double precision type\n");
+ PRINTVALSTREAM(rawoutstream, " Can not use with '-p' or '-d'.\n");
+ PRINTVALSTREAM(rawoutstream, " --exclude-path \"path\"\n");
+ PRINTVALSTREAM(rawoutstream,
+ " Exclude the specified path to an object when comparing files or groups.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " If a group is excluded, all member objects will also be excluded.\n");
+ PRINTVALSTREAM(rawoutstream, " The specified path is excluded wherever it occurs.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " This flexibility enables the same option to exclude either objects that\n");
+ PRINTVALSTREAM(rawoutstream,
+ " exist only in one file or common objects that are known to differ.\n");
+ PRINTVALSTREAM(rawoutstream, "\n");
+ PRINTVALSTREAM(rawoutstream,
+ " When comparing files, \"path\" is the absolute path to the excluded;\n");
+ PRINTVALSTREAM(rawoutstream,
+ " object; when comparing groups, \"path\" is similar to the relative\n");
+ PRINTVALSTREAM(rawoutstream,
+ " path from the group to the excluded object. This \"path\" can be\n");
+ PRINTVALSTREAM(rawoutstream,
+ " taken from the first section of the output of the --verbose option.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " For example, if you are comparing the group /groupA in two files and\n");
+ PRINTVALSTREAM(rawoutstream,
+ " you want to exclude /groupA/groupB/groupC in both files, the exclude\n");
+ PRINTVALSTREAM(rawoutstream, " option would read as follows:\n");
+ PRINTVALSTREAM(rawoutstream, " --exclude-path \"/groupB/groupC\"\n");
+ PRINTVALSTREAM(rawoutstream, "\n");
+ PRINTVALSTREAM(rawoutstream,
+ " If there are multiple paths to an object, only the specified path(s)\n");
+ PRINTVALSTREAM(rawoutstream,
+ " will be excluded; the comparison will include any path not explicitly\n");
+ PRINTVALSTREAM(rawoutstream, " excluded.\n");
+ PRINTVALSTREAM(rawoutstream, " This option can be used repeatedly to exclude multiple paths.\n");
+ PRINTVALSTREAM(rawoutstream, "\n");
+ PRINTVALSTREAM(rawoutstream, " --exclude-attribute \"path/to/object/with/attribute\"\n");
+ PRINTVALSTREAM(
+ rawoutstream,
+ " Exclude attributes on the specified path to an object when comparing files or groups.\n");
+ PRINTVALSTREAM(rawoutstream, "\n");
+ PRINTVALSTREAM(rawoutstream,
+ " If there are multiple paths to an object, only the specified path(s)\n");
+ PRINTVALSTREAM(rawoutstream,
+ " will be excluded; the comparison will include any path not explicitly\n");
+ PRINTVALSTREAM(rawoutstream, " excluded.\n");
+ PRINTVALSTREAM(rawoutstream, " This option can be used repeatedly to exclude multiple paths.\n");
+ PRINTVALSTREAM(rawoutstream, "\n");
+ PRINTVALSTREAM(rawoutstream, " Modes of output:\n");
+ PRINTVALSTREAM(rawoutstream,
+ " Default mode: print the number of differences found and where they occurred\n");
+ PRINTVALSTREAM(rawoutstream, " -r Report mode: print the above plus the differences\n");
+ PRINTVALSTREAM(rawoutstream, " -v Verbose mode: print the above plus a list of objects and warnings\n");
+ PRINTVALSTREAM(rawoutstream, " -q Quiet mode: do not print output\n");
+
+ PRINTVALSTREAM(rawoutstream, "\n");
+
+ PRINTVALSTREAM(rawoutstream, " File comparison:\n");
+ PRINTVALSTREAM(rawoutstream,
+ " If no objects [obj1[ obj2]] are specified, the h5diff comparison proceeds as\n");
+ PRINTVALSTREAM(rawoutstream,
+ " a comparison of the two files' root groups. That is, h5diff first compares\n");
+ PRINTVALSTREAM(rawoutstream,
+ " the names of root group members, generates a report of root group objects\n");
+ PRINTVALSTREAM(rawoutstream,
+ " that appear in only one file or in both files, and recursively compares\n");
+ PRINTVALSTREAM(rawoutstream, " common objects.\n");
+ PRINTVALSTREAM(rawoutstream, "\n");
+
+ PRINTVALSTREAM(rawoutstream, " Object comparison:\n");
+ PRINTVALSTREAM(rawoutstream, " 1) Groups\n");
+ PRINTVALSTREAM(rawoutstream,
+ " First compares the names of member objects (relative path, from the\n");
+ PRINTVALSTREAM(rawoutstream,
+ " specified group) and generates a report of objects that appear in only\n");
+ PRINTVALSTREAM(rawoutstream,
+ " one group or in both groups. Common objects are then compared recursively.\n");
+ PRINTVALSTREAM(rawoutstream, " 2) Datasets\n");
+ PRINTVALSTREAM(rawoutstream,
+ " Array rank and dimensions, datatypes, and data values are compared.\n");
+ PRINTVALSTREAM(rawoutstream, " 3) Datatypes\n");
+ PRINTVALSTREAM(rawoutstream, " The comparison is based on the return value of H5Tequal.\n");
+ PRINTVALSTREAM(rawoutstream, " 4) Symbolic links\n");
+ PRINTVALSTREAM(rawoutstream, " The paths to the target objects are compared.\n");
+ PRINTVALSTREAM(rawoutstream, " (The option --follow-symlinks overrides the default behavior when\n");
+ PRINTVALSTREAM(rawoutstream, " symbolic links are compared.).\n");
+ PRINTVALSTREAM(rawoutstream, "\n");
+ /*
+ * TRILABS_227 is complete except for an issue with printing indices
+ * the following will be needed for subsetting
+ */
+ PRINTVALSTREAM(rawoutstream, " Subsetting options:\n");
+ PRINTVALSTREAM(rawoutstream,
+ " Subsetting is available by using the fcompact form of subsetting, as follows:\n");
+ PRINTVALSTREAM(rawoutstream, " obj1 /foo/mydataset[START;STRIDE;COUNT;BLOCK]\n");
+ PRINTVALSTREAM(rawoutstream,
+ " It is not required to use all parameters, but until the last parameter value used,\n");
+ PRINTVALSTREAM(
+ rawoutstream,
+ " all of the semicolons (;) are required, even when a parameter value is not specified. Example:\n");
+ PRINTVALSTREAM(rawoutstream, " obj1 /foo/mydataset[START;;COUNT;BLOCK]\n");
+ PRINTVALSTREAM(rawoutstream, " obj1 /foo/mydataset[START]\n");
+ PRINTVALSTREAM(rawoutstream,
+ " The STRIDE, COUNT, and BLOCK parameters are optional and will default to 1 in\n");
+ PRINTVALSTREAM(rawoutstream,
+ " each dimension. START is optional and will default to 0 in each dimension.\n");
+ PRINTVALSTREAM(
+ rawoutstream,
+ " Each of START, STRIDE, COUNT, and BLOCK must be a comma-separated list of integers with\n");
+ PRINTVALSTREAM(rawoutstream, " one integer for each dimension of the dataset.\n");
+ PRINTVALSTREAM(rawoutstream, "\n");
+ PRINTVALSTREAM(rawoutstream, " Exit code:\n");
+ PRINTVALSTREAM(rawoutstream, " 0 if no differences, 1 if differences found, 2 if error\n");
+ PRINTVALSTREAM(rawoutstream, "\n");
+ PRINTVALSTREAM(rawoutstream, " Examples of use:\n");
+ PRINTVALSTREAM(rawoutstream, " 1) h5diff file1 file2 /g1/dset1 /g1/dset2\n");
+ PRINTVALSTREAM(rawoutstream, " Compares object '/g1/dset1' in file1 with '/g1/dset2' in file2\n");
+ PRINTVALSTREAM(rawoutstream, "\n");
+ PRINTVALSTREAM(rawoutstream, " 2) h5diff file1 file2 /g1/dset1\n");
+ PRINTVALSTREAM(rawoutstream, " Compares object '/g1/dset1' in both files\n");
+ PRINTVALSTREAM(rawoutstream, "\n");
+ PRINTVALSTREAM(rawoutstream, " 3) h5diff file1 file2\n");
+ PRINTVALSTREAM(rawoutstream, " Compares all objects in both files\n");
+ PRINTVALSTREAM(rawoutstream, "\n");
+ PRINTVALSTREAM(rawoutstream, " Notes:\n");
+ PRINTVALSTREAM(rawoutstream, " file1 and file2 can be the same file.\n");
+ PRINTVALSTREAM(rawoutstream, " Use h5diff file1 file1 /g1/dset1 /g1/dset2 to compare\n");
+ PRINTVALSTREAM(rawoutstream, " '/g1/dset1' and '/g1/dset2' in the same file\n");
+ PRINTVALSTREAM(rawoutstream, "\n");
}
diff --git a/tools/src/h5diff/h5diff_common.h b/tools/src/h5diff/h5diff_common.h
index dc0676c..35e5dfb 100644
--- a/tools/src/h5diff/h5diff_common.h
+++ b/tools/src/h5diff/h5diff_common.h
@@ -6,13 +6,13 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#ifndef H5DIFFCOMMON_H__
-#define H5DIFFCOMMON_H__
+#ifndef H5DIFFCOMMON_H
+#define H5DIFFCOMMON_H
#include "h5tools.h"
/* Name of tool */
@@ -23,12 +23,13 @@ extern "C" {
#endif
void usage(void);
-void parse_command_line(int argc, const char* argv[], const char** fname1, const char** fname2, const char** objname1, const char** objname2, diff_opt_t* opts);
+void parse_command_line(int argc, const char *const *argv, const char **fname1, const char **fname2,
+ const char **objname1, const char **objname2, diff_opt_t *opts);
void h5diff_exit(int status);
-void print_info(diff_opt_t* opts);
+void print_info(diff_opt_t *opts);
#ifdef __cplusplus
}
#endif
-#endif /* H5DIFFCOMMON_H__ */
+#endif /* H5DIFFCOMMON_H */
diff --git a/tools/src/h5diff/h5diff_main.c b/tools/src/h5diff/h5diff_main.c
index c5a0cbf..2a43b56 100644
--- a/tools/src/h5diff/h5diff_main.c
+++ b/tools/src/h5diff/h5diff_main.c
@@ -6,7 +6,7 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -17,7 +17,6 @@
#include "h5tools.h"
#include "h5tools_utils.h"
-
/*-------------------------------------------------------------------------
* Function: main
*
@@ -26,7 +25,7 @@
* Return: An exit status of 0 means no differences were found, 1 means some
* differences were found.
*
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ * Programmer: Pedro Vicente
*
* Date: May 9, 2003
*
@@ -34,7 +33,7 @@
*
* Modifications: July 2004
* Introduced the four modes:
- * Normal mode: print the number of differences found and where they occured
+ * Normal mode: print the number of differences found and where they occurred
* Report mode: print the above plus the differences
* Verbose mode: print the above plus a list of objects and warnings
* Quiet mode: do not print output
@@ -65,60 +64,47 @@
*-------------------------------------------------------------------------
*/
-
-int main(int argc, const char *argv[])
+int
+main(int argc, char *argv[])
{
- int ret;
- H5E_auto2_t func;
- H5E_auto2_t tools_func;
- void *edata;
- void *tools_edata;
- const char *fname1 = NULL;
- const char *fname2 = NULL;
- const char *objname1 = NULL;
- const char *objname2 = NULL;
- hsize_t nfound=0;
- diff_opt_t opts;
+ int ret;
+ int i;
+ const char *fname1 = NULL;
+ const char *fname2 = NULL;
+ const char *objname1 = NULL;
+ const char *objname2 = NULL;
+ hsize_t nfound = 0;
+ diff_opt_t opts;
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);
-
/*-------------------------------------------------------------------------
- * process the command-line
- *-------------------------------------------------------------------------
- */
- parse_command_line(argc, argv, &fname1, &fname2, &objname1, &objname2, &opts);
-
- if (enable_error_stack > 0) {
- H5Eset_auto2(H5E_DEFAULT, func, edata);
- H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata);
- }
+ * process the command-line
+ *-------------------------------------------------------------------------
+ */
+ parse_command_line(argc, (const char *const *)argv, &fname1, &fname2, &objname1, &objname2, &opts);
+
+ /* enable error reporting if command line option */
+ h5tools_error_report();
/*-------------------------------------------------------------------------
- * do the diff
- *-------------------------------------------------------------------------
- */
+ * do the diff
+ *-------------------------------------------------------------------------
+ */
nfound = h5diff(fname1, fname2, objname1, objname2, &opts);
print_info(&opts);
- /*-------------------------------------------------------------------------
- * exit code
- * 1 if differences, 0 if no differences, 2 if error
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * exit code
+ * 1 if differences, 0 if no differences, 2 if error
+ *-------------------------------------------------------------------------
+ */
ret = (nfound == 0 ? 0 : 1);
@@ -130,6 +116,23 @@ int main(int argc, const char *argv[])
if (opts.err_stat)
ret = 2;
+ /* free any buffers */
+ for (i = 0; i < 2; i++) {
+ if (opts.sset[i]) {
+ if (opts.sset[i]->start.data)
+ HDfree(opts.sset[i]->start.data);
+ if (opts.sset[i]->stride.data)
+ HDfree(opts.sset[i]->stride.data);
+ if (opts.sset[i]->count.data)
+ HDfree(opts.sset[i]->count.data);
+ if (opts.sset[i]->block.data)
+ HDfree(opts.sset[i]->block.data);
+
+ HDfree(opts.sset[i]);
+ opts.sset[i] = NULL;
+ }
+ }
+
h5diff_exit(ret);
}
@@ -156,4 +159,3 @@ h5diff_exit(int status)
HDexit(status);
}
-
diff --git a/tools/src/h5diff/ph5diff_main.c b/tools/src/h5diff/ph5diff_main.c
index 380ab3b..8e5c3e8 100644
--- a/tools/src/h5diff/ph5diff_main.c
+++ b/tools/src/h5diff/ph5diff_main.c
@@ -6,7 +6,7 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -21,7 +21,7 @@
/* Name of tool */
#define PROGRAMNAME "h5diff"
-static void ph5diff_worker(int );
+static void ph5diff_worker(int);
/*-------------------------------------------------------------------------
* Function: main
@@ -31,7 +31,7 @@ static void ph5diff_worker(int );
* Return: An exit status of 0 means no differences were found, 1 means some
* differences were found.
*
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ * Programmer: Pedro Vicente
*
* Date: May 9, 2003
*
@@ -43,14 +43,15 @@ static void ph5diff_worker(int );
*-------------------------------------------------------------------------
*/
-int main(int argc, const char *argv[])
+int
+main(int argc, char *argv[])
{
- int nID = 0;
- const char *fname1 = NULL;
- const char *fname2 = NULL;
- const char *objname1 = NULL;
- const char *objname2 = NULL;
- diff_opt_t opts;
+ int nID = 0;
+ const char *fname1 = NULL;
+ const char *fname2 = NULL;
+ const char *objname1 = NULL;
+ const char *objname2 = NULL;
+ diff_opt_t opts;
h5tools_setprogname(PROGRAMNAME);
h5tools_setstatus(EXIT_SUCCESS);
@@ -59,20 +60,19 @@ int main(int argc, const char *argv[])
h5tools_init();
outBuffOffset = 0;
- g_Parallel = 1;
+ g_Parallel = 1;
- MPI_Init(&argc, (char***) &argv);
+ MPI_Init(&argc, (char ***)&argv);
MPI_Comm_rank(MPI_COMM_WORLD, &nID);
MPI_Comm_size(MPI_COMM_WORLD, &g_nTasks);
- if(g_nTasks == 1)
- {
+ if (g_nTasks == 1) {
HDprintf("Only 1 task available...doing serial diff\n");
g_Parallel = 0;
- parse_command_line(argc, argv, &fname1, &fname2, &objname1, &objname2, &opts);
+ parse_command_line(argc, (const char *const *)argv, &fname1, &fname2, &objname1, &objname2, &opts);
h5diff(fname1, fname2, objname1, objname2, &opts);
@@ -82,9 +82,9 @@ int main(int argc, const char *argv[])
else {
/* Have the manager process the command-line */
- if(nID == 0)
- {
- parse_command_line(argc, argv, &fname1, &fname2, &objname1, &objname2, &opts);
+ if (nID == 0) {
+ parse_command_line(argc, (const char *const *)argv, &fname1, &fname2, &objname1, &objname2,
+ &opts);
h5diff(fname1, fname2, objname1, objname2, &opts);
@@ -126,33 +126,30 @@ int main(int argc, const char *argv[])
static void
ph5diff_worker(int nID)
{
- hid_t file1_id = -1, file2_id = -1;
+ hid_t file1_id = H5I_INVALID_HID;
+ hid_t file2_id = H5I_INVALID_HID;
- while(1)
- {
+ while (1) {
MPI_Status Status;
MPI_Probe(0, MPI_ANY_TAG, MPI_COMM_WORLD, &Status);
/* Check for filenames */
- if(Status.MPI_TAG == MPI_TAG_PARALLEL)
- {
- char filenames[2][MAX_FILENAME];
+ if (Status.MPI_TAG == MPI_TAG_PARALLEL) {
+ char filenames[2][MAX_FILENAME];
/* Retrieve filenames */
- MPI_Recv(filenames, MAX_FILENAME*2, MPI_CHAR, 0, MPI_ANY_TAG, MPI_COMM_WORLD, &Status);
+ MPI_Recv(filenames, MAX_FILENAME * 2, MPI_CHAR, 0, MPI_ANY_TAG, MPI_COMM_WORLD, &Status);
/* disable error reporting */
H5E_BEGIN_TRY
{
/* Open the files */
- if ((file1_id = H5Fopen (filenames[0], H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
- {
+ if ((file1_id = H5Fopen(filenames[0], H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) {
HDprintf("h5diff Task [%d]: <%s>: unable to open file\n", nID, filenames[0]);
MPI_Abort(MPI_COMM_WORLD, 0);
}
- if ((file2_id = H5Fopen (filenames[1], H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
- {
+ if ((file2_id = H5Fopen(filenames[1], H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) {
HDprintf("h5diff Task [%d]: <%s>: unable to open file\n", nID, filenames[1]);
MPI_Abort(MPI_COMM_WORLD, 0);
}
@@ -161,15 +158,13 @@ ph5diff_worker(int nID)
H5E_END_TRY;
}
/* Check for work */
- else if(Status.MPI_TAG == MPI_TAG_ARGS)
- {
+ else if (Status.MPI_TAG == MPI_TAG_ARGS) {
struct diff_mpi_args args;
- struct diffs_found diffs;
- int i;
+ struct diffs_found diffs;
+ unsigned i;
/* Make certain we've received the filenames and opened the files already */
- if(file1_id < 0 || file2_id < 0)
- {
+ if (file1_id < 0 || file2_id < 0) {
HDprintf("ph5diff_worker: ERROR: work received before/without filenames\n");
break;
}
@@ -178,44 +173,43 @@ ph5diff_worker(int nID)
MPI_Recv(&args, sizeof(args), MPI_BYTE, 0, MPI_TAG_ARGS, MPI_COMM_WORLD, &Status);
/* Do the diff */
- diffs.nfound = diff(file1_id, args.name1, file2_id, args.name2, &(args.opts), &(args.argdata));
+ diffs.nfound = diff(file1_id, args.name1, file2_id, args.name2, &(args.opts), &(args.argdata));
diffs.not_cmp = args.opts.not_cmp;
/* If print buffer has something in it, request print token.*/
- if(outBuffOffset>0)
- {
+ if (outBuffOffset > 0) {
MPI_Send(NULL, 0, MPI_BYTE, 0, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD);
/* Wait for print token. */
MPI_Recv(NULL, 0, MPI_BYTE, 0, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD, &Status);
/* When get token, send all of our output to the manager task and then return the token */
- for(i=0; i<outBuffOffset; i+=PRINT_DATA_MAX_SIZE)
- MPI_Send(outBuff+i, PRINT_DATA_MAX_SIZE, MPI_BYTE, 0, MPI_TAG_PRINT_DATA, MPI_COMM_WORLD);
+ for (i = 0; i < outBuffOffset; i += PRINT_DATA_MAX_SIZE)
+ MPI_Send(outBuff + i, PRINT_DATA_MAX_SIZE, MPI_BYTE, 0, MPI_TAG_PRINT_DATA,
+ MPI_COMM_WORLD);
/* An overflow file exists, so we send it's output to the manager too and then delete it */
- if(overflow_file)
- {
+ if (overflow_file) {
char out_data[PRINT_DATA_MAX_SIZE];
- int tmp;
+ int tmp;
HDmemset(out_data, 0, PRINT_DATA_MAX_SIZE);
- i=0;
+ i = 0;
rewind(overflow_file);
- while((tmp = getc(overflow_file)) >= 0)
- {
+ while ((tmp = getc(overflow_file)) >= 0) {
*(out_data + i++) = (char)tmp;
- if(i==PRINT_DATA_MAX_SIZE)
- {
- MPI_Send(out_data, PRINT_DATA_MAX_SIZE, MPI_BYTE, 0, MPI_TAG_PRINT_DATA, MPI_COMM_WORLD);
- i=0;
+ if (i == PRINT_DATA_MAX_SIZE) {
+ MPI_Send(out_data, PRINT_DATA_MAX_SIZE, MPI_BYTE, 0, MPI_TAG_PRINT_DATA,
+ MPI_COMM_WORLD);
+ i = 0;
HDmemset(out_data, 0, PRINT_DATA_MAX_SIZE);
}
}
- if(i>0)
- MPI_Send(out_data, PRINT_DATA_MAX_SIZE, MPI_BYTE, 0, MPI_TAG_PRINT_DATA, MPI_COMM_WORLD);
+ if (i > 0)
+ MPI_Send(out_data, PRINT_DATA_MAX_SIZE, MPI_BYTE, 0, MPI_TAG_PRINT_DATA,
+ MPI_COMM_WORLD);
fclose(overflow_file);
overflow_file = NULL;
@@ -231,17 +225,14 @@ ph5diff_worker(int nID)
MPI_Send(&diffs, sizeof(diffs), MPI_BYTE, 0, MPI_TAG_DONE, MPI_COMM_WORLD);
}
/* Check for leaving */
- else if(Status.MPI_TAG == MPI_TAG_END)
- {
+ else if (Status.MPI_TAG == MPI_TAG_END) {
MPI_Recv(NULL, 0, MPI_BYTE, 0, MPI_TAG_END, MPI_COMM_WORLD, &Status);
break;
}
- else
- {
+ else {
HDprintf("ph5diff_worker: ERROR: invalid tag (%d) received\n", Status.MPI_TAG);
break;
}
-
}
return;
@@ -261,18 +252,17 @@ ph5diff_worker(int nID)
*
*-------------------------------------------------------------------------
*/
-void print_manager_output(void)
+void
+print_manager_output(void)
{
/* If there was something we buffered, let's print it now */
- if( (outBuffOffset>0) && g_Parallel)
- {
+ if ((outBuffOffset > 0) && g_Parallel) {
HDprintf("%s", outBuff);
- if(overflow_file)
- {
- int tmp;
+ if (overflow_file) {
+ int tmp;
rewind(overflow_file);
- while((tmp = HDgetc(overflow_file)) >= 0)
+ while ((tmp = HDgetc(overflow_file)) >= 0)
HDputchar(tmp);
fclose(overflow_file);
overflow_file = NULL;
@@ -282,8 +272,7 @@ void print_manager_output(void)
HDmemset(outBuff, 0, OUTBUFF_SIZE);
outBuffOffset = 0;
}
- else if( (outBuffOffset>0) && !g_Parallel)
- {
+ else if ((outBuffOffset > 0) && !g_Parallel) {
HDfprintf(stderr, "h5diff error: outBuffOffset>0, but we're not in parallel!\n");
}
}
@@ -304,16 +293,18 @@ void print_manager_output(void)
*
*-------------------------------------------------------------------------
*/
-void h5diff_exit(int status)
+void
+h5diff_exit(int status)
{
/* if in parallel mode, dismiss workers, close down MPI, then exit */
- if(g_Parallel) {
- if(g_nTasks > 1) {
+ if (g_Parallel) {
+ if (g_nTasks > 1) {
phdiff_dismiss_workers();
MPI_Barrier(MPI_COMM_WORLD);
}
MPI_Finalize();
- status = EXIT_SUCCESS; /* Reset exit status, since some mpiexec commands generate output on failure status */
+ status = EXIT_SUCCESS; /* Reset exit status, since some mpiexec commands generate output on failure
+ status */
}
h5tools_close();
@@ -323,4 +314,3 @@ void h5diff_exit(int status)
*/
HDexit(0);
}
-
diff --git a/tools/src/h5dump/CMakeLists.txt b/tools/src/h5dump/CMakeLists.txt
index 383b04e..8a12434 100644
--- a/tools/src/h5dump/CMakeLists.txt
+++ b/tools/src/h5dump/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.10)
+cmake_minimum_required (VERSION 3.12)
project (HDF5_TOOLS_SRC_H5DUMP C)
# --------------------------------------------------------------------
@@ -9,8 +9,14 @@ if (NOT ONLY_SHARED_LIBS)
${HDF5_TOOLS_SRC_H5DUMP_SOURCE_DIR}/h5dump.c
${HDF5_TOOLS_SRC_H5DUMP_SOURCE_DIR}/h5dump_ddl.c
${HDF5_TOOLS_SRC_H5DUMP_SOURCE_DIR}/h5dump_xml.c
+ ${HDF5_TOOLS_SRC_H5DUMP_SOURCE_DIR}/h5dump.h
+ ${HDF5_TOOLS_SRC_H5DUMP_SOURCE_DIR}/h5dump_defines.h
+ ${HDF5_TOOLS_SRC_H5DUMP_SOURCE_DIR}/h5dump_extern.h
+ ${HDF5_TOOLS_SRC_H5DUMP_SOURCE_DIR}/h5dump_ddl.h
+ ${HDF5_TOOLS_SRC_H5DUMP_SOURCE_DIR}/h5dump_xml.h
)
- target_include_directories (h5dump PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_include_directories (h5dump PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5dump PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5dump STATIC)
target_link_libraries (h5dump PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
set_target_properties (h5dump PROPERTIES FOLDER tools)
@@ -24,8 +30,14 @@ if (BUILD_SHARED_LIBS)
${HDF5_TOOLS_SRC_H5DUMP_SOURCE_DIR}/h5dump.c
${HDF5_TOOLS_SRC_H5DUMP_SOURCE_DIR}/h5dump_ddl.c
${HDF5_TOOLS_SRC_H5DUMP_SOURCE_DIR}/h5dump_xml.c
+ ${HDF5_TOOLS_SRC_H5DUMP_SOURCE_DIR}/h5dump.h
+ ${HDF5_TOOLS_SRC_H5DUMP_SOURCE_DIR}/h5dump_defines.h
+ ${HDF5_TOOLS_SRC_H5DUMP_SOURCE_DIR}/h5dump_extern.h
+ ${HDF5_TOOLS_SRC_H5DUMP_SOURCE_DIR}/h5dump_ddl.h
+ ${HDF5_TOOLS_SRC_H5DUMP_SOURCE_DIR}/h5dump_xml.h
)
- target_include_directories (h5dump-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_include_directories (h5dump-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5dump-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5dump-shared SHARED)
target_link_libraries (h5dump-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
set_target_properties (h5dump-shared PROPERTIES FOLDER tools)
@@ -34,6 +46,17 @@ if (BUILD_SHARED_LIBS)
set (H5_DEP_EXECUTABLES ${H5_DEP_EXECUTABLES} h5dump-shared)
endif ()
+#-----------------------------------------------------------------------------
+# Add Target to clang-format
+#-----------------------------------------------------------------------------
+if (HDF5_ENABLE_FORMATTERS)
+ if (NOT ONLY_SHARED_LIBS)
+ clang_format (HDF5_H5DUMP_SRC_FORMAT h5dump)
+ else ()
+ clang_format (HDF5_H5DUMP_SRC_FORMAT h5dump-shared)
+ endif ()
+endif ()
+
##############################################################################
##############################################################################
### I N S T A L L A T I O N ###
diff --git a/tools/src/h5dump/Makefile.am b/tools/src/h5dump/Makefile.am
index 86109d5..faf9ec6 100644
--- a/tools/src/h5dump/Makefile.am
+++ b/tools/src/h5dump/Makefile.am
@@ -6,7 +6,7 @@
# This file is part of HDF5. The full HDF5 copyright notice, including
# terms governing use, modification, and redistribution, is contained in
# the COPYING file, which can be found at the root of the source code
-# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.
+# distribution tree, or in https://www.hdfgroup.org/licenses.
# If you do not have access to either file, you may request a copy from
# help@hdfgroup.org.
##
diff --git a/tools/src/h5dump/h5dump.c b/tools/src/h5dump/h5dump.c
index b1e736a..d82ea94 100644
--- a/tools/src/h5dump/h5dump.c
+++ b/tools/src/h5dump/h5dump.c
@@ -6,7 +6,7 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -18,66 +18,59 @@
/* Name of tool */
#define PROGRAMNAME "h5dump"
-static const char *driver = NULL; /* The driver to open the file with. */
-const char *outfname=NULL;
-static int doxml = 0;
-static int useschema = 1;
-static const char *xml_dtd_uri = NULL;
+const char * outfname_g = NULL;
+static hbool_t doxml_g = FALSE;
+static hbool_t useschema_g = TRUE;
+static const char *xml_dtd_uri_g = NULL;
+
+static hbool_t use_custom_vol_g = FALSE;
+static hbool_t use_custom_vfd_g = FALSE;
+static h5tools_vol_info_t vol_info_g;
+static h5tools_vfd_info_t vfd_info_g;
#ifdef H5_HAVE_ROS3_VFD
-static H5FD_ros3_fapl_t ros3_fa = {
- 1, /* version */
- false, /* authenticate */
- "", /* aws region */
- "", /* access key id */
- "", /* secret access key */
+/* Default "anonymous" S3 configuration */
+static H5FD_ros3_fapl_t ros3_fa_g = {
+ 1, /* Structure Version */
+ FALSE, /* Authenticate? */
+ "", /* AWS Region */
+ "", /* Access Key ID */
+ "", /* Secret Access Key */
};
#endif /* H5_HAVE_ROS3_VFD */
#ifdef H5_HAVE_LIBHDFS
-static H5FD_hdfs_fapl_t hdfs_fa = {
- 1, /* fapl version */
- "localhost", /* namenode name */
- 0, /* namenode port */
- "", /* kerberos ticket cache */
- "", /* user name */
- 2048, /* stream buffer size */
+/* "Default" HDFS configuration */
+static H5FD_hdfs_fapl_t hdfs_fa_g = {
+ 1, /* Structure Version */
+ "localhost", /* Namenode Name */
+ 0, /* Namenode Port */
+ "", /* Kerberos ticket cache */
+ "", /* User name */
+ 2048, /* Stream buffer size */
};
#endif /* H5_HAVE_LIBHDFS */
/* module-scoped variables for XML option */
-#define DEFAULT_XSD "http://www.hdfgroup.org/HDF5/XML/schema/HDF5-File.xsd"
-#define DEFAULT_DTD "http://www.hdfgroup.org/HDF5/XML/DTD/HDF5-File.dtd"
+#define DEFAULT_XSD "http://www.hdfgroup.org/HDF5/XML/schema/HDF5-File.xsd"
+#define DEFAULT_DTD "http://www.hdfgroup.org/HDF5/XML/DTD/HDF5-File.dtd"
/* Standard DDL output */
static const dump_functions ddl_function_table = {
- dump_group,
- dump_named_datatype,
- dump_dataset,
- dump_dataspace,
- dump_datatype,
- dump_attr_cb,
- dump_data
-};
+ dump_group, dump_named_datatype, dump_dataset, dump_dataspace, dump_datatype, dump_attr_cb, dump_data};
/* XML output */
static const dump_functions xml_function_table = {
- xml_dump_group,
- xml_dump_named_datatype,
- xml_dump_dataset,
- xml_dump_dataspace,
- xml_dump_datatype,
- xml_dump_attr,
- xml_dump_data
-};
+ xml_dump_group, xml_dump_named_datatype, xml_dump_dataset, xml_dump_dataspace,
+ xml_dump_datatype, xml_dump_attr, xml_dump_data};
/* internal functions */
-static void init_prefix(char **prfx, size_t prfx_len);
+static void init_prefix(char **prfx, size_t prfx_len);
/* a structure for handling the order command-line parameters come in */
struct handler_t {
void (*func)(hid_t, const char *, void *, int, const char *);
- char *obj;
+ char * obj;
struct subset_t *subset_info;
};
@@ -88,132 +81,57 @@ struct handler_t {
*/
/* The following initialization makes use of C language concatenating */
/* "xxx" "yyy" into "xxxyyy". */
-static const char *s_opts = "hn*peyBHirVa:c:d:f:g:k:l:t:w:xD:uX:o*b*F:s:S:A*q:z:m:RE*CM:O*N:vG:";
-static struct long_options l_opts[] = {
- { "help", no_arg, 'h' },
- { "hel", no_arg, 'h' },
- { "contents", optional_arg, 'n' },
- { "properties", no_arg, 'p' },
- { "superblock", no_arg, 'B' },
- { "boot-block", no_arg, 'B' },
- { "boot-bloc", no_arg, 'B' },
- { "boot-blo", no_arg, 'B' },
- { "boot-bl", no_arg, 'B' },
- { "boot-b", no_arg, 'B' },
- { "boot", no_arg, 'B' },
- { "boo", no_arg, 'B' },
- { "bo", no_arg, 'B' },
- { "header", no_arg, 'H' },
- { "heade", no_arg, 'H' },
- { "head", no_arg, 'H' },
- { "hea", no_arg, 'H' },
- { "object-ids", no_arg, 'i' },
- { "object-id", no_arg, 'i' },
- { "object-i", no_arg, 'i' },
- { "object", no_arg, 'i' },
- { "objec", no_arg, 'i' },
- { "obje", no_arg, 'i' },
- { "obj", no_arg, 'i' },
- { "ob", no_arg, 'i' },
- { "version", no_arg, 'V' },
- { "versio", no_arg, 'V' },
- { "versi", no_arg, 'V' },
- { "vers", no_arg, 'V' },
- { "ver", no_arg, 'V' },
- { "ve", no_arg, 'V' },
- { "attribute", require_arg, 'a' },
- { "attribut", require_arg, 'a' },
- { "attribu", require_arg, 'a' },
- { "attrib", require_arg, 'a' },
- { "attri", require_arg, 'a' },
- { "attr", require_arg, 'a' },
- { "att", require_arg, 'a' },
- { "at", require_arg, 'a' },
- { "block", require_arg, 'k' },
- { "bloc", require_arg, 'k' },
- { "blo", require_arg, 'k' },
- { "bl", require_arg, 'k' },
- { "count", require_arg, 'c' },
- { "coun", require_arg, 'c' },
- { "cou", require_arg, 'c' },
- { "co", require_arg, 'c' },
- { "dataset", require_arg, 'd' },
- { "datase", require_arg, 'd' },
- { "datas", require_arg, 'd' },
- { "datatype", require_arg, 't' },
- { "datatyp", require_arg, 't' },
- { "dataty", require_arg, 't' },
- { "datat", require_arg, 't' },
- { "filedriver", require_arg, 'f' },
- { "filedrive", require_arg, 'f' },
- { "filedriv", require_arg, 'f' },
- { "filedri", require_arg, 'f' },
- { "filedr", require_arg, 'f' },
- { "filed", require_arg, 'f' },
- { "file", require_arg, 'f' },
- { "fil", require_arg, 'f' },
- { "fi", require_arg, 'f' },
- { "group", require_arg, 'g' },
- { "grou", require_arg, 'g' },
- { "gro", require_arg, 'g' },
- { "gr", require_arg, 'g' },
- { "output", optional_arg, 'o' },
- { "outpu", optional_arg, 'o' },
- { "outp", optional_arg, 'o' },
- { "out", optional_arg, 'o' },
- { "ou", optional_arg, 'o' },
- { "soft-link", require_arg, 'l' },
- { "soft-lin", require_arg, 'l' },
- { "soft-li", require_arg, 'l' },
- { "soft-l", require_arg, 'l' },
- { "soft", require_arg, 'l' },
- { "sof", require_arg, 'l' },
- { "start", require_arg, 's' },
- { "star", require_arg, 's' },
- { "sta", require_arg, 's' },
- { "stride", require_arg, 'S' },
- { "strid", require_arg, 'S' },
- { "string", no_arg, 'r' },
- { "strin", no_arg, 'r' },
- { "use-dtd", no_arg, 'u' },
- { "use-dt", no_arg, 'u' },
- { "use-d", no_arg, 'u' },
- { "use-", no_arg, 'u' },
- { "use", no_arg, 'u' },
- { "us", no_arg, 'u' },
- { "u", no_arg, 'u' },
- { "width", require_arg, 'w' },
- { "widt", require_arg, 'w' },
- { "wid", require_arg, 'w' },
- { "wi", require_arg, 'w' },
- { "xml-dtd", require_arg, 'D' },
- { "xml-dt", require_arg, 'D' },
- { "xml-d", require_arg, 'D' },
- { "xml-ns", require_arg, 'X' },
- { "xml-n", require_arg, 'X' },
- { "xml", no_arg, 'x' },
- { "xm", no_arg, 'x' },
- { "onlyattr", optional_arg, 'A' },
- { "escape", no_arg, 'e' },
- { "noindex", no_arg, 'y' },
- { "binary", optional_arg, 'b' },
- { "form", require_arg, 'F' },
- { "sort_by", require_arg, 'q' },
- { "sort_order", require_arg, 'z' },
- { "format", require_arg, 'm' },
- { "region", no_arg, 'R' },
- { "enable-error-stack", optional_arg, 'E' },
- { "packed-bits", require_arg, 'M' },
- { "no-compact-subset", no_arg, 'C' },
- { "ddl", optional_arg, 'O' },
- { "any_path", require_arg, 'N' },
- { "vds-view-first-missing", no_arg, 'v' },
- { "vds-gap-size", require_arg, 'G' },
- { "s3-cred", require_arg, '$' },
- { "hdfs-attrs", require_arg, '#' },
- { NULL, 0, '\0' }
-};
-
+static const char * s_opts = "a:b*c:d:ef:g:hik:l:m:n*o*pq:rs:t:uvw:xyz:A*BCD:E*F:G:HM:N:O*RS:VX:";
+static struct h5_long_options l_opts[] = {{"attribute", require_arg, 'a'},
+ {"binary", optional_arg, 'b'},
+ {"count", require_arg, 'c'},
+ {"dataset", require_arg, 'd'},
+ {"escape", no_arg, 'e'},
+ {"filedriver", require_arg, 'f'},
+ {"group", require_arg, 'g'},
+ {"help", no_arg, 'h'},
+ {"object-ids", no_arg, 'i'},
+ {"block", require_arg, 'k'},
+ {"soft-link", require_arg, 'l'},
+ {"format", require_arg, 'm'},
+ {"contents", optional_arg, 'n'},
+ {"output", optional_arg, 'o'},
+ {"properties", no_arg, 'p'},
+ {"sort_by", require_arg, 'q'},
+ {"string", no_arg, 'r'},
+ {"start", require_arg, 's'},
+ {"datatype", require_arg, 't'},
+ {"use-dtd", no_arg, 'u'},
+ {"vds-view-first-missing", no_arg, 'v'},
+ {"width", require_arg, 'w'},
+ {"xml", no_arg, 'x'},
+ {"noindex", no_arg, 'y'},
+ {"sort_order", require_arg, 'z'},
+ {"onlyattr", optional_arg, 'A'},
+ {"superblock", no_arg, 'B'},
+ {"boot-block", no_arg, 'B'},
+ {"no-compact-subset", no_arg, 'C'},
+ {"xml-dtd", require_arg, 'D'},
+ {"enable-error-stack", optional_arg, 'E'},
+ {"form", require_arg, 'F'},
+ {"vds-gap-size", require_arg, 'G'},
+ {"header", no_arg, 'H'},
+ {"packed-bits", require_arg, 'M'},
+ {"any_path", require_arg, 'N'},
+ {"ddl", optional_arg, 'O'},
+ {"region", no_arg, 'R'},
+ {"stride", require_arg, 'S'},
+ {"version", no_arg, 'V'},
+ {"xml-ns", require_arg, 'X'},
+ {"s3-cred", require_arg, '$'},
+ {"hdfs-attrs", require_arg, '#'},
+ {"vol-value", require_arg, '1'},
+ {"vol-name", require_arg, '2'},
+ {"vol-info", require_arg, '3'},
+ {"vfd-value", require_arg, '4'},
+ {"vfd-name", require_arg, '5'},
+ {"vfd-info", require_arg, '6'},
+ {NULL, 0, '\0'}};
/*-------------------------------------------------------------------------
* Function: leave
@@ -221,12 +139,6 @@ static struct long_options l_opts[] = {
* Purpose: Shutdown MPI & HDF5 and call exit()
*
* Return: Does not return
- *
- * Programmer: Quincey Koziol
- * Saturday, 31. January 2004
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static void
@@ -237,7 +149,6 @@ leave(int ret)
HDexit(ret);
}
-
/*-------------------------------------------------------------------------
* Function: usage
*
@@ -254,6 +165,12 @@ usage(const char *prog)
PRINTVALSTREAM(rawoutstream, " OPTIONS\n");
PRINTVALSTREAM(rawoutstream, " -h, --help Print a usage message and exit\n");
PRINTVALSTREAM(rawoutstream, " -V, --version Print version number and exit\n");
+ PRINTVALSTREAM(rawoutstream, "--------------- Error Options ---------------\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --enable-error-stack Prints messages from the HDF5 error stack as they occur.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " Optional value 2 also prints file open errors.\n");
+ PRINTVALSTREAM(rawoutstream, " Default setting disables any error reporting.\n");
PRINTVALSTREAM(rawoutstream, "--------------- File Options ---------------\n");
PRINTVALSTREAM(rawoutstream, " -n, --contents Print a list of the file contents and exit\n");
PRINTVALSTREAM(rawoutstream, " Optional value 1 also prints attributes.\n");
@@ -263,40 +180,76 @@ usage(const char *prog)
PRINTVALSTREAM(rawoutstream, " -o F, --output=F Output raw data into file F\n");
PRINTVALSTREAM(rawoutstream, " -b B, --binary=B Binary file output, of form B\n");
PRINTVALSTREAM(rawoutstream, " -O F, --ddl=F Output ddl text into file F\n");
- PRINTVALSTREAM(rawoutstream, " Use blank(empty) filename F to suppress ddl display\n");
- PRINTVALSTREAM(rawoutstream, " --s3-cred=<cred> Supply S3 authentication information to \"ros3\" vfd.\n");
- PRINTVALSTREAM(rawoutstream, " <cred> :: \"(<aws-region>,<access-id>,<access-key>)\"\n");
- PRINTVALSTREAM(rawoutstream, " If absent or <cred> -> \"(,,)\", no authentication.\n");
- PRINTVALSTREAM(rawoutstream, " Has no effect is filedriver is not `ros3'.\n");
- PRINTVALSTREAM(rawoutstream, " --hdfs-attrs=<attrs> Supply configuration information for HDFS file access.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " Use blank(empty) filename F to suppress ddl display\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --s3-cred=<cred> Supply S3 authentication information to \"ros3\" vfd.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " <cred> :: \"(<aws-region>,<access-id>,<access-key>)\"\n");
+ PRINTVALSTREAM(rawoutstream,
+ " If absent or <cred> -> \"(,,)\", no authentication.\n");
+ PRINTVALSTREAM(rawoutstream, " Has no effect if filedriver is not \"ros3\".\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --hdfs-attrs=<attrs> Supply configuration information for HDFS file access.\n");
PRINTVALSTREAM(rawoutstream, " For use with \"--filedriver=hdfs\"\n");
PRINTVALSTREAM(rawoutstream, " <attrs> :: (<namenode name>,<namenode port>,\n");
PRINTVALSTREAM(rawoutstream, " <kerberos cache path>,<username>,\n");
PRINTVALSTREAM(rawoutstream, " <buffer size>)\n");
- PRINTVALSTREAM(rawoutstream, " Any absent attribute will use a default value.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " Any absent attribute will use a default value.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --vol-value Value (ID) of the VOL connector to use for opening the\n");
+ PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --vol-name Name of the VOL connector to use for opening the\n");
+ PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --vol-info VOL-specific info to pass to the VOL connector used for\n");
+ PRINTVALSTREAM(rawoutstream, " opening the HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --vfd-value Value (ID) of the VFL driver to use for opening the\n");
+ PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream, " --vfd-name Name of the VFL driver to use for opening the\n");
+ PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --vfd-info VFD-specific info to pass to the VFL driver used for\n");
+ PRINTVALSTREAM(rawoutstream, " opening the HDF5 file specified\n");
PRINTVALSTREAM(rawoutstream, "--------------- Object Options ---------------\n");
PRINTVALSTREAM(rawoutstream, " -a P, --attribute=P Print the specified attribute\n");
- PRINTVALSTREAM(rawoutstream, " If an attribute name contains a slash (/), escape the\n");
+ PRINTVALSTREAM(rawoutstream,
+ " If an attribute name contains a slash (/), escape the\n");
PRINTVALSTREAM(rawoutstream, " slash with a preceding backslash (\\).\n");
PRINTVALSTREAM(rawoutstream, " (See example section below.)\n");
PRINTVALSTREAM(rawoutstream, " -d P, --dataset=P Print the specified dataset\n");
PRINTVALSTREAM(rawoutstream, " -g P, --group=P Print the specified group and all members\n");
PRINTVALSTREAM(rawoutstream, " -l P, --soft-link=P Print the value(s) of the specified soft link\n");
PRINTVALSTREAM(rawoutstream, " -t P, --datatype=P Print the specified named datatype\n");
- PRINTVALSTREAM(rawoutstream, " -N P, --any_path=P Print any attribute, dataset, group, datatype, or link that matches P\n");
- PRINTVALSTREAM(rawoutstream, " P can be the absolute path or just a relative path.\n");
+ PRINTVALSTREAM(
+ rawoutstream,
+ " -N P, --any_path=P Print any attribute, dataset, group, datatype, or link that matches P\n");
+ PRINTVALSTREAM(rawoutstream,
+ " P can be the absolute path or just a relative path.\n");
PRINTVALSTREAM(rawoutstream, " -A, --onlyattr Print the header and value of attributes\n");
- PRINTVALSTREAM(rawoutstream, " Optional value 0 suppresses printing attributes.\n");
- PRINTVALSTREAM(rawoutstream, " --vds-view-first-missing Set the VDS bounds to first missing mapped elements.\n");
- PRINTVALSTREAM(rawoutstream, " --vds-gap-size=N Set the missing file gap size, N=non-negative integers\n");
+ PRINTVALSTREAM(rawoutstream,
+ " Optional value 0 suppresses printing attributes.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --vds-view-first-missing Set the VDS bounds to first missing mapped elements.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --vds-gap-size=N Set the missing file gap size, N=non-negative integers\n");
PRINTVALSTREAM(rawoutstream, "--------------- Object Property Options ---------------\n");
PRINTVALSTREAM(rawoutstream, " -i, --object-ids Print the object ids\n");
- PRINTVALSTREAM(rawoutstream, " -p, --properties Print dataset filters, storage layout and fill value\n");
- PRINTVALSTREAM(rawoutstream, " -M L, --packedbits=L Print packed bits as unsigned integers, using mask\n");
- PRINTVALSTREAM(rawoutstream, " format L for an integer dataset specified with\n");
- PRINTVALSTREAM(rawoutstream, " option -d. L is a list of offset,length values,\n");
- PRINTVALSTREAM(rawoutstream, " separated by commas. Offset is the beginning bit in\n");
- PRINTVALSTREAM(rawoutstream, " the data value and length is the number of bits of\n");
+ PRINTVALSTREAM(rawoutstream,
+ " -p, --properties Print dataset filters, storage layout and fill value\n");
+ PRINTVALSTREAM(rawoutstream,
+ " -M L, --packedbits=L Print packed bits as unsigned integers, using mask\n");
+ PRINTVALSTREAM(rawoutstream,
+ " format L for an integer dataset specified with\n");
+ PRINTVALSTREAM(rawoutstream,
+ " option -d. L is a list of offset,length values,\n");
+ PRINTVALSTREAM(rawoutstream,
+ " separated by commas. Offset is the beginning bit in\n");
+ PRINTVALSTREAM(rawoutstream,
+ " the data value and length is the number of bits of\n");
PRINTVALSTREAM(rawoutstream, " the mask.\n");
PRINTVALSTREAM(rawoutstream, " -R, --region Print dataset pointed by region references\n");
PRINTVALSTREAM(rawoutstream, "--------------- Formatting Options ---------------\n");
@@ -306,12 +259,13 @@ usage(const char *prog)
PRINTVALSTREAM(rawoutstream, " -m T, --format=T Set the floating point output format\n");
PRINTVALSTREAM(rawoutstream, " -q Q, --sort_by=Q Sort groups and attributes by index Q\n");
PRINTVALSTREAM(rawoutstream, " -z Z, --sort_order=Z Sort groups and attributes by order Z\n");
- PRINTVALSTREAM(rawoutstream, " --enable-error-stack Prints messages from the HDF5 error stack as they occur.\n");
- PRINTVALSTREAM(rawoutstream, " Optional value 2 also prints file open errors.\n");
- PRINTVALSTREAM(rawoutstream, " --no-compact-subset Disable compact form of subsetting and allow the use\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --no-compact-subset Disable compact form of subsetting and allow the use\n");
PRINTVALSTREAM(rawoutstream, " of \"[\" in dataset names.\n");
- PRINTVALSTREAM(rawoutstream, " -w N, --width=N Set the number of columns of output. A value of 0 (zero)\n");
- PRINTVALSTREAM(rawoutstream, " sets the number of columns to the maximum (65535).\n");
+ PRINTVALSTREAM(rawoutstream,
+ " -w N, --width=N Set the number of columns of output. A value of 0 (zero)\n");
+ PRINTVALSTREAM(rawoutstream,
+ " sets the number of columns to the maximum (65535).\n");
PRINTVALSTREAM(rawoutstream, " Default width is 80 columns.\n");
PRINTVALSTREAM(rawoutstream, "--------------- XML Options ---------------\n");
PRINTVALSTREAM(rawoutstream, " -x, --xml Output in XML using Schema\n");
@@ -319,31 +273,44 @@ usage(const char *prog)
PRINTVALSTREAM(rawoutstream, " -D U, --xml-dtd=U Use the DTD or schema at U\n");
PRINTVALSTREAM(rawoutstream, " -X S, --xml-ns=S (XML Schema) Use qualified names n the XML\n");
PRINTVALSTREAM(rawoutstream, " \":\": no namespace, default: \"hdf5:\"\n");
- PRINTVALSTREAM(rawoutstream, " E.g., to dump a file called `-f', use h5dump -- -f\n");
+ PRINTVALSTREAM(rawoutstream,
+ " E.g., to dump a file called \"-f\", use h5dump -- -f\n");
PRINTVALSTREAM(rawoutstream, "\n");
PRINTVALSTREAM(rawoutstream, "--------------- Subsetting Options ---------------\n");
PRINTVALSTREAM(rawoutstream, " Subsetting is available by using the following options with a dataset\n");
PRINTVALSTREAM(rawoutstream, " option. Subsetting is done by selecting a hyperslab from the data.\n");
PRINTVALSTREAM(rawoutstream, " Thus, the options mirror those for performing a hyperslab selection.\n");
- PRINTVALSTREAM(rawoutstream, " One of the START, COUNT, STRIDE, or BLOCK parameters are mandatory if you do subsetting.\n");
- PRINTVALSTREAM(rawoutstream, " The STRIDE, COUNT, and BLOCK parameters are optional and will default to 1 in\n");
- PRINTVALSTREAM(rawoutstream, " each dimension. START is optional and will default to 0 in each dimension.\n");
+ PRINTVALSTREAM(
+ rawoutstream,
+ " One of the START, COUNT, STRIDE, or BLOCK parameters are mandatory if you do subsetting.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " The STRIDE, COUNT, and BLOCK parameters are optional and will default to 1 in\n");
+ PRINTVALSTREAM(rawoutstream,
+ " each dimension. START is optional and will default to 0 in each dimension.\n");
PRINTVALSTREAM(rawoutstream, "\n");
- PRINTVALSTREAM(rawoutstream, " -s START, --start=START Offset of start of subsetting selection\n");
+ PRINTVALSTREAM(rawoutstream,
+ " -s START, --start=START Offset of start of subsetting selection\n");
PRINTVALSTREAM(rawoutstream, " -S STRIDE, --stride=STRIDE Hyperslab stride\n");
- PRINTVALSTREAM(rawoutstream, " -c COUNT, --count=COUNT Number of blocks to include in selection\n");
+ PRINTVALSTREAM(rawoutstream,
+ " -c COUNT, --count=COUNT Number of blocks to include in selection\n");
PRINTVALSTREAM(rawoutstream, " -k BLOCK, --block=BLOCK Size of block in hyperslab\n");
- PRINTVALSTREAM(rawoutstream, " START, COUNT, STRIDE, and BLOCK - is a list of integers the number of which are equal to the\n");
+ PRINTVALSTREAM(
+ rawoutstream,
+ " START, COUNT, STRIDE, and BLOCK - is a list of integers the number of which are equal to the\n");
PRINTVALSTREAM(rawoutstream, " number of dimensions in the dataspace being queried\n");
- PRINTVALSTREAM(rawoutstream, " (Alternate compact form of subsetting is described in the Reference Manual)\n");
+ PRINTVALSTREAM(rawoutstream,
+ " (Alternate compact form of subsetting is described in the Reference Manual)\n");
PRINTVALSTREAM(rawoutstream, "\n");
PRINTVALSTREAM(rawoutstream, "--------------- Option Argument Conventions ---------------\n");
PRINTVALSTREAM(rawoutstream, " D - is the file driver to use in opening the file. Acceptable values\n");
- PRINTVALSTREAM(rawoutstream, " are \"sec2\", \"family\", \"split\", \"multi\", \"direct\", and \"stream\". Without\n");
+ PRINTVALSTREAM(
+ rawoutstream,
+ " are \"sec2\", \"family\", \"split\", \"multi\", \"direct\", and \"stream\". Without\n");
PRINTVALSTREAM(rawoutstream, " the file driver flag, the file will be opened with each driver in\n");
PRINTVALSTREAM(rawoutstream, " turn and in the order specified above until one driver succeeds\n");
PRINTVALSTREAM(rawoutstream, " in opening the file.\n");
- PRINTVALSTREAM(rawoutstream, " See examples below for family, split, and multi driver special file name usage.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " See examples below for family, split, and multi driver special file name usage.\n");
PRINTVALSTREAM(rawoutstream, "\n");
PRINTVALSTREAM(rawoutstream, " F - is a filename.\n");
PRINTVALSTREAM(rawoutstream, " P - is the full path from the root group to the object.\n");
@@ -351,12 +318,17 @@ usage(const char *prog)
PRINTVALSTREAM(rawoutstream, " T - is a string containing the floating point format, e.g '%%.3f'\n");
PRINTVALSTREAM(rawoutstream, " U - is a URI reference (as defined in [IETF RFC 2396],\n");
PRINTVALSTREAM(rawoutstream, " updated by [IETF RFC 2732])\n");
- PRINTVALSTREAM(rawoutstream, " B - is the form of binary output: NATIVE for a memory type, FILE for the\n");
- PRINTVALSTREAM(rawoutstream, " file type, LE or BE for pre-existing little or big endian types.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " B - is the form of binary output: NATIVE for a memory type, FILE for the\n");
+ PRINTVALSTREAM(rawoutstream,
+ " file type, LE or BE for pre-existing little or big endian types.\n");
PRINTVALSTREAM(rawoutstream, " Must be used with -o (output file) and it is recommended that\n");
- PRINTVALSTREAM(rawoutstream, " -d (dataset) is used. B is an optional argument, defaults to NATIVE\n");
- PRINTVALSTREAM(rawoutstream, " Q - is the sort index type. It can be \"creation_order\" or \"name\" (default)\n");
- PRINTVALSTREAM(rawoutstream, " Z - is the sort order type. It can be \"descending\" or \"ascending\" (default)\n");
+ PRINTVALSTREAM(rawoutstream,
+ " -d (dataset) is used. B is an optional argument, defaults to NATIVE\n");
+ PRINTVALSTREAM(rawoutstream,
+ " Q - is the sort index type. It can be \"creation_order\" or \"name\" (default)\n");
+ PRINTVALSTREAM(rawoutstream,
+ " Z - is the sort order type. It can be \"descending\" or \"ascending\" (default)\n");
PRINTVALSTREAM(rawoutstream, "\n");
PRINTVALSTREAM(rawoutstream, "--------------- Examples ---------------\n");
PRINTVALSTREAM(rawoutstream, "\n");
@@ -370,14 +342,16 @@ usage(const char *prog)
PRINTVALSTREAM(rawoutstream, "\n");
PRINTVALSTREAM(rawoutstream, " 2) Selecting a subset from dataset /foo in file quux.h5\n");
PRINTVALSTREAM(rawoutstream, "\n");
- PRINTVALSTREAM(rawoutstream, " h5dump -d /foo -s \"0,1\" -S \"1,1\" -c \"2,3\" -k \"2,2\" quux.h5\n");
+ PRINTVALSTREAM(rawoutstream,
+ " h5dump -d /foo -s \"0,1\" -S \"1,1\" -c \"2,3\" -k \"2,2\" quux.h5\n");
PRINTVALSTREAM(rawoutstream, "\n");
PRINTVALSTREAM(rawoutstream, " 3) Saving dataset 'dset' in file quux.h5 to binary file 'out.bin'\n");
PRINTVALSTREAM(rawoutstream, " using a little-endian type\n");
PRINTVALSTREAM(rawoutstream, "\n");
PRINTVALSTREAM(rawoutstream, " h5dump -d /dset -b LE -o out.bin quux.h5\n");
PRINTVALSTREAM(rawoutstream, "\n");
- PRINTVALSTREAM(rawoutstream, " 4) Display two packed bits (bits 0-1 and bits 4-6) in the dataset /dset\n");
+ PRINTVALSTREAM(rawoutstream,
+ " 4) Display two packed bits (bits 0-1 and bits 4-6) in the dataset /dset\n");
PRINTVALSTREAM(rawoutstream, "\n");
PRINTVALSTREAM(rawoutstream, " h5dump -d /dset -M 0,1,4,3 quux.h5\n");
PRINTVALSTREAM(rawoutstream, "\n");
@@ -389,57 +363,54 @@ usage(const char *prog)
PRINTVALSTREAM(rawoutstream, "\n");
PRINTVALSTREAM(rawoutstream, " h5dump -d /foo -f split splitfile\n");
PRINTVALSTREAM(rawoutstream, "\n");
- PRINTVALSTREAM(rawoutstream, " 7) Dataset foo in multi files mf-s.h5, mf-b.h5, mf-r.h5, mf-g.h5, mf-l.h5 and mf-o.h5\n");
+ PRINTVALSTREAM(
+ rawoutstream,
+ " 7) Dataset foo in multi files mf-s.h5, mf-b.h5, mf-r.h5, mf-g.h5, mf-l.h5 and mf-o.h5\n");
PRINTVALSTREAM(rawoutstream, "\n");
PRINTVALSTREAM(rawoutstream, " h5dump -d /foo -f multi mf\n");
PRINTVALSTREAM(rawoutstream, "\n");
- PRINTVALSTREAM(rawoutstream, " 8) Dataset foo in family files fam00000.h5 fam00001.h5 and fam00002.h5\n");
+ PRINTVALSTREAM(rawoutstream,
+ " 8) Dataset foo in family files fam00000.h5 fam00001.h5 and fam00002.h5\n");
PRINTVALSTREAM(rawoutstream, "\n");
PRINTVALSTREAM(rawoutstream, " h5dump -d /foo -f family fam%%05d.h5\n");
PRINTVALSTREAM(rawoutstream, "\n");
}
-
/*-------------------------------------------------------------------------
- * Function: table_list_add
- *
- * Purpose: Add a new set of tables
- *
- * Return: index of added table on success, -1 on failure
+ * Function: table_list_add
*
- * Programmer: Neil Fortner, nfortne2@hdfgroup.org
- * Adapted from trav_addr_add in h5trav.c by Quincey Koziol
- *
- * Date: October 13, 2008
+ * Purpose: Add a new set of tables
*
+ * Return: index of added table on success, -1 on failure
*-------------------------------------------------------------------------
*/
ssize_t
table_list_add(hid_t oid, unsigned long file_no)
{
- size_t idx; /* Index of table to use */
+ size_t idx; /* Index of table to use */
find_objs_t info;
/* Allocate space if necessary */
- if(table_list.nused == table_list.nalloc) {
- h5dump_table_items_t *tmp_ptr;
+ if (table_list.nused == table_list.nalloc) {
+ h5dump_table_items_t *tmp_ptr;
table_list.nalloc = MAX(1, table_list.nalloc * 2);
- if(NULL == (tmp_ptr = (h5dump_table_items_t *)HDrealloc(table_list.tables, table_list.nalloc * sizeof(table_list.tables[0]))))
+ if (NULL == (tmp_ptr = (h5dump_table_items_t *)HDrealloc(
+ table_list.tables, table_list.nalloc * sizeof(table_list.tables[0]))))
return -1;
table_list.tables = tmp_ptr;
} /* end if */
/* Append it */
- idx = table_list.nused++;
+ idx = table_list.nused++;
table_list.tables[idx].fileno = file_no;
- table_list.tables[idx].oid = oid;
- if(H5Iinc_ref(oid) < 0) {
+ table_list.tables[idx].oid = oid;
+ if (H5Iinc_ref(oid) < 0) {
table_list.nused--;
return -1;
}
- if(init_objs(oid, &info, &table_list.tables[idx].group_table,
- &table_list.tables[idx].dset_table, &table_list.tables[idx].type_table) < 0) {
+ if (init_objs(oid, &info, &table_list.tables[idx].group_table, &table_list.tables[idx].dset_table,
+ &table_list.tables[idx].type_table) < 0) {
H5Idec_ref(oid);
table_list.nused--;
return -1;
@@ -449,71 +420,55 @@ table_list_add(hid_t oid, unsigned long file_no)
dump_tables(&info);
#endif /* H5DUMP_DEBUG */
- return((ssize_t) idx);
+ return ((ssize_t)idx);
} /* end table_list_add() */
-
/*-------------------------------------------------------------------------
- * Function: table_list_visited
+ * Function: table_list_visited
*
- * Purpose: Check if a table already exists for the specified fileno
- *
- * Return: The index of the matching table, or -1 if no matches found
- *
- * Programmer: Neil Fortner, nfortne2@hdfgroup.org
- * Adapted from trav_addr_visited in h5trav.c by Quincey Koziol
- *
- * Date: October 13, 2008
+ * Purpose: Check if a table already exists for the specified fileno
*
+ * Return: The index of the matching table, or -1 if no matches found
*-------------------------------------------------------------------------
*/
H5_ATTR_PURE ssize_t
table_list_visited(unsigned long file_no)
{
- size_t u; /* Local index variable */
+ size_t u; /* Local index variable */
/* Look for table */
- for(u = 0; u < table_list.nused; u++)
+ for (u = 0; u < table_list.nused; u++)
/* Check for fileno value already in array */
- if(table_list.tables[u].fileno == file_no)
- return((ssize_t) u);
+ if (table_list.tables[u].fileno == file_no)
+ return ((ssize_t)u);
/* Didn't find table */
- return(-1);
+ return (-1);
} /* end table_list_visited() */
-
/*-------------------------------------------------------------------------
- * Function: table_list_free
+ * Function: table_list_free
*
- * Purpose: Frees the table list
- *
- * Return: void
- *
- * Programmer: Neil Fortner, nfortne2@hdfgroup.org
- *
- * Date: October 13, 2008
+ * Purpose: Frees the table list
*
+ * Return: void
*-------------------------------------------------------------------------
*/
static void
table_list_free(void)
{
- size_t u; /* Local index variable */
+ size_t u; /* Local index variable */
/* Iterate over tables */
- for(u = 0; u < table_list.nused; u++) {
+ for (u = 0; u < table_list.nused; u++) {
/* Release object id */
- if(H5Idec_ref(table_list.tables[u].oid) < 0)
+ if (H5Idec_ref(table_list.tables[u].oid) < 0)
h5tools_setstatus(EXIT_FAILURE);
/* Free each table */
free_table(table_list.tables[u].group_table);
- HDfree(table_list.tables[u].group_table);
free_table(table_list.tables[u].dset_table);
- HDfree(table_list.tables[u].dset_table);
free_table(table_list.tables[u].type_table);
- HDfree(table_list.tables[u].type_table);
}
/* Free the table list */
@@ -525,16 +480,10 @@ table_list_free(void)
/*-------------------------------------------------------------------------
* Function: set_binary_form
*
- * Purpose: set the binary form of output by translating from a string input
- * parameter to a integer return value
- *
- * Return: integer form of binary output or -1 if none found
- *
- * Programmer: Pedro Vicente Nunes
- * June 28, 2006
- *
- * Modifications:
+ * Purpose: set the binary form of output by translating from a string input
+ * parameter to a integer return value
*
+ * Return: integer form of binary output or -1 if none found
*-------------------------------------------------------------------------
*/
static int
@@ -542,15 +491,15 @@ set_binary_form(const char *form)
{
int bform = -1;
- if (HDstrcmp(form,"NATIVE") == 0 || HDstrcmp(form,"MEMORY") == 0) {
+ if (HDstrcmp(form, "NATIVE") == 0 || HDstrcmp(form, "MEMORY") == 0) {
/* native form */
bform = 0;
}
- else if (HDstrcmp(form,"FILE") == 0) /* file type form */
+ else if (HDstrcmp(form, "FILE") == 0) /* file type form */
bform = 1;
- else if (HDstrcmp(form,"LE") == 0) /* convert to little endian */
+ else if (HDstrcmp(form, "LE") == 0) /* convert to little endian */
bform = 2;
- else if (HDstrcmp(form,"BE") == 0) /* convert to big endian */
+ else if (HDstrcmp(form, "BE") == 0) /* convert to big endian */
bform = 3;
return bform;
@@ -559,17 +508,11 @@ set_binary_form(const char *form)
/*-------------------------------------------------------------------------
* Function: set_sort_by
*
- * Purpose: set the "by" form of sorting by translating from a string input
- * parameter to a H5_index_t return value
- * current sort values are [creation_order | name]
- *
- * Return: H5_index_t form of sort or H5_INDEX_UNKNOWN if none found
- *
- * Programmer: Pedro Vicente Nunes
- * October 1, 2007
- *
- * Modifications:
+ * Purpose: set the "by" form of sorting by translating from a string input
+ * parameter to a H5_index_t return value
+ * current sort values are [creation_order | name]
*
+ * Return: H5_index_t form of sort or H5_INDEX_UNKNOWN if none found
*-------------------------------------------------------------------------
*/
static H5_index_t
@@ -577,9 +520,9 @@ set_sort_by(const char *form)
{
H5_index_t idx_type = H5_INDEX_UNKNOWN;
- if (HDstrcmp(form,"name")==0) /* H5_INDEX_NAME */
+ if (HDstrcmp(form, "name") == 0) /* H5_INDEX_NAME */
idx_type = H5_INDEX_NAME;
- else if (HDstrcmp(form,"creation_order")==0) /* H5_INDEX_CRT_ORDER */
+ else if (HDstrcmp(form, "creation_order") == 0) /* H5_INDEX_CRT_ORDER */
idx_type = H5_INDEX_CRT_ORDER;
return idx_type;
@@ -588,17 +531,11 @@ set_sort_by(const char *form)
/*-------------------------------------------------------------------------
* Function: set_sort_order
*
- * Purpose: set the order of sorting by translating from a string input
- * parameter to a H5_iter_order_t return value
- * current order values are [ascending | descending ]
- *
- * Return: H5_iter_order_t form of order or H5_ITER_UNKNOWN if none found
- *
- * Programmer: Pedro Vicente Nunes
- * October 1, 2007
- *
- * Modifications:
+ * Purpose: set the order of sorting by translating from a string input
+ * parameter to a H5_iter_order_t return value
+ * current order values are [ascending | descending ]
*
+ * Return: H5_iter_order_t form of order or H5_ITER_UNKNOWN if none found
*-------------------------------------------------------------------------
*/
static H5_iter_order_t
@@ -606,9 +543,9 @@ set_sort_order(const char *form)
{
H5_iter_order_t iter_order = H5_ITER_UNKNOWN;
- if (HDstrcmp(form,"ascending")==0) /* H5_ITER_INC */
+ if (HDstrcmp(form, "ascending") == 0) /* H5_ITER_INC */
iter_order = H5_ITER_INC;
- else if (HDstrcmp(form,"descending")==0) /* H5_ITER_DEC */
+ else if (HDstrcmp(form, "descending") == 0) /* H5_ITER_DEC */
iter_order = H5_ITER_DEC;
return iter_order;
@@ -627,20 +564,16 @@ set_sort_order(const char *form)
* either commas (,) or white spaces.
*
* Return: <none>
- *
- * Programmer: Bill Wendling
- * Tuesday, 6. February 2001
- *
*-------------------------------------------------------------------------
*/
static void
parse_hsize_list(const char *h_list, subset_d *d)
{
- hsize_t *p_list;
- const char *ptr;
- unsigned int size_count = 0;
- unsigned int i = 0;
- unsigned int last_digit = 0;
+ hsize_t * p_list;
+ const char * ptr;
+ unsigned int size_count = 0;
+ unsigned int i = 0;
+ unsigned int last_digit = 0;
if (!h_list || !*h_list || *h_list == ';')
return;
@@ -665,7 +598,7 @@ parse_hsize_list(const char *h_list, subset_d *d)
p_list = (hsize_t *)HDcalloc(size_count, sizeof(hsize_t));
for (ptr = h_list; i < size_count && ptr && *ptr && *ptr != ';' && *ptr != ']'; ptr++)
- if(HDisdigit(*ptr)) {
+ if (HDisdigit(*ptr)) {
/* we should have an integer now */
p_list[i++] = (hsize_t)HDstrtoull(ptr, NULL, 0);
@@ -674,32 +607,25 @@ parse_hsize_list(const char *h_list, subset_d *d)
ptr++;
}
d->data = p_list;
- d->len = size_count;
+ d->len = size_count;
}
/*-------------------------------------------------------------------------
* Function: parse_subset_params
*
- * Purpose: Parse the so-called "terse" syntax for specifying subsetting
- * parameters.
+ * Purpose: Parse the so-called "terse" syntax for specifying subsetting parameters.
*
* Return: Success: struct subset_t object
* Failure: NULL
- *
- * Programmer: Bill Wendling
- * Tuesday, 6. February 2001
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static struct subset_t *
-parse_subset_params(char *dset)
+parse_subset_params(const char *dset)
{
struct subset_t *s = NULL;
- char *brace;
+ char * brace;
- if (!disable_compact_subset && ((brace = HDstrrchr(dset, '[')) != NULL)) {
+ if (!dump_opts.disable_compact_subset && ((brace = HDstrrchr(dset, '[')) != NULL)) {
*brace++ = '\0';
s = (struct subset_t *)HDcalloc(1, sizeof(struct subset_t));
@@ -708,21 +634,24 @@ parse_subset_params(char *dset)
while (*brace && *brace != ';')
brace++;
- if (*brace) brace++;
+ if (*brace)
+ brace++;
parse_hsize_list(brace, &s->stride);
while (*brace && *brace != ';')
brace++;
- if (*brace) brace++;
+ if (*brace)
+ brace++;
parse_hsize_list(brace, &s->count);
while (*brace && *brace != ';')
brace++;
- if (*brace) brace++;
+ if (*brace)
+ brace++;
parse_hsize_list(brace, &s->block);
}
@@ -738,9 +667,7 @@ parse_subset_params(char *dset)
* should be at the start of the list you want to parse.
*
* Return: Success: SUCCEED
- *
* Failure: FAIL
- *
*-------------------------------------------------------------------------
*/
static int
@@ -751,11 +678,11 @@ parse_mask_list(const char *h_list)
int slength_value;
unsigned length_value;
unsigned long long temp_mask;
- const char *ptr = NULL;
+ const char * ptr = NULL;
/* sanity check */
- if(h_list) {
- HDmemset(packed_mask,0,sizeof(packed_mask));
+ if (h_list) {
+ HDmemset(packed_mask, 0, sizeof(packed_mask));
packed_bits_num = 0;
/* scan in pair of offset,length separated by commas. */
@@ -767,10 +694,10 @@ parse_mask_list(const char *h_list)
return FAIL;
}
soffset_value = HDatoi(ptr);
- offset_value = (unsigned)soffset_value;
+ offset_value = (unsigned)soffset_value;
if (soffset_value < 0 || offset_value >= PACKED_BITS_SIZE_MAX) {
- error_msg("Packed Bit offset value(%d) must be between 0 and %u\n",
- soffset_value, (unsigned)(PACKED_BITS_SIZE_MAX - 1));
+ error_msg("Packed Bit offset value(%d) must be between 0 and %u\n", soffset_value,
+ (unsigned)(PACKED_BITS_SIZE_MAX - 1));
return FAIL;
}
@@ -796,7 +723,7 @@ parse_mask_list(const char *h_list)
length_value = (unsigned)slength_value;
if ((offset_value + length_value) > PACKED_BITS_SIZE_MAX) {
error_msg("Packed Bit offset+length value(%u) too large. Max is %u\n",
- offset_value+length_value, (unsigned)PACKED_BITS_SIZE_MAX);
+ offset_value + length_value, (unsigned)PACKED_BITS_SIZE_MAX);
return FAIL;
}
@@ -816,8 +743,8 @@ parse_mask_list(const char *h_list)
/* After packed_mask is calculated, packed_length is not needed but */
/* keep it for debug purpose. */
temp_mask = ~0ULL;
- if(length_value < (int)(8 *sizeof(unsigned long long))) {
- temp_mask = temp_mask << length_value;
+ if (length_value < (int)(8 * sizeof(unsigned long long))) {
+ temp_mask = temp_mask << length_value;
packed_mask[packed_bits_num] = ~temp_mask;
}
else
@@ -833,7 +760,7 @@ parse_mask_list(const char *h_list)
}
}
}
- if(packed_bits_num > PACKED_BITS_MAX) {
+ if (packed_bits_num > PACKED_BITS_MAX) {
error_msg("Maximum number of packed bits exceeded\n");
return FAIL;
}
@@ -844,13 +771,12 @@ parse_mask_list(const char *h_list)
}
return SUCCEED;
}
- else {
+ else {
error_msg("Bad mask list argument\n");
return FAIL;
}
}
-
/*-------------------------------------------------------------------------
* Function: free_handler
*
@@ -859,12 +785,6 @@ parse_mask_list(const char *h_list)
* to free
*
* Return: Nothing
- *
- * Programmer: Bill Wendling
- * Tuesday, 20. February 2001
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static void
@@ -872,25 +792,25 @@ free_handler(struct handler_t *hand, int len)
{
int i;
- if(hand) {
+ if (hand) {
for (i = 0; i < len; i++) {
- if(hand[i].obj) {
+ if (hand[i].obj) {
HDfree(hand[i].obj);
- hand[i].obj=NULL;
+ hand[i].obj = NULL;
}
if (hand[i].subset_info) {
- if(hand[i].subset_info->start.data)
+ if (hand[i].subset_info->start.data)
HDfree(hand[i].subset_info->start.data);
- if(hand[i].subset_info->stride.data)
+ if (hand[i].subset_info->stride.data)
HDfree(hand[i].subset_info->stride.data);
- if(hand[i].subset_info->count.data)
+ if (hand[i].subset_info->count.data)
HDfree(hand[i].subset_info->count.data);
- if(hand[i].subset_info->block.data)
+ if (hand[i].subset_info->block.data)
HDfree(hand[i].subset_info->block.data);
HDfree(hand[i].subset_info);
- hand[i].subset_info=NULL;
+ hand[i].subset_info = NULL;
}
}
@@ -898,7 +818,6 @@ free_handler(struct handler_t *hand, int len)
}
}
-
/*-------------------------------------------------------------------------
* Function: parse_command_line
*
@@ -907,544 +826,484 @@ free_handler(struct handler_t *hand, int len)
* Return: Success: A pointer to an array of handler_t structures.
* These contain all the information needed to dump
* the necessary object.
- *
* Failure: Exits program with EXIT_FAILURE value.
- *
- * Programmer: Bill Wendling
- * Tuesday, 20. February 2001
- *
- * Modifications:
- * pvn June, 1, 2006. Add a switch for binary output
- *
*-------------------------------------------------------------------------
*/
static struct handler_t *
-parse_command_line(int argc, const char *argv[])
+parse_command_line(int argc, const char *const *argv)
{
- struct handler_t *hand = NULL;
- struct handler_t *last_dset = NULL;
- int i;
- int opt;
- int last_was_dset = FALSE;
+ struct handler_t *hand = NULL;
+ struct handler_t *last_dset = NULL;
+ int i;
+ int opt;
+ int last_was_dset = FALSE;
- /* no arguments */
+ /* no arguments */
if (argc == 1) {
usage(h5tools_getprogname());
goto error;
}
/* this will be plenty big enough to hold the info */
- if((hand = (struct handler_t *)HDcalloc((size_t)argc, sizeof(struct handler_t)))==NULL) {
+ if ((hand = (struct handler_t *)HDcalloc((size_t)argc, sizeof(struct handler_t))) == NULL) {
goto error;
}
/* parse command line options */
- while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) {
+ while ((opt = H5_get_option(argc, argv, s_opts, l_opts)) != EOF) {
parse_start:
switch ((char)opt) {
- case 'R':
- display_region = TRUE;
- region_output = TRUE;
- break;
- case 'B':
- display_bb = TRUE;
- last_was_dset = FALSE;
- break;
- case 'n':
- display_fi = TRUE;
- last_was_dset = FALSE;
- if (opt_arg != NULL)
- h5trav_set_verbose(HDatoi(opt_arg));
- break;
- case 'p':
- display_dcpl = TRUE;
- break;
- case 'y':
- display_ai = FALSE;
- break;
- case 'e':
- display_escape = TRUE;
- break;
- case 'H':
- display_data = FALSE;
- display_attr_data = FALSE;
- last_was_dset = FALSE;
- break;
- case 'A':
- if (opt_arg != NULL) {
- if(0 == HDatoi(opt_arg))
- include_attrs = FALSE;
- }
- else {
- display_data = FALSE;
- display_attr_data = TRUE;
- last_was_dset = FALSE;
- }
- break;
- case 'i':
- display_oid = TRUE;
- last_was_dset = FALSE;
- break;
- case 'r':
- display_char = TRUE;
- break;
- case 'V':
- print_version(h5tools_getprogname());
- free_handler(hand, argc);
- hand = NULL;
- h5tools_setstatus(EXIT_SUCCESS);
- goto done;
- break;
- case 'w':
- {
- int sh5tools_nCols = HDatoi(opt_arg);
+ case 'R':
+ dump_opts.display_region = TRUE;
+ region_output = TRUE;
+ break;
+ case 'B':
+ dump_opts.display_bb = TRUE;
+ last_was_dset = FALSE;
+ break;
+ case 'n':
+ dump_opts.display_fi = TRUE;
+ last_was_dset = FALSE;
+ if (H5_optarg != NULL)
+ h5trav_set_verbose(HDatoi(H5_optarg));
+ break;
+ case 'p':
+ dump_opts.display_dcpl = TRUE;
+ break;
+ case 'y':
+ dump_opts.display_ai = FALSE;
+ break;
+ case 'e':
+ dump_opts.display_escape = TRUE;
+ break;
+ case 'H':
+ dump_opts.display_data = FALSE;
+ dump_opts.display_attr_data = FALSE;
+ last_was_dset = FALSE;
+ break;
+ case 'A':
+ if (H5_optarg != NULL) {
+ if (0 == HDatoi(H5_optarg))
+ dump_opts.include_attrs = FALSE;
+ }
+ else {
+ dump_opts.display_data = FALSE;
+ dump_opts.display_attr_data = TRUE;
+ last_was_dset = FALSE;
+ }
+ break;
+ case 'i':
+ dump_opts.display_oid = TRUE;
+ last_was_dset = FALSE;
+ break;
+ case 'r':
+ dump_opts.display_char = TRUE;
+ break;
+ case 'V':
+ print_version(h5tools_getprogname());
+ free_handler(hand, argc);
+ hand = NULL;
+ h5tools_setstatus(EXIT_SUCCESS);
+ goto done;
+ break;
+ case 'w': {
+ int sh5tools_nCols = HDatoi(H5_optarg);
if (sh5tools_nCols <= 0)
h5tools_nCols = 65535;
else
h5tools_nCols = (unsigned)sh5tools_nCols;
last_was_dset = FALSE;
- }
- break;
- case 'N':
- display_all = 0;
-
- for (i = 0; i < argc; i++)
- if (!hand[i].func) {
- hand[i].func = handle_paths;
- hand[i].obj = HDstrdup(opt_arg);
- break;
- }
-
- last_was_dset = FALSE;
- break;
- case 'a':
- display_all = 0;
+ } break;
+ case 'N':
+ dump_opts.display_all = 0;
+
+ for (i = 0; i < argc; i++)
+ if (!hand[i].func) {
+ hand[i].func = handle_paths;
+ hand[i].obj = HDstrdup(H5_optarg);
+ break;
+ }
- for (i = 0; i < argc; i++)
- if (!hand[i].func) {
- hand[i].func = handle_attributes;
- hand[i].obj = HDstrdup(opt_arg);
- break;
- }
+ last_was_dset = FALSE;
+ break;
+ case 'a':
+ dump_opts.display_all = 0;
+
+ for (i = 0; i < argc; i++)
+ if (!hand[i].func) {
+ hand[i].func = handle_attributes;
+ hand[i].obj = HDstrdup(H5_optarg);
+ break;
+ }
- last_was_dset = FALSE;
- break;
- case 'd':
- display_all = 0;
-
- for (i = 0; i < argc; i++)
- if (!hand[i].func) {
- hand[i].func = handle_datasets;
- hand[i].obj = HDstrdup(opt_arg);
- hand[i].subset_info = parse_subset_params(hand[i].obj);
- last_dset = &hand[i];
- break;
- }
+ last_was_dset = FALSE;
+ break;
+ case 'd':
+ dump_opts.display_all = 0;
+
+ for (i = 0; i < argc; i++)
+ if (!hand[i].func) {
+ hand[i].func = handle_datasets;
+ hand[i].obj = HDstrdup(H5_optarg);
+ hand[i].subset_info = parse_subset_params(hand[i].obj);
+ last_dset = &hand[i];
+ break;
+ }
- last_was_dset = TRUE;
- break;
- case 'f':
- driver = opt_arg;
- break;
- case 'g':
- display_all = 0;
-
- for (i = 0; i < argc; i++)
- if (!hand[i].func) {
- hand[i].func = handle_groups;
- hand[i].obj = HDstrdup(opt_arg);
- break;
- }
+ last_was_dset = TRUE;
+ break;
+ case 'f':
+ vfd_info_g.type = VFD_BY_NAME;
+ vfd_info_g.u.name = H5_optarg;
+ vfd_info_g.info = NULL;
+ use_custom_vfd_g = TRUE;
+ break;
+ case 'g':
+ dump_opts.display_all = 0;
+
+ for (i = 0; i < argc; i++)
+ if (!hand[i].func) {
+ hand[i].func = handle_groups;
+ hand[i].obj = HDstrdup(H5_optarg);
+ break;
+ }
- last_was_dset = FALSE;
- break;
- case 'l':
- display_all = 0;
+ last_was_dset = FALSE;
+ break;
+ case 'l':
+ dump_opts.display_all = 0;
+
+ for (i = 0; i < argc; i++)
+ if (!hand[i].func) {
+ hand[i].func = handle_links;
+ hand[i].obj = HDstrdup(H5_optarg);
+ break;
+ }
- for (i = 0; i < argc; i++)
- if (!hand[i].func) {
- hand[i].func = handle_links;
- hand[i].obj = HDstrdup(opt_arg);
- break;
- }
+ last_was_dset = FALSE;
+ break;
+ case 't':
+ dump_opts.display_all = 0;
+
+ for (i = 0; i < argc; i++)
+ if (!hand[i].func) {
+ hand[i].func = handle_datatypes;
+ hand[i].obj = HDstrdup(H5_optarg);
+ break;
+ }
- last_was_dset = FALSE;
- break;
- case 't':
- display_all = 0;
+ last_was_dset = FALSE;
+ break;
- for (i = 0; i < argc; i++)
- if (!hand[i].func) {
- hand[i].func = handle_datatypes;
- hand[i].obj = HDstrdup(opt_arg);
- break;
+ case 'O':
+ if (h5tools_set_output_file(H5_optarg, 0) < 0) {
+ usage(h5tools_getprogname());
+ goto error;
}
+ break;
- last_was_dset = FALSE;
- break;
+ case 'o':
+ if (bin_output) {
+ if (h5tools_set_data_output_file(H5_optarg, 1) < 0) {
+ usage(h5tools_getprogname());
+ goto error;
+ }
+ }
+ else {
+ if (dump_opts.display_attr_data && !dump_opts.display_data) {
+ if (h5tools_set_attr_output_file(H5_optarg, 0) < 0) {
+ usage(h5tools_getprogname());
+ goto error;
+ }
+ }
+ if (dump_opts.display_data || dump_opts.display_all) {
+ if (h5tools_set_data_output_file(H5_optarg, 0) < 0) {
+ usage(h5tools_getprogname());
+ goto error;
+ }
+ }
+ }
- case 'O':
- if (h5tools_set_output_file(opt_arg, 0) < 0) {
- usage(h5tools_getprogname());
- goto error;
- }
- break;
+ dump_opts.usingdasho = TRUE;
+ last_was_dset = FALSE;
+ outfname_g = H5_optarg;
+ break;
- case 'o':
- if (bin_output) {
- if (h5tools_set_data_output_file(opt_arg, 1) < 0) {
- usage(h5tools_getprogname());
- goto error;
- }
- }
- else {
- if(display_attr_data && !display_data) {
- if (h5tools_set_attr_output_file(opt_arg, 0) < 0) {
+ case 'b':
+ if (H5_optarg != NULL) {
+ if ((bin_form = set_binary_form(H5_optarg)) < 0) {
+ /* failed to set binary form */
usage(h5tools_getprogname());
goto error;
}
}
- if(display_data || display_all) {
- if (h5tools_set_data_output_file(opt_arg, 0) < 0) {
+ bin_output = TRUE;
+ if (outfname_g != NULL) {
+ if (h5tools_set_data_output_file(outfname_g, 1) < 0) {
+ /* failed to set output file */
usage(h5tools_getprogname());
goto error;
}
+
+ last_was_dset = FALSE;
}
- }
+ break;
- usingdasho = TRUE;
- last_was_dset = FALSE;
- outfname = opt_arg;
- break;
+ case 'q':
+ if ((sort_by = set_sort_by(H5_optarg)) < 0) {
+ /* failed to set "sort by" form */
+ usage(h5tools_getprogname());
+ goto error;
+ }
+ break;
- case 'b':
- if (opt_arg != NULL) {
- if ((bin_form = set_binary_form(opt_arg)) < 0) {
- /* failed to set binary form */
+ case 'z':
+ if ((sort_order = set_sort_order(H5_optarg)) < 0) {
+ /* failed to set "sort order" form */
usage(h5tools_getprogname());
goto error;
}
- }
- bin_output = TRUE;
- if (outfname!=NULL) {
- if (h5tools_set_data_output_file(outfname, 1) < 0) {
- /* failed to set output file */
+ break;
+
+ case 'M':
+ if (!last_was_dset) {
+ error_msg("option \"-%c\" can only be used after --dataset option\n", opt);
+ goto error;
+ }
+ if (parse_mask_list(H5_optarg) != SUCCEED) {
+ usage(h5tools_getprogname());
+ goto error;
+ }
+ dump_opts.display_packed_bits = TRUE;
+ break;
+ case 'v':
+ dump_opts.display_vds_first = TRUE;
+ break;
+ case 'G':
+ dump_opts.vds_gap_size = HDatoi(H5_optarg);
+ if (dump_opts.vds_gap_size < 0) {
usage(h5tools_getprogname());
goto error;
}
+ break;
- last_was_dset = FALSE;
- }
- break;
+ /** begin XML parameters **/
+ case 'x':
+ /* select XML output */
+ doxml_g = TRUE;
+ useschema_g = TRUE;
+ h5tools_dump_header_format = NULL;
+ dump_function_table = &xml_function_table;
+ h5tools_nCols = 0;
+ break;
+ case 'u':
+ doxml_g = TRUE;
+ useschema_g = FALSE;
+ xmlnsprefix = "";
+ h5tools_dump_header_format = NULL;
+ dump_function_table = &xml_function_table;
+ h5tools_nCols = 0;
+ break;
+ case 'D':
+ /* specify alternative XML DTD or schema */
+ /* To Do: check format of this value? */
+ xml_dtd_uri_g = H5_optarg;
+ h5tools_nCols = 0;
+ break;
- case 'q':
- if ((sort_by = set_sort_by(opt_arg)) < 0) {
- /* failed to set "sort by" form */
- usage(h5tools_getprogname());
- goto error;
- }
- break;
+ case 'm':
+ /* specify alternative floating point printing format */
+ fp_format = H5_optarg;
+ h5tools_nCols = 0;
+ break;
- case 'z':
- if ((sort_order = set_sort_order(opt_arg)) < 0) {
- /* failed to set "sort order" form */
- usage(h5tools_getprogname());
- goto error;
- }
- break;
+ case 'X':
+ /* specify XML namespace (default="hdf5:"), or none */
+ /* To Do: check format of this value? */
+ if (!useschema_g) {
+ usage(h5tools_getprogname());
+ goto error;
+ }
+ if (HDstrcmp(H5_optarg, ":") == 0)
+ xmlnsprefix = "";
+ else
+ xmlnsprefix = H5_optarg;
+ h5tools_nCols = 0;
+ break;
+ /** end XML parameters **/
- case 'M':
- if (!last_was_dset) {
- error_msg("option `-%c' can only be used after --dataset option\n", opt);
- goto error;
- }
- if (parse_mask_list(opt_arg) != SUCCEED){
- usage(h5tools_getprogname());
- goto error;
- }
- display_packed_bits = TRUE;
- break;
- case 'v':
- display_vds_first = TRUE;
- break;
- case 'G':
- vds_gap_size = HDatoi(opt_arg);
- if (vds_gap_size < 0) {
- usage(h5tools_getprogname());
- goto error;
- }
- break;
-
- /** begin XML parameters **/
- case 'x':
- /* select XML output */
- doxml = TRUE;
- useschema = TRUE;
- h5tools_dump_header_format = NULL;
- dump_function_table = &xml_function_table;
- h5tools_nCols = 0;
- break;
- case 'u':
- doxml = TRUE;
- useschema = FALSE;
- xmlnsprefix = "";
- h5tools_dump_header_format = NULL;
- dump_function_table = &xml_function_table;
- h5tools_nCols = 0;
- break;
- case 'D':
- /* specify alternative XML DTD or schema */
- /* To Do: check format of this value? */
- xml_dtd_uri = opt_arg;
- h5tools_nCols = 0;
- break;
-
- case 'm':
- /* specify alternative floating point printing format */
- fp_format = opt_arg;
- h5tools_nCols = 0;
- break;
-
- case 'X':
- /* specify XML namespace (default="hdf5:"), or none */
- /* To Do: check format of this value? */
- if (!useschema) {
- usage(h5tools_getprogname());
- goto error;
- }
- if (HDstrcmp(opt_arg,":") == 0)
- xmlnsprefix = "";
- else
- xmlnsprefix = opt_arg;
- h5tools_nCols = 0;
- break;
- /** end XML parameters **/
-
- /** begin subsetting parameters **/
- case 's':
- case 'S':
- case 'c':
- case 'k': {
- struct subset_t *s;
-
- if (!last_was_dset) {
- error_msg("option `-%c' can only be used after --dataset option\n", opt);
- goto error;
- }
+ /** begin subsetting parameters **/
+ case 's':
+ case 'S':
+ case 'c':
+ case 'k': {
+ struct subset_t *s;
+
+ if (!last_was_dset) {
+ error_msg("option \"-%c\" can only be used after --dataset option\n", opt);
+ goto error;
+ }
+
+ if (last_dset->subset_info) {
+ /*
+ * This overrides the "terse" syntax if they actually mixed
+ * the two.
+ */
+ s = last_dset->subset_info;
+ }
+ else {
+ last_dset->subset_info = s = (struct subset_t *)HDcalloc(1, sizeof(struct subset_t));
+ }
- if (last_dset->subset_info) {
/*
- * This overrides the "terse" syntax if they actually mixed
- * the two.
+ * slightly convoluted, but...we are only interested in options
+ * for subsetting: "--start", "--stride", "--count", and "--block"
+ * which can come in any order. If we run out of parameters (EOF)
+ * or run into one which isn't a subsetting parameter (NOT s, S,
+ * c, or K), then we exit the do-while look, set the subset_info
+ * to the structure we've been filling. If we've reached the end
+ * of the options, we exit the parsing (goto parse_end) otherwise,
+ * since we've "read" the next option, we need to parse it. So we
+ * jump to the beginning of the switch statement (goto parse_start).
*/
- s = last_dset->subset_info;
- }
- else {
- last_dset->subset_info = s = (struct subset_t *)HDcalloc(1, sizeof(struct subset_t));
- }
-
- /*
- * slightly convoluted, but...we are only interested in options
- * for subsetting: "--start", "--stride", "--count", and "--block"
- * which can come in any order. If we run out of parameters (EOF)
- * or run into one which isn't a subsetting parameter (NOT s, S,
- * c, or K), then we exit the do-while look, set the subset_info
- * to the structure we've been filling. If we've reached the end
- * of the options, we exit the parsing (goto parse_end) otherwise,
- * since we've "read" the next option, we need to parse it. So we
- * jump to the beginning of the switch statement (goto parse_start).
- */
- do {
- switch ((char)opt) {
- case 's':
- if (s->start.data) {
- HDfree(s->start.data);
- s->start.data = NULL;
- }
- parse_hsize_list(opt_arg, &s->start);
- break;
- case 'S':
- if (s->stride.data) {
- HDfree(s->stride.data);
- s->stride.data = NULL;
- }
- parse_hsize_list(opt_arg, &s->stride);
- break;
- case 'c':
- if (s->count.data) {
- HDfree(s->count.data);
- s->count.data = NULL;
+ do {
+ switch ((char)opt) {
+ case 's':
+ if (s->start.data) {
+ HDfree(s->start.data);
+ s->start.data = NULL;
+ }
+ parse_hsize_list(H5_optarg, &s->start);
+ break;
+ case 'S':
+ if (s->stride.data) {
+ HDfree(s->stride.data);
+ s->stride.data = NULL;
+ }
+ parse_hsize_list(H5_optarg, &s->stride);
+ break;
+ case 'c':
+ if (s->count.data) {
+ HDfree(s->count.data);
+ s->count.data = NULL;
+ }
+ parse_hsize_list(H5_optarg, &s->count);
+ break;
+ case 'k':
+ if (s->block.data) {
+ HDfree(s->block.data);
+ s->block.data = NULL;
+ }
+ parse_hsize_list(H5_optarg, &s->block);
+ break;
+ default:
+ goto end_collect;
}
- parse_hsize_list(opt_arg, &s->count);
- break;
- case 'k':
- if (s->block.data) {
- HDfree(s->block.data);
- s->block.data = NULL;
- }
- parse_hsize_list(opt_arg, &s->block);
- break;
- default:
- goto end_collect;
- }
- } while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF);
+ } while ((opt = H5_get_option(argc, argv, s_opts, l_opts)) != EOF);
end_collect:
- last_was_dset = FALSE;
+ last_was_dset = FALSE;
- if (opt != EOF)
- goto parse_start;
- else
- goto parse_end;
- }
- /** end subsetting parameters **/
+ if (opt != EOF)
+ goto parse_start;
+ else
+ goto parse_end;
+ }
+ /** end subsetting parameters **/
- case 'E':
- if (opt_arg != NULL)
- enable_error_stack = HDatoi(opt_arg);
- else
- enable_error_stack = 1;
- break;
- case 'C':
- disable_compact_subset = TRUE;
- break;
- case 'h':
- usage(h5tools_getprogname());
- free_handler(hand, argc);
- hand = NULL;
- h5tools_setstatus(EXIT_SUCCESS);
- goto done;
+ case 'E':
+ if (H5_optarg != NULL)
+ enable_error_stack = HDatoi(H5_optarg);
+ else
+ enable_error_stack = 1;
+ break;
+ case 'C':
+ dump_opts.disable_compact_subset = TRUE;
+ break;
+ case 'h':
+ usage(h5tools_getprogname());
+ free_handler(hand, argc);
+ hand = NULL;
+ h5tools_setstatus(EXIT_SUCCESS);
+ goto done;
- case '$':
-#ifndef H5_HAVE_ROS3_VFD
- error_msg("Read-Only S3 VFD not enabled.\n");
- h5tools_setstatus(EXIT_FAILURE);
- goto done;
-#else
- /* s3 credential */
- {
- char **s3_cred = NULL;
- char *s3_cred_string = NULL;
- const char *ccred[3];
- unsigned nelems = 0;
- if ( FAIL ==
- parse_tuple(opt_arg, ',',
- &s3_cred_string, &nelems, &s3_cred))
- {
- error_msg("unable to parse malformed s3 credentials\n");
- usage(h5tools_getprogname());
- free_handler(hand, argc);
- hand= NULL;
- h5tools_setstatus(EXIT_FAILURE);
- goto done;
- }
- if (nelems != 3) {
- error_msg("s3 credentials expects 3 elements\n");
+ case '$':
+#ifdef H5_HAVE_ROS3_VFD
+ if (h5tools_parse_ros3_fapl_tuple(H5_optarg, ',', &ros3_fa_g) < 0) {
+ error_msg("failed to parse S3 VFD credential info\n");
usage(h5tools_getprogname());
free_handler(hand, argc);
- hand= NULL;
+ hand = NULL;
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
- ccred[0] = (const char *)s3_cred[0];
- ccred[1] = (const char *)s3_cred[1];
- ccred[2] = (const char *)s3_cred[2];
- if (0 == h5tools_populate_ros3_fapl(&ros3_fa, ccred)) {
- error_msg("Invalid S3 credentials\n");
+#else
+ error_msg("Read-Only S3 VFD not enabled.\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+#endif
+ break;
+
+ case '#':
+#ifdef H5_HAVE_LIBHDFS
+ if (h5tools_parse_hdfs_fapl_tuple(H5_optarg, ',', &hdfs_fa_g) < 0) {
+ error_msg("failed to parse HDFS VFD configuration info\n");
usage(h5tools_getprogname());
free_handler(hand, argc);
- hand= NULL;
+ hand = NULL;
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
- HDfree(s3_cred);
- HDfree(s3_cred_string);
- } /* s3 credential block */
- break;
-#endif /* H5_HAVE_ROS3_VFD */
-
- case '#':
-#ifndef H5_HAVE_LIBHDFS
- error_msg("HDFS VFD is not enabled.\n");
- goto error;
#else
- {
- /* read hdfs properties tuple and store values in `hdfs_fa`
- */
- unsigned nelems = 0;
- char *props_src = NULL;
- char **props = NULL;
- unsigned long k = 0;
- if (FAIL == parse_tuple(
- (const char *)opt_arg,
- ',',
- &props_src,
- &nelems,
- &props))
- {
- error_msg("unable to parse hdfs properties tuple\n");
- goto error;
- }
- /* sanity-check tuple count
- */
- if (nelems != 5) {
- h5tools_setstatus(EXIT_FAILURE);
- goto error;
- }
- /* Populate fapl configuration structure with given
- * properties.
- * WARNING: No error-checking is done on length of input
- * strings... Silent overflow is possible, albeit
- * unlikely.
- */
- if (strncmp(props[0], "", 1)) {
- HDstrncpy(hdfs_fa.namenode_name,
- (const char *)props[0],
- HDstrlen(props[0]));
- }
- if (strncmp(props[1], "", 1)) {
- k = strtoul((const char *)props[1], NULL, 0);
- if (errno == ERANGE) {
- h5tools_setstatus(EXIT_FAILURE);
- goto error;
- }
- hdfs_fa.namenode_port = (int32_t)k;
- }
- if (strncmp(props[2], "", 1)) {
- HDstrncpy(hdfs_fa.kerberos_ticket_cache,
- (const char *)props[2],
- HDstrlen(props[2]));
- }
- if (strncmp(props[3], "", 1)) {
- HDstrncpy(hdfs_fa.user_name,
- (const char *)props[3],
- HDstrlen(props[3]));
- }
- if (strncmp(props[4], "", 1)) {
- k = strtoul((const char *)props[4], NULL, 0);
- if (errno == ERANGE) {
- h5tools_setstatus(EXIT_FAILURE);
- goto error;
- }
- hdfs_fa.stream_buffer_size = (int32_t)k;
- }
- HDfree(props);
- HDfree(props_src);
- }
-#endif /* H5_HAVE_LIBHDFS */
- break;
+ error_msg("HDFS VFD not enabled.\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+#endif
+ break;
- case '?':
- default:
- usage(h5tools_getprogname());
- goto error;
+ case '1':
+ vol_info_g.type = VOL_BY_VALUE;
+ vol_info_g.u.value = (H5VL_class_value_t)HDatoi(H5_optarg);
+ use_custom_vol_g = TRUE;
+ break;
+
+ case '2':
+ vol_info_g.type = VOL_BY_NAME;
+ vol_info_g.u.name = H5_optarg;
+ use_custom_vol_g = TRUE;
+ break;
+
+ case '3':
+ vol_info_g.info_string = H5_optarg;
+ break;
+
+ case '4':
+ vfd_info_g.type = VFD_BY_VALUE;
+ vfd_info_g.u.value = (H5FD_class_value_t)HDatoi(H5_optarg);
+ use_custom_vfd_g = TRUE;
+ break;
+
+ case '5':
+ vfd_info_g.type = VFD_BY_NAME;
+ vfd_info_g.u.name = H5_optarg;
+ use_custom_vfd_g = TRUE;
+ break;
+
+ case '6':
+ vfd_info_g.info = (const void *)H5_optarg;
+ break;
+
+ case '?':
+ default:
+ usage(h5tools_getprogname());
+ goto error;
}
}
parse_end:
/* check for file name to be processed */
- if (argc <= opt_ind) {
+ if (argc <= H5_optind) {
error_msg("missing file name\n");
usage(h5tools_getprogname());
goto error;
@@ -1462,7 +1321,6 @@ error:
return hand;
}
-
/*-------------------------------------------------------------------------
* Function: main
*
@@ -1470,180 +1328,99 @@ error:
*
* Return: Success: 0
* Failure: 1
- *
- * Programmer: Ruey-Hsia Li
- *
- * Modifications:
- * Albert Cheng
- * 30. September 2000
- * Add the -o option--output file for datasets raw data
- *
- * REMcG
- * November 2000
- * Changes to support XML.
- *
- * Bill Wendling
- * Wednesday, 10. January 2001
- * Modified the way command line parameters are interpreted. They go
- * through one function call now (get_option).
- *
- * Bill Wendling
- * Tuesday, 20. February 2001
- * Moved command line parsing to separate function. Made various
- * "display_*" flags global.
- *
- * REMcG
- * August 2003
- * Major upgrade to XML support.
- *
- * Pedro Vicente
- * September 2007
- * list objects in requested order (creation order or alphabetically)
- *
*-------------------------------------------------------------------------
*/
int
-main(int argc, const char *argv[])
+main(int argc, char *argv[])
{
- hid_t fid = -1;
- hid_t gid = -1;
- hid_t fapl_id = H5P_DEFAULT;
- H5E_auto2_t func;
- H5E_auto2_t tools_func;
- H5O_info_t oi;
- struct handler_t *hand = NULL;
- int i;
- unsigned u;
- void *edata;
- void *tools_edata;
- char *fname = NULL;
+ hid_t fid = H5I_INVALID_HID;
+ hid_t gid = H5I_INVALID_HID;
+ hid_t fapl_id = H5P_DEFAULT;
+ H5O_info2_t oi;
+ struct handler_t *hand = NULL;
+ int i;
+ unsigned u;
+ char * fname = NULL;
h5tools_setprogname(PROGRAMNAME);
h5tools_setstatus(EXIT_SUCCESS);
h5tools_dump_header_format = &h5tools_standardformat;
- dump_function_table = &ddl_function_table;
- dump_indent = 0;
-
- /* Disable error reporting */
- H5Eget_auto2(H5E_DEFAULT, &func, &edata);
- H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
+ dump_function_table = &ddl_function_table;
+ dump_indent = 0;
/* 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);
-
- if((hand = parse_command_line(argc, argv))==NULL) {
+ if ((hand = parse_command_line(argc, (const char *const *)argv)) == NULL) {
goto done;
}
- if (bin_output && outfname == NULL) {
+ if (bin_output && outfname_g == NULL) {
error_msg("binary output requires a file name, use -o <filename>\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
- if (enable_error_stack > 0) {
- H5Eset_auto2(H5E_DEFAULT, func, edata);
- H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata);
- }
-
/* Check for conflicting options */
- if (doxml) {
- if (!display_all) {
- error_msg("option \"%s\" not available for XML\n",
- "to display selected objects");
+ if (doxml_g) {
+ if (!dump_opts.display_all) {
+ error_msg("option \"%s\" not available for XML\n", "to display selected objects");
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
- else if (display_bb) {
+ else if (dump_opts.display_bb) {
error_msg("option \"%s\" not available for XML\n", "--boot-block");
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
- else if (display_oid == 1) {
+ else if (dump_opts.display_oid == 1) {
error_msg("option \"%s\" not available for XML\n", "--object-ids");
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
- else if (display_char == TRUE) {
+ else if (dump_opts.display_char == TRUE) {
error_msg("option \"%s\" not available for XML\n", "--string");
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
- else if (usingdasho) {
+ else if (dump_opts.usingdasho) {
error_msg("option \"%s\" not available for XML\n", "--output");
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
}
else {
- if (xml_dtd_uri) {
- warn_msg("option \"%s\" only applies with XML: %s\n", "--xml-dtd", xml_dtd_uri);
+ if (xml_dtd_uri_g) {
+ warn_msg("option \"%s\" only applies with XML: %s\n", "--xml-dtd", xml_dtd_uri_g);
}
}
- if (argc <= opt_ind) {
+ if (argc <= H5_optind) {
error_msg("missing file name\n");
usage(h5tools_getprogname());
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
+
+ /* enable error reporting if command line option */
+ h5tools_error_report();
+
/* Initialize indexing options */
h5trav_set_index(sort_by, sort_order);
- if (driver != NULL) {
- void *conf_fa = NULL;
-
- if (!strcmp(driver, "ros3")) {
-#ifndef H5_HAVE_ROS3_VFD
- error_msg("Read-Only S3 VFD not enabled.\n");
+ if (use_custom_vol_g || use_custom_vfd_g) {
+ if ((fapl_id = h5tools_get_fapl(H5P_DEFAULT, use_custom_vol_g ? &vol_info_g : NULL,
+ use_custom_vfd_g ? &vfd_info_g : NULL)) < 0) {
+ error_msg("unable to create FAPL for file access\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
-#else
- conf_fa = (void *)&ros3_fa;
-#endif /* H5_HAVE_ROS3_VFD */
- } else if (!HDstrcmp(driver, "hdfs")) {
-#ifndef H5_HAVE_LIBHDFS
- error_msg("HDFS VFD is not enabled.\n");
- h5tools_setstatus(EXIT_FAILURE);
- goto done;
-#else
- conf_fa = (void *)&hdfs_fa;
-#endif /* H5_HAVE_LIBHDFS */
}
+ }
- if (conf_fa != NULL) {
- fapl_id = H5Pcreate(H5P_FILE_ACCESS);
- if (fapl_id < 0) {
- error_msg("unable to create fapl entry\n");
- h5tools_setstatus(EXIT_FAILURE);
- goto done;
- }
- if (0 == h5tools_set_configured_fapl(
- fapl_id,
- driver, /* guaranteed "ros3" or "hdfs" */
- conf_fa)) /* appropriate to driver */
- {
- error_msg("unable to set fapl\n");
- h5tools_setstatus(EXIT_FAILURE);
- goto done;
- }
- }
- } /* driver defined */
-
- while(opt_ind < argc) {
- fname = HDstrdup(argv[opt_ind++]);
+ while (H5_optind < argc) {
+ fname = HDstrdup(argv[H5_optind++]);
- if (fapl_id != H5P_DEFAULT) {
- fid = H5Fopen(fname, H5F_ACC_RDONLY, fapl_id);
- }
- else {
- fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT,
- driver, NULL, 0);
- }
+ fid = h5tools_fopen(fname, H5F_ACC_RDONLY, fapl_id, (fapl_id != H5P_DEFAULT), NULL, 0);
if (fid < 0) {
error_msg("unable to open file \"%s\"\n", fname);
@@ -1657,24 +1434,25 @@ main(int argc, const char *argv[])
/* Prepare to find objects that might be targets of a reference */
fill_ref_path_table(fid);
- if(doxml) {
+ if (doxml_g) {
/* initialize XML */
/* reset prefix! */
HDstrcpy(prefix, "");
/* make sure the URI is initialized to something */
- if (xml_dtd_uri == NULL) {
- if (useschema) {
- xml_dtd_uri = DEFAULT_XSD;
+ if (xml_dtd_uri_g == NULL) {
+ if (useschema_g) {
+ xml_dtd_uri_g = DEFAULT_XSD;
}
else {
- xml_dtd_uri = DEFAULT_DTD;
- xmlnsprefix = "";
+ xml_dtd_uri_g = DEFAULT_DTD;
+ xmlnsprefix = "";
}
}
else {
- if (useschema && HDstrcmp(xmlnsprefix,"")) {
- error_msg("Cannot set Schema URL for a qualified namespace--use -X or -U option with -D \n");
+ if (useschema_g && HDstrcmp(xmlnsprefix, "") != 0) {
+ error_msg(
+ "Cannot set Schema URL for a qualified namespace--use -X or -U option with -D \n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
@@ -1682,23 +1460,23 @@ main(int argc, const char *argv[])
}
/* Get object info for root group */
- if(H5Oget_info_by_name2(fid, "/", &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) {
+ if (H5Oget_info_by_name3(fid, "/", &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) {
error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
/* Initialize object tables */
- if(table_list_add(fid, oi.fileno) < 0) {
+ if (table_list_add(fid, oi.fileno) < 0) {
error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
group_table = table_list.tables[0].group_table;
- dset_table = table_list.tables[0].dset_table;
- type_table = table_list.tables[0].type_table;
+ dset_table = table_list.tables[0].dset_table;
+ type_table = table_list.tables[0].type_table;
- /* does there exist unamed committed datatype */
+ /* does there exist unnamed committed datatype */
for (u = 0; u < type_table->nobjs; u++)
if (!type_table->objs[u].recorded) {
unamedtype = 1;
@@ -1706,90 +1484,96 @@ main(int argc, const char *argv[])
} /* end if */
/* start to dump - display file header information */
- if (!doxml) {
- begin_obj(h5tools_dump_header_format->filebegin, fname, h5tools_dump_header_format->fileblockbegin);
+ if (!doxml_g) {
+ begin_obj(h5tools_dump_header_format->filebegin, fname,
+ h5tools_dump_header_format->fileblockbegin);
}
else {
PRINTVALSTREAM(rawoutstream, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
/* alternative first element, depending on schema or DTD. */
- if (useschema) {
- if (HDstrcmp(xmlnsprefix,"") == 0) {
- PRINTSTREAM(rawoutstream, "<HDF5-File xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"%s\">\n",
- xml_dtd_uri);
+ if (useschema_g) {
+ if (HDstrcmp(xmlnsprefix, "") == 0) {
+ PRINTSTREAM(rawoutstream,
+ "<HDF5-File xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
+ "xsi:noNamespaceSchemaLocation=\"%s\">\n",
+ xml_dtd_uri_g);
}
else {
/* TO DO: make -url option work in this case (may need new option) */
char *ns;
char *indx;
- ns = HDstrdup(xmlnsprefix);
- indx = HDstrrchr(ns,(int)':');
- if (indx) *indx = '\0';
-
- PRINTSTREAM(rawoutstream, "<%sHDF5-File xmlns:%s=\"http://hdfgroup.org/HDF5/XML/schema/HDF5-File.xsd\" "
- "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
- "xsi:schemaLocation=\"http://hdfgroup.org/HDF5/XML/schema/HDF5-File "
- "http://www.hdfgroup.org/HDF5/XML/schema/HDF5-File.xsd\">\n",xmlnsprefix,ns);
+ ns = HDstrdup(xmlnsprefix);
+ indx = HDstrrchr(ns, (int)':');
+ if (indx)
+ *indx = '\0';
+
+ PRINTSTREAM(rawoutstream,
+ "<%sHDF5-File xmlns:%s=\"http://hdfgroup.org/HDF5/XML/schema/HDF5-File.xsd\" "
+ "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
+ "xsi:schemaLocation=\"http://hdfgroup.org/HDF5/XML/schema/HDF5-File "
+ "http://www.hdfgroup.org/HDF5/XML/schema/HDF5-File.xsd\">\n",
+ xmlnsprefix, ns);
HDfree(ns);
}
}
else {
- PRINTSTREAM(rawoutstream, "<!DOCTYPE HDF5-File PUBLIC \"HDF5-File.dtd\" \"%s\">\n", xml_dtd_uri);
+ PRINTSTREAM(rawoutstream, "<!DOCTYPE HDF5-File PUBLIC \"HDF5-File.dtd\" \"%s\">\n",
+ xml_dtd_uri_g);
PRINTVALSTREAM(rawoutstream, "<HDF5-File>\n");
}
}
- if (!doxml) {
- if (display_fi) {
+ if (!doxml_g) {
+ if (dump_opts.display_fi) {
PRINTVALSTREAM(rawoutstream, "\n");
dump_fcontents(fid);
- end_obj(h5tools_dump_header_format->fileend,h5tools_dump_header_format->fileblockend);
+ end_obj(h5tools_dump_header_format->fileend, h5tools_dump_header_format->fileblockend);
PRINTVALSTREAM(rawoutstream, "\n");
goto done;
}
- if (display_bb)
+ if (dump_opts.display_bb)
dump_fcpl(fid);
}
- if(display_all) {
- if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) {
+ if (dump_opts.display_all) {
+ if ((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) {
error_msg("unable to open root group\n");
h5tools_setstatus(EXIT_FAILURE);
}
else {
- if (!doxml)
+ if (!doxml_g)
dump_indent += COL;
- dump_function_table->dump_group_function(gid, "/" );
- if (!doxml)
+ dump_function_table->dump_group_function(gid, "/");
+ if (!doxml_g)
dump_indent -= COL;
PRINTVALSTREAM(rawoutstream, "\n");
}
- if(H5Gclose(gid) < 0) {
+ if (H5Gclose(gid) < 0) {
error_msg("unable to close root group\n");
h5tools_setstatus(EXIT_FAILURE);
}
-
}
else {
/* Note: this option is not supported for XML */
- if(doxml) {
+ if (doxml_g) {
error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
h5tools_setstatus(EXIT_FAILURE);
goto done;
} /* end if */
- for(i = 0; i < argc; i++) {
- if(hand[i].func) {
+ for (i = 0; i < argc; i++) {
+ if (hand[i].func) {
hand[i].func(fid, hand[i].obj, hand[i].subset_info, 1, NULL);
}
}
PRINTVALSTREAM(rawoutstream, "\n");
}
- if (!doxml) {
+ if (!doxml_g) {
end_obj(h5tools_dump_header_format->fileend, h5tools_dump_header_format->fileblockend);
PRINTVALSTREAM(rawoutstream, "\n");
}
@@ -1799,21 +1583,21 @@ main(int argc, const char *argv[])
/* Free tables for objects */
table_list_free();
- if(fid >=0)
+ if (fid >= 0)
if (H5Fclose(fid) < 0)
h5tools_setstatus(EXIT_FAILURE);
- if(prefix) {
+ if (prefix) {
HDfree(prefix);
prefix = NULL;
}
- if(fname) {
+ if (fname) {
HDfree(fname);
fname = NULL;
}
} /* end while */
- if(hand)
+ if (hand)
free_handler(hand, argc);
/* To Do: clean up XML table */
@@ -1829,30 +1613,27 @@ done:
h5tools_setstatus(EXIT_FAILURE);
}
- if(fid >=0)
+ if (fid >= 0)
if (H5Fclose(fid) < 0)
h5tools_setstatus(EXIT_FAILURE);
- if(prefix) {
+ if (prefix) {
HDfree(prefix);
prefix = NULL;
}
- if(fname) {
+ if (fname) {
HDfree(fname);
fname = NULL;
}
- if(hand)
+ if (hand)
free_handler(hand, argc);
/* To Do: clean up XML table */
- H5Eset_auto2(H5E_DEFAULT, func, edata);
-
leave(h5tools_getstatus());
} /* main */
-
/*-------------------------------------------------------------------------
* Function: init_prefix
*
@@ -1867,13 +1648,12 @@ done:
static void
init_prefix(char **prfx, size_t prfx_len)
{
- if(prfx_len > 0)
+ if (prfx_len > 0)
*prfx = (char *)HDcalloc(prfx_len, 1);
else
error_msg("unable to allocate prefix buffer\n");
}
-
/*-------------------------------------------------------------------------
* Function: add_prefix
*
@@ -1889,12 +1669,11 @@ add_prefix(char **prfx, size_t *prfx_len, const char *name)
size_t new_len = HDstrlen(*prfx) + HDstrlen(name) + 2;
/* Check if we need more space */
- if(*prfx_len <= new_len) {
+ if (*prfx_len <= new_len) {
*prfx_len = new_len + 1;
- *prfx = (char *)HDrealloc(*prfx, *prfx_len);
+ *prfx = (char *)HDrealloc(*prfx, *prfx_len);
}
/* Append object name to prefix */
HDstrcat(HDstrcat(*prfx, "/"), name);
} /* end add_prefix */
-
diff --git a/tools/src/h5dump/h5dump.h b/tools/src/h5dump/h5dump.h
index 801f60d..a53d1ba 100644
--- a/tools/src/h5dump/h5dump.h
+++ b/tools/src/h5dump/h5dump.h
@@ -6,12 +6,12 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#ifndef H5DUMP_H__
-#define H5DUMP_H__
+#ifndef H5DUMP_H
+#define H5DUMP_H
#include "hdf5.h"
#include "H5private.h"
@@ -26,62 +26,67 @@
**/
/* the table of dump functions */
typedef struct dump_functions_t {
- void (*dump_group_function) (hid_t, const char *);
- void (*dump_named_datatype_function) (hid_t, const char *);
- void (*dump_dataset_function) (hid_t, const char *, struct subset_t *);
- void (*dump_dataspace_function) (hid_t);
- void (*dump_datatype_function) (hid_t);
- herr_t (*dump_attribute_function) (hid_t, const char *, const H5A_info_t *, void *);
- void (*dump_data_function) (hid_t, int, struct subset_t *, int);
+ void (*dump_group_function)(hid_t, const char *);
+ void (*dump_named_datatype_function)(hid_t, const char *);
+ void (*dump_dataset_function)(hid_t, const char *, struct subset_t *);
+ void (*dump_dataspace_function)(hid_t);
+ void (*dump_datatype_function)(hid_t);
+ herr_t (*dump_attribute_function)(hid_t, const char *, const H5A_info_t *, void *);
+ void (*dump_data_function)(hid_t, int, struct subset_t *, int);
} dump_functions;
/* List of table structures. There is one table structure for each file */
typedef struct h5dump_table_items_t {
- unsigned long fileno; /* File number that these tables refer to */
- hid_t oid; /* ID of an object in this file, held open so fileno is consistent */
- table_t *group_table; /* Table of groups */
- table_t *dset_table; /* Table of datasets */
- table_t *type_table; /* Table of datatypes */
+ unsigned long fileno; /* File number that these tables refer to */
+ hid_t oid; /* ID of an object in this file, held open so fileno is consistent */
+ table_t * group_table; /* Table of groups */
+ table_t * dset_table; /* Table of datasets */
+ table_t * type_table; /* Table of datatypes */
} h5dump_table_items_t;
+
typedef struct h5dump_table_list_t {
- size_t nalloc;
- size_t nused;
- h5dump_table_items_t *tables;
+ size_t nalloc;
+ size_t nused;
+ h5dump_table_items_t *tables;
} h5dump_table_list_t;
-h5dump_table_list_t table_list = {0, 0, NULL};
-table_t *group_table = NULL, *dset_table = NULL, *type_table = NULL;
-unsigned dump_indent = 0; /*how far in to indent the line */
+h5dump_table_list_t table_list = {0, 0, NULL};
+table_t * group_table = NULL, *dset_table = NULL, *type_table = NULL;
-int unamedtype = 0; /* shared datatype with no name */
-hbool_t hit_elink = FALSE; /* whether we have traversed an external link */
-size_t prefix_len = 1024;
-char *prefix = NULL;
-const char *fp_format = NULL;
+unsigned dump_indent = 0; /* how far in to indent the line */
+int unamedtype = 0; /* shared datatype with no name */
+hbool_t hit_elink = FALSE; /* whether we have traversed an external link */
+size_t prefix_len = 1024;
+char * prefix = NULL;
+const char *fp_format = NULL;
/* things to display or which are set via command line parameters */
-int display_all = TRUE;
-int display_oid = FALSE;
-int display_data = TRUE;
-int display_attr_data = TRUE;
-int display_char = FALSE; /*print 1-byte numbers as ASCII */
-int usingdasho = FALSE;
-int display_bb = FALSE; /*superblock */
-int display_dcpl = FALSE; /*dcpl */
-int display_fi = FALSE; /*file index */
-int display_ai = TRUE; /*array index */
-int display_escape = FALSE; /*escape non printable characters */
-int display_region = FALSE; /*print region reference data */
-int disable_compact_subset= FALSE; /* disable compact form of subset notation */
-int display_packed_bits = FALSE; /*print 1-8 byte numbers as packed bits*/
-int include_attrs = TRUE; /* Display attributes */
-int display_vds_first = FALSE; /* vds display to all by default*/
-int vds_gap_size = 0; /* vds skip missing files default is none */
+typedef struct {
+ int display_all;
+ int display_oid;
+ int display_data;
+ int display_attr_data;
+ int display_char; /* print 1-byte numbers as ASCII */
+ int usingdasho;
+ int display_bb; /* superblock */
+ int display_dcpl; /* dcpl */
+ int display_fi; /* file index */
+ int display_ai; /* array index */
+ int display_escape; /* escape non printable characters */
+ int display_region; /* print region reference data */
+ int disable_compact_subset; /* disable compact form of subset notation */
+ int display_packed_bits; /* print 1-8 byte numbers as packed bits */
+ int include_attrs; /* Display attributes */
+ int display_vds_first; /* vds display to all by default */
+ int vds_gap_size; /* vds skip missing files default is none */
+} dump_opt_t;
+dump_opt_t dump_opts = {TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE,
+ TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, 0};
-#define PACKED_BITS_MAX 8 /* Maximum number of packed-bits to display */
-#define PACKED_BITS_SIZE_MAX (8*sizeof(long long)) /* Maximum bits size of integer types of packed-bits */
+#define PACKED_BITS_MAX 8 /* Maximum number of packed-bits to display */
+#define PACKED_BITS_SIZE_MAX (8 * sizeof(long long)) /* Maximum bits size of integer types of packed-bits */
/* mask list for packed bits */
-unsigned long long packed_mask[PACKED_BITS_MAX]; /* packed bits are restricted to 8*sizeof(llong) bytes */
+unsigned long long packed_mask[PACKED_BITS_MAX]; /* packed bits are restricted to 8*sizeof(llong) bytes */
/* packed bits display parameters */
unsigned packed_offset[PACKED_BITS_MAX];
@@ -94,16 +99,17 @@ unsigned packed_length[PACKED_BITS_MAX];
const dump_functions *dump_function_table;
#ifdef __cplusplus
-"C" {
+"C"
+{
#endif
-void add_prefix(char **prfx, size_t *prfx_len, const char *name);
-hid_t h5_fileaccess(void);
-ssize_t table_list_add(hid_t oid, unsigned long file_no);
-ssize_t table_list_visited(unsigned long file_no);
+ void add_prefix(char **prfx, size_t *prfx_len, const char *name);
+ hid_t h5_fileaccess(void);
+ ssize_t table_list_add(hid_t oid, unsigned long file_no);
+ ssize_t table_list_visited(unsigned long file_no);
#ifdef __cplusplus
}
#endif
-#endif /* !H5DUMP_H__ */
+#endif /* H5DUMP_H */
diff --git a/tools/src/h5dump/h5dump_ddl.c b/tools/src/h5dump/h5dump_ddl.c
index d7c7b1a..b0bce0c 100644
--- a/tools/src/h5dump/h5dump_ddl.c
+++ b/tools/src/h5dump/h5dump_ddl.c
@@ -6,7 +6,7 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -21,18 +21,18 @@
#include "h5dump_ddl.h"
typedef struct {
- hid_t fid; /* File ID being traversed */
- const char *op_name; /* Object name wanted */
+ hid_t fid; /* File ID being traversed */
+ const char *op_name; /* Object name wanted */
} trav_handle_udata_t;
typedef struct {
- const char *path; /* Path of object being searched */
- const char *op_name; /* Object name wanted */
+ const char *path; /* Path of object being searched */
+ const char *op_name; /* Object name wanted */
} trav_attr_udata_t;
/* callback function used by H5Literate() */
-static herr_t dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void *op_data);
-static int dump_extlink(hid_t group, const char *linkname, const char *objname);
+static herr_t dump_all_cb(hid_t group, const char *name, const H5L_info2_t *linfo, void *op_data);
+static int dump_extlink(hid_t group, const char *linkname, const char *objname);
/*-------------------------------------------------------------------------
* Function: dump_datatype
@@ -41,22 +41,17 @@ static int dump_extlink(hid_t group, const char *linkname, const char *objn
* atomic datatype or committed/transient datatype.
*
* Return: void
- *
- * Programmer: Ruey-Hsia Li
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void
dump_datatype(hid_t type)
{
- h5tools_context_t ctx; /* print context */
- h5tool_format_t *outputformat = &h5tools_dataformat;
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t * outputformat = &h5tools_dataformat;
HDmemset(&ctx, 0, sizeof(ctx));
ctx.indent_level = dump_indent / COL;
- ctx.cur_column = dump_indent;
+ ctx.cur_column = dump_indent;
h5dump_type_table = type_table;
h5tools_dump_datatype(rawoutstream, outputformat, &ctx, type);
@@ -70,84 +65,74 @@ dump_datatype(hid_t type)
* array, or others.
*
* Return: void
- *
- * Programmer: Ruey-Hsia Li
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void
dump_dataspace(hid_t space)
{
- h5tools_context_t ctx; /* print context */
- h5tool_format_t *outputformat = &h5tools_dataformat;
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t * outputformat = &h5tools_dataformat;
HDmemset(&ctx, 0, sizeof(ctx));
ctx.indent_level = dump_indent / COL;
- ctx.cur_column = dump_indent;
+ ctx.cur_column = dump_indent;
h5tools_dump_dataspace(rawoutstream, outputformat, &ctx, space);
}
-
/*-------------------------------------------------------------------------
* Function: dump_attr_cb
*
* Purpose: attribute function callback called by H5Aiterate2, displays the attribute
*
* Return: Success: SUCCEED
- *
* Failure: FAIL
- *
- * Programmer: Ruey-Hsia Li
- *
- * Modifications: Pedro Vicente, October 4, 2007
- * Added H5A_info_t parameter to conform with H5Aiterate2
- *
*-------------------------------------------------------------------------
*/
herr_t
-dump_attr_cb(hid_t oid, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *info, void H5_ATTR_UNUSED *_op_data)
+dump_attr_cb(hid_t oid, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *info,
+ void H5_ATTR_UNUSED *_op_data)
{
- h5tools_context_t ctx; /* print context */
- h5tool_format_t *outputformat = &h5tools_dataformat;
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t * outputformat = &h5tools_dataformat;
h5tool_format_t string_dataformat;
- hid_t attr_id;
- herr_t ret = SUCCEED;
+ hid_t attr_id;
+ herr_t ret = SUCCEED;
HDmemset(&ctx, 0, sizeof(ctx));
- ctx.indent_level = dump_indent / COL;
- ctx.cur_column = dump_indent;
+ ctx.indent_level = dump_indent / COL;
+ ctx.cur_column = dump_indent;
+ ctx.display_index = dump_opts.display_ai;
+ ctx.display_char = dump_opts.display_char;
- attr_id = H5Aopen(oid, attr_name, H5P_DEFAULT);
- oid_output = display_oid;
- data_output = display_data;
- attr_data_output = display_attr_data;
+ attr_id = H5Aopen(oid, attr_name, H5P_DEFAULT);
+ oid_output = dump_opts.display_oid;
+ data_output = dump_opts.display_data;
+ attr_data_output = dump_opts.display_attr_data;
string_dataformat = *outputformat;
if (fp_format) {
string_dataformat.fmt_double = fp_format;
- string_dataformat.fmt_float = fp_format;
+ string_dataformat.fmt_float = fp_format;
}
if (h5tools_nCols == 0) {
- string_dataformat.line_ncols = 65535;
+ string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
- outputformat = &string_dataformat;
+ string_dataformat.do_escape = dump_opts.display_escape;
+ outputformat = &string_dataformat;
h5dump_type_table = type_table;
- h5tools_dump_attribute(rawoutstream, outputformat, &ctx, attr_name, attr_id, display_ai, display_char);
+ h5tools_dump_attribute(rawoutstream, outputformat, &ctx, attr_name, attr_id);
h5dump_type_table = NULL;
- if(attr_id < 0) {
+ if (attr_id < 0) {
h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
}
@@ -155,7 +140,6 @@ dump_attr_cb(hid_t oid, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *
return ret;
}
-
/*-------------------------------------------------------------------------
* Function: dump_all_cb
*
@@ -163,60 +147,49 @@ dump_attr_cb(hid_t oid, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *
* displays everything in the specified object
*
* Return: Success: SUCCEED
- *
* Failure: FAIL
- *
- * Programmer: Ruey-Hsia Li
- *
- * Modifications:
- * RMcG, November 2000
- * Added XML support. Also, optionally checks the op_data argument
- *
- * PVN, May 2008
- * Dump external links
- *
*-------------------------------------------------------------------------
*/
static herr_t
-dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void H5_ATTR_UNUSED *op_data)
+dump_all_cb(hid_t group, const char *name, const H5L_info2_t *linfo, void H5_ATTR_UNUSED *op_data)
{
- hid_t obj;
- hid_t dapl_id = H5P_DEFAULT; /* dataset access property list ID */
- herr_t ret = SUCCEED;
- char *obj_path = NULL; /* Full path of object */
- h5tools_str_t buffer; /* string into which to render */
- h5tools_context_t ctx; /* print context */
- h5tool_format_t *outputformat = &h5tools_dataformat;
+ hid_t obj;
+ hid_t dapl_id = H5P_DEFAULT; /* dataset access property list ID */
+ herr_t ret = SUCCEED;
+ char * obj_path = NULL; /* Full path of object */
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t * outputformat = &h5tools_dataformat;
h5tool_format_t string_dataformat;
- hsize_t curr_pos = 0; /* total data element position */
+ hsize_t curr_pos = 0; /* total data element position */
/* setup */
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
HDmemset(&ctx, 0, sizeof(ctx));
ctx.indent_level = dump_indent / COL;
- ctx.cur_column = dump_indent;
+ ctx.cur_column = dump_indent;
string_dataformat = *outputformat;
if (fp_format) {
string_dataformat.fmt_double = fp_format;
- string_dataformat.fmt_float = fp_format;
+ string_dataformat.fmt_float = fp_format;
}
if (h5tools_nCols == 0) {
- string_dataformat.line_ncols = 65535;
+ string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
- outputformat = &string_dataformat;
+ string_dataformat.do_escape = dump_opts.display_escape;
+ outputformat = &string_dataformat;
/* Build the object's path name */
obj_path = (char *)HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2);
- if(!obj_path) {
+ if (!obj_path) {
ret = FAIL;
goto done;
}
@@ -225,355 +198,369 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void H5_ATTR
HDstrcat(obj_path, "/");
HDstrcat(obj_path, name);
- if(linfo->type == H5L_TYPE_HARD) {
- H5O_info_t oinfo;
+ if (linfo->type == H5L_TYPE_HARD) {
+ H5O_info2_t oinfo;
/* Stat the object */
- if(H5Oget_info_by_name2(group, name, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) {
+ if (H5Oget_info_by_name3(group, name, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) {
error_msg("unable to get object information for \"%s\"\n", name);
h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
goto done;
} /* end if */
- switch(oinfo.type) {
- case H5O_TYPE_GROUP:
- if((obj = H5Gopen2(group, name, H5P_DEFAULT)) < 0) {
- error_msg("unable to dump group \"%s\"\n", name);
- h5tools_setstatus(EXIT_FAILURE);
- ret = FAIL;
- }
- else {
- char *old_prefix; /* Pointer to previous prefix */
+ switch (oinfo.type) {
+ case H5O_TYPE_GROUP:
+ if ((obj = H5Gopen2(group, name, H5P_DEFAULT)) < 0) {
+ error_msg("unable to dump group \"%s\"\n", name);
+ h5tools_setstatus(EXIT_FAILURE);
+ ret = FAIL;
+ }
+ else {
+ char *old_prefix; /* Pointer to previous prefix */
- /* Keep copy of prefix before iterating into group */
- old_prefix = HDstrdup(prefix);
- if (old_prefix) {
- /* Append group name to prefix */
- add_prefix(&prefix, &prefix_len, name);
+ /* Keep copy of prefix before iterating into group */
+ old_prefix = HDstrdup(prefix);
+ if (old_prefix) {
+ /* Append group name to prefix */
+ add_prefix(&prefix, &prefix_len, name);
- /* Iterate into group */
- dump_function_table->dump_group_function(obj, name);
+ /* Iterate into group */
+ dump_function_table->dump_group_function(obj, name);
- /* Restore old prefix name */
- HDstrcpy(prefix, old_prefix);
- HDfree(old_prefix);
- }
- else
- error_msg("warning: null prefix\n");
+ /* Restore old prefix name */
+ HDstrcpy(prefix, old_prefix);
+ HDfree(old_prefix);
+ }
+ else
+ error_msg("warning: null prefix\n");
- /* Close group */
- H5Gclose(obj);
- }
- break;
+ /* Close group */
+ H5Gclose(obj);
+ }
+ break;
- case H5O_TYPE_DATASET:
- if(display_data) {
- if ((dapl_id = H5Pcreate(H5P_DATASET_ACCESS)) < 0) {
- error_msg("error in creating default access property list ID\n");
+ case H5O_TYPE_DATASET:
+ if (dump_opts.display_data) {
+ if ((dapl_id = H5Pcreate(H5P_DATASET_ACCESS)) < 0) {
+ error_msg("error in creating default access property list ID\n");
+ }
+ if (dump_opts.display_vds_first) {
+ if (H5Pset_virtual_view(dapl_id, H5D_VDS_FIRST_MISSING) < 0)
+ error_msg("error in setting access property list ID, virtual_view\n");
+ }
+ if (dump_opts.vds_gap_size > 0) {
+ if (H5Pset_virtual_printf_gap(dapl_id, (hsize_t)dump_opts.vds_gap_size) < 0)
+ error_msg("error in setting access property list ID, virtual_printf_gap\n");
+ }
}
- if (display_vds_first) {
- if(H5Pset_virtual_view(dapl_id, H5D_VDS_FIRST_MISSING) < 0)
- error_msg("error in setting access property list ID, virtual_view\n");
+ if ((obj = H5Dopen2(group, name, dapl_id)) >= 0) {
+ if (oinfo.rc > 1 || hit_elink) {
+ obj_t *found_obj; /* Found object */
+
+ found_obj = search_obj(dset_table, &oinfo.token);
+
+ if (found_obj == NULL) {
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "%s \"%s\" %s",
+ h5tools_dump_header_format->datasetbegin, name,
+ h5tools_dump_header_format->datasetblockbegin);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+
+ error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
+
+ ctx.need_prefix = TRUE;
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ if (HDstrlen(h5tools_dump_header_format->datasetblockend)) {
+ h5tools_str_append(&buffer, "%s",
+ h5tools_dump_header_format->datasetblockend);
+ if (HDstrlen(h5tools_dump_header_format->datasetend))
+ h5tools_str_append(&buffer, " ");
+ }
+ if (HDstrlen(h5tools_dump_header_format->datasetend))
+ h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetend);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+
+ ctx.indent_level--;
+
+ h5tools_setstatus(EXIT_FAILURE);
+ ret = FAIL;
+ if (dapl_id != H5P_DEFAULT)
+ H5Pclose(dapl_id);
+ H5Dclose(obj);
+ goto done;
+ }
+ else if (found_obj->displayed) {
+ ctx.need_prefix = TRUE;
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "%s \"%s\" %s",
+ h5tools_dump_header_format->datasetbegin, name,
+ h5tools_dump_header_format->datasetblockbegin);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "%s \"%s\"", HARDLINK, found_obj->objname);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+
+ ctx.indent_level--;
+
+ ctx.need_prefix = TRUE;
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ if (HDstrlen(h5tools_dump_header_format->datasetblockend)) {
+ h5tools_str_append(&buffer, "%s",
+ h5tools_dump_header_format->datasetblockend);
+ if (HDstrlen(h5tools_dump_header_format->datasetend))
+ h5tools_str_append(&buffer, " ");
+ }
+ if (HDstrlen(h5tools_dump_header_format->datasetend))
+ h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetend);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+
+ if (dapl_id != H5P_DEFAULT)
+ H5Pclose(dapl_id);
+ H5Dclose(obj);
+ goto done;
+ }
+ else {
+ found_obj->displayed = TRUE;
+ }
+ } /* end if */
+
+ dump_function_table->dump_dataset_function(obj, name, NULL);
+ if (dapl_id != H5P_DEFAULT)
+ H5Pclose(dapl_id);
+ H5Dclose(obj);
}
- if (vds_gap_size > 0) {
- if(H5Pset_virtual_printf_gap(dapl_id, (hsize_t)vds_gap_size) < 0)
- error_msg("error in setting access property list ID, virtual_printf_gap\n");
+ else {
+ if (dapl_id != H5P_DEFAULT)
+ H5Pclose(dapl_id);
+ error_msg("unable to dump dataset \"%s\"\n", name);
+ h5tools_setstatus(EXIT_FAILURE);
+ ret = FAIL;
}
- }
- if((obj = H5Dopen2(group, name, dapl_id)) >= 0) {
- if(oinfo.rc > 1 || hit_elink) {
- obj_t *found_obj; /* Found object */
-
- found_obj = search_obj(dset_table, oinfo.addr);
-
- if(found_obj == NULL) {
- ctx.indent_level++;
-
- ctx.need_prefix = TRUE;
+ break;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s \"%s\" %s",
- h5tools_dump_header_format->datasetbegin, name,
- h5tools_dump_header_format->datasetblockbegin);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ case H5O_TYPE_NAMED_DATATYPE:
+ if ((obj = H5Topen2(group, name, H5P_DEFAULT)) < 0) {
+ error_msg("unable to dump datatype \"%s\"\n", name);
+ h5tools_setstatus(EXIT_FAILURE);
+ ret = FAIL;
+ }
+ else {
+ dump_function_table->dump_named_datatype_function(obj, name);
+ H5Tclose(obj);
+ }
+ break;
- error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
+ case H5O_TYPE_MAP:
+ case H5O_TYPE_UNKNOWN:
+ case H5O_TYPE_NTYPES:
+ default:
+ error_msg("unknown object \"%s\"\n", name);
+ h5tools_setstatus(EXIT_FAILURE);
+ ret = FAIL;
+ }
+ } /* end if */
+ else {
+ char *targbuf;
- ctx.need_prefix = TRUE;
+ switch (linfo->type) {
+ case H5L_TYPE_SOFT:
+ if ((targbuf = (char *)HDmalloc(linfo->u.val_size)) == NULL) {
+ error_msg("unable to allocate buffer\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ ret = FAIL;
+ }
+ else {
+ ctx.need_prefix = TRUE;
- /* Render the element */
- h5tools_str_reset(&buffer);
- if(HDstrlen(h5tools_dump_header_format->datasetblockend)) {
- h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetblockend);
- if(HDstrlen(h5tools_dump_header_format->datasetend))
- h5tools_str_append(&buffer, " ");
- }
- if(HDstrlen(h5tools_dump_header_format->datasetend))
- h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetend);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "%s \"%s\" %s", h5tools_dump_header_format->softlinkbegin,
+ name, h5tools_dump_header_format->softlinkblockbegin);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- ctx.indent_level--;
+ ctx.indent_level++;
+ if (H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) {
+ error_msg("unable to get link value\n");
h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
- if (dapl_id != H5P_DEFAULT)
- H5Pclose(dapl_id);
- H5Dclose(obj);
- goto done;
}
- else if(found_obj->displayed) {
- ctx.need_prefix = TRUE;
-
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s \"%s\" %s",
- h5tools_dump_header_format->datasetbegin, name,
- h5tools_dump_header_format->datasetblockbegin);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
-
- ctx.indent_level++;
-
- ctx.need_prefix = TRUE;
-
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s \"%s\"", HARDLINK, found_obj->objname);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
-
- ctx.indent_level--;
-
+ else {
+ /* print the value of a soft link */
+ /* Standard DDL: no modification */
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- if(HDstrlen(h5tools_dump_header_format->datasetblockend)) {
- h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetblockend);
- if(HDstrlen(h5tools_dump_header_format->datasetend))
- h5tools_str_append(&buffer, " ");
- }
- if(HDstrlen(h5tools_dump_header_format->datasetend))
- h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetend);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
-
- if (dapl_id != H5P_DEFAULT)
- H5Pclose(dapl_id);
- H5Dclose(obj);
- goto done;
+ h5tools_str_append(&buffer, "LINKTARGET \"%s\"", targbuf);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
}
- else {
- found_obj->displayed = TRUE;
- }
- } /* end if */
-
- dump_function_table->dump_dataset_function(obj, name, NULL);
- if (dapl_id != H5P_DEFAULT)
- H5Pclose(dapl_id);
- H5Dclose(obj);
- }
- else {
- if (dapl_id != H5P_DEFAULT)
- H5Pclose(dapl_id);
- error_msg("unable to dump dataset \"%s\"\n", name);
- h5tools_setstatus(EXIT_FAILURE);
- ret = FAIL;
- }
- break;
-
- case H5O_TYPE_NAMED_DATATYPE:
- if((obj = H5Topen2(group, name, H5P_DEFAULT)) < 0) {
- error_msg("unable to dump datatype \"%s\"\n", name);
- h5tools_setstatus(EXIT_FAILURE);
- ret = FAIL;
- }
- else {
- dump_function_table->dump_named_datatype_function(obj, name);
- H5Tclose(obj);
- }
- break;
- case H5O_TYPE_MAP:
- case H5O_TYPE_UNKNOWN:
- case H5O_TYPE_NTYPES:
- default:
- error_msg("unknown object \"%s\"\n", name);
- h5tools_setstatus(EXIT_FAILURE);
- ret = FAIL;
- }
- } /* end if */
- else {
- char *targbuf;
+ ctx.indent_level--;
- switch(linfo->type) {
- case H5L_TYPE_SOFT:
- if((targbuf = (char *)HDmalloc(linfo->u.val_size)) == NULL) {
- error_msg("unable to allocate buffer\n");
- h5tools_setstatus(EXIT_FAILURE);
- ret = FAIL;
- }
- else {
- ctx.need_prefix = TRUE;
+ ctx.need_prefix = TRUE;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s \"%s\" %s",
- h5tools_dump_header_format->softlinkbegin, name,
- h5tools_dump_header_format->softlinkblockbegin);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ if (HDstrlen(h5tools_dump_header_format->softlinkblockend)) {
+ h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->softlinkblockend);
+ if (HDstrlen(h5tools_dump_header_format->softlinkend))
+ h5tools_str_append(&buffer, " ");
+ }
+ if (HDstrlen(h5tools_dump_header_format->softlinkend))
+ h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->softlinkend);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- ctx.indent_level++;
+ HDfree(targbuf);
+ }
+ break;
- if(H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) {
- error_msg("unable to get link value\n");
+ case H5L_TYPE_EXTERNAL:
+ if ((targbuf = (char *)HDmalloc(linfo->u.val_size)) == NULL) {
+ error_msg("unable to allocate buffer\n");
h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
}
else {
- /* print the value of a soft link */
- /* Standard DDL: no modification */
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "LINKTARGET \"%s\"", targbuf);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- }
+ h5tools_str_append(&buffer, "%s \"%s\" %s", h5tools_dump_header_format->extlinkbegin,
+ name, h5tools_dump_header_format->extlinkblockbegin);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- ctx.indent_level--;
+ if (H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) {
+ indentation(dump_indent);
+ error_msg("unable to get external link value\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ ret = FAIL;
+ } /* end if */
+ else {
+ const char *filename;
+ const char *targname;
+
+ if (H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL, &filename, &targname) < 0) {
+ indentation(dump_indent);
+ error_msg("unable to unpack external link value\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ ret = FAIL;
+ } /* end if */
+ else {
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "TARGETFILE \"%s\"", filename);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+
+ ctx.need_prefix = TRUE;
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "TARGETPATH \"%s\"", targname);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+
+ /* dump the external link */
+ dump_extlink(group, name, targname);
+ ctx.indent_level--;
+ } /* end else */
+ } /* end else */
+ ctx.need_prefix = TRUE;
- ctx.need_prefix = TRUE;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ if (HDstrlen(h5tools_dump_header_format->extlinkblockend)) {
+ h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->extlinkblockend);
+ if (HDstrlen(h5tools_dump_header_format->extlinkend))
+ h5tools_str_append(&buffer, " ");
+ }
+ if (HDstrlen(h5tools_dump_header_format->extlinkend))
+ h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->extlinkend);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- /* Render the element */
- h5tools_str_reset(&buffer);
- if(HDstrlen(h5tools_dump_header_format->softlinkblockend)) {
- h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->softlinkblockend);
- if(HDstrlen(h5tools_dump_header_format->softlinkend))
- h5tools_str_append(&buffer, " ");
+ HDfree(targbuf);
}
- if(HDstrlen(h5tools_dump_header_format->softlinkend))
- h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->softlinkend);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
-
- HDfree(targbuf);
- }
- break;
+ break;
- case H5L_TYPE_EXTERNAL:
- if((targbuf = (char *)HDmalloc(linfo->u.val_size)) == NULL) {
- error_msg("unable to allocate buffer\n");
- h5tools_setstatus(EXIT_FAILURE);
- ret = FAIL;
- }
- else {
+ case H5L_TYPE_ERROR:
+ case H5L_TYPE_MAX:
+ case H5L_TYPE_HARD:
+ default:
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s \"%s\" %s",
- h5tools_dump_header_format->extlinkbegin, name,
- h5tools_dump_header_format->extlinkblockbegin);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
-
- if(H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) {
- indentation(dump_indent);
- error_msg("unable to get external link value\n");
- h5tools_setstatus(EXIT_FAILURE);
- ret = FAIL;
- } /* end if */
- else {
- const char *filename;
- const char *targname;
-
- if(H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL, &filename, &targname) < 0) {
- indentation(dump_indent);
- error_msg("unable to unpack external link value\n");
- h5tools_setstatus(EXIT_FAILURE);
- ret = FAIL;
- } /* end if */
- else {
- ctx.indent_level++;
+ h5tools_str_append(&buffer, "%s \"%s\" %s", h5tools_dump_header_format->udlinkbegin, name,
+ h5tools_dump_header_format->udlinkblockbegin);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- ctx.need_prefix = TRUE;
+ ctx.indent_level++;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "TARGETFILE \"%s\"", filename);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ ctx.need_prefix = TRUE;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "LINKCLASS %d", linfo->type);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- ctx.need_prefix = TRUE;
+ ctx.indent_level--;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "TARGETPATH \"%s\"", targname);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
-
- /* dump the external link */
- dump_extlink(group, name, targname);
- ctx.indent_level--;
- } /* end else */
- } /* end else */
ctx.need_prefix = TRUE;
-
/* Render the element */
h5tools_str_reset(&buffer);
- if(HDstrlen(h5tools_dump_header_format->extlinkblockend)) {
- h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->extlinkblockend);
- if(HDstrlen(h5tools_dump_header_format->extlinkend))
+ if (HDstrlen(h5tools_dump_header_format->udlinkblockend)) {
+ h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->udlinkblockend);
+ if (HDstrlen(h5tools_dump_header_format->udlinkend))
h5tools_str_append(&buffer, " ");
}
- if(HDstrlen(h5tools_dump_header_format->extlinkend))
- h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->extlinkend);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
-
- HDfree(targbuf);
- }
- break;
-
- case H5L_TYPE_ERROR:
- case H5L_TYPE_MAX:
- case H5L_TYPE_HARD:
- default:
- ctx.need_prefix = TRUE;
-
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s \"%s\" %s",
- h5tools_dump_header_format->udlinkbegin, name,
- h5tools_dump_header_format->udlinkblockbegin);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
-
- ctx.indent_level++;
-
- ctx.need_prefix = TRUE;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "LINKCLASS %d", linfo->type);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
-
- ctx.indent_level--;
-
- ctx.need_prefix = TRUE;
- /* Render the element */
- h5tools_str_reset(&buffer);
- if(HDstrlen(h5tools_dump_header_format->udlinkblockend)) {
- h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->udlinkblockend);
- if(HDstrlen(h5tools_dump_header_format->udlinkend))
- h5tools_str_append(&buffer, " ");
- }
- if(HDstrlen(h5tools_dump_header_format->udlinkend))
- h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->udlinkend);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ if (HDstrlen(h5tools_dump_header_format->udlinkend))
+ h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->udlinkend);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- break;
+ break;
} /* end switch */
- } /* end else */
+ } /* end else */
done:
h5tools_str_close(&buffer);
- if(obj_path)
+ if (obj_path)
HDfree(obj_path);
return ret;
}
@@ -584,7 +571,6 @@ done:
* Purpose: Iterate and display attributes within the specified group
*
* Return: void
- *
*-------------------------------------------------------------------------
*/
void
@@ -592,19 +578,19 @@ attr_iteration(hid_t gid, unsigned attr_crt_order_flags)
{
/* attribute iteration: if there is a request to do H5_INDEX_CRT_ORDER and tracking order is set
in the group for attributes, then, sort by creation order, otherwise by name */
- if(include_attrs) {
- if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) {
- if(H5Aiterate2(gid, sort_by, sort_order, NULL, dump_attr_cb, NULL) < 0) {
+ if (dump_opts.include_attrs) {
+ if ((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) {
+ if (H5Aiterate2(gid, sort_by, sort_order, NULL, dump_attr_cb, NULL) < 0) {
error_msg("error getting attribute information\n");
h5tools_setstatus(EXIT_FAILURE);
} /* end if */
- } /* end if */
+ } /* end if */
else {
- if(H5Aiterate2(gid, H5_INDEX_NAME, sort_order, NULL, dump_attr_cb, NULL) < 0) {
+ if (H5Aiterate2(gid, H5_INDEX_NAME, sort_order, NULL, dump_attr_cb, NULL) < 0) {
error_msg("error getting attribute information\n");
h5tools_setstatus(EXIT_FAILURE);
} /* end if */
- } /* end else */
+ } /* end else */
}
}
@@ -614,7 +600,6 @@ attr_iteration(hid_t gid, unsigned attr_crt_order_flags)
* Purpose: Iterate and display links within the specified group
*
* Return: void
- *
*-------------------------------------------------------------------------
*/
void
@@ -623,10 +608,10 @@ link_iteration(hid_t gid, unsigned crt_order_flags)
/* if there is a request to do H5_INDEX_CRT_ORDER and tracking order is set
in the group, then, sort by creation order, otherwise by name */
- if((sort_by == H5_INDEX_CRT_ORDER) && (crt_order_flags & H5P_CRT_ORDER_TRACKED))
- H5Literate(gid, sort_by, sort_order, NULL, dump_all_cb, NULL);
+ if ((sort_by == H5_INDEX_CRT_ORDER) && (crt_order_flags & H5P_CRT_ORDER_TRACKED))
+ H5Literate2(gid, sort_by, sort_order, NULL, dump_all_cb, NULL);
else
- H5Literate(gid, H5_INDEX_NAME, sort_order, NULL, dump_all_cb, NULL);
+ H5Literate2(gid, H5_INDEX_NAME, sort_order, NULL, dump_all_cb, NULL);
}
/*-------------------------------------------------------------------------
@@ -635,27 +620,18 @@ link_iteration(hid_t gid, unsigned crt_order_flags)
* Purpose: Dump named datatype
*
* Return: void
- *
- * Programmer: Ruey-Hsia Li
- *
- * Modifications:
- * Pedro Vicente, March 27, 2006
- * added display of attributes
- * Pedro Vicente, October 4, 2007, added parameters to H5Aiterate2() to allow for
- * other iteration orders
- *
*-------------------------------------------------------------------------
*/
void
dump_named_datatype(hid_t tid, const char *name)
{
- H5O_info_t oinfo;
+ H5O_info2_t oinfo;
unsigned attr_crt_order_flags;
- hid_t tcpl_id = -1; /* datatype creation property list ID */
- hsize_t curr_pos = 0; /* total data element position */
- h5tools_str_t buffer; /* string into which to render */
- h5tools_context_t ctx; /* print context */
- h5tool_format_t *outputformat = &h5tools_dataformat;
+ hid_t tcpl_id = H5I_INVALID_HID; /* datatype creation property list ID */
+ hsize_t curr_pos = 0; /* total data element position */
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t * outputformat = &h5tools_dataformat;
h5tool_format_t string_dataformat;
/* setup */
@@ -663,24 +639,24 @@ dump_named_datatype(hid_t tid, const char *name)
HDmemset(&ctx, 0, sizeof(ctx));
ctx.indent_level = dump_indent / COL;
- ctx.cur_column = dump_indent;
+ ctx.cur_column = dump_indent;
string_dataformat = *outputformat;
if (fp_format) {
string_dataformat.fmt_double = fp_format;
- string_dataformat.fmt_float = fp_format;
+ string_dataformat.fmt_float = fp_format;
}
if (h5tools_nCols == 0) {
- string_dataformat.line_ncols = 65535;
+ string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
- outputformat = &string_dataformat;
+ string_dataformat.do_escape = dump_opts.display_escape;
+ outputformat = &string_dataformat;
if ((tcpl_id = H5Tget_create_plist(tid)) < 0) {
error_msg("error in getting creation property list ID\n");
@@ -693,7 +669,7 @@ dump_named_datatype(hid_t tid, const char *name)
h5tools_setstatus(EXIT_FAILURE);
}
- if(H5Pclose(tcpl_id) < 0) {
+ if (H5Pclose(tcpl_id) < 0) {
error_msg("error in closing creation property list ID\n");
h5tools_setstatus(EXIT_FAILURE);
}
@@ -702,20 +678,20 @@ dump_named_datatype(hid_t tid, const char *name)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s \"%s\" %s",
- h5tools_dump_header_format->datatypebegin, name,
- h5tools_dump_header_format->datatypeblockbegin);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "%s \"%s\" %s", h5tools_dump_header_format->datatypebegin, name,
+ h5tools_dump_header_format->datatypeblockbegin);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- H5Oget_info2(tid, &oinfo, H5O_INFO_BASIC);
+ H5Oget_info3(tid, &oinfo, H5O_INFO_BASIC);
/* Must check for uniqueness of all objects if we've traversed an elink,
* otherwise only check if the reference count > 1.
*/
- if(oinfo.rc > 1 || hit_elink) {
- obj_t *found_obj; /* Found object */
+ if (oinfo.rc > 1 || hit_elink) {
+ obj_t *found_obj; /* Found object */
- found_obj = search_obj(type_table, oinfo.addr);
+ found_obj = search_obj(type_table, &oinfo.token);
if (found_obj == NULL) {
error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
@@ -726,7 +702,8 @@ dump_named_datatype(hid_t tid, const char *name)
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "%s \"%s\"", HARDLINK, found_obj->objname);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
goto done;
}
else
@@ -737,11 +714,12 @@ dump_named_datatype(hid_t tid, const char *name)
h5tools_str_reset(&buffer);
h5tools_print_datatype(rawoutstream, &buffer, outputformat, &ctx, tid, FALSE);
- if(H5Tget_class(tid) != H5T_COMPOUND) {
+ if (H5Tget_class(tid) != H5T_COMPOUND) {
h5tools_str_append(&buffer, ";");
}
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
/* print attributes */
dump_indent += COL;
@@ -753,14 +731,15 @@ dump_named_datatype(hid_t tid, const char *name)
done:
/* Render the element */
h5tools_str_reset(&buffer);
- if(HDstrlen(h5tools_dump_header_format->datatypeblockend)) {
+ if (HDstrlen(h5tools_dump_header_format->datatypeblockend)) {
h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datatypeblockend);
- if(HDstrlen(h5tools_dump_header_format->datatypeend))
+ if (HDstrlen(h5tools_dump_header_format->datatypeend))
h5tools_str_append(&buffer, " ");
}
- if(HDstrlen(h5tools_dump_header_format->datatypeend))
+ if (HDstrlen(h5tools_dump_header_format->datatypeend))
h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datatypeend);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
h5tools_str_close(&buffer);
}
@@ -771,33 +750,23 @@ done:
* Purpose: Dump everything within the specified group
*
* Return: void
- *
- * Programmer: Ruey-Hsia Li
- *
- * Modifications:
- *
- * Call to dump_all_cb -- add parameter to select everything.
- *
- * Pedro Vicente, October 1, 2007
- * handle several iteration orders for attributes and groups
- *
*-------------------------------------------------------------------------
*/
void
dump_group(hid_t gid, const char *name)
{
- H5O_info_t oinfo;
- hid_t dset;
- hid_t type;
- hid_t gcpl_id;
- unsigned crt_order_flags;
- unsigned attr_crt_order_flags;
- char type_name[1024];
- h5tools_str_t buffer; /* string into which to render */
- h5tools_context_t ctx; /* print context */
- h5tool_format_t *outputformat = &h5tools_dataformat;
+ H5O_info2_t oinfo;
+ hid_t dset;
+ hid_t type;
+ hid_t gcpl_id;
+ unsigned crt_order_flags;
+ unsigned attr_crt_order_flags;
+ char type_name[1024];
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t * outputformat = &h5tools_dataformat;
h5tool_format_t string_dataformat;
- hsize_t curr_pos = 0; /* total data element position */
+ hsize_t curr_pos = 0; /* total data element position */
if ((gcpl_id = H5Gget_create_plist(gid)) < 0) {
error_msg("error in getting group creation property list ID\n");
@@ -811,12 +780,12 @@ dump_group(hid_t gid, const char *name)
}
/* query the group creation properties */
- if(H5Pget_link_creation_order(gcpl_id, &crt_order_flags) < 0) {
+ if (H5Pget_link_creation_order(gcpl_id, &crt_order_flags) < 0) {
error_msg("error in getting group creation properties\n");
h5tools_setstatus(EXIT_FAILURE);
}
- if(H5Pclose(gcpl_id) < 0) {
+ if (H5Pclose(gcpl_id) < 0) {
error_msg("error in closing group creation property list ID\n");
h5tools_setstatus(EXIT_FAILURE);
}
@@ -826,66 +795,72 @@ dump_group(hid_t gid, const char *name)
HDmemset(&ctx, 0, sizeof(ctx));
ctx.indent_level = dump_indent / COL;
- ctx.cur_column = dump_indent;
+ ctx.cur_column = dump_indent;
string_dataformat = *outputformat;
if (fp_format) {
string_dataformat.fmt_double = fp_format;
- string_dataformat.fmt_float = fp_format;
+ string_dataformat.fmt_float = fp_format;
}
if (h5tools_nCols == 0) {
- string_dataformat.line_ncols = 65535;
+ string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
- outputformat = &string_dataformat;
+ string_dataformat.do_escape = dump_opts.display_escape;
+ outputformat = &string_dataformat;
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s \"%s\" %s",
- h5tools_dump_header_format->groupbegin, name,
- h5tools_dump_header_format->groupblockbegin);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "%s \"%s\" %s", h5tools_dump_header_format->groupbegin, name,
+ h5tools_dump_header_format->groupblockbegin);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level++;
dump_indent += COL;
- if(!HDstrcmp(name, "/") && unamedtype) {
- unsigned u; /* Local index variable */
+ if (!HDstrcmp(name, "/") && unamedtype) {
+ unsigned u; /* Local index variable */
+
+ /* dump unnamed type in root group */
+ for (u = 0; u < type_table->nobjs; u++)
+ if (!type_table->objs[u].recorded) {
+ char *obj_tok_str = NULL;
- /* dump unamed type in root group */
- for(u = 0; u < type_table->nobjs; u++)
- if(!type_table->objs[u].recorded) {
dset = H5Dopen2(gid, type_table->objs[u].objname, H5P_DEFAULT);
type = H5Dget_type(dset);
- HDsprintf(type_name, "#"H5_PRINTF_HADDR_FMT, type_table->objs[u].objno);
+
+ H5Otoken_to_str(dset, &type_table->objs[u].obj_token, &obj_tok_str);
+ HDsnprintf(type_name, sizeof(type_name), "#%s", obj_tok_str);
+ H5free_memory(obj_tok_str);
+
dump_function_table->dump_named_datatype_function(type, type_name);
H5Tclose(type);
H5Dclose(dset);
}
} /* end if */
- if(display_oid)
+ if (dump_opts.display_oid)
h5tools_dump_oid(rawoutstream, outputformat, &ctx, gid);
h5tools_dump_comment(rawoutstream, outputformat, &ctx, gid);
- H5Oget_info2(gid, &oinfo, H5O_INFO_BASIC);
+ H5Oget_info3(gid, &oinfo, H5O_INFO_BASIC);
/* Must check for uniqueness of all objects if we've traversed an elink,
* otherwise only check if the reference count > 1.
*/
- if(oinfo.rc > 1 || hit_elink) {
- obj_t *found_obj; /* Found object */
+ if (oinfo.rc > 1 || hit_elink) {
+ obj_t *found_obj; /* Found object */
- found_obj = search_obj(group_table, oinfo.addr);
+ found_obj = search_obj(group_table, &oinfo.token);
if (found_obj == NULL) {
error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
@@ -897,7 +872,8 @@ dump_group(hid_t gid, const char *name)
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "%s \"%s\"", HARDLINK, found_obj->objname);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
}
else {
found_obj->displayed = TRUE;
@@ -917,14 +893,15 @@ dump_group(hid_t gid, const char *name)
/* Render the element */
h5tools_str_reset(&buffer);
- if(HDstrlen(h5tools_dump_header_format->groupblockend)) {
+ if (HDstrlen(h5tools_dump_header_format->groupblockend)) {
h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->groupblockend);
- if(HDstrlen(h5tools_dump_header_format->groupend))
+ if (HDstrlen(h5tools_dump_header_format->groupend))
h5tools_str_append(&buffer, " ");
}
- if(HDstrlen(h5tools_dump_header_format->groupend))
+ if (HDstrlen(h5tools_dump_header_format->groupend))
h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->groupend);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
h5tools_str_close(&buffer);
}
@@ -935,48 +912,40 @@ dump_group(hid_t gid, const char *name)
* Purpose: Dump the specified data set
*
* Return: void
- *
- * Programmer: Ruey-Hsia Li
- *
- * Modifications:
- * Pedro Vicente, 2004, added dataset creation property list display
- * Pedro Vicente, October 4, 2007, added parameters to H5Aiterate2() to allow for
- * other iteration orders
- *
*-------------------------------------------------------------------------
*/
void
dump_dataset(hid_t did, const char *name, struct subset_t *sset)
{
- h5tools_context_t ctx; /* print context */
- h5tool_format_t *outputformat = &h5tools_dataformat;
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t * outputformat = &h5tools_dataformat;
h5tool_format_t string_dataformat;
- hid_t type, space;
- unsigned attr_crt_order_flags;
- hid_t dcpl_id; /* dataset creation property list ID */
- h5tools_str_t buffer; /* string into which to render */
- hsize_t curr_pos = 0; /* total data element position */
+ hid_t type, space;
+ unsigned attr_crt_order_flags;
+ hid_t dcpl_id; /* dataset creation property list ID */
+ h5tools_str_t buffer; /* string into which to render */
+ hsize_t curr_pos = 0; /* total data element position */
HDmemset(&ctx, 0, sizeof(ctx));
ctx.indent_level = dump_indent / COL;
- ctx.cur_column = dump_indent;
+ ctx.cur_column = dump_indent;
string_dataformat = *outputformat;
if (fp_format) {
string_dataformat.fmt_double = fp_format;
- string_dataformat.fmt_float = fp_format;
+ string_dataformat.fmt_float = fp_format;
}
if (h5tools_nCols == 0) {
- string_dataformat.line_ncols = 65535;
+ string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
- outputformat = &string_dataformat;
+ string_dataformat.do_escape = dump_opts.display_escape;
+ outputformat = &string_dataformat;
if ((dcpl_id = H5Dget_create_plist(did)) < 0) {
error_msg("error in getting creation property list ID\n");
@@ -995,19 +964,19 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset)
ctx.need_prefix = TRUE;
h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- /* Render the element */
+ /* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s \"%s\" %s",
- h5tools_dump_header_format->datasetbegin, name,
- h5tools_dump_header_format->datasetblockbegin);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "%s \"%s\" %s", h5tools_dump_header_format->datasetbegin, name,
+ h5tools_dump_header_format->datasetblockbegin);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
h5tools_dump_comment(rawoutstream, outputformat, &ctx, did);
dump_indent += COL;
ctx.indent_level++;
- type = H5Dget_type(did);
+ type = H5Dget_type(did);
h5dump_type_table = type_table;
h5tools_dump_datatype(rawoutstream, outputformat, &ctx, type);
h5dump_type_table = NULL;
@@ -1016,71 +985,74 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset)
h5tools_dump_dataspace(rawoutstream, outputformat, &ctx, space);
H5Sclose(space);
- if(display_oid) {
+ if (dump_opts.display_oid) {
h5tools_dump_oid(rawoutstream, outputformat, &ctx, did);
}
- if(display_dcpl) {
+ if (dump_opts.display_dcpl) {
h5dump_type_table = type_table;
h5tools_dump_dcpl(rawoutstream, outputformat, &ctx, dcpl_id, type, did);
h5dump_type_table = NULL;
}
H5Pclose(dcpl_id);
- if(display_data) {
- unsigned data_loop = 1;
- unsigned u;
+ ctx.sset = sset;
+ ctx.display_index = dump_opts.display_ai;
+ ctx.display_char = dump_opts.display_char;
+ if (dump_opts.display_data) {
+ unsigned data_loop = 1;
+ unsigned u;
- if(display_packed_bits)
+ if (dump_opts.display_packed_bits)
data_loop = packed_bits_num;
- for(u = 0; u < data_loop; u++) {
- if(display_packed_bits) {
+ for (u = 0; u < data_loop; u++) {
+ if (dump_opts.display_packed_bits) {
ctx.need_prefix = TRUE;
h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
/* Render the element */
h5tools_str_reset(&buffer);
- packed_data_mask = packed_mask[u];
+ packed_data_mask = packed_mask[u];
packed_data_offset = packed_offset[u];
packed_data_length = packed_length[u];
h5tools_print_packed_bits(&buffer, type);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
}
- switch(H5Tget_class(type)) {
- case H5T_TIME:
- ctx.indent_level++;
-
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "DATA{ not yet implemented.}");
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ switch (H5Tget_class(type)) {
+ case H5T_TIME:
+ ctx.indent_level++;
- ctx.indent_level--;
- break;
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "DATA{ not yet implemented.}");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- case H5T_INTEGER:
- case H5T_FLOAT:
- case H5T_STRING:
- case H5T_BITFIELD:
- case H5T_OPAQUE:
- case H5T_COMPOUND:
- case H5T_REFERENCE:
- case H5T_ENUM:
- case H5T_VLEN:
- case H5T_ARRAY:
- {
- h5tools_dump_data(rawoutstream, outputformat, &ctx, did, TRUE, sset, display_ai, display_char);
- }
- break;
+ ctx.indent_level--;
+ break;
- case H5T_NO_CLASS:
- case H5T_NCLASSES:
- default:
- error_msg("invalid H5TCLASS type\n");
- break;
+ case H5T_INTEGER:
+ case H5T_FLOAT:
+ case H5T_STRING:
+ case H5T_BITFIELD:
+ case H5T_OPAQUE:
+ case H5T_COMPOUND:
+ case H5T_REFERENCE:
+ case H5T_ENUM:
+ case H5T_VLEN:
+ case H5T_ARRAY: {
+ h5tools_dump_data(rawoutstream, outputformat, &ctx, did, TRUE);
+ } break;
+
+ case H5T_NO_CLASS:
+ case H5T_NCLASSES:
+ default:
+ error_msg("invalid H5TCLASS type\n");
+ break;
} /* end switch */
- } /* for(u=0; u<data_loop; u++) */
+ } /* for(u=0; u<data_loop; u++) */
}
H5Tclose(type);
@@ -1095,14 +1067,15 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset)
/* Render the element */
h5tools_str_reset(&buffer);
- if(HDstrlen(h5tools_dump_header_format->datasetblockend)) {
+ if (HDstrlen(h5tools_dump_header_format->datasetblockend)) {
h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetblockend);
- if(HDstrlen(h5tools_dump_header_format->datasetend))
+ if (HDstrlen(h5tools_dump_header_format->datasetend))
h5tools_str_append(&buffer, " ");
}
- if(HDstrlen(h5tools_dump_header_format->datasetend))
+ if (HDstrlen(h5tools_dump_header_format->datasetend))
h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetend);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
h5tools_str_close(&buffer);
}
@@ -1113,20 +1086,13 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset)
* Purpose: Dump attribute or dataset data
*
* Return: void
- *
- * Programmer: Ruey-Hsia Li
- *
- * Modifications: pvn, print the matrix indices
- * Albert Cheng, 2004/11/18
- * Add --string printing for attributes too.
- *
*-------------------------------------------------------------------------
*/
void
dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_index)
{
- h5tools_context_t ctx; /* print context */
- h5tool_format_t *outputformat = &h5tools_dataformat;
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t * outputformat = &h5tools_dataformat;
h5tool_format_t string_dataformat;
int print_dataset = FALSE;
@@ -1134,160 +1100,174 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_index)
if (fp_format) {
string_dataformat.fmt_double = fp_format;
- string_dataformat.fmt_float = fp_format;
+ string_dataformat.fmt_float = fp_format;
}
if (h5tools_nCols == 0) {
- string_dataformat.line_ncols = 65535;
+ string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
- outputformat = &string_dataformat;
+ string_dataformat.do_escape = dump_opts.display_escape;
+ outputformat = &string_dataformat;
HDmemset(&ctx, 0, sizeof(ctx));
- ctx.indent_level = dump_indent / COL;
- ctx.cur_column = dump_indent;
+ ctx.indent_level = dump_indent / COL;
+ ctx.cur_column = dump_indent;
+ ctx.sset = sset;
+ ctx.display_index = display_index;
+ ctx.display_char = dump_opts.display_char;
- if(obj_data == DATASET_DATA)
+ if (obj_data == DATASET_DATA)
print_dataset = TRUE;
- h5tools_dump_data(rawoutstream, outputformat, &ctx, obj_id, print_dataset, sset, display_index, display_char);
+ h5tools_dump_data(rawoutstream, outputformat, &ctx, obj_id, print_dataset);
}
-
/*-------------------------------------------------------------------------
* Function: dump_fcpl
*
* Purpose: prints file creation property list information
*
* Return: void
- *
- * Programmer: pvn
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void
dump_fcpl(hid_t fid)
{
- hid_t fcpl; /* file creation property list ID */
- hsize_t userblock; /* userblock size retrieved from FCPL */
- size_t off_size; /* size of offsets in the file */
- size_t len_size; /* size of lengths in the file */
- H5F_fspace_strategy_t fs_strategy; /* file space strategy */
- hbool_t fs_persist; /* Persisting free-space or not */
- hsize_t fs_threshold; /* free-space section threshold */
- hsize_t fsp_size; /* file space page size */
- H5F_info2_t finfo; /* file information */
+ hid_t fcpl; /* file creation property list ID */
+ hsize_t userblock; /* userblock size retrieved from FCPL */
+ size_t off_size; /* size of offsets in the file */
+ size_t len_size; /* size of lengths in the file */
+ H5F_fspace_strategy_t fs_strategy; /* file space strategy */
+ hbool_t fs_persist; /* Persisting free-space or not */
+ hsize_t fs_threshold; /* free-space section threshold */
+ hsize_t fsp_size; /* file space page size */
+ H5F_info2_t finfo; /* file information */
#ifdef SHOW_FILE_DRIVER
- hid_t fapl; /* file access property list ID */
- hid_t fdriver; /* file driver */
- char dname[32]; /* buffer to store driver name */
+ hid_t fapl; /* file access property list ID */
+ hid_t fdriver; /* file driver */
+ char dname[32]; /* buffer to store driver name */
#endif
unsigned sym_lk; /* symbol table B-tree leaf 'K' value */
unsigned sym_ik; /* symbol table B-tree internal 'K' value */
unsigned istore_ik; /* indexed storage B-tree internal 'K' value */
- fcpl=H5Fget_create_plist(fid);
+ uint64_t supported = 0;
+
+ /* Dumping the information here only makes sense for the native
+ * VOL connector. The only VOL call here is H5Fget_info(), so we'll
+ * use that as a proxy for "native-ness". If that isn't supported, we'll
+ * just return.
+ */
+ H5VLquery_optional(fid, H5VL_SUBCLS_FILE, H5VL_NATIVE_FILE_GET_INFO, &supported);
+
+ if (!(supported & H5VL_OPT_QUERY_SUPPORTED))
+ return;
+
+ fcpl = H5Fget_create_plist(fid);
H5Fget_info2(fid, &finfo);
- H5Pget_userblock(fcpl,&userblock);
- H5Pget_sizes(fcpl,&off_size,&len_size);
- H5Pget_sym_k(fcpl,&sym_ik,&sym_lk);
- H5Pget_istore_k(fcpl,&istore_ik);
+ H5Pget_userblock(fcpl, &userblock);
+ H5Pget_sizes(fcpl, &off_size, &len_size);
+ H5Pget_sym_k(fcpl, &sym_ik, &sym_lk);
+ H5Pget_istore_k(fcpl, &istore_ik);
H5Pget_file_space_strategy(fcpl, &fs_strategy, &fs_persist, &fs_threshold);
H5Pget_file_space_page_size(fcpl, &fsp_size);
H5Pclose(fcpl);
#ifdef SHOW_FILE_DRIVER
- fapl=h5_fileaccess();
- fdriver=H5Pget_driver(fapl);
+ fapl = h5_fileaccess();
+ fdriver = H5Pget_driver(fapl);
H5Pclose(fapl);
#endif
- /*-------------------------------------------------------------------------
- * SUPER_BLOCK
- *-------------------------------------------------------------------------
- */
- PRINTSTREAM(rawoutstream, "\n%s %s\n",SUPER_BLOCK, BEGIN);
+ /*-------------------------------------------------------------------------
+ * SUPER_BLOCK
+ *-------------------------------------------------------------------------
+ */
+ PRINTSTREAM(rawoutstream, "\n%s %s\n", SUPER_BLOCK, BEGIN);
indentation(dump_indent + COL);
- PRINTSTREAM(rawoutstream, "%s %u\n","SUPERBLOCK_VERSION", finfo.super.version);
+ PRINTSTREAM(rawoutstream, "%s %u\n", "SUPERBLOCK_VERSION", finfo.super.version);
indentation(dump_indent + COL);
- PRINTSTREAM(rawoutstream, "%s %u\n","FREELIST_VERSION", finfo.free.version);
+ PRINTSTREAM(rawoutstream, "%s %u\n", "FREELIST_VERSION", finfo.free.version);
indentation(dump_indent + COL);
- PRINTSTREAM(rawoutstream, "%s %u\n","SYMBOLTABLE_VERSION", 0); /* Retain this for backward compatibility, for now (QAK) */
+ PRINTSTREAM(rawoutstream, "%s %u\n", "SYMBOLTABLE_VERSION",
+ 0); /* Retain this for backward compatibility, for now (QAK) */
indentation(dump_indent + COL);
- PRINTSTREAM(rawoutstream, "%s %u\n","OBJECTHEADER_VERSION", finfo.sohm.version);
+ PRINTSTREAM(rawoutstream, "%s %u\n", "OBJECTHEADER_VERSION", finfo.sohm.version);
indentation(dump_indent + COL);
- PRINTSTREAM(rawoutstream,"%s %zu\n","OFFSET_SIZE", off_size);
+ PRINTSTREAM(rawoutstream, "%s %zu\n", "OFFSET_SIZE", off_size);
indentation(dump_indent + COL);
- PRINTSTREAM(rawoutstream,"%s %zu\n","LENGTH_SIZE", len_size);
+ PRINTSTREAM(rawoutstream, "%s %zu\n", "LENGTH_SIZE", len_size);
indentation(dump_indent + COL);
- PRINTSTREAM(rawoutstream, "%s %u\n","BTREE_RANK", sym_ik);
+ PRINTSTREAM(rawoutstream, "%s %u\n", "BTREE_RANK", sym_ik);
indentation(dump_indent + COL);
- PRINTSTREAM(rawoutstream, "%s %d\n","BTREE_LEAF", sym_lk);
+ PRINTSTREAM(rawoutstream, "%s %d\n", "BTREE_LEAF", sym_lk);
#ifdef SHOW_FILE_DRIVER
- if(H5FD_CORE==fdriver)
- HDstrcpy(dname,"H5FD_CORE");
+ if (H5FD_CORE == fdriver)
+ HDstrcpy(dname, "H5FD_CORE");
#ifdef H5_HAVE_DIRECT
- else if(H5FD_DIRECT==fdriver)
- HDstrcpy(dname,"H5FD_DIRECT");
+ else if (H5FD_DIRECT == fdriver)
+ HDstrcpy(dname, "H5FD_DIRECT");
#endif
- else if(H5FD_FAMILY==fdriver)
- HDstrcpy(dname,"H5FD_FAMILY");
- else if(H5FD_LOG==fdriver)
- HDstrcpy(dname,"H5FD_LOG");
- else if(H5FD_MPIO==fdriver)
- HDstrcpy(dname,"H5FD_MPIO");
- else if(H5FD_MULTI==fdriver)
- HDstrcpy(dname,"H5FD_MULTI");
- else if(H5FD_SEC2==fdriver)
- HDstrcpy(dname,"H5FD_SEC2");
- else if(H5FD_STDIO==fdriver)
- HDstrcpy(dname,"H5FD_STDIO");
+ else if (H5FD_FAMILY == fdriver)
+ HDstrcpy(dname, "H5FD_FAMILY");
+ else if (H5FD_LOG == fdriver)
+ HDstrcpy(dname, "H5FD_LOG");
+ else if (H5FD_MPIO == fdriver)
+ HDstrcpy(dname, "H5FD_MPIO");
+ else if (H5FD_MULTI == fdriver)
+ HDstrcpy(dname, "H5FD_MULTI");
+ else if (H5FD_SEC2 == fdriver)
+ HDstrcpy(dname, "H5FD_SEC2");
+ else if (H5FD_STDIO == fdriver)
+ HDstrcpy(dname, "H5FD_STDIO");
else
- HDstrcpy(dname,"Unknown driver");
+ HDstrcpy(dname, "Unknown driver");
- /* Take out this because the driver used can be different from the
- * standard output. */
- /*indentation(dump_indent + COL);
- PRINTSTREAM(rawoutstream, "%s %s\n","FILE_DRIVER", dname);*/
+ /* Take out this because the driver used can be different from the
+ * standard output. */
+ /*indentation(dump_indent + COL);
+ PRINTSTREAM(rawoutstream, "%s %s\n","FILE_DRIVER", dname);*/
#endif
indentation(dump_indent + COL);
- PRINTSTREAM(rawoutstream, "%s %u\n","ISTORE_K", istore_ik);
+ PRINTSTREAM(rawoutstream, "%s %u\n", "ISTORE_K", istore_ik);
indentation(dump_indent + COL);
- if(fs_strategy == H5F_FSPACE_STRATEGY_FSM_AGGR) {
+ if (fs_strategy == H5F_FSPACE_STRATEGY_FSM_AGGR) {
PRINTSTREAM(rawoutstream, "%s %s\n", "FILE_SPACE_STRATEGY", "H5F_FSPACE_STRATEGY_FSM_AGGR");
- } else if(fs_strategy == H5F_FSPACE_STRATEGY_PAGE) {
+ }
+ else if (fs_strategy == H5F_FSPACE_STRATEGY_PAGE) {
PRINTSTREAM(rawoutstream, "%s %s\n", "FILE_SPACE_STRATEGY", "H5F_FSPACE_STRATEGY_PAGE");
- } else if(fs_strategy == H5F_FSPACE_STRATEGY_AGGR) {
+ }
+ else if (fs_strategy == H5F_FSPACE_STRATEGY_AGGR) {
PRINTSTREAM(rawoutstream, "%s %s\n", "FILE_SPACE_STRATEGY", "H5F_FSPACE_STRATEGY_AGGR");
- } else if(fs_strategy == H5F_FSPACE_STRATEGY_NONE) {
+ }
+ else if (fs_strategy == H5F_FSPACE_STRATEGY_NONE) {
PRINTSTREAM(rawoutstream, "%s %s\n", "FILE_SPACE_STRATEGY", "H5F_FSPACE_STRATEGY_NONE");
- } else
+ }
+ else
PRINTSTREAM(rawoutstream, "%s %s\n", "FILE_SPACE_STRATEGY", "Unknown strategy");
indentation(dump_indent + COL);
- PRINTSTREAM(rawoutstream, "%s %s\n","FREE_SPACE_PERSIST", fs_persist ? "TRUE" : "FALSE");
+ PRINTSTREAM(rawoutstream, "%s %s\n", "FREE_SPACE_PERSIST", fs_persist ? "TRUE" : "FALSE");
indentation(dump_indent + COL);
- PRINTSTREAM(rawoutstream, "%s %Hu\n","FREE_SPACE_SECTION_THRESHOLD", fs_threshold);
+ PRINTSTREAM(rawoutstream, "%s %" PRIuHSIZE "\n", "FREE_SPACE_SECTION_THRESHOLD", fs_threshold);
indentation(dump_indent + COL);
- PRINTSTREAM(rawoutstream, "%s %Hu\n","FILE_SPACE_PAGE_SIZE", fsp_size);
+ PRINTSTREAM(rawoutstream, "%s %" PRIuHSIZE "\n", "FILE_SPACE_PAGE_SIZE", fsp_size);
/*-------------------------------------------------------------------------
- * USER_BLOCK
- *-------------------------------------------------------------------------
- */
+ * USER_BLOCK
+ *-------------------------------------------------------------------------
+ */
indentation(dump_indent + COL);
- PRINTSTREAM(rawoutstream, "USER_BLOCK %s\n",BEGIN);
+ PRINTSTREAM(rawoutstream, "USER_BLOCK %s\n", BEGIN);
indentation(dump_indent + COL + COL);
- PRINTSTREAM(rawoutstream,"%s %Hu\n","USERBLOCK_SIZE", userblock);
+ PRINTSTREAM(rawoutstream, "%s %" PRIuHSIZE "\n", "USERBLOCK_SIZE", userblock);
indentation(dump_indent + COL);
- PRINTSTREAM(rawoutstream, "%s\n",END);
+ PRINTSTREAM(rawoutstream, "%s\n", END);
- PRINTSTREAM(rawoutstream, "%s",END);
+ PRINTSTREAM(rawoutstream, "%s", END);
}
/*-------------------------------------------------------------------------
@@ -1296,80 +1276,88 @@ dump_fcpl(hid_t fid)
* Purpose: prints all objects
*
* Return: void
- *
- * Programmer: pvn
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void
dump_fcontents(hid_t fid)
{
- PRINTSTREAM(rawoutstream, "%s %s\n",FILE_CONTENTS, BEGIN);
+ PRINTSTREAM(rawoutstream, "%s %s\n", FILE_CONTENTS, BEGIN);
- /* special case of unamed types in root group */
+ /* special case of unnamed types in root group */
if (unamedtype) {
unsigned u;
for (u = 0; u < type_table->nobjs; u++) {
- if (!type_table->objs[u].recorded)
- PRINTSTREAM(rawoutstream, " %-10s /#"H5_PRINTF_HADDR_FMT"\n", "datatype", type_table->objs[u].objno);
+ if (!type_table->objs[u].recorded) {
+ char *obj_tok_str = NULL;
+
+ H5Otoken_to_str(fid, &type_table->objs[u].obj_token, &obj_tok_str);
+ PRINTSTREAM(rawoutstream, " %-10s /#%s\n", "datatype", obj_tok_str);
+ H5free_memory(obj_tok_str);
+ }
}
}
/* print objects in the files */
h5trav_print(fid);
- PRINTSTREAM(rawoutstream, " %s\n",END);
+ PRINTSTREAM(rawoutstream, " %s\n", END);
}
static herr_t
attr_search(hid_t oid, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *ainfo, void *_op_data)
{
- herr_t ret = SUCCEED;
- int j;
- char *obj_op_name;
- char *obj_name;
- trav_attr_udata_t *attr_data = (trav_attr_udata_t*)_op_data;
- const char *buf = attr_data->path;
- const char *op_name = attr_data->op_name;
+ herr_t ret = SUCCEED;
+ int j;
+ char * obj_op_name;
+ char * obj_name;
+ trav_attr_udata_t *attr_data = (trav_attr_udata_t *)_op_data;
+ const char * buf = attr_data->path;
+ const char * op_name = attr_data->op_name;
j = (int)HDstrlen(op_name) - 1;
/* find the last / */
- while(j >= 0) {
- if(op_name[j] == '/' && (j == 0 || (j > 0 && op_name[j - 1] != '\\')))
+ while (j >= 0) {
+ if (op_name[j] == '/' && (j == 0 || (op_name[j - 1] != '\\')))
break;
j--;
}
obj_op_name = h5tools_str_replace(op_name + j + 1, "\\/", "/");
- if(obj_op_name == NULL) {
+ if (obj_op_name == NULL) {
h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
}
else {
- if(HDstrcmp(attr_name, obj_op_name)==0) {
+ if (HDstrcmp(attr_name, obj_op_name) == 0) {
size_t u, v, w;
/* object name */
- u = HDstrlen(buf);
- v = HDstrlen(op_name);
- w = u + 1 + v + 1 + 2;
+ u = HDstrlen(buf);
+ v = HDstrlen(op_name);
+ w = u + 1 + v + 1 + 2;
obj_name = (char *)HDmalloc(w);
- if(obj_name == NULL) {
+ if (obj_name == NULL) {
h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
}
else {
+ size_t buffer_space = w - 1;
+
HDmemset(obj_name, '\0', w);
- if(op_name[0] != '/') {
- HDstrncat(obj_name, buf, u + 1);
- if(buf[u - 1] != '/')
- HDstrncat(obj_name, "/", (size_t)2);
+ if (op_name[0] != '/') {
+ HDstrncat(obj_name, buf, buffer_space);
+ buffer_space -= MIN(buffer_space, u);
+
+ if (buf[u - 1] != '/') {
+ HDstrncat(obj_name, "/", buffer_space);
+ buffer_space -= MIN(buffer_space, 2);
+ }
}
- HDstrncat(obj_name, op_name, v + 1);
+
+ HDstrncat(obj_name, op_name, buffer_space);
+ buffer_space -= MIN(buffer_space, v);
handle_attributes(oid, obj_name, NULL, 0, NULL);
HDfree(obj_name);
@@ -1381,18 +1369,20 @@ attr_search(hid_t oid, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *a
} /* end attr_search() */
static herr_t
-obj_search(const char *path, const H5O_info_t *oi, const char H5_ATTR_UNUSED *already_visited, void *_op_data)
+obj_search(const char *path, const H5O_info2_t *oi, const char H5_ATTR_UNUSED *already_visited,
+ void *_op_data)
{
- trav_handle_udata_t *handle_data = (trav_handle_udata_t*)_op_data;
- const char *op_name = handle_data->op_name;
- trav_attr_udata_t attr_data;
+ trav_handle_udata_t *handle_data = (trav_handle_udata_t *)_op_data;
+ const char * op_name = handle_data->op_name;
+ trav_attr_udata_t attr_data;
- attr_data.path = path;
+ attr_data.path = path;
attr_data.op_name = op_name;
- H5Aiterate_by_name(handle_data->fid, path, H5_INDEX_NAME, H5_ITER_INC, NULL, attr_search, (void*)&attr_data, H5P_DEFAULT);
+ H5Aiterate_by_name(handle_data->fid, path, H5_INDEX_NAME, H5_ITER_INC, NULL, attr_search,
+ (void *)&attr_data, H5P_DEFAULT);
- if(HDstrcmp(path, op_name) == 0) {
- switch(oi->type) {
+ if (HDstrcmp(path, op_name) == 0) {
+ switch (oi->type) {
case H5O_TYPE_GROUP:
handle_groups(handle_data->fid, path, NULL, 0, NULL);
break;
@@ -1418,47 +1408,47 @@ obj_search(const char *path, const H5O_info_t *oi, const char H5_ATTR_UNUSED *al
} /* end obj_search() */
static herr_t
-lnk_search(const char *path, const H5L_info_t *li, void *_op_data)
+lnk_search(const char *path, const H5L_info2_t *li, void *_op_data)
{
- size_t search_len;
- size_t k;
- char *search_name;
- trav_handle_udata_t *handle_data = (trav_handle_udata_t*)_op_data;
- const char *op_name = handle_data->op_name;
+ size_t search_len;
+ size_t k;
+ char * search_name;
+ trav_handle_udata_t *handle_data = (trav_handle_udata_t *)_op_data;
+ const char * op_name = handle_data->op_name;
search_len = HDstrlen(op_name);
- if(search_len > 0 && op_name[0] != '/')
+ if (search_len > 0 && op_name[0] != '/')
k = 2;
else
k = 1;
search_name = (char *)HDmalloc(search_len + k);
- if(search_name == NULL) {
+ if (search_name == NULL) {
error_msg("creating temporary link\n");
h5tools_setstatus(EXIT_FAILURE);
}
else {
if (k == 2) {
HDstrcpy(search_name, "/");
- HDstrncat(search_name, op_name, search_len + 1);
+ HDstrcat(search_name, op_name);
}
else
- HDstrncpy(search_name, op_name, search_len + 1);
+ HDstrcpy(search_name, op_name);
search_name[search_len + k - 1] = '\0';
- if(HDstrcmp(path, search_name) == 0) {
- switch(li->type) {
- case H5L_TYPE_SOFT:
- case H5L_TYPE_EXTERNAL:
- handle_links(handle_data->fid, op_name, NULL, 0, NULL);
- break;
+ if (HDstrcmp(path, search_name) == 0) {
+ switch (li->type) {
+ case H5L_TYPE_SOFT:
+ case H5L_TYPE_EXTERNAL:
+ handle_links(handle_data->fid, op_name, NULL, 0, NULL);
+ break;
- case H5L_TYPE_HARD:
- case H5L_TYPE_MAX:
- case H5L_TYPE_ERROR:
- default:
- error_msg("unknown link type value\n");
- h5tools_setstatus(EXIT_FAILURE);
- break;
+ case H5L_TYPE_HARD:
+ case H5L_TYPE_MAX:
+ case H5L_TYPE_ERROR:
+ default:
+ error_msg("unknown link type value\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ break;
} /* end switch() */
}
HDfree(search_name);
@@ -1472,23 +1462,23 @@ lnk_search(const char *path, const H5L_info_t *li, void *_op_data)
* Purpose: Handle objects from the command.
*
* Return: void
- *
*-------------------------------------------------------------------------
*/
void
-handle_paths(hid_t fid, const char *path_name, void H5_ATTR_UNUSED * data, int H5_ATTR_UNUSED pe, const char H5_ATTR_UNUSED *display_name)
+handle_paths(hid_t fid, const char *path_name, void H5_ATTR_UNUSED *data, int H5_ATTR_UNUSED pe,
+ const char H5_ATTR_UNUSED *display_name)
{
- hid_t gid = -1;
+ hid_t gid = H5I_INVALID_HID;
- if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) {
+ if ((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) {
error_msg("unable to open root group\n");
h5tools_setstatus(EXIT_FAILURE);
}
else {
- hid_t gcpl_id;
- unsigned crt_order_flags;
- unsigned attr_crt_order_flags;
- trav_handle_udata_t handle_udata; /* User data for traversal */
+ hid_t gcpl_id;
+ unsigned crt_order_flags;
+ unsigned attr_crt_order_flags;
+ trav_handle_udata_t handle_udata; /* User data for traversal */
if ((gcpl_id = H5Gget_create_plist(gid)) < 0) {
error_msg("error in getting group creation property list ID\n");
@@ -1502,19 +1492,19 @@ handle_paths(hid_t fid, const char *path_name, void H5_ATTR_UNUSED * data, int H
}
/* query the group creation properties */
- if(H5Pget_link_creation_order(gcpl_id, &crt_order_flags) < 0) {
+ if (H5Pget_link_creation_order(gcpl_id, &crt_order_flags) < 0) {
error_msg("error in getting group creation properties\n");
h5tools_setstatus(EXIT_FAILURE);
}
- if(H5Pclose(gcpl_id) < 0) {
+ if (H5Pclose(gcpl_id) < 0) {
error_msg("error in closing group creation property list ID\n");
h5tools_setstatus(EXIT_FAILURE);
}
- handle_udata.fid = fid;
+ handle_udata.fid = fid;
handle_udata.op_name = path_name;
- if(h5trav_visit(fid, "/", TRUE, TRUE, obj_search, lnk_search, &handle_udata, H5O_INFO_BASIC) < 0) {
+ if (h5trav_visit(fid, "/", TRUE, TRUE, obj_search, lnk_search, &handle_udata, H5O_INFO_BASIC) < 0) {
error_msg("error traversing information\n");
h5tools_setstatus(EXIT_FAILURE);
}
@@ -1527,45 +1517,37 @@ handle_paths(hid_t fid, const char *path_name, void H5_ATTR_UNUSED * data, int H
* Purpose: Handle the attributes from the command.
*
* Return: void
- *
- * Programmer: Bill Wendling
- * Tuesday, 9. January 2001
- *
- * Modifications:
- *
- * PVN, May 2008
- * add an extra parameter PE, to allow printing/not printing of error messages
- *
*-------------------------------------------------------------------------
*/
void
-handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED * data, int H5_ATTR_UNUSED pe, const char H5_ATTR_UNUSED *display_name)
+handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED *data, int H5_ATTR_UNUSED pe,
+ const char H5_ATTR_UNUSED *display_name)
{
- hid_t oid = -1;
- hid_t attr_id = -1;
- char *obj_name = NULL;
- char *attr_name = NULL;
- int j;
- h5tools_str_t buffer; /* string into which to render */
- h5tools_context_t ctx; /* print context */
- h5tool_format_t *outputformat = &h5tools_dataformat;
+ hid_t oid = H5I_INVALID_HID;
+ hid_t attr_id = H5I_INVALID_HID;
+ char * obj_name = NULL;
+ char * attr_name = NULL;
+ int j;
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t * outputformat = &h5tools_dataformat;
h5tool_format_t string_dataformat;
- hsize_t curr_pos = 0; /* total data element position */
+ hsize_t curr_pos = 0; /* total data element position */
- j = (int)HDstrlen(attr) - 1;
+ j = (int)HDstrlen(attr) - 1;
obj_name = (char *)HDmalloc((size_t)j + 2);
- if(obj_name == NULL)
+ if (obj_name == NULL)
goto error;
/* find the last / */
- while(j >= 0) {
- if (attr[j] == '/' && (j==0 || (j>0 && attr[j-1]!='\\')))
+ while (j >= 0) {
+ if (attr[j] == '/' && (j == 0 || (attr[j - 1] != '\\')))
break;
j--;
}
/* object name */
- if(j == -1)
+ if (j == -1)
HDstrcpy(obj_name, "/");
else {
HDstrncpy(obj_name, attr, (size_t)j + 1);
@@ -1574,30 +1556,32 @@ handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED * data, int H
dump_indent += COL;
HDmemset(&ctx, 0, sizeof(ctx));
- ctx.indent_level = dump_indent / COL;
- ctx.cur_column = dump_indent;
+ ctx.indent_level = dump_indent / COL;
+ ctx.cur_column = dump_indent;
+ ctx.display_index = dump_opts.display_ai;
+ ctx.display_char = dump_opts.display_char;
string_dataformat = *outputformat;
if (fp_format) {
string_dataformat.fmt_double = fp_format;
- string_dataformat.fmt_float = fp_format;
+ string_dataformat.fmt_float = fp_format;
}
if (h5tools_nCols == 0) {
- string_dataformat.line_ncols = 65535;
+ string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
- outputformat = &string_dataformat;
+ string_dataformat.do_escape = dump_opts.display_escape;
+ outputformat = &string_dataformat;
attr_name = h5tools_str_replace(attr + j + 1, "\\/", "/");
/* handle error case: cannot open the object with the attribute */
- if((oid = H5Oopen(fid, obj_name, H5P_DEFAULT)) < 0) {
+ if ((oid = H5Oopen(fid, obj_name, H5P_DEFAULT)) < 0) {
/* setup */
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
@@ -1605,45 +1589,46 @@ handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED * data, int H
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s \"%s\" %s",
- h5tools_dump_header_format->attributebegin, attr,
- h5tools_dump_header_format->attributeblockbegin);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "%s \"%s\" %s", h5tools_dump_header_format->attributebegin, attr,
+ h5tools_dump_header_format->attributeblockbegin);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
error_msg("unable to open object \"%s\"\n", obj_name);
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- if(HDstrlen(h5tools_dump_header_format->attributeblockend)) {
+ if (HDstrlen(h5tools_dump_header_format->attributeblockend)) {
h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->attributeblockend);
- if(HDstrlen(h5tools_dump_header_format->attributeend))
+ if (HDstrlen(h5tools_dump_header_format->attributeend))
h5tools_str_append(&buffer, " ");
}
- if(HDstrlen(h5tools_dump_header_format->attributeend))
+ if (HDstrlen(h5tools_dump_header_format->attributeend))
h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->attributeend);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
h5tools_str_close(&buffer);
goto error;
} /* end if */
- attr_id = H5Aopen(oid, attr_name, H5P_DEFAULT);
- oid_output = display_oid;
- data_output = display_data;
- attr_data_output = display_attr_data;
+ attr_id = H5Aopen(oid, attr_name, H5P_DEFAULT);
+ oid_output = dump_opts.display_oid;
+ data_output = dump_opts.display_data;
+ attr_data_output = dump_opts.display_attr_data;
h5dump_type_table = type_table;
- h5tools_dump_attribute(rawoutstream, outputformat, &ctx, attr_name, attr_id, display_ai, display_char);
+ h5tools_dump_attribute(rawoutstream, outputformat, &ctx, attr_name, attr_id);
h5dump_type_table = NULL;
- if(attr_id < 0) {
+ if (attr_id < 0) {
goto error;
}
/* Close object */
- if(H5Oclose(oid) < 0) {
+ if (H5Oclose(oid) < 0) {
goto error;
} /* end if */
@@ -1654,16 +1639,18 @@ handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED * data, int H
error:
h5tools_setstatus(EXIT_FAILURE);
- if(obj_name)
+ if (obj_name)
HDfree(obj_name);
if (attr_name)
HDfree(attr_name);
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Oclose(oid);
H5Aclose(attr_id);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
dump_indent -= COL;
}
@@ -1673,89 +1660,76 @@ error:
* Purpose: Handle the datasets from the command.
*
* Return: void
- *
- * Programmer: Bill Wendling
- * Tuesday, 9. January 2001
- *
- * Modifications:
- * Pedro Vicente, Tuesday, January 15, 2008
- * check for block overlap\
- *
- * Pedro Vicente, May 8, 2008
- * added a flag PE that prints/not prints error messages
- * added for cases of external links not found, to avoid printing of
- * objects not found, since external links are dumped on a trial error basis
- *
*-------------------------------------------------------------------------
*/
void
handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *display_name)
{
- H5O_info_t oinfo;
+ H5O_info2_t oinfo;
hid_t dsetid;
- hid_t dapl_id = H5P_DEFAULT; /* dataset access property list ID */
- struct subset_t *sset = (struct subset_t *)data;
- const char *real_name = display_name ? display_name : dset;
+ hid_t dapl_id = H5P_DEFAULT; /* dataset access property list ID */
+ struct subset_t *sset = (struct subset_t *)data;
+ const char * real_name = display_name ? display_name : dset;
- if(display_data) {
+ if (dump_opts.display_data) {
if ((dapl_id = H5Pcreate(H5P_DATASET_ACCESS)) < 0) {
error_msg("error in creating default access property list ID\n");
}
- if (display_vds_first) {
- if(H5Pset_virtual_view(dapl_id, H5D_VDS_FIRST_MISSING) < 0)
+ if (dump_opts.display_vds_first) {
+ if (H5Pset_virtual_view(dapl_id, H5D_VDS_FIRST_MISSING) < 0)
error_msg("error in setting access property list ID, virtual_view\n");
}
- if (vds_gap_size > 0) {
- if(H5Pset_virtual_printf_gap(dapl_id, (hsize_t)vds_gap_size) < 0)
+ if (dump_opts.vds_gap_size > 0) {
+ if (H5Pset_virtual_printf_gap(dapl_id, (hsize_t)dump_opts.vds_gap_size) < 0)
error_msg("error in setting access property list ID, virtual_printf_gap\n");
}
}
- if((dsetid = H5Dopen2(fid, dset, dapl_id)) < 0) {
+ if ((dsetid = H5Dopen2(fid, dset, dapl_id)) < 0) {
if (pe)
handle_links(fid, dset, data, pe, display_name);
return;
} /* end if */
- if(sset) {
+ if (sset) {
unsigned int i;
unsigned int ndims;
- hid_t sid = H5Dget_space(dsetid);
- int ndims_res = H5Sget_simple_extent_ndims(sid);
+ hid_t sid = H5Dget_space(dsetid);
+ int ndims_res = H5Sget_simple_extent_ndims(sid);
H5Sclose(sid);
- if(ndims_res < 0) {
+ if (ndims_res < 0) {
error_msg("H5Sget_simple_extent_ndims failed\n");
h5tools_setstatus(EXIT_FAILURE);
return;
}
ndims = (unsigned)ndims_res;
- if(!sset->start.data || !sset->stride.data || !sset->count.data || !sset->block.data) {
+ if (!sset->start.data || !sset->stride.data || !sset->count.data || !sset->block.data) {
/* they didn't specify a ``stride'' or ``block''. default to 1 in all
* dimensions */
- if(!sset->start.data) {
+ if (!sset->start.data) {
/* default to (0, 0, ...) for the start coord */
sset->start.data = (hsize_t *)HDcalloc((size_t)ndims, sizeof(hsize_t));
- sset->start.len = ndims;
+ sset->start.len = ndims;
}
- if(!sset->stride.data) {
+ if (!sset->stride.data) {
sset->stride.data = (hsize_t *)HDcalloc((size_t)ndims, sizeof(hsize_t));
- sset->stride.len = ndims;
+ sset->stride.len = ndims;
for (i = 0; i < ndims; i++)
sset->stride.data[i] = 1;
}
- if(!sset->count.data) {
+ if (!sset->count.data) {
sset->count.data = (hsize_t *)HDcalloc((size_t)ndims, sizeof(hsize_t));
- sset->count.len = ndims;
+ sset->count.len = ndims;
for (i = 0; i < ndims; i++)
sset->count.data[i] = 1;
}
- if(!sset->block.data) {
+ if (!sset->block.data) {
sset->block.data = (hsize_t *)HDcalloc((size_t)ndims, sizeof(hsize_t));
- sset->block.len = ndims;
+ sset->block.len = ndims;
for (i = 0; i < ndims; i++)
sset->block.data[i] = 1;
}
@@ -1765,22 +1739,22 @@ handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *dis
* check for dimension overflow
*-------------------------------------------------------------------------
*/
- if(sset->start.len > ndims) {
+ if (sset->start.len > ndims) {
error_msg("number of start dims (%u) exceed dataset dims (%u)\n", sset->start.len, ndims);
h5tools_setstatus(EXIT_FAILURE);
return;
}
- if(sset->stride.len > ndims) {
+ if (sset->stride.len > ndims) {
error_msg("number of stride dims (%u) exceed dataset dims (%u)\n", sset->stride.len, ndims);
h5tools_setstatus(EXIT_FAILURE);
return;
}
- if(sset->count.len > ndims) {
+ if (sset->count.len > ndims) {
error_msg("number of count dims (%u) exceed dataset dims (%u)\n", sset->count.len, ndims);
h5tools_setstatus(EXIT_FAILURE);
return;
}
- if(sset->block.len > ndims) {
+ if (sset->block.len > ndims) {
error_msg("number of block dims (%u) exceed dataset dims (%u)\n", sset->block.len, ndims);
h5tools_setstatus(EXIT_FAILURE);
return;
@@ -1790,29 +1764,29 @@ handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *dis
* check for block overlap
*-------------------------------------------------------------------------
*/
- for(i = 0; i < ndims; i++) {
- if(sset->count.data[i] > 1) {
- if(sset->stride.data[i] < sset->block.data[i]) {
+ for (i = 0; i < ndims; i++) {
+ if (sset->count.data[i] > 1) {
+ if (sset->stride.data[i] < sset->block.data[i]) {
error_msg("wrong subset selection; blocks overlap\n");
h5tools_setstatus(EXIT_FAILURE);
return;
} /* end if */
- } /* end if */
- } /* end for */
- } /* end if */
-
+ } /* end if */
+ } /* end for */
+ } /* end if */
- H5Oget_info2(dsetid, &oinfo, H5O_INFO_BASIC);
- if(oinfo.rc > 1 || hit_elink) {
- obj_t *found_obj; /* Found object */
+ H5Oget_info3(dsetid, &oinfo, H5O_INFO_BASIC);
+ if (oinfo.rc > 1 || hit_elink) {
+ obj_t *found_obj; /* Found object */
- found_obj = search_obj(dset_table, oinfo.addr);
+ found_obj = search_obj(dset_table, &oinfo.token);
- if(found_obj) {
+ if (found_obj) {
if (found_obj->displayed) {
PRINTVALSTREAM(rawoutstream, "\n");
indentation(dump_indent);
- begin_obj(h5tools_dump_header_format->datasetbegin, real_name, h5tools_dump_header_format->datasetblockbegin);
+ begin_obj(h5tools_dump_header_format->datasetbegin, real_name,
+ h5tools_dump_header_format->datasetblockbegin);
PRINTVALSTREAM(rawoutstream, "\n");
indentation(dump_indent + COL);
PRINTSTREAM(rawoutstream, "%s \"%s\"\n", HARDLINK, found_obj->objname);
@@ -1836,7 +1810,7 @@ handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *dis
}
if (dapl_id != H5P_DEFAULT)
H5Pclose(dapl_id);
- if(H5Dclose(dsetid) < 0)
+ if (H5Dclose(dsetid) < 0)
h5tools_setstatus(EXIT_FAILURE);
}
@@ -1846,30 +1820,19 @@ handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *dis
* Purpose: Handle the groups from the command.
*
* Return: void
- *
- * Programmer: Bill Wendling
- * Tuesday, 9. January 2001
- *
- * Modifications: Pedro Vicente, September 26, 2007
- * handle creation order
- *
- * Pedro Vicente, May 8, 2008
- * added a flag PE that prints/not prints error messages
- * added for cases of external links not found, to avoid printing of
- * objects not found, since external links are dumped on a trial error basis
- *
*-------------------------------------------------------------------------
*/
void
handle_groups(hid_t fid, const char *group, void H5_ATTR_UNUSED *data, int pe, const char *display_name)
{
hid_t gid;
- const char *real_name = display_name ? display_name : group;
+ const char *real_name = display_name ? display_name : group;
- if((gid = H5Gopen2(fid, group, H5P_DEFAULT)) < 0) {
+ if ((gid = H5Gopen2(fid, group, H5P_DEFAULT)) < 0) {
if (pe) {
PRINTVALSTREAM(rawoutstream, "\n");
- begin_obj(h5tools_dump_header_format->groupbegin, real_name, h5tools_dump_header_format->groupblockbegin);
+ begin_obj(h5tools_dump_header_format->groupbegin, real_name,
+ h5tools_dump_header_format->groupblockbegin);
PRINTVALSTREAM(rawoutstream, "\n");
indentation(COL);
error_msg("unable to open group \"%s\"\n", real_name);
@@ -1880,9 +1843,9 @@ handle_groups(hid_t fid, const char *group, void H5_ATTR_UNUSED *data, int pe, c
else {
size_t new_len = HDstrlen(group) + 1;
- if(prefix_len <= new_len) {
+ if (prefix_len <= new_len) {
prefix_len = new_len;
- prefix = (char *)HDrealloc(prefix, prefix_len);
+ prefix = (char *)HDrealloc(prefix, prefix_len);
} /* end if */
HDstrcpy(prefix, group);
@@ -1891,7 +1854,7 @@ handle_groups(hid_t fid, const char *group, void H5_ATTR_UNUSED *data, int pe, c
dump_group(gid, real_name);
dump_indent -= COL;
- if(H5Gclose(gid) < 0)
+ if (H5Gclose(gid) < 0)
h5tools_setstatus(EXIT_FAILURE);
} /* end else */
} /* end handle_groups() */
@@ -1902,24 +1865,19 @@ handle_groups(hid_t fid, const char *group, void H5_ATTR_UNUSED *data, int pe, c
* Purpose: Handle soft or UD links from the command.
*
* Return: void
- *
- * Programmer: Bill Wendling
- * Tuesday, 9. January 2001
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void
-handle_links(hid_t fid, const char *links, void H5_ATTR_UNUSED * data, int H5_ATTR_UNUSED pe, const char H5_ATTR_UNUSED *display_name)
+handle_links(hid_t fid, const char *links, void H5_ATTR_UNUSED *data, int H5_ATTR_UNUSED pe,
+ const char H5_ATTR_UNUSED *display_name)
{
- H5L_info_t linfo;
+ H5L_info2_t linfo;
- if(H5Lget_info(fid, links, &linfo, H5P_DEFAULT) < 0) {
+ if (H5Lget_info2(fid, links, &linfo, H5P_DEFAULT) < 0) {
error_msg("unable to get link info from \"%s\"\n", links);
h5tools_setstatus(EXIT_FAILURE);
}
- else if(linfo.type == H5L_TYPE_HARD) {
+ else if (linfo.type == H5L_TYPE_HARD) {
error_msg("\"%s\" is a hard link\n", links);
h5tools_setstatus(EXIT_FAILURE);
}
@@ -1927,56 +1885,60 @@ handle_links(hid_t fid, const char *links, void H5_ATTR_UNUSED * data, int H5_AT
char *buf = (char *)HDmalloc(linfo.u.val_size);
PRINTVALSTREAM(rawoutstream, "\n");
- switch(linfo.type) {
- case H5L_TYPE_SOFT: /* Soft link */
- begin_obj(h5tools_dump_header_format->softlinkbegin, links, h5tools_dump_header_format->softlinkblockbegin);
- PRINTVALSTREAM(rawoutstream, "\n");
- indentation(COL);
- if(H5Lget_val(fid, links, buf, linfo.u.val_size, H5P_DEFAULT) >= 0) {
- PRINTSTREAM(rawoutstream, "LINKTARGET \"%s\"\n", buf);
- }
- else {
- error_msg("h5dump error: unable to get link value for \"%s\"\n", links);
- h5tools_setstatus(EXIT_FAILURE);
- }
- end_obj(h5tools_dump_header_format->softlinkend, h5tools_dump_header_format->softlinkblockend);
- break;
+ switch (linfo.type) {
+ case H5L_TYPE_SOFT: /* Soft link */
+ begin_obj(h5tools_dump_header_format->softlinkbegin, links,
+ h5tools_dump_header_format->softlinkblockbegin);
+ PRINTVALSTREAM(rawoutstream, "\n");
+ indentation(COL);
+ if (H5Lget_val(fid, links, buf, linfo.u.val_size, H5P_DEFAULT) >= 0) {
+ PRINTSTREAM(rawoutstream, "LINKTARGET \"%s\"\n", buf);
+ }
+ else {
+ error_msg("h5dump error: unable to get link value for \"%s\"\n", links);
+ h5tools_setstatus(EXIT_FAILURE);
+ }
+ end_obj(h5tools_dump_header_format->softlinkend,
+ h5tools_dump_header_format->softlinkblockend);
+ break;
- case H5L_TYPE_EXTERNAL:
- begin_obj(h5tools_dump_header_format->extlinkbegin, links, h5tools_dump_header_format->extlinkblockbegin);
- PRINTVALSTREAM(rawoutstream, "\n");
- if(H5Lget_val(fid, links, buf, linfo.u.val_size, H5P_DEFAULT) >= 0) {
- const char *elink_file;
- const char *elink_path;
-
- if(H5Lunpack_elink_val(buf, linfo.u.val_size, NULL, &elink_file, &elink_path)>=0) {
- indentation(COL);
- PRINTSTREAM(rawoutstream, "TARGETFILE \"%s\"\n", elink_file);
- indentation(COL);
- PRINTSTREAM(rawoutstream, "TARGETPATH \"%s\"\n", elink_path);
+ case H5L_TYPE_EXTERNAL:
+ begin_obj(h5tools_dump_header_format->extlinkbegin, links,
+ h5tools_dump_header_format->extlinkblockbegin);
+ PRINTVALSTREAM(rawoutstream, "\n");
+ if (H5Lget_val(fid, links, buf, linfo.u.val_size, H5P_DEFAULT) >= 0) {
+ const char *elink_file;
+ const char *elink_path;
+
+ if (H5Lunpack_elink_val(buf, linfo.u.val_size, NULL, &elink_file, &elink_path) >= 0) {
+ indentation(COL);
+ PRINTSTREAM(rawoutstream, "TARGETFILE \"%s\"\n", elink_file);
+ indentation(COL);
+ PRINTSTREAM(rawoutstream, "TARGETPATH \"%s\"\n", elink_path);
+ }
+ else {
+ error_msg("h5dump error: unable to unpack external link value for \"%s\"\n", links);
+ h5tools_setstatus(EXIT_FAILURE);
+ }
}
else {
- error_msg("h5dump error: unable to unpack external link value for \"%s\"\n", links);
+ error_msg("h5dump error: unable to get external link value for \"%s\"\n", links);
h5tools_setstatus(EXIT_FAILURE);
}
- }
- else {
- error_msg("h5dump error: unable to get external link value for \"%s\"\n", links);
- h5tools_setstatus(EXIT_FAILURE);
- }
- end_obj(h5tools_dump_header_format->extlinkend, h5tools_dump_header_format->extlinkblockend);
- break;
+ end_obj(h5tools_dump_header_format->extlinkend, h5tools_dump_header_format->extlinkblockend);
+ break;
- case H5L_TYPE_ERROR:
- case H5L_TYPE_MAX:
- case H5L_TYPE_HARD:
- default:
- begin_obj(h5tools_dump_header_format->udlinkbegin, links, h5tools_dump_header_format->udlinkblockbegin);
- PRINTVALSTREAM(rawoutstream, "\n");
- indentation(COL);
- PRINTSTREAM(rawoutstream, "LINKCLASS %d\n", linfo.type);
- end_obj(h5tools_dump_header_format->udlinkend, h5tools_dump_header_format->udlinkblockend);
- break;
+ case H5L_TYPE_ERROR:
+ case H5L_TYPE_MAX:
+ case H5L_TYPE_HARD:
+ default:
+ begin_obj(h5tools_dump_header_format->udlinkbegin, links,
+ h5tools_dump_header_format->udlinkblockbegin);
+ PRINTVALSTREAM(rawoutstream, "\n");
+ indentation(COL);
+ PRINTSTREAM(rawoutstream, "LINKCLASS %d\n", linfo.type);
+ end_obj(h5tools_dump_header_format->udlinkend, h5tools_dump_header_format->udlinkblockend);
+ break;
} /* end switch */
HDfree(buf);
} /* end else */
@@ -1988,58 +1950,53 @@ handle_links(hid_t fid, const char *links, void H5_ATTR_UNUSED * data, int H5_AT
* Purpose: Handle the datatypes from the command.
*
* Return: void
- *
- * Programmer: Bill Wendling
- * Tuesday, 9. January 2001
- *
- * Modifications:
- *
- * Pedro Vicente, May 8, 2008
- * added a flag PE that prints/not prints error messages
- * added for cases of external links not found, to avoid printing of
- * objects not found, since external links are dumped on a trial error basis
- *
*-------------------------------------------------------------------------
*/
void
-handle_datatypes(hid_t fid, const char *type, void H5_ATTR_UNUSED * data, int pe, const char *display_name)
+handle_datatypes(hid_t fid, const char *type, void H5_ATTR_UNUSED *data, int pe, const char *display_name)
{
hid_t type_id;
- const char *real_name = display_name ? display_name : type;
+ const char *real_name = display_name ? display_name : type;
- if((type_id = H5Topen2(fid, type, H5P_DEFAULT)) < 0) {
- /* check if type is unamed datatype */
+ if ((type_id = H5Topen2(fid, type, H5P_DEFAULT)) < 0) {
+ /* check if type is unnamed datatype */
unsigned idx = 0;
- while(idx < type_table->nobjs ) {
+ while (idx < type_table->nobjs) {
char name[128];
- if(!type_table->objs[idx].recorded) {
- /* unamed datatype */
- HDsprintf(name, "/#"H5_PRINTF_HADDR_FMT, type_table->objs[idx].objno);
+ if (!type_table->objs[idx].recorded) {
+ char *obj_tok_str = NULL;
- if(!HDstrcmp(name, real_name))
+ /* unnamed datatype */
+ H5Otoken_to_str(fid, &type_table->objs[idx].obj_token, &obj_tok_str);
+ HDsnprintf(name, sizeof(name), "/#%s", obj_tok_str);
+ H5free_memory(obj_tok_str);
+
+ if (!HDstrcmp(name, real_name))
break;
} /* end if */
idx++;
} /* end while */
- if(idx == type_table->nobjs) {
+ if (idx == type_table->nobjs) {
if (pe) {
/* unknown type */
PRINTVALSTREAM(rawoutstream, "\n");
- begin_obj(h5tools_dump_header_format->datatypebegin, real_name, h5tools_dump_header_format->datatypeblockbegin);
+ begin_obj(h5tools_dump_header_format->datatypebegin, real_name,
+ h5tools_dump_header_format->datatypeblockbegin);
PRINTVALSTREAM(rawoutstream, "\n");
indentation(COL);
error_msg("unable to open datatype \"%s\"\n", real_name);
- end_obj(h5tools_dump_header_format->datatypeend, h5tools_dump_header_format->datatypeblockend);
+ end_obj(h5tools_dump_header_format->datatypeend,
+ h5tools_dump_header_format->datatypeblockend);
h5tools_setstatus(EXIT_FAILURE);
}
}
else {
hid_t dsetid = H5Dopen2(fid, type_table->objs[idx].objname, H5P_DEFAULT);
- type_id = H5Dget_type(dsetid);
+ type_id = H5Dget_type(dsetid);
dump_indent += COL;
dump_named_datatype(type_id, real_name);
@@ -2054,28 +2011,18 @@ handle_datatypes(hid_t fid, const char *type, void H5_ATTR_UNUSED * data, int pe
dump_named_datatype(type_id, real_name);
dump_indent -= COL;
- if(H5Tclose(type_id) < 0)
+ if (H5Tclose(type_id) < 0)
h5tools_setstatus(EXIT_FAILURE);
}
}
-
/*-------------------------------------------------------------------------
* Function: dump_extlink
*
- * made by: PVN
- *
* Purpose: Dump an external link
- * Since external links are soft links, they are dumped on a trial error
- * basis, attempting to dump as a dataset, as a group and as a named datatype
- * Error messages are supressed
- *
- * Modifications:
- * Neil Fortner
- * 13 October 2008
- * Function basically rewritten. No longer directly opens the target file,
- * now initializes a new set of tables for the external file. No longer
- * dumps on a trial and error basis, but errors are still suppressed.
+ * Function does not directly open the target file,
+ * it initializes a new set of tables for the external file.
+ * Errors are suppressed.
*
*-------------------------------------------------------------------------
*/
@@ -2083,10 +2030,10 @@ static int
dump_extlink(hid_t group, const char *linkname, const char *objname)
{
hid_t oid;
- H5O_info_t oi;
- table_t *old_group_table = group_table;
- table_t *old_dset_table = dset_table;
- table_t *old_type_table = type_table;
+ H5O_info2_t oi;
+ table_t * old_group_table = group_table;
+ table_t * old_dset_table = dset_table;
+ table_t * old_type_table = type_table;
hbool_t old_hit_elink;
ssize_t idx;
@@ -2095,7 +2042,7 @@ dump_extlink(hid_t group, const char *linkname, const char *objname)
goto fail;
/* Get object info */
- if (H5Oget_info2(oid, &oi, H5O_INFO_BASIC) < 0) {
+ if (H5Oget_info3(oid, &oi, H5O_INFO_BASIC) < 0) {
H5Oclose(oid);
goto fail;
}
@@ -2113,12 +2060,12 @@ dump_extlink(hid_t group, const char *linkname, const char *objname)
if (idx) {
/* Update table pointers */
group_table = table_list.tables[idx].group_table;
- dset_table = table_list.tables[idx].dset_table;
- type_table = table_list.tables[idx].type_table;
+ dset_table = table_list.tables[idx].dset_table;
+ type_table = table_list.tables[idx].type_table;
/* We will now traverse the external link, set this global to indicate this */
old_hit_elink = hit_elink;
- hit_elink = TRUE;
+ hit_elink = TRUE;
/* add some indentation to distinguish that these objects are external */
dump_indent += COL;
@@ -2148,8 +2095,8 @@ dump_extlink(hid_t group, const char *linkname, const char *objname)
/* Reset table pointers */
group_table = old_group_table;
- dset_table = old_dset_table;
- type_table = old_type_table;
+ dset_table = old_dset_table;
+ type_table = old_type_table;
/* Reset hit_elink */
hit_elink = old_hit_elink;
@@ -2163,4 +2110,3 @@ dump_extlink(hid_t group, const char *linkname, const char *objname)
fail:
return FAIL;
}
-
diff --git a/tools/src/h5dump/h5dump_ddl.h b/tools/src/h5dump/h5dump_ddl.h
index ae01086..8487270 100644
--- a/tools/src/h5dump/h5dump_ddl.h
+++ b/tools/src/h5dump/h5dump_ddl.h
@@ -6,13 +6,13 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#ifndef H5DUMP_DDL_H__
-#define H5DUMP_DDL_H__
+#ifndef H5DUMP_DDL_H
+#define H5DUMP_DDL_H
#ifdef __cplusplus
extern "C" {
@@ -20,17 +20,17 @@ extern "C" {
/* The dump functions of the dump_function_table */
/* standard format: no change */
-void dump_group(hid_t, const char *);
-void dump_named_datatype(hid_t, const char *);
-void dump_dataset(hid_t, const char *, struct subset_t *);
-void dump_dataspace(hid_t space);
-void dump_datatype(hid_t type);
-void dump_data(hid_t, int, struct subset_t *, int);
-void dump_fcpl(hid_t fid);
-void dump_fcontents(hid_t fid);
+void dump_group(hid_t, const char *);
+void dump_named_datatype(hid_t, const char *);
+void dump_dataset(hid_t, const char *, struct subset_t *);
+void dump_dataspace(hid_t space);
+void dump_datatype(hid_t type);
+void dump_data(hid_t, int, struct subset_t *, int);
+void dump_fcpl(hid_t fid);
+void dump_fcontents(hid_t fid);
/* callback function used by H5Aiterate2() */
-herr_t dump_attr_cb(hid_t loc_id, const char *attr_name, const H5A_info_t *info, void *_op_data);
+herr_t dump_attr_cb(hid_t loc_id, const char *attr_name, const H5A_info_t *info, void *_op_data);
/* other iteration functions */
void link_iteration(hid_t gid, unsigned crt_order_flags);
@@ -38,13 +38,16 @@ void attr_iteration(hid_t gid, unsigned attr_crt_order_flags);
void handle_paths(hid_t fid, const char *path_name, void *data, int pe, const char *display_name);
void handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *display_name);
-void handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED * data, int H5_ATTR_UNUSED pe, const char H5_ATTR_UNUSED *display_name);
+void handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED *data, int H5_ATTR_UNUSED pe,
+ const char H5_ATTR_UNUSED *display_name);
void handle_groups(hid_t fid, const char *group, void H5_ATTR_UNUSED *data, int pe, const char *display_name);
-void handle_links(hid_t fid, const char *links, void H5_ATTR_UNUSED * data, int H5_ATTR_UNUSED pe, const char H5_ATTR_UNUSED *display_name);
-void handle_datatypes(hid_t fid, const char *type, void H5_ATTR_UNUSED * data, int pe, const char *display_name);
+void handle_links(hid_t fid, const char *links, void H5_ATTR_UNUSED *data, int H5_ATTR_UNUSED pe,
+ const char H5_ATTR_UNUSED *display_name);
+void handle_datatypes(hid_t fid, const char *type, void H5_ATTR_UNUSED *data, int pe,
+ const char *display_name);
#ifdef __cplusplus
}
#endif
-#endif /* !H5DUMP_DDL_H__ */
+#endif /* H5DUMP_DDL_H */
diff --git a/tools/src/h5dump/h5dump_defines.h b/tools/src/h5dump/h5dump_defines.h
index 7a9d4c0..21a31dd 100644
--- a/tools/src/h5dump/h5dump_defines.h
+++ b/tools/src/h5dump/h5dump_defines.h
@@ -6,49 +6,48 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#ifndef H5DUMP_DEFINES_H__
-#define H5DUMP_DEFINES_H__
+#ifndef H5DUMP_DEFINES_H
+#define H5DUMP_DEFINES_H
-#define H5DUMP_MAX_RANK H5S_MAX_RANK
+#define H5DUMP_MAX_RANK H5S_MAX_RANK
-#define ATTRIBUTE_DATA 0
-#define DATASET_DATA 1
-#define ENUM_DATA 2
-#define COL 3
+#define ATTRIBUTE_DATA 0
+#define DATASET_DATA 1
+#define ENUM_DATA 2
+#define COL 3
/* Macros for displaying objects */
-#define begin_obj(obj,name,begin) \
- do { \
- if ((name)) { \
- PRINTSTREAM(rawoutstream, "%s \"%s\" %s", (obj), (name), (begin)); \
- } \
- else { \
- PRINTSTREAM(rawoutstream, "%s %s", (obj), (begin)); \
- } \
- } while(0);
-
-#define end_obj(obj,end) \
- do { \
- if(HDstrlen(end)) { \
- PRINTSTREAM(rawoutstream, "%s", end); \
- if(HDstrlen(obj)) \
- PRINTVALSTREAM(rawoutstream, " "); \
- } \
- if(HDstrlen(obj)) \
- PRINTSTREAM(rawoutstream, "%s", obj); \
- } while(0);
+#define begin_obj(obj, name, begin) \
+ do { \
+ if ((name)) { \
+ PRINTSTREAM(rawoutstream, "%s \"%s\" %s", (obj), (name), (begin)); \
+ } \
+ else { \
+ PRINTSTREAM(rawoutstream, "%s %s", (obj), (begin)); \
+ } \
+ } while (0);
+#define end_obj(obj, end) \
+ do { \
+ if (HDstrlen(end)) { \
+ PRINTSTREAM(rawoutstream, "%s", end); \
+ if (HDstrlen(obj)) \
+ PRINTVALSTREAM(rawoutstream, " "); \
+ } \
+ if (HDstrlen(obj)) \
+ PRINTSTREAM(rawoutstream, "%s", obj); \
+ } while (0);
/* 3 private values: can't be set, but can be read.
Note: these are defined in H5Zprivate, they are
duplicated here.
*/
-#define H5_SZIP_LSB_OPTION_MASK 8
-#define H5_SZIP_MSB_OPTION_MASK 16
-#define H5_SZIP_RAW_OPTION_MASK 128
+#define H5_SZIP_LSB_OPTION_MASK 8
+#define H5_SZIP_MSB_OPTION_MASK 16
+#define H5_SZIP_RAW_OPTION_MASK 128
-#endif /* !H5DUMP_DEFINES_H__ */
+#endif /* H5DUMP_DEFINES_H */
diff --git a/tools/src/h5dump/h5dump_extern.h b/tools/src/h5dump/h5dump_extern.h
index 00d3bd2..308f602 100644
--- a/tools/src/h5dump/h5dump_extern.h
+++ b/tools/src/h5dump/h5dump_extern.h
@@ -6,12 +6,12 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#ifndef H5DUMP_EXTERN_H__
-#define H5DUMP_EXTERN_H__
+#ifndef H5DUMP_EXTERN_H
+#define H5DUMP_EXTERN_H
#include "hdf5.h"
#include "H5private.h"
@@ -26,61 +26,65 @@
**/
/* the table of dump functions */
typedef struct dump_functions_t {
- void (*dump_group_function) (hid_t, const char *);
- void (*dump_named_datatype_function) (hid_t, const char *);
- void (*dump_dataset_function) (hid_t, const char *, struct subset_t *);
- void (*dump_dataspace_function) (hid_t);
- void (*dump_datatype_function) (hid_t);
- herr_t (*dump_attribute_function) (hid_t, const char *, const H5A_info_t *, void *);
- void (*dump_data_function) (hid_t, int, struct subset_t *, int);
+ void (*dump_group_function)(hid_t, const char *);
+ void (*dump_named_datatype_function)(hid_t, const char *);
+ void (*dump_dataset_function)(hid_t, const char *, struct subset_t *);
+ void (*dump_dataspace_function)(hid_t);
+ void (*dump_datatype_function)(hid_t);
+ herr_t (*dump_attribute_function)(hid_t, const char *, const H5A_info_t *, void *);
+ void (*dump_data_function)(hid_t, int, struct subset_t *, int);
} dump_functions;
/* List of table structures. There is one table structure for each file */
typedef struct h5dump_table_list_t {
- size_t nalloc;
- size_t nused;
+ size_t nalloc;
+ size_t nused;
struct {
- unsigned long fileno; /* File number that these tables refer to */
- hid_t oid; /* ID of an object in this file, held open so fileno is consistent */
- table_t *group_table; /* Table of groups */
- table_t *dset_table; /* Table of datasets */
- table_t *type_table; /* Table of datatypes */
- } *tables;
+ unsigned long fileno; /* File number that these tables refer to */
+ hid_t oid; /* ID of an object in this file, held open so fileno is consistent */
+ table_t * group_table; /* Table of groups */
+ table_t * dset_table; /* Table of datasets */
+ table_t * type_table; /* Table of datatypes */
+ } * tables;
} h5dump_table_list_t;
-extern h5dump_table_list_t table_list;
-extern table_t *group_table, *dset_table, *type_table;
-extern unsigned dump_indent; /*how far in to indent the line */
+extern h5dump_table_list_t table_list;
+extern table_t * group_table, *dset_table, *type_table;
-extern int unamedtype; /* shared datatype with no name */
-extern hbool_t hit_elink; /* whether we have traversed an external link */
-extern size_t prefix_len;
-extern char *prefix;
-extern const char *fp_format;
+extern unsigned dump_indent; /* how far in to indent the line */
+extern int unamedtype; /* shared datatype with no name */
+extern hbool_t hit_elink; /* whether we have traversed an external link */
+extern size_t prefix_len;
+extern char * prefix;
+extern const char *fp_format;
/* things to display or which are set via command line parameters */
-extern int display_all;
-extern int display_oid;
-extern int display_data;
-extern int display_attr_data;
-extern int display_char; /*print 1-byte numbers as ASCII */
-extern int usingdasho;
-extern int display_bb; /*superblock */
-extern int display_dcpl; /*dcpl */
-extern int display_fi; /*file index */
-extern int display_ai; /*array index */
-extern int display_escape; /*escape non printable characters */
-extern int display_region; /*print region reference data */
-extern int disable_compact_subset; /* disable compact form of subset notation */
-extern int display_packed_bits; /*print 1-8 byte numbers as packed bits*/
-extern int include_attrs; /* Display attributes */
-extern int display_vds_first; /* vds display to first missing */
-extern int vds_gap_size; /* vds skip missing files */
+typedef struct {
+ int display_all;
+ int display_oid;
+ int display_data;
+ int display_attr_data;
+ int display_char; /* print 1-byte numbers as ASCII */
+ int usingdasho;
+ int display_bb; /* superblock */
+ int display_dcpl; /* dcpl */
+ int display_fi; /* file index */
+ int display_ai; /* array index */
+ int display_escape; /* escape non printable characters */
+ int display_region; /* print region reference data */
+ int disable_compact_subset; /* disable compact form of subset notation */
+ int display_packed_bits; /* print 1-8 byte numbers as packed bits */
+ int include_attrs; /* Display attributes */
+ int display_vds_first; /* vds display to all by default */
+ int vds_gap_size; /* vds skip missing files default is none */
+} dump_opt_t;
+extern dump_opt_t dump_opts;
-#define PACKED_BITS_MAX 8 /* Maximum number of packed-bits to display */
-#define PACKED_BITS_SIZE_MAX 8*sizeof(long long) /* Maximum bits size of integer types of packed-bits */
+#define PACKED_BITS_MAX 8 /* Maximum number of packed-bits to display */
+#define PACKED_BITS_SIZE_MAX 8 * sizeof(long long) /* Maximum bits size of integer types of packed-bits */
/* mask list for packed bits */
-extern unsigned long long packed_mask[PACKED_BITS_MAX]; /* packed bits are restricted to 8*sizeof(llong) bytes */
+extern unsigned long long
+ packed_mask[PACKED_BITS_MAX]; /* packed bits are restricted to 8*sizeof(llong) bytes */
/* packed bits display parameters */
extern unsigned packed_offset[PACKED_BITS_MAX];
@@ -96,13 +100,13 @@ extern const dump_functions *dump_function_table;
extern "C" {
#endif
-void add_prefix(char **prfx, size_t *prfx_len, const char *name);
-hid_t h5_fileaccess(void);
-ssize_t table_list_add(hid_t oid, unsigned long file_no);
-ssize_t table_list_visited(unsigned long file_no);
+void add_prefix(char **prfx, size_t *prfx_len, const char *name);
+hid_t h5_fileaccess(void);
+ssize_t table_list_add(hid_t oid, unsigned long file_no);
+ssize_t table_list_visited(unsigned long file_no);
#ifdef __cplusplus
}
#endif
-#endif /* !H5DUMP_EXTERN_H__ */
+#endif /* H5DUMP_EXTERN_H */
diff --git a/tools/src/h5dump/h5dump_xml.c b/tools/src/h5dump/h5dump_xml.c
index c4fd948..827daf3 100644
--- a/tools/src/h5dump/h5dump_xml.c
+++ b/tools/src/h5dump/h5dump_xml.c
@@ -6,7 +6,7 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -20,10 +20,10 @@
#include "h5dump_extern.h"
#include "h5dump_xml.h"
-const char *xmlnsprefix="hdf5:";
+const char *xmlnsprefix = "hdf5:";
/*
- * Alternative formating for data dumped to XML
+ * Alternative formatting for data dumped to XML
* In general, the numbers are the same, but separators
* except spaces are not used.
*
@@ -34,53 +34,54 @@ const char *xmlnsprefix="hdf5:";
*
* This table only affects XML output.
*/
-static h5tool_format_t xml_dataformat = {
- 0, /*raw */
-
- "", /*fmt_raw */
- "%d", /*fmt_int */
- "%u", /*fmt_uint */
- "%hhd", /*fmt_schar */
- "%u", /*fmt_uchar */
- "%d", /*fmt_short */
- "%u", /*fmt_ushort */
- "%ld", /*fmt_long */
- "%lu", /*fmt_ulong */
- NULL, /*fmt_llong */
- NULL, /*fmt_ullong */
- "%g", /*fmt_double */
- "%g", /*fmt_float */
-
- 0, /*ascii */
- 0, /*str_locale */
- 0, /*str_repeat */
-
- "", /*arr_pre */
- "", /*arr_sep */
- "", /*arr_suf */
- 1, /*arr_linebreak */
-
- "", /*cmpd_name */
- "", /*cmpd_sep */
- "", /*cmpd_pre */
- "", /*cmpd_suf */
- "", /*cmpd_end */
- NULL, /*cmpd_listv */
-
- " ", /*vlen_sep */
- " ", /*vlen_pre */
- "", /*vlen_suf */
- "", /*vlen_end */
-
- "%s", /*elmt_fmt */
- "", /*elmt_suf1 */
- " ", /*elmt_suf2 */
-
- "", /*idx_n_fmt */
- "", /*idx_sep */
- "", /*idx_fmt */
-
- 80, /*line_ncols *//*standard default columns */
+static h5tool_format_t xml_dataformat = {
+ 0, /*raw */
+
+ "", /*fmt_raw */
+ "%d", /*fmt_int */
+ "%u", /*fmt_uint */
+ "%hhd", /*fmt_schar */
+ "%u", /*fmt_uchar */
+ "%d", /*fmt_short */
+ "%u", /*fmt_ushort */
+ "%ld", /*fmt_long */
+ "%lu", /*fmt_ulong */
+ NULL, /*fmt_llong */
+ NULL, /*fmt_ullong */
+ "%g", /*fmt_double */
+ "%g", /*fmt_float */
+
+ 0, /*ascii */
+ 0, /*str_locale */
+ 0, /*str_repeat */
+
+ "", /*arr_pre */
+ "", /*arr_sep */
+ "", /*arr_suf */
+ 1, /*arr_linebreak */
+
+ "", /*cmpd_name */
+ "", /*cmpd_sep */
+ "", /*cmpd_pre */
+ "", /*cmpd_suf */
+ "", /*cmpd_end */
+ NULL, /*cmpd_listv */
+
+ " ", /*vlen_sep */
+ " ", /*vlen_pre */
+ "", /*vlen_suf */
+ "", /*vlen_end */
+
+ "%s", /*elmt_fmt */
+ "", /*elmt_suf1 */
+ " ", /*elmt_suf2 */
+
+ "", /*idx_n_fmt */
+ "", /*idx_sep */
+ "", /*idx_fmt */
+
+ 80,
+ /*line_ncols */ /*standard default columns */
0, /*line_per_line */
"", /*line_pre */
"%s", /*line_1st */
@@ -90,31 +91,30 @@ static h5tool_format_t xml_dataformat = {
1, /*line_multi_new */
" ", /*line_indent */
- 1, /*skip_first */
+ 1, /*skip_first */
1, /*obj_hidefileno */
- " "H5_PRINTF_HADDR_FMT, /*obj_format */
-
- 1, /*dset_hidefileno */
- "DATASET %s ", /*dset_format */
- "%s", /*dset_blockformat_pre */
- "%s", /*dset_ptformat_pre */
- "%s", /*dset_ptformat */
- 0, /*array indices */
- 0 /*escape non printable characters */
+ " %" PRIuHADDR, /*obj_format */
+
+ 1, /*dset_hidefileno */
+ "DATASET %s ", /*dset_format */
+ "%s", /*dset_blockformat_pre */
+ "%s", /*dset_ptformat_pre */
+ "%s", /*dset_ptformat */
+ 0, /*array indices */
+ 0 /*escape non printable characters */
};
-
/* internal functions */
-static int xml_name_to_XID(const char *, char *, int , int );
+static int xml_name_to_XID(hid_t, const char *, char *, int, int);
/* internal functions used by XML option */
-static void xml_print_datatype(hid_t, unsigned);
-static void xml_print_enum(hid_t);
-static int xml_print_refs(hid_t, int);
-static int xml_print_strs(hid_t, int);
-static char *xml_escape_the_string(const char *, int);
-static char *xml_escape_the_name(const char *);
+static void xml_print_datatype(hid_t, unsigned);
+static void xml_print_enum(hid_t);
+static int xml_print_refs(hid_t, int);
+static int xml_print_strs(hid_t, int);
+static char *xml_escape_the_string(const char *, int);
+static char *xml_escape_the_name(const char *);
/*-------------------------------------------------------------------------
* Function: xml_dump_all_cb
@@ -130,44 +130,44 @@ static char *xml_escape_the_name(const char *);
*-------------------------------------------------------------------------
*/
static herr_t
-xml_dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void H5_ATTR_UNUSED *op_data)
+xml_dump_all_cb(hid_t group, const char *name, const H5L_info2_t *linfo, void H5_ATTR_UNUSED *op_data)
{
hid_t obj;
- herr_t ret = SUCCEED;
- char *obj_path = NULL; /* Full path of object */
- h5tools_str_t buffer; /* string into which to render */
- h5tools_context_t ctx; /* print context */
- h5tool_format_t *outputformat = &xml_dataformat;
+ herr_t ret = SUCCEED;
+ char * obj_path = NULL; /* Full path of object */
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t * outputformat = &xml_dataformat;
h5tool_format_t string_dataformat;
- hsize_t curr_pos = 0; /* total data element position */
+ hsize_t curr_pos = 0; /* total data element position */
/* setup */
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
HDmemset(&ctx, 0, sizeof(ctx));
ctx.indent_level = dump_indent / COL;
- ctx.cur_column = dump_indent;
+ ctx.cur_column = dump_indent;
string_dataformat = *outputformat;
if (fp_format) {
string_dataformat.fmt_double = fp_format;
- string_dataformat.fmt_float = fp_format;
+ string_dataformat.fmt_float = fp_format;
}
- if (h5tools_nCols==0) {
- string_dataformat.line_ncols = 65535;
+ if (h5tools_nCols == 0) {
+ string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
- outputformat = &string_dataformat;
+ string_dataformat.do_escape = dump_opts.display_escape;
+ outputformat = &string_dataformat;
/* Build the object's path name */
obj_path = (char *)HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2);
- if(!obj_path) {
+ if (!obj_path) {
ret = FAIL;
goto done;
}
@@ -176,393 +176,400 @@ xml_dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void H5_
HDstrcat(obj_path, "/");
HDstrcat(obj_path, name);
- if(linfo->type == H5L_TYPE_HARD) {
- H5O_info_t oinfo;
+ if (linfo->type == H5L_TYPE_HARD) {
+ H5O_info2_t oinfo;
/* Stat the object */
- if(H5Oget_info_by_name2(group, name, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) {
+ if (H5Oget_info_by_name3(group, name, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) {
error_msg("unable to get object information for \"%s\"\n", name);
h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
goto done;
} /* end if */
- switch(oinfo.type) {
- case H5O_TYPE_GROUP:
- if((obj = H5Gopen2(group, name, H5P_DEFAULT)) < 0) {
- error_msg("unable to dump group \"%s\"\n", name);
- h5tools_setstatus(EXIT_FAILURE);
- ret = FAIL;
- }
- else {
- char *old_prefix; /* Pointer to previous prefix */
-
- /* Keep copy of prefix before iterating into group */
- if((old_prefix = HDstrdup(prefix)) == NULL) {
- error_msg("unable to allocate buffer\n");
+ switch (oinfo.type) {
+ case H5O_TYPE_GROUP:
+ if ((obj = H5Gopen2(group, name, H5P_DEFAULT)) < 0) {
+ error_msg("unable to dump group \"%s\"\n", name);
h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
}
else {
- /* Append group name to prefix */
- add_prefix(&prefix, &prefix_len, name);
-
- /* Iterate into group */
- dump_function_table->dump_group_function(obj, name);
-
- /* Restore old prefix name */
- HDstrcpy(prefix, old_prefix);
- HDfree(old_prefix);
- }
-
- /* Close group */
- H5Gclose(obj);
- }
- break;
-
- case H5O_TYPE_DATASET:
- if((obj = H5Dopen2(group, name, H5P_DEFAULT)) >= 0) {
- if(oinfo.rc > 1 || hit_elink) {
- obj_t *found_obj; /* Found object */
-
- found_obj = search_obj(dset_table, oinfo.addr);
-
- if(found_obj == NULL) {
- ctx.indent_level++;
-
- ctx.need_prefix = TRUE;
-
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s \"%s\" %s",
- h5tools_dump_header_format->datasetbegin, name,
- h5tools_dump_header_format->datasetblockbegin);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
-
- error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
-
- ctx.need_prefix = TRUE;
-
- /* Render the element */
- h5tools_str_reset(&buffer);
- if(HDstrlen(h5tools_dump_header_format->datasetblockend)) {
- h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetblockend);
- if(HDstrlen(h5tools_dump_header_format->datasetend))
- h5tools_str_append(&buffer, " ");
- }
- if(HDstrlen(h5tools_dump_header_format->datasetend))
- h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetend);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
-
- ctx.indent_level--;
+ char *old_prefix; /* Pointer to previous prefix */
+ /* Keep copy of prefix before iterating into group */
+ if ((old_prefix = HDstrdup(prefix)) == NULL) {
+ error_msg("unable to allocate buffer\n");
h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
- H5Dclose(obj);
- goto done;
}
- else if(found_obj->displayed) {
- /* the XML version */
- char *t_obj_path = xml_escape_the_name(obj_path);
- char *t_prefix = xml_escape_the_name(HDstrcmp(prefix,"") ? prefix : "/");
- char *t_name = xml_escape_the_name(name);
- char *t_objname = xml_escape_the_name(found_obj->objname);
- char dsetxid[100];
- char parentxid[100];
- char pointerxid[100];
-
- /* Create OBJ-XIDs for the parent and object */
- xml_name_to_XID(obj_path, dsetxid, (int)sizeof(dsetxid), 1);
- xml_name_to_XID(prefix, parentxid, (int)sizeof(parentxid), 1);
-
- ctx.need_prefix = TRUE;
-
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sDataset Name=\"%s\" OBJ-XID=\"%s-%d\" "
- "H5Path=\"%s\" Parents=\"%s\" "
- "H5ParentPaths=\"%s\">",
- xmlnsprefix,
- t_name, /* Dataset Name */
- dsetxid, get_next_xid(), /* OBJ-XID */
- t_obj_path, /* H5Path */
- parentxid, /* Parents */
- t_prefix); /* H5ParentPaths */
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
-
- xml_name_to_XID(found_obj->objname, pointerxid, (int)sizeof(pointerxid), 1);
-
- ctx.indent_level++;
-
- ctx.need_prefix = TRUE;
-
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sDatasetPtr OBJ-XID=\"%s\" H5Path=\"%s\"/>",
- xmlnsprefix,
- pointerxid,t_objname);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ else {
+ /* Append group name to prefix */
+ add_prefix(&prefix, &prefix_len, name);
- ctx.indent_level--;
+ /* Iterate into group */
+ dump_function_table->dump_group_function(obj, name);
- ctx.need_prefix = TRUE;
+ /* Restore old prefix name */
+ HDstrcpy(prefix, old_prefix);
+ HDfree(old_prefix);
+ }
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sDataset>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ /* Close group */
+ H5Gclose(obj);
+ }
+ break;
- HDfree(t_name);
- HDfree(t_obj_path);
- HDfree(t_prefix);
- HDfree(t_objname);
+ case H5O_TYPE_DATASET:
+ if ((obj = H5Dopen2(group, name, H5P_DEFAULT)) >= 0) {
+ if (oinfo.rc > 1 || hit_elink) {
+ obj_t *found_obj; /* Found object */
+
+ found_obj = search_obj(dset_table, &oinfo.token);
+
+ if (found_obj == NULL) {
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "%s \"%s\" %s",
+ h5tools_dump_header_format->datasetbegin, name,
+ h5tools_dump_header_format->datasetblockbegin);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+
+ error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
+
+ ctx.need_prefix = TRUE;
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ if (HDstrlen(h5tools_dump_header_format->datasetblockend)) {
+ h5tools_str_append(&buffer, "%s",
+ h5tools_dump_header_format->datasetblockend);
+ if (HDstrlen(h5tools_dump_header_format->datasetend))
+ h5tools_str_append(&buffer, " ");
+ }
+ if (HDstrlen(h5tools_dump_header_format->datasetend))
+ h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetend);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+
+ ctx.indent_level--;
+
+ h5tools_setstatus(EXIT_FAILURE);
+ ret = FAIL;
+ H5Dclose(obj);
+ goto done;
+ }
+ else if (found_obj->displayed) {
+ /* the XML version */
+ char *t_obj_path = xml_escape_the_name(obj_path);
+ char *t_prefix = xml_escape_the_name(HDstrcmp(prefix, "") ? prefix : "/");
+ char *t_name = xml_escape_the_name(name);
+ char *t_objname = xml_escape_the_name(found_obj->objname);
+ char dsetxid[100];
+ char parentxid[100];
+ char pointerxid[100];
+
+ /* Create OBJ-XIDs for the parent and object */
+ xml_name_to_XID(obj, obj_path, dsetxid, (int)sizeof(dsetxid), 1);
+ xml_name_to_XID(obj, prefix, parentxid, (int)sizeof(parentxid), 1);
+
+ ctx.need_prefix = TRUE;
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer,
+ "<%sDataset Name=\"%s\" OBJ-XID=\"%s-%d\" "
+ "H5Path=\"%s\" Parents=\"%s\" "
+ "H5ParentPaths=\"%s\">",
+ xmlnsprefix, t_name, /* Dataset Name */
+ dsetxid, get_next_xid(), /* OBJ-XID */
+ t_obj_path, /* H5Path */
+ parentxid, /* Parents */
+ t_prefix); /* H5ParentPaths */
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+
+ xml_name_to_XID(obj, found_obj->objname, pointerxid, (int)sizeof(pointerxid), 1);
+
+ ctx.indent_level++;
+
+ ctx.need_prefix = TRUE;
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sDatasetPtr OBJ-XID=\"%s\" H5Path=\"%s\"/>",
+ xmlnsprefix, pointerxid, t_objname);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+
+ ctx.indent_level--;
+
+ ctx.need_prefix = TRUE;
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sDataset>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+
+ HDfree(t_name);
+ HDfree(t_obj_path);
+ HDfree(t_prefix);
+ HDfree(t_objname);
+
+ H5Dclose(obj);
+ goto done;
+ }
+ else
+ found_obj->displayed = TRUE;
+ } /* end if */
- H5Dclose(obj);
- goto done;
- }
- else
- found_obj->displayed = TRUE;
- } /* end if */
+ dump_function_table->dump_dataset_function(obj, name, NULL);
+ H5Dclose(obj);
+ }
+ else {
+ error_msg("unable to dump dataset \"%s\"\n", name);
+ h5tools_setstatus(EXIT_FAILURE);
+ ret = FAIL;
+ }
+ break;
- dump_function_table->dump_dataset_function(obj, name, NULL);
- H5Dclose(obj);
- }
- else {
- error_msg("unable to dump dataset \"%s\"\n", name);
- h5tools_setstatus(EXIT_FAILURE);
- ret = FAIL;
- }
- break;
+ case H5O_TYPE_NAMED_DATATYPE:
+ if ((obj = H5Topen2(group, name, H5P_DEFAULT)) < 0) {
+ error_msg("unable to dump datatype \"%s\"\n", name);
+ h5tools_setstatus(EXIT_FAILURE);
+ ret = FAIL;
+ }
+ else {
+ dump_function_table->dump_named_datatype_function(obj, name);
+ H5Tclose(obj);
+ }
+ break;
- case H5O_TYPE_NAMED_DATATYPE:
- if((obj = H5Topen2(group, name, H5P_DEFAULT)) < 0) {
- error_msg("unable to dump datatype \"%s\"\n", name);
+ case H5O_TYPE_MAP:
+ case H5O_TYPE_UNKNOWN:
+ case H5O_TYPE_NTYPES:
+ default:
+ error_msg("unknown object \"%s\"\n", name);
h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
- }
- else {
- dump_function_table->dump_named_datatype_function(obj, name);
- H5Tclose(obj);
- }
- break;
-
- case H5O_TYPE_MAP:
- case H5O_TYPE_UNKNOWN:
- case H5O_TYPE_NTYPES:
- default:
- error_msg("unknown object \"%s\"\n", name);
- h5tools_setstatus(EXIT_FAILURE);
- ret = FAIL;
}
} /* end if */
else {
- char *targbuf;
+ char *targbuf;
- switch(linfo->type) {
- case H5L_TYPE_SOFT:
- if((targbuf = (char *)HDmalloc(linfo->u.val_size)) == NULL) {
- error_msg("unable to allocate buffer\n");
- h5tools_setstatus(EXIT_FAILURE);
- ret = FAIL;
- }
- else {
- if(H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) {
- error_msg("unable to get link value\n");
+ switch (linfo->type) {
+ case H5L_TYPE_SOFT:
+ if ((targbuf = (char *)HDmalloc(linfo->u.val_size)) == NULL) {
+ error_msg("unable to allocate buffer\n");
h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
}
else {
- /* print the value of a soft link */
- /* XML */
- char linkxid[100];
- char parentxid[100];
- char targetxid[100];
- char *t_prefix = xml_escape_the_name(HDstrcmp(prefix,"") ? prefix : "/");
- char *t_name = xml_escape_the_name(name);
- char *t_targbuf = xml_escape_the_name(targbuf);
- char *t_obj_path = xml_escape_the_name(obj_path);
- char *t_link_path;
- int res;
-
- t_link_path = (char *)HDmalloc(HDstrlen(prefix) + linfo->u.val_size + 1);
- if(targbuf[0] == '/')
- HDstrcpy(t_link_path, targbuf);
- else {
- HDstrcpy(t_link_path, prefix);
- HDstrcat(HDstrcat(t_link_path, "/"), targbuf);
- } /* end else */
-
- /* Create OBJ-XIDs for the parent and object */
- xml_name_to_XID(t_obj_path, linkxid, (int)sizeof(linkxid), 1);
- xml_name_to_XID(prefix, parentxid, (int)sizeof(parentxid), 1);
-
- /* Try to create an OBJ-XID for the object pointed to */
- res = xml_name_to_XID(t_link_path, targetxid, (int)sizeof(targetxid), 0);
- if (res == 0) {
- /* target obj found */
- ctx.need_prefix = TRUE;
-
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sSoftLink LinkName=\"%s\" "
- "OBJ-XID=\"%s\" "
- "H5SourcePath=\"%s\" "
- "TargetPath=\"%s\" TargetObj=\"%s\" "
- "Parents=\"%s\" H5ParentPaths=\"%s\" />",
- xmlnsprefix,
- t_name, /* LinkName */
- linkxid, /* OBJ-XID */
- t_obj_path, /* H5SourcePath */
- t_targbuf, /* TargetPath */
- targetxid, /* TargetObj */
- parentxid, /* Parents */
- t_prefix); /* H5ParentPaths */
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ if (H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) {
+ error_msg("unable to get link value\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ ret = FAIL;
}
else {
- /* dangling link -- omit from xml attributes */
- ctx.need_prefix = TRUE;
+ /* print the value of a soft link */
+ /* XML */
+ char linkxid[100];
+ char parentxid[100];
+ char targetxid[100];
+ char *t_prefix = xml_escape_the_name(HDstrcmp(prefix, "") ? prefix : "/");
+ char *t_name = xml_escape_the_name(name);
+ char *t_targbuf = xml_escape_the_name(targbuf);
+ char *t_obj_path = xml_escape_the_name(obj_path);
+ char *t_link_path;
+ int res;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sSoftLink LinkName=\"%s\" "
- "OBJ-XID=\"%s\" "
- "H5SourcePath=\"%s\" "
- "TargetPath=\"%s\" "
- "Parents=\"%s\" H5ParentPaths=\"%s\" />",
- xmlnsprefix,
- t_name, /* LinkName */
- linkxid, /* OBJ-XID */
- t_obj_path, /* H5SourcePath */
- t_targbuf, /* TargetPath */
- parentxid, /* Parents */
- t_prefix); /* H5ParentPaths */
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ t_link_path = (char *)HDmalloc(HDstrlen(prefix) + linfo->u.val_size + 1);
+ if (targbuf[0] == '/')
+ HDstrcpy(t_link_path, targbuf);
+ else {
+ HDstrcpy(t_link_path, prefix);
+ HDstrcat(HDstrcat(t_link_path, "/"), targbuf);
+ } /* end else */
+
+ /* Create OBJ-XIDs for the parent and object */
+ xml_name_to_XID(group, t_obj_path, linkxid, (int)sizeof(linkxid), 1);
+ xml_name_to_XID(group, prefix, parentxid, (int)sizeof(parentxid), 1);
+
+ /* Try to create an OBJ-XID for the object pointed to */
+ res = xml_name_to_XID(group, t_link_path, targetxid, (int)sizeof(targetxid), 0);
+ if (res == 0) {
+ /* target obj found */
+ ctx.need_prefix = TRUE;
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer,
+ "<%sSoftLink LinkName=\"%s\" "
+ "OBJ-XID=\"%s\" "
+ "H5SourcePath=\"%s\" "
+ "TargetPath=\"%s\" TargetObj=\"%s\" "
+ "Parents=\"%s\" H5ParentPaths=\"%s\" />",
+ xmlnsprefix, t_name, /* LinkName */
+ linkxid, /* OBJ-XID */
+ t_obj_path, /* H5SourcePath */
+ t_targbuf, /* TargetPath */
+ targetxid, /* TargetObj */
+ parentxid, /* Parents */
+ t_prefix); /* H5ParentPaths */
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ }
+ else {
+ /* dangling link -- omit from xml attributes */
+ ctx.need_prefix = TRUE;
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer,
+ "<%sSoftLink LinkName=\"%s\" "
+ "OBJ-XID=\"%s\" "
+ "H5SourcePath=\"%s\" "
+ "TargetPath=\"%s\" "
+ "Parents=\"%s\" H5ParentPaths=\"%s\" />",
+ xmlnsprefix, t_name, /* LinkName */
+ linkxid, /* OBJ-XID */
+ t_obj_path, /* H5SourcePath */
+ t_targbuf, /* TargetPath */
+ parentxid, /* Parents */
+ t_prefix); /* H5ParentPaths */
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ }
+
+ HDfree(t_prefix);
+ HDfree(t_name);
+ HDfree(t_targbuf);
+ HDfree(t_obj_path);
+ HDfree(t_link_path);
}
- HDfree(t_prefix);
- HDfree(t_name);
- HDfree(t_targbuf);
- HDfree(t_obj_path);
- HDfree(t_link_path);
+ HDfree(targbuf);
}
+ break;
- HDfree(targbuf);
- }
- break;
-
- case H5L_TYPE_EXTERNAL:
- if((targbuf = (char *)HDmalloc(linfo->u.val_size)) == NULL) {
- error_msg("unable to allocate buffer\n");
- h5tools_setstatus(EXIT_FAILURE);
- ret = FAIL;
- }
- else {
- if(H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) {
- error_msg("unable to get external link value\n");
+ case H5L_TYPE_EXTERNAL:
+ if ((targbuf = (char *)HDmalloc(linfo->u.val_size)) == NULL) {
+ error_msg("unable to allocate buffer\n");
h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
- } /* end if */
+ }
else {
- const char *filename;
- const char *targname;
-
- if(H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL, &filename, &targname) < 0) {
- error_msg("unable to unpack external link value\n");
+ if (H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) {
+ error_msg("unable to get external link value\n");
h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
} /* end if */
else {
- char linkxid[100];
- char parentxid[100];
- char *t_name = xml_escape_the_name(name);
- char *t_prefix = xml_escape_the_name(HDstrcmp(prefix,"") ? prefix : "/");
- char *t_obj_path = xml_escape_the_name(obj_path);
- char *t_filename = xml_escape_the_name(filename);
- char *t_targname = xml_escape_the_name(targname);
-
- /* Create OBJ-XIDs for the parent and object */
- xml_name_to_XID(t_obj_path, linkxid, (int)sizeof(linkxid), 1);
- xml_name_to_XID(prefix, parentxid, (int)sizeof(parentxid), 1);
-
- ctx.need_prefix = TRUE;
-
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sExternalLink LinkName=\"%s\" "
- "OBJ-XID=\"%s\" "
- "H5SourcePath=\"%s\" "
- "TargetFilename=\"%s\" "
- "TargetPath=\"%s\" "
- "Parents=\"%s\" H5ParentPaths=\"%s\" />",
- xmlnsprefix,
- t_name, /* LinkName */
- linkxid, /* OBJ-XID */
- t_obj_path, /* H5SourcePath */
- filename, /* TargetFilename */
- targname, /* TargetPath*/
- parentxid, /* Parents */
- t_prefix); /* H5ParentPaths */
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
-
- HDfree(t_prefix);
- HDfree(t_name);
- HDfree(t_filename);
- HDfree(t_targname);
- HDfree(t_obj_path);
- } /* end else */
- } /* end else */
- HDfree(targbuf);
- }
- break;
+ const char *filename;
+ const char *targname;
+
+ if (H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL, &filename, &targname) < 0) {
+ error_msg("unable to unpack external link value\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ ret = FAIL;
+ } /* end if */
+ else {
+ char linkxid[100];
+ char parentxid[100];
+ char *t_name = xml_escape_the_name(name);
+ char *t_prefix = xml_escape_the_name(HDstrcmp(prefix, "") ? prefix : "/");
+ char *t_obj_path = xml_escape_the_name(obj_path);
+ char *t_filename = xml_escape_the_name(filename);
+ char *t_targname = xml_escape_the_name(targname);
+
+ /* Create OBJ-XIDs for the parent and object */
+ xml_name_to_XID(group, t_obj_path, linkxid, (int)sizeof(linkxid), 1);
+ xml_name_to_XID(group, prefix, parentxid, (int)sizeof(parentxid), 1);
+
+ ctx.need_prefix = TRUE;
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer,
+ "<%sExternalLink LinkName=\"%s\" "
+ "OBJ-XID=\"%s\" "
+ "H5SourcePath=\"%s\" "
+ "TargetFilename=\"%s\" "
+ "TargetPath=\"%s\" "
+ "Parents=\"%s\" H5ParentPaths=\"%s\" />",
+ xmlnsprefix, t_name, /* LinkName */
+ linkxid, /* OBJ-XID */
+ t_obj_path, /* H5SourcePath */
+ filename, /* TargetFilename */
+ targname, /* TargetPath*/
+ parentxid, /* Parents */
+ t_prefix); /* H5ParentPaths */
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+
+ HDfree(t_prefix);
+ HDfree(t_name);
+ HDfree(t_filename);
+ HDfree(t_targname);
+ HDfree(t_obj_path);
+ } /* end else */
+ } /* end else */
+ HDfree(targbuf);
+ }
+ break;
- case H5L_TYPE_ERROR:
- case H5L_TYPE_MAX:
- case H5L_TYPE_HARD:
- default:
- {
- char linkxid[100];
- char parentxid[100];
- char *t_name = xml_escape_the_name(name);
- char *t_prefix = xml_escape_the_name(HDstrcmp(prefix,"") ? prefix : "/");
+ case H5L_TYPE_ERROR:
+ case H5L_TYPE_MAX:
+ case H5L_TYPE_HARD:
+ default: {
+ char linkxid[100];
+ char parentxid[100];
+ char *t_name = xml_escape_the_name(name);
+ char *t_prefix = xml_escape_the_name(HDstrcmp(prefix, "") ? prefix : "/");
char *t_obj_path = xml_escape_the_name(obj_path);
/* Create OBJ-XIDs for the parent and object */
- xml_name_to_XID(t_obj_path, linkxid, (int)sizeof(linkxid), 1);
- xml_name_to_XID(prefix, parentxid, (int)sizeof(parentxid), 1);
+ xml_name_to_XID(group, t_obj_path, linkxid, (int)sizeof(linkxid), 1);
+ xml_name_to_XID(group, prefix, parentxid, (int)sizeof(parentxid), 1);
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sUserDefined LinkName=\"%s\" "
- "OBJ-XID=\"%s\" "
- "H5SourcePath=\"%s\" "
- "LinkClass=\"%d\" "
- "Parents=\"%s\" H5ParentPaths=\"%s\" />",
- xmlnsprefix,
- t_name, /* LinkName */
- linkxid, /* OBJ-XID */
- t_obj_path, /* H5SourcePath */
- linfo->type, /* LinkClass */
- parentxid, /* Parents */
- t_prefix); /* H5ParentPaths */
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer,
+ "<%sUserDefined LinkName=\"%s\" "
+ "OBJ-XID=\"%s\" "
+ "H5SourcePath=\"%s\" "
+ "LinkClass=\"%d\" "
+ "Parents=\"%s\" H5ParentPaths=\"%s\" />",
+ xmlnsprefix, t_name, /* LinkName */
+ linkxid, /* OBJ-XID */
+ t_obj_path, /* H5SourcePath */
+ linfo->type, /* LinkClass */
+ parentxid, /* Parents */
+ t_prefix); /* H5ParentPaths */
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
HDfree(t_prefix);
HDfree(t_name);
HDfree(t_obj_path);
- }
- break;
+ } break;
} /* end switch */
- } /* end else */
+ } /* end else */
done:
h5tools_str_close(&buffer);
- if(obj_path)
+ if (obj_path)
HDfree(obj_path);
return ret;
}
@@ -575,20 +582,29 @@ done:
* 1 - generate a fake entry and return fake id.
*/
int
-xml_name_to_XID(const char *str , char *outstr, int outlen, int gen)
+xml_name_to_XID(hid_t loc_id, const char *str, char *outstr, int outlen, int gen)
{
- haddr_t objno; /* Object ID for object at path */
+ H5O_token_t obj_token;
+ char * obj_tok_str = NULL;
+ int lookup_ret;
+
+ if (outlen < 22)
+ return 1;
- if (outlen < 22) return 1;
+ H5_CHECK_OVERFLOW(outlen, int, size_t);
- objno = ref_path_table_lookup(str);
- if (objno == HADDR_UNDEF) {
+ lookup_ret = ref_path_table_lookup(str, &obj_token);
+ if (lookup_ret < 0) {
if (HDstrlen(str) == 0) {
- objno = ref_path_table_lookup("/");
- if (objno == HADDR_UNDEF) {
+ lookup_ret = ref_path_table_lookup("/", &obj_token);
+ if (lookup_ret < 0) {
if (gen) {
- objno = ref_path_table_gen_fake(str);
- HDsprintf(outstr, "xid_"H5_PRINTF_HADDR_FMT, objno);
+ ref_path_table_gen_fake(str, &obj_token);
+
+ H5Otoken_to_str(loc_id, &obj_token, &obj_tok_str);
+ HDsnprintf(outstr, (size_t)outlen, "xid_%s", obj_tok_str);
+ H5free_memory(obj_tok_str);
+
return 0;
}
else {
@@ -598,8 +614,12 @@ xml_name_to_XID(const char *str , char *outstr, int outlen, int gen)
}
else {
if (gen) {
- objno = ref_path_table_gen_fake(str);
- HDsprintf(outstr, "xid_"H5_PRINTF_HADDR_FMT, objno);
+ ref_path_table_gen_fake(str, &obj_token);
+
+ H5Otoken_to_str(loc_id, &obj_token, &obj_tok_str);
+ HDsnprintf(outstr, (size_t)outlen, "xid_%s", obj_tok_str);
+ H5free_memory(obj_tok_str);
+
return 0;
}
else {
@@ -608,16 +628,18 @@ xml_name_to_XID(const char *str , char *outstr, int outlen, int gen)
}
}
- HDsprintf(outstr, "xid_"H5_PRINTF_HADDR_FMT, objno);
+ H5Otoken_to_str(loc_id, &obj_token, &obj_tok_str);
+ HDsnprintf(outstr, (size_t)outlen, "xid_%s", obj_tok_str);
+ H5free_memory(obj_tok_str);
- return(0);
+ return 0;
}
-static const char *quote = "&quot;";
-static const char *amp = "&amp;";
-static const char *lt = "&lt;";
-static const char *gt = "&gt;";
-static const char *apos = "&apos;";
+static const char *quote = "&quot;";
+static const char *amp = "&amp;";
+static const char *lt = "&lt;";
+static const char *gt = "&gt;";
+static const char *apos = "&apos;";
/*-------------------------------------------------------------------------
* Function: xml_escape_the_name
@@ -630,22 +652,22 @@ static const char *apos = "&apos;";
* Programmer: REMcG
*-------------------------------------------------------------------------
*/
-static char *
+static char *
xml_escape_the_name(const char *str)
{
size_t extra;
size_t len;
size_t i;
const char *cp;
- char *ncp;
- char *rcp;
+ char * ncp;
+ char * rcp;
size_t ncp_len;
if (!str)
return NULL;
- cp = str;
- len = HDstrlen(str);
+ cp = str;
+ len = HDstrlen(str);
extra = 0;
for (i = 0; i < len; i++) {
@@ -666,12 +688,12 @@ xml_escape_the_name(const char *str)
if (extra == 0)
return HDstrdup(str);
- cp = str;
+ cp = str;
ncp_len = len + extra + 1;
rcp = ncp = (char *)HDmalloc(ncp_len);
if (!ncp)
- return NULL; /* ?? */
+ return NULL; /* ?? */
for (i = 0; i < len; i++) {
size_t esc_len;
@@ -697,7 +719,7 @@ xml_escape_the_name(const char *str)
esc_len = HDstrlen(amp);
}
else {
- *ncp = *cp;
+ *ncp = *cp;
esc_len = 1;
}
ncp += esc_len;
@@ -720,15 +742,15 @@ xml_escape_the_name(const char *str)
* Programmer: REMcG
*-------------------------------------------------------------------------
*/
-static char *
+static char *
xml_escape_the_string(const char *str, int slen)
{
size_t extra;
size_t len;
size_t i;
- const char *cp;
- char *ncp;
- char *rcp;
+ const char *cp = NULL;
+ char * ncp = NULL;
+ char * rcp = NULL;
size_t ncp_len;
if (!str)
@@ -759,9 +781,9 @@ xml_escape_the_string(const char *str, int slen)
cp++;
}
- cp = str;
+ cp = str;
ncp_len = len + extra + 1;
- rcp = ncp = (char *) HDcalloc(ncp_len, sizeof(char));
+ rcp = ncp = (char *)HDcalloc(ncp_len, sizeof(char));
if (ncp == NULL)
return NULL; /* ?? */
@@ -771,32 +793,34 @@ xml_escape_the_string(const char *str, int slen)
if (*cp == '\\') {
*ncp++ = '\\';
- *ncp = *cp;
+ ncp_len--;
+ *ncp = *cp;
esc_len = 1;
}
else if (*cp == '\"') {
*ncp++ = '\\';
- *ncp = *cp;
+ ncp_len--;
+ *ncp = *cp;
esc_len = 1;
}
else if (*cp == '\'') {
+ HDstrncpy(ncp, apos, ncp_len);
esc_len = HDstrlen(apos);
- HDstrncpy(ncp, apos, esc_len);
}
else if (*cp == '<') {
+ HDstrncpy(ncp, lt, ncp_len);
esc_len = HDstrlen(lt);
- HDstrncpy(ncp, lt, esc_len);
}
else if (*cp == '>') {
+ HDstrncpy(ncp, gt, ncp_len);
esc_len = HDstrlen(gt);
- HDstrncpy(ncp, gt, esc_len);
}
else if (*cp == '&') {
+ HDstrncpy(ncp, amp, ncp_len);
esc_len = HDstrlen(amp);
- HDstrncpy(ncp, amp, esc_len);
}
else {
- *ncp = *cp;
+ *ncp = *cp;
esc_len = 1;
}
ncp += esc_len;
@@ -827,71 +851,71 @@ xml_escape_the_string(const char *str, int slen)
static void
xml_print_datatype(hid_t type, unsigned in_group)
{
- char *mname;
- hid_t mtype;
- unsigned nmembers;
- unsigned ndims;
- unsigned i;
- size_t size;
- hsize_t dims[H5DUMP_MAX_RANK];
- H5T_str_t str_pad;
- H5T_cset_t cset;
- hid_t super;
- H5T_order_t ord;
- H5T_sign_t sgn;
- size_t sz;
- size_t spos;
- size_t epos;
- size_t esize;
- size_t mpos;
- size_t msize;
- int nmembs;
- htri_t is_vlstr = FALSE;
- h5tools_str_t buffer; /* string into which to render */
- h5tools_context_t ctx; /* print context */
- h5tool_format_t *outputformat = &xml_dataformat;
- h5tool_format_t string_dataformat;
- hsize_t curr_pos = 0; /* total data element position */
+ char * mname;
+ hid_t mtype;
+ unsigned nmembers;
+ unsigned ndims;
+ unsigned i;
+ size_t size;
+ hsize_t dims[H5DUMP_MAX_RANK];
+ H5T_str_t str_pad;
+ H5T_cset_t cset;
+ hid_t super;
+ H5T_order_t ord;
+ H5T_sign_t sgn;
+ size_t sz;
+ size_t spos;
+ size_t epos;
+ size_t esize;
+ size_t mpos;
+ size_t msize;
+ int nmembs;
+ htri_t is_vlstr = FALSE;
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t * outputformat = &xml_dataformat;
+ h5tool_format_t string_dataformat;
+ hsize_t curr_pos = 0; /* total data element position */
/* setup */
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
HDmemset(&ctx, 0, sizeof(ctx));
ctx.indent_level = dump_indent / COL;
- ctx.cur_column = dump_indent;
+ ctx.cur_column = dump_indent;
string_dataformat = *outputformat;
if (fp_format) {
string_dataformat.fmt_double = fp_format;
- string_dataformat.fmt_float = fp_format;
+ string_dataformat.fmt_float = fp_format;
}
- if (h5tools_nCols==0) {
- string_dataformat.line_ncols = 65535;
+ if (h5tools_nCols == 0) {
+ string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
- outputformat = &string_dataformat;
+ string_dataformat.do_escape = dump_opts.display_escape;
+ outputformat = &string_dataformat;
- if(!in_group && H5Tcommitted(type) > 0) {
- H5O_info_t oinfo;
- obj_t *found_obj; /* Found object */
+ if (!in_group && H5Tcommitted(type) > 0) {
+ H5O_info2_t oinfo;
+ obj_t * found_obj; /* Found object */
/* detect a shared datatype, output only once */
- H5Oget_info2(type, &oinfo, H5O_INFO_BASIC);
- found_obj = search_obj(type_table, oinfo.addr);
+ H5Oget_info3(type, &oinfo, H5O_INFO_BASIC);
+ found_obj = search_obj(type_table, &oinfo.token);
- if(found_obj) {
+ if (found_obj) {
/* This should be defined somewhere else */
/* These 2 cases are handled the same right now, but
probably will have something different eventually */
- char * dtxid = (char *)HDmalloc((size_t)100);
+ char *dtxid = (char *)HDmalloc((size_t)100);
- xml_name_to_XID(found_obj->objname, dtxid, 100, 1);
+ xml_name_to_XID(type, found_obj->objname, dtxid, 100, 1);
if (!found_obj->recorded) {
/* 'anonymous' NDT. Use it's object num.
as it's name. */
@@ -900,9 +924,9 @@ xml_print_datatype(hid_t type, unsigned in_group)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sNamedDataTypePtr OBJ-XID=\"/%s\"/>",
- xmlnsprefix, dtxid);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "<%sNamedDataTypePtr OBJ-XID=\"/%s\"/>", xmlnsprefix, dtxid);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
}
else {
/* point to the NDT by name */
@@ -912,9 +936,10 @@ xml_print_datatype(hid_t type, unsigned in_group)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sNamedDataTypePtr OBJ-XID=\"%s\" H5Path=\"%s\"/>",
- xmlnsprefix, dtxid, t_objname);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "<%sNamedDataTypePtr OBJ-XID=\"%s\" H5Path=\"%s\"/>", xmlnsprefix,
+ dtxid, t_objname);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
HDfree(t_objname);
}
HDfree(dtxid);
@@ -925,7 +950,8 @@ xml_print_datatype(hid_t type, unsigned in_group)
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "<!-- h5dump error: unknown committed type. -->");
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
h5tools_setstatus(EXIT_FAILURE);
}
}
@@ -936,8 +962,9 @@ xml_print_datatype(hid_t type, unsigned in_group)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "<%sAtomicType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level++;
/* <hdf5:IntegerType ByteOrder="bo" Sign="torf" Size="bytes"/> */
@@ -948,7 +975,7 @@ xml_print_datatype(hid_t type, unsigned in_group)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sIntegerType ByteOrder=\"",xmlnsprefix);
+ h5tools_str_append(&buffer, "<%sIntegerType ByteOrder=\"", xmlnsprefix);
switch (ord) {
case H5T_ORDER_LE:
h5tools_str_append(&buffer, "LE");
@@ -985,15 +1012,17 @@ xml_print_datatype(hid_t type, unsigned in_group)
sz = H5Tget_size(type);
h5tools_str_append(&buffer, "%lu", (unsigned long)sz);
h5tools_str_append(&buffer, "\" />");
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level--;
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "</%sAtomicType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
break;
case H5T_FLOAT:
@@ -1007,15 +1036,16 @@ xml_print_datatype(hid_t type, unsigned in_group)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "<%sAtomicType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level++;
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sFloatType ByteOrder=\"",xmlnsprefix);
+ h5tools_str_append(&buffer, "<%sFloatType ByteOrder=\"", xmlnsprefix);
switch (ord) {
case H5T_ORDER_LE:
@@ -1039,17 +1069,21 @@ xml_print_datatype(hid_t type, unsigned in_group)
h5tools_str_append(&buffer, "%lu", (unsigned long)sz);
H5Tget_fields(type, &spos, &epos, &esize, &mpos, &msize);
h5tools_str_append(&buffer, "\" SignBitLocation=\"%lu\" ", (unsigned long)spos);
- h5tools_str_append(&buffer, "ExponentBits=\"%lu\" ExponentLocation=\"%lu\" ", (unsigned long)esize, (unsigned long)epos);
- h5tools_str_append(&buffer, "MantissaBits=\"%lu\" MantissaLocation=\"%lu\" />", (unsigned long)msize, (unsigned long)mpos);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "ExponentBits=\"%lu\" ExponentLocation=\"%lu\" ",
+ (unsigned long)esize, (unsigned long)epos);
+ h5tools_str_append(&buffer, "MantissaBits=\"%lu\" MantissaLocation=\"%lu\" />",
+ (unsigned long)msize, (unsigned long)mpos);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level--;
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "</%sAtomicType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
break;
case H5T_TIME:
@@ -1057,16 +1091,18 @@ xml_print_datatype(hid_t type, unsigned in_group)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "<%sAtomicType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level++;
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sTimeType />",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "<%sTimeType />", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
h5tools_str_append(&buffer, "<!-- H5T_TIME: not yet implemented -->");
ctx.indent_level--;
@@ -1074,23 +1110,25 @@ xml_print_datatype(hid_t type, unsigned in_group)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "</%sAtomicType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
break;
case H5T_STRING:
/* <hdf5:StringType Cset="cs" StrSize="chars" StrPad="pad" /> */
- size = H5Tget_size(type);
- str_pad = H5Tget_strpad(type);
- cset = H5Tget_cset(type);
+ size = H5Tget_size(type);
+ str_pad = H5Tget_strpad(type);
+ cset = H5Tget_cset(type);
is_vlstr = H5Tis_variable_str(type);
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "<%sAtomicType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level++;
@@ -1098,17 +1136,17 @@ xml_print_datatype(hid_t type, unsigned in_group)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sStringType Cset=\"",xmlnsprefix);
+ h5tools_str_append(&buffer, "<%sStringType Cset=\"", xmlnsprefix);
if (cset == H5T_CSET_ASCII)
h5tools_str_append(&buffer, "H5T_CSET_ASCII\" ");
else
h5tools_str_append(&buffer, "unknown_cset\" ");
- if(is_vlstr)
+ if (is_vlstr)
h5tools_str_append(&buffer, "StrSize=\"H5T_VARIABLE\" StrPad=\"");
else
- h5tools_str_append(&buffer, "StrSize=\"%d\" StrPad=\"", (int) size);
+ h5tools_str_append(&buffer, "StrSize=\"%d\" StrPad=\"", (int)size);
if (str_pad == H5T_STR_NULLTERM)
h5tools_str_append(&buffer, "H5T_STR_NULLTERM\"/>");
@@ -1118,15 +1156,17 @@ xml_print_datatype(hid_t type, unsigned in_group)
h5tools_str_append(&buffer, "H5T_STR_SPACEPAD\"/>");
else
h5tools_str_append(&buffer, "H5T_STR_ERROR\"/>");
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level--;
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "</%sAtomicType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
break;
case H5T_BITFIELD:
@@ -1137,15 +1177,16 @@ xml_print_datatype(hid_t type, unsigned in_group)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "<%sAtomicType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level++;
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sBitfieldType ByteOrder=\"",xmlnsprefix);
+ h5tools_str_append(&buffer, "<%sBitfieldType ByteOrder=\"", xmlnsprefix);
switch (ord) {
case H5T_ORDER_LE:
@@ -1164,15 +1205,17 @@ xml_print_datatype(hid_t type, unsigned in_group)
size = H5Tget_size(type);
h5tools_str_append(&buffer, "\" Size=\"%lu\"/>", (unsigned long)size);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level--;
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "</%sAtomicType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
break;
case H5T_OPAQUE:
@@ -1182,8 +1225,9 @@ xml_print_datatype(hid_t type, unsigned in_group)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "<%sAtomicType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level++;
mname = H5Tget_tag(type);
@@ -1191,19 +1235,21 @@ xml_print_datatype(hid_t type, unsigned in_group)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sOpaqueType Tag=\"%s\" ",xmlnsprefix, mname);
+ h5tools_str_append(&buffer, "<%sOpaqueType Tag=\"%s\" ", xmlnsprefix, mname);
H5free_memory(mname);
size = H5Tget_size(type);
h5tools_str_append(&buffer, "Size=\"%lu\"/>", (unsigned long)size);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level--;
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "</%sAtomicType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
break;
case H5T_COMPOUND:
@@ -1216,8 +1262,9 @@ xml_print_datatype(hid_t type, unsigned in_group)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sCompoundType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "<%sCompoundType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
/* List each member Field of the type */
/* <hdf5:Field FieldName="name" > */
@@ -1227,16 +1274,17 @@ xml_print_datatype(hid_t type, unsigned in_group)
for (i = 0; i < nmembers; i++) {
char *t_fname;
- mname = H5Tget_member_name(type, i);
- mtype = H5Tget_member_type(type, i);
+ mname = H5Tget_member_name(type, i);
+ mtype = H5Tget_member_type(type, i);
t_fname = xml_escape_the_name(mname);
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sField FieldName=\"%s\">",xmlnsprefix, t_fname);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "<%sField FieldName=\"%s\">", xmlnsprefix, t_fname);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
H5free_memory(mname);
HDfree(t_fname);
@@ -1247,11 +1295,12 @@ xml_print_datatype(hid_t type, unsigned in_group)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sDataType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "<%sDataType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level++;
dump_indent += COL;
- xml_print_datatype(mtype,0);
+ xml_print_datatype(mtype, 0);
dump_indent -= COL;
ctx.indent_level--;
@@ -1259,8 +1308,9 @@ xml_print_datatype(hid_t type, unsigned in_group)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sDataType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "</%sDataType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
dump_indent -= COL;
ctx.indent_level--;
@@ -1268,8 +1318,9 @@ xml_print_datatype(hid_t type, unsigned in_group)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sField>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "</%sField>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
}
dump_indent -= COL;
ctx.indent_level--;
@@ -1278,8 +1329,9 @@ xml_print_datatype(hid_t type, unsigned in_group)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sCompoundType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "</%sCompoundType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
break;
case H5T_REFERENCE:
@@ -1287,8 +1339,9 @@ xml_print_datatype(hid_t type, unsigned in_group)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "<%sAtomicType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level++;
/* Only Object references supported at this time */
@@ -1296,32 +1349,36 @@ xml_print_datatype(hid_t type, unsigned in_group)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sReferenceType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "<%sReferenceType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level++;
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sObjectReferenceType />",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "<%sObjectReferenceType />", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level--;
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sReferenceType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "</%sReferenceType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level--;
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "</%sAtomicType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
break;
case H5T_ENUM:
@@ -1332,8 +1389,9 @@ xml_print_datatype(hid_t type, unsigned in_group)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "<%sAtomicType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
dump_indent += COL;
ctx.indent_level++;
@@ -1341,16 +1399,18 @@ xml_print_datatype(hid_t type, unsigned in_group)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sEnumType Nelems=\"%d\">",xmlnsprefix, nmembs);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "<%sEnumType Nelems=\"%d\">", xmlnsprefix, nmembs);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
xml_print_enum(type);
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sEnumType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "</%sEnumType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
dump_indent -= COL;
ctx.indent_level--;
@@ -1358,8 +1418,9 @@ xml_print_datatype(hid_t type, unsigned in_group)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "</%sAtomicType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
break;
case H5T_VLEN:
@@ -1367,8 +1428,9 @@ xml_print_datatype(hid_t type, unsigned in_group)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sVLType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "<%sVLType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
super = H5Tget_super(type);
dump_indent += COL;
ctx.indent_level++;
@@ -1377,11 +1439,12 @@ xml_print_datatype(hid_t type, unsigned in_group)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sDataType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "<%sDataType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
dump_indent += COL;
ctx.indent_level++;
- xml_print_datatype(super,0);
+ xml_print_datatype(super, 0);
dump_indent -= COL;
ctx.indent_level--;
@@ -1389,8 +1452,9 @@ xml_print_datatype(hid_t type, unsigned in_group)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sDataType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "</%sDataType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
dump_indent -= COL;
ctx.indent_level--;
@@ -1398,8 +1462,9 @@ xml_print_datatype(hid_t type, unsigned in_group)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sVLType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "</%sVLType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
H5Tclose(super);
break;
@@ -1413,10 +1478,11 @@ xml_print_datatype(hid_t type, unsigned in_group)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sArrayType Ndims=\"",xmlnsprefix);
+ h5tools_str_append(&buffer, "<%sArrayType Ndims=\"", xmlnsprefix);
ndims = (unsigned)H5Tget_array_ndims(type);
h5tools_str_append(&buffer, "%u\">", ndims);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
/* Get array information */
H5Tget_array_dims2(type, dims);
@@ -1428,8 +1494,10 @@ xml_print_datatype(hid_t type, unsigned in_group)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sArrayDimension DimSize=\"%u\"/>", xmlnsprefix, (int) dims[i]);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "<%sArrayDimension DimSize=\"%u\"/>", xmlnsprefix,
+ (int)dims[i]);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
}
ctx.indent_level--;
@@ -1440,11 +1508,12 @@ xml_print_datatype(hid_t type, unsigned in_group)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sDataType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "<%sDataType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
dump_indent += COL;
ctx.indent_level++;
- xml_print_datatype(super,0);
+ xml_print_datatype(super, 0);
dump_indent -= COL;
ctx.indent_level--;
@@ -1452,8 +1521,9 @@ xml_print_datatype(hid_t type, unsigned in_group)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sDataType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "</%sDataType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
dump_indent -= COL;
ctx.indent_level--;
@@ -1461,8 +1531,9 @@ xml_print_datatype(hid_t type, unsigned in_group)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sArrayType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "</%sArrayType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
/* Close array base type */
H5Tclose(super);
break;
@@ -1475,7 +1546,8 @@ xml_print_datatype(hid_t type, unsigned in_group)
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "<!-- unknown datatype -->");
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
h5tools_setstatus(EXIT_FAILURE);
break;
}
@@ -1497,53 +1569,53 @@ xml_print_datatype(hid_t type, unsigned in_group)
void
xml_dump_datatype(hid_t type)
{
- h5tools_str_t buffer; /* string into which to render */
- h5tools_context_t ctx; /* print context */
- h5tool_format_t *outputformat = &xml_dataformat;
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t * outputformat = &xml_dataformat;
h5tool_format_t string_dataformat;
- hsize_t curr_pos = 0; /* total data element position */
+ hsize_t curr_pos = 0; /* total data element position */
/* setup */
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
HDmemset(&ctx, 0, sizeof(ctx));
ctx.indent_level = dump_indent / COL;
- ctx.cur_column = dump_indent;
+ ctx.cur_column = dump_indent;
string_dataformat = *outputformat;
if (fp_format) {
string_dataformat.fmt_double = fp_format;
- string_dataformat.fmt_float = fp_format;
+ string_dataformat.fmt_float = fp_format;
}
if (h5tools_nCols == 0) {
- string_dataformat.line_ncols = 65535;
+ string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
- outputformat = &string_dataformat;
+ string_dataformat.do_escape = dump_opts.display_escape;
+ outputformat = &string_dataformat;
ctx.indent_level++;
dump_indent += COL;
- if(H5Tcommitted(type) > 0) {
- H5O_info_t oinfo;
- obj_t *found_obj; /* Found object */
+ if (H5Tcommitted(type) > 0) {
+ H5O_info2_t oinfo;
+ obj_t * found_obj; /* Found object */
/* Datatype is a shared or named datatype */
- H5Oget_info2(type, &oinfo, H5O_INFO_BASIC);
- found_obj = search_obj(type_table, oinfo.addr);
+ H5Oget_info3(type, &oinfo, H5O_INFO_BASIC);
+ found_obj = search_obj(type_table, &oinfo.token);
- if(found_obj) {
+ if (found_obj) {
/* Shared datatype, must be entered as an object */
/* These 2 cases are the same now, but may change */
char *dtxid = (char *)HDmalloc((size_t)100);
- xml_name_to_XID(found_obj->objname, dtxid, 100, 1);
+ xml_name_to_XID(type, found_obj->objname, dtxid, 100, 1);
if (!found_obj->recorded) {
/* anonymous stored datatype:
following the dumper's current
@@ -1555,9 +1627,9 @@ xml_dump_datatype(hid_t type)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sNamedDataTypePtr OBJ-XID=\"%s\"/>",
- xmlnsprefix, dtxid);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "<%sNamedDataTypePtr OBJ-XID=\"%s\"/>", xmlnsprefix, dtxid);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
}
else {
/* pointer to a named datatype already in XML */
@@ -1568,8 +1640,9 @@ xml_dump_datatype(hid_t type)
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "<%sNamedDataTypePtr OBJ-XID=\"%s\" H5Path=\"%s\" />",
- xmlnsprefix, dtxid, t_objname);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ xmlnsprefix, dtxid, t_objname);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
HDfree(t_objname);
}
HDfree(dtxid);
@@ -1580,7 +1653,8 @@ xml_dump_datatype(hid_t type)
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "<!-- h5dump error: unknown committed type. -->");
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
}
}
else {
@@ -1589,7 +1663,8 @@ xml_dump_datatype(hid_t type)
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "<%sDataType>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level++;
dump_indent += COL;
xml_print_datatype(type, 0);
@@ -1601,7 +1676,8 @@ xml_dump_datatype(hid_t type)
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "</%sDataType>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
}
ctx.indent_level--;
dump_indent -= COL;
@@ -1625,38 +1701,38 @@ xml_dump_dataspace(hid_t space)
hsize_t size[H5DUMP_MAX_RANK];
hsize_t maxsize[H5DUMP_MAX_RANK];
int i;
- h5tools_str_t buffer; /* string into which to render */
- h5tools_context_t ctx; /* print context */
- h5tool_format_t *outputformat = &xml_dataformat;
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t * outputformat = &xml_dataformat;
h5tool_format_t string_dataformat;
- hsize_t curr_pos = 0; /* total data element position */
+ hsize_t curr_pos = 0; /* total data element position */
- int ndims = H5Sget_simple_extent_dims(space, size, maxsize);
- H5S_class_t space_type = H5Sget_simple_extent_type(space);
+ int ndims = H5Sget_simple_extent_dims(space, size, maxsize);
+ H5S_class_t space_type = H5Sget_simple_extent_type(space);
/* setup */
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
HDmemset(&ctx, 0, sizeof(ctx));
ctx.indent_level = dump_indent / COL;
- ctx.cur_column = dump_indent;
+ ctx.cur_column = dump_indent;
string_dataformat = *outputformat;
if (fp_format) {
string_dataformat.fmt_double = fp_format;
- string_dataformat.fmt_float = fp_format;
+ string_dataformat.fmt_float = fp_format;
}
if (h5tools_nCols == 0) {
- string_dataformat.line_ncols = 65535;
+ string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
- outputformat = &string_dataformat;
+ string_dataformat.do_escape = dump_opts.display_escape;
+ outputformat = &string_dataformat;
ctx.indent_level++;
@@ -1665,96 +1741,108 @@ xml_dump_dataspace(hid_t space)
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "<%sDataspace>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level++;
switch (space_type) {
- case H5S_SCALAR:
- /* scalar dataspace (just a tag, no XML attrs. defined */
+ case H5S_SCALAR:
+ /* scalar dataspace (just a tag, no XML attrs. defined */
- ctx.need_prefix = TRUE;
+ ctx.need_prefix = TRUE;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sScalarDataspace />",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- break;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sScalarDataspace />", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ break;
- case H5S_SIMPLE:
- /* simple dataspace */
- /* <hdf5:SimpleDataspace Ndims="nd"> */
+ case H5S_SIMPLE:
+ /* simple dataspace */
+ /* <hdf5:SimpleDataspace Ndims="nd"> */
- ctx.need_prefix = TRUE;
+ ctx.need_prefix = TRUE;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sSimpleDataspace Ndims=\"%d\">",xmlnsprefix, ndims);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sSimpleDataspace Ndims=\"%d\">", xmlnsprefix, ndims);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- /* print the <hdf5:Dimension> elements */
- ctx.indent_level++;
- for (i = 0; i < ndims; i++) {
- if (maxsize[i] == H5S_UNLIMITED) {
- ctx.need_prefix = TRUE;
+ /* print the <hdf5:Dimension> elements */
+ ctx.indent_level++;
+ for (i = 0; i < ndims; i++) {
+ if (maxsize[i] == H5S_UNLIMITED) {
+ ctx.need_prefix = TRUE;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sDimension DimSize=\"%" H5_PRINTF_LL_WIDTH "u\" MaxDimSize=\"UNLIMITED\"/>",
- xmlnsprefix,size[i]);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- }
- else if (maxsize[i] == (hsize_t) 0) {
- ctx.need_prefix = TRUE;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer,
+ "<%sDimension DimSize=\"%" PRIuHSIZE "\" MaxDimSize=\"UNLIMITED\"/>",
+ xmlnsprefix, size[i]);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ }
+ else if (maxsize[i] == (hsize_t)0) {
+ ctx.need_prefix = TRUE;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sDimension DimSize=\"%" H5_PRINTF_LL_WIDTH "u\" MaxDimSize=\"%" H5_PRINTF_LL_WIDTH "u\"/>",
- xmlnsprefix,size[i], size[i]);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- }
- else {
- ctx.need_prefix = TRUE;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(
+ &buffer, "<%sDimension DimSize=\"%" PRIuHSIZE "\" MaxDimSize=\"%" PRIuHSIZE "\"/>",
+ xmlnsprefix, size[i], size[i]);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ }
+ else {
+ ctx.need_prefix = TRUE;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sDimension DimSize=\"%" H5_PRINTF_LL_WIDTH "u\" MaxDimSize=\"%" H5_PRINTF_LL_WIDTH "u\"/>",
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(
+ &buffer, "<%sDimension DimSize=\"%" PRIuHSIZE "\" MaxDimSize=\"%" PRIuHSIZE "\"/>",
xmlnsprefix, size[i], maxsize[i]);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ }
}
- }
- ctx.indent_level--;
+ ctx.indent_level--;
- ctx.need_prefix = TRUE;
+ ctx.need_prefix = TRUE;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sSimpleDataspace>", xmlnsprefix );
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- break;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sSimpleDataspace>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ break;
#ifdef TMP
- /* Commented out: wait until the schema is updated first */
- case H5S_NULL:
- /* null dataspace (just a tag, no XML attrs. defined */
+ /* Commented out: wait until the schema is updated first */
+ case H5S_NULL:
+ /* null dataspace (just a tag, no XML attrs. defined */
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sNullDataspace />",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- break;
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sNullDataspace />", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ break;
#endif /* TMP */
- case H5S_NULL:
- case H5S_NO_CLASS:
- default:
- ctx.need_prefix = TRUE;
+ case H5S_NULL:
+ case H5S_NO_CLASS:
+ default:
+ ctx.need_prefix = TRUE;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<!-- unknown dataspace -->");
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<!-- unknown dataspace -->");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
}
ctx.indent_level--;
@@ -1764,7 +1852,8 @@ xml_dump_dataspace(hid_t space)
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "</%sDataspace>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level--;
h5tools_str_close(&buffer);
@@ -1778,31 +1867,24 @@ xml_dump_dataspace(hid_t space)
* the h5tools library.
*
* Return: void
- *
- * Programmer: REMcG
*-------------------------------------------------------------------------
*/
void
-xml_dump_data(hid_t obj_id, int obj_data, struct subset_t H5_ATTR_UNUSED * sset, int H5_ATTR_UNUSED pindex)
+xml_dump_data(hid_t obj_id, int obj_data, struct subset_t H5_ATTR_UNUSED *sset, int H5_ATTR_UNUSED pindex)
{
- hid_t space = -1;
- hid_t type = -1;
- hid_t p_type = -1;
- hsize_t size[64];
- hsize_t nelmts = 1;
- int ndims;
- int i;
- int status = -1;
- void *buf = NULL;
- hsize_t curr_pos = 0; /* total data element position */
- h5tools_str_t buffer; /* string into which to render */
- h5tools_context_t ctx; /* print context */
- h5tool_format_t *outputformat = &xml_dataformat;
- h5tool_format_t string_dataformat;
+ hid_t space = H5I_INVALID_HID;
+ hid_t type = H5I_INVALID_HID;
+ hid_t p_type = H5I_INVALID_HID;
+ int status = -1;
+ hsize_t curr_pos = 0; /* total data element position */
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t * outputformat = &xml_dataformat;
+ h5tool_format_t string_dataformat;
HDmemset(&ctx, 0, sizeof(ctx));
ctx.indent_level = dump_indent / COL;
- ctx.cur_column = dump_indent;
+ ctx.cur_column = dump_indent;
/* Print all the values. */
/* setup */
@@ -1812,29 +1894,30 @@ xml_dump_data(hid_t obj_id, int obj_data, struct subset_t H5_ATTR_UNUSED * sset,
if (fp_format) {
string_dataformat.fmt_double = fp_format;
- string_dataformat.fmt_float = fp_format;
+ string_dataformat.fmt_float = fp_format;
}
if (h5tools_nCols == 0) {
- string_dataformat.line_ncols = 65535;
+ string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.cmpd_sep = " ";
- string_dataformat.cmpd_pre = "";
- string_dataformat.cmpd_suf = "";
- string_dataformat.cmpd_end = "";
+ string_dataformat.cmpd_sep = " ";
+ string_dataformat.cmpd_pre = "";
+ string_dataformat.cmpd_suf = "";
+ string_dataformat.cmpd_end = "";
string_dataformat.arr_linebreak = 0;
- string_dataformat.arr_pre = "";
- outputformat = &string_dataformat;
+ string_dataformat.arr_pre = "";
+ outputformat = &string_dataformat;
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "<%sData>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level++;
@@ -1843,7 +1926,8 @@ xml_dump_data(hid_t obj_id, int obj_data, struct subset_t H5_ATTR_UNUSED * sset,
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level--;
@@ -1859,10 +1943,10 @@ xml_dump_data(hid_t obj_id, int obj_data, struct subset_t H5_ATTR_UNUSED * sset,
else {
h5tools_context_t datactx;
HDmemset(&datactx, 0, sizeof(datactx));
- datactx.need_prefix = TRUE;
+ datactx.need_prefix = TRUE;
datactx.indent_level = ctx.indent_level;
- datactx.cur_column = ctx.cur_column;
- status = h5tools_dump_dset(rawoutstream, outputformat, &datactx, obj_id, NULL);
+ datactx.cur_column = ctx.cur_column;
+ status = h5tools_dump_dset(rawoutstream, outputformat, &datactx, obj_id);
}
}
else {
@@ -1881,48 +1965,18 @@ xml_dump_data(hid_t obj_id, int obj_data, struct subset_t H5_ATTR_UNUSED * sset,
else if (H5Tget_class(type) == H5T_STRING) {
status = xml_print_strs(obj_id, ATTRIBUTE_DATA);
}
- else { /* all other data */
- /* VL data special information */
- unsigned int vl_data = 0; /* contains VL datatypes */
-
- p_type = H5Tget_native_type(type, H5T_DIR_DEFAULT);
-
- /* Check if we have VL data in the dataset's datatype */
- if (h5tools_detect_vlen(p_type) == TRUE)
- vl_data = TRUE;
-
- H5Tclose(type);
-
+ else { /* all other data */
space = H5Aget_space(obj_id);
- if(space == H5S_NULL || space == H5S_NO_CLASS) {
+ if (space == H5S_NULL || space == H5S_NO_CLASS) {
status = SUCCEED;
}
else {
- ndims = H5Sget_simple_extent_dims(space, size, NULL);
-
- for (i = 0; i < ndims; i++)
- nelmts *= size[i];
-
- if((buf = HDmalloc((size_t)(nelmts * MAX(H5Tget_size(type), H5Tget_size(p_type))))) == NULL) {
- error_msg("unable to allocate buffer\n");
- h5tools_setstatus(EXIT_FAILURE);
- status = FAIL;
- }
- else {
- if (H5Aread(obj_id, p_type, buf) >= 0) {
- h5tools_context_t datactx;
- HDmemset(&datactx, 0, sizeof(datactx));
- datactx.need_prefix = TRUE;
- datactx.indent_level = ctx.indent_level;
- datactx.cur_column = ctx.cur_column;
- status = h5tools_dump_mem(rawoutstream, outputformat, &datactx, obj_id, p_type, space, buf);
- }
- /* Reclaim any VL memory, if necessary */
- if (vl_data)
- H5Dvlen_reclaim(p_type, space, H5P_DEFAULT, buf);
-
- HDfree(buf);
- }
+ h5tools_context_t datactx;
+ HDmemset(&datactx, 0, sizeof(datactx));
+ datactx.need_prefix = TRUE;
+ datactx.indent_level = ctx.indent_level;
+ datactx.cur_column = ctx.cur_column;
+ status = h5tools_dump_mem(rawoutstream, outputformat, &datactx, obj_id);
}
H5Tclose(p_type);
H5Sclose(space);
@@ -1938,7 +1992,8 @@ xml_dump_data(hid_t obj_id, int obj_data, struct subset_t H5_ATTR_UNUSED * sset,
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "Unable to print data.");
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level--;
@@ -1953,8 +2008,9 @@ xml_dump_data(hid_t obj_id, int obj_data, struct subset_t H5_ATTR_UNUSED * sset,
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sDataFromFile>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "</%sDataFromFile>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level--;
@@ -1963,7 +2019,8 @@ xml_dump_data(hid_t obj_id, int obj_data, struct subset_t H5_ATTR_UNUSED * sset,
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "</%sData>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
h5tools_str_close(&buffer);
}
@@ -1980,16 +2037,16 @@ xml_dump_data(hid_t obj_id, int obj_data, struct subset_t H5_ATTR_UNUSED * sset,
*/
herr_t
xml_dump_attr(hid_t attr, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *info,
- void H5_ATTR_UNUSED * op_data)
+ void H5_ATTR_UNUSED *op_data)
{
- hid_t attr_id = -1;
- hid_t type = -1;
- hid_t space = -1;
+ hid_t attr_id = H5I_INVALID_HID;
+ hid_t type = H5I_INVALID_HID;
+ hid_t space = H5I_INVALID_HID;
H5S_class_t space_type;
- hsize_t curr_pos = 0; /* total data element position */
- h5tools_str_t buffer; /* string into which to render */
- h5tools_context_t ctx; /* print context */
- h5tool_format_t *outputformat = &xml_dataformat;
+ hsize_t curr_pos = 0; /* total data element position */
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t * outputformat = &xml_dataformat;
h5tool_format_t string_dataformat;
char *t_aname = xml_escape_the_name(attr_name);
@@ -1999,36 +2056,37 @@ xml_dump_attr(hid_t attr, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED
HDmemset(&ctx, 0, sizeof(ctx));
ctx.indent_level = dump_indent / COL;
- ctx.cur_column = dump_indent;
+ ctx.cur_column = dump_indent;
string_dataformat = *outputformat;
if (fp_format) {
string_dataformat.fmt_double = fp_format;
- string_dataformat.fmt_float = fp_format;
+ string_dataformat.fmt_float = fp_format;
}
if (h5tools_nCols == 0) {
- string_dataformat.line_ncols = 65535;
+ string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
- outputformat = &string_dataformat;
+ string_dataformat.do_escape = dump_opts.display_escape;
+ outputformat = &string_dataformat;
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "<%sAttribute Name=\"%s\">", xmlnsprefix, t_aname);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
HDfree(t_aname);
if ((attr_id = H5Aopen(attr, attr_name, H5P_DEFAULT)) >= 0) {
- type = H5Aget_type(attr_id);
- space = H5Aget_space(attr_id);
+ type = H5Aget_type(attr_id);
+ space = H5Aget_space(attr_id);
space_type = H5Sget_simple_extent_type(space);
dump_function_table->dump_dataspace_function(space);
@@ -2037,160 +2095,177 @@ xml_dump_attr(hid_t attr, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED
ctx.indent_level++;
dump_indent += COL;
- if (display_attr_data && space_type != H5S_NULL) {
+ if (dump_opts.display_attr_data && space_type != H5S_NULL) {
switch (H5Tget_class(type)) {
- case H5T_INTEGER:
- case H5T_FLOAT:
- case H5T_STRING:
- case H5T_BITFIELD:
- case H5T_OPAQUE:
- case H5T_ENUM:
- case H5T_ARRAY:
- dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0);
- break;
+ case H5T_INTEGER:
+ case H5T_FLOAT:
+ case H5T_STRING:
+ case H5T_BITFIELD:
+ case H5T_OPAQUE:
+ case H5T_ENUM:
+ case H5T_ARRAY:
+ dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0);
+ break;
+
+ case H5T_TIME:
+ ctx.indent_level++;
+ dump_indent += COL;
- case H5T_TIME:
- ctx.indent_level++;
- dump_indent += COL;
+ ctx.need_prefix = TRUE;
- ctx.need_prefix = TRUE;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sData>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sData>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ ctx.need_prefix = TRUE;
- ctx.need_prefix = TRUE;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<!-- Time data not yet implemented. -->");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<!-- Time data not yet implemented. -->");
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ ctx.need_prefix = TRUE;
- ctx.need_prefix = TRUE;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sNoData/>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sNoData/>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ ctx.need_prefix = TRUE;
- ctx.need_prefix = TRUE;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<hdf5:Data>");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<hdf5:Data>");
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ ctx.need_prefix = TRUE;
- ctx.need_prefix = TRUE;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sData>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sData>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ ctx.indent_level--;
+ dump_indent -= COL;
+ break;
- ctx.indent_level--;
- dump_indent -= COL;
- break;
+ case H5T_COMPOUND:
+ ctx.need_prefix = TRUE;
- case H5T_COMPOUND:
- ctx.need_prefix = TRUE;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<!-- Note: format of compound data not specified -->");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0);
+ break;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<!-- Note: format of compound data not specified -->");
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0);
- break;
+ case H5T_REFERENCE:
+ ctx.need_prefix = TRUE;
- case H5T_REFERENCE:
- ctx.need_prefix = TRUE;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sData>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ if (!H5Tequal(type, H5T_STD_REF_OBJ)) {
+ ctx.need_prefix = TRUE;
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<!-- Note: Region references not supported -->");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+
+ ctx.need_prefix = TRUE;
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ }
+ else {
+ ctx.need_prefix = TRUE;
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+
+ xml_print_refs(attr_id, ATTRIBUTE_DATA);
+
+ ctx.need_prefix = TRUE;
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sDataFromFile>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ }
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sData>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- if (!H5Tequal(type, H5T_STD_REF_OBJ)) {
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<!-- Note: Region references not supported -->");
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "</%sData>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ break;
+ case H5T_VLEN:
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- }
- else {
+ h5tools_str_append(&buffer, "<!-- Note: format of VL data not specified -->");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+
+ dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0);
+ break;
+ case H5T_NO_CLASS:
+ case H5T_NCLASSES:
+ default:
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
-
- xml_print_refs(attr_id, ATTRIBUTE_DATA);
+ h5tools_str_append(&buffer, "<%sData>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sDataFromFile>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- }
-
- ctx.need_prefix = TRUE;
-
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sData>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- break;
-
- case H5T_VLEN:
- ctx.need_prefix = TRUE;
-
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<!-- Note: format of VL data not specified -->");
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
-
- dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0);
- break;
- case H5T_NO_CLASS:
- case H5T_NCLASSES:
- default:
- ctx.need_prefix = TRUE;
-
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sData>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
-
- ctx.need_prefix = TRUE;
+ h5tools_str_append(&buffer, "<!-- Unknown datatype: %d -->", H5Tget_class(type));
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<!-- Unknown datatype: %d -->", H5Tget_class(type));
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
-
- ctx.need_prefix = TRUE;
+ ctx.need_prefix = TRUE;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sNoData/>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sNoData/>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- ctx.need_prefix = TRUE;
+ ctx.need_prefix = TRUE;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sData>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- break;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sData>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ break;
}
}
else {
@@ -2201,7 +2276,8 @@ xml_dump_attr(hid_t attr, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "<%sData>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level++;
@@ -2210,7 +2286,8 @@ xml_dump_attr(hid_t attr, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "<%sNoData/>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level--;
@@ -2219,7 +2296,8 @@ xml_dump_attr(hid_t attr, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "</%sData>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
}
ctx.indent_level--;
dump_indent -= COL;
@@ -2233,7 +2311,8 @@ xml_dump_attr(hid_t attr, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "</%sAttribute>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
h5tools_str_close(&buffer);
return SUCCEED;
@@ -2247,7 +2326,8 @@ xml_dump_attr(hid_t attr, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "<!-- h5dump error: unable to open attribute. -->");
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level--;
@@ -2256,7 +2336,8 @@ xml_dump_attr(hid_t attr, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "</%sAttribute>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
h5tools_str_close(&buffer);
@@ -2278,19 +2359,26 @@ xml_dump_attr(hid_t attr, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED
void
xml_dump_named_datatype(hid_t type, const char *name)
{
- hsize_t curr_pos = 0; /* total data element position */
- h5tools_str_t buffer; /* string into which to render */
- h5tools_context_t ctx; /* print context */
- h5tool_format_t *outputformat = &xml_dataformat;
+ hsize_t curr_pos = 0; /* total data element position */
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t * outputformat = &xml_dataformat;
h5tool_format_t string_dataformat;
- char *tmp;
- char *dtxid;
- char *parentxid;
- char *t_tmp;
- char *t_prefix;
- char *t_name;
+ char * tmp = NULL;
+ char * dtxid = NULL;
+ char * parentxid = NULL;
+ char * t_tmp = NULL;
+ char * t_prefix = NULL;
+ char * t_name = NULL;
tmp = (char *)HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2);
+ if (tmp == NULL) {
+ indentation(dump_indent);
+ error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+
HDstrcpy(tmp, prefix);
HDstrcat(tmp, "/");
HDstrcat(tmp, name);
@@ -2300,34 +2388,34 @@ xml_dump_named_datatype(hid_t type, const char *name)
HDmemset(&ctx, 0, sizeof(ctx));
ctx.indent_level = dump_indent / COL;
- ctx.cur_column = dump_indent;
+ ctx.cur_column = dump_indent;
string_dataformat = *outputformat;
if (fp_format) {
string_dataformat.fmt_double = fp_format;
- string_dataformat.fmt_float = fp_format;
+ string_dataformat.fmt_float = fp_format;
}
if (h5tools_nCols == 0) {
- string_dataformat.line_ncols = 65535;
+ string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
- outputformat = &string_dataformat;
+ string_dataformat.do_escape = dump_opts.display_escape;
+ outputformat = &string_dataformat;
- dtxid = (char *)HDmalloc((size_t)100);
+ dtxid = (char *)HDmalloc((size_t)100);
parentxid = (char *)HDmalloc((size_t)100);
- t_tmp = xml_escape_the_name(tmp);
- t_prefix = xml_escape_the_name(prefix);
- t_name = xml_escape_the_name(name);
+ t_tmp = xml_escape_the_name(tmp);
+ t_prefix = xml_escape_the_name(prefix);
+ t_name = xml_escape_the_name(name);
- xml_name_to_XID(tmp, dtxid, 100, 1);
- xml_name_to_XID(prefix, parentxid, 100, 1);
- if(HDstrncmp(name, "#", (size_t)1) == 0) {
+ xml_name_to_XID(type, tmp, dtxid, 100, 1);
+ xml_name_to_XID(type, prefix, parentxid, 100, 1);
+ if (HDstrncmp(name, "#", (size_t)1) == 0) {
/* Special: this is an 'anonymous' NDT, deleted but
still in use.
We follow the dumper's undocumented practice, and
@@ -2341,34 +2429,35 @@ xml_dump_named_datatype(hid_t type, const char *name)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sNamedDataType Name=\"%s\" OBJ-XID=\"%s\" "
- "Parents=\"%s\" H5ParentPaths=\"%s\">",
- xmlnsprefix,
- name, dtxid,
- parentxid, HDstrcmp(prefix,"") ? t_prefix : "/");
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer,
+ "<%sNamedDataType Name=\"%s\" OBJ-XID=\"%s\" "
+ "Parents=\"%s\" H5ParentPaths=\"%s\">",
+ xmlnsprefix, name, dtxid, parentxid, HDstrcmp(prefix, "") ? t_prefix : "/");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
}
else {
- H5O_info_t oinfo; /* Object info */
+ H5O_info2_t oinfo; /* Object info */
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sNamedDataType Name=\"%s\" OBJ-XID=\"%s\" "
- "H5Path=\"%s\" Parents=\"%s\" H5ParentPaths=\"%s\">",
- xmlnsprefix,
- t_name, dtxid,
- t_tmp, parentxid, (HDstrcmp(prefix, "") ? t_prefix : "/"));
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer,
+ "<%sNamedDataType Name=\"%s\" OBJ-XID=\"%s\" "
+ "H5Path=\"%s\" Parents=\"%s\" H5ParentPaths=\"%s\">",
+ xmlnsprefix, t_name, dtxid, t_tmp, parentxid,
+ (HDstrcmp(prefix, "") ? t_prefix : "/"));
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
/* Check uniqueness of named datatype */
- H5Oget_info2(type, &oinfo, H5O_INFO_BASIC);
- if(oinfo.rc > 1) {
- obj_t *found_obj; /* Found object */
+ H5Oget_info3(type, &oinfo, H5O_INFO_BASIC);
+ if (oinfo.rc > 1) {
+ obj_t *found_obj; /* Found object */
/* Group with more than one link to it... */
- found_obj = search_obj(type_table, oinfo.addr);
+ found_obj = search_obj(type_table, &oinfo.token);
if (found_obj == NULL) {
indentation(dump_indent);
@@ -2376,23 +2465,25 @@ xml_dump_named_datatype(hid_t type, const char *name)
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
- else if(found_obj->displayed) {
+ else if (found_obj->displayed) {
/* We have already printed this named datatype, print it as a
* NamedDatatypePtr
*/
- char pointerxid[100];
+ char pointerxid[100];
char *t_objname = xml_escape_the_name(found_obj->objname);
ctx.indent_level++;
- xml_name_to_XID(found_obj->objname, pointerxid, (int)sizeof(pointerxid), 1);
+ xml_name_to_XID(type, found_obj->objname, pointerxid, (int)sizeof(pointerxid), 1);
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sNamedDatatypePtr OBJ-XID=\"%s\" H5Path=\"%s\"/>", xmlnsprefix, pointerxid, t_objname);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "<%sNamedDatatypePtr OBJ-XID=\"%s\" H5Path=\"%s\"/>", xmlnsprefix,
+ pointerxid, t_objname);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level--;
@@ -2401,7 +2492,8 @@ xml_dump_named_datatype(hid_t type, const char *name)
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "</%sNamedDataType>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
HDfree(t_objname);
goto done;
}
@@ -2417,12 +2509,13 @@ xml_dump_named_datatype(hid_t type, const char *name)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sDataType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "<%sDataType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level++;
dump_indent += COL;
- xml_print_datatype(type,1);
+ xml_print_datatype(type, 1);
ctx.indent_level--;
dump_indent -= COL;
@@ -2430,8 +2523,9 @@ xml_dump_named_datatype(hid_t type, const char *name)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sDataType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "</%sDataType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level--;
dump_indent -= COL;
@@ -2440,8 +2534,9 @@ xml_dump_named_datatype(hid_t type, const char *name)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sNamedDataType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "</%sNamedDataType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
done:
@@ -2468,23 +2563,23 @@ done:
void
xml_dump_group(hid_t gid, const char *name)
{
- H5O_info_t oinfo;
- hid_t gcpl_id;
- hid_t dset, type;
- unsigned crt_order_flags;
- unsigned attr_crt_order_flags;
- int isRoot = 0;
- char type_name[1024];
- char *t_objname = NULL;
- char *par_name = NULL;
- char *cp = NULL;
- char *tmp = NULL;
- char *par = NULL;
- h5tools_str_t buffer; /* string into which to render */
- h5tools_context_t ctx; /* print context */
- h5tool_format_t *outputformat = &xml_dataformat;
- h5tool_format_t string_dataformat;
- hsize_t curr_pos = 0; /* total data element position */
+ H5O_info2_t oinfo;
+ hid_t gcpl_id;
+ hid_t dset, type;
+ unsigned crt_order_flags;
+ unsigned attr_crt_order_flags;
+ int isRoot = 0;
+ char type_name[1024];
+ char * t_objname = NULL;
+ char * par_name = NULL;
+ char * cp = NULL;
+ char * tmp = NULL;
+ char * par = NULL;
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t * outputformat = &xml_dataformat;
+ h5tool_format_t string_dataformat;
+ hsize_t curr_pos = 0; /* total data element position */
if ((gcpl_id = H5Gget_create_plist(gid)) < 0) {
error_msg("error in getting group creation property list ID\n");
@@ -2498,12 +2593,12 @@ xml_dump_group(hid_t gid, const char *name)
}
/* query the group creation properties */
- if(H5Pget_link_creation_order(gcpl_id, &crt_order_flags) < 0) {
+ if (H5Pget_link_creation_order(gcpl_id, &crt_order_flags) < 0) {
error_msg("error in getting group creation properties\n");
h5tools_setstatus(EXIT_FAILURE);
}
- if(H5Pclose(gcpl_id) < 0) {
+ if (H5Pclose(gcpl_id) < 0) {
error_msg("error in closing group creation property list ID\n");
h5tools_setstatus(EXIT_FAILURE);
}
@@ -2513,49 +2608,56 @@ xml_dump_group(hid_t gid, const char *name)
HDmemset(&ctx, 0, sizeof(ctx));
ctx.indent_level = dump_indent / COL;
- ctx.cur_column = dump_indent;
+ ctx.cur_column = dump_indent;
string_dataformat = *outputformat;
if (fp_format) {
string_dataformat.fmt_double = fp_format;
- string_dataformat.fmt_float = fp_format;
+ string_dataformat.fmt_float = fp_format;
}
if (h5tools_nCols == 0) {
- string_dataformat.line_ncols = 65535;
+ string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
- outputformat = &string_dataformat;
+ string_dataformat.do_escape = dump_opts.display_escape;
+ outputformat = &string_dataformat;
- if(HDstrcmp(name, "/") == 0) {
+ if (HDstrcmp(name, "/") == 0) {
isRoot = 1;
- tmp = HDstrdup("/");
+ tmp = HDstrdup("/");
}
else {
tmp = (char *)HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2);
+ if (tmp == NULL) {
+ indentation(dump_indent);
+ error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
+ h5tools_setstatus(EXIT_FAILURE);
+ return;
+ }
+
HDstrcpy(tmp, prefix);
par = HDstrdup(tmp);
- cp = HDstrrchr(par, '/');
- if(cp) {
- if((cp == par) && HDstrlen(par) > 1)
+ cp = HDstrrchr(par, '/');
+ if (cp) {
+ if ((cp == par) && HDstrlen(par) > 1)
*(cp + 1) = '\0';
else
*cp = '\0';
}
}
- H5Oget_info2(gid, &oinfo, H5O_INFO_BASIC);
+ H5Oget_info3(gid, &oinfo, H5O_INFO_BASIC);
- if(oinfo.rc > 1) {
- obj_t *found_obj; /* Found object */
+ if (oinfo.rc > 1) {
+ obj_t *found_obj; /* Found object */
/* Group with more than one link to it... */
- found_obj = search_obj(group_table, oinfo.addr);
+ found_obj = search_obj(group_table, &oinfo.token);
if (found_obj == NULL) {
indentation(dump_indent);
@@ -2563,60 +2665,64 @@ xml_dump_group(hid_t gid, const char *name)
h5tools_setstatus(EXIT_FAILURE);
}
else {
- char *t_name = xml_escape_the_name(name);
- char *grpxid = (char *)HDmalloc((size_t)100);
+ char *t_name = xml_escape_the_name(name);
+ char *grpxid = (char *)HDmalloc((size_t)100);
char *parentxid = (char *)HDmalloc((size_t)100);
- if(found_obj->displayed) {
+ if (found_obj->displayed) {
char *ptrstr = (char *)HDmalloc((size_t)100);
/* already seen: enter a groupptr */
- if(isRoot) {
+ if (isRoot) {
/* probably can't happen! */
- xml_name_to_XID("/", grpxid, 100, 1);
+ xml_name_to_XID(gid, "/", grpxid, 100, 1);
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sRootGroup OBJ-XID=\"%s\" H5Path=\"%s\">",
- xmlnsprefix, grpxid, "/");
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "<%sRootGroup OBJ-XID=\"%s\" H5Path=\"%s\">", xmlnsprefix,
+ grpxid, "/");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
}
else {
t_objname = xml_escape_the_name(found_obj->objname);
- par_name = xml_escape_the_name(par);
- xml_name_to_XID(tmp, grpxid, 100, 1);
- xml_name_to_XID(par, parentxid, 100, 1);
+ par_name = xml_escape_the_name(par);
+ xml_name_to_XID(gid, tmp, grpxid, 100, 1);
+ xml_name_to_XID(gid, par, parentxid, 100, 1);
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sGroup Name=\"%s\" OBJ-XID=\"%s-%d\" H5Path=\"%s\" "
- "Parents=\"%s\" H5ParentPaths=\"%s\">",
- xmlnsprefix,t_name, grpxid, get_next_xid(),
- t_objname, parentxid, par_name);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer,
+ "<%sGroup Name=\"%s\" OBJ-XID=\"%s-%d\" H5Path=\"%s\" "
+ "Parents=\"%s\" H5ParentPaths=\"%s\">",
+ xmlnsprefix, t_name, grpxid, get_next_xid(), t_objname, parentxid,
+ par_name);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
HDfree(t_objname);
HDfree(par_name);
ctx.indent_level++;
- t_objname = xml_escape_the_name(found_obj->objname);/* point to the NDT by name */
- par_name = xml_escape_the_name(par);
- xml_name_to_XID(found_obj->objname, ptrstr, 100, 1);
- xml_name_to_XID(par, parentxid, 100, 1);
+ t_objname = xml_escape_the_name(found_obj->objname); /* point to the NDT by name */
+ par_name = xml_escape_the_name(par);
+ xml_name_to_XID(gid, found_obj->objname, ptrstr, 100, 1);
+ xml_name_to_XID(gid, par, parentxid, 100, 1);
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sGroupPtr OBJ-XID=\"%s\" H5Path=\"%s\" "
- "Parents=\"%s\" H5ParentPaths=\"%s\" />",
- xmlnsprefix,
- ptrstr, t_objname, parentxid, par_name);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer,
+ "<%sGroupPtr OBJ-XID=\"%s\" H5Path=\"%s\" "
+ "Parents=\"%s\" H5ParentPaths=\"%s\" />",
+ xmlnsprefix, ptrstr, t_objname, parentxid, par_name);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level--;
@@ -2628,32 +2734,35 @@ xml_dump_group(hid_t gid, const char *name)
else {
/* first time this group has been seen -- describe it */
- if(isRoot) {
- xml_name_to_XID("/", grpxid, 100, 1);
+ if (isRoot) {
+ xml_name_to_XID(gid, "/", grpxid, 100, 1);
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sRootGroup OBJ-XID=\"%s\" H5Path=\"%s\">",
- xmlnsprefix, grpxid, "/");
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "<%sRootGroup OBJ-XID=\"%s\" H5Path=\"%s\">", xmlnsprefix,
+ grpxid, "/");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
}
else {
char *t_tmp = xml_escape_the_name(tmp);
par_name = xml_escape_the_name(par);
- xml_name_to_XID(tmp, grpxid, 100, 1);
- xml_name_to_XID(par, parentxid, 100, 1);
+ xml_name_to_XID(gid, tmp, grpxid, 100, 1);
+ xml_name_to_XID(gid, par, parentxid, 100, 1);
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sGroup Name=\"%s\" OBJ-XID=\"%s\" H5Path=\"%s\" "
- "Parents=\"%s\" H5ParentPaths=\"%s\" >",
- xmlnsprefix,t_name, grpxid, t_tmp, parentxid, par_name);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer,
+ "<%sGroup Name=\"%s\" OBJ-XID=\"%s\" H5Path=\"%s\" "
+ "Parents=\"%s\" H5ParentPaths=\"%s\" >",
+ xmlnsprefix, t_name, grpxid, t_tmp, parentxid, par_name);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
HDfree(t_tmp);
HDfree(par_name);
@@ -2665,28 +2774,36 @@ xml_dump_group(hid_t gid, const char *name)
ctx.indent_level++;
dump_indent += COL;
- if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) {
- if(H5Aiterate2(gid, sort_by, sort_order, NULL, dump_function_table->dump_attribute_function, NULL) < 0) {
+ if ((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) {
+ if (H5Aiterate2(gid, sort_by, sort_order, NULL,
+ dump_function_table->dump_attribute_function, NULL) < 0) {
error_msg("error getting attribute information\n");
h5tools_setstatus(EXIT_FAILURE);
} /* end if */
- } /* end if */
+ } /* end if */
else {
- if(H5Aiterate2(gid, H5_INDEX_NAME, sort_order, NULL, dump_function_table->dump_attribute_function, NULL) < 0) {
+ if (H5Aiterate2(gid, H5_INDEX_NAME, sort_order, NULL,
+ dump_function_table->dump_attribute_function, NULL) < 0) {
error_msg("error getting attribute information\n");
h5tools_setstatus(EXIT_FAILURE);
} /* end if */
- } /* end else */
+ } /* end else */
- if(isRoot && unamedtype) {
+ if (isRoot && unamedtype) {
unsigned u;
- /* Very special case: dump unamed type in root group */
- for(u = 0; u < type_table->nobjs; u++) {
- if(!type_table->objs[u].recorded) {
+ /* Very special case: dump unnamed type in root group */
+ for (u = 0; u < type_table->nobjs; u++) {
+ if (!type_table->objs[u].recorded) {
+ char *obj_tok_str = NULL;
+
dset = H5Dopen2(gid, type_table->objs[u].objname, H5P_DEFAULT);
type = H5Dget_type(dset);
- HDsprintf(type_name, "#"H5_PRINTF_HADDR_FMT, type_table->objs[u].objno);
+
+ H5Otoken_to_str(dset, &type_table->objs[u].obj_token, &obj_tok_str);
+ HDsnprintf(type_name, sizeof(type_name), "#%s", obj_tok_str);
+ H5free_memory(obj_tok_str);
+
dump_function_table->dump_named_datatype_function(type, type_name);
H5Tclose(type);
H5Dclose(dset);
@@ -2696,10 +2813,10 @@ xml_dump_group(hid_t gid, const char *name)
/* iterate through all the links */
- if((sort_by == H5_INDEX_CRT_ORDER) && (crt_order_flags & H5P_CRT_ORDER_TRACKED))
- H5Literate(gid, sort_by, sort_order, NULL, xml_dump_all_cb, NULL);
+ if ((sort_by == H5_INDEX_CRT_ORDER) && (crt_order_flags & H5P_CRT_ORDER_TRACKED))
+ H5Literate2(gid, sort_by, sort_order, NULL, xml_dump_all_cb, NULL);
else
- H5Literate(gid, H5_INDEX_NAME, sort_order, NULL, xml_dump_all_cb, NULL);
+ H5Literate2(gid, H5_INDEX_NAME, sort_order, NULL, xml_dump_all_cb, NULL);
dump_indent -= COL;
ctx.indent_level--;
@@ -2711,8 +2828,8 @@ xml_dump_group(hid_t gid, const char *name)
}
else {
/* only link -- must be first time! */
- char *t_name = xml_escape_the_name(name);
- char *grpxid = (char *)HDmalloc((size_t)100);
+ char *t_name = xml_escape_the_name(name);
+ char *grpxid = (char *)HDmalloc((size_t)100);
char *parentxid = (char *)HDmalloc((size_t)100);
ctx.need_prefix = TRUE;
@@ -2720,23 +2837,26 @@ xml_dump_group(hid_t gid, const char *name)
/* Render the element */
h5tools_str_reset(&buffer);
- if(isRoot) {
- xml_name_to_XID("/", grpxid, 100, 1);
- h5tools_str_append(&buffer, "<%sRootGroup OBJ-XID=\"%s\" H5Path=\"%s\">", xmlnsprefix, grpxid, "/");
+ if (isRoot) {
+ xml_name_to_XID(gid, "/", grpxid, 100, 1);
+ h5tools_str_append(&buffer, "<%sRootGroup OBJ-XID=\"%s\" H5Path=\"%s\">", xmlnsprefix, grpxid,
+ "/");
}
else {
char *t_tmp = xml_escape_the_name(tmp);
par_name = xml_escape_the_name(par);
- xml_name_to_XID(tmp, grpxid, 100, 1);
- xml_name_to_XID(par, parentxid, 100, 1);
- h5tools_str_append(&buffer, "<%sGroup Name=\"%s\" OBJ-XID=\"%s\" H5Path=\"%s\" "
- "Parents=\"%s\" H5ParentPaths=\"%s\" >",
- xmlnsprefix, t_name, grpxid, t_tmp, parentxid, par_name);
+ xml_name_to_XID(gid, tmp, grpxid, 100, 1);
+ xml_name_to_XID(gid, par, parentxid, 100, 1);
+ h5tools_str_append(&buffer,
+ "<%sGroup Name=\"%s\" OBJ-XID=\"%s\" H5Path=\"%s\" "
+ "Parents=\"%s\" H5ParentPaths=\"%s\" >",
+ xmlnsprefix, t_name, grpxid, t_tmp, parentxid, par_name);
HDfree(t_tmp);
HDfree(par_name);
}
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
HDfree(t_name);
HDfree(grpxid);
@@ -2747,28 +2867,36 @@ xml_dump_group(hid_t gid, const char *name)
ctx.indent_level++;
dump_indent += COL;
- if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) {
- if(H5Aiterate2(gid, sort_by, sort_order, NULL, dump_function_table->dump_attribute_function, NULL) < 0) {
+ if ((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) {
+ if (H5Aiterate2(gid, sort_by, sort_order, NULL, dump_function_table->dump_attribute_function,
+ NULL) < 0) {
error_msg("error getting attribute information\n");
h5tools_setstatus(EXIT_FAILURE);
} /* end if */
- } /* end if */
+ } /* end if */
else {
- if(H5Aiterate2(gid, H5_INDEX_NAME, sort_order, NULL, dump_function_table->dump_attribute_function, NULL) < 0) {
+ if (H5Aiterate2(gid, H5_INDEX_NAME, sort_order, NULL,
+ dump_function_table->dump_attribute_function, NULL) < 0) {
error_msg("error getting attribute information\n");
h5tools_setstatus(EXIT_FAILURE);
} /* end if */
- } /* end else */
+ } /* end else */
- if(isRoot && unamedtype) {
+ if (isRoot && unamedtype) {
unsigned u;
- /* Very special case: dump unamed type in root group */
- for(u = 0; u < type_table->nobjs; u++) {
- if(!type_table->objs[u].recorded) {
+ /* Very special case: dump unnamed type in root group */
+ for (u = 0; u < type_table->nobjs; u++) {
+ if (!type_table->objs[u].recorded) {
+ char *obj_tok_str = NULL;
+
dset = H5Dopen2(gid, type_table->objs[u].objname, H5P_DEFAULT);
type = H5Dget_type(dset);
- HDsprintf(type_name, "#"H5_PRINTF_HADDR_FMT, type_table->objs[u].objno);
+
+ H5Otoken_to_str(dset, &type_table->objs[u].obj_token, &obj_tok_str);
+ HDsnprintf(type_name, sizeof(type_name), "#%s", obj_tok_str);
+ H5free_memory(obj_tok_str);
+
dump_function_table->dump_named_datatype_function(type, type_name);
H5Tclose(type);
H5Dclose(dset);
@@ -2778,10 +2906,10 @@ xml_dump_group(hid_t gid, const char *name)
/* iterate through all the links */
- if((sort_by == H5_INDEX_CRT_ORDER) && (crt_order_flags & H5P_CRT_ORDER_TRACKED))
- H5Literate(gid, sort_by, sort_order, NULL, xml_dump_all_cb, NULL);
+ if ((sort_by == H5_INDEX_CRT_ORDER) && (crt_order_flags & H5P_CRT_ORDER_TRACKED))
+ H5Literate2(gid, sort_by, sort_order, NULL, xml_dump_all_cb, NULL);
else
- H5Literate(gid, H5_INDEX_NAME, sort_order, NULL, xml_dump_all_cb, NULL);
+ H5Literate2(gid, H5_INDEX_NAME, sort_order, NULL, xml_dump_all_cb, NULL);
dump_indent -= COL;
ctx.indent_level--;
@@ -2791,24 +2919,25 @@ xml_dump_group(hid_t gid, const char *name)
/* Render the element */
h5tools_str_reset(&buffer);
- if(isRoot)
+ if (isRoot)
h5tools_str_append(&buffer, "</%sRootGroup>", xmlnsprefix);
else
h5tools_str_append(&buffer, "</%sGroup>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
h5tools_str_close(&buffer);
- if(par)
+ if (par)
HDfree(par);
- if(tmp)
+ if (tmp)
HDfree(tmp);
}
/*-------------------------------------------------------------------------
* Function: xml_print_refs
*
- * Purpose: Print a path to the objects referenced by HDF5 Referneces.
+ * Purpose: Print a path to the objects referenced by HDF5 References.
*
* Return: void
*
@@ -2819,18 +2948,17 @@ static int
xml_print_refs(hid_t did, int source)
{
herr_t e;
- hid_t type = -1;
- hid_t space = -1;
- hssize_t ssiz = -1;
+ hid_t type = H5I_INVALID_HID;
+ hid_t space = H5I_INVALID_HID;
+ hssize_t ssiz = -1;
hsize_t i;
- size_t tsiz;
- hobj_ref_t *refbuf = NULL;
- char *buf = NULL;
- h5tools_str_t buffer; /* string into which to render */
- h5tools_context_t ctx; /* print context */
- h5tool_format_t *outputformat = &xml_dataformat;
+ H5R_ref_t * refbuf = NULL;
+ char * buf = NULL;
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t * outputformat = &xml_dataformat;
h5tool_format_t string_dataformat;
- hsize_t curr_pos = 0; /* total data element position */
+ hsize_t curr_pos = 0; /* total data element position */
if (source == DATASET_DATA) {
type = H5Dget_type(did);
@@ -2855,13 +2983,11 @@ xml_print_refs(hid_t did, int source)
space = H5Dget_space(did);
if ((ssiz = H5Sget_simple_extent_npoints(space)) < 0)
goto error;
- if ((tsiz = H5Tget_size(type)) == 0)
- goto error;
- buf = (char *) HDcalloc((size_t)ssiz, tsiz);
+ buf = (char *)HDcalloc((size_t)ssiz, sizeof(H5R_ref_t));
if (buf == NULL)
goto error;
- e = H5Dread(did, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf);
+ e = H5Dread(did, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf);
/* need to check result here */
if (e < 0)
goto error;
@@ -2870,43 +2996,41 @@ xml_print_refs(hid_t did, int source)
space = H5Aget_space(did);
if ((ssiz = H5Sget_simple_extent_npoints(space)) < 0)
goto error;
- if ((tsiz = H5Tget_size(type)) == 0)
- goto error;
- buf = (char *) HDcalloc((size_t)ssiz, tsiz);
+ buf = (char *)HDcalloc((size_t)ssiz, sizeof(H5R_ref_t));
if (buf == NULL)
goto error;
- e = H5Aread(did, H5T_STD_REF_OBJ, buf);
+ e = H5Aread(did, H5T_STD_REF, buf);
/* need to check the result here */
if (e < 0)
goto error;
}
- refbuf = (hobj_ref_t *)((void *)buf);
+ refbuf = (H5R_ref_t *)((void *)buf);
/* setup */
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
HDmemset(&ctx, 0, sizeof(ctx));
ctx.indent_level = dump_indent / COL;
- ctx.cur_column = dump_indent;
+ ctx.cur_column = dump_indent;
string_dataformat = *outputformat;
if (fp_format) {
string_dataformat.fmt_double = fp_format;
- string_dataformat.fmt_float = fp_format;
+ string_dataformat.fmt_float = fp_format;
}
if (h5tools_nCols == 0) {
- string_dataformat.line_ncols = 65535;
+ string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
- outputformat = &string_dataformat;
+ string_dataformat.do_escape = dump_opts.display_escape;
+ outputformat = &string_dataformat;
for (i = 0; i < (hsize_t)ssiz; i++) {
const char *path = lookup_ref_path(*refbuf);
@@ -2918,7 +3042,8 @@ xml_print_refs(hid_t did, int source)
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "\"%s\"", "NULL");
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
}
else {
char *t_path = xml_escape_the_string(path, -1);
@@ -2928,11 +3053,14 @@ xml_print_refs(hid_t did, int source)
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "\"%s\"", t_path);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
HDfree(t_path);
}
ctx.indent_level--;
+ H5Rdestroy(refbuf);
+
refbuf++;
}
@@ -2944,13 +3072,15 @@ xml_print_refs(hid_t did, int source)
return SUCCEED;
error:
- if(buf)
+ if (buf)
HDfree(buf);
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Tclose(type);
H5Sclose(space);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return FAIL;
}
@@ -2968,21 +3098,21 @@ static int
xml_print_strs(hid_t did, int source)
{
herr_t e;
- hid_t type = -1;
- hid_t space = -1;
- hssize_t ssiz = -1;
+ hid_t type = H5I_INVALID_HID;
+ hid_t space = H5I_INVALID_HID;
+ hssize_t ssiz = -1;
htri_t is_vlstr = FALSE;
- size_t tsiz = 0;
+ size_t tsiz = 0;
hsize_t i;
- size_t str_size = 0;
- char *bp = NULL;
- char *onestring = NULL;
- void *buf = NULL;
- h5tools_str_t buffer; /* string into which to render */
- h5tools_context_t ctx; /* print context */
- h5tool_format_t *outputformat = &xml_dataformat;
+ size_t str_size = 0;
+ char * bp = NULL;
+ char * onestring = NULL;
+ void * buf = NULL;
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t * outputformat = &xml_dataformat;
h5tool_format_t string_dataformat;
- hsize_t curr_pos = 0; /* total data element position */
+ hsize_t curr_pos = 0; /* total data element position */
if (source == DATASET_DATA)
type = H5Dget_type(did);
@@ -2999,9 +3129,9 @@ xml_print_strs(hid_t did, int source)
if (source == DATASET_DATA) {
space = H5Dget_space(did);
- if((ssiz = H5Sget_simple_extent_npoints(space)) < 0)
+ if ((ssiz = H5Sget_simple_extent_npoints(space)) < 0)
goto error;
- if((tsiz = H5Tget_size(type)) == 0)
+ if ((tsiz = H5Tget_size(type)) == 0)
goto error;
buf = HDmalloc((size_t)ssiz * tsiz);
@@ -3014,9 +3144,9 @@ xml_print_strs(hid_t did, int source)
}
else if (source == ATTRIBUTE_DATA) {
space = H5Aget_space(did);
- if((ssiz = H5Sget_simple_extent_npoints(space)) < 0)
+ if ((ssiz = H5Sget_simple_extent_npoints(space)) < 0)
goto error;
- if((tsiz = H5Tget_size(type)) == 0)
+ if ((tsiz = H5Tget_size(type)) == 0)
goto error;
buf = HDmalloc((size_t)ssiz * tsiz);
@@ -3028,33 +3158,36 @@ xml_print_strs(hid_t did, int source)
goto error;
}
- bp = (char*) buf;
- if (!is_vlstr)
- onestring = (char *) HDcalloc(tsiz, sizeof(char));
+ bp = (char *)buf;
+ if (!is_vlstr) {
+ onestring = (char *)HDcalloc(tsiz, sizeof(char));
+ if (onestring == NULL)
+ goto error;
+ }
/* setup */
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
HDmemset(&ctx, 0, sizeof(ctx));
ctx.indent_level = dump_indent / COL;
- ctx.cur_column = dump_indent;
+ ctx.cur_column = dump_indent;
string_dataformat = *outputformat;
if (fp_format) {
string_dataformat.fmt_double = fp_format;
- string_dataformat.fmt_float = fp_format;
+ string_dataformat.fmt_float = fp_format;
}
if (h5tools_nCols == 0) {
- string_dataformat.line_ncols = 65535;
+ string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
- outputformat = &string_dataformat;
+ string_dataformat.do_escape = dump_opts.display_escape;
+ outputformat = &string_dataformat;
for (i = 0; i < (hsize_t)ssiz; i++) {
if (is_vlstr) {
@@ -3073,7 +3206,8 @@ xml_print_strs(hid_t did, int source)
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "NULL");
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
}
else {
char *t_onestring = xml_escape_the_string(onestring, (int)str_size);
@@ -3084,7 +3218,8 @@ xml_print_strs(hid_t did, int source)
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "\"%s\"", t_onestring);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
HDfree(t_onestring);
}
}
@@ -3099,7 +3234,7 @@ xml_print_strs(hid_t did, int source)
HDfree(onestring);
if (buf) {
if (is_vlstr)
- H5Dvlen_reclaim(type, space, H5P_DEFAULT, buf);
+ H5Treclaim(type, space, H5P_DEFAULT, buf);
HDfree(buf);
}
H5Tclose(type);
@@ -3107,13 +3242,15 @@ xml_print_strs(hid_t did, int source)
return SUCCEED;
error:
- if(buf)
+ if (buf)
HDfree(buf);
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Tclose(type);
H5Sclose(space);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return FAIL;
}
@@ -3138,41 +3275,42 @@ check_filters(hid_t dcpl)
size_t cd_nelmts = 20;
unsigned int cd_values[20];
unsigned int flags;
- h5tools_str_t buffer; /* string into which to render */
- h5tools_context_t ctx; /* print context */
- h5tool_format_t *outputformat = &xml_dataformat;
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t * outputformat = &xml_dataformat;
h5tool_format_t string_dataformat;
- hsize_t curr_pos = 0; /* total data element position */
+ hsize_t curr_pos = 0; /* total data element position */
/* setup */
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
HDmemset(&ctx, 0, sizeof(ctx));
ctx.indent_level = dump_indent / COL;
- ctx.cur_column = dump_indent;
+ ctx.cur_column = dump_indent;
string_dataformat = *outputformat;
if (fp_format) {
string_dataformat.fmt_double = fp_format;
- string_dataformat.fmt_float = fp_format;
+ string_dataformat.fmt_float = fp_format;
}
if (h5tools_nCols == 0) {
- string_dataformat.line_ncols = 65535;
+ string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
- outputformat = &string_dataformat;
+ string_dataformat.do_escape = dump_opts.display_escape;
+ outputformat = &string_dataformat;
nfilt = H5Pget_nfilters(dcpl);
if (nfilt <= 0)
return;
for (i = 0; i < nfilt; i++) {
- filter = H5Pget_filter2(dcpl, (unsigned) i, &flags, (size_t *) &cd_nelmts, cd_values, (size_t)120, namebuf, NULL);
+ filter = H5Pget_filter2(dcpl, (unsigned)i, &flags, (size_t *)&cd_nelmts, cd_values, (size_t)120,
+ namebuf, NULL);
if (filter == H5Z_FILTER_DEFLATE) {
ctx.indent_level++;
ctx.need_prefix = TRUE;
@@ -3188,7 +3326,8 @@ check_filters(hid_t dcpl)
h5tools_str_append(&buffer, "%d", cd_values[0]);
}
h5tools_str_append(&buffer, "\"/>");
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level--;
}
else if (filter == H5Z_FILTER_FLETCHER32) {
@@ -3198,7 +3337,8 @@ check_filters(hid_t dcpl)
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "<%sFletcher32 />", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level--;
}
else if (filter == H5Z_FILTER_SHUFFLE) {
@@ -3208,7 +3348,8 @@ check_filters(hid_t dcpl)
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "<%sShuffle />", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level--;
}
else if (filter == H5Z_FILTER_SZIP) {
@@ -3255,7 +3396,8 @@ check_filters(hid_t dcpl)
h5tools_str_append(&buffer, "Header=\"Raw\"");
}
h5tools_str_append(&buffer, "/>");
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level--;
}
else {
@@ -3272,37 +3414,37 @@ xml_dump_fill_value(hid_t dcpl, hid_t type)
size_t sz;
size_t i;
hsize_t space;
- void *buf;
- char *name;
- h5tools_str_t buffer; /* string into which to render */
- h5tools_context_t ctx; /* print context */
- h5tool_format_t *outputformat = &xml_dataformat;
+ void * buf;
+ char * name;
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t * outputformat = &xml_dataformat;
h5tool_format_t string_dataformat;
- hsize_t curr_pos = 0; /* total data element position */
+ hsize_t curr_pos = 0; /* total data element position */
/* setup */
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
HDmemset(&ctx, 0, sizeof(ctx));
ctx.indent_level = dump_indent / COL;
- ctx.cur_column = dump_indent;
+ ctx.cur_column = dump_indent;
string_dataformat = *outputformat;
if (fp_format) {
string_dataformat.fmt_double = fp_format;
- string_dataformat.fmt_float = fp_format;
+ string_dataformat.fmt_float = fp_format;
}
if (h5tools_nCols == 0) {
- string_dataformat.line_ncols = 65535;
+ string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
- outputformat = &string_dataformat;
+ string_dataformat.do_escape = dump_opts.display_escape;
+ outputformat = &string_dataformat;
ctx.indent_level++;
dump_indent += COL;
@@ -3312,31 +3454,34 @@ xml_dump_fill_value(hid_t dcpl, hid_t type)
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "<%sData>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level++;
dump_indent += COL;
space = H5Tget_size(type);
- buf = HDmalloc((size_t) space);
+ buf = HDmalloc((size_t)space);
H5Pget_fill_value(dcpl, type, buf);
if (H5Tget_class(type) == H5T_REFERENCE) {
- const char * path = lookup_ref_path(*(hobj_ref_t *) buf);
+ const char *path = lookup_ref_path(*(H5R_ref_t *)buf);
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
if (!path) {
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "\"%s\"", "NULL");
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
}
else {
char *t_path = xml_escape_the_string(path, -1);
@@ -3346,7 +3491,8 @@ xml_dump_fill_value(hid_t dcpl, hid_t type)
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "\"%s\"", t_path);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
HDfree(t_path);
}
@@ -3355,7 +3501,10 @@ xml_dump_fill_value(hid_t dcpl, hid_t type)
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "</%sDataFromFile>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+
+ H5Rdestroy((H5R_ref_t *)buf);
}
else if (H5Tget_class(type) == H5T_STRING) {
/* ????? */
@@ -3364,197 +3513,224 @@ xml_dump_fill_value(hid_t dcpl, hid_t type)
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "<!-- String fill values not yet implemented. -->");
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
}
else {
/* all other data */
switch (H5Tget_class(type)) {
- case H5T_INTEGER:
- ctx.need_prefix = TRUE;
+ case H5T_INTEGER:
+ ctx.need_prefix = TRUE;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "\"%d\"", *(int *) buf);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "\"%d\"", *(int *)buf);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- ctx.need_prefix = TRUE;
+ ctx.need_prefix = TRUE;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sDataFromFile>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- break;
- case H5T_FLOAT:
- ctx.need_prefix = TRUE;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sDataFromFile>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ break;
+ case H5T_FLOAT:
+ ctx.need_prefix = TRUE;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "\"%f\"", (double)*(float *)buf);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "\"%f\"", (double)*(float *)buf);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- ctx.need_prefix = TRUE;
+ ctx.need_prefix = TRUE;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sDataFromFile>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- break;
- case H5T_BITFIELD:
- case H5T_OPAQUE:
- ctx.need_prefix = TRUE;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sDataFromFile>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ break;
+ case H5T_BITFIELD:
+ case H5T_OPAQUE:
+ ctx.need_prefix = TRUE;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- sz = H5Tget_size(type);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ sz = H5Tget_size(type);
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "\"");
- for (i = 0; i < sz; i++) {
- h5tools_str_append(&buffer, "%x ", *(unsigned int *) buf + (i * sizeof(unsigned int)));
- }
- h5tools_str_append(&buffer, "\"");
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "\"");
+ for (i = 0; i < sz; i++) {
+ unsigned long val = *(unsigned int *)buf + (i * sizeof(unsigned int));
- ctx.need_prefix = TRUE;
+ H5_CHECK_OVERFLOW(val, unsigned long, unsigned);
+ h5tools_str_append(&buffer, "%x ", (unsigned)val);
+ }
+ h5tools_str_append(&buffer, "\"");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sDataFromFile>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- break;
- case H5T_ENUM:
- ctx.need_prefix = TRUE;
+ ctx.need_prefix = TRUE;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- name = H5Tget_member_name(type, *(unsigned *) buf);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sDataFromFile>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ break;
+ case H5T_ENUM:
+ ctx.need_prefix = TRUE;
- ctx.need_prefix = TRUE;
- h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ name = H5Tget_member_name(type, *(unsigned *)buf);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "\"%s\"", name);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- if(name)
- H5free_memory(name);
- ctx.need_prefix = TRUE;
+ ctx.need_prefix = TRUE;
+ h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sDataFromFile>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- break;
- case H5T_ARRAY:
- ctx.need_prefix = TRUE;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "\"%s\"", name);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ if (name)
+ H5free_memory(name);
+ ctx.need_prefix = TRUE;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<!-- Array fill values not yet implemented. -->");
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sDataFromFile>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ break;
+ case H5T_ARRAY:
+ ctx.need_prefix = TRUE;
- ctx.need_prefix = TRUE;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<!-- Array fill values not yet implemented. -->");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- break;
- case H5T_TIME:
- ctx.need_prefix = TRUE;
+ ctx.need_prefix = TRUE;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<!-- Time fill not yet implemented. -->");
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ break;
+ case H5T_TIME:
+ ctx.need_prefix = TRUE;
- ctx.need_prefix = TRUE;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<!-- Time fill not yet implemented. -->");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- break;
- case H5T_COMPOUND:
- ctx.need_prefix = TRUE;
+ ctx.need_prefix = TRUE;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<!-- Compound fill not yet implemented. -->");
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ break;
+ case H5T_COMPOUND:
+ ctx.need_prefix = TRUE;
- ctx.need_prefix = TRUE;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<!-- Compound fill not yet implemented. -->");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- break;
- case H5T_VLEN:
- ctx.need_prefix = TRUE;
+ ctx.need_prefix = TRUE;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<!-- VL fill not yet implemented. -->");
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ break;
+ case H5T_VLEN:
+ ctx.need_prefix = TRUE;
- ctx.need_prefix = TRUE;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<!-- VL fill not yet implemented. -->");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- break;
- case H5T_NO_CLASS:
- case H5T_NCLASSES:
- case H5T_STRING:
- case H5T_REFERENCE:
- default:
- ctx.need_prefix = TRUE;
+ ctx.need_prefix = TRUE;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<!-- Unknown fill datatype: %d -->", H5Tget_class(type));
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ break;
+ case H5T_NO_CLASS:
+ case H5T_NCLASSES:
+ case H5T_STRING:
+ case H5T_REFERENCE:
+ default:
+ ctx.need_prefix = TRUE;
- ctx.need_prefix = TRUE;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<!-- Unknown fill datatype: %d -->", H5Tget_class(type));
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sNoData/>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- break;
+ ctx.need_prefix = TRUE;
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sNoData/>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ break;
}
}
HDfree(buf);
@@ -3566,7 +3742,8 @@ xml_dump_fill_value(hid_t dcpl, hid_t type)
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "</%sData>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level--;
dump_indent -= COL;
@@ -3579,39 +3756,45 @@ xml_dump_fill_value(hid_t dcpl, hid_t type)
* Purpose: Dump a description of an HDF5 dataset in XML.
*
* Return: void
- *
- * Programmer: REMcG
*-------------------------------------------------------------------------
*/
void
-xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED * sset)
+xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *sset)
{
- hid_t type;
- hid_t space;
- hid_t dcpl;
- H5D_fill_value_t fvstatus;
- int maxdims;
- hsize_t *chsize;
- int ndims;
- int i;
- H5D_alloc_time_t at;
- H5D_fill_time_t ft;
- hsize_t tempi;
- char *tmp;
- char *t_name;
- char *t_tmp;
- char *t_prefix;
- unsigned attr_crt_order_flags;
- h5tools_str_t buffer; /* string into which to render */
- h5tools_context_t ctx; /* print context */
- h5tool_format_t *outputformat = &xml_dataformat;
- h5tool_format_t string_dataformat;
- hsize_t curr_pos = 0; /* total data element position */
-
- char *rstr = (char*) HDmalloc((size_t)100);
- char *pstr = (char*) HDmalloc((size_t)100);
-
- tmp = (char*) HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2);
+ hid_t type;
+ hid_t space;
+ hid_t dcpl;
+ H5D_fill_value_t fvstatus;
+ int maxdims;
+ hsize_t * chsize;
+ int ndims;
+ int i;
+ H5D_alloc_time_t at;
+ H5D_fill_time_t ft;
+ hsize_t tempi;
+ char * tmp;
+ char * t_name;
+ char * t_tmp;
+ char * t_prefix;
+ unsigned attr_crt_order_flags;
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t * outputformat = &xml_dataformat;
+ h5tool_format_t string_dataformat;
+ hsize_t curr_pos = 0; /* total data element position */
+
+ char *rstr = (char *)HDmalloc((size_t)100);
+ char *pstr = (char *)HDmalloc((size_t)100);
+
+ tmp = (char *)HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2);
+ if (tmp == NULL) {
+ error_msg("buffer allocation failed\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ HDfree(rstr);
+ HDfree(pstr);
+ return;
+ }
+
HDstrcpy(tmp, prefix);
HDstrcat(tmp, "/");
HDstrcat(tmp, name);
@@ -3621,40 +3804,41 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED * s
HDmemset(&ctx, 0, sizeof(ctx));
ctx.indent_level = dump_indent / COL;
- ctx.cur_column = dump_indent;
+ ctx.cur_column = dump_indent;
- t_name = xml_escape_the_name(name);
- t_tmp = xml_escape_the_name(tmp);
+ t_name = xml_escape_the_name(name);
+ t_tmp = xml_escape_the_name(tmp);
t_prefix = xml_escape_the_name(prefix);
string_dataformat = *outputformat;
if (fp_format) {
string_dataformat.fmt_double = fp_format;
- string_dataformat.fmt_float = fp_format;
+ string_dataformat.fmt_float = fp_format;
}
if (h5tools_nCols == 0) {
- string_dataformat.line_ncols = 65535;
+ string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
- outputformat = &string_dataformat;
+ string_dataformat.do_escape = dump_opts.display_escape;
+ outputformat = &string_dataformat;
- xml_name_to_XID(tmp, rstr, 100, 1);
- xml_name_to_XID(prefix, pstr, 100, 1);
+ xml_name_to_XID(did, tmp, rstr, 100, 1);
+ xml_name_to_XID(did, prefix, pstr, 100, 1);
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sDataset Name=\"%s\" OBJ-XID=\"%s\" H5Path= \"%s\" Parents=\"%s\" H5ParentPaths=\"%s\">",
- xmlnsprefix, t_name, rstr, t_tmp, pstr,
- strcmp(prefix, "") ? t_prefix : "/");
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(
+ &buffer, "<%sDataset Name=\"%s\" OBJ-XID=\"%s\" H5Path= \"%s\" Parents=\"%s\" H5ParentPaths=\"%s\">",
+ xmlnsprefix, t_name, rstr, t_tmp, pstr, strcmp(prefix, "") ? t_prefix : "/");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
HDfree(t_name);
HDfree(t_tmp);
@@ -3663,8 +3847,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED * s
HDfree(pstr);
HDfree(tmp);
- dcpl = H5Dget_create_plist(did);
- type = H5Dget_type(did);
+ dcpl = H5Dget_create_plist(did);
+ type = H5Dget_type(did);
space = H5Dget_space(did);
/* query the creation properties for attributes */
@@ -3672,7 +3856,7 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED * s
/* Print information about storage layout */
if (H5D_CHUNKED == H5Pget_layout(dcpl)) {
- if((maxdims = H5Sget_simple_extent_ndims(space)) < 0) {
+ if ((maxdims = H5Sget_simple_extent_ndims(space)) < 0) {
error_msg("unable to get maxdims\n");
h5tools_setstatus(EXIT_FAILURE);
}
@@ -3686,7 +3870,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED * s
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "<%sStorageLayout>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level++;
dump_indent += COL;
@@ -3697,7 +3882,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED * s
h5tools_str_append(&buffer, "<%sChunkedLayout ", xmlnsprefix);
ndims = H5Pget_chunk(dcpl, maxdims, chsize);
h5tools_str_append(&buffer, "Ndims=\"%d\">", ndims);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level++;
dump_indent += COL;
@@ -3708,8 +3894,10 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED * s
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sChunkDimension DimSize=\"%" H5_PRINTF_LL_WIDTH "u\" />", xmlnsprefix, chsize[i]);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "<%sChunkDimension DimSize=\"%" PRIuHSIZE "\" />", xmlnsprefix,
+ chsize[i]);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
}
ctx.need_prefix = TRUE;
@@ -3717,7 +3905,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED * s
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "<%sRequiredFilter>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level++;
dump_indent += COL;
@@ -3730,7 +3919,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED * s
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "</%sRequiredFilter>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level--;
dump_indent -= COL;
@@ -3740,7 +3930,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED * s
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "</%sChunkedLayout>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level--;
dump_indent -= COL;
@@ -3749,7 +3940,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED * s
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "</%sStorageLayout>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level--;
dump_indent -= COL;
HDfree(chsize);
@@ -3763,7 +3955,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED * s
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "<%sStorageLayout>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level++;
ctx.need_prefix = TRUE;
@@ -3771,7 +3964,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED * s
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "<%sContiguousLayout/>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level--;
ctx.need_prefix = TRUE;
@@ -3779,7 +3973,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED * s
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "</%sStorageLayout>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level--;
}
else if (H5D_COMPACT == H5Pget_layout(dcpl)) {
@@ -3790,7 +3985,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED * s
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "<%sStorageLayout>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level++;
ctx.need_prefix = TRUE;
@@ -3798,7 +3994,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED * s
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "<%sCompactLayout/>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level--;
ctx.need_prefix = TRUE;
@@ -3806,7 +4003,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED * s
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "</%sStorageLayout>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level--;
}
/* and check for external.... ?? */
@@ -3859,7 +4057,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED * s
} /* end switch */
h5tools_str_append(&buffer, "\"");
h5tools_str_append(&buffer, ">");
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level++;
dump_indent += COL;
@@ -3869,10 +4068,12 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED * s
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "<%sFillValue>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
H5Pfill_value_defined(dcpl, &fvstatus);
- if (fvstatus == H5D_FILL_VALUE_UNDEFINED || (fvstatus == H5D_FILL_VALUE_DEFAULT && ft == H5D_FILL_TIME_IFSET)) {
+ if (fvstatus == H5D_FILL_VALUE_UNDEFINED ||
+ (fvstatus == H5D_FILL_VALUE_DEFAULT && ft == H5D_FILL_TIME_IFSET)) {
ctx.indent_level++;
ctx.need_prefix = TRUE;
@@ -3880,7 +4081,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED * s
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "<%sNoFill/>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level--;
}
else {
@@ -3892,7 +4094,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED * s
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "</%sFillValue>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level--;
dump_indent -= COL;
@@ -3902,7 +4105,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED * s
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "</%sFillValueInfo>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level--;
dump_indent -= COL;
@@ -3914,184 +4118,202 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED * s
dump_indent += COL;
if ((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) {
- if (H5Aiterate2(did, sort_by, sort_order, NULL, dump_function_table->dump_attribute_function, NULL) < 0) {
+ if (H5Aiterate2(did, sort_by, sort_order, NULL, dump_function_table->dump_attribute_function, NULL) <
+ 0) {
error_msg("error getting attribute information\n");
h5tools_setstatus(EXIT_FAILURE);
} /* end if */
- } /* end if */
+ } /* end if */
else {
- if (H5Aiterate2(did, H5_INDEX_NAME, sort_order, NULL, dump_function_table->dump_attribute_function, NULL) < 0) {
+ if (H5Aiterate2(did, H5_INDEX_NAME, sort_order, NULL, dump_function_table->dump_attribute_function,
+ NULL) < 0) {
error_msg("error getting attribute information\n");
h5tools_setstatus(EXIT_FAILURE);
} /* end if */
- } /* end else */
+ } /* end else */
ctx.indent_level--;
dump_indent -= COL;
tempi = H5Dget_storage_size(did);
- if (display_data && (tempi > 0)) {
+ if (dump_opts.display_data && (tempi > 0)) {
switch (H5Tget_class(type)) {
- case H5T_INTEGER:
- case H5T_FLOAT:
- case H5T_STRING:
- case H5T_BITFIELD:
- case H5T_OPAQUE:
- case H5T_ENUM:
- case H5T_ARRAY:
- ctx.indent_level++;
- dump_indent += COL;
- dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0);
- ctx.indent_level--;
- dump_indent -= COL;
- break;
-
- case H5T_TIME:
- ctx.indent_level++;
+ case H5T_INTEGER:
+ case H5T_FLOAT:
+ case H5T_STRING:
+ case H5T_BITFIELD:
+ case H5T_OPAQUE:
+ case H5T_ENUM:
+ case H5T_ARRAY:
+ ctx.indent_level++;
+ dump_indent += COL;
+ dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0);
+ ctx.indent_level--;
+ dump_indent -= COL;
+ break;
- ctx.need_prefix = TRUE;
+ case H5T_TIME:
+ ctx.indent_level++;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sData>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ ctx.need_prefix = TRUE;
- ctx.need_prefix = TRUE;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sData>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<!-- Time data not yet implemented. -->");
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ ctx.need_prefix = TRUE;
- ctx.need_prefix = TRUE;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<!-- Time data not yet implemented. -->");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ ctx.need_prefix = TRUE;
- ctx.need_prefix = TRUE;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sData>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ ctx.need_prefix = TRUE;
- ctx.indent_level--;
- break;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sData>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- case H5T_COMPOUND:
- ctx.need_prefix = TRUE;
+ ctx.indent_level--;
+ break;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<!-- Note: format of compound data not specified -->");
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ case H5T_COMPOUND:
+ ctx.need_prefix = TRUE;
- ctx.indent_level++;
- dump_indent += COL;
- dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0);
- ctx.indent_level--;
- dump_indent -= COL;
- break;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<!-- Note: format of compound data not specified -->");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- case H5T_REFERENCE:
- ctx.need_prefix = TRUE;
+ ctx.indent_level++;
+ dump_indent += COL;
+ dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0);
+ ctx.indent_level--;
+ dump_indent -= COL;
+ break;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sData>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- if (!H5Tequal(type, H5T_STD_REF_OBJ)) {
+ case H5T_REFERENCE:
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<!-- Note: Region references not supported -->");
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "<%sData>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ if (!H5Tequal(type, H5T_STD_REF_OBJ)) {
+ ctx.need_prefix = TRUE;
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<!-- Note: Region references not supported -->");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+
+ ctx.need_prefix = TRUE;
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ }
+ else {
+ ctx.need_prefix = TRUE;
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+
+ xml_print_refs(did, DATASET_DATA);
+
+ ctx.need_prefix = TRUE;
+
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sDataFromFile>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ }
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- }
- else {
+ h5tools_str_append(&buffer, "</%sData>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ break;
+
+ case H5T_VLEN:
+ ctx.indent_level--;
+ dump_indent -= COL;
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
-
- xml_print_refs(did, DATASET_DATA);
+ h5tools_str_append(&buffer, "<!-- Note: format of VL data not specified -->");
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ ctx.indent_level++;
+ dump_indent += COL;
+ ctx.indent_level++;
+ dump_indent += COL;
+ dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0);
+ ctx.indent_level--;
+ dump_indent -= COL;
+ break;
+ case H5T_NO_CLASS:
+ case H5T_NCLASSES:
+ default:
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sDataFromFile>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- }
-
- ctx.need_prefix = TRUE;
-
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sData>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- break;
-
- case H5T_VLEN:
- ctx.indent_level--;
- dump_indent -= COL;
- ctx.need_prefix = TRUE;
-
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<!-- Note: format of VL data not specified -->");
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- ctx.indent_level++;
- dump_indent += COL;
-
- ctx.indent_level++;
- dump_indent += COL;
- dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0);
- ctx.indent_level--;
- dump_indent -= COL;
- break;
- case H5T_NO_CLASS:
- case H5T_NCLASSES:
- default:
- ctx.need_prefix = TRUE;
-
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sData>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "<%sData>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- ctx.need_prefix = TRUE;
+ ctx.need_prefix = TRUE;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<!-- Unknown datatype: %d -->", H5Tget_class(type));
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<!-- Unknown datatype: %d -->", H5Tget_class(type));
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- ctx.need_prefix = TRUE;
+ ctx.need_prefix = TRUE;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sNoData/>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "<%sNoData/>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- ctx.need_prefix = TRUE;
+ ctx.need_prefix = TRUE;
- /* Render the element */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sData>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- break;
+ /* Render the element */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "</%sData>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ break;
}
}
else {
@@ -4103,7 +4325,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED * s
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "<%sData>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level++;
ctx.need_prefix = TRUE;
@@ -4111,7 +4334,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED * s
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "<%sNoData/>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level--;
ctx.need_prefix = TRUE;
@@ -4119,7 +4343,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED * s
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "</%sData>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level--;
}
@@ -4132,7 +4357,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED * s
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "</%sDataset>", xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
h5tools_str_close(&buffer);
}
@@ -4151,62 +4377,64 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED * s
static void
xml_print_enum(hid_t type)
{
- char **name = NULL; /*member names */
- unsigned char *value = NULL; /*value array */
- unsigned nmembs; /*number of members */
- hid_t super; /*enum base integer type */
- hid_t native = -1; /*native integer datatype */
- size_t dst_size; /*destination value type size */
- unsigned i; /*miscellaneous counters */
- size_t j;
- h5tools_str_t buffer; /* string into which to render */
- h5tools_context_t ctx; /* print context */
- h5tool_format_t *outputformat = &xml_dataformat;
- h5tool_format_t string_dataformat;
- hsize_t curr_pos = 0; /* total data element position */
+ char ** name = NULL; /*member names */
+ unsigned char * value = NULL; /*value array */
+ unsigned nmembs; /*number of members */
+ hid_t super; /*enum base integer type */
+ hid_t native = H5I_INVALID_HID; /*native integer datatype */
+ size_t dst_size; /*destination value type size */
+ unsigned i; /*miscellaneous counters */
+ size_t j;
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t * outputformat = &xml_dataformat;
+ h5tool_format_t string_dataformat;
+ hsize_t curr_pos = 0; /* total data element position */
/* setup */
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
HDmemset(&ctx, 0, sizeof(ctx));
ctx.indent_level = dump_indent / COL;
- ctx.cur_column = dump_indent;
+ ctx.cur_column = dump_indent;
string_dataformat = *outputformat;
if (fp_format) {
string_dataformat.fmt_double = fp_format;
- string_dataformat.fmt_float = fp_format;
+ string_dataformat.fmt_float = fp_format;
}
if (h5tools_nCols == 0) {
- string_dataformat.line_ncols = 65535;
+ string_dataformat.line_ncols = 65535;
string_dataformat.line_per_line = 1;
}
else
string_dataformat.line_ncols = h5tools_nCols;
- string_dataformat.do_escape = display_escape;
- outputformat = &string_dataformat;
+ string_dataformat.do_escape = dump_opts.display_escape;
+ outputformat = &string_dataformat;
nmembs = (unsigned)H5Tget_nmembers(type);
- super = H5Tget_super(type);
+ super = H5Tget_super(type);
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sDataType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "<%sDataType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- xml_print_datatype(super,0);
+ xml_print_datatype(super, 0);
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sDataType>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "</%sDataType>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
/*
* Determine what datatype to use for the native values. To simplify
@@ -4230,7 +4458,7 @@ xml_print_enum(hid_t type)
}
/* Get the names and raw values of all members */
- name = (char **)HDcalloc((size_t)nmembs, sizeof(char *));
+ name = (char **)HDcalloc((size_t)nmembs, sizeof(char *));
value = (unsigned char *)HDcalloc((size_t)nmembs, MAX(H5Tget_size(type), dst_size));
for (i = 0; i < nmembs; i++) {
@@ -4255,8 +4483,9 @@ xml_print_enum(hid_t type)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sEnumElement>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "<%sEnumElement>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level++;
ctx.need_prefix = TRUE;
h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
@@ -4264,7 +4493,8 @@ xml_print_enum(hid_t type)
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "%s", t_name);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
HDfree(t_name);
ctx.indent_level--;
@@ -4272,15 +4502,17 @@ xml_print_enum(hid_t type)
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sEnumElement>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "</%sEnumElement>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "<%sEnumValue>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "<%sEnumValue>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level++;
ctx.need_prefix = TRUE;
h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
@@ -4294,22 +4526,28 @@ xml_print_enum(hid_t type)
h5tools_str_append(&buffer, "%02x", value[i * dst_size + j]);
}
else if (H5T_SGN_NONE == H5Tget_sign(native)) {
- h5tools_str_append(&buffer,"%" H5_PRINTF_LL_WIDTH "u", *((unsigned long long *)
- ((void *) (value + i * dst_size))));
+ unsigned long long copy;
+
+ HDmemcpy(&copy, value + i * dst_size, sizeof(copy));
+ h5tools_str_append(&buffer, "%llu", copy);
}
else {
- h5tools_str_append(&buffer,"%" H5_PRINTF_LL_WIDTH "d",
- *((long long *) ((void *) (value + i * dst_size))));
+ long long copy;
+
+ HDmemcpy(&copy, value + i * dst_size, sizeof(copy));
+ h5tools_str_append(&buffer, "%lld", copy);
}
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
ctx.indent_level--;
ctx.need_prefix = TRUE;
/* Render the element */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "</%sEnumValue>",xmlnsprefix);
- h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_str_append(&buffer, "</%sEnumValue>", xmlnsprefix);
+ h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos,
+ (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
}
ctx.indent_level--;
dump_indent -= COL;
@@ -4324,4 +4562,3 @@ xml_print_enum(hid_t type)
HDfree(value);
H5Tclose(super);
}
-
diff --git a/tools/src/h5dump/h5dump_xml.h b/tools/src/h5dump/h5dump_xml.h
index 3c59917..d69f6d5 100644
--- a/tools/src/h5dump/h5dump_xml.h
+++ b/tools/src/h5dump/h5dump_xml.h
@@ -6,14 +6,14 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#ifndef H5DUMP_XML_H__
-#define H5DUMP_XML_H__
+#ifndef H5DUMP_XML_H
+#define H5DUMP_XML_H
-extern const char *xmlnsprefix;
+extern const char *xmlnsprefix;
#ifdef __cplusplus
extern "C" {
@@ -22,16 +22,16 @@ extern "C" {
/* The dump functions of the dump_function_table */
/* XML format: same interface, alternative output */
-void xml_dump_group(hid_t, const char *);
-void xml_dump_named_datatype(hid_t, const char *);
-void xml_dump_dataset(hid_t, const char *, struct subset_t *);
-void xml_dump_dataspace(hid_t space);
-void xml_dump_datatype(hid_t type);
-herr_t xml_dump_attr(hid_t, const char *, const H5A_info_t *, void *);
-void xml_dump_data(hid_t, int, struct subset_t *, int);
+void xml_dump_group(hid_t, const char *);
+void xml_dump_named_datatype(hid_t, const char *);
+void xml_dump_dataset(hid_t, const char *, struct subset_t *);
+void xml_dump_dataspace(hid_t space);
+void xml_dump_datatype(hid_t type);
+herr_t xml_dump_attr(hid_t, const char *, const H5A_info_t *, void *);
+void xml_dump_data(hid_t, int, struct subset_t *, int);
#ifdef __cplusplus
}
#endif
-#endif /* !H5DUMP_XML_H__ */
+#endif /* H5DUMP_XML_H */
diff --git a/tools/src/h5format_convert/CMakeLists.txt b/tools/src/h5format_convert/CMakeLists.txt
index 540be8c..d0ddb32 100644
--- a/tools/src/h5format_convert/CMakeLists.txt
+++ b/tools/src/h5format_convert/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.10)
+cmake_minimum_required (VERSION 3.12)
project (HDF5_TOOLS_SRC_H5FC C)
# --------------------------------------------------------------------
@@ -6,7 +6,8 @@ project (HDF5_TOOLS_SRC_H5FC C)
# --------------------------------------------------------------------
if (NOT ONLY_SHARED_LIBS)
add_executable (h5format_convert ${HDF5_TOOLS_SRC_H5FC_SOURCE_DIR}/h5format_convert.c)
- target_include_directories (h5format_convert PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_include_directories (h5format_convert PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5format_convert PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5format_convert STATIC)
target_link_libraries (h5format_convert PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
set_target_properties (h5format_convert PROPERTIES FOLDER tools)
@@ -16,7 +17,8 @@ if (NOT ONLY_SHARED_LIBS)
endif ()
if (BUILD_SHARED_LIBS)
add_executable (h5format_convert-shared ${HDF5_TOOLS_SRC_H5FC_SOURCE_DIR}/h5format_convert.c)
- target_include_directories (h5format_convert-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_include_directories (h5format_convert-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5format_convert-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5format_convert-shared SHARED)
target_link_libraries (h5format_convert-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
set_target_properties (h5format_convert-shared PROPERTIES FOLDER tools)
@@ -25,6 +27,17 @@ if (BUILD_SHARED_LIBS)
set (H5_DEP_EXECUTABLES ${H5_DEP_EXECUTABLES} h5format_convert-shared)
endif ()
+#-----------------------------------------------------------------------------
+# Add Target to clang-format
+#-----------------------------------------------------------------------------
+if (HDF5_ENABLE_FORMATTERS)
+ if (NOT ONLY_SHARED_LIBS)
+ clang_format (HDF5_H5FORMAT_SRC_FORMAT h5format_convert)
+ else ()
+ clang_format (HDF5_H5FORMAT_SRC_FORMAT h5format_convert-shared)
+ endif ()
+endif ()
+
##############################################################################
##############################################################################
### I N S T A L L A T I O N ###
diff --git a/tools/src/h5format_convert/Makefile.am b/tools/src/h5format_convert/Makefile.am
index 2b36949..2c968a3 100644
--- a/tools/src/h5format_convert/Makefile.am
+++ b/tools/src/h5format_convert/Makefile.am
@@ -6,7 +6,7 @@
# This file is part of HDF5. The full HDF5 copyright notice, including
# terms governing use, modification, and redistribution, is contained in
# the COPYING file, which can be found at the root of the source code
-# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.
+# distribution tree, or in https://www.hdfgroup.org/licenses.
# If you do not have access to either file, you may request a copy from
# help@hdfgroup.org.
##
diff --git a/tools/src/h5format_convert/h5format_convert.c b/tools/src/h5format_convert/h5format_convert.c
index 257a047..50d0f5d 100644
--- a/tools/src/h5format_convert/h5format_convert.c
+++ b/tools/src/h5format_convert/h5format_convert.c
@@ -6,7 +6,7 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -15,10 +15,9 @@
* Programmer: Vailin Choi; Feb 2015
*/
-
/*
* We include the private header file so we can get to the uniform
- * programming environment it declares.
+ * programming environment it declares.
* HDF5 API functions (except for H5G_basename())
*/
#include "H5private.h"
@@ -29,41 +28,22 @@
/* Name of tool */
#define PROGRAMNAME "h5format_convert"
-static char *fname_g = NULL;
-static char *dname_g = NULL;
-static int dset_g = FALSE;
-static int noop_g = FALSE;
-static int verbose_g = 0;
+static char *fname_g = NULL;
+static char *dname_g = NULL;
+static int dset_g = FALSE;
+static int noop_g = FALSE;
+static int verbose_g = 0;
/*
* Command-line options: The user can specify short or long-named
* parameters.
*/
-static const char *s_opts = "hVvd:n";
-static struct long_options l_opts[] = {
- { "help", no_arg, 'h' },
- { "hel", no_arg, 'h'},
- { "he", no_arg, 'h'},
- { "version", no_arg, 'V' },
- { "version", no_arg, 'V' },
- { "versio", no_arg, 'V' },
- { "versi", no_arg, 'V' },
- { "vers", no_arg, 'V' },
- { "verbose", no_arg, 'v' },
- { "verbos", no_arg, 'v' },
- { "verbo", no_arg, 'v' },
- { "verb", no_arg, 'v' },
- { "dname", require_arg, 'd' },
- { "dnam", require_arg, 'd' },
- { "dna", require_arg, 'd' },
- { "dn", require_arg, 'd' },
- { "noop", no_arg, 'n' },
- { "noo", no_arg, 'n' },
- { "no", no_arg, 'n' },
- { NULL, 0, '\0' }
-};
-
-
+static const char * s_opts = "hVvd:n";
+static struct h5_long_options l_opts[] = {{"help", no_arg, 'h'}, {"version", no_arg, 'V'},
+ {"verbose", no_arg, 'v'}, {"dname", require_arg, 'd'},
+ {"noop", no_arg, 'n'}, {"enable-error-stack", no_arg, 'E'},
+ {NULL, 0, '\0'}};
+
/*-------------------------------------------------------------------------
* Function: usage
*
@@ -73,7 +53,8 @@ static struct long_options l_opts[] = {
*
*-------------------------------------------------------------------------
*/
-static void usage(const char *prog)
+static void
+usage(const char *prog)
{
HDfprintf(stdout, "usage: %s [OPTIONS] file_name\n", prog);
HDfprintf(stdout, " OPTIONS\n");
@@ -108,79 +89,83 @@ static void usage(const char *prog)
* Purpose: parse command line input
*
* Return: Success: 0
- * Failure: 1
+ * Failure: 1
*
*-------------------------------------------------------------------------
*/
static int
-parse_command_line(int argc, const char **argv)
+parse_command_line(int argc, const char *const *argv)
{
int opt;
- /* no arguments */
+ /* no arguments */
if (argc == 1) {
usage(h5tools_getprogname());
- h5tools_setstatus(EXIT_FAILURE);
+ h5tools_setstatus(EXIT_FAILURE);
goto error;
}
/* parse command line options */
- while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) {
- switch((char) opt) {
- case 'h':
- usage(h5tools_getprogname());
- h5tools_setstatus(EXIT_SUCCESS);
- goto error;
-
- case 'V':
- print_version(h5tools_getprogname());
- h5tools_setstatus(EXIT_SUCCESS);
- goto error;
-
- case 'v':
- verbose_g = TRUE;
- break;
-
- case 'd': /* -d dname */
- if(opt_arg != NULL && *opt_arg)
- dname_g = HDstrdup(opt_arg);
- if(dname_g == NULL) {
- h5tools_setstatus(EXIT_FAILURE);
- error_msg("No dataset name\n", opt_arg);
- usage(h5tools_getprogname());
- goto error;
- }
- dset_g = TRUE;
- break;
-
- case 'n': /* -n */
- noop_g = TRUE;
- break;
-
- default:
- h5tools_setstatus(EXIT_FAILURE);
- usage(h5tools_getprogname());
- goto error;
- break;
- } /* switch */
- } /* while */
-
- if (argc <= opt_ind) {
+ while ((opt = H5_get_option(argc, argv, s_opts, l_opts)) != EOF) {
+ switch ((char)opt) {
+ case 'h':
+ usage(h5tools_getprogname());
+ h5tools_setstatus(EXIT_SUCCESS);
+ goto error;
+
+ case 'V':
+ print_version(h5tools_getprogname());
+ h5tools_setstatus(EXIT_SUCCESS);
+ goto error;
+
+ case 'v':
+ verbose_g = TRUE;
+ break;
+
+ case 'd': /* -d dname */
+ if (H5_optarg != NULL && *H5_optarg)
+ dname_g = HDstrdup(H5_optarg);
+ if (dname_g == NULL) {
+ h5tools_setstatus(EXIT_FAILURE);
+ error_msg("No dataset name `%s`\n", H5_optarg);
+ usage(h5tools_getprogname());
+ goto error;
+ }
+ dset_g = TRUE;
+ break;
+
+ case 'n': /* -n */
+ noop_g = TRUE;
+ break;
+
+ case 'E':
+ enable_error_stack = 1;
+ break;
+
+ default:
+ h5tools_setstatus(EXIT_FAILURE);
+ usage(h5tools_getprogname());
+ goto error;
+ break;
+ } /* switch */
+ } /* while */
+
+ if (argc <= H5_optind) {
error_msg("missing file name\n");
usage(h5tools_getprogname());
- h5tools_setstatus(EXIT_FAILURE);
+ h5tools_setstatus(EXIT_FAILURE);
goto error;
}
- fname_g = HDstrdup(argv[opt_ind]);
+ fname_g = HDstrdup(argv[H5_optind]);
- return(0);
+ return 0;
error:
- return(-1); ;
+ return -1;
+ ;
} /* parse_command_line() */
-
/*-------------------------------------------------------------------------
* Function: leave
*
@@ -202,151 +187,155 @@ leave(int ret)
* Function: convert()
*
* Purpose: To downgrade a dataset's indexing type or layout version:
- * For chunked:
- * Downgrade the chunk indexing type to version 1 B-tree
- * If type is already version 1 B-tree, no further action
- * For compact/contiguous:
- * Downgrade the layout version from 4 to 3
- * If version is already <= 3, no further action
- * For virtual:
- * No further action
+ * For chunked:
+ * Downgrade the chunk indexing type to version 1 B-tree
+ * If type is already version 1 B-tree, no further action
+ * For compact/contiguous:
+ * Downgrade the layout version from 4 to 3
+ * If version is already <= 3, no further action
+ * For virtual:
+ * No further action
*
* Return: Success: 0
- * Failure: 1
+ * Failure: 1
*
*-------------------------------------------------------------------------
*/
static int
convert(hid_t fid, const char *dname)
{
- hid_t dcpl = -1;
- hid_t did = -1;
- H5D_layout_t layout_type;
+ hid_t dcpl = H5I_INVALID_HID;
+ hid_t did = H5I_INVALID_HID;
+ H5D_layout_t layout_type;
H5D_chunk_index_t idx_type;
/* Open the dataset */
- if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) {
+ if ((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) {
error_msg("unable to open dataset \"%s\"\n", dname);
h5tools_setstatus(EXIT_FAILURE);
goto error;
}
- else if(verbose_g)
+ else if (verbose_g)
HDfprintf(stdout, "Open the dataset\n");
/* Get the dataset's creation property list */
- if((dcpl = H5Dget_create_plist(did)) < 0) {
+ if ((dcpl = H5Dget_create_plist(did)) < 0) {
error_msg("unable to get the dataset creation property list\n");
h5tools_setstatus(EXIT_FAILURE);
goto error;
}
/* Get the dataset's layout */
- if((layout_type = H5Pget_layout(dcpl)) < 0) {
+ if ((layout_type = H5Pget_layout(dcpl)) < 0) {
error_msg("unable to get the dataset layout type\n");
h5tools_setstatus(EXIT_FAILURE);
goto error;
}
- else if(verbose_g)
+ else if (verbose_g)
HDfprintf(stdout, "Retrieve the dataset's layout\n");
- switch(layout_type) {
- case H5D_CHUNKED:
- if(verbose_g)
- HDfprintf(stdout, "Dataset is a chunked dataset\n");
+ switch (layout_type) {
+ case H5D_CHUNKED:
+ if (verbose_g)
+ HDfprintf(stdout, "Dataset is a chunked dataset\n");
+
+ /* Get the dataset's chunk indexing type */
+ if (H5Dget_chunk_index_type(did, &idx_type) < 0) {
+ error_msg("unable to get the chunk indexing type for \"%s\"\n", dname);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto error;
+ }
+ else if (verbose_g)
+ HDfprintf(stdout, "Retrieve the dataset's chunk indexing type\n");
+
+ if (idx_type == H5D_CHUNK_IDX_BTREE) {
+ if (verbose_g)
+ HDfprintf(
+ stdout,
+ "Dataset's chunk indexing type is already version 1 B-tree: no further action\n");
+ h5tools_setstatus(EXIT_SUCCESS);
+ goto done;
+ }
+ else if (verbose_g)
+ HDfprintf(stdout, "Dataset's chunk indexing type is not version 1 B-tree\n");
+
+ break;
+
+ case H5D_CONTIGUOUS:
+ if (verbose_g)
+ HDfprintf(stdout, "Dataset is a contiguous dataset: downgrade layout version as needed\n");
+ break;
+
+ case H5D_COMPACT:
+ if (verbose_g)
+ HDfprintf(stdout, "Dataset is a compact dataset: downgrade layout version as needed\n");
+ break;
+
+ case H5D_VIRTUAL:
+ if (verbose_g)
+ HDfprintf(stdout, "No further action for virtual dataset\n");
+ goto done;
- /* Get the dataset's chunk indexing type */
- if(H5Dget_chunk_index_type(did, &idx_type) < 0) {
- error_msg("unable to get the chunk indexing type for \"%s\"\n", dname);
+ case H5D_NLAYOUTS:
+ case H5D_LAYOUT_ERROR:
+ default:
+ error_msg("unknown layout type for \"%s\"\n", dname);
h5tools_setstatus(EXIT_FAILURE);
goto error;
- }
- else if(verbose_g)
- HDfprintf(stdout, "Retrieve the dataset's chunk indexing type\n");
-
- if(idx_type == H5D_CHUNK_IDX_BTREE) {
- if(verbose_g)
- HDfprintf(stdout, "Dataset's chunk indexing type is already version 1 B-tree: no further action\n");
- h5tools_setstatus(EXIT_SUCCESS);
- goto done;
- }
- else if (verbose_g)
- HDfprintf(stdout, "Dataset's chunk indexing type is not version 1 B-tree\n");
-
- break;
-
- case H5D_CONTIGUOUS:
- if(verbose_g)
- HDfprintf(stdout, "Dataset is a contiguous dataset: downgrade layout version as needed\n");
- break;
-
- case H5D_COMPACT:
- if(verbose_g)
- HDfprintf(stdout, "Dataset is a compact dataset: downgrade layout version as needed\n");
- break;
-
- case H5D_VIRTUAL:
- if(verbose_g)
- HDfprintf(stdout, "No further action for virtual dataset\n");
- goto done;
-
- case H5D_NLAYOUTS:
- case H5D_LAYOUT_ERROR:
- default:
- error_msg("unknown layout type for \"%s\"\n", dname);
- h5tools_setstatus(EXIT_FAILURE);
- goto error;
} /* end switch */
/* No further action if it is a noop */
- if(noop_g) {
- if(verbose_g)
+ if (noop_g) {
+ if (verbose_g)
HDfprintf(stdout, "Not converting the dataset\n");
h5tools_setstatus(EXIT_SUCCESS);
goto done;
}
- if(verbose_g)
- HDfprintf(stdout, "Converting the dataset...\n");
+ if (verbose_g)
+ HDfprintf(stdout, "Converting the dataset...\n");
/* Downgrade the dataset */
- if(H5Dformat_convert(did) < 0) {
+ if (H5Dformat_convert(did) < 0) {
error_msg("unable to downgrade dataset \"%s\"\n", dname);
h5tools_setstatus(EXIT_FAILURE);
goto error;
}
- else if(verbose_g)
+ else if (verbose_g)
HDfprintf(stdout, "Done\n");
done:
/* Close the dataset */
- if(H5Dclose(did) < 0) {
+ if (H5Dclose(did) < 0) {
error_msg("unable to close dataset \"%s\"\n", dname);
h5tools_setstatus(EXIT_FAILURE);
goto error;
}
- else if(verbose_g)
+ else if (verbose_g)
HDfprintf(stdout, "Close the dataset\n");
-
+
/* Close the dataset creation property list */
- if(H5Pclose(dcpl) < 0) {
+ if (H5Pclose(dcpl) < 0) {
error_msg("unable to close dataset creation property list\n");
h5tools_setstatus(EXIT_FAILURE);
goto error;
}
- else if(verbose_g)
+ else if (verbose_g)
HDprintf("Close the dataset creation property list\n");
return 0;
error:
- if(verbose_g)
+ if (verbose_g)
HDfprintf(stdout, "Error encountered\n");
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Pclose(dcpl);
H5Dclose(did);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return -1;
} /* convert() */
@@ -362,19 +351,19 @@ error:
*-------------------------------------------------------------------------
*/
static int
-convert_dsets_cb(const char *path, const H5O_info_t *oi, const char *already_visited, void *_fid)
+convert_dsets_cb(const char *path, const H5O_info2_t *oi, const char *already_visited, void *_fid)
{
hid_t fid = *(hid_t *)_fid;
/* If the object has already been seen then just return */
- if(NULL == already_visited) {
- if(oi->type == H5O_TYPE_DATASET) {
- if(verbose_g)
+ if (NULL == already_visited) {
+ if (oi->type == H5O_TYPE_DATASET) {
+ if (verbose_g)
HDfprintf(stdout, "Going to process dataset:%s...\n", path);
- if(convert(fid, path) < 0)
- goto error;
+ if (convert(fid, path) < 0)
+ goto error;
} /* end if */
- } /* end if */
+ } /* end if */
return 0;
@@ -382,66 +371,64 @@ error:
return -1;
} /* end convert_dsets_cb() */
-
/*-------------------------------------------------------------------------
* Function: main
*
* Purpose: To convert the chunk indexing type of a dataset in a file to
- * version 1 B-tree.
+ * version 1 B-tree.
*
* Return: Success: 0
- * Failure: 1
+ * Failure: 1
*
*-------------------------------------------------------------------------
*/
int
-main(int argc, const char *argv[])
+main(int argc, char *argv[])
{
- H5E_auto2_t func;
- void *edata;
- hid_t fid = -1;
+ hid_t fid = H5I_INVALID_HID;
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();
/* Parse command line options */
- if(parse_command_line(argc, argv) < 0)
- goto done;
- else if(verbose_g)
- HDfprintf(stdout, "Process command line options\n");
+ if (parse_command_line(argc, (const char *const *)argv) < 0)
+ goto done;
+ else if (verbose_g)
+ HDfprintf(stdout, "Process command line options\n");
- if(noop_g && verbose_g)
- HDfprintf(stdout, "It is noop...\n");
+ if (noop_g && verbose_g)
+ HDfprintf(stdout, "It is noop...\n");
+
+ /* enable error reporting if command line option */
+ h5tools_error_report();
/* Open the HDF5 file */
- if((fid = h5tools_fopen(fname_g, H5F_ACC_RDWR, H5P_DEFAULT, NULL, NULL, 0)) < 0) {
- error_msg("unable to open file \"%s\"\n", fname_g);
- h5tools_setstatus(EXIT_FAILURE);
- goto done;
- } else if(verbose_g)
- HDfprintf(stdout, "Open the file %s\n", fname_g);
-
- if(dset_g) { /* Convert a specified dataset in the file */
- if(verbose_g)
- HDfprintf(stdout, "Going to process dataset: %s...\n", dname_g);
- if(convert(fid, dname_g) < 0)
- goto done;
- } else { /* Convert all datasets in the file */
- if(verbose_g)
- HDfprintf(stdout, "Processing all datasets in the file...\n");
- if(h5trav_visit(fid, "/", TRUE, TRUE, convert_dsets_cb, NULL, &fid, H5O_INFO_BASIC) < 0)
- goto done;
+ if ((fid = h5tools_fopen(fname_g, H5F_ACC_RDWR, H5P_DEFAULT, FALSE, NULL, 0)) < 0) {
+ error_msg("unable to open file \"%s\"\n", fname_g);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+ else if (verbose_g)
+ HDfprintf(stdout, "Open the file %s\n", fname_g);
+
+ if (dset_g) { /* Convert a specified dataset in the file */
+ if (verbose_g)
+ HDfprintf(stdout, "Going to process dataset: %s...\n", dname_g);
+ if (convert(fid, dname_g) < 0)
+ goto done;
+ }
+ else { /* Convert all datasets in the file */
+ if (verbose_g)
+ HDfprintf(stdout, "Processing all datasets in the file...\n");
+ if (h5trav_visit(fid, "/", TRUE, TRUE, convert_dsets_cb, NULL, &fid, H5O_INFO_BASIC) < 0)
+ goto done;
} /* end else */
- if(verbose_g) {
- if(noop_g) {
+ if (verbose_g) {
+ if (noop_g) {
HDfprintf(stdout, "Not processing the file's superblock...\n");
h5tools_setstatus(EXIT_SUCCESS);
goto done;
@@ -450,7 +437,7 @@ main(int argc, const char *argv[])
} /* end if */
/* Process superblock */
- if(H5Fformat_convert(fid) < 0) {
+ if (H5Fformat_convert(fid) < 0) {
error_msg("unable to convert file's superblock\"%s\"\n", fname_g);
h5tools_setstatus(EXIT_FAILURE);
goto done;
@@ -458,21 +445,21 @@ main(int argc, const char *argv[])
done:
/* Close the file */
- if(fid >= 0) {
- if(H5Fclose(fid) < 0) {
- error_msg("unable to close file \"%s\"\n", fname_g);
- h5tools_setstatus(EXIT_FAILURE);
- } else if(verbose_g)
- HDfprintf(stdout, "Close the file\n");
- } /* end if */
-
- if(fname_g)
- HDfree(fname_g);
- if(dname_g)
- HDfree(dname_g);
-
- H5Eset_auto2(H5E_DEFAULT, func, edata);
+ if (fid >= 0) {
+ if (H5Fclose(fid) < 0) {
+ error_msg("unable to close file \"%s\"\n", fname_g);
+ h5tools_setstatus(EXIT_FAILURE);
+ }
+ else if (verbose_g) {
+ HDfprintf(stdout, "Close the file\n");
+ }
+ } /* end if */
+
+ if (fname_g)
+ HDfree(fname_g);
+ if (dname_g)
+ HDfree(dname_g);
+
leave(h5tools_getstatus());
} /* end main() */
-
diff --git a/tools/src/h5import/CMakeLists.txt b/tools/src/h5import/CMakeLists.txt
index dd7921d..a7f238e 100644
--- a/tools/src/h5import/CMakeLists.txt
+++ b/tools/src/h5import/CMakeLists.txt
@@ -1,12 +1,12 @@
-cmake_minimum_required (VERSION 3.10)
+cmake_minimum_required (VERSION 3.12)
project (HDF5_TOOLS_SRC_H5IMPORT C)
# --------------------------------------------------------------------
# Add the h5import executables
# --------------------------------------------------------------------
if (NOT ONLY_SHARED_LIBS)
- add_executable (h5import ${HDF5_TOOLS_SRC_H5IMPORT_SOURCE_DIR}/h5import.c)
- target_include_directories (h5import PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ add_executable (h5import ${HDF5_TOOLS_SRC_H5IMPORT_SOURCE_DIR}/h5import.c ${HDF5_TOOLS_SRC_H5IMPORT_SOURCE_DIR}/h5import.h)
+ target_include_directories (h5import PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
TARGET_C_PROPERTIES (h5import STATIC)
target_link_libraries (h5import PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
#set_target_properties (h5import PROPERTIES COMPILE_DEFINITIONS H5DEBUGIMPORT)
@@ -17,8 +17,8 @@ if (NOT ONLY_SHARED_LIBS)
endif ()
if (BUILD_SHARED_LIBS)
- add_executable (h5import-shared ${HDF5_TOOLS_SRC_H5IMPORT_SOURCE_DIR}/h5import.c)
- target_include_directories (h5import-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ add_executable (h5import-shared ${HDF5_TOOLS_SRC_H5IMPORT_SOURCE_DIR}/h5import.c ${HDF5_TOOLS_SRC_H5IMPORT_SOURCE_DIR}/h5import.h)
+ target_include_directories (h5import-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
TARGET_C_PROPERTIES (h5import-shared SHARED)
target_link_libraries (h5import-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
#set_target_properties (h5import-shared PROPERTIES COMPILE_DEFINITIONS H5DEBUGIMPORT)
@@ -28,6 +28,17 @@ if (BUILD_SHARED_LIBS)
set (H5_DEP_EXECUTABLES ${H5_DEP_EXECUTABLES} h5import-shared)
endif ()
+#-----------------------------------------------------------------------------
+# Add Target to clang-format
+#-----------------------------------------------------------------------------
+if (HDF5_ENABLE_FORMATTERS)
+ if (NOT ONLY_SHARED_LIBS)
+ clang_format (HDF5_H5IMPORT_SRC_FORMAT h5import)
+ else ()
+ clang_format (HDF5_H5IMPORT_SRC_FORMAT h5import-shared)
+ endif ()
+endif ()
+
##############################################################################
##############################################################################
### I N S T A L L A T I O N ###
diff --git a/tools/src/h5import/Makefile.am b/tools/src/h5import/Makefile.am
index 4623eb5..14a8670 100644
--- a/tools/src/h5import/Makefile.am
+++ b/tools/src/h5import/Makefile.am
@@ -6,7 +6,7 @@
# This file is part of HDF5. The full HDF5 copyright notice, including
# terms governing use, modification, and redistribution, is contained in
# the COPYING file, which can be found at the root of the source code
-# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.
+# distribution tree, or in https://www.hdfgroup.org/licenses.
# If you do not have access to either file, you may request a copy from
# help@hdfgroup.org.
##
diff --git a/tools/src/h5import/h5import.c b/tools/src/h5import/h5import.c
index 1eef5ab..317db81 100644
--- a/tools/src/h5import/h5import.c
+++ b/tools/src/h5import/h5import.c
@@ -6,7 +6,7 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -27,68 +27,69 @@
#endif
/* Local function declarations */
-static int gtoken(char *s);
-static int process(struct Options *opt);
-static int processConfigurationFile(char *infile, struct Input *in);
-static int mapKeywordToIndex(char *key);
-static int parsePathInfo(struct path_info *path, char *strm);
-static int parseDimensions(struct Input *in, char *strm);
-static int getInputSize(struct Input *in, int ival);
-static int getInputClass(struct Input *in, char * strm);
-static int getInputClassType(struct Input *in, char * strm);
-static int getInputByteOrder(struct Input *in, FILE *strm);
-static int InputClassStrToInt(char *temp);
-static int getRank(struct Input *in, FILE *strm);
-static int getDimensionSizes(struct Input *in, FILE *strm);
-static int getOutputSize(struct Input *in, FILE *strm);
-static int getOutputClass(struct Input *in, FILE *strm);
-static int OutputClassStrToInt(char *temp);
-static int getOutputArchitecture(struct Input *in, FILE *strm);
-static int OutputArchStrToInt(const char *temp);
-static int getOutputByteOrder(struct Input *in, FILE *strm);
-static int OutputByteOrderStrToInt(const char *temp);
-static int getChunkedDimensionSizes(struct Input *in, FILE *strm);
-static int getCompressionType(struct Input *in, FILE *strm);
-static int CompressionTypeStrToInt(char *temp);
-static int getCompressionParameter(struct Input *in, FILE *strm);
-static int getExternalFilename(struct Input *in, FILE *strm);
-static int getMaximumDimensionSizes(struct Input *in, FILE *strm);
-static int processDataFile(char *infile, struct Input *in, hid_t file_id);
-static int readIntegerData(FILE *strm, struct Input *in);
-static int readFloatData(FILE *strm, struct Input *in);
-static int allocateIntegerStorage(struct Input *in);
-static int allocateFloatStorage(struct Input *in);
-static int readUIntegerData(FILE *strm, struct Input *in);
-static int allocateUIntegerStorage(struct Input *in);
-static int validateConfigurationParameters(struct Input *in);
-static int processStrData(FILE *strm, struct Input *in, hid_t file_id);
-static int processStrHDFData(FILE *strm, struct Input *in, hid_t file_id);
-uint16_t swap_uint16(uint16_t val);
-int16_t swap_int16(int16_t val);
-uint32_t swap_uint32(uint32_t val);
-int32_t swap_int32(int32_t val);
-int64_t swap_int64(int64_t val);
-uint64_t swap_uint64(uint64_t val);
-
-int main(int argc, char *argv[])
+static int gtoken(char *s);
+static int process(struct Options *opt);
+static int processConfigurationFile(char *infile, struct Input *in);
+static int mapKeywordToIndex(char *key);
+static int parsePathInfo(struct path_info *path, char *strm);
+static int parseDimensions(struct Input *in, char *strm);
+static int getInputSize(struct Input *in, int ival);
+static int getInputClass(struct Input *in, char *strm);
+static int getInputClassType(struct Input *in, char *strm);
+static int getInputByteOrder(struct Input *in, FILE *strm);
+static int InputClassStrToInt(char *temp);
+static int getRank(struct Input *in, FILE *strm);
+static int getDimensionSizes(struct Input *in, FILE *strm);
+static int getOutputSize(struct Input *in, FILE *strm);
+static int getOutputClass(struct Input *in, FILE *strm);
+static int OutputClassStrToInt(char *temp);
+static int getOutputArchitecture(struct Input *in, FILE *strm);
+static int OutputArchStrToInt(const char *temp);
+static int getOutputByteOrder(struct Input *in, FILE *strm);
+static int OutputByteOrderStrToInt(const char *temp);
+static int getChunkedDimensionSizes(struct Input *in, FILE *strm);
+static int getCompressionType(struct Input *in, FILE *strm);
+static int CompressionTypeStrToInt(char *temp);
+static int getCompressionParameter(struct Input *in, FILE *strm);
+static int getExternalFilename(struct Input *in, FILE *strm);
+static int getMaximumDimensionSizes(struct Input *in, FILE *strm);
+static int processDataFile(char *infile, struct Input *in, hid_t file_id);
+static int readIntegerData(FILE *strm, struct Input *in);
+static int readFloatData(FILE *strm, struct Input *in);
+static int allocateIntegerStorage(struct Input *in);
+static int allocateFloatStorage(struct Input *in);
+static int readUIntegerData(FILE *strm, struct Input *in);
+static int allocateUIntegerStorage(struct Input *in);
+static int validateConfigurationParameters(struct Input *in);
+static int processStrData(FILE *strm, struct Input *in, hid_t file_id);
+static int processStrHDFData(FILE *strm, struct Input *in, hid_t file_id);
+uint16_t swap_uint16(uint16_t val);
+int16_t swap_int16(int16_t val);
+uint32_t swap_uint32(uint32_t val);
+int32_t swap_int32(int32_t val);
+int64_t swap_int64(int64_t val);
+uint64_t swap_uint64(uint64_t val);
+
+int
+main(int argc, char *argv[])
{
- struct Options opt;
+ struct Options *opt;
int outfile_named = FALSE;
int token;
int i;
int state = 0;
- struct Input *in = NULL;
-
- const char *err1 = "Invalid number of arguments: %d.\n";
- const char *err2 = "Error in state table.\n";
- const char *err3 = "No output file given.\n";
- const char *err4 = "Program aborted.\n";
- const char *err5 = "Invalid path %s.\n";
- const char *err6 = "Invalid dimensions - %s.\n";
- const char *err7 = "Invalid type of data - %s.\n";
- const char *err8 = "Invalid size of data - %s.\n";
- const char *err9 = "Cannot specify more than 30 input files in one call to h5import.\n";
- const char *err10 = "Length of output file name limited to 255 chars.\n";
+ struct Input * in = NULL;
+
+ const char *err1 = "Invalid number of arguments: %d.\n";
+ const char *err2 = "Error in state table.\n";
+ const char *err3 = "No output file given.\n";
+ const char *err4 = "Program aborted.\n";
+ const char *err5 = "Invalid path %s.\n";
+ const char *err6 = "Invalid dimensions - %s.\n";
+ const char *err7 = "Invalid type of data - %s.\n";
+ const char *err8 = "Invalid size of data - %s.\n";
+ const char *err9 = "Cannot specify more than 30 input files in one call to h5import.\n";
+ const char *err10 = "Length of output file name limited to 255 chars.\n";
h5tools_setprogname(PROGRAMNAME);
h5tools_setstatus(EXIT_SUCCESS);
@@ -96,11 +97,11 @@ int main(int argc, char *argv[])
/* Initialize h5tools lib */
h5tools_init();
- (void) HDsetvbuf(stderr, (char *) NULL, _IOLBF, 0);
- (void) HDsetvbuf(stdout, (char *) NULL, _IOLBF, 0);
+ (void)HDsetvbuf(stderr, (char *)NULL, _IOLBF, 0);
+ (void)HDsetvbuf(stdout, (char *)NULL, _IOLBF, 0);
- /* Initialize the file structure to 0 */
- HDmemset(&opt, 0, sizeof(struct Options));
+ if ((opt = (struct Options *)HDcalloc(1, sizeof(struct Options))) == NULL)
+ goto err;
if (argv[1] && (HDstrcmp("-V", argv[1]) == 0)) {
print_version(PROGRAMNAME);
@@ -111,7 +112,7 @@ int main(int argc, char *argv[])
* validate the number of command line arguments
*/
if (argc < 2) {
- (void) HDfprintf(stderr, err1, argc);
+ (void)HDfprintf(stderr, err1, argc);
usage(argv[0]);
goto err;
}
@@ -129,114 +130,114 @@ int main(int argc, char *argv[])
switch (state) {
- case 1: /* counting input files */
- if (opt.fcount < 29) {
- (void) HDstrcpy(opt.infiles[opt.fcount].datafile, argv[i]);
- in = &(opt.infiles[opt.fcount].in);
- opt.infiles[opt.fcount].config = 0;
- setDefaultValues(in, opt.fcount);
- opt.fcount++;
- }
- else {
- (void) HDfprintf(stderr, err9, argv[i]);
- goto err;
- }
+ case 1: /* counting input files */
+ if (opt->fcount < 29) {
+ (void)HDstrcpy(opt->infiles[opt->fcount].datafile, argv[i]);
+ in = &(opt->infiles[opt->fcount].in);
+ opt->infiles[opt->fcount].config = 0;
+ setDefaultValues(in, opt->fcount);
+ opt->fcount++;
+ }
+ else {
+ (void)HDfprintf(stderr, err9, argv[i]);
+ goto err;
+ }
- break;
+ break;
- case 2: /* -c found; look for configfile */
- break;
+ case 2: /* -c found; look for configfile */
+ break;
- case 3: /* get configfile name */
- (void) HDstrcpy(opt.infiles[opt.fcount-1].configfile, argv[i]);
- opt.infiles[opt.fcount - 1].config = 1;
- break;
+ case 3: /* get configfile name */
+ (void)HDstrcpy(opt->infiles[opt->fcount - 1].configfile, argv[i]);
+ opt->infiles[opt->fcount - 1].config = 1;
+ break;
- case 4: /* -o found; look for outfile */
- break;
+ case 4: /* -o found; look for outfile */
+ break;
- case 5: /* get outfile found */
- if (HDstrlen(argv[i]) > MAX_PATH_NAME_LENGTH) {
- (void) HDfprintf(stderr, err10, argv[i]);
- goto err;
- }
- (void) HDstrcpy(opt.outfile, argv[i]);
- outfile_named = TRUE;
- break;
+ case 5: /* get outfile found */
+ if (HDstrlen(argv[i]) > MAX_PATH_NAME_LENGTH) {
+ (void)HDfprintf(stderr, err10, argv[i]);
+ goto err;
+ }
+ (void)HDstrcpy(opt->outfile, argv[i]);
+ outfile_named = TRUE;
+ break;
- case 6: /* -h found; help, then exit */
- help(argv[0]);
- HDexit(EXIT_SUCCESS);
- break;
+ case 6: /* -h found; help, then exit */
+ help(argv[0]);
+ HDexit(EXIT_SUCCESS);
+ break;
- case 7: /* -d found; look for dimensions */
- break;
+ case 7: /* -d found; look for dimensions */
+ break;
- case 8: /* read dimensions */
- if (parseDimensions(in, argv[i]) == -1) {
- (void) HDfprintf(stderr, err6, argv[i]);
- goto err;
- }
- break;
+ case 8: /* read dimensions */
+ if (parseDimensions(in, argv[i]) == -1) {
+ (void)HDfprintf(stderr, err6, argv[i]);
+ goto err;
+ }
+ break;
- case 9: /* -p found; look for path name */
- break;
+ case 9: /* -p found; look for path name */
+ break;
- case 10: /* read path name */
- if (parsePathInfo(&in->path, argv[i]) == -1) {
- (void) HDfprintf(stderr, err5, argv[i]);
- goto err;
- }
- break;
+ case 10: /* read path name */
+ if (parsePathInfo(&in->path, argv[i]) == -1) {
+ (void)HDfprintf(stderr, err5, argv[i]);
+ goto err;
+ }
+ break;
- case 11: /* -t found; look for data type */
- break;
+ case 11: /* -t found; look for data type */
+ break;
- case 12: /* read data type */
- if (getInputClass(in, argv[i]) == -1) {
- (void) HDfprintf(stderr, err7, argv[i]);
- goto err;
- }
+ case 12: /* read data type */
+ if (getInputClass(in, argv[i]) == -1) {
+ (void)HDfprintf(stderr, err7, argv[i]);
+ goto err;
+ }
- if (in->inputClass == 0 || in->inputClass == 4)
- in->outputClass = 0;
- if (in->inputClass == 1 || in->inputClass == 2 || in->inputClass == 3)
- in->outputClass = 1;
- if (in->inputClass == 6 || in->inputClass == 7)
- in->outputClass = 2;
- break;
+ if (in->inputClass == 0 || in->inputClass == 4)
+ in->outputClass = 0;
+ if (in->inputClass == 1 || in->inputClass == 2 || in->inputClass == 3)
+ in->outputClass = 1;
+ if (in->inputClass == 6 || in->inputClass == 7)
+ in->outputClass = 2;
+ break;
- case 13: /* -s found; look for data size */
- break;
+ case 13: /* -s found; look for data size */
+ break;
- case 14: /* read data size */
- if (getInputSize(in, (int) HDstrtol(argv[i], NULL, BASE_10)) == -1) {
- (void) HDfprintf(stderr, err8, argv[i]);
- goto err;
- }
- /*set default value for output-size */
- in->outputSize = in->inputSize;
- break;
+ case 14: /* read data size */
+ if (getInputSize(in, (int)HDstrtol(argv[i], NULL, BASE_10)) == -1) {
+ (void)HDfprintf(stderr, err8, argv[i]);
+ goto err;
+ }
+ /*set default value for output-size */
+ in->outputSize = in->inputSize;
+ break;
- case ERR: /* command syntax error */
- default:
- (void) HDfprintf(stderr, "%s", err2);
- usage(argv[0]);
- goto err;
+ case ERR: /* command syntax error */
+ default:
+ (void)HDfprintf(stderr, "%s", err2);
+ usage(argv[0]);
+ goto err;
}
}
if (FALSE == outfile_named) {
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err3);
usage(argv[0]);
goto err;
}
- if (process(&opt) == -1)
+ if (process(opt) == -1)
goto err;
- for (i = 0; i < opt.fcount; i++) {
- in = &(opt.infiles[i].in);
+ for (i = 0; i < opt->fcount; i++) {
+ in = &(opt->infiles[i].in);
if (in->sizeOfDimension)
HDfree(in->sizeOfDimension);
if (in->sizeOfChunk)
@@ -248,12 +249,13 @@ int main(int argc, char *argv[])
if (in->data)
HDfree(in->data);
}
+ HDfree(opt);
- return (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
err:
- (void) HDfprintf(stderr, "%s", err4);
- for (i = 0; i < opt.fcount; i++) {
- in = &(opt.infiles[i].in);
+ (void)HDfprintf(stderr, "%s", err4);
+ for (i = 0; i < opt->fcount; i++) {
+ in = &(opt->infiles[i].in);
if (in->sizeOfDimension)
HDfree(in->sizeOfDimension);
if (in->sizeOfChunk)
@@ -265,13 +267,16 @@ err:
if (in->data)
HDfree(in->data);
}
- return (EXIT_FAILURE);
+ HDfree(opt);
+
+ return EXIT_FAILURE;
}
-static int gtoken(char *s)
+static int
+gtoken(char *s)
{
- size_t len;
- int token = ERR;
+ size_t len;
+ int token = ERR;
const char *err1 = "Illegal argument: %s.\n";
@@ -281,47 +286,47 @@ static int gtoken(char *s)
if (s[0] == '-') { /* option name (or negative number) */
len = HDstrlen(&s[1]);
switch (s[1]) {
- case 'o':
- if (!HDstrncmp("outfile", &s[1], len))
- token = OPT_o;
- break;
+ case 'o':
+ if (!HDstrncmp("outfile", &s[1], len))
+ token = OPT_o;
+ break;
- case 'c':
- if (!HDstrncmp("config", &s[1], len))
- token = OPT_c;
- break;
+ case 'c':
+ if (!HDstrncmp("config", &s[1], len))
+ token = OPT_c;
+ break;
- case 'h':
- if (!HDstrncmp("help", &s[1], len))
- token = OPT_h;
- break;
+ case 'h':
+ if (!HDstrncmp("help", &s[1], len))
+ token = OPT_h;
+ break;
- case 'd':
- if (!HDstrncmp("dims", &s[1], len))
- token = OPT_d;
- break;
+ case 'd':
+ if (!HDstrncmp("dims", &s[1], len))
+ token = OPT_d;
+ break;
- case 'p':
- if (!HDstrncmp("path", &s[1], len))
- token = OPT_p;
- break;
+ case 'p':
+ if (!HDstrncmp("path", &s[1], len))
+ token = OPT_p;
+ break;
- case 't':
- if (!HDstrncmp("type", &s[1], len))
- token = OPT_t;
- break;
+ case 't':
+ if (!HDstrncmp("type", &s[1], len))
+ token = OPT_t;
+ break;
- case 's':
- if (!HDstrncmp("size", &s[1], len))
- token = OPT_s;
- break;
- default:
- token = ERR; /* not a supported option tag */
- break;
+ case 's':
+ if (!HDstrncmp("size", &s[1], len))
+ token = OPT_s;
+ break;
+ default:
+ token = ERR; /* not a supported option tag */
+ break;
}
if (token == ERR)
- (void) HDfprintf(stderr, err1, s);
+ (void)HDfprintf(stderr, err1, s);
}
else { /* filename */
token = FILNAME;
@@ -344,19 +349,20 @@ static int gtoken(char *s)
*-------------------------------------------------------------------------
*/
-static int processDataFile(char *infile, struct Input *in, hid_t file_id)
+static int
+processDataFile(char *infile, struct Input *in, hid_t file_id)
{
- FILE *strm = NULL;
- const char *err1 = "Unable to open the input file %s for reading.\n";
- const char *err2 = "Error in allocating integer data storage.\n";
- const char *err3 = "Error in allocating floating-point data storage.\n";
- const char *err4 = "Error in reading integer data.\n";
- const char *err5 = "Error in reading floating-point data.\n";
- const char *err6 = "Error in allocating unsigned integer data storage.\n";
- const char *err7 = "Error in reading unsigned integer data.\n";
- const char *err10 = "Unrecognized input class type.\n";
- const char *err11 = "Error in reading string data.\n";
- int retval = -1;
+ FILE * strm = NULL;
+ const char *err1 = "Unable to open the input file %s for reading.\n";
+ const char *err2 = "Error in allocating integer data storage.\n";
+ const char *err3 = "Error in allocating floating-point data storage.\n";
+ const char *err4 = "Error in reading integer data.\n";
+ const char *err5 = "Error in reading floating-point data.\n";
+ const char *err6 = "Error in allocating unsigned integer data storage.\n";
+ const char *err7 = "Error in reading unsigned integer data.\n";
+ const char *err10 = "Unrecognized input class type.\n";
+ const char *err11 = "Error in reading string data.\n";
+ int retval = -1;
/*-------------------------------------------------------------------------
* special case for opening binary classes in H5_HAVE_WIN32_API
@@ -365,10 +371,10 @@ static int processDataFile(char *infile, struct Input *in, hid_t file_id)
* "UIN" denotes an unsigned integer binary file,
*-------------------------------------------------------------------------
*/
- if (in->inputClass == 4 /* "IN" */|| in->inputClass == 3 /* "FP" */|| in->inputClass == 7 /* "UIN" */) {
+ if (in->inputClass == 4 /* "IN" */ || in->inputClass == 3 /* "FP" */ || in->inputClass == 7 /* "UIN" */) {
if ((strm = HDfopen(infile, READ_OPEN_FLAGS)) == NULL) {
- (void) HDfprintf(stderr, err1, infile);
+ (void)HDfprintf(stderr, err1, infile);
goto error;
}
}
@@ -378,94 +384,92 @@ static int processDataFile(char *infile, struct Input *in, hid_t file_id)
*/
else {
if ((strm = HDfopen(infile, "r")) == NULL) {
- (void) HDfprintf(stderr, err1, infile);
+ (void)HDfprintf(stderr, err1, infile);
goto error;
}
}
switch (in->inputClass) {
- case 0: /* TEXTIN */
- case 4: /* IN */
- if (allocateIntegerStorage(in) == -1) {
- (void) HDfprintf(stderr, err2, infile);
- goto error;
- }
+ case 0: /* TEXTIN */
+ case 4: /* IN */
+ if (allocateIntegerStorage(in) == -1) {
+ (void)HDfprintf(stderr, err2, infile);
+ goto error;
+ }
- if (readIntegerData(strm, in) == -1) {
- (void) HDfprintf(stderr, err4, infile);
- goto error;
- }
- break;
+ if (readIntegerData(strm, in) == -1) {
+ (void)HDfprintf(stderr, err4, infile);
+ goto error;
+ }
+ break;
- case 1: /* TEXTFP */
- case 2: /* TEXTFPE */
- case 3: /* FP */
- if (allocateFloatStorage(in) == -1) {
- (void) HDfprintf(stderr, err3, infile);
- goto error;
+ case 1: /* TEXTFP */
+ case 2: /* TEXTFPE */
+ case 3: /* FP */
+ if (allocateFloatStorage(in) == -1) {
+ (void)HDfprintf(stderr, err3, infile);
+ goto error;
+ }
- }
+ if (readFloatData(strm, in) == -1) {
+ (void)HDfprintf(stderr, err5, infile);
+ goto error;
+ }
+ break;
- if (readFloatData(strm, in) == -1) {
- (void) HDfprintf(stderr, err5, infile);
- goto error;
- }
- break;
+ case 5: /* STR */
+ if (in->h5dumpInput) {
+ if (processStrHDFData(strm, in, file_id) == -1) {
+ (void)HDfprintf(stderr, err11, infile);
+ goto error;
+ }
+ }
+ else {
+ if (processStrData(strm, in, file_id) == -1) {
+ (void)HDfprintf(stderr, err11, infile);
+ goto error;
+ }
+ }
+
+ break;
- case 5: /* STR */
- if (in->h5dumpInput) {
- if (processStrHDFData(strm, in, file_id) == -1) {
- (void) HDfprintf(stderr, err11, infile);
+ case 6: /* TEXTUIN */
+ case 7: /* UIN */
+ if (allocateUIntegerStorage(in) == -1) {
+ (void)HDfprintf(stderr, err6, infile);
goto error;
}
- }
- else {
- if (processStrData(strm, in, file_id) == -1) {
- (void) HDfprintf(stderr, err11, infile);
+ if (readUIntegerData(strm, in) == -1) {
+ (void)HDfprintf(stderr, err7, infile);
goto error;
}
- }
-
- break;
+ break;
- case 6: /* TEXTUIN */
- case 7: /* UIN */
- if (allocateUIntegerStorage(in) == -1) {
- (void) HDfprintf(stderr, err6, infile);
- goto error;
- }
- if (readUIntegerData(strm, in) == -1) {
- (void) HDfprintf(stderr, err7, infile);
+ default:
+ (void)HDfprintf(stderr, "%s", err10);
goto error;
- }
- break;
-
- default:
- (void) HDfprintf(stderr, "%s", err10);
- goto error;
}
/* Set success return value */
retval = 0;
error:
- if(strm)
+ if (strm)
HDfclose(strm);
- return(retval);
+ return (retval);
}
-static int readIntegerData(FILE *strm, struct Input *in)
+static int
+readIntegerData(FILE *strm, struct Input *in)
{
- H5DT_INT8 *in08;
+ H5DT_INT8 * in08;
H5DT_INT16 *in16;
H5DT_INT16 temp16;
H5DT_INT32 *in32;
H5DT_INT32 temp32;
-#ifdef H5_SIZEOF_LONG_LONG
H5DT_INT64 *in64;
H5DT_INT64 temp64;
char buffer[256];
-#endif
hsize_t len = 1;
hsize_t i;
int j;
@@ -478,335 +482,331 @@ static int readIntegerData(FILE *strm, struct Input *in)
len *= in->sizeOfDimension[j];
switch (in->inputSize) {
- case 8:
- switch (in->inputClass) {
- case 0: /* TEXTIN */
- in08 = (H5DT_INT8 *) in->data;
- for (i = 0; i < len; i++, in08++) {
- if (fscanf(strm, "%hd", &temp16) != 1) {
- (void) HDfprintf(stderr, "%s", err1);
- return (-1);
- }
- (*in08) = (H5DT_INT8) temp16;
- }
- break;
+ case 8:
+ switch (in->inputClass) {
+ case 0: /* TEXTIN */
+ in08 = (H5DT_INT8 *)in->data;
+ for (i = 0; i < len; i++, in08++) {
+ if (HDfscanf(strm, "%hd", &temp16) != 1) {
+ (void)HDfprintf(stderr, "%s", err1);
+ return (-1);
+ }
+ (*in08) = (H5DT_INT8)temp16;
+ }
+ break;
- case 4: /* IN */
- in08 = (H5DT_INT8 *) in->data;
- for (i = 0; i < len; i++, in08++) {
- if (HDfread((char *) in08, sizeof(H5DT_INT8), 1, strm) != 1) {
- (void) HDfprintf(stderr, "%s", err1);
- return (-1);
- }
+ case 4: /* IN */
+ in08 = (H5DT_INT8 *)in->data;
+ for (i = 0; i < len; i++, in08++) {
+ if (HDfread((char *)in08, sizeof(H5DT_INT8), 1, strm) != 1) {
+ (void)HDfprintf(stderr, "%s", err1);
+ return (-1);
+ }
#ifdef H5DEBUGIMPORT
- HDprintf("readIntegerData %d (0x%.8X)\n", *in08, *in08);
+ HDprintf("readIntegerData %d (0x%.8X)\n", *in08, *in08);
#endif
- }
- break;
-
- default:
- (void) HDfprintf(stderr, "%s", err2);
- return (-1);
- }
- break;
+ }
+ break;
- case 16:
- in16 = (H5DT_INT16 *) in->data;
- switch (in->inputClass) {
- case 0: /* TEXTIN */
- for (i = 0; i < len; i++, in16++) {
- if (fscanf(strm, "%hd", in16) != 1) {
- (void) HDfprintf(stderr, "%s", err1);
+ default:
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
- }
}
- in16 = (H5DT_INT16 *) in->data;
break;
- case 4: /* IN */
- for (i = 0; i < len; i++, in16++) {
- if (HDfread((char *)&temp16, sizeof(H5DT_INT16), 1, strm) != 1) {
- (void) HDfprintf(stderr, "%s", err1);
- return (-1);
- }
-/*
- if (in-> h5dumpInput && (in->inputByteOrder != in->outputByteOrder))
- *in16 = swap_int16(temp16);
- else
-*/
- *in16 = temp16;
+ case 16:
+ in16 = (H5DT_INT16 *)in->data;
+ switch (in->inputClass) {
+ case 0: /* TEXTIN */
+ for (i = 0; i < len; i++, in16++) {
+ if (HDfscanf(strm, "%hd", in16) != 1) {
+ (void)HDfprintf(stderr, "%s", err1);
+ return (-1);
+ }
+ }
+ in16 = (H5DT_INT16 *)in->data;
+ break;
+
+ case 4: /* IN */
+ for (i = 0; i < len; i++, in16++) {
+ if (HDfread((char *)&temp16, sizeof(H5DT_INT16), 1, strm) != 1) {
+ (void)HDfprintf(stderr, "%s", err1);
+ return (-1);
+ }
+ /*
+ if (in-> h5dumpInput && (in->inputByteOrder != in->outputByteOrder))
+ *in16 = swap_int16(temp16);
+ else
+ */
+ *in16 = temp16;
#ifdef H5DEBUGIMPORT
- HDprintf("readIntegerData %d (0x%.8X)\n", *in16, temp16);
+ HDprintf("readIntegerData %d (0x%.8X)\n", *in16, temp16);
#endif
- }
- break;
-
- default:
- (void) HDfprintf(stderr, "%s", err2);
- return (-1);
- }
- break;
+ }
+ break;
- case 32:
- in32 = (H5DT_INT32 *) in->data;
- switch (in->inputClass) {
- case 0: /* TEXTIN */
- for (i = 0; i < len; i++, in32++) {
- if (fscanf(strm, "%d", in32) != 1) {
- (void) HDfprintf(stderr, "%s", err1);
+ default:
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
- }
}
break;
- case 4: /* IN */
- for (i = 0; i < len; i++, in32++) {
- if (HDfread((char *)&temp32, sizeof(H5DT_INT32), 1, strm) != 1) {
- (void) HDfprintf(stderr, "%s", err1);
- return (-1);
- }
-/*
- if (in-> h5dumpInput && (in->inputByteOrder != in->outputByteOrder))
- *in32 = swap_int32(temp32);
- else
-*/
- *in32 = temp32;
+ case 32:
+ in32 = (H5DT_INT32 *)in->data;
+ switch (in->inputClass) {
+ case 0: /* TEXTIN */
+ for (i = 0; i < len; i++, in32++) {
+ if (HDfscanf(strm, "%d", in32) != 1) {
+ (void)HDfprintf(stderr, "%s", err1);
+ return (-1);
+ }
+ }
+ break;
+
+ case 4: /* IN */
+ for (i = 0; i < len; i++, in32++) {
+ if (HDfread((char *)&temp32, sizeof(H5DT_INT32), 1, strm) != 1) {
+ (void)HDfprintf(stderr, "%s", err1);
+ return (-1);
+ }
+ /*
+ if (in-> h5dumpInput && (in->inputByteOrder != in->outputByteOrder))
+ *in32 = swap_int32(temp32);
+ else
+ */
+ *in32 = temp32;
#ifdef H5DEBUGIMPORT
- HDprintf("readIntegerData %d (0x%.8X = 0x%.8X)\n", *in32, *in32, temp32);
+ HDprintf("readIntegerData %d (0x%.8X = 0x%.8X)\n", *in32, *in32, temp32);
#endif
- }
- break;
-
- default:
- (void) HDfprintf(stderr, "%s", err2);
- return (-1);
- }
- break;
+ }
+ break;
-#ifdef H5_SIZEOF_LONG_LONG
- case 64:
- in64 = (H5DT_INT64 *) in->data;
- switch (in->inputClass) {
- case 0: /* TEXTIN */
- for (i = 0; i < len; i++, in64++) {
- if (fscanf(strm, "%s", buffer) < 1) {
- (void) HDfprintf(stderr, "%s", err1);
+ default:
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
- }
- *in64 = (H5DT_INT64) HDstrtoll(buffer, NULL, 10);
}
break;
- case 4: /* IN */
- for (i = 0; i < len; i++, in64++) {
- if (HDfread((char *)&temp64, sizeof(H5DT_INT64), 1, strm) != 1) {
- (void) HDfprintf(stderr, "%s", err1);
- return (-1);
- }
-/*
- if (in-> h5dumpInput && (in->inputByteOrder != in->outputByteOrder))
- *in64 = swap_int64(temp64);
- else
-*/
- *in64 = temp64;
+ case 64:
+ in64 = (H5DT_INT64 *)in->data;
+ switch (in->inputClass) {
+ case 0: /* TEXTIN */
+ for (i = 0; i < len; i++, in64++) {
+ if (HDfscanf(strm, "%s", buffer) < 1) {
+ (void)HDfprintf(stderr, "%s", err1);
+ return (-1);
+ }
+ *in64 = (H5DT_INT64)HDstrtoll(buffer, NULL, 10);
+ }
+ break;
+
+ case 4: /* IN */
+ for (i = 0; i < len; i++, in64++) {
+ if (HDfread((char *)&temp64, sizeof(H5DT_INT64), 1, strm) != 1) {
+ (void)HDfprintf(stderr, "%s", err1);
+ return (-1);
+ }
+ /*
+ if (in-> h5dumpInput && (in->inputByteOrder != in->outputByteOrder))
+ *in64 = swap_int64(temp64);
+ else
+ */
+ *in64 = temp64;
#ifdef H5DEBUGIMPORT
- HDprintf("readIntegerData %d (0x%.8X)\n", *in64, temp64);
+ HDprintf("readIntegerData %d (0x%.8X)\n", *in64, temp64);
#endif
+ }
+ break;
+
+ default:
+ (void)HDfprintf(stderr, "%s", err2);
+ return (-1);
}
break;
default:
- (void) HDfprintf(stderr, "%s", err2);
- return (-1);
- }
- break;
-#endif /* ifdef H5_SIZEOF_LONG_LONG */
-
- default:
- (void) HDfprintf(stderr, "%s", err3);
- break;
+ (void)HDfprintf(stderr, "%s", err3);
+ break;
}
return (0);
}
-static int readUIntegerData(FILE *strm, struct Input *in)
+static int
+readUIntegerData(FILE *strm, struct Input *in)
{
- H5DT_UINT8 *in08;
+ H5DT_UINT8 * in08;
H5DT_UINT16 *in16;
H5DT_UINT16 temp16;
H5DT_UINT32 *in32;
H5DT_UINT32 temp32;
-#ifdef H5_SIZEOF_LONG_LONG
H5DT_UINT64 *in64;
H5DT_UINT64 temp64;
- char buffer[256];
-#endif
- hsize_t len = 1;
- hsize_t i;
- int j;
- const char *err1 = "Unable to get unsigned integer value from file.\n";
- const char *err2 = "Unrecognized input class type.\n";
- const char *err3 = "Invalid input size.\n";
+ char buffer[256];
+ hsize_t len = 1;
+ hsize_t i;
+ int j;
+ const char * err1 = "Unable to get unsigned integer value from file.\n";
+ const char * err2 = "Unrecognized input class type.\n";
+ const char * err3 = "Invalid input size.\n";
for (j = 0; j < in->rank; j++)
len *= in->sizeOfDimension[j];
switch (in->inputSize) {
- case 8:
- switch (in->inputClass) {
- case 6: /* TEXTUIN */
- in08 = (H5DT_UINT8 *) in->data;
- for (i = 0; i < len; i++, in08++) {
- if (fscanf(strm, "%hu", &temp16) != 1) {
- (void) HDfprintf(stderr, "%s", err1);
- return (-1);
- }
- (*in08) = (H5DT_UINT8) temp16;
- }
- break;
-
- case 7: /* UIN */
- in08 = (H5DT_UINT8 *) in->data;
- for (i = 0; i < len; i++, in08++) {
- if (HDfread((char *) in08, sizeof(H5DT_UINT8), 1, strm) != 1) {
- (void) HDfprintf(stderr, "%s", err1);
- return (-1);
- }
- }
- break;
+ case 8:
+ switch (in->inputClass) {
+ case 6: /* TEXTUIN */
+ in08 = (H5DT_UINT8 *)in->data;
+ for (i = 0; i < len; i++, in08++) {
+ if (HDfscanf(strm, "%hu", &temp16) != 1) {
+ (void)HDfprintf(stderr, "%s", err1);
+ return (-1);
+ }
+ (*in08) = (H5DT_UINT8)temp16;
+ }
+ break;
- default:
- (void) HDfprintf(stderr, "%s", err2);
- return (-1);
- }
- break;
+ case 7: /* UIN */
+ in08 = (H5DT_UINT8 *)in->data;
+ for (i = 0; i < len; i++, in08++) {
+ if (HDfread((char *)in08, sizeof(H5DT_UINT8), 1, strm) != 1) {
+ (void)HDfprintf(stderr, "%s", err1);
+ return (-1);
+ }
+ }
+ break;
- case 16:
- in16 = (H5DT_UINT16 *) in->data;
- switch (in->inputClass) {
- case 6: /* TEXTUIN */
- for (i = 0; i < len; i++, in16++) {
- if (fscanf(strm, "%hu", in16) != 1) {
- (void) HDfprintf(stderr, "%s", err1);
+ default:
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
- }
}
break;
- case 7: /* UIN */
- for (i = 0; i < len; i++, in16++) {
- if (HDfread((char *)&temp16, sizeof(H5DT_UINT16), 1, strm) != 1) {
- (void) HDfprintf(stderr, "%s", err1);
- return (-1);
- }
-/*
- if (in-> h5dumpInput && (in->inputByteOrder != in->outputByteOrder))
- *in16 = swap_uint16(temp16);
- else
-*/
- *in16 = temp16;
+ case 16:
+ in16 = (H5DT_UINT16 *)in->data;
+ switch (in->inputClass) {
+ case 6: /* TEXTUIN */
+ for (i = 0; i < len; i++, in16++) {
+ if (HDfscanf(strm, "%hu", in16) != 1) {
+ (void)HDfprintf(stderr, "%s", err1);
+ return (-1);
+ }
+ }
+ break;
+
+ case 7: /* UIN */
+ for (i = 0; i < len; i++, in16++) {
+ if (HDfread((char *)&temp16, sizeof(H5DT_UINT16), 1, strm) != 1) {
+ (void)HDfprintf(stderr, "%s", err1);
+ return (-1);
+ }
+ /*
+ if (in-> h5dumpInput && (in->inputByteOrder != in->outputByteOrder))
+ *in16 = swap_uint16(temp16);
+ else
+ */
+ *in16 = temp16;
#ifdef H5DEBUGIMPORT
- HDprintf("readUIntegerData %d (0x%.4X = 0x%.4X)\n", *in16, *in16, temp16);
+ HDprintf("readUIntegerData %d (0x%.4X = 0x%.4X)\n", *in16, *in16, temp16);
#endif
- }
- break;
-
- default:
- (void) HDfprintf(stderr, "%s", err2);
- return (-1);
- }
- break;
+ }
+ break;
- case 32:
- in32 = (H5DT_UINT32 *) in->data;
- switch (in->inputClass) {
- case 6: /* TEXTUIN */
- for (i = 0; i < len; i++, in32++) {
- if (fscanf(strm, "%u", in32) != 1) {
- (void) HDfprintf(stderr, "%s", err1);
+ default:
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
- }
}
break;
- case 7: /* UIN */
- for (i = 0; i < len; i++, in32++) {
- if (HDfread((char *)&temp32, sizeof(H5DT_UINT32), 1, strm) != 1) {
- (void) HDfprintf(stderr, "%s", err1);
- return (-1);
- }
-/*
- if (in-> h5dumpInput && (in->inputByteOrder != in->outputByteOrder))
- *in32 = swap_uint32(temp32);
- else
-*/
- *in32 = temp32;
+ case 32:
+ in32 = (H5DT_UINT32 *)in->data;
+ switch (in->inputClass) {
+ case 6: /* TEXTUIN */
+ for (i = 0; i < len; i++, in32++) {
+ if (HDfscanf(strm, "%u", in32) != 1) {
+ (void)HDfprintf(stderr, "%s", err1);
+ return (-1);
+ }
+ }
+ break;
+
+ case 7: /* UIN */
+ for (i = 0; i < len; i++, in32++) {
+ if (HDfread((char *)&temp32, sizeof(H5DT_UINT32), 1, strm) != 1) {
+ (void)HDfprintf(stderr, "%s", err1);
+ return (-1);
+ }
+ /*
+ if (in-> h5dumpInput && (in->inputByteOrder != in->outputByteOrder))
+ *in32 = swap_uint32(temp32);
+ else
+ */
+ *in32 = temp32;
#ifdef H5DEBUGIMPORT
- HDprintf("readUIntegerData %d (0x%.8X = 0x%.8X)\n", *in32, *in32, temp32);
+ HDprintf("readUIntegerData %d (0x%.8X = 0x%.8X)\n", *in32, *in32, temp32);
#endif
- }
- break;
-
- default:
- (void) HDfprintf(stderr, "%s", err2);
- return (-1);
- }
- break;
+ }
+ break;
-#ifdef H5_SIZEOF_LONG_LONG
- case 64:
- in64 = (H5DT_UINT64 *) in->data;
- switch (in->inputClass) {
- case 6: /* TEXTUIN */
- for (i = 0; i < len; i++, in64++) {
- if (fscanf(strm, "%s", buffer) < 1) {
- (void) HDfprintf(stderr, "%s", err1);
+ default:
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
- }
- *in64 = (H5DT_UINT64) HDstrtoll(buffer, NULL, 10);
}
break;
- case 7: /* UIN */
- for (i = 0; i < len; i++, in64++) {
- if (HDfread((char *)&temp64, sizeof(H5DT_UINT64), 1, strm) != 1) {
- (void) HDfprintf(stderr, "%s", err1);
- return (-1);
- }
-/*
- if (in-> h5dumpInput && (in->inputByteOrder != in->outputByteOrder))
- *in64 = swap_uint64(temp64);
- else
-*/
- *in64 = temp64;
+ case 64:
+ in64 = (H5DT_UINT64 *)in->data;
+ switch (in->inputClass) {
+ case 6: /* TEXTUIN */
+ for (i = 0; i < len; i++, in64++) {
+ if (HDfscanf(strm, "%s", buffer) < 1) {
+ (void)HDfprintf(stderr, "%s", err1);
+ return (-1);
+ }
+ *in64 = (H5DT_UINT64)HDstrtoll(buffer, NULL, 10);
+ }
+ break;
+
+ case 7: /* UIN */
+ for (i = 0; i < len; i++, in64++) {
+ if (HDfread((char *)&temp64, sizeof(H5DT_UINT64), 1, strm) != 1) {
+ (void)HDfprintf(stderr, "%s", err1);
+ return (-1);
+ }
+ /*
+ if (in-> h5dumpInput && (in->inputByteOrder != in->outputByteOrder))
+ *in64 = swap_uint64(temp64);
+ else
+ */
+ *in64 = temp64;
#ifdef H5DEBUGIMPORT
- HDprintf("readUIntegerData %ld (0x%.8X = 0x%.8X)\n", *in64, *in64, temp64);
+ HDprintf("readUIntegerData %ld (0x%.8X = 0x%.8X)\n", *in64, *in64, temp64);
#endif
+ }
+ break;
+
+ default:
+ (void)HDfprintf(stderr, "%s", err2);
+ return (-1);
}
break;
default:
- (void) HDfprintf(stderr, "%s", err2);
- return (-1);
- }
- break;
-#endif /* ifdef H5_SIZEOF_LONG_LONG */
-
- default:
- (void) HDfprintf(stderr, "%s", err3);
- break;
+ (void)HDfprintf(stderr, "%s", err3);
+ break;
}
return (0);
}
-static int readFloatData(FILE *strm, struct Input *in)
+static int
+readFloatData(FILE *strm, struct Input *in)
{
H5DT_FLOAT32 *fp32;
- uint32_t *bfp32;
- uint32_t temp32;
+ uint32_t * bfp32;
+ uint32_t temp32;
H5DT_FLOAT64 *fp64;
- uint64_t *bfp64;
- uint64_t temp64;
+ uint64_t * bfp64;
+ uint64_t temp64;
hsize_t len = 1;
hsize_t i;
@@ -819,113 +819,113 @@ static int readFloatData(FILE *strm, struct Input *in)
len *= in->sizeOfDimension[j];
switch (in->inputSize) {
- case 32:
- fp32 = (H5DT_FLOAT32 *) in->data;
- switch (in->inputClass) {
- case 1: /* TEXTFP */
- for (i = 0; i < len; i++, fp32++) {
- if (fscanf(strm, "%f", fp32) != 1) {
- (void) HDfprintf(stderr, "%s", err1);
- return (-1);
- }
- }
+ case 32:
+ fp32 = (H5DT_FLOAT32 *)in->data;
+ switch (in->inputClass) {
+ case 1: /* TEXTFP */
+ for (i = 0; i < len; i++, fp32++) {
+ if (HDfscanf(strm, "%f", fp32) != 1) {
+ (void)HDfprintf(stderr, "%s", err1);
+ return (-1);
+ }
+ }
- fp32 = (H5DT_FLOAT32 *) in->data;
- break;
+ fp32 = (H5DT_FLOAT32 *)in->data;
+ break;
- /* same as TEXTFP */
- case 2: /*TEXTFPE */
+ /* same as TEXTFP */
+ case 2: /*TEXTFPE */
- for (i = 0; i < len; i++, fp32++) {
- if (fscanf(strm, "%f", fp32) != 1) {
- (void) HDfprintf(stderr, "%s", err1);
- return (-1);
- }
- }
+ for (i = 0; i < len; i++, fp32++) {
+ if (HDfscanf(strm, "%f", fp32) != 1) {
+ (void)HDfprintf(stderr, "%s", err1);
+ return (-1);
+ }
+ }
- fp32 = (H5DT_FLOAT32 *) in->data;
- break;
+ fp32 = (H5DT_FLOAT32 *)in->data;
+ break;
- case 3: /* FP */
- bfp32 = (uint32_t *) in->data;
- for (i = 0; i < len; i++, bfp32++) {
- if (HDfread((char *)&temp32, sizeof(uint32_t), 1, strm) != 1) {
- (void) HDfprintf(stderr, "%s", err1);
- return (-1);
- }
-/*
- if (in-> h5dumpInput && (in->inputByteOrder != in->outputByteOrder))
- *bfp32 = swap_uint32(temp32);
- else
-*/
- *bfp32 = temp32;
+ case 3: /* FP */
+ bfp32 = (uint32_t *)in->data;
+ for (i = 0; i < len; i++, bfp32++) {
+ if (HDfread((char *)&temp32, sizeof(uint32_t), 1, strm) != 1) {
+ (void)HDfprintf(stderr, "%s", err1);
+ return (-1);
+ }
+ /*
+ if (in-> h5dumpInput && (in->inputByteOrder != in->outputByteOrder))
+ *bfp32 = swap_uint32(temp32);
+ else
+ */
+ *bfp32 = temp32;
#ifdef H5DEBUGIMPORT
- HDprintf("readFloatData %ld (0x%.8X = 0x%.8X)\n", *bfp32, *bfp32, temp32);
+ HDprintf("readFloatData %ld (0x%.8X = 0x%.8X)\n", *bfp32, *bfp32, temp32);
#endif
- }
- break;
-
- default:
- (void) HDfprintf(stderr, "%s", err2);
- return (-1);
- }
- break;
+ }
+ break;
- case 64:
- fp64 = (H5DT_FLOAT64 *) in->data;
- switch (in->inputClass) {
- case 1: /* TEXTFP */
- for (i = 0; i < len; i++, fp64++) {
- if (fscanf(strm, "%lf", fp64) != 1) {
- (void) HDfprintf(stderr, "%s", err1);
+ default:
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
- }
}
-
- fp64 = (H5DT_FLOAT64 *) in->data;
break;
- /* same as TEXTFP */
- case 2: /*TEXTFPE */
+ case 64:
+ fp64 = (H5DT_FLOAT64 *)in->data;
+ switch (in->inputClass) {
+ case 1: /* TEXTFP */
+ for (i = 0; i < len; i++, fp64++) {
+ if (HDfscanf(strm, "%lf", fp64) != 1) {
+ (void)HDfprintf(stderr, "%s", err1);
+ return (-1);
+ }
+ }
- for (i = 0; i < len; i++, fp64++) {
- if (fscanf(strm, "%lf", fp64) != 1) {
- (void) HDfprintf(stderr, "%s", err1);
- return (-1);
- }
- }
+ fp64 = (H5DT_FLOAT64 *)in->data;
+ break;
- fp64 = (H5DT_FLOAT64 *) in->data;
- break;
+ /* same as TEXTFP */
+ case 2: /*TEXTFPE */
- case 3: /* FP */
- bfp64 = (uint64_t *) in->data;
- for (i = 0; i < len; i++, bfp64++) {
- if (HDfread((char *)&temp64, sizeof(uint64_t), 1, strm) != 1) {
- (void) HDfprintf(stderr, "%s", err1);
- return (-1);
- }
-/*
- if (in-> h5dumpInput && (in->inputByteOrder != in->outputByteOrder))
- *bfp64 = swap_uint64(temp64);
- else
-*/
- *bfp64 = temp64;
+ for (i = 0; i < len; i++, fp64++) {
+ if (HDfscanf(strm, "%lf", fp64) != 1) {
+ (void)HDfprintf(stderr, "%s", err1);
+ return (-1);
+ }
+ }
+
+ fp64 = (H5DT_FLOAT64 *)in->data;
+ break;
+
+ case 3: /* FP */
+ bfp64 = (uint64_t *)in->data;
+ for (i = 0; i < len; i++, bfp64++) {
+ if (HDfread((char *)&temp64, sizeof(uint64_t), 1, strm) != 1) {
+ (void)HDfprintf(stderr, "%s", err1);
+ return (-1);
+ }
+ /*
+ if (in-> h5dumpInput && (in->inputByteOrder != in->outputByteOrder))
+ *bfp64 = swap_uint64(temp64);
+ else
+ */
+ *bfp64 = temp64;
#ifdef H5DEBUGIMPORT
- HDprintf("readFloatData %ld (0x%.16lX)\n", *bfp64, temp64);
+ HDprintf("readFloatData %ld (0x%.16lX)\n", *bfp64, temp64);
#endif
+ }
+ break;
+
+ default:
+ (void)HDfprintf(stderr, "%s", err2);
+ return (-1);
}
break;
default:
- (void) HDfprintf(stderr, "%s", err2);
- return (-1);
- }
- break;
-
- default:
- (void) HDfprintf(stderr, "%s", err3);
- break;
+ (void)HDfprintf(stderr, "%s", err3);
+ break;
}
return (0);
}
@@ -938,13 +938,14 @@ static int readFloatData(FILE *strm, struct Input *in)
*
* Return: 0, ok, -1 no
*
- * Programmer: Pedro Vicente, pvn@hdfgroup.org
+ * Programmer: Pedro Vicente
*
* Date: July, 26, 2007
*
*-------------------------------------------------------------------------
*/
-static int processStrData(FILE *strm, struct Input *in, hid_t file_id)
+static int
+processStrData(FILE *strm, struct Input *in, hid_t file_id)
{
hid_t group_id;
hid_t dset_id;
@@ -965,8 +966,8 @@ static int processStrData(FILE *strm, struct Input *in, hid_t file_id)
*-------------------------------------------------------------------------
*/
- while(EOF != (c = HDfgetc(strm)))
- if (c == 10) /* eol */
+ while (EOF != (c = HDfgetc(strm)))
+ if (c == 10) /* eol */
nlines++;
if (!nlines)
@@ -994,13 +995,14 @@ static int processStrData(FILE *strm, struct Input *in, hid_t file_id)
{
/* create parent groups */
if (in->path.count > 1) {
- j = 0;
+ j = 0;
handle = file_id;
while (j < in->path.count - 1) {
if ((group_id = H5Gopen2(handle, in->path.group[j], H5P_DEFAULT)) < 0) {
group_id = H5Gcreate2(handle, in->path.group[j++], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
for (; j < in->path.count - 1; j++)
- group_id = H5Gcreate2(group_id, in->path.group[j], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ group_id =
+ H5Gcreate2(group_id, in->path.group[j], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
handle = group_id;
break;
}
@@ -1010,7 +1012,7 @@ static int processStrData(FILE *strm, struct Input *in, hid_t file_id)
}
else {
handle = file_id;
- j = 0;
+ j = 0;
}
/*enable error reporting */
@@ -1023,21 +1025,22 @@ static int processStrData(FILE *strm, struct Input *in, hid_t file_id)
if ((mspace_id = H5Screate(H5S_SCALAR)) < 0)
goto out;
- if ((dset_id = H5Dcreate2(handle, in->path.group[j], type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((dset_id = H5Dcreate2(handle, in->path.group[j], type_id, space_id, H5P_DEFAULT, H5P_DEFAULT,
+ H5P_DEFAULT)) < 0)
goto out;
line = 0;
- while(EOF != (c = HDfgetc(strm))) {
+ while (EOF != (c = HDfgetc(strm))) {
str[i] = (char)c;
i++;
if (c == 10) { /* eol */
- char *str2 = str;
- hid_t fspace_id;
+ char * str2 = str;
+ hid_t fspace_id;
hsize_t start[1];
- hsize_t count[1] = { 1 };
+ hsize_t count[1] = {1};
str[i - 1] = '\0'; /* terminate string */
@@ -1055,9 +1058,8 @@ static int processStrData(FILE *strm, struct Input *in, hid_t file_id)
if (H5Sclose(fspace_id) < 0)
goto out;
- i = 0;
+ i = 0;
str[0] = '\0';
-
}
}
@@ -1084,20 +1086,21 @@ out:
*
*-------------------------------------------------------------------------
*/
-static int processStrHDFData(FILE *strm, struct Input *in, hid_t file_id)
+static int
+processStrHDFData(FILE *strm, struct Input *in, hid_t file_id)
{
- hid_t group_id = -1;
- hid_t dset_id = -1;
- hid_t space_id = -1;
- hid_t mspace_id = -1;
- hid_t type_id = -1;
- hid_t handle = -1;
- char *str1 = NULL;
- char *str2 = NULL;
- char *str3 = NULL;
- char str[1024] = "";
+ hid_t group_id = H5I_INVALID_HID;
+ hid_t dset_id = H5I_INVALID_HID;
+ hid_t space_id = H5I_INVALID_HID;
+ hid_t mspace_id = H5I_INVALID_HID;
+ hid_t type_id = H5I_INVALID_HID;
+ hid_t handle = H5I_INVALID_HID;
+ char * str1 = NULL;
+ char * str2 = NULL;
+ char * str3 = NULL;
+ char str[1024] = "";
int j;
- hsize_t line;
+ hsize_t line;
/*-------------------------------------------------------------------------
* read file and generate an HDF5 dataset
@@ -1118,13 +1121,14 @@ static int processStrHDFData(FILE *strm, struct Input *in, hid_t file_id)
{
/* create parent groups */
if (in->path.count > 1) {
- j = 0;
+ j = 0;
handle = file_id;
while (j < in->path.count - 1) {
if ((group_id = H5Gopen2(handle, in->path.group[j], H5P_DEFAULT)) < 0) {
group_id = H5Gcreate2(handle, in->path.group[j++], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
for (; j < in->path.count - 1; j++)
- group_id = H5Gcreate2(group_id, in->path.group[j], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ group_id =
+ H5Gcreate2(group_id, in->path.group[j], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
handle = group_id;
break;
}
@@ -1134,7 +1138,7 @@ static int processStrHDFData(FILE *strm, struct Input *in, hid_t file_id)
}
else {
handle = file_id;
- j = 0;
+ j = 0;
}
/*enable error reporting */
@@ -1150,67 +1154,69 @@ static int processStrHDFData(FILE *strm, struct Input *in, hid_t file_id)
if ((mspace_id = H5Screate(H5S_SCALAR)) < 0)
goto out;
- if ((dset_id = H5Dcreate2(handle, in->path.group[j], type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((dset_id = H5Dcreate2(handle, in->path.group[j], type_id, space_id, H5P_DEFAULT, H5P_DEFAULT,
+ H5P_DEFAULT)) < 0)
goto out;
#ifdef H5DEBUGIMPORT
HDprintf("processStrHDFData DATATYPE STRING ready to process strings\n");
#endif
line = 0;
- j = 0;
+ j = 0;
- while (HDfgets(str,sizeof(str),strm)) {
+ while (HDfgets(str, sizeof(str), strm)) {
str1 = str;
str2 = NULL;
str3 = NULL;
#ifdef H5DEBUGIMPORT
- HDprintf("processStrHDFData DATATYPE STRING[%llu]={%s}\n", (unsigned long long)line, str1);
+ HDprintf("processStrHDFData DATATYPE STRING[%llu]={%s}\n", (unsigned long long)line, str1);
#endif
- /* process string to remove the first and last quote char */
- str2 = strchr(str1, '"');
- if (str2 != NULL) {
+ /* process string to remove the first and last quote char */
+ str2 = strchr(str1, '"');
+ if (str2 != NULL) {
#ifdef H5DEBUGIMPORT
- HDprintf("processStrHDFData DATATYPE STRING len:%d for {%s}\n", HDstrlen(str2), str2);
+ HDprintf("processStrHDFData DATATYPE STRING len:%d for {%s}\n", HDstrlen(str2), str2);
#endif
- str2++;
+ str2++;
#ifdef H5DEBUGIMPORT
- HDprintf("processStrHDFData DATATYPE STRING len:%d for {%s}\n", HDstrlen(str2), str2);
+ HDprintf("processStrHDFData DATATYPE STRING len:%d for {%s}\n", HDstrlen(str2), str2);
#endif
- str3 = strrchr(str2, '"');
- if (str3 != NULL) {
+ str3 = strrchr(str2, '"');
+ if (str3 != NULL) {
#ifdef H5DEBUGIMPORT
- HDprintf("processStrHDFData DATATYPE STRING len:%d for {%s}\n", HDstrlen(str3), str3);
+ HDprintf("processStrHDFData DATATYPE STRING len:%d for {%s}\n", HDstrlen(str3), str3);
#endif
- *str3 = '\0';
+ *str3 = '\0';
#ifdef H5DEBUGIMPORT
- HDprintf("processStrHDFData DATATYPE STRING len:%d for {%s}\n", HDstrlen(str2), str2);
+ HDprintf("processStrHDFData DATATYPE STRING len:%d for {%s}\n", HDstrlen(str2), str2);
#endif
- if(HDstrlen(str2) > 0) {
- hid_t fspace_id;
- hsize_t start[1];
- hsize_t count[1] = { 1 };
+ if (HDstrlen(str2) > 0) {
+ hid_t fspace_id;
+ hsize_t start[1];
+ hsize_t count[1] = {1};
#ifdef H5DEBUGIMPORT
- HDprintf("processStrHDFData DATATYPE STRING[%llu] store %s\n", (unsigned long long)line, str2);
+ HDprintf("processStrHDFData DATATYPE STRING[%llu] store %s\n", (unsigned long long)line,
+ str2);
#endif
- if ((fspace_id = H5Dget_space(dset_id)) < 0)
- goto out;
+ if ((fspace_id = H5Dget_space(dset_id)) < 0)
+ goto out;
- start[0] = line++;
+ start[0] = line++;
- if (H5Sselect_hyperslab(fspace_id, H5S_SELECT_SET, start, NULL, count, NULL) < 0)
- goto out;
+ if (H5Sselect_hyperslab(fspace_id, H5S_SELECT_SET, start, NULL, count, NULL) < 0)
+ goto out;
- if (H5Dwrite(dset_id, type_id, mspace_id, fspace_id, H5P_DEFAULT, &str2) < 0)
- goto out;
+ if (H5Dwrite(dset_id, type_id, mspace_id, fspace_id, H5P_DEFAULT, &str2) < 0)
+ goto out;
- if (H5Sclose(fspace_id) < 0)
- goto out;
- }
+ if (H5Sclose(fspace_id) < 0)
+ goto out;
}
}
+ }
str[0] = '\0';
j++;
}
@@ -1230,21 +1236,22 @@ out:
#ifdef H5DEBUGIMPORT
HDprintf("processStrHDFData DATATYPE STRING error exit\n");
#endif
-/* disable error reporting */
-H5E_BEGIN_TRY
-{
- /* close */
- H5Dclose(dset_id);
- H5Sclose(space_id);
- H5Sclose(mspace_id);
- H5Tclose(type_id);
-}
-H5E_END_TRY;
+ /* disable error reporting */
+ H5E_BEGIN_TRY
+ {
+ /* close */
+ H5Dclose(dset_id);
+ H5Sclose(space_id);
+ H5Sclose(mspace_id);
+ H5Tclose(type_id);
+ }
+ H5E_END_TRY;
return (-1);
}
-static int allocateIntegerStorage(struct Input *in)
+static int
+allocateIntegerStorage(struct Input *in)
{
hsize_t len = 1;
int j;
@@ -1255,44 +1262,45 @@ static int allocateIntegerStorage(struct Input *in)
len *= in->sizeOfDimension[j];
switch (in->inputSize) {
- case 8:
- if ((in->data = (VOIDP) HDmalloc((size_t) len * sizeof(H5DT_INT8))) == NULL) {
- (void) HDfprintf(stderr, "%s", err1);
- return (-1);
- }
- break;
+ case 8:
+ if ((in->data = (VOIDP)HDmalloc((size_t)len * sizeof(H5DT_INT8))) == NULL) {
+ (void)HDfprintf(stderr, "%s", err1);
+ return (-1);
+ }
+ break;
- case 16:
- if ((in->data = (VOIDP) HDmalloc((size_t) len * sizeof(H5DT_INT16))) == NULL) {
- (void) HDfprintf(stderr, "%s", err1);
- return (-1);
- }
- break;
+ case 16:
+ if ((in->data = (VOIDP)HDmalloc((size_t)len * sizeof(H5DT_INT16))) == NULL) {
+ (void)HDfprintf(stderr, "%s", err1);
+ return (-1);
+ }
+ break;
- case 32:
- if ((in->data = (VOIDP) HDmalloc((size_t) len * sizeof(H5DT_INT32))) == NULL) {
- (void) HDfprintf(stderr, "%s", err1);
- return (-1);
- }
- break;
+ case 32:
+ if ((in->data = (VOIDP)HDmalloc((size_t)len * sizeof(H5DT_INT32))) == NULL) {
+ (void)HDfprintf(stderr, "%s", err1);
+ return (-1);
+ }
+ break;
- case 64:
- if ((in->data = (VOIDP) HDmalloc((size_t) len * sizeof(H5DT_INT64))) == NULL) {
- (void) HDfprintf(stderr, "%s", err1);
- return (-1);
- }
- break;
+ case 64:
+ if ((in->data = (VOIDP)HDmalloc((size_t)len * sizeof(H5DT_INT64))) == NULL) {
+ (void)HDfprintf(stderr, "%s", err1);
+ return (-1);
+ }
+ break;
- default:
- (void) HDfprintf(stderr, "%s", err2);
- break;
+ default:
+ (void)HDfprintf(stderr, "%s", err2);
+ break;
}
return (0);
}
-static int allocateUIntegerStorage(struct Input *in)
+static int
+allocateUIntegerStorage(struct Input *in)
{
- hsize_t len = 1;
+ hsize_t len = 1;
const char *err1 = "Unable to allocate dynamic memory.\n";
const char *err2 = "Invalid storage size for unsigned integer input data.\n";
int j;
@@ -1301,42 +1309,43 @@ static int allocateUIntegerStorage(struct Input *in)
len *= in->sizeOfDimension[j];
switch (in->inputSize) {
- case 8:
- if ((in->data = (VOIDP) HDmalloc((size_t) len * sizeof(H5DT_UINT8))) == NULL) {
- (void) HDfprintf(stderr, "%s", err1);
- return (-1);
- }
- break;
+ case 8:
+ if ((in->data = (VOIDP)HDmalloc((size_t)len * sizeof(H5DT_UINT8))) == NULL) {
+ (void)HDfprintf(stderr, "%s", err1);
+ return (-1);
+ }
+ break;
- case 16:
- if ((in->data = (VOIDP) HDmalloc((size_t) len * sizeof(H5DT_UINT16))) == NULL) {
- (void) HDfprintf(stderr, "%s", err1);
- return (-1);
- }
- break;
+ case 16:
+ if ((in->data = (VOIDP)HDmalloc((size_t)len * sizeof(H5DT_UINT16))) == NULL) {
+ (void)HDfprintf(stderr, "%s", err1);
+ return (-1);
+ }
+ break;
- case 32:
- if ((in->data = (VOIDP) HDmalloc((size_t) len * sizeof(H5DT_UINT32))) == NULL) {
- (void) HDfprintf(stderr, "%s", err1);
- return (-1);
- }
- break;
+ case 32:
+ if ((in->data = (VOIDP)HDmalloc((size_t)len * sizeof(H5DT_UINT32))) == NULL) {
+ (void)HDfprintf(stderr, "%s", err1);
+ return (-1);
+ }
+ break;
- case 64:
- if ((in->data = (VOIDP) HDmalloc((size_t) len * sizeof(H5DT_UINT64))) == NULL) {
- (void) HDfprintf(stderr, "%s", err1);
- return (-1);
- }
- break;
+ case 64:
+ if ((in->data = (VOIDP)HDmalloc((size_t)len * sizeof(H5DT_UINT64))) == NULL) {
+ (void)HDfprintf(stderr, "%s", err1);
+ return (-1);
+ }
+ break;
- default:
- (void) HDfprintf(stderr, "%s", err2);
- break;
+ default:
+ (void)HDfprintf(stderr, "%s", err2);
+ break;
}
return (0);
}
-static int allocateFloatStorage(struct Input *in)
+static int
+allocateFloatStorage(struct Input *in)
{
hsize_t len = 1;
int j;
@@ -1347,54 +1356,55 @@ static int allocateFloatStorage(struct Input *in)
len *= in->sizeOfDimension[j];
switch (in->inputSize) {
- case 32:
- if ((in->data = (VOIDP) HDmalloc((size_t) len * sizeof(H5DT_FLOAT32))) == NULL) {
- (void) HDfprintf(stderr, "%s", err1);
- return (-1);
- }
- break;
+ case 32:
+ if ((in->data = (VOIDP)HDmalloc((size_t)len * sizeof(H5DT_FLOAT32))) == NULL) {
+ (void)HDfprintf(stderr, "%s", err1);
+ return (-1);
+ }
+ break;
- case 64:
- if ((in->data = (VOIDP) HDmalloc((size_t) len * sizeof(H5DT_FLOAT64))) == NULL) {
- (void) HDfprintf(stderr, "%s", err1);
- return (-1);
- }
- break;
+ case 64:
+ if ((in->data = (VOIDP)HDmalloc((size_t)len * sizeof(H5DT_FLOAT64))) == NULL) {
+ (void)HDfprintf(stderr, "%s", err1);
+ return (-1);
+ }
+ break;
- default:
- (void) HDfprintf(stderr, "%s", err2);
- break;
+ default:
+ (void)HDfprintf(stderr, "%s", err2);
+ break;
}
return (0);
}
-static int processConfigurationFile(char *infile, struct Input *in)
+static int
+processConfigurationFile(char *infile, struct Input *in)
{
- FILE *strm = NULL;
- char key[MAX_PATH_NAME_LENGTH];
- int kindex;
- char temp[MAX_PATH_NAME_LENGTH];
- int ival;
- int scanret;
- int retval = -1;
-
- const char *err1 = "Unable to open the configuration file: %s for reading.\n";
- const char *err2 = "Unknown keyword: %s in configuration file: %s\n";
- const char *err3a = "PATH keyword appears twice in %s.\n";
- const char *err3b = "Error in parsing the path information from %s.\n";
- const char *err4a = "INPUT-CLASS keyword appears twice in %s.\n";
- const char *err4b = "Error in retrieving the input class from %s.\n";
- const char *err5a = "INPUT-SIZE keyword appears twice in %s.\n";
- const char *err5b = "Error in retrieving the input size from %s.\n";
- const char *err6a = "RANK keyword appears twice in %s.\n";
- const char *err6b = "Error in retrieving the rank from %s.\n";
- const char *err7a = "DIMENSION-SIZES keyword appears twice in %s.\n";
- const char *err7b = "DIMENSION-SIZES cannot appear before RANK is provided.\n";
- const char *err7c = "Error in retrieving the dimension sizes from %s.\n";
- const char *err8a = "OUTPUT-CLASS keyword appears twice in %s.\n";
- const char *err8b = "Error in retrieving the output class from %s.\n";
- const char *err9a = "OUTPUT-SIZE keyword appears twice in %s.\n";
- const char *err9b = "Error in retrieving the output size from %s.\n";
+ FILE *strm = NULL;
+ char key[MAX_PATH_NAME_LENGTH];
+ int kindex;
+ char temp[MAX_PATH_NAME_LENGTH];
+ int ival;
+ int scanret;
+ int retval = -1;
+
+ const char *err1 = "Unable to open the configuration file: %s for reading.\n";
+ const char *err2 = "Unknown keyword: %s in configuration file: %s\n";
+ const char *err3a = "PATH keyword appears twice in %s.\n";
+ const char *err3b = "Error in parsing the path information from %s.\n";
+ const char *err4a = "INPUT-CLASS keyword appears twice in %s.\n";
+ const char *err4b = "Error in retrieving the input class from %s.\n";
+ const char *err5a = "INPUT-SIZE keyword appears twice in %s.\n";
+ const char *err5b = "Error in retrieving the input size from %s.\n";
+ const char *err6a = "RANK keyword appears twice in %s.\n";
+ const char *err6b = "Error in retrieving the rank from %s.\n";
+ const char *err7a = "DIMENSION-SIZES keyword appears twice in %s.\n";
+ const char *err7b = "DIMENSION-SIZES cannot appear before RANK is provided.\n";
+ const char *err7c = "Error in retrieving the dimension sizes from %s.\n";
+ const char *err8a = "OUTPUT-CLASS keyword appears twice in %s.\n";
+ const char *err8b = "Error in retrieving the output class from %s.\n";
+ const char *err9a = "OUTPUT-SIZE keyword appears twice in %s.\n";
+ const char *err9b = "Error in retrieving the output size from %s.\n";
const char *err10a = "OUTPUT-ARCHITECTURE keyword appears twice in %s.\n";
const char *err10b = "Error in retrieving the output architecture from %s.\n";
const char *err11a = "OUTPUT-BYTE-ORDER keyword appears twice in %s.\n";
@@ -1414,10 +1424,10 @@ static int processConfigurationFile(char *infile, struct Input *in)
const char *err16a = "MAXIMUM-DIMENSIONS keyword appears twice in %s.\n";
const char *err16b = "MAXIMUM-DIMENSIONS cannot appear before DIMENSION-SIZES are provided.\n";
const char *err16c = "Error in retrieving the maximum dimension sizes from %s.\n";
- const char *err17 = "Configuration parameters are invalid in %s.\n";
- const char *err18 = "Unable to get string value.\n";
- const char *err19 = "Unable to get integer value.\n";
- const char *err20 = "Unable to get subset values.\n";
+ const char *err17 = "Configuration parameters are invalid in %s.\n";
+ const char *err18 = "Unable to get string value.\n";
+ const char *err19 = "Unable to get integer value.\n";
+ const char *err20 = "Unable to get subset values.\n";
/* create vector to map which keywords have been found
check vector after each keyword to check for violation
@@ -1426,17 +1436,17 @@ static int processConfigurationFile(char *infile, struct Input *in)
*/
/* Initialize machine endian */
- volatile uint32_t ibyte=0x01234567;
+ volatile uint32_t ibyte = 0x01234567;
/* 0 for big endian, 1 for little endian. */
- if ((*((uint8_t*)(&ibyte))) == 0x67) {
+ if ((*((volatile uint8_t *)(&ibyte))) == 0x67) {
if ((kindex = OutputByteOrderStrToInt("LE")) == -1) {
- (void) HDfprintf(stderr, "%s", err11e);
+ (void)HDfprintf(stderr, "%s", err11e);
return (-1);
}
}
else {
if ((kindex = OutputByteOrderStrToInt("BE")) == -1) {
- (void) HDfprintf(stderr, "%s", err11e);
+ (void)HDfprintf(stderr, "%s", err11e);
return (-1);
}
}
@@ -1447,64 +1457,64 @@ static int processConfigurationFile(char *infile, struct Input *in)
in->inputArchitecture = 0; /* default to NATIVE */
if ((strm = HDfopen(infile, "r")) == NULL) {
- (void) HDfprintf(stderr, err1, infile);
+ (void)HDfprintf(stderr, err1, infile);
goto error;
}
- scanret = fscanf(strm, "%254s", key);
- if((scanret == 1) && !HDstrcmp("HDF5", key)) {
+ scanret = HDfscanf(strm, "%254s", key);
+ if ((scanret == 1) && !HDstrcmp("HDF5", key)) {
#ifdef H5DEBUGIMPORT
int pndx;
HDprintf("\nh5dump file\n");
#endif
in->h5dumpInput = 1;
- scanret = fscanf(strm, "%254s", temp); /* filename */
- scanret = fscanf(strm, "%254s", temp); /* start bracket */
- scanret = fscanf(strm, "%254s", key); /* DATASET */
+ scanret = HDfscanf(strm, "%254s", temp); /* filename */
+ scanret = HDfscanf(strm, "%254s", temp); /* start bracket */
+ scanret = HDfscanf(strm, "%254s", key); /* DATASET */
while (scanret == 1) {
- if(!HDstrcmp("DATASET", key)) { /* PATH */
+ if (!HDstrcmp("DATASET", key)) { /* PATH */
#ifdef H5DEBUGIMPORT
HDprintf("h5dump DATASET key\n");
#endif
if (in->configOptionVector[PATH] == 1) {
- (void) HDfprintf(stderr, err3a, infile);
+ (void)HDfprintf(stderr, err3a, infile);
goto error;
}
- if (fscanf(strm, "%254s", temp) != 1) {
- (void) HDfprintf(stderr, "%s", err18);
+ if (HDfscanf(strm, "%254s", temp) != 1) {
+ (void)HDfprintf(stderr, "%s", err18);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump DATASET %s found\n", temp);
#endif
if (parsePathInfo(&in->path, temp) == -1) {
- (void) HDfprintf(stderr, err3b, infile);
+ (void)HDfprintf(stderr, err3b, infile);
goto error;
}
in->configOptionVector[PATH] = 1;
- scanret = fscanf(strm, "%254s", temp); /* start bracket */
+ scanret = HDfscanf(strm, "%254s", temp); /* start bracket */
#ifdef H5DEBUGIMPORT
HDprintf("h5dump DATASET %s found\n", temp);
#endif
- } /* if(!HDstrcmp("DATASET", key)) PATH */
- else if(!HDstrcmp("DATATYPE", key)) { /* INPUT-CLASS */
+ } /* if(!HDstrcmp("DATASET", key)) PATH */
+ else if (!HDstrcmp("DATATYPE", key)) { /* INPUT-CLASS */
#ifdef H5DEBUGIMPORT
HDprintf("h5dump DATATYPE key\n");
#endif
if (in->configOptionVector[INPUT_CLASS] == 1) {
- (void) HDfprintf(stderr, err4a, infile);
+ (void)HDfprintf(stderr, err4a, infile);
goto error;
}
- if (fscanf(strm, "%254s", temp) != 1) {
- (void) HDfprintf(stderr, "%s", err18);
+ if (HDfscanf(strm, "%254s", temp) != 1) {
+ (void)HDfprintf(stderr, "%s", err18);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump DATATYPE %s found\n", temp);
#endif
if ((kindex = getInputClassType(in, temp)) == -1) {
- (void) HDfprintf(stderr, err4b, infile);
+ (void)HDfprintf(stderr, err4b, infile);
goto error;
}
#ifdef H5DEBUGIMPORT
@@ -1517,8 +1527,7 @@ static int processConfigurationFile(char *infile, struct Input *in)
if (in->configOptionVector[OUTPUT_CLASS] == 0) {
if (in->inputClass == 0 || in->inputClass == 4)
in->outputClass = 0;
- if (in->inputClass == 1 || in->inputClass == 2
- || in->inputClass == 3)
+ if (in->inputClass == 1 || in->inputClass == 2 || in->inputClass == 3)
in->outputClass = 1;
if (in->inputClass == 6 || in->inputClass == 7)
in->outputClass = 2;
@@ -1527,37 +1536,37 @@ static int processConfigurationFile(char *infile, struct Input *in)
HDprintf("h5dump DATATYPE type %d outputClass\n", in->outputClass);
#endif
- if(in->inputClass == 5) { /* STRING */
+ if (in->inputClass == 5) { /* STRING */
int get_next_prop = 1;
- in->outputClass = -1;
+ in->outputClass = -1;
#ifdef H5DEBUGIMPORT
HDprintf("h5dump DATATYPE STRING found\n");
#endif
- if (fscanf(strm, "%254s", temp) != 1) { /* start bracket */
- (void) HDfprintf(stderr, "%s", err18);
+ if (HDfscanf(strm, "%254s", temp) != 1) { /* start bracket */
+ (void)HDfprintf(stderr, "%s", err18);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump DATATYPE STRING %s found\n", temp);
#endif
- if (fscanf(strm, "%254s", temp) != 1) { /* string properties */
- (void) HDfprintf(stderr, "%s", err18);
+ if (HDfscanf(strm, "%254s", temp) != 1) { /* string properties */
+ (void)HDfprintf(stderr, "%s", err18);
goto error;
}
while (get_next_prop) {
- if(!HDstrcmp("STRSIZE", temp)) { /* STRSIZE */
- if (fscanf(strm, "%254s", temp) != 1) {
- (void) HDfprintf(stderr, "%s", err19);
+ if (!HDstrcmp("STRSIZE", temp)) { /* STRSIZE */
+ if (HDfscanf(strm, "%254s", temp) != 1) {
+ (void)HDfprintf(stderr, "%s", err19);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump DATATYPE STRING STRSIZE %s found\n", temp);
#endif
- if (HDstrcmp("H5T_VARIABLE;", temp)) {
+ if (HDstrcmp("H5T_VARIABLE;", temp) != 0) {
char *more = temp;
- ival = (int)HDstrtol(more, &more, 10);
+ ival = (int)HDstrtol(more, &more, 10);
if (getInputSize(in, ival) == -1) {
- (void) HDfprintf(stderr, err5b, infile);
+ (void)HDfprintf(stderr, err5b, infile);
goto error;
}
#ifdef H5DEBUGIMPORT
@@ -1565,119 +1574,119 @@ static int processConfigurationFile(char *infile, struct Input *in)
#endif
}
}
- else if(!HDstrcmp("STRPAD", temp)) { /* STRPAD */
- if (fscanf(strm, "%254s", temp) != 1) { /* STRPAD type */
- (void) HDfprintf(stderr, "%s", err18);
+ else if (!HDstrcmp("STRPAD", temp)) { /* STRPAD */
+ if (HDfscanf(strm, "%254s", temp) != 1) { /* STRPAD type */
+ (void)HDfprintf(stderr, "%s", err18);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump DATATYPE STRING STRPAD %s found\n", temp);
#endif
}
- else if(!HDstrcmp("CSET", key)) { /* CSET */
- if (fscanf(strm, "%254s", temp) != 1) { /* CSET type */
- (void) HDfprintf(stderr, "%s", err18);
+ else if (!HDstrcmp("CSET", key)) { /* CSET */
+ if (HDfscanf(strm, "%254s", temp) != 1) { /* CSET type */
+ (void)HDfprintf(stderr, "%s", err18);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump DATATYPE STRING CSET %s found\n", temp);
#endif
-
}
- else if(!HDstrcmp("CTYPE", temp)) { /* CTYPE */
- if (fscanf(strm, "%254s", temp) != 1) { /* CTYPE type */
- (void) HDfprintf(stderr, "%s", err18);
+ else if (!HDstrcmp("CTYPE", temp)) { /* CTYPE */
+ if (HDfscanf(strm, "%254s", temp) != 1) { /* CTYPE type */
+ (void)HDfprintf(stderr, "%s", err18);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump DATATYPE STRING CTYPE %s found\n", temp);
#endif
} /* if(!HDstrcmp("CSET", key)) */
- if (fscanf(strm, "%254s", temp) != 1) {
- (void) HDfprintf(stderr, "%s", err18);
+ if (HDfscanf(strm, "%254s", temp) != 1) {
+ (void)HDfprintf(stderr, "%s", err18);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump DATATYPE STRING %s found\n", temp);
#endif
- if(!HDstrcmp("}", temp)) { /* end bracket */
+ if (!HDstrcmp("}", temp)) { /* end bracket */
get_next_prop = 0;
}
- } /* while (get_next_prop) */
- } /* if(kindex == 5) STRING */
- } /* else if(!HDstrcmp("DATATYPE", key)) INPUT-CLASS */
- else if(!HDstrcmp("DATASPACE", key)) { /* RANK and DIMENSIONS */
- hsize_t temp_dims[MAX_NUM_DIMENSION];
+ } /* while (get_next_prop) */
+ } /* if(kindex == 5) STRING */
+ } /* else if(!HDstrcmp("DATATYPE", key)) INPUT-CLASS */
+ else if (!HDstrcmp("DATASPACE", key)) { /* RANK and DIMENSIONS */
+ hsize_t temp_dims[MAX_NUM_DIMENSION];
#ifdef H5DEBUGIMPORT
HDprintf("h5dump DATASPACE key\n");
#endif
- if (fscanf(strm, "%254s", temp) != 1) {
- (void) HDfprintf(stderr, "%s", err18);
+ if (HDfscanf(strm, "%254s", temp) != 1) {
+ (void)HDfprintf(stderr, "%s", err18);
goto error;
}
- if(!HDstrcmp("SCALAR", temp)) { /* SCALAR */
+ if (!HDstrcmp("SCALAR", temp)) { /* SCALAR */
in->rank = 0;
- } /* if(!HDstrcmp("SCALAR", key)) */
- else if(!HDstrcmp("NULL", temp)) { /* NULL */
- (void) HDfprintf(stderr, err6b, infile);
+ } /* if(!HDstrcmp("SCALAR", key)) */
+ else if (!HDstrcmp("NULL", temp)) { /* NULL */
+ (void)HDfprintf(stderr, err6b, infile);
goto error;
- } /* else if(!HDstrcmp("NULL", key)) */
- else if(!HDstrcmp("SIMPLE", temp)) { /* SIMPLE */
+ } /* else if(!HDstrcmp("NULL", key)) */
+ else if (!HDstrcmp("SIMPLE", temp)) { /* SIMPLE */
int icount = 0;
#ifdef H5DEBUGIMPORT
HDprintf("h5dump DATASPACE SIMPLE found\n");
#endif
- if (fscanf(strm, "%254s", temp) != 1) { /* start bracket */
- (void) HDfprintf(stderr, err6b, infile);
+ if (HDfscanf(strm, "%254s", temp) != 1) { /* start bracket */
+ (void)HDfprintf(stderr, err6b, infile);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump DATASPACE SIMPLE %s found\n", temp);
#endif
- if (fscanf(strm, "%254s", temp) != 1) { /* start paren */
- (void) HDfprintf(stderr, err6b, infile);
+ if (HDfscanf(strm, "%254s", temp) != 1) { /* start paren */
+ (void)HDfprintf(stderr, err6b, infile);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump DATASPACE SIMPLE %s found\n", temp);
#endif
- if(!HDstrcmp("(", temp)) { /* start paren */
+ if (!HDstrcmp("(", temp)) { /* start paren */
int get_next_dim = 1;
- int i = 0;
+ int i = 0;
- if (fscanf(strm, "%254s", temp) != 1) { /* Dimension with optional comma */
- (void) HDfprintf(stderr, err16c, infile);
+ if (HDfscanf(strm, "%254s", temp) != 1) { /* Dimension with optional comma */
+ (void)HDfprintf(stderr, err16c, infile);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump DATASPACE SIMPLE %s found\n", temp);
#endif
while (get_next_dim) {
- char *more = temp;
+ char *more = temp;
temp_dims[icount] = HDstrtoull(more, &more, 10);
- if (fscanf(strm, "%254s", temp) != 1) { /* Dimension or end paren */
- (void) HDfprintf(stderr, err6b, infile);
+ if (HDfscanf(strm, "%254s", temp) != 1) { /* Dimension or end paren */
+ (void)HDfprintf(stderr, err6b, infile);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump DATASPACE SIMPLE %s found\n", temp);
#endif
- if(!HDstrcmp(")", temp)) { /* end paren */
- in->rank = ++icount;
+ if (!HDstrcmp(")", temp)) { /* end paren */
+ in->rank = ++icount;
in->configOptionVector[RANK] = 1;
- get_next_dim = 0;
+ get_next_dim = 0;
}
else { /* Dimension */
icount++;
if (icount > MAX_NUM_DIMENSION) {
- (void) HDfprintf(stderr, "Invalid value for rank.\n");
+ (void)HDfprintf(stderr, "Invalid value for rank.\n");
goto error;
}
}
} /* while (get_next_dim) */
- if ((in->sizeOfDimension = (hsize_t *) HDmalloc ((size_t) in->rank * sizeof(hsize_t))) == NULL) {
+ if ((in->sizeOfDimension = (hsize_t *)HDmalloc((size_t)in->rank * sizeof(hsize_t))) ==
+ NULL) {
goto error;
}
#ifdef H5DEBUGIMPORT
@@ -1696,36 +1705,37 @@ static int processConfigurationFile(char *infile, struct Input *in)
in->configOptionVector[DIM] = 1;
} /* if(!HDstrcmp("(", key)) start paren */
else {
- (void) HDfprintf(stderr, err5b, infile);
+ (void)HDfprintf(stderr, err5b, infile);
goto error;
}
- if (fscanf(strm, "%254s", temp) != 1) {
- (void) HDfprintf(stderr, "%s", err18);
+ if (HDfscanf(strm, "%254s", temp) != 1) {
+ (void)HDfprintf(stderr, "%s", err18);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump DATASPACE SIMPLE %s found\n", temp);
#endif
- if(!HDstrcmp("/", temp)) { /* / max dims */
- if ((in->maxsizeOfDimension = (hsize_t *) HDmalloc ((size_t) in->rank * sizeof(hsize_t))) == NULL) {
+ if (!HDstrcmp("/", temp)) { /* / max dims */
+ if ((in->maxsizeOfDimension =
+ (hsize_t *)HDmalloc((size_t)in->rank * sizeof(hsize_t))) == NULL) {
goto error;
}
- if (fscanf(strm, "%254s", temp) != 1) { /* start paren */
- (void) HDfprintf(stderr, err6b, infile);
+ if (HDfscanf(strm, "%254s", temp) != 1) { /* start paren */
+ (void)HDfprintf(stderr, err6b, infile);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump DATASPACE SIMPLE %s found\n", temp);
#endif
- if(!HDstrcmp("(", temp)) { /* start paren */
+ if (!HDstrcmp("(", temp)) { /* start paren */
int get_next_dim = 1;
- int i = 0;
+ int i = 0;
#ifdef H5DEBUGIMPORT
HDprintf("h5dump DATASPACE SIMPLE process max dim values\n");
#endif
- if (fscanf(strm, "%254s", temp) != 1) { /* max dim with optional comma */
- (void) HDfprintf(stderr, err16c, infile);
+ if (HDfscanf(strm, "%254s", temp) != 1) { /* max dim with optional comma */
+ (void)HDfprintf(stderr, err16c, infile);
goto error;
}
#ifdef H5DEBUGIMPORT
@@ -1735,28 +1745,29 @@ static int processConfigurationFile(char *infile, struct Input *in)
#ifdef H5DEBUGIMPORT
HDprintf("h5dump DATASPACE SIMPLE get max dim value\n");
#endif
- if(!HDstrcmp("H5S_UNLIMITED", temp) || !HDstrcmp("H5S_UNLIMITED,", temp)) { /* unlimited */
- in->maxsizeOfDimension[i] = H5S_UNLIMITED;
+ if (!HDstrcmp("H5S_UNLIMITED", temp) ||
+ !HDstrcmp("H5S_UNLIMITED,", temp)) { /* unlimited */
+ in->maxsizeOfDimension[i] = H5S_UNLIMITED;
in->configOptionVector[EXTEND] = 1;
}
else {
- char *more = temp;
+ char *more = temp;
in->maxsizeOfDimension[i] = HDstrtoull(more, &more, 10);
}
- if (fscanf(strm, "%254s", temp) != 1) { /* max dim or end paren */
- (void) HDfprintf(stderr, err16c, infile);
+ if (HDfscanf(strm, "%254s", temp) != 1) { /* max dim or end paren */
+ (void)HDfprintf(stderr, err16c, infile);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump DATASPACE SIMPLE %s found\n", temp);
#endif
- if(!HDstrcmp(")", temp)) { /* end paren */
+ if (!HDstrcmp(")", temp)) { /* end paren */
get_next_dim = 0;
}
else { /* comma */
i++;
if (i >= MAX_NUM_DIMENSION) {
- (void) HDfprintf(stderr, "Invalid value for rank.\n");
+ (void)HDfprintf(stderr, "Invalid value for rank.\n");
goto error;
}
}
@@ -1771,79 +1782,79 @@ static int processConfigurationFile(char *infile, struct Input *in)
#endif
} /* if(!HDstrcmp("(", key)) start paren */
else {
- (void) HDfprintf(stderr, err16c, infile);
+ (void)HDfprintf(stderr, err16c, infile);
goto error;
}
- scanret = fscanf(strm, "%254s", temp); /* end bracket */
+ scanret = HDfscanf(strm, "%254s", temp); /* end bracket */
#ifdef H5DEBUGIMPORT
HDprintf("h5dump DATASPACE SIMPLE %s found\n", temp);
#endif
} /* if(!HDstrcmp("/", key)) max dims separator */
- } /* else if(!HDstrcmp("SIMPLE", key)) */
+ } /* else if(!HDstrcmp("SIMPLE", key)) */
else {
- (void) HDfprintf(stderr, err5b, infile);
+ (void)HDfprintf(stderr, err5b, infile);
goto error;
}
} /* else if(!HDstrcmp("DATASPACE", key)) RANK and DIMENSIONS */
- else if(!HDstrcmp("STORAGE_LAYOUT", key)) { /* CHUNKED-DIMENSION-SIZES */
+ else if (!HDstrcmp("STORAGE_LAYOUT", key)) { /* CHUNKED-DIMENSION-SIZES */
#ifdef H5DEBUGIMPORT
HDprintf("h5dump STORAGE_LAYOUT key\n");
#endif
- if (fscanf(strm, "%254s", temp) != 1) { /* start bracket */
- (void) HDfprintf(stderr, err6b, infile);
+ if (HDfscanf(strm, "%254s", temp) != 1) { /* start bracket */
+ (void)HDfprintf(stderr, err6b, infile);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump STORAGE_LAYOUT %s found\n", temp);
#endif
- if (fscanf(strm, "%254s", temp) != 1) { /* CHUNKED */
- (void) HDfprintf(stderr, err6b, infile);
+ if (HDfscanf(strm, "%254s", temp) != 1) { /* CHUNKED */
+ (void)HDfprintf(stderr, err6b, infile);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump STORAGE_LAYOUT %s found\n", temp);
#endif
- if(!HDstrcmp("CHUNKED", temp)) { /* CHUNKED */
- if ((in->sizeOfChunk = (hsize_t *) HDmalloc ((size_t) in->rank * sizeof(hsize_t))) == NULL) {
- (void) HDfprintf(stderr, "Unable to allocate dynamic memory.\n");
+ if (!HDstrcmp("CHUNKED", temp)) { /* CHUNKED */
+ if ((in->sizeOfChunk = (hsize_t *)HDmalloc((size_t)in->rank * sizeof(hsize_t))) == NULL) {
+ (void)HDfprintf(stderr, "Unable to allocate dynamic memory.\n");
goto error;
}
- if (fscanf(strm, "%254s", temp) != 1) { /* start paren */
- (void) HDfprintf(stderr, err6b, infile);
+ if (HDfscanf(strm, "%254s", temp) != 1) { /* start paren */
+ (void)HDfprintf(stderr, err6b, infile);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump STORAGE_LAYOUT CHUNKED %s found\n", temp);
#endif
- if(!HDstrcmp("(", temp)) { /* start paren */
+ if (!HDstrcmp("(", temp)) { /* start paren */
int get_next_dim = 1;
- int icount = 0;
+ int icount = 0;
- if (fscanf(strm, "%254s", temp) != 1) { /* Dimension with optional comma */
- (void) HDfprintf(stderr, err16c, infile);
+ if (HDfscanf(strm, "%254s", temp) != 1) { /* Dimension with optional comma */
+ (void)HDfprintf(stderr, err16c, infile);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump STORAGE_LAYOUT CHUNKED %s found\n", temp);
#endif
while (get_next_dim) {
- char *more = temp;
+ char *more = temp;
in->sizeOfChunk[icount] = HDstrtoull(more, &more, 10);
- if (fscanf(strm, "%254s", temp) != 1) { /* Dimension or end paren */
- (void) HDfprintf(stderr, err6b, infile);
+ if (HDfscanf(strm, "%254s", temp) != 1) { /* Dimension or end paren */
+ (void)HDfprintf(stderr, err6b, infile);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump STORAGE_LAYOUT CHUNKED %s found\n", temp);
#endif
- if(!HDstrcmp(")", temp)) { /* end paren */
+ if (!HDstrcmp(")", temp)) { /* end paren */
in->configOptionVector[RANK] = 1;
- get_next_dim = 0;
+ get_next_dim = 0;
}
else { /* Dimension */
icount++;
if (icount > MAX_NUM_DIMENSION) {
- (void) HDfprintf(stderr, "Invalid value for rank.\n");
+ (void)HDfprintf(stderr, "Invalid value for rank.\n");
goto error;
}
}
@@ -1858,28 +1869,28 @@ static int processConfigurationFile(char *infile, struct Input *in)
in->configOptionVector[DIM] = 1;
} /* if(!HDstrcmp("(", key)) start paren */
else {
- (void) HDfprintf(stderr, err5b, infile);
+ (void)HDfprintf(stderr, err5b, infile);
goto error;
}
- if (fscanf(strm, "%254s", temp) != 1) { /* SIZE */
- (void) HDfprintf(stderr, err6b, infile);
+ if (HDfscanf(strm, "%254s", temp) != 1) { /* SIZE */
+ (void)HDfprintf(stderr, err6b, infile);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump STORAGE_LAYOUT CHUNKED %s found\n", temp);
#endif
- if(!HDstrcmp("SIZE", temp)) { /* SIZE */
- if (fscanf(strm, "%d", (&ival)) != 1) {
- (void) HDfprintf(stderr, "%s", err19);
+ if (!HDstrcmp("SIZE", temp)) { /* SIZE */
+ if (HDfscanf(strm, "%d", (&ival)) != 1) {
+ (void)HDfprintf(stderr, "%s", err19);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump STORAGE_LAYOUT CHUNKED SIZE %d found\n", ival);
#endif
}
- while (HDstrcmp("}", temp)) {
- if (fscanf(strm, "%254s", temp) != 1) { /* end bracket */
- (void) HDfprintf(stderr, "%s", err18);
+ while (HDstrcmp("}", temp) != 0) {
+ if (HDfscanf(strm, "%254s", temp) != 1) { /* end bracket */
+ (void)HDfprintf(stderr, "%s", err18);
goto error;
}
#ifdef H5DEBUGIMPORT
@@ -1888,148 +1899,148 @@ static int processConfigurationFile(char *infile, struct Input *in)
}
in->configOptionVector[CHUNK] = 1;
} /* if(!HDstrcmp("CHUNKED", key)) CHUNKED */
- } /* else if(!HDstrcmp("STORAGE_LAYOUT", key)) CHUNKED-DIMENSION-SIZES */
- else if(!HDstrcmp("FILTERS", key)) { /* FILTERS */
+ } /* else if(!HDstrcmp("STORAGE_LAYOUT", key)) CHUNKED-DIMENSION-SIZES */
+ else if (!HDstrcmp("FILTERS", key)) { /* FILTERS */
#ifdef H5DEBUGIMPORT
HDprintf("h5dump FILTERS key\n");
#endif
- if (fscanf(strm, "%254s", temp) != 1) { /* start bracket */
- (void) HDfprintf(stderr, err6b, infile);
+ if (HDfscanf(strm, "%254s", temp) != 1) { /* start bracket */
+ (void)HDfprintf(stderr, err6b, infile);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump FILTERS %s found\n", temp);
#endif
- if (fscanf(strm, "%254s", temp) != 1) {
- (void) HDfprintf(stderr, err6b, infile);
+ if (HDfscanf(strm, "%254s", temp) != 1) {
+ (void)HDfprintf(stderr, err6b, infile);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump FILTERS %s found\n", temp);
#endif
- if(!HDstrcmp("COMPRESSION", temp)) { /* COMPRESSION */
+ if (!HDstrcmp("COMPRESSION", temp)) { /* COMPRESSION */
#ifdef H5DEBUGIMPORT
HDprintf("h5dump FILTERS COMPRESSION found\n");
#endif
- if (fscanf(strm, "%254s", temp) != 1) { /* DEFLATE */
- (void) HDfprintf(stderr, "%s", err18);
+ if (HDfscanf(strm, "%254s", temp) != 1) { /* DEFLATE */
+ (void)HDfprintf(stderr, "%s", err18);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump FILTERS COMPRESSION %s found\n", temp);
#endif
- if (fscanf(strm, "%254s", temp) != 1) { /* bgin bracket */
- (void) HDfprintf(stderr, "%s", err18);
+ if (HDfscanf(strm, "%254s", temp) != 1) { /* bgin bracket */
+ (void)HDfprintf(stderr, "%s", err18);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump FILTERS COMPRESSION %s found\n", temp);
#endif
- if (fscanf(strm, "%254s", temp) != 1) { /* LEVEL */
- (void) HDfprintf(stderr, "%s", err18);
+ if (HDfscanf(strm, "%254s", temp) != 1) { /* LEVEL */
+ (void)HDfprintf(stderr, "%s", err18);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump FILTERS COMPRESSION %s found\n", temp);
#endif
- if (fscanf(strm, "%d", (&ival)) != 1) {
- (void) HDfprintf(stderr, "%s", err19);
+ if (HDfscanf(strm, "%d", (&ival)) != 1) {
+ (void)HDfprintf(stderr, "%s", err19);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump FILTERS COMPRESSION LEVEL %d found\n", ival);
#endif
in->compressionParam = ival;
- if (fscanf(strm, "%254s", temp) != 1) { /* end bracket */
- (void) HDfprintf(stderr, "%s", err18);
+ if (HDfscanf(strm, "%254s", temp) != 1) { /* end bracket */
+ (void)HDfprintf(stderr, "%s", err18);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump FILTERS COMPRESSION %s found\n", temp);
#endif
- in->compressionType = 0; /* ONLY GZIP supported */
+ in->compressionType = 0; /* ONLY GZIP supported */
in->configOptionVector[COMPRESS] = 1;
}
- else if(!HDstrcmp("CONTIGUOUS", temp)) { /* CONTIGUOUS */
+ else if (!HDstrcmp("CONTIGUOUS", temp)) { /* CONTIGUOUS */
#ifdef H5DEBUGIMPORT
- HDprintf("h5dump FILTERS CONTIGUOUS found\n");
+ HDprintf("h5dump FILTERS CONTIGUOUS found\n");
#endif
in->configOptionVector[COMPRESS] = 0;
}
- else if(!HDstrcmp("NONE", temp)) { /* NONE */
+ else if (!HDstrcmp("NONE", temp)) { /* NONE */
#ifdef H5DEBUGIMPORT
- HDprintf("h5dump FILTERS NONE found\n");
+ HDprintf("h5dump FILTERS NONE found\n");
#endif
in->configOptionVector[COMPRESS] = 0;
}
- if (fscanf(strm, "%254s", temp) != 1) { /* end bracket */
- (void) HDfprintf(stderr, "%s", err18);
+ if (HDfscanf(strm, "%254s", temp) != 1) { /* end bracket */
+ (void)HDfprintf(stderr, "%s", err18);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump FILTERS %s found\n", temp);
#endif
}
- else if(!HDstrcmp("SUBSET", key)) { /* reduce dimensions */
- hsize_t temp_dims[MAX_NUM_DIMENSION];
- int get_next_prop = 1;
+ else if (!HDstrcmp("SUBSET", key)) { /* reduce dimensions */
+ hsize_t temp_dims[MAX_NUM_DIMENSION];
+ int get_next_prop = 1;
#ifdef H5DEBUGIMPORT
HDprintf("h5dump SUBSET key\n");
#endif
- if (fscanf(strm, "%254s", temp) != 1) { /* start bracket */
- (void) HDfprintf(stderr, err20, infile);
+ if (HDfscanf(strm, "%254s", temp) != 1) { /* start bracket */
+ (void)HDfprintf(stderr, err20, infile);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump SUBSET %s found\n", temp);
#endif
- if (fscanf(strm, "%254s", temp) != 1) { /* SUBSET keyword */
- (void) HDfprintf(stderr, "%s", err18);
+ if (HDfscanf(strm, "%254s", temp) != 1) { /* SUBSET keyword */
+ (void)HDfprintf(stderr, "%s", err18);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump SUBSET %s found\n", temp);
#endif
while (get_next_prop) {
- if(!HDstrcmp("COUNT", temp)) { /* COUNT */
+ if (!HDstrcmp("COUNT", temp)) { /* COUNT */
int icount = 0;
- if (fscanf(strm, "%254s", temp) != 1) { /* start paren */
- (void) HDfprintf(stderr, err6b, infile);
+ if (HDfscanf(strm, "%254s", temp) != 1) { /* start paren */
+ (void)HDfprintf(stderr, err6b, infile);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump SUBSET %s found\n", temp);
#endif
- if(!HDstrcmp("(", temp)) { /* start paren */
+ if (!HDstrcmp("(", temp)) { /* start paren */
int get_next_dim = 1;
- int i = 0;
+ int i = 0;
- if (fscanf(strm, "%254s", temp) != 1) { /* Dimension with optional comma */
- (void) HDfprintf(stderr, err16c, infile);
+ if (HDfscanf(strm, "%254s", temp) != 1) { /* Dimension with optional comma */
+ (void)HDfprintf(stderr, err16c, infile);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump SUBSET COUNT [%s] found\n", temp);
#endif
while (get_next_dim) {
- char *more = temp;
+ char *more = temp;
temp_dims[icount] = HDstrtoull(more, &more, 10);
- if (fscanf(strm, "%254s", temp) != 1) { /* Dimension or end paren */
- (void) HDfprintf(stderr, err6b, infile);
+ if (HDfscanf(strm, "%254s", temp) != 1) { /* Dimension or end paren */
+ (void)HDfprintf(stderr, err6b, infile);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump SUBSET COUNT %s found\n", temp);
#endif
- if(!HDstrcmp(");", temp)) { /* end paren */
- in->rank = ++icount;
+ if (!HDstrcmp(");", temp)) { /* end paren */
+ in->rank = ++icount;
in->configOptionVector[RANK] = 1;
- get_next_dim = 0;
+ get_next_dim = 0;
}
else { /* Dimension */
icount++;
if (icount >= MAX_NUM_DIMENSION) {
- (void) HDfprintf(stderr, "Invalid value for rank.\n");
+ (void)HDfprintf(stderr, "Invalid value for rank.\n");
goto error;
}
}
@@ -2045,47 +2056,47 @@ static int processConfigurationFile(char *infile, struct Input *in)
HDprintf("\n");
#endif
in->configOptionVector[DIM] = 1;
- } /* if(!HDstrcmp("(", key)) start paren */
- } /* if(!HDstrcmp("COUNT", temp)) COUNT */
- if(!HDstrcmp("BLOCK", temp)) { /* BLOCK */
+ } /* if(!HDstrcmp("(", key)) start paren */
+ } /* if(!HDstrcmp("COUNT", temp)) COUNT */
+ if (!HDstrcmp("BLOCK", temp)) { /* BLOCK */
int icount = 0;
- if (fscanf(strm, "%254s", temp) != 1) { /* start paren */
- (void) HDfprintf(stderr, err6b, infile);
+ if (HDfscanf(strm, "%254s", temp) != 1) { /* start paren */
+ (void)HDfprintf(stderr, err6b, infile);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump SUBSET %s found\n", temp);
#endif
- if(!HDstrcmp("(", temp)) { /* start paren */
+ if (!HDstrcmp("(", temp)) { /* start paren */
int get_next_dim = 1;
- int i = 0;
+ int i = 0;
- if (fscanf(strm, "%254s", temp) != 1) { /* Dimension with optional comma */
- (void) HDfprintf(stderr, err16c, infile);
+ if (HDfscanf(strm, "%254s", temp) != 1) { /* Dimension with optional comma */
+ (void)HDfprintf(stderr, err16c, infile);
goto error;
}
#ifdef H5DEBUGIMPORT
- HDprintf("h5dump SUBSET BLOCK [%s] found\n", temp);
+ HDprintf("h5dump SUBSET BLOCK [%s] found\n", temp);
#endif
while (get_next_dim) {
- char *more = temp;
+ char *more = temp;
temp_dims[icount] = HDstrtoull(more, &more, 10);
- if (fscanf(strm, "%254s", temp) != 1) { /* Dimension or end paren */
- (void) HDfprintf(stderr, err6b, infile);
+ if (HDfscanf(strm, "%254s", temp) != 1) { /* Dimension or end paren */
+ (void)HDfprintf(stderr, err6b, infile);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump SUBSET BLOCK %s found\n", temp);
#endif
- if(!HDstrcmp(");", temp)) { /* end paren */
- in->rank = ++icount;
+ if (!HDstrcmp(");", temp)) { /* end paren */
+ in->rank = ++icount;
in->configOptionVector[RANK] = 1;
- get_next_dim = 0;
+ get_next_dim = 0;
}
else { /* Dimension */
icount++;
if (icount > MAX_NUM_DIMENSION) {
- (void) HDfprintf(stderr, "Invalid value for rank.\n");
+ (void)HDfprintf(stderr, "Invalid value for rank.\n");
goto error;
}
}
@@ -2102,27 +2113,27 @@ static int processConfigurationFile(char *infile, struct Input *in)
#endif
in->configOptionVector[DIM] = 1;
} /* if(!HDstrcmp("(", key)) start paren */
- } /* if(!HDstrcmp("BLOCK", temp)) BLOCK */
- if (fscanf(strm, "%254s", temp) != 1) {
- (void) HDfprintf(stderr, "%s", err18);
+ } /* if(!HDstrcmp("BLOCK", temp)) BLOCK */
+ if (HDfscanf(strm, "%254s", temp) != 1) {
+ (void)HDfprintf(stderr, "%s", err18);
goto error;
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump SUBSET %s found\n", temp);
#endif
- if(!HDstrcmp("}", temp)) { /* end bracket */
+ if (!HDstrcmp("}", temp)) { /* end bracket */
get_next_prop = 0;
}
- } /* while (get_next_prop) */
- } /* else if(!HDstrcmp("SUBSET", key)) */
- else if(!HDstrcmp("DATA", key)) { /* FINSHED */
+ } /* while (get_next_prop) */
+ } /* else if(!HDstrcmp("SUBSET", key)) */
+ else if (!HDstrcmp("DATA", key)) { /* FINISHED */
#ifdef H5DEBUGIMPORT
HDprintf("h5dump DATA key\n");
#endif
scanret = 0;
break;
}
- scanret = fscanf(strm, "%254s", key);
+ scanret = HDfscanf(strm, "%254s", key);
}
#ifdef H5DEBUGIMPORT
HDprintf("h5dump path");
@@ -2154,258 +2165,257 @@ static int processConfigurationFile(char *infile, struct Input *in)
#endif
while (scanret == 1) {
if ((kindex = mapKeywordToIndex(key)) == -1) {
- (void) HDfprintf(stderr, err2, key, infile);
+ (void)HDfprintf(stderr, err2, key, infile);
goto error;
}
switch (kindex) {
- case 0: /* PATH */
- if (in->configOptionVector[PATH] == 1) {
- (void) HDfprintf(stderr, err3a, infile);
- goto error;
- }
- if (fscanf(strm, "%254s", temp) != 1) {
- (void) HDfprintf(stderr, "%s", err18);
- goto error;
- }
- if (parsePathInfo(&in->path, temp) == -1) {
- (void) HDfprintf(stderr, err3b, infile);
- goto error;
- }
- in->configOptionVector[PATH] = 1;
- break;
+ case 0: /* PATH */
+ if (in->configOptionVector[PATH] == 1) {
+ (void)HDfprintf(stderr, err3a, infile);
+ goto error;
+ }
+ if (HDfscanf(strm, "%254s", temp) != 1) {
+ (void)HDfprintf(stderr, "%s", err18);
+ goto error;
+ }
+ if (parsePathInfo(&in->path, temp) == -1) {
+ (void)HDfprintf(stderr, err3b, infile);
+ goto error;
+ }
+ in->configOptionVector[PATH] = 1;
+ break;
- case 1: /* INPUT-CLASS */
- if (in->configOptionVector[INPUT_CLASS] == 1) {
- (void) HDfprintf(stderr, err4a, infile);
- goto error;
- }
+ case 1: /* INPUT-CLASS */
+ if (in->configOptionVector[INPUT_CLASS] == 1) {
+ (void)HDfprintf(stderr, err4a, infile);
+ goto error;
+ }
- if (fscanf(strm, "%254s", temp) != 1) {
- (void) HDfprintf(stderr, "%s", err18);
- goto error;
- }
- if (getInputClass(in, temp) == -1) {
- (void) HDfprintf(stderr, err4b, infile);
- goto error;
- }
+ if (HDfscanf(strm, "%254s", temp) != 1) {
+ (void)HDfprintf(stderr, "%s", err18);
+ goto error;
+ }
+ if (getInputClass(in, temp) == -1) {
+ (void)HDfprintf(stderr, err4b, infile);
+ goto error;
+ }
- in->configOptionVector[INPUT_CLASS] = 1;
+ in->configOptionVector[INPUT_CLASS] = 1;
- /*set default value for output-class */
- if (in->configOptionVector[OUTPUT_CLASS] == 0) {
- if (in->inputClass == 0 || in->inputClass == 4)
- in->outputClass = 0;
- if (in->inputClass == 1 || in->inputClass == 2
- || in->inputClass == 3)
- in->outputClass = 1;
- if (in->inputClass == 6 || in->inputClass == 7)
- in->outputClass = 2;
- }
- break;
+ /*set default value for output-class */
+ if (in->configOptionVector[OUTPUT_CLASS] == 0) {
+ if (in->inputClass == 0 || in->inputClass == 4)
+ in->outputClass = 0;
+ if (in->inputClass == 1 || in->inputClass == 2 || in->inputClass == 3)
+ in->outputClass = 1;
+ if (in->inputClass == 6 || in->inputClass == 7)
+ in->outputClass = 2;
+ }
+ break;
- case 2: /* INPUT-SIZE */
- if (in->configOptionVector[INPUT_SIZE] == 1) {
- (void) HDfprintf(stderr, err5a, infile);
- goto error;
- }
- if (fscanf(strm, "%254d", (&ival)) != 1) {
- (void) HDfprintf(stderr, "%s", err19);
- goto error;
- }
- if (getInputSize(in, ival) == -1) {
- (void) HDfprintf(stderr, err5b, infile);
- goto error;
- }
- in->configOptionVector[INPUT_SIZE] = 1;
+ case 2: /* INPUT-SIZE */
+ if (in->configOptionVector[INPUT_SIZE] == 1) {
+ (void)HDfprintf(stderr, err5a, infile);
+ goto error;
+ }
+ if (HDfscanf(strm, "%254d", (&ival)) != 1) {
+ (void)HDfprintf(stderr, "%s", err19);
+ goto error;
+ }
+ if (getInputSize(in, ival) == -1) {
+ (void)HDfprintf(stderr, err5b, infile);
+ goto error;
+ }
+ in->configOptionVector[INPUT_SIZE] = 1;
- /*set default value for output-size */
- if (in->configOptionVector[OUTPUT_SIZE] == 0)
- in->outputSize = in->inputSize;
- break;
+ /*set default value for output-size */
+ if (in->configOptionVector[OUTPUT_SIZE] == 0)
+ in->outputSize = in->inputSize;
+ break;
- case 3: /* RANK */
- if (in->configOptionVector[RANK] == 1) {
- (void) HDfprintf(stderr, err6a, infile);
- goto error;
- }
+ case 3: /* RANK */
+ if (in->configOptionVector[RANK] == 1) {
+ (void)HDfprintf(stderr, err6a, infile);
+ goto error;
+ }
- if (getRank(in, strm) == -1) {
- (void) HDfprintf(stderr, err6b, infile);
- goto error;
- }
- in->configOptionVector[RANK] = 1;
- break;
+ if (getRank(in, strm) == -1) {
+ (void)HDfprintf(stderr, err6b, infile);
+ goto error;
+ }
+ in->configOptionVector[RANK] = 1;
+ break;
- case 4: /* DIMENSION-SIZES */
- if (in->configOptionVector[DIM] == 1) {
- (void) HDfprintf(stderr, err7a, infile);
- goto error;
- }
+ case 4: /* DIMENSION-SIZES */
+ if (in->configOptionVector[DIM] == 1) {
+ (void)HDfprintf(stderr, err7a, infile);
+ goto error;
+ }
- if (in->configOptionVector[RANK] == 0) {
- (void) HDfprintf(stderr, err7b, infile);
- goto error;
- }
- if (getDimensionSizes(in, strm) == -1) {
- (void) HDfprintf(stderr, err7c, infile);
- goto error;
- }
- in->configOptionVector[DIM] = 1;
- break;
+ if (in->configOptionVector[RANK] == 0) {
+ (void)HDfprintf(stderr, err7b, infile);
+ goto error;
+ }
+ if (getDimensionSizes(in, strm) == -1) {
+ (void)HDfprintf(stderr, err7c, infile);
+ goto error;
+ }
+ in->configOptionVector[DIM] = 1;
+ break;
- case 5: /* OUTPUT-CLASS */
- if (in->configOptionVector[OUTPUT_CLASS] == 1) {
- (void) HDfprintf(stderr, err8a, infile);
- goto error;
- }
+ case 5: /* OUTPUT-CLASS */
+ if (in->configOptionVector[OUTPUT_CLASS] == 1) {
+ (void)HDfprintf(stderr, err8a, infile);
+ goto error;
+ }
- if (getOutputClass(in, strm) == -1) {
- (void) HDfprintf(stderr, err8b, infile);
- goto error;
- }
- in->configOptionVector[OUTPUT_CLASS] = 1;
- break;
+ if (getOutputClass(in, strm) == -1) {
+ (void)HDfprintf(stderr, err8b, infile);
+ goto error;
+ }
+ in->configOptionVector[OUTPUT_CLASS] = 1;
+ break;
- case 6: /* OUTPUT-SIZE */
- if (in->configOptionVector[OUTPUT_SIZE] == 1) {
- (void) HDfprintf(stderr, err9a, infile);
- goto error;
- }
+ case 6: /* OUTPUT-SIZE */
+ if (in->configOptionVector[OUTPUT_SIZE] == 1) {
+ (void)HDfprintf(stderr, err9a, infile);
+ goto error;
+ }
- if (getOutputSize(in, strm) == -1) {
- (void) HDfprintf(stderr, err9b, infile);
- goto error;
- }
- in->configOptionVector[OUTPUT_SIZE] = 1;
- break;
+ if (getOutputSize(in, strm) == -1) {
+ (void)HDfprintf(stderr, err9b, infile);
+ goto error;
+ }
+ in->configOptionVector[OUTPUT_SIZE] = 1;
+ break;
- case 7: /* OUTPUT-ARCHITECTURE */
- if (in->configOptionVector[OUTPUT_ARCH] == 1) {
- (void) HDfprintf(stderr, err10a, infile);
- goto error;
- }
+ case 7: /* OUTPUT-ARCHITECTURE */
+ if (in->configOptionVector[OUTPUT_ARCH] == 1) {
+ (void)HDfprintf(stderr, err10a, infile);
+ goto error;
+ }
- if (getOutputArchitecture(in, strm) == -1) {
- (void) HDfprintf(stderr, err10b, infile);
- goto error;
- }
- in->configOptionVector[OUTPUT_ARCH] = 1;
- break;
+ if (getOutputArchitecture(in, strm) == -1) {
+ (void)HDfprintf(stderr, err10b, infile);
+ goto error;
+ }
+ in->configOptionVector[OUTPUT_ARCH] = 1;
+ break;
- case 8: /* OUTPUT-BYTE-ORDER */
- if (in->configOptionVector[OUTPUT_B_ORDER] == 1) {
- (void) HDfprintf(stderr, err11a, infile);
- goto error;
- }
+ case 8: /* OUTPUT-BYTE-ORDER */
+ if (in->configOptionVector[OUTPUT_B_ORDER] == 1) {
+ (void)HDfprintf(stderr, err11a, infile);
+ goto error;
+ }
- if (getOutputByteOrder(in, strm) == -1) {
- (void) HDfprintf(stderr, err11b, infile);
- goto error;
- }
- in->configOptionVector[OUTPUT_B_ORDER] = 1;
- break;
+ if (getOutputByteOrder(in, strm) == -1) {
+ (void)HDfprintf(stderr, err11b, infile);
+ goto error;
+ }
+ in->configOptionVector[OUTPUT_B_ORDER] = 1;
+ break;
- case 9: /* CHUNKED-DIMENSION-SIZES */
- if (in->configOptionVector[CHUNK] == 1) {
- (void) HDfprintf(stderr, err12a, infile);
- goto error;
- }
- /* cant appear before dimension sizes have been provided */
- if (in->configOptionVector[DIM] == 0) {
- (void) HDfprintf(stderr, err12b, infile);
- goto error;
- }
+ case 9: /* CHUNKED-DIMENSION-SIZES */
+ if (in->configOptionVector[CHUNK] == 1) {
+ (void)HDfprintf(stderr, err12a, infile);
+ goto error;
+ }
+ /* can't appear before dimension sizes have been provided */
+ if (in->configOptionVector[DIM] == 0) {
+ (void)HDfprintf(stderr, err12b, infile);
+ goto error;
+ }
- if (getChunkedDimensionSizes(in, strm) == -1) {
- (void) HDfprintf(stderr, err12c, infile);
- goto error;
- }
- in->configOptionVector[CHUNK] = 1;
- break;
+ if (getChunkedDimensionSizes(in, strm) == -1) {
+ (void)HDfprintf(stderr, err12c, infile);
+ goto error;
+ }
+ in->configOptionVector[CHUNK] = 1;
+ break;
- case 10: /* COMPRESSION-TYPE */
- if (in->configOptionVector[COMPRESS] == 1) {
- (void) HDfprintf(stderr, err13a, infile);
- goto error;
- }
+ case 10: /* COMPRESSION-TYPE */
+ if (in->configOptionVector[COMPRESS] == 1) {
+ (void)HDfprintf(stderr, err13a, infile);
+ goto error;
+ }
- if (getCompressionType(in, strm) == -1) {
- (void) HDfprintf(stderr, err13b, infile);
- goto error;
- }
- in->configOptionVector[COMPRESS] = 1;
+ if (getCompressionType(in, strm) == -1) {
+ (void)HDfprintf(stderr, err13b, infile);
+ goto error;
+ }
+ in->configOptionVector[COMPRESS] = 1;
- if (in->configOptionVector[COMPRESS_PARAM] == 0) {
- if (in->compressionType == 0)
- in->compressionParam = 6; /* default value if compressionType is GZIP */
- }
- break;
+ if (in->configOptionVector[COMPRESS_PARAM] == 0) {
+ if (in->compressionType == 0)
+ in->compressionParam = 6; /* default value if compressionType is GZIP */
+ }
+ break;
- case 11: /* COMPRESSION-PARAM */
- if (in->configOptionVector[COMPRESS_PARAM] == 1) {
- (void) HDfprintf(stderr, err14a, infile);
- goto error;
- }
+ case 11: /* COMPRESSION-PARAM */
+ if (in->configOptionVector[COMPRESS_PARAM] == 1) {
+ (void)HDfprintf(stderr, err14a, infile);
+ goto error;
+ }
- if (getCompressionParameter(in, strm) == -1) {
- (void) HDfprintf(stderr, err14b, infile);
- goto error;
- }
+ if (getCompressionParameter(in, strm) == -1) {
+ (void)HDfprintf(stderr, err14b, infile);
+ goto error;
+ }
- in->configOptionVector[COMPRESS_PARAM] = 1;
+ in->configOptionVector[COMPRESS_PARAM] = 1;
- if (in->configOptionVector[COMPRESS] == 0)
- in->compressionType = 0;
+ if (in->configOptionVector[COMPRESS] == 0)
+ in->compressionType = 0;
- break;
+ break;
- case 12: /* EXTERNAL-STORAGE */
- if (in->configOptionVector[EXTERNALSTORE] == 1) {
- (void) HDfprintf(stderr, err15a, infile);
- goto error;
- }
+ case 12: /* EXTERNAL-STORAGE */
+ if (in->configOptionVector[EXTERNALSTORE] == 1) {
+ (void)HDfprintf(stderr, err15a, infile);
+ goto error;
+ }
- if (getExternalFilename(in, strm) == -1) {
- (void) HDfprintf(stderr, err15b, infile);
- goto error;
- }
- in->configOptionVector[EXTERNALSTORE] = 1;
- break;
+ if (getExternalFilename(in, strm) == -1) {
+ (void)HDfprintf(stderr, err15b, infile);
+ goto error;
+ }
+ in->configOptionVector[EXTERNALSTORE] = 1;
+ break;
- case 13: /* MAXIMUM-DIMENSIONS */
- if (in->configOptionVector[EXTEND] == 1) {
- (void) HDfprintf(stderr, err16a, infile);
- goto error;
- }
- /* cant appear before dimension sizes have been provided */
- if (in->configOptionVector[DIM] == 0) {
- (void) HDfprintf(stderr, err16b, infile);
- goto error;
- }
- if (getMaximumDimensionSizes(in, strm) == -1) {
- (void) HDfprintf(stderr, err16c, infile);
- goto error;
- }
- in->configOptionVector[EXTEND] = 1;
- break;
+ case 13: /* MAXIMUM-DIMENSIONS */
+ if (in->configOptionVector[EXTEND] == 1) {
+ (void)HDfprintf(stderr, err16a, infile);
+ goto error;
+ }
+ /* can't appear before dimension sizes have been provided */
+ if (in->configOptionVector[DIM] == 0) {
+ (void)HDfprintf(stderr, err16b, infile);
+ goto error;
+ }
+ if (getMaximumDimensionSizes(in, strm) == -1) {
+ (void)HDfprintf(stderr, err16c, infile);
+ goto error;
+ }
+ in->configOptionVector[EXTEND] = 1;
+ break;
- case 14: /* INPUT-BYTE-ORDER */
- if (in->configOptionVector[INPUT_B_ORDER] == 1) {
- (void) HDfprintf(stderr, err11c, infile);
- goto error;
- }
+ case 14: /* INPUT-BYTE-ORDER */
+ if (in->configOptionVector[INPUT_B_ORDER] == 1) {
+ (void)HDfprintf(stderr, err11c, infile);
+ goto error;
+ }
- if (getInputByteOrder(in, strm) == -1) {
- (void) HDfprintf(stderr, err11d, infile);
- goto error;
- }
- in->configOptionVector[INPUT_B_ORDER] = 1;
- break;
+ if (getInputByteOrder(in, strm) == -1) {
+ (void)HDfprintf(stderr, err11d, infile);
+ goto error;
+ }
+ in->configOptionVector[INPUT_B_ORDER] = 1;
+ break;
- default:
- break;
+ default:
+ break;
}
- scanret = fscanf(strm, "%254s", key);
+ scanret = HDfscanf(strm, "%254s", key);
}
/*
@@ -2414,7 +2424,7 @@ static int processConfigurationFile(char *infile, struct Input *in)
*/
if (validateConfigurationParameters(in) == -1) {
- (void) HDfprintf(stderr, err17, infile);
+ (void)HDfprintf(stderr, err17, infile);
goto error;
}
}
@@ -2423,76 +2433,72 @@ static int processConfigurationFile(char *infile, struct Input *in)
retval = 0;
error:
- if(strm)
+ if (strm)
HDfclose(strm);
- return(retval);
+ return (retval);
}
-static int validateConfigurationParameters(struct Input *in)
+static int
+validateConfigurationParameters(struct Input *in)
{
const char *err1 = "One or more of the required fields (RANK, DIMENSION-SIZES) missing.\n";
- const char *err2 = "Cannot specify chunking or compression or extendible data sets with the external file option.\n";
- const char *err3 = "Cannot specify the compression or the extendible data sets without the chunking option.\n";
+ const char *err2 =
+ "Cannot specify chunking or compression or extendible data sets with the external file option.\n";
+ const char *err3 =
+ "Cannot specify the compression or the extendible data sets without the chunking option.\n";
const char *err4a = "OUTPUT-ARCHITECTURE cannot be STD if OUTPUT-CLASS is floating point (FP).\n";
const char *err4b = "OUTPUT-ARCHITECTURE cannot be IEEE if OUTPUT-CLASS is integer (IN).\n";
- const char *err5 = "For OUTPUT-CLASS FP, valid values for OUTPUT-SIZE are (32, 64) .\n";
-#ifndef H5_SIZEOF_LONG_LONG
- const char *err6 = "No support for reading 64-bit integer (INPUT-CLASS: IN, TEXTIN, UIN, TEXTUIN files\n";
-#endif
+ const char *err5 = "For OUTPUT-CLASS FP, valid values for OUTPUT-SIZE are (32, 64) .\n";
/* for class STR other parameters are ignored */
if (in->inputClass == 5) /* STR */
return (0);
if ((in->configOptionVector[DIM] != 1) || (in->configOptionVector[RANK] != 1)) {
- (void) HDfprintf(stderr, "%s", err1);
+ (void)HDfprintf(stderr, "%s", err1);
return (-1);
}
if (in->configOptionVector[EXTERNALSTORE] == 1) {
- if ((in->configOptionVector[COMPRESS] == 1) || (in->configOptionVector[CHUNK] == 1) || (in->configOptionVector[EXTEND] == 1)) {
- (void) HDfprintf(stderr, "%s", err2);
+ if ((in->configOptionVector[COMPRESS] == 1) || (in->configOptionVector[CHUNK] == 1) ||
+ (in->configOptionVector[EXTEND] == 1)) {
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
}
if ((in->configOptionVector[COMPRESS] == 1) || (in->configOptionVector[EXTEND] == 1)) {
if (in->configOptionVector[CHUNK] != 1) {
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err3);
return (-1);
}
}
- /* Arch cant be STD if O/p class is FP */
+ /* Arch can't be STD if O/p class is FP */
if (in->outputArchitecture == 1)
if (in->outputClass == 1) {
- (void) HDfprintf(stderr, "%s", err4a);
+ (void)HDfprintf(stderr, "%s", err4a);
return (-1);
}
- /* Arch cant be IEEE if O/p class is IN */
+ /* Arch can't be IEEE if O/p class is IN */
if (in->outputArchitecture == 2)
if (in->outputClass == 0) {
- (void) HDfprintf(stderr, "%s", err4b);
+ (void)HDfprintf(stderr, "%s", err4b);
return (-1);
}
if (in->outputClass == 1)
if (in->outputSize != 32 && in->outputSize != 64) {
- (void) HDfprintf(stderr, "%s", err5);
+ (void)HDfprintf(stderr, "%s", err5);
return (-1);
}
-#ifndef H5_SIZEOF_LONG_LONG
- if (in->inputSize == 64 && (in->inputClass == 0 || in->inputClass == 4 || in->inputClass == 6 || in->inputClass == 7) ) {
- (void) HDfprintf(stderr, "%s", err6);
- return -1;
- }
-#endif
return (0);
}
-static int mapKeywordToIndex(char *key)
+static int
+mapKeywordToIndex(char *key)
{
int i;
@@ -2502,66 +2508,67 @@ static int mapKeywordToIndex(char *key)
return -1;
}
-static int parsePathInfo(struct path_info *path, char *temp)
+static int
+parsePathInfo(struct path_info *path, char *temp)
{
const char delimiter[] = "/\"";
- char *token;
- int i = 0;
+ char * token;
+ int i = 0;
const char *err1 = "Path string larger than MAX_PATH_NAME_LENGTH.\n";
- token = HDstrtok (temp, delimiter);
+ token = HDstrtok(temp, delimiter);
if (HDstrlen(token) >= MAX_PATH_NAME_LENGTH) {
- (void) HDfprintf(stderr, err1);
+ (void)HDfprintf(stderr, "%s", err1);
return (-1);
}
- HDstrcpy(path->group[i++],token);
+ HDstrcpy(path->group[i++], token);
while (1) {
- token = HDstrtok (NULL, delimiter);
+ token = HDstrtok(NULL, delimiter);
if (token == NULL)
break;
if (HDstrlen(token) >= MAX_PATH_NAME_LENGTH) {
- (void) HDfprintf(stderr, err1);
+ (void)HDfprintf(stderr, "%s", err1);
return (-1);
}
- HDstrcpy(path->group[i++],token);
+ HDstrcpy(path->group[i++], token);
}
path->count = i;
return (0);
}
-static int parseDimensions(struct Input *in, char *strm)
+static int
+parseDimensions(struct Input *in, char *strm)
{
const char delimiter[] = ",";
char temp[255];
- char *token;
- int i = 0;
+ char * token;
+ int i = 0;
const char *err1 = "Unable to allocate dynamic memory.\n";
HDstrncpy(temp, strm, sizeof(temp));
temp[sizeof(temp) - 1] = '\0';
- HDstrtok (temp, delimiter);
+ HDstrtok(temp, delimiter);
while (1) {
- token = HDstrtok (NULL, delimiter);
+ token = HDstrtok(NULL, delimiter);
if (token == NULL)
break;
i++;
}
in->rank = i + 1;
- if ((in->sizeOfDimension = (hsize_t *) HDmalloc ((size_t) in->rank * sizeof(hsize_t))) == NULL) {
- (void) HDfprintf(stderr, "%s", err1);
+ if ((in->sizeOfDimension = (hsize_t *)HDmalloc((size_t)in->rank * sizeof(hsize_t))) == NULL) {
+ (void)HDfprintf(stderr, "%s", err1);
return (-1);
}
i = 0;
HDstrncpy(temp, strm, sizeof(temp));
- temp[sizeof(temp) - 1] = '\0';
- in->sizeOfDimension[i++]
- = HDstrtoull(HDstrtok (temp, delimiter), NULL, BASE_10);
+ temp[sizeof(temp) - 1] = '\0';
+ in->sizeOfDimension[i++] = HDstrtoull(HDstrtok(temp, delimiter), NULL, BASE_10);
while (1) {
- token = HDstrtok (NULL, delimiter);
+ token = HDstrtok(NULL, delimiter);
if (token == NULL)
break;
in->sizeOfDimension[i++] = HDstrtoull(token, NULL, BASE_10);
@@ -2569,20 +2576,21 @@ static int parseDimensions(struct Input *in, char *strm)
return (0);
}
-static int getOutputClass(struct Input *in, FILE *strm)
+static int
+getOutputClass(struct Input *in, FILE *strm)
{
char temp[255];
int kindex;
const char *err1 = "Unable to get 'string' value.\n";
const char *err2 = "Invalid value for output class.\n";
- if (fscanf(strm, "%254s", temp) != 1) {
- (void) HDfprintf(stderr, "%s", err1);
+ if (HDfscanf(strm, "%254s", temp) != 1) {
+ (void)HDfprintf(stderr, "%s", err1);
return (-1);
}
if ((kindex = OutputClassStrToInt(temp)) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
@@ -2590,10 +2598,11 @@ static int getOutputClass(struct Input *in, FILE *strm)
return (0);
}
-static int OutputClassStrToInt(char *temp)
+static int
+OutputClassStrToInt(char *temp)
{
- int i;
- char classKeywordTable[3][15] = { "IN", "FP", "UIN" };
+ int i;
+ char classKeywordTable[3][15] = {"IN", "FP", "UIN"};
for (i = 0; i < 3; i++)
if (!HDstrcmp(classKeywordTable[i], temp))
return i;
@@ -2601,16 +2610,17 @@ static int OutputClassStrToInt(char *temp)
return -1;
}
/* same as getInputSize. But defined separately for extensibility */
-static int getOutputSize(struct Input *in, FILE *strm)
+static int
+getOutputSize(struct Input *in, FILE *strm)
{
int ival;
int i;
- int outputSizeValidValues[4] = { 8, 16, 32, 64 };
- const char *err1 = "Unable to get integer value.\n";
- const char *err2 = "Invalid value for output size.\n";
+ int outputSizeValidValues[4] = {8, 16, 32, 64};
+ const char *err1 = "Unable to get integer value.\n";
+ const char *err2 = "Invalid value for output size.\n";
- if (fscanf(strm, "%d", (&ival)) != 1) {
- (void) HDfprintf(stderr, "%s", err1);
+ if (HDfscanf(strm, "%d", (&ival)) != 1) {
+ (void)HDfprintf(stderr, "%s", err1);
return (-1);
}
@@ -2619,17 +2629,18 @@ static int getOutputSize(struct Input *in, FILE *strm)
in->outputSize = ival;
return (0);
}
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
-static int getInputClass(struct Input *in, char * temp)
+static int
+getInputClass(struct Input *in, char *temp)
{
int kindex;
const char *err1 = "Invalid value for input class.\n";
if ((kindex = InputClassStrToInt(temp)) == -1) {
- (void) HDfprintf(stderr, "%s", err1);
+ (void)HDfprintf(stderr, "%s", err1);
return (-1);
}
@@ -2637,355 +2648,356 @@ static int getInputClass(struct Input *in, char * temp)
return (0);
}
-static int getInputClassType(struct Input *in, char * buffer)
+static int
+getInputClassType(struct Input *in, char *buffer)
{
int kindex = -1;
- const char *err1 = "Invalid value for input class.\n";
- const char *err2 = "Invalid value for output architecture.\n";
- const char *err3 = "Invalid value for input byte-order.\n";
+ const char *err1 = "Invalid value for input class.\n";
+ const char *err2 = "Invalid value for output architecture.\n";
+ const char *err3 = "Invalid value for input byte-order.\n";
if (!HDstrcmp(buffer, "H5T_STD_I8BE")) {
- in->inputSize = 8;
+ in->inputSize = 8;
in->configOptionVector[INPUT_SIZE] = 1;
if ((kindex = OutputArchStrToInt("STD")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
if ((kindex = OutputByteOrderStrToInt("BE")) == -1) {
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err3);
return (-1);
}
in->outputByteOrder = kindex;
- #ifdef H5DEBUGIMPORT
+#ifdef H5DEBUGIMPORT
HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder);
- #endif
+#endif
kindex = 4;
}
else if (!HDstrcmp(buffer, "H5T_STD_I8LE")) {
- in->inputSize = 8;
+ in->inputSize = 8;
in->configOptionVector[INPUT_SIZE] = 1;
if ((kindex = OutputArchStrToInt("STD")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
if ((kindex = OutputByteOrderStrToInt("LE")) == -1) {
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err3);
return (-1);
}
in->outputByteOrder = kindex;
- #ifdef H5DEBUGIMPORT
+#ifdef H5DEBUGIMPORT
HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder);
- #endif
+#endif
kindex = 4;
}
else if (!HDstrcmp(buffer, "H5T_STD_I16BE")) {
- in->inputSize = 16;
+ in->inputSize = 16;
in->configOptionVector[INPUT_SIZE] = 1;
if ((kindex = OutputArchStrToInt("STD")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
if ((kindex = OutputByteOrderStrToInt("BE")) == -1) {
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err3);
return (-1);
}
in->outputByteOrder = kindex;
- #ifdef H5DEBUGIMPORT
+#ifdef H5DEBUGIMPORT
HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder);
- #endif
+#endif
kindex = 4;
}
else if (!HDstrcmp(buffer, "H5T_STD_I16LE")) {
- in->inputSize = 16;
+ in->inputSize = 16;
in->configOptionVector[INPUT_SIZE] = 1;
if ((kindex = OutputArchStrToInt("STD")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
if ((kindex = OutputByteOrderStrToInt("LE")) == -1) {
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err3);
return (-1);
}
in->outputByteOrder = kindex;
- #ifdef H5DEBUGIMPORT
+#ifdef H5DEBUGIMPORT
HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder);
- #endif
+#endif
kindex = 4;
}
else if (!HDstrcmp(buffer, "H5T_STD_I32BE")) {
- in->inputSize = 32;
+ in->inputSize = 32;
in->configOptionVector[INPUT_SIZE] = 1;
if ((kindex = OutputArchStrToInt("STD")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
if ((kindex = OutputByteOrderStrToInt("BE")) == -1) {
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err3);
return (-1);
}
in->outputByteOrder = kindex;
- #ifdef H5DEBUGIMPORT
+#ifdef H5DEBUGIMPORT
HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder);
- #endif
+#endif
kindex = 4;
}
else if (!HDstrcmp(buffer, "H5T_STD_I32LE")) {
- in->inputSize = 32;
+ in->inputSize = 32;
in->configOptionVector[INPUT_SIZE] = 1;
if ((kindex = OutputArchStrToInt("STD")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
if ((kindex = OutputByteOrderStrToInt("LE")) == -1) {
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err3);
return (-1);
}
in->outputByteOrder = kindex;
- #ifdef H5DEBUGIMPORT
+#ifdef H5DEBUGIMPORT
HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder);
- #endif
+#endif
kindex = 4;
}
else if (!HDstrcmp(buffer, "H5T_STD_I64BE")) {
- in->inputSize = 64;
+ in->inputSize = 64;
in->configOptionVector[INPUT_SIZE] = 1;
if ((kindex = OutputArchStrToInt("STD")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
if ((kindex = OutputByteOrderStrToInt("BE")) == -1) {
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err3);
return (-1);
}
in->outputByteOrder = kindex;
- #ifdef H5DEBUGIMPORT
+#ifdef H5DEBUGIMPORT
HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder);
- #endif
+#endif
kindex = 4;
}
else if (!HDstrcmp(buffer, "H5T_STD_I64LE")) {
- in->inputSize = 64;
+ in->inputSize = 64;
in->configOptionVector[INPUT_SIZE] = 1;
if ((kindex = OutputArchStrToInt("STD")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
if ((kindex = OutputByteOrderStrToInt("LE")) == -1) {
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err3);
return (-1);
}
in->outputByteOrder = kindex;
- #ifdef H5DEBUGIMPORT
+#ifdef H5DEBUGIMPORT
HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder);
- #endif
+#endif
kindex = 4;
}
else if (!HDstrcmp(buffer, "H5T_STD_U8BE")) {
- in->inputSize = 8;
+ in->inputSize = 8;
in->configOptionVector[INPUT_SIZE] = 1;
if ((kindex = OutputArchStrToInt("STD")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
if ((kindex = OutputByteOrderStrToInt("BE")) == -1) {
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err3);
return (-1);
}
in->outputByteOrder = kindex;
- #ifdef H5DEBUGIMPORT
+#ifdef H5DEBUGIMPORT
HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder);
- #endif
+#endif
kindex = 7;
}
else if (!HDstrcmp(buffer, "H5T_STD_U8LE")) {
- in->inputSize = 8;
+ in->inputSize = 8;
in->configOptionVector[INPUT_SIZE] = 1;
if ((kindex = OutputArchStrToInt("STD")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
if ((kindex = OutputByteOrderStrToInt("LE")) == -1) {
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err3);
return (-1);
}
in->outputByteOrder = kindex;
- #ifdef H5DEBUGIMPORT
+#ifdef H5DEBUGIMPORT
HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder);
- #endif
+#endif
kindex = 7;
}
else if (!HDstrcmp(buffer, "H5T_STD_U16BE")) {
- in->inputSize = 16;
+ in->inputSize = 16;
in->configOptionVector[INPUT_SIZE] = 1;
if ((kindex = OutputArchStrToInt("STD")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
if ((kindex = OutputByteOrderStrToInt("BE")) == -1) {
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err3);
return (-1);
}
in->outputByteOrder = kindex;
- #ifdef H5DEBUGIMPORT
+#ifdef H5DEBUGIMPORT
HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder);
- #endif
+#endif
kindex = 7;
}
else if (!HDstrcmp(buffer, "H5T_STD_U16LE")) {
- in->inputSize = 16;
+ in->inputSize = 16;
in->configOptionVector[INPUT_SIZE] = 1;
if ((kindex = OutputArchStrToInt("STD")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
if ((kindex = OutputByteOrderStrToInt("LE")) == -1) {
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err3);
return (-1);
}
in->outputByteOrder = kindex;
- #ifdef H5DEBUGIMPORT
+#ifdef H5DEBUGIMPORT
HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder);
- #endif
+#endif
kindex = 7;
}
else if (!HDstrcmp(buffer, "H5T_STD_U32BE")) {
- in->inputSize = 32;
+ in->inputSize = 32;
in->configOptionVector[INPUT_SIZE] = 1;
if ((kindex = OutputArchStrToInt("STD")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
if ((kindex = OutputByteOrderStrToInt("BE")) == -1) {
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err3);
return (-1);
}
in->outputByteOrder = kindex;
- #ifdef H5DEBUGIMPORT
+#ifdef H5DEBUGIMPORT
HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder);
- #endif
+#endif
kindex = 7;
}
else if (!HDstrcmp(buffer, "H5T_STD_U32LE")) {
- in->inputSize = 32;
+ in->inputSize = 32;
in->configOptionVector[INPUT_SIZE] = 1;
if ((kindex = OutputArchStrToInt("STD")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
if ((kindex = OutputByteOrderStrToInt("LE")) == -1) {
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err3);
return (-1);
}
in->outputByteOrder = kindex;
- #ifdef H5DEBUGIMPORT
+#ifdef H5DEBUGIMPORT
HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder);
- #endif
+#endif
kindex = 7;
}
else if (!HDstrcmp(buffer, "H5T_STD_U64BE")) {
- in->inputSize = 64;
+ in->inputSize = 64;
in->configOptionVector[INPUT_SIZE] = 1;
if ((kindex = OutputArchStrToInt("STD")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
if ((kindex = OutputByteOrderStrToInt("BE")) == -1) {
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err3);
return (-1);
}
in->outputByteOrder = kindex;
- #ifdef H5DEBUGIMPORT
+#ifdef H5DEBUGIMPORT
HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder);
- #endif
+#endif
kindex = 7;
}
else if (!HDstrcmp(buffer, "H5T_STD_U64LE")) {
- in->inputSize = 64;
+ in->inputSize = 64;
in->configOptionVector[INPUT_SIZE] = 1;
if ((kindex = OutputArchStrToInt("STD")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
if ((kindex = OutputByteOrderStrToInt("LE")) == -1) {
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err3);
return (-1);
}
in->outputByteOrder = kindex;
- #ifdef H5DEBUGIMPORT
+#ifdef H5DEBUGIMPORT
HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder);
- #endif
+#endif
kindex = 7;
}
else if (!HDstrcmp(buffer, "H5T_NATIVE_SCHAR")) {
- in->inputSize = 8;
+ in->inputSize = 8;
in->configOptionVector[INPUT_SIZE] = 1;
if ((kindex = OutputArchStrToInt("NATIVE")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
@@ -2993,11 +3005,11 @@ static int getInputClassType(struct Input *in, char * buffer)
kindex = 4;
}
else if (!HDstrcmp(buffer, "H5T_NATIVE_UCHAR")) {
- in->inputSize = 8;
+ in->inputSize = 8;
in->configOptionVector[INPUT_SIZE] = 1;
if ((kindex = OutputArchStrToInt("NATIVE")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
@@ -3005,11 +3017,11 @@ static int getInputClassType(struct Input *in, char * buffer)
kindex = 7;
}
else if (!HDstrcmp(buffer, "H5T_NATIVE_SHORT")) {
- in->inputSize = 16;
+ in->inputSize = 16;
in->configOptionVector[INPUT_SIZE] = 1;
if ((kindex = OutputArchStrToInt("NATIVE")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
@@ -3017,11 +3029,11 @@ static int getInputClassType(struct Input *in, char * buffer)
kindex = 4;
}
else if (!HDstrcmp(buffer, "H5T_NATIVE_USHORT")) {
- in->inputSize = 16;
+ in->inputSize = 16;
in->configOptionVector[INPUT_SIZE] = 1;
if ((kindex = OutputArchStrToInt("NATIVE")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
@@ -3029,11 +3041,11 @@ static int getInputClassType(struct Input *in, char * buffer)
kindex = 7;
}
else if (!HDstrcmp(buffer, "H5T_NATIVE_INT")) {
- in->inputSize = 32;
+ in->inputSize = 32;
in->configOptionVector[INPUT_SIZE] = 1;
if ((kindex = OutputArchStrToInt("NATIVE")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
@@ -3041,11 +3053,11 @@ static int getInputClassType(struct Input *in, char * buffer)
kindex = 4;
}
else if (!HDstrcmp(buffer, "H5T_NATIVE_UINT")) {
- in->inputSize = 32;
+ in->inputSize = 32;
in->configOptionVector[INPUT_SIZE] = 1;
if ((kindex = OutputArchStrToInt("NATIVE")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
@@ -3053,11 +3065,11 @@ static int getInputClassType(struct Input *in, char * buffer)
kindex = 7;
}
else if (!HDstrcmp(buffer, "H5T_NATIVE_LONG")) {
- in->inputSize = 32;
+ in->inputSize = 32;
in->configOptionVector[INPUT_SIZE] = 1;
if ((kindex = OutputArchStrToInt("NATIVE")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
@@ -3065,11 +3077,11 @@ static int getInputClassType(struct Input *in, char * buffer)
kindex = 4;
}
else if (!HDstrcmp(buffer, "H5T_NATIVE_ULONG")) {
- in->inputSize = 32;
+ in->inputSize = 32;
in->configOptionVector[INPUT_SIZE] = 1;
if ((kindex = OutputArchStrToInt("NATIVE")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
@@ -3077,11 +3089,11 @@ static int getInputClassType(struct Input *in, char * buffer)
kindex = 7;
}
else if (!HDstrcmp(buffer, "H5T_NATIVE_LLONG")) {
- in->inputSize = 64;
+ in->inputSize = 64;
in->configOptionVector[INPUT_SIZE] = 1;
if ((kindex = OutputArchStrToInt("NATIVE")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
@@ -3089,11 +3101,11 @@ static int getInputClassType(struct Input *in, char * buffer)
kindex = 4;
}
else if (!HDstrcmp(buffer, "H5T_NATIVE_ULLONG")) {
- in->inputSize = 64;
+ in->inputSize = 64;
in->configOptionVector[INPUT_SIZE] = 1;
if ((kindex = OutputArchStrToInt("NATIVE")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
@@ -3101,107 +3113,107 @@ static int getInputClassType(struct Input *in, char * buffer)
kindex = 7;
}
else if (!HDstrcmp(buffer, "H5T_IEEE_F32BE")) {
- in->inputSize = 32;
+ in->inputSize = 32;
in->configOptionVector[INPUT_SIZE] = 1;
if ((kindex = OutputArchStrToInt("IEEE")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
if ((kindex = OutputByteOrderStrToInt("BE")) == -1) {
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err3);
return (-1);
}
in->outputByteOrder = kindex;
- #ifdef H5DEBUGIMPORT
+#ifdef H5DEBUGIMPORT
HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder);
- #endif
+#endif
kindex = 3;
}
else if (!HDstrcmp(buffer, "H5T_IEEE_F32LE")) {
- in->inputSize = 32;
+ in->inputSize = 32;
in->configOptionVector[INPUT_SIZE] = 1;
if ((kindex = OutputArchStrToInt("IEEE")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
if ((kindex = OutputByteOrderStrToInt("LE")) == -1) {
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err3);
return (-1);
}
in->outputByteOrder = kindex;
- #ifdef H5DEBUGIMPORT
+#ifdef H5DEBUGIMPORT
HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder);
- #endif
+#endif
kindex = 3;
}
else if (!HDstrcmp(buffer, "H5T_IEEE_F64BE")) {
- in->inputSize = 64;
+ in->inputSize = 64;
in->configOptionVector[INPUT_SIZE] = 1;
if ((kindex = OutputArchStrToInt("IEEE")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
if ((kindex = OutputByteOrderStrToInt("BE")) == -1) {
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err3);
return (-1);
}
in->outputByteOrder = kindex;
- #ifdef H5DEBUGIMPORT
+#ifdef H5DEBUGIMPORT
HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder);
- #endif
+#endif
kindex = 3;
}
else if (!HDstrcmp(buffer, "H5T_IEEE_F64LE")) {
- in->inputSize = 64;
+ in->inputSize = 64;
in->configOptionVector[INPUT_SIZE] = 1;
if ((kindex = OutputArchStrToInt("IEEE")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
if ((kindex = OutputByteOrderStrToInt("LE")) == -1) {
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err3);
return (-1);
}
in->outputByteOrder = kindex;
- #ifdef H5DEBUGIMPORT
+#ifdef H5DEBUGIMPORT
HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder);
- #endif
+#endif
kindex = 3;
}
else if (!HDstrcmp(buffer, "H5T_VAX_F32")) {
- in->inputSize = 32;
+ in->inputSize = 32;
in->configOptionVector[INPUT_SIZE] = 1;
kindex = 3;
}
else if (!HDstrcmp(buffer, "H5T_VAX_F64")) {
- in->inputSize = 64;
+ in->inputSize = 64;
in->configOptionVector[INPUT_SIZE] = 1;
kindex = 3;
}
else if (!HDstrcmp(buffer, "H5T_NATIVE_FLOAT")) {
- in->inputSize = 32;
+ in->inputSize = 32;
in->configOptionVector[INPUT_SIZE] = 1;
if ((kindex = OutputArchStrToInt("NATIVE")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
@@ -3209,217 +3221,215 @@ static int getInputClassType(struct Input *in, char * buffer)
kindex = 3;
}
else if (!HDstrcmp(buffer, "H5T_NATIVE_DOUBLE")) {
- in->inputSize = 64;
+ in->inputSize = 64;
in->configOptionVector[INPUT_SIZE] = 1;
if ((kindex = OutputArchStrToInt("NATIVE")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
kindex = 3;
}
-#if H5_SIZEOF_LONG_DOUBLE !=0
else if (!HDstrcmp(buffer, "H5T_NATIVE_LDOUBLE")) {
- in->inputSize = H5_SIZEOF_LONG_DOUBLE;
+ in->inputSize = H5_SIZEOF_LONG_DOUBLE;
in->configOptionVector[INPUT_SIZE] = 1;
if ((kindex = OutputArchStrToInt("NATIVE")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
kindex = 3;
}
-#endif
- else if(!HDstrcmp(buffer, "H5T_TIME: not yet implemented")) {
+ else if (!HDstrcmp(buffer, "H5T_TIME: not yet implemented")) {
kindex = -1;
}
- else if(!HDstrcmp(buffer, "H5T_STRING")) {
+ else if (!HDstrcmp(buffer, "H5T_STRING")) {
kindex = 5;
}
/* case H5T_BITFIELD: */
else if (!HDstrcmp(buffer, "H5T_STD_B8BE")) {
if ((kindex = OutputArchStrToInt("STD")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
if ((kindex = OutputByteOrderStrToInt("BE")) == -1) {
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err3);
return (-1);
}
in->outputByteOrder = kindex;
- #ifdef H5DEBUGIMPORT
+#ifdef H5DEBUGIMPORT
HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder);
- #endif
+#endif
kindex = -1;
}
else if (!HDstrcmp(buffer, "H5T_STD_B8LE")) {
if ((kindex = OutputArchStrToInt("STD")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
if ((kindex = OutputByteOrderStrToInt("LE")) == -1) {
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err3);
return (-1);
}
in->outputByteOrder = kindex;
- #ifdef H5DEBUGIMPORT
+#ifdef H5DEBUGIMPORT
HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder);
- #endif
+#endif
kindex = -1;
}
else if (!HDstrcmp(buffer, "H5T_STD_B16BE")) {
if ((kindex = OutputArchStrToInt("STD")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
if ((kindex = OutputByteOrderStrToInt("BE")) == -1) {
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err3);
return (-1);
}
in->outputByteOrder = kindex;
- #ifdef H5DEBUGIMPORT
+#ifdef H5DEBUGIMPORT
HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder);
- #endif
+#endif
kindex = -1;
}
else if (!HDstrcmp(buffer, "H5T_STD_B16LE")) {
if ((kindex = OutputArchStrToInt("STD")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
if ((kindex = OutputByteOrderStrToInt("LE")) == -1) {
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err3);
return (-1);
}
in->outputByteOrder = kindex;
- #ifdef H5DEBUGIMPORT
+#ifdef H5DEBUGIMPORT
HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder);
- #endif
+#endif
kindex = -1;
}
else if (!HDstrcmp(buffer, "H5T_STD_B32BE")) {
if ((kindex = OutputArchStrToInt("STD")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
if ((kindex = OutputByteOrderStrToInt("BE")) == -1) {
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err3);
return (-1);
}
in->outputByteOrder = kindex;
- #ifdef H5DEBUGIMPORT
+#ifdef H5DEBUGIMPORT
HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder);
- #endif
+#endif
kindex = -1;
}
else if (!HDstrcmp(buffer, "H5T_STD_B32LE")) {
if ((kindex = OutputArchStrToInt("STD")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
if ((kindex = OutputByteOrderStrToInt("LE")) == -1) {
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err3);
return (-1);
}
in->outputByteOrder = kindex;
- #ifdef H5DEBUGIMPORT
+#ifdef H5DEBUGIMPORT
HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder);
- #endif
+#endif
kindex = -1;
}
else if (!HDstrcmp(buffer, "H5T_STD_B64BE")) {
if ((kindex = OutputArchStrToInt("STD")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
if ((kindex = OutputByteOrderStrToInt("BE")) == -1) {
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err3);
return (-1);
}
in->outputByteOrder = kindex;
- #ifdef H5DEBUGIMPORT
+#ifdef H5DEBUGIMPORT
HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder);
- #endif
+#endif
kindex = -1;
}
else if (!HDstrcmp(buffer, "H5T_STD_B64LE")) {
if ((kindex = OutputArchStrToInt("STD")) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->outputArchitecture = kindex;
if ((kindex = OutputByteOrderStrToInt("LE")) == -1) {
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err3);
return (-1);
}
in->outputByteOrder = kindex;
- #ifdef H5DEBUGIMPORT
+#ifdef H5DEBUGIMPORT
HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder);
- #endif
+#endif
kindex = -1;
}
/* case H5T_OPAQUE: */
- else if(!HDstrcmp(buffer, "H5T_OPAQUE")) {
+ else if (!HDstrcmp(buffer, "H5T_OPAQUE")) {
kindex = -1;
}
/* case H5T_COMPOUND: */
- else if(!HDstrcmp(buffer, "H5T_COMPOUND")) {
+ else if (!HDstrcmp(buffer, "H5T_COMPOUND")) {
kindex = -1;
}
/* case H5T_REFERENCE: */
- else if(!HDstrcmp(buffer, "H5T_REFERENCE")) {
+ else if (!HDstrcmp(buffer, "H5T_REFERENCE")) {
kindex = -1;
}
/* case H5T_ENUM: */
- else if(!HDstrcmp(buffer, "H5T_ENUM")) {
+ else if (!HDstrcmp(buffer, "H5T_ENUM")) {
kindex = -1;
}
/* case H5T_VLEN: */
- else if(!HDstrcmp(buffer, "H5T_VLEN")) {
+ else if (!HDstrcmp(buffer, "H5T_VLEN")) {
kindex = -1;
}
/* case H5T_ARRAY: */
- else if(!HDstrcmp(buffer, "H5T_ARRAY")) {
+ else if (!HDstrcmp(buffer, "H5T_ARRAY")) {
kindex = -1;
}
if (kindex == -1) {
- (void) HDfprintf(stderr, "%s", err1);
+ (void)HDfprintf(stderr, "%s", err1);
return (-1);
}
@@ -3436,10 +3446,11 @@ static int getInputClassType(struct Input *in, char * buffer)
return (0);
}
-static int InputClassStrToInt(char *temp)
+static int
+InputClassStrToInt(char *temp)
{
- int i;
- char classKeywordTable[8][15] = { "TEXTIN", "TEXTFP", "TEXTFPE", "FP", "IN", "STR", "TEXTUIN", "UIN" };
+ int i;
+ char classKeywordTable[8][15] = {"TEXTIN", "TEXTFP", "TEXTFPE", "FP", "IN", "STR", "TEXTUIN", "UIN"};
for (i = 0; i < 8; i++)
if (!HDstrcmp(classKeywordTable[i], temp))
return i;
@@ -3447,35 +3458,37 @@ static int InputClassStrToInt(char *temp)
}
/* same as getOutputSize. But defined separately for extensibility */
-static int getInputSize(struct Input *in, int ival)
+static int
+getInputSize(struct Input *in, int ival)
{
int i;
- int inputSizeValidValues[4] = { 8, 16, 32, 64 };
- const char *err1 = "Invalid value for input size.\n";
+ int inputSizeValidValues[4] = {8, 16, 32, 64};
+ const char *err1 = "Invalid value for input size.\n";
for (i = 0; i < 4; i++)
if (inputSizeValidValues[i] == ival) {
in->inputSize = ival;
return (0);
}
- (void) HDfprintf(stderr, "%s", err1);
+ (void)HDfprintf(stderr, "%s", err1);
return (-1);
}
-static int getInputByteOrder(struct Input *in, FILE *strm)
+static int
+getInputByteOrder(struct Input *in, FILE *strm)
{
char temp[255];
int kindex;
const char *err1 = "Unable to get 'string' value.\n";
const char *err2 = "Invalid value for input byte-order.\n";
- if (fscanf(strm, "%254s", temp) != 1) {
- (void) HDfprintf(stderr, "%s", err1);
+ if (HDfscanf(strm, "%254s", temp) != 1) {
+ (void)HDfprintf(stderr, "%s", err1);
return (-1);
}
if ((kindex = OutputByteOrderStrToInt(temp)) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
@@ -3483,15 +3496,16 @@ static int getInputByteOrder(struct Input *in, FILE *strm)
return (0);
}
-static int getRank(struct Input *in, FILE *strm)
+static int
+getRank(struct Input *in, FILE *strm)
{
- int ival;
+ int ival;
const char *err1 = "Unable to get integer value.\n";
const char *err2 = "Invalid value for rank.\n";
- if (fscanf(strm, "%d", (&ival)) != 1) {
- (void) HDfprintf(stderr, "%s", err1);
+ if (HDfscanf(strm, "%d", (&ival)) != 1) {
+ (void)HDfprintf(stderr, "%s", err1);
return (-1);
}
if (ival >= MIN_NUM_DIMENSION && ival <= MAX_NUM_DIMENSION) {
@@ -3499,79 +3513,86 @@ static int getRank(struct Input *in, FILE *strm)
return (0);
}
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
/* same as getChunkedDimensionSizes. But defined separately for extensibility */
-static int getDimensionSizes(struct Input *in, FILE *strm)
+static int
+getDimensionSizes(struct Input *in, FILE *strm)
{
unsigned long long ullval;
- int i = 0;
+ int i = 0;
const char *err1 = "Unable to allocate dynamic memory.\n";
- const char *err2 = "No. of dimensions for which dimension sizes provided is not equal to provided rank.\n";
+ const char *err2 =
+ "No. of dimensions for which dimension sizes provided is not equal to provided rank.\n";
- if ((in->sizeOfDimension = (hsize_t *) HDmalloc ((size_t) in->rank * sizeof(hsize_t))) == NULL) {
- (void) HDfprintf(stderr, "%s", err1);
+ if ((in->sizeOfDimension = (hsize_t *)HDmalloc((size_t)in->rank * sizeof(hsize_t))) == NULL) {
+ (void)HDfprintf(stderr, "%s", err1);
return (-1);
}
- while (fscanf(strm, "%llu", (&ullval)) == 1)
+ while (HDfscanf(strm, "%llu", (&ullval)) == 1)
in->sizeOfDimension[i++] = ullval;
if (in->rank != i) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
return (0);
}
/* same as getDimensionSizes. But defined separately for extensibility */
-static int getChunkedDimensionSizes(struct Input *in, FILE *strm)
+static int
+getChunkedDimensionSizes(struct Input *in, FILE *strm)
{
unsigned long long ullval;
- int i = 0;
+ int i = 0;
const char *err1 = "Unable to allocate dynamic memory.\n";
- const char *err2 = "No. of dimensions for which chunked dimension sizes provided is not equal to provided rank.\n";
+ const char *err2 =
+ "No. of dimensions for which chunked dimension sizes provided is not equal to provided rank.\n";
const char *err3 = "The CHUNKED-DIMENSION-SIZES cannot exceed the sizes of DIMENSION-SIZES\n";
- if ((in->sizeOfChunk = (hsize_t *) HDmalloc ((size_t) in->rank * sizeof(hsize_t))) == NULL) {
- (void) HDfprintf(stderr, "%s", err1);
+ if ((in->sizeOfChunk = (hsize_t *)HDmalloc((size_t)in->rank * sizeof(hsize_t))) == NULL) {
+ (void)HDfprintf(stderr, "%s", err1);
return (-1);
}
- while (fscanf(strm, "%llu", (&ullval)) == 1)
+ while (HDfscanf(strm, "%llu", (&ullval)) == 1)
in->sizeOfChunk[i++] = ullval;
if (in->rank != i) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
for (i = 0; i < in->rank; i++)
if (in->sizeOfChunk[i] > in->sizeOfDimension[i]) {
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err3);
return (-1);
}
return (0);
}
-static int getMaximumDimensionSizes(struct Input *in, FILE *strm)
+static int
+getMaximumDimensionSizes(struct Input *in, FILE *strm)
{
long long llval;
- int i = 0;
+ int i = 0;
const char *err1 = "Unable to allocate dynamic memory.\n";
- const char *err2 = "No. of dimensions for which maximum dimension sizes provided is not equal to provided rank.\n";
- const char *err3 = "The MAXIMUM-DIMENSIONS cannot be less than the sizes of DIMENSION-SIZES. Exception: can be -1 to indicate unlimited size\n";
+ const char *err2 =
+ "No. of dimensions for which maximum dimension sizes provided is not equal to provided rank.\n";
+ const char *err3 = "The MAXIMUM-DIMENSIONS cannot be less than the sizes of DIMENSION-SIZES. Exception: "
+ "can be -1 to indicate unlimited size\n";
- if ((in->maxsizeOfDimension = (hsize_t *) HDmalloc ((size_t) in->rank * sizeof(hsize_t))) == NULL) {
- (void) HDfprintf(stderr, "%s", err1);
+ if ((in->maxsizeOfDimension = (hsize_t *)HDmalloc((size_t)in->rank * sizeof(hsize_t))) == NULL) {
+ (void)HDfprintf(stderr, "%s", err1);
return (-1);
}
- while (fscanf(strm, "%lld", (&llval)) == 1) {
+ while (HDfscanf(strm, "%lld", (&llval)) == 1) {
if (llval == -1)
in->maxsizeOfDimension[i++] = H5S_UNLIMITED;
else
@@ -3579,34 +3600,35 @@ static int getMaximumDimensionSizes(struct Input *in, FILE *strm)
}
if (in->rank != i) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
for (i = 0; i < in->rank; i++) {
if (in->maxsizeOfDimension[i] != H5S_UNLIMITED)
if (in->maxsizeOfDimension[i] < in->sizeOfDimension[i]) {
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err3);
return (-1);
}
}
return (0);
}
-static int getOutputArchitecture(struct Input *in, FILE *strm)
+static int
+getOutputArchitecture(struct Input *in, FILE *strm)
{
char temp[255];
int kindex;
const char *err1 = "Unable to get 'string' value.\n";
const char *err2 = "Invalid value for output architecture.\n";
- if (fscanf(strm, "%254s", temp) != 1) {
- (void) HDfprintf(stderr, "%s", err1);
+ if (HDfscanf(strm, "%254s", temp) != 1) {
+ (void)HDfprintf(stderr, "%s", err1);
return (-1);
}
if ((kindex = OutputArchStrToInt(temp)) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
@@ -3614,31 +3636,32 @@ static int getOutputArchitecture(struct Input *in, FILE *strm)
return (0);
}
-static int OutputArchStrToInt(const char *temp)
+static int
+OutputArchStrToInt(const char *temp)
{
- int i;
- char outputArchKeywordTable[8][15] = { "NATIVE", "STD", "IEEE", "INTEL",
- "CRAY", "MIPS", "ALPHA", "UNIX" };
+ int i;
+ char outputArchKeywordTable[8][15] = {"NATIVE", "STD", "IEEE", "INTEL", "CRAY", "MIPS", "ALPHA", "UNIX"};
for (i = 0; i < 8; i++)
if (!HDstrcmp(outputArchKeywordTable[i], temp))
return i;
return -1;
}
-static int getOutputByteOrder(struct Input *in, FILE *strm)
+static int
+getOutputByteOrder(struct Input *in, FILE *strm)
{
char temp[255];
int kindex;
const char *err1 = "Unable to get 'string' value.\n";
const char *err2 = "Invalid value for output byte-order.\n";
- if (fscanf(strm, "%254s", temp) != 1) {
- (void) HDfprintf(stderr, "%s", err1);
+ if (HDfscanf(strm, "%254s", temp) != 1) {
+ (void)HDfprintf(stderr, "%s", err1);
return (-1);
}
if ((kindex = OutputByteOrderStrToInt(temp)) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
@@ -3646,52 +3669,55 @@ static int getOutputByteOrder(struct Input *in, FILE *strm)
return (0);
}
-static int OutputByteOrderStrToInt(const char *temp)
+static int
+OutputByteOrderStrToInt(const char *temp)
{
- int i;
- char outputByteOrderKeywordTable[2][15] = { "BE", "LE" };
+ int i;
+ char outputByteOrderKeywordTable[2][15] = {"BE", "LE"};
for (i = 0; i < 2; i++)
if (!HDstrcmp(outputByteOrderKeywordTable[i], temp))
return i;
return -1;
}
-static int getCompressionType(struct Input *in, FILE *strm)
+static int
+getCompressionType(struct Input *in, FILE *strm)
{
char temp[255];
int kindex;
const char *err1 = "Unable to get 'string' value.\n";
const char *err2 = "Invalid value for compression.\n";
- if (fscanf(strm, "%254s", temp) != 1) {
- (void) HDfprintf(stderr, "%s", err1);
+ if (HDfscanf(strm, "%254s", temp) != 1) {
+ (void)HDfprintf(stderr, "%s", err1);
return (-1);
}
if ((kindex = CompressionTypeStrToInt(temp)) == -1) {
- (void) HDfprintf(stderr, "%s", err2);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
}
in->compressionType = kindex;
return (0);
-
}
-static int CompressionTypeStrToInt(char *temp)
+static int
+CompressionTypeStrToInt(char *temp)
{
/* currently supports only GZIP */
/* can be extended by adding fields to the table */
- int i;
- char CompressionTypeKeywordTable[1][15] = { "GZIP" };
+ int i;
+ char CompressionTypeKeywordTable[1][15] = {"GZIP"};
for (i = 0; i < 1; i++)
if (!HDstrcmp(CompressionTypeKeywordTable[i], temp))
return i;
return -1;
}
-static int getCompressionParameter(struct Input *in, FILE *strm)
+static int
+getCompressionParameter(struct Input *in, FILE *strm)
{
/* currently supports only GZIP */
/* can be extended by adding more values to COMPRESSION-TYPE and */
@@ -3699,887 +3725,896 @@ static int getCompressionParameter(struct Input *in, FILE *strm)
int ival;
const char *err1 = "Unable to get integer value.\n";
- const char *err2 = "Invalid value for compression paramter.\n";
+ const char *err2 = "Invalid value for compression parameter.\n";
const char *err3 = "Unsupported Compression Type.\n";
switch (in->compressionType) {
- case 0: /* GZIP */
- if (fscanf(strm, "%d", (&ival)) != 1) {
- (void) HDfprintf(stderr, "%s", err1);
- return (-1);
- }
+ case 0: /* GZIP */
+ if (HDfscanf(strm, "%d", (&ival)) != 1) {
+ (void)HDfprintf(stderr, "%s", err1);
+ return (-1);
+ }
- if (ival < 0 || ival > 9) {
- (void) HDfprintf(stderr, "%s", err2);
- return (-1);
- }
- in->compressionParam = ival;
- return (0);
+ if (ival < 0 || ival > 9) {
+ (void)HDfprintf(stderr, "%s", err2);
+ return (-1);
+ }
+ in->compressionParam = ival;
+ return (0);
- default:
- (void) HDfprintf(stderr, "%s", err3);
- return (-1);
+ default:
+ (void)HDfprintf(stderr, "%s", err3);
+ return (-1);
}
}
-static int getExternalFilename(struct Input *in, FILE *strm)
+static int
+getExternalFilename(struct Input *in, FILE *strm)
{
+ size_t temp_len;
char temp[255];
const char *err1 = "Unable to get 'string' value.\n";
- if (fscanf(strm, "%254s", temp) != 1) {
- (void) HDfprintf(stderr, "%s", err1);
+ if (HDfscanf(strm, "%254s", temp) != 1) {
+ (void)HDfprintf(stderr, "%s", err1);
return (-1);
}
- in->externFilename = (char *) HDmalloc ((size_t) (HDstrlen(temp)) * sizeof(char));
- (void) HDstrcpy(in->externFilename, temp);
+ temp_len = HDstrlen(temp);
+ in->externFilename = (char *)HDmalloc((temp_len + 1) * sizeof(char));
+ (void)HDstrcpy(in->externFilename, temp);
+ in->externFilename[temp_len] = '\0';
return (0);
}
-void setDefaultValues(struct Input *in, int count)
+void
+setDefaultValues(struct Input *in, int count)
{
- int i;
- char temp[255];
- char num[255];
-
- in->h5dumpInput = 0;
- in->inputClass = 3; /* FP */
- in->inputSize = 32;
- in->outputClass = 1; /* FP */
- in->outputSize = 32;
+ int i;
+ char temp[255];
+ char num[255];
+
+ in->h5dumpInput = 0;
+ in->inputClass = 3; /* FP */
+ in->inputSize = 32;
+ in->outputClass = 1; /* FP */
+ in->outputSize = 32;
in->inputByteOrder = -1; /* use default */
- in->rank = 0;
- in->path.count = 1;
+ in->rank = 0;
+ in->path.count = 1;
HDstrcpy(temp, "dataset");
- HDsprintf(num, "%d", count);
+ HDsnprintf(num, sizeof(num), "%d", count);
HDstrcat(temp, num);
HDstrcpy(in->path.group[0], temp);
- in->outputArchitecture = 0; /* NATIVE */
- in->outputByteOrder = -1; /* use default */
- in->compressionType = 0; /* GZIP */
+ in->outputArchitecture = 0; /* NATIVE */
+ in->outputByteOrder = -1; /* use default */
+ in->compressionType = 0; /* GZIP */
for (i = 0; i < NUM_KEYS; i++)
in->configOptionVector[i] = 0;
}
-hid_t createOutputDataType(struct Input *in)
+hid_t
+createOutputDataType(struct Input *in)
{
hid_t new_type = (-1);
- const char *err1 = "Invalid value for output class.\n";
- const char *err2 = "Invalid value for output size.\n";
- const char *err3 = "Invalid value for output byte order.\n";
- const char *err4 = "Invalid value for output architecture.\n";
- const char *err5 = "STD not supported for float.\n";
- const char *err6 = "IEEE not supported for INT.\n";
+ const char *err1 = "Invalid value for output class.\n";
+ const char *err2 = "Invalid value for output size.\n";
+ const char *err3 = "Invalid value for output byte order.\n";
+ const char *err4 = "Invalid value for output architecture.\n";
+ const char *err5 = "STD not supported for float.\n";
+ const char *err6 = "IEEE not supported for INT.\n";
switch (in->outputClass) {
- case 0:
- switch (in->outputArchitecture) {
- case 0: /* NATIVE */
- switch (in->outputSize) {
- case 8:
- new_type = H5Tcopy(H5T_NATIVE_CHAR);
- break;
-
- case 16:
- new_type = H5Tcopy(H5T_NATIVE_SHORT);
- break;
+ case 0:
+ switch (in->outputArchitecture) {
+ case 0: /* NATIVE */
+ switch (in->outputSize) {
+ case 8:
+ new_type = H5Tcopy(H5T_NATIVE_CHAR);
+ break;
- case 32:
- new_type = H5Tcopy(H5T_NATIVE_INT);
- break;
+ case 16:
+ new_type = H5Tcopy(H5T_NATIVE_SHORT);
+ break;
- case 64:
- new_type = H5Tcopy(H5T_NATIVE_LLONG);
- break;
+ case 32:
+ new_type = H5Tcopy(H5T_NATIVE_INT);
+ break;
- default:
- (void) HDfprintf(stderr, "%s", err2);
- return (-1);
- }
- switch (in->outputByteOrder) {
- case -1: /* default */
- break;
- case 0:
- H5Tset_order(new_type, H5T_ORDER_BE);
- break;
+ case 64:
+ new_type = H5Tcopy(H5T_NATIVE_LLONG);
+ break;
- case 1:
- H5Tset_order(new_type, H5T_ORDER_LE);
- break;
+ default:
+ (void)HDfprintf(stderr, "%s", err2);
+ return (-1);
+ }
+ switch (in->outputByteOrder) {
+ case -1: /* default */
+ break;
+ case 0:
+ H5Tset_order(new_type, H5T_ORDER_BE);
+ break;
- default:
- (void) HDfprintf(stderr, "%s", err3);
- return (-1);
- }
- break;
+ case 1:
+ H5Tset_order(new_type, H5T_ORDER_LE);
+ break;
- case 1: /* STD */
- switch (in->outputSize) {
- case 8:
- switch (in->outputByteOrder) {
- case -1:
- case 0:
- new_type = H5Tcopy(H5T_STD_I8BE);
+ default:
+ (void)HDfprintf(stderr, "%s", err3);
+ return (-1);
+ }
break;
- case 1:
- new_type = H5Tcopy(H5T_STD_I8LE);
- break;
+ case 1: /* STD */
+ switch (in->outputSize) {
+ case 8:
+ switch (in->outputByteOrder) {
+ case -1:
+ case 0:
+ new_type = H5Tcopy(H5T_STD_I8BE);
+ break;
+
+ case 1:
+ new_type = H5Tcopy(H5T_STD_I8LE);
+ break;
+
+ default:
+ (void)HDfprintf(stderr, "%s", err3);
+ return (-1);
+ }
+ break;
- default:
- (void) HDfprintf(stderr, "%s", err3);
- return (-1);
- }
- break;
+ case 16:
+ switch (in->outputByteOrder) {
+ case -1:
+ case 0:
+ new_type = H5Tcopy(H5T_STD_I16BE);
+ break;
- case 16:
- switch (in->outputByteOrder) {
- case -1:
- case 0:
- new_type = H5Tcopy(H5T_STD_I16BE);
- break;
+ case 1:
+ new_type = H5Tcopy(H5T_STD_I16LE);
+ break;
- case 1:
- new_type = H5Tcopy(H5T_STD_I16LE);
- break;
+ default:
+ (void)HDfprintf(stderr, "%s", err3);
+ return (-1);
+ }
+ break;
- default:
- (void) HDfprintf(stderr, "%s", err3);
- return (-1);
- }
- break;
+ case 32:
+ switch (in->outputByteOrder) {
+ case -1:
+ case 0:
+ new_type = H5Tcopy(H5T_STD_I32BE);
+ break;
- case 32:
- switch (in->outputByteOrder) {
- case -1:
- case 0:
- new_type = H5Tcopy(H5T_STD_I32BE);
- break;
+ case 1:
+ new_type = H5Tcopy(H5T_STD_I32LE);
+ break;
- case 1:
- new_type = H5Tcopy(H5T_STD_I32LE);
- break;
+ default:
+ (void)HDfprintf(stderr, "%s", err3);
+ return (-1);
+ }
+ break;
- default:
- (void) HDfprintf(stderr, "%s", err3);
- return (-1);
- }
- break;
+ case 64:
+ switch (in->outputByteOrder) {
+ case -1:
+ case 0:
+ new_type = H5Tcopy(H5T_STD_I64BE);
+ break;
- case 64:
- switch (in->outputByteOrder) {
- case -1:
- case 0:
- new_type = H5Tcopy(H5T_STD_I64BE);
- break;
+ case 1:
+ new_type = H5Tcopy(H5T_STD_I64LE);
+ break;
- case 1:
- new_type = H5Tcopy(H5T_STD_I64LE);
+ default:
+ (void)HDfprintf(stderr, "%s", err3);
+ return (-1);
+ }
+ break;
+
+ default:
+ (void)HDfprintf(stderr, "%s", err2);
+ return (-1);
+ }
break;
default:
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err4);
return (-1);
- }
- break;
-
- default:
- (void) HDfprintf(stderr, "%s", err2);
- return (-1);
}
break;
- default:
- (void) HDfprintf(stderr, "%s", err4);
- return (-1);
- }
- break;
-
- case 1:
- switch (in->outputArchitecture) {
- case 0:
- switch (in->outputSize) {
- case 32:
- new_type = H5Tcopy(H5T_NATIVE_FLOAT);
- break;
-
- case 64:
- new_type = H5Tcopy(H5T_NATIVE_DOUBLE);
- break;
-
- default:
- (void) HDfprintf(stderr, "%s", err2);
- return (-1);
- }
- switch (in->outputByteOrder) {
- case -1: /* DEFAULT */
- break;
- case 0:
- H5Tset_order(new_type, H5T_ORDER_BE);
- break;
+ case 1:
+ switch (in->outputArchitecture) {
+ case 0:
+ switch (in->outputSize) {
+ case 32:
+ new_type = H5Tcopy(H5T_NATIVE_FLOAT);
+ break;
- case 1:
- H5Tset_order(new_type, H5T_ORDER_LE);
- break;
+ case 64:
+ new_type = H5Tcopy(H5T_NATIVE_DOUBLE);
+ break;
- default:
- (void) HDfprintf(stderr, "%s", err3);
- return (-1);
- }
- break;
+ default:
+ (void)HDfprintf(stderr, "%s", err2);
+ return (-1);
+ }
+ switch (in->outputByteOrder) {
+ case -1: /* DEFAULT */
+ break;
+ case 0:
+ H5Tset_order(new_type, H5T_ORDER_BE);
+ break;
- case 1:
- (void) HDfprintf(stderr, "%s", err5);
- return (-1);
+ case 1:
+ H5Tset_order(new_type, H5T_ORDER_LE);
+ break;
- case 2:
- switch (in->outputSize) {
- case 32:
- switch (in->outputByteOrder) {
- case -1:
- case 0:
- new_type = H5Tcopy(H5T_IEEE_F32BE);
+ default:
+ (void)HDfprintf(stderr, "%s", err3);
+ return (-1);
+ }
break;
case 1:
- new_type = H5Tcopy(H5T_IEEE_F32LE);
- break;
-
- default:
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err5);
return (-1);
- }
- break;
- case 64:
- switch (in->outputByteOrder) {
- case -1:
- case 0:
- new_type = H5Tcopy(H5T_IEEE_F64BE);
- break;
+ case 2:
+ switch (in->outputSize) {
+ case 32:
+ switch (in->outputByteOrder) {
+ case -1:
+ case 0:
+ new_type = H5Tcopy(H5T_IEEE_F32BE);
+ break;
+
+ case 1:
+ new_type = H5Tcopy(H5T_IEEE_F32LE);
+ break;
+
+ default:
+ (void)HDfprintf(stderr, "%s", err3);
+ return (-1);
+ }
+ break;
- case 1:
- new_type = H5Tcopy(H5T_IEEE_F64LE);
+ case 64:
+ switch (in->outputByteOrder) {
+ case -1:
+ case 0:
+ new_type = H5Tcopy(H5T_IEEE_F64BE);
+ break;
+
+ case 1:
+ new_type = H5Tcopy(H5T_IEEE_F64LE);
+ break;
+
+ default:
+ (void)HDfprintf(stderr, "%s", err3);
+ return (-1);
+ }
+ break;
+
+ default:
+ (void)HDfprintf(stderr, "%s", err2);
+ return (-1);
+ }
break;
default:
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err4);
return (-1);
- }
- break;
-
- default:
- (void) HDfprintf(stderr, "%s", err2);
- return (-1);
}
break;
- default:
- (void) HDfprintf(stderr, "%s", err4);
- return (-1);
- }
- break;
-
- case 2:
- switch (in->outputArchitecture) {
- case 0:
- switch (in->outputSize) {
- case 8:
- new_type = H5Tcopy(H5T_NATIVE_UCHAR);
- break;
-
- case 16:
- new_type = H5Tcopy(H5T_NATIVE_USHORT);
- break;
+ case 2:
+ switch (in->outputArchitecture) {
+ case 0:
+ switch (in->outputSize) {
+ case 8:
+ new_type = H5Tcopy(H5T_NATIVE_UCHAR);
+ break;
- case 32:
- new_type = H5Tcopy(H5T_NATIVE_UINT);
- break;
+ case 16:
+ new_type = H5Tcopy(H5T_NATIVE_USHORT);
+ break;
- case 64:
- new_type = H5Tcopy(H5T_NATIVE_ULLONG);
- break;
+ case 32:
+ new_type = H5Tcopy(H5T_NATIVE_UINT);
+ break;
- default:
- (void) HDfprintf(stderr, "%s", err2);
- return (-1);
- }
- switch (in->outputByteOrder) {
- case -1: /* Default */
- break;
- case 0:
- H5Tset_order(new_type, H5T_ORDER_BE);
- break;
+ case 64:
+ new_type = H5Tcopy(H5T_NATIVE_ULLONG);
+ break;
- case 1:
- H5Tset_order(new_type, H5T_ORDER_LE);
- break;
+ default:
+ (void)HDfprintf(stderr, "%s", err2);
+ return (-1);
+ }
+ switch (in->outputByteOrder) {
+ case -1: /* Default */
+ break;
+ case 0:
+ H5Tset_order(new_type, H5T_ORDER_BE);
+ break;
- default:
- (void) HDfprintf(stderr, "%s", err3);
- return (-1);
- }
- break;
+ case 1:
+ H5Tset_order(new_type, H5T_ORDER_LE);
+ break;
- case 1:
- switch (in->outputSize) {
- case 8:
- switch (in->outputByteOrder) {
- case -1:
- case 0:
- new_type = H5Tcopy(H5T_STD_U8BE);
+ default:
+ (void)HDfprintf(stderr, "%s", err3);
+ return (-1);
+ }
break;
case 1:
- new_type = H5Tcopy(H5T_STD_U8LE);
- break;
+ switch (in->outputSize) {
+ case 8:
+ switch (in->outputByteOrder) {
+ case -1:
+ case 0:
+ new_type = H5Tcopy(H5T_STD_U8BE);
+ break;
+
+ case 1:
+ new_type = H5Tcopy(H5T_STD_U8LE);
+ break;
+
+ default:
+ (void)HDfprintf(stderr, "%s", err3);
+ return (-1);
+ }
+ break;
- default:
- (void) HDfprintf(stderr, "%s", err3);
- return (-1);
- }
- break;
+ case 16:
+ switch (in->outputByteOrder) {
+ case -1:
+ case 0:
+ new_type = H5Tcopy(H5T_STD_U16BE);
+ break;
- case 16:
- switch (in->outputByteOrder) {
- case -1:
- case 0:
- new_type = H5Tcopy(H5T_STD_U16BE);
- break;
+ case 1:
+ new_type = H5Tcopy(H5T_STD_U16LE);
+ break;
- case 1:
- new_type = H5Tcopy(H5T_STD_U16LE);
- break;
+ default:
+ (void)HDfprintf(stderr, "%s", err3);
+ return (-1);
+ }
+ break;
- default:
- (void) HDfprintf(stderr, "%s", err3);
- return (-1);
- }
- break;
+ case 32:
+ switch (in->outputByteOrder) {
+ case -1:
+ case 0:
+ new_type = H5Tcopy(H5T_STD_U32BE);
+ break;
- case 32:
- switch (in->outputByteOrder) {
- case -1:
- case 0:
- new_type = H5Tcopy(H5T_STD_U32BE);
- break;
+ case 1:
+ new_type = H5Tcopy(H5T_STD_U32LE);
+ break;
- case 1:
- new_type = H5Tcopy(H5T_STD_U32LE);
- break;
+ default:
+ (void)HDfprintf(stderr, "%s", err3);
+ return (-1);
+ }
+ break;
- default:
- (void) HDfprintf(stderr, "%s", err3);
- return (-1);
- }
- break;
+ case 64:
+ switch (in->outputByteOrder) {
+ case -1:
+ case 0:
+ new_type = H5Tcopy(H5T_STD_U64BE);
+ break;
- case 64:
- switch (in->outputByteOrder) {
- case -1:
- case 0:
- new_type = H5Tcopy(H5T_STD_U64BE);
- break;
+ case 1:
+ new_type = H5Tcopy(H5T_STD_U64LE);
+ break;
- case 1:
- new_type = H5Tcopy(H5T_STD_U64LE);
+ default:
+ (void)HDfprintf(stderr, "%s", err3);
+ return (-1);
+ }
+ break;
+
+ default:
+ (void)HDfprintf(stderr, "%s", err2);
+ return (-1);
+ }
break;
- default:
- (void) HDfprintf(stderr, "%s", err3);
+ case 2:
+ (void)HDfprintf(stderr, "%s", err6);
return (-1);
- }
- break;
- default:
- (void) HDfprintf(stderr, "%s", err2);
- return (-1);
+ default:
+ (void)HDfprintf(stderr, "%s", err4);
+ return (-1);
}
break;
- case 2:
- (void) HDfprintf(stderr, "%s", err6);
- return (-1);
-
default:
- (void) HDfprintf(stderr, "%s", err4);
+ (void)HDfprintf(stderr, "%s", err1);
return (-1);
- }
- break;
-
- default:
- (void) HDfprintf(stderr, "%s", err1);
- return (-1);
}
return new_type;
}
-hid_t createInputDataType(struct Input *in)
+hid_t
+createInputDataType(struct Input *in)
{
hid_t new_type = (-1);
- const char *err1 = "Invalid value for input class.\n";
- const char *err2 = "Invalid value for input size.\n";
- const char *err3 = "Invalid value for input byte order.\n";
- const char *err4 = "Invalid value for output architecture.\n";
- const char *err5 = "STD not supported for float.\n";
- const char *err6 = "IEEE not supported for INT.\n";
+ const char *err1 = "Invalid value for input class.\n";
+ const char *err2 = "Invalid value for input size.\n";
+ const char *err3 = "Invalid value for input byte order.\n";
+ const char *err4 = "Invalid value for output architecture.\n";
+ const char *err5 = "STD not supported for float.\n";
+ const char *err6 = "IEEE not supported for INT.\n";
if (in->h5dumpInput) {
switch (in->inputClass) {
- case 4:
- switch (in->inputArchitecture) {
- case 0: /*NATIVE*/
- switch (in->inputSize) {
- case 8:
- new_type = H5Tcopy(H5T_NATIVE_CHAR);
- break;
-
- case 16:
- new_type = H5Tcopy(H5T_NATIVE_SHORT);
- break;
-
- case 32:
- new_type = H5Tcopy(H5T_NATIVE_INT);
- break;
-
- case 64:
- new_type = H5Tcopy(H5T_NATIVE_LLONG);
- break;
+ case 4:
+ switch (in->inputArchitecture) {
+ case 0: /*NATIVE*/
+ switch (in->inputSize) {
+ case 8:
+ new_type = H5Tcopy(H5T_NATIVE_CHAR);
+ break;
+
+ case 16:
+ new_type = H5Tcopy(H5T_NATIVE_SHORT);
+ break;
+
+ case 32:
+ new_type = H5Tcopy(H5T_NATIVE_INT);
+ break;
+
+ case 64:
+ new_type = H5Tcopy(H5T_NATIVE_LLONG);
+ break;
+
+ default:
+ (void)HDfprintf(stderr, "%s", err2);
+ return (-1);
+ }
+ switch (in->inputByteOrder) {
+ case -1: /* default */
+ break;
+ case 0:
+ H5Tset_order(new_type, H5T_ORDER_BE);
+ break;
+
+ case 1:
+ H5Tset_order(new_type, H5T_ORDER_LE);
+ break;
+
+ default:
+ (void)HDfprintf(stderr, "%s", err3);
+ return (-1);
+ }
+ break;
- default:
- (void) HDfprintf(stderr, "%s", err2);
- return (-1);
- }
- switch (in->inputByteOrder) {
- case -1: /* default */
- break;
- case 0:
- H5Tset_order(new_type, H5T_ORDER_BE);
- break;
+ case 1: /*STD*/
+ switch (in->inputSize) {
+ case 8:
+ switch (in->inputByteOrder) {
+ case -1:
+ case 0:
+ new_type = H5Tcopy(H5T_STD_I8BE);
+ break;
+
+ case 1:
+ new_type = H5Tcopy(H5T_STD_I8LE);
+ break;
+
+ default:
+ (void)HDfprintf(stderr, "%s", err3);
+ return (-1);
+ }
+ break;
+
+ case 16:
+ switch (in->inputByteOrder) {
+ case -1:
+ case 0:
+ new_type = H5Tcopy(H5T_STD_I16BE);
+ break;
+
+ case 1:
+ new_type = H5Tcopy(H5T_STD_I16LE);
+ break;
+
+ default:
+ (void)HDfprintf(stderr, "%s", err3);
+ return (-1);
+ }
+ break;
+
+ case 32:
+ switch (in->inputByteOrder) {
+ case -1:
+ case 0:
+ new_type = H5Tcopy(H5T_STD_I32BE);
+ break;
+
+ case 1:
+ new_type = H5Tcopy(H5T_STD_I32LE);
+ break;
+
+ default:
+ (void)HDfprintf(stderr, "%s", err3);
+ return (-1);
+ }
+ break;
+
+ case 64:
+ switch (in->inputByteOrder) {
+ case -1:
+ case 0:
+ new_type = H5Tcopy(H5T_STD_I64BE);
+ break;
+
+ case 1:
+ new_type = H5Tcopy(H5T_STD_I64LE);
+ break;
+
+ default:
+ (void)HDfprintf(stderr, "%s", err3);
+ return (-1);
+ }
+ break;
- case 1:
- H5Tset_order(new_type, H5T_ORDER_LE);
- break;
+ default:
+ (void)HDfprintf(stderr, "%s", err2);
+ return (-1);
+ }
+ break;
- default:
- (void) HDfprintf(stderr, "%s", err3);
- return (-1);
+ default:
+ (void)HDfprintf(stderr, "%s", err4);
+ return (-1);
}
break;
- case 1: /*STD*/
- switch (in->inputSize) {
- case 8:
- switch (in->inputByteOrder) {
- case -1:
+ case 3:
+ switch (in->inputArchitecture) {
case 0:
- new_type = H5Tcopy(H5T_STD_I8BE);
+ switch (in->inputSize) {
+ case 32:
+ new_type = H5Tcopy(H5T_NATIVE_FLOAT);
+ break;
+
+ case 64:
+ new_type = H5Tcopy(H5T_NATIVE_DOUBLE);
+ break;
+
+ default:
+ (void)HDfprintf(stderr, "%s", err2);
+ return (-1);
+ }
+ switch (in->inputByteOrder) {
+ case -1: /* DEFAULT */
+ break;
+ case 0:
+ H5Tset_order(new_type, H5T_ORDER_BE);
+ break;
+
+ case 1:
+ H5Tset_order(new_type, H5T_ORDER_LE);
+ break;
+
+ default:
+ (void)HDfprintf(stderr, "%s", err3);
+ return (-1);
+ }
break;
case 1:
- new_type = H5Tcopy(H5T_STD_I8LE);
- break;
-
- default:
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err5);
return (-1);
- }
- break;
- case 16:
- switch (in->inputByteOrder) {
- case -1:
- case 0:
- new_type = H5Tcopy(H5T_STD_I16BE);
- break;
+ case 2:
+ switch (in->inputSize) {
+ case 32:
+ switch (in->inputByteOrder) {
+ case -1:
+ case 0:
+ new_type = H5Tcopy(H5T_IEEE_F32BE);
+ break;
+
+ case 1:
+ new_type = H5Tcopy(H5T_IEEE_F32LE);
+ break;
+
+ default:
+ (void)HDfprintf(stderr, "%s", err3);
+ return (-1);
+ }
+ break;
+
+ case 64:
+ switch (in->inputByteOrder) {
+ case -1:
+ case 0:
+ new_type = H5Tcopy(H5T_IEEE_F64BE);
+ break;
+
+ case 1:
+ new_type = H5Tcopy(H5T_IEEE_F64LE);
+ break;
+
+ default:
+ (void)HDfprintf(stderr, "%s", err3);
+ return (-1);
+ }
+ break;
- case 1:
- new_type = H5Tcopy(H5T_STD_I16LE);
+ default:
+ (void)HDfprintf(stderr, "%s", err2);
+ return (-1);
+ }
break;
default:
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err4);
return (-1);
- }
- break;
+ }
+ break;
- case 32:
- switch (in->inputByteOrder) {
- case -1:
+ case 7:
+ switch (in->inputArchitecture) {
case 0:
- new_type = H5Tcopy(H5T_STD_I32BE);
+ switch (in->inputSize) {
+ case 8:
+ new_type = H5Tcopy(H5T_NATIVE_UCHAR);
+ break;
+
+ case 16:
+ new_type = H5Tcopy(H5T_NATIVE_USHORT);
+ break;
+
+ case 32:
+ new_type = H5Tcopy(H5T_NATIVE_UINT);
+ break;
+
+ case 64:
+ new_type = H5Tcopy(H5T_NATIVE_ULLONG);
+ break;
+
+ default:
+ (void)HDfprintf(stderr, "%s", err2);
+ return (-1);
+ }
+ switch (in->inputByteOrder) {
+ case -1: /* Default */
+ break;
+ case 0:
+ H5Tset_order(new_type, H5T_ORDER_BE);
+ break;
+
+ case 1:
+ H5Tset_order(new_type, H5T_ORDER_LE);
+ break;
+
+ default:
+ (void)HDfprintf(stderr, "%s", err3);
+ return (-1);
+ }
break;
case 1:
- new_type = H5Tcopy(H5T_STD_I32LE);
- break;
-
- default:
- (void) HDfprintf(stderr, "%s", err3);
- return (-1);
- }
- break;
+ switch (in->inputSize) {
+ case 8:
+ switch (in->inputByteOrder) {
+ case -1:
+ case 0:
+ new_type = H5Tcopy(H5T_STD_U8BE);
+ break;
+
+ case 1:
+ new_type = H5Tcopy(H5T_STD_U8LE);
+ break;
+
+ default:
+ (void)HDfprintf(stderr, "%s", err3);
+ return (-1);
+ }
+ break;
+
+ case 16:
+ switch (in->inputByteOrder) {
+ case -1:
+ case 0:
+ new_type = H5Tcopy(H5T_STD_U16BE);
+ break;
+
+ case 1:
+ new_type = H5Tcopy(H5T_STD_U16LE);
+ break;
+
+ default:
+ (void)HDfprintf(stderr, "%s", err3);
+ return (-1);
+ }
+ break;
+
+ case 32:
+ switch (in->inputByteOrder) {
+ case -1:
+ case 0:
+ new_type = H5Tcopy(H5T_STD_U32BE);
+ break;
+
+ case 1:
+ new_type = H5Tcopy(H5T_STD_U32LE);
+ break;
+
+ default:
+ (void)HDfprintf(stderr, "%s", err3);
+ return (-1);
+ }
+ break;
+
+ case 64:
+ switch (in->inputByteOrder) {
+ case -1:
+ case 0:
+ new_type = H5Tcopy(H5T_STD_U64BE);
+ break;
+
+ case 1:
+ new_type = H5Tcopy(H5T_STD_U64LE);
+ break;
+
+ default:
+ (void)HDfprintf(stderr, "%s", err3);
+ return (-1);
+ }
+ break;
- case 64:
- switch (in->inputByteOrder) {
- case -1:
- case 0:
- new_type = H5Tcopy(H5T_STD_I64BE);
+ default:
+ (void)HDfprintf(stderr, "%s", err2);
+ return (-1);
+ }
break;
- case 1:
- new_type = H5Tcopy(H5T_STD_I64LE);
- break;
+ case 2:
+ (void)HDfprintf(stderr, "%s", err6);
+ return (-1);
default:
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err4);
return (-1);
- }
- break;
-
- default:
- (void) HDfprintf(stderr, "%s", err2);
- return (-1);
}
break;
default:
- (void) HDfprintf(stderr, "%s", err4);
+ (void)HDfprintf(stderr, "%s", err1);
return (-1);
- }
- break;
-
- case 3:
- switch (in->inputArchitecture) {
+ }
+ }
+ else {
+ switch (in->inputClass) {
case 0:
+ case 4:
switch (in->inputSize) {
- case 32:
- new_type = H5Tcopy(H5T_NATIVE_FLOAT);
- break;
-
- case 64:
- new_type = H5Tcopy(H5T_NATIVE_DOUBLE);
- break;
-
- default:
- (void) HDfprintf(stderr, "%s", err2);
- return (-1);
- }
- switch (in->inputByteOrder) {
- case -1: /* DEFAULT */
- break;
- case 0:
- H5Tset_order(new_type, H5T_ORDER_BE);
- break;
-
- case 1:
- H5Tset_order(new_type, H5T_ORDER_LE);
- break;
-
- default:
- (void) HDfprintf(stderr, "%s", err3);
- return (-1);
- }
- break;
-
- case 1:
- (void) HDfprintf(stderr, "%s", err5);
- return (-1);
-
- case 2:
- switch (in->inputSize) {
- case 32:
- switch (in->inputByteOrder) {
- case -1:
- case 0:
- new_type = H5Tcopy(H5T_IEEE_F32BE);
+ case 8:
+ new_type = H5Tcopy(H5T_NATIVE_CHAR);
break;
- case 1:
- new_type = H5Tcopy(H5T_IEEE_F32LE);
+ case 16:
+ new_type = H5Tcopy(H5T_NATIVE_SHORT);
break;
- default:
- (void) HDfprintf(stderr, "%s", err3);
- return (-1);
- }
- break;
-
- case 64:
- switch (in->inputByteOrder) {
- case -1:
- case 0:
- new_type = H5Tcopy(H5T_IEEE_F64BE);
+ case 32:
+ new_type = H5Tcopy(H5T_NATIVE_INT);
break;
- case 1:
- new_type = H5Tcopy(H5T_IEEE_F64LE);
+ case 64:
+ new_type = H5Tcopy(H5T_NATIVE_LLONG);
break;
default:
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
- }
- break;
-
- default:
- (void) HDfprintf(stderr, "%s", err2);
- return (-1);
- }
- break;
-
- default:
- (void) HDfprintf(stderr, "%s", err4);
- return (-1);
- }
- break;
-
- case 7:
- switch (in->inputArchitecture) {
- case 0:
- switch (in->inputSize) {
- case 8:
- new_type = H5Tcopy(H5T_NATIVE_UCHAR);
- break;
-
- case 16:
- new_type = H5Tcopy(H5T_NATIVE_USHORT);
- break;
-
- case 32:
- new_type = H5Tcopy(H5T_NATIVE_UINT);
- break;
-
- case 64:
- new_type = H5Tcopy(H5T_NATIVE_ULLONG);
- break;
-
- default:
- (void) HDfprintf(stderr, "%s", err2);
- return (-1);
- }
- switch (in->inputByteOrder) {
- case -1: /* Default */
- break;
- case 0:
- H5Tset_order(new_type, H5T_ORDER_BE);
- break;
-
- case 1:
- H5Tset_order(new_type, H5T_ORDER_LE);
- break;
-
- default:
- (void) HDfprintf(stderr, "%s", err3);
- return (-1);
}
break;
case 1:
+ case 2:
+ case 3:
switch (in->inputSize) {
- case 8:
- switch (in->inputByteOrder) {
- case -1:
- case 0:
- new_type = H5Tcopy(H5T_STD_U8BE);
+ case 32:
+ new_type = H5Tcopy(H5T_NATIVE_FLOAT);
break;
- case 1:
- new_type = H5Tcopy(H5T_STD_U8LE);
+ case 64:
+ new_type = H5Tcopy(H5T_NATIVE_DOUBLE);
break;
default:
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
- }
- break;
+ }
+ break;
- case 16:
- switch (in->inputByteOrder) {
- case -1:
- case 0:
- new_type = H5Tcopy(H5T_STD_U16BE);
- break;
+ case 5:
+ (void)HDfprintf(stderr, "%s", err1);
+ return (-1);
+ break;
- case 1:
- new_type = H5Tcopy(H5T_STD_U16LE);
+ case 6:
+ case 7:
+ switch (in->inputSize) {
+ case 8:
+ new_type = H5Tcopy(H5T_NATIVE_UCHAR);
break;
- default:
- (void) HDfprintf(stderr, "%s", err3);
- return (-1);
- }
- break;
-
- case 32:
- switch (in->inputByteOrder) {
- case -1:
- case 0:
- new_type = H5Tcopy(H5T_STD_U32BE);
+ case 16:
+ new_type = H5Tcopy(H5T_NATIVE_USHORT);
break;
- case 1:
- new_type = H5Tcopy(H5T_STD_U32LE);
+ case 32:
+ new_type = H5Tcopy(H5T_NATIVE_UINT);
break;
- default:
- (void) HDfprintf(stderr, "%s", err3);
- return (-1);
- }
- break;
-
- case 64:
- switch (in->inputByteOrder) {
- case -1:
- case 0:
- new_type = H5Tcopy(H5T_STD_U64BE);
- break;
-
- case 1:
- new_type = H5Tcopy(H5T_STD_U64LE);
+ case 64:
+ new_type = H5Tcopy(H5T_NATIVE_ULLONG);
break;
default:
- (void) HDfprintf(stderr, "%s", err3);
+ (void)HDfprintf(stderr, "%s", err2);
return (-1);
- }
- break;
-
- default:
- (void) HDfprintf(stderr, "%s", err2);
- return (-1);
}
break;
- case 2:
- (void) HDfprintf(stderr, "%s", err6);
- return (-1);
-
default:
- (void) HDfprintf(stderr, "%s", err4);
+ (void)HDfprintf(stderr, "%s", err1);
return (-1);
- }
- break;
-
- default:
- (void) HDfprintf(stderr, "%s", err1);
- return (-1);
- }
- }
- else {
- switch (in->inputClass) {
- case 0:
- case 4:
- switch (in->inputSize) {
- case 8:
- new_type = H5Tcopy(H5T_NATIVE_CHAR);
- break;
-
- case 16:
- new_type = H5Tcopy(H5T_NATIVE_SHORT);
- break;
-
- case 32:
- new_type = H5Tcopy(H5T_NATIVE_INT);
- break;
-
- case 64:
- new_type = H5Tcopy(H5T_NATIVE_LLONG);
- break;
-
- default:
- (void) HDfprintf(stderr, "%s", err2);
- return (-1);
- }
- break;
-
- case 1:
- case 2:
- case 3:
- switch (in->inputSize) {
- case 32:
- new_type = H5Tcopy(H5T_NATIVE_FLOAT);
- break;
-
- case 64:
- new_type = H5Tcopy(H5T_NATIVE_DOUBLE);
- break;
-
- default:
- (void) HDfprintf(stderr, "%s", err2);
- return (-1);
- }
- break;
-
- case 5:
- (void) HDfprintf(stderr, "%s", err1);
- return (-1);
- break;
-
- case 6:
- case 7:
- switch (in->inputSize) {
- case 8:
- new_type = H5Tcopy(H5T_NATIVE_UCHAR);
- break;
-
- case 16:
- new_type = H5Tcopy(H5T_NATIVE_USHORT);
- break;
-
- case 32:
- new_type = H5Tcopy(H5T_NATIVE_UINT);
- break;
-
- case 64:
- new_type = H5Tcopy(H5T_NATIVE_ULLONG);
- break;
-
- default:
- (void) HDfprintf(stderr, "%s", err2);
- return (-1);
- }
- break;
-
- default:
- (void) HDfprintf(stderr, "%s", err1);
- return (-1);
}
}
return new_type;
}
-static int process(struct Options *opt)
+static int
+process(struct Options *opt)
{
- struct Input *in;
- FILE *extfile;
- hid_t file_id;
- hid_t group_id;
- hid_t handle;
- hid_t dataset;
- hid_t dataspace = (-1);
- hid_t intype;
- hid_t outtype;
- hid_t proplist;
- hsize_t numOfElements = 1;
- int j;
- int k;
+ struct Input *in;
+ FILE * extfile;
+ hid_t file_id;
+ hid_t group_id;
+ hid_t handle;
+ hid_t dataset;
+ hid_t dataspace = (-1);
+ hid_t intype;
+ hid_t outtype;
+ hid_t proplist;
+ hsize_t numOfElements = 1;
+ int j;
+ int k;
const char *err1 = "Error creating HDF output file: %s.\n";
const char *err2 = "Error in processing the configuration file: %s.\n";
const char *err3 = "Error in reading the input file: %s.\n";
const char *err4 = "Error in creating or opening external file.\n";
- const char *err5 = "Error in creating the output data set. Dataset with the same name may exist at the specified path\n";
+ const char *err5 =
+ "Error in creating the output data set. Dataset with the same name may exist at the specified path\n";
const char *err6 = "Error in writing the output data set.\n";
H5E_BEGIN_TRY
{
if ((file_id = H5Fopen(opt->outfile, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) {
if ((file_id = H5Fcreate(opt->outfile, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) == FAIL) {
- (void) HDfprintf(stderr, err1, opt->outfile);
+ (void)HDfprintf(stderr, err1, opt->outfile);
return (-1);
}
}
@@ -4590,13 +4625,13 @@ static int process(struct Options *opt)
in = &(opt->infiles[k].in);
if (opt->infiles[k].config == 1) {
if (processConfigurationFile(opt->infiles[k].configfile, in) == -1) {
- (void) HDfprintf(stderr, err2, opt->infiles[k].configfile);
+ (void)HDfprintf(stderr, err2, opt->infiles[k].configfile);
return (-1);
}
}
if (processDataFile(opt->infiles[k].datafile, in, file_id) == -1) {
- (void) HDfprintf(stderr, err3, opt->infiles[k].datafile);
+ (void)HDfprintf(stderr, err3, opt->infiles[k].datafile);
return (-1);
}
@@ -4609,13 +4644,15 @@ static int process(struct Options *opt)
{
/* create parent groups */
if (in->path.count > 1) {
- j = 0;
+ j = 0;
handle = file_id;
while (j < in->path.count - 1) {
if ((group_id = H5Gopen2(handle, in->path.group[j], H5P_DEFAULT)) < 0) {
- group_id = H5Gcreate2(handle, in->path.group[j++], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ group_id = H5Gcreate2(handle, in->path.group[j++], H5P_DEFAULT, H5P_DEFAULT,
+ H5P_DEFAULT);
for (; j < in->path.count - 1; j++)
- group_id = H5Gcreate2(group_id, in->path.group[j], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ group_id = H5Gcreate2(group_id, in->path.group[j], H5P_DEFAULT, H5P_DEFAULT,
+ H5P_DEFAULT);
handle = group_id;
break;
}
@@ -4625,7 +4662,7 @@ static int process(struct Options *opt)
}
else {
handle = file_id;
- j = 0;
+ j = 0;
}
/*enable error reporting */
@@ -4633,7 +4670,7 @@ static int process(struct Options *opt)
H5E_END_TRY;
/*create data type */
- intype = createInputDataType(in);
+ intype = createInputDataType(in);
outtype = createOutputDataType(in);
#ifdef H5DEBUGIMPORT
HDprintf("process intype %ld outtype %ld\n", intype, outtype);
@@ -4648,20 +4685,21 @@ static int process(struct Options *opt)
}
if (in->configOptionVector[COMPRESS] == 1) {
- H5Pset_deflate(proplist, (unsigned) in->compressionParam);
+ H5Pset_deflate(proplist, (unsigned)in->compressionParam);
}
if (in->configOptionVector[EXTERNALSTORE] == 1) {
- /* creating the external file if it doesnt exist */
+ /* creating the external file if it doesn't exist */
if ((extfile = HDfopen(in->externFilename, "ab")) == NULL) {
- (void) HDfprintf(stderr, "%s", err4);
+ (void)HDfprintf(stderr, "%s", err4);
H5Pclose(proplist);
H5Sclose(dataspace);
H5Fclose(file_id);
return (-1);
}
HDfclose(extfile);
- H5Pset_external(proplist, in->externFilename, (off_t)0, numOfElements * (hsize_t)in->inputSize / 8);
+ H5Pset_external(proplist, in->externFilename, (off_t)0,
+ numOfElements * (hsize_t)in->inputSize / 8);
}
/* create dataspace */
@@ -4674,8 +4712,9 @@ static int process(struct Options *opt)
H5E_BEGIN_TRY
{
/* create data set */
- if ((dataset = H5Dcreate2(handle, in->path.group[j], outtype, dataspace, H5P_DEFAULT, proplist, H5P_DEFAULT)) < 0) {
- (void) HDfprintf(stderr, "%s", err5);
+ if ((dataset = H5Dcreate2(handle, in->path.group[j], outtype, dataspace, H5P_DEFAULT,
+ proplist, H5P_DEFAULT)) < 0) {
+ (void)HDfprintf(stderr, "%s", err5);
H5Pclose(proplist);
H5Sclose(dataspace);
H5Fclose(file_id);
@@ -4687,8 +4726,8 @@ static int process(struct Options *opt)
H5E_END_TRY;
/* write dataset */
- if (H5Dwrite(dataset, intype, H5S_ALL, H5S_ALL, H5P_DEFAULT, (VOIDP) in->data) < 0) {
- (void) HDfprintf(stderr, "%s", err6);
+ if (H5Dwrite(dataset, intype, H5S_ALL, H5S_ALL, H5P_DEFAULT, (VOIDP)in->data) < 0) {
+ (void)HDfprintf(stderr, "%s", err6);
H5Dclose(dataset);
H5Pclose(proplist);
H5Sclose(dataspace);
@@ -4707,36 +4746,44 @@ static int process(struct Options *opt)
return (0);
}
-uint16_t swap_uint16( uint16_t val)
+uint16_t
+swap_uint16(uint16_t val)
{
- return (val << 8) | (val >> 8);
+ return (uint16_t)((val << 8) | (val >> 8));
}
-int16_t swap_int16(int16_t val)
+int16_t
+swap_int16(int16_t val)
{
- return (val << 8) | ((val >> 8) & 0xFF);
+ return (int16_t)((val << 8) | ((val >> 8) & 0xFF));
}
-uint32_t swap_uint32(uint32_t val)
+uint32_t
+swap_uint32(uint32_t val)
{
val = ((val << 8) & 0xFF00FF00) | ((val >> 8) & 0xFF00FF);
return (val << 16) | (val >> 16);
}
-int32_t swap_int32(int32_t val)
+int32_t
+swap_int32(int32_t val)
{
- val = ((val << 8) & 0xFF00FF00) | ((val >> 8) & 0xFF00FF);
+ val = (int32_t)(((uint32_t)(val << 8) & 0xFF00FF00) | ((val >> 8) & 0xFF00FF));
return (val << 16) | ((val >> 16) & 0xFFFF);
}
-int64_t swap_int64(int64_t val)
+int64_t
+swap_int64(int64_t val)
{
- val = ((val << 8) & 0xFF00FF00FF00FF00ULL) | ((val >> 8) & 0x00FF00FF00FF00FFULL);
- val = ((val << 16) & 0xFFFF0000FFFF0000ULL) | ((val >> 16) & 0x0000FFFF0000FFFFULL);
- return (val << 32) | ((val >> 32) & 0xFFFFFFFFULL);
+ val = (int64_t)(((uint64_t)(val << 8) & 0xFF00FF00FF00FF00ULL) |
+ ((uint64_t)(val >> 8) & 0x00FF00FF00FF00FFULL));
+ val = (int64_t)(((uint64_t)(val << 16) & 0xFFFF0000FFFF0000ULL) |
+ ((uint64_t)(val >> 16) & 0x0000FFFF0000FFFFULL));
+ return (int64_t)((uint64_t)(val << 32) | ((uint64_t)(val >> 32) & 0xFFFFFFFFULL));
}
-uint64_t swap_uint64(uint64_t val)
+uint64_t
+swap_uint64(uint64_t val)
{
val = ((val << 8) & 0xFF00FF00FF00FF00ULL) | ((val >> 8) & 0x00FF00FF00FF00FFULL);
val = ((val << 16) & 0xFFFF0000FFFF0000ULL) | ((val >> 16) & 0x0000FFFF0000FFFFULL);
@@ -4751,414 +4798,295 @@ uint64_t swap_uint64(uint64_t val)
* Print a helpful summary of command usage and features.
*/
-void help(char *name)
+void
+help(char *name)
{
- (void) HDfprintf(stdout, "Name:\n\n");
- (void) HDfprintf(stdout, "\t%s\n\n", name);
- (void) HDfprintf(stdout, "\t TOOL NAME:\n");
- (void) HDfprintf(stdout, "\t %s\n", name);
- (void) HDfprintf(stdout, "\t SYNTAX:\n");
- (void) HDfprintf(stdout, "\t %s -h[elp], OR\n", name);
- (void) HDfprintf(stdout,
- "\t %s <infile> -c[onfig] <configfile> [<infile> -c[config] <configfile>...]", name);
- (void) HDfprintf(stdout, "\t\t\t\t -o[utfile] <outfile>\n\n");
- (void) HDfprintf(stdout, "\t PURPOSE:\n");
- (void) HDfprintf(stdout,
- "\t To convert data stored in one or more ASCII or binary files\n");
- (void) HDfprintf(stdout,
- "\t into one or more datasets (in accordance with the \n");
- (void) HDfprintf(stdout,
- "\t user-specified type and storage properties) in an existing \n");
- (void) HDfprintf(stdout, "\t or new HDF5 file.\n\n");
- (void) HDfprintf(stdout, "\t DESCRIPTION:\n");
- (void) HDfprintf(stdout,
- "\t The primary objective of the utility is to convert floating\n");
- (void) HDfprintf(stdout,
- "\t point or integer data stored in ASCII text or binary form \n");
- (void) HDfprintf(stdout,
- "\t into a data-set according to the type and storage properties\n");
- (void) HDfprintf(stdout,
- "\t specified by the user. The utility can also accept ASCII\n");
- (void) HDfprintf(stdout,
- "\t text files and store the contents in a compact form as an\n");
- (void) HDfprintf(stdout, "\t array of one-dimensional strings.\n\n");
- (void) HDfprintf(stdout,
- "\t The input data to be written as a data-set can be provided\n");
- (void) HDfprintf(stdout, "\t to the utility in one of the following forms:\n");
- (void) HDfprintf(stdout,
- "\t 1. ASCII text file with numeric data (floating point or \n");
- (void) HDfprintf(stdout, "\t integer data). \n");
- (void) HDfprintf(stdout,
- "\t 2. Binary file with native floating point data (32-bit or \n");
- (void) HDfprintf(stdout, "\t 64-bit) \n");
- (void) HDfprintf(stdout,
- "\t 3. Binary file with native integer (signed or unsigned)\n");
- (void) HDfprintf(stdout, "\t data (8-bit or 16-bit or 32-bit or 64-bit). \n");
- (void) HDfprintf(stdout,
- "\t 4. ASCII text file containing strings (text data).\n");
- (void) HDfprintf(stdout, "\t \n");
- (void) HDfprintf(stdout,
- "\t Every input file is associated with a configuration file \n");
- (void) HDfprintf(stdout,
- "\t also provided as an input to the utility. (See Section \n");
- (void) HDfprintf(stdout,
- "\t \"CONFIGURATION FILE\" to know how it is to be organized).\n");
- (void) HDfprintf(stdout,
- "\t The class, size and dimensions of the input data is \n");
- (void) HDfprintf(stdout,
- "\t specified in this configuration file. A point to note is\n");
- (void) HDfprintf(stdout,
- "\t that the floating point data in the ASCII text file may be\n");
- (void) HDfprintf(stdout,
- "\t organized in the fixed floating form (for example 323.56)\n");
- (void) HDfprintf(stdout,
- "\t or in a scientific notation (for example 3.23E+02). A \n");
- (void) HDfprintf(stdout,
- "\t different input-class specification is to be used for both\n");
- (void) HDfprintf(stdout, "\t forms.\n\n");
- (void) HDfprintf(stdout,
- "\t The utility extracts the input data from the input file \n");
- (void) HDfprintf(stdout,
- "\t according to the specified parameters and saves it into \n");
- (void) HDfprintf(stdout, "\t an H5 dataset. \n\n");
- (void) HDfprintf(stdout,
- "\t The user can specify output type and storage properties in \n");
- (void) HDfprintf(stdout,
- "\t the configuration file. The user is required to specify the \n");
- (void) HDfprintf(stdout,
- "\t path of the dataset. If the groups in the path leading to \n");
- (void) HDfprintf(stdout,
- "\t the data-set do not exist, the groups will be created by the\n");
- (void) HDfprintf(stdout,
- "\t utility. If no group is specified, the dataset will be\n");
- (void) HDfprintf(stdout, "\t created under the root group.\n\n");
- (void) HDfprintf(stdout,
- "\t In addition to the name, the user is also required to \n");
- (void) HDfprintf(stdout,
- "\t provide the class and size of output data to be written to \n");
- (void) HDfprintf(stdout,
- "\t the dataset and may optionally specify the output-architecture,\n");
- (void) HDfprintf(stdout,
- "\t and the output-byte-order. If output-architecture is not \n");
- (void) HDfprintf(stdout,
- "\t specified the default is NATIVE. Output-byte-orders are fixed\n");
- (void) HDfprintf(stdout,
- "\t for some architectures and may be specified only if output-\n");
- (void) HDfprintf(stdout, "\t architecture is IEEE, UNIX or STD.\n\n");
- (void) HDfprintf(stdout,
- "\t Also, layout and other storage properties such as \n");
- (void) HDfprintf(stdout,
- "\t compression, external storage and extendible data-sets may be\n");
- (void) HDfprintf(stdout,
- "\t optionally specified. The layout and storage properties \n");
- (void) HDfprintf(stdout,
- "\t denote how raw data is to be organized on the disk. If these \n");
- (void) HDfprintf(stdout,
- "\t options are not specified the default is Contiguous layout \n");
- (void) HDfprintf(stdout, "\t and storage.\n\n");
- (void) HDfprintf(stdout,
- "\t The dataset can be organized in any of the following ways:\n");
- (void) HDfprintf(stdout, "\t 1. Contiguous.\n");
- (void) HDfprintf(stdout, "\t 2. Chunked.\n");
- (void) HDfprintf(stdout,
- "\t 3. External Storage File (has to be contiguous)\n");
- (void) HDfprintf(stdout,
- "\t 4. Extendible data sets (has to be chunked)\n");
- (void) HDfprintf(stdout, "\t 5. Compressed. (has to be chunked)\n");
- (void) HDfprintf(stdout,
- "\t 6. Compressed & Extendible (has to be chunked)\n\n");
- (void) HDfprintf(stdout,
- "\t If the user wants to store raw data in a non-HDF file then \n");
- (void) HDfprintf(stdout,
- "\t the external storage file option is to be used and the name \n");
- (void) HDfprintf(stdout, "\t of the file is to be specified. \n\n");
- (void) HDfprintf(stdout,
- "\t If the user wants the dimensions of the data-set to be\n");
- (void) HDfprintf(stdout,
- "\t unlimited, the extendible data set option can be chosen. \n\n");
- (void) HDfprintf(stdout,
- "\t The user may also specify the type of compression and the \n");
- (void) HDfprintf(stdout,
- "\t level to which the data set must be compresses by setting \n");
- (void) HDfprintf(stdout, "\t the compressed option.\n\n");
- (void) HDfprintf(stdout, "\t SYNOPSIS:\n");
- (void) HDfprintf(stdout, "\t h5import -h[elp], OR\n");
- (void) HDfprintf( stdout,
- "\t h5import <infile> -c[onfig] <configfile> \
+ (void)HDfprintf(stdout, "Name:\n\n");
+ (void)HDfprintf(stdout, "\t%s\n\n", name);
+ (void)HDfprintf(stdout, "\t TOOL NAME:\n");
+ (void)HDfprintf(stdout, "\t %s\n", name);
+ (void)HDfprintf(stdout, "\t SYNTAX:\n");
+ (void)HDfprintf(stdout, "\t %s -h[elp], OR\n", name);
+ (void)HDfprintf(stdout, "\t %s <infile> -c[onfig] <configfile> [<infile> -c[config] <configfile>...]",
+ name);
+ (void)HDfprintf(stdout, "\t\t\t\t -o[utfile] <outfile>\n\n");
+ (void)HDfprintf(stdout, "\t PURPOSE:\n");
+ (void)HDfprintf(stdout, "\t To convert data stored in one or more ASCII or binary files\n");
+ (void)HDfprintf(stdout, "\t into one or more datasets (in accordance with the \n");
+ (void)HDfprintf(stdout, "\t user-specified type and storage properties) in an existing \n");
+ (void)HDfprintf(stdout, "\t or new HDF5 file.\n\n");
+ (void)HDfprintf(stdout, "\t DESCRIPTION:\n");
+ (void)HDfprintf(stdout, "\t The primary objective of the utility is to convert floating\n");
+ (void)HDfprintf(stdout, "\t point or integer data stored in ASCII text or binary form \n");
+ (void)HDfprintf(stdout, "\t into a data-set according to the type and storage properties\n");
+ (void)HDfprintf(stdout, "\t specified by the user. The utility can also accept ASCII\n");
+ (void)HDfprintf(stdout, "\t text files and store the contents in a compact form as an\n");
+ (void)HDfprintf(stdout, "\t array of one-dimensional strings.\n\n");
+ (void)HDfprintf(stdout, "\t The input data to be written as a data-set can be provided\n");
+ (void)HDfprintf(stdout, "\t to the utility in one of the following forms:\n");
+ (void)HDfprintf(stdout, "\t 1. ASCII text file with numeric data (floating point or \n");
+ (void)HDfprintf(stdout, "\t integer data). \n");
+ (void)HDfprintf(stdout, "\t 2. Binary file with native floating point data (32-bit or \n");
+ (void)HDfprintf(stdout, "\t 64-bit) \n");
+ (void)HDfprintf(stdout, "\t 3. Binary file with native integer (signed or unsigned)\n");
+ (void)HDfprintf(stdout, "\t data (8-bit or 16-bit or 32-bit or 64-bit). \n");
+ (void)HDfprintf(stdout, "\t 4. ASCII text file containing strings (text data).\n");
+ (void)HDfprintf(stdout, "\t \n");
+ (void)HDfprintf(stdout, "\t Every input file is associated with a configuration file \n");
+ (void)HDfprintf(stdout, "\t also provided as an input to the utility. (See Section \n");
+ (void)HDfprintf(stdout, "\t \"CONFIGURATION FILE\" to know how it is to be organized).\n");
+ (void)HDfprintf(stdout, "\t The class, size and dimensions of the input data is \n");
+ (void)HDfprintf(stdout, "\t specified in this configuration file. A point to note is\n");
+ (void)HDfprintf(stdout, "\t that the floating point data in the ASCII text file may be\n");
+ (void)HDfprintf(stdout, "\t organized in the fixed floating form (for example 323.56)\n");
+ (void)HDfprintf(stdout, "\t or in a scientific notation (for example 3.23E+02). A \n");
+ (void)HDfprintf(stdout, "\t different input-class specification is to be used for both\n");
+ (void)HDfprintf(stdout, "\t forms.\n\n");
+ (void)HDfprintf(stdout, "\t The utility extracts the input data from the input file \n");
+ (void)HDfprintf(stdout, "\t according to the specified parameters and saves it into \n");
+ (void)HDfprintf(stdout, "\t an H5 dataset. \n\n");
+ (void)HDfprintf(stdout, "\t The user can specify output type and storage properties in \n");
+ (void)HDfprintf(stdout, "\t the configuration file. The user is required to specify the \n");
+ (void)HDfprintf(stdout, "\t path of the dataset. If the groups in the path leading to \n");
+ (void)HDfprintf(stdout, "\t the data-set do not exist, the groups will be created by the\n");
+ (void)HDfprintf(stdout, "\t utility. If no group is specified, the dataset will be\n");
+ (void)HDfprintf(stdout, "\t created under the root group.\n\n");
+ (void)HDfprintf(stdout, "\t In addition to the name, the user is also required to \n");
+ (void)HDfprintf(stdout, "\t provide the class and size of output data to be written to \n");
+ (void)HDfprintf(stdout, "\t the dataset and may optionally specify the output-architecture,\n");
+ (void)HDfprintf(stdout, "\t and the output-byte-order. If output-architecture is not \n");
+ (void)HDfprintf(stdout, "\t specified the default is NATIVE. Output-byte-orders are fixed\n");
+ (void)HDfprintf(stdout, "\t for some architectures and may be specified only if output-\n");
+ (void)HDfprintf(stdout, "\t architecture is IEEE, UNIX or STD.\n\n");
+ (void)HDfprintf(stdout, "\t Also, layout and other storage properties such as \n");
+ (void)HDfprintf(stdout, "\t compression, external storage and extendible data-sets may be\n");
+ (void)HDfprintf(stdout, "\t optionally specified. The layout and storage properties \n");
+ (void)HDfprintf(stdout, "\t denote how raw data is to be organized on the disk. If these \n");
+ (void)HDfprintf(stdout, "\t options are not specified the default is Contiguous layout \n");
+ (void)HDfprintf(stdout, "\t and storage.\n\n");
+ (void)HDfprintf(stdout, "\t The dataset can be organized in any of the following ways:\n");
+ (void)HDfprintf(stdout, "\t 1. Contiguous.\n");
+ (void)HDfprintf(stdout, "\t 2. Chunked.\n");
+ (void)HDfprintf(stdout, "\t 3. External Storage File (has to be contiguous)\n");
+ (void)HDfprintf(stdout, "\t 4. Extendible data sets (has to be chunked)\n");
+ (void)HDfprintf(stdout, "\t 5. Compressed. (has to be chunked)\n");
+ (void)HDfprintf(stdout, "\t 6. Compressed & Extendible (has to be chunked)\n\n");
+ (void)HDfprintf(stdout, "\t If the user wants to store raw data in a non-HDF file then \n");
+ (void)HDfprintf(stdout, "\t the external storage file option is to be used and the name \n");
+ (void)HDfprintf(stdout, "\t of the file is to be specified. \n\n");
+ (void)HDfprintf(stdout, "\t If the user wants the dimensions of the data-set to be\n");
+ (void)HDfprintf(stdout, "\t unlimited, the extendible data set option can be chosen. \n\n");
+ (void)HDfprintf(stdout, "\t The user may also specify the type of compression and the \n");
+ (void)HDfprintf(stdout, "\t level to which the data set must be compresses by setting \n");
+ (void)HDfprintf(stdout, "\t the compressed option.\n\n");
+ (void)HDfprintf(stdout, "\t SYNOPSIS:\n");
+ (void)HDfprintf(stdout, "\t h5import -h[elp], OR\n");
+ (void)HDfprintf(stdout, "\t h5import <infile> -c[onfig] <configfile> \
[<infile> -c[config] <confile2>...] -o[utfile] <outfile>\n\n");
- (void) HDfprintf(stdout, "\t -h[elp]:\n");
- (void) HDfprintf(stdout,
- "\t Prints this summary of usage, and exits.\n\n");
- (void) HDfprintf(stdout, "\t <infile(s)>:\n");
- (void) HDfprintf(stdout,
- "\t Name of the Input file(s), containing a \n");
- (void) HDfprintf(stdout,
- "\t single n-dimensional floating point or integer array \n");
- (void) HDfprintf(stdout,
- "\t in either ASCII text, native floating point(32-bit \n");
- (void) HDfprintf(stdout,
- "\t or 64-bit) or native integer(8-bit or 16-bit or \n");
- (void) HDfprintf(stdout,
- "\t 32-bit or 64-bit). Data to be specified in the order\n");
- (void) HDfprintf(stdout, "\t of fastest changing dimensions first.\n\n");
- (void) HDfprintf(stdout, "\t -c[config] <configfile>:\n");
- (void) HDfprintf(stdout,
- "\t Every input file should be associated with a \n");
- (void) HDfprintf(stdout,
- "\t configuration file and this is done by the -c option.\n");
- (void) HDfprintf(stdout,
- "\t <configfile> is the name of the configuration file.\n");
- (void) HDfprintf(stdout, "\t (See Section \"CONFIGURATION FILE\")\n\n");
- (void) HDfprintf(stdout, "\t -o[utfile] <outfile>:\n");
- (void) HDfprintf(stdout,
- "\t Name of the HDF5 output file. Data from one or more \n");
- (void) HDfprintf(stdout,
- "\t input files are stored as one or more data sets in \n");
- (void) HDfprintf(stdout,
- "\t <outfile>. The output file may be an existing file or \n");
- (void) HDfprintf(stdout,
- "\t it maybe new in which case it will be created.\n\n\n");
- (void) HDfprintf(stdout, "\t CONFIGURATION FILE:\n");
- (void) HDfprintf(stdout,
- "\t The configuration file is an ASCII text file and must be \n");
- (void) HDfprintf(stdout,
- "\t the ddl formatted file (without data values) produced by h5dump \n");
- (void) HDfprintf(stdout,
- "\t when used with the options '-o outfilename -b' of a single dataset (-d) \n");
- (void) HDfprintf(stdout,
- "\t OR organized as \"CONFIG-KEYWORD VALUE\" pairs, one pair on each \n");
- (void) HDfprintf(stdout, "\t line.\n\n");
- (void) HDfprintf(stdout,
- "\t The configuration file may have the following keywords each \n");
- (void) HDfprintf(stdout, "\t followed by an acceptable value.\n\n");
- (void) HDfprintf(stdout, "\t Required KEYWORDS:\n");
- (void) HDfprintf(stdout, "\t PATH\n");
- (void) HDfprintf(stdout, "\t INPUT-CLASS\n");
- (void) HDfprintf(stdout, "\t INPUT-SIZE\n");
- (void) HDfprintf(stdout, "\t INPUT-BYTE-ORDER\n");
- (void) HDfprintf(stdout, "\t RANK\n");
- (void) HDfprintf(stdout, "\t DIMENSION-SIZES\n");
- (void) HDfprintf(stdout, "\t OUTPUT-CLASS\n");
- (void) HDfprintf(stdout, "\t OUTPUT-SIZE\n\n");
- (void) HDfprintf(stdout, "\t Optional KEYWORDS:\n");
- (void) HDfprintf(stdout, "\t OUTPUT-ARCHITECTURE\n");
- (void) HDfprintf(stdout, "\t OUTPUT-BYTE-ORDER\n");
- (void) HDfprintf(stdout, "\t CHUNKED-DIMENSION-SIZES\n");
- (void) HDfprintf(stdout, "\t COMPRESSION-TYPE\n");
- (void) HDfprintf(stdout, "\t COMPRESSION-PARAM\n");
- (void) HDfprintf(stdout, "\t EXTERNAL-STORAGE\n");
- (void) HDfprintf(stdout, "\t MAXIMUM-DIMENSIONS\n\n\n");
- (void) HDfprintf(stdout, "\t Values for keywords:\n");
- (void) HDfprintf(stdout, "\t PATH:\n");
- (void) HDfprintf(stdout, "\t Strings separated by spaces to represent\n");
- (void) HDfprintf(stdout, "\t the path of the data-set. If the groups in\n");
- (void) HDfprintf(stdout,
- "\t the path do not exist, they will be created. \n");
- (void) HDfprintf(stdout, "\t For example,\n");
- (void) HDfprintf(stdout, "\t PATH grp1/grp2/dataset1\n");
- (void) HDfprintf(stdout, "\t PATH: keyword\n");
- (void) HDfprintf(stdout, "\t grp1: group under the root. If\n");
- (void) HDfprintf(stdout, "\t non-existent will be created.\n");
- (void) HDfprintf(stdout, "\t grp2: group under grp1. If \n");
- (void) HDfprintf(stdout, "\t non-existent will be created \n");
- (void) HDfprintf(stdout, "\t under grp1.\n");
- (void) HDfprintf(stdout, "\t dataset1: the name of the data-set \n");
- (void) HDfprintf(stdout, "\t to be created.\n\n");
- (void) HDfprintf(stdout, "\t INPUT-CLASS:\n");
- (void) HDfprintf(stdout, "\t String denoting the type of input data.\n");
- (void) HDfprintf(stdout, "\t (\"TEXTIN\", \"TEXTFP\", \"FP\", \"IN\", \n");
- (void) HDfprintf(stdout, "\t \"STR\", \"TEXTUIN\", \"UIN\"). \n");
- (void) HDfprintf(stdout,
- "\t INPUT-CLASS \"TEXTIN\" denotes an ASCII text \n");
- (void) HDfprintf(stdout,
- "\t file with signed integer data in ASCII form,\n");
- (void) HDfprintf(stdout,
- "\t INPUT-CLASS \"TEXTUIN\" denotes an ASCII text \n");
- (void) HDfprintf(stdout,
- "\t file with unsigned integer data in ASCII form,\n");
- (void) HDfprintf(stdout,
- "\t \"TEXTFP\" denotes an ASCII text file containing\n");
- (void) HDfprintf(stdout, "\t floating point data in the fixed notation\n");
- (void) HDfprintf(stdout, "\t (325.34),\n");
- (void) HDfprintf(stdout,
- "\t \"FP\" denotes a floating point binary file,\n");
- (void) HDfprintf(stdout,
- "\t \"IN\" denotes a signed integer binary file,\n");
- (void) HDfprintf(stdout,
- "\t \"UIN\" denotes an unsigned integer binary file,\n");
- (void) HDfprintf(stdout, "\t & \"STR\" denotes an ASCII text file the \n");
- (void) HDfprintf(stdout,
- "\t contents of which should be stored as an 1-D \n");
- (void) HDfprintf(stdout, "\t array of strings.\n");
- (void) HDfprintf(stdout, "\t If INPUT-CLASS is \"STR\", then RANK, \n");
- (void) HDfprintf(stdout,
- "\t DIMENSION-SIZES, OUTPUT-CLASS, OUTPUT-SIZE, \n");
- (void) HDfprintf(stdout, "\t OUTPUT-ARCHITECTURE and OUTPUT-BYTE-ORDER \n");
- (void) HDfprintf(stdout, "\t will be ignored.\n\n\n");
- (void) HDfprintf(stdout, "\t INPUT-SIZE:\n");
- (void) HDfprintf(stdout,
- "\t Integer denoting the size of the input data \n");
- (void) HDfprintf(stdout, "\t (8, 16, 32, 64). \n\n");
- (void) HDfprintf(stdout, "\t For floating point,\n");
- (void) HDfprintf(stdout, "\t INPUT-SIZE can be 32 or 64.\n");
- (void) HDfprintf(stdout, "\t For integers (signed and unsigned)\n");
- (void) HDfprintf(stdout, "\t INPUT-SIZE can be 8, 16, 32 or 64.\n\n");
- (void) HDfprintf(stdout, "\t RANK:\n");
- (void) HDfprintf(stdout,
- "\t Integer denoting the number of dimensions.\n\n");
- (void) HDfprintf(stdout, "\t DIMENSION-SIZES:\n");
- (void) HDfprintf(stdout,
- "\t Integers separated by spaces to denote the \n");
- (void) HDfprintf(stdout, "\t dimension sizes for the no. of dimensions \n");
- (void) HDfprintf(stdout, "\t determined by rank.\n\n");
- (void) HDfprintf(stdout, "\t OUTPUT-CLASS:\n");
- (void) HDfprintf(stdout,
- "\t String dentoting data type of the dataset to \n");
- (void) HDfprintf(stdout, "\t be written (\"IN\",\"FP\", \"UIN\")\n\n");
- (void) HDfprintf(stdout, "\t OUTPUT-SIZE:\n");
- (void) HDfprintf(stdout,
- "\t Integer denoting the size of the data in the \n");
- (void) HDfprintf(stdout, "\t output dataset to be written.\n");
- (void) HDfprintf(stdout,
- "\t If OUTPUT-CLASS is \"FP\", OUTPUT-SIZE can be \n");
- (void) HDfprintf(stdout, "\t 32 or 64.\n");
- (void) HDfprintf(stdout,
- "\t If OUTPUT-CLASS is \"IN\" or \"UIN\", OUTPUT-SIZE\n");
- (void) HDfprintf(stdout, "\t can be 8, 16, 32 or 64.\n\n");
- (void) HDfprintf(stdout, "\t OUTPUT-ARCHITECTURE:\n");
- (void) HDfprintf(stdout, "\t STRING denoting the type of output \n");
- (void) HDfprintf(stdout,
- "\t architecture. Can accept the following values\n");
- (void) HDfprintf(stdout, "\t STD\n");
- (void) HDfprintf(stdout, "\t IEEE\n");
- (void) HDfprintf(stdout, "\t INTEL\n");
- (void) HDfprintf(stdout, "\t CRAY\n");
- (void) HDfprintf(stdout, "\t MIPS\n");
- (void) HDfprintf(stdout, "\t ALPHA\n");
- (void) HDfprintf(stdout, "\t NATIVE (default)\n");
- (void) HDfprintf(stdout, "\t UNIX\n\n");
- (void) HDfprintf(stdout, "\t OUTPUT-BYTE-ORDER:\n");
- (void) HDfprintf(stdout,
- "\t String denoting the output-byte-order. Ignored\n");
- (void) HDfprintf(stdout,
- "\t if the OUTPUT-ARCHITECTURE is not specified or\n");
- (void) HDfprintf(stdout, "\t if it is IEEE, UNIX or STD. Can accept the \n");
- (void) HDfprintf(stdout, "\t following values.\n");
- (void) HDfprintf(stdout, "\t BE (default)\n");
- (void) HDfprintf(stdout, "\t LE\n\n");
- (void) HDfprintf(stdout, "\t CHUNKED-DIMENSION-SIZES:\n");
- (void) HDfprintf(stdout, "\t Integers separated by spaces to denote the \n");
- (void) HDfprintf(stdout,
- "\t dimension sizes of the chunk for the no. of \n");
- (void) HDfprintf(stdout,
- "\t dimensions determined by rank. Required field\n");
- (void) HDfprintf(stdout,
- "\t to denote that the dataset will be stored with\n");
- (void) HDfprintf(stdout,
- "\t chunked storage. If this field is absent the\n");
- (void) HDfprintf(stdout,
- "\t dataset will be stored with contiguous storage.\n\n");
- (void) HDfprintf(stdout, "\t COMPRESSION-TYPE:\n");
- (void) HDfprintf(stdout,
- "\t String denoting the type of compression to be\n");
- (void) HDfprintf(stdout, "\t used with the chunked storage. Requires the\n");
- (void) HDfprintf(stdout,
- "\t CHUNKED-DIMENSION-SIZES to be specified. The only \n");
- (void) HDfprintf(stdout,
- "\t currently supported compression method is GZIP. \n");
- (void) HDfprintf(stdout, "\t Will accept the following value\n");
- (void) HDfprintf(stdout, "\t GZIP\n\n");
- (void) HDfprintf(stdout, "\t COMPRESSION-PARAM:\n");
- (void) HDfprintf(stdout,
- "\t Integer used to denote compression level and \n");
- (void) HDfprintf(stdout, "\t this option is to be always specified when \n");
- (void) HDfprintf(stdout,
- "\t the COMPRESSION-TYPE option is specified. The\n");
- (void) HDfprintf(stdout, "\t values are applicable only to GZIP \n");
- (void) HDfprintf(stdout, "\t compression.\n");
- (void) HDfprintf(stdout, "\t Value 1-9: The level of Compression. \n");
- (void) HDfprintf(stdout, "\t 1 will result in the fastest \n");
- (void) HDfprintf(stdout, "\t compression while 9 will result in \n");
- (void) HDfprintf(stdout, "\t the best compression ratio. The default\n");
- (void) HDfprintf(stdout, "\t level of compression is 6.\n\n");
- (void) HDfprintf(stdout, "\t EXTERNAL-STORAGE:\n");
- (void) HDfprintf(stdout,
- "\t String to denote the name of the non-HDF5 file \n");
- (void) HDfprintf(stdout,
- "\t to store data to. Cannot be used if CHUNKED-\n");
- (void) HDfprintf(stdout,
- "\t DIMENSIONS or COMPRESSION-TYPE or EXTENDIBLE-\n");
- (void) HDfprintf(stdout, "\t DATASET is specified.\n");
- (void) HDfprintf(stdout, "\t Value <external-filename>: the name of the \n");
- (void) HDfprintf(stdout, "\t external file as a string to be used.\n\n");
- (void) HDfprintf(stdout, "\t MAXIMUM-DIMENSIONS:\n");
- (void) HDfprintf(stdout, "\t Integers separated by spaces to denote the \n");
- (void) HDfprintf(stdout, "\t maximum dimension sizes of all the \n");
- (void) HDfprintf(stdout, "\t dimensions determined by rank. Requires the\n");
- (void) HDfprintf(stdout,
- "\t CHUNKED-DIMENSION-SIZES to be specified. A value of \n");
- (void) HDfprintf(stdout, "\t -1 for any dimension implies UNLIMITED \n");
- (void) HDfprintf(stdout,
- "\t DIMENSION size for that particular dimension.\n\n");
- (void) HDfprintf(stdout, "\t EXAMPLES:\n");
- (void) HDfprintf(stdout, "\t 1. Configuration File may look like:\n\n");
- (void) HDfprintf(stdout, "\t PATH work h5 pkamat First-set\n");
- (void) HDfprintf(stdout, "\t INPUT-CLASS TEXTFP\n");
- (void) HDfprintf(stdout, "\t RANK 3\n");
- (void) HDfprintf(stdout, "\t DIMENSION-SIZES 5 2 4\n");
- (void) HDfprintf(stdout, "\t OUTPUT-CLASS FP\n");
- (void) HDfprintf(stdout, "\t OUTPUT-SIZE 64\n");
- (void) HDfprintf(stdout, "\t OUTPUT-ARCHITECTURE IEEE\n");
- (void) HDfprintf(stdout, "\t OUTPUT-BYTE-ORDER LE\n");
- (void) HDfprintf(stdout, "\t CHUNKED-DIMENSION-SIZES 2 2 2 \n\n");
- (void) HDfprintf(stdout,
- "\t The above configuration will accept a floating point array \n");
- (void) HDfprintf(stdout,
- "\t (5 x 2 x 4) in an ASCII file with the rank and dimension sizes \n");
- (void) HDfprintf(stdout,
- "\t specified and will save it in a chunked data-set (of pattern \n");
- (void) HDfprintf(stdout,
- "\t 2 X 2 X 2) of 64-bit floating point in the little-endian order \n");
- (void) HDfprintf(stdout,
- "\t and IEEE architecture. The dataset will be stored at\n");
- (void) HDfprintf(stdout, "\t \"/work/h5/pkamat/First-set\"\n\n");
- (void) HDfprintf(stdout, "\t 2. Another configuration could be:\n\n");
- (void) HDfprintf(stdout, "\t PATH Second-set\n");
- (void) HDfprintf(stdout, "\t INPUT-CLASS IN \n");
- (void) HDfprintf(stdout, "\t RANK 5\n");
- (void) HDfprintf(stdout, "\t DIMENSION-SIZES 6 3 5 2 4\n");
- (void) HDfprintf(stdout, "\t OUTPUT-CLASS IN\n");
- (void) HDfprintf(stdout, "\t OUTPUT-SIZE 32\n");
- (void) HDfprintf(stdout, "\t CHUNKED-DIMENSION-SIZES 2 2 2 2 2\n");
- (void) HDfprintf(stdout, "\t EXTENDIBLE-DATASET 1 3 \n");
- (void) HDfprintf(stdout, "\t COMPRESSION-TYPE GZIP\n");
- (void) HDfprintf(stdout, "\t COMPRESSION-PARAM 7\n\n\n");
- (void) HDfprintf(stdout,
- "\t The above configuration will accept an integer array \n");
- (void) HDfprintf(stdout,
- "\t (6 X 3 X 5 x 2 x 4) in a binary file with the rank and \n");
- (void) HDfprintf(stdout,
- "\t dimension sizes specified and will save it in a chunked data-set\n");
- (void) HDfprintf(stdout,
- "\t (of pattern 2 X 2 X 2 X 2 X 2) of 32-bit floating point in \n");
- (void) HDfprintf(stdout,
- "\t native format (as output-architecture is not specified). The \n");
- (void) HDfprintf(stdout,
- "\t first and the third dimension will be defined as unlimited. The \n");
- (void) HDfprintf(stdout,
- "\t data-set will be compressed using GZIP and a compression level \n");
- (void) HDfprintf(stdout, "\t of 7.\n");
- (void) HDfprintf(stdout,
- "\t The dataset will be stored at \"/Second-set\"\n\n");
- return;
+ (void)HDfprintf(stdout, "\t -h[elp]:\n");
+ (void)HDfprintf(stdout, "\t Prints this summary of usage, and exits.\n\n");
+ (void)HDfprintf(stdout, "\t <infile(s)>:\n");
+ (void)HDfprintf(stdout, "\t Name of the Input file(s), containing a \n");
+ (void)HDfprintf(stdout, "\t single n-dimensional floating point or integer array \n");
+ (void)HDfprintf(stdout, "\t in either ASCII text, native floating point(32-bit \n");
+ (void)HDfprintf(stdout, "\t or 64-bit) or native integer(8-bit or 16-bit or \n");
+ (void)HDfprintf(stdout, "\t 32-bit or 64-bit). Data to be specified in the order\n");
+ (void)HDfprintf(stdout, "\t of fastest changing dimensions first.\n\n");
+ (void)HDfprintf(stdout, "\t -c[config] <configfile>:\n");
+ (void)HDfprintf(stdout, "\t Every input file should be associated with a \n");
+ (void)HDfprintf(stdout, "\t configuration file and this is done by the -c option.\n");
+ (void)HDfprintf(stdout, "\t <configfile> is the name of the configuration file.\n");
+ (void)HDfprintf(stdout, "\t (See Section \"CONFIGURATION FILE\")\n\n");
+ (void)HDfprintf(stdout, "\t -o[utfile] <outfile>:\n");
+ (void)HDfprintf(stdout, "\t Name of the HDF5 output file. Data from one or more \n");
+ (void)HDfprintf(stdout, "\t input files are stored as one or more data sets in \n");
+ (void)HDfprintf(stdout, "\t <outfile>. The output file may be an existing file or \n");
+ (void)HDfprintf(stdout, "\t it maybe new in which case it will be created.\n\n\n");
+ (void)HDfprintf(stdout, "\t CONFIGURATION FILE:\n");
+ (void)HDfprintf(stdout, "\t The configuration file is an ASCII text file and must be \n");
+ (void)HDfprintf(stdout, "\t the ddl formatted file (without data values) produced by h5dump \n");
+ (void)HDfprintf(stdout, "\t when used with the options '-o outfilename -b' of a single dataset (-d) \n");
+ (void)HDfprintf(stdout, "\t OR organized as \"CONFIG-KEYWORD VALUE\" pairs, one pair on each \n");
+ (void)HDfprintf(stdout, "\t line.\n\n");
+ (void)HDfprintf(stdout, "\t The configuration file may have the following keywords each \n");
+ (void)HDfprintf(stdout, "\t followed by an acceptable value.\n\n");
+ (void)HDfprintf(stdout, "\t Required KEYWORDS:\n");
+ (void)HDfprintf(stdout, "\t PATH\n");
+ (void)HDfprintf(stdout, "\t INPUT-CLASS\n");
+ (void)HDfprintf(stdout, "\t INPUT-SIZE\n");
+ (void)HDfprintf(stdout, "\t INPUT-BYTE-ORDER\n");
+ (void)HDfprintf(stdout, "\t RANK\n");
+ (void)HDfprintf(stdout, "\t DIMENSION-SIZES\n");
+ (void)HDfprintf(stdout, "\t OUTPUT-CLASS\n");
+ (void)HDfprintf(stdout, "\t OUTPUT-SIZE\n\n");
+ (void)HDfprintf(stdout, "\t Optional KEYWORDS:\n");
+ (void)HDfprintf(stdout, "\t OUTPUT-ARCHITECTURE\n");
+ (void)HDfprintf(stdout, "\t OUTPUT-BYTE-ORDER\n");
+ (void)HDfprintf(stdout, "\t CHUNKED-DIMENSION-SIZES\n");
+ (void)HDfprintf(stdout, "\t COMPRESSION-TYPE\n");
+ (void)HDfprintf(stdout, "\t COMPRESSION-PARAM\n");
+ (void)HDfprintf(stdout, "\t EXTERNAL-STORAGE\n");
+ (void)HDfprintf(stdout, "\t MAXIMUM-DIMENSIONS\n\n\n");
+ (void)HDfprintf(stdout, "\t Values for keywords:\n");
+ (void)HDfprintf(stdout, "\t PATH:\n");
+ (void)HDfprintf(stdout, "\t Strings separated by spaces to represent\n");
+ (void)HDfprintf(stdout, "\t the path of the data-set. If the groups in\n");
+ (void)HDfprintf(stdout, "\t the path do not exist, they will be created. \n");
+ (void)HDfprintf(stdout, "\t For example,\n");
+ (void)HDfprintf(stdout, "\t PATH grp1/grp2/dataset1\n");
+ (void)HDfprintf(stdout, "\t PATH: keyword\n");
+ (void)HDfprintf(stdout, "\t grp1: group under the root. If\n");
+ (void)HDfprintf(stdout, "\t non-existent will be created.\n");
+ (void)HDfprintf(stdout, "\t grp2: group under grp1. If \n");
+ (void)HDfprintf(stdout, "\t non-existent will be created \n");
+ (void)HDfprintf(stdout, "\t under grp1.\n");
+ (void)HDfprintf(stdout, "\t dataset1: the name of the data-set \n");
+ (void)HDfprintf(stdout, "\t to be created.\n\n");
+ (void)HDfprintf(stdout, "\t INPUT-CLASS:\n");
+ (void)HDfprintf(stdout, "\t String denoting the type of input data.\n");
+ (void)HDfprintf(stdout, "\t (\"TEXTIN\", \"TEXTFP\", \"FP\", \"IN\", \n");
+ (void)HDfprintf(stdout, "\t \"STR\", \"TEXTUIN\", \"UIN\"). \n");
+ (void)HDfprintf(stdout, "\t INPUT-CLASS \"TEXTIN\" denotes an ASCII text \n");
+ (void)HDfprintf(stdout, "\t file with signed integer data in ASCII form,\n");
+ (void)HDfprintf(stdout, "\t INPUT-CLASS \"TEXTUIN\" denotes an ASCII text \n");
+ (void)HDfprintf(stdout, "\t file with unsigned integer data in ASCII form,\n");
+ (void)HDfprintf(stdout, "\t \"TEXTFP\" denotes an ASCII text file containing\n");
+ (void)HDfprintf(stdout, "\t floating point data in the fixed notation\n");
+ (void)HDfprintf(stdout, "\t (325.34),\n");
+ (void)HDfprintf(stdout, "\t \"FP\" denotes a floating point binary file,\n");
+ (void)HDfprintf(stdout, "\t \"IN\" denotes a signed integer binary file,\n");
+ (void)HDfprintf(stdout, "\t \"UIN\" denotes an unsigned integer binary file,\n");
+ (void)HDfprintf(stdout, "\t & \"STR\" denotes an ASCII text file the \n");
+ (void)HDfprintf(stdout, "\t contents of which should be stored as an 1-D \n");
+ (void)HDfprintf(stdout, "\t array of strings.\n");
+ (void)HDfprintf(stdout, "\t If INPUT-CLASS is \"STR\", then RANK, \n");
+ (void)HDfprintf(stdout, "\t DIMENSION-SIZES, OUTPUT-CLASS, OUTPUT-SIZE, \n");
+ (void)HDfprintf(stdout, "\t OUTPUT-ARCHITECTURE and OUTPUT-BYTE-ORDER \n");
+ (void)HDfprintf(stdout, "\t will be ignored.\n\n\n");
+ (void)HDfprintf(stdout, "\t INPUT-SIZE:\n");
+ (void)HDfprintf(stdout, "\t Integer denoting the size of the input data \n");
+ (void)HDfprintf(stdout, "\t (8, 16, 32, 64). \n\n");
+ (void)HDfprintf(stdout, "\t For floating point,\n");
+ (void)HDfprintf(stdout, "\t INPUT-SIZE can be 32 or 64.\n");
+ (void)HDfprintf(stdout, "\t For integers (signed and unsigned)\n");
+ (void)HDfprintf(stdout, "\t INPUT-SIZE can be 8, 16, 32 or 64.\n\n");
+ (void)HDfprintf(stdout, "\t RANK:\n");
+ (void)HDfprintf(stdout, "\t Integer denoting the number of dimensions.\n\n");
+ (void)HDfprintf(stdout, "\t DIMENSION-SIZES:\n");
+ (void)HDfprintf(stdout, "\t Integers separated by spaces to denote the \n");
+ (void)HDfprintf(stdout, "\t dimension sizes for the no. of dimensions \n");
+ (void)HDfprintf(stdout, "\t determined by rank.\n\n");
+ (void)HDfprintf(stdout, "\t OUTPUT-CLASS:\n");
+ (void)HDfprintf(stdout, "\t String dentoting data type of the dataset to \n");
+ (void)HDfprintf(stdout, "\t be written (\"IN\",\"FP\", \"UIN\")\n\n");
+ (void)HDfprintf(stdout, "\t OUTPUT-SIZE:\n");
+ (void)HDfprintf(stdout, "\t Integer denoting the size of the data in the \n");
+ (void)HDfprintf(stdout, "\t output dataset to be written.\n");
+ (void)HDfprintf(stdout, "\t If OUTPUT-CLASS is \"FP\", OUTPUT-SIZE can be \n");
+ (void)HDfprintf(stdout, "\t 32 or 64.\n");
+ (void)HDfprintf(stdout, "\t If OUTPUT-CLASS is \"IN\" or \"UIN\", OUTPUT-SIZE\n");
+ (void)HDfprintf(stdout, "\t can be 8, 16, 32 or 64.\n\n");
+ (void)HDfprintf(stdout, "\t OUTPUT-ARCHITECTURE:\n");
+ (void)HDfprintf(stdout, "\t STRING denoting the type of output \n");
+ (void)HDfprintf(stdout, "\t architecture. Can accept the following values\n");
+ (void)HDfprintf(stdout, "\t STD\n");
+ (void)HDfprintf(stdout, "\t IEEE\n");
+ (void)HDfprintf(stdout, "\t INTEL\n");
+ (void)HDfprintf(stdout, "\t CRAY\n");
+ (void)HDfprintf(stdout, "\t MIPS\n");
+ (void)HDfprintf(stdout, "\t ALPHA\n");
+ (void)HDfprintf(stdout, "\t NATIVE (default)\n");
+ (void)HDfprintf(stdout, "\t UNIX\n\n");
+ (void)HDfprintf(stdout, "\t OUTPUT-BYTE-ORDER:\n");
+ (void)HDfprintf(stdout, "\t String denoting the output-byte-order. Ignored\n");
+ (void)HDfprintf(stdout, "\t if the OUTPUT-ARCHITECTURE is not specified or\n");
+ (void)HDfprintf(stdout, "\t if it is IEEE, UNIX or STD. Can accept the \n");
+ (void)HDfprintf(stdout, "\t following values.\n");
+ (void)HDfprintf(stdout, "\t BE (default)\n");
+ (void)HDfprintf(stdout, "\t LE\n\n");
+ (void)HDfprintf(stdout, "\t CHUNKED-DIMENSION-SIZES:\n");
+ (void)HDfprintf(stdout, "\t Integers separated by spaces to denote the \n");
+ (void)HDfprintf(stdout, "\t dimension sizes of the chunk for the no. of \n");
+ (void)HDfprintf(stdout, "\t dimensions determined by rank. Required field\n");
+ (void)HDfprintf(stdout, "\t to denote that the dataset will be stored with\n");
+ (void)HDfprintf(stdout, "\t chunked storage. If this field is absent the\n");
+ (void)HDfprintf(stdout, "\t dataset will be stored with contiguous storage.\n\n");
+ (void)HDfprintf(stdout, "\t COMPRESSION-TYPE:\n");
+ (void)HDfprintf(stdout, "\t String denoting the type of compression to be\n");
+ (void)HDfprintf(stdout, "\t used with the chunked storage. Requires the\n");
+ (void)HDfprintf(stdout, "\t CHUNKED-DIMENSION-SIZES to be specified. The only \n");
+ (void)HDfprintf(stdout, "\t currently supported compression method is GZIP. \n");
+ (void)HDfprintf(stdout, "\t Will accept the following value\n");
+ (void)HDfprintf(stdout, "\t GZIP\n\n");
+ (void)HDfprintf(stdout, "\t COMPRESSION-PARAM:\n");
+ (void)HDfprintf(stdout, "\t Integer used to denote compression level and \n");
+ (void)HDfprintf(stdout, "\t this option is to be always specified when \n");
+ (void)HDfprintf(stdout, "\t the COMPRESSION-TYPE option is specified. The\n");
+ (void)HDfprintf(stdout, "\t values are applicable only to GZIP \n");
+ (void)HDfprintf(stdout, "\t compression.\n");
+ (void)HDfprintf(stdout, "\t Value 1-9: The level of Compression. \n");
+ (void)HDfprintf(stdout, "\t 1 will result in the fastest \n");
+ (void)HDfprintf(stdout, "\t compression while 9 will result in \n");
+ (void)HDfprintf(stdout, "\t the best compression ratio. The default\n");
+ (void)HDfprintf(stdout, "\t level of compression is 6.\n\n");
+ (void)HDfprintf(stdout, "\t EXTERNAL-STORAGE:\n");
+ (void)HDfprintf(stdout, "\t String to denote the name of the non-HDF5 file \n");
+ (void)HDfprintf(stdout, "\t to store data to. Cannot be used if CHUNKED-\n");
+ (void)HDfprintf(stdout, "\t DIMENSIONS or COMPRESSION-TYPE or EXTENDIBLE-\n");
+ (void)HDfprintf(stdout, "\t DATASET is specified.\n");
+ (void)HDfprintf(stdout, "\t Value <external-filename>: the name of the \n");
+ (void)HDfprintf(stdout, "\t external file as a string to be used.\n\n");
+ (void)HDfprintf(stdout, "\t MAXIMUM-DIMENSIONS:\n");
+ (void)HDfprintf(stdout, "\t Integers separated by spaces to denote the \n");
+ (void)HDfprintf(stdout, "\t maximum dimension sizes of all the \n");
+ (void)HDfprintf(stdout, "\t dimensions determined by rank. Requires the\n");
+ (void)HDfprintf(stdout, "\t CHUNKED-DIMENSION-SIZES to be specified. A value of \n");
+ (void)HDfprintf(stdout, "\t -1 for any dimension implies UNLIMITED \n");
+ (void)HDfprintf(stdout, "\t DIMENSION size for that particular dimension.\n\n");
+ (void)HDfprintf(stdout, "\t EXAMPLES:\n");
+ (void)HDfprintf(stdout, "\t 1. Configuration File may look like:\n\n");
+ (void)HDfprintf(stdout, "\t PATH work h5 pkamat First-set\n");
+ (void)HDfprintf(stdout, "\t INPUT-CLASS TEXTFP\n");
+ (void)HDfprintf(stdout, "\t RANK 3\n");
+ (void)HDfprintf(stdout, "\t DIMENSION-SIZES 5 2 4\n");
+ (void)HDfprintf(stdout, "\t OUTPUT-CLASS FP\n");
+ (void)HDfprintf(stdout, "\t OUTPUT-SIZE 64\n");
+ (void)HDfprintf(stdout, "\t OUTPUT-ARCHITECTURE IEEE\n");
+ (void)HDfprintf(stdout, "\t OUTPUT-BYTE-ORDER LE\n");
+ (void)HDfprintf(stdout, "\t CHUNKED-DIMENSION-SIZES 2 2 2 \n\n");
+ (void)HDfprintf(stdout, "\t The above configuration will accept a floating point array \n");
+ (void)HDfprintf(stdout, "\t (5 x 2 x 4) in an ASCII file with the rank and dimension sizes \n");
+ (void)HDfprintf(stdout, "\t specified and will save it in a chunked data-set (of pattern \n");
+ (void)HDfprintf(stdout, "\t 2 X 2 X 2) of 64-bit floating point in the little-endian order \n");
+ (void)HDfprintf(stdout, "\t and IEEE architecture. The dataset will be stored at\n");
+ (void)HDfprintf(stdout, "\t \"/work/h5/pkamat/First-set\"\n\n");
+ (void)HDfprintf(stdout, "\t 2. Another configuration could be:\n\n");
+ (void)HDfprintf(stdout, "\t PATH Second-set\n");
+ (void)HDfprintf(stdout, "\t INPUT-CLASS IN \n");
+ (void)HDfprintf(stdout, "\t RANK 5\n");
+ (void)HDfprintf(stdout, "\t DIMENSION-SIZES 6 3 5 2 4\n");
+ (void)HDfprintf(stdout, "\t OUTPUT-CLASS IN\n");
+ (void)HDfprintf(stdout, "\t OUTPUT-SIZE 32\n");
+ (void)HDfprintf(stdout, "\t CHUNKED-DIMENSION-SIZES 2 2 2 2 2\n");
+ (void)HDfprintf(stdout, "\t EXTENDIBLE-DATASET 1 3 \n");
+ (void)HDfprintf(stdout, "\t COMPRESSION-TYPE GZIP\n");
+ (void)HDfprintf(stdout, "\t COMPRESSION-PARAM 7\n\n\n");
+ (void)HDfprintf(stdout, "\t The above configuration will accept an integer array \n");
+ (void)HDfprintf(stdout, "\t (6 X 3 X 5 x 2 x 4) in a binary file with the rank and \n");
+ (void)HDfprintf(stdout, "\t dimension sizes specified and will save it in a chunked data-set\n");
+ (void)HDfprintf(stdout, "\t (of pattern 2 X 2 X 2 X 2 X 2) of 32-bit floating point in \n");
+ (void)HDfprintf(stdout, "\t native format (as output-architecture is not specified). The \n");
+ (void)HDfprintf(stdout, "\t first and the third dimension will be defined as unlimited. The \n");
+ (void)HDfprintf(stdout, "\t data-set will be compressed using GZIP and a compression level \n");
+ (void)HDfprintf(stdout, "\t of 7.\n");
+ (void)HDfprintf(stdout, "\t The dataset will be stored at \"/Second-set\"\n\n");
}
-void usage(char *name)
+void
+usage(char *name)
{
- (void) HDfprintf(stdout, "\nUsage:\t%s -h[elp], OR\n", name);
- (void) HDfprintf(stdout,
- "\t%s <infile> -c[onfig] <configfile> \
- [<infile> -c[config] <configfile>...] -o[utfile] <outfile> \n\n", name);
- return;
+ (void)HDfprintf(stdout, "\nUsage:\t%s -h[elp], OR\n", name);
+ (void)HDfprintf(stdout, "\t%s <infile> -c[onfig] <configfile> \
+ [<infile> -c[config] <configfile>...] -o[utfile] <outfile> \n\n",
+ name);
}
-
diff --git a/tools/src/h5import/h5import.h b/tools/src/h5import/h5import.h
index 00c41f6..efd40e1 100644
--- a/tools/src/h5import/h5import.h
+++ b/tools/src/h5import/h5import.h
@@ -6,7 +6,7 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -17,124 +17,117 @@
*
*/
-#ifndef H5IMPORT_H__
-#define H5IMPORT_H__
+#ifndef H5IMPORT_H
+#define H5IMPORT_H
/*
* state table tokens
*/
#define FILNAME 0
/* filename */
-#define OPT_o 1
+#define OPT_o 1
/* output filename */
-#define OPT_c 2 /* configuration filename */
-#define OPT_h 3 /* request for explanation */
-#define OPT_d 4 /* dimensions */
-#define OPT_p 5 /* pathname */
-#define OPT_t 6 /* data type */
-#define OPT_s 7 /* data size */
-#define ERR 20 /* invalid token */
-
-#define MAX_GROUPS_IN_PATH 20
+#define OPT_c 2 /* configuration filename */
+#define OPT_h 3 /* request for explanation */
+#define OPT_d 4 /* dimensions */
+#define OPT_p 5 /* pathname */
+#define OPT_t 6 /* data type */
+#define OPT_s 7 /* data size */
+#define ERR 20 /* invalid token */
+
+#define MAX_GROUPS_IN_PATH 20
#define MAX_PATH_NAME_LENGTH 255
-#define NUM_KEYS 15
-#define MIN_NUM_DIMENSION 1
-#define MAX_NUM_DIMENSION 32
-#define BASE_10 10
-
-#define PATH 0
-#define INPUT_CLASS 1
-#define INPUT_SIZE 2
-#define RANK 3
-#define DIM 4
-#define OUTPUT_CLASS 5
-#define OUTPUT_SIZE 6
-#define OUTPUT_ARCH 7
-#define OUTPUT_B_ORDER 8
-#define CHUNK 9
-#define COMPRESS 10
-#define COMPRESS_PARAM 11
-#define EXTERNALSTORE 12
-#define EXTEND 13
-#define INPUT_B_ORDER 14
+#define NUM_KEYS 15
+#define MIN_NUM_DIMENSION 1
+#define MAX_NUM_DIMENSION 32
+#define BASE_10 10
+
+#define PATH 0
+#define INPUT_CLASS 1
+#define INPUT_SIZE 2
+#define RANK 3
+#define DIM 4
+#define OUTPUT_CLASS 5
+#define OUTPUT_SIZE 6
+#define OUTPUT_ARCH 7
+#define OUTPUT_B_ORDER 8
+#define CHUNK 9
+#define COMPRESS 10
+#define COMPRESS_PARAM 11
+#define EXTERNALSTORE 12
+#define EXTEND 13
+#define INPUT_B_ORDER 14
/* data types */
-#define H5DT_INT8 signed char
-#define H5DT_INT16 short
-#define H5DT_INT32 int
-#define H5DT_FLOAT32 float
-#define H5DT_FLOAT64 double
-#define VOIDP void*
-#define H5DT_UINT8 unsigned char
-#define H5DT_UINT16 unsigned short
-#define H5DT_UINT32 unsigned int
-#define H5DT_INT64 long long
-#define H5DT_UINT64 unsigned H5DT_INT64
-
-struct path_info
-{
+#define H5DT_INT8 signed char
+#define H5DT_INT16 short
+#define H5DT_INT32 int
+#define H5DT_FLOAT32 float
+#define H5DT_FLOAT64 double
+#define VOIDP void *
+#define H5DT_UINT8 unsigned char
+#define H5DT_UINT16 unsigned short
+#define H5DT_UINT32 unsigned int
+#define H5DT_INT64 long long
+#define H5DT_UINT64 unsigned H5DT_INT64
+
+struct path_info {
char group[MAX_GROUPS_IN_PATH][MAX_PATH_NAME_LENGTH];
- int count;
+ int count;
};
-struct Input
-{
- int h5dumpInput;
+struct Input {
+ int h5dumpInput;
struct path_info path;
- int inputClass;
- int inputSize;
- int inputArchitecture;
- int inputByteOrder;
- int rank;
- hsize_t* sizeOfDimension;
- int outputClass;
- int outputSize;
- int outputArchitecture;
- int outputByteOrder;
- hsize_t* sizeOfChunk;
- hsize_t* maxsizeOfDimension;
- int compressionType;
- int compressionParam;
- char *externFilename;
- VOIDP data;
- int configOptionVector[NUM_KEYS];
+ int inputClass;
+ int inputSize;
+ int inputArchitecture;
+ int inputByteOrder;
+ int rank;
+ hsize_t * sizeOfDimension;
+ int outputClass;
+ int outputSize;
+ int outputArchitecture;
+ int outputByteOrder;
+ hsize_t * sizeOfChunk;
+ hsize_t * maxsizeOfDimension;
+ int compressionType;
+ int compressionParam;
+ char * externFilename;
+ VOIDP data;
+ int configOptionVector[NUM_KEYS];
};
-struct infilesformat
-{
- char datafile[MAX_PATH_NAME_LENGTH];
- char configfile[MAX_PATH_NAME_LENGTH];
+struct infilesformat {
+ char datafile[MAX_PATH_NAME_LENGTH];
+ char configfile[MAX_PATH_NAME_LENGTH];
struct Input in;
- int config; /* Configfile present? No - 0. Yes - 1 */
+ int config; /* Configfile present? No - 0. Yes - 1 */
};
-struct Options
-{
- struct infilesformat infiles[30]; /* structure to hold the list of input file names. Limited to 30*/
- char outfile[256]; /* output file name */
- int fcount; /* number of input files */
+struct Options {
+ struct infilesformat infiles[30]; /* structure to hold the list of input file names. Limited to 30*/
+ char outfile[256]; /* output file name */
+ int fcount; /* number of input files */
};
-char keytable[NUM_KEYS][30] = {
- "PATH",
- "INPUT-CLASS",
- "INPUT-SIZE",
- "RANK",
- "DIMENSION-SIZES",
- "OUTPUT-CLASS",
- "OUTPUT-SIZE",
- "OUTPUT-ARCHITECTURE",
- "OUTPUT-BYTE-ORDER",
- "CHUNKED-DIMENSION-SIZES",
- "COMPRESSION-TYPE",
- "COMPRESSION-PARAM",
- "EXTERNAL-STORAGE",
- "MAXIMUM-DIMENSIONS",
- "INPUT-BYTE-ORDER"
-};
-
-static int state_table[15][8] =
-{
+char keytable[NUM_KEYS][30] = {"PATH",
+ "INPUT-CLASS",
+ "INPUT-SIZE",
+ "RANK",
+ "DIMENSION-SIZES",
+ "OUTPUT-CLASS",
+ "OUTPUT-SIZE",
+ "OUTPUT-ARCHITECTURE",
+ "OUTPUT-BYTE-ORDER",
+ "CHUNKED-DIMENSION-SIZES",
+ "COMPRESSION-TYPE",
+ "COMPRESSION-PARAM",
+ "EXTERNAL-STORAGE",
+ "MAXIMUM-DIMENSIONS",
+ "INPUT-BYTE-ORDER"};
+
+static int state_table[15][8] = {
/* token ordering: FILNAME OPT_o OPT_c OPT_h OPT_d OPT_p OPT_t OPT_s */
/* state 0: start */
@@ -189,12 +182,11 @@ static int state_table[15][8] =
* Function declarations for h5import
*
*/
-void usage(char *);
-void setDefaultValues(struct Input *in, int count);
-void help(char *);
-
-hid_t createOutputDataType(struct Input *in);
-hid_t createInputDataType(struct Input *in);
+void usage(char *);
+void setDefaultValues(struct Input *in, int count);
+void help(char *);
-#endif /* H5IMPORT_H__ */
+hid_t createOutputDataType(struct Input *in);
+hid_t createInputDataType(struct Input *in);
+#endif /* H5IMPORT_H */
diff --git a/tools/src/h5jam/CMakeLists.txt b/tools/src/h5jam/CMakeLists.txt
index f430417..0a31215 100644
--- a/tools/src/h5jam/CMakeLists.txt
+++ b/tools/src/h5jam/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.10)
+cmake_minimum_required (VERSION 3.12)
project (HDF5_TOOLS_SRC_H5JAM C)
# --------------------------------------------------------------------
@@ -6,14 +6,14 @@ project (HDF5_TOOLS_SRC_H5JAM C)
# --------------------------------------------------------------------
if (NOT ONLY_SHARED_LIBS)
add_executable (h5jam ${HDF5_TOOLS_SRC_H5JAM_SOURCE_DIR}/h5jam.c)
- target_include_directories (h5jam PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_include_directories (h5jam PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
TARGET_C_PROPERTIES (h5jam STATIC)
target_link_libraries (h5jam PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
set_target_properties (h5jam PROPERTIES FOLDER tools)
set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};h5jam")
add_executable (h5unjam ${HDF5_TOOLS_SRC_H5JAM_SOURCE_DIR}/h5unjam.c)
- target_include_directories (h5unjam PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_include_directories (h5unjam PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
TARGET_C_PROPERTIES (h5unjam STATIC)
target_link_libraries (h5unjam PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
set_target_properties (h5unjam PROPERTIES FOLDER tools)
@@ -27,14 +27,14 @@ endif ()
if (BUILD_SHARED_LIBS)
add_executable (h5jam-shared ${HDF5_TOOLS_SRC_H5JAM_SOURCE_DIR}/h5jam.c)
- target_include_directories (h5jam-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_include_directories (h5jam-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
TARGET_C_PROPERTIES (h5jam-shared SHARED)
target_link_libraries (h5jam-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
set_target_properties (h5jam-shared PROPERTIES FOLDER tools)
set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};h5jam-shared")
add_executable (h5unjam-shared ${HDF5_TOOLS_SRC_H5JAM_SOURCE_DIR}/h5unjam.c)
- target_include_directories (h5unjam-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_include_directories (h5unjam-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
TARGET_C_PROPERTIES (h5unjam-shared SHARED)
target_link_libraries (h5unjam-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
set_target_properties (h5unjam-shared PROPERTIES FOLDER tools)
@@ -46,6 +46,19 @@ if (BUILD_SHARED_LIBS)
)
endif ()
+#-----------------------------------------------------------------------------
+# Add Target to clang-format
+#-----------------------------------------------------------------------------
+if (HDF5_ENABLE_FORMATTERS)
+ if (NOT ONLY_SHARED_LIBS)
+ clang_format (HDF5_H5JAM_SRC_FORMAT h5jam)
+ clang_format (HDF5_H5UNJAM_SRC_FORMAT h5unjam)
+ else ()
+ clang_format (HDF5_H5JAM_SRC_FORMAT h5jam-shared)
+ clang_format (HDF5_H5UNJAM_SRC_FORMAT h5unjam-shared)
+ endif ()
+endif ()
+
##############################################################################
##############################################################################
### I N S T A L L A T I O N ###
diff --git a/tools/src/h5jam/Makefile.am b/tools/src/h5jam/Makefile.am
index 4c44b08..2dd496d 100644
--- a/tools/src/h5jam/Makefile.am
+++ b/tools/src/h5jam/Makefile.am
@@ -6,7 +6,7 @@
# This file is part of HDF5. The full HDF5 copyright notice, including
# terms governing use, modification, and redistribution, is contained in
# the COPYING file, which can be found at the root of the source code
-# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.
+# distribution tree, or in https://www.hdfgroup.org/licenses.
# If you do not have access to either file, you may request a copy from
# help@hdfgroup.org.
##
diff --git a/tools/src/h5jam/h5jam.c b/tools/src/h5jam/h5jam.c
index 8222e06..45978bb 100644
--- a/tools/src/h5jam/h5jam.c
+++ b/tools/src/h5jam/h5jam.c
@@ -6,7 +6,7 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -19,36 +19,25 @@
/* Name of tool */
#define PROGRAMNAME "h5jam"
-herr_t write_pad(int ofile, hsize_t old_where, hsize_t *new_where);
-hsize_t compute_user_block_size (hsize_t);
-hsize_t copy_some_to_file (int, int, hsize_t, hsize_t, ssize_t);
-void parse_command_line (int, const char *[]);
+herr_t write_pad(int ofile, hsize_t old_where, hsize_t *new_where);
+hsize_t compute_user_block_size(hsize_t);
+hsize_t copy_some_to_file(int, int, hsize_t, hsize_t, ssize_t);
+void parse_command_line(int, const char *const *);
-int do_clobber = FALSE;
+int do_clobber = FALSE;
char *output_file = NULL;
-char *input_file = NULL;
-char *ub_file = NULL;
+char *input_file = NULL;
+char *ub_file = NULL;
/*
* Command-line options: The user can specify short or long-named
* parameters. The long-named ones can be partially spelled. When
* adding more, make sure that they don't clash with each other.
*/
-static const char *s_opts = "hi:u:o:c:V"; /* add more later ? */
-static struct long_options l_opts[] = {
- {"help", no_arg, 'h'},
- {"hel", no_arg, 'h'},
- {"i", require_arg, 'i'}, /* input file */
- {"u", require_arg, 'u'}, /* user block file */
- {"o", require_arg, 'o'}, /* output file */
- {"clobber", no_arg, 'c'}, /* clobber existing UB */
- {"clobbe", no_arg, 'c'},
- {"clobb", no_arg, 'c'},
- {"clob", no_arg, 'c'},
- {"clo", no_arg, 'c'},
- {"cl", no_arg, 'c'},
- {NULL, 0, '\0'}
-};
+static const char * s_opts = "hi:u:o:c:V";
+static struct h5_long_options l_opts[] = {{"help", no_arg, 'h'}, {"i", require_arg, 'i'},
+ {"u", require_arg, 'u'}, {"o", require_arg, 'o'},
+ {"clobber", no_arg, 'c'}, {NULL, 0, '\0'}};
/*-------------------------------------------------------------------------
* Function: usage
@@ -59,56 +48,35 @@ static struct long_options l_opts[] = {
*-------------------------------------------------------------------------
*/
static void
-usage (const char *prog)
+usage(const char *prog)
{
- HDfflush (stdout);
- HDfprintf (stdout,
- "usage: %s -i <in_file.h5> -u <in_user_file> [-o <out_file.h5>] [--clobber]\n", prog);
- HDfprintf (stdout, "\n");
- HDfprintf (stdout,
- "Adds user block to front of an HDF5 file and creates a new concatenated file.\n");
- HDfprintf (stdout, "\n");
- HDfprintf (stdout,
- "OPTIONS\n");
- HDfprintf (stdout,
- " -i in_file.h5 Specifies the input HDF5 file.\n");
- HDfprintf (stdout,
- " -u in_user_file Specifies the file to be inserted into the user block.\n");
- HDfprintf (stdout,
- " Can be any file format except an HDF5 format.\n");
- HDfprintf (stdout,
- " -o out_file.h5 Specifies the output HDF5 file.\n");
- HDfprintf (stdout,
- " If not specified, the user block will be concatenated in\n");
- HDfprintf (stdout,
- " place to the input HDF5 file.\n");
- HDfprintf (stdout,
- " --clobber Wipes out any existing user block before concatenating\n");
- HDfprintf (stdout,
- " the given user block.\n");
- HDfprintf (stdout,
- " The size of the new user block will be the larger of;\n");
- HDfprintf (stdout,
- " - the size of existing user block in the input HDF5 file\n");
- HDfprintf (stdout,
- " - the size of user block required by new input user file\n");
- HDfprintf (stdout,
- " (size = 512 x 2N, N is positive integer.)\n");
- HDfprintf (stdout, "\n");
- HDfprintf (stdout,
- " -h Prints a usage message and exits.\n");
- HDfprintf (stdout,
- " -V Prints the HDF5 library version and exits.\n");
- HDfprintf (stdout, "\n");
- HDfprintf (stdout,
- "Exit Status:\n");
- HDfprintf (stdout,
- " 0 Succeeded.\n");
- HDfprintf (stdout,
- " >0 An error occurred.\n");
+ HDfflush(stdout);
+ HDfprintf(stdout, "usage: %s -i <in_file.h5> -u <in_user_file> [-o <out_file.h5>] [--clobber]\n", prog);
+ HDfprintf(stdout, "\n");
+ HDfprintf(stdout, "Adds user block to front of an HDF5 file and creates a new concatenated file.\n");
+ HDfprintf(stdout, "\n");
+ HDfprintf(stdout, "OPTIONS\n");
+ HDfprintf(stdout, " -i in_file.h5 Specifies the input HDF5 file.\n");
+ HDfprintf(stdout, " -u in_user_file Specifies the file to be inserted into the user block.\n");
+ HDfprintf(stdout, " Can be any file format except an HDF5 format.\n");
+ HDfprintf(stdout, " -o out_file.h5 Specifies the output HDF5 file.\n");
+ HDfprintf(stdout, " If not specified, the user block will be concatenated in\n");
+ HDfprintf(stdout, " place to the input HDF5 file.\n");
+ HDfprintf(stdout, " --clobber Wipes out any existing user block before concatenating\n");
+ HDfprintf(stdout, " the given user block.\n");
+ HDfprintf(stdout, " The size of the new user block will be the larger of;\n");
+ HDfprintf(stdout, " - the size of existing user block in the input HDF5 file\n");
+ HDfprintf(stdout, " - the size of user block required by new input user file\n");
+ HDfprintf(stdout, " (size = 512 x 2N, N is positive integer.)\n");
+ HDfprintf(stdout, "\n");
+ HDfprintf(stdout, " -h Prints a usage message and exits.\n");
+ HDfprintf(stdout, " -V Prints the HDF5 library version and exits.\n");
+ HDfprintf(stdout, "\n");
+ HDfprintf(stdout, "Exit Status:\n");
+ HDfprintf(stdout, " 0 Succeeded.\n");
+ HDfprintf(stdout, " >0 An error occurred.\n");
}
-
/*-------------------------------------------------------------------------
* Function: leave
*
@@ -120,13 +88,6 @@ usage (const char *prog)
static void
leave(int ret)
{
- if (ub_file)
- HDfree (ub_file);
- if (input_file)
- HDfree (input_file);
- if (output_file)
- HDfree (output_file);
-
h5tools_close();
HDexit(ret);
@@ -143,40 +104,38 @@ leave(int ret)
*/
void
-parse_command_line (int argc, const char *argv[])
+parse_command_line(int argc, const char *const *argv)
{
- int opt = FALSE;
-
- /* parse command line options */
- while ((opt = get_option (argc, argv, s_opts, l_opts)) != EOF)
- {
- switch ((char) opt)
- {
- case 'o':
- output_file = HDstrdup (opt_arg);
- break;
- case 'i':
- input_file = HDstrdup (opt_arg);
- break;
- case 'u':
- ub_file = HDstrdup (opt_arg);
- break;
- case 'c':
- do_clobber = TRUE;
- break;
- case 'h':
- usage (h5tools_getprogname());
- leave (EXIT_SUCCESS);
- break;
- case 'V':
- print_version (h5tools_getprogname());
- leave (EXIT_SUCCESS);
- break;
- case '?':
- default:
- usage (h5tools_getprogname());
- leave (EXIT_FAILURE);
- }
+ int opt = FALSE;
+
+ /* parse command line options */
+ while ((opt = H5_get_option(argc, argv, s_opts, l_opts)) != EOF) {
+ switch ((char)opt) {
+ case 'o':
+ output_file = HDstrdup(H5_optarg);
+ break;
+ case 'i':
+ input_file = HDstrdup(H5_optarg);
+ break;
+ case 'u':
+ ub_file = HDstrdup(H5_optarg);
+ break;
+ case 'c':
+ do_clobber = TRUE;
+ break;
+ case 'h':
+ usage(h5tools_getprogname());
+ leave(EXIT_SUCCESS);
+ break;
+ case 'V':
+ print_version(h5tools_getprogname());
+ leave(EXIT_SUCCESS);
+ break;
+ case '?':
+ default:
+ usage(h5tools_getprogname());
+ leave(EXIT_FAILURE);
+ }
}
}
@@ -190,44 +149,42 @@ parse_command_line (int argc, const char *argv[])
*-------------------------------------------------------------------------
*/
int
-main (int argc, const char *argv[])
+main(int argc, char *argv[])
{
- int ufid = -1;
- int h5fid = -1;
- int ofid = -1;
- void *edata;
- H5E_auto2_t func;
- hid_t ifile = -1;
- hid_t plist = -1;
- herr_t status;
- htri_t testval;
- hsize_t usize;
- hsize_t h5fsize;
- hsize_t startub;
- hsize_t where;
- hsize_t newubsize;
- off_t fsize;
- h5_stat_t sbuf;
- h5_stat_t sbuf2;
- int res;
+ int ufid = -1;
+ int h5fid = -1;
+ int ofid = -1;
+ hid_t ifile = H5I_INVALID_HID;
+ hid_t plist = H5I_INVALID_HID;
+ herr_t status;
+ htri_t testval;
+ hsize_t usize;
+ hsize_t h5fsize;
+ hsize_t startub;
+ hsize_t where;
+ hsize_t newubsize;
+ off_t fsize;
+ h5_stat_t sbuf;
+ h5_stat_t sbuf2;
+ int res;
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();
- parse_command_line(argc, argv);
+ parse_command_line(argc, (const char *const *)argv);
+
+ /* enable error reporting if command line option */
+ h5tools_error_report();
if (ub_file == NULL) {
/* no user block */
error_msg("missing argument for -u <user_file>.\n");
help_ref_msg(stderr);
- leave (EXIT_FAILURE);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
}
testval = H5Fis_accessible(ub_file, H5P_DEFAULT);
@@ -235,13 +192,15 @@ main (int argc, const char *argv[])
if (testval > 0) {
error_msg("-u <user_file> cannot be HDF5 file, but it appears to be an HDF5 file.\n");
help_ref_msg(stderr);
- leave (EXIT_FAILURE);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
}
if (input_file == NULL) {
error_msg("missing argument for -i <HDF5 file>.\n");
help_ref_msg(stderr);
- leave (EXIT_FAILURE);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
}
testval = H5Fis_accessible(input_file, H5P_DEFAULT);
@@ -249,62 +208,65 @@ main (int argc, const char *argv[])
if (testval <= 0) {
error_msg("Input HDF5 file \"%s\" is not HDF5 format.\n", input_file);
help_ref_msg(stderr);
- leave (EXIT_FAILURE);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
}
ifile = H5Fopen(input_file, H5F_ACC_RDONLY, H5P_DEFAULT);
if (ifile < 0) {
error_msg("Can't open input HDF5 file \"%s\"\n", input_file);
- leave (EXIT_FAILURE);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
}
plist = H5Fget_create_plist(ifile);
if (plist < 0) {
error_msg("Can't get file creation plist for file \"%s\"\n", input_file);
- H5Fclose(ifile);
- leave (EXIT_FAILURE);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
}
status = H5Pget_userblock(plist, &usize);
if (status < 0) {
error_msg("Can't get user block for file \"%s\"\n", input_file);
- H5Pclose(plist);
- H5Fclose(ifile);
- leave (EXIT_FAILURE);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
}
H5Pclose(plist);
+ plist = H5I_INVALID_HID;
H5Fclose(ifile);
+ ifile = H5I_INVALID_HID;
ufid = HDopen(ub_file, O_RDONLY);
- if(ufid < 0) {
+ if (ufid < 0) {
error_msg("unable to open user block file \"%s\"\n", ub_file);
- leave (EXIT_FAILURE);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
}
res = HDfstat(ufid, &sbuf);
- if(res < 0) {
+ if (res < 0) {
error_msg("Can't stat file \"%s\"\n", ub_file);
- HDclose (ufid);
- leave (EXIT_FAILURE);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
}
fsize = (off_t)sbuf.st_size;
h5fid = HDopen(input_file, O_RDONLY);
- if(h5fid < 0) {
+ if (h5fid < 0) {
error_msg("unable to open HDF5 file for read \"%s\"\n", input_file);
- HDclose (ufid);
- leave (EXIT_FAILURE);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
}
res = HDfstat(h5fid, &sbuf2);
- if(res < 0) {
+ if (res < 0) {
error_msg("Can't stat file \"%s\"\n", input_file);
- HDclose (h5fid);
- HDclose (ufid);
- leave (EXIT_FAILURE);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
}
h5fsize = (hsize_t)sbuf2.st_size;
@@ -314,9 +276,8 @@ main (int argc, const char *argv[])
if (ofid < 0) {
error_msg("unable to open output file \"%s\"\n", output_file);
- HDclose (h5fid);
- HDclose (ufid);
- leave (EXIT_FAILURE);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
}
}
else {
@@ -324,13 +285,12 @@ main (int argc, const char *argv[])
if (ofid < 0) {
error_msg("unable to create output file \"%s\"\n", output_file);
- HDclose (h5fid);
- HDclose (ufid);
- leave (EXIT_FAILURE);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
}
}
- newubsize = compute_user_block_size((hsize_t) fsize);
+ newubsize = compute_user_block_size((hsize_t)fsize);
startub = usize;
@@ -340,52 +300,56 @@ main (int argc, const char *argv[])
if (usize > newubsize) {
newubsize = usize;
}
- startub = 0; /*blast the old */
+ startub = 0; /*blast the old */
}
else {
/* add new ub to current ublock, pad to new offset */
newubsize += usize;
- newubsize = compute_user_block_size((hsize_t) newubsize);
+ newubsize = compute_user_block_size((hsize_t)newubsize);
}
}
/* copy the HDF5 from starting at usize to starting at newubsize:
* makes room at 'from' for new ub */
/* if no current ub, usize is 0 */
- copy_some_to_file(h5fid, ofid, usize, newubsize, (ssize_t) (h5fsize - usize));
+ copy_some_to_file(h5fid, ofid, usize, newubsize, (ssize_t)(h5fsize - usize));
/* copy the old ub to the beginning of the new file */
if (!do_clobber) {
- where = copy_some_to_file(h5fid, ofid, (hsize_t) 0, (hsize_t) 0, (ssize_t) usize);
+ where = copy_some_to_file(h5fid, ofid, (hsize_t)0, (hsize_t)0, (ssize_t)usize);
}
/* copy the new ub to the end of the ub */
- where = copy_some_to_file(ufid, ofid, (hsize_t) 0, startub, (ssize_t) - 1);
+ where = copy_some_to_file(ufid, ofid, (hsize_t)0, startub, (ssize_t)-1);
/* pad the ub */
- if(write_pad(ofid, where, &where) < 0) {
+ if (write_pad(ofid, where, &where) < 0) {
error_msg("Can't pad file \"%s\"\n", output_file);
- HDclose (h5fid);
- HDclose (ufid);
- HDclose (ofid);
- leave (EXIT_FAILURE);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
} /* end if */
- if(ub_file)
+done:
+ if (ub_file)
HDfree(ub_file);
- if(input_file)
+ if (input_file)
HDfree(input_file);
- if(output_file)
+ if (output_file)
HDfree(output_file);
- if(ufid >= 0)
+ if (plist >= 0)
+ H5Pclose(plist);
+ if (ifile >= 0)
+ H5Fclose(ifile);
+
+ if (ufid >= 0)
HDclose(ufid);
- if(h5fid >= 0)
+ if (h5fid >= 0)
HDclose(h5fid);
- if(ofid >= 0)
+ if (ofid >= 0)
HDclose(ofid);
- return h5tools_getstatus();
+ leave(h5tools_getstatus());
}
/*-------------------------------------------------------------------------
@@ -394,7 +358,7 @@ main (int argc, const char *argv[])
* Purpose: Copy part of the input file to output.
* infid: fd of file to read
* outfid: fd of file to write
- * startin: offset of where to read from infid
+ * starting: offset of where to read from infid
* startout: offset of where to write to outfid
* limit: bytes to read/write
*
@@ -409,29 +373,28 @@ main (int argc, const char *argv[])
*-------------------------------------------------------------------------
*/
hsize_t
-copy_some_to_file(int infid, int outfid, hsize_t startin, hsize_t startout,
- ssize_t limit)
+copy_some_to_file(int infid, int outfid, hsize_t starting, hsize_t startout, ssize_t limit)
{
- char buf[1024];
+ char buf[1024];
h5_stat_t sbuf;
- int res;
- ssize_t tot = 0;
- ssize_t howmuch = 0;
- ssize_t nchars = -1;
- ssize_t to;
- ssize_t from;
- ssize_t toend;
- ssize_t fromend;
-
- if(startin > startout) {
+ int res;
+ ssize_t tot = 0;
+ ssize_t howmuch = 0;
+ ssize_t nchars = -1;
+ ssize_t to;
+ ssize_t from;
+ ssize_t toend;
+ ssize_t fromend;
+
+ if (starting > startout) {
/* this case is prohibited */
- error_msg("copy_some_to_file: panic: startin > startout?\n");
- exit (EXIT_FAILURE);
+ error_msg("copy_some_to_file: panic: starting > startout?\n");
+ exit(EXIT_FAILURE);
} /* end if */
- if(limit < 0) {
+ if (limit < 0) {
res = HDfstat(infid, &sbuf);
- if(res < 0) {
+ if (res < 0) {
error_msg("Can't stat file \n");
HDexit(EXIT_FAILURE);
} /* end if */
@@ -442,27 +405,27 @@ copy_some_to_file(int infid, int outfid, hsize_t startin, hsize_t startout,
howmuch = limit;
} /* end if */
- if(0 == howmuch)
+ if (0 == howmuch)
return 0;
- toend = (ssize_t) startout + howmuch;
- fromend = (ssize_t) startin + howmuch;
+ toend = (ssize_t)startout + howmuch;
+ fromend = (ssize_t)starting + howmuch;
if (howmuch > 512) {
- to = toend - 512;
+ to = toend - 512;
from = fromend - 512;
}
else {
- to = toend - howmuch;
+ to = toend - howmuch;
from = fromend - howmuch;
} /* end if */
while (howmuch > 0) {
- HDlseek(outfid, (off_t) to, SEEK_SET);
- HDlseek(infid, (off_t) from, SEEK_SET);
+ HDlseek(outfid, (off_t)to, SEEK_SET);
+ HDlseek(infid, (off_t)from, SEEK_SET);
if (howmuch > 512) {
- nchars = HDread(infid, buf, (unsigned) 512);
+ nchars = HDread(infid, buf, (unsigned)512);
}
else {
nchars = HDread(infid, buf, (unsigned)howmuch);
@@ -473,14 +436,14 @@ copy_some_to_file(int infid, int outfid, hsize_t startin, hsize_t startout,
HDexit(EXIT_FAILURE);
} /* end if */
- if(HDwrite (outfid, buf, (unsigned) nchars) < 0) {
+ if (HDwrite(outfid, buf, (unsigned)nchars) < 0) {
error_msg("Write error \n");
HDexit(EXIT_FAILURE);
}
tot += nchars;
howmuch -= nchars;
- if(howmuch > 512) {
+ if (howmuch > 512) {
to -= nchars;
from -= nchars;
}
@@ -488,12 +451,11 @@ copy_some_to_file(int infid, int outfid, hsize_t startin, hsize_t startout,
to -= howmuch;
from -= howmuch;
} /* end if */
- } /* end while */
+ } /* end while */
return (hsize_t)tot + (hsize_t)startout;
} /* end copy_some_to_file() */
-
/*-------------------------------------------------------------------------
* Function: compute_user_block_size
*
@@ -510,10 +472,10 @@ compute_user_block_size(hsize_t ublock_size)
{
hsize_t where = 512;
- if(0 == ublock_size)
+ if (0 == ublock_size)
return 0;
- while(where < ublock_size)
+ while (where < ublock_size)
where *= 2;
return where;
@@ -530,10 +492,10 @@ herr_t
write_pad(int ofile, hsize_t old_where, hsize_t *new_where)
{
unsigned int i;
- char buf[1];
- hsize_t psize;
+ char buf[1];
+ hsize_t psize;
- if(new_where == NULL)
+ if (new_where == NULL)
return FAIL;
buf[0] = '\0';
@@ -543,8 +505,8 @@ write_pad(int ofile, hsize_t old_where, hsize_t *new_where)
psize = compute_user_block_size(old_where);
psize -= old_where;
- for(i = 0; i < psize; i++)
- if(HDwrite(ofile, buf, 1) < 0)
+ for (i = 0; i < psize; i++)
+ if (HDwrite(ofile, buf, 1) < 0)
return FAIL;
/* Set the new size of the file. */
@@ -552,4 +514,3 @@ write_pad(int ofile, hsize_t old_where, hsize_t *new_where)
return SUCCEED;
} /* end write_pad() */
-
diff --git a/tools/src/h5jam/h5unjam.c b/tools/src/h5jam/h5unjam.c
index aa893f9..8ff354e 100644
--- a/tools/src/h5jam/h5unjam.c
+++ b/tools/src/h5jam/h5unjam.c
@@ -6,7 +6,7 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -21,34 +21,24 @@
#define COPY_BUF_SIZE 1024
-hsize_t write_pad( int , hsize_t );
-hsize_t compute_pad( hsize_t );
-herr_t copy_to_file( FILE *, FILE * , ssize_t, ssize_t );
+hsize_t write_pad(int, hsize_t);
+hsize_t compute_pad(hsize_t);
+herr_t copy_to_file(FILE *, FILE *, ssize_t, ssize_t);
-int do_delete = FALSE;
+int do_delete = FALSE;
char *output_file = NULL;
-char *input_file = NULL;
-char *ub_file = NULL;
+char *input_file = NULL;
+char *ub_file = NULL;
/*
* Command-line options: The user can specify short or long-named
* parameters. The long-named ones can be partially spelled. When
* adding more, make sure that they don't clash with each other.
*/
-static const char *s_opts = "hu:i:o:d:V";
-static struct long_options l_opts[] = {
- { "help", no_arg, 'h' },
- { "hel", no_arg, 'h' },
- {"i", require_arg, 'i'}, /* input file */
- {"u", require_arg, 'u'}, /* user block file */
- {"o", require_arg, 'o'}, /* output file */
- {"delete", no_arg, 'd'}, /* delete ub */
- {"delet", no_arg, 'd'},
- {"dele", no_arg, 'd'},
- {"del", no_arg, 'd'},
- {"de", no_arg, 'd'},
- { NULL, 0, '\0' }
-};
+static const char * s_opts = "hu:i:o:d:V";
+static struct h5_long_options l_opts[] = {{"help", no_arg, 'h'}, {"i", require_arg, 'i'},
+ {"u", require_arg, 'u'}, {"o", require_arg, 'o'},
+ {"delete", no_arg, 'd'}, {NULL, 0, '\0'}};
/*-------------------------------------------------------------------------
* Function: usage
@@ -62,55 +52,34 @@ static void
usage(const char *prog)
{
HDfflush(stdout);
- HDfprintf(stdout,
- "usage: %s -i <in_file.h5> [-o <out_file.h5> ] [-u <out_user_file> | --delete]\n", prog);
+ HDfprintf(stdout, "usage: %s -i <in_file.h5> [-o <out_file.h5> ] [-u <out_user_file> | --delete]\n",
+ prog);
HDfprintf(stdout, "\n");
- HDfprintf(stdout,
- "Splits user file and HDF5 file into two files: user block data and HDF5 data.\n");
+ HDfprintf(stdout, "Splits user file and HDF5 file into two files: user block data and HDF5 data.\n");
HDfprintf(stdout, "\n");
- HDfprintf(stdout,
- "OPTIONS\n");
- HDfprintf(stdout,
- " -i in_file.h5 Specifies the HDF5 as input. If the input HDF5 file\n");
- HDfprintf(stdout,
- " contains no user block, exit with an error message.\n");
- HDfprintf(stdout,
- " -o out_file.h5 Specifies output HDF5 file without a user block.\n");
- HDfprintf(stdout,
- " If not specified, the user block will be removed from the\n");
- HDfprintf(stdout,
- " input HDF5 file.\n");
- HDfprintf(stdout,
- " -u out_user_file\n");
- HDfprintf(stdout,
- " Specifies the output file containing the data from the\n");
- HDfprintf(stdout,
- " user block.\n");
- HDfprintf(stdout,
- " Cannot be used with --delete option.\n");
- HDfprintf(stdout,
- " --delete Remove the user block from the input HDF5 file. The content\n");
- HDfprintf(stdout,
- " of the user block is discarded.\n");
- HDfprintf(stdout,
- " Cannot be used with the -u option.\n");
+ HDfprintf(stdout, "OPTIONS\n");
+ HDfprintf(stdout, " -i in_file.h5 Specifies the HDF5 as input. If the input HDF5 file\n");
+ HDfprintf(stdout, " contains no user block, exit with an error message.\n");
+ HDfprintf(stdout, " -o out_file.h5 Specifies output HDF5 file without a user block.\n");
+ HDfprintf(stdout, " If not specified, the user block will be removed from the\n");
+ HDfprintf(stdout, " input HDF5 file.\n");
+ HDfprintf(stdout, " -u out_user_file\n");
+ HDfprintf(stdout, " Specifies the output file containing the data from the\n");
+ HDfprintf(stdout, " user block.\n");
+ HDfprintf(stdout, " Cannot be used with --delete option.\n");
+ HDfprintf(stdout, " --delete Remove the user block from the input HDF5 file. The content\n");
+ HDfprintf(stdout, " of the user block is discarded.\n");
+ HDfprintf(stdout, " Cannot be used with the -u option.\n");
HDfprintf(stdout, "\n");
- HDfprintf(stdout,
- " -h Prints a usage message and exits.\n");
- HDfprintf(stdout,
- " -V Prints the HDF5 library version and exits.\n");
+ HDfprintf(stdout, " -h Prints a usage message and exits.\n");
+ HDfprintf(stdout, " -V Prints the HDF5 library version and exits.\n");
HDfprintf(stdout, "\n");
- HDfprintf(stdout,
- " If neither --delete nor -u is specified, the user block from the input file\n");
- HDfprintf(stdout,
- " will be displayed to stdout.\n");
+ HDfprintf(stdout, " If neither --delete nor -u is specified, the user block from the input file\n");
+ HDfprintf(stdout, " will be displayed to stdout.\n");
HDfprintf(stdout, "\n");
- HDfprintf(stdout,
- "Exit Status:\n");
- HDfprintf(stdout,
- " 0 Succeeded.\n");
- HDfprintf(stdout,
- " >0 An error occurred.\n");
+ HDfprintf(stdout, "Exit Status:\n");
+ HDfprintf(stdout, " 0 Succeeded.\n");
+ HDfprintf(stdout, " >0 An error occurred.\n");
}
/*-------------------------------------------------------------------------
@@ -123,27 +92,28 @@ usage(const char *prog)
*-------------------------------------------------------------------------
*/
static int
-parse_command_line(int argc, const char *argv[])
+parse_command_line(int argc, const char *const *argv)
{
int opt = FALSE;
- /* parse command line options */
- while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) {
- switch((char)opt) {
+ /* parse command line options */
+ while ((opt = H5_get_option(argc, argv, s_opts, l_opts)) != EOF) {
+ switch ((char)opt) {
case 'o':
- output_file = HDstrdup(opt_arg);
+ output_file = HDstrdup(H5_optarg);
if (output_file)
h5tools_set_data_output_file(output_file, 1);
break;
case 'i':
- input_file = HDstrdup(opt_arg);
+ input_file = HDstrdup(H5_optarg);
if (input_file)
h5tools_set_input_file(input_file, 1);
- break;;
+ break;
+ ;
case 'u':
- ub_file = HDstrdup(opt_arg);
+ ub_file = HDstrdup(H5_optarg);
if (ub_file)
h5tools_set_output_file(ub_file, 1);
else
@@ -160,7 +130,7 @@ parse_command_line(int argc, const char *argv[])
goto done;
case 'V':
- print_version (h5tools_getprogname());
+ print_version(h5tools_getprogname());
h5tools_setstatus(EXIT_SUCCESS);
goto done;
@@ -175,16 +145,23 @@ parse_command_line(int argc, const char *argv[])
return EXIT_SUCCESS;
done:
- if(input_file)
+ if (input_file)
HDfree(input_file);
- if(output_file)
+ if (output_file)
HDfree(output_file);
- if(ub_file)
+ if (ub_file)
HDfree(ub_file);
return EXIT_FAILURE;
}
+static void
+leave(int ret)
+{
+ h5tools_close();
+ HDexit(ret);
+}
+
/*-------------------------------------------------------------------------
* Function: main
*
@@ -195,32 +172,29 @@ done:
*-------------------------------------------------------------------------
*/
int
-main(int argc, const char *argv[])
+main(int argc, char *argv[])
{
- void *edata;
- H5E_auto2_t func;
- hid_t ifile = -1;
- hid_t plist = -1;
- off_t fsize;
- hsize_t usize;
- htri_t testval;
- herr_t status;
- int res;
- h5_stat_t sbuf;
+ hid_t ifile = H5I_INVALID_HID;
+ hid_t plist = H5I_INVALID_HID;
+ off_t fsize;
+ hsize_t usize;
+ htri_t testval;
+ herr_t status;
+ int res;
+ h5_stat_t sbuf;
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();
- if(EXIT_FAILURE == parse_command_line(argc, argv))
+ if (EXIT_FAILURE == parse_command_line(argc, (const char *const *)argv))
goto done;
+ /* enable error reporting if command line option */
+ h5tools_error_report();
+
if (input_file == NULL) {
/* no user block */
error_msg("missing argument for HDF5 file input.\n");
@@ -233,12 +207,12 @@ main(int argc, const char *argv[])
if (testval <= 0) {
error_msg("Input HDF5 file \"%s\" is not HDF\n", input_file);
- help_ref_msg (stderr);
+ help_ref_msg(stderr);
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
- ifile = H5Fopen(input_file, H5F_ACC_RDONLY , H5P_DEFAULT);
+ ifile = H5Fopen(input_file, H5F_ACC_RDONLY, H5P_DEFAULT);
if (ifile < 0) {
error_msg("Can't open input HDF5 file \"%s\"\n", input_file);
@@ -253,7 +227,7 @@ main(int argc, const char *argv[])
goto done;
}
- status = H5Pget_userblock(plist, & usize);
+ status = H5Pget_userblock(plist, &usize);
if (status < 0) {
error_msg("Can't get user block for file \"%s\"\n", input_file);
h5tools_setstatus(EXIT_FAILURE);
@@ -264,14 +238,14 @@ main(int argc, const char *argv[])
H5Fclose(ifile);
if (usize == 0) {
- /* no user block to remove: message? */
+ /* no user block to remove: message? */
error_msg("\"%s\" has no user block: no change to file\n", input_file);
h5tools_setstatus(EXIT_SUCCESS);
goto done;
}
res = HDfstat(HDfileno(rawinstream), &sbuf);
- if(res < 0) {
+ if (res < 0) {
error_msg("Can't stat file \"%s\"\n", input_file);
h5tools_setstatus(EXIT_FAILURE);
goto done;
@@ -286,14 +260,14 @@ main(int argc, const char *argv[])
}
if (output_file == NULL) {
- error_msg("unable to open output HDF5 file \"%s\"\n", input_file);
- h5tools_setstatus(EXIT_FAILURE);
- goto done;
+ error_msg("unable to open output HDF5 file \"%s\"\n", input_file);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
}
/* copy from 0 to 'usize - 1' into ufid */
if (!do_delete) {
- if(copy_to_file(rawinstream, rawoutstream, 0, (ssize_t) usize) < 0) {
+ if (copy_to_file(rawinstream, rawoutstream, 0, (ssize_t)usize) < 0) {
error_msg("unable to copy user block to output file \"%s\"\n", ub_file);
h5tools_setstatus(EXIT_FAILURE);
goto done;
@@ -302,26 +276,24 @@ main(int argc, const char *argv[])
/* copy from usize to end of file into h5fid,
* starting at end of user block if present */
- if(copy_to_file(rawinstream, rawdatastream, (ssize_t) usize, (ssize_t)(fsize - (ssize_t)usize)) < 0) {
+ if (copy_to_file(rawinstream, rawdatastream, (ssize_t)usize, (ssize_t)(fsize - (ssize_t)usize)) < 0) {
error_msg("unable to copy hdf5 data to output file \"%s\"\n", output_file);
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
done:
- if(input_file)
+ if (input_file)
HDfree(input_file);
- if(output_file)
+ if (output_file)
HDfree(output_file);
- if(ub_file) {
+ if (ub_file) {
HDfree(ub_file);
}
- h5tools_close();
-
- return h5tools_getstatus();
+ leave(h5tools_getstatus());
}
/*-------------------------------------------------------------------------
@@ -332,17 +304,17 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-copy_to_file( FILE *infid, FILE *ofid, ssize_t _where, ssize_t show_much )
+copy_to_file(FILE *infid, FILE *ofid, ssize_t _where, ssize_t show_much)
{
static char buf[COPY_BUF_SIZE];
- size_t how_much;
- off_t where = (off_t)_where;
- off_t to;
- off_t from;
- herr_t ret_value = 0;
+ size_t how_much;
+ off_t where = (off_t)_where;
+ off_t to;
+ off_t from;
+ herr_t ret_value = 0;
/* nothing to copy */
- if(show_much <= 0)
+ if (show_much <= 0)
goto done;
how_much = (size_t)show_much;
@@ -350,27 +322,27 @@ copy_to_file( FILE *infid, FILE *ofid, ssize_t _where, ssize_t show_much )
HDfseek(infid, 0L, 0);
from = where;
- to = 0;
- while(how_much > 0) {
- size_t bytes_in = 0; /* # of bytes to read */
- size_t bytes_read = 0; /* # of bytes actually read */
- size_t bytes_wrote = 0; /* # of bytes written */
+ to = 0;
+ while (how_much > 0) {
+ size_t bytes_in = 0; /* # of bytes to read */
+ size_t bytes_read = 0; /* # of bytes actually read */
+ size_t bytes_wrote = 0; /* # of bytes written */
if (how_much > COPY_BUF_SIZE)
bytes_in = COPY_BUF_SIZE;
else
bytes_in = how_much;
- /* Seek to correct position in input file */
+ /* Seek to correct position in input file */
HDfseek(infid, from, SEEK_SET);
/* Read data to buffer */
bytes_read = HDfread(buf, (size_t)1, bytes_in, infid);
- if(0 == bytes_read && HDferror(infid)) {
+ if (0 == bytes_read && HDferror(infid)) {
ret_value = -1;
goto done;
} /* end if */
- if(0 == bytes_read && HDfeof(infid)) {
+ if (0 == bytes_read && HDfeof(infid)) {
goto done;
} /* end if */
@@ -382,15 +354,14 @@ copy_to_file( FILE *infid, FILE *ofid, ssize_t _where, ssize_t show_much )
from += (off_t)bytes_read;
to += (off_t)bytes_read;
- /* Write nchars bytes to output file */
+ /* Write nchars bytes to output file */
bytes_wrote = HDfwrite(buf, (size_t)1, bytes_read, ofid);
- if(bytes_wrote != bytes_read || (0 == bytes_wrote && HDferror(ofid))) { /* error */
+ if (bytes_wrote != bytes_read || (0 == bytes_wrote && HDferror(ofid))) { /* error */
ret_value = -1;
goto done;
} /* end if */
- } /* end while */
+ } /* end while */
done:
return ret_value;
-} /* end copy_to_file */
-
+} /* end copy_to_file */
diff --git a/tools/src/h5ls/CMakeLists.txt b/tools/src/h5ls/CMakeLists.txt
index f2470fb..80b9b0c 100644
--- a/tools/src/h5ls/CMakeLists.txt
+++ b/tools/src/h5ls/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.10)
+cmake_minimum_required (VERSION 3.12)
project (HDF5_TOOLS_SRC_H5LS C)
#-----------------------------------------------------------------------------
@@ -6,7 +6,9 @@ project (HDF5_TOOLS_SRC_H5LS C)
#-----------------------------------------------------------------------------
if (NOT ONLY_SHARED_LIBS)
add_executable (h5ls ${HDF5_TOOLS_SRC_H5LS_SOURCE_DIR}/h5ls.c)
- target_include_directories (h5ls PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_include_directories (h5ls PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5ls PRIVATE "${HDF5_CMAKE_C_FLAGS}")
+ #target_compile_definitions(h5ls PRIVATE H5_TOOLS_DEBUG)
TARGET_C_PROPERTIES (h5ls STATIC)
target_link_libraries (h5ls PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
set_target_properties (h5ls PROPERTIES FOLDER tools)
@@ -17,7 +19,9 @@ endif ()
if (BUILD_SHARED_LIBS)
add_executable (h5ls-shared ${HDF5_TOOLS_SRC_H5LS_SOURCE_DIR}/h5ls.c)
- target_include_directories (h5ls-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_include_directories (h5ls-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5ls-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}")
+ #target_compile_definitions(h5ls-shared PRIVATE H5_TOOLS_DEBUG)
TARGET_C_PROPERTIES (h5ls-shared SHARED)
target_link_libraries (h5ls-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
set_target_properties (h5ls-shared PROPERTIES FOLDER tools)
@@ -26,6 +30,17 @@ if (BUILD_SHARED_LIBS)
set (H5_DEP_EXECUTABLES ${H5_DEP_EXECUTABLES} h5ls-shared)
endif ()
+#-----------------------------------------------------------------------------
+# Add Target to clang-format
+#-----------------------------------------------------------------------------
+if (HDF5_ENABLE_FORMATTERS)
+ if (NOT ONLY_SHARED_LIBS)
+ clang_format (HDF5_H5LS_SRC_FORMAT h5ls)
+ else ()
+ clang_format (HDF5_H5LS_SRC_FORMAT h5ls-shared)
+ endif ()
+endif ()
+
##############################################################################
##############################################################################
### I N S T A L L A T I O N ###
diff --git a/tools/src/h5ls/Makefile.am b/tools/src/h5ls/Makefile.am
index 07279c1..9a4466d 100644
--- a/tools/src/h5ls/Makefile.am
+++ b/tools/src/h5ls/Makefile.am
@@ -6,7 +6,7 @@
# This file is part of HDF5. The full HDF5 copyright notice, including
# terms governing use, modification, and redistribution, is contained in
# the COPYING file, which can be found at the root of the source code
-# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.
+# distribution tree, or in https://www.hdfgroup.org/licenses.
# If you do not have access to either file, you may request a copy from
# help@hdfgroup.org.
##
diff --git a/tools/src/h5ls/h5ls.c b/tools/src/h5ls/h5ls.c
index 20a68e8..c30c08f 100644
--- a/tools/src/h5ls/h5ls.c
+++ b/tools/src/h5ls/h5ls.c
@@ -6,17 +6,16 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Programmer: Robb Matzke <matzke@llnl.gov>
+ * Programmer: Robb Matzke
* Monday, March 23, 1998
*/
-
/*
* We include the private header file so we can get to the uniform
* programming environment it declares. Other than that, h5ls only calls
@@ -31,112 +30,112 @@
/* Name of tool */
#define PROGRAMNAME "h5ls"
-#define NAME_BUF_SIZE 2048
+#define NAME_BUF_SIZE 2048
/*
- * Alternative formating for data dumped by H5LS
+ * Alternative formatting for data dumped by H5LS
*
* This table only affects H5LS output.
*/
-static h5tool_format_t ls_dataformat = {
- 0, /*raw */
-
- "", /*fmt_raw */
- "%d", /*fmt_int */
- "%u", /*fmt_uint */
- "%hhd", /*fmt_schar */
- "%u", /*fmt_uchar */
- "%d", /*fmt_short */
- "%u", /*fmt_ushort */
- "%ld", /*fmt_long */
- "%lu", /*fmt_ulong */
- NULL, /*fmt_llong */
- NULL, /*fmt_ullong */
- "%g", /*fmt_double */
- "%g", /*fmt_float */
-
- 0, /*ascii */
- 0, /*str_locale */
- 0, /*str_repeat */
-
- "[", /*arr_pre */
- ",", /*arr_sep */
- "]", /*arr_suf */
- 1, /*arr_linebreak */
-
- "", /*cmpd_name */
- ",", /*cmpd_sep */
- "{", /*cmpd_pre */
- "}", /*cmpd_suf */
- "", /*cmpd_end */
- NULL, /* cmpd_listv */
-
- ",", /*vlen_sep */
- "(", /*vlen_pre */
- ")", /*vlen_suf */
- "", /*vlen_end */
-
- "%s", /*elmt_fmt */
- ",", /*elmt_suf1 */
- " ", /*elmt_suf2 */
-
- HSIZE_T_FORMAT, /*idx_n_fmt */
- ",", /*idx_sep */
- "(%s)", /*idx_fmt */
-
- 65535, /*line_ncols *//*standard default columns */
- 0, /*line_per_line */
- "", /*line_pre */
- "%s", /*line_1st */
- "%s", /*line_cont */
- "", /*line_suf */
- "", /*line_sep */
- 1, /*line_multi_new */
- "", /*line_indent */
-
- 0, /*skip_first */
-
- 0, /*obj_hidefileno */
- "-%lu:"H5_PRINTF_HADDR_FMT, /*obj_format */
-
- 0, /*dset_hidefileno */
- "DSET-%s ", /*dset_format */
- "%sBlk%lu: ", /*dset_blockformat_pre */
- "%sPt%lu: ", /*dset_ptformat_pre */
- "%s", /*dset_ptformat */
- 1, /*array indices */
- 1 /*escape non printable characters */
+static h5tool_format_t ls_dataformat = {
+ 0, /*raw */
+
+ "", /*fmt_raw */
+ "%d", /*fmt_int */
+ "%u", /*fmt_uint */
+ "%hhd", /*fmt_schar */
+ "%u", /*fmt_uchar */
+ "%d", /*fmt_short */
+ "%u", /*fmt_ushort */
+ "%ld", /*fmt_long */
+ "%lu", /*fmt_ulong */
+ NULL, /*fmt_llong */
+ NULL, /*fmt_ullong */
+ "%g", /*fmt_double */
+ "%g", /*fmt_float */
+
+ 0, /*ascii */
+ 0, /*str_locale */
+ 0, /*str_repeat */
+
+ "[", /*arr_pre */
+ ",", /*arr_sep */
+ "]", /*arr_suf */
+ 1, /*arr_linebreak */
+
+ "", /*cmpd_name */
+ ",", /*cmpd_sep */
+ "{", /*cmpd_pre */
+ "}", /*cmpd_suf */
+ "", /*cmpd_end */
+ NULL, /* cmpd_listv */
+
+ ",", /*vlen_sep */
+ "(", /*vlen_pre */
+ ")", /*vlen_suf */
+ "", /*vlen_end */
+
+ "%s", /*elmt_fmt */
+ ",", /*elmt_suf1 */
+ " ", /*elmt_suf2 */
+
+ "%" PRIuHSIZE, /*idx_n_fmt */
+ ",", /*idx_sep */
+ "(%s)", /*idx_fmt */
+
+ 65535,
+ /*line_ncols */ /*standard default columns */
+ 0, /*line_per_line */
+ "", /*line_pre */
+ "%s", /*line_1st */
+ "%s", /*line_cont */
+ "", /*line_suf */
+ "", /*line_sep */
+ 1, /*line_multi_new */
+ " ", /*line_indent */
+
+ 0, /*skip_first */
+
+ 0, /*obj_hidefileno */
+ "-%lu:%" PRIuHADDR, /*obj_format */
+
+ 0, /*dset_hidefileno */
+ "DSET-%s ", /*dset_format */
+ "%sBlk%lu: ", /*dset_blockformat_pre */
+ "%sPt%lu: ", /*dset_ptformat_pre */
+ "%s", /*dset_ptformat */
+ 1, /*array indices */
+ 1 /*escape non printable characters */
};
/* Struct to pass through to visitors */
typedef struct {
- const char *fname; /* Filename */
- hid_t fid; /* File ID */
- hid_t gid; /* Group ID */
- hbool_t symlink_target; /* Whether this is the target of an symbolic link */
- symlink_trav_t *symlink_list; /* List of visited symbolic links */
- size_t base_len; /* Length of base path name, if not root */
- size_t name_start; /* # of leading characters to strip off path names on output */
-}iter_t;
+ const char * fname; /* Filename */
+ hid_t fid; /* File ID */
+ hid_t gid; /* Group ID */
+ hbool_t symlink_target; /* Whether this is the target of an symbolic link */
+ symlink_trav_t *symlink_list; /* List of visited symbolic links */
+ size_t base_len; /* Length of base path name, if not root */
+ size_t name_start; /* # of leading characters to strip off path names on output */
+} iter_t;
/* Command-line switches */
-static int verbose_g = 0; /* lots of extra output */
-static int width_g = 80; /* output width in characters */
-static hbool_t address_g = FALSE; /* print raw data addresses */
-static hbool_t data_g = FALSE; /* display dataset values? */
-static hbool_t label_g = FALSE; /* label compound values? */
-static hbool_t string_g = FALSE; /* print 1-byte numbers as ASCII? */
-static hbool_t fullname_g = FALSE; /* print full path names */
-static hbool_t recursive_g = FALSE; /* recursive descent listing */
-static hbool_t follow_symlink_g = FALSE; /* follow symbolic links */
-static hbool_t no_dangling_link_g = FALSE; /* treat dangling link is error */
-static hbool_t follow_elink_g = FALSE; /* follow external links */
-static hbool_t grp_literal_g = FALSE; /* list group, not contents */
-static hbool_t hexdump_g = FALSE; /* show data as raw hexadecimal */
-static hbool_t show_errors_g = FALSE; /* print HDF5 error messages */
-static hbool_t simple_output_g = FALSE; /* make output more machine-readable */
-static hbool_t show_file_name_g = FALSE; /* show file name for full names */
-static hbool_t no_line_wrap_g = FALSE; /* show data content without line wrap */
-static hbool_t display_root_g = FALSE; /* show root group in output? */
+static int verbose_g = 0; /* lots of extra output */
+static int width_g = 80; /* output width in characters */
+static hbool_t address_g = FALSE; /* print raw data addresses */
+static hbool_t data_g = FALSE; /* display dataset values? */
+static hbool_t label_g = FALSE; /* label compound values? */
+static hbool_t string_g = FALSE; /* print 1-byte numbers as ASCII? */
+static hbool_t fullname_g = FALSE; /* print full path names */
+static hbool_t recursive_g = FALSE; /* recursive descent listing */
+static hbool_t follow_symlink_g = FALSE; /* follow symbolic links */
+static hbool_t no_dangling_link_g = FALSE; /* treat dangling link is error */
+static hbool_t follow_elink_g = FALSE; /* follow external links */
+static hbool_t grp_literal_g = FALSE; /* list group, not contents */
+static hbool_t hexdump_g = FALSE; /* show data as raw hexadecimal */
+static hbool_t simple_output_g = FALSE; /* make output more machine-readable */
+static hbool_t show_file_name_g = FALSE; /* show file name for full names */
+static hbool_t no_line_wrap_g = FALSE; /* show data content without line wrap */
+static hbool_t display_root_g = FALSE; /* show root group in output? */
/* Information about how to display each type of object */
static struct dispatch_t {
@@ -147,17 +146,17 @@ static struct dispatch_t {
herr_t (*list2)(hid_t obj, const char *name);
} dispatch_g[H5O_TYPE_NTYPES];
-#define DISPATCH(TYPE, NAME, LIST1, LIST2) { \
- dispatch_g[TYPE].name = (NAME); \
- dispatch_g[TYPE].list1 = (LIST1); \
- dispatch_g[TYPE].list2 = (LIST2); \
-}
+#define DISPATCH(TYPE, NAME, LIST1, LIST2) \
+ { \
+ dispatch_g[TYPE].name = (NAME); \
+ dispatch_g[TYPE].list1 = (LIST1); \
+ dispatch_g[TYPE].list2 = (LIST2); \
+ }
-static void print_type(h5tools_str_t *buffer, hid_t type, int ind);
+static void print_type(h5tools_str_t *buffer, hid_t type, int ind);
static hbool_t print_int_type(h5tools_str_t *buffer, hid_t type, int ind);
static hbool_t print_float_type(h5tools_str_t *buffer, hid_t type, int ind);
-static herr_t visit_obj(hid_t file, const char *oname, iter_t *iter);
-
+static herr_t visit_obj(hid_t file, const char *oname, iter_t *iter);
/*-------------------------------------------------------------------------
* Function: usage
@@ -168,36 +167,46 @@ static herr_t visit_obj(hid_t file, const char *oname, iter_t *iter);
*-------------------------------------------------------------------------
*/
static void
-usage (void)
+usage(void)
{
FLUSHSTREAM(rawoutstream);
PRINTVALSTREAM(rawoutstream, "usage: h5ls [OPTIONS] file[/OBJECT] [file[/[OBJECT]...]\n");
PRINTVALSTREAM(rawoutstream, " OPTIONS\n");
PRINTVALSTREAM(rawoutstream, " -h, -?, --help Print a usage message and exit\n");
- PRINTVALSTREAM(rawoutstream, " -a, --address Print raw data address. If dataset is contiguous, address\n");
- PRINTVALSTREAM(rawoutstream, " is offset in file of beginning of raw data. If chunked,\n");
- PRINTVALSTREAM(rawoutstream, " returned list of addresses indicates offset of each chunk.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " -a, --address Print raw data address. If dataset is contiguous, address\n");
+ PRINTVALSTREAM(rawoutstream,
+ " is offset in file of beginning of raw data. If chunked,\n");
+ PRINTVALSTREAM(rawoutstream,
+ " returned list of addresses indicates offset of each chunk.\n");
PRINTVALSTREAM(rawoutstream, " Must be used with -v, --verbose option.\n");
PRINTVALSTREAM(rawoutstream, " Provides no information for non-dataset objects.\n");
PRINTVALSTREAM(rawoutstream, " -d, --data Print the values of datasets\n");
PRINTVALSTREAM(rawoutstream, " --enable-error-stack\n");
- PRINTVALSTREAM(rawoutstream, " Prints messages from the HDF5 error stack as they occur.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " Prints messages from the HDF5 error stack as they occur.\n");
PRINTVALSTREAM(rawoutstream, " --follow-symlinks\n");
- PRINTVALSTREAM(rawoutstream, " Follow symbolic links (soft links and external links)\n");
+ PRINTVALSTREAM(rawoutstream,
+ " Follow symbolic links (soft links and external links)\n");
PRINTVALSTREAM(rawoutstream, " to display target object information.\n");
PRINTVALSTREAM(rawoutstream, " Without this option, h5ls identifies a symbolic link\n");
PRINTVALSTREAM(rawoutstream, " as a soft link or external link and prints the value\n");
- PRINTVALSTREAM(rawoutstream, " assigned to the symbolic link; it does not provide any\n");
+ PRINTVALSTREAM(rawoutstream,
+ " assigned to the symbolic link; it does not provide any\n");
PRINTVALSTREAM(rawoutstream, " information regarding the target object or determine\n");
PRINTVALSTREAM(rawoutstream, " whether the link is a dangling link.\n");
PRINTVALSTREAM(rawoutstream, " --no-dangling-links\n");
PRINTVALSTREAM(rawoutstream, " Must be used with --follow-symlinks option;\n");
- PRINTVALSTREAM(rawoutstream, " otherwise, h5ls shows error message and returns an exit\n");
- PRINTVALSTREAM(rawoutstream, " code of 1. \n");
- PRINTVALSTREAM(rawoutstream, " Check for any symbolic links (soft links or external links)\n");
- PRINTVALSTREAM(rawoutstream, " that do not resolve to an existing object (dataset, group,\n");
+ PRINTVALSTREAM(rawoutstream,
+ " otherwise, h5ls shows error message and returns an exit\n");
+ PRINTVALSTREAM(rawoutstream, " code of 1.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " Check for any symbolic links (soft links or external links)\n");
+ PRINTVALSTREAM(rawoutstream,
+ " that do not resolve to an existing object (dataset, group,\n");
PRINTVALSTREAM(rawoutstream, " or named datatype).\n");
- PRINTVALSTREAM(rawoutstream, " If any dangling link is found, this situation is treated\n");
+ PRINTVALSTREAM(rawoutstream,
+ " If any dangling link is found, this situation is treated\n");
PRINTVALSTREAM(rawoutstream, " as an error and h5ls returns an exit code of 1.\n");
PRINTVALSTREAM(rawoutstream, " -f, --full Print full path names instead of base names\n");
PRINTVALSTREAM(rawoutstream, " -g, --group Show information about a group, not its contents\n");
@@ -210,15 +219,33 @@ usage (void)
PRINTVALSTREAM(rawoutstream, " -V, --version Print version number and exit\n");
PRINTVALSTREAM(rawoutstream, " --vfd=DRIVER Use the specified virtual file driver\n");
PRINTVALSTREAM(rawoutstream, " -x, --hexdump Show raw data in hexadecimal format\n");
- PRINTVALSTREAM(rawoutstream, " --s3-cred=C Supply S3 authentication information to \"ros3\" vfd.\n");
- PRINTVALSTREAM(rawoutstream, " Accepts tuple of \"(<aws-region>,<access-id>,<access-key>)\".\n");
- PRINTVALSTREAM(rawoutstream, " If absent or C->\"(,,)\", defaults to no-authentication.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --s3-cred=C Supply S3 authentication information to \"ros3\" vfd.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " Accepts tuple of \"(<aws-region>,<access-id>,<access-key>)\".\n");
+ PRINTVALSTREAM(rawoutstream,
+ " If absent or C->\"(,,)\", defaults to no-authentication.\n");
PRINTVALSTREAM(rawoutstream, " Has no effect if vfd flag not set to \"ros3\".\n");
PRINTVALSTREAM(rawoutstream, " --hdfs-attrs=A Supply configuration information to Hadoop VFD.\n");
PRINTVALSTREAM(rawoutstream, " Accepts tuple of (<namenode name>,<namenode port>,\n");
PRINTVALSTREAM(rawoutstream, " ...<kerberos cache path>,<username>,<buffer size>)\n");
- PRINTVALSTREAM(rawoutstream, " If absent or A == '(,,,,)', all default values are used.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " If absent or A == '(,,,,)', all default values are used.\n");
PRINTVALSTREAM(rawoutstream, " Has no effect if vfd flag is not 'hdfs'.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --vol-value Value (ID) of the VOL connector to use for opening the\n");
+ PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream, " --vol-name Name of the VOL connector to use for opening the\n");
+ PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --vol-info VOL-specific info to pass to the VOL connector used for\n");
+ PRINTVALSTREAM(rawoutstream, " opening the HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream, " --vfd-value Value (ID) of the VFL driver to use for opening the\n");
+ PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream, " --vfd-name Name of the VFL driver to use for opening the\n");
+ PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream, " --vfd-info VFD-specific info to pass to the VFL driver used for\n");
+ PRINTVALSTREAM(rawoutstream, " opening the HDF5 file specified\n");
PRINTVALSTREAM(rawoutstream, "\n");
PRINTVALSTREAM(rawoutstream, " file/OBJECT\n");
PRINTVALSTREAM(rawoutstream, " Each object consists of an HDF5 file name optionally followed by a\n");
@@ -228,11 +255,9 @@ usage (void)
PRINTVALSTREAM(rawoutstream, " \"%%05d\" to open a file family.\n");
PRINTVALSTREAM(rawoutstream, "\n");
PRINTVALSTREAM(rawoutstream, " Deprecated Options\n");
- PRINTVALSTREAM(rawoutstream, " The following options have been deprecated in HDF5. While they remain\n");
- PRINTVALSTREAM(rawoutstream, " available, they have been superseded as indicated and may be removed\n");
- PRINTVALSTREAM(rawoutstream, " from HDF5 in the future. Use the indicated replacement option in all\n");
- PRINTVALSTREAM(rawoutstream, " new work; where possible, existing scripts, et cetera, should also be\n");
- PRINTVALSTREAM(rawoutstream, " updated to use the replacement option.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " The following options have been removed in HDF5 1.12. Use the indicated\n");
+ PRINTVALSTREAM(rawoutstream, " replacement option in all work.\n");
PRINTVALSTREAM(rawoutstream, "\n");
PRINTVALSTREAM(rawoutstream, " -E or --external Follow external links.\n");
PRINTVALSTREAM(rawoutstream, " Replaced by --follow-symlinks.\n");
@@ -240,20 +265,19 @@ usage (void)
PRINTVALSTREAM(rawoutstream, " Replaced by --enable-error-stack.\n");
}
-
/*-------------------------------------------------------------------------
- * Function: print_string
+ * Function: print_string
*
- * Purpose: Print a string value by escaping unusual characters. If
- * STREAM is null then we only count how large the output would be.
+ * Purpose: Print a string value by escaping unusual characters. If
+ * STREAM is null then we only count how large the output would be.
*
- * Return: Number of characters printed.
+ * Return: Number of characters printed.
*-------------------------------------------------------------------------
*/
static int
print_string(h5tools_str_t *buffer, const char *s, hbool_t escape_spaces)
{
- int nprint=0;
+ int nprint = 0;
for (/*void*/; s && *s; s++) {
switch (*s) {
@@ -288,7 +312,8 @@ print_string(h5tools_str_t *buffer, const char *s, hbool_t escape_spaces)
nprint += 2;
break;
case '\t':
- if (buffer) h5tools_str_append(buffer, "\\t");
+ if (buffer)
+ h5tools_str_append(buffer, "\\t");
nprint += 2;
break;
case ' ':
@@ -311,7 +336,7 @@ print_string(h5tools_str_t *buffer, const char *s, hbool_t escape_spaces)
}
else {
if (buffer)
- h5tools_str_append(buffer, "\\%03o", *((const unsigned char*)s));
+ h5tools_str_append(buffer, "\\%03o", *((const unsigned char *)s));
nprint += 4;
}
break;
@@ -320,23 +345,21 @@ print_string(h5tools_str_t *buffer, const char *s, hbool_t escape_spaces)
return nprint;
}
-
/*-------------------------------------------------------------------------
- * Function: print_obj_name
+ * Function: print_obj_name
*
- * Purpose: Print an object name and another string.
+ * Purpose: Print an object name and another string.
*
- * Return: Success: TRUE
- * Failure: FALSE, nothing printed
+ * Return: Success: TRUE
+ * Failure: FALSE, nothing printed
*-------------------------------------------------------------------------
*/
static int
-print_obj_name(h5tools_str_t *buffer, const iter_t *iter, const char *oname,
- const char *s)
+print_obj_name(h5tools_str_t *buffer, const iter_t *iter, const char *oname, const char *s)
{
- static char fullname[NAME_BUF_SIZE]; /* Buffer for file and/or object name */
- const char *name = fullname; /* Pointer to buffer for printing */
- int n;
+ static char fullname[NAME_BUF_SIZE]; /* Buffer for file and/or object name */
+ const char *name = fullname; /* Pointer to buffer for printing */
+ int n;
if (show_file_name_g)
HDsnprintf(fullname, sizeof(fullname), "%s/%s", iter->fname, oname + iter->name_start);
@@ -347,7 +370,7 @@ print_obj_name(h5tools_str_t *buffer, const iter_t *iter, const char *oname,
if (fullname_g)
n = print_string(buffer, name, TRUE);
else {
- const char *last_sep; /* The location of the last group separator */
+ const char *last_sep; /* The location of the last group separator */
/* Find the last component of the path name */
if (NULL == (last_sep = HDstrrchr(name, '/')))
@@ -362,14 +385,13 @@ print_obj_name(h5tools_str_t *buffer, const iter_t *iter, const char *oname,
return TRUE;
}
-
/*-------------------------------------------------------------------------
- * Function: print_native_type
+ * Function: print_native_type
*
- * Purpose: Prints the name of a native C data type.
+ * Purpose: Prints the name of a native C data type.
*
- * Return: Success: TRUE
- * Failure: FALSE, nothing printed.
+ * Return: Success: TRUE
+ * Failure: FALSE, nothing printed.
*-------------------------------------------------------------------------
*/
static hbool_t
@@ -412,11 +434,6 @@ print_native_type(h5tools_str_t *buffer, hid_t type, int ind)
else if (H5Tequal(type, H5T_NATIVE_DOUBLE) == TRUE) {
h5tools_str_append(buffer, "native double");
}
-#if H5_SIZEOF_LONG_DOUBLE !=0
- else if (H5Tequal(type, H5T_NATIVE_LDOUBLE) == TRUE) {
- h5tools_str_append(buffer, "native long double");
- }
-#endif
else if (H5Tequal(type, H5T_NATIVE_INT8) == TRUE) {
h5tools_str_append(buffer, "native int8_t");
}
@@ -516,20 +533,20 @@ print_native_type(h5tools_str_t *buffer, hid_t type, int ind)
else {
return print_int_type(buffer, type, ind);
}
- } else {
+ }
+ else {
return print_int_type(buffer, type, ind);
}
return TRUE;
}
-
/*-------------------------------------------------------------------------
- * Function: print_ieee_type
+ * Function: print_ieee_type
*
- * Purpose: Print the name of an IEEE floating-point data type.
+ * Purpose: Print the name of an IEEE floating-point data type.
*
- * Return: Success: TRUE
- * Failure: FALSE, nothing printed
+ * Return: Success: TRUE
+ * Failure: FALSE, nothing printed
*-------------------------------------------------------------------------
*/
static hbool_t
@@ -553,36 +570,35 @@ print_ieee_type(h5tools_str_t *buffer, hid_t type, int ind)
return TRUE;
}
-
/*-------------------------------------------------------------------------
- * Function: print_precision
+ * Function: print_precision
*
- * Purpose: Prints information on the next line about precision and
- * padding if the precision is less than the total data type
- * size.
+ * Purpose: Prints information on the next line about precision and
+ * padding if the precision is less than the total data type
+ * size.
*
- * Return: void
+ * Return: void
*-------------------------------------------------------------------------
*/
static void
print_precision(h5tools_str_t *buffer, hid_t type, int ind)
{
- size_t prec; /* precision */
- H5T_pad_t plsb, pmsb; /* lsb and msb padding */
- const char *plsb_s=NULL; /* lsb padding string */
- const char *pmsb_s=NULL; /* msb padding string */
- size_t nbits; /* number of bits */
+ size_t prec; /* precision */
+ H5T_pad_t plsb, pmsb; /* lsb and msb padding */
+ const char *plsb_s = NULL; /* lsb padding string */
+ const char *pmsb_s = NULL; /* msb padding string */
+ size_t nbits; /* number of bits */
/* If the precision is less than the total size then show the precision
* and offset on the following line. Also display the padding
* information. */
if (8 * H5Tget_size(type) != (prec = H5Tget_precision(type))) {
- h5tools_str_append(buffer, "\n%*s(%lu bit%s of precision beginning at bit %lu)",
- ind, "", (unsigned long)prec, 1 == prec ? "" : "s", (unsigned long)H5Tget_offset(type));
+ h5tools_str_append(buffer, "\n%*s(%lu bit%s of precision beginning at bit %lu)", ind, "",
+ (unsigned long)prec, 1 == prec ? "" : "s", (unsigned long)H5Tget_offset(type));
H5Tget_pad(type, &plsb, &pmsb);
if (H5Tget_offset(type) > 0) {
- switch(plsb) {
+ switch (plsb) {
case H5T_PAD_ZERO:
plsb_s = "zero";
break;
@@ -601,7 +617,7 @@ print_precision(h5tools_str_t *buffer, hid_t type, int ind)
}
}
if ((unsigned)H5Tget_offset(type) + prec < 8 * H5Tget_size(type)) {
- switch(pmsb) {
+ switch (pmsb) {
case H5T_PAD_ZERO:
pmsb_s = "zero";
break;
@@ -623,39 +639,40 @@ print_precision(h5tools_str_t *buffer, hid_t type, int ind)
h5tools_str_append(buffer, "\n%*s(", ind, "");
if (plsb_s) {
nbits = (unsigned)H5Tget_offset(type);
- h5tools_str_append(buffer, "%lu %s bit%s at bit 0", (unsigned long)nbits, plsb_s, 1 == nbits ? "" : "s");
+ h5tools_str_append(buffer, "%lu %s bit%s at bit 0", (unsigned long)nbits, plsb_s,
+ 1 == nbits ? "" : "s");
}
if (plsb_s && pmsb_s)
h5tools_str_append(buffer, ", ");
if (pmsb_s) {
nbits = (8 * H5Tget_size(type)) - ((unsigned)H5Tget_offset(type) + prec);
- h5tools_str_append(buffer, "%lu %s bit%s at bit %lu", (unsigned long)nbits, pmsb_s, 1 == nbits ? "" : "s", (unsigned long)(8 * H5Tget_size(type) - nbits));
+ h5tools_str_append(buffer, "%lu %s bit%s at bit %lu", (unsigned long)nbits, pmsb_s,
+ 1 == nbits ? "" : "s", (unsigned long)(8 * H5Tget_size(type) - nbits));
}
h5tools_str_append(buffer, ")");
}
}
}
-
/*-------------------------------------------------------------------------
- * Function: print_int_type
+ * Function: print_int_type
*
- * Purpose: Print the name of an integer data type. Common information
- * like number of bits, byte order, and sign scheme appear on
- * the first line. Additional information might appear in
- * parentheses on the following lines.
+ * Purpose: Print the name of an integer data type. Common information
+ * like number of bits, byte order, and sign scheme appear on
+ * the first line. Additional information might appear in
+ * parentheses on the following lines.
*
- * Return: Success: TRUE
- * Failure: FALSE, nothing printed
+ * Return: Success: TRUE
+ * Failure: FALSE, nothing printed
*-------------------------------------------------------------------------
*/
static hbool_t
print_int_type(h5tools_str_t *buffer, hid_t type, int ind)
{
- H5T_order_t order; /* byte order value */
- const char *order_s = NULL; /* byte order string */
- H5T_sign_t sign; /* sign scheme value */
- const char *sign_s = NULL; /* sign scheme string */
+ H5T_order_t order; /* byte order value */
+ const char *order_s = NULL; /* byte order string */
+ H5T_sign_t sign; /* sign scheme value */
+ const char *sign_s = NULL; /* sign scheme string */
if (H5T_INTEGER != H5Tget_class(type))
return FALSE;
@@ -698,34 +715,34 @@ print_int_type(h5tools_str_t *buffer, hid_t type, int ind)
/* Print size, order, and sign on first line, precision and padding
* information on the subsequent lines */
- h5tools_str_append(buffer, "%lu-bit%s%s integer", (unsigned long)(8*H5Tget_size(type)), order_s, sign_s);
+ h5tools_str_append(buffer, "%lu-bit%s%s integer", (unsigned long)(8 * H5Tget_size(type)), order_s,
+ sign_s);
print_precision(buffer, type, ind);
return TRUE;
}
-
/*-------------------------------------------------------------------------
- * Function: print_float_type
+ * Function: print_float_type
*
- * Purpose: Print info about a floating point data type.
+ * Purpose: Print info about a floating point data type.
*
- * Return: Success: TRUE
- * Failure: FALSE, nothing printed
+ * Return: Success: TRUE
+ * Failure: FALSE, nothing printed
*-------------------------------------------------------------------------
*/
static hbool_t
print_float_type(h5tools_str_t *buffer, hid_t type, int ind)
{
H5T_order_t order; /* byte order value */
- const char *order_s=NULL; /* byte order string */
+ const char *order_s = NULL; /* byte order string */
size_t spos; /* sign bit position */
size_t esize, epos; /* exponent size and position */
size_t msize, mpos; /* significand size and position */
size_t ebias; /* exponent bias */
H5T_norm_t norm; /* significand normalization */
- const char *norm_s=NULL; /* normalization string */
+ const char *norm_s = NULL; /* normalization string */
H5T_pad_t pad; /* internal padding value */
- const char *pad_s=NULL; /* internal padding string */
+ const char *pad_s = NULL; /* internal padding string */
if (H5T_FLOAT != H5Tget_class(type))
return FALSE;
@@ -752,13 +769,13 @@ print_float_type(h5tools_str_t *buffer, hid_t type, int ind)
/* Print size and byte order on first line, precision and padding on
* subsequent lines. */
- h5tools_str_append(buffer, "%lu-bit%s floating-point", (unsigned long)(8*H5Tget_size(type)), order_s);
+ h5tools_str_append(buffer, "%lu-bit%s floating-point", (unsigned long)(8 * H5Tget_size(type)), order_s);
print_precision(buffer, type, ind);
/* Print sizes, locations, and other information about each field */
- H5Tget_fields (type, &spos, &epos, &esize, &mpos, &msize);
+ H5Tget_fields(type, &spos, &epos, &esize, &mpos, &msize);
ebias = H5Tget_ebias(type);
- norm = H5Tget_norm(type);
+ norm = H5Tget_norm(type);
switch (norm) {
case H5T_NORM_IMPLIED:
norm_s = ", msb implied";
@@ -772,14 +789,14 @@ print_float_type(h5tools_str_t *buffer, hid_t type, int ind)
case H5T_NORM_ERROR:
norm_s = ", unknown normalization";
break;
- default:
- ;
- break;
+ default:;
+ break;
}
- h5tools_str_append(buffer, "\n%*s(significant for %lu bit%s at bit %lu%s)", ind, "",
- (unsigned long)msize, 1==msize?"":"s", (unsigned long)mpos, norm_s);
- h5tools_str_append(buffer, "\n%*s(exponent for %lu bit%s at bit %lu, bias is 0x%lx)",
- ind, "", (unsigned long)esize, 1==esize?"":"s", (unsigned long)epos, (unsigned long)ebias);
+ h5tools_str_append(buffer, "\n%*s(significant for %lu bit%s at bit %lu%s)", ind, "", (unsigned long)msize,
+ 1 == msize ? "" : "s", (unsigned long)mpos, norm_s);
+ h5tools_str_append(buffer, "\n%*s(exponent for %lu bit%s at bit %lu, bias is 0x%lx)", ind, "",
+ (unsigned long)esize, 1 == esize ? "" : "s", (unsigned long)epos,
+ (unsigned long)ebias);
h5tools_str_append(buffer, "\n%*s(sign bit at %lu)", ind, "", (unsigned long)spos);
/* Display internal padding */
@@ -799,75 +816,73 @@ print_float_type(h5tools_str_t *buffer, hid_t type, int ind)
case H5T_NPAD:
pad_s = "unknown";
break;
- default:
- ;
- break;
+ default:;
+ break;
}
h5tools_str_append(buffer, "\n%*s(internal padding bits are %s)", ind, "", pad_s);
}
return TRUE;
}
-
/*-------------------------------------------------------------------------
- * Function: print_cmpd_type
+ * Function: print_cmpd_type
*
- * Purpose: Print info about a compound data type.
+ * Purpose: Print info about a compound data type.
*
- * Return: Success: TRUE
- * Failure: FALSE, nothing printed
+ * Return: Success: TRUE
+ * Failure: FALSE, nothing printed
*-------------------------------------------------------------------------
*/
static hbool_t
print_cmpd_type(h5tools_str_t *buffer, hid_t type, int ind)
{
- char *name=NULL; /* member name */
- size_t size; /* total size of type in bytes */
- hid_t subtype; /* member data type */
- int nmembs; /* number of members */
- int n; /* miscellaneous counters */
- unsigned i; /* miscellaneous counters */
-
- if(H5T_COMPOUND != H5Tget_class(type))
+ char * name = NULL; /* member name */
+ size_t size; /* total size of type in bytes */
+ hid_t subtype; /* member data type */
+ int nmembs; /* number of members */
+ int n; /* miscellaneous counters */
+ unsigned i; /* miscellaneous counters */
+
+ if (H5T_COMPOUND != H5Tget_class(type))
return FALSE;
- if((nmembs = H5Tget_nmembers(type)) < 0)
+ if ((nmembs = H5Tget_nmembers(type)) < 0)
return FALSE;
h5tools_str_append(buffer, "struct {");
for (i = 0; i < (unsigned)nmembs; i++) {
/* Name and offset */
name = H5Tget_member_name(type, i);
- h5tools_str_append(buffer, "\n%*s\"", ind+4, "");
+ h5tools_str_append(buffer, "\n%*s\"", ind + 4, "");
n = print_string(buffer, name, FALSE);
- h5tools_str_append(buffer, "\"%*s +%-4lu ", MAX(0, 16-n), "", (unsigned long)H5Tget_member_offset(type, i));
+ h5tools_str_append(buffer, "\"%*s +%-4lu ", MAX(0, 16 - n), "",
+ (unsigned long)H5Tget_member_offset(type, i));
H5free_memory(name);
/* Member's type */
subtype = H5Tget_member_type(type, i);
- print_type(buffer, subtype, ind+4);
+ print_type(buffer, subtype, ind + 4);
H5Tclose(subtype);
}
size = H5Tget_size(type);
- h5tools_str_append(buffer, "\n%*s} %lu byte%s", ind, "", (unsigned long)size, 1==size?"":"s");
+ h5tools_str_append(buffer, "\n%*s} %lu byte%s", ind, "", (unsigned long)size, 1 == size ? "" : "s");
return TRUE;
}
-
/*-------------------------------------------------------------------------
- * Function: print_enum_type
+ * Function: print_enum_type
*
- * Purpose: Print info about an enumeration data type.
+ * Purpose: Print info about an enumeration data type.
*
- * Return: Success: TRUE
- * Failure: FALSE, nothing printed
+ * Return: Success: TRUE
+ * Failure: FALSE, nothing printed
*-------------------------------------------------------------------------
*/
static hbool_t
print_enum_type(h5tools_str_t *buffer, hid_t type, int ind)
{
- int nmembs; /* number of members */
- hid_t super; /* enum base integer type */
+ int nmembs; /* number of members */
+ hid_t super; /* enum base integer type */
if (H5T_ENUM != H5Tget_class(type))
return FALSE;
@@ -880,11 +895,11 @@ print_enum_type(h5tools_str_t *buffer, hid_t type, int ind)
h5tools_str_append(buffer, " {");
if (nmembs > 0) {
- char **name; /* member names */
- unsigned char *value; /* value array */
- hid_t native = -1; /* native integer data type */
- size_t dst_size; /* destination value type size */
- unsigned i; /* miscellaneous counters */
+ char ** name; /* member names */
+ unsigned char *value; /* value array */
+ hid_t native = H5I_INVALID_HID; /* native integer data type */
+ size_t dst_size; /* destination value type size */
+ unsigned i; /* miscellaneous counters */
/* Determine what data type to use for the native values. To simplify
* things we entertain three possibilities:
@@ -902,7 +917,7 @@ print_enum_type(h5tools_str_t *buffer, hid_t type, int ind)
dst_size = H5Tget_size(type);
/* Get the names and raw values of all members */
- name = (char **)HDcalloc((size_t)nmembs, sizeof(char *));
+ name = (char **)HDcalloc((size_t)nmembs, sizeof(char *));
value = (unsigned char *)HDcalloc((size_t)nmembs, MAX(H5Tget_size(type), dst_size));
for (i = 0; i < (unsigned)nmembs; i++) {
name[i] = H5Tget_member_name(type, i);
@@ -917,6 +932,7 @@ print_enum_type(h5tools_str_t *buffer, hid_t type, int ind)
H5free_memory(name[i]);
HDfree(name);
HDfree(value);
+ H5Tclose(super);
return FALSE;
}
@@ -926,10 +942,9 @@ print_enum_type(h5tools_str_t *buffer, hid_t type, int ind)
/* Print members */
for (i = 0; i < (unsigned)nmembs; i++) {
- unsigned char *copy; /* a pointer to value array */
- int nchars; /* number of output characters */
+ int nchars; /* number of output characters */
- h5tools_str_append(buffer, "\n%*s", ind+4, "");
+ h5tools_str_append(buffer, "\n%*s", ind + 4, "");
nchars = print_string(buffer, name[i], TRUE);
h5tools_str_append(buffer, "%*s = ", MAX(0, 16 - nchars), "");
@@ -938,30 +953,30 @@ print_enum_type(h5tools_str_t *buffer, hid_t type, int ind)
h5tools_str_append(buffer, "0x");
for (j = 0; j < dst_size; j++)
- h5tools_str_append(buffer, "%02x", value[i*dst_size+j]);
+ h5tools_str_append(buffer, "%02x", value[i * dst_size + j]);
}
else if (H5T_SGN_NONE == H5Tget_sign(native)) {
- /*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size"
- *strangely, unless use another pointer "copy".*/
- copy = value + i * dst_size;
- h5tools_str_append(buffer, HSIZE_T_FORMAT, *((unsigned long long*)((void*)copy)));
+ unsigned long long copy;
+
+ HDmemcpy(&copy, value + i * dst_size, sizeof(copy));
+ h5tools_str_append(buffer, "%llu", copy);
}
else {
- /*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size"
- *strangely, unless use another pointer "copy".*/
- copy = value + i * dst_size;
- h5tools_str_append(buffer, "%"H5_PRINTF_LL_WIDTH"d", *((long long*)((void*)copy)));
+ long long copy;
+
+ HDmemcpy(&copy, value + i * dst_size, sizeof(copy));
+ h5tools_str_append(buffer, "%lld", copy);
}
}
/* Release resources */
- for(i = 0; i < (unsigned)nmembs; i++)
+ for (i = 0; i < (unsigned)nmembs; i++)
H5free_memory(name[i]);
HDfree(name);
HDfree(value);
}
else
- h5tools_str_append(buffer, "\n%*s <empty>", ind+4, "");
+ h5tools_str_append(buffer, "\n%*s <empty>", ind + 4, "");
h5tools_str_append(buffer, "\n%*s}", ind, "");
@@ -970,23 +985,22 @@ print_enum_type(h5tools_str_t *buffer, hid_t type, int ind)
return TRUE;
}
-
/*-------------------------------------------------------------------------
- * Function: print_string_type
+ * Function: print_string_type
*
- * Purpose: Print information about a string data type.
+ * Purpose: Print information about a string data type.
*
- * Return: Success: TRUE
- * Failure: FALSE, nothing printed
+ * Return: Success: TRUE
+ * Failure: FALSE, nothing printed
*-------------------------------------------------------------------------
*/
static hbool_t
print_string_type(h5tools_str_t *buffer, hid_t type, int H5_ATTR_UNUSED ind)
{
- H5T_str_t pad;
- const char *pad_s=NULL;
+ H5T_str_t pad;
+ const char *pad_s = NULL;
H5T_cset_t cset;
- const char *cset_s=NULL;
+ const char *cset_s = NULL;
if (H5T_STRING != H5Tget_class(type))
return FALSE;
@@ -1019,9 +1033,8 @@ print_string_type(h5tools_str_t *buffer, hid_t type, int H5_ATTR_UNUSED ind)
case H5T_STR_ERROR:
pad_s = "unknown-format";
break;
- default:
- ;
- break;
+ default:;
+ break;
}
/* Character set */
@@ -1050,9 +1063,8 @@ print_string_type(h5tools_str_t *buffer, hid_t type, int H5_ATTR_UNUSED ind)
case H5T_CSET_ERROR:
cset_s = "unknown-character-set";
break;
- default:
- ;
- break;
+ default:;
+ break;
}
if (H5Tis_variable_str(type)) {
@@ -1065,14 +1077,13 @@ print_string_type(h5tools_str_t *buffer, hid_t type, int H5_ATTR_UNUSED ind)
return TRUE;
}
-
/*-------------------------------------------------------------------------
- * Function: print_reference_type
+ * Function: print_reference_type
*
- * Purpose: Prints information about a reference data type.
+ * Purpose: Prints information about a reference data type.
*
- * Return: Success: TRUE
- * Failure: FALSE, nothing printed
+ * Return: Success: TRUE
+ * Failure: FALSE, nothing printed
*-------------------------------------------------------------------------
*/
static hbool_t
@@ -1081,7 +1092,10 @@ print_reference_type(h5tools_str_t *buffer, hid_t type, int H5_ATTR_UNUSED ind)
if (H5T_REFERENCE != H5Tget_class(type))
return FALSE;
- if (H5Tequal(type, H5T_STD_REF_OBJ) == TRUE) {
+ if (H5Tequal(type, H5T_STD_REF) == TRUE) {
+ h5tools_str_append(buffer, "standard reference");
+ }
+ else if (H5Tequal(type, H5T_STD_REF_OBJ) == TRUE) {
h5tools_str_append(buffer, "object reference");
}
else if (H5Tequal(type, H5T_STD_REF_DSETREG) == TRUE) {
@@ -1094,20 +1108,19 @@ print_reference_type(h5tools_str_t *buffer, hid_t type, int H5_ATTR_UNUSED ind)
return TRUE;
}
-
/*-------------------------------------------------------------------------
- * Function: print_opaque_type
+ * Function: print_opaque_type
*
- * Purpose: Prints information about an opaque data type.
+ * Purpose: Prints information about an opaque data type.
*
- * Return: Success: TRUE
- * Failure: FALSE, nothing printed
+ * Return: Success: TRUE
+ * Failure: FALSE, nothing printed
*-------------------------------------------------------------------------
*/
static hbool_t
print_opaque_type(h5tools_str_t *buffer, hid_t type, int ind)
{
- char *tag;
+ char * tag;
size_t size;
if (H5T_OPAQUE != H5Tget_class(type))
@@ -1124,7 +1137,6 @@ print_opaque_type(h5tools_str_t *buffer, hid_t type, int ind)
return TRUE;
}
-
/*-------------------------------------------------------------------------
* Function: print_vlen_type
*
@@ -1137,7 +1149,7 @@ print_opaque_type(h5tools_str_t *buffer, hid_t type, int ind)
static hbool_t
print_vlen_type(h5tools_str_t *buffer, hid_t type, int ind)
{
- hid_t super;
+ hid_t super;
if (H5T_VLEN != H5Tget_class(type))
return FALSE;
@@ -1149,7 +1161,6 @@ print_vlen_type(h5tools_str_t *buffer, hid_t type, int ind)
return TRUE;
}
-
/*---------------------------------------------------------------------------
* Purpose: Print information about an array type
*
@@ -1160,9 +1171,9 @@ print_vlen_type(h5tools_str_t *buffer, hid_t type, int ind)
static hbool_t
print_array_type(h5tools_str_t *buffer, hid_t type, int ind)
{
- hid_t super;
- int ndims, i;
- hsize_t *dims=NULL;
+ hid_t super;
+ int ndims, i;
+ hsize_t *dims = NULL;
if (H5T_ARRAY != H5Tget_class(type))
return FALSE;
@@ -1173,42 +1184,40 @@ print_array_type(h5tools_str_t *buffer, hid_t type, int ind)
/* Print dimensions */
for (i = 0; i < ndims; i++)
- h5tools_str_append(buffer, "%s" HSIZE_T_FORMAT , i?",":"[", dims[i]);
+ h5tools_str_append(buffer, "%s%" PRIuHSIZE, i ? "," : "[", dims[i]);
h5tools_str_append(buffer, "]");
HDfree(dims);
}
else
- h5tools_str_append(buffer, " [SCALAR]\n", rawoutstream);
-
+ h5tools_str_append(buffer, " [SCALAR]\n");
/* Print parent type */
h5tools_str_append(buffer, " ");
super = H5Tget_super(type);
- print_type(buffer, super, ind+4);
+ print_type(buffer, super, ind + 4);
H5Tclose(super);
return TRUE;
}
-
/*-------------------------------------------------------------------------
- * Function: print_bitfield_type
+ * Function: print_bitfield_type
*
- * Purpose: Print information about a bitfield type.
+ * Purpose: Print information about a bitfield type.
*
- * Return: Success: TRUE
- * Failure: FALSE, nothing printed
+ * Return: Success: TRUE
+ * Failure: FALSE, nothing printed
*-------------------------------------------------------------------------
*/
static hbool_t
print_bitfield_type(h5tools_str_t *buffer, hid_t type, int ind)
{
H5T_order_t order; /* byte order value */
- const char *order_s=NULL; /* byte order string */
+ const char *order_s = NULL; /* byte order string */
if (H5T_BITFIELD != H5Tget_class(type))
return FALSE;
- if (H5Tget_size(type)>1) {
+ if (H5Tget_size(type) > 1) {
order = H5Tget_order(type);
if (H5T_ORDER_LE == order) {
order_s = " little-endian";
@@ -1227,98 +1236,107 @@ print_bitfield_type(h5tools_str_t *buffer, hid_t type, int ind)
order_s = "";
}
- h5tools_str_append(buffer, "%lu-bit%s bitfield", (unsigned long)(8*H5Tget_size(type)), order_s);
+ h5tools_str_append(buffer, "%lu-bit%s bitfield", (unsigned long)(8 * H5Tget_size(type)), order_s);
print_precision(buffer, type, ind);
return TRUE;
}
-
/*-------------------------------------------------------------------------
- * Function: print_type
+ * Function: print_type
*
- * Purpose: Prints a data type definition. The definition is printed
- * without any leading space or trailing line-feed (although
- * there might be line-feeds inside the type definition). The
- * first line is assumed to have IND characters before it on
- * the same line (printed by the caller).
- * Prints the OID of shared data types.
+ * Purpose: Prints a data type definition. The definition is printed
+ * without any leading space or trailing line-feed (although
+ * there might be line-feeds inside the type definition). The
+ * first line is assumed to have IND characters before it on
+ * the same line (printed by the caller).
+ * Prints the OID of shared data types.
*
- * Return: void
+ * Return: void
*-------------------------------------------------------------------------
*/
static void
print_type(h5tools_str_t *buffer, hid_t type, int ind)
{
- H5T_class_t data_class = H5Tget_class(type);
+ H5T_class_t data_class = H5Tget_class(type);
/* Bad data type */
if (type < 0) {
- h5tools_str_append(buffer,"<ERROR>");
+ h5tools_str_append(buffer, "<ERROR>");
return;
}
/* Shared? If so then print the type's OID */
if (H5Tcommitted(type)) {
- H5O_info_t oi;
+ H5O_info2_t oi;
- if (H5Oget_info2(type, &oi, H5O_INFO_BASIC) >= 0)
- h5tools_str_append(buffer,"shared-%lu:"H5_PRINTF_HADDR_FMT" ", oi.fileno, oi.addr);
+ if (H5Oget_info3(type, &oi, H5O_INFO_BASIC) >= 0) {
+ char *type_string = NULL;
+
+ H5Otoken_to_str(type, &oi.token, &type_string);
+
+ h5tools_str_append(buffer, "shared-%lu:%s", oi.fileno, type_string);
+
+ H5free_memory(type_string);
+ } /* end if */
else
- h5tools_str_append(buffer,"shared ");
+ h5tools_str_append(buffer, "shared ");
} /* end if */
/* Print the type */
- if (print_native_type(buffer, type, ind) ||
- print_ieee_type(buffer, type, ind) ||
- print_cmpd_type(buffer, type, ind) ||
- print_enum_type(buffer, type, ind) ||
- print_string_type(buffer, type, ind) ||
- print_reference_type(buffer, type, ind) ||
- print_vlen_type(buffer, type, ind) ||
- print_array_type(buffer, type, ind) ||
- print_opaque_type(buffer, type, ind) ||
- print_bitfield_type(buffer, type, ind))
+ if (print_native_type(buffer, type, ind) || print_ieee_type(buffer, type, ind) ||
+ print_cmpd_type(buffer, type, ind) || print_enum_type(buffer, type, ind) ||
+ print_string_type(buffer, type, ind) || print_reference_type(buffer, type, ind) ||
+ print_vlen_type(buffer, type, ind) || print_array_type(buffer, type, ind) ||
+ print_opaque_type(buffer, type, ind) || print_bitfield_type(buffer, type, ind))
return;
/* Unknown type */
- h5tools_str_append(buffer,"%lu-byte class-%u unknown", (unsigned long)H5Tget_size(type), (unsigned)data_class);
+ h5tools_str_append(buffer, "%lu-byte class-%u unknown", (unsigned long)H5Tget_size(type),
+ (unsigned)data_class);
}
-
/*-------------------------------------------------------------------------
- * Function: dump_dataset_values
+ * Function: dump_dataset_values
*
- * Purpose: Prints all values of a dataset.
+ * Purpose: Prints all values of a dataset.
*
- * Return: void
+ * Return: void
*-------------------------------------------------------------------------
*/
static void
dump_dataset_values(hid_t dset)
{
- char string_prefix[64];
- static char fmt_double[16];
- static char fmt_float[16];
- hsize_t curr_pos = 0; /* total data element position */
- h5tools_str_t buffer; /* string into which to render */
- h5tools_context_t ctx; /* print context */
- h5tool_format_t outputformat;
- h5tool_format_t *info = &ls_dataformat;
-
- hid_t f_type = H5Dget_type(dset);
- size_t size = H5Tget_size(f_type);
+ hid_t f_type = H5I_INVALID_HID;
+ hid_t space = H5I_INVALID_HID;
+ hsize_t total_size[H5S_MAX_RANK];
+ int ndims;
+ char string_prefix[64];
+ static char fmt_double[16];
+ static char fmt_float[16];
+ hsize_t curr_pos = 0; /* total data element position */
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t outputformat;
+ h5tool_format_t * info = &ls_dataformat;
+ H5R_ref_t * ref_buf = NULL;
+
+ H5TOOLS_START_DEBUG(" ");
+
+ f_type = H5Dget_type(dset);
+ space = H5Dget_space(dset);
HDmemset(&ctx, 0, sizeof(ctx));
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
- outputformat = *info;
- outputformat.line_1st = NULL;
+ outputformat = *info;
+ outputformat.line_1st = NULL;
+ outputformat.idx_fmt = "";
if (simple_output_g) {
- outputformat.idx_fmt = "";
- outputformat.line_per_line = 1;
+ outputformat.idx_fmt = "";
+ outputformat.line_per_line = 1;
outputformat.line_multi_new = 0;
- outputformat.line_pre = " ";
- outputformat.line_cont = " ";
+ outputformat.line_pre = " ";
+ outputformat.line_cont = " ";
outputformat.arr_pre = "";
outputformat.arr_suf = "";
@@ -1333,9 +1351,8 @@ dump_dataset_values(hid_t dset)
if (label_g)
outputformat.cmpd_name = "%s=";
- outputformat.elmt_suf1 = " ";
+ outputformat.elmt_suf1 = " ";
outputformat.str_locale = ESCAPE_HTML;
-
}
else {
if (no_line_wrap_g) {
@@ -1344,9 +1361,10 @@ dump_dataset_values(hid_t dset)
else {
outputformat.line_ncols = (unsigned)width_g;
}
- if (label_g) outputformat.cmpd_name = "%s=";
- outputformat.line_pre = " %s ";
- outputformat.line_cont = " %s ";
+ if (label_g)
+ outputformat.cmpd_name = "%s=";
+ outputformat.line_pre = " %s ";
+ outputformat.line_cont = " %s ";
outputformat.str_repeat = 8;
outputformat.arr_pre = NULL;
@@ -1374,10 +1392,10 @@ dump_dataset_values(hid_t dset)
* command line switch was given. */
outputformat.raw = TRUE;
}
- else if (string_g && 1 == size && H5T_INTEGER == H5Tget_class(f_type)) {
+ else if (string_g && H5Tget_size(f_type) == 1 && (H5Tget_class(f_type) == H5T_INTEGER)) {
/* Print 1-byte integer data as an ASCI character string instead of
* integers if the `-s' or `--string' command-line option was given. */
- outputformat.ascii = TRUE;
+ outputformat.ascii = TRUE;
outputformat.elmt_suf1 = "";
outputformat.elmt_suf2 = "";
HDsnprintf(string_prefix, sizeof(string_prefix), "%s\"", outputformat.line_pre);
@@ -1386,232 +1404,377 @@ dump_dataset_values(hid_t dset)
}
info = &outputformat;
- ctx.indent_level = 2;
- ctx.cur_column = (size_t)curr_pos;
+ ctx.indent_level = 1;
+ ctx.cur_column = (size_t)curr_pos;
/* Print all the values. */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, " Data:\n");
- h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
+
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0,
+ (hsize_t)0);
+
ctx.need_prefix = TRUE;
- ctx.cur_column = (size_t)curr_pos;
- if (h5tools_dump_dset(rawoutstream, info, &ctx, dset, NULL) < 0) {
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, " Unable to print data.");
- h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
- }
+ ctx.cur_column = (size_t)curr_pos;
+ if (H5Tget_class(f_type) == H5T_REFERENCE) {
+ H5TOOLS_DEBUG("reference class type");
+ if (!H5Tequal(f_type, H5T_STD_REF) && !H5Tequal(f_type, H5T_STD_REF_DSETREG) &&
+ !H5Tequal(f_type, H5T_STD_REF_OBJ)) {
+ H5TOOLS_GOTO_DONE_NO_RET();
+ }
+
+ ndims = (int)H5Sget_simple_extent_npoints(space);
+ H5TOOLS_DEBUG("ndims=%d - ctx.ndims=%d", ndims, ctx.ndims);
+
+ /* Assume entire data space to be printed */
+ H5Sget_simple_extent_dims(space, total_size, NULL);
+ init_acc_pos(ctx.ndims, total_size, ctx.acc, ctx.pos, ctx.p_min_idx);
+
+ ctx.need_prefix = TRUE;
+
+ if (NULL !=
+ (ref_buf = (H5R_ref_t *)HDcalloc(MAX(sizeof(unsigned), sizeof(H5R_ref_t)), (size_t)ndims))) {
+ H5TOOLS_DEBUG("H5Dread reference read");
+ if (H5Dread(dset, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_buf) < 0) {
+ HDfree(ref_buf);
+ H5TOOLS_INFO("H5Dread reference failed");
+ H5TOOLS_GOTO_DONE_NO_RET();
+ }
+ h5tools_dump_reference(rawoutstream, info, &ctx, dset, ref_buf, ndims);
+ PRINTVALSTREAM(rawoutstream, "\n");
+ HDfree(ref_buf);
+ }
+ }
+ else {
+ if (h5tools_dump_dset(rawoutstream, info, &ctx, dset) < 0) {
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, " Unable to print data.");
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols,
+ (hsize_t)0, (hsize_t)0);
+ }
+ }
+done:
+ H5Sclose(space);
H5Tclose(f_type);
h5tools_str_close(&buffer);
PRINTVALSTREAM(rawoutstream, "\n");
+
+ H5TOOLS_ENDDEBUG(" ");
}
+/*-------------------------------------------------------------------------
+ * Function: dump_attribute_values
+ *
+ * Purpose: Prints all values of a attribute.
+ *
+ * Return: void
+ *-------------------------------------------------------------------------
+ */
+static void
+dump_attribute_values(hid_t attr)
+{
+ hid_t f_type = H5I_INVALID_HID;
+ hid_t space = H5I_INVALID_HID;
+ hsize_t total_size[H5S_MAX_RANK];
+ int ndims;
+ char string_prefix[64];
+ static char fmt_double[16];
+ static char fmt_float[16];
+ hsize_t curr_pos = 0; /* total data element position */
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t outputformat;
+ h5tool_format_t * info = &ls_dataformat;
+ H5R_ref_t * ref_buf = NULL;
+
+ H5TOOLS_START_DEBUG(" ");
+
+ f_type = H5Aget_type(attr);
+ space = H5Aget_space(attr);
+
+ HDmemset(&ctx, 0, sizeof(ctx));
+ HDmemset(&buffer, 0, sizeof(h5tools_str_t));
+
+ outputformat = *info;
+ outputformat.line_1st = NULL;
+ outputformat.idx_fmt = "";
+ if (simple_output_g) {
+ outputformat.idx_fmt = "";
+ outputformat.line_per_line = 1;
+ outputformat.line_multi_new = 0;
+ outputformat.line_pre = " ";
+ outputformat.line_cont = " ";
+
+ outputformat.arr_pre = "";
+ outputformat.arr_suf = "";
+ outputformat.arr_sep = " ";
+
+ if (!label_g) {
+ outputformat.cmpd_pre = "";
+ outputformat.cmpd_suf = "";
+ }
+ outputformat.cmpd_sep = " ";
+
+ if (label_g)
+ outputformat.cmpd_name = "%s=";
+
+ outputformat.elmt_suf1 = " ";
+ outputformat.str_locale = ESCAPE_HTML;
+ }
+ else {
+ if (no_line_wrap_g) {
+ outputformat.line_per_line = 1;
+ }
+ else {
+ outputformat.line_ncols = (unsigned)width_g;
+ }
+ if (label_g)
+ outputformat.cmpd_name = "%s=";
+ outputformat.line_pre = " %s ";
+ outputformat.line_cont = " %s ";
+ outputformat.str_repeat = 8;
+
+ outputformat.arr_pre = NULL;
+ outputformat.arr_suf = NULL;
+ outputformat.arr_sep = NULL;
+
+ outputformat.cmpd_pre = NULL;
+ outputformat.cmpd_suf = NULL;
+ outputformat.cmpd_sep = NULL;
+
+ outputformat.vlen_sep = NULL;
+ outputformat.vlen_pre = NULL;
+ outputformat.vlen_suf = NULL;
+ outputformat.vlen_end = NULL;
+ }
+ outputformat.arr_linebreak = 0;
+ /* Floating point types should display full precision */
+ HDsnprintf(fmt_float, sizeof(fmt_float), "%%1.%dg", FLT_DIG);
+ outputformat.fmt_float = fmt_float;
+ HDsnprintf(fmt_double, sizeof(fmt_double), "%%1.%dg", DBL_DIG);
+ outputformat.fmt_double = fmt_double;
+
+ if (hexdump_g) {
+ /* Print all data in hexadecimal format if the `-x' or `--hexdump'
+ * command line switch was given. */
+ outputformat.raw = TRUE;
+ }
+ else if (string_g && H5Tget_size(f_type) == 1 && (H5Tget_class(f_type) == H5T_INTEGER)) {
+ /* Print 1-byte integer data as an ASCI character string instead of
+ * integers if the `-s' or `--string' command-line option was given. */
+ outputformat.ascii = TRUE;
+ outputformat.elmt_suf1 = "";
+ outputformat.elmt_suf2 = "";
+ HDsnprintf(string_prefix, sizeof(string_prefix), "%s\"", outputformat.line_pre);
+ outputformat.line_pre = string_prefix;
+ outputformat.line_suf = "\"";
+ }
+ info = &outputformat;
+
+ ctx.indent_level = 2;
+ ctx.cur_column = (size_t)curr_pos;
+
+ /* Print all the values. */
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, " Data:\n");
+
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0,
+ (hsize_t)0);
+
+ ctx.need_prefix = TRUE;
+ ctx.cur_column = (size_t)curr_pos;
+ if (H5Tget_class(f_type) == H5T_REFERENCE) {
+ H5TOOLS_DEBUG("reference class type");
+ if (!H5Tequal(f_type, H5T_STD_REF) && !H5Tequal(f_type, H5T_STD_REF_DSETREG) &&
+ !H5Tequal(f_type, H5T_STD_REF_OBJ)) {
+ H5TOOLS_GOTO_DONE_NO_RET();
+ }
+
+ ndims = (int)H5Sget_simple_extent_npoints(space);
+ H5TOOLS_DEBUG("ndims=%d - ctx.ndims=%d", ndims, ctx.ndims);
+
+ /* Assume entire data space to be printed */
+ H5Sget_simple_extent_dims(space, total_size, NULL);
+ init_acc_pos(ctx.ndims, total_size, ctx.acc, ctx.pos, ctx.p_min_idx);
+
+ ctx.need_prefix = TRUE;
+
+ if (NULL !=
+ (ref_buf = (H5R_ref_t *)HDcalloc(MAX(sizeof(unsigned), sizeof(H5R_ref_t)), (size_t)ndims))) {
+ H5TOOLS_DEBUG("H5Aread reference read");
+ if (H5Aread(attr, H5T_STD_REF, ref_buf) < 0) {
+ HDfree(ref_buf);
+ H5TOOLS_INFO("H5Aread reference failed");
+ H5TOOLS_GOTO_DONE_NO_RET();
+ }
+ ctx.indent_level++;
+ h5tools_dump_reference(rawoutstream, info, &ctx, attr, ref_buf, ndims);
+
+ PRINTVALSTREAM(rawoutstream, "\n");
+ ctx.indent_level--;
+ HDfree(ref_buf);
+ }
+ }
+ else {
+ H5TOOLS_DEBUG("Attribute data read");
+ ctx.indent_level++;
+ if (h5tools_dump_mem(rawoutstream, info, &ctx, attr) < 0) {
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, " Unable to print data.");
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols,
+ (hsize_t)0, (hsize_t)0);
+ }
+ ctx.indent_level--;
+ H5TOOLS_DEBUG("Attribute data read complete");
+ }
+done:
+ H5Sclose(space);
+ H5Tclose(f_type);
+
+ h5tools_str_close(&buffer);
+
+ PRINTVALSTREAM(rawoutstream, "\n");
+
+ H5TOOLS_ENDDEBUG(" ");
+}
/*-------------------------------------------------------------------------
- * Function: list_attr
+ * Function: list_attr
*
- * Purpose: Prints information about attributes.
+ * Purpose: Prints information about attributes.
*
- * Return: Success: 0
- * Failure: -1
+ * Return: Success: 0
+ * Failure: -1
*-------------------------------------------------------------------------
*/
static herr_t
list_attr(hid_t obj, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *ainfo,
- void H5_ATTR_UNUSED *op_data)
+ void H5_ATTR_UNUSED *op_data)
{
- hid_t attr = -1;
- hid_t space = -1;
- hid_t type = -1;
- hid_t p_type = -1;
- hsize_t size[H5S_MAX_RANK];
- hsize_t nelmts = 1;
- hsize_t temp_need;
- size_t need;
- int ndims;
- int i;
- void *buf;
- H5S_class_t space_type;
- hsize_t curr_pos = 0; /* total data element position */
- h5tools_str_t buffer; /* string into which to render */
- h5tools_context_t ctx; /* print context */
- h5tool_format_t *info = &ls_dataformat;
- h5tool_format_t outputformat;
+ hid_t attr = H5I_INVALID_HID;
+ hid_t space = H5I_INVALID_HID;
+ hid_t type = H5I_INVALID_HID;
+ hsize_t size[H5S_MAX_RANK];
+ hsize_t nelmts = 1;
+ int ndims;
+ int i;
+ H5S_class_t space_type;
+ hsize_t curr_pos = 0; /* total data element position */
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t * info = &ls_dataformat;
+
+ H5TOOLS_START_DEBUG(" ");
HDmemset(&ctx, 0, sizeof(ctx));
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
+ ctx.indent_level = 2;
+ ctx.cur_column = (size_t)curr_pos;
+
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, " Attribute: ");
print_string(&buffer, attr_name, TRUE);
- if ((attr = H5Aopen(obj, attr_name, H5P_DEFAULT))) {
+ H5TOOLS_DEBUG("Attribute name:%s", attr_name);
+ if ((attr = H5Aopen(obj, attr_name, H5P_DEFAULT)) >= 0) {
space = H5Aget_space(attr);
- type = H5Aget_type(attr);
+ type = H5Aget_type(attr);
/* Data space */
- ndims = H5Sget_simple_extent_dims(space, size, NULL);
+ ndims = H5Sget_simple_extent_dims(space, size, NULL);
space_type = H5Sget_simple_extent_type(space);
- switch(space_type) {
+ H5TOOLS_DEBUG("Attribute ndims:%d", ndims);
+ switch (space_type) {
case H5S_SCALAR:
/* scalar dataspace */
h5tools_str_append(&buffer, " scalar\n");
- h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols,
+ (hsize_t)0, (hsize_t)0);
break;
case H5S_SIMPLE:
/* simple dataspace */
h5tools_str_append(&buffer, " {");
for (i = 0; i < ndims; i++) {
- h5tools_str_append(&buffer, "%s" HSIZE_T_FORMAT, i?", ":"", size[i]);
+ h5tools_str_append(&buffer, "%s%" PRIuHSIZE, i ? ", " : "", size[i]);
nelmts *= size[i];
}
h5tools_str_append(&buffer, "}\n");
- h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols,
+ (hsize_t)0, (hsize_t)0);
break;
case H5S_NULL:
/* null dataspace */
h5tools_str_append(&buffer, " null\n");
- h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols,
+ (hsize_t)0, (hsize_t)0);
break;
case H5S_NO_CLASS:
default:
/* Unknown dataspace type */
h5tools_str_append(&buffer, " unknown\n");
- h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols,
+ (hsize_t)0, (hsize_t)0);
break;
} /* end switch */
/* Data type */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, " Type: ");
+ h5tools_str_append(&buffer, " %-10s ", "Type:");
print_type(&buffer, type, 15);
h5tools_str_append(&buffer, "\n");
- h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
-
- /* Data */
- outputformat = *info;
-
- if (nelmts < 5) {
- outputformat.idx_fmt = "";
- outputformat.line_1st = " Data: ";
- outputformat.line_pre = " ";
- outputformat.line_cont = " ";
- outputformat.str_repeat = 8;
-
- }
- else {
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, " Data:\n");
- h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
- outputformat.line_1st = NULL;
- outputformat.line_pre = " %s ";
- outputformat.line_cont = " %s ";
- outputformat.str_repeat = 8;
- }
-
- outputformat.line_ncols = (unsigned)width_g;
- if (label_g)
- outputformat.cmpd_name = "%s=";
- if (string_g && 1 == H5Tget_size(type) && H5T_INTEGER == H5Tget_class(type)) {
- outputformat.ascii = TRUE;
- outputformat.elmt_suf1 = "";
- outputformat.elmt_suf2 = "";
- outputformat.line_pre = " %s \"";
- outputformat.line_suf = "\"";
- } /* end if */
-
-
- outputformat.arr_pre = NULL;
- outputformat.arr_suf = NULL;
- outputformat.arr_sep = NULL;
-
- outputformat.cmpd_pre = NULL;
- outputformat.cmpd_suf = NULL;
- outputformat.cmpd_sep = NULL;
-
- outputformat.vlen_sep = NULL;
- outputformat.vlen_pre = NULL;
- outputformat.vlen_suf = NULL;
- outputformat.vlen_end = NULL;
-
- info = &outputformat;
-
- if (space_type != H5S_NULL && space_type != H5S_NO_CLASS) {
- if (hexdump_g)
- p_type = H5Tcopy(type);
- else
- p_type = H5Tget_native_type(type, H5T_DIR_DEFAULT);
-
- if (p_type >= 0) {
- /* VL data special information */
- unsigned int vl_data = 0; /* contains VL datatypes */
-
- /* Check if we have VL data in the dataset's datatype */
- if (h5tools_detect_vlen(p_type) == TRUE)
- vl_data = TRUE;
-
- temp_need = nelmts * MAX(H5Tget_size(type), H5Tget_size(p_type));
- need = (size_t)temp_need;
- if((buf = HDmalloc(need)) != NULL) {
- if(H5Aread(attr, p_type, buf) >= 0) {
- ctx.need_prefix = TRUE;
- ctx.indent_level = 2;
- ctx.cur_column = (size_t)curr_pos;
- h5tools_dump_mem(rawoutstream, info, &ctx, attr, p_type, space, buf);
- }
-
- /* Reclaim any VL memory, if necessary */
- if (vl_data)
- H5Dvlen_reclaim(p_type, space, H5P_DEFAULT, buf);
-
- HDfree(buf);
- }
- H5Tclose(p_type);
- } /* end if */
- }
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols,
+ (hsize_t)0, (hsize_t)0);
H5Sclose(space);
H5Tclose(type);
+
+ h5tools_str_close(&buffer);
+
+ if (data_g)
+ dump_attribute_values(attr);
H5Aclose(attr);
}
- h5tools_str_close(&buffer);
-
- PRINTVALSTREAM(rawoutstream, "\n");
+ else {
+ H5TOOLS_DEBUG("Attribute open failed");
+ h5tools_str_close(&buffer);
+ }
+ H5TOOLS_ENDDEBUG(" ");
return 0;
}
-
/*-------------------------------------------------------------------------
- * Function: dataset_list1
+ * Function: dataset_list1
*
- * Purpose: List information about a dataset which should appear on the
- * same line as the dataset name. This information will precede
- * information which is applicable to all objects which will be
- * printed by the caller.
+ * Purpose: List information about a dataset which should appear on the
+ * same line as the dataset name. This information will precede
+ * information which is applicable to all objects which will be
+ * printed by the caller.
*
- * Return: Success: 0
- * Failure: -1
+ * Return: Success: 0
+ * Failure: -1
*-------------------------------------------------------------------------
*/
static herr_t
dataset_list1(hid_t dset)
{
- hsize_t cur_size[H5S_MAX_RANK]; /* current dataset dimensions */
- hsize_t max_size[H5S_MAX_RANK]; /* maximum dataset dimensions */
- hid_t space; /* data space */
- int ndims; /* dimensionality */
- H5S_class_t space_type; /* type of dataspace */
- int i;
- hsize_t curr_pos = 0; /* total data element position */
- h5tools_str_t buffer; /* string into which to render */
- h5tools_context_t ctx; /* print context */
- h5tool_format_t *info = &ls_dataformat;
+ hsize_t cur_size[H5S_MAX_RANK]; /* current dataset dimensions */
+ hsize_t max_size[H5S_MAX_RANK]; /* maximum dataset dimensions */
+ hid_t space; /* data space */
+ int ndims; /* dimensionality */
+ H5S_class_t space_type; /* type of dataspace */
+ int i;
+ hsize_t curr_pos = 0; /* total data element position */
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t * info = &ls_dataformat;
HDmemset(&ctx, 0, sizeof(ctx));
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
@@ -1620,17 +1783,17 @@ dataset_list1(hid_t dset)
/* Information that goes on the same row as the name. The name has
* already been printed. */
- space = H5Dget_space(dset);
+ space = H5Dget_space(dset);
space_type = H5Sget_simple_extent_type(space);
- ndims = H5Sget_simple_extent_dims(space, cur_size, max_size);
+ ndims = H5Sget_simple_extent_dims(space, cur_size, max_size);
h5tools_str_append(&buffer, " {");
for (i = 0; i < ndims; i++) {
- h5tools_str_append(&buffer, "%s"HSIZE_T_FORMAT, i?", ":"", cur_size[i]);
- if (max_size[i]==H5S_UNLIMITED) {
+ h5tools_str_append(&buffer, "%s%" PRIuHSIZE, i ? ", " : "", cur_size[i]);
+ if (max_size[i] == H5S_UNLIMITED) {
h5tools_str_append(&buffer, "/%s", "Inf");
}
else if (max_size[i] != cur_size[i] || verbose_g > 0) {
- h5tools_str_append(&buffer, "/"HSIZE_T_FORMAT, max_size[i]);
+ h5tools_str_append(&buffer, "/%" PRIuHSIZE, max_size[i]);
}
}
if (space_type == H5S_SCALAR)
@@ -1638,52 +1801,52 @@ dataset_list1(hid_t dset)
else if (space_type == H5S_NULL)
h5tools_str_append(&buffer, "NULL");
h5tools_str_append(&buffer, "}");
- h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
- H5Sclose (space);
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0,
+ (hsize_t)0);
+ H5Sclose(space);
h5tools_str_close(&buffer);
return 0;
}
-
/*-------------------------------------------------------------------------
- * Function: dataset_list2
+ * Function: dataset_list2
*
- * Purpose: List information about a dataset which should appear after
- * information which is general to all objects.
+ * Purpose: List information about a dataset which should appear after
+ * information which is general to all objects.
*
- * Return: Success: 0
- * Failure: -1
+ * Return: Success: 0
+ * Failure: -1
*-------------------------------------------------------------------------
*/
static herr_t
dataset_list2(hid_t dset, const char H5_ATTR_UNUSED *name)
{
- hid_t dcpl; /* dataset creation property list */
- hid_t type; /* data type of dataset */
- hid_t space; /* data space of dataset */
- int nf; /* number of filters */
- unsigned filt_flags; /* filter flags */
- H5Z_filter_t filt_id; /* filter identification number */
- unsigned cd_values[20]; /* filter client data values */
- size_t cd_nelmts; /* filter client number of values */
- size_t cd_num; /* filter client data counter */
- char f_name[256]; /* filter/file name */
- char s[64]; /* temporary string buffer */
- off_t f_offset; /* offset in external file */
- hsize_t f_size; /* bytes used in external file */
- hsize_t total, used; /* total size or offset */
- int ndims; /* dimensionality */
- int n, max_len; /* max extern file name length */
- double utilization; /* percent utilization of storage */
- H5T_class_t tclass; /* datatype class identifier */
- int i;
- H5D_layout_t stl;
- hsize_t curr_pos = 0; /* total data element position */
- h5tools_str_t buffer; /* string into which to render */
- h5tools_context_t ctx; /* print context */
- h5tool_format_t *info = &ls_dataformat;
+ hid_t dcpl; /* dataset creation property list */
+ hid_t type; /* data type of dataset */
+ hid_t space; /* data space of dataset */
+ int nf; /* number of filters */
+ unsigned filt_flags; /* filter flags */
+ H5Z_filter_t filt_id; /* filter identification number */
+ unsigned cd_values[20]; /* filter client data values */
+ size_t cd_nelmts; /* filter client number of values */
+ size_t cd_num; /* filter client data counter */
+ char f_name[256]; /* filter/file name */
+ char s[64]; /* temporary string buffer */
+ off_t f_offset; /* offset in external file */
+ hsize_t f_size; /* bytes used in external file */
+ hsize_t total, used; /* total size or offset */
+ int ndims; /* dimensionality */
+ int n, max_len; /* max extern file name length */
+ double utilization; /* percent utilization of storage */
+ H5T_class_t tclass; /* datatype class identifier */
+ int i;
+ H5D_layout_t stl;
+ hsize_t curr_pos = 0; /* total data element position */
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t * info = &ls_dataformat;
HDmemset(&ctx, 0, sizeof(ctx));
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
@@ -1691,26 +1854,24 @@ dataset_list2(hid_t dset, const char H5_ATTR_UNUSED *name)
h5tools_str_reset(&buffer);
if (verbose_g > 0) {
- dcpl = H5Dget_create_plist(dset);
+ dcpl = H5Dget_create_plist(dset);
space = H5Dget_space(dset);
- type = H5Dget_type(dset);
+ type = H5Dget_type(dset);
stl = H5Pget_layout(dcpl);
switch (stl) {
- case H5D_CHUNKED:
- {
- hsize_t chsize[64]; /* chunk size in elements */
-
- ndims = H5Pget_chunk(dcpl, (int)NELMTS(chsize), chsize/*out*/);
- h5tools_str_append(&buffer, " %-10s {", "Chunks:");
- total = H5Tget_size(type);
- for (i = 0; i < ndims; i++) {
- h5tools_str_append(&buffer, "%s"HSIZE_T_FORMAT, i?", ":"", chsize[i]);
- total *= chsize[i];
- }
- h5tools_str_append(&buffer, "} "HSIZE_T_FORMAT" bytes\n", total);
+ case H5D_CHUNKED: {
+ hsize_t chsize[64]; /* chunk size in elements */
+
+ ndims = H5Pget_chunk(dcpl, (int)NELMTS(chsize), chsize /*out*/);
+ h5tools_str_append(&buffer, " %-10s {", "Chunks:");
+ total = H5Tget_size(type);
+ for (i = 0; i < ndims; i++) {
+ h5tools_str_append(&buffer, "%s%" PRIuHSIZE, i ? ", " : "", chsize[i]);
+ total *= chsize[i];
}
- break;
+ h5tools_str_append(&buffer, "} %" PRIuHSIZE " bytes\n", total);
+ } break;
case H5D_COMPACT:
break;
case H5D_CONTIGUOUS:
@@ -1719,64 +1880,70 @@ dataset_list2(hid_t dset, const char H5_ATTR_UNUSED *name)
for (i = 0, max_len = 0; i < nf; i++) {
if (H5Pget_external(dcpl, (unsigned)i, sizeof(f_name), f_name, NULL, NULL) < 0)
continue;
- n = print_string(NULL, f_name, TRUE);
+ n = print_string(NULL, f_name, TRUE);
max_len = MAX(max_len, n);
} /* end for */
- h5tools_str_append(&buffer, " %-10s %d external file%s\n", "Extern:", nf, 1==nf?"":"s");
- h5tools_str_append(&buffer, " %4s %10s %10s %10s %s\n", "ID", "DSet-Addr", "File-Addr", "Bytes", "File");
- h5tools_str_append(&buffer, " %4s %10s %10s %10s ", "----", "----------", "----------", "----------");
+ h5tools_str_append(&buffer, " %-10s %d external file%s\n", "Extern:", nf,
+ 1 == nf ? "" : "s");
+ h5tools_str_append(&buffer, " %4s %10s %10s %10s %s\n", "ID", "DSet-Addr",
+ "File-Addr", "Bytes", "File");
+ h5tools_str_append(&buffer, " %4s %10s %10s %10s ", "----", "----------",
+ "----------", "----------");
for (i = 0; i < max_len; i++)
h5tools_str_append(&buffer, "-");
h5tools_str_append(&buffer, "\n");
- for (i = 0, total=0; i < nf; i++) {
- if (H5Pget_external(dcpl, (unsigned)i, sizeof(f_name), f_name, &f_offset, &f_size)<0) {
- h5tools_str_append(&buffer, " #%03d %10"H5_PRINTF_LL_WIDTH"u %10s %10s ***ERROR*** %s\n",
- i, total, "", "", i+1<nf?"Following addresses are incorrect":"");
+ for (i = 0, total = 0; i < nf; i++) {
+ if (H5Pget_external(dcpl, (unsigned)i, sizeof(f_name), f_name, &f_offset, &f_size) <
+ 0) {
+ h5tools_str_append(
+ &buffer, " #%03d %10" PRIuHSIZE " %10s %10s ***ERROR*** %s\n", i,
+ total, "", "", i + 1 < nf ? "Following addresses are incorrect" : "");
}
else if (H5S_UNLIMITED == f_size) {
- h5tools_str_append(&buffer, " #%03d %10"H5_PRINTF_LL_WIDTH"u %10"H5_PRINTF_LL_WIDTH"u %10s ",
- i, total, (hsize_t)f_offset, "INF");
+ h5tools_str_append(&buffer,
+ " #%03d %10" PRIuHSIZE " %10" PRIuHSIZE " %10s ", i,
+ total, (hsize_t)f_offset, "INF");
print_string(&buffer, f_name, TRUE);
}
else {
- h5tools_str_append(&buffer, " #%03d %10"H5_PRINTF_LL_WIDTH"u %10"H5_PRINTF_LL_WIDTH"u %10"H5_PRINTF_LL_WIDTH"u ",
- i, total, (hsize_t)f_offset, f_size);
+ h5tools_str_append(
+ &buffer, " #%03d %10" PRIuHSIZE " %10" PRIuHSIZE " %10" PRIuHSIZE " ",
+ i, total, (hsize_t)f_offset, f_size);
print_string(&buffer, f_name, TRUE);
}
h5tools_str_append(&buffer, "\n");
total += f_size;
}
- h5tools_str_append(&buffer, " %4s %10s %10s %10s ", "----", "----------", "----------", "----------");
+ h5tools_str_append(&buffer, " %4s %10s %10s %10s ", "----", "----------",
+ "----------", "----------");
for (i = 0; i < max_len; i++)
h5tools_str_append(&buffer, "-");
h5tools_str_append(&buffer, "\n");
} /* end if */
break;
- case H5D_VIRTUAL:
- {
- char dset_name[256]; /* Dataset name */
- size_t vmaps;
+ case H5D_VIRTUAL: {
+ char dset_name[256]; /* Dataset name */
+ size_t vmaps;
- H5Pget_virtual_count(dcpl, &vmaps);
+ H5Pget_virtual_count(dcpl, &vmaps);
- if (vmaps) {
- size_t next;
+ if (vmaps) {
+ size_t next;
- h5tools_str_append(&buffer, " %-10s {%ld} Source {\n", "Maps:", vmaps);
- for (next = 0; next < (unsigned) vmaps; next++) {
- H5Pget_virtual_filename(dcpl, next, f_name, sizeof(f_name));
- H5Pget_virtual_dsetname(dcpl, next, dset_name, sizeof(dset_name));
- h5tools_str_append(&buffer, " %-10s ", " ");
- print_string(&buffer, f_name, TRUE);
- h5tools_str_append(&buffer, " ");
- print_string(&buffer, dset_name, TRUE);
- h5tools_str_append(&buffer, "\n");
- }
- h5tools_str_append(&buffer, " %-10s}\n", " ");
+ h5tools_str_append(&buffer, " %-10s {%ld} Source {\n", "Maps:", vmaps);
+ for (next = 0; next < (unsigned)vmaps; next++) {
+ H5Pget_virtual_filename(dcpl, next, f_name, sizeof(f_name));
+ H5Pget_virtual_dsetname(dcpl, next, dset_name, sizeof(dset_name));
+ h5tools_str_append(&buffer, " %-10s ", " ");
+ print_string(&buffer, f_name, TRUE);
+ h5tools_str_append(&buffer, " ");
+ print_string(&buffer, dset_name, TRUE);
+ h5tools_str_append(&buffer, "\n");
}
+ h5tools_str_append(&buffer, " %-10s}\n", " ");
}
- break;
+ } break;
case H5D_LAYOUT_ERROR:
case H5D_NLAYOUTS:
@@ -1785,38 +1952,42 @@ dataset_list2(hid_t dset, const char H5_ATTR_UNUSED *name)
break;
}
/* Print total raw storage size */
- total = (hsize_t)H5Sget_simple_extent_npoints(space) * H5Tget_size(type);
- used = H5Dget_storage_size(dset);
+ total = (hsize_t)H5Sget_simple_extent_npoints(space) * H5Tget_size(type);
+ used = H5Dget_storage_size(dset);
tclass = H5Tget_class(type);
h5tools_str_append(&buffer, " %-10s ", "Storage:");
switch (tclass) {
- case H5T_VLEN:
- h5tools_str_append(&buffer, "information not available");
- break;
-
- case H5T_REFERENCE:
- if (H5Tequal(type, H5T_STD_REF_DSETREG)) {
+ case H5T_VLEN:
h5tools_str_append(&buffer, "information not available");
- }
- break;
+ break;
- case H5T_NO_CLASS:
- case H5T_INTEGER:
- case H5T_FLOAT:
- case H5T_TIME:
- case H5T_STRING:
- case H5T_BITFIELD:
- case H5T_OPAQUE:
- case H5T_COMPOUND:
- case H5T_ENUM:
- case H5T_ARRAY:
- case H5T_NCLASSES:
- default:
- h5tools_str_append(&buffer, HSIZE_T_FORMAT" logical byte%s, "HSIZE_T_FORMAT" allocated byte%s", total, 1==total?"":"s", used, 1==used?"":"s");
- if (used>0) {
- utilization = ((double)total * (double)100.0f) / (double)used;
- h5tools_str_append(&buffer, ", %1.2f%% utilization", utilization);
- }
+ case H5T_REFERENCE:
+ if (H5Tequal(dset, H5T_STD_REF)) {
+ h5tools_str_append(&buffer, "reference information not available");
+ }
+ else if (H5Tequal(dset, H5T_STD_REF_DSETREG)) {
+ h5tools_str_append(&buffer, "information not available");
+ }
+ break;
+
+ case H5T_NO_CLASS:
+ case H5T_INTEGER:
+ case H5T_FLOAT:
+ case H5T_TIME:
+ case H5T_STRING:
+ case H5T_BITFIELD:
+ case H5T_OPAQUE:
+ case H5T_COMPOUND:
+ case H5T_ENUM:
+ case H5T_ARRAY:
+ case H5T_NCLASSES:
+ default:
+ h5tools_str_append(&buffer, "%" PRIuHSIZE " logical byte%s, %" PRIuHSIZE " allocated byte%s",
+ total, 1 == total ? "" : "s", used, 1 == used ? "" : "s");
+ if (used > 0) {
+ utilization = ((double)total * 100.0) / (double)used;
+ h5tools_str_append(&buffer, ", %1.2f%% utilization", utilization);
+ }
}
h5tools_str_append(&buffer, "\n");
@@ -1825,21 +1996,27 @@ dataset_list2(hid_t dset, const char H5_ATTR_UNUSED *name)
if ((nf = H5Pget_nfilters(dcpl)) > 0) {
for (i = 0; i < nf; i++) {
cd_nelmts = NELMTS(cd_values);
- filt_id = H5Pget_filter2(dcpl, (unsigned)i, &filt_flags, &cd_nelmts, cd_values, sizeof(f_name), f_name, NULL);
+ filt_id = H5Pget_filter2(dcpl, (unsigned)i, &filt_flags, &cd_nelmts, cd_values,
+ sizeof(f_name), f_name, NULL);
f_name[sizeof(f_name) - 1] = '\0';
HDsnprintf(s, sizeof(s), "Filter-%d:", i);
- h5tools_str_append(&buffer, " %-10s %s-%u %s {", s, (f_name[0] ? f_name : "method"), (unsigned)filt_id, ((filt_flags & H5Z_FLAG_OPTIONAL) ? "OPT" : ""));
+ h5tools_str_append(&buffer, " %-10s %s-%u %s {", s, (f_name[0] ? f_name : "method"),
+ (unsigned)filt_id, ((filt_flags & H5Z_FLAG_OPTIONAL) ? "OPT" : ""));
for (cd_num = 0; cd_num < cd_nelmts; cd_num++)
h5tools_str_append(&buffer, "%s%u", (cd_num ? ", " : ""), cd_values[cd_num]);
h5tools_str_append(&buffer, "}\n");
} /* end for */
- } /* end if */
+ } /* end if */
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols,
+ (hsize_t)0, (hsize_t)0);
/* Print data type */
+ h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, " %-10s ", "Type:");
print_type(&buffer, type, 15);
h5tools_str_append(&buffer, "\n");
- h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols,
+ (hsize_t)0, (hsize_t)0);
/* Print address information */
if (address_g)
@@ -1859,25 +2036,24 @@ dataset_list2(hid_t dset, const char H5_ATTR_UNUSED *name)
return 0;
} /* end dataset_list2() */
-
/*-------------------------------------------------------------------------
- * Function: datatype_list2
+ * Function: datatype_list2
*
- * Purpose: List information about a datatype which should appear after
- * information which is general to all objects.
+ * Purpose: List information about a datatype which should appear after
+ * information which is general to all objects.
*
- * Return: Success: 0
- * Failure: -1
+ * Return: Success: 0
+ * Failure: -1
*-------------------------------------------------------------------------
*/
static herr_t
datatype_list2(hid_t type, const char H5_ATTR_UNUSED *name)
{
if (verbose_g > 0) {
- hsize_t curr_pos = 0; /* total data element position */
- h5tools_str_t buffer; /* string into which to render */
- h5tools_context_t ctx; /* print context */
- h5tool_format_t *info = &ls_dataformat;
+ hsize_t curr_pos = 0; /* total data element position */
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t * info = &ls_dataformat;
HDmemset(&ctx, 0, sizeof(ctx));
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
@@ -1887,38 +2063,41 @@ datatype_list2(hid_t type, const char H5_ATTR_UNUSED *name)
h5tools_str_append(&buffer, " %-10s ", "Type:");
print_type(&buffer, type, 15);
h5tools_str_append(&buffer, "\n");
- h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols,
+ (hsize_t)0, (hsize_t)0);
h5tools_str_close(&buffer);
}
return 0;
}
-
/*-------------------------------------------------------------------------
- * Function: list_obj
+ * Function: list_obj
*
- * Purpose: Prints information about an object
+ * Purpose: Prints information about an object
*
- * Return: Success: 0
- * Failure: -1
+ * Return: Success: 0
+ * Failure: -1
*-------------------------------------------------------------------------
*/
static herr_t
-list_obj(const char *name, const H5O_info_t *oinfo, const char *first_seen, void *_iter)
+list_obj(const char *name, const H5O_info2_t *oinfo, const char *first_seen, void *_iter)
{
- H5O_type_t obj_type = oinfo->type; /* Type of the object */
- iter_t *iter = (iter_t*)_iter;
- hsize_t curr_pos = 0; /* total data element position */
- h5tools_str_t buffer; /* string into which to render */
- h5tools_context_t ctx; /* print context */
- h5tool_format_t *info = &ls_dataformat;
+ H5O_type_t obj_type = oinfo->type; /* Type of the object */
+ iter_t * iter = (iter_t *)_iter;
+ hsize_t curr_pos = 0; /* total data element position */
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t * info = &ls_dataformat;
+
+ H5TOOLS_START_DEBUG(" ");
HDmemset(&ctx, 0, sizeof(ctx));
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
h5tools_str_reset(&buffer);
+ H5TOOLS_DEBUG("Object name:%s", name);
/* Print the link's name, either full name or base name */
if (!iter->symlink_target)
print_obj_name(&buffer, iter, name, "");
@@ -1932,7 +2111,8 @@ list_obj(const char *name, const H5O_info_t *oinfo, const char *first_seen, void
h5tools_str_append(&buffer, "{");
if (obj_type >= 0 && dispatch_g[obj_type].name)
h5tools_str_append(&buffer, "%s", dispatch_g[obj_type].name);
- h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0,
+ (hsize_t)0);
/* Check if we've seen this object before */
if (first_seen) {
@@ -1942,53 +2122,66 @@ list_obj(const char *name, const H5O_info_t *oinfo, const char *first_seen, void
if (!iter->symlink_target) {
h5tools_str_append(&buffer, "\n");
}
- h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols,
+ (hsize_t)0, (hsize_t)0);
} /* end if */
else {
- hid_t obj = (-1); /* ID of object opened */
+ hid_t obj_id = H5I_INVALID_HID; /* ID of object opened */
/* Open the object. Not all objects can be opened. If this is the case
* then return right away.
*/
- if (obj_type >= 0 && (obj = H5Oopen(iter->fid, name, H5P_DEFAULT)) < 0) {
+ H5TOOLS_DEBUG("Open object name=%s", name);
+ if (obj_type >= 0 && (obj_id = H5Oopen(iter->fid, name, H5P_DEFAULT)) < 0) {
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, " *ERROR*\n");
- h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols,
+ (hsize_t)0, (hsize_t)0);
goto done;
} /* end if */
/* List the first line of information for the object. */
+ H5TOOLS_DEBUG("Object type:%d", obj_type);
if (obj_type >= 0 && dispatch_g[obj_type].list1)
- (dispatch_g[obj_type].list1)(obj);
+ (dispatch_g[obj_type].list1)(obj_id);
if (!iter->symlink_target || (verbose_g > 0)) {
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "\n");
- h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols,
+ (hsize_t)0, (hsize_t)0);
}
/* Show detailed information about the object, beginning with information
* which is common to all objects. */
if (verbose_g > 0) {
- size_t buf_size = 0;
- char* comment = NULL;
- ssize_t cmt_bufsize = -1;
+ size_t buf_size = 0;
+ char * comment = NULL;
+ char * obj_tok_str = NULL;
+ ssize_t cmt_bufsize = -1;
+ uint64_t supported = 0;
/* Display attributes */
+ H5TOOLS_DEBUG("Display attributes");
if (obj_type >= 0)
- H5Aiterate2(obj, H5_INDEX_NAME, H5_ITER_INC, NULL, list_attr, NULL);
+ H5Aiterate2(obj_id, H5_INDEX_NAME, H5_ITER_INC, NULL, list_attr, NULL);
/* Object location & reference count */
+ H5Otoken_to_str(obj_id, &oinfo->token, &obj_tok_str);
+
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, " %-10s %lu:"H5_PRINTF_HADDR_FMT"\n", "Location:", oinfo->fileno, oinfo->addr);
+ h5tools_str_append(&buffer, " %-10s %lu:%s\n", "Location:", oinfo->fileno, obj_tok_str);
h5tools_str_append(&buffer, " %-10s %u\n", "Links:", (unsigned)oinfo->rc);
- h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols,
+ (hsize_t)0, (hsize_t)0);
+
+ H5free_memory(obj_tok_str);
/* Modification time */
if (oinfo->mtime > 0) {
- char buf[256];
+ char buf[256];
struct tm *tm;
- if(simple_output_g)
+ if (simple_output_g)
tm = HDgmtime(&(oinfo->mtime));
else
tm = HDlocaltime(&(oinfo->mtime));
@@ -1996,55 +2189,66 @@ list_obj(const char *name, const H5O_info_t *oinfo, const char *first_seen, void
HDstrftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", tm);
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, " %-10s %s\n", "Modified:", buf);
- h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos,
+ (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
} /* end if */
- } /* end if */
-
- /* Object comment */
- cmt_bufsize = H5Oget_comment(obj, comment, buf_size);
-
- /* if the actual length of the comment is longer than cmt_bufsize, then call
- * H5Oget_comment again with the correct value.
- * If the call to H5Oget_comment returned an error, skip this block */
- if (cmt_bufsize > 0) {
- comment = (char *)HDmalloc((size_t)cmt_bufsize + 1); /* new_size including null terminator */
- if (comment) {
- cmt_bufsize = H5Oget_comment(obj, comment, (size_t)cmt_bufsize);
- if (cmt_bufsize > 0) {
- comment[cmt_bufsize] = 0;
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, " %-10s \"", "Comment:");
- print_string(&buffer, comment, FALSE);
- h5tools_str_append(&buffer, "\"\n");
- h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
- } /* end if */
- HDfree(comment);
+ } /* end if */
+
+ /* Only emit comments if the VOL connector supports that */
+ H5VLquery_optional(obj_id, H5VL_SUBCLS_OBJECT, H5VL_NATIVE_OBJECT_GET_COMMENT, &supported);
+
+ if (supported & H5VL_OPT_QUERY_SUPPORTED) {
+
+ /* Object comment */
+ cmt_bufsize = H5Oget_comment(obj_id, comment, buf_size);
+
+ /* if the actual length of the comment is longer than cmt_bufsize, then call
+ * H5Oget_comment again with the correct value.
+ */
+ if (cmt_bufsize > 0) {
+ comment =
+ (char *)HDmalloc((size_t)cmt_bufsize + 1); /* new_size including null terminator */
+ if (comment) {
+ cmt_bufsize = H5Oget_comment(obj_id, comment, (size_t)cmt_bufsize);
+ if (cmt_bufsize > 0) {
+ comment[cmt_bufsize] = 0;
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, " %-10s \"", "Comment:");
+ print_string(&buffer, comment, FALSE);
+ h5tools_str_append(&buffer, "\"\n");
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos,
+ (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
+ } /* end if */
+ HDfree(comment);
+ }
}
}
} /* end if */
/* Detailed list for object */
if (obj_type >= 0 && dispatch_g[obj_type].list2)
- (dispatch_g[obj_type].list2)(obj, name);
+ (dispatch_g[obj_type].list2)(obj_id, name);
/* Close the object. */
if (obj_type >= 0)
- H5Oclose(obj);
+ H5Oclose(obj_id);
} /* end else */
done:
if (iter->symlink_target) {
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "}\n");
- h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols,
+ (hsize_t)0, (hsize_t)0);
iter->symlink_target = FALSE;
}
h5tools_str_close(&buffer);
+ H5TOOLS_ENDDEBUG(" ");
+
return 0;
} /* end list_obj() */
-
/*-------------------------------------------------------------------------
* Function: list_lnk
*
@@ -2055,16 +2259,16 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-list_lnk(const char *name, const H5L_info_t *linfo, void *_iter)
+list_lnk(const char *name, const H5L_info2_t *linfo, void *_iter)
{
- char *buf=NULL;
- iter_t *iter = (iter_t*)_iter;
- int ret;
- hsize_t curr_pos = 0; /* total data element position */
+ char * buf = NULL;
+ iter_t * iter = (iter_t *)_iter;
+ int ret;
+ hsize_t curr_pos = 0; /* total data element position */
h5tool_link_info_t lnk_info;
- h5tools_str_t buffer; /* string into which to render */
- h5tools_context_t ctx; /* print context */
- h5tool_format_t *info = &ls_dataformat;
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t * info = &ls_dataformat;
HDmemset(&ctx, 0, sizeof(ctx));
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
@@ -2076,17 +2280,17 @@ list_lnk(const char *name, const H5L_info_t *linfo, void *_iter)
/* if verbose, make H5tools_get_symlink_info() display more */
if (verbose_g)
- lnk_info.opt.msg_mode=1;
+ lnk_info.opt.msg_mode = 1;
/* Print the link's name, either full name or base name */
print_obj_name(&buffer, iter, name, "");
- switch(linfo->type) {
+ switch (linfo->type) {
case H5L_TYPE_SOFT:
ret = H5tools_get_symlink_info(iter->fid, name, &lnk_info, follow_symlink_g);
/* lnk_info.trg_path is malloced in H5tools_get_symlink_info()
* so it will be freed via buf later */
- buf = (char*)lnk_info.trg_path;
+ buf = (char *)lnk_info.trg_path;
/* error */
if (ret < 0)
goto done;
@@ -2095,9 +2299,10 @@ list_lnk(const char *name, const H5L_info_t *linfo, void *_iter)
iter->symlink_list->dangle_link = TRUE;
h5tools_str_append(&buffer, "Soft Link {");
- h5tools_str_append(&buffer, buf);
+ h5tools_str_append(&buffer, "%s", buf);
h5tools_str_append(&buffer, "}");
- h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols,
+ (hsize_t)0, (hsize_t)0);
if (follow_symlink_g) {
hbool_t orig_grp_literal = grp_literal_g;
h5tools_str_reset(&buffer);
@@ -2106,10 +2311,12 @@ list_lnk(const char *name, const H5L_info_t *linfo, void *_iter)
/* Check if we have already seen this softlink */
if (symlink_is_visited(iter->symlink_list, linfo->type, NULL, buf)) {
h5tools_str_append(&buffer, "{Already Visited}\n");
- h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos,
+ (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
goto done;
}
- h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols,
+ (hsize_t)0, (hsize_t)0);
/* Add this link to the list of seen softlinks */
if (symlink_visit_add(iter->symlink_list, linfo->type, NULL, buf) < 0)
@@ -2134,21 +2341,21 @@ list_lnk(const char *name, const H5L_info_t *linfo, void *_iter)
else {
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "\n");
- h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols,
+ (hsize_t)0, (hsize_t)0);
}
break;
- case H5L_TYPE_EXTERNAL:
- {
+ case H5L_TYPE_EXTERNAL: {
const char *filename;
const char *path;
- hbool_t follow_link = follow_symlink_g || follow_elink_g;
+ hbool_t follow_link = follow_symlink_g || follow_elink_g;
ret = H5tools_get_symlink_info(iter->fid, name, &lnk_info, follow_link);
/* lnk_info.trg_path is malloced in H5tools_get_symlink_info()
* so it will be freed via buf later */
- buf = (char*)lnk_info.trg_path;
+ buf = (char *)lnk_info.trg_path;
/* error */
if (ret < 0)
goto done;
@@ -2160,13 +2367,14 @@ list_lnk(const char *name, const H5L_info_t *linfo, void *_iter)
goto done;
h5tools_str_append(&buffer, "External Link {");
- h5tools_str_append(&buffer, filename);
+ h5tools_str_append(&buffer, "%s", filename);
h5tools_str_append(&buffer, "/");
- if(*path != '/')
+ if (*path != '/')
h5tools_str_append(&buffer, "/");
- h5tools_str_append(&buffer, path);
+ h5tools_str_append(&buffer, "%s", path);
h5tools_str_append(&buffer, "}");
- h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols,
+ (hsize_t)0, (hsize_t)0);
/* Recurse through the external link */
/* keep the follow_elink_g for backward compatibility with -E */
@@ -2178,10 +2386,12 @@ list_lnk(const char *name, const H5L_info_t *linfo, void *_iter)
/* Check if we have already seen this elink */
if (symlink_is_visited(iter->symlink_list, linfo->type, filename, path)) {
h5tools_str_append(&buffer, "{Already Visited}\n");
- h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos,
+ (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
goto done;
}
- h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols,
+ (hsize_t)0, (hsize_t)0);
/* Add this link to the list of seen elinks */
if (symlink_visit_add(iter->symlink_list, linfo->type, filename, path) < 0) {
@@ -2207,15 +2417,15 @@ list_lnk(const char *name, const H5L_info_t *linfo, void *_iter)
}
else
PRINTVALSTREAM(rawoutstream, "\n");
- }
- break;
+ } break;
case H5L_TYPE_ERROR:
case H5L_TYPE_HARD:
case H5L_TYPE_MAX:
default:
h5tools_str_append(&buffer, "UD Link {cannot follow UD links}\n");
- h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols,
+ (hsize_t)0, (hsize_t)0);
break;
} /* end switch */
@@ -2227,26 +2437,24 @@ done:
return 0;
} /* end list_lnk() */
-
/*-------------------------------------------------------------------------
- * Function: visit_obj
+ * Function: visit_obj
*
- * Purpose: Begins iteration on an object
+ * Purpose: Begins iteration on an object
*
- * Return:
- * Success: 0
- * Failure: -1
+ * Return: Success: 0
+ * Failure: -1
*-------------------------------------------------------------------------
*/
static herr_t
visit_obj(hid_t file, const char *oname, iter_t *iter)
{
- int retval = 0;
- H5O_info_t oi; /* Information for object */
- hsize_t curr_pos = 0; /* total data element position */
- h5tools_str_t buffer; /* string into which to render */
- h5tools_context_t ctx; /* print context */
- h5tool_format_t *info = &ls_dataformat;
+ int retval = 0;
+ H5O_info2_t oi; /* Information for object */
+ hsize_t curr_pos = 0; /* total data element position */
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t * info = &ls_dataformat;
HDmemset(&ctx, 0, sizeof(ctx));
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
@@ -2254,14 +2462,15 @@ visit_obj(hid_t file, const char *oname, iter_t *iter)
h5tools_str_reset(&buffer);
/* Retrieve info for object to list */
- if (H5Oget_info_by_name2(file, oname, &oi, H5O_INFO_BASIC|H5O_INFO_TIME, H5P_DEFAULT) < 0) {
+ if (H5Oget_info_by_name3(file, oname, &oi, H5O_INFO_BASIC | H5O_INFO_TIME, H5P_DEFAULT) < 0) {
if (iter->symlink_target) {
h5tools_str_append(&buffer, "{**NOT FOUND**}\n");
iter->symlink_target = FALSE;
}
else
print_obj_name(&buffer, iter, oname, "**NOT FOUND**");
- h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols,
+ (hsize_t)0, (hsize_t)0);
retval = -1;
goto done;
} /* end if */
@@ -2271,18 +2480,20 @@ visit_obj(hid_t file, const char *oname, iter_t *iter)
/* Get ID for group */
if (!iter->symlink_target && (iter->gid = H5Gopen2(file, oname, H5P_DEFAULT)) < 0) {
h5tools_str_append(&buffer, "%s: unable to open '%s' as group\n", iter->fname, oname);
- h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
- goto done; /* Previously "continue", when this code was in main().
- * We don't "continue" here in order to close the file
- * and free the file name properly. */
- } /* end if */
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols,
+ (hsize_t)0, (hsize_t)0);
+ goto done; /* Previously "continue", when this code was in main().
+ * We don't "continue" here in order to close the file
+ * and free the file name properly. */
+ } /* end if */
/* Delay specifying the name start point so the original object name is
* displayed if it is a link or non-group object */
iter->name_start = iter->base_len;
/* Specified name is a group. List the complete contents of the group. */
- h5trav_visit(file, oname, (hbool_t) (display_root_g || iter->symlink_target), recursive_g, list_obj, list_lnk, iter, H5O_INFO_BASIC|H5O_INFO_TIME);
+ h5trav_visit(file, oname, (hbool_t)(display_root_g || iter->symlink_target), recursive_g, list_obj,
+ list_lnk, iter, H5O_INFO_BASIC | H5O_INFO_TIME);
/* Close group */
if (!iter->symlink_target)
@@ -2302,23 +2513,22 @@ done:
return retval;
}
-
/*-------------------------------------------------------------------------
- * Function: get_width
+ * Function: get_width
*
- * Purpose: Figure out how wide the screen is. This is highly
- * unportable, but the user can always override the width we
- * detect by giving a command-line option. These code snippets
- * were borrowed from the GNU less(1).
+ * Purpose: Figure out how wide the screen is. This is highly
+ * unportable, but the user can always override the width we
+ * detect by giving a command-line option. These code snippets
+ * were borrowed from the GNU less(1).
*
- * Return: Success: Number of columns.
- * Failure: Some default number of columms.
+ * Return: Success: Number of columns.
+ * Failure: Some default number of columns.
*-------------------------------------------------------------------------
*/
static int
get_width(void)
{
- int width = 80; /*the default */
+ int width = 80; /*the default */
char *s;
/* Try to get it from the COLUMNS environment variable first since it's
@@ -2358,14 +2568,14 @@ get_width(void)
{
/* Unix with ioctl(TIOCGWINSZ) */
struct winsize w;
- if (ioctl(2, (int)TIOCGWINSZ, &w)>=0 && w.ws_col>0)
+ if (ioctl(2, (int)TIOCGWINSZ, &w) >= 0 && w.ws_col > 0)
width = w.ws_col;
}
#elif defined(H5_HAVE_TIOCGETD) && defined(H5_HAVE_IOCTL)
{
/* Unix with ioctl(TIOCGETD) */
struct uwdata w;
- if (ioctl(2, WIOCGETD, &w)>=0 && w.uw_width>0)
+ if (ioctl(2, WIOCGETD, &w) >= 0 && w.uw_width > 0)
width = w.uw_width / w.uw_hs;
}
#endif
@@ -2377,13 +2587,12 @@ get_width(void)
}
/*-------------------------------------------------------------------------
- * Function: is_valid_args
+ * Function: is_valid_args
*
- * Purpose: check if command line arguments are valid
+ * Purpose: check if command line arguments are valid
*
- * Return:
- * Success: TRUE (1)
- * Failure: FALSE (0)
+ * Return: Success: TRUE (1)
+ * Failure: FALSE (0)
*-------------------------------------------------------------------------*/
static hbool_t
is_valid_args(void)
@@ -2397,7 +2606,8 @@ is_valid_args(void)
}
if (no_dangling_link_g && !follow_symlink_g) {
- HDfprintf(rawerrorstream, "Error: --no-dangling-links must be used along with --follow-symlinks option!\n\n");
+ HDfprintf(rawerrorstream,
+ "Error: --no-dangling-links must be used along with --follow-symlinks option!\n\n");
ret = FALSE;
goto out;
}
@@ -2406,13 +2616,12 @@ out:
return ret;
}
-
/*-------------------------------------------------------------------------
- * Function: leave
+ * Function: leave
*
- * Purpose: Close HDF5 and MPI and call exit()
+ * Purpose: Close HDF5 and MPI and call exit()
*
- * Return: Does not return
+ * Return: Does not return
*-------------------------------------------------------------------------
*/
static void
@@ -2423,50 +2632,52 @@ leave(int ret)
HDexit(ret);
}
-
/*-------------------------------------------------------------------------
- * Function: main
+ * Function: main
*
- * Purpose: Opens a file and lists the specified group
+ * Purpose: Opens a file and lists the specified group
*
- * Return: Success: 0
- * Failure: 1
+ * Return: Success: 0
+ * Failure: 1
*-------------------------------------------------------------------------
*/
int
-main(int argc, const char *argv[])
+main(int argc, char *argv[])
{
- hid_t file = -1;
- char *fname = NULL, *oname = NULL, *x;
- const char *s = NULL;
- char *rest;
- int argno;
- static char root_name[] = "/";
- char drivername[50];
- const char *preferred_driver = NULL;
- int err_exit = 0;
- hid_t fapl_id = H5P_DEFAULT;
+ hid_t file_id = H5I_INVALID_HID;
+ char * fname = NULL, *oname = NULL, *x = NULL;
+ const char * s = NULL;
+ char * rest;
+ int argno;
+ static char root_name[] = "/";
+ char drivername[50];
+ int err_exit = 0;
+ hid_t fapl_id = H5P_DEFAULT;
+ hbool_t custom_vol_fapl = FALSE;
+ hbool_t custom_vfd_fapl = FALSE;
+ h5tools_vol_info_t vol_info;
+ h5tools_vfd_info_t vfd_info;
#ifdef H5_HAVE_ROS3_VFD
- /* default "anonymous" s3 configuration */
+ /* Default "anonymous" S3 configuration */
H5FD_ros3_fapl_t ros3_fa = {
- 1, /* fapl version */
- false, /* authenticate */
- "", /* aws region */
- "", /* access key id */
- "", /* secret access key */
+ 1, /* Structure Version */
+ FALSE, /* Authenticate? */
+ "", /* AWS Region */
+ "", /* Access Key ID */
+ "", /* Secret Access Key */
};
-#endif /* H5_HVAE_ROS3_VFD */
+#endif /* H5_HAVE_ROS3_VFD */
#ifdef H5_HAVE_LIBHDFS
- /* "default" HDFS configuration */
+ /* "Default" HDFS configuration */
H5FD_hdfs_fapl_t hdfs_fa = {
- 1, /* fapl version */
- "localhost", /* namenode name */
- 0, /* namenode port */
- "", /* kerberos ticket cache */
- "", /* user name */
- 2048, /* stream buffer size */
+ 1, /* Structure Version */
+ "localhost", /* Namenode Name */
+ 0, /* Namenode Port */
+ "", /* Kerberos ticket cache */
+ "", /* User name */
+ 2048, /* Stream buffer size */
};
#endif /* H5_HAVE_LIBHDFS */
@@ -2476,6 +2687,10 @@ main(int argc, const char *argv[])
/* Initialize h5tools lib */
h5tools_init();
+ /* Initialize fapl info structs */
+ HDmemset(&vol_info, 0, sizeof(h5tools_vol_info_t));
+ HDmemset(&vfd_info, 0, sizeof(h5tools_vfd_info_t));
+
/* Build object display table */
DISPATCH(H5O_TYPE_GROUP, "Group", NULL, NULL);
DISPATCH(H5O_TYPE_DATASET, "Dataset", dataset_list1, dataset_list2);
@@ -2498,15 +2713,15 @@ main(int argc, const char *argv[])
else if (!HDstrcmp(argv[argno], "--address")) {
address_g = TRUE;
}
- else if(!HDstrcmp(argv[argno], "--data")) {
+ else if (!HDstrcmp(argv[argno], "--data")) {
data_g = TRUE;
}
else if (!HDstrcmp(argv[argno], "--enable-error-stack")) {
- show_errors_g = TRUE;
- /* deprecated --errors */
+ enable_error_stack = 1;
}
else if (!HDstrcmp(argv[argno], "--errors")) {
- show_errors_g = TRUE;
+ /* deprecated --errors */
+ enable_error_stack = 1;
}
else if (!HDstrcmp(argv[argno], "--follow-symlinks")) {
follow_symlink_g = TRUE;
@@ -2528,7 +2743,7 @@ main(int argc, const char *argv[])
}
else if (!HDstrcmp(argv[argno], "--recursive")) {
recursive_g = TRUE;
- fullname_g = TRUE;
+ fullname_g = TRUE;
}
else if (!HDstrcmp(argv[argno], "--simple")) {
simple_output_g = TRUE;
@@ -2536,11 +2751,40 @@ main(int argc, const char *argv[])
else if (!HDstrcmp(argv[argno], "--string")) {
string_g = TRUE;
}
+ else if (!HDstrncmp(argv[argno], "--vol-value=", (size_t)12)) {
+ vol_info.type = VOL_BY_VALUE;
+ vol_info.u.value = (H5VL_class_value_t)HDatoi(argv[argno] + 12);
+ custom_vol_fapl = TRUE;
+ }
+ else if (!HDstrncmp(argv[argno], "--vol-name=", (size_t)11)) {
+ vol_info.type = VOL_BY_NAME;
+ vol_info.u.name = argv[argno] + 11;
+ custom_vol_fapl = TRUE;
+ }
+ else if (!HDstrncmp(argv[argno], "--vol-info=", (size_t)11)) {
+ vol_info.info_string = argv[argno] + 11;
+ }
else if (!HDstrncmp(argv[argno], "--vfd=", (size_t)6)) {
- preferred_driver = argv[argno]+6;
+ vfd_info.type = VFD_BY_NAME;
+ vfd_info.u.name = argv[argno] + 6;
+ vfd_info.info = NULL;
+ custom_vfd_fapl = TRUE;
+ }
+ else if (!HDstrncmp(argv[argno], "--vfd-value=", (size_t)12)) {
+ vfd_info.type = VFD_BY_VALUE;
+ vfd_info.u.value = (H5FD_class_value_t)HDatoi(argv[argno] + 12);
+ custom_vfd_fapl = TRUE;
+ }
+ else if (!HDstrncmp(argv[argno], "--vfd-name=", (size_t)11)) {
+ vfd_info.type = VFD_BY_NAME;
+ vfd_info.u.name = argv[argno] + 11;
+ custom_vfd_fapl = TRUE;
+ }
+ else if (!HDstrncmp(argv[argno], "--vfd-info=", (size_t)11)) {
+ vfd_info.info = (const void *)(argv[argno] + 11);
}
else if (!HDstrncmp(argv[argno], "--width=", (size_t)8)) {
- width_g = (int)HDstrtol(argv[argno]+8, &rest, 0);
+ width_g = (int)HDstrtol(argv[argno] + 8, &rest, 0);
if (0 == width_g)
no_line_wrap_g = TRUE;
@@ -2586,27 +2830,18 @@ main(int argc, const char *argv[])
}
width_g = (int)HDstrtol(s, &rest, 0);
- if(0 == width_g) {
+ if (0 == width_g) {
no_line_wrap_g = TRUE;
}
- else if(width_g < 0 || *rest) {
+ else if (width_g < 0 || *rest) {
usage();
leave(EXIT_FAILURE);
}
+ }
+ else if (!HDstrncmp(argv[argno], "--s3-cred=", (size_t)10)) {
+#ifdef H5_HAVE_ROS3_VFD
+ char const *start = NULL;
- } else if (!HDstrncmp(argv[argno], "--s3-cred=", (size_t)10)) {
-#ifndef H5_HAVE_ROS3_VFD
- HDfprintf(rawerrorstream, "Error: Read-Only S3 VFD is not enabled\n\n");
- usage();
- leave(EXIT_FAILURE);
-#else
- unsigned nelems = 0;
- char *start = NULL;
- char *s3cred_src = NULL;
- char **s3cred = NULL;
- char const *ccred[3];
- /* try to parse s3 credentials tuple
- */
start = strchr(argv[argno], '=');
if (start == NULL) {
HDfprintf(rawerrorstream,
@@ -2616,130 +2851,43 @@ main(int argc, const char *argv[])
leave(EXIT_FAILURE);
}
start++;
- if (FAIL == parse_tuple((const char *)start, ',', &s3cred_src, &nelems, &s3cred)) {
- HDfprintf(rawerrorstream, "Error: Unable to parse S3 credentials\n\n");
- usage();
- leave(EXIT_FAILURE);
- }
- /* sanity-check tuple count
- */
- if (nelems != 3) {
- HDfprintf(rawerrorstream, "Error: Invalid S3 credentials\n\n");
- usage();
- leave(EXIT_FAILURE);
- }
- ccred[0] = (const char *)s3cred[0];
- ccred[1] = (const char *)s3cred[1];
- ccred[2] = (const char *)s3cred[2];
- if (0 == h5tools_populate_ros3_fapl(&ros3_fa, ccred)) {
- HDfprintf(rawerrorstream, "Error: Invalid S3 credentials\n\n");
+
+ if (h5tools_parse_ros3_fapl_tuple(start, ',', &ros3_fa) < 0) {
+ HDfprintf(rawerrorstream, "Error: failed to parse S3 VFD credential info\n\n");
usage();
leave(EXIT_FAILURE);
}
- HDfree(s3cred);
- HDfree(s3cred_src);
-#endif /* H5_HAVE_ROS3_VFD */
-
+#else
+ HDfprintf(rawerrorstream, "Error: Read-Only S3 VFD is not enabled\n\n");
+ usage();
+ leave(EXIT_FAILURE);
+#endif
}
else if (!HDstrncmp(argv[argno], "--hdfs-attrs=", (size_t)13)) {
-#ifndef H5_HAVE_LIBHDFS
- PRINTVALSTREAM(rawoutstream, "The HDFS VFD is not enabled.\n");
- leave(EXIT_FAILURE);
-#else
- /* Parse received configuration data and set fapl config struct */
-
- hbool_t _debug = FALSE;
- unsigned nelems = 0;
- char const *start = NULL;
- char *props_src = NULL;
- char **props = NULL;
- unsigned long k = 0;
-
- /* try to parse tuple
- */
- if (_debug) {
- HDfprintf(stderr, "configuring hdfs...\n");
- }
- start = argv[argno]+13; /* should never segfault: worst case of */
- if (*start != '(') { /* null-termintor after '='. */
-
- if (_debug) {
- HDfprintf(stderr, " no tuple.\n");
- }
- usage();
- leave(EXIT_FAILURE);
- }
- if (FAIL == parse_tuple((const char *)start, ',', &props_src, &nelems, &props)) {
- HDfprintf(stderr, " unable to parse tuple.\n");
+#ifdef H5_HAVE_LIBHDFS
+ char const *start = NULL;
+
+ start = argv[argno] + 13; /* should never segfault: worst case of */
+ if (*start != '(') { /* null-termintor after '='. */
usage();
leave(EXIT_FAILURE);
}
- /* sanity-check tuple count
- */
- if (nelems != 5) {
- HDfprintf(stderr, " expected 5-ple, got `%d`\n", nelems);
+ if (h5tools_parse_hdfs_fapl_tuple(start, ',', &hdfs_fa) < 0) {
+ HDfprintf(rawerrorstream, "Error: failed to parse HDFS VFD configuration info\n\n");
usage();
leave(EXIT_FAILURE);
}
- if (_debug) {
- HDfprintf(stderr, " got hdfs-attrs tuple: `(%s,%s,%s,%s,%s)`\n",
- props[0], props[1], props[2], props[3], props[4]);
- }
-
- /* Populate fapl configuration structure with given properties.
- * WARNING: No error-checking is done on length of input strings...
- * Silent overflow is possible, albeit unlikely.
- */
- if (HDstrncmp(props[0], "", 1)) {
- if (_debug) {
- HDfprintf(stderr, " setting namenode name: %s\n", props[0]);
- }
- HDstrncpy(hdfs_fa.namenode_name, (const char *)props[0], HDstrlen(props[0]));
- }
- if (HDstrncmp(props[1], "", 1)) {
- k = strtoul((const char *)props[1], NULL, 0);
- if (errno == ERANGE) {
- HDfprintf(stderr, " supposed port number wasn't.\n");
- leave(EXIT_FAILURE);
- }
- if (_debug) {
- HDfprintf(stderr, " setting namenode port: %lu\n", k);
- }
- hdfs_fa.namenode_port = (int32_t)k;
- }
- if (HDstrncmp(props[2], "", 1)) {
- if (_debug) {
- HDfprintf(stderr, " setting kerb cache path: %s\n", props[2]);
- }
- HDstrncpy(hdfs_fa.kerberos_ticket_cache, (const char *)props[2], HDstrlen(props[2]));
- }
- if (HDstrncmp(props[3], "", 1)) {
- if (_debug) {
- HDfprintf(stderr, " setting username: %s\n", props[3]);
- }
- HDstrncpy(hdfs_fa.user_name, (const char *)props[3], HDstrlen(props[3]));
- }
- if (HDstrncmp(props[4], "", 1)) {
- k = HDstrtoul((const char *)props[4], NULL, 0);
- if (errno == ERANGE) {
- HDfprintf(stderr, " supposed buffersize number wasn't.\n");
- leave(EXIT_FAILURE);
- }
- if (_debug) {
- HDfprintf(stderr, " setting stream buffer size: %lu\n", k);
- }
- hdfs_fa.stream_buffer_size = (int32_t)k;
- }
- HDfree(props);
- HDfree(props_src);
-#endif /* H5_HAVE_LIBHDFS */
-
+#else
+ HDfprintf(rawerrorstream, "Error: The HDFS VFD is not enabled\n\n");
+ usage();
+ leave(EXIT_FAILURE);
+#endif
}
- else if('-'!=argv[argno][1]) {
+ else if ('-' != argv[argno][1]) {
/* Single-letter switches */
- for(s = argv[argno] + 1; *s; s++) {
- switch(*s) {
+ for (s = argv[argno] + 1; *s; s++) {
+ switch (*s) {
case '?':
case 'h': /* --help */
usage();
@@ -2756,7 +2904,7 @@ main(int argc, const char *argv[])
/* deprecated -e */
case 'e': /* --errors */
- show_errors_g = TRUE;
+ enable_error_stack = 1;
break;
case 'E': /* --external */
@@ -2777,7 +2925,7 @@ main(int argc, const char *argv[])
case 'r': /* --recursive */
recursive_g = TRUE;
- fullname_g = TRUE;
+ fullname_g = TRUE;
break;
case 'S': /* --simple */
@@ -2805,7 +2953,7 @@ main(int argc, const char *argv[])
usage();
leave(EXIT_FAILURE);
} /* end switch */
- } /* end for */
+ } /* end for */
}
else {
HDfprintf(stderr, "Unknown argument: %s\n", argv[argno]);
@@ -2814,6 +2962,9 @@ main(int argc, const char *argv[])
}
} /* end for */
+ /* enable error reporting if command line option */
+ h5tools_error_report();
+
/* If no arguments remain then print a usage message (instead of doing
* absolutely nothing ;-) */
if (argno >= argc) {
@@ -2827,47 +2978,14 @@ main(int argc, const char *argv[])
leave(EXIT_FAILURE);
}
- if (preferred_driver) {
- void *conf_fa = NULL;
-
- if (!HDstrcmp(preferred_driver, "ros3")) {
-#ifndef H5_HAVE_ROS3_VFD
- HDfprintf(rawerrorstream, "Error: Read-Only S3 VFD not enabled.\n\n");
- usage();
+ /* Setup a custom fapl for file accesses */
+ if (custom_vol_fapl || custom_vfd_fapl) {
+ if ((fapl_id = h5tools_get_fapl(H5P_DEFAULT, custom_vol_fapl ? &vol_info : NULL,
+ custom_vfd_fapl ? &vfd_info : NULL)) < 0) {
+ error_msg("failed to setup file access property list (fapl) for file\n");
leave(EXIT_FAILURE);
-#else
- conf_fa = (void *)&ros3_fa;
-#endif /* H5_HAVE_ROS3_VFD */
-
}
- else if (!HDstrcmp(preferred_driver, "hdfs")) {
-#ifndef H5_HAVE_LIBHDFS
- PRINTVALSTREAM(rawoutstream, "The HDFS VFD is not enabled.\n");
- leave(EXIT_FAILURE);
-#else
- conf_fa = (void *)&hdfs_fa;
-#endif /* H5_HAVE_LIBHDFS */
- }
-
- if (conf_fa != NULL) {
- HDassert(fapl_id == H5P_DEFAULT);
- fapl_id = H5Pcreate(H5P_FILE_ACCESS);
- if (fapl_id < 0) {
- HDfprintf(rawerrorstream, "Error: Unable to create fapl entry\n\n");
- leave(EXIT_FAILURE);
- }
- if (0 == h5tools_set_configured_fapl(fapl_id, preferred_driver, conf_fa)) {
- HDfprintf(rawerrorstream, "Error: Unable to set fapl\n\n");
- usage();
- leave(EXIT_FAILURE);
- }
- }
- } /* preferred_driver defined */
-
- /* Turn off HDF5's automatic error printing unless you're debugging h5ls */
- if(!show_errors_g)
- H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
-
+ }
/* Each remaining argument is an hdf5 file followed by an optional slash
* and object name.
@@ -2881,33 +2999,29 @@ main(int argc, const char *argv[])
* chops off the last component. If we reach the beginning of the name
* then there must have been something wrong with the file (perhaps it
* doesn't exist). */
- show_file_name_g = (argc-argno > 1); /*show file names if more than one*/
- while(argno < argc) {
- H5L_info_t li;
- iter_t iter;
+ show_file_name_g = (argc - argno > 1); /*show file names if more than one*/
+ while (argno < argc) {
+ H5L_info2_t li;
+ iter_t iter;
symlink_trav_t symlink_list;
- size_t u;
+ size_t u;
- fname = HDstrdup(argv[argno++]);
- oname = NULL;
- file = -1;
+ fname = HDstrdup(argv[argno++]);
+ oname = NULL;
+ file_id = H5I_INVALID_HID;
while (fname && *fname) {
- if (fapl_id != H5P_DEFAULT) {
- file = H5Fopen(fname, H5F_ACC_RDONLY, fapl_id);
- }
- else {
- file = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, preferred_driver, drivername, sizeof drivername);
- }
+ file_id = h5tools_fopen(fname, H5F_ACC_RDONLY, fapl_id, (fapl_id != H5P_DEFAULT), drivername,
+ sizeof drivername);
- if (file >= 0) {
+ if (file_id >= 0) {
if (verbose_g)
PRINTSTREAM(rawoutstream, "Opened \"%s\" with %s driver.\n", fname, drivername);
break; /*success*/
- } /* end if */
+ } /* end if */
/* Shorten the file name; lengthen the object name */
- x = oname;
+ x = oname;
oname = HDstrrchr(fname, '/');
if (x)
*x = '/';
@@ -2916,8 +3030,8 @@ main(int argc, const char *argv[])
*oname = '\0';
} /* end while */
- if (file < 0) {
- HDfprintf(rawerrorstream, "%s: unable to open file\n", argv[argno-1]);
+ if (file_id < 0) {
+ HDfprintf(rawerrorstream, "%s: unable to open file\n", argv[argno - 1]);
HDfree(fname);
err_exit = 1;
continue;
@@ -2925,9 +3039,9 @@ main(int argc, const char *argv[])
if (oname) {
/* Always use absolute paths to avoid confusion, keep track of where
* to begin path name output */
- *oname = '/';
+ *oname = '/';
iter.base_len = HDstrlen(oname);
- iter.base_len -= oname[iter.base_len-1] == '/';
+ iter.base_len -= oname[iter.base_len - 1] == '/';
x = oname;
if (NULL == (oname = HDstrdup(oname))) {
HDfprintf(rawerrorstream, "memory allocation failed\n");
@@ -2942,57 +3056,59 @@ main(int argc, const char *argv[])
oname = root_name;
if (recursive_g)
display_root_g = TRUE;
- iter.base_len = 0;
+ iter.base_len = 0;
iter.name_start = 0;
/* Use x to remember if we have allocated space in oname */
x = NULL;
} /* end if */
/* Remember the file information for later */
- iter.fname = fname;
- iter.fid = file;
- iter.gid = -1;
- iter.symlink_target = FALSE;
- iter.symlink_list = &symlink_list;
+ iter.fname = fname;
+ iter.fid = file_id;
+ iter.gid = H5I_INVALID_HID;
+ iter.symlink_target = FALSE;
+ iter.symlink_list = &symlink_list;
iter.symlink_list->dangle_link = FALSE;
/* Initialize list of visited symbolic links */
symlink_list.nused = symlink_list.nalloc = 0;
- symlink_list.objs = NULL;
+ symlink_list.objs = NULL;
/* Check for root group as object name */
- if (HDstrcmp(oname, root_name)) {
+ if (HDstrcmp(oname, root_name) != 0) {
/* Check the type of link given */
- if (H5Lget_info(file, oname, &li, H5P_DEFAULT) < 0) {
- hsize_t curr_pos = 0; /* total data element position */
- h5tools_str_t buffer; /* string into which to render */
- h5tools_context_t ctx; /* print context */
- h5tool_format_t *info = &ls_dataformat;
+ if (H5Lget_info2(file_id, oname, &li, H5P_DEFAULT) < 0) {
+ hsize_t curr_pos = 0; /* total data element position */
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t * info = &ls_dataformat;
HDmemset(&ctx, 0, sizeof(ctx));
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
h5tools_str_reset(&buffer);
print_obj_name(&buffer, &iter, oname, "**NOT FOUND**");
- h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols,
+ (hsize_t)0, (hsize_t)0);
leave(EXIT_FAILURE);
} /* end if */
- } /* end if */
+ } /* end if */
else
li.type = H5L_TYPE_HARD;
/* Open the object and display it's information */
if (li.type == H5L_TYPE_HARD) {
- if (visit_obj(file, oname, &iter) < 0)
+ if (visit_obj(file_id, oname, &iter) < 0) {
leave(EXIT_FAILURE);
+ }
} /* end if(li.type == H5L_TYPE_HARD) */
else {
/* Specified name is not for object -- list that link */
- /* Use file ID for root group ID */
- iter.gid = file;
+ /* Use file_id ID for root group ID */
+ iter.gid = file_id;
list_lnk(oname, &li, &iter);
}
- H5Fclose(file);
+ H5Fclose(file_id);
HDfree(fname);
if (x)
HDfree(oname);
@@ -3022,4 +3138,3 @@ main(int argc, const char *argv[])
else
leave(EXIT_SUCCESS);
} /* end main() */
-
diff --git a/tools/src/h5perf/CMakeLists.txt b/tools/src/h5perf/CMakeLists.txt
new file mode 100644
index 0000000..36b0b2f
--- /dev/null
+++ b/tools/src/h5perf/CMakeLists.txt
@@ -0,0 +1,103 @@
+cmake_minimum_required (VERSION 3.12)
+project (HDF5_TOOLS_SRC_H5PERF C)
+
+# --------------------------------------------------------------------
+# Add the executables
+# --------------------------------------------------------------------
+#-- Adding test for h5perf_serial
+set (h5perf_serial_SOURCES
+ ${HDF5_TOOLS_SRC_H5PERF_SOURCE_DIR}/sio_perf.c
+ ${HDF5_TOOLS_SRC_H5PERF_SOURCE_DIR}/sio_engine.c
+)
+add_executable (h5perf_serial ${h5perf_serial_SOURCES})
+target_include_directories (h5perf_serial PRIVATE "${HDF5_TEST_SRC_DIR};${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+if (NOT ONLY_SHARED_LIBS)
+ TARGET_C_PROPERTIES (h5perf_serial STATIC)
+ target_link_libraries (h5perf_serial PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
+else ()
+ TARGET_C_PROPERTIES (h5perf_serial SHARED)
+ target_link_libraries (h5perf_serial PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
+endif ()
+set_target_properties (h5perf_serial PROPERTIES FOLDER perform)
+set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};h5perf_serial")
+
+set (H5_DEP_EXECUTABLES h5perf_serial)
+
+#-----------------------------------------------------------------------------
+# Add Target to clang-format
+#-----------------------------------------------------------------------------
+if (HDF5_ENABLE_FORMATTERS)
+ clang_format (HDF5_TOOLS_SRC_H5PERF_h5perf_serial_FORMAT h5perf_serial)
+endif ()
+
+if (H5_HAVE_PARALLEL)
+ if (UNIX)
+ #-- Adding test for perf - only on unix systems
+ set (perf_SOURCES
+ ${HDF5_TOOLS_SRC_H5PERF_SOURCE_DIR}/perf.c
+ )
+ add_executable (perf ${perf_SOURCES})
+ target_include_directories (perf PRIVATE "${HDF5_TEST_SRC_DIR};${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ if (NOT ONLY_SHARED_LIBS)
+ TARGET_C_PROPERTIES (perf STATIC)
+ target_link_libraries (perf PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET} "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_LIBRARIES}>")
+ else ()
+ TARGET_C_PROPERTIES (perf SHARED)
+ target_link_libraries (perf PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_LIBRARIES}>")
+ endif ()
+ set_target_properties (perf PROPERTIES FOLDER perform)
+ set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};perf")
+
+ set (H5_DEP_EXECUTABLES perf)
+
+ #-----------------------------------------------------------------------------
+ # Add Target to clang-format
+ #-----------------------------------------------------------------------------
+ if (HDF5_ENABLE_FORMATTERS)
+ clang_format (HDF5_TOOLS_SRC_H5PERF_perf_FORMAT perf)
+ endif ()
+ endif ()
+
+ #-- Adding test for h5perf
+ set (h5perf_SOURCES
+ ${HDF5_TOOLS_SRC_H5PERF_SOURCE_DIR}/pio_perf.c
+ ${HDF5_TOOLS_SRC_H5PERF_SOURCE_DIR}/pio_engine.c
+ )
+ add_executable (h5perf ${h5perf_SOURCES})
+ target_include_directories (h5perf PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ if (NOT ONLY_SHARED_LIBS)
+ TARGET_C_PROPERTIES (h5perf STATIC)
+ target_link_libraries (h5perf PRIVATE ${LINK_LIBS} ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET} "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_LIBRARIES}>")
+ else ()
+ TARGET_C_PROPERTIES (h5perf SHARED)
+ target_link_libraries (h5perf PRIVATE ${LINK_LIBS} ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_LIBRARIES}>")
+ endif ()
+ set_target_properties (h5perf PROPERTIES FOLDER perform)
+ set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};h5perf")
+
+ set (H5_DEP_EXECUTABLES h5perf)
+
+ #-----------------------------------------------------------------------------
+ # Add Target to clang-format
+ #-----------------------------------------------------------------------------
+ if (HDF5_ENABLE_FORMATTERS)
+ clang_format (HDF5_TOOLS_SRC_H5PERF_h5perf_FORMAT h5perf)
+ endif ()
+endif ()
+
+#-----------------------------------------------------------------------------
+# Rules for Installation of tools using make Install target
+#-----------------------------------------------------------------------------
+if (HDF5_EXPORTED_TARGETS)
+ foreach (exec ${H5_DEP_EXECUTABLES})
+ INSTALL_PROGRAM_PDB (${exec} ${HDF5_INSTALL_BIN_DIR} toolsapplications)
+ endforeach ()
+
+ install (
+ TARGETS
+ ${H5_DEP_EXECUTABLES}
+ EXPORT
+ ${HDF5_EXPORTED_TARGETS}
+ RUNTIME DESTINATION ${HDF5_INSTALL_BIN_DIR} COMPONENT toolsapplications
+ )
+endif ()
diff --git a/tools/src/h5perf/Makefile.am b/tools/src/h5perf/Makefile.am
new file mode 100644
index 0000000..e8a9fdd
--- /dev/null
+++ b/tools/src/h5perf/Makefile.am
@@ -0,0 +1,63 @@
+#
+# Copyright by The HDF Group.
+# Copyright by the Board of Trustees of the University of Illinois.
+# All rights reserved.
+#
+# This file is part of HDF5. The full HDF5 copyright notice, including
+# terms governing use, modification, and redistribution, is contained in
+# the COPYING file, which can be found at the root of the source code
+# distribution tree, or in https://www.hdfgroup.org/licenses.
+# If you do not have access to either file, you may request a copy from
+# help@hdfgroup.org.
+##
+## Makefile.am
+## Run automake to generate a Makefile.in from this file.
+##
+#
+# HDF5 Library Performance Makefile(.in)
+#
+
+include $(top_srcdir)/config/commence.am
+
+AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/test -I$(top_srcdir)/tools/lib
+
+# bin_PROGRAMS will be installed.
+if BUILD_PARALLEL_CONDITIONAL
+ bin_PROGRAMS=h5perf_serial perf h5perf
+else
+ bin_PROGRAMS=h5perf_serial
+endif
+
+# Add h5perf and h5perf_serial specific linker flags here
+h5perf_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS)
+h5perf_serial_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS)
+
+# Some programs are not built or run by default, but can be built by hand or by
+# specifying --enable-build-all at configure time.
+# Also, some of these programs should only be built in parallel.
+# Currently there is no such program.
+if BUILD_PARALLEL_CONDITIONAL
+ PARA_BUILD_ALL=
+endif
+if BUILD_ALL_CONDITIONAL
+ BUILD_ALL_PROGS=$(PARA_BUILD_ALL)
+endif
+
+# Define programs that will be run in 'make check'
+# List them in the order they should be run.
+# Parallel test programs.
+if BUILD_PARALLEL_CONDITIONAL
+ TEST_PROG_PARA=h5perf perf
+endif
+
+h5perf_SOURCES=pio_perf.c pio_engine.c
+h5perf_serial_SOURCES=sio_perf.c sio_engine.c
+
+# All of the programs depend on the main hdf5 library, and some of them
+# depend on test or tools library.
+LDADD=$(LIBHDF5)
+h5perf_LDADD=$(LIBH5TOOLS) $(LIBHDF5)
+h5perf_serial_LDADD=$(LIBH5TOOLS) $(LIBHDF5)
+perf_LDADD=$(LIBHDF5)
+
+include $(top_srcdir)/config/conclude.am
diff --git a/tools/src/h5perf/perf.c b/tools/src/h5perf/perf.c
new file mode 100644
index 0000000..84be7e8
--- /dev/null
+++ b/tools/src/h5perf/perf.c
@@ -0,0 +1,796 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Author: Albert Cheng of NCSA, May 1, 2001.
+ * This is derived from code given to me by Robert Ross.
+ *
+ * NOTE: This code assumes that all command line arguments make it out to all
+ * the processes that make up the parallel job, which isn't always the case.
+ * So if it doesn't work on some platform, that might be why.
+ */
+
+#include "hdf5.h"
+#include "H5private.h"
+
+#ifdef H5_HAVE_PARALLEL
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+#ifdef H5_HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+
+#ifdef H5_HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+
+#ifdef H5_HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+#ifdef H5_HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include <mpi.h>
+#ifndef MPI_FILE_NULL /*MPIO may be defined in mpi.h already */
+#include <mpio.h>
+#endif
+
+/* Macro definitions */
+/* Verify:
+ * if val is false (0), print mesg and if fatal is true (non-zero), die.
+ */
+#define H5FATAL 1
+#define VRFY(val, mesg, fatal) \
+ do { \
+ if (!val) { \
+ printf("Proc %d: ", mynod); \
+ printf("*** Assertion failed (%s) at line %4d in %s\n", mesg, (int)__LINE__, __FILE__); \
+ if (fatal) { \
+ fflush(stdout); \
+ goto die_jar_jar_die; \
+ } \
+ } \
+ } while (0)
+#define RANK 1
+#define MAX_PATH 1024
+
+hsize_t dims[RANK]; /* dataset dim sizes */
+hsize_t block[RANK], stride[RANK], count[RANK];
+hsize_t start[RANK];
+hid_t fid; /* HDF5 file ID */
+hid_t acc_tpl; /* File access templates */
+hid_t sid; /* Dataspace ID */
+hid_t file_dataspace; /* File dataspace ID */
+hid_t mem_dataspace; /* memory dataspace ID */
+hid_t dataset; /* Dataset ID */
+hsize_t opt_alignment = 1;
+hsize_t opt_threshold = 1;
+int opt_split_vfd = 0;
+char * meta_ext, *raw_ext; /* holds the meta and raw file extension if */
+ /* opt_split_vfd is set */
+
+/* DEFAULT VALUES FOR OPTIONS */
+int64_t opt_block = 1048576 * 16;
+int opt_iter = 1;
+int opt_stripe = -1;
+int opt_correct = 0;
+int amode = O_RDWR | O_CREAT;
+char opt_file[256] = "perftest.out";
+char opt_pvfstab[256] = "notset";
+int opt_pvfstab_set = 0;
+
+const char *FILENAME[] = {opt_file, NULL};
+
+/* function prototypes */
+static int parse_args(int argc, char **argv);
+
+#ifndef H5_HAVE_UNISTD_H
+/* globals needed for getopt */
+extern char *optarg;
+#endif
+
+#ifndef HDF5_PARAPREFIX
+#define HDF5_PARAPREFIX ""
+#endif
+char * paraprefix = NULL; /* for command line option para-prefix */
+MPI_Info h5_io_info_g = MPI_INFO_NULL; /* MPI INFO object for IO */
+
+static char *h5_fixname_real(const char *base_name, hid_t fapl, const char *_suffix, char *fullname,
+ size_t size, hbool_t nest_printf, hbool_t subst_for_superblock);
+
+int
+main(int argc, char **argv)
+{
+ char * buf = NULL, *tmp = NULL, *buf2 = NULL, *tmp2 = NULL, *check = NULL;
+ int i, j, mynod = 0, nprocs = 1, my_correct = 1, correct, myerrno;
+ double stim, etim;
+ double write_tim = 0;
+ double read_tim = 0;
+ double read_bw, write_bw;
+ double max_read_tim, max_write_tim;
+ double min_read_tim, min_write_tim;
+ double ave_read_tim, ave_write_tim;
+ int64_t iter_jump = 0;
+ char filename[MAX_PATH];
+ herr_t ret; /* Generic return value */
+
+ /* startup MPI and determine the rank of this process */
+ MPI_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+ MPI_Comm_rank(MPI_COMM_WORLD, &mynod);
+
+ /* parse the command line arguments */
+ parse_args(argc, argv);
+
+ if (mynod == 0)
+ printf("# Using hdf5-io calls.\n");
+
+#ifdef H5_HAVE_UNISTD_H
+ /* Kind of a weird hack- if the location of the pvfstab file was
+ * specified on the command line, then spit out this location into
+ * the appropriate environment variable.
+ */
+ if (opt_pvfstab_set) {
+ if ((setenv("PVFSTAB_FILE", opt_pvfstab, 1)) < 0) {
+ perror("setenv");
+ goto die_jar_jar_die;
+ }
+ }
+#endif
+
+ /* this is how much of the file data is covered on each iteration of
+ * the test. used to help determine the seek offset on each
+ * iteration */
+ iter_jump = nprocs * opt_block;
+
+ /* setup a buffer of data to write */
+ if (!(tmp = (char *)malloc((size_t)opt_block + 256))) {
+ perror("malloc");
+ goto die_jar_jar_die;
+ }
+ buf = tmp + 128 - (((long)tmp) % 128); /* align buffer */
+
+ if (opt_correct) {
+ /* do the same buffer setup for verifiable data */
+ if (!(tmp2 = (char *)malloc((size_t)opt_block + 256))) {
+ perror("malloc2");
+ goto die_jar_jar_die;
+ }
+ buf2 = tmp + 128 - (((long)tmp) % 128);
+ }
+
+ /* setup file access template with parallel IO access. */
+ if (opt_split_vfd) {
+ hid_t mpio_pl;
+
+ mpio_pl = H5Pcreate(H5P_FILE_ACCESS);
+ VRFY((acc_tpl >= 0), "", H5FATAL);
+ ret = H5Pset_fapl_mpio(mpio_pl, MPI_COMM_WORLD, MPI_INFO_NULL);
+ VRFY((ret >= 0), "", H5FATAL);
+
+ /* set optional allocation alignment */
+ if (opt_alignment * opt_threshold != 1) {
+ ret = H5Pset_alignment(acc_tpl, opt_threshold, opt_alignment);
+ VRFY((ret >= 0), "H5Pset_alignment succeeded", !H5FATAL);
+ }
+
+ /* setup file access template */
+ acc_tpl = H5Pcreate(H5P_FILE_ACCESS);
+ VRFY((acc_tpl >= 0), "", H5FATAL);
+ ret = H5Pset_fapl_split(acc_tpl, meta_ext, mpio_pl, raw_ext, mpio_pl);
+ VRFY((ret >= 0), "H5Pset_fapl_split succeeded", H5FATAL);
+ ret = H5Pclose(mpio_pl);
+ VRFY((ret >= 0), "H5Pclose mpio_pl succeeded", H5FATAL);
+ }
+ else {
+ /* setup file access template */
+ acc_tpl = H5Pcreate(H5P_FILE_ACCESS);
+ VRFY((acc_tpl >= 0), "", H5FATAL);
+ ret = H5Pset_fapl_mpio(acc_tpl, MPI_COMM_WORLD, MPI_INFO_NULL);
+ VRFY((ret >= 0), "", H5FATAL);
+
+ /* set optional allocation alignment */
+ if (opt_alignment * opt_threshold != 1) {
+ ret = H5Pset_alignment(acc_tpl, opt_threshold, opt_alignment);
+ VRFY((ret >= 0), "H5Pset_alignment succeeded", !H5FATAL);
+ }
+ }
+
+ h5_fixname_real(FILENAME[0], acc_tpl, NULL, filename, sizeof filename, FALSE, FALSE);
+
+ /* create the parallel file */
+ fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, acc_tpl);
+ VRFY((fid >= 0), "H5Fcreate succeeded", H5FATAL);
+
+ /* define a contiquous dataset of opt_iter*nprocs*opt_block chars */
+ dims[0] = (hsize_t)opt_iter * (hsize_t)nprocs * (hsize_t)opt_block;
+ sid = H5Screate_simple(RANK, dims, NULL);
+ VRFY((sid >= 0), "H5Screate_simple succeeded", H5FATAL);
+ dataset = H5Dcreate2(fid, "Dataset1", H5T_NATIVE_CHAR, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ VRFY((dataset >= 0), "H5Dcreate2 succeeded", H5FATAL);
+
+ /* create the memory dataspace and the file dataspace */
+ dims[0] = (hsize_t)opt_block;
+ mem_dataspace = H5Screate_simple(RANK, dims, NULL);
+ VRFY((mem_dataspace >= 0), "", H5FATAL);
+ file_dataspace = H5Dget_space(dataset);
+ VRFY((file_dataspace >= 0), "H5Dget_space succeeded", H5FATAL);
+
+ /* now each process writes a block of opt_block chars in round robbin
+ * fashion until the whole dataset is covered.
+ */
+ for (j = 0; j < opt_iter; j++) {
+ /* setup a file dataspace selection */
+ start[0] = (hsize_t)((j * iter_jump) + (mynod * opt_block));
+ stride[0] = block[0] = (hsize_t)opt_block;
+ count[0] = 1;
+ ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block);
+ VRFY((ret >= 0), "H5Sset_hyperslab succeeded", H5FATAL);
+
+ if (opt_correct) /* fill in buffer for iteration */ {
+ for (i = mynod + j, check = buf; i < opt_block; i++, check++)
+ *check = (char)i;
+ }
+
+ /* discover the starting time of the operation */
+ MPI_Barrier(MPI_COMM_WORLD);
+ stim = MPI_Wtime();
+
+ /* write data */
+ ret = H5Dwrite(dataset, H5T_NATIVE_CHAR, mem_dataspace, file_dataspace, H5P_DEFAULT, buf);
+ VRFY((ret >= 0), "H5Dwrite dataset1 succeeded", !H5FATAL);
+
+ /* discover the ending time of the operation */
+ etim = MPI_Wtime();
+
+ write_tim += (etim - stim);
+
+ /* we are done with this "write" iteration */
+ }
+
+ /* close dataset and file */
+ ret = H5Dclose(dataset);
+ VRFY((ret >= 0), "H5Dclose succeeded", H5FATAL);
+ ret = H5Fclose(fid);
+ VRFY((ret >= 0), "H5Fclose succeeded", H5FATAL);
+
+ /* wait for everyone to synchronize at this point */
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ /* reopen the file for reading */
+ fid = H5Fopen(filename, H5F_ACC_RDONLY, acc_tpl);
+ VRFY((fid >= 0), "", H5FATAL);
+
+ /* open the dataset */
+ dataset = H5Dopen2(fid, "Dataset1", H5P_DEFAULT);
+ VRFY((dataset >= 0), "H5Dopen succeeded", H5FATAL);
+
+ /* we can re-use the same mem_dataspace and file_dataspace
+ * the H5Dwrite used since the dimension size is the same.
+ */
+
+ /* we are going to repeat the read the same pattern the write used */
+ for (j = 0; j < opt_iter; j++) {
+ /* setup a file dataspace selection */
+ start[0] = (hsize_t)((j * iter_jump) + (mynod * opt_block));
+ stride[0] = block[0] = (hsize_t)opt_block;
+ count[0] = 1;
+ ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block);
+ VRFY((ret >= 0), "H5Sset_hyperslab succeeded", H5FATAL);
+ /* seek to the appropriate spot give the current iteration and
+ * rank within the MPI processes */
+
+ /* discover the start time */
+ MPI_Barrier(MPI_COMM_WORLD);
+ stim = MPI_Wtime();
+
+ /* read in the file data */
+ if (!opt_correct) {
+ ret = H5Dread(dataset, H5T_NATIVE_CHAR, mem_dataspace, file_dataspace, H5P_DEFAULT, buf);
+ }
+ else {
+ ret = H5Dread(dataset, H5T_NATIVE_CHAR, mem_dataspace, file_dataspace, H5P_DEFAULT, buf2);
+ }
+ myerrno = errno;
+
+ /* discover the end time */
+ etim = MPI_Wtime();
+ read_tim += (etim - stim);
+ VRFY((ret >= 0), "H5Dwrite dataset1 succeeded", !H5FATAL);
+
+ if (ret < 0)
+ HDfprintf(stderr, "node %d, read error, loc = %" PRId64 ": %s\n", mynod, mynod * opt_block,
+ strerror(myerrno));
+
+ /* if the user wanted to check correctness, compare the write
+ * buffer to the read buffer */
+ if (opt_correct && memcmp(buf, buf2, (size_t)opt_block)) {
+ HDfprintf(stderr, "node %d, correctness test failed\n", mynod);
+ my_correct = 0;
+ MPI_Allreduce(&my_correct, &correct, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD);
+ }
+
+ /* we are done with this read iteration */
+ }
+
+ /* close dataset and file */
+ ret = H5Dclose(dataset);
+ VRFY((ret >= 0), "H5Dclose succeeded", H5FATAL);
+ ret = H5Fclose(fid);
+ VRFY((ret >= 0), "H5Fclose succeeded", H5FATAL);
+ ret = H5Pclose(acc_tpl);
+ VRFY((ret >= 0), "H5Pclose succeeded", H5FATAL);
+
+ /* compute the read and write times */
+ MPI_Allreduce(&read_tim, &max_read_tim, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD);
+ MPI_Allreduce(&read_tim, &min_read_tim, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD);
+ MPI_Allreduce(&read_tim, &ave_read_tim, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
+
+ /* calculate the average from the sum */
+ ave_read_tim = ave_read_tim / nprocs;
+
+ MPI_Allreduce(&write_tim, &max_write_tim, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD);
+ MPI_Allreduce(&write_tim, &min_write_tim, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD);
+ MPI_Allreduce(&write_tim, &ave_write_tim, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
+
+ /* calculate the average from the sum */
+ ave_write_tim = ave_write_tim / nprocs;
+
+ /* print out the results on one node */
+ if (mynod == 0) {
+ read_bw = (double)((int64_t)(opt_block * nprocs * opt_iter)) / (max_read_tim * 1000000.0);
+ write_bw = (double)((int64_t)(opt_block * nprocs * opt_iter)) / (max_write_tim * 1000000.0);
+
+ printf("nr_procs = %d, nr_iter = %d, blk_sz = %ld\n", nprocs, opt_iter, (long)opt_block);
+
+ printf("# total_size = %ld\n", (long)(opt_block * nprocs * opt_iter));
+
+ printf("# Write: min_time = %f, max_time = %f, mean_time = %f\n", min_write_tim, max_write_tim,
+ ave_write_tim);
+ printf("# Read: min_time = %f, max_time = %f, mean_time = %f\n", min_read_tim, max_read_tim,
+ ave_read_tim);
+
+ printf("Write bandwidth = %f Mbytes/sec\n", write_bw);
+ printf("Read bandwidth = %f Mbytes/sec\n", read_bw);
+
+ if (opt_correct) {
+ printf("Correctness test %s.\n", correct ? "passed" : "failed");
+ }
+ }
+
+die_jar_jar_die:
+
+#ifdef H5_HAVE_UNISTD
+ /* Clear the environment variable if it was set earlier */
+ if (opt_pvfstab_set) {
+ unsetenv("PVFSTAB_FILE");
+ }
+#endif
+
+ free(tmp);
+ if (opt_correct)
+ free(tmp2);
+
+ MPI_Finalize();
+
+ return (0);
+}
+
+static int
+parse_args(int argc, char **argv)
+{
+ int c;
+
+ while ((c = getopt(argc, argv, "s:b:i:f:p:a:2:c")) != EOF) {
+ switch (c) {
+ case 's': /* stripe */
+ opt_stripe = atoi(optarg);
+ break;
+ case 'b': /* block size */
+ opt_block = atoi(optarg);
+ break;
+ case 'i': /* iterations */
+ opt_iter = atoi(optarg);
+ break;
+ case 'f': /* filename */
+ strncpy(opt_file, optarg, 255);
+ FILENAME[0] = opt_file;
+ break;
+ case 'p': /* pvfstab file */
+ strncpy(opt_pvfstab, optarg, 255);
+ opt_pvfstab_set = 1;
+ break;
+ case 'a': /* aligned allocation.
+ * syntax: -a<alignment>/<threshold>
+ * e.g., -a4096/512 allocate at 4096 bytes
+ * boundary if request size >= 512.
+ */
+ {
+ char *p;
+
+ opt_alignment = (hsize_t)HDatoi(optarg);
+ if (NULL != (p = (char *)HDstrchr(optarg, '/')))
+ opt_threshold = (hsize_t)HDatoi(p + 1);
+ }
+ HDfprintf(stdout, "alignment/threshold=%" PRIuHSIZE "/%" PRIuHSIZE "\n", opt_alignment,
+ opt_threshold);
+ break;
+ case '2': /* use 2-files, i.e., split file driver */
+ opt_split_vfd = 1;
+ /* get meta and raw file extension. */
+ /* syntax is <raw_ext>,<meta_ext> */
+ meta_ext = raw_ext = optarg;
+ while (*raw_ext != '\0') {
+ if (*raw_ext == ',') {
+ *raw_ext = '\0';
+ raw_ext++;
+ break;
+ }
+ raw_ext++;
+ }
+ printf("split-file-vfd used: %s,%s\n", meta_ext, raw_ext);
+ break;
+ case 'c': /* correctness */
+ opt_correct = 1;
+ break;
+ case '?': /* unknown */
+ default:
+ break;
+ }
+ }
+
+ return (0);
+}
+/*-------------------------------------------------------------------------
+ * Function: getenv_all
+ *
+ * Purpose: Used to get the environment that the root MPI task has.
+ * name specifies which environment variable to look for
+ * val is the string to which the value of that environment
+ * variable will be copied.
+ *
+ * NOTE: The pointer returned by this function is only
+ * valid until the next call to getenv_all and the data
+ * stored there must be copied somewhere else before any
+ * further calls to getenv_all take place.
+ *
+ * Return: pointer to a string containing the value of the environment variable
+ * NULL if the varialbe doesn't exist in task 'root's environment.
+ *
+ * Programmer: Leon Arber
+ * 4/4/05
+ *
+ * Modifications:
+ * Use original getenv if MPI is not initialized. This happens
+ * one uses the PHDF5 library to build a serial nature code.
+ * Albert 2006/04/07
+ *
+ *-------------------------------------------------------------------------
+ */
+char *
+getenv_all(MPI_Comm comm, int root, const char *name)
+{
+ int mpi_size, mpi_rank, mpi_initialized, mpi_finalized;
+ int len;
+ static char *env = NULL;
+
+ HDassert(name);
+
+ MPI_Initialized(&mpi_initialized);
+ MPI_Finalized(&mpi_finalized);
+
+ if (mpi_initialized && !mpi_finalized) {
+ MPI_Comm_rank(comm, &mpi_rank);
+ MPI_Comm_size(comm, &mpi_size);
+ HDassert(root < mpi_size);
+
+ /* The root task does the getenv call
+ * and sends the result to the other tasks */
+ if (mpi_rank == root) {
+ env = HDgetenv(name);
+ if (env) {
+ len = (int)HDstrlen(env);
+ MPI_Bcast(&len, 1, MPI_INT, root, comm);
+ MPI_Bcast(env, len, MPI_CHAR, root, comm);
+ }
+ else {
+ /* len -1 indicates that the variable was not in the environment */
+ len = -1;
+ MPI_Bcast(&len, 1, MPI_INT, root, comm);
+ }
+ }
+ else {
+ MPI_Bcast(&len, 1, MPI_INT, root, comm);
+ if (len >= 0) {
+ if (env == NULL)
+ env = (char *)HDmalloc((size_t)len + 1);
+ else if (HDstrlen(env) < (size_t)len)
+ env = (char *)HDrealloc(env, (size_t)len + 1);
+
+ MPI_Bcast(env, len, MPI_CHAR, root, comm);
+ env[len] = '\0';
+ }
+ else {
+ if (env)
+ HDfree(env);
+ env = NULL;
+ }
+ }
+#ifndef NDEBUG
+ MPI_Barrier(comm);
+#endif
+ }
+ else {
+ /* use original getenv */
+ if (env)
+ HDfree(env);
+ env = HDgetenv(name);
+ } /* end if */
+
+ return env;
+}
+
+/*-------------------------------------------------------------------------
+ * Function: h5_fixname_real
+ *
+ * Purpose: Create a file name from a file base name like `test' and
+ * return it through the FULLNAME (at most SIZE characters
+ * counting the null terminator). The full name is created by
+ * prepending the contents of HDF5_PREFIX (separated from the
+ * base name by a slash) and appending a file extension based on
+ * the driver supplied, resulting in something like
+ * `ufs:/u/matzke/test.h5'.
+ *
+ * Return: Success: The FULLNAME pointer.
+ *
+ * Failure: NULL if BASENAME or FULLNAME is the null
+ * pointer or if FULLNAME isn't large enough for
+ * the result.
+ *
+ * Programmer: Robb Matzke
+ * Thursday, November 19, 1998
+ *
+ *-------------------------------------------------------------------------
+ */
+static char *
+h5_fixname_real(const char *base_name, hid_t fapl, const char *_suffix, char *fullname, size_t size,
+ hbool_t nest_printf, hbool_t subst_for_superblock)
+{
+ const char *prefix = NULL;
+ const char *env = NULL; /* HDF5_DRIVER environment variable */
+ char * ptr, last = '\0';
+ const char *suffix = _suffix;
+ size_t i, j;
+ hid_t driver = -1;
+ int isppdriver = 0; /* if the driver is MPI parallel */
+
+ if (!base_name || !fullname || size < 1)
+ return NULL;
+
+ HDmemset(fullname, 0, size);
+
+ /* figure out the suffix */
+ if (H5P_DEFAULT != fapl) {
+ if ((driver = H5Pget_driver(fapl)) < 0)
+ return NULL;
+
+ if (suffix) {
+ if (H5FD_FAMILY == driver) {
+ if (subst_for_superblock)
+ suffix = "00000.h5";
+ else
+ suffix = nest_printf ? "%%05d.h5" : "%05d.h5";
+ }
+ else if (H5FD_MULTI == driver) {
+
+ /* Get the environment variable, if it exists, in case
+ * we are using the split driver since both of those
+ * use the multi VFD under the hood.
+ */
+ env = HDgetenv(HDF5_DRIVER);
+#ifdef HDF5_DRIVER
+ /* Use the environment variable, then the compile-time constant */
+ if (!env)
+ env = HDF5_DRIVER;
+#endif
+ if (env && !HDstrcmp(env, "split")) {
+ /* split VFD */
+ if (subst_for_superblock)
+ suffix = "-m.h5";
+ else
+ suffix = NULL;
+ }
+ else {
+ /* multi VFD */
+ if (subst_for_superblock)
+ suffix = "-s.h5";
+ else
+ suffix = NULL;
+ }
+ }
+ }
+ }
+
+ /* Must first check fapl is not H5P_DEFAULT (-1) because H5FD_XXX
+ * could be of value -1 if it is not defined.
+ */
+ isppdriver = H5P_DEFAULT != fapl && (H5FD_MPIO == driver);
+
+ /* Check what prefix to use for test files. Process HDF5_PARAPREFIX and
+ * HDF5_PREFIX.
+ * Use different ones depending on parallel or serial driver used.
+ * (The #ifdef is needed to prevent compile failure in case MPI is not
+ * configured.)
+ */
+ if (isppdriver) {
+ /*
+ * For parallel:
+ * First use command line option, then the environment
+ * variable, then try the constant
+ */
+ static int explained = 0;
+
+ prefix = (paraprefix ? paraprefix : getenv_all(MPI_COMM_WORLD, 0, "HDF5_PARAPREFIX"));
+
+ if (!prefix && !explained) {
+ /* print hint by process 0 once. */
+ int mpi_rank;
+
+ MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
+
+ if (mpi_rank == 0)
+ HDprintf("*** Hint ***\n"
+ "You can use environment variable HDF5_PARAPREFIX to "
+ "run parallel test files in a\n"
+ "different directory or to add file type prefix. e.g.,\n"
+ " HDF5_PARAPREFIX=pfs:/PFS/user/me\n"
+ " export HDF5_PARAPREFIX\n"
+ "*** End of Hint ***\n");
+
+ explained = TRUE;
+#ifdef HDF5_PARAPREFIX
+ prefix = HDF5_PARAPREFIX;
+#endif /* HDF5_PARAPREFIX */
+ }
+ }
+ else {
+ /*
+ * For serial:
+ * First use the environment variable, then try the constant
+ */
+ prefix = HDgetenv("HDF5_PREFIX");
+
+#ifdef HDF5_PREFIX
+ if (!prefix)
+ prefix = HDF5_PREFIX;
+#endif /* HDF5_PREFIX */
+ }
+
+ /* Prepend the prefix value to the base name */
+ if (prefix && *prefix) {
+ if (isppdriver) {
+ /* This is a parallel system */
+ char *subdir;
+
+ if (!HDstrcmp(prefix, HDF5_PARAPREFIX)) {
+ /*
+ * If the prefix specifies the HDF5_PARAPREFIX directory, then
+ * default to using the "/tmp/$USER" or "/tmp/$LOGIN"
+ * directory instead.
+ */
+ char *user, *login;
+
+ user = HDgetenv("USER");
+ login = HDgetenv("LOGIN");
+ subdir = (user ? user : login);
+
+ if (subdir) {
+ for (i = 0; i < size && prefix[i]; i++)
+ fullname[i] = prefix[i];
+
+ fullname[i++] = '/';
+
+ for (j = 0; i < size && subdir[j]; ++i, ++j)
+ fullname[i] = subdir[j];
+ }
+ }
+
+ if (!fullname[0]) {
+ /* We didn't append the prefix yet */
+ HDstrncpy(fullname, prefix, size);
+ fullname[size - 1] = '\0';
+ }
+
+ if (HDstrlen(fullname) + HDstrlen(base_name) + 1 < size) {
+ /*
+ * Append the base_name with a slash first. Multiple
+ * slashes are handled below.
+ */
+ h5_stat_t buf;
+
+ if (HDstat(fullname, &buf) < 0)
+ /* The directory doesn't exist just yet */
+ if (HDmkdir(fullname, (mode_t)0755) < 0 && errno != EEXIST)
+ /*
+ * We couldn't make the "/tmp/${USER,LOGIN}"
+ * subdirectory. Default to PREFIX's original
+ * prefix value.
+ */
+ HDstrcpy(fullname, prefix);
+
+ HDstrcat(fullname, "/");
+ HDstrcat(fullname, base_name);
+ }
+ else {
+ /* Buffer is too small */
+ return NULL;
+ }
+ }
+ else {
+ if (HDsnprintf(fullname, size, "%s/%s", prefix, base_name) == (int)size)
+ /* Buffer is too small */
+ return NULL;
+ }
+ }
+ else if (HDstrlen(base_name) >= size) {
+ /* Buffer is too small */
+ return NULL;
+ }
+ else {
+ HDstrcpy(fullname, base_name);
+ }
+
+ /* Append a suffix */
+ if (suffix) {
+ if (HDstrlen(fullname) + HDstrlen(suffix) >= size)
+ return NULL;
+
+ HDstrcat(fullname, suffix);
+ }
+
+ /* Remove any double slashes in the filename */
+ for (ptr = fullname, i = j = 0; ptr && i < size; i++, ptr++) {
+ if (*ptr != '/' || last != '/')
+ fullname[j++] = *ptr;
+
+ last = *ptr;
+ }
+
+ return fullname;
+}
+
+/*
+ * Local variables:
+ * c-indent-level: 3
+ * c-basic-offset: 3
+ * tab-width: 3
+ * End:
+ */
+
+#else /* H5_HAVE_PARALLEL */
+/* dummy program since H5_HAVE_PARALLEL is not configured in */
+int
+main(int H5_ATTR_UNUSED argc, char H5_ATTR_UNUSED **argv)
+{
+ printf("No parallel performance because parallel is not configured in\n");
+ return (0);
+}
+#endif /* H5_HAVE_PARALLEL */
diff --git a/tools/src/h5perf/pio_engine.c b/tools/src/h5perf/pio_engine.c
new file mode 100644
index 0000000..1baaca2
--- /dev/null
+++ b/tools/src/h5perf/pio_engine.c
@@ -0,0 +1,2745 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Author: Albert Cheng of NCSA, Oct 24, 2001.
+ */
+
+#include "hdf5.h"
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef H5_HAVE_UNISTD_H
+#include <sys/types.h>
+#include <unistd.h>
+#endif
+
+#ifdef H5_HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+
+#ifdef H5_HAVE_PARALLEL
+
+#include <mpi.h>
+
+#ifndef MPI_FILE_NULL /*MPIO may be defined in mpi.h already */
+#include <mpio.h>
+#endif /* !MPI_FILE_NULL */
+
+#include "pio_perf.h"
+
+/* Macro definitions */
+
+#if H5_VERS_MAJOR == 1 && H5_VERS_MINOR == 6
+#define H5DCREATE(fd, name, type, space, dcpl) H5Dcreate(fd, name, type, space, dcpl)
+#define H5DOPEN(fd, name) H5Dopen(fd, name)
+#else
+#define H5DCREATE(fd, name, type, space, dcpl) \
+ H5Dcreate2(fd, name, type, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)
+#define H5DOPEN(fd, name) H5Dopen2(fd, name, H5P_DEFAULT)
+#endif
+
+/* sizes of various items. these sizes won't change during program execution */
+/* The following three must have the same type */
+#define ELMT_H5_TYPE H5T_NATIVE_UCHAR
+
+#define GOTOERROR(errcode) \
+ { \
+ ret_code = errcode; \
+ goto done; \
+ }
+#define ERRMSG(mesg) \
+ { \
+ HDfprintf(stderr, "Proc %d: ", pio_mpi_rank_g); \
+ HDfprintf(stderr, "*** Assertion failed (%s) at line %4d in %s\n", mesg, (int)__LINE__, __FILE__); \
+ }
+
+/* verify: if val is false (0), print mesg. */
+#define VRFY(val, mesg) \
+ do { \
+ if (!val) { \
+ ERRMSG(mesg); \
+ GOTOERROR(FAIL); \
+ } \
+ } while (0)
+
+/* POSIX I/O macros */
+#ifdef H5_HAVE_WIN32_API
+/* Can't link against the library, so this test will use the older, non-Unicode
+ * _open() call on Windows.
+ */
+#define HDopen(S, F, ...) _open(S, F | _O_BINARY, __VA_ARGS__)
+#endif /* H5_HAVE_WIN32_API */
+#define POSIXCREATE(fn) HDopen(fn, O_CREAT | O_TRUNC | O_RDWR, 0600)
+#define POSIXOPEN(fn, F) HDopen(fn, F, 0600)
+#define POSIXCLOSE(F) HDclose(F)
+#define POSIXSEEK(F, L) HDlseek(F, L, SEEK_SET)
+#define POSIXWRITE(F, B, S) HDwrite(F, B, S)
+#define POSIXREAD(F, B, S) HDread(F, B, S)
+
+enum { PIO_CREATE = 1, PIO_WRITE = 2, PIO_READ = 4 };
+
+/* Global variables */
+static int clean_file_g = -1; /*whether to cleanup temporary test */
+/*files. -1 is not defined; */
+/*0 is no cleanup; 1 is do cleanup */
+
+/*
+ * In a parallel machine, the filesystem suitable for compiling is
+ * unlikely a parallel file system that is suitable for parallel I/O.
+ * There is no standard pathname for the parallel file system. /tmp
+ * is about the best guess.
+ */
+#ifndef HDF5_PARAPREFIX
+#define HDF5_PARAPREFIX ""
+#endif /* !HDF5_PARAPREFIX */
+
+#ifndef MIN
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+#endif /* !MIN */
+
+/* the different types of file descriptors we can expect */
+typedef union _file_descr {
+ int posixfd; /* POSIX file handle*/
+ MPI_File mpifd; /* MPI file */
+ hid_t h5fd; /* HDF5 file */
+} file_descr;
+
+/* local functions */
+static char * pio_create_filename(iotype iot, const char *base_name, char *fullname, size_t size);
+static herr_t do_write(results *res, file_descr *fd, parameters *parms, long ndsets, off_t nelmts,
+ size_t buf_size, void *buffer);
+static herr_t do_read(results *res, file_descr *fd, parameters *parms, long ndsets, off_t nelmts,
+ size_t buf_size, void *buffer /*out*/);
+static herr_t do_fopen(parameters *param, char *fname, file_descr *fd /*out*/, int flags);
+static herr_t do_fclose(iotype iot, file_descr *fd);
+static void do_cleanupfile(iotype iot, char *fname);
+static off_t sqrto(off_t);
+
+/*
+ * Function: do_pio
+ * Purpose: PIO Engine where Parallel IO are executed.
+ * Return: results
+ * Programmer: Albert Cheng, Bill Wendling 2001/12/12
+ * Modifications:
+ * Added 2D testing (Christian Chilan, 10. August 2005)
+ */
+results
+do_pio(parameters param)
+{
+ /* return codes */
+ herr_t ret_code = 0; /*return code */
+ results res;
+
+ file_descr fd;
+ iotype iot;
+
+ char fname[FILENAME_MAX];
+ long nf;
+ long ndsets;
+ off_t nbytes; /*number of bytes per dataset */
+ off_t snbytes; /*general dataset size */
+ /*for 1D, it is the actual dataset size */
+ /*for 2D, it is the size of a side of the dataset square */
+ char * buffer = NULL; /*data buffer pointer */
+ size_t buf_size; /*general buffer size in bytes */
+ /*for 1D, it is the actual buffer size */
+ /*for 2D, it is the length of the buffer rectangle */
+ size_t blk_size; /*data block size in bytes */
+ size_t bsize; /*actual buffer size */
+
+ /* HDF5 variables */
+ herr_t hrc; /*HDF5 return code */
+
+ /* Sanity check parameters */
+
+ /* IO type */
+ iot = param.io_type;
+
+ switch (iot) {
+ case MPIO:
+ fd.mpifd = MPI_FILE_NULL;
+ res.timers = io_time_new(MPI_CLOCK);
+ break;
+ case POSIXIO:
+ fd.posixfd = -1;
+ res.timers = io_time_new(MPI_CLOCK);
+ break;
+ case PHDF5:
+ fd.h5fd = -1;
+ res.timers = io_time_new(MPI_CLOCK);
+ break;
+ default:
+ /* unknown request */
+ HDfprintf(stderr, "Unknown IO type request (%d)\n", iot);
+ GOTOERROR(FAIL);
+ }
+
+ ndsets = param.num_dsets; /* number of datasets per file */
+ nbytes = param.num_bytes; /* number of bytes per dataset */
+ buf_size = param.buf_size;
+ blk_size = param.blk_size;
+
+ if (!param.dim2d) {
+ snbytes = nbytes; /* General dataset size */
+ bsize = buf_size; /* Actual buffer size */
+ }
+ else {
+ snbytes = sqrto(nbytes); /* General dataset size */
+ bsize = buf_size * blk_size; /* Actual buffer size */
+ }
+
+ if (param.num_files < 0) {
+ HDfprintf(stderr, "number of files must be >= 0 (%ld)\n", param.num_files);
+ GOTOERROR(FAIL);
+ }
+
+ if (ndsets < 0) {
+ HDfprintf(stderr, "number of datasets per file must be >= 0 (%ld)\n", ndsets);
+ GOTOERROR(FAIL);
+ }
+
+ if (param.num_procs <= 0) {
+ HDfprintf(stderr, "maximum number of process to use must be > 0 (%d)\n", param.num_procs);
+ GOTOERROR(FAIL);
+ }
+
+ /* Validate transfer buffer size & block size*/
+ if (blk_size <= 0) {
+ HDfprintf(stderr, "Transfer block size (%zu) must be > 0\n", blk_size);
+ GOTOERROR(FAIL);
+ }
+ if (buf_size <= 0) {
+ HDfprintf(stderr, "Transfer buffer size (%zu) must be > 0\n", buf_size);
+ GOTOERROR(FAIL);
+ }
+ if ((buf_size % blk_size) != 0) {
+ HDfprintf(stderr,
+ "Transfer buffer size (%zu) must be a multiple of the "
+ "interleaved I/O block size (%zu)\n",
+ buf_size, blk_size);
+ GOTOERROR(FAIL);
+ }
+ if ((snbytes % pio_mpi_nprocs_g) != 0) {
+ HDfprintf(stderr,
+ "Dataset size (%" H5_PRINTF_LL_WIDTH "d) must be a multiple of the "
+ "number of processes (%d)\n",
+ (long long)snbytes, pio_mpi_nprocs_g);
+ GOTOERROR(FAIL);
+ }
+
+ if (!param.dim2d) {
+ if (((size_t)(snbytes / pio_mpi_nprocs_g) % buf_size) != 0) {
+ HDfprintf(stderr,
+ "Dataset size/process (%" H5_PRINTF_LL_WIDTH "d) must be a multiple of the "
+ "transfer buffer size (%zu)\n",
+ (long long)(snbytes / pio_mpi_nprocs_g), buf_size);
+ GOTOERROR(FAIL);
+ }
+ }
+ else {
+ if (((size_t)snbytes % buf_size) != 0) {
+ HDfprintf(stderr,
+ "Dataset side size (%" H5_PRINTF_LL_WIDTH "d) must be a multiple of the "
+ "transfer buffer size (%zu)\n",
+ (long long)snbytes, buf_size);
+ GOTOERROR(FAIL);
+ }
+ }
+
+ /* Allocate transfer buffer */
+ if ((buffer = malloc(bsize)) == NULL) {
+ HDfprintf(stderr, "malloc for transfer buffer size (%zu) failed\n", bsize);
+ GOTOERROR(FAIL);
+ }
+
+ if (pio_debug_level >= 4) {
+ int myrank;
+
+ MPI_Comm_rank(pio_comm_g, &myrank);
+
+ /* output all of the times for all iterations */
+ if (myrank == 0)
+ HDfprintf(output, "Timer details:\n");
+ }
+
+ for (nf = 1; nf <= param.num_files; nf++) {
+ /*
+ * Write performance measurement
+ */
+ /* Open file for write */
+ char base_name[256];
+
+ HDsnprintf(base_name, sizeof(base_name), "#pio_tmp_%lu", nf);
+ pio_create_filename(iot, base_name, fname, sizeof(fname));
+ if (pio_debug_level > 0)
+ HDfprintf(output, "rank %d: data filename=%s\n", pio_mpi_rank_g, fname);
+
+ /* Need barrier to make sure everyone starts at the same time */
+ MPI_Barrier(pio_comm_g);
+
+ io_time_set(res.timers, HDF5_GROSS_WRITE_FIXED_DIMS, TSTART);
+ hrc = do_fopen(&param, fname, &fd, PIO_CREATE | PIO_WRITE);
+
+ VRFY((hrc == SUCCESS), "do_fopen failed");
+
+ io_time_set(res.timers, HDF5_FINE_WRITE_FIXED_DIMS, TSTART);
+ hrc = do_write(&res, &fd, &param, ndsets, nbytes, buf_size, buffer);
+ io_time_set(res.timers, HDF5_FINE_WRITE_FIXED_DIMS, TSTOP);
+
+ VRFY((hrc == SUCCESS), "do_write failed");
+
+ /* Close file for write */
+ hrc = do_fclose(iot, &fd);
+
+ io_time_set(res.timers, HDF5_GROSS_WRITE_FIXED_DIMS, TSTOP);
+ VRFY((hrc == SUCCESS), "do_fclose failed");
+
+ if (!param.h5_write_only) {
+ /*
+ * Read performance measurement
+ */
+ /* Need barrier to make sure everyone is done writing and has
+ * closed the file. Also to make sure everyone starts reading
+ * at the same time.
+ */
+ MPI_Barrier(pio_comm_g);
+
+ /* Open file for read */
+ io_time_set(res.timers, HDF5_GROSS_READ_FIXED_DIMS, TSTART);
+ hrc = do_fopen(&param, fname, &fd, PIO_READ);
+
+ VRFY((hrc == SUCCESS), "do_fopen failed");
+
+ io_time_set(res.timers, HDF5_FINE_READ_FIXED_DIMS, TSTART);
+ hrc = do_read(&res, &fd, &param, ndsets, nbytes, buf_size, buffer);
+ io_time_set(res.timers, HDF5_FINE_READ_FIXED_DIMS, TSTOP);
+ VRFY((hrc == SUCCESS), "do_read failed");
+
+ /* Close file for read */
+ hrc = do_fclose(iot, &fd);
+
+ io_time_set(res.timers, HDF5_GROSS_READ_FIXED_DIMS, TSTOP);
+ VRFY((hrc == SUCCESS), "do_fclose failed");
+ }
+
+ /* Need barrier to make sure everyone is done with the file */
+ /* before it may be removed by do_cleanupfile */
+ MPI_Barrier(pio_comm_g);
+ do_cleanupfile(iot, fname);
+ }
+
+done:
+ /* clean up */
+ /* release HDF5 objects */
+
+ /* close any opened files */
+ /* no remove(fname) because that should have happened normally. */
+ switch (iot) {
+ case POSIXIO:
+ if (fd.posixfd != -1)
+ hrc = do_fclose(iot, &fd);
+ break;
+ case MPIO:
+ if (fd.mpifd != MPI_FILE_NULL)
+ hrc = do_fclose(iot, &fd);
+ break;
+ case PHDF5:
+ if (fd.h5fd != -1)
+ hrc = do_fclose(iot, &fd);
+ break;
+ default:
+ break;
+ }
+
+ /* release generic resources */
+ if (buffer)
+ HDfree(buffer);
+ res.ret_code = ret_code;
+ return res;
+}
+
+/*
+ * Function: pio_create_filename
+ * Purpose: Create a new filename to write to. Determine the correct
+ * suffix to append to the filename by the type of I/O we're
+ * doing. Also, place in the /tmp/{$USER,$LOGIN} directory if
+ * USER or LOGIN are specified in the environment.
+ * Return: Pointer to filename or NULL
+ * Programmer: Bill Wendling, 21. November 2001
+ * Modifications:
+ */
+static char *
+pio_create_filename(iotype iot, const char *base_name, char *fullname, size_t size)
+{
+ const char *prefix, *suffix = "";
+ char * ptr, last = '\0';
+ size_t i, j;
+
+ if (!base_name || !fullname || size < 1)
+ return NULL;
+
+ HDmemset(fullname, 0, size);
+
+ switch (iot) {
+ case POSIXIO:
+ suffix = ".posix";
+ break;
+ case MPIO:
+ suffix = ".mpio";
+ break;
+ case PHDF5:
+ suffix = ".h5";
+ break;
+ default:
+ break;
+ }
+
+ /* First use the environment variable and then try the constant */
+ prefix = HDgetenv("HDF5_PARAPREFIX");
+
+#ifdef HDF5_PARAPREFIX
+ if (!prefix)
+ prefix = HDF5_PARAPREFIX;
+#endif /* HDF5_PARAPREFIX */
+
+ /* Prepend the prefix value to the base name */
+ if (prefix && *prefix) {
+ /* If the prefix specifies the HDF5_PARAPREFIX directory, then
+ * default to using the "/tmp/$USER" or "/tmp/$LOGIN"
+ * directory instead. */
+ char *user, *login, *subdir;
+
+ user = HDgetenv("USER");
+ login = HDgetenv("LOGIN");
+ subdir = (user ? user : login);
+
+ if (subdir) {
+ for (i = 0; i < size - 1 && prefix[i]; i++)
+ fullname[i] = prefix[i];
+
+ fullname[i++] = '/';
+
+ for (j = 0; i < size && subdir[j]; i++, j++)
+ fullname[i] = subdir[j];
+ }
+ else {
+ /* We didn't append the prefix yet */
+ HDstrncpy(fullname, prefix, size);
+ fullname[size - 1] = '\0';
+ }
+
+ if ((HDstrlen(fullname) + HDstrlen(base_name) + 1) < size) {
+ /* Append the base_name with a slash first. Multiple slashes are
+ * handled below. */
+ h5_stat_t buf;
+
+ if (HDstat(fullname, &buf) < 0)
+ /* The directory doesn't exist just yet */
+ if (HDmkdir(fullname, (mode_t)0755) < 0 && errno != EEXIST) {
+ /* We couldn't make the "/tmp/${USER,LOGIN}" subdirectory.
+ * Default to PREFIX's original prefix value. */
+ HDstrcpy(fullname, prefix);
+ }
+
+ HDstrcat(fullname, "/");
+ HDstrcat(fullname, base_name);
+ }
+ else {
+ /* Buffer is too small */
+ return NULL;
+ }
+ }
+ else if (HDstrlen(base_name) >= size) {
+ /* Buffer is too small */
+ return NULL;
+ }
+ else {
+ HDstrcpy(fullname, base_name);
+ }
+
+ /* Append a suffix */
+ if (suffix) {
+ if (HDstrlen(fullname) + HDstrlen(suffix) >= size)
+ return NULL;
+
+ HDstrcat(fullname, suffix);
+ }
+
+ /* Remove any double slashes in the filename */
+ for (ptr = fullname, i = j = 0; ptr && i < size; i++, ptr++) {
+ if (*ptr != '/' || last != '/')
+ fullname[j++] = *ptr;
+
+ last = *ptr;
+ }
+
+ return fullname;
+}
+
+/*
+ * Function: do_write
+ * Purpose: Write the required amount of data to the file.
+ * Return: SUCCESS or FAIL
+ * Programmer: Albert Cheng, Bill Wendling, 2001/12/13
+ * Modifications:
+ * Added 2D testing (Christian Chilan, 10. August 2005)
+ */
+static herr_t
+do_write(results *res, file_descr *fd, parameters *parms, long ndsets, off_t nbytes, size_t buf_size,
+ void *buffer)
+{
+ int ret_code = SUCCESS;
+ int rc; /*routine return code */
+ long ndset;
+ size_t blk_size; /* The block size to subdivide the xfer buffer into */
+ off_t nbytes_xfer; /* Total number of bytes transferred so far */
+ size_t nbytes_xfer_advance; /* Number of bytes transferred in a single I/O operation */
+ size_t nbytes_toxfer; /* Number of bytes to transfer a particular time */
+ char dname[64];
+ off_t dset_offset = 0; /*dataset offset in a file */
+ off_t bytes_begin[2]; /*first elmt this process transfer */
+ off_t bytes_count; /*number of elmts this process transfer */
+ off_t snbytes = 0; /*size of a side of the dataset square */
+ unsigned char *buf_p; /* Current buffer pointer */
+
+ /* POSIX variables */
+ off_t file_offset; /* File offset of the next transfer */
+ off_t file_offset_advance; /* File offset advance after each I/O operation */
+ off_t posix_file_offset; /* Base file offset of the next transfer */
+
+ /* MPI variables */
+ MPI_Offset mpi_file_offset; /* Base file offset of the next transfer*/
+ MPI_Offset mpi_offset; /* Offset in MPI file */
+ MPI_Offset mpi_offset_advance; /* Offset advance after each I/O operation */
+ MPI_Datatype mpi_file_type; /* MPI derived type for 1D file */
+ MPI_Datatype mpi_blk_type; /* MPI derived type for 1D buffer */
+ MPI_Datatype mpi_cont_type; /* MPI derived type for 2D contiguous file */
+ MPI_Datatype mpi_partial_buffer_cont; /* MPI derived type for partial 2D contiguous buffer */
+ MPI_Datatype mpi_inter_type; /* MPI derived type for 2D interleaved file */
+ MPI_Datatype mpi_partial_buffer_inter; /* MPI derived type for partial 2D interleaved buffer */
+ MPI_Datatype mpi_full_buffer; /* MPI derived type for 2D full buffer */
+ MPI_Datatype mpi_full_chunk; /* MPI derived type for 2D full chunk */
+ MPI_Datatype mpi_chunk_inter_type; /* MPI derived type for 2D chunk interleaved file */
+ MPI_Datatype mpi_collective_type; /* Generic MPI derived type for 2D collective access */
+ MPI_Status mpi_status;
+ int mrc; /* MPI return code */
+
+ /* HDF5 variables */
+ herr_t hrc; /*HDF5 return code */
+ hsize_t h5dims[2]; /*dataset dim sizes */
+ hid_t h5dset_space_id = H5I_INVALID_HID; /*dataset space ID */
+ hid_t h5mem_space_id = H5I_INVALID_HID; /*memory dataspace ID */
+ hid_t h5ds_id = H5I_INVALID_HID; /*dataset handle */
+ hsize_t h5block[2]; /*dataspace selection */
+ hsize_t h5stride[2];
+ hsize_t h5count[2];
+ hsize_t h5start[2];
+ hssize_t h5offset[2]; /* Selection offset within dataspace */
+ hid_t h5dcpl = H5I_INVALID_HID; /* Dataset creation property list */
+ hid_t h5dxpl = H5I_INVALID_HID; /* Dataset transfer property list */
+
+ /* Get the parameters from the parameter block */
+ blk_size = parms->blk_size;
+
+ /* There are two kinds of transfer patterns, contiguous and interleaved.
+ * Let 0,1,2,...,n be data accessed by process 0,1,2,...,n
+ * where n is rank of the last process.
+ * In contiguous pattern, data are accessed as
+ * 000...111...222...nnn...
+ * In interleaved pattern, data are accessed as
+ * 012...n012...n...
+ * These are all in the scope of one dataset.
+ */
+
+ /* 1D dataspace */
+ if (!parms->dim2d) {
+ /* Contiguous Pattern: */
+ if (!parms->interleaved) {
+ bytes_begin[0] = (off_t)(((double)nbytes * pio_mpi_rank_g) / pio_mpi_nprocs_g);
+ } /* end if */
+ /* Interleaved Pattern: */
+ else {
+ bytes_begin[0] = (off_t)(blk_size * (size_t)pio_mpi_rank_g);
+ } /* end else */
+
+ /* Prepare buffer for verifying data */
+ if (parms->verify)
+ memset(buffer, pio_mpi_rank_g + 1, buf_size);
+ } /* end if */
+ /* 2D dataspace */
+ else {
+ /* nbytes is always the number of bytes per dataset (1D or 2D). If the
+ dataspace is 2D, snbytes is the size of a side of the dataset square.
+ */
+ snbytes = sqrto(nbytes);
+
+ /* Contiguous Pattern: */
+ if (!parms->interleaved) {
+ bytes_begin[0] = (off_t)((double)snbytes * pio_mpi_rank_g / pio_mpi_nprocs_g);
+ bytes_begin[1] = 0;
+ } /* end if */
+ /* Interleaved Pattern: */
+ else {
+ bytes_begin[0] = 0;
+
+ if (!parms->h5_use_chunks || parms->io_type == PHDF5)
+ bytes_begin[1] = (off_t)(blk_size * (size_t)pio_mpi_rank_g);
+ else
+ bytes_begin[1] = (off_t)(blk_size * blk_size * (size_t)pio_mpi_rank_g);
+ } /* end else */
+
+ /* Prepare buffer for verifying data */
+ if (parms->verify)
+ HDmemset(buffer, pio_mpi_rank_g + 1, buf_size * blk_size);
+ } /* end else */
+
+ /* Calculate the total number of bytes (bytes_count) to be
+ * transferred by this process. It may be different for different
+ * transfer pattern due to rounding to integral values.
+ */
+ /*
+ * Calculate the beginning bytes of this process and the next.
+ * bytes_count is the difference between these two beginnings.
+ * This way, it eliminates any rounding errors.
+ * (This is tricky, don't mess with the formula, rounding errors
+ * can easily get introduced) */
+ bytes_count = (off_t)(((double)nbytes * (pio_mpi_rank_g + 1)) / pio_mpi_nprocs_g) -
+ (off_t)(((double)nbytes * pio_mpi_rank_g) / pio_mpi_nprocs_g);
+
+ /* debug */
+ if (pio_debug_level >= 4) {
+ HDprint_rank(output);
+ if (!parms->dim2d) {
+ HDfprintf(output,
+ "Debug(do_write): "
+ "buf_size=%zu, bytes_begin=%" H5_PRINTF_LL_WIDTH "d, bytes_count=%" H5_PRINTF_LL_WIDTH
+ "d\n",
+ buf_size, (long long)bytes_begin[0], (long long)bytes_count);
+ }
+ else {
+ HDfprintf(output,
+ "Debug(do_write): "
+ "linear buf_size=%zu, bytes_begin=(%" H5_PRINTF_LL_WIDTH "d,%" H5_PRINTF_LL_WIDTH
+ "d), bytes_count=%" H5_PRINTF_LL_WIDTH "d\n",
+ buf_size * blk_size, (long long)bytes_begin[0], (long long)bytes_begin[1],
+ (long long)bytes_count);
+ }
+ }
+
+ /* I/O Access specific setup */
+ switch (parms->io_type) {
+ case POSIXIO:
+ /* No extra setup */
+ break;
+
+ case MPIO: /* MPI-I/O setup */
+ /* 1D dataspace */
+ if (!parms->dim2d) {
+ /* Build block's derived type */
+ mrc = MPI_Type_contiguous((int)blk_size, MPI_BYTE, &mpi_blk_type);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_CREATE");
+
+ /* Build file's derived type */
+ mrc = MPI_Type_vector((int)(buf_size / blk_size), (int)1, (int)pio_mpi_nprocs_g, mpi_blk_type,
+ &mpi_file_type);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_CREATE");
+
+ /* Commit file type */
+ mrc = MPI_Type_commit(&mpi_file_type);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_COMMIT");
+
+ /* Commit buffer type */
+ mrc = MPI_Type_commit(&mpi_blk_type);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_COMMIT");
+ } /* end if */
+ /* 2D dataspace */
+ else {
+ /* Build partial buffer derived type for contiguous access */
+
+ mrc = MPI_Type_contiguous((int)buf_size, MPI_BYTE, &mpi_partial_buffer_cont);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_CREATE");
+
+ /* Commit partial buffer derived type */
+ mrc = MPI_Type_commit(&mpi_partial_buffer_cont);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_COMMIT");
+
+ /* Build contiguous file's derived type */
+ mrc = MPI_Type_vector((int)blk_size, (int)1, (int)((size_t)snbytes / buf_size),
+ mpi_partial_buffer_cont, &mpi_cont_type);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_CREATE");
+
+ /* Commit contiguous file type */
+ mrc = MPI_Type_commit(&mpi_cont_type);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_COMMIT");
+
+ /* Build partial buffer derived type for interleaved access */
+ mrc = MPI_Type_contiguous((int)blk_size, MPI_BYTE, &mpi_partial_buffer_inter);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_CREATE");
+
+ /* Commit partial buffer derived type */
+ mrc = MPI_Type_commit(&mpi_partial_buffer_inter);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_COMMIT");
+
+ /* Build interleaved file's derived type */
+ mrc = MPI_Type_vector((int)buf_size, (int)1, (int)((size_t)snbytes / blk_size),
+ mpi_partial_buffer_inter, &mpi_inter_type);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_CREATE");
+
+ /* Commit interleaved file type */
+ mrc = MPI_Type_commit(&mpi_inter_type);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_COMMIT");
+
+ /* Build full buffer derived type */
+ mrc = MPI_Type_contiguous((int)(blk_size * buf_size), MPI_BYTE, &mpi_full_buffer);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_CREATE");
+
+ /* Commit full buffer derived type */
+ mrc = MPI_Type_commit(&mpi_full_buffer);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_COMMIT");
+
+ /* Build full chunk derived type */
+ mrc = MPI_Type_contiguous((int)(blk_size * blk_size), MPI_BYTE, &mpi_full_chunk);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_CREATE");
+
+ /* Commit full chunk derived type */
+ mrc = MPI_Type_commit(&mpi_full_chunk);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_COMMIT");
+
+ /* Build chunk interleaved file's derived type */
+ mrc = MPI_Type_vector((int)(buf_size / blk_size), (int)1, (int)((size_t)snbytes / blk_size),
+ mpi_full_chunk, &mpi_chunk_inter_type);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_CREATE");
+
+ /* Commit chunk interleaved file type */
+ mrc = MPI_Type_commit(&mpi_chunk_inter_type);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_COMMIT");
+
+ } /* end else */
+ break;
+
+ case PHDF5: /* HDF5 setup */
+ /* 1D dataspace */
+ if (!parms->dim2d) {
+ if (nbytes > 0) {
+ /* define a contiguous dataset of nbytes native bytes */
+ h5dims[0] = (hsize_t)nbytes;
+ h5dset_space_id = H5Screate_simple(1, h5dims, NULL);
+ VRFY((h5dset_space_id >= 0), "H5Screate_simple");
+
+ /* Set up the file dset space id to select the pattern to access */
+ if (!parms->interleaved) {
+ /* Contiguous pattern */
+ h5start[0] = (hsize_t)bytes_begin[0];
+ h5stride[0] = h5block[0] = blk_size;
+ h5count[0] = buf_size / blk_size;
+ } /* end if */
+ else {
+ /* Interleaved access pattern */
+ /* Skip offset over blocks of other processes */
+ h5start[0] = (hsize_t)bytes_begin[0];
+ h5stride[0] = blk_size * (size_t)pio_mpi_nprocs_g;
+ h5block[0] = blk_size;
+ h5count[0] = buf_size / blk_size;
+ } /* end else */
+ hrc = H5Sselect_hyperslab(h5dset_space_id, H5S_SELECT_SET, h5start, h5stride, h5count,
+ h5block);
+ VRFY((hrc >= 0), "H5Sselect_hyperslab");
+ } /* end if */
+ else {
+ h5dset_space_id = H5Screate(H5S_SCALAR);
+ VRFY((h5dset_space_id >= 0), "H5Screate");
+ } /* end else */
+
+ /* Create the memory dataspace that corresponds to the xfer buffer */
+ if (buf_size > 0) {
+ h5dims[0] = buf_size;
+ h5mem_space_id = H5Screate_simple(1, h5dims, NULL);
+ VRFY((h5mem_space_id >= 0), "H5Screate_simple");
+ } /* end if */
+ else {
+ h5mem_space_id = H5Screate(H5S_SCALAR);
+ VRFY((h5mem_space_id >= 0), "H5Screate");
+ } /* end else */
+ } /* end if */
+ /* 2D dataspace */
+ else {
+ if (nbytes > 0) {
+ /* define a contiguous dataset of nbytes native bytes */
+ h5dims[0] = (hsize_t)snbytes;
+ h5dims[1] = (hsize_t)snbytes;
+ h5dset_space_id = H5Screate_simple(2, h5dims, NULL);
+ VRFY((h5dset_space_id >= 0), "H5Screate_simple");
+
+ /* Set up the file dset space id to select the pattern to access */
+ if (!parms->interleaved) {
+ /* Contiguous pattern */
+ h5start[0] = (hsize_t)bytes_begin[0];
+ h5start[1] = (hsize_t)bytes_begin[1];
+ h5stride[0] = 1;
+ h5stride[1] = h5block[0] = h5block[1] = blk_size;
+ h5count[0] = 1;
+ h5count[1] = buf_size / blk_size;
+ } /* end if */
+ else {
+ /* Interleaved access pattern */
+ /* Skip offset over blocks of other processes */
+ h5start[0] = (hsize_t)bytes_begin[0];
+ h5start[1] = (hsize_t)bytes_begin[1];
+ h5stride[0] = blk_size;
+ h5stride[1] = blk_size * (size_t)pio_mpi_nprocs_g;
+ h5block[0] = h5block[1] = blk_size;
+ h5count[0] = buf_size / blk_size;
+ h5count[1] = 1;
+ } /* end else */
+ hrc = H5Sselect_hyperslab(h5dset_space_id, H5S_SELECT_SET, h5start, h5stride, h5count,
+ h5block);
+ VRFY((hrc >= 0), "H5Sselect_hyperslab");
+ } /* end if */
+ else {
+ h5dset_space_id = H5Screate(H5S_SCALAR);
+ VRFY((h5dset_space_id >= 0), "H5Screate");
+ } /* end else */
+
+ /* Create the memory dataspace that corresponds to the xfer buffer */
+ if (buf_size > 0) {
+ if (!parms->interleaved) {
+ h5dims[0] = blk_size;
+ h5dims[1] = buf_size;
+ }
+ else {
+ h5dims[0] = buf_size;
+ h5dims[1] = blk_size;
+ }
+ h5mem_space_id = H5Screate_simple(2, h5dims, NULL);
+ VRFY((h5mem_space_id >= 0), "H5Screate_simple");
+ } /* end if */
+ else {
+ h5mem_space_id = H5Screate(H5S_SCALAR);
+ VRFY((h5mem_space_id >= 0), "H5Screate");
+ } /* end else */
+ } /* end else */
+
+ /* Create the dataset transfer property list */
+ h5dxpl = H5Pcreate(H5P_DATASET_XFER);
+ if (h5dxpl < 0) {
+ HDfprintf(stderr, "HDF5 Property List Create failed\n");
+ GOTOERROR(FAIL);
+ }
+
+ /* Change to collective I/O, if asked */
+ if (parms->collective) {
+ hrc = H5Pset_dxpl_mpio(h5dxpl, H5FD_MPIO_COLLECTIVE);
+ if (hrc < 0) {
+ HDfprintf(stderr, "HDF5 Property List Set failed\n");
+ GOTOERROR(FAIL);
+ } /* end if */
+ } /* end if */
+ break;
+
+ default:
+ break;
+ } /* end switch */
+
+ for (ndset = 1; ndset <= ndsets; ++ndset) {
+
+ /* Calculate dataset offset within a file */
+
+ /* create dataset */
+ switch (parms->io_type) {
+ case POSIXIO:
+ case MPIO:
+ /* both posix and mpi io just need dataset offset in file*/
+ dset_offset = (ndset - 1) * nbytes;
+ break;
+
+ case PHDF5:
+ h5dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ if (h5dcpl < 0) {
+ HDfprintf(stderr, "HDF5 Property List Create failed\n");
+ GOTOERROR(FAIL);
+ }
+ /* 1D dataspace */
+ if (!parms->dim2d) {
+ /* Make the dataset chunked if asked */
+ if (parms->h5_use_chunks) {
+ /* Set the chunk size to be the same as the buffer size */
+ h5dims[0] = blk_size;
+ hrc = H5Pset_chunk(h5dcpl, 1, h5dims);
+ if (hrc < 0) {
+ HDfprintf(stderr, "HDF5 Property List Set failed\n");
+ GOTOERROR(FAIL);
+ } /* end if */
+ } /* end if */
+ } /* end if */
+ else {
+ /* 2D dataspace */
+ if (parms->h5_use_chunks) {
+ /* Set the chunk size to be the same as the block size */
+ h5dims[0] = blk_size;
+ h5dims[1] = blk_size;
+ hrc = H5Pset_chunk(h5dcpl, 2, h5dims);
+ if (hrc < 0) {
+ HDfprintf(stderr, "HDF5 Property List Set failed\n");
+ GOTOERROR(FAIL);
+ } /* end if */
+ } /* end if */
+ } /* end else */
+
+ HDsnprintf(dname, sizeof(dname), "Dataset_%ld", ndset);
+ h5ds_id = H5DCREATE(fd->h5fd, dname, ELMT_H5_TYPE, h5dset_space_id, h5dcpl);
+
+ if (h5ds_id < 0) {
+ HDfprintf(stderr, "HDF5 Dataset Create failed\n");
+ GOTOERROR(FAIL);
+ }
+
+ hrc = H5Pclose(h5dcpl);
+ /* verifying the close of the dcpl */
+ if (hrc < 0) {
+ HDfprintf(stderr, "HDF5 Property List Close failed\n");
+ GOTOERROR(FAIL);
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ /* The task is to transfer bytes_count bytes, starting at
+ * bytes_begin position, using transfer buffer of buf_size bytes.
+ * If interleaved, select buf_size at a time, in round robin
+ * fashion, according to number of process. Otherwise, select
+ * all bytes_count in contiguous.
+ */
+ nbytes_xfer = 0;
+
+ /* 1D dataspace */
+ if (!parms->dim2d) {
+ /* Set base file offset for all I/O patterns and POSIX access */
+ posix_file_offset = dset_offset + bytes_begin[0];
+
+ /* Set base file offset for all I/O patterns and MPI access */
+ mpi_file_offset = (MPI_Offset)(dset_offset + bytes_begin[0]);
+ } /* end if */
+ else {
+ /* Set base file offset for all I/O patterns and POSIX access */
+ posix_file_offset = dset_offset + bytes_begin[0] * snbytes + bytes_begin[1];
+
+ /* Set base file offset for all I/O patterns and MPI access */
+ mpi_file_offset = (MPI_Offset)(dset_offset + bytes_begin[0] * snbytes + bytes_begin[1]);
+ } /* end else */
+
+ /* Start "raw data" write timer */
+ io_time_set(res->timers, HDF5_RAW_WRITE_FIXED_DIMS, TSTART);
+
+ while (nbytes_xfer < bytes_count) {
+ /* Write */
+ /* Calculate offset of write within a dataset/file */
+ switch (parms->io_type) {
+ case POSIXIO:
+ /* 1D dataspace */
+ if (!parms->dim2d) {
+ /* Contiguous pattern */
+ if (!parms->interleaved) {
+ /* Compute file offset */
+ file_offset = posix_file_offset + (off_t)nbytes_xfer;
+
+ /* only care if seek returns error */
+ rc = POSIXSEEK(fd->posixfd, file_offset) < 0 ? -1 : 0;
+ VRFY((rc == 0), "POSIXSEEK");
+
+ /* check if all bytes are written */
+ rc = ((ssize_t)buf_size == POSIXWRITE(fd->posixfd, buffer, buf_size));
+ VRFY((rc != 0), "POSIXWRITE");
+
+ /* Advance global offset in dataset */
+ nbytes_xfer += (ssize_t)buf_size;
+ } /* end if */
+ /* Interleaved access pattern */
+ else {
+ /* Set the base of user's buffer */
+ buf_p = (unsigned char *)buffer;
+
+ /* Set the number of bytes to transfer this time */
+ nbytes_toxfer = buf_size;
+
+ /* Loop over the buffers to write */
+ while (nbytes_toxfer > 0) {
+ /* Skip offset over blocks of other processes */
+ file_offset = posix_file_offset + (off_t)(nbytes_xfer * pio_mpi_nprocs_g);
+
+ /* only care if seek returns error */
+ rc = POSIXSEEK(fd->posixfd, file_offset) < 0 ? -1 : 0;
+ VRFY((rc == 0), "POSIXSEEK");
+
+ /* check if all bytes are written */
+ rc = ((ssize_t)blk_size == POSIXWRITE(fd->posixfd, buf_p, blk_size));
+ VRFY((rc != 0), "POSIXWRITE");
+
+ /* Advance location in buffer */
+ buf_p += blk_size;
+
+ /* Advance global offset in dataset */
+ nbytes_xfer += (ssize_t)blk_size;
+
+ /* Decrement number of bytes left this time */
+ nbytes_toxfer -= blk_size;
+ } /* end while */
+ } /* end else */
+ } /* end if */
+ /* 2D dataspace */
+ else {
+ /* Contiguous storage */
+ if (!parms->h5_use_chunks) {
+ /* Contiguous access pattern */
+ if (!parms->interleaved) {
+ /* Compute file offset */
+ file_offset = posix_file_offset +
+ (off_t)((((size_t)nbytes_xfer / blk_size) / (size_t)snbytes) *
+ (blk_size * (size_t)snbytes) +
+ (((size_t)nbytes_xfer / blk_size) % (size_t)snbytes));
+
+ /* Number of bytes to be transferred per I/O operation */
+ nbytes_xfer_advance = buf_size;
+
+ /* Global offset advance after each I/O operation */
+ file_offset_advance = (off_t)snbytes;
+ } /* end if */
+ /* Interleaved access pattern */
+ else {
+ /* Compute file offset */
+ file_offset =
+ posix_file_offset +
+ (off_t)(((((size_t)nbytes_xfer / buf_size) * (size_t)pio_mpi_nprocs_g) /
+ (size_t)snbytes) *
+ (buf_size * (size_t)snbytes) +
+ (((size_t)nbytes_xfer / buf_size) * (size_t)pio_mpi_nprocs_g) %
+ (size_t)snbytes);
+
+ /* Number of bytes to be transferred per I/O operation */
+ nbytes_xfer_advance = blk_size;
+
+ /* Global offset advance after each I/O operation */
+ file_offset_advance = (off_t)snbytes;
+ } /* end else */
+ } /* end if */
+ /* Chunked storage */
+ else {
+ /*Contiguous access pattern */
+ if (!parms->interleaved) {
+ /* Compute file offset */
+ file_offset = posix_file_offset + (off_t)nbytes_xfer;
+
+ /* Number of bytes to be transferred per I/O operation */
+ nbytes_xfer_advance = blk_size * buf_size;
+
+ /* Global offset advance after each I/O operation */
+ file_offset_advance = 0;
+ } /* end if */
+ /*Interleaved access pattern */
+ else {
+ /* Compute file offset */
+ /* Before simplification */
+ /* file_offset=posix_file_offset+(off_t)((nbytes_xfer/(buf_size/blk_size)
+ *pio_mpi_nprocs_g)/(snbytes/blk_size*(blk_size*blk_size))*(buf_size/blk_size
+ *snbytes/blk_size*(blk_size*blk_size))+((nbytes_xfer/(buf_size/blk_size))
+ *pio_mpi_nprocs_g)%(snbytes/blk_size*(blk_size*blk_size))); */
+
+ file_offset = posix_file_offset +
+ (off_t)((((size_t)nbytes_xfer / (buf_size / blk_size) *
+ (size_t)pio_mpi_nprocs_g) /
+ ((size_t)snbytes * blk_size)) *
+ (buf_size * (size_t)snbytes) +
+ (((size_t)nbytes_xfer / (buf_size / blk_size)) *
+ (size_t)pio_mpi_nprocs_g) %
+ ((size_t)snbytes * blk_size));
+
+ /* Number of bytes to be transferred per I/O operation */
+ nbytes_xfer_advance = blk_size * blk_size;
+
+ /* Global offset advance after each I/O operation */
+ /* file_offset_advance = (off_t)(snbytes/blk_size*(blk_size*blk_size)); */
+ file_offset_advance = (off_t)snbytes * (off_t)blk_size;
+ } /* end else */
+ } /* end else */
+
+ /* Common code for file access */
+
+ /* Set the base of user's buffer */
+ buf_p = (unsigned char *)buffer;
+
+ /* Set the number of bytes to transfer this time */
+ nbytes_toxfer = buf_size * blk_size;
+
+ /* Loop over portions of the buffer to write */
+ while (nbytes_toxfer > 0) {
+ /* only care if seek returns error */
+ rc = POSIXSEEK(fd->posixfd, file_offset) < 0 ? -1 : 0;
+ VRFY((rc == 0), "POSIXSEEK");
+
+ /* check if all bytes are written */
+ rc = ((ssize_t)nbytes_xfer_advance ==
+ POSIXWRITE(fd->posixfd, buf_p, nbytes_xfer_advance));
+ VRFY((rc != 0), "POSIXWRITE");
+
+ /* Advance location in buffer */
+ buf_p += nbytes_xfer_advance;
+
+ /* Advance global offset in dataset */
+ nbytes_xfer += (ssize_t)nbytes_xfer_advance;
+
+ /* Decrement number of bytes left this time */
+ nbytes_toxfer -= nbytes_xfer_advance;
+
+ /* Partially advance file offset */
+ file_offset += file_offset_advance;
+ } /* end while */
+
+ } /* end else */
+
+ break;
+
+ case MPIO:
+ /* 1D dataspace */
+ if (!parms->dim2d) {
+ /* Independent file access */
+ if (!parms->collective) {
+ /* Contiguous pattern */
+ if (!parms->interleaved) {
+ /* Compute offset in file */
+ mpi_offset = mpi_file_offset + nbytes_xfer;
+
+ /* Perform independent write */
+ mrc =
+ MPI_File_write_at(fd->mpifd, mpi_offset, buffer,
+ (int)(buf_size / blk_size), mpi_blk_type, &mpi_status);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_WRITE");
+
+ /* Advance global offset in dataset */
+ nbytes_xfer += (ssize_t)buf_size;
+ } /* end if */
+ /* Interleaved access pattern */
+ else {
+ /* Set the base of user's buffer */
+ buf_p = (unsigned char *)buffer;
+
+ /* Set the number of bytes to transfer this time */
+ nbytes_toxfer = buf_size;
+
+ /* Loop over the buffers to write */
+ while (nbytes_toxfer > 0) {
+ /* Skip offset over blocks of other processes */
+ mpi_offset = mpi_file_offset + (nbytes_xfer * pio_mpi_nprocs_g);
+
+ /* Perform independent write */
+ mrc = MPI_File_write_at(fd->mpifd, mpi_offset, buf_p, (int)1,
+ mpi_blk_type, &mpi_status);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_WRITE");
+
+ /* Advance location in buffer */
+ buf_p += blk_size;
+
+ /* Advance global offset in dataset */
+ nbytes_xfer += (ssize_t)blk_size;
+
+ /* Decrement number of bytes left this time */
+ nbytes_toxfer -= blk_size;
+ } /* end while */
+ } /* end else */
+ } /* end if */
+ /* Collective file access */
+ else {
+ /* Contiguous access pattern */
+ if (!parms->interleaved) {
+ /* Compute offset in file */
+ mpi_offset = mpi_file_offset + nbytes_xfer;
+
+ /* Perform independent write */
+ mrc = MPI_File_write_at_all(fd->mpifd, mpi_offset, buffer,
+ (int)(buf_size / blk_size), mpi_blk_type,
+ &mpi_status);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_WRITE");
+
+ /* Advance global offset in dataset */
+ nbytes_xfer += (ssize_t)buf_size;
+ } /* end if */
+ /* Interleaved access pattern */
+ else {
+ /* Compute offset in file */
+ mpi_offset = mpi_file_offset + (nbytes_xfer * pio_mpi_nprocs_g);
+
+ /* Set the file view */
+ mrc = MPI_File_set_view(fd->mpifd, mpi_offset, mpi_blk_type, mpi_file_type,
+ "native", h5_io_info_g);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_VIEW");
+
+ /* Perform write */
+ mrc = MPI_File_write_at_all(fd->mpifd, 0, buffer, (int)(buf_size / blk_size),
+ mpi_blk_type, &mpi_status);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_WRITE");
+
+ /* Advance global offset in dataset */
+ nbytes_xfer += (ssize_t)buf_size;
+ } /* end else */
+ } /* end else */
+ } /* end if */
+ /* 2D dataspace */
+ else {
+ /* Contiguous storage */
+ if (!parms->h5_use_chunks) {
+ /* Contiguous access pattern */
+ if (!parms->interleaved) {
+ /* Compute offset in file */
+ mpi_offset =
+ mpi_file_offset +
+ (MPI_Offset)((((size_t)nbytes_xfer / blk_size) / (size_t)snbytes) *
+ (blk_size * (size_t)snbytes)) +
+ (MPI_Offset)(((size_t)nbytes_xfer / blk_size) % (size_t)snbytes);
+
+ /* Number of bytes to be transferred per I/O operation */
+ nbytes_xfer_advance = buf_size;
+
+ /* Global offset advance after each I/O operation */
+ mpi_offset_advance = snbytes;
+
+ /* MPI type to be used for collective access */
+ mpi_collective_type = mpi_cont_type;
+ } /* end if */
+ /* Interleaved access pattern */
+ else {
+ /* Compute offset in file */
+ mpi_offset =
+ mpi_file_offset +
+ (MPI_Offset)(
+ ((((size_t)nbytes_xfer / buf_size) * (size_t)pio_mpi_nprocs_g) /
+ (size_t)snbytes) *
+ (buf_size * (size_t)snbytes)) +
+ (MPI_Offset)(
+ (((size_t)nbytes_xfer / buf_size) * (size_t)pio_mpi_nprocs_g) %
+ (size_t)snbytes);
+
+ /* Number of bytes to be transferred per I/O operation */
+ nbytes_xfer_advance = blk_size;
+
+ /* Global offset advance after each I/O operation */
+ mpi_offset_advance = snbytes;
+
+ /* MPI type to be used for collective access */
+ mpi_collective_type = mpi_inter_type;
+ } /* end else */
+ } /* end if */
+ /* Chunked storage */
+ else {
+ /*Contiguous access pattern */
+ if (!parms->interleaved) {
+ /* Compute offset in file */
+ mpi_offset = mpi_file_offset + nbytes_xfer;
+
+ /* Number of bytes to be transferred per I/O operation */
+ nbytes_xfer_advance = blk_size * buf_size;
+
+ /* Global offset advance after each I/O operation */
+ mpi_offset_advance = 0;
+
+ /* MPI type to be used for collective access */
+ mpi_collective_type = mpi_full_buffer;
+ } /* end if */
+ /*Interleaved access pattern */
+ else {
+ /* Compute offset in file */
+ /* Before simplification */
+ /* mpi_offset=mpi_file_offset+(nbytes_xfer/(buf_size/blk_size)
+ *pio_mpi_nprocs_g)/(snbytes/blk_size*(blk_size*blk_size))*
+ (buf_size/blk_size*snbytes/blk_size*(blk_size*blk_size))+
+ ((nbytes_xfer/(buf_size/blk_size))*pio_mpi_nprocs_g)%(snbytes
+ /blk_size*(blk_size*blk_size)); */
+ mpi_offset = mpi_file_offset +
+ (MPI_Offset)((((size_t)nbytes_xfer / (buf_size / blk_size) *
+ (size_t)pio_mpi_nprocs_g) /
+ ((size_t)snbytes * blk_size)) *
+ (buf_size * (size_t)snbytes)) +
+ (MPI_Offset)((((size_t)nbytes_xfer / (buf_size / blk_size)) *
+ (size_t)pio_mpi_nprocs_g) %
+ ((size_t)snbytes * blk_size));
+
+ /* Number of bytes to be transferred per I/O operation */
+ nbytes_xfer_advance = blk_size * blk_size;
+
+ /* Global offset advance after each I/O operation */
+ /* mpi_offset_advance = (MPI_Offset)(snbytes/blk_size*(blk_size*blk_size)); */
+ mpi_offset_advance = (MPI_Offset)((size_t)snbytes * blk_size);
+
+ /* MPI type to be used for collective access */
+ mpi_collective_type = mpi_chunk_inter_type;
+ } /* end else */
+ } /* end else */
+
+ /* Common code for independent file access */
+ if (!parms->collective) {
+ /* Set the base of user's buffer */
+ buf_p = (unsigned char *)buffer;
+
+ /* Set the number of bytes to transfer this time */
+ nbytes_toxfer = buf_size * blk_size;
+
+ /* Loop over portions of the buffer to write */
+ while (nbytes_toxfer > 0) {
+ /* Perform independent write */
+ mrc = MPI_File_write_at(fd->mpifd, mpi_offset, buf_p,
+ (int)nbytes_xfer_advance, MPI_BYTE, &mpi_status);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_WRITE");
+
+ /* Advance location in buffer */
+ buf_p += nbytes_xfer_advance;
+
+ /* Advance global offset in dataset */
+ nbytes_xfer += (ssize_t)nbytes_xfer_advance;
+
+ /* Decrement number of bytes left this time */
+ nbytes_toxfer -= nbytes_xfer_advance;
+
+ /* Partially advance global offset in dataset */
+ mpi_offset += mpi_offset_advance;
+ } /* end while */
+ } /* end if */
+
+ /* Common code for collective file access */
+ else {
+ /* Set the file view */
+ mrc = MPI_File_set_view(fd->mpifd, mpi_offset, MPI_BYTE, mpi_collective_type,
+ "native", h5_io_info_g);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_VIEW");
+
+ /* Perform write */
+ MPI_File_write_at_all(fd->mpifd, 0, buffer, (int)(buf_size * blk_size), MPI_BYTE,
+ &mpi_status);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_WRITE");
+
+ /* Advance global offset in dataset */
+ nbytes_xfer += (off_t)buf_size * (off_t)blk_size;
+ } /* end else */
+
+ } /* end else */
+
+ break;
+
+ case PHDF5:
+ /* 1D dataspace */
+ if (!parms->dim2d) {
+ /* Set up the file dset space id to move the selection to process */
+ if (!parms->interleaved) {
+ /* Contiguous pattern */
+ h5offset[0] = nbytes_xfer;
+ } /* end if */
+ else {
+ /* Interleaved access pattern */
+ /* Skip offset over blocks of other processes */
+ h5offset[0] = (nbytes_xfer * pio_mpi_nprocs_g);
+ } /* end else */
+ hrc = H5Soffset_simple(h5dset_space_id, h5offset);
+ VRFY((hrc >= 0), "H5Soffset_simple");
+
+ /* Write the buffer out */
+ hrc =
+ H5Dwrite(h5ds_id, ELMT_H5_TYPE, h5mem_space_id, h5dset_space_id, h5dxpl, buffer);
+ VRFY((hrc >= 0), "H5Dwrite");
+
+ /* Increment number of bytes transferred */
+ nbytes_xfer += (ssize_t)buf_size;
+ } /* end if */
+ /* 2D dataspace */
+ else {
+ /* Set up the file dset space id to move the selection to process */
+ if (!parms->interleaved) {
+ /* Contiguous pattern */
+ h5offset[0] =
+ (hssize_t)(((size_t)nbytes_xfer / ((size_t)snbytes * blk_size)) * blk_size);
+ h5offset[1] =
+ (hssize_t)(((size_t)nbytes_xfer % ((size_t)snbytes * blk_size)) / blk_size);
+
+ } /* end if */
+ else {
+ /* Interleaved access pattern */
+ /* Skip offset over blocks of other processes */
+ h5offset[0] = (hssize_t)((((size_t)nbytes_xfer * (size_t)pio_mpi_nprocs_g) /
+ ((size_t)snbytes * buf_size)) *
+ buf_size);
+ h5offset[1] = (hssize_t)((((size_t)nbytes_xfer * (size_t)pio_mpi_nprocs_g) %
+ ((size_t)snbytes * buf_size)) /
+ buf_size);
+
+ } /* end else */
+ hrc = H5Soffset_simple(h5dset_space_id, h5offset);
+ VRFY((hrc >= 0), "H5Soffset_simple");
+
+ /* Write the buffer out */
+ hrc =
+ H5Dwrite(h5ds_id, ELMT_H5_TYPE, h5mem_space_id, h5dset_space_id, h5dxpl, buffer);
+ VRFY((hrc >= 0), "H5Dwrite");
+
+ /* Increment number of bytes transferred */
+ nbytes_xfer += (off_t)buf_size * (off_t)blk_size;
+
+ } /* end else */
+
+ break;
+
+ default:
+ break;
+ } /* switch (parms->io_type) */
+ } /* end while */
+
+ /* Stop "raw data" write timer */
+ io_time_set(res->timers, HDF5_RAW_WRITE_FIXED_DIMS, TSTOP);
+
+ /* Calculate write time */
+
+ /* Close dataset. Only HDF5 needs to do an explicit close. */
+ if (parms->io_type == PHDF5) {
+ hrc = H5Dclose(h5ds_id);
+
+ if (hrc < 0) {
+ HDfprintf(stderr, "HDF5 Dataset Close failed\n");
+ GOTOERROR(FAIL);
+ }
+
+ h5ds_id = H5I_INVALID_HID;
+ } /* end if */
+ } /* end for */
+
+done:
+ /* release MPI-I/O objects */
+ if (parms->io_type == MPIO) {
+ /* 1D dataspace */
+ if (!parms->dim2d) {
+ /* Free file type */
+ mrc = MPI_Type_free(&mpi_file_type);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_FREE");
+
+ /* Free buffer type */
+ mrc = MPI_Type_free(&mpi_blk_type);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_FREE");
+ } /* end if */
+ /* 2D dataspace */
+ else {
+ /* Free partial buffer type for contiguous access */
+ mrc = MPI_Type_free(&mpi_partial_buffer_cont);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_FREE");
+
+ /* Free contiguous file type */
+ mrc = MPI_Type_free(&mpi_cont_type);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_FREE");
+
+ /* Free partial buffer type for interleaved access */
+ mrc = MPI_Type_free(&mpi_partial_buffer_inter);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_FREE");
+
+ /* Free interleaved file type */
+ mrc = MPI_Type_free(&mpi_inter_type);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_FREE");
+
+ /* Free full buffer type */
+ mrc = MPI_Type_free(&mpi_full_buffer);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_FREE");
+
+ /* Free full chunk type */
+ mrc = MPI_Type_free(&mpi_full_chunk);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_FREE");
+
+ /* Free chunk interleaved file type */
+ mrc = MPI_Type_free(&mpi_chunk_inter_type);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_FREE");
+ } /* end else */
+ } /* end if */
+
+ /* release HDF5 objects */
+ if (h5dset_space_id != -1) {
+ hrc = H5Sclose(h5dset_space_id);
+ if (hrc < 0) {
+ HDfprintf(stderr, "HDF5 Dataset Space Close failed\n");
+ ret_code = FAIL;
+ }
+ else {
+ h5dset_space_id = H5I_INVALID_HID;
+ }
+ }
+
+ if (h5mem_space_id != -1) {
+ hrc = H5Sclose(h5mem_space_id);
+ if (hrc < 0) {
+ HDfprintf(stderr, "HDF5 Memory Space Close failed\n");
+ ret_code = FAIL;
+ }
+ else {
+ h5mem_space_id = H5I_INVALID_HID;
+ }
+ }
+
+ if (h5dxpl != -1) {
+ hrc = H5Pclose(h5dxpl);
+ if (hrc < 0) {
+ HDfprintf(stderr, "HDF5 Dataset Transfer Property List Close failed\n");
+ ret_code = FAIL;
+ }
+ else {
+ h5dxpl = H5I_INVALID_HID;
+ }
+ }
+
+ return ret_code;
+}
+
+static off_t
+sqrto(off_t x)
+{
+ double root_x = sqrt((double)x);
+ return (off_t)root_x;
+}
+
+/*
+ * Function: do_read
+ * Purpose: read the required amount of data from the file.
+ * Return: SUCCESS or FAIL
+ * Programmer: Albert Cheng 2001/12/13
+ * Modifications:
+ * Added 2D testing (Christian Chilan, 10. August 2005)
+ */
+static herr_t
+do_read(results *res, file_descr *fd, parameters *parms, long ndsets, off_t nbytes, size_t buf_size,
+ void *buffer /*out*/)
+{
+ int ret_code = SUCCESS;
+ int rc; /*routine return code */
+ long ndset;
+ size_t blk_size; /* The block size to subdivide the xfer buffer into */
+ size_t bsize; /* Size of the actual buffer */
+ off_t nbytes_xfer; /* Total number of bytes transferred so far */
+ size_t nbytes_xfer_advance; /* Number of bytes transferred in a single I/O operation */
+ size_t nbytes_toxfer; /* Number of bytes to transfer a particular time */
+ char dname[64];
+ off_t dset_offset = 0; /*dataset offset in a file */
+ off_t bytes_begin[2]; /*first elmt this process transfer */
+ off_t bytes_count; /*number of elmts this process transfer */
+ off_t snbytes = 0; /*size of a side of the dataset square */
+ unsigned char *buf_p; /* Current buffer pointer */
+
+ /* POSIX variables */
+ off_t file_offset; /* File offset of the next transfer */
+ off_t file_offset_advance; /* File offset advance after each I/O operation */
+ off_t posix_file_offset; /* Base file offset of the next transfer */
+
+ /* MPI variables */
+ MPI_Offset mpi_file_offset; /* Base file offset of the next transfer*/
+ MPI_Offset mpi_offset; /* Offset in MPI file */
+ MPI_Offset mpi_offset_advance; /* Offset advance after each I/O operation */
+ MPI_Datatype mpi_file_type; /* MPI derived type for 1D file */
+ MPI_Datatype mpi_blk_type; /* MPI derived type for 1D buffer */
+ MPI_Datatype mpi_cont_type; /* MPI derived type for 2D contiguous file */
+ MPI_Datatype mpi_partial_buffer_cont; /* MPI derived type for partial 2D contiguous buffer */
+ MPI_Datatype mpi_inter_type; /* MPI derived type for 2D interleaved file */
+ MPI_Datatype mpi_partial_buffer_inter; /* MPI derived type for partial 2D interleaved buffer */
+ MPI_Datatype mpi_full_buffer; /* MPI derived type for 2D full buffer */
+ MPI_Datatype mpi_full_chunk; /* MPI derived type for 2D full chunk */
+ MPI_Datatype mpi_chunk_inter_type; /* MPI derived type for 2D chunk interleaved file */
+ MPI_Datatype mpi_collective_type; /* Generic MPI derived type for 2D collective access */
+ MPI_Status mpi_status;
+ int mrc; /* MPI return code */
+
+ /* HDF5 variables */
+ herr_t hrc; /*HDF5 return code */
+ hsize_t h5dims[2]; /*dataset dim sizes */
+ hid_t h5dset_space_id = H5I_INVALID_HID; /*dataset space ID */
+ hid_t h5mem_space_id = H5I_INVALID_HID; /*memory dataspace ID */
+ hid_t h5ds_id = H5I_INVALID_HID; /*dataset handle */
+ hsize_t h5block[2]; /*dataspace selection */
+ hsize_t h5stride[2];
+ hsize_t h5count[2];
+ hsize_t h5start[2];
+ hssize_t h5offset[2]; /* Selection offset within dataspace */
+ hid_t h5dxpl = H5I_INVALID_HID; /* Dataset transfer property list */
+
+ /* Get the parameters from the parameter block */
+ blk_size = parms->blk_size;
+
+ /* There are two kinds of transfer patterns, contiguous and interleaved.
+ * Let 0,1,2,...,n be data accessed by process 0,1,2,...,n
+ * where n is rank of the last process.
+ * In contiguous pattern, data are accessed as
+ * 000...111...222...nnn...
+ * In interleaved pattern, data are accessed as
+ * 012...n012...n...
+ * These are all in the scope of one dataset.
+ */
+
+ /* 1D dataspace */
+ if (!parms->dim2d) {
+ bsize = buf_size;
+ /* Contiguous Pattern: */
+ if (!parms->interleaved) {
+ bytes_begin[0] = (off_t)(((double)nbytes * pio_mpi_rank_g) / pio_mpi_nprocs_g);
+ } /* end if */
+ /* Interleaved Pattern: */
+ else {
+ bytes_begin[0] = (off_t)blk_size * (off_t)pio_mpi_rank_g;
+ } /* end else */
+ } /* end if */
+ /* 2D dataspace */
+ else {
+ /* nbytes is always the number of bytes per dataset (1D or 2D). If the
+ dataspace is 2D, snbytes is the size of a side of the 'dataset square'.
+ */
+ snbytes = sqrto(nbytes);
+
+ bsize = buf_size * blk_size;
+
+ /* Contiguous Pattern: */
+ if (!parms->interleaved) {
+ bytes_begin[0] = (off_t)((double)snbytes * pio_mpi_rank_g / pio_mpi_nprocs_g);
+ bytes_begin[1] = 0;
+ } /* end if */
+ /* Interleaved Pattern: */
+ else {
+ bytes_begin[0] = 0;
+
+ if (!parms->h5_use_chunks || parms->io_type == PHDF5)
+ bytes_begin[1] = (off_t)blk_size * (off_t)pio_mpi_rank_g;
+ else
+ bytes_begin[1] = (off_t)blk_size * (off_t)blk_size * (off_t)pio_mpi_rank_g;
+ } /* end else */
+ } /* end else */
+
+ /* Calculate the total number of bytes (bytes_count) to be
+ * transferred by this process. It may be different for different
+ * transfer pattern due to rounding to integral values.
+ */
+ /*
+ * Calculate the beginning bytes of this process and the next.
+ * bytes_count is the difference between these two beginnings.
+ * This way, it eliminates any rounding errors.
+ * (This is tricky, don't mess with the formula, rounding errors
+ * can easily get introduced) */
+ bytes_count = (off_t)(((double)nbytes * (pio_mpi_rank_g + 1)) / pio_mpi_nprocs_g) -
+ (off_t)(((double)nbytes * pio_mpi_rank_g) / pio_mpi_nprocs_g);
+
+ /* debug */
+ if (pio_debug_level >= 4) {
+ HDprint_rank(output);
+ if (!parms->dim2d) {
+ HDfprintf(output,
+ "Debug(do_write): "
+ "buf_size=%zu, bytes_begin=%" H5_PRINTF_LL_WIDTH "d, bytes_count=%" H5_PRINTF_LL_WIDTH
+ "d\n",
+ buf_size, (long long)bytes_begin[0], (long long)bytes_count);
+ }
+ else {
+ HDfprintf(output,
+ "Debug(do_write): "
+ "linear buf_size=%zu, bytes_begin=(%" H5_PRINTF_LL_WIDTH "d,%" H5_PRINTF_LL_WIDTH
+ "d), bytes_count=%" H5_PRINTF_LL_WIDTH "d\n",
+ buf_size * blk_size, (long long)bytes_begin[0], (long long)bytes_begin[1],
+ (long long)bytes_count);
+ }
+ }
+
+ /* I/O Access specific setup */
+ switch (parms->io_type) {
+ case POSIXIO:
+ /* No extra setup */
+ break;
+
+ case MPIO: /* MPI-I/O setup */
+ /* 1D dataspace */
+ if (!parms->dim2d) {
+ /* Build block's derived type */
+ mrc = MPI_Type_contiguous((int)blk_size, MPI_BYTE, &mpi_blk_type);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_CREATE");
+
+ /* Build file's derived type */
+ mrc = MPI_Type_vector((int)(buf_size / blk_size), (int)1, (int)pio_mpi_nprocs_g, mpi_blk_type,
+ &mpi_file_type);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_CREATE");
+
+ /* Commit file type */
+ mrc = MPI_Type_commit(&mpi_file_type);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_COMMIT");
+
+ /* Commit buffer type */
+ mrc = MPI_Type_commit(&mpi_blk_type);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_COMMIT");
+ } /* end if */
+ /* 2D dataspace */
+ else {
+ /* Build partial buffer derived type for contiguous access */
+ mrc = MPI_Type_contiguous((int)buf_size, MPI_BYTE, &mpi_partial_buffer_cont);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_CREATE");
+
+ /* Commit partial buffer derived type */
+ mrc = MPI_Type_commit(&mpi_partial_buffer_cont);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_COMMIT");
+
+ /* Build contiguous file's derived type */
+ mrc = MPI_Type_vector((int)blk_size, (int)1, (int)((size_t)snbytes / buf_size),
+ mpi_partial_buffer_cont, &mpi_cont_type);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_CREATE");
+
+ /* Commit contiguous file type */
+ mrc = MPI_Type_commit(&mpi_cont_type);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_COMMIT");
+
+ /* Build partial buffer derived type for interleaved access */
+ mrc = MPI_Type_contiguous((int)blk_size, MPI_BYTE, &mpi_partial_buffer_inter);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_CREATE");
+
+ /* Commit partial buffer derived type */
+ mrc = MPI_Type_commit(&mpi_partial_buffer_inter);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_COMMIT");
+
+ /* Build interleaved file's derived type */
+ mrc = MPI_Type_vector((int)buf_size, (int)1, (int)((size_t)snbytes / blk_size),
+ mpi_partial_buffer_inter, &mpi_inter_type);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_CREATE");
+
+ /* Commit interleaved file type */
+ mrc = MPI_Type_commit(&mpi_inter_type);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_COMMIT");
+
+ /* Build full buffer derived type */
+ mrc = MPI_Type_contiguous((int)(blk_size * buf_size), MPI_BYTE, &mpi_full_buffer);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_CREATE");
+
+ /* Commit full buffer derived type */
+ mrc = MPI_Type_commit(&mpi_full_buffer);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_COMMIT");
+
+ /* Build full chunk derived type */
+ mrc = MPI_Type_contiguous((int)(blk_size * blk_size), MPI_BYTE, &mpi_full_chunk);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_CREATE");
+
+ /* Commit full chunk derived type */
+ mrc = MPI_Type_commit(&mpi_full_chunk);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_COMMIT");
+
+ /* Build chunk interleaved file's derived type */
+ mrc = MPI_Type_vector((int)(buf_size / blk_size), (int)1, (int)((size_t)snbytes / blk_size),
+ mpi_full_chunk, &mpi_chunk_inter_type);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_CREATE");
+
+ /* Commit chunk interleaved file type */
+ mrc = MPI_Type_commit(&mpi_chunk_inter_type);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_COMMIT");
+ } /* end else */
+ break;
+
+ case PHDF5: /* HDF5 setup */
+ /* 1D dataspace */
+ if (!parms->dim2d) {
+ if (nbytes > 0) {
+ /* define a contiguous dataset of nbytes native bytes */
+ h5dims[0] = (hsize_t)nbytes;
+ h5dset_space_id = H5Screate_simple(1, h5dims, NULL);
+ VRFY((h5dset_space_id >= 0), "H5Screate_simple");
+
+ /* Set up the file dset space id to select the pattern to access */
+ if (!parms->interleaved) {
+ /* Contiguous pattern */
+ h5start[0] = (hsize_t)bytes_begin[0];
+ h5stride[0] = h5block[0] = blk_size;
+ h5count[0] = buf_size / blk_size;
+ } /* end if */
+ else {
+ /* Interleaved access pattern */
+ /* Skip offset over blocks of other processes */
+ h5start[0] = (hsize_t)bytes_begin[0];
+ h5stride[0] = blk_size * (size_t)pio_mpi_nprocs_g;
+ h5block[0] = blk_size;
+ h5count[0] = buf_size / blk_size;
+ } /* end else */
+ hrc = H5Sselect_hyperslab(h5dset_space_id, H5S_SELECT_SET, h5start, h5stride, h5count,
+ h5block);
+ VRFY((hrc >= 0), "H5Sselect_hyperslab");
+ } /* end if */
+ else {
+ h5dset_space_id = H5Screate(H5S_SCALAR);
+ VRFY((h5dset_space_id >= 0), "H5Screate");
+ } /* end else */
+
+ /* Create the memory dataspace that corresponds to the xfer buffer */
+ if (buf_size > 0) {
+ h5dims[0] = buf_size;
+ h5mem_space_id = H5Screate_simple(1, h5dims, NULL);
+ VRFY((h5mem_space_id >= 0), "H5Screate_simple");
+ } /* end if */
+ else {
+ h5mem_space_id = H5Screate(H5S_SCALAR);
+ VRFY((h5mem_space_id >= 0), "H5Screate");
+ } /* end else */
+ } /* end if */
+ /* 2D dataspace */
+ else {
+ if (nbytes > 0) {
+ /* define a contiguous dataset of nbytes native bytes */
+ h5dims[0] = (hsize_t)snbytes;
+ h5dims[1] = (hsize_t)snbytes;
+ h5dset_space_id = H5Screate_simple(2, h5dims, NULL);
+ VRFY((h5dset_space_id >= 0), "H5Screate_simple");
+
+ /* Set up the file dset space id to select the pattern to access */
+ if (!parms->interleaved) {
+ /* Contiguous pattern */
+ h5start[0] = (hsize_t)bytes_begin[0];
+ h5start[1] = (hsize_t)bytes_begin[1];
+ h5stride[0] = 1;
+ h5stride[1] = h5block[0] = h5block[1] = blk_size;
+ h5count[0] = 1;
+ h5count[1] = buf_size / blk_size;
+ } /* end if */
+ else {
+ /* Interleaved access pattern */
+ /* Skip offset over blocks of other processes */
+ h5start[0] = (hsize_t)bytes_begin[0];
+ h5start[1] = (hsize_t)bytes_begin[1];
+ h5stride[0] = blk_size;
+ h5stride[1] = blk_size * (size_t)pio_mpi_nprocs_g;
+ h5block[0] = h5block[1] = blk_size;
+ h5count[0] = buf_size / blk_size;
+ h5count[1] = 1;
+ } /* end else */
+ hrc = H5Sselect_hyperslab(h5dset_space_id, H5S_SELECT_SET, h5start, h5stride, h5count,
+ h5block);
+ VRFY((hrc >= 0), "H5Sselect_hyperslab");
+ } /* end if */
+ else {
+ h5dset_space_id = H5Screate(H5S_SCALAR);
+ VRFY((h5dset_space_id >= 0), "H5Screate");
+ } /* end else */
+
+ /* Create the memory dataspace that corresponds to the xfer buffer */
+ if (buf_size > 0) {
+ if (!parms->interleaved) {
+ h5dims[0] = blk_size;
+ h5dims[1] = buf_size;
+ }
+ else {
+ h5dims[0] = buf_size;
+ h5dims[1] = blk_size;
+ }
+ h5mem_space_id = H5Screate_simple(2, h5dims, NULL);
+ VRFY((h5mem_space_id >= 0), "H5Screate_simple");
+ } /* end if */
+ else {
+ h5mem_space_id = H5Screate(H5S_SCALAR);
+ VRFY((h5mem_space_id >= 0), "H5Screate");
+ } /* end else */
+ } /* end else */
+
+ /* Create the dataset transfer property list */
+ h5dxpl = H5Pcreate(H5P_DATASET_XFER);
+ if (h5dxpl < 0) {
+ HDfprintf(stderr, "HDF5 Property List Create failed\n");
+ GOTOERROR(FAIL);
+ }
+
+ /* Change to collective I/O, if asked */
+ if (parms->collective) {
+ hrc = H5Pset_dxpl_mpio(h5dxpl, H5FD_MPIO_COLLECTIVE);
+ if (hrc < 0) {
+ HDfprintf(stderr, "HDF5 Property List Set failed\n");
+ GOTOERROR(FAIL);
+ } /* end if */
+ } /* end if */
+ break;
+
+ default:
+ break;
+ } /* end switch */
+
+ for (ndset = 1; ndset <= ndsets; ++ndset) {
+
+ /* Calculate dataset offset within a file */
+
+ /* create dataset */
+ switch (parms->io_type) {
+ case POSIXIO:
+ case MPIO:
+ /* both posix and mpi io just need dataset offset in file*/
+ dset_offset = (ndset - 1) * nbytes;
+ break;
+
+ case PHDF5:
+ HDsnprintf(dname, sizeof(dname), "Dataset_%ld", ndset);
+ h5ds_id = H5DOPEN(fd->h5fd, dname);
+ if (h5ds_id < 0) {
+ HDfprintf(stderr, "HDF5 Dataset open failed\n");
+ GOTOERROR(FAIL);
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ /* The task is to transfer bytes_count bytes, starting at
+ * bytes_begin position, using transfer buffer of buf_size bytes.
+ * If interleaved, select buf_size at a time, in round robin
+ * fashion, according to number of process. Otherwise, select
+ * all bytes_count in contiguous.
+ */
+ nbytes_xfer = 0;
+
+ /* 1D dataspace */
+ if (!parms->dim2d) {
+ /* Set base file offset for all I/O patterns and POSIX access */
+ posix_file_offset = dset_offset + bytes_begin[0];
+
+ /* Set base file offset for all I/O patterns and MPI access */
+ mpi_file_offset = (MPI_Offset)(dset_offset + bytes_begin[0]);
+ } /* end if */
+ else {
+ /* Set base file offset for all I/O patterns and POSIX access */
+ posix_file_offset = dset_offset + bytes_begin[0] * snbytes + bytes_begin[1];
+
+ /* Set base file offset for all I/O patterns and MPI access */
+ mpi_file_offset = (MPI_Offset)(dset_offset + bytes_begin[0] * snbytes + bytes_begin[1]);
+ } /* end else */
+
+ /* Start "raw data" read timer */
+ io_time_set(res->timers, HDF5_RAW_READ_FIXED_DIMS, TSTART);
+
+ while (nbytes_xfer < bytes_count) {
+ /* Read */
+ /* Calculate offset of read within a dataset/file */
+ switch (parms->io_type) {
+ case POSIXIO:
+ /* 1D dataspace */
+ if (!parms->dim2d) {
+ /* Contiguous pattern */
+ if (!parms->interleaved) {
+ /* Compute file offset */
+ file_offset = posix_file_offset + (off_t)nbytes_xfer;
+
+ /* only care if seek returns error */
+ rc = POSIXSEEK(fd->posixfd, file_offset) < 0 ? -1 : 0;
+ VRFY((rc == 0), "POSIXSEEK");
+
+ /* check if all bytes are read */
+ rc = ((ssize_t)buf_size == POSIXREAD(fd->posixfd, buffer, buf_size));
+ VRFY((rc != 0), "POSIXREAD");
+
+ /* Advance global offset in dataset */
+ nbytes_xfer += (off_t)buf_size;
+ } /* end if */
+ /* Interleaved access pattern */
+ else {
+ /* Set the base of user's buffer */
+ buf_p = (unsigned char *)buffer;
+
+ /* Set the number of bytes to transfer this time */
+ nbytes_toxfer = buf_size;
+
+ /* Loop over the buffers to read */
+ while (nbytes_toxfer > 0) {
+ /* Skip offset over blocks of other processes */
+ file_offset = posix_file_offset + (off_t)(nbytes_xfer * pio_mpi_nprocs_g);
+
+ /* only care if seek returns error */
+ rc = POSIXSEEK(fd->posixfd, file_offset) < 0 ? -1 : 0;
+ VRFY((rc == 0), "POSIXSEEK");
+
+ /* check if all bytes are read */
+ rc = ((ssize_t)blk_size == POSIXREAD(fd->posixfd, buf_p, blk_size));
+ VRFY((rc != 0), "POSIXREAD");
+
+ /* Advance location in buffer */
+ buf_p += blk_size;
+
+ /* Advance global offset in dataset */
+ nbytes_xfer += (off_t)blk_size;
+
+ /* Decrement number of bytes left this time */
+ nbytes_toxfer -= blk_size;
+ } /* end while */
+ } /* end else */
+ } /* end if */
+ /* 2D dataspace */
+ else {
+ /* Contiguous storage */
+ if (!parms->h5_use_chunks) {
+ /* Contiguous access pattern */
+ if (!parms->interleaved) {
+ /* Compute file offset */
+ file_offset = posix_file_offset +
+ (off_t)((((size_t)nbytes_xfer / blk_size) / (size_t)snbytes) *
+ (blk_size * (size_t)snbytes) +
+ (((size_t)nbytes_xfer / blk_size) % (size_t)snbytes));
+
+ /* Number of bytes to be transferred per I/O operation */
+ nbytes_xfer_advance = buf_size;
+
+ /* Global offset advance after each I/O operation */
+ file_offset_advance = (off_t)snbytes;
+ } /* end if */
+ /* Interleaved access pattern */
+ else {
+ /* Compute file offset */
+ file_offset =
+ posix_file_offset +
+ (off_t)(((((size_t)nbytes_xfer / buf_size) * (size_t)pio_mpi_nprocs_g) /
+ (size_t)snbytes) *
+ (buf_size * (size_t)snbytes) +
+ (((size_t)nbytes_xfer / buf_size) * (size_t)pio_mpi_nprocs_g) %
+ (size_t)snbytes);
+
+ /* Number of bytes to be transferred per I/O operation */
+ nbytes_xfer_advance = blk_size;
+
+ /* Global offset advance after each I/O operation */
+ file_offset_advance = (off_t)snbytes;
+ } /* end else */
+ } /* end if */
+ /* Chunked storage */
+ else {
+ /*Contiguous access pattern */
+ if (!parms->interleaved) {
+ /* Compute file offset */
+ file_offset = posix_file_offset + (off_t)nbytes_xfer;
+
+ /* Number of bytes to be transferred per I/O operation */
+ nbytes_xfer_advance = blk_size * buf_size;
+
+ /* Global offset advance after each I/O operation */
+ file_offset_advance = 0;
+ } /* end if */
+ /*Interleaved access pattern */
+ else {
+ /* Compute file offset */
+ /* Before simplification */
+ /* file_offset=posix_file_offset+(off_t)((nbytes_xfer/(buf_size/blk_size)
+ *pio_mpi_nprocs_g)/(snbytes/blk_size*(blk_size*blk_size))*(buf_size/blk_size
+ *snbytes/blk_size*(blk_size*blk_size))+((nbytes_xfer/(buf_size/blk_size))
+ *pio_mpi_nprocs_g)%(snbytes/blk_size*(blk_size*blk_size))); */
+
+ file_offset = posix_file_offset +
+ (off_t)((((size_t)nbytes_xfer / (buf_size / blk_size) *
+ (size_t)pio_mpi_nprocs_g) /
+ ((size_t)snbytes * blk_size)) *
+ (buf_size * (size_t)snbytes) +
+ (((size_t)nbytes_xfer / (buf_size / blk_size)) *
+ (size_t)pio_mpi_nprocs_g) %
+ ((size_t)snbytes * blk_size));
+
+ /* Number of bytes to be transferred per I/O operation */
+ nbytes_xfer_advance = blk_size * blk_size;
+
+ /* Global offset advance after each I/O operation */
+ /* file_offset_advance = (off_t)(snbytes/blk_size*(blk_size*blk_size)); */
+ file_offset_advance = (off_t)((size_t)snbytes * blk_size);
+ } /* end else */
+ } /* end else */
+
+ /* Common code for file access */
+
+ /* Set the base of user's buffer */
+ buf_p = (unsigned char *)buffer;
+
+ /* Set the number of bytes to transfer this time */
+ nbytes_toxfer = buf_size * blk_size;
+
+ /* Loop over portions of the buffer to read */
+ while (nbytes_toxfer > 0) {
+ /* only care if seek returns error */
+ rc = POSIXSEEK(fd->posixfd, file_offset) < 0 ? -1 : 0;
+ VRFY((rc == 0), "POSIXSEEK");
+
+ /* check if all bytes are read */
+ rc = ((ssize_t)nbytes_xfer_advance ==
+ POSIXREAD(fd->posixfd, buf_p, nbytes_xfer_advance));
+ VRFY((rc != 0), "POSIXREAD");
+
+ /* Advance location in buffer */
+ buf_p += nbytes_xfer_advance;
+
+ /* Advance global offset in dataset */
+ nbytes_xfer += (off_t)nbytes_xfer_advance;
+
+ /* Decrement number of bytes left this time */
+ nbytes_toxfer -= nbytes_xfer_advance;
+
+ /* Partially advance file offset */
+ file_offset += file_offset_advance;
+ } /* end while */
+
+ } /* end else */
+ break;
+
+ case MPIO:
+ /* 1D dataspace */
+ if (!parms->dim2d) {
+ /* Independent file access */
+ if (!parms->collective) {
+ /* Contiguous pattern */
+ if (!parms->interleaved) {
+ /* Compute offset in file */
+ mpi_offset = mpi_file_offset + nbytes_xfer;
+
+ /* Perform independent read */
+ mrc = MPI_File_read_at(fd->mpifd, mpi_offset, buffer,
+ (int)(buf_size / blk_size), mpi_blk_type, &mpi_status);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_READ");
+
+ /* Advance global offset in dataset */
+ nbytes_xfer += (off_t)buf_size;
+ } /* end if */
+ /* Interleaved access pattern */
+ else {
+ /* Set the base of user's buffer */
+ buf_p = (unsigned char *)buffer;
+
+ /* Set the number of bytes to transfer this time */
+ nbytes_toxfer = buf_size;
+
+ /* Loop over the buffers to read */
+ while (nbytes_toxfer > 0) {
+ /* Skip offset over blocks of other processes */
+ mpi_offset = mpi_file_offset + (nbytes_xfer * pio_mpi_nprocs_g);
+
+ /* Perform independent read */
+ mrc = MPI_File_read_at(fd->mpifd, mpi_offset, buf_p, (int)1, mpi_blk_type,
+ &mpi_status);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_READ");
+
+ /* Advance location in buffer */
+ buf_p += blk_size;
+
+ /* Advance global offset in dataset */
+ nbytes_xfer += (off_t)blk_size;
+
+ /* Decrement number of bytes left this time */
+ nbytes_toxfer -= blk_size;
+ } /* end while */
+ } /* end else */
+ } /* end if */
+ /* Collective file access */
+ else {
+ /* Contiguous access pattern */
+ if (!parms->interleaved) {
+ /* Compute offset in file */
+ mpi_offset = mpi_file_offset + nbytes_xfer;
+
+ /* Perform collective read */
+ mrc = MPI_File_read_at_all(fd->mpifd, mpi_offset, buffer,
+ (int)(buf_size / blk_size), mpi_blk_type,
+ &mpi_status);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_READ");
+
+ /* Advance global offset in dataset */
+ nbytes_xfer += (off_t)buf_size;
+ } /* end if */
+ /* Interleaved access pattern */
+ else {
+ /* Compute offset in file */
+ mpi_offset = mpi_file_offset + (nbytes_xfer * pio_mpi_nprocs_g);
+
+ /* Set the file view */
+ mrc = MPI_File_set_view(fd->mpifd, mpi_offset, mpi_blk_type, mpi_file_type,
+ "native", h5_io_info_g);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_VIEW");
+
+ /* Perform collective read */
+ mrc = MPI_File_read_at_all(fd->mpifd, 0, buffer, (int)(buf_size / blk_size),
+ mpi_blk_type, &mpi_status);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_READ");
+
+ /* Advance global offset in dataset */
+ nbytes_xfer += (off_t)buf_size;
+ } /* end else */
+ } /* end else */
+ } /* end if */
+ /* 2D dataspace */
+ else {
+ /* Contiguous storage */
+ if (!parms->h5_use_chunks) {
+ /* Contiguous access pattern */
+ if (!parms->interleaved) {
+ /* Compute offset in file */
+ mpi_offset =
+ mpi_file_offset +
+ (MPI_Offset)((((size_t)nbytes_xfer / blk_size) / (size_t)snbytes) *
+ (blk_size * (size_t)snbytes)) +
+ (MPI_Offset)(((size_t)nbytes_xfer / blk_size) % (size_t)snbytes);
+
+ /* Number of bytes to be transferred per I/O operation */
+ nbytes_xfer_advance = buf_size;
+
+ /* Global offset advance after each I/O operation */
+ mpi_offset_advance = snbytes;
+
+ /* MPI type to be used for collective access */
+ mpi_collective_type = mpi_cont_type;
+ } /* end if */
+ /* Interleaved access pattern */
+ else {
+ /* Compute offset in file */
+ mpi_offset =
+ mpi_file_offset +
+ (MPI_Offset)(
+ ((((size_t)nbytes_xfer / buf_size) * (size_t)pio_mpi_nprocs_g) /
+ (size_t)snbytes) *
+ (buf_size * (size_t)snbytes)) +
+ (MPI_Offset)(
+ (((size_t)nbytes_xfer / buf_size) * (size_t)pio_mpi_nprocs_g) %
+ (size_t)snbytes);
+
+ /* Number of bytes to be transferred per I/O operation */
+ nbytes_xfer_advance = blk_size;
+
+ /* Global offset advance after each I/O operation */
+ mpi_offset_advance = snbytes;
+
+ /* MPI type to be used for collective access */
+ mpi_collective_type = mpi_inter_type;
+ } /* end else */
+ } /* end if */
+ /* Chunked storage */
+ else {
+ /*Contiguous access pattern */
+ if (!parms->interleaved) {
+ /* Compute offset in file */
+ mpi_offset = mpi_file_offset + nbytes_xfer;
+
+ /* Number of bytes to be transferred per I/O operation */
+ nbytes_xfer_advance = blk_size * buf_size;
+
+ /* Global offset advance after each I/O operation */
+ mpi_offset_advance = 0;
+
+ /* MPI type to be used for collective access */
+ mpi_collective_type = mpi_full_buffer;
+ } /* end if */
+ /*Interleaved access pattern */
+ else {
+ /* Compute offset in file */
+ /* Before simplification */
+ /* mpi_offset=mpi_file_offset+(nbytes_xfer/(buf_size/blk_size)
+ *pio_mpi_nprocs_g)/(snbytes/blk_size*(blk_size*blk_size))*
+ (buf_size/blk_size*snbytes/blk_size*(blk_size*blk_size))+
+ ((nbytes_xfer/(buf_size/blk_size))*pio_mpi_nprocs_g)%(snbytes
+ /blk_size*(blk_size*blk_size)); */
+ mpi_offset = mpi_file_offset +
+ (MPI_Offset)((((size_t)nbytes_xfer / (buf_size / blk_size) *
+ (size_t)pio_mpi_nprocs_g) /
+ ((size_t)snbytes * blk_size)) *
+ (buf_size * (size_t)snbytes)) +
+ (MPI_Offset)((((size_t)nbytes_xfer / (buf_size / blk_size)) *
+ (size_t)pio_mpi_nprocs_g) %
+ ((size_t)snbytes * blk_size));
+
+ /* Number of bytes to be transferred per I/O operation */
+ nbytes_xfer_advance = blk_size * blk_size;
+
+ /* Global offset advance after each I/O operation */
+ /* mpi_offset_advance = (MPI_Offset)(snbytes/blk_size*(blk_size*blk_size)); */
+ mpi_offset_advance = (MPI_Offset)((size_t)snbytes * blk_size);
+
+ /* MPI type to be used for collective access */
+ mpi_collective_type = mpi_chunk_inter_type;
+ } /* end else */
+ } /* end else */
+
+ /* Common code for independent file access */
+ if (!parms->collective) {
+ /* Set the base of user's buffer */
+ buf_p = (unsigned char *)buffer;
+
+ /* Set the number of bytes to transfer this time */
+ nbytes_toxfer = buf_size * blk_size;
+
+ /* Loop over portions of the buffer to read */
+ while (nbytes_toxfer > 0) {
+ /* Perform independent read */
+ mrc = MPI_File_read_at(fd->mpifd, mpi_offset, buf_p, (int)nbytes_xfer_advance,
+ MPI_BYTE, &mpi_status);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_READ");
+
+ /* Advance location in buffer */
+ buf_p += nbytes_xfer_advance;
+
+ /* Advance global offset in dataset */
+ nbytes_xfer += (off_t)nbytes_xfer_advance;
+
+ /* Decrement number of bytes left this time */
+ nbytes_toxfer -= nbytes_xfer_advance;
+
+ /* Partially advance global offset in dataset */
+ mpi_offset += mpi_offset_advance;
+ } /* end while */
+ } /* end if */
+
+ /* Common code for collective file access */
+ else {
+ /* Set the file view */
+ mrc = MPI_File_set_view(fd->mpifd, mpi_offset, MPI_BYTE, mpi_collective_type,
+ "native", h5_io_info_g);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_VIEW");
+
+ /* Perform read */
+ MPI_File_read_at_all(fd->mpifd, 0, buffer, (int)(buf_size * blk_size), MPI_BYTE,
+ &mpi_status);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_READ");
+
+ /* Advance global offset in dataset */
+ nbytes_xfer += (off_t)buf_size * (off_t)blk_size;
+ } /* end else */
+
+ } /* end else */
+ break;
+
+ case PHDF5:
+ /* 1D dataspace */
+ if (!parms->dim2d) {
+ /* Set up the file dset space id to move the selection to process */
+ if (!parms->interleaved) {
+ /* Contiguous pattern */
+ h5offset[0] = nbytes_xfer;
+ } /* end if */
+ else {
+ /* Interleaved access pattern */
+ /* Skip offset over blocks of other processes */
+ h5offset[0] = (nbytes_xfer * pio_mpi_nprocs_g);
+ } /* end else */
+ hrc = H5Soffset_simple(h5dset_space_id, h5offset);
+ VRFY((hrc >= 0), "H5Soffset_simple");
+
+ /* Read the buffer in */
+ hrc = H5Dread(h5ds_id, ELMT_H5_TYPE, h5mem_space_id, h5dset_space_id, h5dxpl, buffer);
+ VRFY((hrc >= 0), "H5Dread");
+
+ /* Increment number of bytes transferred */
+ nbytes_xfer += (off_t)buf_size;
+ } /* end if */
+ /* 2D dataspace */
+ else {
+ /* Set up the file dset space id to move the selection to process */
+ if (!parms->interleaved) {
+ /* Contiguous pattern */
+ h5offset[0] =
+ (hssize_t)(((size_t)nbytes_xfer / ((size_t)snbytes * blk_size)) * blk_size);
+ h5offset[1] =
+ (hssize_t)(((size_t)nbytes_xfer % ((size_t)snbytes * blk_size)) / blk_size);
+ } /* end if */
+ else {
+ /* Interleaved access pattern */
+ /* Skip offset over blocks of other processes */
+ h5offset[0] = (hssize_t)((((size_t)nbytes_xfer * (size_t)pio_mpi_nprocs_g) /
+ ((size_t)snbytes * buf_size)) *
+ buf_size);
+ h5offset[1] = (hssize_t)((((size_t)nbytes_xfer * (size_t)pio_mpi_nprocs_g) %
+ ((size_t)snbytes * buf_size)) /
+ buf_size);
+
+ } /* end else */
+ hrc = H5Soffset_simple(h5dset_space_id, h5offset);
+ VRFY((hrc >= 0), "H5Soffset_simple");
+
+ /* Write the buffer out */
+ hrc = H5Dread(h5ds_id, ELMT_H5_TYPE, h5mem_space_id, h5dset_space_id, h5dxpl, buffer);
+ VRFY((hrc >= 0), "H5Dread");
+
+ /* Increment number of bytes transferred */
+ nbytes_xfer += (off_t)buf_size * (off_t)blk_size;
+
+ } /* end else */
+ break;
+
+ default:
+ break;
+ } /* switch (parms->io_type) */
+
+ /* Verify raw data, if asked */
+ if (parms->verify) {
+ /* Verify data read */
+ unsigned char *ucharptr = (unsigned char *)buffer;
+ size_t i;
+ int nerror = 0;
+
+ for (i = 0; i < bsize; ++i) {
+ if (*ucharptr++ != pio_mpi_rank_g + 1) {
+ if (++nerror < 20) {
+ /* report at most 20 errors */
+ HDprint_rank(output);
+ HDfprintf(output,
+ "read data error, expected (%d), "
+ "got (%d)\n",
+ pio_mpi_rank_g + 1, (int)*(ucharptr - 1));
+ } /* end if */
+ } /* end if */
+ } /* end for */
+ if (nerror >= 20) {
+ HDprint_rank(output);
+ HDfprintf(output, "...");
+ HDfprintf(output, "total read data errors=%d\n", nerror);
+ } /* end if */
+ } /* if (parms->verify) */
+
+ } /* end while */
+
+ /* Stop "raw data" read timer */
+ io_time_set(res->timers, HDF5_RAW_READ_FIXED_DIMS, TSTOP);
+
+ /* Calculate read time */
+
+ /* Close dataset. Only HDF5 needs to do an explicit close. */
+ if (parms->io_type == PHDF5) {
+ hrc = H5Dclose(h5ds_id);
+
+ if (hrc < 0) {
+ HDfprintf(stderr, "HDF5 Dataset Close failed\n");
+ GOTOERROR(FAIL);
+ }
+
+ h5ds_id = H5I_INVALID_HID;
+ } /* end if */
+ } /* end for */
+
+done:
+ /* release MPI-I/O objects */
+ if (parms->io_type == MPIO) {
+ /* 1D dataspace */
+ if (!parms->dim2d) {
+ /* Free file type */
+ mrc = MPI_Type_free(&mpi_file_type);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_FREE");
+
+ /* Free buffer type */
+ mrc = MPI_Type_free(&mpi_blk_type);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_FREE");
+ } /* end if */
+ /* 2D dataspace */
+ else {
+ /* Free partial buffer type for contiguous access */
+ mrc = MPI_Type_free(&mpi_partial_buffer_cont);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_FREE");
+
+ /* Free contiguous file type */
+ mrc = MPI_Type_free(&mpi_cont_type);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_FREE");
+
+ /* Free partial buffer type for interleaved access */
+ mrc = MPI_Type_free(&mpi_partial_buffer_inter);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_FREE");
+
+ /* Free interleaved file type */
+ mrc = MPI_Type_free(&mpi_inter_type);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_FREE");
+
+ /* Free full buffer type */
+ mrc = MPI_Type_free(&mpi_full_buffer);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_FREE");
+
+ /* Free full chunk type */
+ mrc = MPI_Type_free(&mpi_full_chunk);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_FREE");
+
+ /* Free chunk interleaved file type */
+ mrc = MPI_Type_free(&mpi_chunk_inter_type);
+ VRFY((mrc == MPI_SUCCESS), "MPIO_TYPE_FREE");
+ } /* end else */
+ } /* end if */
+
+ /* release HDF5 objects */
+ if (h5dset_space_id != -1) {
+ hrc = H5Sclose(h5dset_space_id);
+ if (hrc < 0) {
+ HDfprintf(stderr, "HDF5 Dataset Space Close failed\n");
+ ret_code = FAIL;
+ }
+ else {
+ h5dset_space_id = H5I_INVALID_HID;
+ }
+ }
+
+ if (h5mem_space_id != -1) {
+ hrc = H5Sclose(h5mem_space_id);
+ if (hrc < 0) {
+ HDfprintf(stderr, "HDF5 Memory Space Close failed\n");
+ ret_code = FAIL;
+ }
+ else {
+ h5mem_space_id = H5I_INVALID_HID;
+ }
+ }
+
+ if (h5dxpl != -1) {
+ hrc = H5Pclose(h5dxpl);
+ if (hrc < 0) {
+ HDfprintf(stderr, "HDF5 Dataset Transfer Property List Close failed\n");
+ ret_code = FAIL;
+ }
+ else {
+ h5dxpl = H5I_INVALID_HID;
+ }
+ }
+
+ return ret_code;
+}
+
+/*
+ * Function: do_fopen
+ * Purpose: Open the specified file.
+ * Return: SUCCESS or FAIL
+ * Programmer: Albert Cheng, Bill Wendling, 2001/12/13
+ * Modifications:
+ */
+static herr_t
+do_fopen(parameters *param, char *fname, file_descr *fd /*out*/, int flags)
+{
+ int ret_code = SUCCESS, mrc;
+ hid_t acc_tpl = H5I_INVALID_HID; /* file access templates */
+
+ switch (param->io_type) {
+ case POSIXIO:
+ if (flags & (PIO_CREATE | PIO_WRITE))
+ fd->posixfd = POSIXCREATE(fname);
+ else
+ fd->posixfd = POSIXOPEN(fname, O_RDONLY);
+
+ if (fd->posixfd < 0) {
+ HDfprintf(stderr, "POSIX File Open failed(%s)\n", fname);
+ GOTOERROR(FAIL);
+ }
+
+ /* The perils of POSIX I/O in a parallel environment. The problem is:
+ *
+ * - Process n opens a file with truncation and then starts
+ * writing to the file.
+ * - Process m also opens the file with truncation, but after
+ * process n has already started to write to the file. Thus,
+ * all of the stuff process n wrote is now lost.
+ */
+ MPI_Barrier(pio_comm_g);
+
+ break;
+
+ case MPIO:
+ if (flags & (PIO_CREATE | PIO_WRITE)) {
+ MPI_File_delete(fname, h5_io_info_g);
+ mrc = MPI_File_open(pio_comm_g, fname, MPI_MODE_CREATE | MPI_MODE_RDWR, h5_io_info_g,
+ &fd->mpifd);
+
+ if (mrc != MPI_SUCCESS) {
+ HDfprintf(stderr, "MPI File Open failed(%s)\n", fname);
+ GOTOERROR(FAIL);
+ }
+
+ /*since MPI_File_open with MPI_MODE_CREATE does not truncate */
+ /*filesize , set size to 0 explicitedly. */
+ mrc = MPI_File_set_size(fd->mpifd, (MPI_Offset)0);
+ if (mrc != MPI_SUCCESS) {
+ HDfprintf(stderr, "MPI_File_set_size failed\n");
+ GOTOERROR(FAIL);
+ }
+ }
+ else {
+ mrc = MPI_File_open(pio_comm_g, fname, MPI_MODE_RDONLY, h5_io_info_g, &fd->mpifd);
+ if (mrc != MPI_SUCCESS) {
+ HDfprintf(stderr, "MPI File Open failed(%s)\n", fname);
+ GOTOERROR(FAIL);
+ }
+ }
+
+ break;
+
+ case PHDF5:
+ if ((acc_tpl = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
+ HDfprintf(stderr, "HDF5 Property List Create failed\n");
+ GOTOERROR(FAIL);
+ }
+
+ /* Set the file driver to the MPI-IO driver */
+ if (H5Pset_fapl_mpio(acc_tpl, pio_comm_g, h5_io_info_g) < 0) {
+ HDfprintf(stderr, "HDF5 Property List Set failed\n");
+ GOTOERROR(FAIL);
+ }
+
+ /* Set the alignment of objects in HDF5 file */
+ if (H5Pset_alignment(acc_tpl, param->h5_thresh, param->h5_align) < 0) {
+ HDfprintf(stderr, "HDF5 Property List Set failed\n");
+ GOTOERROR(FAIL);
+ }
+
+ /* create the parallel file */
+ if (flags & (PIO_CREATE | PIO_WRITE))
+ fd->h5fd = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, acc_tpl);
+ else
+ fd->h5fd = H5Fopen(fname, H5F_ACC_RDONLY, acc_tpl);
+ if (fd->h5fd < 0) {
+ HDfprintf(stderr, "HDF5 File Create failed(%s)\n", fname);
+ GOTOERROR(FAIL);
+ }
+
+ /* verifying the close of the acc_tpl */
+ if (H5Pclose(acc_tpl) < 0) {
+ HDfprintf(stderr, "HDF5 Property List Close failed\n");
+ GOTOERROR(FAIL);
+ }
+
+ break;
+
+ default:
+ break;
+ }
+
+done:
+ return ret_code;
+}
+
+/*
+ * Function: do_fclose
+ * Purpose: Close the specified file descriptor.
+ * Return: SUCCESS or FAIL
+ * Programmer: Albert Cheng, Bill Wendling, 2001/12/13
+ * Modifications:
+ */
+static herr_t
+do_fclose(iotype iot, file_descr *fd /*out*/)
+{
+ herr_t ret_code = SUCCESS, hrc;
+ int mrc = 0, rc = 0;
+
+ switch (iot) {
+ case POSIXIO:
+ rc = POSIXCLOSE(fd->posixfd);
+
+ if (rc != 0) {
+ HDfprintf(stderr, "POSIX File Close failed\n");
+ GOTOERROR(FAIL);
+ }
+
+ fd->posixfd = -1;
+ break;
+
+ case MPIO:
+ mrc = MPI_File_close(&fd->mpifd);
+
+ if (mrc != MPI_SUCCESS) {
+ HDfprintf(stderr, "MPI File close failed\n");
+ GOTOERROR(FAIL);
+ }
+
+ fd->mpifd = MPI_FILE_NULL;
+ break;
+
+ case PHDF5:
+ hrc = H5Fclose(fd->h5fd);
+
+ if (hrc < 0) {
+ HDfprintf(stderr, "HDF5 File Close failed\n");
+ GOTOERROR(FAIL);
+ }
+
+ fd->h5fd = -1;
+ break;
+
+ default:
+ break;
+ }
+
+done:
+ return ret_code;
+}
+
+/*
+ * Function: do_fclose
+ * Purpose: Cleanup temporary file unless HDF5_NOCLEANUP is set.
+ * Only Proc 0 of the PIO communicator will do the cleanup.
+ * Other processes just return.
+ * Return: void
+ * Programmer: Albert Cheng 2001/12/12
+ * Modifications:
+ */
+static void
+do_cleanupfile(iotype iot, char *fname)
+{
+ if (pio_mpi_rank_g != 0)
+ return;
+
+ if (clean_file_g == -1)
+ clean_file_g = (getenv(HDF5_NOCLEANUP) == NULL) ? 1 : 0;
+
+ if (clean_file_g) {
+ switch (iot) {
+ case POSIXIO:
+ HDremove(fname);
+ break;
+ case MPIO:
+ case PHDF5:
+ MPI_File_delete(fname, h5_io_info_g);
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+#ifdef TIME_MPI
+/* instrument the MPI_File_wrirte_xxx and read_xxx calls to measure
+ * pure time spent in MPI_File code.
+ */
+int
+MPI_File_read_at(MPI_File fh, MPI_Offset offset, void *buf, int count, MPI_Datatype datatype,
+ MPI_Status *status)
+{
+ int err;
+ io_time_set(timer_g, HDF5_MPI_READ, TSTART);
+ err = PMPI_File_read_at(fh, offset, buf, count, datatype, status);
+ io_time_set(timer_g, HDF5_MPI_READ, TSTOP);
+ return err;
+}
+
+int
+MPI_File_read_at_all(MPI_File fh, MPI_Offset offset, void *buf, int count, MPI_Datatype datatype,
+ MPI_Status *status)
+{
+ int err;
+ io_time_set(timer_g, HDF5_MPI_READ, TSTART);
+ err = PMPI_File_read_at_all(fh, offset, buf, count, datatype, status);
+ io_time_set(timer_g, HDF5_MPI_READ, TSTOP);
+ return err;
+}
+
+int
+MPI_File_write_at(MPI_File fh, MPI_Offset offset, void *buf, int count, MPI_Datatype datatype,
+ MPI_Status *status)
+{
+ int err;
+ io_time_set(timer_g, HDF5_MPI_WRITE, TSTART);
+ err = PMPI_File_write_at(fh, offset, buf, count, datatype, status);
+ io_time_set(timer_g, HDF5_MPI_WRITE, TSTOP);
+ return err;
+}
+
+int
+MPI_File_write_at_all(MPI_File fh, MPI_Offset offset, void *buf, int count, MPI_Datatype datatype,
+ MPI_Status *status)
+{
+ int err;
+ io_time_set(timer_g, HDF5_MPI_WRITE, TSTART);
+ err = PMPI_File_write_at_all(fh, offset, buf, count, datatype, status);
+ io_time_set(timer_g, HDF5_MPI_WRITE, TSTOP);
+ return err;
+}
+
+#endif /* TIME_MPI */
+#endif /* H5_HAVE_PARALLEL */
diff --git a/tools/src/h5perf/pio_perf.c b/tools/src/h5perf/pio_perf.c
new file mode 100644
index 0000000..003c4f2
--- /dev/null
+++ b/tools/src/h5perf/pio_perf.c
@@ -0,0 +1,1717 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Parallel HDF5 Performance Testing Code
+ * --------------------------------------
+ *
+ * Portable code to test performance on the different platforms we support.
+ * This is what the report should look like:
+ *
+ * nprocs = Max#Procs
+ * IO API = POSIXIO
+ * # Files = 1, # of dsets = 1000, Elements per dset = 37000
+ * Write Results = x MB/s
+ * Read Results = x MB/s
+ * # Files = 1, # of dsets = 3000, Elements per dset = 37000
+ * Write Results = x MB/s
+ * Read Results = x MB/s
+ *
+ * . . .
+ *
+ * IO API = MPIO
+ * # Files = 1, # of dsets = 1000, Elements per dset = 37000
+ * Write Results = x MB/s
+ * Read Results = x MB/s
+ * # Files = 1, # of dsets = 3000, Elements per dset = 37000
+ * Write Results = x MB/s
+ * Read Results = x MB/s
+ *
+ * . . .
+ *
+ * IO API = PHDF5
+ * # Files = 1, # of dsets = 1000, Elements per dset = 37000
+ * Write Results = x MB/s
+ * Read Results = x MB/s
+ * # Files = 1, # of dsets = 3000, Elements per dset = 37000
+ * Write Results = x MB/s
+ * Read Results = x MB/s
+ *
+ * . . .
+ *
+ * nprocs = Max#Procs / 2
+ *
+ * . . .
+ *
+ */
+
+/* system header files */
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "hdf5.h"
+
+#ifdef H5_HAVE_PARALLEL
+
+/* library header files */
+#include <mpi.h>
+
+/* our header files */
+#include "pio_perf.h"
+
+/* useful macros */
+#define TAB_SPACE 4
+
+#define ONE_KB 1024
+#define ONE_MB (ONE_KB * ONE_KB)
+#define ONE_GB (ONE_MB * ONE_KB)
+
+#define PIO_POSIX 0x1
+#define PIO_MPI 0x2
+#define PIO_HDF5 0x4
+
+#ifdef STANDALONE
+#define DBL_EPSILON 2.2204460492503131e-16
+#define H5_DBL_ABS_EQUAL(X, Y) (fabs((X) - (Y)) < DBL_EPSILON)
+#endif
+
+/* report 0.0 in case t is zero too */
+#define MB_PER_SEC(bytes, t) (H5_DBL_ABS_EQUAL((t), 0.0) ? 0.0 : ((((double)bytes) / ONE_MB) / (t)))
+
+#ifndef TRUE
+#define TRUE 1
+#endif /* TRUE */
+#ifndef FALSE
+#define FALSE (!TRUE)
+#endif /* FALSE */
+
+/* global variables */
+FILE * output; /* output file */
+int comm_world_rank_g; /* my rank in MPI_COMM_RANK */
+int comm_world_nprocs_g; /* num. of processes of MPI_COMM_WORLD */
+MPI_Comm pio_comm_g; /* Communicator to run the PIO */
+int pio_mpi_rank_g; /* MPI rank of pio_comm_g */
+int pio_mpi_nprocs_g; /* Number of processes of pio_comm_g */
+int pio_debug_level = 0; /* The debug level:
+ * 0 - Off
+ * 1 - Minimal
+ * 2 - Some more
+ * 3 - Maximal
+ * 4 - Maximal & then some
+ */
+
+/* local variables */
+static const char *progname = "h5perf";
+
+#ifndef HDF5_PARAPREFIX
+#define HDF5_PARAPREFIX ""
+#endif
+char * paraprefix = NULL; /* for command line option para-prefix */
+MPI_Info h5_io_info_g = MPI_INFO_NULL; /* MPI INFO object for IO */
+
+/*
+ * Command-line options: The user can specify short or long-named
+ * parameters. The long-named ones can be partially spelled. When
+ * adding more, make sure that they don't clash with each other.
+ */
+#if 1
+static const char *s_opts = "a:A:B:cCd:D:e:F:ghi:Imno:p:P:stT:wx:X:";
+#else
+static const char *s_opts = "a:A:bB:cCd:D:e:F:ghi:Imno:p:P:stT:wx:X:";
+#endif /* 1 */
+static struct h5_long_options l_opts[] = {{"align", require_arg, 'a'},
+ {"api", require_arg, 'A'},
+#if 0
+ /* a sighting of the elusive binary option */
+ { "binary", no_arg, 'b' },
+#endif /* 0 */
+ {"block-size", require_arg, 'B'},
+ {"chunk", no_arg, 'c'},
+ {"collective", no_arg, 'C'},
+ {"debug", require_arg, 'D'},
+ {"geometry", no_arg, 'g'},
+ {"help", no_arg, 'h'},
+ {"interleaved", require_arg, 'I'},
+ {"max-num-processes", require_arg, 'P'},
+ {"min-num-processes", require_arg, 'p'},
+ {"max-xfer-size", require_arg, 'X'},
+ {"min-xfer-size", require_arg, 'x'},
+ {"num-bytes", require_arg, 'e'},
+ {"num-dsets", require_arg, 'd'},
+ {"num-files", require_arg, 'F'},
+ {"num-iterations", require_arg, 'i'},
+ {"output", require_arg, 'o'},
+ {"threshold", require_arg, 'T'},
+ {"write-only", require_arg, 'w'},
+ {NULL, 0, '\0'}};
+
+struct options {
+ long io_types; /* bitmask of which I/O types to test */
+ const char *output_file; /* file to print report to */
+ long num_dsets; /* number of datasets */
+ long num_files; /* number of files */
+ off_t num_bpp; /* number of bytes per proc per dset */
+ int num_iters; /* number of iterations */
+ int max_num_procs; /* maximum number of processes to use */
+ int min_num_procs; /* minimum number of processes to use */
+ size_t max_xfer_size; /* maximum transfer buffer size */
+ size_t min_xfer_size; /* minimum transfer buffer size */
+ size_t blk_size; /* Block size */
+ unsigned interleaved; /* Interleaved vs. contiguous blocks */
+ unsigned collective; /* Collective vs. independent I/O */
+ unsigned dim2d; /* 1D vs. 2D geometry */
+ int print_times; /* print times as well as throughputs */
+ int print_raw; /* print raw data throughput info */
+ off_t h5_alignment; /* alignment in HDF5 file */
+ off_t h5_threshold; /* threshold for alignment in HDF5 file */
+ int h5_use_chunks; /* Make HDF5 dataset chunked */
+ int h5_write_only; /* Perform the write tests only */
+ int verify; /* Verify data correctness */
+};
+
+typedef struct _minmax {
+ double min;
+ double max;
+ double sum;
+ int num;
+} minmax;
+
+/* local functions */
+static off_t parse_size_directive(const char *size);
+static struct options *parse_command_line(int argc, const char *const *argv);
+static void run_test_loop(struct options *options);
+static int run_test(iotype iot, parameters parms, struct options *opts);
+static void output_all_info(minmax *mm, int count, int indent_level);
+static void get_minmax(minmax *mm, double val);
+static minmax accumulate_minmax_stuff(minmax *mm, int count);
+static int create_comm_world(int num_procs, int *doing_pio);
+static int destroy_comm_world(void);
+static void output_results(const struct options *options, const char *name, minmax *table, int table_size,
+ off_t data_size);
+static void output_times(const struct options *options, const char *name, minmax *table, int table_size);
+static void output_report(const char *fmt, ...);
+static void print_indent(int indent);
+static void usage(const char *prog);
+static void report_parameters(struct options *opts);
+static off_t squareo(off_t);
+
+/*
+ * Function: main
+ * Purpose: Start things up. Initialize MPI and then call the test looping
+ * function.
+ * Return: EXIT_SUCCESS or EXIT_FAILURE
+ * Programmer: Bill Wendling, 30. October 2001
+ * Modifications:
+ */
+int
+main(int argc, char *argv[])
+{
+ int ret;
+ int exit_value = EXIT_SUCCESS;
+ struct options *opts = NULL;
+
+#ifndef STANDALONE
+ /* Initialize h5tools lib */
+ h5tools_init();
+#endif
+
+ output = stdout;
+
+ /* initialize MPI and get the maximum num of processors we started with */
+ MPI_Init(&argc, &argv);
+ ret = MPI_Comm_size(MPI_COMM_WORLD, &comm_world_nprocs_g);
+
+ if (ret != MPI_SUCCESS) {
+ HDfprintf(stderr, "%s: MPI_Comm_size call failed\n", progname);
+
+ if (ret == MPI_ERR_COMM)
+ HDfprintf(stderr, "invalid MPI communicator\n");
+ else
+ HDfprintf(stderr, "invalid argument\n");
+
+ exit_value = EXIT_FAILURE;
+ goto finish;
+ }
+
+ ret = MPI_Comm_rank(MPI_COMM_WORLD, &comm_world_rank_g);
+
+ if (ret != MPI_SUCCESS) {
+ HDfprintf(stderr, "%s: MPI_Comm_rank call failed\n", progname);
+
+ if (ret == MPI_ERR_COMM)
+ HDfprintf(stderr, "invalid MPI communicator\n");
+ else
+ HDfprintf(stderr, "invalid argument\n");
+
+ exit_value = EXIT_FAILURE;
+ goto finish;
+ }
+
+ pio_comm_g = MPI_COMM_WORLD;
+
+ h5_set_info_object();
+ opts = parse_command_line(argc, (const char *const *)argv);
+
+ if (!opts) {
+ exit_value = EXIT_FAILURE;
+ goto finish;
+ }
+
+ if (opts->output_file) {
+ if ((output = HDfopen(opts->output_file, "w")) == NULL) {
+ HDfprintf(stderr, "%s: cannot open output file\n", progname);
+ perror(opts->output_file);
+ goto finish;
+ }
+ }
+
+ if ((pio_debug_level == 0 && comm_world_rank_g == 0) || pio_debug_level > 0)
+ report_parameters(opts);
+
+ run_test_loop(opts);
+
+finish:
+ MPI_Finalize();
+ free(opts);
+ return exit_value;
+}
+
+off_t
+squareo(off_t x)
+{
+ return x * x;
+}
+
+/*
+ * Function: run_test_loop
+ * Purpose: Run the I/O tests. Write the results to OUTPUT.
+ *
+ * - The slowest changing part of the test is the number of
+ * processors to use. For each loop iteration, we divide that
+ * number by 2 and rerun the test.
+ *
+ * - The second slowest is what type of IO API to perform. We have
+ * three choices: POSIXIO, MPI-IO, and PHDF5.
+ *
+ * - Then we change the size of the buffer. This information is
+ * inferred from the number of datasets to create and the number
+ * of integers to put into each dataset. The backend code figures
+ * this out.
+ *
+ * Return: Nothing
+ * Programmer: Bill Wendling, 30. October 2001
+ * Modifications:
+ * Added 2D testing (Christian Chilan, 10. August 2005)
+ */
+static void
+run_test_loop(struct options *opts)
+{
+ parameters parms;
+ int num_procs;
+ int doing_pio; /* if this process is doing PIO */
+
+ parms.num_files = opts->num_files;
+ parms.num_dsets = opts->num_dsets;
+ parms.num_iters = opts->num_iters;
+ parms.blk_size = opts->blk_size;
+ parms.interleaved = opts->interleaved;
+ parms.collective = opts->collective;
+ parms.dim2d = opts->dim2d;
+ parms.h5_align = (hsize_t)opts->h5_alignment;
+ parms.h5_thresh = (hsize_t)opts->h5_threshold;
+ parms.h5_use_chunks = opts->h5_use_chunks;
+ parms.h5_write_only = opts->h5_write_only;
+ parms.verify = opts->verify;
+
+ /* start with max_num_procs and decrement it by half for each loop. */
+ /* if performance needs restart, fewer processes may be needed. */
+ for (num_procs = opts->max_num_procs; num_procs >= opts->min_num_procs; num_procs >>= 1) {
+ size_t buf_size;
+
+ parms.num_procs = num_procs;
+
+ if (create_comm_world(parms.num_procs, &doing_pio) != SUCCESS) {
+ /* do something harsh */
+ }
+
+ /* only processes doing PIO will run the tests */
+ if (doing_pio) {
+ output_report("Number of processors = %ld\n", parms.num_procs);
+
+ /* multiply the xfer buffer size by 2 for each loop iteration */
+ for (buf_size = opts->min_xfer_size; buf_size <= opts->max_xfer_size; buf_size <<= 1) {
+ parms.buf_size = buf_size;
+
+ if (parms.dim2d) {
+ parms.num_bytes = squareo(opts->num_bpp * parms.num_procs);
+ if (parms.interleaved)
+ output_report("Transfer Buffer Size: %ldx%ld bytes, File size: %.2f MB\n", buf_size,
+ opts->blk_size,
+ ((double)parms.num_dsets * (double)parms.num_bytes) / ONE_MB);
+ else
+ output_report("Transfer Buffer Size: %ldx%ld bytes, File size: %.2f MB\n",
+ opts->blk_size, buf_size,
+ ((double)parms.num_dsets * (double)parms.num_bytes) / ONE_MB);
+
+ print_indent(1);
+ output_report(" # of files: %ld, # of datasets: %ld, dataset size: %.2fx%.2f KB\n",
+ parms.num_files, parms.num_dsets,
+ (double)(opts->num_bpp * parms.num_procs) / ONE_KB,
+ (double)(opts->num_bpp * parms.num_procs) / ONE_KB);
+ }
+ else {
+ parms.num_bytes = (off_t)opts->num_bpp * parms.num_procs;
+ output_report("Transfer Buffer Size: %ld bytes, File size: %.2f MB\n", buf_size,
+ ((double)parms.num_dsets * (double)parms.num_bytes) / ONE_MB);
+
+ print_indent(1);
+ output_report(" # of files: %ld, # of datasets: %ld, dataset size: %.2f MB\n",
+ parms.num_files, parms.num_dsets,
+ (double)(opts->num_bpp * parms.num_procs) / ONE_MB);
+ }
+
+ if (opts->io_types & PIO_POSIX)
+ run_test(POSIXIO, parms, opts);
+
+ if (opts->io_types & PIO_MPI)
+ run_test(MPIO, parms, opts);
+
+ if (opts->io_types & PIO_HDF5)
+ run_test(PHDF5, parms, opts);
+
+ /* Run the tests once if buf_size==0, but then break out */
+ if (buf_size == 0)
+ break;
+ }
+
+ if (destroy_comm_world() != SUCCESS) {
+ /* do something harsh */
+ }
+ }
+ }
+}
+
+/*
+ * Function: run_test
+ * Purpose: Inner loop call to actually run the I/O test.
+ * Return: Nothing
+ * Programmer: Bill Wendling, 18. December 2001
+ * Modifications:
+ */
+static int
+run_test(iotype iot, parameters parms, struct options *opts)
+{
+ results res;
+ int i, ret_value = SUCCESS;
+ int comm_size;
+ off_t raw_size;
+ minmax *write_mpi_mm_table = NULL;
+ minmax *write_mm_table = NULL;
+ minmax *write_gross_mm_table = NULL;
+ minmax *write_raw_mm_table = NULL;
+ minmax *read_mpi_mm_table = NULL;
+ minmax *read_mm_table = NULL;
+ minmax *read_gross_mm_table = NULL;
+ minmax *read_raw_mm_table = NULL;
+ minmax *read_open_mm_table = NULL;
+ minmax *read_close_mm_table = NULL;
+ minmax *write_open_mm_table = NULL;
+ minmax *write_close_mm_table = NULL;
+ minmax write_mpi_mm = {0.0, 0.0, 0.0, 0};
+ minmax write_mm = {0.0, 0.0, 0.0, 0};
+ minmax write_gross_mm = {0.0, 0.0, 0.0, 0};
+ minmax write_raw_mm = {0.0, 0.0, 0.0, 0};
+ minmax read_mpi_mm = {0.0, 0.0, 0.0, 0};
+ minmax read_mm = {0.0, 0.0, 0.0, 0};
+ minmax read_gross_mm = {0.0, 0.0, 0.0, 0};
+ minmax read_raw_mm = {0.0, 0.0, 0.0, 0};
+ minmax read_open_mm = {0.0, 0.0, 0.0, 0};
+ minmax read_close_mm = {0.0, 0.0, 0.0, 0};
+ minmax write_open_mm = {0.0, 0.0, 0.0, 0};
+ minmax write_close_mm = {0.0, 0.0, 0.0, 0};
+
+ raw_size = parms.num_files * (off_t)parms.num_dsets * (off_t)parms.num_bytes;
+ parms.io_type = iot;
+ print_indent(2);
+ output_report("IO API = ");
+
+ switch (iot) {
+ case POSIXIO:
+ output_report("POSIX\n");
+ break;
+ case MPIO:
+ output_report("MPIO\n");
+ break;
+ case PHDF5:
+ output_report("PHDF5 (w/MPI-IO driver)\n");
+ break;
+ default:
+ break;
+ }
+
+ MPI_Comm_size(pio_comm_g, &comm_size);
+
+ /* allocate space for tables minmax and that it is sufficient */
+ /* to initialize all elements to zeros by calloc. */
+ write_mpi_mm_table = calloc((size_t)parms.num_iters, sizeof(minmax));
+ write_mm_table = calloc((size_t)parms.num_iters, sizeof(minmax));
+ write_gross_mm_table = calloc((size_t)parms.num_iters, sizeof(minmax));
+ write_raw_mm_table = calloc((size_t)parms.num_iters, sizeof(minmax));
+ write_open_mm_table = calloc((size_t)parms.num_iters, sizeof(minmax));
+ write_close_mm_table = calloc((size_t)parms.num_iters, sizeof(minmax));
+ if (!parms.h5_write_only) {
+ read_mpi_mm_table = calloc((size_t)parms.num_iters, sizeof(minmax));
+ read_mm_table = calloc((size_t)parms.num_iters, sizeof(minmax));
+ read_gross_mm_table = calloc((size_t)parms.num_iters, sizeof(minmax));
+ read_raw_mm_table = calloc((size_t)parms.num_iters, sizeof(minmax));
+ read_open_mm_table = calloc((size_t)parms.num_iters, sizeof(minmax));
+ read_close_mm_table = calloc((size_t)parms.num_iters, sizeof(minmax));
+ }
+
+ /* Do IO iteration times, collecting statistics each time */
+ for (i = 0; i < parms.num_iters; ++i) {
+ double t;
+
+ MPI_Barrier(pio_comm_g);
+ res = do_pio(parms);
+
+ /* gather all of the "mpi write" times */
+ t = io_time_get(res.timers, HDF5_MPI_WRITE);
+ get_minmax(&write_mpi_mm, t);
+
+ write_mpi_mm_table[i] = write_mpi_mm;
+
+ /* gather all of the "write" times */
+ t = io_time_get(res.timers, HDF5_FINE_WRITE_FIXED_DIMS);
+ get_minmax(&write_mm, t);
+
+ write_mm_table[i] = write_mm;
+
+ /* gather all of the "write" times from open to close */
+ t = io_time_get(res.timers, HDF5_GROSS_WRITE_FIXED_DIMS);
+ get_minmax(&write_gross_mm, t);
+
+ write_gross_mm_table[i] = write_gross_mm;
+
+ /* gather all of the raw "write" times */
+ t = io_time_get(res.timers, HDF5_RAW_WRITE_FIXED_DIMS);
+ get_minmax(&write_raw_mm, t);
+
+ write_raw_mm_table[i] = write_raw_mm;
+
+ /* gather all of the file open times (time from open to first write) */
+ t = io_time_get(res.timers, HDF5_FILE_WRITE_OPEN);
+ get_minmax(&write_open_mm, t);
+
+ write_open_mm_table[i] = write_open_mm;
+
+ /* gather all of the file close times (time from last write to close) */
+ t = io_time_get(res.timers, HDF5_FILE_WRITE_CLOSE);
+ get_minmax(&write_close_mm, t);
+
+ write_close_mm_table[i] = write_close_mm;
+
+ if (!parms.h5_write_only) {
+ /* gather all of the "mpi read" times */
+ t = io_time_get(res.timers, HDF5_MPI_READ);
+ get_minmax(&read_mpi_mm, t);
+
+ read_mpi_mm_table[i] = read_mpi_mm;
+
+ /* gather all of the "read" times */
+ t = io_time_get(res.timers, HDF5_FINE_READ_FIXED_DIMS);
+ get_minmax(&read_mm, t);
+
+ read_mm_table[i] = read_mm;
+
+ /* gather all of the "read" times from open to close */
+ t = io_time_get(res.timers, HDF5_GROSS_READ_FIXED_DIMS);
+ get_minmax(&read_gross_mm, t);
+
+ read_gross_mm_table[i] = read_gross_mm;
+
+ /* gather all of the raw "read" times */
+ t = io_time_get(res.timers, HDF5_RAW_READ_FIXED_DIMS);
+ get_minmax(&read_raw_mm, t);
+
+ read_raw_mm_table[i] = read_raw_mm;
+
+ /* gather all of the file open times (time from open to first read) */
+ t = io_time_get(res.timers, HDF5_FILE_READ_OPEN);
+ get_minmax(&read_open_mm, t);
+
+ read_open_mm_table[i] = read_open_mm;
+
+ /* gather all of the file close times (time from last read to close) */
+ t = io_time_get(res.timers, HDF5_FILE_READ_CLOSE);
+ get_minmax(&read_close_mm, t);
+
+ read_close_mm_table[i] = read_close_mm;
+ }
+
+ io_time_destroy(res.timers);
+ }
+
+ /*
+ * Show various statistics
+ */
+ /* Write statistics */
+ /* Print the raw data throughput if desired */
+ if (opts->print_raw) {
+ /* accumulate and output the max, min, and average "raw write" times */
+ if (pio_debug_level >= 3) {
+ /* output all of the times for all iterations */
+ print_indent(3);
+ output_report("Raw Data Write details:\n");
+ output_all_info(write_raw_mm_table, parms.num_iters, 4);
+ }
+
+ output_results(opts, "Raw Data Write", write_raw_mm_table, parms.num_iters, raw_size);
+ } /* end if */
+
+ /* show mpi write statistics */
+ if (pio_debug_level >= 3) {
+ /* output all of the times for all iterations */
+ print_indent(3);
+ output_report("MPI Write details:\n");
+ output_all_info(write_mpi_mm_table, parms.num_iters, 4);
+ }
+
+ /* We don't currently output the MPI write results */
+
+ /* accumulate and output the max, min, and average "write" times */
+ if (pio_debug_level >= 3) {
+ /* output all of the times for all iterations */
+ print_indent(3);
+ output_report("Write details:\n");
+ output_all_info(write_mm_table, parms.num_iters, 4);
+ }
+
+ output_results(opts, "Write", write_mm_table, parms.num_iters, raw_size);
+
+ /* accumulate and output the max, min, and average "gross write" times */
+ if (pio_debug_level >= 3) {
+ /* output all of the times for all iterations */
+ print_indent(3);
+ output_report("Write Open-Close details:\n");
+ output_all_info(write_gross_mm_table, parms.num_iters, 4);
+ }
+
+ output_results(opts, "Write Open-Close", write_gross_mm_table, parms.num_iters, raw_size);
+
+ if (opts->print_times) {
+ output_times(opts, "Write File Open", write_open_mm_table, parms.num_iters);
+ output_times(opts, "Write File Close", write_close_mm_table, parms.num_iters);
+ }
+
+ /* Print out time from open to first write */
+ if (pio_debug_level >= 3) {
+ /* output all of the times for all iterations */
+ print_indent(3);
+ output_report("Write file open details:\n");
+ output_all_info(write_open_mm_table, parms.num_iters, 4);
+ }
+
+ /* Print out time from last write to close */
+ if (pio_debug_level >= 3) {
+ /* output all of the times for all iterations */
+ print_indent(3);
+ output_report("Write file close details:\n");
+ output_all_info(write_close_mm_table, parms.num_iters, 4);
+ }
+
+ if (!parms.h5_write_only) {
+ /* Read statistics */
+ /* Print the raw data throughput if desired */
+ if (opts->print_raw) {
+ /* accumulate and output the max, min, and average "raw read" times */
+ if (pio_debug_level >= 3) {
+ /* output all of the times for all iterations */
+ print_indent(3);
+ output_report("Raw Data Read details:\n");
+ output_all_info(read_raw_mm_table, parms.num_iters, 4);
+ }
+
+ output_results(opts, "Raw Data Read", read_raw_mm_table, parms.num_iters, raw_size);
+ } /* end if */
+
+ /* show mpi read statistics */
+ if (pio_debug_level >= 3) {
+ /* output all of the times for all iterations */
+ print_indent(3);
+ output_report("MPI Read details:\n");
+ output_all_info(read_mpi_mm_table, parms.num_iters, 4);
+ }
+
+ /* We don't currently output the MPI read results */
+
+ /* accumulate and output the max, min, and average "read" times */
+ if (pio_debug_level >= 3) {
+ /* output all of the times for all iterations */
+ print_indent(3);
+ output_report("Read details:\n");
+ output_all_info(read_mm_table, parms.num_iters, 4);
+ }
+
+ output_results(opts, "Read", read_mm_table, parms.num_iters, raw_size);
+
+ /* accumulate and output the max, min, and average "gross read" times */
+ if (pio_debug_level >= 3) {
+ /* output all of the times for all iterations */
+ print_indent(3);
+ output_report("Read Open-Close details:\n");
+ output_all_info(read_gross_mm_table, parms.num_iters, 4);
+ }
+
+ output_results(opts, "Read Open-Close", read_gross_mm_table, parms.num_iters, raw_size);
+
+ if (opts->print_times) {
+ output_times(opts, "Read File Open", read_open_mm_table, parms.num_iters);
+ output_times(opts, "Read File Close", read_close_mm_table, parms.num_iters);
+ }
+
+ /* Print out time from open to first read */
+ if (pio_debug_level >= 3) {
+ /* output all of the times for all iterations */
+ print_indent(3);
+ output_report("Read file open details:\n");
+ output_all_info(read_open_mm_table, parms.num_iters, 4);
+ }
+
+ /* Print out time from last read to close */
+ if (pio_debug_level >= 3) {
+ /* output all of the times for all iterations */
+ print_indent(3);
+ output_report("Read file close details:\n");
+ output_all_info(read_close_mm_table, parms.num_iters, 4);
+ }
+ }
+
+ /* clean up our mess */
+ free(write_mpi_mm_table);
+ free(write_mm_table);
+ free(write_gross_mm_table);
+ free(write_raw_mm_table);
+ free(write_open_mm_table);
+ free(write_close_mm_table);
+
+ if (!parms.h5_write_only) {
+ free(read_mpi_mm_table);
+ free(read_mm_table);
+ free(read_gross_mm_table);
+ free(read_raw_mm_table);
+ free(read_open_mm_table);
+ free(read_close_mm_table);
+ }
+
+ return ret_value;
+}
+
+/*
+ * Function: output_all_info
+ * Purpose:
+ * Return: Nothing
+ * Programmer: Bill Wendling, 29. January 2002
+ * Modifications:
+ */
+static void
+output_all_info(minmax *mm, int count, int indent_level)
+{
+ int i;
+
+ for (i = 0; i < count; ++i) {
+ print_indent(indent_level);
+ output_report("Iteration %d:\n", i + 1);
+ print_indent(indent_level + 1);
+ output_report("Minimum Time: %.2fs\n", mm[i].min);
+ print_indent(indent_level + 1);
+ output_report("Maximum Time: %.2fs\n", mm[i].max);
+ }
+}
+
+/*
+ * Function: h5_set_info_object
+ * Purpose: Process environment variables setting to set up MPI Info
+ * object.
+ * Return: 0 if all is fine; otherwise non-zero.
+ * Programmer: Albert Cheng, 2002/05/21.
+ * Modifications:
+ * Bill Wendling, 2002/05/31
+ * Modified so that the HDF5_MPI_INFO environment variable can
+ * be a semicolon separated list of "key=value" pairings. Most
+ * of the code is to remove any whitespaces which might be
+ * surrounding the "key=value" pairs.
+ */
+int
+h5_set_info_object(void)
+{
+ char *envp; /* environment pointer */
+ int ret_value = 0;
+
+ /* handle any MPI INFO hints via $HDF5_MPI_INFO */
+ if ((envp = HDgetenv("HDF5_MPI_INFO")) != NULL) {
+ char *next, *valp;
+
+ valp = envp = next = HDstrdup(envp);
+
+ if (!valp)
+ return 0;
+
+ /* create an INFO object if not created yet */
+ if (h5_io_info_g == MPI_INFO_NULL)
+ MPI_Info_create(&h5_io_info_g);
+
+ do {
+ size_t len;
+ char * key_val, *endp, *namep;
+
+ if (*valp == ';')
+ valp++;
+
+ /* copy key/value pair into temporary buffer */
+ len = strcspn(valp, ";");
+ next = &valp[len];
+ key_val = (char *)HDcalloc(1, len + 1);
+
+ /* increment the next pointer past the terminating semicolon */
+ if (*next == ';')
+ ++next;
+
+ namep = HDstrncpy(key_val, valp, len);
+
+ /* pass up any beginning whitespaces */
+ while (*namep && (*namep == ' ' || *namep == '\t'))
+ namep++;
+
+ if (!*namep)
+ continue; /* was all white space, so move to next k/v pair */
+
+ /* eat up any ending white spaces */
+ endp = &namep[HDstrlen(namep) - 1];
+
+ while (endp && (*endp == ' ' || *endp == '\t'))
+ *endp-- = '\0';
+
+ /* find the '=' */
+ valp = HDstrchr(namep, '=');
+
+ if (valp != NULL) { /* it's a valid key/value pairing */
+ char *tmp_val = valp + 1;
+
+ /* change '=' to \0, move valp down one */
+ *valp-- = '\0';
+
+ /* eat up ending whitespace on the "key" part */
+ while (*valp == ' ' || *valp == '\t')
+ *valp-- = '\0';
+
+ valp = tmp_val;
+
+ /* eat up beginning whitespace on the "value" part */
+ while (*valp == ' ' || *valp == '\t')
+ *valp++ = '\0';
+
+ /* actually set the darned thing */
+ if (MPI_SUCCESS != MPI_Info_set(h5_io_info_g, namep, valp)) {
+ HDprintf("MPI_Info_set failed\n");
+ ret_value = -1;
+ }
+ }
+
+ valp = next;
+ HDfree(key_val);
+ } while (next && *next);
+
+ HDfree(envp);
+ }
+
+ return ret_value;
+}
+
+/*
+ * Function: h5_dump_info_object
+ * Purpose: Display content of an MPI Info object
+ * Return: void
+ * Programmer: Albert Cheng 2002/05/21
+ * Modifications:
+ */
+void
+h5_dump_info_object(MPI_Info info)
+{
+ char key[MPI_MAX_INFO_KEY + 1];
+ char value[MPI_MAX_INFO_VAL + 1];
+ int flag;
+ int i, nkeys;
+
+ HDprintf("Dumping MPI Info Object (up to %d bytes per item):\n", MPI_MAX_INFO_VAL);
+ if (info == MPI_INFO_NULL) {
+ HDprintf("object is MPI_INFO_NULL\n");
+ }
+ else {
+ MPI_Info_get_nkeys(info, &nkeys);
+ HDprintf("object has %d items\n", nkeys);
+ for (i = 0; i < nkeys; i++) {
+ MPI_Info_get_nthkey(info, i, key);
+ MPI_Info_get(info, key, MPI_MAX_INFO_VAL, value, &flag);
+ HDprintf("%s=%s\n", key, value);
+ }
+ }
+}
+
+/*
+ * Function: get_minmax
+ * Purpose: Gather all the min, max and total of val.
+ * Return: Nothing
+ * Programmer: Bill Wendling, 21. December 2001
+ * Modifications:
+ * Use MPI_Allreduce to do it. -akc, 2002/01/11
+ */
+static void
+get_minmax(minmax *mm, double val)
+{
+ int myrank;
+
+ MPI_Comm_rank(pio_comm_g, &myrank);
+ MPI_Comm_size(pio_comm_g, &mm->num);
+
+ MPI_Allreduce(&val, &mm->max, 1, MPI_DOUBLE, MPI_MAX, pio_comm_g);
+ MPI_Allreduce(&val, &mm->min, 1, MPI_DOUBLE, MPI_MIN, pio_comm_g);
+ MPI_Allreduce(&val, &mm->sum, 1, MPI_DOUBLE, MPI_SUM, pio_comm_g);
+}
+
+/*
+ * Function: accumulate_minmax_stuff
+ * Purpose: Accumulate the minimum, maximum, and average of the times
+ * across all processes.
+ * Return: TOTAL_MM - the total of all of these.
+ * Programmer: Bill Wendling, 21. December 2001
+ * Modifications:
+ * Changed to use seconds instead of MB/s - QAK, 5/9/02
+ */
+static minmax
+accumulate_minmax_stuff(minmax *mm, int count)
+{
+ int i;
+ minmax total_mm;
+
+ total_mm.sum = 0.0;
+ total_mm.max = -DBL_MAX;
+ total_mm.min = DBL_MAX;
+ total_mm.num = count;
+
+ for (i = 0; i < count; ++i) {
+ double m = mm[i].max;
+
+ total_mm.sum += m;
+
+ if (m < total_mm.min)
+ total_mm.min = m;
+
+ if (m > total_mm.max)
+ total_mm.max = m;
+ }
+
+ return total_mm;
+}
+
+/*
+ * Function: create_comm_world
+ * Purpose: Create an MPI Comm world and store it in pio_comm_g, which
+ * is a global variable.
+ * Return: SUCCESS on success.
+ * FAIL otherwise.
+ * Programmer: Bill Wendling, 19. December 2001
+ * Modifications:
+ */
+static int
+create_comm_world(int num_procs, int *doing_pio)
+{
+ /* MPI variables */
+ int mrc; /* return values */
+ int color; /* for communicator creation */
+ int myrank, nprocs;
+
+ pio_comm_g = MPI_COMM_NULL;
+
+ /*
+ * Create a sub communicator for this PIO run. Easier to use the first N
+ * processes.
+ */
+ MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+
+ if (num_procs > nprocs) {
+ HDfprintf(stderr, "number of process(%d) must be <= number of processes in MPI_COMM_WORLD(%d)\n",
+ num_procs, nprocs);
+ goto error_done;
+ }
+
+ MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
+ color = (myrank < num_procs);
+ mrc = MPI_Comm_split(MPI_COMM_WORLD, color, myrank, &pio_comm_g);
+
+ if (mrc != MPI_SUCCESS) {
+ HDfprintf(stderr, "MPI_Comm_split failed\n");
+ goto error_done;
+ }
+
+ if (!color) {
+ /* not involved in this run */
+ mrc = destroy_comm_world();
+ goto done;
+ }
+
+ /* determine the MPI rank in the PIO communicator */
+ MPI_Comm_size(pio_comm_g, &pio_mpi_nprocs_g);
+ MPI_Comm_rank(pio_comm_g, &pio_mpi_rank_g);
+
+done:
+ *doing_pio = color;
+ return SUCCESS;
+
+error_done:
+ destroy_comm_world();
+ return FAIL;
+}
+
+/*
+ * Function: destroy_comm_world
+ * Purpose: Destroy the created MPI Comm world which is stored in the
+ * pio_comm_g global variable.
+ * Return: SUCCESS on success.
+ * FAIL otherwise.
+ * Programmer: Bill Wendling, 19. December 2001
+ * Modifications:
+ */
+static int
+destroy_comm_world(void)
+{
+ int mrc = SUCCESS; /* return code */
+
+ /* release MPI resources */
+ if (pio_comm_g != MPI_COMM_NULL)
+ mrc = (MPI_Comm_free(&pio_comm_g) == MPI_SUCCESS ? SUCCESS : FAIL);
+
+ return mrc;
+}
+
+/*
+ * Function: output_results
+ * Purpose: Print information about the time & bandwidth for a given
+ * minmax & # of iterations.
+ * Return: Nothing
+ * Programmer: Quincey Koziol, 9. May 2002
+ * Modifications:
+ */
+static void
+output_results(const struct options *opts, const char *name, minmax *table, int table_size, off_t data_size)
+{
+ minmax total_mm;
+
+ total_mm = accumulate_minmax_stuff(table, table_size);
+
+ print_indent(3);
+ output_report("%s (%d iteration(s)):\n", name, table_size);
+
+ /* Note: The maximum throughput uses the minimum amount of time & vice versa */
+
+ print_indent(4);
+ output_report("Maximum Throughput: %6.2f MB/s", MB_PER_SEC(data_size, total_mm.min));
+ if (opts->print_times)
+ output_report(" (%7.3f s)\n", total_mm.min);
+ else
+ output_report("\n");
+
+ print_indent(4);
+ output_report("Average Throughput: %6.2f MB/s", MB_PER_SEC(data_size, total_mm.sum / total_mm.num));
+ if (opts->print_times)
+ output_report(" (%7.3f s)\n", (total_mm.sum / total_mm.num));
+ else
+ output_report("\n");
+
+ print_indent(4);
+ output_report("Minimum Throughput: %6.2f MB/s", MB_PER_SEC(data_size, total_mm.max));
+ if (opts->print_times)
+ output_report(" (%7.3f s)\n", total_mm.max);
+ else
+ output_report("\n");
+}
+
+static void
+output_times(const struct options *opts, const char *name, minmax *table, int table_size)
+{
+ minmax total_mm;
+
+ total_mm = accumulate_minmax_stuff(table, table_size);
+
+ print_indent(3);
+ output_report("%s (%d iteration(s)):\n", name, table_size);
+
+ /* Note: The maximum throughput uses the minimum amount of time & vice versa */
+
+ print_indent(4);
+ output_report("Minimum Accumulated Time using %d file(s): %7.5f s\n", opts->num_files, (total_mm.min));
+
+ print_indent(4);
+ output_report("Average Accumulated Time using %d file(s): %7.5f s\n", opts->num_files,
+ (total_mm.sum / total_mm.num));
+
+ print_indent(4);
+ output_report("Maximum Accumulated Time using %d file(s): %7.5f s\n", opts->num_files, (total_mm.max));
+}
+
+/*
+ * Function: output_report
+ * Purpose: Print a line of the report. Only do so if I'm the 0 process.
+ * Return: Nothing
+ * Programmer: Bill Wendling, 19. December 2001
+ * Modifications:
+ */
+static void
+output_report(const char *fmt, ...)
+{
+ int myrank;
+
+ MPI_Comm_rank(pio_comm_g, &myrank);
+
+ if (myrank == 0) {
+ va_list ap;
+
+ HDva_start(ap, fmt);
+ HDvfprintf(output, fmt, ap);
+ HDva_end(ap);
+ }
+}
+
+/*
+ * Function: print_indent
+ * Purpose: Print spaces to indent a new line of text for pretty printing
+ * things.
+ * Return: Nothing
+ * Programmer: Bill Wendling, 29. October 2001
+ */
+static void
+print_indent(int indent)
+{
+ int myrank;
+
+ MPI_Comm_rank(pio_comm_g, &myrank);
+
+ if (myrank == 0) {
+ indent *= TAB_SPACE;
+
+ for (; indent > 0; --indent)
+ HDfputc(' ', output);
+ }
+}
+
+static void
+recover_size_and_print(long long val, const char *end)
+{
+ if (val >= ONE_KB && (val % ONE_KB) == 0) {
+ if (val >= ONE_MB && (val % ONE_MB) == 0) {
+ if (val >= ONE_GB && (val % ONE_GB) == 0)
+ HDfprintf(output,
+ "%" H5_PRINTF_LL_WIDTH "d"
+ "GB%s",
+ val / ONE_GB, end);
+ else
+ HDfprintf(output,
+ "%" H5_PRINTF_LL_WIDTH "d"
+ "MB%s",
+ val / ONE_MB, end);
+ }
+ else {
+ HDfprintf(output,
+ "%" H5_PRINTF_LL_WIDTH "d"
+ "KB%s",
+ val / ONE_KB, end);
+ }
+ }
+ else {
+ HDfprintf(output,
+ "%" H5_PRINTF_LL_WIDTH "d"
+ "%s",
+ val, end);
+ }
+}
+
+static void
+print_io_api(long io_types)
+{
+ if (io_types & PIO_POSIX)
+ HDfprintf(output, "posix ");
+ if (io_types & PIO_MPI)
+ HDfprintf(output, "mpiio ");
+ if (io_types & PIO_HDF5)
+ HDfprintf(output, "phdf5 ");
+ HDfprintf(output, "\n");
+}
+
+static void
+report_parameters(struct options *opts)
+{
+ int rank = comm_world_rank_g;
+
+ print_version("HDF5 Library"); /* print library version */
+ HDfprintf(output, "rank %d: ==== Parameters ====\n", rank);
+
+ HDfprintf(output, "rank %d: IO API=", rank);
+ print_io_api(opts->io_types);
+
+ HDfprintf(output, "rank %d: Number of files=%ld\n", rank, opts->num_files);
+ HDfprintf(output, "rank %d: Number of datasets=%ld\n", rank, opts->num_dsets);
+ HDfprintf(output, "rank %d: Number of iterations=%d\n", rank, opts->num_iters);
+ HDfprintf(output, "rank %d: Number of processes=%d:%d\n", rank, opts->min_num_procs, opts->max_num_procs);
+
+ if (opts->dim2d) {
+ HDfprintf(output, "rank %d: Number of bytes per process per dataset=", rank);
+ recover_size_and_print((long long)(opts->num_bpp * opts->num_bpp * opts->min_num_procs), ":");
+ recover_size_and_print((long long)(opts->num_bpp * opts->num_bpp * opts->max_num_procs), "\n");
+
+ HDfprintf(output, "rank %d: Size of dataset(s)=", rank);
+ recover_size_and_print((long long)(opts->num_bpp * opts->min_num_procs), "x");
+ recover_size_and_print((long long)(opts->num_bpp * opts->min_num_procs), ":");
+ recover_size_and_print((long long)(opts->num_bpp * opts->max_num_procs), "x");
+ recover_size_and_print((long long)(opts->num_bpp * opts->max_num_procs), "\n");
+
+ HDfprintf(output, "rank %d: File size=", rank);
+ recover_size_and_print((long long)(squareo(opts->num_bpp * opts->min_num_procs) * opts->num_dsets),
+ ":");
+ recover_size_and_print((long long)(squareo(opts->num_bpp * opts->max_num_procs) * opts->num_dsets),
+ "\n");
+
+ HDfprintf(output, "rank %d: Transfer buffer size=", rank);
+ if (opts->interleaved) {
+ recover_size_and_print((long long)opts->min_xfer_size, "x");
+ recover_size_and_print((long long)opts->blk_size, ":");
+ recover_size_and_print((long long)opts->max_xfer_size, "x");
+ recover_size_and_print((long long)opts->blk_size, "\n");
+ }
+ else {
+ recover_size_and_print((long long)opts->blk_size, "x");
+ recover_size_and_print((long long)opts->min_xfer_size, ":");
+ recover_size_and_print((long long)opts->blk_size, "x");
+ recover_size_and_print((long long)opts->max_xfer_size, "\n");
+ }
+ HDfprintf(output, "rank %d: Block size=", rank);
+ recover_size_and_print((long long)opts->blk_size, "x");
+ recover_size_and_print((long long)opts->blk_size, "\n");
+ }
+ else {
+ HDfprintf(output, "rank %d: Number of bytes per process per dataset=", rank);
+ recover_size_and_print((long long)opts->num_bpp, "\n");
+
+ HDfprintf(output, "rank %d: Size of dataset(s)=", rank);
+ recover_size_and_print((long long)(opts->num_bpp * opts->min_num_procs), ":");
+ recover_size_and_print((long long)(opts->num_bpp * opts->max_num_procs), "\n");
+
+ HDfprintf(output, "rank %d: File size=", rank);
+ recover_size_and_print((long long)(opts->num_bpp * opts->min_num_procs * opts->num_dsets), ":");
+ recover_size_and_print((long long)(opts->num_bpp * opts->max_num_procs * opts->num_dsets), "\n");
+
+ HDfprintf(output, "rank %d: Transfer buffer size=", rank);
+ recover_size_and_print((long long)opts->min_xfer_size, ":");
+ recover_size_and_print((long long)opts->max_xfer_size, "\n");
+ HDfprintf(output, "rank %d: Block size=", rank);
+ recover_size_and_print((long long)opts->blk_size, "\n");
+ }
+
+ HDfprintf(output, "rank %d: Block Pattern in Dataset=", rank);
+ if (opts->interleaved)
+ HDfprintf(output, "Interleaved\n");
+ else
+ HDfprintf(output, "Contiguous\n");
+
+ HDfprintf(output, "rank %d: I/O Method for MPI and HDF5=", rank);
+ if (opts->collective)
+ HDfprintf(output, "Collective\n");
+ else
+ HDfprintf(output, "Independent\n");
+
+ HDfprintf(output, "rank %d: Geometry=", rank);
+ if (opts->dim2d)
+ HDfprintf(output, "2D\n");
+ else
+ HDfprintf(output, "1D\n");
+
+ HDfprintf(output, "rank %d: VFL used for HDF5 I/O=%s\n", rank, "MPI-IO driver");
+
+ HDfprintf(output, "rank %d: Data storage method in HDF5=", rank);
+ if (opts->h5_use_chunks)
+ HDfprintf(output, "Chunked\n");
+ else
+ HDfprintf(output, "Contiguous\n");
+
+ {
+ char *prefix = HDgetenv("HDF5_PARAPREFIX");
+
+ HDfprintf(output, "rank %d: Env HDF5_PARAPREFIX=%s\n", rank, (prefix ? prefix : "not set"));
+ }
+
+ HDfprintf(output, "rank %d: ", rank);
+ h5_dump_info_object(h5_io_info_g);
+
+ HDfprintf(output, "rank %d: ==== End of Parameters ====\n", rank);
+ HDfprintf(output, "\n");
+}
+
+/*
+ * Function: parse_command_line
+ * Purpose: Parse the command line options and return a STRUCT OPTIONS
+ * structure which will need to be freed by the calling function.
+ * Return: Pointer to an OPTIONS structure
+ * Programmer: Bill Wendling, 31. October 2001
+ * Modifications:
+ * Added 2D testing (Christian Chilan, 10. August 2005)
+ */
+static struct options *
+parse_command_line(int argc, const char *const *argv)
+{
+ int opt;
+ struct options *cl_opts;
+
+ cl_opts = (struct options *)malloc(sizeof(struct options));
+
+ cl_opts->output_file = NULL;
+ cl_opts->io_types = 0; /* will set default after parsing options */
+ cl_opts->num_dsets = 1;
+ cl_opts->num_files = 1;
+ cl_opts->num_bpp = 0;
+ cl_opts->num_iters = 1;
+ cl_opts->max_num_procs = comm_world_nprocs_g;
+ cl_opts->min_num_procs = 1;
+ cl_opts->max_xfer_size = 0;
+ cl_opts->min_xfer_size = 0;
+ cl_opts->blk_size = 0;
+ cl_opts->interleaved = 0; /* Default to contiguous blocks in dataset */
+ cl_opts->collective = 0; /* Default to independent I/O access */
+ cl_opts->dim2d = 0; /* Default to 1D */
+ cl_opts->print_times = FALSE; /* Printing times is off by default */
+ cl_opts->print_raw = FALSE; /* Printing raw data throughput is off by default */
+ cl_opts->h5_alignment = 1; /* No alignment for HDF5 objects by default */
+ cl_opts->h5_threshold = 1; /* No threshold for aligning HDF5 objects by default */
+ cl_opts->h5_use_chunks = FALSE; /* Don't chunk the HDF5 dataset by default */
+ cl_opts->h5_write_only = FALSE; /* Do both read and write by default */
+ cl_opts->verify = FALSE; /* No Verify data correctness by default */
+
+ while ((opt = H5_get_option(argc, argv, s_opts, l_opts)) != EOF) {
+ switch ((char)opt) {
+ case 'a':
+ cl_opts->h5_alignment = parse_size_directive(H5_optarg);
+ break;
+ case 'A': {
+ const char *end = H5_optarg;
+
+ while (end && *end != '\0') {
+ char buf[10];
+ int i;
+
+ HDmemset(buf, '\0', sizeof(buf));
+
+ for (i = 0; *end != '\0' && *end != ','; ++end)
+ if (isalnum(*end) && i < 10)
+ buf[i++] = *end;
+
+ if (!HDstrcasecmp(buf, "phdf5")) {
+ cl_opts->io_types |= PIO_HDF5;
+ }
+ else if (!HDstrcasecmp(buf, "mpiio")) {
+ cl_opts->io_types |= PIO_MPI;
+ }
+ else if (!HDstrcasecmp(buf, "posix")) {
+ cl_opts->io_types |= PIO_POSIX;
+ }
+ else {
+ HDfprintf(stderr, "pio_perf: invalid --api option %s\n", buf);
+ HDexit(EXIT_FAILURE);
+ }
+
+ if (*end == '\0')
+ break;
+
+ end++;
+ }
+ }
+
+ break;
+#if 0
+ case 'b':
+ /* the future "binary" option */
+ break;
+#endif /* 0 */
+ case 'B':
+ cl_opts->blk_size = (size_t)parse_size_directive(H5_optarg);
+ break;
+ case 'c':
+ /* Turn on chunked HDF5 dataset creation */
+ cl_opts->h5_use_chunks = TRUE;
+ break;
+ case 'C':
+ cl_opts->collective = 1;
+ break;
+ case 'd':
+ cl_opts->num_dsets = atoi(H5_optarg);
+ break;
+ case 'D': {
+ const char *end = H5_optarg;
+
+ while (end && *end != '\0') {
+ char buf[10];
+ int i;
+
+ HDmemset(buf, '\0', sizeof(buf));
+
+ for (i = 0; *end != '\0' && *end != ','; ++end)
+ if (HDisalnum(*end) && i < 10)
+ buf[i++] = *end;
+
+ if (HDstrlen(buf) > 1 || HDisdigit(buf[0])) {
+ size_t j;
+
+ for (j = 0; j < 10 && buf[j] != '\0'; ++j)
+ if (!isdigit(buf[j])) {
+ HDfprintf(stderr, "pio_perf: invalid --debug option %s\n", buf);
+ HDexit(EXIT_FAILURE);
+ }
+
+ pio_debug_level = atoi(buf);
+
+ if (pio_debug_level > 4)
+ pio_debug_level = 4;
+ else if (pio_debug_level < 0)
+ pio_debug_level = 0;
+ }
+ else {
+ switch (*buf) {
+ case 'r':
+ /* Turn on raw data throughput info */
+ cl_opts->print_raw = TRUE;
+ break;
+ case 't':
+ /* Turn on time printing */
+ cl_opts->print_times = TRUE;
+ break;
+ case 'v':
+ /* Turn on verify data correctness*/
+ cl_opts->verify = TRUE;
+ break;
+ default:
+ HDfprintf(stderr, "pio_perf: invalid --debug option %s\n", buf);
+ HDexit(EXIT_FAILURE);
+ }
+ }
+
+ if (*end == '\0')
+ break;
+
+ end++;
+ }
+ }
+
+ break;
+ case 'e':
+ cl_opts->num_bpp = parse_size_directive(H5_optarg);
+ break;
+ case 'F':
+ cl_opts->num_files = HDatoi(H5_optarg);
+ break;
+ case 'g':
+ cl_opts->dim2d = 1;
+ break;
+ case 'i':
+ cl_opts->num_iters = HDatoi(H5_optarg);
+ break;
+ case 'I':
+ cl_opts->interleaved = 1;
+ break;
+ case 'o':
+ cl_opts->output_file = H5_optarg;
+ break;
+ case 'p':
+ cl_opts->min_num_procs = HDatoi(H5_optarg);
+ break;
+ case 'P':
+ cl_opts->max_num_procs = HDatoi(H5_optarg);
+ break;
+ case 'T':
+ cl_opts->h5_threshold = parse_size_directive(H5_optarg);
+ break;
+ case 'w':
+ cl_opts->h5_write_only = TRUE;
+ break;
+ case 'x':
+ cl_opts->min_xfer_size = (size_t)parse_size_directive(H5_optarg);
+ break;
+ case 'X':
+ cl_opts->max_xfer_size = (size_t)parse_size_directive(H5_optarg);
+ break;
+ case 'h':
+ case '?':
+ default:
+ usage(progname);
+ HDfree(cl_opts);
+ return NULL;
+ }
+ }
+
+ if (cl_opts->num_bpp == 0) {
+ if (cl_opts->dim2d == 0)
+ cl_opts->num_bpp = 256 * ONE_KB;
+ else
+ cl_opts->num_bpp = 8 * ONE_KB;
+ }
+
+ if (cl_opts->max_xfer_size == 0)
+ cl_opts->max_xfer_size = (size_t)cl_opts->num_bpp;
+
+ if (cl_opts->min_xfer_size == 0)
+ cl_opts->min_xfer_size = (size_t)(cl_opts->num_bpp) / 2;
+
+ if (cl_opts->blk_size == 0)
+ cl_opts->blk_size = (size_t)(cl_opts->num_bpp) / 2;
+
+ /* set default if none specified yet */
+ if (!cl_opts->io_types)
+ cl_opts->io_types = PIO_HDF5 | PIO_MPI | PIO_POSIX; /* run all API */
+
+ /* verify parameters sanity. Adjust if needed. */
+ /* cap xfer_size with bytes per process */
+ if (!cl_opts->dim2d) {
+ if (cl_opts->min_xfer_size > (size_t)cl_opts->num_bpp)
+ cl_opts->min_xfer_size = (size_t)cl_opts->num_bpp;
+ if (cl_opts->max_xfer_size > (size_t)cl_opts->num_bpp)
+ cl_opts->max_xfer_size = (size_t)cl_opts->num_bpp;
+ }
+ if (cl_opts->min_xfer_size > cl_opts->max_xfer_size)
+ cl_opts->min_xfer_size = cl_opts->max_xfer_size;
+ if (cl_opts->blk_size > (size_t)cl_opts->num_bpp)
+ cl_opts->blk_size = (size_t)cl_opts->num_bpp;
+ /* check range of number of processes */
+ if (cl_opts->min_num_procs <= 0)
+ cl_opts->min_num_procs = 1;
+ if (cl_opts->max_num_procs <= 0)
+ cl_opts->max_num_procs = 1;
+ if (cl_opts->min_num_procs > cl_opts->max_num_procs)
+ cl_opts->min_num_procs = cl_opts->max_num_procs;
+ /* check iteration */
+ if (cl_opts->num_iters <= 0)
+ cl_opts->num_iters = 1;
+
+ return cl_opts;
+}
+
+/*
+ * Function: parse_size_directive
+ * Purpose: Parse the size directive passed on the commandline. The size
+ * directive is an integer followed by a size indicator:
+ *
+ * K, k - Kilobyte
+ * M, m - Megabyte
+ * G, g - Gigabyte
+ *
+ * Return: The size as a off_t because this is related to file size.
+ * If an unknown size indicator is used, then the program will
+ * exit with EXIT_FAILURE as the return value.
+ * Programmer: Bill Wendling, 18. December 2001
+ * Modifications:
+ */
+static off_t
+parse_size_directive(const char *size)
+{
+ off_t s;
+ char *endptr;
+
+ s = HDstrtol(size, &endptr, 10);
+
+ if (endptr && *endptr) {
+ while (*endptr != '\0' && (*endptr == ' ' || *endptr == '\t'))
+ ++endptr;
+
+ switch (*endptr) {
+ case 'K':
+ case 'k':
+ s *= ONE_KB;
+ break;
+ case 'M':
+ case 'm':
+ s *= ONE_MB;
+ break;
+ case 'G':
+ case 'g':
+ s *= ONE_GB;
+ break;
+ default:
+ HDfprintf(stderr, "Illegal size specifier '%c'\n", *endptr);
+ HDexit(EXIT_FAILURE);
+ }
+ }
+
+ return s;
+}
+
+/*
+ * Function: usage
+ * Purpose: Print a usage message and then exit.
+ * Return: Nothing
+ * Programmer: Bill Wendling, 31. October 2001
+ * Modifications:
+ * Added 2D testing (Christian Chilan, 10. August 2005)
+ */
+static void
+usage(const char *prog)
+{
+ int myrank;
+
+ MPI_Comm_rank(pio_comm_g, &myrank);
+
+ if (myrank == 0) {
+ print_version(prog);
+ HDprintf("usage: %s [OPTIONS]\n", prog);
+ HDprintf(" OPTIONS\n");
+ HDprintf(" -h, --help Print a usage message and exit\n");
+ HDprintf(" -a S, --align=S Alignment of objects in HDF5 file [default: 1]\n");
+ HDprintf(" -A AL, --api=AL Which APIs to test [default: all of them]\n");
+#if 0
+ HDprintf(" -b, --binary The elusive binary option\n");
+#endif /* 0 */
+ HDprintf(" -B S, --block-size=S Block size within transfer buffer\n");
+ HDprintf(" (see below for description)\n");
+ HDprintf(" [default: half the number of bytes per process\n");
+ HDprintf(" per dataset]\n");
+ HDprintf(" -c, --chunk Create HDF5 datasets using chunked storage\n");
+ HDprintf(" [default: contiguous storage]\n");
+ HDprintf(" -C, --collective Use collective I/O for MPI and HDF5 APIs\n");
+ HDprintf(" [default: independent I/O)\n");
+ HDprintf(" -d N, --num-dsets=N Number of datasets per file [default: 1]\n");
+ HDprintf(" -D DL, --debug=DL Indicate the debugging level\n");
+ HDprintf(" [default: no debugging]\n");
+ HDprintf(" -e S, --num-bytes=S Number of bytes per process per dataset\n");
+ HDprintf(" (see below for description)\n");
+ HDprintf(" [default: 256K for 1D, 8K for 2D]\n");
+ HDprintf(" -F N, --num-files=N Number of files [default: 1]\n");
+ HDprintf(" -g, --geometry Use 2D geometry [default: 1D geometry]\n");
+ HDprintf(" -i N, --num-iterations=N Number of iterations to perform [default: 1]\n");
+ HDprintf(" -I, --interleaved Interleaved access pattern\n");
+ HDprintf(" (see below for example)\n");
+ HDprintf(" [default: Contiguous access pattern]\n");
+ HDprintf(" -o F, --output=F Output raw data into file F [default: none]\n");
+ HDprintf(" -p N, --min-num-processes=N Minimum number of processes to use [default: 1]\n");
+ HDprintf(" -P N, --max-num-processes=N Maximum number of processes to use\n");
+ HDprintf(" [default: all MPI_COMM_WORLD processes ]\n");
+ HDprintf(" -T S, --threshold=S Threshold for alignment of objects in HDF5 file\n");
+ HDprintf(" [default: 1]\n");
+ HDprintf(" -w, --write-only Perform write tests not the read tests\n");
+ HDprintf(" -x S, --min-xfer-size=S Minimum transfer buffer size\n");
+ HDprintf(" (see below for description)\n");
+ HDprintf(" [default: half the number of bytes per process\n");
+ HDprintf(" per dataset]\n");
+ HDprintf(" -X S, --max-xfer-size=S Maximum transfer buffer size\n");
+ HDprintf(" [default: the number of bytes per process per\n");
+ HDprintf(" dataset]\n");
+ HDprintf("\n");
+ HDprintf(" F - is a filename.\n");
+ HDprintf(" N - is an integer >=0.\n");
+ HDprintf(" S - is a size specifier, an integer >=0 followed by a size indicator:\n");
+ HDprintf(" K - Kilobyte (%d)\n", ONE_KB);
+ HDprintf(" M - Megabyte (%d)\n", ONE_MB);
+ HDprintf(" G - Gigabyte (%d)\n", ONE_GB);
+ HDprintf("\n");
+ HDprintf(" Example: '37M' is 37 megabytes or %d bytes\n", 37 * ONE_MB);
+ HDprintf("\n");
+ HDprintf(" AL - is an API list. Valid values are:\n");
+ HDprintf(" phdf5 - Parallel HDF5\n");
+ HDprintf(" mpiio - MPI-I/O\n");
+ HDprintf(" posix - POSIX\n");
+ HDprintf("\n");
+ HDprintf(" Example: --api=mpiio,phdf5\n");
+ HDprintf("\n");
+ HDprintf(" Dataset size:\n");
+ HDprintf(" Depending on the selected geometry, each test dataset is either a linear\n");
+ HDprintf(" array of size bytes-per-process * num-processes, or a square array of size\n");
+ HDprintf(" (bytes-per-process * num-processes) x (bytes-per-process * num-processes).\n");
+ HDprintf("\n");
+ HDprintf(" Block size vs. Transfer buffer size:\n");
+ HDprintf(" buffer-size controls the size of the memory buffer, which is broken into\n");
+ HDprintf(" blocks and written to the file. Depending on the selected geometry, each\n");
+ HDprintf(" block can be a linear array of size block-size or a square array of size\n");
+ HDprintf(" block-size x block-size. The arrangement in which blocks are written is\n");
+ HDprintf(" determined by the access pattern.\n");
+ HDprintf("\n");
+ HDprintf(" In 1D geometry, the transfer buffer is a linear array of size buffer-size.\n");
+ HDprintf(" In 2D geometry, it is a rectangular array of size block-size x buffer-size\n");
+ HDprintf(" or buffer-size x block-size if interleaved pattern is selected.\n");
+ HDprintf("\n");
+ HDprintf(" Interleaved and Contiguous patterns in 1D geometry:\n");
+ HDprintf(" When contiguous access pattern is chosen, the dataset is evenly divided\n");
+ HDprintf(" into num-processes regions and each process writes data to its own region.\n");
+ HDprintf(" When interleaved blocks are written to a dataset, space for the first\n");
+ HDprintf(" block of the first process is allocated in the dataset, then space is\n");
+ HDprintf(" allocated for the first block of the second process, etc. until space is\n");
+ HDprintf(" allocated for the first block of each process, then space is allocated for\n");
+ HDprintf(" the second block of the first process, the second block of the second\n");
+ HDprintf(" process, etc.\n");
+ HDprintf("\n");
+ HDprintf(" For example, with a 3 process run, 512KB bytes-per-process, 256KB transfer\n");
+ HDprintf(" buffer size, and 64KB block size, each process must issue 2 transfer\n");
+ HDprintf(" requests to complete access to the dataset.\n");
+ HDprintf(" Contiguous blocks of the first transfer request are written like so:\n");
+ HDprintf(" 1111----2222----3333----\n");
+ HDprintf(" Interleaved blocks of the first transfer request are written like so:\n");
+ HDprintf(" 123123123123------------\n");
+ HDprintf(" The actual number of I/O operations involved in a transfer request\n");
+ HDprintf(" depends on the access pattern and communication mode.\n");
+ HDprintf(" When using independent I/O with interleaved pattern, each process\n");
+ HDprintf(" performs 4 small non-contiguous I/O operations per transfer request.\n");
+ HDprintf(" If collective I/O is turned on, the combined content of the buffers of\n");
+ HDprintf(" the 3 processes will be written using one collective I/O operation\n");
+ HDprintf(" per transfer request.\n");
+ HDprintf("\n");
+ HDprintf(" For information about access patterns in 2D geometry, please refer to the\n");
+ HDprintf(" HDF5 Reference Manual.\n");
+ HDprintf("\n");
+ HDprintf(" DL - is a list of debugging flags. Valid values are:\n");
+ HDprintf(" 1 - Minimal\n");
+ HDprintf(" 2 - Not quite everything\n");
+ HDprintf(" 3 - Everything\n");
+ HDprintf(" 4 - The kitchen sink\n");
+ HDprintf(" r - Raw data I/O throughput information\n");
+ HDprintf(" t - Times as well as throughputs\n");
+ HDprintf(" v - Verify data correctness\n");
+ HDprintf("\n");
+ HDprintf(" Example: --debug=2,r,t\n");
+ HDprintf("\n");
+ HDprintf(" Environment variables:\n");
+ HDprintf(" HDF5_NOCLEANUP Do not remove data files if set [default remove]\n");
+ HDprintf(" HDF5_MPI_INFO MPI INFO object key=value separated by ;\n");
+ HDprintf(" HDF5_PARAPREFIX Paralllel data files prefix\n");
+ fflush(stdout);
+ } /* end if */
+} /* end usage() */
+
+#else /* H5_HAVE_PARALLEL */
+
+/*
+ * Function: main
+ * Purpose: Dummy main() function for if HDF5 was configured without
+ * parallel stuff.
+ * Return: EXIT_SUCCESS
+ * Programmer: Bill Wendling, 14. November 2001
+ */
+int
+main(void)
+{
+ HDprintf("No parallel IO performance because parallel is not configured\n");
+ return EXIT_SUCCESS;
+} /* end main */
+
+#endif /* !H5_HAVE_PARALLEL */
diff --git a/tools/src/h5perf/pio_perf.h b/tools/src/h5perf/pio_perf.h
new file mode 100644
index 0000000..8924c20
--- /dev/null
+++ b/tools/src/h5perf/pio_perf.h
@@ -0,0 +1,109 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+#ifndef PIO_PERF_H
+#define PIO_PERF_H
+
+#ifndef STANDALONE
+#include "io_timer.h"
+#include "H5private.h"
+#include "h5tools.h"
+#include "h5tools_utils.h"
+#else
+#include "io_timer.h"
+#include "pio_standalone.h"
+#endif
+
+#ifdef H5_HAVE_PARALLEL
+extern MPI_Info h5_io_info_g; /* MPI INFO object for IO */
+#endif
+
+#ifdef H5_HAVE_PARALLEL
+int h5_set_info_object(void);
+void h5_dump_info_object(MPI_Info info);
+#endif
+
+/* setup the dataset no fill option if this is v1.5 or more */
+#if H5_VERS_MAJOR > 1 || H5_VERS_MINOR > 4
+#define H5_HAVE_NOFILL 1
+#endif
+
+typedef enum iotype_ {
+ POSIXIO,
+ MPIO,
+ PHDF5
+ /*NUM_TYPES*/
+} iotype;
+
+typedef struct parameters_ {
+ iotype io_type; /* The type of IO test to perform */
+ int num_procs; /* Maximum number of processes to use */
+ long num_files; /* Number of files to create */
+ long num_dsets; /* Number of datasets to create */
+ off_t num_bytes; /* Number of bytes in each dset */
+ int num_iters; /* Number of times to loop doing the IO */
+ size_t buf_size; /* Buffer size */
+ size_t blk_size; /* Block size */
+ unsigned interleaved; /* Interleaved vs. contiguous blocks */
+ unsigned collective; /* Collective vs. independent I/O */
+ unsigned dim2d; /* 1D vs. 2D */
+ hsize_t h5_align; /* HDF5 object alignment */
+ hsize_t h5_thresh; /* HDF5 object alignment threshold */
+ int h5_use_chunks; /* Make HDF5 dataset chunked */
+ int h5_write_only; /* Perform the write tests only */
+ int verify; /* Verify data correctness */
+} parameters;
+
+typedef struct results_ {
+ herr_t ret_code;
+ io_time_t *timers;
+} results;
+
+#ifndef SUCCESS
+#define SUCCESS 0
+#endif /* !SUCCESS */
+
+#ifndef FAIL
+#define FAIL -1
+#endif /* !FAIL */
+
+extern FILE * output; /* output file */
+extern io_time_t *timer_g; /* timer: global for stub functions */
+extern int comm_world_rank_g; /* my rank in MPI_COMM_RANK */
+extern int comm_world_nprocs_g; /* num. of processes of MPI_COMM_WORLD */
+extern MPI_Comm pio_comm_g; /* Communicator to run the PIO */
+extern int pio_mpi_rank_g; /* MPI rank of pio_comm_g */
+extern int pio_mpi_nprocs_g; /* number of processes of pio_comm_g */
+extern int pio_debug_level; /* The debug level:
+ * 0 - Off
+ * 1 - Minimal
+ * 2 - Some more
+ * 3 - Maximal
+ * 4 - Even More Debugging (timer stuff)
+ */
+
+#define HDprint_rank(f) /* print rank in MPI_COMM_WORLD */ HDfprintf(f, "%d: ", comm_world_rank_g);
+#define HDprint_size(f) /* print size of MPI_COMM_WORLD */ HDfprintf(f, "%d", comm_world_nprocs_g);
+#define HDprint_rank_size(f) /* print rank/size of MPI_COMM_WORLD */ \
+ HDfprintf(f, "%d/%d: ", comm_world_rank_g, comm_world_nprocs_g);
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+extern results do_pio(parameters param);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* PIO_PERF_H */
diff --git a/tools/src/h5perf/sio_engine.c b/tools/src/h5perf/sio_engine.c
new file mode 100644
index 0000000..bdd2c08
--- /dev/null
+++ b/tools/src/h5perf/sio_engine.c
@@ -0,0 +1,1328 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Author: Christian Chilan, April 2008
+ */
+
+#include "hdf5.h"
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef H5_HAVE_UNISTD_H
+#include <sys/types.h>
+#include <unistd.h>
+#endif
+
+#ifdef H5_HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+
+#include "sio_perf.h"
+
+/* Macro definitions */
+
+/* sizes of various items. these sizes won't change during program execution */
+#define ELMT_H5_TYPE H5T_NATIVE_UCHAR
+
+#define GOTOERROR(errcode) \
+ { \
+ ret_code = errcode; \
+ goto done; \
+ }
+#define ERRMSG(mesg) \
+ { \
+ HDfprintf(stderr, "*** Assertion failed (%s) at line %4d in %s\n", mesg, (int)__LINE__, __FILE__); \
+ }
+
+/* verify: if val is false (0), print mesg. */
+#define VRFY(val, mesg) \
+ do { \
+ if (!(val)) { \
+ ERRMSG(mesg); \
+ GOTOERROR(FAIL); \
+ } \
+ } while (0)
+
+/* POSIX I/O macros */
+#ifdef H5_HAVE_WIN32_API
+/* Can't link against the library, so this test will use the older, non-Unicode
+ * _open() call on Windows.
+ */
+#define HDopen(S, F, ...) _open(S, F | _O_BINARY, __VA_ARGS__)
+#endif /* H5_HAVE_WIN32_API */
+#define POSIXCREATE(fn) HDopen(fn, O_CREAT | O_TRUNC | O_RDWR, 0600)
+#define POSIXOPEN(fn, F) HDopen(fn, F, 0600)
+#define POSIXCLOSE(F) HDclose(F)
+#define POSIXSEEK(F, L) HDlseek(F, L, SEEK_SET)
+#define POSIXWRITE(F, B, S) HDwrite(F, B, S)
+#define POSIXREAD(F, B, S) HDread(F, B, S)
+
+enum { SIO_CREATE = 1, SIO_WRITE = 2, SIO_READ = 4 };
+
+/* Global variables */
+static int clean_file_g = -1; /*whether to cleanup temporary test */
+/*files. -1 is not defined; */
+/*0 is no cleanup; 1 is do cleanup */
+
+/* the different types of file descriptors we can expect */
+typedef union {
+ int posixfd; /* POSIX file handle*/
+ hid_t h5fd; /* HDF5 file */
+} file_descr;
+
+/* local functions */
+static char * sio_create_filename(iotype iot, const char *base_name, char *fullname, size_t size,
+ parameters *param);
+static herr_t do_write(results *res, file_descr *fd, parameters *parms, void *buffer);
+static herr_t do_read(results *res, file_descr *fd, parameters *parms, void *buffer);
+static herr_t dset_write(int local_dim, file_descr *fd, parameters *parms, void *buffer);
+static herr_t posix_buffer_write(int local_dim, file_descr *fd, parameters *parms, void *buffer);
+static herr_t dset_read(int localrank, file_descr *fd, parameters *parms, void *buffer, const char *buffer2);
+static herr_t posix_buffer_read(int local_dim, file_descr *fd, parameters *parms, void *buffer);
+static herr_t do_fopen(parameters *param, char *fname, file_descr *fd /*out*/, int flags);
+hid_t set_vfd(parameters *param);
+static herr_t do_fclose(iotype iot, file_descr *fd);
+static void do_cleanupfile(iotype iot, char *fname);
+
+/* global variables */
+static HDoff_t offset[MAX_DIMS]; /* dataset size in bytes */
+static size_t buf_offset[MAX_DIMS]; /* dataset size in bytes */
+static int order[MAX_DIMS]; /* dimension access order */
+static size_t linear_buf_size; /* linear buffer size */
+static int cont_dim; /* lowest dimension for contiguous POSIX
+ access */
+static size_t cont_size; /* size of contiguous POSIX access */
+static hid_t fapl; /* file access list */
+static unsigned char *buf_p; /* buffer pointer */
+static const char * multi_letters = "msbrglo"; /* string for multi driver */
+
+/* HDF5 global variables */
+static hsize_t h5count[MAX_DIMS]; /*selection count */
+static hssize_t h5offset[MAX_DIMS]; /* Selection offset within dataspace */
+static hid_t h5dset_space_id = H5I_INVALID_HID; /*dataset space ID */
+static hid_t h5mem_space_id = H5I_INVALID_HID; /*memory dataspace ID */
+static hid_t h5ds_id = H5I_INVALID_HID; /*dataset handle */
+static hid_t h5dcpl = H5I_INVALID_HID; /* Dataset creation property list */
+static hid_t h5dxpl = H5I_INVALID_HID; /* Dataset transfer property list */
+
+/*
+ * Function: do_sio
+ * Purpose: SIO Engine where IO are executed.
+ * Return: results
+ * Programmer: Christian Chilan, April, 2008
+ * Modifications:
+ */
+void
+do_sio(parameters param, results *res)
+{
+ char * buffer = NULL; /*data buffer pointer */
+ size_t buf_size[MAX_DIMS]; /* general buffer size in bytes */
+ file_descr fd; /* file handles */
+ iotype iot; /* API type */
+ char base_name[256]; /* test file base name */
+ /* return codes */
+ herr_t ret_code = 0; /*return code */
+
+ char fname[FILENAME_MAX]; /* test file name */
+ int i;
+ /* HDF5 variables */
+ herr_t hrc; /*HDF5 return code */
+
+ /* Sanity check parameters */
+
+ /* IO type */
+ iot = param.io_type;
+
+ switch (iot) {
+ case POSIXIO:
+ fd.posixfd = -1;
+ res->timers = io_time_new(SYS_CLOCK);
+ break;
+ case HDF5:
+ fd.h5fd = -1;
+ res->timers = io_time_new(SYS_CLOCK);
+ break;
+ default:
+ /* unknown request */
+ HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)iot);
+ GOTOERROR(FAIL);
+ }
+
+ linear_buf_size = 1;
+
+ for (i = 0; i < param.rank; i++) {
+ buf_size[i] = param.buf_size[i];
+ order[i] = param.order[i];
+ linear_buf_size *= buf_size[i];
+ buf_offset[i] = 0;
+ offset[i] = 0;
+
+ /* Validate transfer buffer size */
+ if (param.buf_size[i] <= 0) {
+ HDfprintf(stderr, "Transfer buffer size[%d] (%zu) must be > 0\n", i, buf_size[i]);
+ GOTOERROR(FAIL);
+ }
+
+ if ((param.dset_size[i] % param.buf_size[i]) != 0) {
+ HDfprintf(stderr,
+ "Dataset size[%d] (%" H5_PRINTF_LL_WIDTH "d) must be a multiple of the "
+ "transfer buffer size[%d] (%zu)\n",
+ param.rank, (long long)param.dset_size[i], param.rank, param.buf_size[i]);
+ GOTOERROR(FAIL);
+ }
+ }
+
+ /* Allocate transfer buffer */
+ if ((buffer = (char *)malloc(linear_buf_size)) == NULL) {
+ HDfprintf(stderr, "malloc for transfer buffer size (%zu) failed\n", linear_buf_size);
+ GOTOERROR(FAIL);
+ }
+
+ if (sio_debug_level >= 4)
+
+ /* output all of the times for all iterations */
+ HDfprintf(output, "Timer details:\n");
+
+ /*
+ * Write performance measurement
+ */
+ /* Open file for write */
+
+ HDstrcpy(base_name, "#sio_tmp");
+ sio_create_filename(iot, base_name, fname, sizeof(fname), &param);
+
+ if (sio_debug_level > 0)
+ HDfprintf(output, "data filename=%s\n", fname);
+
+ io_time_set(res->timers, HDF5_GROSS_WRITE_FIXED_DIMS, TSTART);
+ hrc = do_fopen(&param, fname, &fd, SIO_CREATE | SIO_WRITE);
+ VRFY((hrc == SUCCESS), "do_fopen failed");
+
+ io_time_set(res->timers, HDF5_FINE_WRITE_FIXED_DIMS, TSTART);
+ hrc = do_write(res, &fd, &param, buffer);
+ io_time_set(res->timers, HDF5_FINE_WRITE_FIXED_DIMS, TSTOP);
+ VRFY((hrc == SUCCESS), "do_write failed");
+
+ /* Close file for write */
+ hrc = do_fclose(iot, &fd);
+ io_time_set(res->timers, HDF5_GROSS_WRITE_FIXED_DIMS, TSTOP);
+ VRFY((hrc == SUCCESS), "do_fclose failed");
+
+ if (!param.h5_write_only) {
+ /*
+ * Read performance measurement
+ */
+
+ /* Open file for read */
+ io_time_set(res->timers, HDF5_GROSS_READ_FIXED_DIMS, TSTART);
+ hrc = do_fopen(&param, fname, &fd, SIO_READ);
+ VRFY((hrc == SUCCESS), "do_fopen failed");
+
+ io_time_set(res->timers, HDF5_FINE_READ_FIXED_DIMS, TSTART);
+ hrc = do_read(res, &fd, &param, buffer);
+ io_time_set(res->timers, HDF5_FINE_READ_FIXED_DIMS, TSTOP);
+ VRFY((hrc == SUCCESS), "do_read failed");
+
+ /* Close file for read */
+ hrc = do_fclose(iot, &fd);
+
+ io_time_set(res->timers, HDF5_GROSS_READ_FIXED_DIMS, TSTOP);
+ VRFY((hrc == SUCCESS), "do_fclose failed");
+ }
+
+ do_cleanupfile(iot, fname);
+
+done:
+ /* clean up */
+ /* release HDF5 objects */
+
+ /* close any opened files */
+ /* no remove(fname) because that should have happened normally. */
+ switch (iot) {
+ case POSIXIO:
+ if (fd.posixfd != -1)
+ hrc = do_fclose(iot, &fd);
+ break;
+ case HDF5:
+ if (fd.h5fd != -1)
+ hrc = do_fclose(iot, &fd);
+ break;
+ default:
+ /* unknown request */
+ HDassert(0 && "Unknown IO type");
+ break;
+ }
+
+ /* release generic resources */
+ if (buffer)
+ free(buffer);
+
+ res->ret_code = ret_code;
+}
+
+/*
+ * Function: sio_create_filename
+ * Purpose: Create a new filename to write to. Determine the correct
+ * suffix to append to the filename by the type of I/O we're
+ * doing. Also, place in the /tmp/{$USER,$LOGIN} directory if
+ * USER or LOGIN are specified in the environment.
+ * Return: Pointer to filename or NULL
+ * Programmer: Bill Wendling, 21. November 2001
+ * Modifications: Support for file drivers. Christian Chilan, April, 2008
+ */
+static char *
+sio_create_filename(iotype iot, const char *base_name, char *fullname, size_t size, parameters *param)
+{
+ const char *prefix, *suffix = "";
+ char * ptr, last = '\0';
+ size_t i, j;
+ vfdtype vfd;
+ vfd = param->vfd;
+
+ if (!base_name || !fullname || size < 1)
+ return NULL;
+
+ memset(fullname, 0, size);
+
+ switch (iot) {
+ case POSIXIO:
+ suffix = ".posix";
+ break;
+ case HDF5:
+ suffix = ".h5";
+ if (vfd == family)
+ suffix = "%05d.h5";
+ else if (vfd == multi)
+ suffix = NULL;
+ break;
+ default:
+ /* unknown request */
+ HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)iot);
+ HDassert(0 && "Unknown IO type");
+ break;
+ }
+
+ /* First use the environment variable and then try the constant */
+ prefix = HDgetenv("HDF5_PREFIX");
+
+#ifdef HDF5_PREFIX
+ if (!prefix)
+ prefix = HDF5_PREFIX;
+#endif /* HDF5_PREFIX */
+
+ /* Prepend the prefix value to the base name */
+ if (prefix && *prefix) {
+ /* If the prefix specifies the HDF5_PREFIX directory, then
+ * default to using the "/tmp/$USER" or "/tmp/$LOGIN"
+ * directory instead. */
+ char *user, *login, *subdir;
+
+ user = HDgetenv("USER");
+ login = HDgetenv("LOGIN");
+ subdir = (user ? user : login);
+
+ if (subdir) {
+ for (i = 0; i < size - 1 && prefix[i]; i++)
+ fullname[i] = prefix[i];
+
+ fullname[i++] = '/';
+
+ for (j = 0; i < size && subdir[j]; i++, j++)
+ fullname[i] = subdir[j];
+ }
+ else {
+ /* We didn't append the prefix yet */
+ HDstrncpy(fullname, prefix, size);
+ fullname[size - 1] = '\0';
+ }
+
+ if ((HDstrlen(fullname) + HDstrlen(base_name) + 1) < size) {
+ /* Append the base_name with a slash first. Multiple slashes are
+ * handled below. */
+ h5_stat_t buf;
+
+ if (HDstat(fullname, &buf) < 0)
+ /* The directory doesn't exist just yet */
+ if (HDmkdir(fullname, 0755) < 0 && errno != EEXIST) {
+ /* We couldn't make the "/tmp/${USER,LOGIN}" subdirectory.
+ * Default to PREFIX's original prefix value. */
+ HDstrcpy(fullname, prefix);
+ }
+
+ HDstrcat(fullname, "/");
+ HDstrcat(fullname, base_name);
+ }
+ else {
+ /* Buffer is too small */
+ return NULL;
+ }
+ }
+ else if (strlen(base_name) >= size) {
+ /* Buffer is too small */
+ return NULL;
+ }
+ else {
+ HDstrcpy(fullname, base_name);
+ }
+
+ /* Append a suffix */
+ if (suffix) {
+ if (HDstrlen(fullname) + HDstrlen(suffix) >= size)
+ return NULL;
+
+ HDstrcat(fullname, suffix);
+ }
+
+ /* Remove any double slashes in the filename */
+ for (ptr = fullname, i = j = 0; ptr && (i < size); i++, ptr++) {
+ if (*ptr != '/' || last != '/')
+ fullname[j++] = *ptr;
+
+ last = *ptr;
+ }
+
+ return fullname;
+}
+
+/*
+ * Function: do_write
+ * Purpose: Write the required amount of data to the file.
+ * Return: SUCCESS or FAIL
+ * Programmer: Christian Chilan, April, 2008
+ * Modifications:
+ */
+static herr_t
+do_write(results *res, file_descr *fd, parameters *parms, void *buffer)
+{
+ int ret_code = SUCCESS;
+ char dname[64];
+ int i;
+ size_t u;
+ /* HDF5 variables */
+ herr_t hrc; /*HDF5 return code */
+ hsize_t h5dims[MAX_DIMS]; /*dataset dim sizes */
+ hsize_t h5chunk[MAX_DIMS]; /*dataset dim sizes */
+ hsize_t h5block[MAX_DIMS]; /*dataspace selection */
+ hsize_t h5stride[MAX_DIMS]; /*selection stride */
+ hsize_t h5start[MAX_DIMS]; /*selection start */
+ hsize_t h5maxdims[MAX_DIMS];
+ int rank; /*rank of dataset */
+
+ /* Prepare buffer for verifying data */
+ /* if (parms->verify)
+ memset(buffer,1,linear_buf_size); */
+
+ buf_p = (unsigned char *)buffer;
+
+ for (u = 0; u < linear_buf_size; u++)
+ buf_p[u] = u % 128;
+
+ rank = parms->rank;
+
+ for (i = 0; i < rank; i++)
+ h5offset[i] = offset[i] = 0;
+
+ /* I/O Access specific setup */
+ switch (parms->io_type) {
+ case POSIXIO:
+
+ /* determine lowest dimension for contiguous POSIX access */
+ cont_dim = rank;
+
+ for (i = rank - 1; i >= 0; i--) {
+ if (parms->buf_size[i] == parms->dset_size[i])
+ cont_dim = i;
+ else
+ break;
+ }
+
+ /* determine size of the contiguous POSIX access */
+ cont_size = (!cont_dim) ? 1 : parms->buf_size[cont_dim - 1];
+ for (i = cont_dim; i < rank; i++)
+ cont_size *= parms->buf_size[i];
+
+ break;
+
+ case HDF5: /* HDF5 setup */
+
+ for (i = 0; i < rank; i++) {
+ h5dims[i] = parms->dset_size[i];
+ h5start[i] = 0;
+ h5stride[i] = 1;
+ h5block[i] = 1;
+ h5count[i] = parms->buf_size[i];
+ h5chunk[i] = parms->chk_size[i];
+ h5maxdims[i] = H5S_UNLIMITED;
+ }
+
+ if (parms->h5_use_chunks && parms->h5_extendable) {
+ h5dset_space_id = H5Screate_simple(rank, h5count, h5maxdims);
+ VRFY((h5dset_space_id >= 0), "H5Screate_simple");
+ }
+ else {
+ h5dset_space_id = H5Screate_simple(rank, h5dims, NULL);
+ VRFY((h5dset_space_id >= 0), "H5Screate_simple");
+ }
+
+ hrc = H5Sselect_hyperslab(h5dset_space_id, H5S_SELECT_SET, h5start, h5stride, h5count, h5block);
+ VRFY((hrc >= 0), "H5Sselect_hyperslab");
+
+ /* Create the memory dataspace that corresponds to the xfer buffer */
+ h5mem_space_id = H5Screate_simple(rank, h5count, NULL);
+ VRFY((h5mem_space_id >= 0), "H5Screate_simple");
+
+ /* Create the dataset transfer property list */
+ h5dxpl = H5Pcreate(H5P_DATASET_XFER);
+ if (h5dxpl < 0) {
+ HDfprintf(stderr, "HDF5 Property List Create failed\n");
+ GOTOERROR(FAIL);
+ }
+
+ break;
+
+ default:
+ HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)parms->io_type);
+ GOTOERROR(FAIL);
+ break;
+ } /* end switch */
+
+ /* create dataset */
+ switch (parms->io_type) {
+ case POSIXIO:
+ break;
+
+ case HDF5:
+ h5dcpl = H5Pcreate(H5P_DATASET_CREATE);
+
+ if (h5dcpl < 0) {
+ HDfprintf(stderr, "HDF5 Property List Create failed\n");
+ GOTOERROR(FAIL);
+ }
+
+ if (parms->h5_use_chunks) {
+ /* Set the chunk size to be the same as the buffer size */
+ hrc = H5Pset_chunk(h5dcpl, rank, h5chunk);
+ if (hrc < 0) {
+ HDfprintf(stderr, "HDF5 Property List Set failed\n");
+ GOTOERROR(FAIL);
+ } /* end if */
+ } /* end if */
+
+ HDsprintf(dname, "Dataset_%ld", (unsigned long)parms->num_bytes);
+ h5ds_id =
+ H5Dcreate2(fd->h5fd, dname, ELMT_H5_TYPE, h5dset_space_id, H5P_DEFAULT, h5dcpl, H5P_DEFAULT);
+
+ if (h5ds_id < 0) {
+ HDfprintf(stderr, "HDF5 Dataset Create failed\n");
+ GOTOERROR(FAIL);
+ }
+
+ hrc = H5Pclose(h5dcpl);
+ /* verifying the close of the dcpl */
+ if (hrc < 0) {
+ HDfprintf(stderr, "HDF5 Property List Close failed\n");
+ GOTOERROR(FAIL);
+ }
+ break;
+
+ default:
+ /* unknown request */
+ HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)parms->io_type);
+ GOTOERROR(FAIL);
+ break;
+ }
+
+ /* Start "raw data" write timer */
+ io_time_set(res->timers, HDF5_RAW_WRITE_FIXED_DIMS, TSTART);
+
+ /* Perform write */
+ hrc = dset_write(rank - 1, fd, parms, buffer);
+
+ if (hrc < 0) {
+ HDfprintf(stderr, "Error in dataset write\n");
+ GOTOERROR(FAIL);
+ }
+
+ /* Stop "raw data" write timer */
+ io_time_set(res->timers, HDF5_RAW_WRITE_FIXED_DIMS, TSTOP);
+
+ /* Calculate write time */
+
+ /* Close dataset. Only HDF5 needs to do an explicit close. */
+ if (parms->io_type == HDF5) {
+ hrc = H5Dclose(h5ds_id);
+
+ if (hrc < 0) {
+ HDfprintf(stderr, "HDF5 Dataset Close failed\n");
+ GOTOERROR(FAIL);
+ }
+
+ h5ds_id = H5I_INVALID_HID;
+ } /* end if */
+
+done:
+
+ /* release HDF5 objects */
+ if (h5dset_space_id != -1) {
+ hrc = H5Sclose(h5dset_space_id);
+ if (hrc < 0) {
+ HDfprintf(stderr, "HDF5 Dataset Space Close failed\n");
+ ret_code = FAIL;
+ }
+ else {
+ h5dset_space_id = H5I_INVALID_HID;
+ }
+ }
+
+ if (h5mem_space_id != -1) {
+ hrc = H5Sclose(h5mem_space_id);
+ if (hrc < 0) {
+ HDfprintf(stderr, "HDF5 Memory Space Close failed\n");
+ ret_code = FAIL;
+ }
+ else {
+ h5mem_space_id = H5I_INVALID_HID;
+ }
+ }
+
+ if (h5dxpl != -1) {
+ hrc = H5Pclose(h5dxpl);
+ if (hrc < 0) {
+ HDfprintf(stderr, "HDF5 Dataset Transfer Property List Close failed\n");
+ ret_code = FAIL;
+ }
+ else {
+ h5dxpl = H5I_INVALID_HID;
+ }
+ }
+
+ return ret_code;
+}
+
+/*
+ * Function: dset_write
+ * Purpose: Write buffer into the dataset.
+ * Return: SUCCESS or FAIL
+ * Programmer: Christian Chilan, April, 2008
+ * Modifications:
+ */
+static herr_t
+dset_write(int local_dim, file_descr *fd, parameters *parms, void *buffer)
+{
+ int cur_dim = order[local_dim] - 1;
+ int ret_code = SUCCESS;
+ int k;
+ hsize_t dims[MAX_DIMS], maxdims[MAX_DIMS];
+ hsize_t i;
+ int j;
+ herr_t hrc;
+
+ /* iterates according to the dimensions in order array */
+ for (i = 0; i < parms->dset_size[cur_dim]; i += parms->buf_size[cur_dim]) {
+
+ h5offset[cur_dim] = (hssize_t)i;
+ offset[cur_dim] = (HDoff_t)i;
+
+ if (local_dim > 0) {
+
+ dset_write(local_dim - 1, fd, parms, buffer);
+ }
+ else {
+
+ switch (parms->io_type) {
+
+ case POSIXIO:
+ /* initialize POSIX offset in the buffer */
+ for (j = 0; j < parms->rank; j++)
+ buf_offset[j] = 0;
+ buf_p = (unsigned char *)buffer;
+ /* write POSIX buffer */
+ posix_buffer_write(0, fd, parms, buffer);
+ break;
+
+ case HDF5:
+ /* if dimensions are extendable, extend them as needed during access */
+ if (parms->h5_use_chunks && parms->h5_extendable) {
+
+ hrc = H5Sget_simple_extent_dims(h5dset_space_id, dims, maxdims);
+ VRFY((hrc >= 0), "H5Sget_simple_extent_dims");
+
+ for (k = 0; k < parms->rank; k++) {
+
+ HDassert(h5offset[k] >= 0);
+ if (dims[k] <= (hsize_t)h5offset[k]) {
+ dims[k] = dims[k] + h5count[k];
+ hrc = H5Sset_extent_simple(h5dset_space_id, parms->rank, dims, maxdims);
+ VRFY((hrc >= 0), "H5Sset_extent_simple");
+ hrc = H5Dset_extent(h5ds_id, dims);
+ VRFY((hrc >= 0), "H5Dextend");
+ }
+ }
+ }
+ /* applies offset */
+ hrc = H5Soffset_simple(h5dset_space_id, h5offset);
+ VRFY((hrc >= 0), "H5Soffset_simple");
+
+ /* Write the buffer out */
+ hrc = H5Sget_simple_extent_dims(h5dset_space_id, dims, maxdims);
+ hrc = H5Dwrite(h5ds_id, ELMT_H5_TYPE, h5mem_space_id, h5dset_space_id, h5dxpl, buffer);
+ VRFY((hrc >= 0), "H5Dwrite");
+
+ break;
+
+ default:
+ /* unknown request */
+ HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)parms->io_type);
+ HDassert(0 && "Unknown IO type");
+ break;
+ } /* switch (parms->io_type) */
+ }
+ }
+done:
+ return ret_code;
+}
+
+/*
+ * Function: posix_buffer_write
+ * Purpose: Write buffer into the POSIX file considering contiguity.
+ * Return: SUCCESS or FAIL
+ * Programmer: Christian Chilan, April, 2008
+ * Modifications:
+ */
+
+static herr_t
+posix_buffer_write(int local_dim, file_descr *fd, parameters *parms, void *buffer)
+{
+ int ret_code = SUCCESS;
+
+ /* if dimension is not contiguous, call recursively */
+ if (local_dim < parms->rank - 1 && local_dim != cont_dim) {
+ size_t u;
+
+ for (u = 0; u < parms->buf_size[local_dim]; u++) {
+ buf_offset[local_dim] = u;
+ posix_buffer_write(local_dim + 1, fd, parms, buffer);
+
+ /* if next dimension is cont_dim, it will fill out the buffer
+ traversing the entire dimension local_dim without the need
+ of performing iteration */
+ if (local_dim + 1 == cont_dim)
+ break;
+ }
+ /* otherwise, perform contiguous POSIX access */
+ }
+ else {
+ HDoff_t d_offset;
+ HDoff_t linear_dset_offset = 0;
+ int i, j, rc;
+
+ buf_offset[local_dim] = 0;
+
+ /* determine offset in the buffer */
+ for (i = 0; i < parms->rank; i++) {
+ d_offset = 1;
+
+ for (j = i + 1; j < parms->rank; j++)
+ d_offset *= (HDoff_t)parms->dset_size[j];
+
+ linear_dset_offset += (offset[i] + (HDoff_t)buf_offset[i]) * d_offset;
+ }
+
+ /* only care if seek returns error */
+ rc = POSIXSEEK(fd->posixfd, linear_dset_offset) < 0 ? -1 : 0;
+ VRFY((rc == 0), "POSIXSEEK");
+ /* check if all bytes are written */
+ rc = ((ssize_t)cont_size == POSIXWRITE(fd->posixfd, buf_p, cont_size));
+ VRFY((rc != 0), "POSIXWRITE");
+
+ /* Advance location in buffer */
+ buf_p += cont_size;
+ }
+
+done:
+ return ret_code;
+}
+
+/*
+ * Function: do_read
+ * Purpose: Read the required amount of data to the file.
+ * Return: SUCCESS or FAIL
+ * Programmer: Christian Chilan, April, 2008
+ * Modifications:
+ */
+static herr_t
+do_read(results *res, file_descr *fd, parameters *parms, void *buffer)
+{
+ char * buffer2 = NULL; /* Buffer for data verification */
+ int ret_code = SUCCESS;
+ char dname[64];
+ int i;
+ size_t u;
+ /* HDF5 variables */
+ herr_t hrc; /*HDF5 return code */
+ hsize_t h5dims[MAX_DIMS]; /*dataset dim sizes */
+ hsize_t h5block[MAX_DIMS]; /*dataspace selection */
+ hsize_t h5stride[MAX_DIMS]; /*selection stride */
+ hsize_t h5start[MAX_DIMS]; /*selection start */
+ int rank;
+
+ /* Allocate data verification buffer */
+ if (NULL == (buffer2 = (char *)malloc(linear_buf_size))) {
+ HDfprintf(stderr, "malloc for data verification buffer size (%zu) failed\n", linear_buf_size);
+ GOTOERROR(FAIL);
+ } /* end if */
+
+ /* Prepare buffer for verifying data */
+ for (u = 0; u < linear_buf_size; u++)
+ buffer2[u] = (char)(u % 128);
+
+ rank = parms->rank;
+ for (i = 0; i < rank; i++)
+ h5offset[i] = offset[i] = 0;
+
+ /* I/O Access specific setup */
+ switch (parms->io_type) {
+ case POSIXIO:
+ cont_dim = rank;
+
+ for (i = rank - 1; i >= 0; i--) {
+ if (parms->buf_size[i] == parms->dset_size[i])
+ cont_dim = i;
+ else
+ break;
+ }
+ cont_size = (!cont_dim) ? 1 : parms->buf_size[cont_dim - 1];
+ for (i = cont_dim; i < rank; i++)
+ cont_size *= parms->buf_size[i];
+
+ break;
+
+ case HDF5: /* HDF5 setup */
+ for (i = 0; i < rank; i++) {
+ h5dims[i] = parms->dset_size[i];
+ h5start[i] = 0;
+ h5stride[i] = 1;
+ h5block[i] = 1;
+ h5count[i] = parms->buf_size[i];
+ }
+
+ h5dset_space_id = H5Screate_simple(rank, h5dims, NULL);
+ VRFY((h5dset_space_id >= 0), "H5Screate_simple");
+
+ hrc = H5Sselect_hyperslab(h5dset_space_id, H5S_SELECT_SET, h5start, h5stride, h5count, h5block);
+ VRFY((hrc >= 0), "H5Sselect_hyperslab");
+
+ /* Create the memory dataspace that corresponds to the xfer buffer */
+ h5mem_space_id = H5Screate_simple(rank, h5count, NULL);
+ VRFY((h5mem_space_id >= 0), "H5Screate_simple");
+
+ /* Create the dataset transfer property list */
+ h5dxpl = H5Pcreate(H5P_DATASET_XFER);
+ if (h5dxpl < 0) {
+ HDfprintf(stderr, "HDF5 Property List Create failed\n");
+ GOTOERROR(FAIL);
+ }
+ break;
+
+ default:
+ /* unknown request */
+ HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)parms->io_type);
+ GOTOERROR(FAIL);
+ break;
+ } /* end switch */
+
+ /* create dataset */
+ switch (parms->io_type) {
+ case POSIXIO:
+ break;
+
+ case HDF5:
+ HDsprintf(dname, "Dataset_%ld", (long)parms->num_bytes);
+ h5ds_id = H5Dopen2(fd->h5fd, dname, H5P_DEFAULT);
+ if (h5ds_id < 0) {
+ HDfprintf(stderr, "HDF5 Dataset open failed\n");
+ GOTOERROR(FAIL);
+ }
+ break;
+
+ default:
+ /* unknown request */
+ HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)parms->io_type);
+ GOTOERROR(FAIL);
+ break;
+ } /* end switch */
+
+ /* Start "raw data" read timer */
+ io_time_set(res->timers, HDF5_RAW_READ_FIXED_DIMS, TSTART);
+ hrc = dset_read(rank - 1, fd, parms, buffer, buffer2);
+
+ if (hrc < 0) {
+ HDfprintf(stderr, "Error in dataset read\n");
+ GOTOERROR(FAIL);
+ }
+
+ /* Stop "raw data" read timer */
+ io_time_set(res->timers, HDF5_RAW_READ_FIXED_DIMS, TSTOP);
+
+ /* Calculate read time */
+
+ /* Close dataset. Only HDF5 needs to do an explicit close. */
+ if (parms->io_type == HDF5) {
+ hrc = H5Dclose(h5ds_id);
+
+ if (hrc < 0) {
+ HDfprintf(stderr, "HDF5 Dataset Close failed\n");
+ GOTOERROR(FAIL);
+ }
+
+ h5ds_id = H5I_INVALID_HID;
+ } /* end if */
+
+done:
+
+ /* release HDF5 objects */
+ if (h5dset_space_id != -1) {
+ hrc = H5Sclose(h5dset_space_id);
+ if (hrc < 0) {
+ HDfprintf(stderr, "HDF5 Dataset Space Close failed\n");
+ ret_code = FAIL;
+ }
+ else {
+ h5dset_space_id = H5I_INVALID_HID;
+ }
+ }
+
+ if (h5mem_space_id != -1) {
+ hrc = H5Sclose(h5mem_space_id);
+ if (hrc < 0) {
+ HDfprintf(stderr, "HDF5 Memory Space Close failed\n");
+ ret_code = FAIL;
+ }
+ else {
+ h5mem_space_id = H5I_INVALID_HID;
+ }
+ }
+
+ if (h5dxpl != -1) {
+ hrc = H5Pclose(h5dxpl);
+ if (hrc < 0) {
+ HDfprintf(stderr, "HDF5 Dataset Transfer Property List Close failed\n");
+ ret_code = FAIL;
+ }
+ else {
+ h5dxpl = H5I_INVALID_HID;
+ }
+ }
+
+ /* release generic resources */
+ if (buffer2)
+ free(buffer2);
+
+ return ret_code;
+}
+
+/*
+ * Function: dset_read
+ * Purpose: Read buffer into the dataset.
+ * Return: SUCCESS or FAIL
+ * Programmer: Christian Chilan, April, 2008
+ * Modifications:
+ */
+
+static herr_t
+dset_read(int local_dim, file_descr *fd, parameters *parms, void *buffer, const char *buffer2)
+{
+ int cur_dim = order[local_dim] - 1;
+ hsize_t i;
+ int j;
+ herr_t hrc;
+ int ret_code = SUCCESS;
+
+ /* iterate on the current dimension */
+ for (i = 0; i < parms->dset_size[cur_dim]; i += parms->buf_size[cur_dim]) {
+
+ h5offset[cur_dim] = (hssize_t)i;
+ offset[cur_dim] = (HDoff_t)i;
+
+ /* if traverse in order array is incomplete, recurse */
+ if (local_dim > 0) {
+
+ ret_code = dset_read(local_dim - 1, fd, parms, buffer, buffer2);
+
+ /* otherwise, write buffer into dataset */
+ }
+ else {
+
+ switch (parms->io_type) {
+
+ case POSIXIO:
+ for (j = 0; j < parms->rank; j++) {
+ buf_offset[j] = 0;
+ }
+ buf_p = (unsigned char *)buffer;
+ posix_buffer_read(0, fd, parms, buffer);
+ break;
+
+ case HDF5:
+ hrc = H5Soffset_simple(h5dset_space_id, h5offset);
+ VRFY((hrc >= 0), "H5Soffset_simple");
+ /* Read the buffer out */
+ hrc = H5Dread(h5ds_id, ELMT_H5_TYPE, h5mem_space_id, h5dset_space_id, h5dxpl, buffer);
+ VRFY((hrc >= 0), "H5Dread");
+ break;
+
+ default:
+ /* unknown request */
+ HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)parms->io_type);
+ HDassert(0 && "Unknown IO type");
+ break;
+ } /* switch (parms->io_type) */
+ }
+ }
+done:
+ return ret_code;
+}
+
+/*
+ * Function: posix_buffer_read
+ * Purpose: Read buffer into the POSIX file considering contiguity.
+ * Return: SUCCESS or FAIL
+ * Programmer: Christian Chilan, April, 2008
+ * Modifications:
+ */
+
+static herr_t
+posix_buffer_read(int local_dim, file_descr *fd, parameters *parms, void *buffer)
+{
+ int ret_code = SUCCESS;
+
+ /* if local dimension is not contiguous, recurse */
+ if (local_dim < parms->rank - 1 && local_dim != cont_dim) {
+ size_t u;
+
+ for (u = 0; u < parms->buf_size[local_dim]; u++) {
+ buf_offset[local_dim] = u;
+ ret_code = posix_buffer_read(local_dim + 1, fd, parms, buffer);
+ if (local_dim + 1 == cont_dim)
+ break;
+ }
+ /* otherwise, perform contiguous POSIX access */
+ }
+ else {
+ HDoff_t d_offset;
+ HDoff_t linear_dset_offset = 0;
+ int i, j, rc;
+
+ buf_offset[local_dim] = 0;
+ /* determine offset in buffer */
+ for (i = 0; i < parms->rank; i++) {
+ d_offset = 1;
+
+ for (j = i + 1; j < parms->rank; j++)
+ d_offset *= (HDoff_t)parms->dset_size[j];
+
+ linear_dset_offset += (offset[i] + (HDoff_t)buf_offset[i]) * d_offset;
+ }
+
+ /* only care if seek returns error */
+ rc = POSIXSEEK(fd->posixfd, linear_dset_offset) < 0 ? -1 : 0;
+ VRFY((rc == 0), "POSIXSEEK");
+ /* check if all bytes are read */
+ rc = ((ssize_t)cont_size == POSIXREAD(fd->posixfd, buf_p, cont_size));
+ VRFY((rc != 0), "POSIXREAD");
+
+ /* Advance location in buffer */
+ buf_p += cont_size;
+ }
+done:
+ return ret_code;
+}
+
+/*
+ * Function: do_fopen
+ * Purpose: Open the specified file.
+ * Return: SUCCESS or FAIL
+ * Programmer: Albert Cheng, Bill Wendling, 2001/12/13
+ * Modifications: Support for file drivers, Christian Chilan, April, 2008
+ */
+static herr_t
+do_fopen(parameters *param, char *fname, file_descr *fd /*out*/, int flags)
+{
+ int ret_code = SUCCESS;
+ hid_t fcpl;
+
+ switch (param->io_type) {
+ case POSIXIO:
+ if (flags & (SIO_CREATE | SIO_WRITE))
+ fd->posixfd = POSIXCREATE(fname);
+ else
+ fd->posixfd = POSIXOPEN(fname, O_RDONLY);
+
+ if (fd->posixfd < 0) {
+ HDfprintf(stderr, "POSIX File Open failed(%s)\n", fname);
+ GOTOERROR(FAIL);
+ }
+
+ break;
+
+ case HDF5:
+
+ fapl = set_vfd(param);
+
+ if (fapl < 0) {
+ HDfprintf(stderr, "HDF5 Property List Create failed\n");
+ GOTOERROR(FAIL);
+ }
+
+ fcpl = H5Pcreate(H5P_FILE_CREATE);
+ if (param->page_size) {
+ H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, (hsize_t)1);
+ H5Pset_file_space_page_size(fcpl, param->page_size);
+ if (param->page_buffer_size)
+ H5Pset_page_buffer_size(fapl, param->page_buffer_size, 0, 0);
+ }
+
+ /* create the parallel file */
+ if (flags & (SIO_CREATE | SIO_WRITE)) {
+ fd->h5fd = H5Fcreate(fname, H5F_ACC_TRUNC, fcpl, fapl);
+ }
+ else {
+ fd->h5fd = H5Fopen(fname, H5F_ACC_RDONLY, fapl);
+ }
+
+ if (fd->h5fd < 0) {
+ HDfprintf(stderr, "HDF5 File Create failed(%s)\n", fname);
+ GOTOERROR(FAIL);
+ }
+ break;
+
+ default:
+ /* unknown request */
+ HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)param->io_type);
+ GOTOERROR(FAIL);
+ break;
+ }
+
+done:
+ return ret_code;
+}
+
+/*
+ * Function: set_vfd
+ * Purpose: Sets file driver.
+ * Return: SUCCESS or FAIL
+ * Programmer: Christian Chilan, April, 2008
+ * Modifications:
+ */
+
+hid_t
+set_vfd(parameters *param)
+{
+ hid_t my_fapl = H5I_INVALID_HID;
+ vfdtype vfd;
+
+ vfd = param->vfd;
+
+ if ((my_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ return -1;
+
+ if (vfd == sec2) {
+ /* Unix read() and write() system calls */
+ if (H5Pset_fapl_sec2(my_fapl) < 0)
+ return -1;
+ }
+ else if (vfd == stdio) {
+ /* Standard C fread() and fwrite() system calls */
+ if (H5Pset_fapl_stdio(my_fapl) < 0)
+ return -1;
+ }
+ else if (vfd == core) {
+ /* In-core temporary file with 1MB increment */
+ if (H5Pset_fapl_core(my_fapl, (size_t)1024 * 1024, TRUE) < 0)
+ return -1;
+ }
+ else if (vfd == split) {
+ /* Split meta data and raw data each using default driver */
+ if (H5Pset_fapl_split(my_fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT) < 0)
+ return -1;
+ }
+ else if (vfd == multi) {
+ /* Multi-file driver, general case of the split driver */
+ H5FD_mem_t memb_map[H5FD_MEM_NTYPES];
+ hid_t memb_fapl[H5FD_MEM_NTYPES];
+ const char *memb_name[H5FD_MEM_NTYPES];
+ char sv[H5FD_MEM_NTYPES][1024];
+ haddr_t memb_addr[H5FD_MEM_NTYPES];
+ H5FD_mem_t mt;
+
+ HDmemset(memb_map, 0, sizeof memb_map);
+ HDmemset(memb_fapl, 0, sizeof memb_fapl);
+ HDmemset(memb_name, 0, sizeof memb_name);
+ HDmemset(memb_addr, 0, sizeof memb_addr);
+
+ HDassert(HDstrlen(multi_letters) == H5FD_MEM_NTYPES);
+ for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) {
+ memb_fapl[mt] = H5P_DEFAULT;
+ HDsprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]);
+ memb_name[mt] = sv[mt];
+ memb_addr[mt] = (haddr_t)MAX(mt - 1, 0) * (HADDR_MAX / 10);
+ }
+
+ if (H5Pset_fapl_multi(my_fapl, memb_map, memb_fapl, memb_name, memb_addr, FALSE) < 0) {
+ return -1;
+ }
+ }
+ else if (vfd == family) {
+ hsize_t fam_size = 1 * 1024 * 1024; /*100 MB*/
+
+ /* Family of files, each 1MB and using the default driver */
+ /* if ((val=HDstrtok(NULL, " \t\n\r")))
+ fam_size = (hsize_t)(HDstrtod(val, NULL) * 1024*1024); */
+ if (H5Pset_fapl_family(my_fapl, fam_size, H5P_DEFAULT) < 0)
+ return -1;
+ }
+ else if (vfd == direct) {
+#ifdef H5_HAVE_DIRECT
+ /* Linux direct read() and write() system calls. Set memory boundary, file block size,
+ * and copy buffer size to the default values. */
+ if (H5Pset_fapl_direct(my_fapl, 1024, 4096, 8 * 4096) < 0)
+ return -1;
+#endif
+ }
+ else {
+ /* Unknown driver */
+ return -1;
+ }
+
+ return my_fapl;
+}
+
+/*
+ * Function: do_fclose
+ * Purpose: Close the specified file descriptor.
+ * Return: SUCCESS or FAIL
+ * Programmer: Albert Cheng, Bill Wendling, 2001/12/13
+ * Modifications:
+ */
+static herr_t
+do_fclose(iotype iot, file_descr *fd /*out*/)
+{
+ herr_t ret_code = SUCCESS, hrc;
+ int rc = 0;
+
+ switch (iot) {
+ case POSIXIO:
+ rc = POSIXCLOSE(fd->posixfd);
+
+ if (rc != 0) {
+ HDfprintf(stderr, "POSIX File Close failed\n");
+ GOTOERROR(FAIL);
+ }
+
+ fd->posixfd = -1;
+ break;
+
+ case HDF5:
+ hrc = H5Fclose(fd->h5fd);
+
+ if (hrc < 0) {
+ HDfprintf(stderr, "HDF5 File Close failed\n");
+ GOTOERROR(FAIL);
+ }
+
+ fd->h5fd = -1;
+ break;
+
+ default:
+ /* unknown request */
+ HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)iot);
+ GOTOERROR(FAIL);
+ break;
+ }
+
+done:
+ return ret_code;
+}
+
+/*
+ * Function: do_cleanupfile
+ * Purpose: Cleanup temporary file unless HDF5_NOCLEANUP is set.
+ * Return: void
+ * Programmer: Albert Cheng 2001/12/12
+ * Modifications: Support for file drivers. Christian Chilan, April, 2008
+ */
+static void
+do_cleanupfile(iotype iot, char *filename)
+{
+ char temp[4096 + sizeof("-?.h5")];
+ int j;
+ hid_t driver;
+
+ if (clean_file_g == -1)
+ clean_file_g = (HDgetenv(HDF5_NOCLEANUP) == NULL) ? 1 : 0;
+
+ if (clean_file_g) {
+
+ switch (iot) {
+ case POSIXIO:
+ HDremove(filename);
+ break;
+
+ case HDF5:
+ driver = H5Pget_driver(fapl);
+
+ if (driver == H5FD_FAMILY) {
+ for (j = 0; /*void*/; j++) {
+ HDsnprintf(temp, sizeof temp, filename, j);
+
+ if (HDaccess(temp, F_OK) < 0)
+ break;
+
+ HDremove(temp);
+ }
+ }
+ else if (driver == H5FD_CORE) {
+ hbool_t backing; /* Whether the core file has backing store */
+
+ H5Pget_fapl_core(fapl, NULL, &backing);
+
+ /* If the file was stored to disk with bacing store, remove it */
+ if (backing)
+ HDremove(filename);
+ }
+ else if (driver == H5FD_MULTI) {
+ H5FD_mem_t mt;
+ assert(HDstrlen(multi_letters) == H5FD_MEM_NTYPES);
+
+ for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) {
+ HDsnprintf(temp, sizeof temp, "%s-%c.h5", filename, multi_letters[mt]);
+ HDremove(temp); /*don't care if it fails*/
+ }
+ }
+ else {
+ HDremove(filename);
+ }
+ H5Pclose(fapl);
+ break;
+
+ default:
+ /* unknown request */
+ HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)iot);
+ HDassert(0 && "Unknown IO type");
+ break;
+ }
+ }
+}
diff --git a/tools/src/h5perf/sio_perf.c b/tools/src/h5perf/sio_perf.c
new file mode 100644
index 0000000..dc2e15e
--- /dev/null
+++ b/tools/src/h5perf/sio_perf.c
@@ -0,0 +1,1300 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Serial HDF5 Performance Testing Code
+ * --------------------------------------
+ *
+ * Portable code to test performance on the different platforms we support.
+ * This is what the report should look like:
+ *
+ * nprocs = Max#Procs
+ * IO API = POSIXIO
+ * # Files = 1, # of dsets = 1000, Elements per dset = 37000
+ * Write Results = x MB/s
+ * Read Results = x MB/s
+ * # Files = 1, # of dsets = 3000, Elements per dset = 37000
+ * Write Results = x MB/s
+ * Read Results = x MB/s
+ *
+ * . . .
+ *
+ *
+ * IO API = HDF5
+ * # Files = 1, # of dsets = 1000, Elements per dset = 37000
+ * Write Results = x MB/s
+ * Read Results = x MB/s
+ * # Files = 1, # of dsets = 3000, Elements per dset = 37000
+ * Write Results = x MB/s
+ * Read Results = x MB/s
+ *
+ * . . .
+ *
+ *
+ * . . .
+ *
+ */
+
+/* system header files */
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "hdf5.h"
+
+/* our header files */
+#include "sio_perf.h"
+
+/* useful macros */
+#define TAB_SPACE 4
+
+#define ONE_KB 1024
+#define ONE_MB (ONE_KB * ONE_KB)
+#define ONE_GB (ONE_MB * ONE_KB)
+
+#define SIO_POSIX 0x1
+#define SIO_HDF5 0x4
+
+/* report 0.0 in case t is zero too */
+#define MB_PER_SEC(bytes, t) (H5_DBL_ABS_EQUAL(t, 0.0) ? 0.0 : ((((double)(bytes)) / (double)ONE_MB) / (t)))
+
+#ifndef TRUE
+#define TRUE 1
+#endif /* TRUE */
+#ifndef FALSE
+#define FALSE (!TRUE)
+#endif /* FALSE */
+
+/* global variables */
+FILE *output; /* output file */
+int sio_debug_level = 0; /* The debug level:
+ * 0 - Off
+ * 1 - Minimal
+ * 2 - Some more
+ * 3 - Maximal
+ * 4 - Maximal & then some
+ */
+
+/* local variables */
+static const char *progname = "h5perf_serial";
+
+/*
+ * Command-line options: The user can specify short or long-named
+ * parameters. The long-named ones can be partially spelled. When
+ * adding more, make sure that they don't clash with each other.
+ */
+
+/*
+ * It seems that only the options that accept additional information
+ * such as dataset size (-e) require the colon next to it.
+ */
+static const char * s_opts = "a:A:B:c:Cd:D:e:F:ghi:Imno:p:P:r:stT:v:wx:X:";
+static struct h5_long_options l_opts[] = {{"align", require_arg, 'a'},
+ {"api", require_arg, 'A'},
+#if 0
+ /* a sighting of the elusive binary option */
+ { "binary", no_arg, 'b' },
+#endif /* 0 */
+ {"block-size", require_arg, 'B'},
+ {"chunk", no_arg, 'c'},
+ {"collective", no_arg, 'C'},
+ {"debug", require_arg, 'D'},
+ {"file-driver", require_arg, 'v'},
+ {"geometry", no_arg, 'g'},
+ {"help", no_arg, 'h'},
+ {"interleaved", require_arg, 'I'},
+ {"max-num-processes", require_arg, 'P'},
+ {"min-num-processes", require_arg, 'p'},
+ {"max-xfer-size", require_arg, 'X'},
+ {"min-xfer-size", require_arg, 'x'},
+ {"num-bytes", require_arg, 'e'},
+ {"num-dsets", require_arg, 'd'},
+ {"num-files", require_arg, 'F'},
+ {"num-iterations", require_arg, 'i'},
+ {"order", require_arg, 'r'},
+ {"output", require_arg, 'o'},
+ {"extendable", no_arg, 't'},
+ {"threshold", require_arg, 'T'},
+ {"write-only", require_arg, 'w'},
+ {NULL, 0, '\0'}};
+
+struct options {
+ long io_types; /* bitmask of which I/O types to test */
+ const char *output_file; /* file to print report to */
+ long num_dsets; /* number of datasets */
+ long num_files; /* number of files */
+ off_t num_bpp; /* number of bytes per proc per dset */
+ int num_iters; /* number of iterations */
+ hsize_t dset_size[MAX_DIMS]; /* Dataset size */
+ size_t buf_size[MAX_DIMS]; /* Buffer size */
+ size_t chk_size[MAX_DIMS]; /* Chunk size */
+ int order[MAX_DIMS]; /* Dimension access order */
+ int dset_rank; /* Rank */
+ int buf_rank; /* Rank */
+ int order_rank; /* Rank */
+ int chk_rank; /* Rank */
+ int print_times; /* print times as well as throughputs */
+ int print_raw; /* print raw data throughput info */
+ hsize_t h5_alignment; /* alignment in HDF5 file */
+ hsize_t h5_threshold; /* threshold for alignment in HDF5 file */
+ int h5_use_chunks; /* Make HDF5 dataset chunked */
+ int h5_write_only; /* Perform the write tests only */
+ int h5_extendable; /* Perform the write tests only */
+ int verify; /* Verify data correctness */
+ vfdtype vfd; /* File driver */
+ size_t page_buffer_size;
+ size_t page_size;
+};
+
+typedef struct {
+ double min;
+ double max;
+ double sum;
+ int num;
+} minmax;
+
+/* local functions */
+static hsize_t parse_size_directive(const char *size);
+static struct options *parse_command_line(int argc, const char *const *argv);
+static void run_test_loop(struct options *options);
+static int run_test(iotype iot, parameters parms, struct options *opts);
+static void output_all_info(minmax *mm, int count, int indent_level);
+static void get_minmax(minmax *mm, double val);
+static void accumulate_minmax_stuff(const minmax *mm, int count, minmax *total_mm);
+static void output_results(const struct options *options, const char *name, minmax *table, int table_size,
+ off_t data_size);
+static void output_report(const char *fmt, ...);
+static void print_indent(int indent);
+static void usage(const char *prog);
+static void report_parameters(struct options *opts);
+
+/*
+ * Function: main
+ * Purpose: Start things up.
+ * Return: EXIT_SUCCESS or EXIT_FAILURE
+ * Programmer: Bill Wendling, 30. October 2001
+ * Modifications:
+ */
+int
+main(int argc, char *argv[])
+{
+ int exit_value = EXIT_SUCCESS;
+ struct options *opts = NULL;
+
+#ifndef STANDALONE
+ /* Initialize h5tools lib */
+ h5tools_init();
+#endif
+
+ output = stdout;
+
+ opts = parse_command_line(argc, (const char *const *)argv);
+
+ if (!opts) {
+ exit_value = EXIT_FAILURE;
+ goto finish;
+ }
+
+ if (opts->output_file) {
+ if ((output = HDfopen(opts->output_file, "w")) == NULL) {
+ HDfprintf(stderr, "%s: cannot open output file\n", progname);
+ HDperror(opts->output_file);
+ goto finish;
+ }
+ }
+
+ report_parameters(opts);
+
+ run_test_loop(opts);
+
+finish:
+ HDfree(opts);
+ return exit_value;
+}
+
+/*
+ * Function: run_test_loop
+ * Purpose: Run the I/O tests. Write the results to OUTPUT.
+ *
+ * - The slowest changing part of the test is the number of
+ * processors to use. For each loop iteration, we divide that
+ * number by 2 and rerun the test.
+ *
+ * - The second slowest is what type of IO API to perform. We have
+ * three choices: POSIXIO, and HDF5.
+ *
+ * - Then we change the size of the buffer. This information is
+ * inferred from the number of datasets to create and the number
+ * of integers to put into each dataset. The backend code figures
+ * this out.
+ *
+ * Return: Nothing
+ * Programmer: Bill Wendling, 30. October 2001
+ * Modifications:
+ * Added multidimensional testing (Christian Chilan, April, 2008)
+ */
+static void
+run_test_loop(struct options *opts)
+{
+ parameters parms;
+ int i;
+ size_t buf_bytes;
+
+ /* load options into parameter structure */
+ parms.num_files = opts->num_files;
+ parms.num_dsets = opts->num_dsets;
+ parms.num_iters = opts->num_iters;
+ parms.rank = opts->dset_rank;
+ parms.h5_align = opts->h5_alignment;
+ parms.h5_thresh = opts->h5_threshold;
+ parms.h5_use_chunks = opts->h5_use_chunks;
+ parms.h5_extendable = opts->h5_extendable;
+ parms.h5_write_only = opts->h5_write_only;
+ parms.verify = opts->verify;
+ parms.vfd = opts->vfd;
+ parms.page_buffer_size = opts->page_buffer_size;
+ parms.page_size = opts->page_size;
+
+ /* load multidimensional options */
+ parms.num_bytes = 1;
+ buf_bytes = 1;
+ for (i = 0; i < parms.rank; i++) {
+ parms.buf_size[i] = opts->buf_size[i];
+ parms.dset_size[i] = opts->dset_size[i];
+ parms.chk_size[i] = opts->chk_size[i];
+ parms.order[i] = opts->order[i];
+ parms.num_bytes *= opts->dset_size[i];
+ buf_bytes *= opts->buf_size[i];
+ }
+
+ /* print size information */
+ output_report("Transfer Buffer Size (bytes): %zu\n", buf_bytes);
+ output_report("File Size(MB): %.2f\n", ((double)parms.num_bytes) / ONE_MB);
+
+ print_indent(0);
+ if (opts->io_types & SIO_POSIX)
+ run_test(POSIXIO, parms, opts);
+
+ print_indent(0);
+ if (opts->io_types & SIO_HDF5)
+ run_test(HDF5, parms, opts);
+}
+
+/*
+ * Function: run_test
+ * Purpose: Inner loop call to actually run the I/O test.
+ * Return: Nothing
+ * Programmer: Bill Wendling, 18. December 2001
+ * Modifications:
+ */
+static int
+run_test(iotype iot, parameters parms, struct options *opts)
+{
+ results res;
+ int i, ret_value = SUCCESS;
+ off_t raw_size;
+ minmax *write_sys_mm_table = NULL;
+ minmax *write_mm_table = NULL;
+ minmax *write_gross_mm_table = NULL;
+ minmax *write_raw_mm_table = NULL;
+ minmax *read_sys_mm_table = NULL;
+ minmax *read_mm_table = NULL;
+ minmax *read_gross_mm_table = NULL;
+ minmax *read_raw_mm_table = NULL;
+ minmax write_sys_mm = {0.0, 0.0, 0.0, 0};
+ minmax write_mm = {0.0, 0.0, 0.0, 0};
+ minmax write_gross_mm = {0.0, 0.0, 0.0, 0};
+ minmax write_raw_mm = {0.0, 0.0, 0.0, 0};
+ minmax read_sys_mm = {0.0, 0.0, 0.0, 0};
+ minmax read_mm = {0.0, 0.0, 0.0, 0};
+ minmax read_gross_mm = {0.0, 0.0, 0.0, 0};
+ minmax read_raw_mm = {0.0, 0.0, 0.0, 0};
+
+ raw_size = (off_t)parms.num_bytes;
+ parms.io_type = iot;
+ print_indent(2);
+ output_report("IO API = ");
+
+ switch (iot) {
+ case POSIXIO:
+ output_report("POSIX\n");
+ break;
+ case HDF5:
+ output_report("HDF5\n");
+ break;
+ default:
+ /* unknown request */
+ HDfprintf(stderr, "Unknown IO type request (%d)\n", (int)iot);
+ HDassert(0 && "Unknown IO tpe");
+ break;
+ }
+
+ /* allocate space for tables minmax and that it is sufficient */
+ /* to initialize all elements to zeros by calloc. */
+ write_sys_mm_table = (minmax *)calloc((size_t)parms.num_iters, sizeof(minmax));
+ write_mm_table = (minmax *)calloc((size_t)parms.num_iters, sizeof(minmax));
+ write_gross_mm_table = (minmax *)calloc((size_t)parms.num_iters, sizeof(minmax));
+ write_raw_mm_table = (minmax *)calloc((size_t)parms.num_iters, sizeof(minmax));
+
+ if (!parms.h5_write_only) {
+ read_sys_mm_table = (minmax *)calloc((size_t)parms.num_iters, sizeof(minmax));
+ read_mm_table = (minmax *)calloc((size_t)parms.num_iters, sizeof(minmax));
+ read_gross_mm_table = (minmax *)calloc((size_t)parms.num_iters, sizeof(minmax));
+ read_raw_mm_table = (minmax *)calloc((size_t)parms.num_iters, sizeof(minmax));
+ }
+
+ /* Do IO iteration times, collecting statistics each time */
+ for (i = 0; i < parms.num_iters; ++i) {
+ double t;
+
+ do_sio(parms, &res);
+
+ /* gather all of the "sys write" times */
+ t = io_time_get(res.timers, HDF5_MPI_WRITE);
+ get_minmax(&write_sys_mm, t);
+
+ write_sys_mm_table[i] = write_sys_mm;
+
+ /* gather all of the "write" times */
+ t = io_time_get(res.timers, HDF5_FINE_WRITE_FIXED_DIMS);
+ get_minmax(&write_mm, t);
+
+ write_mm_table[i] = write_mm;
+
+ /* gather all of the "write" times from open to close */
+ t = io_time_get(res.timers, HDF5_GROSS_WRITE_FIXED_DIMS);
+ get_minmax(&write_gross_mm, t);
+
+ write_gross_mm_table[i] = write_gross_mm;
+
+ /* gather all of the raw "write" times */
+ t = io_time_get(res.timers, HDF5_RAW_WRITE_FIXED_DIMS);
+ get_minmax(&write_raw_mm, t);
+
+ write_raw_mm_table[i] = write_raw_mm;
+
+ if (!parms.h5_write_only) {
+ /* gather all of the "mpi read" times */
+ t = io_time_get(res.timers, HDF5_MPI_READ);
+ get_minmax(&read_sys_mm, t);
+
+ read_sys_mm_table[i] = read_sys_mm;
+
+ /* gather all of the "read" times */
+ t = io_time_get(res.timers, HDF5_FINE_READ_FIXED_DIMS);
+ get_minmax(&read_mm, t);
+
+ read_mm_table[i] = read_mm;
+
+ /* gather all of the "read" times from open to close */
+ t = io_time_get(res.timers, HDF5_GROSS_READ_FIXED_DIMS);
+ get_minmax(&read_gross_mm, t);
+
+ read_gross_mm_table[i] = read_gross_mm;
+
+ /* gather all of the raw "read" times */
+ t = io_time_get(res.timers, HDF5_RAW_READ_FIXED_DIMS);
+ get_minmax(&read_raw_mm, t);
+
+ read_raw_mm_table[i] = read_gross_mm;
+ }
+ io_time_destroy(res.timers);
+ }
+
+ /*
+ * Show various statistics
+ */
+ /* Write statistics */
+ /* Print the raw data throughput if desired */
+ if (opts->print_raw) {
+ /* accumulate and output the max, min, and average "raw write" times */
+ if (sio_debug_level >= 3) {
+ /* output all of the times for all iterations */
+ print_indent(3);
+ output_report("Raw Data Write details:\n");
+ output_all_info(write_raw_mm_table, parms.num_iters, 4);
+ }
+
+ output_results(opts, "Raw Data Write", write_raw_mm_table, parms.num_iters, raw_size);
+ } /* end if */
+
+ /* show sys write statistics */
+#if 0
+ if (sio_debug_level >= 3) {
+ /* output all of the times for all iterations */
+ print_indent(3);
+ output_report("MPI Write details:\n");
+ output_all_info(write_sys_mm_table, parms.num_iters, 4);
+ }
+#endif
+ /* We don't currently output the MPI write results */
+
+ /* accumulate and output the max, min, and average "write" times */
+ if (sio_debug_level >= 3) {
+ /* output all of the times for all iterations */
+ print_indent(3);
+ output_report("Write details:\n");
+ output_all_info(write_mm_table, parms.num_iters, 4);
+ }
+
+ output_results(opts, "Write", write_mm_table, parms.num_iters, raw_size);
+
+ /* accumulate and output the max, min, and average "gross write" times */
+ if (sio_debug_level >= 3) {
+ /* output all of the times for all iterations */
+ print_indent(3);
+ output_report("Write Open-Close details:\n");
+ output_all_info(write_gross_mm_table, parms.num_iters, 4);
+ }
+
+ output_results(opts, "Write Open-Close", write_gross_mm_table, parms.num_iters, raw_size);
+
+ if (!parms.h5_write_only) {
+ /* Read statistics */
+ /* Print the raw data throughput if desired */
+ if (opts->print_raw) {
+ /* accumulate and output the max, min, and average "raw read" times */
+ if (sio_debug_level >= 3) {
+ /* output all of the times for all iterations */
+ print_indent(3);
+ output_report("Raw Data Read details:\n");
+ output_all_info(read_raw_mm_table, parms.num_iters, 4);
+ }
+
+ output_results(opts, "Raw Data Read", read_raw_mm_table, parms.num_iters, raw_size);
+ } /* end if */
+
+ /* show mpi read statistics */
+#if 0
+ if (sio_debug_level >= 3) {
+ /* output all of the times for all iterations */
+ print_indent(3);
+ output_report("MPI Read details:\n");
+ output_all_info(read_sys_mm_table, parms.num_iters, 4);
+ }
+#endif
+ /* We don't currently output the MPI read results */
+
+ /* accumulate and output the max, min, and average "read" times */
+ if (sio_debug_level >= 3) {
+ /* output all of the times for all iterations */
+ print_indent(3);
+ output_report("Read details:\n");
+ output_all_info(read_mm_table, parms.num_iters, 4);
+ }
+
+ output_results(opts, "Read", read_mm_table, parms.num_iters, raw_size);
+
+ /* accumulate and output the max, min, and average "gross read" times */
+ if (sio_debug_level >= 3) {
+ /* output all of the times for all iterations */
+ print_indent(3);
+ output_report("Read Open-Close details:\n");
+ output_all_info(read_gross_mm_table, parms.num_iters, 4);
+ }
+
+ output_results(opts, "Read Open-Close", read_gross_mm_table, parms.num_iters, raw_size);
+ }
+
+ /* clean up our mess */
+ HDfree(write_sys_mm_table);
+ HDfree(write_mm_table);
+ HDfree(write_gross_mm_table);
+ HDfree(write_raw_mm_table);
+
+ if (!parms.h5_write_only) {
+ HDfree(read_sys_mm_table);
+ HDfree(read_mm_table);
+ HDfree(read_gross_mm_table);
+ HDfree(read_raw_mm_table);
+ }
+
+ return ret_value;
+}
+
+/*
+ * Function: output_all_info
+ * Purpose:
+ * Return: Nothing
+ * Programmer: Bill Wendling, 29. January 2002
+ * Modifications:
+ */
+static void
+output_all_info(minmax *mm, int count, int indent_level)
+{
+ int i;
+
+ for (i = 0; i < count; ++i) {
+ print_indent(indent_level);
+ output_report("Iteration %d:\n", i + 1);
+ print_indent(indent_level + 1);
+ output_report("Minimum Time: %.2fs\n", mm[i].min);
+ print_indent(indent_level + 1);
+ output_report("Maximum Time: %.2fs\n", mm[i].max);
+ }
+}
+
+/*
+ * Function: get_minmax
+ * Purpose: Gather all the min, max and total of val.
+ * Return: Nothing
+ * Programmer: Bill Wendling, 21. December 2001
+ * Modifications:
+ * Use MPI_Allreduce to do it. -akc, 2002/01/11
+ */
+
+static void
+get_minmax(minmax *mm, double val)
+{
+ mm->max = val;
+ mm->min = val;
+ mm->sum = val;
+}
+
+/*
+ * Function: accumulate_minmax_stuff
+ * Purpose: Accumulate the minimum, maximum, and average of the times
+ * across all processes.
+ * Return: TOTAL_MM - the total of all of these.
+ * Programmer: Bill Wendling, 21. December 2001
+ * Modifications:
+ * Changed to use seconds instead of MB/s - QAK, 5/9/02
+ */
+static void
+accumulate_minmax_stuff(const minmax *mm, int count, minmax *total_mm)
+{
+ int i;
+
+ total_mm->sum = 0.0;
+ total_mm->max = -DBL_MAX;
+ total_mm->min = DBL_MAX;
+ total_mm->num = count;
+
+ for (i = 0; i < count; ++i) {
+ double m = mm[i].max;
+
+ total_mm->sum += m;
+
+ if (m < total_mm->min)
+ total_mm->min = m;
+
+ if (m > total_mm->max)
+ total_mm->max = m;
+ }
+}
+
+/*
+ * Function: output_results
+ * Purpose: Print information about the time & bandwidth for a given
+ * minmax & # of iterations.
+ * Return: Nothing
+ * Programmer: Quincey Koziol, 9. May 2002
+ * Modifications:
+ */
+static void
+output_results(const struct options *opts, const char *name, minmax *table, int table_size, off_t data_size)
+{
+ minmax total_mm;
+
+ accumulate_minmax_stuff(table, table_size, &total_mm);
+
+ print_indent(3);
+ output_report("%s (%d iteration(s)):\n", name, table_size);
+
+ /* Note: The maximum throughput uses the minimum amount of time & vice versa */
+
+ print_indent(4);
+ output_report("Maximum Throughput: %6.2f MB/s", MB_PER_SEC(data_size, total_mm.min));
+ if (opts->print_times)
+ output_report(" (%7.3f s)\n", total_mm.min);
+ else
+ output_report("\n");
+
+ print_indent(4);
+ output_report("Average Throughput: %6.2f MB/s", MB_PER_SEC(data_size, total_mm.sum / total_mm.num));
+ if (opts->print_times)
+ output_report(" (%7.3f s)\n", (total_mm.sum / total_mm.num));
+ else
+ output_report("\n");
+
+ print_indent(4);
+ output_report("Minimum Throughput: %6.2f MB/s", MB_PER_SEC(data_size, total_mm.max));
+ if (opts->print_times)
+ output_report(" (%7.3f s)\n", total_mm.max);
+ else
+ output_report("\n");
+}
+
+/*
+ * Function: output_report
+ * Purpose: Print a line of the report. Only do so if I'm the 0 process.
+ * Return: Nothing
+ * Programmer: Bill Wendling, 19. December 2001
+ * Modifications:
+ */
+static void
+output_report(const char *fmt, ...)
+{
+ va_list ap;
+
+ HDva_start(ap, fmt);
+ HDvfprintf(output, fmt, ap);
+ HDva_end(ap);
+}
+
+/*
+ * Function: print_indent
+ * Purpose: Print spaces to indent a new line of text for pretty printing
+ * things.
+ * Return: Nothing
+ * Programmer: Bill Wendling, 29. October 2001
+ */
+static void
+print_indent(int indent)
+{
+ indent *= TAB_SPACE;
+
+ for (; indent > 0; --indent)
+ HDfputc(' ', output);
+}
+
+static void
+recover_size_and_print(long long val, const char *end)
+{
+ if (val >= ONE_KB && (val % ONE_KB) == 0) {
+ if (val >= ONE_MB && (val % ONE_MB) == 0) {
+ if (val >= ONE_GB && (val % ONE_GB) == 0)
+ HDfprintf(output,
+ "%" H5_PRINTF_LL_WIDTH "d"
+ "GB%s",
+ val / ONE_GB, end);
+ else
+ HDfprintf(output,
+ "%" H5_PRINTF_LL_WIDTH "d"
+ "MB%s",
+ val / ONE_MB, end);
+ }
+ else {
+ HDfprintf(output,
+ "%" H5_PRINTF_LL_WIDTH "d"
+ "KB%s",
+ val / ONE_KB, end);
+ }
+ }
+ else {
+ HDfprintf(output,
+ "%" H5_PRINTF_LL_WIDTH "d"
+ "%s",
+ val, end);
+ }
+}
+
+static void
+print_io_api(long io_types)
+{
+ if (io_types & SIO_POSIX)
+ HDfprintf(output, "posix ");
+ if (io_types & SIO_HDF5)
+ HDfprintf(output, "hdf5 ");
+ HDfprintf(output, "\n");
+}
+
+static void
+report_parameters(struct options *opts)
+{
+ int i, rank;
+ rank = opts->dset_rank;
+
+ print_version("HDF5 Library"); /* print library version */
+ HDfprintf(output, "==== Parameters ====\n");
+
+ HDfprintf(output, "IO API=");
+ print_io_api(opts->io_types);
+
+ HDfprintf(output, "Number of iterations=%d\n", opts->num_iters);
+
+ HDfprintf(output, "Dataset size=");
+
+ for (i = 0; i < rank; i++)
+ recover_size_and_print((long long)opts->dset_size[i], " ");
+ HDfprintf(output, "\n");
+
+ HDfprintf(output, "Transfer buffer size=");
+ for (i = 0; i < rank; i++)
+ recover_size_and_print((long long)opts->buf_size[i], " ");
+ HDfprintf(output, "\n");
+
+ if (opts->page_size) {
+ HDfprintf(output, "Page Aggregation Enabled. Page size = %zu\n", opts->page_size);
+ if (opts->page_buffer_size)
+ HDfprintf(output, "Page Buffering Enabled. Page Buffer size = %zu\n", opts->page_buffer_size);
+ else
+ HDfprintf(output, "Page Buffering Disabled\n");
+ }
+ else
+ HDfprintf(output, "Page Aggregation Disabled\n");
+
+ HDfprintf(output, "Dimension access order=");
+ for (i = 0; i < rank; i++)
+ recover_size_and_print((long long)opts->order[i], " ");
+ HDfprintf(output, "\n");
+
+ if (opts->io_types & SIO_HDF5) {
+
+ HDfprintf(output, "HDF5 data storage method=");
+
+ if (opts->h5_use_chunks) {
+
+ HDfprintf(output, "Chunked\n");
+ HDfprintf(output, "HDF5 chunk size=");
+ for (i = 0; i < rank; i++)
+ recover_size_and_print((long long)opts->chk_size[i], " ");
+ HDfprintf(output, "\n");
+
+ HDfprintf(output, "HDF5 dataset dimensions=");
+ if (opts->h5_extendable) {
+ HDfprintf(output, "Extendable\n");
+ }
+ else {
+ HDfprintf(output, "Fixed\n");
+ }
+ }
+ else {
+ HDfprintf(output, "Contiguous\n");
+ }
+
+ HDfprintf(output, "HDF5 file driver=");
+ if (opts->vfd == sec2) {
+ HDfprintf(output, "sec2\n");
+ }
+ else if (opts->vfd == stdio) {
+ HDfprintf(output, "stdio\n");
+ }
+ else if (opts->vfd == core) {
+ HDfprintf(output, "core\n");
+ }
+ else if (opts->vfd == split) {
+ HDfprintf(output, "split\n");
+ }
+ else if (opts->vfd == multi) {
+ HDfprintf(output, "multi\n");
+ }
+ else if (opts->vfd == family) {
+ HDfprintf(output, "family\n");
+ }
+ else if (opts->vfd == direct) {
+ HDfprintf(output, "direct\n");
+ }
+ }
+
+ {
+ char *prefix = HDgetenv("HDF5_PREFIX");
+
+ HDfprintf(output, "Env HDF5_PREFIX=%s\n", (prefix ? prefix : "not set"));
+ }
+
+ HDfprintf(output, "==== End of Parameters ====\n");
+ HDfprintf(output, "\n");
+}
+
+/*
+ * Function: parse_command_line
+ * Purpose: Parse the command line options and return a STRUCT OPTIONS
+ * structure which will need to be freed by the calling function.
+ * Return: Pointer to an OPTIONS structure
+ * Programmer: Bill Wendling, 31. October 2001
+ * Modifications:
+ * Added multidimensional testing (Christian Chilan, April, 2008)
+ */
+static struct options *
+parse_command_line(int argc, const char *const *argv)
+{
+ int opt;
+ struct options *cl_opts;
+ int i, default_rank, actual_rank, ranks[4];
+
+ cl_opts = (struct options *)HDmalloc(sizeof(struct options));
+
+ cl_opts->page_buffer_size = 0;
+ cl_opts->page_size = 0;
+
+ cl_opts->output_file = NULL;
+ cl_opts->io_types = 0; /* will set default after parsing options */
+ cl_opts->num_iters = 1;
+
+ default_rank = 2;
+
+ cl_opts->dset_rank = 0;
+ cl_opts->buf_rank = 0;
+ cl_opts->chk_rank = 0;
+ cl_opts->order_rank = 0;
+
+ for (i = 0; i < MAX_DIMS; i++) {
+ cl_opts->buf_size[i] = (size_t)((i + 1) * 10);
+ cl_opts->dset_size[i] = (hsize_t)((i + 1) * 100);
+ cl_opts->chk_size[i] = (size_t)((i + 1) * 10);
+ cl_opts->order[i] = i + 1;
+ }
+
+ cl_opts->vfd = sec2;
+
+ cl_opts->print_times = FALSE; /* Printing times is off by default */
+ cl_opts->print_raw = FALSE; /* Printing raw data throughput is off by default */
+ cl_opts->h5_alignment = 1; /* No alignment for HDF5 objects by default */
+ cl_opts->h5_threshold = 1; /* No threshold for aligning HDF5 objects by default */
+ cl_opts->h5_use_chunks = FALSE; /* Don't chunk the HDF5 dataset by default */
+ cl_opts->h5_write_only = FALSE; /* Do both read and write by default */
+ cl_opts->h5_extendable = FALSE; /* Use extendable dataset */
+ cl_opts->verify = FALSE; /* No Verify data correctness by default */
+
+ while ((opt = H5_get_option(argc, argv, s_opts, l_opts)) != EOF) {
+ switch ((char)opt) {
+ case 'a':
+ cl_opts->h5_alignment = parse_size_directive(H5_optarg);
+ break;
+ case 'G':
+ cl_opts->page_size = parse_size_directive(H5_optarg);
+ break;
+ case 'b':
+ cl_opts->page_buffer_size = parse_size_directive(H5_optarg);
+ break;
+ case 'A': {
+ const char *end = H5_optarg;
+ while (end && *end != '\0') {
+ char buf[10];
+
+ HDmemset(buf, '\0', sizeof(buf));
+
+ for (i = 0; *end != '\0' && *end != ','; ++end)
+ if (HDisalnum(*end) && i < 10)
+ buf[i++] = *end;
+
+ if (!HDstrcasecmp(buf, "hdf5")) {
+ cl_opts->io_types |= SIO_HDF5;
+ }
+ else if (!HDstrcasecmp(buf, "posix")) {
+ cl_opts->io_types |= SIO_POSIX;
+ }
+ else {
+ HDfprintf(stderr, "sio_perf: invalid --api option %s\n", buf);
+ HDexit(EXIT_FAILURE);
+ }
+
+ if (*end == '\0')
+ break;
+
+ end++;
+ }
+ }
+
+ break;
+#if 0
+ case 'b':
+ /* the future "binary" option */
+ break;
+#endif /* 0 */
+ case 'c':
+ /* Turn on chunked HDF5 dataset creation */
+ cl_opts->h5_use_chunks = 1;
+ {
+ const char *end = H5_optarg;
+ int j = 0;
+
+ while (end && *end != '\0') {
+ char buf[10];
+
+ HDmemset(buf, '\0', sizeof(buf));
+
+ for (i = 0; *end != '\0' && *end != ','; ++end)
+ if (HDisalnum(*end) && i < 10)
+ buf[i++] = *end;
+
+ cl_opts->chk_size[j] = parse_size_directive(buf);
+
+ j++;
+
+ if (*end == '\0')
+ break;
+
+ end++;
+ }
+ cl_opts->chk_rank = j;
+ }
+
+ break;
+
+ case 'D': {
+ const char *end = H5_optarg;
+
+ while (end && *end != '\0') {
+ char buf[10];
+
+ HDmemset(buf, '\0', sizeof(buf));
+
+ for (i = 0; *end != '\0' && *end != ','; ++end)
+ if (HDisalnum(*end) && i < 10)
+ buf[i++] = *end;
+
+ if (HDstrlen(buf) > 1 || HDisdigit(buf[0])) {
+ size_t j;
+
+ for (j = 0; j < 10 && buf[j] != '\0'; ++j)
+ if (!HDisdigit(buf[j])) {
+ HDfprintf(stderr, "sio_perf: invalid --debug option %s\n", buf);
+ HDexit(EXIT_FAILURE);
+ }
+
+ sio_debug_level = atoi(buf);
+
+ if (sio_debug_level > 4)
+ sio_debug_level = 4;
+ else if (sio_debug_level < 0)
+ sio_debug_level = 0;
+ }
+ else {
+ switch (*buf) {
+ case 'r':
+ /* Turn on raw data throughput info */
+ cl_opts->print_raw = TRUE;
+ break;
+ case 't':
+ /* Turn on time printing */
+ cl_opts->print_times = TRUE;
+ break;
+ case 'v':
+ /* Turn on verify data correctness*/
+ cl_opts->verify = TRUE;
+ break;
+ default:
+ HDfprintf(stderr, "sio_perf: invalid --debug option %s\n", buf);
+ HDexit(EXIT_FAILURE);
+ }
+ }
+
+ if (*end == '\0')
+ break;
+
+ end++;
+ }
+ }
+
+ break;
+ case 'e': {
+ const char *end = H5_optarg;
+ int j = 0;
+
+ while (end && *end != '\0') {
+ char buf[10];
+
+ HDmemset(buf, '\0', sizeof(buf));
+
+ for (i = 0; *end != '\0' && *end != ','; ++end)
+ if (HDisalnum(*end) && i < 10)
+ buf[i++] = *end;
+
+ cl_opts->dset_size[j] = parse_size_directive(buf);
+
+ j++;
+
+ if (*end == '\0')
+ break;
+
+ end++;
+ }
+ cl_opts->dset_rank = j;
+ }
+
+ break;
+
+ case 'i':
+ cl_opts->num_iters = HDatoi(H5_optarg);
+ break;
+ case 'o':
+ cl_opts->output_file = H5_optarg;
+ break;
+ case 'T':
+ cl_opts->h5_threshold = parse_size_directive(H5_optarg);
+ break;
+ case 'v':
+ if (!HDstrcasecmp(H5_optarg, "sec2")) {
+ cl_opts->vfd = sec2;
+ }
+ else if (!HDstrcasecmp(H5_optarg, "stdio")) {
+ cl_opts->vfd = stdio;
+ }
+ else if (!HDstrcasecmp(H5_optarg, "core")) {
+ cl_opts->vfd = core;
+ }
+ else if (!HDstrcasecmp(H5_optarg, "split")) {
+ cl_opts->vfd = split;
+ }
+ else if (!HDstrcasecmp(H5_optarg, "multi")) {
+ cl_opts->vfd = multi;
+ }
+ else if (!HDstrcasecmp(H5_optarg, "family")) {
+ cl_opts->vfd = family;
+ }
+ else if (!HDstrcasecmp(H5_optarg, "direct")) {
+ cl_opts->vfd = direct;
+ }
+ else {
+ HDfprintf(stderr, "sio_perf: invalid --api option %s\n", H5_optarg);
+ HDexit(EXIT_FAILURE);
+ }
+ break;
+ case 'w':
+ cl_opts->h5_write_only = TRUE;
+ break;
+ case 't':
+ cl_opts->h5_extendable = TRUE;
+ break;
+ case 'x': {
+ const char *end = H5_optarg;
+ int j = 0;
+
+ while (end && *end != '\0') {
+ char buf[10];
+
+ HDmemset(buf, '\0', sizeof(buf));
+
+ for (i = 0; *end != '\0' && *end != ','; ++end)
+ if (HDisalnum(*end) && i < 10)
+ buf[i++] = *end;
+
+ cl_opts->buf_size[j] = parse_size_directive(buf);
+
+ j++;
+
+ if (*end == '\0')
+ break;
+
+ end++;
+ }
+ cl_opts->buf_rank = j;
+ }
+
+ break;
+
+ case 'r': {
+ const char *end = H5_optarg;
+ int j = 0;
+
+ while (end && *end != '\0') {
+ char buf[10];
+
+ HDmemset(buf, '\0', sizeof(buf));
+
+ for (i = 0; *end != '\0' && *end != ','; ++end)
+ if (HDisalnum(*end) && i < 10)
+ buf[i++] = *end;
+
+ cl_opts->order[j] = (int)parse_size_directive(buf);
+
+ j++;
+
+ if (*end == '\0')
+ break;
+
+ end++;
+ }
+
+ cl_opts->order_rank = j;
+ }
+
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage(progname);
+ HDfree(cl_opts);
+ return NULL;
+ }
+ }
+
+ /* perform rank consistency analysis */
+ actual_rank = 0;
+
+ ranks[0] = cl_opts->dset_rank;
+ ranks[1] = cl_opts->buf_rank;
+ ranks[2] = cl_opts->order_rank;
+ ranks[3] = cl_opts->chk_rank;
+
+ for (i = 0; i < 4; i++) {
+ if (ranks[i] > 0) {
+ if (!actual_rank) {
+ actual_rank = ranks[i];
+ }
+ else {
+ if (actual_rank != ranks[i])
+ exit(EXIT_FAILURE);
+ }
+ }
+ }
+
+ if (!actual_rank)
+ actual_rank = default_rank;
+
+ cl_opts->dset_rank = actual_rank;
+ cl_opts->buf_rank = actual_rank;
+ cl_opts->order_rank = actual_rank;
+ cl_opts->chk_rank = actual_rank;
+
+ for (i = 0; i < actual_rank; i++) {
+ if (cl_opts->order[i] > actual_rank) {
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ /* set default if none specified yet */
+ if (!cl_opts->io_types)
+ cl_opts->io_types = SIO_HDF5 | SIO_POSIX; /* run all API */
+
+ /* verify parameters sanity. Adjust if needed. */
+ /* cap xfer_size with bytes per process */
+ if (cl_opts->num_iters <= 0)
+ cl_opts->num_iters = 1;
+
+ return cl_opts;
+}
+
+/*
+ * Function: parse_size_directive
+ * Purpose: Parse the size directive passed on the commandline. The size
+ * directive is an integer followed by a size indicator:
+ *
+ * K, k - Kilobyte
+ * M, m - Megabyte
+ * G, g - Gigabyte
+ *
+ * Return: The size as a off_t because this is related to file size.
+ * If an unknown size indicator is used, then the program will
+ * exit with EXIT_FAILURE as the return value.
+ * Programmer: Bill Wendling, 18. December 2001
+ * Modifications:
+ */
+
+static hsize_t
+parse_size_directive(const char *size)
+{
+ hsize_t s;
+ char * endptr;
+
+ s = HDstrtoull(size, &endptr, 10);
+
+ if (endptr && *endptr) {
+ while (*endptr != '\0' && (*endptr == ' ' || *endptr == '\t'))
+ ++endptr;
+
+ switch (*endptr) {
+ case 'K':
+ case 'k':
+ s *= ONE_KB;
+ break;
+
+ case 'M':
+ case 'm':
+ s *= ONE_MB;
+ break;
+
+ case 'G':
+ case 'g':
+ s *= ONE_GB;
+ break;
+
+ default:
+ HDfprintf(stderr, "Illegal size specifier '%c'\n", *endptr);
+ HDexit(EXIT_FAILURE);
+ }
+ }
+
+ return s;
+}
+
+/*
+ * Function: usage
+ * Purpose: Print a usage message and then exit.
+ * Return: Nothing
+ * Programmer: Bill Wendling, 31. October 2001
+ * Modifications:
+ */
+static void
+usage(const char *prog)
+{
+ print_version(prog);
+ HDprintf("usage: %s [OPTIONS]\n", prog);
+ HDprintf(" OPTIONS\n");
+ HDprintf(" -h Print an usage message and exit\n");
+ HDprintf(" -A AL Which APIs to test\n");
+ HDprintf(" [default: all of them]\n");
+ HDprintf(" -c SL Selects chunked storage and defines chunks dimensions\n");
+ HDprintf(" and sizes\n");
+ HDprintf(" [default: Off]\n");
+ HDprintf(" -e SL Dimensions and sizes of dataset\n");
+ HDprintf(" [default: 100,200]\n");
+ HDprintf(" -i N Number of iterations to perform\n");
+ HDprintf(" [default: 1]\n");
+ HDprintf(" -r NL Dimension access order (see below for description)\n");
+ HDprintf(" [default: 1,2]\n");
+ HDprintf(" -t Selects extendable dimensions for HDF5 dataset\n");
+ HDprintf(" [default: Off]\n");
+ HDprintf(" -v VFD Selects file driver for HDF5 access\n");
+ HDprintf(" [default: sec2]\n");
+ HDprintf(" -w Perform write tests, not the read tests\n");
+ HDprintf(" [default: Off]\n");
+ HDprintf(" -x SL Dimensions and sizes of the transfer buffer\n");
+ HDprintf(" [default: 10,20]\n");
+ HDprintf("\n");
+ HDprintf(" N - is an integer > 0.\n");
+ HDprintf("\n");
+ HDprintf(" S - is a size specifier, an integer > 0 followed by a size indicator:\n");
+ HDprintf(" K - Kilobyte (%d)\n", ONE_KB);
+ HDprintf(" M - Megabyte (%d)\n", ONE_MB);
+ HDprintf(" G - Gigabyte (%d)\n", ONE_GB);
+ HDprintf("\n");
+ HDprintf(" Example: '37M' is 37 megabytes or %d bytes\n", 37 * ONE_MB);
+ HDprintf("\n");
+ HDprintf(" AL - is an API list. Valid values are:\n");
+ HDprintf(" hdf5 - HDF5\n");
+ HDprintf(" posix - POSIX\n");
+ HDprintf("\n");
+ HDprintf(" Example: -A posix,hdf5\n");
+ HDprintf("\n");
+ HDprintf(" NL - is list of integers (N) separated by commas.\n");
+ HDprintf("\n");
+ HDprintf(" Example: 1,2,3\n");
+ HDprintf("\n");
+ HDprintf(" SL - is list of size specifiers (S) separated by commas.\n");
+ HDprintf("\n");
+ HDprintf(" Example: 2K,2K,3K\n");
+ HDprintf("\n");
+ HDprintf(" The example defines an object (dataset, transfer buffer) with three\n");
+ HDprintf(" dimensions. Be aware that as the number of dimensions increases, the\n");
+ HDprintf(" the total size of the object increases exponentially.\n");
+ HDprintf("\n");
+ HDprintf(" VFD - is an HDF5 file driver specifier. Valid values are:\n");
+ HDprintf(" sec2, stdio, core, split, multi, family, direct\n");
+ HDprintf("\n");
+ HDprintf(" Dimension access order:\n");
+ HDprintf(" Data access starts at the cardinal origin of the dataset using the\n");
+ HDprintf(" transfer buffer. The next access occurs on a dataset region next to\n");
+ HDprintf(" the previous one. For a multidimensional dataset, there are several\n");
+ HDprintf(" directions as to where to proceed. This can be specified in the dimension\n");
+ HDprintf(" access order. For example, -r 1,2 states that the tool should traverse\n");
+ HDprintf(" dimension 1 first, and then dimension 2.\n");
+ HDprintf("\n");
+ HDprintf(" Environment variables:\n");
+ HDprintf(" HDF5_NOCLEANUP Do not remove data files if set [default remove]\n");
+ HDprintf(" HDF5_PREFIX Data file prefix\n");
+ HDprintf("\n");
+ HDfflush(stdout);
+} /* end usage() */
diff --git a/tools/src/h5perf/sio_perf.h b/tools/src/h5perf/sio_perf.h
new file mode 100644
index 0000000..d998377
--- /dev/null
+++ b/tools/src/h5perf/sio_perf.h
@@ -0,0 +1,104 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+#ifndef SIO_PERF_H
+#define SIO_PERF_H
+
+#ifndef STANDALONE
+#include "io_timer.h"
+#include "H5private.h"
+#include "h5tools.h"
+#include "h5tools_utils.h"
+#else
+#include "io_timer.h"
+#include "sio_standalone.h"
+#endif
+
+/* setup the dataset no fill option if this is v1.5 or more */
+#if H5_VERS_MAJOR > 1 || H5_VERS_MINOR > 4
+#define H5_HAVE_NOFILL 1
+#endif
+
+#define MAX_DIMS 32
+
+typedef enum iotype_ {
+ POSIXIO,
+ HDF5
+ /*NUM_TYPES*/
+} iotype;
+
+typedef enum vfdtype_ {
+ sec2,
+ stdio,
+ core,
+ split,
+ multi,
+ family,
+ direct
+ /*NUM_TYPES*/
+} vfdtype;
+
+typedef struct parameters_ {
+ iotype io_type; /* The type of IO test to perform */
+ vfdtype vfd;
+ long num_files; /* Number of files to create */
+ long num_dsets; /* Number of datasets to create */
+ hsize_t num_bytes; /* Number of bytes in each dset */
+ int num_iters; /* Number of times to loop doing the IO */
+ int rank; /* Rank of dataset */
+ hsize_t dset_size[MAX_DIMS]; /* Dataset size */
+ size_t buf_size[MAX_DIMS]; /* Buffer size */
+ size_t chk_size[MAX_DIMS]; /* Chunk size */
+ int order[MAX_DIMS]; /* Buffer size */
+ hsize_t h5_align; /* HDF5 object alignment */
+ hsize_t h5_thresh; /* HDF5 object alignment threshold */
+ int h5_use_chunks; /* Make HDF5 dataset chunked */
+ int h5_extendable; /* Make HDF5 dataset chunked */
+ int h5_write_only; /* Perform the write tests only */
+ int verify; /* Verify data correctness */
+ size_t page_size;
+ size_t page_buffer_size;
+} parameters;
+
+typedef struct results_ {
+ herr_t ret_code;
+ io_time_t *timers;
+} results;
+
+#ifndef SUCCESS
+#define SUCCESS 0
+#endif /* !SUCCESS */
+
+#ifndef FAIL
+#define FAIL -1
+#endif /* !FAIL */
+
+extern FILE * output; /* output file */
+extern io_time_t *timer_g; /* timer: global for stub functions */
+extern int sio_debug_level; /* The debug level:
+ * 0 - Off
+ * 1 - Minimal
+ * 2 - Some more
+ * 3 - Maximal
+ * 4 - Even More Debugging (timer stuff)
+ */
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+extern void do_sio(parameters param, results *res);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* SIO_PERF_H */
diff --git a/tools/src/h5repack/CMakeLists.txt b/tools/src/h5repack/CMakeLists.txt
index 4a1430e..b8b4709 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)
# --------------------------------------------------------------------
@@ -12,11 +12,13 @@ set (REPACK_COMMON_SOURCES
${HDF5_TOOLS_SRC_H5REPACK_SOURCE_DIR}/h5repack_refs.c
${HDF5_TOOLS_SRC_H5REPACK_SOURCE_DIR}/h5repack_verify.c
${HDF5_TOOLS_SRC_H5REPACK_SOURCE_DIR}/h5repack.c
+ ${HDF5_TOOLS_SRC_H5REPACK_SOURCE_DIR}/h5repack.h
)
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_include_directories (h5repack PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_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)
@@ -27,7 +29,8 @@ 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_include_directories (h5repack-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_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)
@@ -36,6 +39,17 @@ if (BUILD_SHARED_LIBS)
set (H5_DEP_EXECUTABLES ${H5_DEP_EXECUTABLES} h5repack-shared)
endif ()
+#-----------------------------------------------------------------------------
+# Add Target to clang-format
+#-----------------------------------------------------------------------------
+if (HDF5_ENABLE_FORMATTERS)
+ if (NOT ONLY_SHARED_LIBS)
+ clang_format (HDF5_H5REPACK_SRC_FORMAT h5repack)
+ else ()
+ clang_format (HDF5_H5REPACK_SRC_FORMAT h5repack-shared)
+ endif ()
+endif ()
+
##############################################################################
##############################################################################
### I N S T A L L A T I O N ###
diff --git a/tools/src/h5repack/Makefile.am b/tools/src/h5repack/Makefile.am
index 925b8a7..245329d 100644
--- a/tools/src/h5repack/Makefile.am
+++ b/tools/src/h5repack/Makefile.am
@@ -6,7 +6,7 @@
# This file is part of HDF5. The full HDF5 copyright notice, including
# terms governing use, modification, and redistribution, is contained in
# the COPYING file, which can be found at the root of the source code
-# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.
+# distribution tree, or in https://www.hdfgroup.org/licenses.
# If you do not have access to either file, you may request a copy from
# help@hdfgroup.org.
##
diff --git a/tools/src/h5repack/h5repack.c b/tools/src/h5repack/h5repack.c
index c18df6c..d0aad79 100644
--- a/tools/src/h5repack/h5repack.c
+++ b/tools/src/h5repack/h5repack.c
@@ -6,7 +6,7 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -22,10 +22,10 @@
*-------------------------------------------------------------------------
*/
-static int check_options(pack_opt_t *options);
-static int check_objects(const char* fname, pack_opt_t *options);
-static const char* get_sfilter(H5Z_filter_t filtn);
-static int have_request(pack_opt_t *options);
+static int check_options(pack_opt_t *options);
+static int check_objects(const char *fname, pack_opt_t *options);
+static const char *get_sfilter(H5Z_filter_t filtn);
+static int have_request(pack_opt_t *options);
/*-------------------------------------------------------------------------
* Function: h5repack
@@ -41,7 +41,9 @@ static int have_request(pack_opt_t *options);
* Return: 0, ok, -1, fail
*-------------------------------------------------------------------------
*/
-int h5repack(const char* infile, const char* outfile, pack_opt_t *options) {
+int
+h5repack(const char *infile, const char *outfile, pack_opt_t *options)
+{
/* check input */
if (check_options(options) < 0)
return -1;
@@ -55,7 +57,7 @@ int h5repack(const char* infile, const char* outfile, pack_opt_t *options) {
return -1;
return 0;
-}
+} /* end h5repack() */
/*-------------------------------------------------------------------------
* Function: h5repack_init
@@ -71,22 +73,24 @@ h5repack_init(pack_opt_t *options, int verbose, hbool_t latest)
int k, n;
HDmemset(options, 0, sizeof(pack_opt_t));
- options->min_comp = 0;
- options->verbose = verbose;
- options->latest = latest;
- options->layout_g = H5D_LAYOUT_ERROR;
- options->low_bound = H5F_LIBVER_EARLIEST;
+ options->min_comp = 0;
+ options->verbose = verbose;
+ options->latest = 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;
+ options->filter_g[n].filtn = -1;
options->filter_g[n].cd_nelmts = 0;
for (k = 0; k < CD_VALUES; k++)
options->filter_g[n].cd_values[k] = 0;
}
return (options_table_init(&(options->op_tbl)));
-}
+} /* end h5repack_init() */
/*-------------------------------------------------------------------------
* Function: h5repack_end
@@ -95,9 +99,11 @@ h5repack_init(pack_opt_t *options, int verbose, hbool_t latest)
*-------------------------------------------------------------------------
*/
-int h5repack_end(pack_opt_t *options) {
+int
+h5repack_end(pack_opt_t *options)
+{
return options_table_free(options->op_tbl);
-}
+} /* end h5repack_end() */
/*-------------------------------------------------------------------------
* Function: h5repack_addfilter
@@ -111,7 +117,7 @@ int h5repack_end(pack_opt_t *options) {
int
h5repack_addfilter(const char *str, pack_opt_t *options)
{
- obj_list_t *obj_list = NULL; /* one object list for the -f and -l option entry */
+ obj_list_t * obj_list = NULL; /* one object list for the -f and -l option entry */
filter_info_t filter; /* filter info for the current -f option entry */
unsigned n_objs; /* number of objects in the current -f or -l option entry */
int is_glb; /* is the filter global */
@@ -138,7 +144,7 @@ h5repack_addfilter(const char *str, pack_opt_t *options)
HDfree(obj_list);
return 0;
-}
+} /* end h5repack_addfilter() */
/*-------------------------------------------------------------------------
* Function: h5repack_addlayout
@@ -160,7 +166,7 @@ h5repack_addlayout(const char *str, pack_opt_t *options)
init_packobject(&pack);
if (options->all_layout == 1) {
- error_msg( "invalid layout input: 'all' option is present with other objects <%s>\n", str);
+ error_msg("invalid layout input: 'all' option is present with other objects <%s>\n", str);
return ret_value;
}
@@ -175,7 +181,7 @@ h5repack_addlayout(const char *str, pack_opt_t *options)
if (pack.layout == H5D_CHUNKED) {
/* -2 means the NONE option, remove chunking
and set the global layout to contiguous */
- if (pack.chunk.rank == -2)
+ if (pack.chunk.rank == -2) /* TODO: fix 'magic number' */
options->layout_g = H5D_CONTIGUOUS;
/* otherwise set the global chunking type */
else {
@@ -192,10 +198,10 @@ h5repack_addlayout(const char *str, pack_opt_t *options)
HDfree(obj_list);
ret_value = 0;
- }
+ } /* end if obj_list exists */
return ret_value;
-}
+} /* end h5repack_addlayout() */
/* Note: The below copy_named_datatype(), named_datatype_free(), copy_attr()
* were located in h5repack_copy.c as static prior to bugfix1726.
@@ -215,20 +221,30 @@ h5repack_addlayout(const char *str, pack_opt_t *options)
* to free the stack.
*-------------------------------------------------------------------------
*/
-hid_t copy_named_datatype(hid_t type_in, hid_t fidout,
- named_dt_t **named_dt_head_p, trav_table_t *travt, pack_opt_t *options) {
- 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 */
- if (H5Oget_info2(type_in, &oinfo, H5O_INFO_BASIC) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Oget_info failed");
+hid_t
+copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, trav_table_t *travt,
+ pack_opt_t *options)
+{
+ named_dt_t *dt = NULL; /* Stack pointer */
+ named_dt_t *dt_ret = NULL; /* Datatype to return */
+ H5O_info2_t oinfo; /* Object info of input dtype */
+ int token_cmp;
+ hid_t ret_value = H5I_INVALID_HID;
+
+ if (H5Oget_info3(type_in, &oinfo, H5O_INFO_BASIC) < 0)
+ H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "H5Oget_info failed");
if (*named_dt_head_p) {
- /* Stack already exists, search for the datatype */
- while (dt && dt->addr_in != oinfo.addr)
- dt = dt->next;
+ /* Search the stack for the datatype. */
+ for (dt = *named_dt_head_p; dt != NULL; dt = dt->next) {
+ if (H5Otoken_cmp(type_in, &dt->obj_token, &oinfo.token, &token_cmp) < 0)
+ H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "failed to compare object tokens");
+
+ if (token_cmp == 0)
+ break; // found it!
+ }
+
dt_ret = dt;
}
else {
@@ -239,59 +255,64 @@ hid_t copy_named_datatype(hid_t type_in, hid_t fidout,
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");
- dt->next = *named_dt_head_p;
+ 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;
+ /* Update the token/address and id */
+ HDmemcpy(&dt->obj_token, &travt->objs[i].obj_token, sizeof(H5O_token_t));
+ dt->id_out = H5I_INVALID_HID;
/* Check if this type is the one requested */
- if (oinfo.addr == dt->addr_in) {
+ if (H5Otoken_cmp(type_in, &oinfo.token, &dt->obj_token, &token_cmp) < 0)
+ H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "failed to compare object tokens");
+ if (!token_cmp)
dt_ret = dt;
- } /* end if */
- } /* end if */
- } /* end for */
- } /* end else */
+ } /* end if named datatype */
+ } /* end for each object in traversal table */
+ } /* end else (create the stack) */
/* Handle the case that the requested datatype was not found. This is
- * possible if the datatype was committed anonymously in the input file. */
+ * possible if the datatype was committed anonymously in the input file.
+ */
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");
- dt_ret->next = *named_dt_head_p;
+ 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;
- } /* end if */
+ /* Update the token/address and id */
+ HDmemcpy(&dt_ret->obj_token, &oinfo.token, sizeof(H5O_token_t));
+ 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
- * anonymously */
+ * anonymously
+ */
if (dt_ret->id_out < 0) {
if (options->use_native == 1)
dt_ret->id_out = H5Tget_native_type(type_in, H5T_DIR_DEFAULT);
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");
- } /* end if */
+ H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "H5Tcommit_anon failed");
+ } /* end if named datatype not yet in output file */
/* Set return value */
ret_value = dt_ret->id_out;
- /* Increment the ref count on id_out, because the calling function will try to close it */
- if(H5Iinc_ref(ret_value) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Iinc_ref failed");
+ /* Increment the ref count on id_out, because the calling function will try
+ * to close it. (TODO: fix scope envy)
+ */
+ if (H5Iinc_ref(ret_value) < 0)
+ H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "H5Iinc_ref failed");
done:
return ret_value;
-} /* end copy_named_datatype */
+} /* end copy_named_datatype() */
/*-------------------------------------------------------------------------
* Function: named_datatype_free
@@ -299,24 +320,26 @@ done:
* Purpose: Frees the stack of named datatypes.
*-------------------------------------------------------------------------
*/
-int named_datatype_free(named_dt_t **named_dt_head_p, int ignore_err) {
- named_dt_t *dt = *named_dt_head_p;
+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;
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;
- } /* end while */
+ }
ret_value = 0;
done:
return (ret_value);
-} /* end named_datatype_free */
+} /* end named_datatype_free() */
/*-------------------------------------------------------------------------
* Function: copy_attr
@@ -330,283 +353,317 @@ 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)
+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 */
- size_t msize; /* size of type */
- void *buf = NULL; /* data buffer */
- hsize_t nelmts; /* number of elements in dataset */
- int rank; /* rank of dataset */
- htri_t is_named; /* Whether the datatype is named */
- hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */
- char name[255];
- H5O_info_t oinfo; /* object info */
- int j;
- unsigned u;
- hbool_t is_ref = 0;
- H5T_class_t type_class = -1;
-
- if (H5Oget_info2(loc_in, &oinfo, H5O_INFO_NUM_ATTRS) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Oget_info failed");
+ 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 */
+ int rank; /* rank of dataset */
+ htri_t is_named; /* Whether the datatype is named */
+ hsize_t dims[H5S_MAX_RANK]; /* dimensions of dataset */
+ H5_timer_t timer; /* Timer for read/write operations */
+ H5_timevals_t times; /* Elapsed time for each operation */
+ static double read_time = 0;
+ static double write_time = 0;
+ char name[255];
+ H5O_info2_t oinfo; /* object info */
+ int j;
+ unsigned u;
+ hbool_t is_ref = 0;
+ H5T_class_t type_class = -1;
+ int ret_value = 0;
+
+ if (H5Oget_info3(loc_in, &oinfo, H5O_INFO_NUM_ATTRS) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Oget_info failed");
/*-------------------------------------------------------------------------
* copy all attributes
*-------------------------------------------------------------------------
*/
- for (u = 0; u < (unsigned) oinfo.num_attrs; u++) {
+ 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");
+ if ((attr_id = H5Aopen_by_idx(loc_in, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, H5P_DEFAULT,
+ H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Aopen_by_idx failed");
- /* get name */
- if (H5Aget_name(attr_id, (size_t) 255, name) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
+ if (H5Aget_name(attr_id, (size_t)255, name) < 0)
+ 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");
- } /* end if */
+ H5TOOLS_GOTO_ERROR((-1), "copy_named_datatype failed");
+ }
if (H5Fclose(fidout) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fclose failed");
- } /* end if */
+ H5TOOLS_GOTO_ERROR((-1), "H5Fclose failed");
+ } /* end if datatype is committed and we have a traversal table */
else {
if (options->use_native == 1)
wtype_id = H5Tget_native_type(ftype_id, H5T_DIR_DEFAULT);
else
wtype_id = H5Tcopy(ftype_id);
- } /* end else */
+ } /* end else: uncommitted datatype and/or no traversal 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");
-
- /*-------------------------------------------------------------------------
- * object references are a special case. We cannot just copy the buffers,
- * but instead we recreate the reference.
- * This is done on a second sweep of the file that just copies the referenced
- * objects at copy_refs_attr()
- *-------------------------------------------------------------------------
+ H5TOOLS_GOTO_ERROR((-1), "H5Tget_size failed");
+
+ /*---------------------------------------------------------------------
+ * object references are a special case. We cannot just copy the
+ * buffers, but instead we recreate the reference.
+ * This is done on a second sweep of the file that just copies the
+ * referenced objects at copy_refs_attr().
+ *---------------------------------------------------------------------
*/
type_class = H5Tget_class(wtype_id);
- is_ref = (type_class == H5T_REFERENCE);
+ 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));
+ 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) {
int nmembers = H5Tget_nmembers(wtype_id);
for (j = 0; j < nmembers; j++) {
- hid_t mtid = H5Tget_member_type(wtype_id, (unsigned)j);
+ 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;
break;
}
- } /* for (j=0; i<nmembers; j++) */
- } /* if (type_class == H5T_COMPOUND) */
+ } /* end for each member */
+ } /* end if type_class is H5T_COMPOUND */
+
+ read_time = 0;
+ write_time = 0;
if (!is_ref) {
- /*-------------------------------------------------------------------------
+ /*-----------------------------------------------------------------
* read to memory
- *-------------------------------------------------------------------------
+ *-----------------------------------------------------------------
*/
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 (options->verbose == 2) {
+ H5_timer_init(&timer);
+ H5_timer_start(&timer);
+ }
if (H5Aread(attr_id, wtype_id, buf) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aread failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Aread failed");
+ if (options->verbose == 2) {
+ H5_timer_stop(&timer);
+ H5_timer_get_times(timer, &times);
+ read_time += times.elapsed;
+ }
- /*-------------------------------------------------------------------------
+ /*-----------------------------------------------------------------
* copy
- *-------------------------------------------------------------------------
+ *-----------------------------------------------------------------
*/
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 (options->verbose == 2) {
+ H5_timer_init(&timer);
+ H5_timer_start(&timer);
+ }
if (H5Awrite(attr_out, wtype_id, buf) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Awrite failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Awrite failed");
+ if (options->verbose == 2) {
+ H5_timer_stop(&timer);
+ H5_timer_get_times(timer, &times);
+ write_time += times.elapsed;
+ }
/*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 */
if (TRUE == h5tools_detect_vlen(wtype_id))
- H5Dvlen_reclaim(wtype_id, space_id, H5P_DEFAULT, buf);
+ H5Treclaim(wtype_id, space_id, H5P_DEFAULT, buf);
+
HDfree(buf);
buf = NULL;
} /*H5T_REFERENCE*/
- if (options->verbose)
+ if (options->verbose == 2)
+ HDprintf(FORMAT_OBJ_ATTR_TIME, "attr", read_time, write_time, name);
+ else
HDprintf(FORMAT_OBJ_ATTR, "attr", name);
- /*-------------------------------------------------------------------------
+ /*---------------------------------------------------------------------
* close
- *-------------------------------------------------------------------------
+ *---------------------------------------------------------------------
*/
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;
- } /* for u */
+ H5TOOLS_GOTO_ERROR((-1), "H5Aclose failed");
+ attr_id = H5I_INVALID_HID;
+ } /* for u (each attribute) */
done:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
if (buf) {
- /* Check if we have VL data and string in the attribute's datatype that must
- * be reclaimed */
+ /* Check if we have VL data and string in the attribute's
+ * datatype that must be reclaimed
+ */
if (TRUE == h5tools_detect_vlen(wtype_id))
- H5Dvlen_reclaim(wtype_id, space_id, H5P_DEFAULT, buf);
+ H5Treclaim(wtype_id, space_id, H5P_DEFAULT, buf);
/* Free buf */
HDfree(buf);
- } /* end if */
+ }
H5Aclose(attr_out);
H5Sclose(space_id);
H5Tclose(wtype_id);
H5Tclose(ftype_id);
H5Aclose(attr_id);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return ret_value;
} /* end copy_attr() */
-/*-------------------------------------------------------------------------
+/*-----------------------------------------------------------------------------
* Function: check_options
*
* Purpose: print options, checks for invalid options
*
* Return: void, return -1 on error
- *-------------------------------------------------------------------------
+ *-----------------------------------------------------------------------------
*/
-static int check_options(pack_opt_t *options) {
- int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
+static int
+check_options(pack_opt_t *options)
+{
unsigned int i;
int k, j, has_cp = 0, has_ck = 0;
char slayout[30];
+ int ret_value = 0;
/*-------------------------------------------------------------------------
- * objects to layout
- *-------------------------------------------------------------------------
- */
- if (options->verbose && have_request(options) /* only print if requested */) {
+ * Objects to layout
+ *-------------------------------------------------------------------------
+ */
+ if (options->verbose > 0 && have_request(options)) {
if (options->all_layout == 1) {
HDprintf("All objects to modify layout are...\n");
switch (options->layout_g) {
- case H5D_COMPACT:
- strcpy(slayout, "compact");
- break;
- case H5D_CONTIGUOUS:
- strcpy(slayout, "contiguous");
- break;
- case H5D_CHUNKED:
- strcpy(slayout, "chunked");
- break;
- case H5D_VIRTUAL:
- strcpy(slayout, "virtual");
- break;
- case H5D_LAYOUT_ERROR:
- case H5D_NLAYOUTS:
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "invalid layout");
- default:
- strcpy(slayout, "invalid layout\n");
- HGOTO_DONE(FAIL);
+ case H5D_COMPACT:
+ strcpy(slayout, "compact");
+ break;
+ case H5D_CONTIGUOUS:
+ strcpy(slayout, "contiguous");
+ break;
+ case H5D_CHUNKED:
+ strcpy(slayout, "chunked");
+ break;
+ case H5D_VIRTUAL:
+ strcpy(slayout, "virtual");
+ break;
+ case H5D_LAYOUT_ERROR:
+ case H5D_NLAYOUTS:
+ H5TOOLS_GOTO_ERROR((-1), "invalid layout");
+ break;
+ default:
+ strcpy(slayout, "invalid layout\n");
+ H5TOOLS_GOTO_DONE((-1));
}
HDprintf(" Apply %s layout to all", slayout);
if (H5D_CHUNKED == options->layout_g) {
HDprintf("with dimension [ ");
for (j = 0; j < options->chunk_g.rank; j++)
- HDprintf("%d ", (int) options->chunk_g.chunk_lengths[j]);
+ HDprintf("%d ", (int)options->chunk_g.chunk_lengths[j]);
HDprintf("]");
}
HDprintf("\n");
}
else
HDprintf("No all objects to modify layout\n");
- }/* verbose */
+ } /* end if verbose */
for (i = 0; i < options->op_tbl->nelems; i++) {
- char* name = options->op_tbl->objs[i].path;
+ char *name = options->op_tbl->objs[i].path;
if (options->op_tbl->objs[i].chunk.rank > 0) {
- if (options->verbose) {
+ if (options->verbose > 0) {
HDprintf(" <%s> with chunk size ", name);
for (k = 0; k < options->op_tbl->objs[i].chunk.rank; k++)
- HDprintf("%d ", (int) options->op_tbl->objs[i].chunk.chunk_lengths[k]);
+ HDprintf("%d ", (int)options->op_tbl->objs[i].chunk.chunk_lengths[k]);
HDprintf("\n");
}
has_ck = 1;
}
- else if (options->op_tbl->objs[i].chunk.rank == -2) {
- if (options->verbose)
+ else if (options->op_tbl->objs[i].chunk.rank == -2) { /* TODO: replace 'magic number' */
+ if (options->verbose > 0)
HDprintf(" <%s> %s\n", name, "NONE (contiguous)");
has_ck = 1;
}
- }
+ } /* 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
- *-------------------------------------------------------------------------
- */
+ * Objects to filter
+ *-------------------------------------------------------------------------
+ */
- if (options->verbose && have_request(options) /* only print if requested */) {
+ if (options->verbose > 0 && have_request(options)) {
if (options->all_filter == 1) {
HDprintf("All objects to apply filter are...\n");
for (k = 0; k < options->n_filter_g; k++) {
@@ -616,116 +673,124 @@ static int check_options(pack_opt_t *options) {
continue;
}
switch (filtn) {
- case H5Z_FILTER_NONE:
- HDprintf(" Uncompress all\n");
- break;
- case H5Z_FILTER_SHUFFLE:
- case H5Z_FILTER_FLETCHER32:
- HDprintf(" All with %s\n", get_sfilter(filtn));
- break;
- case H5Z_FILTER_SZIP:
- case H5Z_FILTER_DEFLATE:
- HDprintf(" All with %s, parameter %d\n", get_sfilter(filtn), options->filter_g[k].cd_values[0]);
- break;
- default:
- HDprintf(" User Defined %d\n", filtn);
- break;
- } /* k */
- };
- }
+ case H5Z_FILTER_NONE:
+ HDprintf(" Uncompress all\n");
+ break;
+ case H5Z_FILTER_SHUFFLE:
+ case H5Z_FILTER_FLETCHER32:
+ HDprintf(" All with %s\n", get_sfilter(filtn));
+ break;
+ case H5Z_FILTER_SZIP:
+ case H5Z_FILTER_DEFLATE:
+ HDprintf(" All with %s, parameter %d\n", get_sfilter(filtn),
+ options->filter_g[k].cd_values[0]);
+ break;
+ default:
+ HDprintf(" User Defined %d\n", filtn);
+ break;
+ } /* end switch */
+ } /* end for each filter */
+ } /* end if options->all_filter == 1 (TODO: meaning) */
else
HDprintf("No all objects to apply filter\n");
- } /* verbose */
+ } /* end if verbose */
for (i = 0; i < options->op_tbl->nelems; i++) {
pack_info_t pack = options->op_tbl->objs[i];
- char* name = pack.path;
+ char * name = pack.path;
for (j = 0; j < pack.nfilters; j++) {
- if (options->verbose) {
- if(pack.filter[j].filtn >= 0) {
- if(pack.filter[j].filtn > H5Z_FILTER_SCALEOFFSET)
- HDprintf(" <%s> with %s filter %d\n", name, get_sfilter(pack.filter[j].filtn), pack.filter[j].filtn);
- else
+ if (options->verbose > 0) {
+ if (pack.filter[j].filtn >= 0) {
+ if (pack.filter[j].filtn > H5Z_FILTER_SCALEOFFSET) {
+ HDprintf(" <%s> with %s filter %d\n", name, get_sfilter(pack.filter[j].filtn),
+ pack.filter[j].filtn);
+ }
+ else {
HDprintf(" <%s> with %s filter\n", name, get_sfilter(pack.filter[j].filtn));
+ }
}
}
has_cp = 1;
- } /* j */
- } /* i */
+ } /* end for each filter */
+ } /* 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
- *-------------------------------------------------------------------------
- */
+ * Check options for the latest format
+ *-------------------------------------------------------------------------
+ */
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
- *---------------------------------------------------------------------------------
- */
+ /*------------------------------------------------------------------------
+ * Verify new user userblock options; file name must be present
+ *------------------------------------------------------------------------
+ */
if (options->ublock_filename != NULL && options->ublock_size == 0) {
- if (options->verbose) {
- HDprintf("Warning: user block size missing for file %s. Assigning a default size of 1024...\n", options->ublock_filename);
+ if (options->verbose > 0) {
+ HDprintf("Warning: user block size missing for file %s. Assigning a default size of 1024...\n",
+ options->ublock_filename);
options->ublock_size = 1024;
}
}
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");
- /*--------------------------------------------------------------------------------
- * verify alignment options; threshold is zero default but alignment not
- *---------------------------------------------------------------------------------
- */
+ /*------------------------------------------------------------------------
+ * Verify alignment options; threshold is zero default but alignment not
+ *------------------------------------------------------------------------
+ */
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;
-}
+} /* end check_options() */
/*-------------------------------------------------------------------------
* Function: check_objects
*
- * Purpose: locate all HDF5 objects in the file and compare with user
- * supplied list
+ * Purpose: Locate all HDF5 objects in the file and compare with user-supplied
+ * list.
*
* Return: 0, ok, -1 no
*-------------------------------------------------------------------------
*/
-static int check_objects(const char* fname, pack_opt_t *options) {
- int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
- hid_t fid = -1;
- hid_t did = -1;
- hid_t sid = -1;
+static int
+check_objects(const char *fname, pack_opt_t *options)
+{
+ hid_t fid = H5I_INVALID_HID;
+ hid_t did = H5I_INVALID_HID;
+ hid_t sid = H5I_INVALID_HID;
unsigned int i;
- int ifil;
- trav_table_t *travt = NULL;
+ int ifil;
+ trav_table_t *travt = NULL;
+ 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),
+ NULL, 0)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fname, H5FOPENERROR);
/*-------------------------------------------------------------------------
* get the list of objects in the file
@@ -735,91 +800,94 @@ static int check_objects(const char* fname, pack_opt_t *options) {
/* Initialize indexing options */
h5trav_set_index(sort_by, sort_order);
/* init table */
- trav_table_init(&travt);
+ trav_table_init(fid, &travt);
/* 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
*-------------------------------------------------------------------------
*/
- if (options->verbose)
+ if (options->verbose > 0)
HDprintf("Opening file. Searching %zu objects to modify ...\n", travt->nobjs);
for (i = 0; i < options->op_tbl->nelems; i++) {
- char* name = options->op_tbl->objs[i].path;
- if (options->verbose)
+ pack_info_t obj = options->op_tbl->objs[i];
+ char * name = obj.path;
+
+ if (options->verbose > 0)
HDprintf(" <%s>", name);
/* 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",
- (options->verbose ? "\n" : ""), name, fname);
- if (options->verbose)
+ H5TOOLS_GOTO_ERROR((-1), "%s Could not find <%s> in file <%s>. Exiting...\n",
+ (options->verbose > 0 ? "\n" : ""), name, fname);
+ if (options->verbose > 0)
HDprintf("...Found\n");
- for (ifil = 0; ifil < options->op_tbl->objs[i].nfilters; ifil++) {
- if (options->op_tbl->objs[i].filter[ifil].filtn < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "invalid filter");
+ for (ifil = 0; ifil < obj.nfilters; ifil++) {
+ if (obj.filter[ifil].filtn < 0)
+ H5TOOLS_GOTO_ERROR((-1), "invalid filter");
/* check for extra filter conditions */
- switch (options->op_tbl->objs[i].filter[ifil].filtn) {
- /* chunk size must be smaller than pixels per block */
- case H5Z_FILTER_SZIP:
- {
- int j;
- hsize_t csize = 1;
- unsigned ppb = options->op_tbl->objs[i].filter[ifil].cd_values[0];
- hsize_t dims[H5S_MAX_RANK];
- int rank;
-
- if (options->op_tbl->objs[i].chunk.rank > 0) {
- rank = options->op_tbl->objs[i].chunk.rank;
+ switch (obj.filter[ifil].filtn) {
+ /* chunk size must be smaller than pixels per block */
+ case H5Z_FILTER_SZIP: {
+ int j;
+ hsize_t csize = 1;
+ unsigned ppb = obj.filter[ifil].cd_values[0];
+ hsize_t dims[H5S_MAX_RANK];
+ int rank;
+
+ if (obj.chunk.rank > 0) {
+ rank = obj.chunk.rank;
for (j = 0; j < rank; j++)
- csize *= options->op_tbl->objs[i].chunk.chunk_lengths[j];
+ csize *= obj.chunk.chunk_lengths[j];
}
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);
}
- }
- break;
- default:
+ } /* end case SZIP */
break;
- }
- } /* for ifil */
- } /* for i */
+ default:
+ break;
+ } /* end switch */
+ } /* for ifil (each user-defined filter) */
+ } /* for i (each object in options traversal table) */
done:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Sclose(sid);
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
if (travt)
trav_table_free(travt);
return ret_value;
-}
+} /* end check_objects() */
/*-------------------------------------------------------------------------
* Function: have_request
@@ -829,14 +897,15 @@ done:
* Return: 1 yes, 0 no
*-------------------------------------------------------------------------
*/
-static int have_request(pack_opt_t *options) {
+static int
+have_request(pack_opt_t *options)
+{
if (options->all_filter || options->all_layout || options->op_tbl->nelems)
return 1;
return 0;
-
-}
+} /* end have_request() */
/*-------------------------------------------------------------------------
* Function: get_sfilter
@@ -846,8 +915,9 @@ static int have_request(pack_opt_t *options) {
* Return: name of filter, exit on error
*-------------------------------------------------------------------------
*/
-
-static const char* get_sfilter(H5Z_filter_t filtn) {
+static const char *
+get_sfilter(H5Z_filter_t filtn)
+{
if (filtn < 0)
return NULL;
else if (filtn == H5Z_FILTER_NONE)
@@ -866,5 +936,4 @@ static const char* get_sfilter(H5Z_filter_t filtn) {
return "SOFF";
else
return "UD";
-}
-
+} /* end get_sfilter() */
diff --git a/tools/src/h5repack/h5repack.h b/tools/src/h5repack/h5repack.h
index a0e0387..65e5d40 100644
--- a/tools/src/h5repack/h5repack.h
+++ b/tools/src/h5repack/h5repack.h
@@ -6,34 +6,38 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-#ifndef H5REPACK_H__
-#define H5REPACK_H__
+#ifndef H5REPACK_H
+#define H5REPACK_H
#include "H5private.h"
#include "hdf5.h"
#include "h5trav.h"
-#define H5FOPENERROR "unable to open file"
-#define PFORMAT "%-7s %-7s %-7s\n" /* chunk info, compression info, name*/
-#define PFORMAT1 "%-7s %-7s %-7s" /* chunk info, compression info, name*/
-#define MAX_NC_NAME 256 /* max length of a name */
-#define MAX_VAR_DIMS 32 /* max per variable dimensions */
-#define FORMAT_OBJ " %-27s %s\n" /* obj type, name */
-#define FORMAT_OBJ_ATTR " %-27s %s\n" /* obj type, name */
-#define MAX_COMPACT_DSIZE 64512 /* max data size for compact layout. -1k for header size */
+#define H5FOPENERROR "unable to open file"
+#define PFORMAT "%-7s %-7s %-7s\n" /* chunk info, compression info, name*/
+#define PFORMAT1 "%-7s %-7s %-7s" /* chunk info, compression info, name*/
+#define MAX_NC_NAME 256 /* max length of a name */
+#define MAX_VAR_DIMS 32 /* max per variable dimensions */
+#define FORMAT_OBJ " %-27s %s\n" /* obj type, name */
+#define FORMAT_OBJ_ATTR " %-27s %s\n" /* obj type, name */
+#define MAX_COMPACT_DSIZE 64512 /* max data size for compact layout. -1k for header size */
+
+/* timing formats */
+#define FORMAT_OBJ_TIME " %-27s %e/%e %s\n" /* obj type, name */
+#define FORMAT_OBJ_ATTR_TIME " %-27s %e/%e %s\n" /* obj type, name */
+#define FORMAT_OBJ_NOTIME " %-27s %s\n" /* obj type, name */
+#define FORMAT_OBJ_ATTR_NOTIME " %-27s %s\n" /* obj type, name */
/* File space default information */
-#define FS_PAGESIZE_DEF 4096
-#define FS_STRATEGY_DEF H5F_FSPACE_STRATEGY_FSM_AGGR
-#define FS_PERSIST_DEF FALSE
-#define FS_THRESHOLD_DEF 1
-
+#define FS_PAGESIZE_DEF 4096
+#define FS_STRATEGY_DEF H5F_FSPACE_STRATEGY_FSM_AGGR
+#define FS_PERSIST_DEF FALSE
+#define FS_THRESHOLD_DEF 1
/*-------------------------------------------------------------------------
* data structures for command line options
@@ -42,7 +46,7 @@
/* a list of names */
typedef struct {
- char obj[MAX_NC_NAME];
+ char obj[MAX_NC_NAME];
} obj_list_t;
/*
@@ -60,16 +64,16 @@ typedef struct {
#define CD_VALUES 20
typedef struct {
- H5Z_filter_t filtn; /* filter identification number */
- unsigned filt_flag; /* filter definition flag */
- unsigned cd_values[CD_VALUES]; /* filter client data values */
- size_t cd_nelmts; /* filter client number of values */
+ H5Z_filter_t filtn; /* filter identification number */
+ unsigned filt_flag; /* filter definition flag */
+ unsigned cd_values[CD_VALUES]; /* filter client data values */
+ size_t cd_nelmts; /* filter client number of values */
} filter_info_t;
/* chunk lengths along each dimension and rank */
typedef struct {
- hsize_t chunk_lengths[MAX_VAR_DIMS];
- int rank;
+ hsize_t chunk_lengths[MAX_VAR_DIMS];
+ int rank;
} chunk_info_t;
/* we currently define a maximum value for the filters array,
@@ -78,22 +82,21 @@ typedef struct {
/* information for one object, contains PATH, CHUNK info and FILTER info */
typedef struct {
- char path[MAX_NC_NAME]; /* name of object */
- filter_info_t filter[H5_REPACK_MAX_NFILTERS]; /* filter array */
- int nfilters; /* current number of filters */
- H5D_layout_t layout; /* layout information */
- chunk_info_t chunk; /* chunk information */
- hid_t refobj_id; /* object ID, references */
+ char path[MAX_NC_NAME]; /* name of object */
+ filter_info_t filter[H5_REPACK_MAX_NFILTERS]; /* filter array */
+ int nfilters; /* current number of filters */
+ H5D_layout_t layout; /* layout information */
+ chunk_info_t chunk; /* chunk information */
+ hid_t refobj_id; /* object ID, references */
} pack_info_t;
/* store a table of all objects */
typedef struct {
- unsigned int size;
- unsigned int nelems;
- pack_info_t *objs;
+ unsigned int size;
+ unsigned int nelems;
+ pack_info_t *objs;
} pack_opttbl_t;
-
/*-------------------------------------------------------------------------
* command line options
*-------------------------------------------------------------------------
@@ -101,39 +104,42 @@ 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 */
- 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 */
- 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) */
- hsize_t threshold; /* alignment threshold for H5Pset_alignment */
- hsize_t alignment; /* alignment for H5Pset_alignment */
- H5F_fspace_strategy_t fs_strategy; /* File space handling strategy */
- int fs_persist; /* Free space section threshold */
- long fs_threshold; /* Free space section threshold */
- long long fs_pagesize; /* File space page size */
+ 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 */
+ 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 pipeline, 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) */
+ hsize_t threshold; /* alignment threshold for H5Pset_alignment */
+ hsize_t alignment; /* alignment for H5Pset_alignment */
+ H5F_fspace_strategy_t fs_strategy; /* File space handling strategy */
+ int fs_persist; /* Free space section threshold */
+ long fs_threshold; /* Free space section threshold */
+ long long fs_pagesize; /* File space page size */
} pack_opt_t;
-
typedef struct named_dt_t {
- haddr_t addr_in; /* Address of the named dtype in the in file */
- hid_t id_out; /* Open identifier for the dtype in the out file */
- struct named_dt_t *next; /* Next dtype */
+ H5O_token_t obj_token; /* Object token for the named dtype in the in file */
+ hid_t id_out; /* Open identifier for the dtype in the out file */
+ struct named_dt_t *next; /* Next dtype */
} named_dt_t;
/*-------------------------------------------------------------------------
@@ -145,13 +151,13 @@ typedef struct named_dt_t {
extern "C" {
#endif
-int h5repack(const char* infile, const char* outfile, pack_opt_t *options);
-int h5repack_addfilter(const char* str, pack_opt_t *options);
-int h5repack_addlayout(const char* str, pack_opt_t *options);
+int h5repack(const char *infile, const char *outfile, pack_opt_t *options);
+int h5repack_addfilter(const char *str, pack_opt_t *options);
+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
@@ -160,36 +166,29 @@ int h5repack_cmp_pl(const char *fname1, const char *fname2);
* However copy_attr() may be obsoleted when H5Acopy is available and put back
* others to static in h5repack_copy.c.
*/
-hid_t copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, trav_table_t *travt, pack_opt_t *options);
-int named_datatype_free(named_dt_t **named_dt_head_p, int ignore_err);
-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);
+hid_t copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, trav_table_t *travt,
+ pack_opt_t *options);
+int named_datatype_free(named_dt_t **named_dt_head_p, int ignore_err);
+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);
#ifdef __cplusplus
}
#endif
-
-
/*-------------------------------------------------------------------------
* private functions
*-------------------------------------------------------------------------
*/
-
/*-------------------------------------------------------------------------
* copy module
*-------------------------------------------------------------------------
*/
-int copy_objects (const char* fnamein,
- const char* fnameout,
- pack_opt_t *options);
+int copy_objects(const char *fnamein, const char *fnameout, pack_opt_t *options);
-int do_copy_refobjs(hid_t fidin,
- hid_t fidout,
- trav_table_t *travt,
- pack_opt_t *options);
+int do_copy_refobjs(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *options);
/*-------------------------------------------------------------------------
* filters and verify module
@@ -197,56 +196,38 @@ int do_copy_refobjs(hid_t fidin,
*/
void init_packobject(pack_info_t *obj);
-
/*-------------------------------------------------------------------------
* filters and copy module
*-------------------------------------------------------------------------
*/
-int apply_filters(const char* name, /* object name from traverse list */
- int rank, /* rank of dataset */
- hsize_t *dims, /* dimensions of dataset */
- size_t msize, /* size of type */
- hid_t dcpl_id, /* dataset creation property list */
- pack_opt_t *options, /* repack options */
- int *has_filter); /* (OUT) object NAME has a filter */
-
+int apply_filters(const char * name, /* object name from traverse list */
+ int rank, /* rank of dataset */
+ const hsize_t *dims, /* dimensions of dataset */
+ size_t msize, /* size of type */
+ hid_t dcpl_id, /* dataset creation property list */
+ pack_opt_t * options, /* repack options */
+ int * has_filter); /* (OUT) object NAME has a filter */
/*-------------------------------------------------------------------------
* options table
*-------------------------------------------------------------------------
*/
-int options_table_init(pack_opttbl_t **tbl);
-int options_table_free(pack_opttbl_t *table);
-int options_add_layout(obj_list_t *obj_list,
- unsigned n_objs,
- pack_info_t *pack,
- pack_opttbl_t *table);
-int options_add_filter(obj_list_t *obj_list,
- unsigned n_objs,
- filter_info_t filt,
- pack_opttbl_t *table);
-pack_info_t* options_get_object(const char *path,
- pack_opttbl_t *table);
+int options_table_init(pack_opttbl_t **tbl);
+int options_table_free(pack_opttbl_t *table);
+int options_add_layout(obj_list_t *obj_list, unsigned n_objs, pack_info_t *pack, pack_opttbl_t *table);
+int options_add_filter(obj_list_t *obj_list, unsigned n_objs, filter_info_t filt, pack_opttbl_t *table);
+pack_info_t *options_get_object(const char *path, pack_opttbl_t *table);
/*-------------------------------------------------------------------------
* parse functions
*-------------------------------------------------------------------------
*/
-obj_list_t* parse_filter(const char *str,
- unsigned *n_objs,
- filter_info_t *filt,
- pack_opt_t *options,
+obj_list_t *parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, pack_opt_t *options,
int *is_glb);
-obj_list_t* parse_layout(const char *str,
- unsigned *n_objs,
- pack_info_t *pack, /* info about object */
+obj_list_t *parse_layout(const char *str, unsigned *n_objs, pack_info_t *pack, /* info about object */
pack_opt_t *options);
-
-
-
-#endif /* H5REPACK_H__ */
-
+#endif /* H5REPACK_H */
diff --git a/tools/src/h5repack/h5repack_copy.c b/tools/src/h5repack/h5repack_copy.c
index 13adb7c..c38a431 100644
--- a/tools/src/h5repack/h5repack_copy.c
+++ b/tools/src/h5repack/h5repack_copy.c
@@ -6,7 +6,7 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -31,24 +31,22 @@
*/
/* size of buffer/# of bytes to xfer at a time when copying userblock */
-#define USERBLOCK_XFER_SIZE 512
+#define USERBLOCK_XFER_SIZE 512
/*-------------------------------------------------------------------------
* local functions
*-------------------------------------------------------------------------
*/
-static 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);
-static void print_dataset_info(hid_t dcpl_id, char *objname, double per, int pr);
-static int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
- pack_opt_t *options);
-static int copy_user_block(const char *infile, const char *outfile,
- hsize_t size);
-#if defined (H5REPACK_DEBUG_USER_BLOCK)
+static int get_hyperslab(hid_t dcpl_id, int rank_dset, const hsize_t dims_dset[], size_t size_datum,
+ hsize_t dims_hslab[], hsize_t *hslab_nbytes_p);
+static void print_dataset_info(hid_t dcpl_id, char *objname, double per, int pr, pack_opt_t *options,
+ double read_time, double write_time);
+static int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *options);
+static int copy_user_block(const char *infile, const char *outfile, hsize_t size);
+#if defined(H5REPACK_DEBUG_USER_BLOCK)
static void print_user_block(const char *filename, hid_t fid);
#endif
-
/*-------------------------------------------------------------------------
* Function: copy_objects
*
@@ -58,96 +56,100 @@ static void print_user_block(const char *filename, hid_t fid);
* -1 no
*-------------------------------------------------------------------------
*/
-
-int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
+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 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 */
- hbool_t set_persist; /* Persist free-space status to be set in output file */
- hsize_t set_threshold; /* Free-space section threshold to be set in output file */
- hsize_t set_pagesize; /* File space page size to be set in output file */
- H5F_fspace_strategy_t in_strategy; /* Strategy from input file */
- hbool_t in_persist; /* Persist free-space status from input file */
- 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 */
+ 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 */
+ 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 output file */
+ hbool_t set_persist; /* Persist free-space status to be set in output file */
+ hsize_t set_threshold; /* Free-space section threshold to be set in output file */
+ hsize_t set_pagesize; /* File space page size to be set in output file */
+ H5F_fspace_strategy_t in_strategy; /* Strategy from input file */
+ hbool_t in_persist; /* Persist free-space status from input file */
+ 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),
+ 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");
+ if (H5Pget_file_space_strategy(fcpl_in, &in_strategy, &in_persist, &in_threshold) < 0)
+ 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");
+ if (H5Pget_file_space_page_size(fcpl_in, &in_pagesize) < 0)
+ 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)
+ 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];
/* 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");
+ if (H5Pset_link_phase_change(fcpl, (unsigned)options->grp_compact,
+ (unsigned)options->grp_indexed) < 0)
+ 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) {
@@ -175,26 +177,28 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
default:
break;
} /* end switch */
- min_mesg_sizes[nindex] = (unsigned) options->msg_size[i];
+ min_mesg_sizes[nindex] = (unsigned)options->msg_size[i];
nindex++;
} /* end if */
- } /* end for */
+ } /* end for */
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 */
+ /* msg_size[0]=dataspace, 1=datatype, 2=file value, 3=filter pipeline, 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 */
- } /* end if */
-#if defined (H5REPACK_DEBUG_USER_BLOCK)
-print_user_block(fnamein, fidin);
+ } /* end if */
+#if defined(H5REPACK_DEBUG_USER_BLOCK)
+ print_user_block(fnamein, fidin);
#endif
/*-------------------------------------------------------------------------
@@ -206,11 +210,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");
}
/*-------------------------------------------------------------------------
@@ -219,13 +223,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");
}
/*-------------------------------------------------------------------------
@@ -234,13 +238,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");
}
/*-------------------------------------------------------------------------
@@ -252,62 +256,54 @@ 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");
+ if (H5Pset_link_creation_order(fcpl, crt_order_flags) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_link_creation_order failed");
/* Set file space info to those from input file */
- set_strategy = in_strategy;
- set_persist = in_persist;
+ set_strategy = in_strategy;
+ set_persist = in_persist;
set_threshold = in_threshold;
- set_pagesize = in_pagesize;
+ set_pagesize = in_pagesize;
- if(options->fs_strategy == (H5F_fspace_strategy_t)-1) /* A default strategy is specified by user */
+ if (options->fs_strategy == (H5F_fspace_strategy_t)-1) /* A default strategy is specified by user */
set_strategy = FS_STRATEGY_DEF;
- else if(options->fs_strategy != (H5F_fspace_strategy_t)0) /* Set strategy as specified by user */
+ else if (options->fs_strategy != (H5F_fspace_strategy_t)0) /* Set strategy as specified by user */
set_strategy = options->fs_strategy;
- if(options->fs_persist == -1) /* A default "persist" is specified by user */
+ if (options->fs_persist == -1) /* A default "persist" is specified by user */
set_persist = FS_PERSIST_DEF;
- else if(options->fs_persist != 0) /* Set "persist" as specified by user */
+ else if (options->fs_persist != 0) /* Set "persist" as specified by user */
set_persist = (hbool_t)options->fs_persist;
- if(options->fs_threshold == -1) /* A "0" threshold is specified by user */
+ if (options->fs_threshold == -1) /* A "0" threshold is specified by user */
set_threshold = (hsize_t)0;
- else if(options->fs_threshold != 0) /* Set threshold as specified by user */
+ else if (options->fs_threshold != 0) /* Set threshold as specified by user */
set_threshold = (hsize_t)options->fs_threshold;
/* 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");
+ if (H5Pset_file_space_strategy(fcpl, set_strategy, set_persist, set_threshold) < 0)
+ 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 */
+ if (options->fs_pagesize == -1) /* A "0" file space page size is specified by user */
set_pagesize = (hsize_t)0;
- else if(options->fs_pagesize != 0) /* Set file space page size as specified by user */
+ else if (options->fs_pagesize != 0) /* Set file space page size as specified by user */
set_pagesize = (hsize_t)options->fs_pagesize;
- 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");
+ 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)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_file_space_page_size failed to set file space page size");
/*-------------------------------------------------------------------------
* create the output file
*-------------------------------------------------------------------------
*/
- if (options->verbose)
+ if (options->verbose > 0)
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);
-
- /*-------------------------------------------------------------------------
- * write a new user block if requested
- *-------------------------------------------------------------------------
- */
- 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...");
+ if ((fidout = H5Fcreate(fnameout, H5F_ACC_TRUNC, fcpl, options->fout_fapl)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Fcreate could not create file <%s>:", fnameout);
/*-------------------------------------------------------------------------
* get list of objects
@@ -317,71 +313,107 @@ print_user_block(fnamein, fidin);
/* Initialize indexing options */
h5trav_set_index(sort_by, sort_order);
/* init table */
- trav_table_init(&travt);
+ trav_table_init(fidin, &travt);
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
- *-------------------------------------------------------------------------
- */
+ * 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
- * and create hard links
- *-------------------------------------------------------------------------
- */
+ * do the copy of referenced objects
+ * and create hard links
+ *-------------------------------------------------------------------------
+ */
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);
}
/*-------------------------------------------------------------------------
- * write only the input file user block if there is no user block file input
+ * Close the file and everything in it so the lock is removed
*-------------------------------------------------------------------------
*/
+ if (H5Pclose(fcpl) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "could not close fcpl");
+ if (H5Pclose(options->fout_fapl) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "could not close fcpl");
+ options->fout_fapl = H5P_DEFAULT;
+ if (H5Pclose(gcpl_in) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "could not close fcpl");
+ if (H5Gclose(grp_in) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "could not close fcpl");
+ if (H5Fclose(fidout) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "could not close fcpl");
+ if (H5Fclose(fidin) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "could not close fcpl");
- if (ub_size > 0 && options->ublock_size == 0)
+ /*-------------------------------------------------------------------------
+ * NOTE: The userblock MUST be written out AFTER the file is closed or
+ * the file locking will cause failures on Windows, where file locks
+ * are mandatory, not advisory.
+ *-------------------------------------------------------------------------
+ */
+
+ /*-------------------------------------------------------------------------
+ * Write a new user block if requested, using the input file user block if
+ * there is no separate user block file input
+ *-------------------------------------------------------------------------
+ */
+
+ if (options->ublock_size > 0) {
+ if (copy_user_block(options->ublock_filename, fnameout, options->ublock_size) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "Could not copy user block. Exiting...");
+ }
+ else 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);
- H5Fclose(fidout);
- H5Fclose(fidin);
- H5Fclose(fidout);
- } H5E_END_TRY;
+ if (-1 == ret_value) {
+ H5E_BEGIN_TRY
+ {
+ H5Pclose(fcpl);
+ H5Pclose(options->fout_fapl);
+ options->fout_fapl = H5P_DEFAULT;
+ H5Pclose(gcpl_in);
+ H5Gclose(grp_in);
+ H5Pclose(fcpl_in);
+ H5Fclose(fidout);
+ H5Fclose(fidin);
+ }
+ H5E_END_TRY;
+ }
if (travt)
trav_table_free(travt);
return ret_value;
-}
+} /* end copy_objects() */
/*-------------------------------------------------------------------------
- * Function: Get_hyperslab
+ * Function: get_hyperslab
*
- * Purpose: Calulate a hyperslab from a dataset for higher performance.
- * The size of hyperslab is limitted by H5TOOLS_BUFSIZE.
- * Return the hyperslab dimentions and size in byte.
+ * Purpose: Calculate a hyperslab from a dataset for higher performance.
+ * The size of hyperslab is limited by H5TOOLS_BUFSIZE.
+ * Return the hyperslab dimensions and size in byte.
*
* Return: 0 - SUCCEED, -1 FAILED
*
* Parameters:
* dcpl_id : [IN] dataset creation property.
* rank_dset : [IN] dataset rank
- * dims_dset[] : [IN] dataset dimentions
+ * dims_dset[] : [IN] dataset dimensions
* size_datum : [IN] size of a data element in byte
- * dims_hslab[] : [OUT] calculated hyperslab dimentions
+ * dims_hslab[] : [OUT] calculated hyperslab dimensions
* * hslab_nbytes_p : [OUT] total byte of the hyperslab
*
* Update:
@@ -396,24 +428,24 @@ done:
* 3. If not chunked, each data element would be a unit of collection and
* the boundary would be dataset's dims.
*
- * The calulation starts from the last dimention (h5dump dims output).
+ * The calculation starts from the last dimension (h5dump dims output).
*-----------------------------------------*/
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)
+get_hyperslab(hid_t dcpl_id, int rank_dset, const hsize_t dims_dset[], size_t size_datum,
+ hsize_t dims_hslab[], hsize_t *hslab_nbytes_p)
{
- int ret_value = 0;
- int k;
+ int k;
H5D_layout_t dset_layout;
- int rank_chunk;
- hsize_t dims_chunk[H5S_MAX_RANK];
- hsize_t size_chunk = 1;
- hsize_t nchunk_fit; /* number of chunks that fits in hyperslab buffer (H5TOOLS_BUFSIZE) */
- hsize_t ndatum_fit; /* number of dataum that fits in hyperslab buffer (H5TOOLS_BUFSIZE) */
- 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 rank_chunk;
+ hsize_t dims_chunk[H5S_MAX_RANK];
+ hsize_t size_chunk = 1;
+ hsize_t nchunk_fit; /* number of chunks that fits in hyperslab buffer (H5TOOLS_BUFSIZE) */
+ hsize_t ndatum_fit; /* number of dataum that fits in hyperslab buffer (H5TOOLS_BUFSIZE) */
+ hsize_t chunk_dims_map[H5S_MAX_RANK]; /* mapped chunk dimensions */
+ hsize_t hs_dims_map[H5S_MAX_RANK]; /* mapped hyperslab dimensions */
+ 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;
@@ -426,7 +458,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];
@@ -436,23 +468,23 @@ Get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[],
/* 1. if a chunk fit in hyperslab buffer */
if (nchunk_fit >= 1) {
- /* Calulate a hyperslab that contains as many chunks that can fit
+ /* Calculate a hyperslab that contains as many chunks that can fit
* in hyperslab buffer. Hyperslab will be increased starting from
- * the last dimention of the dataset (see h5dump's dims output).
+ * the last dimension of the dataset (see h5dump's dims output).
* The calculation boundary is dataset dims.
* In the loop, used mapping from a datum to a chunk to figure out
* chunk based hyperslab.
*/
for (k = rank_dset; k > 0; --k) {
- /* map dataset dimentions with a chunk dims */
+ /* map dataset dimensions with a chunk dims */
chunk_dims_map[k - 1] = dims_dset[k - 1] / dims_chunk[k - 1];
- /* if reminder exist, increse by 1 to cover partial edge chunks */
+ /* if reminder exist, increase by 1 to cover partial edge chunks */
if (dims_dset[k - 1] % dims_chunk[k - 1] > 0)
chunk_dims_map[k - 1]++;
/* get mapped hyperslab dims */
- hs_dims_map[k - 1] = MIN (nchunk_fit, chunk_dims_map[k-1]);
+ hs_dims_map[k - 1] = MIN(nchunk_fit, chunk_dims_map[k - 1]);
/* prepare next round */
nchunk_fit = nchunk_fit / chunk_dims_map[k - 1];
@@ -460,8 +492,8 @@ Get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[],
if (nchunk_fit == 0)
nchunk_fit = 1;
- /* get hyperslab dimentions as unmapping to actual size */
- dims_hslab[k - 1] = MIN( (hs_dims_map[k-1] * dims_chunk[k-1]), dims_dset[k-1]);
+ /* get hyperslab dimensions as unmapping to actual size */
+ dims_hslab[k - 1] = MIN((hs_dims_map[k - 1] * dims_chunk[k - 1]), dims_dset[k - 1]);
/* calculate total size for the hyperslab */
hslab_nbytes *= dims_hslab[k - 1];
@@ -469,9 +501,9 @@ Get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[],
}
/* 2. if a chunk is bigger than hyperslab buffer */
else {
- /* Calulate a hyperslab that contains as many data elements that
+ /* Calculate a hyperslab that contains as many data elements that
* can fit in hyperslab buffer. Hyperslab will be increased
- * starting from the last dimention of the chunk (see h5dump's dims
+ * starting from the last dimension of the chunk (see h5dump's dims
* output).
* The calculation boundary is a chunk dims.
*/
@@ -481,22 +513,22 @@ Get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[],
/* if a datum is bigger than rest of buffer */
if (ndatum_fit == 0)
ndatum_fit = 1;
- /* get hyperslab dimentions within a chunk boundary */
- dims_hslab[k - 1] = MIN (dims_chunk[k-1], ndatum_fit);
+ /* get hyperslab dimensions within a chunk boundary */
+ dims_hslab[k - 1] = MIN(dims_chunk[k - 1], ndatum_fit);
/* calculate total size for the hyperslab */
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");
}
}
}
/* 3. if dataset is not chunked */
else {
- /* Calulate a hyperslab that contains as many data elements that can
+ /* Calculate a hyperslab that contains as many data elements that can
* fit in hyperslab buffer. Hyperslab will be increased starting from
- * the last dimention of the dataset (see h5dump's dims output).
+ * the last dimension of the dataset (see h5dump's dims output).
* The calculation boundary is dataset dims.
*/
for (k = rank_dset; k > 0; --k) {
@@ -505,14 +537,14 @@ Get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[],
/* if a datum is bigger than rest of buffer */
if (ndatum_fit == 0)
ndatum_fit = 1;
- /* get hyperslab dimentions within dataset boundary */
+ /* get hyperslab dimensions within dataset boundary */
dims_hslab[k - 1] = MIN(dims_dset[k - 1], ndatum_fit);
/* calculate total size for the hyperslab */
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");
}
}
@@ -521,7 +553,7 @@ Get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[],
done:
return ret_value;
-}
+} /* end get_hyperslab() */
/*-------------------------------------------------------------------------
* Function: do_copy_objects
@@ -569,7 +601,7 @@ done:
* in (2) is that, when using the strip mine size, it assures that the "remaining" part
* of the dataset that does not fill an entire strip mine is processed.
*
- * 1. figure out a hyperslab (dimentions) and size (refer to Get_hyperslab()).
+ * 1. figure out a hyperslab (dimensions) and size (refer to get_hyperslab()).
* 2. Calculate the hyperslab selections as the selection is moving forward.
* Selection would be same as the hyperslab except for the remaining edge portion
* of the dataset. The code take care of the remaining portion if exist.
@@ -577,53 +609,69 @@ done:
*-------------------------------------------------------------------------
*/
-int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
- pack_opt_t *options) /* repack options */
+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 */
- named_dt_t *named_dt_head = NULL; /* Pointer to the stack of named datatypes copied */
- size_t msize; /* size of type */
- hsize_t nelmts; /* number of elements in dataset */
- H5D_space_status_t space_status; /* determines whether space has been allocated for the dataset */
- int rank; /* rank of dataset */
- hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */
- hsize_t dsize_in; /* input dataset size before filter */
- hsize_t dsize_out; /* output dataset size after filter */
- int apply_s; /* flag for apply filter to small dataset sizes */
- int apply_f; /* flag for apply filter to return error on H5Dcreate */
- void *buf = NULL; /* buffer for raw data */
- void *hslab_buf = NULL; /* hyperslab buffer for raw data */
- int has_filter; /* current object has a filter */
- 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 */
- unsigned i;
- unsigned u;
- int ifil;
- int is_ref = 0;
- htri_t is_named;
- hbool_t limit_maxdims;
- hsize_t size_dset;
+ 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 */
+ hid_t dxpl_id = H5I_INVALID_HID; /* dataset transfer 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 */
+ H5D_space_status_t space_status; /* determines whether space has been allocated for the dataset */
+ int rank; /* rank of dataset */
+ hsize_t dims[H5S_MAX_RANK]; /* dimensions of dataset */
+ hsize_t dsize_in; /* input dataset size before filter */
+ hsize_t dsize_out; /* output dataset size after filter */
+ int apply_s; /* flag for apply filter to small dataset sizes */
+ int apply_f; /* flag for apply filter to return error on H5Dcreate */
+ void * buf = NULL; /* buffer for raw data */
+ void * hslab_buf = NULL; /* hyperslab buffer for raw data */
+ int has_filter; /* current object has a filter */
+ 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 */
+ H5_timer_t timer; /* Timer for read/write operations */
+ H5_timevals_t times; /* Elapsed time for each operation */
+ static double read_time = 0;
+ static double write_time = 0;
+ h5tool_link_info_t linkinfo;
+ unsigned i;
+ unsigned u;
+ int ifil;
+ int is_ref = 0;
+ 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
*-------------------------------------------------------------------------
*/
- if (options->verbose) {
+ if (options->verbose == 2) {
+ HDprintf("-----------------------------------------------------------------\n");
+ HDprintf(" Type Filter (Compression) Timing read/write Name\n");
+ HDprintf("-----------------------------------------------------------------\n");
+ }
+ else {
HDprintf("-----------------------------------------\n");
HDprintf(" Type Filter (Compression) Name\n");
HDprintf("-----------------------------------------\n");
@@ -632,565 +680,758 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
if (travt->objs) {
for (i = 0; i < travt->nobjs; i++) {
/* init variables per obj */
- buf = NULL;
+ buf = NULL;
limit_maxdims = FALSE;
switch (travt->objs[i].type) {
- case H5TRAV_TYPE_UNKNOWN:
- break;
+ case H5TRAV_TYPE_UNKNOWN:
+ break;
- /*-------------------------------------------------------------------------
- * H5TRAV_TYPE_GROUP
- *-------------------------------------------------------------------------
- */
- case H5TRAV_TYPE_GROUP:
- if (options->verbose)
- HDprintf(FORMAT_OBJ, "group", travt->objs[i].name);
+ /*-------------------------------------------------------------------------
+ * H5TRAV_TYPE_GROUP
+ *-------------------------------------------------------------------------
+ */
+ case H5TRAV_TYPE_GROUP:
+ if (options->verbose == 2)
+ HDprintf(FORMAT_OBJ_NOTIME, "group", travt->objs[i].name);
+ else
+ HDprintf(FORMAT_OBJ, "group", travt->objs[i].name);
- /* 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");
+ /* open input group */
+ if ((grp_in = H5Gopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
+ 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");
+ /* get input group creation property list */
+ if ((gcpl_in = H5Gget_create_plist(grp_in)) < 0)
+ 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");
+ /* query and set the group creation properties */
+ if (H5Pget_link_creation_order(gcpl_in, &crt_order_flags) < 0)
+ 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");
+ /* set up group creation property list */
+ if ((gcpl_out = H5Pcreate(H5P_GROUP_CREATE)) < 0)
+ 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");
+ if (H5Pset_link_creation_order(gcpl_out, crt_order_flags) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_link_creation_order failed");
- /*-------------------------------------------------------------------------
- * the root is a special case, we get an ID for the root group
- * and copy its attributes using that ID
- *-------------------------------------------------------------------------
- */
- 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");
- }
- 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");
+ /*-------------------------------------------------------------------------
+ * the root is a special case, we get an ID for the root group
+ * and copy its attributes using that ID
+ *-------------------------------------------------------------------------
+ */
+ if (HDstrcmp(travt->objs[i].name, "/") == 0) {
+ if ((grp_out = H5Gopen2(fidout, "/", H5P_DEFAULT)) < 0)
+ 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)
+ 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)
+ H5TOOLS_GOTO_ERROR((-1), "H5Gcreate2 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");
- }
+ /*-------------------------------------------------------------------------
+ * copy attrs
+ *-------------------------------------------------------------------------
+ */
+ if (copy_attr(grp_in, grp_out, &named_dt_head, travt, options) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "copy_attr failed");
- /*-------------------------------------------------------------------------
- * copy attrs
- *-------------------------------------------------------------------------
- */
- if (copy_attr(grp_in, grp_out, &named_dt_head, travt, options) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_attr failed");
-
- if (H5Pclose(gcpl_out) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
- if (H5Pclose(gcpl_in) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
- if (H5Gclose(grp_out) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed");
- if (H5Gclose(grp_in) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed");
+ if (H5Pclose(gcpl_out) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
+ if (H5Pclose(gcpl_in) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
+ if (H5Gclose(grp_out) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Gclose failed");
+ if (H5Gclose(grp_in) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Gclose failed");
- break;
+ break;
/*-------------------------------------------------------------------------
* H5TRAV_TYPE_DATASET
*-------------------------------------------------------------------------
*/
- case H5TRAV_TYPE_DATASET:
- has_filter = 0;
- req_filter = 0;
-
- /* check if global filters were requested */
- if (options->n_filter_g)
- req_filter = 1;
-
- /* check if filters were requested for individual objects */
- if (options->op_tbl->objs) {
- for (u = 0; u < options->op_tbl->nelems; u++) {
- if (HDstrcmp(travt->objs[i].name, options->op_tbl->objs[u].path) == 0)
- for (ifil = 0; ifil < options->op_tbl->objs[ifil].nfilters; ifil++) {
- if (options->op_tbl->objs[u].filter[ifil].filtn > 0)
- req_filter = 1;
- }
+ case H5TRAV_TYPE_DATASET: {
+ hbool_t use_h5ocopy;
+
+ read_time = 0.0;
+ write_time = 0.0;
+
+ has_filter = 0;
+ req_filter = 0;
+
+ /* check if global filters were requested */
+ if (options->n_filter_g)
+ req_filter = 1;
+
+ /* check if filters were requested for individual objects */
+ if (options->op_tbl->objs) {
+ for (u = 0; u < options->op_tbl->nelems; u++) {
+ if (HDstrcmp(travt->objs[i].name, options->op_tbl->objs[u].path) == 0)
+ for (ifil = 0; ifil < options->op_tbl->objs[ifil].nfilters; ifil++) {
+ if (options->op_tbl->objs[u].filter[ifil].filtn > 0)
+ req_filter = 1;
+ }
+ }
}
- }
- /* check if layout change requested individual object */
- if (options->layout_g != H5D_LAYOUT_ERROR) {
- pack_info_t *pckinfo;
-
- /* any dataset is specified */
- if (options->op_tbl->nelems > 0) {
- /* check if object exist */
- pckinfo = options_get_object(travt->objs[i].name, options->op_tbl);
- if (pckinfo)
- req_obj_layout = 1;
+ /* check if layout change requested individual object */
+ if (options->layout_g != H5D_LAYOUT_ERROR) {
+ pack_info_t *pckinfo;
+
+ /* any dataset is specified */
+ if (options->op_tbl->nelems > 0) {
+ /* check if object exist */
+ pckinfo = options_get_object(travt->objs[i].name, options->op_tbl);
+ if (pckinfo)
+ req_obj_layout = 1;
+ }
}
- }
-
- /* 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");
- if ((ftype_id = H5Dget_type(dset_in)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "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");
- 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");
-
- if (H5Tclose(ftype_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
- if (H5Dclose(dset_in) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
-
- /*-------------------------------------------------------------------------
- * check if we should use H5Ocopy or not
- * if there is a request for filters/layout, we read/write the object
- * otherwise we do a copy using H5Ocopy
- *-------------------------------------------------------------------------
- */
- if (options->op_tbl->nelems || options->all_filter == 1
- || options->all_layout == 1 || is_ref || is_named) {
-
- int j;
+ /* 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");
- if ((f_space_id = H5Dget_space(dset_in)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space 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");
- if ((dcpl_in = H5Dget_create_plist(dset_in)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed");
- if ((dcpl_out = H5Pcopy(dcpl_in)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcopy failed");
- if ((rank = H5Sget_simple_extent_ndims(f_space_id)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "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");
- if (H5Dget_space_status(dset_in, &space_status) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space_status failed");
-
- nelmts = 1;
- for (j = 0; j < rank; j++)
- nelmts *= dims[j];
-
- /* wtype_id will have already been set if using a named dtype */
- if (!is_named) {
- if (options->use_native == 1)
- wtype_id = H5Tget_native_type(ftype_id, H5T_DIR_DEFAULT);
- else
- wtype_id = H5Tcopy(ftype_id);
- } /* end if */
-
- if ((msize = H5Tget_size(wtype_id)) == 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size 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)
+ H5TOOLS_GOTO_ERROR((-1), "H5Tcommitted failed");
+ if (is_named)
+ if ((wtype_id =
+ copy_named_datatype(ftype_id, fidout, &named_dt_head, travt, options)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "copy_named_datatype failed");
- /* size of current dset */
- size_dset = nelmts * msize;
+ if (H5Tclose(ftype_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
+ if (H5Dclose(dset_in) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed");
/*-------------------------------------------------------------------------
- * check if the dataset creation property list has filters that
- * are not registered in the current configuration
- * 1) the external filters GZIP and SZIP might not be available
- * 2) the internal filters might be turned off
+ * check if we should use H5Ocopy or not
+ * if there is a request for filters/layout, we read/write the object
+ * otherwise we do a copy using H5Ocopy
*-------------------------------------------------------------------------
*/
- if (h5tools_canreadf((travt->objs[i].name), dcpl_in) == 1) {
- apply_s = 1;
- apply_f = 1;
+ use_h5ocopy = !(options->op_tbl->nelems || options->all_filter == 1 ||
+ options->all_layout == 1 || is_ref || is_named);
+
+ /*
+ * Check if we are using different source and destination VOL connectors.
+ * In this case, we currently have to avoid usage of H5Ocopy since it
+ * doesn't support this.
+ */
+ if (use_h5ocopy &&
+ (options->fin_fapl != H5P_DEFAULT || options->fout_fapl != H5P_DEFAULT)) {
+ hid_t in_vol_id;
+ hid_t out_vol_id;
+ hid_t default_vol_id;
+
+ if (H5Pget_vol_id(H5P_FILE_ACCESS_DEFAULT, &default_vol_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pget_vol_id failed");
+
+ if (options->fin_fapl == H5P_DEFAULT)
+ in_vol_id = default_vol_id;
+ else if (H5Pget_vol_id(options->fin_fapl, &in_vol_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pget_vol_id failed");
+ if (options->fout_fapl == H5P_DEFAULT)
+ out_vol_id = default_vol_id;
+ else if (H5Pget_vol_id(options->fout_fapl, &out_vol_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pget_vol_id failed");
+
+ if (in_vol_id != out_vol_id)
+ use_h5ocopy = FALSE;
+
+ if (in_vol_id != default_vol_id)
+ if (H5VLclose(in_vol_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5VLclose failed");
+ if (out_vol_id != default_vol_id)
+ if (H5VLclose(out_vol_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5VLclose failed");
+ if (H5VLclose(default_vol_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5VLclose failed");
+ }
+
+ if (!use_h5ocopy) {
+ int j;
+
+ if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed");
+ if ((f_space_id = H5Dget_space(dset_in)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed");
+ if ((ftype_id = H5Dget_type(dset_in)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_type failed");
+ if ((dcpl_in = H5Dget_create_plist(dset_in)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed");
+ if ((rank = H5Sget_simple_extent_ndims(f_space_id)) < 0)
+ 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)
+ H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_dims failed");
+ if (H5Dget_space_status(dset_in, &space_status) < 0)
+ 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,
+ * so create a new DCPL.
+ * Otherwise, copy dcpl_in.
+ */
+ if (H5Pget_external_count(dcpl_in)) {
+ if ((dcpl_out = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed");
+ }
+ else if ((dcpl_out = H5Pcopy(dcpl_in)) < 0) {
+ H5TOOLS_GOTO_ERROR((-1), "H5Pcopy failed");
+ }
+
+ nelmts = 1;
+ for (j = 0; j < rank; j++)
+ nelmts *= dims[j];
+
+ /* wtype_id will have already been set if using a named dtype */
+ if (!is_named) {
+ if (options->use_native == 1)
+ wtype_id = H5Tget_native_type(ftype_id, H5T_DIR_DEFAULT);
+ else
+ wtype_id = H5Tcopy(ftype_id);
+ }
+
+ if ((msize = H5Tget_size(wtype_id)) == 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Tget_size failed");
+
+ /* size of current dset */
+ size_dset = nelmts * msize;
/*-------------------------------------------------------------------------
- * references are a special case
- * we cannot just copy the buffers, but instead we recreate the reference
- * in a second traversal of the output file
+ * check if the dataset creation property list has filters that
+ * are not registered in the current configuration
+ * 1) the external filters GZIP and SZIP might not be available
+ * 2) the internal filters might be turned off
*-------------------------------------------------------------------------
*/
- if (H5T_REFERENCE != H5Tget_class(wtype_id)) {
- /* get the storage size of the input dataset */
- dsize_in = H5Dget_storage_size(dset_in);
-
- /* check for small size datasets (less than 1k) except
- * changing to COMPACT. For the reference, COMPACT is limited
- * by size 64K by library.
- */
- if (options->layout_g != H5D_COMPACT)
- if (size_dset < options->min_comp)
- apply_s = 0;
-
- /* 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");
-
- /* only if layout change requested for entire file or
- * individual obj */
- if (options->all_layout > 0 || req_obj_layout == 1)
- /*-------------------------------------------------
- * Unset the unlimited max dims if convert to other
- * than chunk layouts, because unlimited max dims
- * only can be applied to chunk layout.
- * Also perform only for targeted dataset
- * Also check for size limit to convert to compact
- *-------------------------------------------------*/
- if (options->layout_g != H5D_CHUNKED) {
- /* any dataset is specified */
- if (options->op_tbl->nelems > 0) {
- /* if current obj match specified obj */
- if (options_get_object(travt->objs[i].name, options->op_tbl))
- limit_maxdims = TRUE;
- }
- else /* no dataset is specified */
- limit_maxdims = TRUE;
-
- /* if convert to COMPACT */
- if (options->layout_g == H5D_COMPACT)
- /* should be smaller than 64K */
- if (size_dset > MAX_COMPACT_DSIZE)
- limit_maxdims = FALSE;
-
- /* unset unlimited max dims */
- if (limit_maxdims)
- H5Sset_extent_simple(f_space_id, rank, dims, NULL);
- }
+ if (h5tools_canreadf((travt->objs[i].name), dcpl_in) == 1) {
+ apply_s = 1;
+ apply_f = 1;
/*-------------------------------------------------------------------------
- * create the output dataset;
- * disable error checking in case the dataset cannot be created with the
- * modified dcpl; in that case use the original instead
+ * references are a special case
+ * we cannot just copy the buffers, but instead we recreate the reference
+ * in a second traversal of the output file
*-------------------------------------------------------------------------
*/
- 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 (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");
- apply_f = 0;
- }
+ if (H5T_REFERENCE != H5Tget_class(wtype_id)) {
+ /* get the storage size of the input dataset */
+ dsize_in = H5Dget_storage_size(dset_in);
- /*-------------------------------------------------------------------------
- * read/write
- *-------------------------------------------------------------------------
- */
- if (nelmts > 0 && space_status != H5D_SPACE_STATUS_NOT_ALLOCATED) {
- size_t need = (size_t)(nelmts * msize); /* bytes needed */
-
- /* have to read the whole dataset if there is only one element in the dataset */
- if (need < H5TOOLS_MALLOCSIZE)
- buf = HDmalloc(need);
-
- 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");
- if(H5Dwrite(dset_out, wtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "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");
- /* free */
- if (buf != NULL) {
- HDfree(buf);
- buf = NULL;
- }
- }
- else { /* possibly not enough memory, read/write by hyperslabs */
- size_t p_type_nbytes = msize; /*size of memory type */
- hsize_t p_nelmts = nelmts; /*total elements */
- hsize_t elmtno; /*counter */
- int carry; /*counter carry value */
- unsigned int vl_data = 0; /*contains VL datatypes */
-
- /* hyperslab info */
- hsize_t hslab_dims[H5S_MAX_RANK]; /*hyperslab dims */
- hsize_t hslab_nbytes; /*bytes per hyperslab */
- hsize_t hslab_nelmts; /*elements per hyperslab*/
- hid_t hslab_space; /*hyperslab data space */
-
- /* hyperslab selection info */
- hsize_t hs_sel_offset[H5S_MAX_RANK];/* selection offset */
- hsize_t hs_sel_count[H5S_MAX_RANK]; /* selection count */
- hsize_t hs_select_nelmts; /* selected elements */
- hsize_t zero[8]; /*vector of zeros */
- int k;
- H5D_layout_t dset_layout;
- hid_t dcpl_tmp = -1; /* dataset creation property list ID */
-
- /* check if we have VL data in the dataset's datatype */
- if (H5Tdetect_class(wtype_id, H5T_VLEN) == TRUE)
- vl_data = TRUE;
-
- /* check first if writing dataset is chunked,
- * if so use its chunk layout for better performance. */
- dset_layout = H5Pget_layout(dcpl_out);
- if (dset_layout == H5D_CHUNKED)
- dcpl_tmp = dcpl_out; /* writing dataset */
- else { /* if reading dataset is chunked */
- dset_layout = H5Pget_layout(dcpl_in);
- if (dset_layout == H5D_CHUNKED)
- dcpl_tmp = dcpl_in; /* reading dataset */
+ /* check for small size datasets (less than 1k) except
+ * changing to COMPACT. For the reference, COMPACT is limited
+ * by size 64K by library.
+ */
+ if (options->layout_g != H5D_COMPACT)
+ if (size_dset < options->min_comp)
+ apply_s = 0;
+
+ /* apply the filter */
+ if (apply_s)
+ if (apply_filters(travt->objs[i].name, rank, dims, msize, dcpl_out,
+ options, &has_filter) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "apply_filters failed");
+
+ /* only if layout change requested for entire file or
+ * individual obj */
+ if (options->all_layout > 0 || req_obj_layout == 1) {
+ /*-------------------------------------------------
+ * Unset the unlimited max dims if convert to other
+ * than chunk layouts, because unlimited max dims
+ * only can be applied to chunk layout.
+ * Also perform only for targeted dataset
+ * Also check for size limit to convert to compact
+ *-------------------------------------------------*/
+ if (options->layout_g != H5D_CHUNKED) {
+ /* any dataset is specified */
+ if (options->op_tbl->nelems > 0) {
+ /* if current obj match specified obj */
+ if (options_get_object(travt->objs[i].name, options->op_tbl))
+ limit_maxdims = TRUE;
+ }
+ else /* no dataset is specified */
+ limit_maxdims = TRUE;
+
+ /* if convert to COMPACT */
+ if (options->layout_g == H5D_COMPACT)
+ if (size_dset > MAX_COMPACT_DSIZE)
+ limit_maxdims = FALSE;
+
+ /* unset unlimited max dims */
+ if (limit_maxdims)
+ H5Sset_extent_simple(f_space_id, rank, dims, NULL);
+ } /* end if not chunked */
+ } /* end if layout change requested for entire file or individual object */
+
+ /*-------------------------------------------------------------------------
+ * create the output dataset;
+ * disable error checking in case the dataset cannot be created with the
+ * modified dcpl; in that case use the original instead
+ *-------------------------------------------------------------------------
+ */
+ dset_out = H5Dcreate2(fidout, travt->objs[i].name, wtype_id, f_space_id,
+ H5P_DEFAULT, dcpl_out, H5P_DEFAULT);
+ if (dset_out == H5I_INVALID_HID) {
+ H5TOOLS_INFO("H5Dcreate2 failed");
+ if (options->verbose > 0)
+ 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)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dcreate2 failed");
+ apply_f = 0;
+ } /* end if retry dataset create */
+
+ /*-------------------------------------------------------------------------
+ * read/write
+ *-------------------------------------------------------------------------
+ */
+ if (nelmts > 0 && space_status != H5D_SPACE_STATUS_NOT_ALLOCATED) {
+ size_t need = (size_t)(nelmts * msize); /* bytes needed */
+
+ /* have to read the whole dataset if there is only one element in the
+ * dataset */
+ if (need < H5TOOLS_MALLOCSIZE)
+ buf = HDmalloc(need);
+
+ /* Set up collective write if using filters in parallel */
+ {
+#ifdef H5_HAVE_PARALLEL
+ hbool_t parallel = (H5FD_MPIO == H5Pget_driver(options->fout_fapl));
+
+ if (parallel && apply_s && apply_f) {
+ if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed");
+ if (H5Pset_dxpl_mpio(dxpl_id, H5FD_MPIO_COLLECTIVE) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_dxpl_mpio failed");
+ }
+ else
+#endif
+ dxpl_id = H5P_DEFAULT;
}
- /* 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");
-
- hslab_buf = HDmalloc((size_t)hslab_nbytes);
-
- hslab_nelmts = hslab_nbytes / p_type_nbytes;
- hslab_space = H5Screate_simple(1, &hslab_nelmts, NULL);
-
- /* the hyperslab selection loop */
- HDmemset(hs_sel_offset, 0, sizeof hs_sel_offset);
- HDmemset(zero, 0, sizeof zero);
-
- for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_select_nelmts) {
- if (rank > 0) {
- /* calculate the hyperslab selections.
- * The selection would be same as the hyperslab
- * except for remaining edge portion of the dataset
- * which is smaller then the hyperslab.
- */
- for (k = 0, hs_select_nelmts = 1; k < rank; k++) {
- /* MIN() is used to get the remaining edge portion if exist.
- * "dims[k] - hs_sel_offset[k]" is remaining edge portion that is smaller then the hyperslab.*/
- hs_sel_count[k] = MIN(dims[k] - hs_sel_offset[k], hslab_dims[k]);
- hs_select_nelmts *= hs_sel_count[k];
- }
+ if (buf != NULL) {
+ if (options->verbose == 2) {
+ H5_timer_init(&timer);
+ H5_timer_start(&timer);
+ }
+ if (H5Dread(dset_in, wtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) <
+ 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dread failed");
+ if (options->verbose == 2) {
+ H5_timer_stop(&timer);
+ H5_timer_get_times(timer, &times);
+ read_time += times.elapsed;
+ H5_timer_init(&timer);
+ H5_timer_start(&timer);
+ }
+ if (H5Dwrite(dset_out, wtype_id, H5S_ALL, H5S_ALL, dxpl_id, buf) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dwrite failed");
+ if (options->verbose == 2) {
+ H5_timer_stop(&timer);
+ H5_timer_get_times(timer, &times);
+ write_time += times.elapsed;
+ }
+
+ /* Check if we have VL data in the dataset's
+ * datatype that must be reclaimed */
+ if (TRUE == H5Tdetect_class(wtype_id, H5T_VLEN))
+ if (H5Treclaim(wtype_id, f_space_id, H5P_DEFAULT, buf) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Treclaim failed");
- 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");
- 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");
+ if (buf != NULL) { /* TODO: is buf potentially released by
+ H5Dvlen_reclaim()? */
+ HDfree(buf);
+ buf = NULL;
}
- else {
- H5Sselect_all(f_space_id);
- H5Sselect_all(hslab_space);
- hs_select_nelmts = 1;
- } /* rank */
-
- 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");
- 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");
-
- /* reclaim any VL memory, if necessary */
- if (vl_data)
- H5Dvlen_reclaim(wtype_id, hslab_space, H5P_DEFAULT, hslab_buf);
-
- /* calculate the next hyperslab offset */
- for (k = rank, carry = 1; k > 0 && carry; --k) {
- hs_sel_offset[k - 1] += hs_sel_count[k - 1];
- /* if reached the end of a dim */
- if (hs_sel_offset[k - 1] == dims[k - 1])
- hs_sel_offset[k - 1] = 0;
- else
- carry = 0;
- } /* k */
- } /* elmtno */
-
- H5Sclose(hslab_space);
- /* free */
- if (hslab_buf != NULL) {
- HDfree(hslab_buf);
- hslab_buf = NULL;
}
- } /* hyperslab read */
- } /* if (nelmts>0 && space_status==H5D_SPACE_STATUS_NOT_ALLOCATED) */
+ else { /* possibly not enough memory, read/write by hyperslabs */
+ size_t p_type_nbytes = msize; /*size of memory type */
+ hsize_t p_nelmts = nelmts; /*total elements */
+ hsize_t elmtno; /*counter */
+ int carry; /*counter carry value */
+ unsigned int vl_data = 0; /*contains VL datatypes */
+
+ /* hyperslab info */
+ hsize_t hslab_dims[H5S_MAX_RANK]; /*hyperslab dims */
+ hsize_t hslab_nbytes; /*bytes per hyperslab */
+ hsize_t hslab_nelmts; /*elements per hyperslab*/
+ hid_t hslab_space; /*hyperslab data space */
+
+ /* hyperslab selection info */
+ hsize_t hs_sel_offset[H5S_MAX_RANK]; /* selection offset */
+ hsize_t hs_sel_count[H5S_MAX_RANK]; /* selection count */
+ hsize_t hs_select_nelmts; /* selected elements */
+ hsize_t zero[8]; /*vector of zeros */
+ int k;
+ H5D_layout_t dset_layout;
+ 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)
+ vl_data = TRUE;
+
+ /* check first if writing dataset is chunked,
+ * if so use its chunk layout for better performance. */
+ dset_layout = H5Pget_layout(dcpl_out);
+ if (dset_layout == H5D_CHUNKED)
+ dcpl_tmp = dcpl_out; /* writing dataset */
+ else {
+ dset_layout = H5Pget_layout(dcpl_in);
+ if (dset_layout == H5D_CHUNKED)
+ dcpl_tmp = dcpl_in; /* reading dataset */
+ }
- /*-------------------------------------------------------------------------
- * amount of compression used
- *-------------------------------------------------------------------------
- */
- if (options->verbose) {
- double ratio = 0;
-
- /* only print the compression ration if there was a filter request */
- if (apply_s && apply_f && req_filter) {
- /* get the storage size of the output dataset */
- dsize_out = H5Dget_storage_size(dset_out);
-
- /* compression ratio = uncompressed size / compressed size */
- if (dsize_out != 0)
- ratio = (double) dsize_in / (double) dsize_out;
- print_dataset_info(dcpl_out, travt->objs[i].name, ratio, 1);
- }
- else
- print_dataset_info(dcpl_in, travt->objs[i].name, ratio, 0);
+ /* get hyperslab dims and size in byte */
+ if (get_hyperslab(dcpl_tmp, rank, dims, p_type_nbytes, hslab_dims,
+ &hslab_nbytes) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "get_hyperslab failed");
+
+ hslab_buf = HDmalloc((size_t)hslab_nbytes);
+ if (hslab_buf == NULL)
+ 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);
+
+ /* the hyperslab selection loop */
+ HDmemset(hs_sel_offset, 0, sizeof hs_sel_offset);
+ HDmemset(zero, 0, sizeof zero);
+
+ for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_select_nelmts) {
+ if (rank > 0) {
+ /* calculate the hyperslab selections.
+ * The selection would be same as the hyperslab
+ * except for remaining edge portion of the dataset
+ * which is smaller then the hyperslab.
+ */
+ for (k = 0, hs_select_nelmts = 1; k < rank; k++) {
+ /* MIN() is used to get the remaining edge portion if
+ * exist. "dims[k] - hs_sel_offset[k]" is remaining edge
+ * portion that is smaller then the hyperslab.*/
+ hs_sel_count[k] =
+ MIN(dims[k] - hs_sel_offset[k], hslab_dims[k]);
+ hs_select_nelmts *= hs_sel_count[k];
+ }
+
+ if (H5Sselect_hyperslab(f_space_id, H5S_SELECT_SET,
+ hs_sel_offset, NULL, hs_sel_count,
+ NULL) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Sselect_hyperslab failed");
+ if (H5Sselect_hyperslab(hslab_space, H5S_SELECT_SET, zero,
+ NULL, &hs_select_nelmts, NULL) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Sselect_hyperslab failed");
+ } /* end if rank > 0 */
+ else {
+ H5Sselect_all(f_space_id);
+ H5Sselect_all(hslab_space);
+ hs_select_nelmts = 1;
+ } /* end (else) rank == 0 */
+
+ if (options->verbose == 2) {
+ H5_timer_init(&timer);
+ H5_timer_start(&timer);
+ }
+ if (H5Dread(dset_in, wtype_id, hslab_space, f_space_id,
+ H5P_DEFAULT, hslab_buf) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dread failed");
+ if (options->verbose == 2) {
+ H5_timer_stop(&timer);
+ H5_timer_get_times(timer, &times);
+ read_time += times.elapsed;
+ H5_timer_init(&timer);
+ H5_timer_start(&timer);
+ }
+ if (H5Dwrite(dset_out, wtype_id, hslab_space, f_space_id, dxpl_id,
+ hslab_buf) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dwrite failed");
+ if (options->verbose == 2) {
+ H5_timer_stop(&timer);
+ H5_timer_get_times(timer, &times);
+ write_time += times.elapsed;
+ }
- /* print a message that the filter was not applied
- (in case there was a filter)
- */
- if (has_filter && apply_s == 0)
- HDprintf(" <warning: filter not applied to %s. dataset smaller than %d bytes>\n", travt->objs[i].name, (int) options->min_comp);
+ /* reclaim any VL memory, if necessary */
+ if (vl_data)
+ H5Treclaim(wtype_id, hslab_space, H5P_DEFAULT, hslab_buf);
+
+ /* calculate the next hyperslab offset */
+ for (k = rank, carry = 1; k > 0 && carry; --k) {
+ hs_sel_offset[k - 1] += hs_sel_count[k - 1];
+ /* if reached the end of a dim */
+ if (hs_sel_offset[k - 1] == dims[k - 1])
+ hs_sel_offset[k - 1] = 0;
+ else
+ carry = 0;
+ }
+ } /* end for (hyperslab selection loop) */
- if (has_filter && apply_f == 0)
- HDprintf(" <warning: could not apply the filter to %s>\n", travt->objs[i].name);
- } /* verbose */
+ H5Sclose(hslab_space);
+ if (hslab_buf != NULL) {
+ HDfree(hslab_buf);
+ hslab_buf = NULL;
+ }
+ } /* end if reading/writing by hyperslab */
+ } /* end if (nelmts > 0 && space_status != H5D_SPACE_STATUS_NOT_ALLOCATED) */
- /*-------------------------------------------------------------------------
- * 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");
+ /*-------------------------------------------------------------------------
+ * print amount of compression used
+ *-------------------------------------------------------------------------
+ */
+ if (options->verbose > 0) {
+ double ratio = 0;
+
+ /* only print the compression ration if there was a filter request */
+ if (apply_s && apply_f && req_filter) {
+ /* get the storage size of the output dataset */
+ dsize_out = H5Dget_storage_size(dset_out);
+
+ /* compression ratio = uncompressed size / compressed size */
+ if (dsize_out != 0)
+ ratio = (double)dsize_in / (double)dsize_out;
+ print_dataset_info(dcpl_out, travt->objs[i].name, ratio, 1, options,
+ read_time, write_time);
+ }
+ else
+ print_dataset_info(dcpl_in, travt->objs[i].name, ratio, 0, options,
+ read_time, write_time);
+
+ /* print a message that the filter was not applied
+ * (in case there was a filter)
+ */
+ if (has_filter && apply_s == 0)
+ HDprintf(" <warning: filter not applied to %s. dataset smaller than "
+ "%d bytes>\n",
+ travt->objs[i].name, (int)options->min_comp);
+
+ if (has_filter && apply_f == 0)
+ HDprintf(" <warning: could not apply the filter to %s>\n",
+ travt->objs[i].name);
+ } /* end if verbose (print compression) */
+
+ /*-------------------------------------------------------------------------
+ * copy attrs
+ *-------------------------------------------------------------------------
+ */
+ if (copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "copy_attr failed");
- /*close */
- if (H5Dclose(dset_out) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
- }/*!H5T_REFERENCE*/
- }/*h5tools_canreadf*/
+ if (H5Dclose(dset_out) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed");
+ } /* end if not a reference */
+ } /* end if h5tools_canreadf (filter availability check) */
+ /*-------------------------------------------------------------------------
+ * Close
+ *-------------------------------------------------------------------------
+ */
+ if (H5Tclose(ftype_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
+ if (H5Tclose(wtype_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
+ if (H5Pclose(dcpl_in) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
+ if (H5Pclose(dcpl_out) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
+ if (H5Sclose(f_space_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed");
+ if (H5Dclose(dset_in) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed");
+ }
/*-------------------------------------------------------------------------
- * close
+ * We do not have request for filter/chunking; use H5Ocopy instead
*-------------------------------------------------------------------------
*/
- if (H5Tclose(ftype_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
- if (H5Tclose(wtype_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
- if (H5Pclose(dcpl_in) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
- if (H5Pclose(dcpl_out) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
- if (H5Sclose(f_space_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed");
- if (H5Dclose(dset_in) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
- }
+ else {
+ /* create property to pass copy options */
+ if ((ocpl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed");
+
+ /* set options for object copy */
+ if (H5Pset_copy_object(ocpl_id, H5O_COPY_WITHOUT_ATTR_FLAG) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_copy_object failed");
+
+ if (options->verbose == 2) {
+ H5_timer_init(&timer);
+ H5_timer_start(&timer);
+ }
+ 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 */
+ ocpl_id, /* Properties which apply to the copy */
+ H5P_DEFAULT) < 0) /* Properties which apply to the new hard link */
+ H5TOOLS_GOTO_ERROR((-1), "H5Ocopy failed");
+ if (options->verbose == 2) {
+ H5_timer_stop(&timer);
+ H5_timer_get_times(timer, &times);
+ write_time += times.elapsed;
+ }
+
+ 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)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed");
+ if ((dset_out = H5Dopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed");
+ if (copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "copy_attr failed");
+ if (H5Dclose(dset_in) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed");
+ if (H5Dclose(dset_out) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed");
+
+ if (options->verbose == 2)
+ HDprintf(FORMAT_OBJ_TIME, "dset", 0.0, write_time, travt->objs[i].name);
+ else
+ HDprintf(FORMAT_OBJ, "dset", travt->objs[i].name);
+
+ } /* end whether we have request for filter/chunking */
+
+ break;
+ } /* H5TRAV_TYPE_DATASET */
+
/*-------------------------------------------------------------------------
- * we do not have request for filter/chunking use H5Ocopy instead
+ * H5TRAV_TYPE_NAMED_DATATYPE
*-------------------------------------------------------------------------
*/
- else {
- hid_t pid = -1;
+ case H5TRAV_TYPE_NAMED_DATATYPE:
+ if (options->verbose == 2)
+ HDprintf(FORMAT_OBJ_NOTIME, "type", travt->objs[i].name);
+ else
+ HDprintf(FORMAT_OBJ, "type", travt->objs[i].name);
- /* create property to pass copy options */
- if ((pid = H5Pcreate(H5P_OBJECT_COPY)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed");
+ if ((type_in = H5Topen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Topen2 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");
+ /* Copy the datatype anonymously */
+ if ((type_out = copy_named_datatype(type_in, fidout, &named_dt_head, travt, options)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "copy_named_datatype failed");
- /*-------------------------------------------------------------------------
- * do the copy
- *-------------------------------------------------------------------------
- */
-
- 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 */
- H5P_DEFAULT) < 0) /* Properties which apply to the new hard link */
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Ocopy failed");
-
- /* close property */
- if (H5Pclose(pid) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
+ /* Link in to group structure */
+ if (H5Lcreate_hard(type_out, ".", fidout, travt->objs[i].name, H5P_DEFAULT, H5P_DEFAULT) <
+ 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Lcreate_hard failed");
/*-------------------------------------------------------------------------
- * copy attrs manually
+ * copy attrs
*-------------------------------------------------------------------------
*/
- if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed");
- if ((dset_out = H5Dopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "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");
- if (H5Dclose(dset_in) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
- if (H5Dclose(dset_out) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
-
- if (options->verbose)
- HDprintf(FORMAT_OBJ, "dset", travt->objs[i].name);
-
- } /* end do we have request for filter/chunking */
- break;
-
- /*-------------------------------------------------------------------------
- * H5TRAV_TYPE_NAMED_DATATYPE
- *-------------------------------------------------------------------------
- */
- case H5TRAV_TYPE_NAMED_DATATYPE:
- if (options->verbose)
- HDprintf(FORMAT_OBJ, "type", travt->objs[i].name);
+ if (copy_attr(type_in, type_out, &named_dt_head, travt, options) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "copy_attr failed");
- if ((type_in = H5Topen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Topen2 failed");
+ if (H5Tclose(type_in) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
+ if (H5Tclose(type_out) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
+ type_out = H5I_INVALID_HID; /* named datatypes stack, named_dt_head, manages allocation */
- /* 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");
-
- /* 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");
+ break;
/*-------------------------------------------------------------------------
- * copy attrs
+ * H5TRAV_TYPE_LINK
+ * H5TRAV_TYPE_UDLINK
+ *
+ * Only handles external links; H5Lcopy will fail for other UD link types
+ * since we don't have creation or copy callbacks for them.
*-------------------------------------------------------------------------
*/
- if (copy_attr(type_in, type_out, &named_dt_head, travt, options) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_attr failed");
-
- if (H5Tclose(type_in) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "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 */
-
- break;
-
- /*-------------------------------------------------------------------------
- * H5TRAV_TYPE_LINK
- * H5TRAV_TYPE_UDLINK
- *
- * Only handles external links; H5Lcopy will fail for other UD link types
- * since we don't have creation or copy callbacks for them.
- *-------------------------------------------------------------------------
- */
- case H5TRAV_TYPE_LINK:
- case H5TRAV_TYPE_UDLINK:
- 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");
+ case H5TRAV_TYPE_LINK:
+ case H5TRAV_TYPE_UDLINK:
+ if (options->verbose == 2)
+ HDprintf(FORMAT_OBJ_NOTIME, "link", travt->objs[i].name);
+ else
+ HDprintf(FORMAT_OBJ, "link", travt->objs[i].name);
+
+ /* 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");
+
+ /* 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");
+ }
- if (options->verbose)
- HDprintf(FORMAT_OBJ, "link", travt->objs[i].name);
- break;
+ /* 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");
+ default:
+ H5TOOLS_GOTO_ERROR((-1), "Object type not found");
} /* switch */
- } /* end for */
- } /* end if */
+ } /* end for each object to traverse */
+ } /* end if there are objects */
done:
@@ -1198,20 +1439,30 @@ 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
- H5E_BEGIN_TRY {
+ else {
+ H5E_BEGIN_TRY
+ {
named_datatype_free(&named_dt_head, 1);
- } H5E_END_TRY;
+ }
+ 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);
+ H5Pclose(dxpl_id);
H5Sclose(f_space_id);
H5Dclose(dset_in);
H5Dclose(dset_out);
@@ -1219,7 +1470,8 @@ done:
H5Tclose(wtype_id);
H5Tclose(type_in);
H5Tclose(type_out);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
/* free */
if (buf != NULL)
@@ -1228,7 +1480,7 @@ done:
HDfree(hslab_buf);
return ret_value;
-}
+} /* end do_copy_objects() */
/*-------------------------------------------------------------------------
* Function: print_dataset_info
@@ -1237,19 +1489,20 @@ done:
*-------------------------------------------------------------------------
*/
static void
-print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr)
+print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr, pack_opt_t *options, double read_time,
+ double write_time)
{
- char strfilter[255];
-#if defined (PRINT_DEBUG )
- char temp[255];
+ char strfilter[255];
+#if defined(PRINT_DEBUG)
+ char temp[255];
#endif
- int nfilters; /* number of filters */
- unsigned filt_flags; /* filter flags */
- H5Z_filter_t filtn; /* filter identification number */
- unsigned cd_values[20]; /* filter client data values */
- size_t cd_nelmts; /* filter client number of values */
- char f_objname[256]; /* filter objname */
- int i;
+ int nfilters; /* number of filters */
+ unsigned filt_flags; /* filter flags */
+ H5Z_filter_t filtn; /* filter identification number */
+ unsigned cd_values[20]; /* filter client data values */
+ size_t cd_nelmts; /* filter client number of values */
+ char f_objname[256]; /* filter objname */
+ int i;
HDstrcpy(strfilter, "\0");
@@ -1260,8 +1513,8 @@ print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr)
for (i = 0; i < nfilters; i++) {
cd_nelmts = NELMTS(cd_values);
- if ((filtn = H5Pget_filter2(dcpl_id, (unsigned) i, &filt_flags, &cd_nelmts,
- cd_values, sizeof(f_objname), f_objname, NULL)) < 0) {
+ if ((filtn = H5Pget_filter2(dcpl_id, (unsigned)i, &filt_flags, &cd_nelmts, cd_values,
+ sizeof(f_objname), f_objname, NULL)) < 0) {
HDstrcat(strfilter, "ERROR ");
continue;
}
@@ -1274,11 +1527,11 @@ print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr)
case H5Z_FILTER_DEFLATE:
HDstrcat(strfilter, "GZIP ");
-#if defined (PRINT_DEBUG)
+#if defined(PRINT_DEBUG)
{
unsigned level = cd_values[0];
- HDsprintf(temp,"(%d)", level);
+ HDsprintf(temp, "(%d)", level);
HDstrcat(strfilter, temp);
}
#endif
@@ -1287,12 +1540,12 @@ print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr)
case H5Z_FILTER_SZIP:
HDstrcat(strfilter, "SZIP ");
-#if defined (PRINT_DEBUG)
+#if defined(PRINT_DEBUG)
{
unsigned options_mask = cd_values[0]; /* from dcpl, not filt*/
- unsigned ppb = cd_values[1];
+ unsigned ppb = cd_values[1];
- HDsprintf(temp,"(%d,", ppb);
+ HDsprintf(temp, "(%d,", ppb);
HDstrcat(strfilter, temp);
if (options_mask & H5_SZIP_EC_OPTION_MASK)
HDstrcpy(temp, "EC) ");
@@ -1322,11 +1575,14 @@ print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr)
default:
HDstrcat(strfilter, "UD ");
break;
- } /* switch */
- }/*i*/
+ } /* end switch */
+ } /* end for each filter */
if (!pr)
- HDprintf(FORMAT_OBJ, "dset", objname);
+ if (options->verbose == 2)
+ HDprintf(FORMAT_OBJ_TIME, "dset", read_time, write_time, objname);
+ else
+ HDprintf(FORMAT_OBJ, "dset", objname);
else {
char str[512], temp[512];
@@ -1334,9 +1590,12 @@ print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr)
HDstrcat(str, strfilter);
HDsprintf(temp, " (%.3f:1)", ratio);
HDstrcat(str, temp);
- HDprintf(FORMAT_OBJ, str, objname);
+ if (options->verbose == 2)
+ HDprintf(FORMAT_OBJ_TIME, str, read_time, write_time, objname);
+ else
+ HDprintf(FORMAT_OBJ, str, objname);
}
-}
+} /* end print_dataset_info() */
/*-------------------------------------------------------------------------
* Function: copy_user_block
@@ -1349,22 +1608,22 @@ 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) {
- ssize_t nread, nbytes; /* # of bytes transfered, etc. */
- char rbuf[USERBLOCK_XFER_SIZE]; /* Buffer for reading */
- const char *wbuf; /* Pointer into buffer, for writing */
+ ssize_t nread, nbytes; /* # of bytes transferred, etc. */
+ char rbuf[USERBLOCK_XFER_SIZE]; /* Buffer for reading */
+ const char *wbuf; /* Pointer into buffer, for writing */
/* Read buffer from source file */
if (size > USERBLOCK_XFER_SIZE)
@@ -1372,20 +1631,20 @@ 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.) */
nbytes = nread;
- wbuf = rbuf;
+ wbuf = rbuf;
while (nbytes > 0) {
ssize_t nwritten; /* # of bytes written */
do {
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");
+ if (-1 == nwritten) /* error */
+ H5TOOLS_GOTO_ERROR((-1), "HDwrite failed");
HDassert(nwritten > 0);
HDassert(nwritten <= nbytes);
@@ -1396,7 +1655,7 @@ copy_user_block(const char *infile, const char *outfile, hsize_t size)
} /* end while */
/* Update size of userblock left to transfer */
- size = size - (hsize_t) nread;
+ size = size - (hsize_t)nread;
} /* end while */
done:
@@ -1406,7 +1665,7 @@ done:
HDclose(outfid);
return ret_value;
-}
+} /* end copy_user_block() */
/*-------------------------------------------------------------------------
* Function: print_user_block
@@ -1416,42 +1675,41 @@ done:
* Return: 0, ok, -1 no
*-------------------------------------------------------------------------
*/
-#if defined (H5REPACK_DEBUG_USER_BLOCK)
-static
-void
+#if defined(H5REPACK_DEBUG_USER_BLOCK)
+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 */
+ int fh = -1; /* file handle */
+ hsize_t ub_size; /* user block size */
+ hsize_t size; /* size read */
+ 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;
/* read file */
while (size > 0) {
- ssize_t nread; /* # of bytes read */
- char rbuf[USERBLOCK_XFER_SIZE]; /* buffer for reading */
+ ssize_t nread; /* # of bytes read */
+ char rbuf[USERBLOCK_XFER_SIZE]; /* buffer for reading */
/* read buffer */
if (size > USERBLOCK_XFER_SIZE)
@@ -1462,12 +1720,11 @@ print_user_block(const char *filename, hid_t fid)
for (i = 0; i < nread; i++) {
HDprintf("%c ", rbuf[i]);
-
}
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 */
@@ -1479,6 +1736,5 @@ done:
HDclose(fh);
return;
-}
+} /* end print_user_block() */
#endif
-
diff --git a/tools/src/h5repack/h5repack_filters.c b/tools/src/h5repack/h5repack_filters.c
index 7e32def..76bac5e 100644
--- a/tools/src/h5repack/h5repack_filters.c
+++ b/tools/src/h5repack/h5repack_filters.c
@@ -6,7 +6,7 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -17,12 +17,12 @@
/* number of members in an array */
#ifndef NELMTS
-# define NELMTS(X) (sizeof(X)/sizeof(X[0]))
+#define NELMTS(X) (sizeof(X) / sizeof(X[0]))
#endif
/* minimum of two values */
#undef MIN
-#define MIN(a,b) (((a)<(b)) ? (a) : (b))
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
/*-------------------------------------------------------------------------
* Function: aux_copy_obj
@@ -32,39 +32,41 @@
* Return: 0 success, -1 failure
*-------------------------------------------------------------------------
*/
-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 */
+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 rank; /* rank of dataset */
+ hsize_t chsize[64]; /* chunk size in elements */
+ 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");
+ 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)
+ 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");
+ if ((rank = H5Pget_chunk(dcpl_id, NELMTS(chsize), chsize /*out*/)) < 0)
+ 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];
@@ -81,30 +83,33 @@ done:
* in the repack options list
*-------------------------------------------------------------------------
*/
-static int aux_find_obj(const char* name, /* object name from traverse list */
- pack_opt_t *options, /* repack options */
- pack_info_t *obj /*OUT*/) /* info about object to filter */
+static int
+aux_find_obj(const char * name, /* object name from traverse list */
+ pack_opt_t * options, /* repack options */
+ pack_info_t *obj /*OUT*/) /* info about object to filter */
{
- char *pdest = NULL;
- const char *pname = NULL;
+ char * pdest = NULL;
+ const char * pname = NULL;
unsigned int i;
for (i = 0; i < options->op_tbl->nelems; i++) {
if (HDstrcmp(options->op_tbl->objs[i].path, name) == 0) {
*obj = options->op_tbl->objs[i];
- return (int) i;
+ return (int)i;
}
pdest = options->op_tbl->objs[i].path;
- if (pdest[0] == '/') pdest++;
+ if (pdest[0] == '/')
+ pdest++;
pname = name;
- if (pname[0] == '/') pname++;
+ if (pname[0] == '/')
+ pname++;
if (HDstrcmp(pdest, pname) == 0) {
*obj = options->op_tbl->objs[i];
- return (int) i;
+ return (int)i;
}
- }/*i*/
+ } /*i*/
return -1;
}
@@ -118,9 +123,10 @@ static int aux_find_obj(const char* name, /* object name from traverse list */
* Return: 0 not found, 1 found
*-------------------------------------------------------------------------
*/
-static int aux_assign_obj(const char* name, /* object name from traverse list */
- pack_opt_t *options, /* repack options */
- pack_info_t *obj /*OUT*/) /* info about object to filter */
+static int
+aux_assign_obj(const char * name, /* object name from traverse list */
+ pack_opt_t * options, /* repack options */
+ pack_info_t *obj /*OUT*/) /* info about object to filter */
{
int idx, i;
pack_info_t tmp;
@@ -136,44 +142,44 @@ static int aux_assign_obj(const char* name, /* object name from traverse list */
/* assign the global layout info to the OBJ info */
tmp.layout = options->layout_g;
switch (options->layout_g) {
- case H5D_CHUNKED:
- tmp.chunk.rank = options->chunk_g.rank;
- for (i = 0; i < tmp.chunk.rank; i++)
- tmp.chunk.chunk_lengths[i] = options->chunk_g.chunk_lengths[i];
- break;
- case H5D_LAYOUT_ERROR:
- case H5D_COMPACT:
- case H5D_CONTIGUOUS:
- case H5D_VIRTUAL:
- case H5D_NLAYOUTS:
- break;
- default:
- break;
- }/*switch*/
+ case H5D_CHUNKED:
+ tmp.chunk.rank = options->chunk_g.rank;
+ for (i = 0; i < tmp.chunk.rank; i++)
+ tmp.chunk.chunk_lengths[i] = options->chunk_g.chunk_lengths[i];
+ break;
+ case H5D_LAYOUT_ERROR:
+ case H5D_COMPACT:
+ case H5D_CONTIGUOUS:
+ case H5D_VIRTUAL:
+ case H5D_NLAYOUTS:
+ break;
+ default:
+ break;
+ } /*switch*/
}
else {
tmp.layout = options->op_tbl->objs[idx].layout;
switch (tmp.layout) {
- case H5D_CHUNKED:
- tmp.chunk.rank = options->op_tbl->objs[idx].chunk.rank;
- for (i = 0; i < tmp.chunk.rank; i++)
- tmp.chunk.chunk_lengths[i] = options->op_tbl->objs[idx].chunk.chunk_lengths[i];
- break;
- case H5D_LAYOUT_ERROR:
- case H5D_COMPACT:
- case H5D_CONTIGUOUS:
- case H5D_VIRTUAL:
- case H5D_NLAYOUTS:
- break;
- default:
- break;
- }/*switch*/
+ case H5D_CHUNKED:
+ tmp.chunk.rank = options->op_tbl->objs[idx].chunk.rank;
+ for (i = 0; i < tmp.chunk.rank; i++)
+ tmp.chunk.chunk_lengths[i] = options->op_tbl->objs[idx].chunk.chunk_lengths[i];
+ break;
+ case H5D_LAYOUT_ERROR:
+ case H5D_COMPACT:
+ case H5D_CONTIGUOUS:
+ case H5D_VIRTUAL:
+ case H5D_NLAYOUTS:
+ break;
+ default:
+ break;
+ } /*switch*/
}
/* applying to all objects */
if (options->all_filter) {
/* assign the global filter */
- tmp.nfilters = 1;
+ tmp.nfilters = 1;
tmp.filter[0] = options->filter_g[0];
} /* if all */
else {
@@ -197,21 +203,20 @@ static int aux_assign_obj(const char* name, /* object name from traverse list */
/* assign the global layout info to the OBJ info */
tmp.layout = options->layout_g;
switch (options->layout_g) {
- case H5D_CHUNKED:
- tmp.chunk.rank = options->chunk_g.rank;
- for (i = 0; i < tmp.chunk.rank; i++)
- tmp.chunk.chunk_lengths[i] =
- options->chunk_g.chunk_lengths[i];
- break;
- case H5D_LAYOUT_ERROR:
- case H5D_COMPACT:
- case H5D_CONTIGUOUS:
- case H5D_VIRTUAL:
- case H5D_NLAYOUTS:
- break;
- default:
- break;
- }/*switch*/
+ case H5D_CHUNKED:
+ tmp.chunk.rank = options->chunk_g.rank;
+ for (i = 0; i < tmp.chunk.rank; i++)
+ tmp.chunk.chunk_lengths[i] = options->chunk_g.chunk_lengths[i];
+ break;
+ case H5D_LAYOUT_ERROR:
+ case H5D_COMPACT:
+ case H5D_CONTIGUOUS:
+ case H5D_VIRTUAL:
+ case H5D_NLAYOUTS:
+ break;
+ default:
+ break;
+ } /*switch*/
}
}
@@ -226,33 +231,34 @@ static int aux_assign_obj(const char* name, /* object name from traverse list */
* do extra checking in the case of SZIP; delete all filters in the case
* of H5Z_FILTER_NONE present in the PACK_INFO_T filter array
*
- * Return: 0 success, -1 an error occured
+ * Return: 0 success, -1 an error occurred
*-------------------------------------------------------------------------
*/
-int apply_filters(const char* name, /* object name from traverse list */
- int rank, /* rank of dataset */
- hsize_t *dims, /* dimensions of dataset */
- size_t msize, /* size of type */
- hid_t dcpl_id, /* dataset creation property list */
- pack_opt_t *options, /* repack options */
- int *has_filter) /* (OUT) object NAME has a filter */
+int
+apply_filters(const char * name, /* object name from traverse list */
+ int rank, /* rank of dataset */
+ const hsize_t *dims, /* dimensions of dataset */
+ size_t msize, /* size of type */
+ hid_t dcpl_id, /* dataset creation property 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
+ * initialize the assignment object
*-------------------------------------------------------------------------
*/
init_packobject(&obj);
@@ -263,12 +269,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");
/*-------------------------------------------------------------------------
* check if we have filters in the pipeline
@@ -279,12 +284,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) {
+ 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,12 +299,12 @@ 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");
- obj.layout = H5D_CHUNKED;
+ if ((rank = H5Pget_chunk(dcpl_id, NELMTS(chsize), chsize /*out*/)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pget_chunk failed");
+ obj.layout = H5D_CHUNKED;
obj.chunk.rank = rank;
for (i = 0; i < rank; i++)
obj.chunk.chunk_lengths[i] = chsize[i];
@@ -327,7 +332,7 @@ int apply_filters(const char* name, /* object name from traverse list */
if (obj.layout == -1) {
/* stripmine info */
hsize_t sm_size[H5S_MAX_RANK]; /*stripmine size */
- hsize_t sm_nbytes; /*bytes per stripmine */
+ hsize_t sm_nbytes; /*bytes per stripmine */
obj.chunk.rank = rank;
@@ -339,8 +344,8 @@ int apply_filters(const char* name, /* object name from traverse list */
sm_nbytes = msize;
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");
+ if (sm_nbytes == 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,126 +360,117 @@ 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) {
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_NONE 0 , uncompress if compressed
- *-------------------------------------------------------------------------
- */
- case H5Z_FILTER_NONE:
- break;
-
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_DEFLATE 1 , deflation like gzip
- *-------------------------------------------------------------------------
- */
- case H5Z_FILTER_DEFLATE:
- {
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_NONE 0 , uncompress if compressed
+ *-------------------------------------------------------------------------
+ */
+ case H5Z_FILTER_NONE:
+ break;
+
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_DEFLATE 1 , deflation like gzip
+ *-------------------------------------------------------------------------
+ */
+ case H5Z_FILTER_DEFLATE: {
unsigned aggression; /* the deflate level */
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");
- }
- break;
-
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_SZIP 4 , szip compression
- *-------------------------------------------------------------------------
- */
- case H5Z_FILTER_SZIP:
- {
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_deflate failed");
+ } break;
+
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_SZIP 4 , szip compression
+ *-------------------------------------------------------------------------
+ */
+ case H5Z_FILTER_SZIP: {
unsigned options_mask;
unsigned pixels_per_block;
- options_mask = obj.filter[i].cd_values[0];
+ options_mask = obj.filter[i].cd_values[0];
pixels_per_block = obj.filter[i].cd_values[1];
/* 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");
- }
- break;
-
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_SHUFFLE 2 , shuffle the data
- *-------------------------------------------------------------------------
- */
- 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");
- if (H5Pset_shuffle(dcpl_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_shuffle failed");
- break;
-
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_FLETCHER32 3 , fletcher32 checksum of EDC
- *-------------------------------------------------------------------------
- */
- 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");
- if (H5Pset_fletcher32(dcpl_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_fletcher32 failed");
- break;
- /*----------- -------------------------------------------------------------
- * H5Z_FILTER_NBIT , NBIT compression
- *-------------------------------------------------------------------------
- */
- 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");
- if (H5Pset_nbit(dcpl_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_nbit failed");
- break;
- /*----------- -------------------------------------------------------------
- * H5Z_FILTER_SCALEOFFSET , scale+offset compression
- *-------------------------------------------------------------------------
- */
- case H5Z_FILTER_SCALEOFFSET:
- {
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_szip failed");
+ } break;
+
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_SHUFFLE 2 , shuffle the data
+ *-------------------------------------------------------------------------
+ */
+ case H5Z_FILTER_SHUFFLE:
+ if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed");
+ if (H5Pset_shuffle(dcpl_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_shuffle failed");
+ break;
+
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_FLETCHER32 3 , fletcher32 checksum of EDC
+ *-------------------------------------------------------------------------
+ */
+ case H5Z_FILTER_FLETCHER32:
+ if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed");
+ if (H5Pset_fletcher32(dcpl_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_fletcher32 failed");
+ break;
+ /*----------- -------------------------------------------------------------
+ * H5Z_FILTER_NBIT , NBIT compression
+ *-------------------------------------------------------------------------
+ */
+ case H5Z_FILTER_NBIT:
+ if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed");
+ if (H5Pset_nbit(dcpl_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_nbit failed");
+ break;
+ /*----------- -------------------------------------------------------------
+ * H5Z_FILTER_SCALEOFFSET , scale+offset compression
+ *-------------------------------------------------------------------------
+ */
+ case H5Z_FILTER_SCALEOFFSET: {
H5Z_SO_scale_type_t scale_type;
- int scale_factor;
+ int scale_factor;
- scale_type = (H5Z_SO_scale_type_t) obj.filter[i].cd_values[0];
- scale_factor = (int) obj.filter[i].cd_values[1];
+ scale_type = (H5Z_SO_scale_type_t)obj.filter[i].cd_values[0];
+ 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");
- }
- break;
- default:
- {
+ 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");
- 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");
- }
- break;
+ 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)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pset_filter failed");
+ } break;
} /* switch */
- }/*i*/
+ } /*i*/
}
/*obj.nfilters*/
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 */
+ } /* nfilters */
/*-------------------------------------------------------------------------
* layout
@@ -484,24 +480,23 @@ 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");
}
}
done:
return ret_value;
}
-
diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c
index b961765..a805b3d 100644
--- a/tools/src/h5repack/h5repack_main.c
+++ b/tools/src/h5repack/h5repack_main.c
@@ -6,7 +6,7 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -18,51 +18,63 @@
/* Name of tool */
#define PROGRAMNAME "h5repack"
-static int parse_command_line(int argc, const char **argv, pack_opt_t* options);
+static int parse_command_line(int argc, const char *const *argv, pack_opt_t *options);
static void leave(int ret) H5_ATTR_NORETURN;
-
/* module-scoped variables */
-static int has_i_o = 0;
-const char *infile = NULL;
+static int has_i = 0;
+static int has_o = 0;
+const char *infile = NULL;
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 struct long_options l_opts[] = {
- { "help", no_arg, 'h' },
- { "version", no_arg, 'V' },
- { "verbose", no_arg, 'v' },
- { "filter", require_arg, 'f' },
- { "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' },
- { "ssize", require_arg, 's' },
- { "ublock", require_arg, 'u' },
- { "block", require_arg, 'b' },
- { "metadata_block_size", require_arg, 'M' },
- { "threshold", require_arg, 't' },
- { "alignment", require_arg, 'a' },
- { "infile", require_arg, 'i' }, /* -i for backward compability */
- { "outfile", require_arg, 'o' }, /* -o for backward compability */
- { "fs_strategy", require_arg, 'S' },
- { "fs_persist", require_arg, 'P' },
- { "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' },
- { NULL, 0, '\0' }
-};
+static const char *s_opts = "a:b:c:d:e:f:hi:j:k:l:m:no:q:s:t:u:v*z:E*G:LM:P:S:T:VXWY:Z:1:2:3:4:5:6:7:8:9:0:";
+static struct h5_long_options l_opts[] = {{"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 compatibility */
+ {"low", require_arg, 'j'},
+ {"high", require_arg, 'k'},
+ {"layout", require_arg, 'l'},
+ {"minimum", require_arg, 'm'},
+ {"native", no_arg, 'n'},
+ {"outfile", require_arg, 'o'}, /* for backward compatibility */
+ {"sort_by", require_arg, 'q'},
+ {"ssize", require_arg, 's'},
+ {"threshold", require_arg, 't'},
+ {"ublock", require_arg, 'u'},
+ {"verbose", optional_arg, 'v'},
+ {"sort_order", require_arg, 'z'},
+ {"enable-error-stack", optional_arg, 'E'},
+ {"fs_pagesize", require_arg, 'G'},
+ {"latest", no_arg, 'L'},
+ {"metadata_block_size", require_arg, 'M'},
+ {"fs_persist", require_arg, 'P'},
+ {"fs_strategy", require_arg, 'S'},
+ {"fs_threshold", require_arg, 'T'},
+ {"version", no_arg, 'V'},
+ {"merge", no_arg, 'X'},
+ {"prune", no_arg, 'W'},
+ {"src-vol-value", require_arg, '1'},
+ {"src-vol-name", require_arg, '2'},
+ {"src-vol-info", require_arg, '3'},
+ {"dst-vol-value", require_arg, '4'},
+ {"dst-vol-name", require_arg, '5'},
+ {"dst-vol-info", require_arg, '6'},
+ {"src-vfd-value", require_arg, '7'},
+ {"src-vfd-name", require_arg, '8'},
+ {"src-vfd-info", require_arg, '9'},
+ {"dst-vfd-value", require_arg, '0'},
+ {"dst-vfd-name", require_arg, 'Y'},
+ {"dst-vfd-info", require_arg, 'Z'},
+ {NULL, 0, '\0'}};
/*-------------------------------------------------------------------------
* Function: usage
@@ -73,91 +85,184 @@ static struct long_options l_opts[] = {
*
*-------------------------------------------------------------------------
*/
-static void usage(const char *prog) {
+static void
+usage(const char *prog)
+{
FLUSHSTREAM(rawoutstream);
PRINTSTREAM(rawoutstream, "usage: %s [OPTIONS] file1 file2\n", prog);
PRINTVALSTREAM(rawoutstream, " file1 Input HDF5 File\n");
PRINTVALSTREAM(rawoutstream, " file2 Output HDF5 File\n");
+ PRINTVALSTREAM(rawoutstream, " ERROR\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --enable-error-stack Prints messages from the HDF5 error stack as they occur.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " Optional value 2 also prints file open errors.\n");
PRINTVALSTREAM(rawoutstream, " OPTIONS\n");
PRINTVALSTREAM(rawoutstream, " -h, --help Print a usage message and exit\n");
- PRINTVALSTREAM(rawoutstream, " -v, --verbose Verbose mode, print object information\n");
+ PRINTVALSTREAM(rawoutstream, " -v N, --verbose=N Verbose mode, print object information.\n");
+ PRINTVALSTREAM(rawoutstream, " N - is an integer greater than 1, 2 displays read/write timing\n");
PRINTVALSTREAM(rawoutstream, " -V, --version Print version number and exit\n");
PRINTVALSTREAM(rawoutstream, " -n, --native Use a native HDF5 type when repacking\n");
- PRINTVALSTREAM(rawoutstream, " --enable-error-stack Prints messages from the HDF5 error stack as they occur\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --src-vol-value Value (ID) of the VOL connector to use for opening the\n");
+ PRINTVALSTREAM(rawoutstream, " input HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --src-vol-name Name of the VOL connector to use for opening the input\n");
+ PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --src-vol-info VOL-specific info to pass to the VOL connector used for\n");
+ PRINTVALSTREAM(rawoutstream, " opening the input HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --dst-vol-value Value (ID) of the VOL connector to use for opening the\n");
+ PRINTVALSTREAM(rawoutstream, " output HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --dst-vol-name Name of the VOL connector to use for opening the output\n");
+ PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --dst-vol-info VOL-specific info to pass to the VOL connector used for\n");
+ PRINTVALSTREAM(rawoutstream, " opening the output HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --src-vfd-value Value (ID) of the VFL driver to use for opening the\n");
+ PRINTVALSTREAM(rawoutstream, " input HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --src-vfd-name Name of the VFL driver to use for opening the input\n");
+ PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --src-vfd-info VFD-specific info to pass to the VFL driver used for\n");
+ PRINTVALSTREAM(rawoutstream, " opening the input HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --dst-vfd-value Value (ID) of the VFL driver to use for opening the\n");
+ PRINTVALSTREAM(rawoutstream, " output HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --dst-vfd-name Name of the VFL driver to use for opening the output\n");
+ PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --dst-vfd-info VFD-specific info to pass to the VFL driver used for\n");
+ PRINTVALSTREAM(rawoutstream, " opening the output HDF5 file specified\n");
PRINTVALSTREAM(rawoutstream, " -L, --latest Use latest version of file format\n");
- PRINTVALSTREAM(rawoutstream, " This option will take precedence over the -j and -k options\n");
- PRINTVALSTREAM(rawoutstream, " --low=BOUND The low bound for library release versions to use when creating\n");
- PRINTVALSTREAM(rawoutstream, " objects in the file (default is H5F_LIBVER_EARLIEST)\n");
- PRINTVALSTREAM(rawoutstream, " --high=BOUND The high bound for library release versions to use when creating\n");
- PRINTVALSTREAM(rawoutstream, " objects in the file (default is H5F_LIBVER_LATEST)\n");
+ PRINTVALSTREAM(rawoutstream,
+ " This option will take precedence over the options\n");
+ PRINTVALSTREAM(rawoutstream, " --low and --high\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --low=BOUND The low bound for library release versions to use\n");
+ PRINTVALSTREAM(rawoutstream, " when creating objects in the file\n");
+ PRINTVALSTREAM(rawoutstream, " (default is H5F_LIBVER_EARLIEST)\n");
+ 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,
+ " -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");
- PRINTVALSTREAM(rawoutstream, " -m M, --minimum=M Do not apply the filter to datasets smaller than M\n");
+ PRINTVALSTREAM(rawoutstream,
+ " -m M, --minimum=M Do not apply the filter to datasets smaller than M\n");
PRINTVALSTREAM(rawoutstream, " -e E, --file=E Name of file E with the -f and -l options\n");
- PRINTVALSTREAM(rawoutstream, " -u U, --ublock=U Name of file U with user block data to be added\n");
+ PRINTVALSTREAM(rawoutstream,
+ " -u U, --ublock=U Name of file U with user block data to be added\n");
PRINTVALSTREAM(rawoutstream, " -b B, --block=B Size of user block to be added\n");
- PRINTVALSTREAM(rawoutstream, " -M A, --metadata_block_size=A Metadata block size for H5Pset_meta_block_size\n");
+ PRINTVALSTREAM(rawoutstream,
+ " -M A, --metadata_block_size=A Metadata block size for H5Pset_meta_block_size\n");
PRINTVALSTREAM(rawoutstream, " -t T, --threshold=T Threshold value for H5Pset_alignment\n");
PRINTVALSTREAM(rawoutstream, " -a A, --alignment=A Alignment value for H5Pset_alignment\n");
PRINTVALSTREAM(rawoutstream, " -q Q, --sort_by=Q Sort groups and attributes by index Q\n");
PRINTVALSTREAM(rawoutstream, " -z Z, --sort_order=Z Sort groups and attributes by order Z\n");
PRINTVALSTREAM(rawoutstream, " -f FILT, --filter=FILT Filter type\n");
PRINTVALSTREAM(rawoutstream, " -l LAYT, --layout=LAYT Layout type\n");
- PRINTVALSTREAM(rawoutstream, " -S FS_STRATEGY, --fs_strategy=FS_STRATEGY File space management strategy for H5Pset_file_space_strategy\n");
- PRINTVALSTREAM(rawoutstream, " -P FS_PERSIST, --fs_persist=FS_PERSIST Persisting or not persisting free-space for H5Pset_file_space_strategy\n");
- PRINTVALSTREAM(rawoutstream, " -T FS_THRESHOLD, --fs_threshold=FS_THRESHOLD Free-space section threshold for H5Pset_file_space_strategy\n");
- PRINTVALSTREAM(rawoutstream, " -G FS_PAGESIZE, --fs_pagesize=FS_PAGESIZE File space page size for H5Pset_file_space_page_size\n");
+ PRINTVALSTREAM(rawoutstream,
+ " -S FS_STRATEGY, --fs_strategy=FS_STRATEGY File space management strategy for\n");
+ PRINTVALSTREAM(rawoutstream, " H5Pset_file_space_strategy\n");
+ PRINTVALSTREAM(rawoutstream,
+ " -P FS_PERSIST, --fs_persist=FS_PERSIST Persisting or not persisting free-\n");
+ PRINTVALSTREAM(rawoutstream, " space for H5Pset_file_space_strategy\n");
+ PRINTVALSTREAM(rawoutstream,
+ " -T FS_THRESHOLD, --fs_threshold=FS_THRESHOLD Free-space section threshold\n");
+ PRINTVALSTREAM(rawoutstream, " for H5Pset_file_space_strategy\n");
+ PRINTVALSTREAM(rawoutstream, " -G FS_PAGESIZE, --fs_pagesize=FS_PAGESIZE File space page size for\n");
+ PRINTVALSTREAM(rawoutstream, " H5Pset_file_space_page_size\n");
PRINTVALSTREAM(rawoutstream, "\n");
- PRINTVALSTREAM(rawoutstream, " M - is an integer greater than 1, size of dataset in bytes (default is 0)\n");
+ PRINTVALSTREAM(rawoutstream,
+ " M - is an integer greater than 1, size of dataset in bytes (default is 0)\n");
PRINTVALSTREAM(rawoutstream, " E - is a filename.\n");
PRINTVALSTREAM(rawoutstream, " S - is an integer\n");
PRINTVALSTREAM(rawoutstream, " U - is a filename.\n");
PRINTVALSTREAM(rawoutstream, " T - is an integer\n");
PRINTVALSTREAM(rawoutstream, " A - is an integer greater than zero\n");
- PRINTVALSTREAM(rawoutstream, " Q - is the sort index type for the input file. It can be \"name\" or \"creation_order\" (default)\n");
- PRINTVALSTREAM(rawoutstream, " Z - is the sort order type for the input file. It can be \"descending\" or \"ascending\" (default)\n");
+ PRINTVALSTREAM(rawoutstream,
+ " Q - is the sort index type for the input file. It can be \"name\" or\n");
+ PRINTVALSTREAM(rawoutstream, " \"creation_order\" (default)\n");
+ PRINTVALSTREAM(rawoutstream,
+ " Z - is the sort order type for the input file. It can be \"descending\" or\n");
+ PRINTVALSTREAM(rawoutstream, " \"ascending\" (default)\n");
PRINTVALSTREAM(rawoutstream, " B - is the user block size, any value that is 512 or greater and is\n");
PRINTVALSTREAM(rawoutstream, " a power of 2 (1024 default)\n");
- PRINTVALSTREAM(rawoutstream, " F - is the shared object header message type, any of <dspace|dtype|fill|\n");
+ PRINTVALSTREAM(rawoutstream,
+ " F - is the shared object header message type, any of <dspace|dtype|fill|\n");
PRINTVALSTREAM(rawoutstream, " pline|attr>. If F is not specified, S applies to all messages\n");
PRINTVALSTREAM(rawoutstream, "\n");
- PRINTVALSTREAM(rawoutstream, " BOUND is an integer indicating the library release versions to use when creating\n");
- PRINTVALSTREAM(rawoutstream, " objects in the file (see H5Pset_libver_bounds()):\n");
+ PRINTVALSTREAM(rawoutstream,
+ " BOUND is an integer indicating the library release versions to use when\n");
+ PRINTVALSTREAM(rawoutstream, " creating objects in the file (see H5Pset_libver_bounds()):\n");
PRINTVALSTREAM(rawoutstream, " 0: This is H5F_LIBVER_EARLIEST in H5F_libver_t struct\n");
PRINTVALSTREAM(rawoutstream, " 1: This is H5F_LIBVER_V18 in H5F_libver_t struct\n");
PRINTVALSTREAM(rawoutstream, " 2: This is H5F_LIBVER_V110 in H5F_libver_t struct\n");
PRINTVALSTREAM(rawoutstream, " 3: This is H5F_LIBVER_V112 in H5F_libver_t struct\n");
- PRINTVALSTREAM(rawoutstream, " (H5F_LIBVER_LATEST is aliased to H5F_LIBVER_V112 for this release\n");
+ PRINTVALSTREAM(rawoutstream, " 4: This is H5F_LIBVER_V114 in H5F_libver_t struct\n");
+ PRINTVALSTREAM(rawoutstream,
+ " (H5F_LIBVER_LATEST is aliased to H5F_LIBVER_V114 for this release\n");
PRINTVALSTREAM(rawoutstream, "\n");
PRINTVALSTREAM(rawoutstream, " FS_STRATEGY is a string indicating the file space strategy used:\n");
PRINTVALSTREAM(rawoutstream, " FSM_AGGR:\n");
- PRINTVALSTREAM(rawoutstream, " The mechanisms used in managing file space are free-space managers, aggregators and virtual file driver.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " The mechanisms used in managing file space are free-space\n");
+ PRINTVALSTREAM(rawoutstream, " managers, aggregators and virtual file driver.\n");
PRINTVALSTREAM(rawoutstream, " PAGE:\n");
- PRINTVALSTREAM(rawoutstream, " The mechanisms used in managing file space are free-space managers with embedded paged aggregation and virtual file driver.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " The mechanisms used in managing file space are free-space\n");
+ PRINTVALSTREAM(rawoutstream,
+ " managers with embedded paged aggregation and virtual file driver.\n");
PRINTVALSTREAM(rawoutstream, " AGGR:\n");
- PRINTVALSTREAM(rawoutstream, " The mechanisms used in managing file space are aggregators and virtual file driver.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " The mechanisms used in managing file space are aggregators and\n");
+ PRINTVALSTREAM(rawoutstream, " virtual file driver.\n");
PRINTVALSTREAM(rawoutstream, " NONE:\n");
- PRINTVALSTREAM(rawoutstream, " The mechanisms used in managing file space are virtual file driver.\n");
- PRINTVALSTREAM(rawoutstream, " The default strategy when not set is FSM_AGGR without persisting free-space.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " The mechanisms used in managing file space are virtual file\n");
+ PRINTVALSTREAM(rawoutstream, " driver.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " The default strategy when not set is FSM_AGGR without persisting free-\n");
+ PRINTVALSTREAM(rawoutstream, " space.\n");
PRINTVALSTREAM(rawoutstream, "\n");
- PRINTVALSTREAM(rawoutstream, " FS_PERSIST is 1 to persisting free-space or 0 to not persisting free-space.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " FS_PERSIST is 1 to persisting free-space or 0 to not persisting free-space.\n");
PRINTVALSTREAM(rawoutstream, " The default when not set is not persisting free-space.\n");
PRINTVALSTREAM(rawoutstream, " The value is ignored for AGGR and NONE strategies.\n");
PRINTVALSTREAM(rawoutstream, "\n");
- PRINTVALSTREAM(rawoutstream, " FS_THRESHOLD is the minimum size (in bytes) of free-space sections to be tracked by the library.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " FS_THRESHOLD is the minimum size (in bytes) of free-space sections to be\n");
+ PRINTVALSTREAM(rawoutstream, " tracked by the library.\n");
PRINTVALSTREAM(rawoutstream, " The default when not set is 1.\n");
PRINTVALSTREAM(rawoutstream, " The value is ignored for AGGR and NONE strategies.\n");
PRINTVALSTREAM(rawoutstream, "\n");
- PRINTVALSTREAM(rawoutstream, " FS_PAGESIZE is the size (in bytes) >=512 that is used by the library when the file space strategy PAGE is used.\n");
+ PRINTVALSTREAM(rawoutstream,
+ " FS_PAGESIZE is the size (in bytes) >=512 that is used by the library when\n");
+ PRINTVALSTREAM(rawoutstream, " the file space strategy PAGE is used.\n");
PRINTVALSTREAM(rawoutstream, " The default when not set is 4096.\n");
PRINTVALSTREAM(rawoutstream, "\n");
PRINTVALSTREAM(rawoutstream, " FILT - is a string with the format:\n");
PRINTVALSTREAM(rawoutstream, "\n");
PRINTVALSTREAM(rawoutstream, " <list of objects>:<name of filter>=<filter parameters>\n");
PRINTVALSTREAM(rawoutstream, "\n");
- PRINTVALSTREAM(rawoutstream, " <list of objects> is a comma separated list of object names, meaning apply\n");
- PRINTVALSTREAM(rawoutstream, " compression only to those objects. If no names are specified, the filter\n");
+ PRINTVALSTREAM(rawoutstream,
+ " <list of objects> is a comma separated list of object names, meaning apply\n");
+ PRINTVALSTREAM(rawoutstream,
+ " compression only to those objects. If no names are specified, the filter\n");
PRINTVALSTREAM(rawoutstream, " is applied to all objects\n");
PRINTVALSTREAM(rawoutstream, " <name of filter> can be:\n");
PRINTVALSTREAM(rawoutstream, " GZIP, to apply the HDF5 GZIP filter (GZIP compression)\n");
@@ -170,24 +275,31 @@ static void usage(const char *prog) {
PRINTVALSTREAM(rawoutstream, " NONE, to remove all filters\n");
PRINTVALSTREAM(rawoutstream, " <filter parameters> is optional filter parameter information\n");
PRINTVALSTREAM(rawoutstream, " GZIP=<deflation level> from 1-9\n");
- PRINTVALSTREAM(rawoutstream, " SZIP=<pixels per block,coding> pixels per block is a even number in\n");
+ PRINTVALSTREAM(rawoutstream,
+ " SZIP=<pixels per block,coding> pixels per block is a even number in\n");
PRINTVALSTREAM(rawoutstream, " 2-32 and coding method is either EC or NN\n");
PRINTVALSTREAM(rawoutstream, " SHUF (no parameter)\n");
PRINTVALSTREAM(rawoutstream, " FLET (no parameter)\n");
PRINTVALSTREAM(rawoutstream, " NBIT (no parameter)\n");
- PRINTVALSTREAM(rawoutstream, " SOFF=<scale_factor,scale_type> scale_factor is an integer and scale_type\n");
+ PRINTVALSTREAM(rawoutstream,
+ " SOFF=<scale_factor,scale_type> scale_factor is an integer and scale_type\n");
PRINTVALSTREAM(rawoutstream, " is either IN or DS\n");
- PRINTVALSTREAM(rawoutstream, " UD=<filter_number,filter_flag,cd_value_count,value_1[,value_2,...,value_N]>\n");
- PRINTVALSTREAM(rawoutstream, " required values for filter_number,filter_flag,cd_value_count,value_1\n");
- PRINTVALSTREAM(rawoutstream, " optional values for value_2 to value_N\n");
+ PRINTVALSTREAM(rawoutstream,
+ " UD=<filter_number,filter_flag,cd_value_count,value1[,value2,...,valueN]>\n");
+ PRINTVALSTREAM(rawoutstream,
+ " Required values: filter_number, filter_flag, cd_value_count, value1\n");
+ PRINTVALSTREAM(rawoutstream, " Optional values: value2 to valueN\n");
+ PRINTVALSTREAM(rawoutstream, " filter_flag: 1 is OPTIONAL or 0 is MANDATORY\n");
PRINTVALSTREAM(rawoutstream, " NONE (no parameter)\n");
PRINTVALSTREAM(rawoutstream, "\n");
PRINTVALSTREAM(rawoutstream, " LAYT - is a string with the format:\n");
PRINTVALSTREAM(rawoutstream, "\n");
PRINTVALSTREAM(rawoutstream, " <list of objects>:<layout type>=<layout parameters>\n");
PRINTVALSTREAM(rawoutstream, "\n");
- PRINTVALSTREAM(rawoutstream, " <list of objects> is a comma separated list of object names, meaning that\n");
- PRINTVALSTREAM(rawoutstream, " layout information is supplied for those objects. If no names are\n");
+ PRINTVALSTREAM(rawoutstream,
+ " <list of objects> is a comma separated list of object names, meaning that\n");
+ PRINTVALSTREAM(rawoutstream,
+ " layout information is supplied for those objects. If no names are\n");
PRINTVALSTREAM(rawoutstream, " specified, the layout type is applied to all objects\n");
PRINTVALSTREAM(rawoutstream, " <layout type> can be:\n");
PRINTVALSTREAM(rawoutstream, " CHUNK, to apply chunking layout\n");
@@ -206,22 +318,20 @@ static void usage(const char *prog) {
PRINTVALSTREAM(rawoutstream, "\n");
PRINTVALSTREAM(rawoutstream, "2) h5repack -v -f dset1:SZIP=8,NN file1 file2\n");
PRINTVALSTREAM(rawoutstream, "\n");
- PRINTVALSTREAM(rawoutstream, " SZIP compression with 8 pixels per block and NN coding method to object dset1\n");
+ PRINTVALSTREAM(rawoutstream,
+ " SZIP compression with 8 pixels per block and NN coding method to object dset1\n");
PRINTVALSTREAM(rawoutstream, "\n");
- PRINTVALSTREAM(rawoutstream, "3) h5repack -v -l dset1,dset2:CHUNK=20x10 -f dset3,dset4,dset5:NONE file1 file2\n");
+ PRINTVALSTREAM(rawoutstream,
+ "3) h5repack -v -l dset1,dset2:CHUNK=20x10 -f dset3,dset4,dset5:NONE file1 file2\n");
PRINTVALSTREAM(rawoutstream, "\n");
- PRINTVALSTREAM(rawoutstream, " Chunked layout, with a layout size of 20x10, to objects dset1 and dset2\n");
+ PRINTVALSTREAM(rawoutstream,
+ " Chunked layout, with a layout size of 20x10, to objects dset1 and dset2\n");
PRINTVALSTREAM(rawoutstream, " and remove filters to objects dset3, dset4, dset5\n");
PRINTVALSTREAM(rawoutstream, "\n");
PRINTVALSTREAM(rawoutstream, "4) h5repack -L -c 10 -s 20:dtype file1 file2\n");
PRINTVALSTREAM(rawoutstream, "\n");
PRINTVALSTREAM(rawoutstream, " Using latest file format with maximum compact group size of 10 and\n");
- PRINTVALSTREAM(rawoutstream, " and minimum shared datatype size of 20\n");
- PRINTVALSTREAM(rawoutstream, "\n");
- PRINTVALSTREAM(rawoutstream, "5) h5repack --low=0 --high=1 file1 file2\n");
- PRINTVALSTREAM(rawoutstream, "\n");
- PRINTVALSTREAM(rawoutstream, " Set low=H5F_LIBVER_EARLIEST and high=H5F_LIBVER_V18 via H5Pset_libver_bounds() when\n");
- PRINTVALSTREAM(rawoutstream, " creating the repacked file: file2\n");
+ PRINTVALSTREAM(rawoutstream, " minimum shared datatype size of 20\n");
PRINTVALSTREAM(rawoutstream, "\n");
PRINTVALSTREAM(rawoutstream, "5) h5repack -f SHUF -f GZIP=1 file1 file2\n");
PRINTVALSTREAM(rawoutstream, "\n");
@@ -231,6 +341,11 @@ static void usage(const char *prog) {
PRINTVALSTREAM(rawoutstream, "\n");
PRINTVALSTREAM(rawoutstream, " Add bzip2 filter to all datasets\n");
PRINTVALSTREAM(rawoutstream, "\n");
+ PRINTVALSTREAM(rawoutstream, "7) h5repack --low=0 --high=1 file1 file2\n");
+ PRINTVALSTREAM(rawoutstream, "\n");
+ PRINTVALSTREAM(rawoutstream, " Set low=H5F_LIBVER_EARLIEST and high=H5F_LIBVER_V18 via\n");
+ PRINTVALSTREAM(rawoutstream, " H5Pset_libver_bounds() when creating the repacked file, file2\n");
+ PRINTVALSTREAM(rawoutstream, "\n");
}
/*-------------------------------------------------------------------------
@@ -241,7 +356,8 @@ static void usage(const char *prog) {
* Return: Does not return
*-------------------------------------------------------------------------
*/
-static void leave(int ret)
+static void
+leave(int ret)
{
h5tools_close();
HDexit(ret);
@@ -255,17 +371,17 @@ static void leave(int ret)
* Return: void, exit on error
*-------------------------------------------------------------------------
*/
-static
-int read_info(const char *filename, pack_opt_t *options)
+static int
+read_info(const char *filename, pack_opt_t *options)
{
- char stype[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- char comp_info[1024];
+ char stype[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ char comp_info[1024];
FILE *fp = NULL;
- char c;
- int i, rc = 1;
- int ret_value = EXIT_SUCCESS;
+ char c;
+ int i;
+ int ret_value = EXIT_SUCCESS;
- if ((fp = HDfopen(filename, "r")) == (FILE *) NULL) {
+ if (NULL == (fp = HDfopen(filename, "r"))) {
error_msg("cannot open options file %s\n", filename);
h5tools_setstatus(EXIT_FAILURE);
ret_value = EXIT_FAILURE;
@@ -274,108 +390,64 @@ int read_info(const char *filename, pack_opt_t *options)
/* cycle until end of file reached */
while (1) {
- rc = fscanf(fp, "%s", stype);
- if (rc == -1)
+ if (EOF == HDfscanf(fp, "%9s", stype))
break;
- /*-------------------------------------------------------------------------
- * filter
- *-------------------------------------------------------------------------
- */
- if (HDstrcmp(stype,"-f") == 0) {
- /* find begining of info */
- i = 0;
- c = '0';
- while (c != ' ') {
- if(fscanf(fp, "%c", &c) < 0 && HDferror(fp)) {
- error_msg("fscanf error\n");
- h5tools_setstatus(EXIT_FAILURE);
- ret_value = EXIT_FAILURE;
- goto done;
- } /* end if */
- if (HDfeof(fp))
- break;
- }
- c = '0';
- /* go until end */
- while (c != ' ') {
- if(fscanf(fp, "%c", &c) < 0 && HDferror(fp)) {
- error_msg("fscanf error\n");
- h5tools_setstatus(EXIT_FAILURE);
- ret_value = EXIT_FAILURE;
- goto done;
- } /* end if */
- comp_info[i] = c;
- i++;
- if (HDfeof(fp))
- break;
- if (c == 10 /*eol*/)
- break;
- }
- comp_info[i - 1] = '\0'; /*cut the last " */
+ /* Info indicator must be for layout or filter */
+ if (HDstrcmp(stype, "-l") != 0 && HDstrcmp(stype, "-f") != 0) {
+ error_msg("bad file format for %s", filename);
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = EXIT_FAILURE;
+ goto done;
+ }
- if (h5repack_addfilter(comp_info, options) == -1) {
- error_msg("could not add compression option\n");
+ /* find beginning of info */
+ i = 0;
+ c = '0';
+ while (c != ' ') {
+ if (HDfscanf(fp, "%c", &c) < 0 && HDferror(fp)) {
+ error_msg("fscanf error\n");
h5tools_setstatus(EXIT_FAILURE);
ret_value = EXIT_FAILURE;
goto done;
}
+ if (HDfeof(fp))
+ break;
}
- /*-------------------------------------------------------------------------
- * layout
- *-------------------------------------------------------------------------
- */
- else if (HDstrcmp(stype,"-l") == 0) {
-
- /* find begining of info */
- i = 0;
- c = '0';
- while (c != ' ') {
- if(fscanf(fp, "%c", &c) < 0 && HDferror(fp)) {
- error_msg("fscanf error\n");
- h5tools_setstatus(EXIT_FAILURE);
- ret_value = EXIT_FAILURE;
- goto done;
- } /* end if */
- if (HDfeof(fp))
- break;
- }
- c = '0';
- /* go until end */
- while (c != ' ') {
- if(fscanf(fp, "%c", &c) < 0 && HDferror(fp)) {
- error_msg("fscanf error\n");
- h5tools_setstatus(EXIT_FAILURE);
- ret_value = EXIT_FAILURE;
- goto done;
- } /* end if */
- comp_info[i] = c;
- i++;
- if (HDfeof(fp))
- break;
- if (c == 10 /*eol*/)
- break;
+ c = '0';
+ /* go until end */
+ while (c != ' ') {
+ if (HDfscanf(fp, "%c", &c) < 0 && HDferror(fp)) {
+ error_msg("fscanf error\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = EXIT_FAILURE;
+ goto done;
}
- comp_info[i - 1] = '\0'; /*cut the last " */
+ comp_info[i++] = c;
+ if (HDfeof(fp))
+ break;
+ if (c == 10 /*eol*/)
+ break;
+ }
+ comp_info[i - 1] = '\0'; /*cut the last " */
+ 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;
}
}
- /*-------------------------------------------------------------------------
- * not valid
- *-------------------------------------------------------------------------
- */
else {
- error_msg("bad file format for %s", filename);
- h5tools_setstatus(EXIT_FAILURE);
- ret_value = EXIT_FAILURE;
- goto done;
+ if (h5repack_addfilter(comp_info, options) == -1) {
+ error_msg("could not add compression option\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = EXIT_FAILURE;
+ goto done;
+ }
}
- }
+ } /* end while info-read cycling */
done:
if (fp)
@@ -399,9 +471,9 @@ set_sort_by(const char *form)
{
H5_index_t idx_type = H5_INDEX_UNKNOWN;
- if (HDstrcmp(form,"name")==0) /* H5_INDEX_NAME */
+ if (!HDstrcmp(form, "name"))
idx_type = H5_INDEX_NAME;
- else if (HDstrcmp(form,"creation_order")==0) /* H5_INDEX_CRT_ORDER */
+ else if (!HDstrcmp(form, "creation_order"))
idx_type = H5_INDEX_CRT_ORDER;
return idx_type;
@@ -422,9 +494,9 @@ set_sort_order(const char *form)
{
H5_iter_order_t iter_order = H5_ITER_UNKNOWN;
- if (HDstrcmp(form,"ascending")==0) /* H5_ITER_INC */
+ if (!HDstrcmp(form, "ascending"))
iter_order = H5_ITER_INC;
- else if (HDstrcmp(form,"descending")==0) /* H5_ITER_DEC */
+ else if (!HDstrcmp(form, "descending"))
iter_order = H5_ITER_DEC;
return iter_order;
@@ -436,47 +508,67 @@ set_sort_order(const char *form)
* Purpose: parse command line input
*-------------------------------------------------------------------------
*/
-static
-int parse_command_line(int argc, const char **argv, pack_opt_t* options)
+static int
+parse_command_line(int argc, const char *const *argv, pack_opt_t *options)
{
- int opt;
- int ret_value = 0;
+ h5tools_vol_info_t in_vol_info;
+ h5tools_vol_info_t out_vol_info;
+ h5tools_vfd_info_t in_vfd_info;
+ h5tools_vfd_info_t out_vfd_info;
+ hbool_t custom_in_vol = FALSE;
+ hbool_t custom_in_vfd = FALSE;
+ hbool_t custom_out_vol = FALSE;
+ hbool_t custom_out_vfd = FALSE;
+ hid_t tmp_fapl = H5I_INVALID_HID;
+ int bound, opt;
+ int ret_value = 0;
+
+ /* Initialize fapl info structs */
+ HDmemset(&in_vol_info, 0, sizeof(h5tools_vol_info_t));
+ HDmemset(&out_vol_info, 0, sizeof(h5tools_vol_info_t));
+ HDmemset(&in_vfd_info, 0, sizeof(h5tools_vfd_info_t));
+ HDmemset(&out_vfd_info, 0, sizeof(h5tools_vfd_info_t));
/* parse command line options */
- while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) {
- switch ((char) opt) {
+ while (EOF != (opt = H5_get_option(argc, argv, s_opts, l_opts))) {
+ switch ((char)opt) {
/* -i for backward compatibility */
case 'i':
- infile = opt_arg;
- has_i_o = 1;
+ infile = H5_optarg;
+ has_i++;
break;
/* -o for backward compatibility */
case 'o':
- outfile = opt_arg;
- has_i_o = 1;
+ outfile = H5_optarg;
+ has_o++;
break;
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':
- options->verbose = 1;
+ if (H5_optarg != NULL) {
+ if (2 == HDatoi(H5_optarg))
+ options->verbose = 2;
+ }
+ else
+ options->verbose = 1;
break;
case 'f':
/* parse the -f filter option */
- if (h5repack_addfilter(opt_arg, options) < 0) {
+ if (h5repack_addfilter(H5_optarg, options) < 0) {
error_msg("in parsing filter\n");
h5tools_setstatus(EXIT_FAILURE);
ret_value = -1;
@@ -486,7 +578,7 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
case 'l':
/* parse the -l layout option */
- if (h5repack_addlayout(opt_arg, options) < 0) {
+ if (h5repack_addlayout(H5_optarg, options) < 0) {
error_msg("in parsing layout\n");
h5tools_setstatus(EXIT_FAILURE);
ret_value = -1;
@@ -495,9 +587,9 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
break;
case 'm':
- options->min_comp = HDstrtoull(opt_arg , NULL, 0);
- if ((int) options->min_comp <= 0) {
- error_msg("invalid minimum compress size <%s>\n", opt_arg);
+ options->min_comp = HDstrtoull(H5_optarg, NULL, 0);
+ if ((int)options->min_comp <= 0) {
+ error_msg("invalid minimum compress size <%s>\n", H5_optarg);
h5tools_setstatus(EXIT_FAILURE);
ret_value = -1;
goto done;
@@ -505,9 +597,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(H5_optarg, options)) < 0) {
+ error_msg("failed to read from repack options file <%s>\n", H5_optarg);
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
goto done;
+ }
break;
case 'n':
@@ -519,139 +614,149 @@ 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(H5_optarg);
+ 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(H5_optarg);
+ 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':
- options->grp_compact = HDatoi( opt_arg );
+ options->grp_compact = HDatoi(H5_optarg);
if (options->grp_compact > 0)
options->latest = TRUE; /* must use latest format */
break;
case 'd':
- options->grp_indexed = HDatoi( opt_arg );
+ options->grp_indexed = HDatoi(H5_optarg);
if (options->grp_indexed > 0)
options->latest = TRUE; /* must use latest format */
break;
- case 's':
- {
- int idx = 0;
- int ssize = 0;
- char *msgPtr = HDstrchr( opt_arg, ':');
- options->latest = TRUE; /* must use latest format */
- if (msgPtr == NULL) {
- ssize = HDatoi( opt_arg );
- for (idx = 0; idx < 5; idx++)
- options->msg_size[idx] = ssize;
- }
- else {
- char msgType[10];
-
- HDstrcpy(msgType, msgPtr + 1);
- msgPtr[0] = '\0';
- ssize = HDatoi( opt_arg );
- if (HDstrncmp(msgType, "dspace",6) == 0)
- options->msg_size[0] = ssize;
- else if (HDstrncmp(msgType, "dtype", 5) == 0)
- options->msg_size[1] = ssize;
- else if (HDstrncmp(msgType, "fill", 4) == 0)
- options->msg_size[2] = ssize;
- else if (HDstrncmp(msgType, "pline", 5) == 0)
- options->msg_size[3] = ssize;
- else if (HDstrncmp(msgType, "attr", 4) == 0)
- options->msg_size[4] = ssize;
- }
+ case 's': {
+ int idx = 0;
+ int ssize = 0;
+ char *msgPtr = HDstrchr(H5_optarg, ':');
+ options->latest = TRUE; /* must use latest format */
+ if (msgPtr == NULL) {
+ ssize = HDatoi(H5_optarg);
+ for (idx = 0; idx < 5; idx++)
+ options->msg_size[idx] = ssize;
}
- break;
+ else {
+ char msgType[10];
+
+ HDstrcpy(msgType, msgPtr + 1);
+ msgPtr[0] = '\0';
+ ssize = HDatoi(H5_optarg);
+ if (!HDstrncmp(msgType, "dspace", 6))
+ options->msg_size[0] = ssize;
+ else if (!HDstrncmp(msgType, "dtype", 5))
+ options->msg_size[1] = ssize;
+ else if (!HDstrncmp(msgType, "fill", 4))
+ options->msg_size[2] = ssize;
+ else if (!HDstrncmp(msgType, "pline", 5))
+ options->msg_size[3] = ssize;
+ else if (!HDstrncmp(msgType, "attr", 4))
+ options->msg_size[4] = ssize;
+ }
+ } break;
case 'u':
- options->ublock_filename = opt_arg;
+ options->ublock_filename = H5_optarg;
break;
case 'b':
- options->ublock_size = (hsize_t) HDatol( opt_arg );
+ options->ublock_size = (hsize_t)HDatol(H5_optarg);
break;
case 'M':
- options->meta_block_size = (hsize_t) HDatol( opt_arg );
+ options->meta_block_size = (hsize_t)HDatol(H5_optarg);
break;
case 't':
- options->threshold = (hsize_t) HDatol( opt_arg );
+ options->threshold = (hsize_t)HDatol(H5_optarg);
break;
case 'a':
- options->alignment = HDstrtoull(opt_arg , NULL, 0);
+ options->alignment = HDstrtoull(H5_optarg, NULL, 0);
if (options->alignment < 1) {
- error_msg("invalid alignment size\n", opt_arg);
+ error_msg("invalid alignment size `%s`\n", H5_optarg);
h5tools_setstatus(EXIT_FAILURE);
ret_value = -1;
goto done;
}
break;
- case 'S':
- {
- char strategy[MAX_NC_NAME];
-
- HDstrcpy(strategy, opt_arg);
- if(!HDstrcmp(strategy, "FSM_AGGR"))
- options->fs_strategy = H5F_FSPACE_STRATEGY_FSM_AGGR;
- else if(!HDstrcmp(strategy, "PAGE"))
- options->fs_strategy = H5F_FSPACE_STRATEGY_PAGE;
- else if(!HDstrcmp(strategy, "AGGR"))
- options->fs_strategy = H5F_FSPACE_STRATEGY_AGGR;
- else if(!HDstrcmp(strategy, "NONE"))
- options->fs_strategy = H5F_FSPACE_STRATEGY_NONE;
- else {
- error_msg("invalid file space management strategy\n", opt_arg);
- h5tools_setstatus(EXIT_FAILURE);
- ret_value = -1;
- goto done;
- }
- if(options->fs_strategy == (H5F_fspace_strategy_t)0)
- /* To distinguish the "specified" zero value */
- options->fs_strategy = (H5F_fspace_strategy_t)-1;
+ case 'S': {
+ char strategy[MAX_NC_NAME];
+
+ HDstrcpy(strategy, H5_optarg);
+ if (!HDstrcmp(strategy, "FSM_AGGR"))
+ options->fs_strategy = H5F_FSPACE_STRATEGY_FSM_AGGR;
+ else if (!HDstrcmp(strategy, "PAGE"))
+ options->fs_strategy = H5F_FSPACE_STRATEGY_PAGE;
+ else if (!HDstrcmp(strategy, "AGGR"))
+ options->fs_strategy = H5F_FSPACE_STRATEGY_AGGR;
+ else if (!HDstrcmp(strategy, "NONE"))
+ options->fs_strategy = H5F_FSPACE_STRATEGY_NONE;
+ else {
+ error_msg("invalid file space management strategy `%s`\n", H5_optarg);
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
+ goto done;
}
- break;
+ if (options->fs_strategy == (H5F_fspace_strategy_t)0)
+ /* To distinguish the "specified" zero value */
+ options->fs_strategy = (H5F_fspace_strategy_t)-1;
+ } break;
case 'P':
- options->fs_persist = HDatoi(opt_arg);
- if(options->fs_persist == 0)
+ options->fs_persist = HDatoi(H5_optarg);
+ if (options->fs_persist == 0)
/* To distinguish the "specified" zero value */
options->fs_persist = -1;
break;
case 'T':
- options->fs_threshold = HDatol(opt_arg);
- if(options->fs_threshold == 0)
+ options->fs_threshold = HDatol(H5_optarg);
+ if (options->fs_threshold == 0)
/* To distinguish the "specified" zero value */
options->fs_threshold = -1;
break;
case 'G':
- options->fs_pagesize = HDstrtoll(opt_arg, NULL, 0);
- if(options->fs_pagesize == 0)
+ options->fs_pagesize = HDstrtoll(H5_optarg, NULL, 0);
+ if (options->fs_pagesize == 0)
/* To distinguish the "specified" zero value */
- options->fs_pagesize = -1;
+ options->fs_pagesize = -1;
break;
case 'q':
- if((sort_by = set_sort_by(opt_arg)) < 0) {
- error_msg(" failed to set sort by form <%s>\n", opt_arg);
+ if (H5_INDEX_UNKNOWN == (sort_by = set_sort_by(H5_optarg))) {
+ error_msg("failed to set sort by form <%s>\n", H5_optarg);
h5tools_setstatus(EXIT_FAILURE);
ret_value = -1;
goto done;
@@ -659,8 +764,8 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
break;
case 'z':
- if((sort_order = set_sort_order(opt_arg)) < 0) {
- error_msg(" failed to set sort order form <%s>\n", opt_arg);
+ if (H5_ITER_UNKNOWN == (sort_order = set_sort_order(H5_optarg))) {
+ error_msg("failed to set sort order form <%s>\n", H5_optarg);
h5tools_setstatus(EXIT_FAILURE);
ret_value = -1;
goto done;
@@ -668,23 +773,150 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
break;
case 'E':
- enable_error_stack = 1;
+ if (H5_optarg != NULL)
+ enable_error_stack = HDatoi(H5_optarg);
+ else
+ enable_error_stack = 1;
+ break;
+
+ case '1':
+ in_vol_info.type = VOL_BY_VALUE;
+ in_vol_info.u.value = (H5VL_class_value_t)HDatoi(H5_optarg);
+ custom_in_vol = TRUE;
+ break;
+
+ case '2':
+ in_vol_info.type = VOL_BY_NAME;
+ in_vol_info.u.name = H5_optarg;
+ custom_in_vol = TRUE;
+ break;
+
+ case '3':
+ in_vol_info.info_string = H5_optarg;
+ break;
+
+ case '4':
+ out_vol_info.type = VOL_BY_VALUE;
+ out_vol_info.u.value = (H5VL_class_value_t)HDatoi(H5_optarg);
+ custom_out_vol = TRUE;
+ break;
+
+ case '5':
+ out_vol_info.type = VOL_BY_NAME;
+ out_vol_info.u.name = H5_optarg;
+ custom_out_vol = TRUE;
+ break;
+
+ case '6':
+ out_vol_info.info_string = H5_optarg;
+ break;
+
+ case '7':
+ in_vfd_info.type = VFD_BY_VALUE;
+ in_vfd_info.u.value = (H5FD_class_value_t)HDatoi(H5_optarg);
+ custom_in_vfd = TRUE;
+ break;
+
+ case '8':
+ in_vfd_info.type = VFD_BY_NAME;
+ in_vfd_info.u.name = H5_optarg;
+ custom_in_vfd = TRUE;
+ break;
+
+ case '9':
+ in_vfd_info.info = (const void *)H5_optarg;
+ break;
+
+ case '0':
+ out_vfd_info.type = VFD_BY_VALUE;
+ out_vfd_info.u.value = (H5FD_class_value_t)HDatoi(H5_optarg);
+ custom_out_vfd = TRUE;
+ break;
+
+ case 'Y':
+ out_vfd_info.type = VFD_BY_NAME;
+ out_vfd_info.u.name = H5_optarg;
+ custom_out_vfd = TRUE;
+ break;
+
+ case 'Z':
+ out_vfd_info.info = (const void *)H5_optarg;
break;
default:
break;
- } /* switch */
- } /* while */
+ } /* end switch */
+ } /* end while there are more options to parse */
- if (has_i_o == 0) {
- /* check for file names to be processed */
- if (argc <= opt_ind || argv[opt_ind + 1] == NULL) {
- error_msg("missing file names\n");
+ /* If neither -i nor -o given, get in and out files positionally */
+ if (0 == (has_i + has_o)) {
+ if (argv[H5_optind] != NULL && argv[H5_optind + 1] != NULL) {
+ infile = argv[H5_optind];
+ outfile = argv[H5_optind + 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;
+ }
+
+ /* Setup FAPL for input and output file accesses */
+ if (custom_in_vol || custom_in_vfd) {
+ if ((tmp_fapl = h5tools_get_fapl(options->fin_fapl, custom_in_vol ? &in_vol_info : NULL,
+ custom_in_vfd ? &in_vfd_info : NULL)) < 0) {
+ error_msg("failed to setup FAPL for input file\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
+ goto done;
+ }
+
+ /* Close old FAPL */
+ if (options->fin_fapl != H5P_DEFAULT)
+ if (H5Pclose(options->fin_fapl) < 0) {
+ error_msg("failed to close FAPL\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
+ goto done;
+ }
+
+ options->fin_fapl = tmp_fapl;
+ }
+
+ if (custom_out_vol || custom_out_vfd) {
+ if ((tmp_fapl = h5tools_get_fapl(options->fout_fapl, custom_out_vol ? &out_vol_info : NULL,
+ custom_out_vfd ? &out_vfd_info : NULL)) < 0) {
+ error_msg("failed to setup FAPL for output file\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
+ goto done;
+ }
+
+ /* Close old FAPL */
+ if (options->fout_fapl != H5P_DEFAULT)
+ if (H5Pclose(options->fout_fapl) < 0) {
+ error_msg("failed to close FAPL\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
+ goto done;
+ }
+
+ options->fout_fapl = tmp_fapl;
+ }
done:
return ret_value;
@@ -700,81 +932,69 @@ done:
* Failure: EXIT_FAILURE(1)
*-------------------------------------------------------------------------
*/
-int main(int argc, const char **argv)
+int
+main(int argc, char **argv)
{
pack_opt_t options; /*the global options */
- H5E_auto2_t func;
- H5E_auto2_t tools_func;
- void *edata;
- void *tools_edata;
+ 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, (const char *const *)argv, &options);
+ if (parse_ret < 0) {
+ HDprintf("Error occurred while parsing command-line options\n");
+ h5tools_setstatus(EXIT_FAILURE);
goto done;
-
- /* get file names if they were not yet got */
- if (has_i_o == 0) {
-
- if (argv[opt_ind] != NULL && argv[opt_ind + 1] != NULL) {
- infile = argv[opt_ind];
- outfile = argv[opt_ind + 1];
-
- if ( HDstrcmp( infile, outfile ) == 0) {
- error_msg("file names cannot be the same\n");
- usage(h5tools_getprogname());
- h5tools_setstatus(EXIT_FAILURE);
- goto done;
- }
- }
- else {
- error_msg("file names missing\n");
- usage(h5tools_getprogname());
- h5tools_setstatus(EXIT_FAILURE);
- goto done;
- }
}
-
- if (enable_error_stack > 0) {
- H5Eset_auto2(H5E_DEFAULT, func, edata);
- H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata);
+ else if (parse_ret > 0) {
+ /* Short-circuit success */
+ h5tools_setstatus(EXIT_SUCCESS);
+ goto done;
}
+ /* 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);
leave(h5tools_getstatus());
}
-
diff --git a/tools/src/h5repack/h5repack_opttable.c b/tools/src/h5repack/h5repack_opttable.c
index 7ab8c6e..167506f 100644
--- a/tools/src/h5repack/h5repack_opttable.c
+++ b/tools/src/h5repack/h5repack_opttable.c
@@ -6,7 +6,7 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -21,23 +21,25 @@
* Purpose: initialize a pack_info_t structure
*
* Return: void
- *-------------------------------------------------------------------------
+ *-------------------------------------------------------------------------
*/
-void init_packobject(pack_info_t *obj) {
+void
+init_packobject(pack_info_t *obj)
+{
int j, k;
HDstrcpy(obj->path, "\0");
for (j = 0; j < H5_REPACK_MAX_NFILTERS; j++) {
- obj->filter[j].filtn = -1;
+ obj->filter[j].filtn = -1;
obj->filter[j].cd_nelmts = CD_VALUES;
for (k = 0; k < CD_VALUES; k++)
obj->filter[j].cd_values[k] = 0;
}
obj->chunk.rank = -1;
- obj->refobj_id = -1;
- obj->layout = H5D_LAYOUT_ERROR;
- obj->nfilters = 0;
+ obj->refobj_id = -1;
+ obj->layout = H5D_LAYOUT_ERROR;
+ obj->nfilters = 0;
}
/*-------------------------------------------------------------------------
@@ -49,11 +51,13 @@ 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 +68,9 @@ 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;
@@ -72,15 +78,14 @@ static void aux_tblinsert_layout(pack_opttbl_t *table, unsigned int I, pack_info
/* -2 means the NONE option, remove chunking
and set the layout to contiguous */
if (pack->chunk.rank == -2) {
- table->objs[I].layout = H5D_CONTIGUOUS;
+ table->objs[I].layout = H5D_CONTIGUOUS;
table->objs[I].chunk.rank = -2;
}
/* otherwise set the chunking type */
else {
table->objs[I].chunk.rank = pack->chunk.rank;
for (k = 0; k < pack->chunk.rank; k++)
- table->objs[I].chunk.chunk_lengths[k] =
- pack->chunk.chunk_lengths[k];
+ table->objs[I].chunk.chunk_lengths[k] = pack->chunk.chunk_lengths[k];
}
}
}
@@ -97,54 +102,56 @@ 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));
+ 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
*
* Purpose: init options table
*
* Return: 0, ok, -1, fail
- *-------------------------------------------------------------------------
+ *-------------------------------------------------------------------------
*/
-int options_table_init(pack_opttbl_t **tbl) {
- unsigned int i;
+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;
+ if (NULL == (table = (pack_opttbl_t *)HDmalloc(sizeof(pack_opttbl_t)))) {
+ H5TOOLS_GOTO_ERROR((-1), "not enough memory for options table");
}
- table->size = 30;
+ 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");
+ if (NULL == (table->objs = (pack_info_t *)HDmalloc(table->size * sizeof(pack_info_t)))) {
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
*
@@ -154,7 +161,9 @@ int options_table_init(pack_opttbl_t **tbl) {
*-------------------------------------------------------------------------
*/
-int options_table_free(pack_opttbl_t *table) {
+int
+options_table_free(pack_opttbl_t *table)
+{
HDfree(table->objs);
HDfree(table);
return 0;
@@ -166,14 +175,15 @@ int options_table_free(pack_opttbl_t *table) {
* Purpose: add a layout option to the option list
*
* Return: 0, ok, -1, fail
- *-------------------------------------------------------------------------
+ *-------------------------------------------------------------------------
*/
int
-options_add_layout(obj_list_t *obj_list, unsigned n_objs, pack_info_t *pack, pack_opttbl_t *table)
+options_add_layout(obj_list_t *obj_list, unsigned n_objs, pack_info_t *pack, pack_opttbl_t *table)
{
unsigned i, j, I;
- unsigned added = 0;
- hbool_t found = FALSE;
+ 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)
@@ -187,10 +197,10 @@ options_add_layout(obj_list_t *obj_list, unsigned n_objs, pack_info_t *pack, pa
/* linear table search */
for (i = 0; i < table->nelems; i++) {
/*already on the table */
- if (HDstrcmp(obj_list[j].obj,table->objs[i].path) == 0) {
+ 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 */
@@ -200,7 +210,7 @@ options_add_layout(obj_list_t *obj_list, unsigned n_objs, pack_info_t *pack, pa
break;
}
} /* if */
- } /* i */
+ } /* i */
if (!found) {
/* keep the grow in a temp var */
@@ -214,14 +224,13 @@ options_add_layout(obj_list_t *obj_list, unsigned n_objs, pack_info_t *pack, pa
-f dset1:GZIP=1 -l dset1,dset2:CHUNK=20x20
dset1 is already inserted, but dset2 must also be
*/
- else
- if(found && HDstrcmp(obj_list[j].obj,table->objs[i].path) != 0) {
- /* keep the grow in a temp var */
- I = table->nelems + added;
- added++;
- HDstrcpy(table->objs[I].path, obj_list[j].obj);
- aux_tblinsert_layout(table, I, pack);
- }
+ else if (found && HDstrcmp(obj_list[j].obj, table->objs[i].path) != 0) {
+ /* keep the grow in a temp var */
+ I = table->nelems + added;
+ added++;
+ HDstrcpy(table->objs[I].path, obj_list[j].obj);
+ aux_tblinsert_layout(table, I, pack);
+ }
} /* j */
}
/* first time insertion */
@@ -237,7 +246,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;
}
/*-------------------------------------------------------------------------
@@ -252,8 +261,8 @@ int
options_add_filter(obj_list_t *obj_list, unsigned n_objs, filter_info_t filt, pack_opttbl_t *table)
{
unsigned int i, j, I;
- unsigned added = 0;
- hbool_t found = FALSE;
+ unsigned added = 0;
+ hbool_t found = FALSE;
/* increase the size of the collection by N_OBJS if necessary */
if (table->nelems + n_objs >= table->size)
@@ -273,7 +282,7 @@ options_add_filter(obj_list_t *obj_list, unsigned n_objs, filter_info_t filt, pa
found = TRUE;
break;
} /* if */
- } /* i */
+ } /* i */
if (!found) {
/* keep the grow in a temp var */
@@ -287,14 +296,13 @@ options_add_filter(obj_list_t *obj_list, unsigned n_objs, filter_info_t filt, pa
-l dset1:CHUNK=20x20 -f dset1,dset2:GZIP=1
dset1 is already inserted, but dset2 must also be
*/
- else
- if(found && HDstrcmp(obj_list[j].obj,table->objs[i].path) != 0) {
- /* keep the grow in a temp var */
- I = table->nelems + added;
- added++;
- HDstrcpy(table->objs[I].path, obj_list[j].obj);
- aux_tblinsert_filter(table, I, filt);
- }
+ else if (found && HDstrcmp(obj_list[j].obj, table->objs[i].path) != 0) {
+ /* keep the grow in a temp var */
+ I = table->nelems + added;
+ added++;
+ HDstrcpy(table->objs[I].path, obj_list[j].obj);
+ aux_tblinsert_filter(table, I, filt);
+ }
} /* j */
}
@@ -323,13 +331,15 @@ options_add_filter(obj_list_t *obj_list, unsigned n_objs, filter_info_t filt, pa
*-------------------------------------------------------------------------
*/
-pack_info_t* options_get_object(const char *path, pack_opttbl_t *table) {
+pack_info_t *
+options_get_object(const char *path, pack_opttbl_t *table)
+{
unsigned int i;
- char tbl_path[MAX_NC_NAME + 1]; /* +1 for start with "/" case */
+ char tbl_path[MAX_NC_NAME + 1]; /* +1 for start with "/" case */
for (i = 0; i < table->nelems; i++) {
/* make full path (start with "/") to compare correctly */
- if (HDstrncmp(table->objs[i].path, "/", 1)) {
+ if (HDstrncmp(table->objs[i].path, "/", 1) != 0) {
HDstrcpy(tbl_path, "/");
HDstrcat(tbl_path, table->objs[i].path);
}
diff --git a/tools/src/h5repack/h5repack_parse.c b/tools/src/h5repack/h5repack_parse.c
index 03fcf0e..1c06cae 100644
--- a/tools/src/h5repack/h5repack_parse.c
+++ b/tools/src/h5repack/h5repack_parse.c
@@ -6,7 +6,7 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -37,8 +37,9 @@
* "A,B:NONE"
*-------------------------------------------------------------------------
*/
-obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
- pack_opt_t *options, int *is_glb) {
+obj_list_t *
+parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, pack_opt_t *options, int *is_glb)
+{
size_t i, m, u;
char c;
size_t len = HDstrlen(str);
@@ -48,7 +49,7 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
char scomp[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
char stype[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
char smask[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- obj_list_t* obj_list = NULL;
+ obj_list_t *obj_list = NULL;
unsigned pixels_per_block;
/* initialize compression info */
@@ -59,7 +60,7 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
for (i = 0, n = 0; i < len; i++) {
c = str[i];
if (c == ':') {
- end_obj = (int) i;
+ end_obj = (int)i;
break;
}
if (c == ',')
@@ -71,13 +72,13 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
if (end_obj == -1) {
/* apply to all objects */
options->all_filter = 1;
- *is_glb = 1;
- *n_objs = 1;
+ *is_glb = 1;
+ *n_objs = 1;
}
else
*n_objs = n;
- obj_list = (obj_list_t *) HDmalloc(n * sizeof(obj_list_t));
+ obj_list = (obj_list_t *)HDmalloc(n * sizeof(obj_list_t));
if (obj_list == NULL) {
error_msg("could not allocate object list\n");
return NULL;
@@ -85,10 +86,10 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
/* get object list */
if (end_obj > 0)
- for (j = 0, k = 0, n = 0; j < (unsigned) end_obj; j++, k++) {
- c = str[j];
+ for (j = 0, k = 0, n = 0; j < (unsigned)end_obj; j++, k++) {
+ c = str[j];
sobj[k] = c;
- if (c == ',' || j == (unsigned) (end_obj - 1)) {
+ if (c == ',' || j == (unsigned)(end_obj - 1)) {
if (c == ',')
sobj[k] = '\0';
else
@@ -101,7 +102,7 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
}
}
/* nothing after : */
- if (end_obj + 1 == (int) len) {
+ if (end_obj + 1 == (int)len) {
if (obj_list)
HDfree(obj_list);
error_msg("input Error: Invalid compression type in <%s>\n", str);
@@ -111,25 +112,25 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
/* get filter additional parameters */
m = 0;
for (i = (size_t)(end_obj + 1), k = 0, j = 0; i < len; i++, k++) {
- c = str[i];
+ c = str[i];
scomp[k] = c;
if (c == '=' || i == len - 1) {
- if (c == '=') { /*one more parameter */
+ if (c == '=') { /*one more parameter */
scomp[k] = '\0'; /*cut space */
/*-------------------------------------------------------------------------
- * H5Z_FILTER_SZIP
- * szip has the format SZIP=<pixels per block,coding>
- * pixels per block is a even number in 2-32 and coding method is 'EC' or 'NN'
- * example SZIP=8,NN
- *-------------------------------------------------------------------------
- */
+ * H5Z_FILTER_SZIP
+ * szip has the format SZIP=<pixels per block,coding>
+ * pixels per block is a even number in 2-32 and coding method is 'EC' or 'NN'
+ * example SZIP=8,NN
+ *-------------------------------------------------------------------------
+ */
if (HDstrcmp(scomp, "SZIP") == 0) {
l = -1; /* mask index check */
for (m = 0, u = i + 1; u < len; u++, m++) {
if (str[u] == ',') {
stype[m] = '\0'; /* end digit of szip */
- l = 0; /* start EC or NN search */
- u++; /* skip ',' */
+ l = 0; /* start EC or NN search */
+ u++; /* skip ',' */
}
c = str[u];
if (!HDisdigit(c) && l == -1) {
@@ -145,10 +146,10 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
l++;
if (l == 2) {
smask[l] = '\0';
- i = len - 1; /* end */
- if (HDstrcmp(smask,"NN") == 0)
+ i = len - 1; /* end */
+ if (HDstrcmp(smask, "NN") == 0)
filt->cd_values[j++] = H5_SZIP_NN_OPTION_MASK;
- else if (HDstrcmp(smask,"EC") == 0)
+ else if (HDstrcmp(smask, "EC") == 0)
filt->cd_values[j++] = H5_SZIP_EC_OPTION_MASK;
else {
error_msg("szip mask must be 'NN' or 'EC' \n");
@@ -157,29 +158,29 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
}
}
} /* u */
- } /*if */
+ } /*if */
/*-------------------------------------------------------------------------
- * H5Z_FILTER_SCALEOFFSET
- * scaleoffset has the format SOFF=<scale_factor,scale_type>
- * scale_type can be
- * integer datatype, H5Z_SO_INT (IN)
- * float datatype using D-scaling method, H5Z_SO_FLOAT_DSCALE (DS)
- * float datatype using E-scaling method, H5Z_SO_FLOAT_ESCALE (ES) , not yet implemented
- * for integer datatypes, scale_factor denotes Minimum Bits
- * for float datatypes, scale_factor denotes decimal scale factor
- * examples
- * SOFF=31,IN
- * SOFF=3,DF
- *-------------------------------------------------------------------------
- */
+ * H5Z_FILTER_SCALEOFFSET
+ * scaleoffset has the format SOFF=<scale_factor,scale_type>
+ * scale_type can be
+ * integer datatype, H5Z_SO_INT (IN)
+ * float datatype using D-scaling method, H5Z_SO_FLOAT_DSCALE (DS)
+ * float datatype using E-scaling method, H5Z_SO_FLOAT_ESCALE (ES) , not yet implemented
+ * for integer datatypes, scale_factor denotes Minimum Bits
+ * for float datatypes, scale_factor denotes decimal scale factor
+ * examples
+ * SOFF=31,IN
+ * SOFF=3,DF
+ *-------------------------------------------------------------------------
+ */
else if (HDstrcmp(scomp, "SOFF") == 0) {
l = -1; /* mask index check */
for (m = 0, u = i + 1; u < len; u++, m++) {
if (str[u] == ',') {
stype[m] = '\0'; /* end digit */
- l = 0; /* start 'IN' , 'DS', or 'ES' search */
- u++; /* skip ',' */
+ l = 0; /* start 'IN' , 'DS', or 'ES' search */
+ u++; /* skip ',' */
}
c = str[u];
if (!HDisdigit(c) && l == -1) {
@@ -195,8 +196,8 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
l++;
if (l == 2) {
smask[l] = '\0';
- i = len - 1; /* end */
- if (HDstrcmp(smask,"IN") == 0)
+ i = len - 1; /* end */
+ if (HDstrcmp(smask, "IN") == 0)
filt->cd_values[j++] = H5Z_SO_INT;
else if (HDstrcmp(smask, "DS") == H5Z_SO_FLOAT_DSCALE)
filt->cd_values[j++] = H5Z_SO_FLOAT_DSCALE;
@@ -207,15 +208,15 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
}
}
} /* u */
- } /*if */
+ } /*if */
/*-------------------------------------------------------------------------
- * User Defined
- * has the format UD=<filter_number,filter_flag,cd_value_count,value_1[,value_2,...,value_N]>
- * BZIP2 example
- * UD=307,0,1,9
- *-------------------------------------------------------------------------
- */
+ * User Defined
+ * has the format
+ *UD=<filter_number,filter_flag,cd_value_count,value_1[,value_2,...,value_N]> BZIP2 example
+ * UD=307,0,1,9
+ *-------------------------------------------------------------------------
+ */
else if (HDstrcmp(scomp, "UD") == 0) {
l = -1; /* filter number index check */
f = -1; /* filter flag index check */
@@ -225,15 +226,15 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
stype[q] = '\0'; /* end digit */
if (l == -1) {
filt->filtn = HDatoi(stype);
- l = 0;
+ l = 0;
}
else if (f == -1) {
- filt->filt_flag = HDstrtoul(stype, NULL, 0);
- f = 0;
+ filt->filt_flag = (unsigned)HDstrtoul(stype, NULL, 0);
+ f = 0;
}
else if (p == -1) {
filt->cd_nelmts = HDstrtoull(stype, NULL, 0);
- p = 0;
+ p = 0;
}
else {
filt->cd_values[j++] = (unsigned)HDstrtoul(stype, NULL, 0);
@@ -260,9 +261,9 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
} /*if */
/*-------------------------------------------------------------------------
- * all other filters
- *-------------------------------------------------------------------------
- */
+ * all other filters
+ *-------------------------------------------------------------------------
+ */
else {
/* here we could have 1 or 2 digits */
for (m = 0, u = i + 1; u < len; u++, m++) {
@@ -279,36 +280,36 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
stype[m] = '\0';
} /*if */
- filt->cd_values[j++] = (unsigned) HDstrtoul(stype, NULL, 0);
- if(filt->cd_nelmts == 0)
+ filt->cd_values[j++] = (unsigned)HDstrtoul(stype, NULL, 0);
+ if (filt->cd_nelmts == 0)
j = 0;
i += m; /* jump */
}
else if (i == len - 1) { /*no more parameters */
scomp[k + 1] = '\0';
- no_param = 1;
+ no_param = 1;
}
/*-------------------------------------------------------------------------
- * translate from string to filter symbol
- *-------------------------------------------------------------------------
- */
+ * translate from string to filter symbol
+ *-------------------------------------------------------------------------
+ */
/*-------------------------------------------------------------------------
- * H5Z_FILTER_NONE
- *-------------------------------------------------------------------------
- */
+ * H5Z_FILTER_NONE
+ *-------------------------------------------------------------------------
+ */
if (HDstrcmp(scomp, "NONE") == 0) {
- filt->filtn = H5Z_FILTER_NONE;
+ filt->filtn = H5Z_FILTER_NONE;
filt->cd_nelmts = 0;
}
/*-------------------------------------------------------------------------
- * H5Z_FILTER_DEFLATE
- *-------------------------------------------------------------------------
- */
+ * H5Z_FILTER_DEFLATE
+ *-------------------------------------------------------------------------
+ */
else if (HDstrcmp(scomp, "GZIP") == 0) {
- filt->filtn = H5Z_FILTER_DEFLATE;
+ filt->filtn = H5Z_FILTER_DEFLATE;
filt->cd_nelmts = 1;
if (no_param) { /*no more parameters, GZIP must have parameter */
if (obj_list)
@@ -319,11 +320,11 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
}
/*-------------------------------------------------------------------------
- * H5Z_FILTER_SZIP
- *-------------------------------------------------------------------------
- */
+ * H5Z_FILTER_SZIP
+ *-------------------------------------------------------------------------
+ */
else if (HDstrcmp(scomp, "SZIP") == 0) {
- filt->filtn = H5Z_FILTER_SZIP;
+ filt->filtn = H5Z_FILTER_SZIP;
filt->cd_nelmts = 2;
if (no_param) { /*no more parameters, SZIP must have parameter */
if (obj_list)
@@ -334,11 +335,11 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
}
/*-------------------------------------------------------------------------
- * H5Z_FILTER_SHUFFLE
- *-------------------------------------------------------------------------
- */
+ * H5Z_FILTER_SHUFFLE
+ *-------------------------------------------------------------------------
+ */
else if (HDstrcmp(scomp, "SHUF") == 0) {
- filt->filtn = H5Z_FILTER_SHUFFLE;
+ filt->filtn = H5Z_FILTER_SHUFFLE;
filt->cd_nelmts = 0;
if (m > 0) { /*shuffle does not have parameter */
if (obj_list)
@@ -348,11 +349,11 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
}
}
/*-------------------------------------------------------------------------
- * H5Z_FILTER_FLETCHER32
- *-------------------------------------------------------------------------
- */
+ * H5Z_FILTER_FLETCHER32
+ *-------------------------------------------------------------------------
+ */
else if (HDstrcmp(scomp, "FLET") == 0) {
- filt->filtn = H5Z_FILTER_FLETCHER32;
+ filt->filtn = H5Z_FILTER_FLETCHER32;
filt->cd_nelmts = 0;
if (m > 0) { /*shuffle does not have parameter */
if (obj_list)
@@ -362,11 +363,11 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
}
}
/*-------------------------------------------------------------------------
- * H5Z_FILTER_NBIT
- *-------------------------------------------------------------------------
- */
+ * H5Z_FILTER_NBIT
+ *-------------------------------------------------------------------------
+ */
else if (HDstrcmp(scomp, "NBIT") == 0) {
- filt->filtn = H5Z_FILTER_NBIT;
+ filt->filtn = H5Z_FILTER_NBIT;
filt->cd_nelmts = 0;
if (m > 0) { /*nbit does not have parameter */
if (obj_list)
@@ -376,11 +377,11 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
}
}
/*-------------------------------------------------------------------------
- * H5Z_FILTER_SCALEOFFSET
- *-------------------------------------------------------------------------
- */
+ * H5Z_FILTER_SCALEOFFSET
+ *-------------------------------------------------------------------------
+ */
else if (HDstrcmp(scomp, "SOFF") == 0) {
- filt->filtn = H5Z_FILTER_SCALEOFFSET;
+ filt->filtn = H5Z_FILTER_SCALEOFFSET;
filt->cd_nelmts = 2;
if (no_param) { /*no more parameters, SOFF must have parameter */
if (obj_list)
@@ -390,9 +391,9 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
}
}
/*-------------------------------------------------------------------------
- * User Defined Filter
- *-------------------------------------------------------------------------
- */
+ * User Defined Filter
+ *-------------------------------------------------------------------------
+ */
else if (HDstrcmp(scomp, "UD") == 0) {
/* parameters does not match count */
if (filt->cd_nelmts != j) {
@@ -413,56 +414,55 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt,
} /*i*/
/*-------------------------------------------------------------------------
- * check valid parameters
- *-------------------------------------------------------------------------
- */
+ * check valid parameters
+ *-------------------------------------------------------------------------
+ */
switch (filt->filtn) {
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_DEFLATE
- *-------------------------------------------------------------------------
- */
- case H5Z_FILTER_DEFLATE:
- if (filt->cd_values[0] > 9) {
- if (obj_list)
- HDfree(obj_list);
- error_msg("invalid compression parameter in <%s>\n", str);
- HDexit(EXIT_FAILURE);
- }
- break;
/*-------------------------------------------------------------------------
- * H5Z_FILTER_SZIP
- *-------------------------------------------------------------------------
- */
- case H5Z_FILTER_SZIP:
- pixels_per_block = filt->cd_values[0];
- if ((pixels_per_block % 2) == 1) {
- if (obj_list)
- HDfree(obj_list);
- error_msg("pixels_per_block is not even in <%s>\n", str);
- HDexit(EXIT_FAILURE);
- }
- if (pixels_per_block > H5_SZIP_MAX_PIXELS_PER_BLOCK) {
- if (obj_list)
- HDfree(obj_list);
- error_msg("pixels_per_block is too large in <%s>\n", str);
- HDexit(EXIT_FAILURE);
- }
- if ((HDstrcmp(smask,"NN") != 0) && (HDstrcmp(smask,"EC") != 0)) {
- if (obj_list)
- HDfree(obj_list);
- error_msg("szip mask must be 'NN' or 'EC' \n");
- HDexit(EXIT_FAILURE);
- }
- break;
- default:
- break;
+ * H5Z_FILTER_DEFLATE
+ *-------------------------------------------------------------------------
+ */
+ case H5Z_FILTER_DEFLATE:
+ if (filt->cd_values[0] > 9) {
+ if (obj_list)
+ HDfree(obj_list);
+ error_msg("invalid compression parameter in <%s>\n", str);
+ HDexit(EXIT_FAILURE);
+ }
+ break;
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_SZIP
+ *-------------------------------------------------------------------------
+ */
+ case H5Z_FILTER_SZIP:
+ pixels_per_block = filt->cd_values[0];
+ if ((pixels_per_block % 2) == 1) {
+ if (obj_list)
+ HDfree(obj_list);
+ error_msg("pixels_per_block is not even in <%s>\n", str);
+ HDexit(EXIT_FAILURE);
+ }
+ if (pixels_per_block > H5_SZIP_MAX_PIXELS_PER_BLOCK) {
+ if (obj_list)
+ HDfree(obj_list);
+ error_msg("pixels_per_block is too large in <%s>\n", str);
+ HDexit(EXIT_FAILURE);
+ }
+ if ((HDstrcmp(smask, "NN") != 0) && (HDstrcmp(smask, "EC") != 0)) {
+ if (obj_list)
+ HDfree(obj_list);
+ error_msg("szip mask must be 'NN' or 'EC' \n");
+ HDexit(EXIT_FAILURE);
+ }
+ break;
+ default:
+ break;
};
return obj_list;
}
-
/*-------------------------------------------------------------------------
* Function: parse_layout
*
@@ -478,15 +478,17 @@ 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
*
*-------------------------------------------------------------------------
*/
-obj_list_t* parse_layout(const char *str, unsigned *n_objs, pack_info_t *pack, /* info about layout needed */
-pack_opt_t *options) {
- obj_list_t* obj_list = NULL;
+obj_list_t *
+parse_layout(const char *str, unsigned *n_objs, pack_info_t *pack, /* info about layout needed */
+ pack_opt_t *options)
+{
+ obj_list_t *obj_list = NULL;
unsigned i, j, n;
char c;
size_t len = HDstrlen(str);
@@ -503,7 +505,7 @@ pack_opt_t *options) {
for (i = 0, n = 0; i < len; i++) {
c = str[i];
if (c == ':')
- end_obj = (int) i;
+ end_obj = (int)i;
if (c == ',')
n++;
}
@@ -513,7 +515,7 @@ pack_opt_t *options) {
}
n++;
- obj_list = (obj_list_t*) HDmalloc(n * sizeof(obj_list_t));
+ obj_list = (obj_list_t *)HDmalloc(n * sizeof(obj_list_t));
if (obj_list == NULL) {
error_msg("could not allocate object list\n");
return NULL;
@@ -522,10 +524,10 @@ pack_opt_t *options) {
/* get object list */
if (end_obj > 0)
- for (j = 0, k = 0, n = 0; j < (unsigned) end_obj; j++, k++) {
- c = str[j];
+ for (j = 0, k = 0, n = 0; j < (unsigned)end_obj; j++, k++) {
+ c = str[j];
sobj[k] = c;
- if (c == ',' || j == (unsigned) (end_obj - 1)) {
+ if (c == ',' || j == (unsigned)(end_obj - 1)) {
if (c == ',')
sobj[k] = '\0';
else
@@ -538,7 +540,7 @@ pack_opt_t *options) {
}
/* nothing after : */
- if (end_obj + 1 == (int) len) {
+ if (end_obj + 1 == (int)len) {
if (obj_list)
HDfree(obj_list);
error_msg("in parse layout, no characters after : in <%s>\n", str);
@@ -546,7 +548,7 @@ pack_opt_t *options) {
}
/* get layout info */
- for (j = (unsigned) (end_obj + 1), n = 0; n <= 5; j++, n++) {
+ for (j = (unsigned)(end_obj + 1), n = 0; n <= 5; j++, n++) {
if (n == 5) {
slayout[n] = '\0'; /*cut string */
if (HDstrcmp(slayout, "COMPA") == 0)
@@ -561,16 +563,16 @@ pack_opt_t *options) {
}
}
else {
- c = str[j];
+ c = str[j];
slayout[n] = c;
}
} /* j */
if (pack->layout == H5D_CHUNKED) {
/*-------------------------------------------------------------------------
- * get chunk info
- *-------------------------------------------------------------------------
- */
+ * get chunk info
+ *-------------------------------------------------------------------------
+ */
k = 0;
if (j > len) {
if (obj_list)
@@ -580,7 +582,7 @@ pack_opt_t *options) {
}
for (i = j, c_index = 0; i < len; i++) {
- c = str[i];
+ c = str[i];
sdim[k] = c;
k++; /*increment sdim index */
@@ -593,8 +595,8 @@ pack_opt_t *options) {
if (c == 'x' || i == len - 1) {
if (c == 'x') {
- sdim[k - 1] = '\0';
- k = 0;
+ sdim[k - 1] = '\0';
+ k = 0;
pack->chunk.chunk_lengths[c_index] = HDstrtoull(sdim, NULL, 0);
if (pack->chunk.chunk_lengths[c_index] == 0) {
if (obj_list)
@@ -606,8 +608,8 @@ pack_opt_t *options) {
}
else if (i == len - 1) { /*no more parameters */
sdim[k] = '\0';
- k = 0;
- if (HDstrcmp(sdim,"NONE") == 0) {
+ k = 0;
+ if (HDstrcmp(sdim, "NONE") == 0) {
pack->chunk.rank = -2;
}
else {
@@ -621,9 +623,9 @@ pack_opt_t *options) {
pack->chunk.rank = c_index + 1;
}
} /*if */
- } /*if c=='x' || i==len-1 */
- } /*i*/
- } /*H5D_CHUNKED*/
+ } /*if c=='x' || i==len-1 */
+ } /*i*/
+ } /*H5D_CHUNKED*/
return obj_list;
}
diff --git a/tools/src/h5repack/h5repack_refs.c b/tools/src/h5repack/h5repack_refs.c
index 7e8951f..3259b89 100644
--- a/tools/src/h5repack/h5repack_refs.c
+++ b/tools/src/h5repack/h5repack_refs.c
@@ -6,7 +6,7 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -15,17 +15,15 @@
#include "h5diff.h"
#include "h5tools.h"
-
/*-------------------------------------------------------------------------
* local functions
*-------------------------------------------------------------------------
*/
-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,
- 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);
+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, 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);
/*-------------------------------------------------------------------------
* Function: do_copy_refobjs
@@ -37,35 +35,33 @@ static herr_t update_ref_value(hid_t obj_id, H5R_type_t ref_type, void *ref_in,
*-------------------------------------------------------------------------
*/
-int do_copy_refobjs(hid_t fidin,
- hid_t fidout,
- trav_table_t *travt,
- pack_opt_t *options) /* repack options */
+int
+do_copy_refobjs(hid_t fidin, hid_t fidout, 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 */
- size_t msize; /* memory size of memory type */
- hsize_t nelmts; /* number of elements in dataset */
- int rank; /* rank of dataset */
- hsize_t dims[H5S_MAX_RANK]; /* dimensions of dataset */
+ 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 */
+ hsize_t dims[H5S_MAX_RANK]; /* dimensions of dataset */
unsigned int i, j;
- int k;
- named_dt_t *named_dt_head = NULL; /* Pointer to the stack of named datatypes copied */
+ int k;
+ named_dt_t * named_dt_head = NULL; /* Pointer to the stack of named datatypes copied */
+ int ret_value = 0;
/*-------------------------------------------------------------------------
- * browse
- *-------------------------------------------------------------------------
- */
- for(i = 0; i < travt->nobjs; i++) {
- switch(travt->objs[i].type) {
+ * browse
+ *-------------------------------------------------------------------------
+ */
+ for (i = 0; i < travt->nobjs; i++) {
+ switch (travt->objs[i].type) {
/*-------------------------------------------------------------------------
* H5TRAV_TYPE_GROUP
*-------------------------------------------------------------------------
@@ -75,27 +71,28 @@ int do_copy_refobjs(hid_t fidin,
* copy referenced objects in attributes
*-------------------------------------------------------------------------
*/
- if((grp_out = H5Gopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gopen2 failed");
+ if ((grp_out = H5Gopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0)
+ 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");
+ if ((grp_in = H5Gopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
+ 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");
+ if (copy_refs_attr(grp_in, grp_out, travt, fidout) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "copy_refs_attr failed");
- if(H5Gclose(grp_out) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed");
- if(H5Gclose(grp_in) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed");
+ if (H5Gclose(grp_out) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Gclose failed");
+ if (H5Gclose(grp_in) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Gclose failed");
/*-------------------------------------------------------------------------
* check for hard links
*-------------------------------------------------------------------------
*/
- if(travt->objs[i].nlinks)
- for(j = 0; j < travt->objs[i].nlinks; j++)
- H5Lcreate_hard(fidout, travt->objs[i].name, H5L_SAME_LOC, travt->objs[i].links[j].new_name, H5P_DEFAULT, H5P_DEFAULT);
+ if (travt->objs[i].nlinks)
+ for (j = 0; j < travt->objs[i].nlinks; j++)
+ H5Lcreate_hard(fidout, travt->objs[i].name, H5L_SAME_LOC,
+ travt->objs[i].links[j].new_name, H5P_DEFAULT, H5P_DEFAULT);
break;
/*-------------------------------------------------------------------------
@@ -103,27 +100,27 @@ 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");
- if((space_id = H5Dget_space(dset_in)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
- if((ftype_id = H5Dget_type(dset_in)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_type failed");
- if((dcpl_id = H5Dget_create_plist(dset_in)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "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");
- if(H5Sget_simple_extent_dims(space_id, dims, NULL) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
+ if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed");
+ if ((space_id = H5Dget_space(dset_in)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed");
+ if ((ftype_id = H5Dget_type(dset_in)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_type failed");
+ if ((dcpl_id = H5Dget_create_plist(dset_in)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed");
+ if ((rank = H5Sget_simple_extent_ndims(space_id)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_ndims failed");
+ if (H5Sget_simple_extent_dims(space_id, dims, NULL) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_dims failed");
nelmts = 1;
- for(k = 0; k < rank; k++)
+ 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");
+ if ((mtype_id = H5Tget_native_type(ftype_id, H5T_DIR_DEFAULT)) < 0)
+ 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");
+ if ((msize = H5Tget_size(mtype_id)) == 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Tget_size failed");
/*-------------------------------------------------------------------------
* check if the dataset creation property list has filters that
@@ -132,7 +129,7 @@ int do_copy_refobjs(hid_t fidin,
* 2) the internal filters might be turned off
*-------------------------------------------------------------------------
*/
- if(h5tools_canreadf(NULL, dcpl_id) == 1) {
+ if (h5tools_canreadf(NULL, dcpl_id) == 1) {
/*-------------------------------------------------------------------------
* test for a valid output dataset
*-------------------------------------------------------------------------
@@ -144,207 +141,220 @@ int do_copy_refobjs(hid_t fidin,
* we cannot just copy the buffers, but instead we recreate the reference
*-------------------------------------------------------------------------
*/
- if(H5Tequal(mtype_id, H5T_STD_REF_OBJ)) {
- hid_t refobj_id = -1;
- hobj_ref_t *refbuf = NULL; /* buffer for object references */
- hobj_ref_t *buf = NULL;
- const char* refname;
- unsigned u;
+ if (H5Tequal(mtype_id, H5T_STD_REF_OBJ)) {
+ hid_t refobj_id = H5I_INVALID_HID;
+ hobj_ref_t *refbuf = NULL; /* buffer for object references */
+ hobj_ref_t *buf = NULL;
+ const char *refname;
+ unsigned u;
/*-------------------------------------------------------------------------
* read to memory
*-------------------------------------------------------------------------
*/
- if(nelmts) {
+ if (nelmts) {
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");
+ if (buf == NULL) {
+ HDprintf("cannot read into memory\n");
+ 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");
+ if (H5Dread(dset_in, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
+ 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");
+ refbuf = (hobj_ref_t *)HDcalloc((unsigned)nelmts, msize);
+ if (refbuf == NULL) {
+ HDprintf("cannot allocate memory\n");
+ H5TOOLS_GOTO_ERROR((-1), "HDcalloc failed");
} /* end if */
- for(u = 0; u < nelmts; u++) {
- H5E_BEGIN_TRY {
- if((refobj_id = H5Rdereference2(dset_in, H5P_DEFAULT, H5R_OBJECT, &buf[u])) < 0)
+ for (u = 0; u < nelmts; u++) {
+ H5E_BEGIN_TRY
+ {
+ if ((refobj_id =
+ H5Rdereference2(dset_in, H5P_DEFAULT, H5R_OBJECT, &buf[u])) < 0)
continue;
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
/* get the name. a valid name could only occur
* in the second traversal of the file
*/
- if((refname = MapIdToName(refobj_id, travt)) != NULL) {
+ 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");
- if(options->verbose) {
- HDprintf(FORMAT_OBJ,"dset",travt->objs[i].name );
+ if (H5Rcreate(&refbuf[u], fidout, refname, H5R_OBJECT, (hid_t)-1) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Rcreate failed");
+ if (options->verbose > 0) {
+ if (options->verbose == 2)
+ HDprintf(FORMAT_OBJ_NOTIME, "dset", travt->objs[i].name);
+ else
+ HDprintf(FORMAT_OBJ, "dset", travt->objs[i].name);
HDprintf("object <%s> object reference created to <%s>\n",
- travt->objs[i].name,
- refname);
+ travt->objs[i].name, refname);
}
} /*refname*/
if (H5Oclose(refobj_id) < 0)
- H5TOOLS_INFO(H5E_tools_min_id_g, "H5Oclose refob failed");
+ H5TOOLS_ERROR((-1), "H5Oclose refob failed");
} /* u */
- } /*nelmts*/
+ } /*nelmts*/
/*-------------------------------------------------------------------------
* create/write dataset/close
*-------------------------------------------------------------------------
*/
- 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");
- 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");
-
- if(buf)
+ if ((dset_out = H5Dcreate2(fidout, travt->objs[i].name, mtype_id, space_id,
+ H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dcreate2 failed");
+ if (nelmts)
+ if (H5Dwrite(dset_out, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, refbuf) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dwrite failed");
+
+ if (buf)
HDfree(buf);
- if(refbuf)
+ if (refbuf)
HDfree(refbuf);
- /*------------------------------------------------------
- * 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");
+ /*------------------------------------------------------
+ * copy attrs
+ *----------------------------------------------------*/
+ if (copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "copy_attr failed");
} /*H5T_STD_REF_OBJ*/
/*-------------------------------------------------------------------------
* dataset region references
*-------------------------------------------------------------------------
*/
- else if(H5Tequal(mtype_id, H5T_STD_REF_DSETREG)) {
- hid_t refobj_id = -1;
- hdset_reg_ref_t *refbuf = NULL; /* input buffer for region references */
- hdset_reg_ref_t *buf = NULL; /* output buffer */
- const char* refname;
+ else if (H5Tequal(mtype_id, H5T_STD_REF_DSETREG)) {
+ 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;
unsigned u;
/*-------------------------------------------------------------------------
* read input to memory
*-------------------------------------------------------------------------
*/
- if(nelmts) {
+ if (nelmts) {
buf = (hdset_reg_ref_t *)HDmalloc((unsigned)(nelmts * msize));
- if(buf == NULL) {
+ 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");
+ if (H5Dread(dset_in, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dread failed");
/*-------------------------------------------------------------------------
* create output
*-------------------------------------------------------------------------
*/
- refbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)nelmts); /*init to zero */
- if(refbuf == NULL) {
+ 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++) {
- H5E_BEGIN_TRY {
- if((refobj_id = H5Rdereference2(dset_in, H5P_DEFAULT, H5R_DATASET_REGION, &buf[u])) < 0)
+ for (u = 0; u < nelmts; u++) {
+ H5E_BEGIN_TRY
+ {
+ if ((refobj_id = H5Rdereference2(dset_in, H5P_DEFAULT, H5R_DATASET_REGION,
+ &buf[u])) < 0)
continue;
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
/* get the name. a valid name could only occur
* 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 */
+ if ((refname = MapIdToName(refobj_id, travt)) != NULL) {
+ 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");
+ if ((region_id = H5Rget_region(dset_in, H5R_DATASET_REGION, &buf[u])) < 0)
+ 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");
- if(H5Sclose(region_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed");
- if(options->verbose) {
- HDprintf(FORMAT_OBJ,"dset",travt->objs[i].name );
+ if (H5Rcreate(&refbuf[u], fidout, refname, H5R_DATASET_REGION,
+ region_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Rcreate failed");
+ if (H5Sclose(region_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed");
+ if (options->verbose > 0) {
+ HDprintf(FORMAT_OBJ, "dset", travt->objs[i].name);
HDprintf("object <%s> region reference created to <%s>\n",
- travt->objs[i].name,
- refname);
+ travt->objs[i].name, refname);
}
} /*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*/
+ } /*nelmts*/
/*-------------------------------------------------------------------------
* create/write dataset/close
*-------------------------------------------------------------------------
*/
- 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");
- 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");
-
- if(buf)
+ if ((dset_out = H5Dcreate2(fidout, travt->objs[i].name, mtype_id, space_id,
+ H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dcreate2 failed");
+ if (nelmts)
+ if (H5Dwrite(dset_out, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, refbuf) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dwrite failed");
+
+ if (buf)
HDfree(buf);
- if(refbuf)
+ if (refbuf)
HDfree(refbuf);
- /*-----------------------------------------------------
- * 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");
+ /*-----------------------------------------------------
+ * copy attrs
+ *----------------------------------------------------*/
+ if (copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "copy_attr failed");
} /* H5T_STD_REF_DSETREG */
/*-------------------------------------------------------------------------
* not references, open previously created object in 1st traversal
*-------------------------------------------------------------------------
*/
else {
- if((dset_out = H5Dopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed");
+ if ((dset_out = H5Dopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed");
} /* end else */
/*-------------------------------------------------------------------------
* copy referenced objects in attributes
*-------------------------------------------------------------------------
*/
- if(copy_refs_attr(dset_in, dset_out, travt, fidout) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_refs_attr failed");
+ if (copy_refs_attr(dset_in, dset_out, travt, fidout) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "copy_refs_attr failed");
/*-------------------------------------------------------------------------
* check for hard links
*-------------------------------------------------------------------------
*/
- if(travt->objs[i].nlinks)
- for(j = 0; j < travt->objs[i].nlinks; j++)
- H5Lcreate_hard(fidout, travt->objs[i].name, H5L_SAME_LOC, travt->objs[i].links[j].new_name, H5P_DEFAULT, H5P_DEFAULT);
+ if (travt->objs[i].nlinks)
+ for (j = 0; j < travt->objs[i].nlinks; j++)
+ 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");
+ if (H5Dclose(dset_out) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed");
} /*can_read*/
/*-------------------------------------------------------------------------
* close
*-------------------------------------------------------------------------
*/
- if(H5Tclose(ftype_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
- if(H5Tclose(mtype_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
- if(H5Pclose(dcpl_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
- if(H5Sclose(space_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed");
- if(H5Dclose(dset_in) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
+ if (H5Tclose(ftype_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
+ if (H5Tclose(mtype_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
+ if (H5Pclose(dcpl_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
+ if (H5Sclose(space_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed");
+ if (H5Dclose(dset_in) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed");
break;
/*-------------------------------------------------------------------------
@@ -352,10 +362,10 @@ 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");
- if(H5Tclose(type_in) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
+ if ((type_in = H5Topen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Topen2 failed");
+ if (H5Tclose(type_in) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
break;
/*-------------------------------------------------------------------------
@@ -368,24 +378,26 @@ 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;
} /* end switch */
- } /* end for */
+ } /* end for */
/* Finalize (link) the stack of named datatypes (if any)
* This function is paired with copy_named_datatype() which is called
* 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;
done:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Gclose(grp_in);
H5Gclose(grp_out);
H5Pclose(dcpl_id);
@@ -396,12 +408,12 @@ done:
H5Tclose(mtype_id);
H5Tclose(type_in);
named_datatype_free(&named_dt_head, 1);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return ret_value;
}
-
/*-------------------------------------------------------------------------
* Function: copy_refs_attr
*
@@ -424,96 +436,91 @@ done:
*-------------------------------------------------------------------------
*/
-static int copy_refs_attr(hid_t loc_in,
- hid_t loc_out,
- trav_table_t *travt,
- hid_t fidout) /* for saving references */
+static int
+copy_refs_attr(hid_t loc_in, hid_t loc_out, 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 */
- size_t msize; /* memory size of type */
- hsize_t nelmts; /* number of elements in dataset */
- hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */
+ 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 */
char name[255];
- H5O_info_t oinfo; /* Object info */
+ H5O_info2_t oinfo; /* Object info */
unsigned u, i, j;
int rank;
H5T_class_t type_class = -1;
- hbool_t is_ref = 0,
- is_ref_vlen = 0,
- is_ref_array = 0,
- is_ref_comp = 0;
- void *refbuf = NULL;
- void *buf = NULL;
- unsigned *ref_comp_index = NULL;
- size_t *ref_comp_size = NULL;
+ hbool_t is_ref = 0, is_ref_vlen = 0, is_ref_array = 0, is_ref_comp = 0;
+ void * refbuf = NULL;
+ void * buf = NULL;
+ unsigned * ref_comp_index = NULL;
+ size_t * ref_comp_size = NULL;
int ref_comp_field_n = 0;
+ int ret_value = 0;
+ if (H5Oget_info3(loc_in, &oinfo, H5O_INFO_NUM_ATTRS) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Oget_info failed");
- if(H5Oget_info2(loc_in, &oinfo, H5O_INFO_NUM_ATTRS) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Oget_info failed");
-
- for(u = 0; u < (unsigned)oinfo.num_attrs; u++) {
+ 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");
+ if ((attr_id = H5Aopen_by_idx(loc_in, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, H5P_DEFAULT,
+ H5P_DEFAULT)) < 0)
+ 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");
+ if ((ftype_id = H5Aget_type(attr_id)) < 0)
+ 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");
+ if ((mtype_id = H5Tget_native_type(ftype_id, H5T_DIR_DEFAULT)) < 0)
+ 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");
+ if ((msize = H5Tget_size(mtype_id)) == 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Tget_size failed");
is_ref = (type_class == H5T_REFERENCE);
- if(type_class == H5T_VLEN ) {
+ if (type_class == H5T_VLEN) {
hid_t base_type = H5Tget_super(ftype_id);
is_ref_vlen = (H5Tget_class(base_type) == H5T_REFERENCE);
- msize = H5Tget_size(base_type);
+ 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 ) {
+ else if (type_class == H5T_ARRAY) {
hid_t base_type = H5Tget_super(ftype_id);
is_ref_array = (H5Tget_class(base_type) == H5T_REFERENCE);
- msize = H5Tget_size(base_type);
+ 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) ;
+ 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));
+ ref_comp_index = (unsigned *)HDmalloc((size_t)nmembers * sizeof(unsigned));
+ ref_comp_size = (size_t *)HDmalloc((size_t)nmembers * sizeof(ref_comp_size));
ref_comp_field_n = 0;
- for (i=0; i<(unsigned)nmembers; i++) {
+ for (i = 0; i < (unsigned)nmembers; i++) {
hid_t mtid = H5Tget_member_type(ftype_id, i);
if ((H5Tget_class(mtid) == H5T_REFERENCE)) {
ref_comp_index[ref_comp_field_n] = i;
- ref_comp_size[ref_comp_field_n] = H5Tget_size(mtid);
+ ref_comp_size[ref_comp_field_n] = H5Tget_size(mtid);
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,200 +537,214 @@ 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 accidentally treated as the reference type.
+ It will then cause the H5Acreate2 failed since that attribute is already created.
+ KY 2020-02-07
+ */
+ 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");
+ if (H5Aget_name(attr_id, 255, name) < 0)
+ 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");
+ if ((space_id = H5Aget_space(attr_id)) < 0)
+ 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");
-
+ if ((rank = H5Sget_simple_extent_dims(space_id, dims, NULL)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_dims failed");
/*-------------------------------------------------------------------------
- * elements
- *-------------------------------------------------------------------------
- */
+ * elements
+ *-------------------------------------------------------------------------
+ */
nelmts = 1;
- for(j = 0; j < (unsigned)rank; j++)
+ for (j = 0; j < (unsigned)rank; j++)
nelmts *= dims[j];
if (is_ref_array) {
- unsigned array_rank = 0;
- hsize_t array_size = 1;
- hsize_t array_dims[H5S_MAX_RANK];
- hid_t base_type = H5Tget_super(ftype_id);
+ unsigned array_rank = 0;
+ hsize_t array_size = 1;
+ hsize_t array_dims[H5S_MAX_RANK];
+ hid_t base_type = H5Tget_super(ftype_id);
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);
- for(j = 0; j <array_rank; j++)
+ for (j = 0; j < array_rank; j++)
array_size *= array_dims[j];
nelmts *= array_size;
}
- 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");
+ if ((attr_out = H5Acreate2(loc_out, name, ftype_id, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Acreate2 failed");
- if (nelmts>0) {
+ if (nelmts > 0) {
/* handle object references */
- if((is_ref || is_ref_array) && (H5R_OBJ_REF_BUF_SIZE==msize)) {
+ if ((is_ref || is_ref_array) && (H5R_OBJ_REF_BUF_SIZE == msize)) {
buf = (hobj_ref_t *)HDmalloc((unsigned)(nelmts * msize));
- if(buf == NULL) {
+ 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");
+ if (H5Aread(attr_id, mtype_id, buf) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Aread failed");
refbuf = (hobj_ref_t *)HDcalloc((unsigned)nelmts, msize);
- if(refbuf == NULL) {
+ 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++)
- if(update_ref_value(attr_id, H5R_OBJECT, &((hobj_ref_t *)buf)[i], fidout, &((hobj_ref_t *)refbuf)[i], travt) < 0)
+ for (i = 0; i < (unsigned)nelmts; i++)
+ if (update_ref_value(attr_id, H5R_OBJECT, &((hobj_ref_t *)buf)[i], fidout,
+ &((hobj_ref_t *)refbuf)[i], travt) < 0)
continue;
} /* H5T_STD_REF_OBJ */
/* handle region references */
- else if((is_ref || is_ref_array) && (H5R_DSET_REG_REF_BUF_SIZE == msize)) {
+ else if ((is_ref || is_ref_array) && (H5R_DSET_REG_REF_BUF_SIZE == msize)) {
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");
+ if (buf == NULL) {
+ HDprintf("cannot read into memory\n");
+ 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");
+ if (H5Aread(attr_id, mtype_id, buf) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Aread failed");
/*-------------------------------------------------------------------------
* create output
*-------------------------------------------------------------------------
*/
- 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");
+ 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");
+ H5TOOLS_GOTO_ERROR((-1), "HDcalloc failed");
} /* end if */
- for(i = 0; i < (unsigned)nelmts; i++)
- if(update_ref_value(attr_id, H5R_DATASET_REGION, &((hdset_reg_ref_t *)buf)[i], fidout, &((hdset_reg_ref_t *)refbuf)[i], travt) < 0)
+ for (i = 0; i < (unsigned)nelmts; i++)
+ if (update_ref_value(attr_id, H5R_DATASET_REGION, &((hdset_reg_ref_t *)buf)[i], fidout,
+ &((hdset_reg_ref_t *)refbuf)[i], travt) < 0)
continue;
} /* H5T_STD_REF_DSETREG */
else if (is_ref_vlen) {
/* handle VLEN of references */
- buf = (hvl_t *)HDmalloc((unsigned)(nelmts * sizeof(hvl_t)));
+ buf = (hvl_t *)HDmalloc((unsigned)(nelmts * sizeof(hvl_t)));
refbuf = buf; /* reuse the read buffer for write */
- if(buf == NULL) {
- HDprintf( "cannot read into memory\n" );
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDmalloc failed");
+ if (buf == NULL) {
+ HDprintf("cannot read into memory\n");
+ 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");
+ if (H5Aread(attr_id, mtype_id, buf) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Aread failed");
- if (H5R_OBJ_REF_BUF_SIZE==msize) {
+ if (H5R_OBJ_REF_BUF_SIZE == msize) {
hobj_ref_t ref_out;
- for (i=0; i<(unsigned)nelmts; i++) {
+ for (i = 0; i < (unsigned)nelmts; i++) {
hobj_ref_t *ptr = (hobj_ref_t *)((hvl_t *)buf)[i].p;
- for (j=0; j<((hvl_t *)buf)[i].len; j++ ) {
- if (update_ref_value(attr_id, H5R_OBJECT, &(ptr[j]), fidout, &ref_out, travt)<0)
+ for (j = 0; j < ((hvl_t *)buf)[i].len; j++) {
+ if (update_ref_value(attr_id, H5R_OBJECT, &(ptr[j]), fidout, &ref_out, travt) < 0)
continue;
HDmemcpy(&(ptr[j]), &ref_out, msize);
}
- } /* for (i=0; i<nelems; i++) */
+ } /* for (i=0; i<nelems; i++) */
}
else if (H5R_DSET_REG_REF_BUF_SIZE == msize) {
hdset_reg_ref_t ref_out;
- for (i=0; i<(unsigned)nelmts; i++) {
+ for (i = 0; i < (unsigned)nelmts; i++) {
hdset_reg_ref_t *ptr = (hdset_reg_ref_t *)((hvl_t *)buf)[i].p;
- for (j=0; j<((hvl_t *)buf)[i].len; j++ ) {
- if (update_ref_value(attr_id, H5R_DATASET_REGION, &(ptr[j]), fidout, &ref_out, travt)<0)
+ for (j = 0; j < ((hvl_t *)buf)[i].len; j++) {
+ if (update_ref_value(attr_id, H5R_DATASET_REGION, &(ptr[j]), fidout, &ref_out,
+ travt) < 0)
continue;
HDmemcpy(&(ptr[j]), &ref_out, msize);
}
- } /* for (i=0; i<nelems; i++) */
+ } /* for (i=0; i<nelems; i++) */
}
} /* else if (is_ref_vlen) */
else if (is_ref_comp) {
/* handle ref fields in a compound */
- buf = HDmalloc((unsigned)(nelmts * msize));
+ buf = HDmalloc((unsigned)(nelmts * msize));
refbuf = buf; /* reuse the read buffer for write */
- if(buf == NULL) {
- HDprintf( "cannot read into memory\n" );
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDmalloc failed");
+ if (buf == NULL) {
+ HDprintf("cannot read into memory\n");
+ 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");
+ if (H5Aread(attr_id, mtype_id, buf) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Aread failed");
- for (i=0; i<(unsigned)nelmts; i++) {
- for (j=0; j<(unsigned)ref_comp_field_n; j++) {
+ for (i = 0; i < (unsigned)nelmts; i++) {
+ for (j = 0; j < (unsigned)ref_comp_field_n; j++) {
if (ref_comp_size[j] == H5R_OBJ_REF_BUF_SIZE) {
- size_t idx = (i * msize) + H5Tget_member_offset(mtype_id, ref_comp_index[j]);
+ size_t idx = (i * msize) + H5Tget_member_offset(mtype_id, ref_comp_index[j]);
hobj_ref_t ref_out;
- if (update_ref_value(attr_id, H5R_OBJECT, (hobj_ref_t *)((void *)(((char *)buf)+idx)), fidout, &ref_out, travt) < 0) /* Extra (void *) cast to quiet "cast to create alignment" warning - 2019/07/05, QAK */
+ if (update_ref_value(attr_id, H5R_OBJECT,
+ (hobj_ref_t *)((void *)(((char *)buf) + idx)), fidout,
+ &ref_out,
+ travt) < 0) /* Extra (void *) cast to quiet "cast to create
+ alignment" warning - 2019/07/05, QAK */
continue;
- HDmemcpy(((char *)buf)+idx, &ref_out, ref_comp_size[j]);
+ HDmemcpy(((char *)buf) + idx, &ref_out, ref_comp_size[j]);
} /* if */
else if (ref_comp_size[j] == H5R_DSET_REG_REF_BUF_SIZE) {
size_t idx = i * msize + H5Tget_member_offset(mtype_id, ref_comp_index[j]);
hdset_reg_ref_t ref_out;
- if (update_ref_value(attr_id, H5R_DATASET_REGION, (hdset_reg_ref_t *)(((char *)buf)+idx), fidout, &ref_out, travt)<0)
+ if (update_ref_value(attr_id, H5R_DATASET_REGION,
+ (hdset_reg_ref_t *)(((char *)buf) + idx), fidout, &ref_out,
+ travt) < 0)
continue;
- HDmemcpy(((char *)buf)+idx, &ref_out, ref_comp_size[j]);
+ HDmemcpy(((char *)buf) + idx, &ref_out, ref_comp_size[j]);
} /* else if */
- } /* j */
- } /* i */
- } /* else if (is_ref_comp) */
+ } /* j */
+ } /* i */
+ } /* else if (is_ref_comp) */
- if(H5Awrite(attr_out, mtype_id, refbuf) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Awrite failed");
+ if (H5Awrite(attr_out, mtype_id, refbuf) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Awrite failed");
if (is_ref_vlen && buf)
- H5Dvlen_reclaim (mtype_id, space_id, H5P_DEFAULT, buf);
+ H5Treclaim(mtype_id, space_id, H5P_DEFAULT, buf);
} /* if (nelmts) */
if (refbuf == buf)
refbuf = NULL; /* set it to NULL to avoid double free since buf and refbuf are the same. */
- if(buf) {
+ if (buf) {
HDfree(buf);
buf = NULL;
}
- if(refbuf) {
+ if (refbuf) {
HDfree(refbuf);
refbuf = NULL;
}
@@ -738,27 +759,27 @@ static int copy_refs_attr(hid_t loc_in,
ref_comp_size = NULL;
}
- if(H5Aclose(attr_out) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aclose failed");
+ if (H5Aclose(attr_out) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Aclose failed");
/*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
- if(H5Tclose(ftype_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
- if(H5Tclose(mtype_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
- if(H5Sclose(space_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed");
- if(H5Aclose(attr_id) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aclose failed");
+ * close
+ *-------------------------------------------------------------------------
+ */
+ if (H5Tclose(ftype_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
+ if (H5Tclose(mtype_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
+ if (H5Sclose(space_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed");
+ if (H5Aclose(attr_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Aclose failed");
} /* for(u = 0; u < (unsigned)oinfo.num_attrs; u++) */
done:
- if(refbuf)
+ if (refbuf)
HDfree(refbuf);
- if(buf)
+ if (buf)
HDfree(buf);
if (ref_comp_index)
@@ -767,13 +788,15 @@ done:
if (ref_comp_size)
HDfree(ref_comp_size);
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Tclose(ftype_id);
H5Tclose(mtype_id);
H5Sclose(space_id);
H5Aclose(attr_id);
H5Aclose(attr_out);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return ret_value;
}
@@ -785,29 +808,32 @@ done:
*
*-------------------------------------------------------------------------
*/
-static const char*
+static const char *
MapIdToName(hid_t refobj_id, trav_table_t *travt)
{
unsigned int u;
- const char *ret = NULL;
+ const char * ret = NULL;
/* linear search */
- for(u = 0; u < travt->nobjs; u++) {
- if(travt->objs[u].type == (h5trav_type_t)H5O_TYPE_DATASET ||
- travt->objs[u].type == (h5trav_type_t)H5O_TYPE_GROUP ||
- travt->objs[u].type == (h5trav_type_t)H5O_TYPE_NAMED_DATATYPE) {
- H5O_info_t ref_oinfo; /* Stat for the refobj id */
+ for (u = 0; u < travt->nobjs; u++) {
+ if (travt->objs[u].type == (h5trav_type_t)H5O_TYPE_DATASET ||
+ travt->objs[u].type == (h5trav_type_t)H5O_TYPE_GROUP ||
+ travt->objs[u].type == (h5trav_type_t)H5O_TYPE_NAMED_DATATYPE) {
+ H5O_info2_t ref_oinfo; /* Stat for the refobj id */
+ int token_cmp;
/* obtain information to identify the referenced object uniquely */
- if(H5Oget_info2(refobj_id, &ref_oinfo, H5O_INFO_BASIC) < 0)
+ if (H5Oget_info3(refobj_id, &ref_oinfo, H5O_INFO_BASIC) < 0)
goto out;
- if(ref_oinfo.addr == travt->objs[u].objno) {
+ if (H5Otoken_cmp(refobj_id, &ref_oinfo.token, &travt->objs[u].obj_token, &token_cmp) < 0)
+ goto out;
+ if (!token_cmp) {
ret = travt->objs[u].name;
goto out;
- } /* end if */
- } /* end if */
- } /* u */
+ }
+ } /* end if */
+ } /* u */
out:
return ret;
@@ -819,37 +845,39 @@ out:
* Purpose: Update a reference value
*-------------------------------------------------------------------------
*/
-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)
+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");
+ if (H5Rcreate(ref_out, fid_out, ref_obj_name, ref_type, space_id) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Rcreate failed");
done:
- H5E_BEGIN_TRY {
- H5Sclose(space_id);
- H5Oclose(ref_obj_id);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY
+ {
+ H5Sclose(space_id);
+ H5Oclose(ref_obj_id);
+ }
+ H5E_END_TRY;
return ret_value;
}
-
diff --git a/tools/src/h5repack/h5repack_verify.c b/tools/src/h5repack/h5repack_verify.c
index dbe8e1a..71ee72e 100644
--- a/tools/src/h5repack/h5repack_verify.c
+++ b/tools/src/h5repack/h5repack_verify.c
@@ -6,7 +6,7 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -17,13 +17,12 @@
/* number of members in an array */
#ifndef NELMTS
-# define NELMTS(X) (sizeof(X)/sizeof(X[0]))
+#define NELMTS(X) (sizeof(X) / sizeof(X[0]))
#endif
static int verify_layout(hid_t pid, pack_info_t *obj);
static int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter);
-
/*-------------------------------------------------------------------------
* Function: h5repack_verify
*
@@ -39,193 +38,195 @@ 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 */
- 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 */
- 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 */
+ 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 = 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);
-
- for(i = 0; i < options->op_tbl->nelems; i++) {
- char *name = options->op_tbl->objs[i].path;
- pack_info_t *obj = &options->op_tbl->objs[i];
-
- /*-------------------------------------------------------------------------
- * open
- *-------------------------------------------------------------------------
- */
- if((did = H5Dopen2(fidout, name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed on <%s>", name);
- if((sid = H5Dget_space(did)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
- if((pid = H5Dget_create_plist(did)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed");
- if((tid = H5Dget_type(did)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_type failed");
-
- /*-------------------------------------------------------------------------
- * filter check
- *-------------------------------------------------------------------------
- */
- if(verify_filters(pid, tid, obj->nfilters, obj->filter) <= 0)
+ if ((fidout = H5Fopen(out_fname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
+ 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;
+ pack_info_t *obj = &options->op_tbl->objs[i];
+
+ /*-------------------------------------------------------------------------
+ * open
+ *-------------------------------------------------------------------------
+ */
+ if ((did = H5Dopen2(fidout, name, H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed on <%s>", name);
+ if ((sid = H5Dget_space(did)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed");
+ if ((pid = H5Dget_create_plist(did)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed");
+ if ((tid = H5Dget_type(did)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_type failed");
+
+ /*-------------------------------------------------------------------------
+ * filter check
+ *-------------------------------------------------------------------------
+ */
+ if (verify_filters(pid, tid, obj->nfilters, obj->filter) <= 0)
ok = 0;
- /*-------------------------------------------------------------------------
- * layout check
- *-------------------------------------------------------------------------
- */
- if((obj->layout != -1) && (verify_layout(pid, obj) == 0))
+ /*-------------------------------------------------------------------------
+ * layout check
+ *-------------------------------------------------------------------------
+ */
+ if ((obj->layout != -1) && (verify_layout(pid, obj) == 0))
ok = 0;
- /*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
- if(H5Pclose(pid) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
+ /*-------------------------------------------------------------------------
+ * close
+ *-------------------------------------------------------------------------
+ */
+ 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");
}
- /*-------------------------------------------------------------------------
- * check for the "all" objects option
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * check for the "all" objects option
+ *-------------------------------------------------------------------------
+ */
- if(options->all_filter == 1 || options->all_layout == 1) {
+ if (options->all_filter == 1 || options->all_layout == 1) {
/* Initialize indexing options */
h5trav_set_index(sort_by, sort_order);
/* init table */
- trav_table_init(&travt);
+ trav_table_init(fidout, &travt);
/* 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");
+ if (h5trav_gettable(fidout, travt) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "h5trav_gettable failed");
- for(i = 0; i < travt->nobjs; i++) {
+ for (i = 0; i < travt->nobjs; i++) {
char *name = travt->objs[i].name;
- if(travt->objs[i].type == H5TRAV_TYPE_DATASET) {
- /*-------------------------------------------------------------------------
- * open
- *-------------------------------------------------------------------------
- */
- if((did = H5Dopen2(fidout, name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed on <%s>", name);
- if((sid = H5Dget_space(did)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
- if((pid = H5Dget_create_plist(did)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed");
- if((tid = H5Dget_type(did)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_type failed");
-
- /*-------------------------------------------------------------------------
- * filter check
- *-------------------------------------------------------------------------
- */
- if(options->all_filter == 1) {
- if(verify_filters(pid, tid, options->n_filter_g, options->filter_g) <= 0)
+ if (travt->objs[i].type == H5TRAV_TYPE_DATASET) {
+ /*-------------------------------------------------------------------------
+ * open
+ *-------------------------------------------------------------------------
+ */
+ if ((did = H5Dopen2(fidout, name, H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed on <%s>", name);
+ if ((sid = H5Dget_space(did)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed");
+ if ((pid = H5Dget_create_plist(did)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed");
+ if ((tid = H5Dget_type(did)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_type failed");
+
+ /*-------------------------------------------------------------------------
+ * filter check
+ *-------------------------------------------------------------------------
+ */
+ if (options->all_filter == 1) {
+ if (verify_filters(pid, tid, options->n_filter_g, options->filter_g) <= 0)
ok = 0;
}
- /*-------------------------------------------------------------------------
- * layout check
- *-------------------------------------------------------------------------
- */
- if(options->all_layout == 1) {
+ /*-------------------------------------------------------------------------
+ * layout check
+ *-------------------------------------------------------------------------
+ */
+ if (options->all_layout == 1) {
pack_info_t pack;
init_packobject(&pack);
pack.layout = options->layout_g;
- pack.chunk = options->chunk_g;
- if(verify_layout(pid, &pack) == 0)
+ pack.chunk = options->chunk_g;
+ if (verify_layout(pid, &pack) == 0)
ok = 0;
}
- /*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * close
+ *-------------------------------------------------------------------------
+ */
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 */
+ } /* i */
/* free table */
trav_table_free(travt);
travt = NULL;
}
- /*-------------------------------------------------------------------------
- * Verify that file space info are set as expected
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * Verify that file space info are set as expected
+ *-------------------------------------------------------------------------
+ */
/* 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);
+ if ((fidin = H5Fopen(in_fname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
+ 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");
+ if ((fcpl_in = H5Fget_create_plist(fidin)) < 0)
+ 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");
+ if (H5Pget_file_space_strategy(fcpl_in, &in_strategy, &in_persist, &in_threshold) < 0)
+ 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");
+ if (H5Pget_file_space_page_size(fcpl_in, &in_pagesize) < 0)
+ 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");
+ if ((fcpl_out = H5Fget_create_plist(fidout)) < 0)
+ 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");
+ if (H5Pget_file_space_strategy(fcpl_out, &out_strategy, &out_persist, &out_threshold) < 0)
+ 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");
+ if (H5Pget_file_space_page_size(fcpl_out, &out_pagesize) < 0)
+ 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.
* If -S option is not set, the file space handling strategy should be
* the same as the input file's strategy.
*/
- 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");
+ if (options->fs_strategy) {
+ if (out_strategy != (options->fs_strategy == (H5F_fspace_strategy_t)-1 ? 0 : options->fs_strategy))
+ 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");
+ if (out_strategy != in_strategy)
+ H5TOOLS_GOTO_ERROR((-1), "file space strategy not set as unexpected");
}
/*
@@ -233,13 +234,13 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
* If the -P option is not set, the free-space persist status should be
* the same as the input file's free-space persist status
*/
- 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");
+ if (options->fs_persist) {
+ if (out_persist != (hbool_t)(options->fs_persist == (-1) ? FALSE : options->fs_persist))
+ 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");
+ if (out_persist != in_persist)
+ H5TOOLS_GOTO_ERROR((-1), "free-space persist status not set as unexpected");
}
/*
@@ -247,13 +248,13 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
* If the -T option is not set, the threshold should be the same as the
* input file's threshold size.
*/
- 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");
+ if (options->fs_threshold) {
+ if (out_threshold != (hsize_t)(options->fs_threshold == (-1) ? 0 : options->fs_threshold))
+ 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");
+ if (out_threshold != in_threshold)
+ H5TOOLS_GOTO_ERROR((-1), "threshold not set as unexpected");
}
/*
@@ -261,20 +262,20 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
* If the -G option is not set, the file space page size should be
* the same as the input file's file space page size.
*/
- 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");
+ if (options->fs_pagesize) {
+ if (out_pagesize != (hsize_t)(options->fs_pagesize == (-1) ? 0 : options->fs_pagesize))
+ 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");
-
+ if (out_pagesize != in_pagesize)
+ H5TOOLS_GOTO_ERROR((-1), "file space page size not set as unexpected");
}
ret_value = ok;
done:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Pclose(fcpl_in);
H5Pclose(fcpl_out);
H5Pclose(pid);
@@ -285,7 +286,8 @@ done:
H5Fclose(fidout);
if (travt)
trav_table_free(travt);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return ret_value;
} /* h5repack_verify() */
@@ -305,13 +307,14 @@ done:
*-------------------------------------------------------------------------
*/
-int verify_layout(hid_t pid, pack_info_t *obj)
+int
+verify_layout(hid_t pid, pack_info_t *obj)
{
- hsize_t chsize[64]; /* chunk size in elements */
- H5D_layout_t layout; /* layout */
- int nfilters; /* number of filters */
- int rank; /* rank */
- int i; /* index */
+ hsize_t chsize[64]; /* chunk size in elements */
+ H5D_layout_t layout; /* layout */
+ int nfilters; /* number of filters */
+ int rank; /* rank */
+ int i; /* index */
/* check if we have filters in the input object */
if ((nfilters = H5Pget_nfilters(pid)) < 0)
@@ -328,8 +331,8 @@ int verify_layout(hid_t pid, pack_info_t *obj)
if (obj->layout != layout)
return 0;
- if (layout==H5D_CHUNKED) {
- if ((rank = H5Pget_chunk(pid, NELMTS(chsize), chsize/*out*/)) < 0)
+ if (layout == H5D_CHUNKED) {
+ if ((rank = H5Pget_chunk(pid, NELMTS(chsize), chsize /*out*/)) < 0)
return -1;
if (obj->chunk.rank != rank)
return 0;
@@ -353,108 +356,111 @@ 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 */
- unsigned crt_order_flag1; /* group creation order flag */
- unsigned crt_order_flag2; /* group creation order flag */
- trav_table_t *trav = NULL;
+ 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;
unsigned int i;
+ int ret_value = 1;
- /*-------------------------------------------------------------------------
- * open the files
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * 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);
-
- /*-------------------------------------------------------------------------
- * get file table list of objects
- *-------------------------------------------------------------------------
- */
+ if ((fid1 = h5tools_fopen(fname1, H5F_ACC_RDONLY, fname1_fapl, (fname1_fapl != H5P_DEFAULT), NULL, 0)) <
+ 0)
+ H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fname1, H5FOPENERROR);
+ if ((fid2 = h5tools_fopen(fname2, H5F_ACC_RDONLY, fname2_fapl, (fname2_fapl != H5P_DEFAULT), NULL, 0)) <
+ 0)
+ H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fname2, H5FOPENERROR);
+
+ /*-------------------------------------------------------------------------
+ * get file table list of objects
+ *-------------------------------------------------------------------------
+ */
/* Initialize indexing options */
h5trav_set_index(sort_by, sort_order);
/* init table */
- trav_table_init(&trav);
- if(h5trav_gettable(fid1, trav) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5trav_gettable failed");
-
- /*-------------------------------------------------------------------------
- * traverse the suppplied object list
- *-------------------------------------------------------------------------
- */
- for(i = 0; i < trav->nobjs; i++) {
- if(trav->objs[i].type == H5TRAV_TYPE_GROUP) {
+ trav_table_init(fid1, &trav);
+ if (h5trav_gettable(fid1, trav) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "h5trav_gettable failed");
+
+ /*-------------------------------------------------------------------------
+ * traverse the supplied object list
+ *-------------------------------------------------------------------------
+ */
+ 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);
- 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);
- if((dcpl1 = H5Dget_create_plist(dset1)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed");
- if((dcpl2 = H5Dget_create_plist(dset2)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "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");
-
- if(ret_value == 0)
- HGOTO_ERROR(0, H5E_tools_min_id_g, "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");
- if(H5Pclose(dcpl2) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
- if(H5Dclose(dset1) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
- if(H5Dclose(dset2) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
+ else if (trav->objs[i].type == H5TRAV_TYPE_DATASET) {
+ if ((dset1 = H5Dopen2(fid1, trav->objs[i].name, H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed on first <%s>", trav->objs[i].name);
+ if ((dset2 = H5Dopen2(fid2, trav->objs[i].name, H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed on second <%s>", trav->objs[i].name);
+ if ((dcpl1 = H5Dget_create_plist(dset1)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed");
+ if ((dcpl2 = H5Dget_create_plist(dset2)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed");
+
+ /*-------------------------------------------------------------------------
+ * compare the property lists
+ *-------------------------------------------------------------------------
+ */
+ if ((ret_value = H5Pequal(dcpl1, dcpl2)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pequal failed");
+
+ if (ret_value == 0)
+ H5TOOLS_GOTO_ERROR(0, "property lists failed for <%s> are different", trav->objs[i].name);
+
+ /*-------------------------------------------------------------------------
+ * close
+ *-------------------------------------------------------------------------
+ */
+ if (H5Pclose(dcpl1) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
+ if (H5Pclose(dcpl2) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed");
+ if (H5Dclose(dset1) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed");
+ if (H5Dclose(dset2) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed");
} /*if*/
- } /*for*/
+ } /*for*/
done:
H5E_BEGIN_TRY
@@ -467,14 +473,14 @@ done:
H5Fclose(fid2);
H5Pclose(gcplid);
H5Gclose(gid);
- if(trav)
+ if (trav)
trav_table_free(trav);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return ret_value;
}
-
/*-------------------------------------------------------------------------
* Function: verify_filters
*
@@ -489,27 +495,25 @@ done:
*-------------------------------------------------------------------------
*/
-static
-int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter)
+static int
+verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter)
{
- int nfilters_dcpl; /* number of filters in DCPL*/
- unsigned filt_flags; /* filter flags */
- H5Z_filter_t filtn; /* filter identification number */
- unsigned cd_values[20]; /* filter client data values */
- size_t cd_nelmts; /* filter client number of values */
- char f_name[256]; /* filter name */
- size_t size; /* type size */
- int i; /* index */
- unsigned j; /* index */
+ int nfilters_dcpl; /* number of filters in DCPL*/
+ unsigned filt_flags; /* filter flags */
+ H5Z_filter_t filtn; /* filter identification number */
+ unsigned cd_values[20]; /* filter client data values */
+ size_t cd_nelmts; /* filter client number of values */
+ char f_name[256]; /* filter name */
+ size_t size; /* type size */
+ int i; /* index */
+ unsigned j; /* index */
/* get information about filters */
- if((nfilters_dcpl = H5Pget_nfilters(pid)) < 0)
+ if ((nfilters_dcpl = H5Pget_nfilters(pid)) < 0)
return -1;
/* if we do not have filters and the requested filter is NONE, return 1 */
- if(!nfilters_dcpl &&
- nfilters == 1 &&
- filter[0].filtn == H5Z_FILTER_NONE)
+ if (!nfilters_dcpl && nfilters == 1 && filter[0].filtn == H5Z_FILTER_NONE)
return 1;
/* else the numbers of filters must match */
@@ -523,8 +527,8 @@ int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter)
for (i = 0; i < nfilters_dcpl; i++) {
cd_nelmts = NELMTS(cd_values);
- filtn = H5Pget_filter2(pid, (unsigned)i, &filt_flags, &cd_nelmts,
- cd_values, sizeof(f_name), f_name, NULL);
+ filtn = H5Pget_filter2(pid, (unsigned)i, &filt_flags, &cd_nelmts, cd_values, sizeof(f_name), f_name,
+ NULL);
/* filter ID */
if (filtn < 0)
@@ -535,7 +539,7 @@ int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter)
/* compare client data values. some filters do return local values */
switch (filtn) {
case H5Z_FILTER_NONE:
- break;
+ break;
case H5Z_FILTER_SHUFFLE:
/* 1 private client value is returned by DCPL */
@@ -543,7 +547,7 @@ int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter)
return 0;
/* get dataset's type size */
- if((size = H5Tget_size(tid)) <= 0)
+ if ((size = H5Tget_size(tid)) <= 0)
return -1;
/* the private client value holds the dataset's type size */
diff --git a/tools/src/h5stat/CMakeLists.txt b/tools/src/h5stat/CMakeLists.txt
index 55c675f..88c0d3d 100644
--- a/tools/src/h5stat/CMakeLists.txt
+++ b/tools/src/h5stat/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.10)
+cmake_minimum_required (VERSION 3.12)
project (HDF5_TOOLS_SRC_H5STAT C)
# --------------------------------------------------------------------
@@ -6,7 +6,8 @@ project (HDF5_TOOLS_SRC_H5STAT C)
# --------------------------------------------------------------------
if (NOT ONLY_SHARED_LIBS)
add_executable (h5stat ${HDF5_TOOLS_SRC_H5STAT_SOURCE_DIR}/h5stat.c)
- target_include_directories (h5stat PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_include_directories (h5stat PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5stat PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5stat STATIC)
target_link_libraries (h5stat PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
set_target_properties (h5stat PROPERTIES FOLDER tools)
@@ -17,7 +18,8 @@ endif ()
if (BUILD_SHARED_LIBS)
add_executable (h5stat-shared ${HDF5_TOOLS_SRC_H5STAT_SOURCE_DIR}/h5stat.c)
- target_include_directories (h5stat-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_include_directories (h5stat-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5stat-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5stat-shared SHARED)
target_link_libraries (h5stat-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
set_target_properties (h5stat-shared PROPERTIES FOLDER tools)
@@ -26,6 +28,17 @@ if (BUILD_SHARED_LIBS)
set (H5_DEP_EXECUTABLES ${H5_DEP_EXECUTABLES} h5stat-shared)
endif ()
+#-----------------------------------------------------------------------------
+# Add Target to clang-format
+#-----------------------------------------------------------------------------
+if (HDF5_ENABLE_FORMATTERS)
+ if (NOT ONLY_SHARED_LIBS)
+ clang_format (HDF5_H5STAT_SRC_FORMAT h5stat)
+ else ()
+ clang_format (HDF5_H5STAT_SRC_FORMAT h5stat-shared)
+ endif ()
+endif ()
+
##############################################################################
##############################################################################
### I N S T A L L A T I O N ###
diff --git a/tools/src/h5stat/Makefile.am b/tools/src/h5stat/Makefile.am
index c228b48..9231633 100644
--- a/tools/src/h5stat/Makefile.am
+++ b/tools/src/h5stat/Makefile.am
@@ -6,7 +6,7 @@
# This file is part of HDF5. The full HDF5 copyright notice, including
# terms governing use, modification, and redistribution, is contained in
# the COPYING file, which can be found at the root of the source code
-# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.
+# distribution tree, or in https://www.hdfgroup.org/licenses.
# If you do not have access to either file, you may request a copy from
# help@hdfgroup.org.
##
diff --git a/tools/src/h5stat/h5stat.c b/tools/src/h5stat/h5stat.c
index 9528d2c..e42af10 100644
--- a/tools/src/h5stat/h5stat.c
+++ b/tools/src/h5stat/h5stat.c
@@ -6,12 +6,12 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#include "H5private.h" /* Generic Functions */
+#include "H5private.h" /* Generic Functions */
#include "h5tools.h"
#include "h5tools_utils.h"
#include "h5tools_ref.h"
@@ -24,148 +24,144 @@
/* Parameters to control statistics gathered */
/* Default threshold for small groups/datasets/attributes */
-#define DEF_SIZE_SMALL_GROUPS 10
-#define DEF_SIZE_SMALL_DSETS 10
-#define DEF_SIZE_SMALL_ATTRS 10
+#define DEF_SIZE_SMALL_GROUPS 10
+#define DEF_SIZE_SMALL_DSETS 10
+#define DEF_SIZE_SMALL_ATTRS 10
-#define SIZE_SMALL_SECTS 10
+#define SIZE_SMALL_SECTS 10
-#define H5_NFILTERS_IMPL 8 /* Number of currently implemented filters + one to
- accommodate for user-define filters + one
- to accomodate datasets whithout any filters */
+#define H5_NFILTERS_IMPL \
+ 8 /* Number of currently implemented filters + one to \
+ accommodate for user-define filters + one \
+ to accommodate datasets without any filters */
/* File space management strategies: see H5Fpublic.h for declarations */
-const char *FS_STRATEGY_NAME[] = {
- "H5F_FSPACE_STRATEGY_FSM_AGGR",
- "H5F_FSPACE_STRATEGY_PAGE",
- "H5F_FSPACE_STRATEGY_AGGR",
- "H5F_FSPACE_STRATEGY_NONE",
- "unknown",
- NULL
-};
+const char *FS_STRATEGY_NAME[] = {"H5F_FSPACE_STRATEGY_FSM_AGGR",
+ "H5F_FSPACE_STRATEGY_PAGE",
+ "H5F_FSPACE_STRATEGY_AGGR",
+ "H5F_FSPACE_STRATEGY_NONE",
+ "unknown",
+ NULL};
/* Datatype statistics for datasets */
typedef struct dtype_info_t {
- hid_t tid; /* ID of datatype */
- unsigned long count; /* Number of types found */
- unsigned long named; /* Number of types that are named */
+ hid_t tid; /* ID of datatype */
+ unsigned long count; /* Number of types found */
+ unsigned long named; /* Number of types that are named */
} dtype_info_t;
typedef struct ohdr_info_t {
- hsize_t total_size; /* Total size of object headers */
- hsize_t free_size; /* Total free space in object headers */
+ hsize_t total_size; /* Total size of object headers */
+ hsize_t free_size; /* Total free space in object headers */
} ohdr_info_t;
/* Info to pass to the iteration functions */
typedef struct iter_t {
- hid_t fid; /* File ID */
- hsize_t filesize; /* Size of the file */
- unsigned long uniq_groups; /* Number of unique groups */
- unsigned long uniq_dsets; /* Number of unique datasets */
- unsigned long uniq_dtypes; /* Number of unique named datatypes */
- unsigned long uniq_links; /* Number of unique links */
- unsigned long uniq_others; /* Number of other unique objects */
-
- unsigned long max_links; /* Maximum # of links to an object */
- hsize_t max_fanout; /* Maximum fanout from a group */
- unsigned long *num_small_groups; /* Size of small groups tracked */
- unsigned group_nbins; /* Number of bins for group counts */
- unsigned long *group_bins; /* Pointer to array of bins for group counts */
- ohdr_info_t group_ohdr_info; /* Object header information for groups */
-
- hsize_t max_attrs; /* Maximum attributes from a group */
- unsigned long *num_small_attrs; /* Size of small attributes tracked */
- unsigned attr_nbins; /* Number of bins for attribute counts */
- unsigned long *attr_bins; /* Pointer to array of bins for attribute counts */
-
- unsigned max_dset_rank; /* Maximum rank of dataset */
- unsigned long dset_rank_count[H5S_MAX_RANK]; /* Number of datasets of each rank */
- hsize_t max_dset_dims; /* Maximum dimension size of dataset */
- unsigned long *small_dset_dims; /* Size of dimensions of small datasets tracked */
- unsigned long dset_layouts[H5D_NLAYOUTS]; /* Type of storage for each dataset */
- unsigned long dset_comptype[H5_NFILTERS_IMPL]; /* Number of currently implemented filters */
- unsigned long dset_ntypes; /* Number of diff. dataset datatypes found */
- dtype_info_t *dset_type_info; /* Pointer to dataset datatype information found */
- unsigned dset_dim_nbins; /* Number of bins for dataset dimensions */
- unsigned long *dset_dim_bins; /* Pointer to array of bins for dataset dimensions */
- ohdr_info_t dset_ohdr_info; /* Object header information for datasets */
- hsize_t dset_storage_size; /* Size of raw data for datasets */
- hsize_t dset_external_storage_size; /* Size of raw data for datasets with external storage */
- ohdr_info_t dtype_ohdr_info; /* Object header information for datatypes */
- hsize_t groups_btree_storage_size; /* btree size for group */
- hsize_t groups_heap_storage_size; /* heap size for group */
- hsize_t attrs_btree_storage_size; /* btree size for attributes (1.8) */
- hsize_t attrs_heap_storage_size; /* fractal heap size for attributes (1.8) */
- hsize_t SM_hdr_storage_size; /* header size for SOHM table (1.8) */
- hsize_t SM_index_storage_size; /* index (btree & list) size for SOHM table (1.8) */
- hsize_t SM_heap_storage_size; /* fractal heap size for SOHM table (1.8) */
- hsize_t super_size; /* superblock size */
- hsize_t super_ext_size; /* superblock extension size */
- hsize_t ublk_size; /* user block size (if exists) */
- H5F_fspace_strategy_t fs_strategy; /* File space management strategy */
- hbool_t fs_persist; /* Free-space persist or not */
- hsize_t fs_threshold; /* Free-space section threshold */
- hsize_t fsp_size; /* File space page size */
- hsize_t free_space; /* Amount of freespace in the file */
- hsize_t free_hdr; /* Size of free space manager metadata in the file */
- unsigned long num_small_sects[SIZE_SMALL_SECTS]; /* Size of small free-space sections */
- unsigned sect_nbins; /* Number of bins for free-space section sizes */
- unsigned long *sect_bins; /* Pointer to array of bins for free-space section sizes */
- hsize_t datasets_index_storage_size;/* meta size for chunked dataset's indexing type */
- hsize_t datasets_heap_storage_size; /* heap size for dataset with external storage */
- unsigned long nexternal; /* Number of external files for a dataset */
- int local; /* Flag to indicate iteration over the object*/
+ hid_t fid; /* File ID */
+ hsize_t filesize; /* Size of the file */
+ unsigned long uniq_groups; /* Number of unique groups */
+ unsigned long uniq_dsets; /* Number of unique datasets */
+ unsigned long uniq_dtypes; /* Number of unique named datatypes */
+ unsigned long uniq_links; /* Number of unique links */
+ unsigned long uniq_others; /* Number of other unique objects */
+
+ unsigned long max_links; /* Maximum # of links to an object */
+ hsize_t max_fanout; /* Maximum fanout from a group */
+ unsigned long *num_small_groups; /* Size of small groups tracked */
+ unsigned group_nbins; /* Number of bins for group counts */
+ unsigned long *group_bins; /* Pointer to array of bins for group counts */
+ ohdr_info_t group_ohdr_info; /* Object header information for groups */
+
+ hsize_t max_attrs; /* Maximum attributes from a group */
+ unsigned long *num_small_attrs; /* Size of small attributes tracked */
+ unsigned attr_nbins; /* Number of bins for attribute counts */
+ unsigned long *attr_bins; /* Pointer to array of bins for attribute counts */
+
+ unsigned max_dset_rank; /* Maximum rank of dataset */
+ unsigned long dset_rank_count[H5S_MAX_RANK]; /* Number of datasets of each rank */
+ hsize_t max_dset_dims; /* Maximum dimension size of dataset */
+ unsigned long *small_dset_dims; /* Size of dimensions of small datasets tracked */
+ unsigned long dset_layouts[H5D_NLAYOUTS]; /* Type of storage for each dataset */
+ unsigned long dset_comptype[H5_NFILTERS_IMPL]; /* Number of currently implemented filters */
+ unsigned long dset_ntypes; /* Number of diff. dataset datatypes found */
+ dtype_info_t * dset_type_info; /* Pointer to dataset datatype information found */
+ unsigned dset_dim_nbins; /* Number of bins for dataset dimensions */
+ unsigned long *dset_dim_bins; /* Pointer to array of bins for dataset dimensions */
+ ohdr_info_t dset_ohdr_info; /* Object header information for datasets */
+ hsize_t dset_storage_size; /* Size of raw data for datasets */
+ hsize_t dset_external_storage_size; /* Size of raw data for datasets with external storage */
+ ohdr_info_t dtype_ohdr_info; /* Object header information for datatypes */
+ hsize_t groups_btree_storage_size; /* btree size for group */
+ hsize_t groups_heap_storage_size; /* heap size for group */
+ hsize_t attrs_btree_storage_size; /* btree size for attributes (1.8) */
+ hsize_t attrs_heap_storage_size; /* fractal heap size for attributes (1.8) */
+ hsize_t SM_hdr_storage_size; /* header size for SOHM table (1.8) */
+ hsize_t SM_index_storage_size; /* index (btree & list) size for SOHM table (1.8) */
+ hsize_t SM_heap_storage_size; /* fractal heap size for SOHM table (1.8) */
+ hsize_t super_size; /* superblock size */
+ hsize_t super_ext_size; /* superblock extension size */
+ hsize_t ublk_size; /* user block size (if exists) */
+ H5F_fspace_strategy_t fs_strategy; /* File space management strategy */
+ hbool_t fs_persist; /* Free-space persist or not */
+ hsize_t fs_threshold; /* Free-space section threshold */
+ hsize_t fsp_size; /* File space page size */
+ hsize_t free_space; /* Amount of freespace in the file */
+ hsize_t free_hdr; /* Size of free space manager metadata in the file */
+ unsigned long num_small_sects[SIZE_SMALL_SECTS]; /* Size of small free-space sections */
+ unsigned sect_nbins; /* Number of bins for free-space section sizes */
+ unsigned long * sect_bins; /* Pointer to array of bins for free-space section sizes */
+ hsize_t datasets_index_storage_size; /* meta size for chunked dataset's indexing type */
+ hsize_t datasets_heap_storage_size; /* heap size for dataset with external storage */
+ unsigned long nexternal; /* Number of external files for a dataset */
+ int local; /* Flag to indicate iteration over the object*/
} iter_t;
-
-static const char *drivername = "";
+static const char *drivername = NULL;
#ifdef H5_HAVE_ROS3_VFD
-/* default "anonymous" s3 configuration
- */
+/* Default "anonymous" S3 configuration */
static H5FD_ros3_fapl_t ros3_fa = {
- 1, /* fapl version */
- false, /* authenticate */
- "", /* aws region */
- "", /* access key id */
- "", /* secret access key */
+ 1, /* Structure Version */
+ FALSE, /* Authenticate? */
+ "", /* AWS Region */
+ "", /* Access Key ID */
+ "", /* Secret Access Key */
};
#endif /* H5_HAVE_ROS3_VFD */
#ifdef H5_HAVE_LIBHDFS
-/* default HDFS access configuration
- */
+/* "Default" HDFS configuration */
static H5FD_hdfs_fapl_t hdfs_fa = {
- 1, /* fapl version */
- "localhost", /* namenode name */
- 0, /* namenode port */
- "", /* kerberos ticket cache */
- "", /* user name */
- 2048, /* stream buffer size */
+ 1, /* Structure Version */
+ "localhost", /* Namenode Name */
+ 0, /* Namenode Port */
+ "", /* Kerberos ticket cache */
+ "", /* User name */
+ 2048, /* Stream buffer size */
};
#endif /* H5_HAVE_LIBHDFS */
-static int display_all = TRUE;
+static int display_all = TRUE;
/* Enable the printing of selected statistics */
-static int display_file = FALSE; /* display file information */
-static int display_group = FALSE; /* display groups information */
-static int display_dset = FALSE; /* display datasets information */
-static int display_dset_dtype_meta = FALSE; /* display datasets' datatype information */
-static int display_attr = FALSE; /* display attributes information */
-static int display_free_sections = FALSE; /* display free space information */
-static int display_summary = FALSE; /* display summary of file space information */
+static int display_file = FALSE; /* display file information */
+static int display_group = FALSE; /* display groups information */
+static int display_dset = FALSE; /* display datasets information */
+static int display_dset_dtype_meta = FALSE; /* display datasets' datatype information */
+static int display_attr = FALSE; /* display attributes information */
+static int display_free_sections = FALSE; /* display free space information */
+static int display_summary = FALSE; /* display summary of file space information */
-static int display_file_metadata = FALSE; /* display file space info for file's metadata */
-static int display_group_metadata = FALSE; /* display file space info for groups' metadata */
-static int display_dset_metadata = FALSE; /* display file space info for datasets' metadata */
+static int display_file_metadata = FALSE; /* display file space info for file's metadata */
+static int display_group_metadata = FALSE; /* display file space info for groups' metadata */
+static int display_dset_metadata = FALSE; /* display file space info for datasets' metadata */
-static int display_object = FALSE; /* not implemented yet */
+static int display_object = FALSE; /* not implemented yet */
/* Initialize threshold for small groups/datasets/attributes */
-static int sgroups_threshold = DEF_SIZE_SMALL_GROUPS;
-static int sdsets_threshold = DEF_SIZE_SMALL_DSETS;
-static int sattrs_threshold = DEF_SIZE_SMALL_ATTRS;
+static int sgroups_threshold = DEF_SIZE_SMALL_GROUPS;
+static int sdsets_threshold = DEF_SIZE_SMALL_DSETS;
+static int sattrs_threshold = DEF_SIZE_SMALL_ATTRS;
/* a structure for handling the order command-line parameters come in */
struct handler_t {
@@ -173,120 +169,33 @@ struct handler_t {
char **obj;
};
-static const char *s_opts ="Aa:Ddm:EFfhGgl:sSTO:Vw:";
+static const char *s_opts = "Aa:Ddm:E*FfhGgl:sSTO:Vw:H:";
/* e.g. "filemetadata" has to precede "file"; "groupmetadata" has to precede "group" etc. */
-static struct long_options l_opts[] = {
- {"help", no_arg, 'h'},
- {"hel", no_arg, 'h'},
- {"he", no_arg, 'h'},
- {"filemetadata", no_arg, 'F'},
- {"filemetadat", no_arg, 'F'},
- {"filemetada", no_arg, 'F'},
- {"filemetad", no_arg, 'F'},
- {"filemeta", no_arg, 'F'},
- {"filemet", no_arg, 'F'},
- {"fileme", no_arg, 'F'},
- {"filem", no_arg, 'F'},
- {"file", no_arg, 'f'},
- {"fil", no_arg, 'f'},
- {"fi", no_arg, 'f'},
- {"groupmetadata", no_arg, 'G'},
- {"groupmetadat", no_arg, 'G'},
- {"groupmetada", no_arg, 'G'},
- {"groupmetad", no_arg, 'G'},
- {"groupmeta", no_arg, 'G'},
- {"groupmet", no_arg, 'G'},
- {"groupme", no_arg, 'G'},
- {"groupm", no_arg, 'G'},
- {"group", no_arg, 'g'},
- {"grou", no_arg, 'g'},
- {"gro", no_arg, 'g'},
- {"gr", no_arg, 'g'},
- { "links", require_arg, 'l' },
- { "link", require_arg, 'l' },
- { "lin", require_arg, 'l' },
- { "li", require_arg, 'l' },
- {"dsetmetadata", no_arg, 'D'},
- {"dsetmetadat", no_arg, 'D'},
- {"dsetmetada", no_arg, 'D'},
- {"dsetmetad", no_arg, 'D'},
- {"dsetmeta", no_arg, 'D'},
- {"dsetmet", no_arg, 'D'},
- {"dsetme", no_arg, 'D'},
- {"dsetm", no_arg, 'D'},
- {"dset", no_arg, 'd'},
- {"dse", no_arg, 'd'},
- {"ds", no_arg, 'd'},
- {"dims", require_arg, 'm'},
- {"dim", require_arg, 'm'},
- {"di", require_arg, 'm'},
- {"dtypemetadata", no_arg, 'T'},
- {"dtypemetadat", no_arg, 'T'},
- {"dtypemetada", no_arg, 'T'},
- {"dtypemetad", no_arg, 'T'},
- {"dtypemeta", no_arg, 'T'},
- {"dtypemet", no_arg, 'T'},
- {"dtypeme", no_arg, 'T'},
- {"dtypem", no_arg, 'T'},
- {"dtype", no_arg, 'T'},
- {"dtyp", no_arg, 'T'},
- {"dty", no_arg, 'T'},
- {"dt", no_arg, 'T'},
- { "object", require_arg, 'O' },
- { "objec", require_arg, 'O' },
- { "obje", require_arg, 'O' },
- { "obj", require_arg, 'O' },
- { "ob", require_arg, 'O' },
- { "version", no_arg, 'V' },
- { "versio", no_arg, 'V' },
- { "versi", no_arg, 'V' },
- { "vers", no_arg, 'V' },
- { "ver", no_arg, 'V' },
- { "ve", no_arg, 'V' },
- { "attribute", no_arg, 'A' },
- { "attribut", no_arg, 'A' },
- { "attribu", no_arg, 'A' },
- { "attrib", no_arg, 'A' },
- { "attri", no_arg, 'A' },
- { "attr", no_arg, 'A' },
- { "att", no_arg, 'A' },
- { "at", no_arg, 'A' },
- { "enable-error-stack", no_arg, 'E' },
- { "numattrs", require_arg, 'a' },
- { "numattr", require_arg, 'a' },
- { "numatt", require_arg, 'a' },
- { "numat", require_arg, 'a' },
- { "numa", require_arg, 'a' },
- { "num", require_arg, 'a' },
- { "nu", require_arg, 'a' },
- { "freespace", no_arg, 's' },
- { "freespac", no_arg, 's' },
- { "freespa", no_arg, 's' },
- { "freesp", no_arg, 's' },
- { "frees", no_arg, 's' },
- { "free", no_arg, 's' },
- { "fre", no_arg, 's' },
- { "fr", no_arg, 's' },
- { "summary", no_arg, 'S' },
- { "summar", no_arg, 'S' },
- { "summa", no_arg, 'S' },
- { "summ", no_arg, 'S' },
- { "sum", no_arg, 'S' },
- { "su", no_arg, 'S' },
- { "s3-cred", require_arg, 'w' },
- { "hdfs-attrs", require_arg, 'H' },
- { NULL, 0, '\0' }
-};
+static struct h5_long_options l_opts[] = {{"help", no_arg, 'h'},
+ {"filemetadata", no_arg, 'F'},
+ {"groupmetadata", no_arg, 'G'},
+ {"links", require_arg, 'l'},
+ {"dsetmetadata", no_arg, 'D'},
+ {"dims", require_arg, 'm'},
+ {"dtypemetadata", no_arg, 'T'},
+ {"object", require_arg, 'O'},
+ {"version", no_arg, 'V'},
+ {"attribute", no_arg, 'A'},
+ {"enable-error-stack", optional_arg, 'E'},
+ {"numattrs", require_arg, 'a'},
+ {"freespace", no_arg, 's'},
+ {"summary", no_arg, 'S'},
+ {"s3-cred", require_arg, 'w'},
+ {"hdfs-attrs", require_arg, 'H'},
+ {NULL, 0, '\0'}};
static void
leave(int ret)
{
- h5tools_close();
- HDexit(ret);
+ h5tools_close();
+ HDexit(ret);
}
-
-
/*-------------------------------------------------------------------------
* Function: usage
*
@@ -296,47 +205,51 @@ leave(int ret)
*
*-------------------------------------------------------------------------
*/
-static void usage(const char *prog)
+static void
+usage(const char *prog)
{
- HDfflush(stdout);
- HDfprintf(stdout, "Usage: %s [OPTIONS] file\n", prog);
- HDfprintf(stdout, "\n");
- HDfprintf(stdout, " OPTIONS\n");
- HDfprintf(stdout, " -h, --help Print a usage message and exit\n");
- HDfprintf(stdout, " -V, --version Print version number and exit\n");
- HDfprintf(stdout, " -f, --file Print file information\n");
- HDfprintf(stdout, " -F, --filemetadata Print file space information for file's metadata\n");
- HDfprintf(stdout, " -g, --group Print group information\n");
- HDfprintf(stdout, " -l N, --links=N Set the threshold for the # of links when printing\n");
- HDfprintf(stdout, " information for small groups. N is an integer greater\n");
- HDfprintf(stdout, " than 0. The default threshold is 10.\n");
- HDfprintf(stdout, " -G, --groupmetadata Print file space information for groups' metadata\n");
- HDfprintf(stdout, " -d, --dset Print dataset information\n");
- HDfprintf(stdout, " -m N, --dims=N Set the threshold for the dimension sizes when printing\n");
- HDfprintf(stdout, " information for small datasets. N is an integer greater\n");
- HDfprintf(stdout, " than 0. The default threshold is 10.\n");
- HDfprintf(stdout, " -D, --dsetmetadata Print file space information for datasets' metadata\n");
- HDfprintf(stdout, " -T, --dtypemetadata Print datasets' datatype information\n");
- HDfprintf(stdout, " -A, --attribute Print attribute information\n");
- HDfprintf(stdout, " -a N, --numattrs=N Set the threshold for the # of attributes when printing\n");
- HDfprintf(stdout, " information for small # of attributes. N is an integer greater\n");
- HDfprintf(stdout, " than 0. The default threshold is 10.\n");
- HDfprintf(stdout, " -s, --freespace Print free space information\n");
- HDfprintf(stdout, " -S, --summary Print summary of file space information\n");
- HDfprintf(stdout, " --enable-error-stack Prints messages from the HDF5 error stack as they occur\n");
- HDfprintf(stdout, " --s3-cred=<cred> Access file on S3, using provided credential\n");
- HDfprintf(stdout, " <cred> :: (region,id,key)\n");
- HDfprintf(stdout, " If <cred> == \"(,,)\", no authentication is used.\n");
- HDfprintf(stdout, " --hdfs-attrs=<attrs> Access a file on HDFS with given configuration\n");
- HDfprintf(stdout, " attributes.\n");
- HDfprintf(stdout, " <attrs> :: (<namenode name>,<namenode port>,\n");
- HDfprintf(stdout, " <kerberos cache path>,<username>,\n");
- HDfprintf(stdout, " <buffer size>)\n");
- HDfprintf(stdout, " If an attribute is empty, a default value will be\n");
- HDfprintf(stdout, " used.\n");
+ HDfflush(stdout);
+ HDfprintf(stdout, "Usage: %s [OPTIONS] file\n", prog);
+ HDfprintf(stdout, "\n");
+ HDfprintf(stdout, " ERROR\n");
+ HDfprintf(stdout, " --enable-error-stack Prints messages from the HDF5 error stack as they occur\n");
+ HDfprintf(stdout, " Optional value 2 also prints file open errors\n");
+ HDfprintf(stdout, " OPTIONS\n");
+ HDfprintf(stdout, " -h, --help Print a usage message and exit\n");
+ HDfprintf(stdout, " -V, --version Print version number and exit\n");
+ HDfprintf(stdout, " -f, --file Print file information\n");
+ HDfprintf(stdout, " -F, --filemetadata Print file space information for file's metadata\n");
+ HDfprintf(stdout, " -g, --group Print group information\n");
+ HDfprintf(stdout, " -l N, --links=N Set the threshold for the # of links when printing\n");
+ HDfprintf(stdout, " information for small groups. N is an integer greater\n");
+ HDfprintf(stdout, " than 0. The default threshold is 10.\n");
+ HDfprintf(stdout, " -G, --groupmetadata Print file space information for groups' metadata\n");
+ HDfprintf(stdout, " -d, --dset Print dataset information\n");
+ HDfprintf(stdout, " -m N, --dims=N Set the threshold for the dimension sizes when printing\n");
+ HDfprintf(stdout,
+ " information for small datasets. N is an integer greater\n");
+ HDfprintf(stdout, " than 0. The default threshold is 10.\n");
+ HDfprintf(stdout, " -D, --dsetmetadata Print file space information for datasets' metadata\n");
+ HDfprintf(stdout, " -T, --dtypemetadata Print datasets' datatype information\n");
+ HDfprintf(stdout, " -A, --attribute Print attribute information\n");
+ HDfprintf(stdout, " -a N, --numattrs=N Set the threshold for the # of attributes when printing\n");
+ HDfprintf(stdout,
+ " information for small # of attributes. N is an integer greater\n");
+ HDfprintf(stdout, " than 0. The default threshold is 10.\n");
+ HDfprintf(stdout, " -s, --freespace Print free space information\n");
+ HDfprintf(stdout, " -S, --summary Print summary of file space information\n");
+ HDfprintf(stdout, " --s3-cred=<cred> Access file on S3, using provided credential\n");
+ HDfprintf(stdout, " <cred> :: (region,id,key)\n");
+ HDfprintf(stdout, " If <cred> == \"(,,)\", no authentication is used.\n");
+ HDfprintf(stdout, " --hdfs-attrs=<attrs> Access a file on HDFS with given configuration\n");
+ HDfprintf(stdout, " attributes.\n");
+ HDfprintf(stdout, " <attrs> :: (<namenode name>,<namenode port>,\n");
+ HDfprintf(stdout, " <kerberos cache path>,<username>,\n");
+ HDfprintf(stdout, " <buffer size>)\n");
+ HDfprintf(stdout, " If an attribute is empty, a default value will be\n");
+ HDfprintf(stdout, " used.\n");
}
-
/*-------------------------------------------------------------------------
* Function: ceil_log10
*
@@ -353,9 +266,9 @@ H5_ATTR_CONST static unsigned
ceil_log10(unsigned long x)
{
unsigned long pow10 = 1;
- unsigned ret = 0;
+ unsigned ret = 0;
- while(x >= pow10) {
+ while (x >= pow10) {
pow10 *= 10;
ret++;
} /* end while */
@@ -363,7 +276,6 @@ ceil_log10(unsigned long x)
return ret;
} /* ceil_log10() */
-
/*-------------------------------------------------------------------------
* Function: attribute_stats
*
@@ -379,41 +291,40 @@ ceil_log10(unsigned long x)
*-------------------------------------------------------------------------
*/
static herr_t
-attribute_stats(iter_t *iter, const H5O_info_t *oi)
+attribute_stats(iter_t *iter, const H5O_info2_t *oi, const H5O_native_info_t *native_oi)
{
- unsigned bin; /* "bin" the number of objects falls in */
+ unsigned bin; /* "bin" the number of objects falls in */
/* Update dataset & attribute metadata info */
- iter->attrs_btree_storage_size += oi->meta_size.attr.index_size;
- iter->attrs_heap_storage_size += oi->meta_size.attr.heap_size;
+ iter->attrs_btree_storage_size += native_oi->meta_size.attr.index_size;
+ iter->attrs_heap_storage_size += native_oi->meta_size.attr.heap_size;
/* Update small # of attribute count & limits */
- if(oi->num_attrs <= (hsize_t)sattrs_threshold)
+ if (oi->num_attrs <= (hsize_t)sattrs_threshold)
(iter->num_small_attrs[(size_t)oi->num_attrs])++;
- if(oi->num_attrs > iter->max_attrs)
+ if (oi->num_attrs > iter->max_attrs)
iter->max_attrs = oi->num_attrs;
/* Add attribute count to proper bin */
bin = ceil_log10((unsigned long)oi->num_attrs);
- if((bin + 1) > iter->attr_nbins) {
+ if ((bin + 1) > iter->attr_nbins) {
iter->attr_bins = (unsigned long *)HDrealloc(iter->attr_bins, (bin + 1) * sizeof(unsigned long));
HDassert(iter->attr_bins);
- /* Initialize counts for intermediate bins */
- while(iter->attr_nbins < bin)
+ /* Initialize counts for intermediate bins */
+ while (iter->attr_nbins < bin)
iter->attr_bins[iter->attr_nbins++] = 0;
iter->attr_nbins++;
/* Initialize count for new bin */
iter->attr_bins[bin] = 1;
- } /* end if */
- else
- (iter->attr_bins[bin])++;
+ } /* end if */
+ else
+ (iter->attr_bins[bin])++;
- return 0;
+ return 0;
} /* end attribute_stats() */
-
/*-------------------------------------------------------------------------
* Function: group_stats
*
@@ -440,40 +351,41 @@ attribute_stats(iter_t *iter, const H5O_info_t *oi)
*-------------------------------------------------------------------------
*/
static herr_t
-group_stats(iter_t *iter, const char *name, const H5O_info_t *oi)
+group_stats(iter_t *iter, const char *name, const H5O_info2_t *oi, const H5O_native_info_t *native_oi)
{
- H5G_info_t ginfo; /* Group information */
- unsigned bin; /* "bin" the number of objects falls in */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5G_info_t ginfo; /* Group information */
+ unsigned bin; /* "bin" the number of objects falls in */
+ herr_t ret_value = SUCCEED;
/* Gather statistics about this type of object */
iter->uniq_groups++;
/* Get object header information */
- iter->group_ohdr_info.total_size += oi->hdr.space.total;
- iter->group_ohdr_info.free_size += oi->hdr.space.free;
+ iter->group_ohdr_info.total_size += native_oi->hdr.space.total;
+ iter->group_ohdr_info.free_size += native_oi->hdr.space.free;
/* Get group information */
- if((ret_value = H5Gget_info_by_name(iter->fid, name, &ginfo, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gget_info_by_name() failed");
+ if ((ret_value = H5Gget_info_by_name(iter->fid, name, &ginfo, H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Gget_info_by_name() failed");
/* Update link stats */
/* Collect statistics for small groups */
- if(ginfo.nlinks < (hsize_t)sgroups_threshold)
+ if (ginfo.nlinks < (hsize_t)sgroups_threshold)
(iter->num_small_groups[(size_t)ginfo.nlinks])++;
/* Determine maximum link count */
- if(ginfo.nlinks > iter->max_fanout)
+ if (ginfo.nlinks > iter->max_fanout)
iter->max_fanout = ginfo.nlinks;
/* Add group count to proper bin */
bin = ceil_log10((unsigned long)ginfo.nlinks);
- if((bin + 1) > iter->group_nbins) {
+ if ((bin + 1) > iter->group_nbins) {
/* Allocate more storage for info about dataset's datatype */
- if((iter->group_bins = (unsigned long *)HDrealloc(iter->group_bins, (bin + 1) * sizeof(unsigned long))) == NULL)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Drealloc() failed");
+ if ((iter->group_bins =
+ (unsigned long *)HDrealloc(iter->group_bins, (bin + 1) * sizeof(unsigned long))) == NULL)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Drealloc() failed");
/* Initialize counts for intermediate bins */
- while(iter->group_nbins < bin)
+ while (iter->group_nbins < bin)
iter->group_bins[iter->group_nbins++] = 0;
iter->group_nbins++;
@@ -484,18 +396,17 @@ group_stats(iter_t *iter, const char *name, const H5O_info_t *oi)
(iter->group_bins[bin])++;
/* Update group metadata info */
- iter->groups_btree_storage_size += oi->meta_size.obj.index_size;
- iter->groups_heap_storage_size += oi->meta_size.obj.heap_size;
+ iter->groups_btree_storage_size += native_oi->meta_size.obj.index_size;
+ iter->groups_heap_storage_size += native_oi->meta_size.obj.heap_size;
/* Update attribute metadata info */
- if((ret_value = attribute_stats(iter, oi)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "attribute_stats failed");
+ if ((ret_value = attribute_stats(iter, oi, native_oi)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "attribute_stats failed");
done:
return ret_value;
} /* end group_stats() */
-
/*-------------------------------------------------------------------------
* Function: dataset_stats
*
@@ -510,68 +421,68 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-dataset_stats(iter_t *iter, const char *name, const H5O_info_t *oi)
+dataset_stats(iter_t *iter, const char *name, const H5O_info2_t *oi, const H5O_native_info_t *native_oi)
{
- unsigned bin; /* "bin" the number of objects falls in */
- hid_t did; /* Dataset ID */
- hid_t sid; /* Dataspace ID */
- hid_t tid; /* Datatype ID */
- hid_t dcpl; /* Dataset creation property list ID */
- hsize_t dims[H5S_MAX_RANK]; /* Dimensions of dataset */
- H5D_layout_t lout; /* Layout of dataset */
- unsigned type_found; /* Whether the dataset's datatype was */
- /* already found */
- int ndims; /* Number of dimensions of dataset */
- hsize_t storage; /* Size of dataset storage */
- unsigned u; /* Local index variable */
- int num_ext; /* Number of external files for a dataset */
- int nfltr; /* Number of filters for a dataset */
- H5Z_filter_t fltr; /* Filter identifier */
- herr_t ret_value = SUCCEED; /* Return value */
+ unsigned bin; /* "bin" the number of objects falls in */
+ hid_t did; /* Dataset ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t tid; /* Datatype ID */
+ hid_t dcpl; /* Dataset creation property list ID */
+ hsize_t dims[H5S_MAX_RANK]; /* Dimensions of dataset */
+ H5D_layout_t lout; /* Layout of dataset */
+ unsigned type_found; /* Whether the dataset's datatype was */
+ /* already found */
+ int ndims; /* Number of dimensions of dataset */
+ hsize_t storage; /* Size of dataset storage */
+ unsigned u; /* Local index variable */
+ int num_ext; /* Number of external files for a dataset */
+ int nfltr; /* Number of filters for a dataset */
+ H5Z_filter_t fltr; /* Filter identifier */
+ herr_t ret_value = SUCCEED;
/* Gather statistics about this type of object */
iter->uniq_dsets++;
/* Get object header information */
- iter->dset_ohdr_info.total_size += oi->hdr.space.total;
- iter->dset_ohdr_info.free_size += oi->hdr.space.free;
+ iter->dset_ohdr_info.total_size += native_oi->hdr.space.total;
+ iter->dset_ohdr_info.free_size += native_oi->hdr.space.free;
- if((did = H5Dopen2(iter->fid, name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen() failed");
+ if ((did = H5Dopen2(iter->fid, name, H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Dopen() failed");
/* Update dataset metadata info */
- iter->datasets_index_storage_size += oi->meta_size.obj.index_size;
- iter->datasets_heap_storage_size += oi->meta_size.obj.heap_size;
+ iter->datasets_index_storage_size += native_oi->meta_size.obj.index_size;
+ iter->datasets_heap_storage_size += native_oi->meta_size.obj.heap_size;
/* Update attribute metadata info */
- if((ret_value = attribute_stats(iter, oi)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "attribute_stats() failed");
+ if ((ret_value = attribute_stats(iter, oi, native_oi)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "attribute_stats() failed");
/* Get storage info */
/* Failure 0 indistinguishable from no-data-stored 0 */
storage = H5Dget_storage_size(did);
/* Gather layout statistics */
- if((dcpl = H5Dget_create_plist(did)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist() failed");
+ if ((dcpl = H5Dget_create_plist(did)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Dget_create_plist() failed");
- if((lout = H5Pget_layout(dcpl)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_layout() failed");
+ if ((lout = H5Pget_layout(dcpl)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Pget_layout() failed");
/* Object header's total size for H5D_COMPACT layout includes raw data size */
/* "storage" also includes H5D_COMPACT raw data size */
- if(lout == H5D_COMPACT)
+ if (lout == H5D_COMPACT)
iter->dset_ohdr_info.total_size -= storage;
/* Track the layout type for dataset */
(iter->dset_layouts[lout])++;
/* Get the number of external files for the dataset */
- if((num_ext = H5Pget_external_count(dcpl)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_external_count() failed");
+ if ((num_ext = H5Pget_external_count(dcpl)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Pget_external_count() failed");
/* Accumulate raw data size accordingly */
- if(num_ext) {
+ if (num_ext) {
iter->nexternal += (unsigned long)num_ext;
iter->dset_external_storage_size += (unsigned long)storage;
}
@@ -579,37 +490,38 @@ dataset_stats(iter_t *iter, const char *name, const H5O_info_t *oi)
iter->dset_storage_size += storage;
/* Gather dataspace statistics */
- if((sid = H5Dget_space(did)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_space() failed");
+ if ((sid = H5Dget_space(did)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Sget_space() failed");
- if((ndims = H5Sget_simple_extent_dims(sid, dims, NULL)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims() failed");
+ if ((ndims = H5Sget_simple_extent_dims(sid, dims, NULL)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Sget_simple_extent_dims() failed");
/* Check for larger rank of dataset */
- if((unsigned)ndims > iter->max_dset_rank)
+ if ((unsigned)ndims > iter->max_dset_rank)
iter->max_dset_rank = (unsigned)ndims;
/* Track the number of datasets with each rank */
(iter->dset_rank_count[ndims])++;
/* Only gather dim size statistics on 1-D datasets */
- if(ndims == 1) {
+ if (ndims == 1) {
/* Determine maximum dimension size */
- if(dims[0] > iter->max_dset_dims)
+ if (dims[0] > iter->max_dset_dims)
iter->max_dset_dims = dims[0];
/* Collect statistics for small datasets */
- if(dims[0] < (hsize_t)sdsets_threshold)
+ if (dims[0] < (hsize_t)sdsets_threshold)
(iter->small_dset_dims[(size_t)dims[0]])++;
/* Add dim count to proper bin */
bin = ceil_log10((unsigned long)dims[0]);
- if((bin + 1) > iter->dset_dim_nbins) {
+ if ((bin + 1) > iter->dset_dim_nbins) {
/* Allocate more storage for info about dataset's datatype */
- if((iter->dset_dim_bins = (unsigned long *)HDrealloc(iter->dset_dim_bins, (bin + 1) * sizeof(unsigned long))) == NULL)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Drealloc() failed");
+ if ((iter->dset_dim_bins = (unsigned long *)HDrealloc(iter->dset_dim_bins,
+ (bin + 1) * sizeof(unsigned long))) == NULL)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Drealloc() failed");
/* Initialize counts for intermediate bins */
- while(iter->dset_dim_nbins < bin)
+ while (iter->dset_dim_nbins < bin)
iter->dset_dim_bins[iter->dset_dim_nbins++] = 0;
iter->dset_dim_nbins++;
@@ -620,22 +532,22 @@ dataset_stats(iter_t *iter, const char *name, const H5O_info_t *oi)
(iter->dset_dim_bins[bin])++;
} /* end if */
- if(H5Sclose(sid) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose() failed");
+ if (H5Sclose(sid) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Sclose() failed");
/* Gather datatype statistics */
- if((tid = H5Dget_type(did)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_type() failed");
+ if ((tid = H5Dget_type(did)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Dget_type() failed");
type_found = FALSE;
- for(u = 0; u < iter->dset_ntypes; u++)
- if(H5Tequal(iter->dset_type_info[u].tid, tid) > 0) {
+ for (u = 0; u < iter->dset_ntypes; u++)
+ if (H5Tequal(iter->dset_type_info[u].tid, tid) > 0) {
type_found = TRUE;
break;
} /* end for */
- if(type_found)
- (iter->dset_type_info[u].count)++;
+ if (type_found)
+ (iter->dset_type_info[u].count)++;
else {
unsigned curr_ntype = (unsigned)iter->dset_ntypes;
@@ -643,12 +555,13 @@ dataset_stats(iter_t *iter, const char *name, const H5O_info_t *oi)
iter->dset_ntypes++;
/* Allocate more storage for info about dataset's datatype */
- if((iter->dset_type_info = (dtype_info_t *)HDrealloc(iter->dset_type_info, iter->dset_ntypes * sizeof(dtype_info_t))) == NULL)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Drealloc() failed");
+ if ((iter->dset_type_info = (dtype_info_t *)HDrealloc(
+ iter->dset_type_info, iter->dset_ntypes * sizeof(dtype_info_t))) == NULL)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Drealloc() failed");
/* Initialize information about datatype */
- if((iter->dset_type_info[curr_ntype].tid = H5Tcopy(tid)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tcopy() failed");
+ if ((iter->dset_type_info[curr_ntype].tid = H5Tcopy(tid)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Tcopy() failed");
iter->dset_type_info[curr_ntype].count = 1;
iter->dset_type_info[curr_ntype].named = 0;
@@ -657,37 +570,36 @@ dataset_stats(iter_t *iter, const char *name, const H5O_info_t *oi)
} /* end else */
/* Check if the datatype is a named datatype */
- if(H5Tcommitted(tid) > 0)
+ if (H5Tcommitted(tid) > 0)
(iter->dset_type_info[u].named)++;
- if(H5Tclose(tid) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose() failed");
+ if (H5Tclose(tid) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Tclose() failed");
/* Track different filters */
- if((nfltr = H5Pget_nfilters(dcpl)) >= 0) {
- if(nfltr == 0)
- iter->dset_comptype[0]++;
- for(u = 0; u < (unsigned)nfltr; u++) {
+ if ((nfltr = H5Pget_nfilters(dcpl)) >= 0) {
+ if (nfltr == 0)
+ iter->dset_comptype[0]++;
+ for (u = 0; u < (unsigned)nfltr; u++) {
fltr = H5Pget_filter2(dcpl, u, 0, 0, 0, 0, 0, NULL);
- if(fltr >= 0) {
- if(fltr < (H5_NFILTERS_IMPL - 1))
+ if (fltr >= 0) {
+ if (fltr < (H5_NFILTERS_IMPL - 1))
iter->dset_comptype[fltr]++;
else
iter->dset_comptype[H5_NFILTERS_IMPL - 1]++; /*other filters*/
- } /* end if */
- } /* end for */
- } /* endif nfltr */
+ } /* end if */
+ } /* end for */
+ } /* endif nfltr */
- if(H5Pclose(dcpl) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose() failed");
+ if (H5Pclose(dcpl) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Pclose() failed");
- if(H5Dclose(did) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose() failed");
+ if (H5Dclose(did) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Dclose() failed");
done:
- return ret_value;
-} /* end dataset_stats() */
-
+ return ret_value;
+} /* end dataset_stats() */
/*-------------------------------------------------------------------------
* Function: datatype_stats
@@ -702,7 +614,7 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-datatype_stats(iter_t *iter, const H5O_info_t *oi)
+datatype_stats(iter_t *iter, const H5O_info2_t *oi, const H5O_native_info_t *native_oi)
{
herr_t ret_value = SUCCEED;
@@ -710,16 +622,15 @@ datatype_stats(iter_t *iter, const H5O_info_t *oi)
iter->uniq_dtypes++;
/* Get object header information */
- iter->dtype_ohdr_info.total_size += oi->hdr.space.total;
- iter->dtype_ohdr_info.free_size += oi->hdr.space.free;
+ iter->dtype_ohdr_info.total_size += native_oi->hdr.space.total;
+ iter->dtype_ohdr_info.free_size += native_oi->hdr.space.free;
/* Update attribute metadata info */
- if((ret_value = attribute_stats(iter, oi)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "attribute_stats() failed");
+ if ((ret_value = attribute_stats(iter, oi, native_oi)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "attribute_stats() failed");
done:
- return ret_value;
-} /* end datatype_stats() */
-
+ return ret_value;
+} /* end datatype_stats() */
/*-------------------------------------------------------------------------
* Function: obj_stats
@@ -735,32 +646,36 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-obj_stats(const char *path, const H5O_info_t *oi, const char *already_visited,
- void *_iter)
+obj_stats(const char *path, const H5O_info2_t *oi, const char *already_visited, void *_iter)
{
- iter_t *iter = (iter_t *)_iter;
- herr_t ret_value = SUCCEED;
+ H5O_native_info_t native_info;
+ iter_t * iter = (iter_t *)_iter;
+ herr_t ret_value = SUCCEED;
/* If the object has already been seen then just return */
- if(NULL == already_visited) {
+ if (NULL == already_visited) {
+ /* Retrieve the native info for the object */
+ if (H5Oget_native_info_by_name(iter->fid, path, &native_info, H5O_NATIVE_INFO_ALL, H5P_DEFAULT) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Oget_native_info_by_name failed");
+
/* Gather some general statistics about the object */
- if(oi->rc > iter->max_links)
+ if (oi->rc > iter->max_links)
iter->max_links = oi->rc;
- switch(oi->type) {
+ switch (oi->type) {
case H5O_TYPE_GROUP:
- if(group_stats(iter, path, oi) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "group_stats failed");
+ if (group_stats(iter, path, oi, &native_info) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "group_stats failed");
break;
case H5O_TYPE_DATASET:
- if(dataset_stats(iter, path, oi) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "dataset_stats failed");
+ if (dataset_stats(iter, path, oi, &native_info) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "dataset_stats failed");
break;
case H5O_TYPE_NAMED_DATATYPE:
- if(datatype_stats(iter, oi) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "datatype_stats failed");
+ if (datatype_stats(iter, oi, &native_info) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "datatype_stats failed");
break;
case H5O_TYPE_MAP:
@@ -771,13 +686,12 @@ obj_stats(const char *path, const H5O_info_t *oi, const char *already_visited,
iter->uniq_others++;
break;
} /* end switch */
- } /* end if */
+ } /* end if */
done:
return ret_value;
} /* end obj_stats() */
-
/*-------------------------------------------------------------------------
* Function: lnk_stats
*
@@ -792,11 +706,11 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-lnk_stats(const char H5_ATTR_UNUSED *path, const H5L_info_t *li, void *_iter)
+lnk_stats(const char H5_ATTR_UNUSED *path, const H5L_info2_t *li, void *_iter)
{
iter_t *iter = (iter_t *)_iter;
- switch(li->type) {
+ switch (li->type) {
case H5L_TYPE_SOFT:
case H5L_TYPE_EXTERNAL:
/* Gather statistics about links and UD links */
@@ -830,35 +744,35 @@ lnk_stats(const char H5_ATTR_UNUSED *path, const H5L_info_t *li, void *_iter)
static herr_t
freespace_stats(hid_t fid, iter_t *iter)
{
- H5F_sect_info_t *sect_info = NULL; /* Free space sections */
- ssize_t nsects; /* Number of free space sections */
- size_t u; /* Local index variable */
+ H5F_sect_info_t *sect_info = NULL; /* Free space sections */
+ ssize_t nsects; /* Number of free space sections */
+ size_t u; /* Local index variable */
/* Query section information */
- if((nsects = H5Fget_free_sections(fid, H5FD_MEM_DEFAULT, 0, NULL)) < 0)
- return(FAIL);
- else if(nsects) {
- if(NULL == (sect_info = (H5F_sect_info_t *)HDcalloc((size_t)nsects, sizeof(H5F_sect_info_t))))
- return(FAIL);
+ if ((nsects = H5Fget_free_sections(fid, H5FD_MEM_DEFAULT, 0, NULL)) < 0)
+ return (FAIL);
+ else if (nsects) {
+ if (NULL == (sect_info = (H5F_sect_info_t *)HDcalloc((size_t)nsects, sizeof(H5F_sect_info_t))))
+ return (FAIL);
nsects = H5Fget_free_sections(fid, H5FD_MEM_DEFAULT, (size_t)nsects, sect_info);
HDassert(nsects);
} /* end else-if */
- for(u = 0; u < (size_t)nsects; u++) {
- unsigned bin; /* "bin" the number of objects falls in */
+ for (u = 0; u < (size_t)nsects; u++) {
+ unsigned bin; /* "bin" the number of objects falls in */
- if(sect_info[u].size < SIZE_SMALL_SECTS)
+ if (sect_info[u].size < SIZE_SMALL_SECTS)
(iter->num_small_sects[(size_t)sect_info[u].size])++;
/* Add section size to proper bin */
bin = ceil_log10((unsigned long)sect_info[u].size);
- if(bin >= iter->sect_nbins) {
+ if (bin >= iter->sect_nbins) {
/* Allocate more storage for section info */
iter->sect_bins = (unsigned long *)HDrealloc(iter->sect_bins, (bin + 1) * sizeof(unsigned long));
HDassert(iter->sect_bins);
/* Initialize counts for intermediate bins */
- while(iter->sect_nbins < bin)
+ while (iter->sect_nbins < bin)
iter->sect_bins[iter->sect_nbins++] = 0;
iter->sect_nbins++;
@@ -869,13 +783,12 @@ freespace_stats(hid_t fid, iter_t *iter)
(iter->sect_bins[bin])++;
} /* end for */
- if(sect_info)
+ if (sect_info)
HDfree(sect_info);
return 0;
} /* end freespace_stats() */
-
/*-------------------------------------------------------------------------
* Function: hand_free
*
@@ -890,11 +803,11 @@ freespace_stats(hid_t fid, iter_t *iter)
static void
hand_free(struct handler_t *hand)
{
- if(hand) {
+ if (hand) {
unsigned u;
- for(u = 0; u < hand->obj_count; u++)
- if(hand->obj[u]) {
+ for (u = 0; u < hand->obj_count; u++)
+ if (hand->obj[u]) {
HDfree(hand->obj[u]);
hand->obj[u] = NULL;
} /* end if */
@@ -904,7 +817,6 @@ hand_free(struct handler_t *hand)
} /* end if */
} /* end hand_free() */
-
/*-------------------------------------------------------------------------
* Function: parse_command_line
*
@@ -920,15 +832,15 @@ hand_free(struct handler_t *hand)
*-------------------------------------------------------------------------
*/
static int
-parse_command_line(int argc, const char *argv[], struct handler_t **hand_ret)
+parse_command_line(int argc, const char *const *argv, struct handler_t **hand_ret)
{
- int opt;
- unsigned u;
- struct handler_t *hand = NULL;
+ int opt;
+ unsigned u;
+ struct handler_t *hand = NULL;
/* parse command line options */
- while((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) {
- switch((char)opt) {
+ while ((opt = H5_get_option(argc, argv, s_opts, l_opts)) != EOF) {
+ switch ((char)opt) {
case 'h':
usage(h5tools_getprogname());
h5tools_setstatus(EXIT_SUCCESS);
@@ -942,33 +854,36 @@ parse_command_line(int argc, const char *argv[], struct handler_t **hand_ret)
break;
case 'E':
- enable_error_stack = 1;
+ if (H5_optarg != NULL)
+ enable_error_stack = HDatoi(H5_optarg);
+ else
+ enable_error_stack = 1;
break;
case 'F':
- display_all = FALSE;
+ display_all = FALSE;
display_file_metadata = TRUE;
break;
case 'f':
- display_all = FALSE;
+ display_all = FALSE;
display_file = TRUE;
break;
case 'G':
- display_all = FALSE;
+ display_all = FALSE;
display_group_metadata = TRUE;
break;
case 'g':
- display_all = FALSE;
+ display_all = FALSE;
display_group = TRUE;
break;
case 'l':
- if(opt_arg) {
- sgroups_threshold = HDatoi(opt_arg);
- if(sgroups_threshold < 1) {
+ if (H5_optarg) {
+ sgroups_threshold = HDatoi(H5_optarg);
+ if (sgroups_threshold < 1) {
error_msg("Invalid threshold for small groups\n");
goto error;
}
@@ -979,19 +894,19 @@ parse_command_line(int argc, const char *argv[], struct handler_t **hand_ret)
break;
case 'D':
- display_all = FALSE;
+ display_all = FALSE;
display_dset_metadata = TRUE;
break;
case 'd':
- display_all = FALSE;
+ display_all = FALSE;
display_dset = TRUE;
break;
case 'm':
- if(opt_arg) {
- sdsets_threshold = HDatoi(opt_arg);
- if(sdsets_threshold < 1) {
+ if (H5_optarg) {
+ sdsets_threshold = HDatoi(H5_optarg);
+ if (sdsets_threshold < 1) {
error_msg("Invalid threshold for small datasets\n");
goto error;
}
@@ -1002,19 +917,19 @@ parse_command_line(int argc, const char *argv[], struct handler_t **hand_ret)
break;
case 'T':
- display_all = FALSE;
+ display_all = FALSE;
display_dset_dtype_meta = TRUE;
break;
case 'A':
- display_all = FALSE;
+ display_all = FALSE;
display_attr = TRUE;
break;
case 'a':
- if(opt_arg) {
- sattrs_threshold = HDatoi(opt_arg);
- if(sattrs_threshold < 1) {
+ if (H5_optarg) {
+ sattrs_threshold = HDatoi(H5_optarg);
+ if (sattrs_threshold < 1) {
error_msg("Invalid threshold for small # of attributes\n");
goto error;
}
@@ -1025,147 +940,76 @@ parse_command_line(int argc, const char *argv[], struct handler_t **hand_ret)
break;
case 's':
- display_all = FALSE;
+ display_all = FALSE;
display_free_sections = TRUE;
break;
case 'S':
- display_all = FALSE;
+ display_all = FALSE;
display_summary = TRUE;
break;
case 'O':
- display_all = FALSE;
+ display_all = FALSE;
display_object = TRUE;
/* Allocate space to hold the command line info */
- if(NULL == (hand = (struct handler_t *)HDcalloc((size_t)1, sizeof(struct handler_t)))) {
+ if (NULL == (hand = (struct handler_t *)HDcalloc((size_t)1, sizeof(struct handler_t)))) {
error_msg("unable to allocate memory for object struct\n");
goto error;
} /* end if */
/* Allocate space to hold the object strings */
hand->obj_count = (size_t)argc;
- if(NULL == (hand->obj = (char **)HDcalloc((size_t)argc, sizeof(char *)))) {
+ if (NULL == (hand->obj = (char **)HDcalloc((size_t)argc, sizeof(char *)))) {
error_msg("unable to allocate memory for object array\n");
goto error;
} /* end if */
/* Store object names */
- for(u = 0; u < hand->obj_count; u++)
- if(NULL == (hand->obj[u] = HDstrdup(opt_arg))) {
+ for (u = 0; u < hand->obj_count; u++)
+ if (NULL == (hand->obj[u] = HDstrdup(H5_optarg))) {
error_msg("unable to allocate memory for object name\n");
goto error;
} /* end if */
break;
case 'w':
-#ifndef H5_HAVE_ROS3_VFD
+#ifdef H5_HAVE_ROS3_VFD
+ if (h5tools_parse_ros3_fapl_tuple(H5_optarg, ',', &ros3_fa) < 0) {
+ error_msg("failed to parse S3 VFD credential info\n");
+ goto error;
+ }
+
+ drivername = drivernames[ROS3_VFD_IDX];
+#else
error_msg("Read-Only S3 VFD not enabled.\n");
goto error;
-#else
- {
- char *cred_str = NULL;
- unsigned nelems = 0;
- char **cred = NULL;
- char const *ccred[3];
-
- if (FAIL == parse_tuple((const char *)opt_arg, ',', &cred_str, &nelems, &cred)) {
- error_msg("Unable to parse s3 credential\n");
- goto error;
- }
- if (nelems != 3) {
- error_msg("s3 credential must have three elements\n");
- goto error;
- }
- ccred[0] = (const char *)cred[0];
- ccred[1] = (const char *)cred[1];
- ccred[2] = (const char *)cred[2];
- if (0 == h5tools_populate_ros3_fapl(&ros3_fa, ccred)) {
- error_msg("Unable to set ros3 fapl config\n");
- goto error;
- }
- HDfree(cred);
- HDfree(cred_str);
- } /* parse s3-cred block */
- drivername = "ros3";
+#endif
break;
-#endif /* H5_HAVE_ROS3_VFD */
case 'H':
-#ifndef H5_HAVE_LIBHDFS
- error_msg("HDFS VFD is not enabled.\n");
- goto error;
-#else
- {
- unsigned nelems = 0;
- char *props_src = NULL;
- char **props = NULL;
- unsigned long k = 0;
- if (FAIL == parse_tuple((const char *)opt_arg,
- ',', &props_src, &nelems, &props)) {
- error_msg("unable to parse hdfs properties tuple\n");
- goto error;
- }
- /* sanity-check tuple count
- */
- if (nelems != 5) {
- char str[64] = "";
- HDsprintf(str,
- "expected 5 elements in hdfs properties tuple "
- "but found %u\n",
- nelems);
- HDfree(props);
- HDfree(props_src);
- error_msg(str);
- goto error;
- }
- /* Populate fapl configuration structure with given
- * properties.
- * TODO/WARNING: No error-checking is done on length of
- * input strings... Silent overflow is possible,
- * albeit unlikely.
- */
- if (HDstrncmp(props[0], "", 1)) {
- HDstrncpy(hdfs_fa.namenode_name,(const char *)props[0], HDstrlen(props[0]));
- }
- if (HDstrncmp(props[1], "", 1)) {
- k = strtoul((const char *)props[1], NULL, 0);
- if (errno == ERANGE) {
- error_msg("supposed port number wasn't.\n");
- goto error;
- }
- hdfs_fa.namenode_port = (int32_t)k;
- }
- if (HDstrncmp(props[2], "", 1)) {
- HDstrncpy(hdfs_fa.kerberos_ticket_cache, (const char *)props[2], HDstrlen(props[2]));
- }
- if (HDstrncmp(props[3], "", 1)) {
- HDstrncpy(hdfs_fa.user_name, (const char *)props[3], HDstrlen(props[3]));
- }
- if (strncmp(props[4], "", 1)) {
- k = HDstrtoul((const char *)props[4], NULL, 0);
- if (errno == ERANGE) {
- error_msg("supposed buffersize number wasn't.\n");
- goto error;
- }
- hdfs_fa.stream_buffer_size = (int32_t)k;
- }
- HDfree(props);
- HDfree(props_src);
- drivername = "hdfs";
+#ifdef H5_HAVE_LIBHDFS
+ if (h5tools_parse_hdfs_fapl_tuple(H5_optarg, ',', &hdfs_fa) < 0) {
+ error_msg("failed to parse HDFS VFD configuration info\n");
+ goto error;
}
+
+ drivername = drivernames[HDFS_VFD_IDX];
+#else
+ error_msg("HDFS VFD not enabled.\n");
+ goto error;
+#endif
break;
-#endif /* H5_HAVE_LIBHDFS */
default:
usage(h5tools_getprogname());
goto error;
} /* end switch */
- } /* end while */
+ } /* end while */
/* check for file name to be processed */
- if(argc <= opt_ind) {
+ if (argc <= H5_optind) {
error_msg("missing file name\n");
usage(h5tools_getprogname());
goto error;
@@ -1184,7 +1028,6 @@ error:
return -1;
}
-
/*-------------------------------------------------------------------------
* Function: iter_free
*
@@ -1201,55 +1044,54 @@ iter_free(iter_t *iter)
{
/* Clear array of bins for group counts */
- if(iter->group_bins) {
+ if (iter->group_bins) {
HDfree(iter->group_bins);
iter->group_bins = NULL;
} /* end if */
/* Clear array for tracking small groups */
- if(iter->num_small_groups) {
+ if (iter->num_small_groups) {
HDfree(iter->num_small_groups);
iter->num_small_groups = NULL;
} /* end if */
/* Clear array of bins for attribute counts */
- if(iter->attr_bins) {
+ if (iter->attr_bins) {
HDfree(iter->attr_bins);
iter->attr_bins = NULL;
} /* end if */
/* Clear array for tracking small attributes */
- if(iter->num_small_attrs) {
+ if (iter->num_small_attrs) {
HDfree(iter->num_small_attrs);
- iter->num_small_attrs= NULL;
+ iter->num_small_attrs = NULL;
} /* end if */
/* Clear dataset datatype information found */
- if(iter->dset_type_info) {
+ if (iter->dset_type_info) {
HDfree(iter->dset_type_info);
iter->dset_type_info = NULL;
} /* end if */
/* Clear array of bins for dataset dimensions */
- if(iter->dset_dim_bins) {
+ if (iter->dset_dim_bins) {
HDfree(iter->dset_dim_bins);
iter->dset_dim_bins = NULL;
} /* end if */
/* Clear array of tracking 1-D small datasets */
- if(iter->small_dset_dims) {
+ if (iter->small_dset_dims) {
HDfree(iter->small_dset_dims);
iter->small_dset_dims = NULL;
} /* end if */
/* Clear array of bins for free-space section sizes */
- if(iter->sect_bins) {
+ if (iter->sect_bins) {
HDfree(iter->sect_bins);
iter->sect_bins = NULL;
} /* end if */
} /* end iter_free() */
-
/*-------------------------------------------------------------------------
* Function: print_file_info
*
@@ -1276,12 +1118,11 @@ print_file_info(const iter_t *iter)
HDprintf("\t# of unique links: %lu\n", iter->uniq_links);
HDprintf("\t# of unique other: %lu\n", iter->uniq_others);
HDprintf("\tMax. # of links to object: %lu\n", iter->max_links);
- HDfprintf(stdout, "\tMax. # of objects in group: %Hu\n", iter->max_fanout);
+ HDfprintf(stdout, "\tMax. # of objects in group: %" PRIuHSIZE "\n", iter->max_fanout);
return 0;
} /* print_file_info() */
-
/*-------------------------------------------------------------------------
* Function: print_file_metadata
*
@@ -1300,45 +1141,44 @@ static herr_t
print_file_metadata(const iter_t *iter)
{
HDfprintf(stdout, "File space information for file metadata (in bytes):\n");
- HDfprintf(stdout, "\tSuperblock: %Hu\n", iter->super_size);
- HDfprintf(stdout, "\tSuperblock extension: %Hu\n", iter->super_ext_size);
- HDfprintf(stdout, "\tUser block: %Hu\n", iter->ublk_size);
+ HDfprintf(stdout, "\tSuperblock: %" PRIuHSIZE "\n", iter->super_size);
+ HDfprintf(stdout, "\tSuperblock extension: %" PRIuHSIZE "\n", iter->super_ext_size);
+ HDfprintf(stdout, "\tUser block: %" PRIuHSIZE "\n", iter->ublk_size);
HDfprintf(stdout, "\tObject headers: (total/unused)\n");
- HDfprintf(stdout, "\t\tGroups: %Hu/%Hu\n", iter->group_ohdr_info.total_size,
- iter->group_ohdr_info.free_size);
- HDfprintf(stdout, "\t\tDatasets(exclude compact data): %Hu/%Hu\n",
- iter->dset_ohdr_info.total_size, iter->dset_ohdr_info.free_size);
- HDfprintf(stdout, "\t\tDatatypes: %Hu/%Hu\n", iter->dtype_ohdr_info.total_size,
- iter->dtype_ohdr_info.free_size);
+ HDfprintf(stdout, "\t\tGroups: %" PRIuHSIZE "/%" PRIuHSIZE "\n", iter->group_ohdr_info.total_size,
+ iter->group_ohdr_info.free_size);
+ HDfprintf(stdout, "\t\tDatasets(exclude compact data): %" PRIuHSIZE "/%" PRIuHSIZE "\n",
+ iter->dset_ohdr_info.total_size, iter->dset_ohdr_info.free_size);
+ HDfprintf(stdout, "\t\tDatatypes: %" PRIuHSIZE "/%" PRIuHSIZE "\n", iter->dtype_ohdr_info.total_size,
+ iter->dtype_ohdr_info.free_size);
HDfprintf(stdout, "\tGroups:\n");
- HDfprintf(stdout, "\t\tB-tree/List: %Hu\n", iter->groups_btree_storage_size);
- HDfprintf(stdout, "\t\tHeap: %Hu\n", iter->groups_heap_storage_size);
+ HDfprintf(stdout, "\t\tB-tree/List: %" PRIuHSIZE "\n", iter->groups_btree_storage_size);
+ HDfprintf(stdout, "\t\tHeap: %" PRIuHSIZE "\n", iter->groups_heap_storage_size);
HDfprintf(stdout, "\tAttributes:\n");
- HDfprintf(stdout, "\t\tB-tree/List: %Hu\n", iter->attrs_btree_storage_size);
- HDfprintf(stdout, "\t\tHeap: %Hu\n", iter->attrs_heap_storage_size);
+ HDfprintf(stdout, "\t\tB-tree/List: %" PRIuHSIZE "\n", iter->attrs_btree_storage_size);
+ HDfprintf(stdout, "\t\tHeap: %" PRIuHSIZE "\n", iter->attrs_heap_storage_size);
HDfprintf(stdout, "\tChunked datasets:\n");
- HDfprintf(stdout, "\t\tIndex: %Hu\n", iter->datasets_index_storage_size);
+ HDfprintf(stdout, "\t\tIndex: %" PRIuHSIZE "\n", iter->datasets_index_storage_size);
HDfprintf(stdout, "\tDatasets:\n");
- HDfprintf(stdout, "\t\tHeap: %Hu\n", iter->datasets_heap_storage_size);
+ HDfprintf(stdout, "\t\tHeap: %" PRIuHSIZE "\n", iter->datasets_heap_storage_size);
HDfprintf(stdout, "\tShared Messages:\n");
- HDfprintf(stdout, "\t\tHeader: %Hu\n", iter->SM_hdr_storage_size);
- HDfprintf(stdout, "\t\tB-tree/List: %Hu\n", iter->SM_index_storage_size);
- HDfprintf(stdout, "\t\tHeap: %Hu\n", iter->SM_heap_storage_size);
+ HDfprintf(stdout, "\t\tHeader: %" PRIuHSIZE "\n", iter->SM_hdr_storage_size);
+ HDfprintf(stdout, "\t\tB-tree/List: %" PRIuHSIZE "\n", iter->SM_index_storage_size);
+ HDfprintf(stdout, "\t\tHeap: %" PRIuHSIZE "\n", iter->SM_heap_storage_size);
HDfprintf(stdout, "\tFree-space managers:\n");
- HDfprintf(stdout, "\t\tHeader: %Hu\n", iter->free_hdr);
- HDfprintf(stdout, "\t\tAmount of free space: %Hu\n", iter->free_space);
+ HDfprintf(stdout, "\t\tHeader: %" PRIuHSIZE "\n", iter->free_hdr);
+ HDfprintf(stdout, "\t\tAmount of free space: %" PRIuHSIZE "\n", iter->free_space);
return 0;
} /* print_file_metadata() */
-
/*-------------------------------------------------------------------------
* Function: print_group_info
*
@@ -1361,32 +1201,32 @@ print_file_metadata(const iter_t *iter)
static herr_t
print_group_info(const iter_t *iter)
{
- unsigned long power; /* Temporary "power" for bins */
- unsigned long total; /* Total count for various statistics */
- unsigned u; /* Local index variable */
+ unsigned long power; /* Temporary "power" for bins */
+ unsigned long total; /* Total count for various statistics */
+ unsigned u; /* Local index variable */
- HDprintf("Small groups (with 0 to %u links):\n", sgroups_threshold-1);
+ HDprintf("Small groups (with 0 to %u links):\n", sgroups_threshold - 1);
total = 0;
- for(u = 0; u < (unsigned)sgroups_threshold; u++) {
- if(iter->num_small_groups[u] > 0) {
+ for (u = 0; u < (unsigned)sgroups_threshold; u++) {
+ if (iter->num_small_groups[u] > 0) {
HDprintf("\t# of groups with %u link(s): %lu\n", u, iter->num_small_groups[u]);
total += iter->num_small_groups[u];
} /* end if */
- } /* end for */
+ } /* end for */
HDprintf("\tTotal # of small groups: %lu\n", total);
HDprintf("Group bins:\n");
total = 0;
- if((iter->group_nbins > 0) && (iter->group_bins[0] > 0)) {
- HDprintf("\t# of groups with 0 link: %lu\n", iter->group_bins[0]);
- total = iter->group_bins[0];
+ if ((iter->group_nbins > 0) && (iter->group_bins[0] > 0)) {
+ HDprintf("\t# of groups with 0 link: %lu\n", iter->group_bins[0]);
+ total = iter->group_bins[0];
} /* end if */
power = 1;
- for(u = 1; u < iter->group_nbins; u++) {
- if(iter->group_bins[u] > 0) {
- HDprintf("\t# of groups with %lu - %lu links: %lu\n", power, (power * 10) - 1,
- iter->group_bins[u]);
- total += iter->group_bins[u];
+ for (u = 1; u < iter->group_nbins; u++) {
+ if (iter->group_bins[u] > 0) {
+ HDprintf("\t# of groups with %lu - %lu links: %lu\n", power, (power * 10) - 1,
+ iter->group_bins[u]);
+ total += iter->group_bins[u];
} /* end if */
power *= 10;
} /* end for */
@@ -1395,7 +1235,6 @@ print_group_info(const iter_t *iter)
return 0;
} /* print_group_info() */
-
/*-------------------------------------------------------------------------
* Function: print_group_metadata
*
@@ -1413,16 +1252,15 @@ print_group_metadata(const iter_t *iter)
{
HDprintf("File space information for groups' metadata (in bytes):\n");
- HDfprintf(stdout, "\tObject headers (total/unused): %Hu/%Hu\n",
- iter->group_ohdr_info.total_size, iter->group_ohdr_info.free_size);
+ HDfprintf(stdout, "\tObject headers (total/unused): %" PRIuHSIZE "/%" PRIuHSIZE "\n",
+ iter->group_ohdr_info.total_size, iter->group_ohdr_info.free_size);
- HDfprintf(stdout, "\tB-tree/List: %Hu\n", iter->groups_btree_storage_size);
- HDfprintf(stdout, "\tHeap: %Hu\n", iter->groups_heap_storage_size);
+ HDfprintf(stdout, "\tB-tree/List: %" PRIuHSIZE "\n", iter->groups_btree_storage_size);
+ HDfprintf(stdout, "\tHeap: %" PRIuHSIZE "\n", iter->groups_heap_storage_size);
return 0;
} /* print_group_metadata() */
-
/*-------------------------------------------------------------------------
* Function: print_dataset_info
*
@@ -1439,44 +1277,43 @@ print_group_metadata(const iter_t *iter)
static herr_t
print_dataset_info(const iter_t *iter)
{
- unsigned long power; /* Temporary "power" for bins */
- unsigned long total; /* Total count for various statistics */
- unsigned u; /* Local index variable */
+ unsigned long power; /* Temporary "power" for bins */
+ unsigned long total; /* Total count for various statistics */
+ unsigned u; /* Local index variable */
- if(iter->uniq_dsets > 0) {
+ if (iter->uniq_dsets > 0) {
HDprintf("Dataset dimension information:\n");
HDprintf("\tMax. rank of datasets: %u\n", iter->max_dset_rank);
HDprintf("\tDataset ranks:\n");
- for(u = 0; u < H5S_MAX_RANK; u++)
- if(iter->dset_rank_count[u] > 0)
+ for (u = 0; u < H5S_MAX_RANK; u++)
+ if (iter->dset_rank_count[u] > 0)
HDprintf("\t\t# of dataset with rank %u: %lu\n", u, iter->dset_rank_count[u]);
HDprintf("1-D Dataset information:\n");
- HDfprintf(stdout, "\tMax. dimension size of 1-D datasets: %Hu\n", iter->max_dset_dims);
+ HDfprintf(stdout, "\tMax. dimension size of 1-D datasets: %" PRIuHSIZE "\n", iter->max_dset_dims);
HDprintf("\tSmall 1-D datasets (with dimension sizes 0 to %u):\n", sdsets_threshold - 1);
total = 0;
- for(u = 0; u < (unsigned)sdsets_threshold; u++) {
- if(iter->small_dset_dims[u] > 0) {
- HDprintf("\t\t# of datasets with dimension sizes %u: %lu\n", u,
- iter->small_dset_dims[u]);
+ for (u = 0; u < (unsigned)sdsets_threshold; u++) {
+ if (iter->small_dset_dims[u] > 0) {
+ HDprintf("\t\t# of datasets with dimension sizes %u: %lu\n", u, iter->small_dset_dims[u]);
total += iter->small_dset_dims[u];
} /* end if */
- } /* end for */
+ } /* end for */
HDprintf("\t\tTotal # of small datasets: %lu\n", total);
/* Protect against no datasets in file */
- if(iter->dset_dim_nbins > 0) {
+ if (iter->dset_dim_nbins > 0) {
HDprintf("\t1-D Dataset dimension bins:\n");
total = 0;
- if(iter->dset_dim_bins[0] > 0) {
+ if (iter->dset_dim_bins[0] > 0) {
HDprintf("\t\t# of datasets with dimension size 0: %lu\n", iter->dset_dim_bins[0]);
total = iter->dset_dim_bins[0];
} /* end if */
power = 1;
- for(u = 1; u < iter->dset_dim_nbins; u++) {
- if(iter->dset_dim_bins[u] > 0) {
- HDprintf("\t\t# of datasets with dimension size %lu - %lu: %lu\n", power, (power * 10) - 1,
- iter->dset_dim_bins[u]);
+ for (u = 1; u < iter->dset_dim_nbins; u++) {
+ if (iter->dset_dim_bins[u] > 0) {
+ HDprintf("\t\t# of datasets with dimension size %lu - %lu: %lu\n", power,
+ (power * 10) - 1, iter->dset_dim_bins[u]);
total += iter->dset_dim_bins[u];
} /* end if */
power *= 10;
@@ -1485,31 +1322,34 @@ print_dataset_info(const iter_t *iter)
} /* end if */
HDprintf("Dataset storage information:\n");
- HDfprintf(stdout, "\tTotal raw data size: %Hu\n", iter->dset_storage_size);
- HDfprintf(stdout, "\tTotal external raw data size: %Hu\n", iter->dset_external_storage_size);
+ HDfprintf(stdout, "\tTotal raw data size: %" PRIuHSIZE "\n", iter->dset_storage_size);
+ HDfprintf(stdout, "\tTotal external raw data size: %" PRIuHSIZE "\n",
+ iter->dset_external_storage_size);
HDprintf("Dataset layout information:\n");
- for(u = 0; u < H5D_NLAYOUTS; u++)
- HDprintf("\tDataset layout counts[%s]: %lu\n", (u == H5D_COMPACT ? "COMPACT" :
- (u == H5D_CONTIGUOUS ? "CONTIG" : (u == H5D_CHUNKED ? "CHUNKED" : "VIRTUAL"))), iter->dset_layouts[u]);
+ for (u = 0; u < H5D_NLAYOUTS; u++)
+ HDprintf("\tDataset layout counts[%s]: %lu\n",
+ (u == H5D_COMPACT
+ ? "COMPACT"
+ : (u == H5D_CONTIGUOUS ? "CONTIG" : (u == H5D_CHUNKED ? "CHUNKED" : "VIRTUAL"))),
+ iter->dset_layouts[u]);
HDprintf("\tNumber of external files : %lu\n", iter->nexternal);
HDprintf("Dataset filters information:\n");
HDprintf("\tNumber of datasets with:\n");
- HDprintf("\t\tNO filter: %lu\n", iter->dset_comptype[H5Z_FILTER_ERROR+1]);
+ HDprintf("\t\tNO filter: %lu\n", iter->dset_comptype[H5Z_FILTER_ERROR + 1]);
HDprintf("\t\tGZIP filter: %lu\n", iter->dset_comptype[H5Z_FILTER_DEFLATE]);
HDprintf("\t\tSHUFFLE filter: %lu\n", iter->dset_comptype[H5Z_FILTER_SHUFFLE]);
HDprintf("\t\tFLETCHER32 filter: %lu\n", iter->dset_comptype[H5Z_FILTER_FLETCHER32]);
HDprintf("\t\tSZIP filter: %lu\n", iter->dset_comptype[H5Z_FILTER_SZIP]);
HDprintf("\t\tNBIT filter: %lu\n", iter->dset_comptype[H5Z_FILTER_NBIT]);
HDprintf("\t\tSCALEOFFSET filter: %lu\n", iter->dset_comptype[H5Z_FILTER_SCALEOFFSET]);
- HDprintf("\t\tUSER-DEFINED filter: %lu\n", iter->dset_comptype[H5_NFILTERS_IMPL-1]);
+ HDprintf("\t\tUSER-DEFINED filter: %lu\n", iter->dset_comptype[H5_NFILTERS_IMPL - 1]);
} /* end if */
return 0;
} /* print_dataset_info() */
-
/*-------------------------------------------------------------------------
* Function: print_dataset_metadata
*
@@ -1528,17 +1368,15 @@ print_dset_metadata(const iter_t *iter)
{
HDprintf("File space information for datasets' metadata (in bytes):\n");
- HDfprintf(stdout, "\tObject headers (total/unused): %Hu/%Hu\n",
- iter->dset_ohdr_info.total_size, iter->dset_ohdr_info.free_size);
+ HDfprintf(stdout, "\tObject headers (total/unused): %" PRIuHSIZE "/%" PRIuHSIZE "\n",
+ iter->dset_ohdr_info.total_size, iter->dset_ohdr_info.free_size);
- HDfprintf(stdout, "\tIndex for Chunked datasets: %Hu\n",
- iter->datasets_index_storage_size);
- HDfprintf(stdout, "\tHeap: %Hu\n", iter->datasets_heap_storage_size);
+ HDfprintf(stdout, "\tIndex for Chunked datasets: %" PRIuHSIZE "\n", iter->datasets_index_storage_size);
+ HDfprintf(stdout, "\tHeap: %" PRIuHSIZE "\n", iter->datasets_heap_storage_size);
return 0;
} /* print_dset_metadata() */
-
/*-------------------------------------------------------------------------
* Function: print_dset_dtype_meta
*
@@ -1555,21 +1393,21 @@ print_dset_metadata(const iter_t *iter)
static herr_t
print_dset_dtype_meta(const iter_t *iter)
{
- unsigned long total; /* Total count for various statistics */
- size_t dtype_size; /* Size of encoded datatype */
- unsigned u; /* Local index variable */
+ unsigned long total; /* Total count for various statistics */
+ size_t dtype_size; /* Size of encoded datatype */
+ unsigned u; /* Local index variable */
- if(iter->dset_ntypes) {
+ if (iter->dset_ntypes) {
HDprintf("Dataset datatype information:\n");
HDprintf("\t# of unique datatypes used by datasets: %lu\n", iter->dset_ntypes);
total = 0;
- for(u = 0; u < iter->dset_ntypes; u++) {
+ for (u = 0; u < iter->dset_ntypes; u++) {
H5Tencode(iter->dset_type_info[u].tid, NULL, &dtype_size);
HDprintf("\tDataset datatype #%u:\n", u);
- HDprintf("\t\tCount (total/named) = (%lu/%lu)\n",
- iter->dset_type_info[u].count, iter->dset_type_info[u].named);
+ HDprintf("\t\tCount (total/named) = (%lu/%lu)\n", iter->dset_type_info[u].count,
+ iter->dset_type_info[u].named);
HDprintf("\t\tSize (desc./elmt) = (%lu/%lu)\n", (unsigned long)dtype_size,
- (unsigned long)H5Tget_size(iter->dset_type_info[u].tid));
+ (unsigned long)H5Tget_size(iter->dset_type_info[u].tid));
H5Tclose(iter->dset_type_info[u].tid);
total += iter->dset_type_info[u].count;
} /* end for */
@@ -1579,7 +1417,6 @@ print_dset_dtype_meta(const iter_t *iter)
return 0;
} /* print_dset_dtype_meta() */
-
/*-------------------------------------------------------------------------
* Function: print_attr_info
*
@@ -1597,28 +1434,28 @@ print_dset_dtype_meta(const iter_t *iter)
static herr_t
print_attr_info(const iter_t *iter)
{
- unsigned long power; /* Temporary "power" for bins */
- unsigned long total; /* Total count for various statistics */
- unsigned u; /* Local index variable */
+ unsigned long power; /* Temporary "power" for bins */
+ unsigned long total; /* Total count for various statistics */
+ unsigned u; /* Local index variable */
HDprintf("Small # of attributes (objects with 1 to %u attributes):\n", sattrs_threshold);
total = 0;
- for(u = 1; u <= (unsigned)sattrs_threshold; u++) {
- if(iter->num_small_attrs[u] > 0) {
+ for (u = 1; u <= (unsigned)sattrs_threshold; u++) {
+ if (iter->num_small_attrs[u] > 0) {
HDprintf("\t# of objects with %u attributes: %lu\n", u, iter->num_small_attrs[u]);
total += iter->num_small_attrs[u];
} /* end if */
- } /* end for */
+ } /* end for */
HDprintf("\tTotal # of objects with small # of attributes: %lu\n", total);
HDprintf("Attribute bins:\n");
total = 0;
power = 1;
- for(u = 1; u < iter->attr_nbins; u++) {
- if(iter->attr_bins[u] > 0) {
- HDprintf("\t# of objects with %lu - %lu attributes: %lu\n", power, (power * 10) - 1,
- iter->attr_bins[u]);
- total += iter->attr_bins[u];
+ for (u = 1; u < iter->attr_nbins; u++) {
+ if (iter->attr_bins[u] > 0) {
+ HDprintf("\t# of objects with %lu - %lu attributes: %lu\n", power, (power * 10) - 1,
+ iter->attr_bins[u]);
+ total += iter->attr_bins[u];
} /* end if */
power *= 10;
} /* end for */
@@ -1628,7 +1465,6 @@ print_attr_info(const iter_t *iter)
return 0;
} /* print_attr_info() */
-
/*-------------------------------------------------------------------------
* Function: print_freespace_info
*
@@ -1645,31 +1481,30 @@ print_attr_info(const iter_t *iter)
static herr_t
print_freespace_info(const iter_t *iter)
{
- unsigned long power; /* Temporary "power" for bins */
- unsigned long total; /* Total count for various statistics */
- unsigned u; /* Local index variable */
+ unsigned long power; /* Temporary "power" for bins */
+ unsigned long total; /* Total count for various statistics */
+ unsigned u; /* Local index variable */
HDfprintf(stdout, "Free-space persist: %s\n", iter->fs_persist ? "TRUE" : "FALSE");
- HDfprintf(stdout, "Free-space section threshold: %Hu bytes\n", iter->fs_threshold);
+ HDfprintf(stdout, "Free-space section threshold: %" PRIuHSIZE " bytes\n", iter->fs_threshold);
HDprintf("Small size free-space sections (< %u bytes):\n", (unsigned)SIZE_SMALL_SECTS);
total = 0;
- for(u = 0; u < SIZE_SMALL_SECTS; u++) {
- if(iter->num_small_sects[u] > 0) {
+ for (u = 0; u < SIZE_SMALL_SECTS; u++) {
+ if (iter->num_small_sects[u] > 0) {
HDprintf("\t# of sections of size %u: %lu\n", u, iter->num_small_sects[u]);
total += iter->num_small_sects[u];
} /* end if */
- } /* end for */
+ } /* end for */
HDprintf("\tTotal # of small size sections: %lu\n", total);
HDprintf("Free-space section bins:\n");
total = 0;
power = 1;
- for(u = 1; u < iter->sect_nbins; u++) {
- if(iter->sect_bins[u] > 0) {
- HDprintf("\t# of sections of size %lu - %lu: %lu\n", power, (power * 10) - 1,
- iter->sect_bins[u]);
- total += iter->sect_bins[u];
+ for (u = 1; u < iter->sect_nbins; u++) {
+ if (iter->sect_bins[u] > 0) {
+ HDprintf("\t# of sections of size %lu - %lu: %lu\n", power, (power * 10) - 1, iter->sect_bins[u]);
+ total += iter->sect_bins[u];
} /* end if */
power *= 10;
} /* end for */
@@ -1678,7 +1513,6 @@ print_freespace_info(const iter_t *iter)
return 0;
} /* print_freespace_info() */
-
/*-------------------------------------------------------------------------
* Function: print_storage_summary
*
@@ -1696,53 +1530,45 @@ static herr_t
print_storage_summary(const iter_t *iter)
{
hsize_t total_meta = 0;
- hsize_t unaccount = 0;
- double percent = 0.0f;
+ hsize_t unaccount = 0;
+ double percent = 0.0;
HDfprintf(stdout, "File space management strategy: %s\n", FS_STRATEGY_NAME[iter->fs_strategy]);
- HDfprintf(stdout, "File space page size: %Hu bytes\n", iter->fsp_size);
+ HDfprintf(stdout, "File space page size: %" PRIuHSIZE " bytes\n", iter->fsp_size);
HDprintf("Summary of file space information:\n");
total_meta =
- iter->super_size + iter->super_ext_size + iter->ublk_size +
- iter->group_ohdr_info.total_size +
- iter->dset_ohdr_info.total_size +
- iter->dtype_ohdr_info.total_size +
- iter->groups_btree_storage_size +
- iter->groups_heap_storage_size +
- iter->attrs_btree_storage_size +
- iter->attrs_heap_storage_size +
- iter->datasets_index_storage_size +
- iter->datasets_heap_storage_size +
- iter->SM_hdr_storage_size +
- iter->SM_index_storage_size +
- iter->SM_heap_storage_size +
- iter->free_hdr;
-
- HDfprintf(stdout, " File metadata: %Hu bytes\n", total_meta);
- HDfprintf(stdout, " Raw data: %Hu bytes\n", iter->dset_storage_size);
-
- percent = ((double)iter->free_space / (double)iter->filesize) * (double)100.0f;
- HDfprintf(stdout, " Amount/Percent of tracked free space: %Hu bytes/%3.1f%\n",
- iter->free_space, percent);
-
- if(iter->filesize < (total_meta + iter->dset_storage_size + iter->free_space)) {
+ iter->super_size + iter->super_ext_size + iter->ublk_size + iter->group_ohdr_info.total_size +
+ iter->dset_ohdr_info.total_size + iter->dtype_ohdr_info.total_size + iter->groups_btree_storage_size +
+ iter->groups_heap_storage_size + iter->attrs_btree_storage_size + iter->attrs_heap_storage_size +
+ iter->datasets_index_storage_size + iter->datasets_heap_storage_size + iter->SM_hdr_storage_size +
+ iter->SM_index_storage_size + iter->SM_heap_storage_size + iter->free_hdr;
+
+ HDfprintf(stdout, " File metadata: %" PRIuHSIZE " bytes\n", total_meta);
+ HDfprintf(stdout, " Raw data: %" PRIuHSIZE " bytes\n", iter->dset_storage_size);
+
+ percent = ((double)iter->free_space / (double)iter->filesize) * 100.0;
+ HDfprintf(stdout, " Amount/Percent of tracked free space: %" PRIuHSIZE " bytes/%3.1f%%\n",
+ iter->free_space, percent);
+
+ if (iter->filesize < (total_meta + iter->dset_storage_size + iter->free_space)) {
unaccount = (total_meta + iter->dset_storage_size + iter->free_space) - iter->filesize;
- HDfprintf(stdout, " ??? File has %Hu more bytes accounted for than its size! ???\n", unaccount);
+ HDfprintf(stdout, " ??? File has %" PRIuHSIZE " more bytes accounted for than its size! ???\n",
+ unaccount);
}
else {
unaccount = iter->filesize - (total_meta + iter->dset_storage_size + iter->free_space);
- HDfprintf(stdout, " Unaccounted space: %Hu bytes\n", unaccount);
+ HDfprintf(stdout, " Unaccounted space: %" PRIuHSIZE " bytes\n", unaccount);
}
- HDfprintf(stdout, "Total space: %Hu bytes\n", total_meta + iter->dset_storage_size + iter->free_space + unaccount);
+ HDfprintf(stdout, "Total space: %" PRIuHSIZE " bytes\n",
+ total_meta + iter->dset_storage_size + iter->free_space + unaccount);
- if(iter->nexternal)
- HDfprintf(stdout, "External raw data: %Hu bytes\n", iter->dset_external_storage_size);
+ if (iter->nexternal)
+ HDfprintf(stdout, "External raw data: %" PRIuHSIZE " bytes\n", iter->dset_external_storage_size);
return 0;
} /* print_storage_summary() */
-
/*-------------------------------------------------------------------------
* Function: print_file_statistics
*
@@ -1760,36 +1586,45 @@ print_storage_summary(const iter_t *iter)
static void
print_file_statistics(const iter_t *iter)
{
- if(display_all) {
- display_file = TRUE;
- display_group = TRUE;
- display_dset = TRUE;
+ if (display_all) {
+ display_file = TRUE;
+ display_group = TRUE;
+ display_dset = TRUE;
display_dset_dtype_meta = TRUE;
- display_attr = TRUE;
- display_free_sections = TRUE;
- display_summary = TRUE;
+ display_attr = TRUE;
+ display_free_sections = TRUE;
+ display_summary = TRUE;
- display_file_metadata = TRUE;
+ display_file_metadata = TRUE;
display_group_metadata = TRUE;
- display_dset_metadata = TRUE;
+ display_dset_metadata = TRUE;
}
- if(display_file) print_file_info(iter);
- if(display_file_metadata) print_file_metadata(iter);
-
- if(display_group) print_group_info(iter);
- if(!display_all && display_group_metadata) print_group_metadata(iter);
-
- if(display_dset) print_dataset_info(iter);
- if(display_dset_dtype_meta) print_dset_dtype_meta(iter);
- if(!display_all && display_dset_metadata) print_dset_metadata(iter);
-
- if(display_attr) print_attr_info(iter);
- if(display_free_sections) print_freespace_info(iter);
- if(display_summary) print_storage_summary(iter);
+ if (display_file)
+ print_file_info(iter);
+ if (display_file_metadata)
+ print_file_metadata(iter);
+
+ if (display_group)
+ print_group_info(iter);
+ if (!display_all && display_group_metadata)
+ print_group_metadata(iter);
+
+ if (display_dset)
+ print_dataset_info(iter);
+ if (display_dset_dtype_meta)
+ print_dset_dtype_meta(iter);
+ if (!display_all && display_dset_metadata)
+ print_dset_metadata(iter);
+
+ if (display_attr)
+ print_attr_info(iter);
+ if (display_free_sections)
+ print_freespace_info(iter);
+ if (display_summary)
+ print_storage_summary(iter);
} /* print_file_statistics() */
-
/*-------------------------------------------------------------------------
* Function: print_object_statistics
*
@@ -1812,7 +1647,6 @@ print_object_statistics(const char *name)
HDprintf("Object name %s\n", name);
} /* print_object_statistics() */
-
/*-------------------------------------------------------------------------
* Function: print_statistics
*
@@ -1832,13 +1666,12 @@ print_object_statistics(const char *name)
static void
print_statistics(const char *name, const iter_t *iter)
{
- if(display_object)
+ if (display_object)
print_object_statistics(name);
else
print_file_statistics(iter);
} /* print_statistics() */
-
/*-------------------------------------------------------------------------
* Function: main
*
@@ -1849,89 +1682,53 @@ print_statistics(const char *name, const iter_t *iter)
*-------------------------------------------------------------------------
*/
int
-main(int argc, const char *argv[])
+main(int argc, char *argv[])
{
- iter_t iter;
- const char *fname = NULL;
- hid_t fid = -1;
- H5E_auto2_t func;
- H5E_auto2_t tools_func;
- void *edata;
- void *tools_edata;
- struct handler_t *hand = NULL;
- hid_t fapl_id = H5P_DEFAULT;
+ iter_t iter;
+ const char * fname = NULL;
+ hid_t fid = H5I_INVALID_HID;
+ struct handler_t *hand = NULL;
+ hid_t fapl_id = H5P_DEFAULT;
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);
-
HDmemset(&iter, 0, sizeof(iter));
- if(parse_command_line(argc, argv, &hand) < 0)
+ if (parse_command_line(argc, (const char *const *)argv, &hand) < 0)
goto done;
- /* if drivername is not null, probably need to set the fapl */
- if (HDstrcmp(drivername, "")) {
- void *conf_fa = NULL;
+ /* enable error reporting if command line option */
+ h5tools_error_report();
- if (!HDstrcmp(drivername, "ros3")) {
-#ifndef H5_HAVE_ROS3_VFD
- error_msg("Read-Only S3 VFD not enabled.\n\n");
- goto done;
-#else
- conf_fa = (void *)&ros3_fa;
-#endif /* H5_HAVE_ROS3_VFD */
+ if (drivername) {
+ h5tools_vfd_info_t vfd_info;
- }
- else if (!HDstrcmp(drivername, "hdfs")) {
-#ifndef H5_HAVE_LIBHDFS
- error_msg("HDFS VFD not enabled.\n\n");
- goto done;
-#else
- conf_fa = (void *)&hdfs_fa;
-#endif /* H5_HAVE_LIBHDFS */
- }
+ vfd_info.type = VFD_BY_NAME;
+ vfd_info.info = NULL;
+ vfd_info.u.name = drivername;
- if (conf_fa != NULL) {
- HDassert(fapl_id == H5P_DEFAULT);
- fapl_id = H5Pcreate(H5P_FILE_ACCESS);
- if (fapl_id < 0) {
- error_msg("Unable to create fapl entry\n");
- goto done;
- }
- if (1 > h5tools_set_configured_fapl(fapl_id, drivername, conf_fa)) {
- error_msg("Unable to set fapl\n");
- goto done;
- }
+ if ((fapl_id = h5tools_get_fapl(H5P_DEFAULT, NULL, &vfd_info)) < 0) {
+ error_msg("Unable to create FAPL for file access\n");
+ goto done;
}
- } /* drivername set */
-
- fname = argv[opt_ind];
-
- if(enable_error_stack > 0) {
- H5Eset_auto2(H5E_DEFAULT, func, edata);
- H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata);
}
+ fname = argv[H5_optind];
+
/* Check for filename given */
- if(fname) {
- hid_t fcpl;
- H5F_info2_t finfo;
+ if (fname) {
+ hid_t fcpl;
+ H5F_info2_t finfo;
HDprintf("Filename: %s\n", fname);
- fid = H5Fopen(fname, H5F_ACC_RDONLY, fapl_id);
- if(fid < 0) {
+ fid = h5tools_fopen(fname, H5F_ACC_RDONLY, fapl_id, (fapl_id != H5P_DEFAULT), NULL, 0);
+
+ if (fid < 0) {
error_msg("unable to open file \"%s\"\n", fname);
h5tools_setstatus(EXIT_FAILURE);
goto done;
@@ -1940,72 +1737,74 @@ main(int argc, const char *argv[])
/* Initialize iter structure */
iter.fid = fid;
- if(H5Fget_filesize(fid, &iter.filesize) < 0)
+ if (H5Fget_filesize(fid, &iter.filesize) < 0)
warn_msg("Unable to retrieve file size\n");
HDassert(iter.filesize != 0);
- /* Get storge info for file-level structures */
- if(H5Fget_info2(fid, &finfo) < 0)
+ /* Get storage info for file-level structures */
+ if (H5Fget_info2(fid, &finfo) < 0)
warn_msg("Unable to retrieve file info\n");
else {
- iter.super_size = finfo.super.super_size;
- iter.super_ext_size = finfo.super.super_ext_size;
- iter.SM_hdr_storage_size = finfo.sohm.hdr_size;
+ iter.super_size = finfo.super.super_size;
+ iter.super_ext_size = finfo.super.super_ext_size;
+ iter.SM_hdr_storage_size = finfo.sohm.hdr_size;
iter.SM_index_storage_size = finfo.sohm.msgs_info.index_size;
- iter.SM_heap_storage_size = finfo.sohm.msgs_info.heap_size;
- iter.free_space = finfo.free.tot_space;
- iter.free_hdr = finfo.free.meta_size;
+ iter.SM_heap_storage_size = finfo.sohm.msgs_info.heap_size;
+ iter.free_space = finfo.free.tot_space;
+ iter.free_hdr = finfo.free.meta_size;
} /* end else */
iter.num_small_groups = (unsigned long *)HDcalloc((size_t)sgroups_threshold, sizeof(unsigned long));
- iter.num_small_attrs = (unsigned long *)HDcalloc((size_t)(sattrs_threshold+1), sizeof(unsigned long));
+ iter.num_small_attrs =
+ (unsigned long *)HDcalloc((size_t)(sattrs_threshold + 1), sizeof(unsigned long));
iter.small_dset_dims = (unsigned long *)HDcalloc((size_t)sdsets_threshold, sizeof(unsigned long));
- if(iter.num_small_groups == NULL || iter.num_small_attrs == NULL || iter.small_dset_dims == NULL) {
+ if (iter.num_small_groups == NULL || iter.num_small_attrs == NULL || iter.small_dset_dims == NULL) {
error_msg("Unable to allocate memory for tracking small groups/datasets/attributes\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
- if((fcpl = H5Fget_create_plist(fid)) < 0)
+ if ((fcpl = H5Fget_create_plist(fid)) < 0)
warn_msg("Unable to retrieve file creation property\n");
- if(H5Pget_userblock(fcpl, &iter.ublk_size) < 0)
+ if (H5Pget_userblock(fcpl, &iter.ublk_size) < 0)
warn_msg("Unable to retrieve userblock size\n");
- if(H5Pget_file_space_strategy(fcpl, &iter.fs_strategy, &iter.fs_persist, &iter.fs_threshold) < 0)
+ if (H5Pget_file_space_strategy(fcpl, &iter.fs_strategy, &iter.fs_persist, &iter.fs_threshold) < 0)
warn_msg("Unable to retrieve file space information\n");
HDassert(iter.fs_strategy >= 0 && iter.fs_strategy < H5F_FSPACE_STRATEGY_NTYPES);
- if(H5Pget_file_space_page_size(fcpl, &iter.fsp_size) < 0)
+ if (H5Pget_file_space_page_size(fcpl, &iter.fsp_size) < 0)
warn_msg("Unable to retrieve file space page size\n");
/* get information for free-space sections */
- if(freespace_stats(fid, &iter) < 0)
+ if (freespace_stats(fid, &iter) < 0)
warn_msg("Unable to retrieve freespace info\n");
/* Walk the objects or all file */
- if(display_object) {
+ if (display_object) {
unsigned u;
- for(u = 0; u < hand->obj_count; u++) {
- if(h5trav_visit(fid, hand->obj[u], TRUE, TRUE, obj_stats, lnk_stats, &iter, H5O_INFO_ALL) < 0) {
+ for (u = 0; u < hand->obj_count; u++) {
+ if (h5trav_visit(fid, hand->obj[u], TRUE, TRUE, obj_stats, lnk_stats, &iter, H5O_INFO_ALL) <
+ 0) {
error_msg("unable to traverse object \"%s\"\n", hand->obj[u]);
h5tools_setstatus(EXIT_FAILURE);
}
else
print_statistics(hand->obj[u], &iter);
} /* end for */
- } /* end if */
+ } /* end if */
else {
- if(h5trav_visit(fid, "/", TRUE, TRUE, obj_stats, lnk_stats, &iter, H5O_INFO_ALL) < 0) {
+ if (h5trav_visit(fid, "/", TRUE, TRUE, obj_stats, lnk_stats, &iter, H5O_INFO_ALL) < 0) {
error_msg("unable to traverse objects/links in file \"%s\"\n", fname);
h5tools_setstatus(EXIT_FAILURE);
}
else
print_statistics("/", &iter);
} /* end else */
- } /* end if */
+ } /* end if */
done:
hand_free(hand);
@@ -2014,19 +1813,16 @@ done:
iter_free(&iter);
if (fapl_id != H5P_DEFAULT) {
- if (0 < H5Pclose(fapl_id)) {
+ if (H5Pclose(fapl_id) < 0) {
error_msg("unable to close fapl entry\n");
h5tools_setstatus(EXIT_FAILURE);
}
}
- if(fid >= 0 && H5Fclose(fid) < 0) {
+ if (fid >= 0 && H5Fclose(fid) < 0) {
error_msg("unable to close file \"%s\"\n", fname);
h5tools_setstatus(EXIT_FAILURE);
} /* end if */
- H5Eset_auto2(H5E_DEFAULT, func, edata);
-
leave(h5tools_getstatus());
} /* end main() */
-
diff --git a/tools/src/misc/CMakeLists.txt b/tools/src/misc/CMakeLists.txt
index 6b41d7f..8811f97 100644
--- a/tools/src/misc/CMakeLists.txt
+++ b/tools/src/misc/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.10)
+cmake_minimum_required (VERSION 3.12)
project (HDF5_TOOLS_SRC_MISC C)
# --------------------------------------------------------------------
@@ -7,77 +7,122 @@ project (HDF5_TOOLS_SRC_MISC C)
#-- Misc Executables
if (NOT ONLY_SHARED_LIBS)
add_executable (h5debug ${HDF5_TOOLS_SRC_MISC_SOURCE_DIR}/h5debug.c)
- target_include_directories (h5debug PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_include_directories (h5debug PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5debug PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5debug STATIC)
target_link_libraries (h5debug PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
set_target_properties (h5debug PROPERTIES FOLDER tools)
set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};h5debug")
add_executable (h5repart ${HDF5_TOOLS_SRC_MISC_SOURCE_DIR}/h5repart.c)
- target_include_directories (h5repart PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_include_directories (h5repart PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5repart PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5repart STATIC)
target_link_libraries (h5repart PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
set_target_properties (h5repart PROPERTIES FOLDER tools)
set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};h5repart")
add_executable (h5mkgrp ${HDF5_TOOLS_SRC_MISC_SOURCE_DIR}/h5mkgrp.c)
- target_include_directories (h5mkgrp PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_include_directories (h5mkgrp PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5mkgrp PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5mkgrp STATIC)
target_link_libraries (h5mkgrp PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
set_target_properties (h5mkgrp PROPERTIES FOLDER tools)
set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};h5mkgrp")
add_executable (h5clear ${HDF5_TOOLS_SRC_MISC_SOURCE_DIR}/h5clear.c)
- target_include_directories (h5clear PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_include_directories (h5clear PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5clear PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5clear STATIC)
target_link_libraries (h5clear PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
set_target_properties (h5clear PROPERTIES FOLDER tools)
set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};h5clear")
+ add_executable (h5delete ${HDF5_TOOLS_SRC_MISC_SOURCE_DIR}/h5delete.c)
+ target_include_directories (h5delete PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5delete PRIVATE "${HDF5_CMAKE_C_FLAGS}")
+ TARGET_C_PROPERTIES (h5delete STATIC)
+ target_link_libraries (h5delete PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
+ set_target_properties (h5delete PROPERTIES FOLDER tools)
+ set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};h5delete")
+
set (H5_DEP_EXECUTABLES
h5debug
h5repart
h5mkgrp
- h5clear
+ h5clear
+ h5delete
)
endif ()
if (BUILD_SHARED_LIBS)
add_executable (h5debug-shared ${HDF5_TOOLS_SRC_MISC_SOURCE_DIR}/h5debug.c)
- target_include_directories (h5debug-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_include_directories (h5debug-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
TARGET_C_PROPERTIES (h5debug-shared SHARED)
+ target_compile_options(h5debug-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}")
target_link_libraries (h5debug-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
set_target_properties (h5debug-shared PROPERTIES FOLDER tools)
set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};h5debug-shared")
add_executable (h5repart-shared ${HDF5_TOOLS_SRC_MISC_SOURCE_DIR}/h5repart.c)
- target_include_directories (h5repart-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_include_directories (h5repart-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5repart-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5repart-shared SHARED)
target_link_libraries (h5repart-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
set_target_properties (h5repart-shared PROPERTIES FOLDER tools)
set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};h5repart-shared")
add_executable (h5mkgrp-shared ${HDF5_TOOLS_SRC_MISC_SOURCE_DIR}/h5mkgrp.c)
- target_include_directories (h5mkgrp-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_include_directories (h5mkgrp-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5mkgrp-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5mkgrp-shared SHARED)
target_link_libraries (h5mkgrp-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
set_target_properties (h5mkgrp-shared PROPERTIES FOLDER tools)
set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};h5mkgrp-shared")
add_executable (h5clear-shared ${HDF5_TOOLS_SRC_MISC_SOURCE_DIR}/h5clear.c)
- target_include_directories (h5clear-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_include_directories (h5clear-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5clear-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5clear-shared SHARED)
target_link_libraries (h5clear-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
set_target_properties (h5clear-shared PROPERTIES FOLDER tools)
set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};h5clear-shared")
+ add_executable (h5delete-shared ${HDF5_TOOLS_SRC_MISC_SOURCE_DIR}/h5delete.c)
+ target_include_directories (h5delete-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5delete-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}")
+ TARGET_C_PROPERTIES (h5delete-shared SHARED)
+ target_link_libraries (h5delete-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
+ set_target_properties (h5delete-shared PROPERTIES FOLDER tools)
+ set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};h5delete-shared")
+
set (H5_DEP_EXECUTABLES ${H5_DEP_EXECUTABLES}
h5debug-shared
h5repart-shared
h5mkgrp-shared
h5clear-shared
+ h5delete-shared
)
endif ()
+#-----------------------------------------------------------------------------
+# Add Target to clang-format
+#-----------------------------------------------------------------------------
+if (HDF5_ENABLE_FORMATTERS)
+ if (NOT ONLY_SHARED_LIBS)
+ clang_format (HDF5_H5DEBUG_SRC_FORMAT h5debug)
+ clang_format (HDF5_H5REPART_SRC_FORMAT h5repart)
+ clang_format (HDF5_H5MKGRP_SRC_FORMAT h5mkgrp)
+ clang_format (HDF5_H5CLEAR_SRC_FORMAT h5clear)
+ clang_format (HDF5_H5DELETE_SRC_FORMAT h5delete)
+ else ()
+ clang_format (HDF5_H5DEBUG_SRC_FORMAT h5debug-shared)
+ clang_format (HDF5_H5REPART_SRC_FORMAT h5repart-shared)
+ clang_format (HDF5_H5MKGRP_SRC_FORMAT h5mkgrp-shared)
+ clang_format (HDF5_H5CLEAR_SRC_FORMAT h5clear-shared)
+ clang_format (HDF5_H5DELETE_SRC_FORMAT h5delete-shared)
+ endif ()
+endif ()
+
##############################################################################
##############################################################################
### I N S T A L L A T I O N ###
diff --git a/tools/src/misc/Makefile.am b/tools/src/misc/Makefile.am
index f1d2aaf..cad13c1 100644
--- a/tools/src/misc/Makefile.am
+++ b/tools/src/misc/Makefile.am
@@ -6,7 +6,7 @@
# This file is part of HDF5. The full HDF5 copyright notice, including
# terms governing use, modification, and redistribution, is contained in
# the COPYING file, which can be found at the root of the source code
-# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.
+# distribution tree, or in https://www.hdfgroup.org/licenses.
# If you do not have access to either file, you may request a copy from
# help@hdfgroup.org.
##
@@ -22,13 +22,14 @@ include $(top_srcdir)/config/commence.am
AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/tools/lib
# These are our main targets, the tools
-bin_PROGRAMS=h5debug h5repart h5mkgrp h5clear
+bin_PROGRAMS=h5debug h5repart h5mkgrp h5clear h5delete
# Add h5debug, h5repart, and h5mkgrp specific linker flags here
h5debug_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS)
h5repart_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS)
h5mkgrp_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS)
h5clear_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS)
+h5delete_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS)
# All programs rely on hdf5 library and h5tools library
LDADD=$(LIBH5TOOLS) $(LIBHDF5)
diff --git a/tools/src/misc/h5clear.c b/tools/src/misc/h5clear.c
index ae57031..15c170d 100644
--- a/tools/src/misc/h5clear.c
+++ b/tools/src/misc/h5clear.c
@@ -6,7 +6,7 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -24,64 +24,31 @@
#include "h5tools_utils.h"
/* Name of tool */
-#define PROGRAMNAME "h5clear"
+#define PROGRAMNAME "h5clear"
/* Make these private properties (defined in H5Fprivate.h) available to h5clear. */
-#define H5F_ACS_CLEAR_STATUS_FLAGS_NAME "clear_status_flags"
-#define H5F_ACS_NULL_FSM_ADDR_NAME "null_fsm_addr"
-#define H5F_ACS_SKIP_EOF_CHECK_NAME "skip_eof_check"
+#define H5F_ACS_CLEAR_STATUS_FLAGS_NAME "clear_status_flags"
+#define H5F_ACS_NULL_FSM_ADDR_NAME "null_fsm_addr"
+#define H5F_ACS_SKIP_EOF_CHECK_NAME "skip_eof_check"
/* Default increment is 1 megabytes for the --increment option */
-#define DEFAULT_INCREMENT 1024*1024
+#define DEFAULT_INCREMENT (1024 * 1024)
-static char *fname_g = NULL;
+static char * fname_g = NULL;
static hbool_t clear_status_flags = FALSE;
static hbool_t remove_cache_image = FALSE;
-static hbool_t print_filesize = FALSE;
-static hbool_t increment_eoa_eof = FALSE;
-static hsize_t increment = DEFAULT_INCREMENT;
+static hbool_t print_filesize = FALSE;
+static hbool_t increment_eoa_eof = FALSE;
+static hsize_t increment = DEFAULT_INCREMENT;
/*
* Command-line options: only publicize long options
*/
-static const char *s_opts = "hVsmzi*";
-static struct long_options l_opts[] = {
- { "help", no_arg, 'h' },
- { "hel", no_arg, 'h'},
- { "he", no_arg, 'h'},
- { "version", no_arg, 'V' },
- { "version", no_arg, 'V' },
- { "versio", no_arg, 'V' },
- { "versi", no_arg, 'V' },
- { "vers", no_arg, 'V' },
- { "status", no_arg, 's' },
- { "statu", no_arg, 's' },
- { "stat", no_arg, 's' },
- { "sta", no_arg, 's' },
- { "st", no_arg, 's' },
- { "image", no_arg, 'm' },
- { "imag", no_arg, 'm' },
- { "ima", no_arg, 'm' },
- { "im", no_arg, 'm' },
- { "filesize", no_arg, 'z' },
- { "filesiz", no_arg, 'z' },
- { "filesi", no_arg, 'z' },
- { "files", no_arg, 'z' },
- { "file", no_arg, 'z' },
- { "fil", no_arg, 'z' },
- { "fi", no_arg, 'z' },
- { "increment", optional_arg, 'i' },
- { "incremen", optional_arg, 'i' },
- { "increme", optional_arg, 'i' },
- { "increm", optional_arg, 'i' },
- { "incre", optional_arg, 'i' },
- { "incr", optional_arg, 'i' },
- { "inc", optional_arg, 'i' },
- { "in", optional_arg, 'i' },
- { NULL, 0, '\0' }
-};
-
-
+static const char * s_opts = "hVsmzi*";
+static struct h5_long_options l_opts[] = {
+ {"help", no_arg, 'h'}, {"version", no_arg, 'V'}, {"status", no_arg, 's'},
+ {"image", no_arg, 'm'}, {"filesize", no_arg, 'z'}, {"increment", optional_arg, 'i'},
+ {NULL, 0, '\0'}};
/*-------------------------------------------------------------------------
* Function: usage
@@ -92,7 +59,8 @@ static struct long_options l_opts[] = {
*
*-------------------------------------------------------------------------
*/
-static void usage(const char *prog)
+static void
+usage(const char *prog)
{
HDfprintf(stdout, "usage: %s [OPTIONS] file_name\n", prog);
HDfprintf(stdout, " OPTIONS\n");
@@ -101,8 +69,18 @@ static void usage(const char *prog)
HDfprintf(stdout, " -s, --status Clear the status_flags field in the file's superblock\n");
HDfprintf(stdout, " -m, --image Remove the metadata cache image from the file\n");
HDfprintf(stdout, " --filesize Print the file's EOA and EOF\n");
- HDfprintf(stdout, " --increment=C Set the file's EOA to the maximum of (EOA, EOF) + C for the file <file_name>\n");
- HDfprintf(stdout, " C is >= 0; C is optional and will default to 1M when not set");
+ HDfprintf(stdout,
+ " --increment=C Set the file's EOA to the maximum of (EOA, EOF) + C for\n");
+ HDfprintf(stdout, " the file <file_name>.\n");
+ HDfprintf(stdout,
+ " C is >= 0; C is optional and will default to 1M when not set.\n");
+ HDfprintf(
+ stdout,
+ " This option helps to repair a crashed file where the stored EOA\n");
+ HDfprintf(stdout, " in the superblock is different from the actual EOF.\n");
+ HDfprintf(stdout,
+ " The file’s EOA and EOF will be the same after applying\n");
+ HDfprintf(stdout, " this option to the file.\n");
HDfprintf(stdout, "\n");
HDfprintf(stdout, "Examples of use:\n");
HDfprintf(stdout, "\n");
@@ -119,7 +97,6 @@ static void usage(const char *prog)
HDfprintf(stdout, " Set the EOA to the maximum of (EOA, EOF) + 512 for the file <file_name>.\n");
} /* usage() */
-
/*-------------------------------------------------------------------------
* Function: parse_command_line
*
@@ -132,11 +109,11 @@ static void usage(const char *prog)
*-------------------------------------------------------------------------
*/
static int
-parse_command_line(int argc, const char **argv)
+parse_command_line(int argc, const char *const *argv)
{
int opt;
- /* no arguments */
+ /* no arguments */
if (argc == 1) {
usage(h5tools_getprogname());
h5tools_setstatus(EXIT_FAILURE);
@@ -144,8 +121,8 @@ parse_command_line(int argc, const char **argv)
}
/* parse command line options */
- while((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) {
- switch((char)opt) {
+ while ((opt = H5_get_option(argc, argv, s_opts, l_opts)) != EOF) {
+ switch ((char)opt) {
case 'h':
usage(h5tools_getprogname());
h5tools_setstatus(EXIT_SUCCESS);
@@ -170,12 +147,12 @@ parse_command_line(int argc, const char **argv)
case 'i':
increment_eoa_eof = TRUE;
- if(opt_arg != NULL) {
- if (HDatoi(opt_arg) < 0) {
+ if (H5_optarg != NULL) {
+ if (HDatoi(H5_optarg) < 0) {
usage(h5tools_getprogname());
goto done;
}
- increment = HDatoi(opt_arg);
+ increment = (hsize_t)HDatoi(H5_optarg);
}
break;
@@ -184,20 +161,20 @@ parse_command_line(int argc, const char **argv)
h5tools_setstatus(EXIT_FAILURE);
goto error;
} /* end switch */
- } /* end while */
+ } /* end while */
/* check for file name to be processed */
- if(argc <= opt_ind) {
+ if (argc <= H5_optind) {
error_msg("missing file name\n");
usage(h5tools_getprogname());
h5tools_setstatus(EXIT_FAILURE);
goto error;
} /* end if */
- fname_g = HDstrdup(argv[opt_ind]);
+ fname_g = HDstrdup(argv[H5_optind]);
done:
- return(0);
+ return (0);
error:
return -1;
@@ -219,8 +196,6 @@ leave(int ret)
HDexit(ret);
} /* leave() */
-
-
/*-------------------------------------------------------------------------
* Function: main
*
@@ -249,42 +224,40 @@ leave(int ret)
*-------------------------------------------------------------------------
*/
int
-main (int argc, const char *argv[])
+main(int argc, char *argv[])
{
- char *fname = NULL; /* File name */
- hid_t fapl = -1; /* File access property list */
- hid_t fid = -1; /* File ID */
- haddr_t image_addr;
- hsize_t image_len;
- unsigned flags = H5F_ACC_RDWR; /* file access flags */
+ char * fname = NULL; /* File name */
+ hid_t fapl = H5I_INVALID_HID; /* File access property list */
+ hid_t fid = H5I_INVALID_HID; /* File ID */
+ haddr_t image_addr;
+ hsize_t image_len;
+ unsigned flags = H5F_ACC_RDWR; /* file access flags */
h5tools_setprogname(PROGRAMNAME);
h5tools_setstatus(EXIT_SUCCESS);
- /* Disable the HDF5 library's error reporting */
- H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
-
/* initialize h5tools lib */
h5tools_init();
/* Parse command line options */
- if(parse_command_line(argc, argv) < 0)
+ if (parse_command_line(argc, (const char *const *)argv) < 0)
goto done;
- if(fname_g == NULL)
+ if (fname_g == NULL)
goto done;
+ /* enable error reporting if command line option */
+ h5tools_error_report();
+
/* Print usage/exit if not using at least one of the options */
- if(!clear_status_flags && !remove_cache_image &&
- !increment_eoa_eof && !print_filesize) {
+ if (!clear_status_flags && !remove_cache_image && !increment_eoa_eof && !print_filesize) {
usage(h5tools_getprogname());
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
/* Cannot combine the --filesize option with other options */
- if(print_filesize &&
- (clear_status_flags || remove_cache_image || increment_eoa_eof)) {
+ if (print_filesize && (clear_status_flags || remove_cache_image || increment_eoa_eof)) {
error_msg("Cannot combine --filesize with other options\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
@@ -294,17 +267,17 @@ main (int argc, const char *argv[])
fname = HDstrdup(fname_g);
/* Get a copy of the file access property list */
- if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
+ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
error_msg("H5Pcreate\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
- }
+ }
/* -s option */
- if(clear_status_flags) {
+ if (clear_status_flags) {
/* Set to clear the status_flags in the file's superblock */
/* Activate this private property */
- if(H5Pset(fapl, H5F_ACS_CLEAR_STATUS_FLAGS_NAME, &clear_status_flags) < 0) {
+ if (H5Pset(fapl, H5F_ACS_CLEAR_STATUS_FLAGS_NAME, &clear_status_flags) < 0) {
error_msg("H5Pset\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
@@ -312,15 +285,15 @@ main (int argc, const char *argv[])
}
/* --increment option */
- if(increment_eoa_eof) {
+ if (increment_eoa_eof) {
/* Activate this private property */
- if(H5Pset(fapl, H5F_ACS_SKIP_EOF_CHECK_NAME, &increment_eoa_eof) < 0) {
+ if (H5Pset(fapl, H5F_ACS_SKIP_EOF_CHECK_NAME, &increment_eoa_eof) < 0) {
error_msg("H5Pset\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
/* Activate this private property */
- if(H5Pset(fapl, H5F_ACS_NULL_FSM_ADDR_NAME, &increment_eoa_eof) < 0) {
+ if (H5Pset(fapl, H5F_ACS_NULL_FSM_ADDR_NAME, &increment_eoa_eof) < 0) {
error_msg("H5Pset\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
@@ -328,9 +301,9 @@ main (int argc, const char *argv[])
}
/* --filesize option; open the file read-only */
- if(print_filesize) {
+ if (print_filesize) {
/* Activate this private property */
- if(H5Pset(fapl, H5F_ACS_SKIP_EOF_CHECK_NAME, &print_filesize) < 0) {
+ if (H5Pset(fapl, H5F_ACS_SKIP_EOF_CHECK_NAME, &print_filesize) < 0) {
error_msg("H5Pset\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
@@ -339,30 +312,30 @@ main (int argc, const char *argv[])
}
/* Open the file */
- if((fid = h5tools_fopen(fname, flags, fapl, NULL, NULL, (size_t)0)) < 0) {
+ if ((fid = h5tools_fopen(fname, flags, fapl, FALSE, NULL, (size_t)0)) < 0) {
error_msg("h5tools_fopen\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
/* --filesize option */
- if(print_filesize) {
- h5_stat_t st; /* Stat info call */
- haddr_t eoa; /* The EOA value */
+ if (print_filesize) {
+ h5_stat_t st; /* Stat info call */
+ haddr_t eoa; /* The EOA value */
/* Get the file's EOA and EOF */
- if(H5Fget_eoa(fid, &eoa) < 0 || HDstat(fname, &st) < 0) {
+ if (H5Fget_eoa(fid, &eoa) < 0 || HDstat(fname, &st) < 0) {
error_msg("H5Fget_eoa or HDstat\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
- HDfprintf(stdout, "EOA is %a; EOF is %a \n", eoa, st.st_size);
+ HDfprintf(stdout, "EOA is %" PRIuHADDR "; EOF is %" PRIuHADDR " \n", eoa, (haddr_t)st.st_size);
}
/* --increment option */
- if(increment_eoa_eof) {
+ if (increment_eoa_eof) {
/* Set the file's EOA to the maximum of (EOA, EOF) + increment */
- if(H5Fincrement_filesize(fid, increment) < 0) {
+ if (H5Fincrement_filesize(fid, increment) < 0) {
error_msg("H5Fset_eoa\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
@@ -370,30 +343,30 @@ main (int argc, const char *argv[])
}
/* -m option */
- if(remove_cache_image) {
- if(H5Fget_mdc_image_info(fid, &image_addr, &image_len) < 0) {
+ if (remove_cache_image) {
+ if (H5Fget_mdc_image_info(fid, &image_addr, &image_len) < 0) {
error_msg("H5Fget_mdc_image_info\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
- if(image_addr == HADDR_UNDEF && image_len == 0)
+ if (image_addr == HADDR_UNDEF && image_len == 0)
warn_msg("No cache image in the file\n");
}
-
h5tools_setstatus(EXIT_SUCCESS);
done:
- if(fname)
+ if (fname)
HDfree(fname);
- if(fname_g)
+ if (fname_g)
HDfree(fname_g);
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Pclose(fapl);
H5Fclose(fid);
- } H5E_END_TRY
+ }
+ H5E_END_TRY
leave(h5tools_getstatus());
} /* main() */
-
diff --git a/tools/src/misc/h5debug.c b/tools/src/misc/h5debug.c
index 96d6b9f..e03c72d 100644
--- a/tools/src/misc/h5debug.c
+++ b/tools/src/misc/h5debug.c
@@ -6,7 +6,7 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -15,48 +15,47 @@
*
* Created: debug.c
* Jul 18 1997
- * Robb Matzke <matzke@llnl.gov>
+ * Robb Matzke
*
* Purpose: Debugs an existing HDF5 file at a low level.
*
*-------------------------------------------------------------------------
*/
-#define H5A_FRIEND /*suppress error about including H5Apkg */
-#define H5B2_FRIEND /*suppress error about including H5B2pkg */
-#define H5B2_TESTING /*suppress warning about H5B2 testing funcs*/
-#define H5D_FRIEND /*suppress error about including H5Dpkg */
-#define H5EA_FRIEND /*suppress error about including H5EApkg */
-#define H5EA_TESTING /*suppress warning about H5EA testing funcs*/
-#define H5FA_FRIEND /*suppress error about including H5FApkg */
-#define H5FA_TESTING /*suppress warning about H5FA testing funcs*/
-#define H5F_FRIEND /*suppress error about including H5Fpkg */
-#define H5G_FRIEND /*suppress error about including H5Gpkg */
-#define H5HF_FRIEND /*suppress error about including H5HFpkg */
-#define H5O_FRIEND /*suppress error about including H5Opkg */
-#define H5SM_FRIEND /*suppress error about including H5SMpkg */
-
-#include "H5private.h" /* Generic Functions */
-#include "H5Apkg.h" /* Attributes */
-#include "H5B2pkg.h" /* v2 B-trees */
+#define H5A_FRIEND /*suppress error about including H5Apkg */
+#define H5B2_FRIEND /*suppress error about including H5B2pkg */
+#define H5B2_TESTING /*suppress warning about H5B2 testing funcs*/
+#define H5D_FRIEND /*suppress error about including H5Dpkg */
+#define H5EA_FRIEND /*suppress error about including H5EApkg */
+#define H5EA_TESTING /*suppress warning about H5EA testing funcs*/
+#define H5FA_FRIEND /*suppress error about including H5FApkg */
+#define H5FA_TESTING /*suppress warning about H5FA testing funcs*/
+#define H5F_FRIEND /*suppress error about including H5Fpkg */
+#define H5G_FRIEND /*suppress error about including H5Gpkg */
+#define H5HF_FRIEND /*suppress error about including H5HFpkg */
+#define H5O_FRIEND /*suppress error about including H5Opkg */
+#define H5SM_FRIEND /*suppress error about including H5SMpkg */
+
+#include "H5private.h" /* Generic Functions */
+#include "H5Apkg.h" /* Attributes */
+#include "H5B2pkg.h" /* v2 B-trees */
#include "H5CXprivate.h" /* API Contexts */
-#include "H5Dpkg.h" /* Datasets */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5EApkg.h" /* Extensible Arrays */
-#include "H5FApkg.h" /* Fixed Arrays */
-#include "H5Fpkg.h" /* File access */
+#include "H5Dpkg.h" /* Datasets */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5EApkg.h" /* Extensible Arrays */
+#include "H5FApkg.h" /* Fixed Arrays */
+#include "H5Fpkg.h" /* File access */
#include "H5FSprivate.h" /* Free space manager */
-#include "H5Gpkg.h" /* Groups */
-#include "H5HFpkg.h" /* Fractal heaps */
+#include "H5Gpkg.h" /* Groups */
+#include "H5HFpkg.h" /* Fractal heaps */
#include "H5HGprivate.h" /* Global Heaps */
-#include "H5Iprivate.h" /* IDs */
-#include "H5Opkg.h" /* Object headers */
-#include "H5SMpkg.h" /* Implicitly shared messages */
+#include "H5Iprivate.h" /* IDs */
+#include "H5Opkg.h" /* Object headers */
+#include "H5SMpkg.h" /* Implicitly shared messages */
/* File drivers */
#include "H5FDfamily.h"
-#define VCOL 50
-
+#define VCOL 50
/*-------------------------------------------------------------------------
* Function: get_H5B2_class
@@ -68,7 +67,6 @@
* Return: Non-NULL on success/NULL on failure
*
* Programmer: Quincey Koziol
- * koziol@hdfgroup.org
* Sep 11 2008
*
*-------------------------------------------------------------------------
@@ -76,72 +74,70 @@
static const H5B2_class_t *
get_H5B2_class(const uint8_t *sig)
{
- H5B2_subid_t subtype = (H5B2_subid_t)sig[H5_SIZEOF_MAGIC + 1];
- const H5B2_class_t *cls;
-
- switch(subtype) {
- case H5B2_TEST_ID:
- cls = H5B2_TEST;
- break;
-
- case H5B2_FHEAP_HUGE_INDIR_ID:
- cls = H5HF_HUGE_BT2_INDIR;
- break;
-
- case H5B2_FHEAP_HUGE_FILT_INDIR_ID:
- cls = H5HF_HUGE_BT2_FILT_INDIR;
- break;
-
- case H5B2_FHEAP_HUGE_DIR_ID:
- cls = H5HF_HUGE_BT2_DIR;
- break;
-
- case H5B2_FHEAP_HUGE_FILT_DIR_ID:
- cls = H5HF_HUGE_BT2_FILT_DIR;
- break;
-
- case H5B2_GRP_DENSE_NAME_ID:
- cls = H5G_BT2_NAME;
- break;
-
- case H5B2_GRP_DENSE_CORDER_ID:
- cls = H5G_BT2_CORDER;
- break;
-
- case H5B2_SOHM_INDEX_ID:
- cls = H5SM_INDEX;
- break;
-
- case H5B2_ATTR_DENSE_NAME_ID:
- cls = H5A_BT2_NAME;
- break;
-
- case H5B2_ATTR_DENSE_CORDER_ID:
- cls = H5A_BT2_CORDER;
- break;
-
- case H5B2_CDSET_ID:
- cls = H5D_BT2;
- break;
-
- case H5B2_CDSET_FILT_ID:
- cls = H5D_BT2_FILT;
- break;
-
- case H5B2_TEST2_ID:
- cls = H5B2_TEST2;
- break;
-
- case H5B2_NUM_BTREE_ID:
- default:
- HDfprintf(stderr, "Unknown v2 B-tree subtype %u\n", (unsigned)(subtype));
- HDexit(4);
+ H5B2_subid_t subtype = (H5B2_subid_t)sig[H5_SIZEOF_MAGIC + 1];
+ const H5B2_class_t *cls = NULL;
+
+ switch (subtype) {
+ case H5B2_TEST_ID:
+ cls = H5B2_TEST;
+ break;
+
+ case H5B2_FHEAP_HUGE_INDIR_ID:
+ cls = H5HF_HUGE_BT2_INDIR;
+ break;
+
+ case H5B2_FHEAP_HUGE_FILT_INDIR_ID:
+ cls = H5HF_HUGE_BT2_FILT_INDIR;
+ break;
+
+ case H5B2_FHEAP_HUGE_DIR_ID:
+ cls = H5HF_HUGE_BT2_DIR;
+ break;
+
+ case H5B2_FHEAP_HUGE_FILT_DIR_ID:
+ cls = H5HF_HUGE_BT2_FILT_DIR;
+ break;
+
+ case H5B2_GRP_DENSE_NAME_ID:
+ cls = H5G_BT2_NAME;
+ break;
+
+ case H5B2_GRP_DENSE_CORDER_ID:
+ cls = H5G_BT2_CORDER;
+ break;
+
+ case H5B2_SOHM_INDEX_ID:
+ cls = H5SM_INDEX;
+ break;
+
+ case H5B2_ATTR_DENSE_NAME_ID:
+ cls = H5A_BT2_NAME;
+ break;
+
+ case H5B2_ATTR_DENSE_CORDER_ID:
+ cls = H5A_BT2_CORDER;
+ break;
+
+ case H5B2_CDSET_ID:
+ cls = H5D_BT2;
+ break;
+
+ case H5B2_CDSET_FILT_ID:
+ cls = H5D_BT2_FILT;
+ break;
+
+ case H5B2_TEST2_ID:
+ cls = H5B2_TEST2;
+ break;
+
+ case H5B2_NUM_BTREE_ID:
+ default:
+ HDfprintf(stderr, "Unknown v2 B-tree subtype %u\n", (unsigned)(subtype));
} /* end switch */
- return(cls);
+ return (cls);
} /* end get_H5B2_class() */
-
/*-------------------------------------------------------------------------
* Function: get_H5EA_class
*
@@ -152,7 +148,6 @@ get_H5B2_class(const uint8_t *sig)
* Return: Non-NULL on success/NULL on failure
*
* Programmer: Quincey Koziol
- * koziol@hdfgroup.org
* Sep 11 2008
*
*-------------------------------------------------------------------------
@@ -160,32 +155,30 @@ get_H5B2_class(const uint8_t *sig)
static const H5EA_class_t *
get_H5EA_class(const uint8_t *sig)
{
- H5EA_cls_id_t clsid = (H5EA_cls_id_t)sig[H5_SIZEOF_MAGIC + 1];
- const H5EA_class_t *cls;
-
- switch(clsid) {
- case H5EA_CLS_TEST_ID:
- cls = H5EA_CLS_TEST;
- break;
-
- case H5EA_CLS_CHUNK_ID:
- cls = H5EA_CLS_CHUNK;
- break;
-
- case H5EA_CLS_FILT_CHUNK_ID:
- cls = H5EA_CLS_FILT_CHUNK;
- break;
-
- case H5EA_NUM_CLS_ID:
- default:
- HDfprintf(stderr, "Unknown extensible array class %u\n", (unsigned)(clsid));
- HDexit(4);
+ H5EA_cls_id_t clsid = (H5EA_cls_id_t)sig[H5_SIZEOF_MAGIC + 1];
+ const H5EA_class_t *cls = NULL;
+
+ switch (clsid) {
+ case H5EA_CLS_TEST_ID:
+ cls = H5EA_CLS_TEST;
+ break;
+
+ case H5EA_CLS_CHUNK_ID:
+ cls = H5EA_CLS_CHUNK;
+ break;
+
+ case H5EA_CLS_FILT_CHUNK_ID:
+ cls = H5EA_CLS_FILT_CHUNK;
+ break;
+
+ case H5EA_NUM_CLS_ID:
+ default:
+ HDfprintf(stderr, "Unknown extensible array class %u\n", (unsigned)(clsid));
} /* end switch */
- return(cls);
+ return (cls);
} /* end get_H5EA_class() */
-
/*-------------------------------------------------------------------------
* Function: get_H5FA_class
*
@@ -196,7 +189,6 @@ get_H5EA_class(const uint8_t *sig)
* Return: Non-NULL on success/NULL on failure
*
* Programmer: Quincey Koziol
- * koziol@hdfgroup.org
* Sep 11 2008
*
*-------------------------------------------------------------------------
@@ -204,32 +196,30 @@ get_H5EA_class(const uint8_t *sig)
static const H5FA_class_t *
get_H5FA_class(const uint8_t *sig)
{
- H5FA_cls_id_t clsid = (H5FA_cls_id_t)sig[H5_SIZEOF_MAGIC + 1];
- const H5FA_class_t *cls;
-
- switch(clsid) {
- case H5FA_CLS_TEST_ID:
- cls = H5FA_CLS_TEST;
- break;
-
- case H5FA_CLS_CHUNK_ID:
- cls = H5FA_CLS_CHUNK;
- break;
-
- case H5FA_CLS_FILT_CHUNK_ID:
- cls = H5FA_CLS_FILT_CHUNK;
- break;
-
- case H5FA_NUM_CLS_ID:
- default:
- HDfprintf(stderr, "Unknown fixed array class %u\n", (unsigned)(clsid));
- HDexit(4);
+ H5FA_cls_id_t clsid = (H5FA_cls_id_t)sig[H5_SIZEOF_MAGIC + 1];
+ const H5FA_class_t *cls = NULL;
+
+ switch (clsid) {
+ case H5FA_CLS_TEST_ID:
+ cls = H5FA_CLS_TEST;
+ break;
+
+ case H5FA_CLS_CHUNK_ID:
+ cls = H5FA_CLS_CHUNK;
+ break;
+
+ case H5FA_CLS_FILT_CHUNK_ID:
+ cls = H5FA_CLS_FILT_CHUNK;
+ break;
+
+ case H5FA_NUM_CLS_ID:
+ default:
+ HDfprintf(stderr, "Unknown fixed array class %u\n", (unsigned)(clsid));
} /* end switch */
- return(cls);
+ return (cls);
} /* end get_H5FA_class() */
-
/*-------------------------------------------------------------------------
* Function: main
*
@@ -240,7 +230,6 @@ get_H5FA_class(const uint8_t *sig)
* Failure: exit (non-zero)
*
* Programmer: Robb Matzke
- * matzke@llnl.gov
* Jul 18 1997
*
*-------------------------------------------------------------------------
@@ -248,25 +237,32 @@ get_H5FA_class(const uint8_t *sig)
int
main(int argc, char *argv[])
{
- hid_t fid, fapl;
- H5F_t *f;
- haddr_t addr = 0, extra = 0, extra2 = 0, extra3 = 0, extra4 = 0;
- uint8_t sig[H5F_SIGNATURE_LEN];
- size_t u;
- H5E_auto2_t func;
- void *edata;
- hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
- herr_t status = SUCCEED;
-
- if(argc == 1) {
- HDfprintf(stderr, "Usage: %s filename [signature-addr [extra]]\n", argv[0]);
- HDexit(1);
+ hid_t fid = H5I_INVALID_HID;
+ hid_t fapl = H5I_INVALID_HID;
+ H5VL_object_t *vol_obj;
+ H5F_t * f;
+ haddr_t addr = 0;
+ int extra_count = 0; /* Number of extra arguments */
+ haddr_t extra[10];
+ uint8_t sig[H5F_SIGNATURE_LEN];
+ size_t u;
+ H5E_auto2_t func = NULL;
+ void * edata = NULL;
+ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
+ herr_t status = SUCCEED;
+ int exit_value = 0;
+
+ if (argc == 1) {
+ HDfprintf(stderr, "Usage: %s filename [signature-addr [extra]*]\n", argv[0]);
+ exit_value = 1;
+ goto done;
} /* end if */
/* Initialize the library */
- if(H5open() < 0) {
+ if (H5open() < 0) {
HDfprintf(stderr, "cannot initialize the library\n");
- HDexit(1);
+ exit_value = 1;
+ goto done;
} /* end if */
/* Disable error reporting */
@@ -274,450 +270,523 @@ main(int argc, char *argv[])
H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
/*
- * Open the file and get the file descriptor.
- */
- if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
+ * Open the file and get the file descriptor.
+ */
+ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
HDfprintf(stderr, "cannot create file access property list\n");
- HDexit(1);
+ exit_value = 1;
+ goto done;
} /* end if */
- if(HDstrchr(argv[1], '%'))
- if(H5Pset_fapl_family (fapl, (hsize_t)0, H5P_DEFAULT) < 0) {
+ if (HDstrchr(argv[1], '%'))
+ if (H5Pset_fapl_family(fapl, (hsize_t)0, H5P_DEFAULT) < 0) {
HDfprintf(stderr, "cannot set file access property list\n");
- HDexit(1);
+ exit_value = 1;
+ goto done;
}
- if((fid = H5Fopen(argv[1], H5F_ACC_RDONLY, fapl)) < 0) {
+ if ((fid = H5Fopen(argv[1], H5F_ACC_RDONLY, fapl)) < 0) {
HDfprintf(stderr, "cannot open file\n");
- HDexit(1);
+ exit_value = 1;
+ goto done;
} /* end if */
/* Push API context */
- if(H5CX_push() < 0) {
+ if (H5CX_push() < 0) {
HDfprintf(stderr, "cannot set API context\n");
- HDexit(1);
+ exit_value = 1;
+ goto done;
}
api_ctx_pushed = TRUE;
- if(NULL == (f = (H5F_t *)H5I_object(fid))) {
+ if (NULL == (vol_obj = (H5VL_object_t *)H5VL_vol_object(fid))) {
+ HDfprintf(stderr, "cannot obtain vol_obj pointer\n");
+ exit_value = 2;
+ goto done;
+ } /* end if */
+
+ if (NULL == (f = (H5F_t *)H5VL_object_data(vol_obj))) {
HDfprintf(stderr, "cannot obtain H5F_t pointer\n");
- HDexit(2);
+ exit_value = 2;
+ goto done;
} /* end if */
/* Ignore metadata tags while using h5debug */
- if(H5AC_ignore_tags(f) < 0) {
+ if (H5AC_ignore_tags(f) < 0) {
HDfprintf(stderr, "cannot ignore metadata tags\n");
- HDexit(1);
+ exit_value = 1;
+ goto done;
}
/*
- * Parse command arguments.
- */
- if(argc > 2)
+ * Parse command arguments.
+ */
+
+ /* Primary data structure to dump */
+ if (argc > 2)
addr = (haddr_t)HDstrtoll(argv[2], NULL, 0);
- if(argc > 3)
- extra = (haddr_t)HDstrtoll(argv[3], NULL, 0);
- if(argc > 4)
- extra2 = (haddr_t)HDstrtoll(argv[4], NULL, 0);
- if(argc > 5)
- extra3 = (haddr_t)HDstrtoll(argv[5], NULL, 0);
- if(argc > 6)
- extra4 = (haddr_t)HDstrtoll(argv[6], NULL, 0);
+
+ /* Extra arguments for primary data structure */
+ HDmemset(extra, 0, sizeof(extra));
+ if (argc > 3) {
+ /* Number of extra arguments */
+ extra_count = argc - 3;
+
+ /* Range check against 'extra' array size */
+ if (extra_count > (int)(sizeof(extra) / sizeof(haddr_t))) {
+ HDfprintf(stderr, "\nWARNING: Only using first %d extra parameters\n\n",
+ (int)(sizeof(extra) / sizeof(haddr_t)));
+ extra_count = (int)(sizeof(extra) / sizeof(haddr_t));
+ } /* end if */
+
+ for (u = 0; u < (size_t)extra_count; u++)
+ extra[u] = (haddr_t)HDstrtoll(argv[u + 3], NULL, 0);
+ } /* end if */
/*
- * Read the signature at the specified file position.
- */
- HDfprintf(stdout, "Reading signature at address %a (rel)\n", addr);
- if(H5F_block_read(f, H5FD_MEM_SUPER, addr, sizeof(sig), sig) < 0) {
+ * Read the signature at the specified file position.
+ */
+ HDfprintf(stdout, "Reading signature at address %" PRIuHADDR " (rel)\n", addr);
+ if (H5F_block_read(f, H5FD_MEM_SUPER, addr, sizeof(sig), sig) < 0) {
HDfprintf(stderr, "cannot read signature\n");
- HDexit(3);
+ exit_value = 3;
+ goto done;
}
- if(!HDmemcmp(sig, H5F_SIGNATURE, (size_t)H5F_SIGNATURE_LEN)) {
+ if (!HDmemcmp(sig, H5F_SIGNATURE, (size_t)H5F_SIGNATURE_LEN)) {
/*
- * Debug the file's super block.
- */
+ * Debug the file's super block.
+ */
status = H5F_debug(f, stdout, 0, VCOL);
-
- } else if(!HDmemcmp(sig, H5HL_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
+ }
+ else if (!HDmemcmp(sig, H5HL_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
- * Debug a local heap.
- */
+ * Debug a local heap.
+ */
status = H5HL_debug(f, addr, stdout, 0, VCOL);
-
}
- else if(!HDmemcmp (sig, H5HG_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
+ else if (!HDmemcmp(sig, H5HG_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
- * Debug a global heap collection.
- */
+ * Debug a global heap collection.
+ */
status = H5HG_debug(f, addr, stdout, 0, VCOL);
-
}
- else if(!HDmemcmp(sig, H5G_NODE_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
+ else if (!HDmemcmp(sig, H5G_NODE_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
- * Debug a symbol table node.
- */
+ * Debug a symbol table node.
+ */
/* Check for extra parameters */
- if(extra == 0) {
- HDfprintf(stderr, "\nWarning: Providing the group's local heap address will give more information\n");
+ if (extra_count == 0 || extra[0] == 0) {
+ HDfprintf(stderr,
+ "\nWarning: Providing the group's local heap address will give more information\n");
HDfprintf(stderr, "Symbol table node usage:\n");
HDfprintf(stderr, "\th5debug <filename> <Symbol table node address> <address of local heap>\n\n");
} /* end if */
- status = H5G_node_debug(f, addr, stdout, 0, VCOL, extra);
-
+ status = H5G_node_debug(f, addr, stdout, 0, VCOL, extra[0]);
}
- else if(!HDmemcmp(sig, H5B_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
+ else if (!HDmemcmp(sig, H5B_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
- * Debug a B-tree. B-trees are debugged through the B-tree
- * subclass. The subclass identifier is the byte immediately
- * after the B-tree signature.
- */
+ * Debug a B-tree. B-trees are debugged through the B-tree
+ * subclass. The subclass identifier is the byte immediately
+ * after the B-tree signature.
+ */
H5B_subid_t subtype = (H5B_subid_t)sig[H5_SIZEOF_MAGIC];
unsigned ndims;
uint32_t dim[H5O_LAYOUT_NDIMS];
- switch(subtype) {
- case H5B_SNODE_ID:
- /* Check for extra parameters */
- if(extra == 0) {
- HDfprintf(stderr, "\nWarning: Providing the group's local heap address will give more information\n");
- HDfprintf(stderr, "B-tree symbol table node usage:\n");
- HDfprintf(stderr, "\th5debug <filename> <B-tree node address> <address of local heap>\n\n");
- HDexit(4);
- } /* end if */
-
- status = H5G_node_debug(f, addr, stdout, 0, VCOL, extra);
- break;
+ switch (subtype) {
+ case H5B_SNODE_ID:
+ /* Check for extra parameters */
+ if (extra_count == 0 || extra[0] == 0) {
+ HDfprintf(
+ stderr,
+ "\nWarning: Providing the group's local heap address will give more information\n");
+ HDfprintf(stderr, "B-tree symbol table node usage:\n");
+ HDfprintf(stderr,
+ "\th5debug <filename> <B-tree node address> <address of local heap>\n\n");
+ exit_value = 4;
+ goto done;
+ } /* end if */
- case H5B_CHUNK_ID:
- /* Check for extra parameters */
- if(extra == 0) {
- HDfprintf(stderr, "ERROR: Need number of dimensions of chunk in order to dump chunk B-tree node\n");
- HDfprintf(stderr, "B-tree chunked storage node usage:\n");
- HDfprintf(stderr, "\th5debug <filename> <B-tree node address> <# of dimensions> <slowest chunk dim>...<fastest chunk dim>\n");
- HDexit(4);
- } /* end if */
-
- /* Build array of chunk dimensions */
- ndims = (unsigned)extra;
- dim[0] = (uint32_t)extra2;
- if(ndims > 1)
- dim[1] = (uint32_t)extra3;
- if(ndims > 2)
- dim[2] = (uint32_t)extra4;
-
- /* Check for dimension error */
- if(ndims > 3) {
- HDfprintf(stderr, "ERROR: Only 3 dimensions support currently (fix h5debug)\n");
- HDfprintf(stderr, "B-tree chunked storage node usage:\n");
- HDfprintf(stderr, "\th5debug <filename> <B-tree node address> <# of dimensions> <slowest chunk dim>...<fastest chunk dim>\n");
- HDexit(4);
- } /* end for */
- for(u = 0; u < ndims; u++)
- if(0 == dim[u]) {
- HDfprintf(stderr, "ERROR: Chunk dimensions should be >0\n");
+ status = H5G_node_debug(f, addr, stdout, 0, VCOL, extra[0]);
+ break;
+
+ case H5B_CHUNK_ID:
+ /* Check for extra parameters */
+ if (extra_count == 0 || extra[0] == 0) {
+ HDfprintf(
+ stderr,
+ "ERROR: Need number of dimensions of chunk in order to dump chunk B-tree node\n");
HDfprintf(stderr, "B-tree chunked storage node usage:\n");
- HDfprintf(stderr, "\th5debug <filename> <B-tree node address> <# of dimensions> <slowest chunk dim>...<fastest chunk dim>\n");
- HDexit(4);
+ HDfprintf(stderr, "\th5debug <filename> <B-tree node address> <# of dimensions> <slowest "
+ "chunk dim>...<fastest chunk dim>\n");
+ exit_value = 4;
+ goto done;
} /* end if */
- /* Set the last dimension (the element size) to zero */
- dim[ndims] = 0;
-
- status = H5D_btree_debug(f, addr, stdout, 0, VCOL, ndims, dim);
- break;
+ /* Set # of dimensions */
+ ndims = (unsigned)extra[0];
- case H5B_NUM_BTREE_ID:
- default:
- HDfprintf(stderr, "Unknown v1 B-tree subtype %u\n", (unsigned)(subtype));
- HDexit(4);
+ /* Check for dimension error */
+ if (ndims > 9) {
+ HDfprintf(stderr, "ERROR: Only 9 dimensions support currently (fix h5debug)\n");
+ HDfprintf(stderr, "B-tree chunked storage node usage:\n");
+ HDfprintf(stderr, "\th5debug <filename> <B-tree node address> <# of dimensions> <slowest "
+ "chunk dim>...<fastest chunk dim>\n");
+ exit_value = 4;
+ goto done;
+ } /* end for */
+
+ /* Build array of chunk dimensions */
+ for (u = 0; u < ndims; u++)
+ dim[u] = (uint32_t)extra[u + 1];
+
+ /* Check for dimension error */
+ for (u = 0; u < ndims; u++)
+ if (0 == dim[u]) {
+ HDfprintf(stderr, "ERROR: Chunk dimensions should be >0\n");
+ HDfprintf(stderr, "B-tree chunked storage node usage:\n");
+ HDfprintf(stderr, "\th5debug <filename> <B-tree node address> <# of dimensions> "
+ "<slowest chunk dim>...<fastest chunk dim>\n");
+ exit_value = 4;
+ goto done;
+ } /* end if */
+
+ /* Set the last dimension (the element size) to zero */
+ dim[ndims] = 0;
+
+ status = H5D_btree_debug(f, addr, stdout, 0, VCOL, ndims, dim);
+ break;
+
+ case H5B_NUM_BTREE_ID:
+ default:
+ HDfprintf(stderr, "Unknown v1 B-tree subtype %u\n", (unsigned)(subtype));
+ exit_value = 4;
+ goto done;
}
-
}
- else if(!HDmemcmp(sig, H5B2_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
+ else if (!HDmemcmp(sig, H5B2_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
- * Debug a v2 B-tree header.
- */
+ * Debug a v2 B-tree header.
+ */
const H5B2_class_t *cls = get_H5B2_class(sig);
HDassert(cls);
- if((cls == H5D_BT2 || cls == H5D_BT2_FILT) && extra == 0) {
- HDfprintf(stderr, "ERROR: Need v2 B-tree header address and object header address containing the layout message in order to dump header\n");
+ if ((cls == H5D_BT2 || cls == H5D_BT2_FILT) && (extra_count == 0 || extra[0] == 0)) {
+ HDfprintf(stderr, "ERROR: Need v2 B-tree header address and object header address containing the "
+ "layout message in order to dump header\n");
HDfprintf(stderr, "v2 B-tree hdr usage:\n");
HDfprintf(stderr, "\th5debug <filename> <v2 B-tree header address> <object header address>\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5B2__hdr_debug(f, addr, stdout, 0, VCOL, cls, (haddr_t)extra);
-
+ status = H5B2__hdr_debug(f, addr, stdout, 0, VCOL, cls, (haddr_t)extra[0]);
}
- else if(!HDmemcmp(sig, H5B2_INT_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
+ else if (!HDmemcmp(sig, H5B2_INT_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
- * Debug a v2 B-tree internal node.
- */
+ * Debug a v2 B-tree internal node.
+ */
const H5B2_class_t *cls = get_H5B2_class(sig);
HDassert(cls);
/* Check for enough valid parameters */
- if((cls == H5D_BT2 || cls == H5D_BT2_FILT) && (extra == 0 || extra2 == 0 || extra3 == 0 || extra4 == 0)) {
- HDfprintf(stderr, "ERROR: Need v2 B-tree header address, the node's number of records, depth, and object header address containing the layout message in order to dump internal node\n");
- HDfprintf(stderr, "NOTE: Leaf nodes are depth 0, the internal nodes above them are depth 1, etc.\n");
+ if ((cls == H5D_BT2 || cls == H5D_BT2_FILT) &&
+ (extra_count == 0 || extra[0] == 0 || extra[1] == 0 || extra[2] == 0 || extra[3] == 0)) {
+ HDfprintf(stderr,
+ "ERROR: Need v2 B-tree header address, the node's number of records, depth, and object "
+ "header address containing the layout message in order to dump internal node\n");
+ HDfprintf(stderr,
+ "NOTE: Leaf nodes are depth 0, the internal nodes above them are depth 1, etc.\n");
HDfprintf(stderr, "v2 B-tree internal node usage:\n");
- HDfprintf(stderr, "\th5debug <filename> <internal node address> <v2 B-tree header address> <number of records> <depth> <object header address>\n");
- HDexit(4);
-
+ HDfprintf(stderr, "\th5debug <filename> <internal node address> <v2 B-tree header address> "
+ "<number of records> <depth> <object header address>\n");
+ exit_value = 4;
+ goto done;
}
- else if(extra == 0 || extra2 == 0 || extra3 == 0) {
- HDfprintf(stderr, "ERROR: Need v2 B-tree header address and the node's number of records and depth in order to dump internal node\n");
- HDfprintf(stderr, "NOTE: Leaf nodes are depth 0, the internal nodes above them are depth 1, etc.\n");
+ else if (extra_count == 0 || extra[0] == 0 || extra[1] == 0 || extra[2] == 0) {
+ HDfprintf(stderr, "ERROR: Need v2 B-tree header address and the node's number of records and "
+ "depth in order to dump internal node\n");
+ HDfprintf(stderr,
+ "NOTE: Leaf nodes are depth 0, the internal nodes above them are depth 1, etc.\n");
HDfprintf(stderr, "v2 B-tree internal node usage:\n");
- HDfprintf(stderr, "\th5debug <filename> <internal node address> <v2 B-tree header address> <number of records> <depth>\n");
- HDexit(4);
+ HDfprintf(stderr, "\th5debug <filename> <internal node address> <v2 B-tree header address> "
+ "<number of records> <depth>\n");
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5B2__int_debug(f, addr, stdout, 0, VCOL, cls, extra, (unsigned)extra2, (unsigned)extra3, (haddr_t)extra4);
-
+ status = H5B2__int_debug(f, addr, stdout, 0, VCOL, cls, extra[0], (unsigned)extra[1],
+ (unsigned)extra[2], (haddr_t)extra[3]);
}
- else if(!HDmemcmp(sig, H5B2_LEAF_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
+ else if (!HDmemcmp(sig, H5B2_LEAF_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
- * Debug a v2 B-tree leaf node.
- */
+ * Debug a v2 B-tree leaf node.
+ */
const H5B2_class_t *cls = get_H5B2_class(sig);
HDassert(cls);
/* Check for enough valid parameters */
- if((cls == H5D_BT2 || cls == H5D_BT2_FILT) && (extra == 0 || extra2 == 0 || extra3 == 0 )) {
+ if ((cls == H5D_BT2 || cls == H5D_BT2_FILT) &&
+ (extra_count == 0 || extra[0] == 0 || extra[1] == 0 || extra[2] == 0)) {
- HDfprintf(stderr, "ERROR: Need v2 B-tree header address, number of records, and object header address containing the layout message in order to dump leaf node\n");
+ HDfprintf(stderr, "ERROR: Need v2 B-tree header address, number of records, and object header "
+ "address containing the layout message in order to dump leaf node\n");
HDfprintf(stderr, "v2 B-tree leaf node usage:\n");
- HDfprintf(stderr, "\th5debug <filename> <leaf node address> <v2 B-tree header address> <number of records> <object header address>\n");
- HDexit(4);
-
+ HDfprintf(stderr, "\th5debug <filename> <leaf node address> <v2 B-tree header address> <number "
+ "of records> <object header address>\n");
+ exit_value = 4;
+ goto done;
}
- else if(extra == 0 || extra2 == 0) {
- HDfprintf(stderr, "ERROR: Need v2 B-tree header address and number of records in order to dump leaf node\n");
+ else if (extra_count == 0 || extra[0] == 0 || extra[1] == 0) {
+ HDfprintf(
+ stderr,
+ "ERROR: Need v2 B-tree header address and number of records in order to dump leaf node\n");
HDfprintf(stderr, "v2 B-tree leaf node usage:\n");
- HDfprintf(stderr, "\th5debug <filename> <leaf node address> <v2 B-tree header address> <number of records>\n");
- HDexit(4);
+ HDfprintf(
+ stderr,
+ "\th5debug <filename> <leaf node address> <v2 B-tree header address> <number of records>\n");
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5B2__leaf_debug(f, addr, stdout, 0, VCOL, cls, extra, (unsigned)extra2, (haddr_t)extra3);
-
+ status =
+ H5B2__leaf_debug(f, addr, stdout, 0, VCOL, cls, extra[0], (unsigned)extra[1], (haddr_t)extra[2]);
}
- else if(!HDmemcmp(sig, H5HF_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
+ else if (!HDmemcmp(sig, H5HF_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
- * Debug a fractal heap header.
- */
+ * Debug a fractal heap header.
+ */
status = H5HF_hdr_debug(f, addr, stdout, 0, VCOL);
-
}
- else if(!HDmemcmp(sig, H5HF_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
+ else if (!HDmemcmp(sig, H5HF_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
- * Debug a fractal heap direct block.
- */
+ * Debug a fractal heap direct block.
+ */
/* Check for enough valid parameters */
- if(extra == 0 || extra2 == 0) {
- HDfprintf(stderr, "ERROR: Need fractal heap header address and size of direct block in order to dump direct block\n");
+ if (extra_count == 0 || extra[0] == 0 || extra[1] == 0) {
+ HDfprintf(stderr, "ERROR: Need fractal heap header address and size of direct block in order to "
+ "dump direct block\n");
HDfprintf(stderr, "Fractal heap direct block usage:\n");
- HDfprintf(stderr, "\th5debug <filename> <direct block address> <heap header address> <size of direct block>\n");
- HDexit(4);
+ HDfprintf(
+ stderr,
+ "\th5debug <filename> <direct block address> <heap header address> <size of direct block>\n");
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5HF_dblock_debug(f, addr, stdout, 0, VCOL, extra, (size_t)extra2);
-
+ status = H5HF_dblock_debug(f, addr, stdout, 0, VCOL, extra[0], (size_t)extra[1]);
}
- else if(!HDmemcmp(sig, H5HF_IBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
+ else if (!HDmemcmp(sig, H5HF_IBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
- * Debug a fractal heap indirect block.
- */
+ * Debug a fractal heap indirect block.
+ */
/* Check for enough valid parameters */
- if(extra == 0 || extra2 == 0) {
- HDfprintf(stderr, "ERROR: Need fractal heap header address and number of rows in order to dump indirect block\n");
+ if (extra_count == 0 || extra[0] == 0 || extra[1] == 0) {
+ HDfprintf(stderr, "ERROR: Need fractal heap header address and number of rows in order to dump "
+ "indirect block\n");
HDfprintf(stderr, "Fractal heap indirect block usage:\n");
- HDfprintf(stderr, "\th5debug <filename> <indirect block address> <heap header address> <number of rows>\n");
- HDexit(4);
+ HDfprintf(
+ stderr,
+ "\th5debug <filename> <indirect block address> <heap header address> <number of rows>\n");
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5HF_iblock_debug(f, addr, stdout, 0, VCOL, extra, (unsigned)extra2);
-
+ status = H5HF_iblock_debug(f, addr, stdout, 0, VCOL, extra[0], (unsigned)extra[1]);
}
- else if(!HDmemcmp(sig, H5FS_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
+ else if (!HDmemcmp(sig, H5FS_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
- * Debug a free space header.
- */
+ * Debug a free space header.
+ */
status = H5FS_debug(f, addr, stdout, 0, VCOL);
-
}
- else if(!HDmemcmp(sig, H5FS_SINFO_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
+ else if (!HDmemcmp(sig, H5FS_SINFO_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
- * Debug free space serialized sections.
- */
+ * Debug free space serialized sections.
+ */
/* Check for enough valid parameters */
- if(extra == 0 || extra2 == 0) {
- HDfprintf(stderr, "ERROR: Need free space header address and client address in order to dump serialized sections\n");
+ if (extra_count == 0 || extra[0] == 0 || extra[1] == 0) {
+ HDfprintf(stderr, "ERROR: Need free space header address and client address in order to dump "
+ "serialized sections\n");
HDfprintf(stderr, "Free space serialized sections usage:\n");
- HDfprintf(stderr, "\th5debug <filename> <serialized sections address> <free space header address> <client address>\n");
- HDexit(4);
+ HDfprintf(stderr, "\th5debug <filename> <serialized sections address> <free space header "
+ "address> <client address>\n");
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5FS_sects_debug(f, addr, stdout, 0, VCOL, extra, extra2);
-
+ status = H5FS_sects_debug(f, addr, stdout, 0, VCOL, extra[0], extra[1]);
}
- else if(!HDmemcmp(sig, H5SM_TABLE_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
+ else if (!HDmemcmp(sig, H5SM_TABLE_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
- * Debug shared message master table.
- */
-
- status = H5SM_table_debug(f, addr, stdout, 0, VCOL, (unsigned) UFAIL, (unsigned) UFAIL);
+ * Debug shared message master table.
+ */
+ status = H5SM_table_debug(f, addr, stdout, 0, VCOL, UINT_MAX, UINT_MAX);
}
- else if(!HDmemcmp(sig, H5SM_LIST_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
+ else if (!HDmemcmp(sig, H5SM_LIST_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
- * Debug shared message list index.
- */
+ * Debug shared message list index.
+ */
/* Check for enough valid parameters */
- if(extra == 0) {
+ if (extra_count == 0 || extra[0] == 0) {
HDfprintf(stderr, "ERROR: Need shared message header address in order to shared message list\n");
HDfprintf(stderr, "Shared message list usage:\n");
- HDfprintf(stderr, "\th5debug <filename> <shared message list address> <shared message header address>\n");
- HDexit(4);
+ HDfprintf(stderr,
+ "\th5debug <filename> <shared message list address> <shared message header address>\n");
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5SM_list_debug(f, addr, stdout, 0, VCOL, (haddr_t)extra);
-
+ status = H5SM_list_debug(f, addr, stdout, 0, VCOL, (haddr_t)extra[0]);
}
- else if(!HDmemcmp(sig, H5EA_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
+ else if (!HDmemcmp(sig, H5EA_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
- * Debug an extensible aray header.
- */
+ * Debug an extensible array header.
+ */
const H5EA_class_t *cls = get_H5EA_class(sig);
HDassert(cls);
/* Check for enough valid parameters */
- if(extra == 0) {
- HDfprintf(stderr, "ERROR: Need object header address containing the layout message in order to dump header\n");
+ if (extra_count == 0 || extra[0] == 0) {
+ HDfprintf(
+ stderr,
+ "ERROR: Need object header address containing the layout message in order to dump header\n");
HDfprintf(stderr, "Extensible array header block usage:\n");
- HDfprintf(stderr, "\th5debug <filename> <Extensible Array header address> <object header address>\n");
- HDexit(4);
+ HDfprintf(stderr,
+ "\th5debug <filename> <Extensible Array header address> <object header address>\n");
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5EA__hdr_debug(f, addr, stdout, 0, VCOL, cls, extra);
-
+ status = H5EA__hdr_debug(f, addr, stdout, 0, VCOL, cls, extra[0]);
}
- else if(!HDmemcmp(sig, H5EA_IBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
+ else if (!HDmemcmp(sig, H5EA_IBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
- * Debug an extensible aray index block.
- */
+ * Debug an extensible array index block.
+ */
const H5EA_class_t *cls = get_H5EA_class(sig);
HDassert(cls);
/* Check for enough valid parameters */
- if(extra == 0 || extra2 == 0) {
- HDfprintf(stderr, "ERROR: Need extensible array header address and object header address containing the layout message in order to dump index block\n");
+ if (extra_count == 0 || extra[0] == 0 || extra[1] == 0) {
+ HDfprintf(stderr, "ERROR: Need extensible array header address and object header address "
+ "containing the layout message in order to dump index block\n");
HDfprintf(stderr, "Extensible array index block usage:\n");
- HDfprintf(stderr, "\th5debug <filename> <index block address> <array header address> <object header address\n");
- HDexit(4);
+ HDfprintf(
+ stderr,
+ "\th5debug <filename> <index block address> <array header address> <object header address\n");
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5EA__iblock_debug(f, addr, stdout, 0, VCOL, cls, extra, extra2);
-
+ status = H5EA__iblock_debug(f, addr, stdout, 0, VCOL, cls, extra[0], extra[1]);
}
- else if(!HDmemcmp(sig, H5EA_SBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
+ else if (!HDmemcmp(sig, H5EA_SBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
- * Debug an extensible aray super block.
- */
+ * Debug an extensible array super block.
+ */
const H5EA_class_t *cls = get_H5EA_class(sig);
HDassert(cls);
/* Check for enough valid parameters */
- if(extra == 0 || extra2 == 0 || extra3 == 0) {
- HDfprintf(stderr, "ERROR: Need extensible array header address, super block index and object header address containing the layout message in order to dump super block\n");
+ if (extra_count == 0 || extra[0] == 0 || extra[1] == 0 || extra[2] == 0) {
+ HDfprintf(stderr, "ERROR: Need extensible array header address, super block index and object "
+ "header address containing the layout message in order to dump super block\n");
HDfprintf(stderr, "Extensible array super block usage:\n");
- HDfprintf(stderr, "\th5debug <filename> <super block address> <array header address> <super block index> <object header address>\n");
- HDexit(4);
+ HDfprintf(stderr, "\th5debug <filename> <super block address> <array header address> <super "
+ "block index> <object header address>\n");
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5EA__sblock_debug(f, addr, stdout, 0, VCOL, cls, extra, (unsigned)extra2, extra3);
-
+ status = H5EA__sblock_debug(f, addr, stdout, 0, VCOL, cls, extra[0], (unsigned)extra[1], extra[2]);
}
- else if(!HDmemcmp(sig, H5EA_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
+ else if (!HDmemcmp(sig, H5EA_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
- * Debug an extensible aray data block.
- */
+ * Debug an extensible array data block.
+ */
const H5EA_class_t *cls = get_H5EA_class(sig);
HDassert(cls);
/* Check for enough valid parameters */
- if(extra == 0 || extra2 == 0 || extra3 == 0) {
- HDfprintf(stderr, "ERROR: Need extensible array header address, # of elements in data block and object header address containing the layout message in order to dump data block\n");
+ if (extra_count == 0 || extra[0] == 0 || extra[1] == 0 || extra[2] == 0) {
+ HDfprintf(stderr,
+ "ERROR: Need extensible array header address, # of elements in data block and object "
+ "header address containing the layout message in order to dump data block\n");
HDfprintf(stderr, "Extensible array data block usage:\n");
- HDfprintf(stderr, "\th5debug <filename> <data block address> <array header address> <# of elements in data block> <object header address\n");
- HDexit(4);
+ HDfprintf(stderr, "\th5debug <filename> <data block address> <array header address> <# of "
+ "elements in data block> <object header address\n");
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5EA__dblock_debug(f, addr, stdout, 0, VCOL, cls, extra, (size_t)extra2, extra3);
-
+ status = H5EA__dblock_debug(f, addr, stdout, 0, VCOL, cls, extra[0], (size_t)extra[1], extra[2]);
}
- else if(!HDmemcmp(sig, H5FA_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
+ else if (!HDmemcmp(sig, H5FA_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
- * Debug a fixed array header.
- */
+ * Debug a fixed array header.
+ */
const H5FA_class_t *cls = get_H5FA_class(sig);
HDassert(cls);
/* Check for enough valid parameters */
- if(extra == 0) {
- HDfprintf(stderr, "ERROR: Need object header address containing the layout message in order to dump header\n");
+ if (extra_count == 0 || extra[0] == 0) {
+ HDfprintf(
+ stderr,
+ "ERROR: Need object header address containing the layout message in order to dump header\n");
HDfprintf(stderr, "Fixed array header block usage:\n");
HDfprintf(stderr, "\th5debug <filename> <Fixed Array header address> <object header address>\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5FA__hdr_debug(f, addr, stdout, 0, VCOL, cls, extra);
-
+ status = H5FA__hdr_debug(f, addr, stdout, 0, VCOL, cls, extra[0]);
}
- else if(!HDmemcmp(sig, H5FA_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
+ else if (!HDmemcmp(sig, H5FA_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
- * Debug a fixed array data block.
- */
+ * Debug a fixed array data block.
+ */
const H5FA_class_t *cls = get_H5FA_class(sig);
HDassert(cls);
/* Check for enough valid parameters */
- if(extra == 0 || extra2 == 0) {
- HDfprintf(stderr, "ERROR: Need fixed array header address and object header address containing the layout message in order to dump data block\n");
+ if (extra_count == 0 || extra[0] == 0 || extra[1] == 0) {
+ HDfprintf(stderr, "ERROR: Need fixed array header address and object header address containing "
+ "the layout message in order to dump data block\n");
HDfprintf(stderr, "fixed array data block usage:\n");
- HDfprintf(stderr, "\th5debug <filename> <data block address> <array header address> <object header address>\n");
- HDexit(4);
+ HDfprintf(
+ stderr,
+ "\th5debug <filename> <data block address> <array header address> <object header address>\n");
+ exit_value = 4;
+ goto done;
} /* end if */
- status = H5FA__dblock_debug(f, addr, stdout, 0, VCOL, cls, extra, extra2);
-
+ status = H5FA__dblock_debug(f, addr, stdout, 0, VCOL, cls, extra[0], extra[1]);
}
- else if(!HDmemcmp(sig, H5O_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
+ else if (!HDmemcmp(sig, H5O_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
- * Debug v2 object header (which have signatures).
- */
+ * Debug v2 object header (which have signatures).
+ */
status = H5O_debug(f, addr, stdout, 0, VCOL);
-
}
- else if(sig[0] == H5O_VERSION_1) {
+ else if (sig[0] == H5O_VERSION_1) {
/*
- * This could be a v1 object header. Since they don't have a signature
- * it's a somewhat "ify" detection.
- */
+ * This could be a v1 object header. Since they don't have a signature
+ * it's a somewhat "ify" detection.
+ */
status = H5O_debug(f, addr, stdout, 0, VCOL);
-
}
else {
/*
- * Got some other unrecognized signature.
- */
+ * Got some other unrecognized signature.
+ */
HDprintf("%-*s ", VCOL, "Signature:");
for (u = 0; u < sizeof(sig); u++) {
if (sig[u] > ' ' && sig[u] <= '~' && '\\' != sig[u])
@@ -732,24 +801,29 @@ main(int argc, char *argv[])
HDputchar('\n');
HDfprintf(stderr, "unknown signature\n");
- HDexit(4);
+ exit_value = 4;
+ goto done;
} /* end else */
/* Check for an error when dumping information */
- if(status < 0) {
+ if (status < 0) {
HDfprintf(stderr, "An error occurred!\n");
H5Eprint2(H5E_DEFAULT, stderr);
- HDexit(5);
+ exit_value = 5;
+ goto done;
} /* end if */
- H5Pclose(fapl);
- H5Fclose(fid);
+done:
+ if (fapl > 0)
+ H5Pclose(fapl);
+ if (fid > 0)
+ H5Fclose(fid);
/* Pop API context */
- if(api_ctx_pushed) H5CX_pop();
+ if (api_ctx_pushed)
+ H5CX_pop(FALSE);
H5Eset_auto2(H5E_DEFAULT, func, edata);
- return 0;
+ return exit_value;
} /* main() */
-
diff --git a/tools/src/misc/h5delete.c b/tools/src/misc/h5delete.c
new file mode 100644
index 0000000..20e81a1
--- /dev/null
+++ b/tools/src/misc/h5delete.c
@@ -0,0 +1,66 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/* h5delete tool
+ *
+ * Deletes storage via H5Fdelete() using the VOL connector specified in the
+ * environment variable.
+ */
+
+#include "H5private.h"
+#include "H5Eprivate.h"
+#include "H5Pprivate.h"
+
+static void usage(void);
+
+static void
+usage(void)
+{
+ HDfprintf(stderr, "Usage: h5delete [-f] <filename>\n");
+}
+
+int
+main(int argc, char *argv[])
+{
+ hbool_t quiet = FALSE;
+ const char *name = NULL;
+ int ret = 0;
+
+ switch (argc) {
+ case 3:
+ if (HDstrcmp(argv[1], "-f") != 0) {
+ usage();
+ return EXIT_FAILURE;
+ }
+ quiet = TRUE;
+ name = argv[2];
+ break;
+ case 2:
+ name = argv[1];
+ break;
+ default:
+ usage();
+ return EXIT_FAILURE;
+ }
+
+ H5E_BEGIN_TRY
+ {
+ /* Only uses the environment variable at this time */
+ ret = (int)H5Fdelete(name, H5P_DEFAULT);
+ }
+ H5E_END_TRY;
+
+ if (ret < 0 && !quiet)
+ HDfprintf(stderr, "Unable to delete storage at: %s\n", name);
+
+ return ret < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
+}
diff --git a/tools/src/misc/h5mkgrp.c b/tools/src/misc/h5mkgrp.c
index feb60d4..1b8b23d 100644
--- a/tools/src/misc/h5mkgrp.c
+++ b/tools/src/misc/h5mkgrp.c
@@ -6,12 +6,11 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
#include "H5private.h"
#include "h5tools.h"
#include "h5tools_utils.h"
@@ -23,28 +22,26 @@
int d_status = EXIT_SUCCESS;
/* command-line options: short and long-named parameters */
-static const char *s_opts = "hlpvV";
-static struct long_options l_opts[] = {
- { "help", no_arg, 'h' },
- { "latest", no_arg, 'l' },
- { "parents", no_arg, 'p' },
- { "verbose", no_arg, 'v' },
- { "version", no_arg, 'V' },
- { NULL, 0, '\0' }
-};
+static const char * s_opts = "hlpvV";
+static struct h5_long_options l_opts[] = {
+ {"help", no_arg, 'h'}, {"latest", no_arg, 'l'}, {"parents", no_arg, 'p'},
+ {"verbose", no_arg, 'v'}, {"version", no_arg, 'V'}, {"vol-value", require_arg, '1'},
+ {"vol-name", require_arg, '2'}, {"vol-info", require_arg, '3'}, {"vfd-value", require_arg, '4'},
+ {"vfd-name", require_arg, '5'}, {"vfd-info", require_arg, '6'}, {NULL, 0, '\0'}};
/* Command line parameter settings */
-typedef struct {
- char *fname; /* File name to operate on */
- hbool_t latest; /* Whether file should use latest format versions */
- hbool_t verbose; /* Whether output should be verbose */
- hbool_t parents; /* Whether to create intermediate groups */
- size_t ngroups; /* Number of groups to create */
- char **groups; /* Pointer to array of group names */
-} param_t;
-param_t params; /* Command line parameter settings */
-
-
+typedef struct mkgrp_opt_t {
+ char * fname; /* File name to operate on */
+ hbool_t latest; /* Whether file should use latest format versions */
+ hbool_t verbose; /* Whether output should be verbose */
+ hbool_t parents; /* Whether to create intermediate groups */
+ size_t ngroups; /* Number of groups to create */
+ char ** groups; /* Pointer to array of group names */
+ hid_t fapl_id; /* fapl to use when opening the file */
+} mkgrp_opt_t;
+
+mkgrp_opt_t params_g; /* Command line parameter settings */
+
/*-------------------------------------------------------------------------
* Function: leave
*
@@ -61,18 +58,21 @@ leave(int ret)
{
size_t curr_group;
- if (params.fname)
- HDfree (params.fname);
- if (params.ngroups) {
- for(curr_group = 0; curr_group < params.ngroups; curr_group++)
- HDfree (params.groups[curr_group]);
- HDfree (params.groups);
+ if (params_g.fname)
+ HDfree(params_g.fname);
+ if (params_g.ngroups) {
+ for (curr_group = 0; curr_group < params_g.ngroups; curr_group++)
+ HDfree(params_g.groups[curr_group]);
+ HDfree(params_g.groups);
}
+ if (H5I_INVALID_HID != params_g.fapl_id && H5P_DEFAULT != params_g.fapl_id)
+ if (H5Pclose(params_g.fapl_id) < 0)
+ error_msg("Could not close file access property list\n");
+
h5tools_close();
HDexit(ret);
} /* end leave() */
-
/*-------------------------------------------------------------------------
* Function: usage
*
@@ -85,65 +85,94 @@ leave(int ret)
*-------------------------------------------------------------------------
*/
static void
-usage(void)
+usage(const char *prog)
{
- HDfprintf(stdout, "\
-usage: h5mkgrp [OPTIONS] FILE GROUP...\n\
- OPTIONS\n\
- -h, --help Print a usage message and exit\n\
- -l, --latest Use latest version of file format to create groups\n\
- -p, --parents No error if existing, make parent groups as needed\n\
- -v, --verbose Print information about OBJECTS and OPTIONS\n\
- -V, --version Print version number and exit\n");
+ FLUSHSTREAM(rawoutstream);
+ PRINTSTREAM(rawoutstream, "usage: %s [OPTIONS] FILE GROUP...\n", prog);
+ PRINTVALSTREAM(rawoutstream, " OPTIONS\n");
+ PRINTVALSTREAM(rawoutstream, " -h, --help Print a usage message and exit\n");
+ PRINTVALSTREAM(rawoutstream,
+ " -l, --latest Use latest version of file format to create groups\n");
+ PRINTVALSTREAM(rawoutstream,
+ " -p, --parents No error if existing, make parent groups as needed\n");
+ PRINTVALSTREAM(rawoutstream, " -v, --verbose Print information about OBJECTS and OPTIONS\n");
+ PRINTVALSTREAM(rawoutstream, " -V, --version Print version number and exit\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --vol-value Value (ID) of the VOL connector to use for opening the\n");
+ PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --vol-name Name of the VOL connector to use for opening the\n");
+ PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --vol-info VOL-specific info to pass to the VOL connector used for\n");
+ PRINTVALSTREAM(rawoutstream, " opening the HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --vfd-value Value (ID) of the VFL driver to use for opening the\n");
+ PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream, " --vfd-name Name of the VFL driver to use for opening the\n");
+ PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream,
+ " --vfd-info VFD-specific info to pass to the VFL driver used for\n");
+ PRINTVALSTREAM(rawoutstream, " opening the HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream, "\n");
} /* end usage() */
-
/*-------------------------------------------------------------------------
- * Function: parse_command_line
+ * Function: parse_command_line
*
- * Purpose: Parses command line and sets up global variable to control output
+ * Purpose: Parses command line and sets up global variable to control
+ * output
*
- * Return: Success: 0
- * Failure: -1
+ * Return: Success: 0
+ * Failure: -1
*
* Programmer: Quincey Koziol, 2/13/2007
*
*-------------------------------------------------------------------------
*/
static int
-parse_command_line(int argc, const char *argv[], param_t *parms)
+parse_command_line(int argc, const char *const *argv, mkgrp_opt_t *options)
{
- int opt; /* Option from command line */
- size_t curr_group; /* Current group name to copy */
+ int opt; /* Option from command line */
+ size_t curr_group; /* Current group name to copy */
+ hbool_t custom_vol = FALSE;
+ hbool_t custom_vfd = FALSE;
+ h5tools_vol_info_t vol_info;
+ h5tools_vfd_info_t vfd_info;
+ hid_t tmp_fapl_id = H5I_INVALID_HID;
/* Check for empty command line */
- if(argc == 1) {
- usage();
+ if (argc == 1) {
+ usage(h5tools_getprogname());
leave(EXIT_SUCCESS);
- } /* end if */
+ }
+
+ /* Initialize fapl info structs */
+ HDmemset(&vol_info, 0, sizeof(h5tools_vol_info_t));
+ HDmemset(&vfd_info, 0, sizeof(h5tools_vfd_info_t));
/* Parse command line options */
- while((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) {
- switch((char)opt) {
+ while ((opt = H5_get_option(argc, argv, s_opts, l_opts)) != EOF) {
+ switch ((char)opt) {
/* Display 'help' */
case 'h':
- usage();
+ usage(h5tools_getprogname());
leave(EXIT_SUCCESS);
break;
/* Create objects with the latest version of the format */
case 'l':
- parms->latest = TRUE;
+ options->latest = TRUE;
break;
/* Create parent groups */
case 'p':
- parms->parents = TRUE;
+ options->parents = TRUE;
break;
/* Verbose output */
case 'v':
- parms->verbose = TRUE;
+ options->verbose = TRUE;
break;
/* Display version */
@@ -152,56 +181,96 @@ parse_command_line(int argc, const char *argv[], param_t *parms)
leave(EXIT_SUCCESS);
break;
+ case '1':
+ vol_info.type = VOL_BY_VALUE;
+ vol_info.u.value = (H5VL_class_value_t)HDatoi(H5_optarg);
+ custom_vol = TRUE;
+ break;
+
+ case '2':
+ vol_info.type = VOL_BY_NAME;
+ vol_info.u.name = H5_optarg;
+ custom_vol = TRUE;
+ break;
+
+ case '3':
+ vol_info.info_string = H5_optarg;
+ break;
+
+ case '4':
+ vfd_info.type = VFD_BY_VALUE;
+ vfd_info.u.value = (H5FD_class_value_t)HDatoi(H5_optarg);
+ custom_vfd = TRUE;
+ break;
+
+ case '5':
+ vfd_info.type = VFD_BY_NAME;
+ vfd_info.u.name = H5_optarg;
+ custom_vfd = TRUE;
+ break;
+
+ case '6':
+ vfd_info.info = (const void *)H5_optarg;
+ break;
+
/* Bad command line argument */
default:
- usage();
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
} /* end switch */
- } /* end while */
+ } /* end while */
/* Check for file name to be processed */
- if(argc <= opt_ind) {
+ if (argc <= H5_optind) {
error_msg("missing file name\n");
- usage();
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
- } /* end if */
+ }
/* Retrieve file name */
- parms->fname = HDstrdup(argv[opt_ind]);
- opt_ind++;
+ options->fname = HDstrdup(argv[H5_optind]);
+ H5_optind++;
/* Check for group(s) to be created */
- if(argc <= opt_ind) {
+ if (argc <= H5_optind) {
error_msg("missing group name(s)\n");
- usage();
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
- } /* end if */
+ }
/* Allocate space for the group name pointers */
- parms->ngroups = (size_t)(argc - opt_ind);
- parms->groups = (char **)HDmalloc(parms->ngroups * sizeof(char *));
+ options->ngroups = (size_t)(argc - H5_optind);
+ options->groups = (char **)HDmalloc(options->ngroups * sizeof(char *));
/* Retrieve the group names */
curr_group = 0;
- while(opt_ind < argc) {
- parms->groups[curr_group] = HDstrdup(argv[opt_ind]);
+ while (H5_optind < argc) {
+ options->groups[curr_group] = HDstrdup(argv[H5_optind]);
curr_group++;
- opt_ind++;
- } /* end while */
-
-#ifdef QAK
-HDfprintf(stderr, "parms->parents = %t\n", parms->parents);
-HDfprintf(stderr, "parms->verbose = %t\n", parms->verbose);
-HDfprintf(stderr, "parms->fname = '%s'\n", parms->fname);
-HDfprintf(stderr, "parms->ngroups = %Zu\n", parms->ngroups);
-for(curr_group = 0; curr_group < parms->ngroups; curr_group++)
- HDfprintf(stderr, "parms->group[%Zu] = '%s'\n", curr_group, parms->groups[curr_group]);
-#endif /* QAK */
-
- return(0);
+ H5_optind++;
+ }
+
+ /* Setup a custom fapl for file accesses */
+ if (custom_vol || custom_vfd) {
+ if ((tmp_fapl_id = h5tools_get_fapl(options->fapl_id, custom_vol ? &vol_info : NULL,
+ custom_vfd ? &vfd_info : NULL)) < 0) {
+ error_msg("failed to setup file access property list (fapl) for file\n");
+ leave(EXIT_FAILURE);
+ }
+
+ /* Close the old fapl */
+ if (options->fapl_id != H5P_DEFAULT)
+ if (H5Pclose(options->fapl_id) < 0) {
+ error_msg("failed to close file access property list (fapl)\n");
+ leave(EXIT_FAILURE);
+ }
+
+ options->fapl_id = tmp_fapl_id;
+ }
+
+ return 0;
} /* parse_command_line() */
-
/*-------------------------------------------------------------------------
* Function: main
*
@@ -212,120 +281,115 @@ for(curr_group = 0; curr_group < parms->ngroups; curr_group++)
*-------------------------------------------------------------------------
*/
int
-main(int argc, const char *argv[])
+main(int argc, char *argv[])
{
- hid_t fid; /* HDF5 file ID */
- hid_t fapl_id; /* File access property list ID */
- hid_t lcpl_id; /* Link creation property list ID */
- size_t curr_group; /* Current group to create */
+ hid_t fid = H5I_INVALID_HID; /* HDF5 file ID */
+ hid_t lcpl_id = H5I_INVALID_HID; /* Link creation property list ID */
+ size_t curr_group; /* Current group to create */
h5tools_setprogname(PROGRAMNAME);
h5tools_setstatus(EXIT_SUCCESS);
- /* Disable the HDF5 library's error reporting */
- H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
-
/* Initialize h5tools lib */
h5tools_init();
- /* Parse command line */
- HDmemset(&params, 0, sizeof(params));
- if(parse_command_line(argc, argv, &params) < 0) {
- error_msg("unable to parse command line arguments\n");
- leave(EXIT_FAILURE);
- } /* end if */
+ /* Initialize the parameters */
+ HDmemset(&params_g, 0, sizeof(params_g));
/* Create file access property list */
- if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
+ if ((params_g.fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
error_msg("Could not create file access property list\n");
leave(EXIT_FAILURE);
- } /* end if */
+ }
+
+ /* Parse command line */
+ if (parse_command_line(argc, (const char *const *)argv, &params_g) < 0) {
+ error_msg("unable to parse command line arguments\n");
+ leave(EXIT_FAILURE);
+ }
+
+ /* enable error reporting if command line option */
+ h5tools_error_report();
/* Check for creating groups with new format version */
- if(params.latest) {
+ if (params_g.latest) {
/* Set the "use the latest version of the format" bounds */
- if(H5Pset_libver_bounds(fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) {
+ if (H5Pset_libver_bounds(params_g.fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) {
error_msg("Could not set property for using latest version of the format\n");
leave(EXIT_FAILURE);
- } /* end if */
+ }
/* Display some output if requested */
- if(params.verbose)
+ if (params_g.verbose)
HDprintf("%s: Creating groups with latest version of the format\n", h5tools_getprogname());
- } /* end if */
+ }
/* Attempt to open an existing HDF5 file first */
- fid = h5tools_fopen(params.fname, H5F_ACC_RDWR, fapl_id, NULL, NULL, 0);
+ fid = h5tools_fopen(params_g.fname, H5F_ACC_RDWR, params_g.fapl_id, (params_g.fapl_id != H5P_DEFAULT),
+ NULL, 0);
/* If we couldn't open an existing file, try creating file */
/* (use "EXCL" instead of "TRUNC", so we don't blow away existing non-HDF5 file) */
- if(fid < 0)
- fid = H5Fcreate(params.fname, H5F_ACC_EXCL, H5P_DEFAULT, fapl_id);
+ if (fid < 0)
+ fid = H5Fcreate(params_g.fname, H5F_ACC_EXCL, H5P_DEFAULT, params_g.fapl_id);
/* Test for error in opening file */
- if(fid < 0) {
- error_msg("Could not open output file '%s'\n", params.fname);
+ if (fid < 0) {
+ error_msg("Could not open output file '%s'\n", params_g.fname);
leave(EXIT_FAILURE);
- } /* end if */
+ }
/* Create link creation property list */
- if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) {
+ if ((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) {
error_msg("Could not create link creation property list\n");
leave(EXIT_FAILURE);
- } /* end if */
+ }
/* Check for creating intermediate groups */
- if(params.parents) {
+ if (params_g.parents) {
/* Set the intermediate group creation property */
- if(H5Pset_create_intermediate_group(lcpl_id, TRUE) < 0) {
+ if (H5Pset_create_intermediate_group(lcpl_id, TRUE) < 0) {
error_msg("Could not set property for creating parent groups\n");
leave(EXIT_FAILURE);
- } /* end if */
+ }
/* Display some output if requested */
- if(params.verbose)
+ if (params_g.verbose)
HDprintf("%s: Creating parent groups\n", h5tools_getprogname());
- } /* end if */
+ }
/* Loop over creating requested groups */
- for(curr_group = 0; curr_group < params.ngroups; curr_group++) {
- hid_t gid; /* Group ID */
+ for (curr_group = 0; curr_group < params_g.ngroups; curr_group++) {
+ hid_t gid; /* Group ID */
/* Attempt to create a group */
- if((gid = H5Gcreate2(fid, params.groups[curr_group], lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
- error_msg("Could not create group '%s'\n", params.groups[curr_group]);
+ if ((gid = H5Gcreate2(fid, params_g.groups[curr_group], lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
+ error_msg("Could not create group '%s'\n", params_g.groups[curr_group]);
leave(EXIT_FAILURE);
- } /* end if */
+ }
/* Close the group */
- if(H5Gclose(gid) < 0) {
- error_msg("Could not close group '%s'??\n", params.groups[curr_group]);
+ if (H5Gclose(gid) < 0) {
+ error_msg("Could not close group '%s'??\n", params_g.groups[curr_group]);
leave(EXIT_FAILURE);
- } /* end if */
+ }
/* Display some output if requested */
- if(params.verbose)
- HDprintf("%s: created group '%s'\n", h5tools_getprogname(), params.groups[curr_group]);
+ if (params_g.verbose)
+ HDprintf("%s: created group '%s'\n", h5tools_getprogname(), params_g.groups[curr_group]);
} /* end for */
/* Close link creation property list */
- if(H5Pclose(lcpl_id) < 0) {
+ if (H5Pclose(lcpl_id) < 0) {
error_msg("Could not close link creation property list\n");
leave(EXIT_FAILURE);
- } /* end if */
+ }
/* Close file */
- if(H5Fclose(fid) < 0) {
- error_msg("Could not close output file '%s'??\n", params.fname);
- leave(EXIT_FAILURE);
- } /* end if */
-
- /* Close file access property list */
- if(H5Pclose(fapl_id) < 0) {
- error_msg("Could not close file access property list\n");
+ if (H5Fclose(fid) < 0) {
+ error_msg("Could not close output file '%s'??\n", params_g.fname);
leave(EXIT_FAILURE);
- } /* end if */
+ }
leave(EXIT_SUCCESS);
} /* end main() */
-
diff --git a/tools/src/misc/h5repart.c b/tools/src/misc/h5repart.c
index d516fa0..f4cef6a 100644
--- a/tools/src/misc/h5repart.c
+++ b/tools/src/misc/h5repart.c
@@ -6,13 +6,13 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Programmer: Robb Matzke <matzke@llnl.gov>
+ * Programmer: Robb Matzke
* Wednesday, May 13, 1998
*
* Purpose: Repartitions a file family. This program can be used to
@@ -26,16 +26,15 @@
#include "hdf5.h"
#include "H5private.h"
-#define NAMELEN 4096
-#define GB *1024*1024*1024
+#define NAMELEN 4096
+#define GB *1024 * 1024 * 1024
/* Make these 2 private properties(defined in H5Fprivate.h) available to h5repart.
* The first one updates the member file size in the superblock. The second one
* change file driver from family to a single file driver.
*/
-#define H5F_ACS_FAMILY_NEWSIZE_NAME "family_newsize"
-#define H5F_ACS_FAMILY_TO_SINGLE_NAME "family_to_single"
-
+#define H5F_ACS_FAMILY_NEWSIZE_NAME "family_newsize"
+#define H5F_ACS_FAMILY_TO_SINGLE_NAME "family_to_single"
/*-------------------------------------------------------------------------
* Function: usage
@@ -52,26 +51,26 @@
*-------------------------------------------------------------------------
*/
static void
-usage (const char *progname)
+usage(const char *progname)
{
HDfprintf(stderr, "usage: %s [-v] [-V] [-[b|m] N[g|m|k]] [-family_to_sec2|-family_to_single] SRC DST\n",
- progname);
+ progname);
HDfprintf(stderr, " -v Produce verbose output\n");
HDfprintf(stderr, " -V Print a version number and exit\n");
HDfprintf(stderr, " -b N The I/O block size, defaults to 1kB\n");
HDfprintf(stderr, " -m N The destination member size or 1GB\n");
HDfprintf(stderr, " -family_to_sec2 Deprecated version of -family_to_single (below)\n");
- HDfprintf(stderr, " -family_to_single Change file driver from family to the default single-file VFD (windows or sec2)\n");
+ HDfprintf(stderr, " -family_to_single Change file driver from family to the default single-file VFD "
+ "(windows or sec2)\n");
HDfprintf(stderr, " SRC The name of the source file\n");
HDfprintf(stderr, " DST The name of the destination files\n");
- HDfprintf(stderr, "Sizes may be suffixed with `g' for GB, `m' for MB or "
- "`k' for kB.\n");
+ HDfprintf(stderr, "Sizes may be suffixed with 'g' for GB, 'm' for MB or "
+ "'k' for kB.\n");
HDfprintf(stderr, "File family names include an integer printf "
- "format such as `%%d'\n");
- HDexit (EXIT_FAILURE);
+ "format such as '%%d'\n");
+ HDexit(EXIT_FAILURE);
}
-
/*-------------------------------------------------------------------------
* Function: get_size
*
@@ -95,48 +94,47 @@ usage (const char *progname)
*-------------------------------------------------------------------------
*/
static off_t
-get_size (const char *progname, int *argno, int argc, char *argv[])
+get_size(const char *progname, int *argno, int argc, char *argv[])
{
- off_t retval=-1;
- char *suffix;
+ off_t retval = -1;
+ char *suffix = NULL;
- if (isdigit ((int)(argv[*argno][2]))) {
- retval = HDstrtol(argv[*argno]+2, &suffix, 10);
+ if (isdigit((int)(argv[*argno][2]))) {
+ retval = HDstrtol(argv[*argno] + 2, &suffix, 10);
(*argno)++;
}
- else if (argv[*argno][2] || *argno+1>=argc) {
- usage (progname);
+ else if (argv[*argno][2] || *argno + 1 >= argc) {
+ usage(progname);
}
else {
- retval = HDstrtol(argv[*argno+1], &suffix, 0);
- if (suffix == argv[*argno+1])
- usage (progname);
+ retval = HDstrtol(argv[*argno + 1], &suffix, 0);
+ if (suffix == argv[*argno + 1])
+ usage(progname);
*argno += 2;
}
if (suffix && suffix[0] && !suffix[1]) {
switch (*suffix) {
- case 'G':
- case 'g':
- retval *= 1024 * 1024 * 1024;
- break;
- case 'M':
- case 'm':
- retval *= 1024 * 1024;
- break;
- case 'k':
- retval *= 1024;
- break;
- default:
- usage(progname);
+ case 'G':
+ case 'g':
+ retval *= 1024 * 1024 * 1024;
+ break;
+ case 'M':
+ case 'm':
+ retval *= 1024 * 1024;
+ break;
+ case 'k':
+ retval *= 1024;
+ break;
+ default:
+ usage(progname);
}
}
else if (suffix && suffix[0]) {
- usage (progname);
+ usage(progname);
}
return retval;
}
-
/*-------------------------------------------------------------------------
* Function: main
*
@@ -154,47 +152,47 @@ get_size (const char *progname, int *argno, int argc, char *argv[])
*-------------------------------------------------------------------------
*/
int
-main (int argc, char *argv[])
+main(int argc, char *argv[])
{
- const char *prog_name; /*program name */
- size_t blk_size=1024; /*size of each I/O block */
- char *buf=NULL; /*I/O block buffer */
- size_t n, i; /*counters */
- ssize_t nio; /*I/O return value */
- int argno=1; /*program argument number */
- int src, dst=-1; /*source & destination files */
- int need_seek=FALSE; /*destination needs to seek? */
- int need_write; /*data needs to be written? */
- h5_stat_t sb; /*temporary file stat buffer */
-
- int verbose=FALSE; /*display file names? */
-
- const char *src_gen_name; /*general source name */
- char *src_name=NULL; /*source member name */
-
- int src_is_family; /*is source name a family name? */
- int src_membno=0; /*source member number */
-
- const char *dst_gen_name; /*general destination name */
- char *dst_name=NULL; /*destination member name */
- int dst_is_family; /*is dst name a family name? */
- int dst_membno=0; /*destination member number */
-
- off_t left_overs=0; /*amount of zeros left over */
- off_t src_offset=0; /*offset in source member */
- off_t dst_offset=0; /*offset in destination member */
- off_t src_size; /*source logical member size */
- off_t src_act_size; /*source actual member size */
- off_t dst_size=1 GB; /*destination logical memb size */
- hid_t fapl; /*file access property list */
- hid_t file;
- hsize_t hdsize; /*destination logical memb size */
- hbool_t family_to_single = FALSE; /*change family to single file driver? */
+ const char *prog_name; /*program name */
+ size_t blk_size = 1024; /*size of each I/O block */
+ char * buf = NULL; /*I/O block buffer */
+ size_t n, i; /*counters */
+ ssize_t nio; /*I/O return value */
+ int argno = 1; /*program argument number */
+ int src, dst = -1; /*source & destination files */
+ int need_seek = FALSE; /*destination needs to seek? */
+ int need_write; /*data needs to be written? */
+ h5_stat_t sb; /*temporary file stat buffer */
+
+ int verbose = FALSE; /*display file names? */
+
+ const char *src_gen_name; /*general source name */
+ char * src_name = NULL; /*source member name */
+
+ int src_is_family; /*is source name a family name? */
+ int src_membno = 0; /*source member number */
+
+ const char *dst_gen_name; /*general destination name */
+ char * dst_name = NULL; /*destination member name */
+ int dst_is_family; /*is dst name a family name? */
+ int dst_membno = 0; /*destination member number */
+
+ off_t left_overs = 0; /*amount of zeros left over */
+ off_t src_offset = 0; /*offset in source member */
+ off_t dst_offset = 0; /*offset in destination member */
+ off_t src_size; /*source logical member size */
+ off_t src_act_size; /*source actual member size */
+ off_t dst_size = 1 GB; /*destination logical memb size */
+ hid_t fapl; /*file access property list */
+ hid_t file;
+ hsize_t hdsize; /*destination logical memb size */
+ hbool_t family_to_single = FALSE; /*change family to single file driver? */
/*
* Get the program name from argv[0]. Use only the last component.
*/
- if ((prog_name = HDstrrchr (argv[0], '/')))
+ if ((prog_name = HDstrrchr(argv[0], '/')))
prog_name++;
else
prog_name = argv[0];
@@ -206,28 +204,35 @@ main (int argc, char *argv[])
if (!HDstrcmp(argv[argno], "-v")) {
verbose = TRUE;
argno++;
- } else if (!HDstrcmp(argv[argno], "-V")) {
- HDprintf("This is %s version %u.%u release %u\n", prog_name, H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE);
+ }
+ else if (!HDstrcmp(argv[argno], "-V")) {
+ HDprintf("This is %s version %u.%u release %u\n", prog_name, H5_VERS_MAJOR, H5_VERS_MINOR,
+ H5_VERS_RELEASE);
HDexit(EXIT_SUCCESS);
- } else if (!HDstrcmp(argv[argno], "-family_to_sec2")) {
+ }
+ else if (!HDstrcmp(argv[argno], "-family_to_sec2")) {
family_to_single = TRUE;
argno++;
- } else if (!HDstrcmp(argv[argno], "-family_to_single")) {
+ }
+ else if (!HDstrcmp(argv[argno], "-family_to_single")) {
family_to_single = TRUE;
argno++;
- } else if ('b' == argv[argno][1]) {
- blk_size = (size_t) get_size(prog_name, &argno, argc, argv);
- } else if ('m' == argv[argno][1]) {
+ }
+ else if ('b' == argv[argno][1]) {
+ blk_size = (size_t)get_size(prog_name, &argno, argc, argv);
+ }
+ else if ('m' == argv[argno][1]) {
dst_size = get_size(prog_name, &argno, argc, argv);
- } else {
+ }
+ else {
usage(prog_name);
} /* end if */
- } /* end while */
+ } /* end while */
/* allocate names */
- if(NULL == (src_name = (char *)HDcalloc((size_t)NAMELEN, sizeof(char))))
+ if (NULL == (src_name = (char *)HDcalloc((size_t)NAMELEN, sizeof(char))))
HDexit(EXIT_FAILURE);
- if(NULL == (dst_name = (char *)HDcalloc((size_t)NAMELEN, sizeof(char))))
+ if (NULL == (dst_name = (char *)HDcalloc((size_t)NAMELEN, sizeof(char))))
HDexit(EXIT_FAILURE);
/*
@@ -238,7 +243,7 @@ main (int argc, char *argv[])
usage(prog_name);
src_gen_name = argv[argno++];
HDsprintf(src_name, src_gen_name, src_membno);
- src_is_family = strcmp (src_name, src_gen_name);
+ src_is_family = strcmp(src_name, src_gen_name);
if ((src = HDopen(src_name, O_RDONLY)) < 0) {
HDperror(src_name);
@@ -256,13 +261,13 @@ main (int argc, char *argv[])
/*
* Get the name for the destination file and open the first member.
*/
- if (argno>=argc)
- usage (prog_name);
+ if (argno >= argc)
+ usage(prog_name);
dst_gen_name = argv[argno++];
HDsprintf(dst_name, dst_gen_name, dst_membno);
dst_is_family = HDstrcmp(dst_name, dst_gen_name);
- if ((dst = HDopen(dst_name, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) {
+ if ((dst = HDopen(dst_name, O_RDWR | O_CREAT | O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) {
HDperror(dst_name);
HDexit(EXIT_FAILURE);
}
@@ -271,32 +276,32 @@ main (int argc, char *argv[])
/* No more arguments */
if (argno < argc)
- usage (prog_name);
+ usage(prog_name);
/* Now the real work, split the file */
buf = (char *)HDmalloc(blk_size);
- while (src_offset<src_size) {
+ while (src_offset < src_size) {
- /* Read a block. The amount to read is the minimum of:
- * 1. The I/O block size
- * 2. What's left to write in the destination member
- * 3. Left over zeros or what's left in the source member.
- */
+ /* Read a block. The amount to read is the minimum of:
+ * 1. The I/O block size
+ * 2. What's left to write in the destination member
+ * 3. Left over zeros or what's left in the source member.
+ */
n = blk_size;
if (dst_is_family)
- n = (size_t)MIN((off_t)n, dst_size-dst_offset);
+ n = (size_t)MIN((off_t)n, dst_size - dst_offset);
if (left_overs) {
- n = (size_t)MIN((off_t)n, left_overs);
- left_overs = left_overs - (off_t) n;
+ n = (size_t)MIN((off_t)n, left_overs);
+ left_overs = left_overs - (off_t)n;
need_write = FALSE;
}
else if (src_offset < src_act_size) {
- n = (size_t)MIN((off_t)n, src_act_size-src_offset);
+ n = (size_t)MIN((off_t)n, src_act_size - src_offset);
if ((nio = HDread(src, buf, n)) < 0) {
HDperror("read");
HDexit(EXIT_FAILURE);
}
- else if ((size_t) nio != n) {
+ else if ((size_t)nio != n) {
HDfprintf(stderr, "%s: short read\n", src_name);
HDexit(EXIT_FAILURE);
}
@@ -307,18 +312,18 @@ main (int argc, char *argv[])
need_write = (i < n);
}
else {
- n = 0;
+ n = 0;
left_overs = src_size - src_act_size;
need_write = FALSE;
}
- /*
- * If the block contains non-zero data then write it to the
- * destination, otherwise just remember that we'll have to do a seek
- * later in the destination when we finally get non-zero data.
- */
+ /*
+ * If the block contains non-zero data then write it to the
+ * destination, otherwise just remember that we'll have to do a seek
+ * later in the destination when we finally get non-zero data.
+ */
if (need_write) {
- if (need_seek && HDlseek (dst, dst_offset, SEEK_SET) < 0) {
+ if (need_seek && HDlseek(dst, dst_offset, SEEK_SET) < 0) {
HDperror("HDlseek");
HDexit(EXIT_FAILURE);
}
@@ -326,7 +331,7 @@ main (int argc, char *argv[])
HDperror("write");
HDexit(EXIT_FAILURE);
}
- else if ((size_t) nio != n) {
+ else if ((size_t)nio != n) {
HDfprintf(stderr, "%s: short write\n", dst_name);
HDexit(EXIT_FAILURE);
}
@@ -336,64 +341,64 @@ main (int argc, char *argv[])
need_seek = TRUE;
}
- /*
- * Update the source offset and open the next source family member if
- * necessary. The source stream ends at the first member which
- * cannot be opened because it doesn't exist. At the end of the
- * source stream, update the destination offset and break out of the
- * loop. The destination offset must be updated so we can fix
- * trailing holes.
- */
- src_offset = src_offset + (off_t) n;
+ /*
+ * Update the source offset and open the next source family member if
+ * necessary. The source stream ends at the first member which
+ * cannot be opened because it doesn't exist. At the end of the
+ * source stream, update the destination offset and break out of the
+ * loop. The destination offset must be updated so we can fix
+ * trailing holes.
+ */
+ src_offset = src_offset + (off_t)n;
if (src_offset == src_act_size) {
HDclose(src);
if (!src_is_family) {
- dst_offset = dst_offset + (off_t) n;
+ dst_offset = dst_offset + (off_t)n;
break;
}
HDsprintf(src_name, src_gen_name, ++src_membno);
if ((src = HDopen(src_name, O_RDONLY)) < 0 && ENOENT == errno) {
- dst_offset = dst_offset + (off_t) n;
+ dst_offset = dst_offset + (off_t)n;
break;
}
else if (src < 0) {
HDperror(src_name);
HDexit(EXIT_FAILURE);
}
- if (HDfstat (src, &sb) < 0) {
+ if (HDfstat(src, &sb) < 0) {
HDperror("fstat");
HDexit(EXIT_FAILURE);
}
src_act_size = sb.st_size;
if (src_act_size > src_size) {
- HDfprintf(stderr, "%s: member truncated to %lu bytes\n", src_name, (unsigned long) src_size);
+ HDfprintf(stderr, "%s: member truncated to %lu bytes\n", src_name, (unsigned long)src_size);
}
src_offset = 0;
if (verbose)
HDfprintf(stderr, "< %s\n", src_name);
}
- /*
- * Update the destination offset, opening a new member if one will be
- * needed. The first member is extended to the logical member size
- * but other members might be smaller if they end with a hole.
- */
- dst_offset = dst_offset + (off_t) n;
+ /*
+ * Update the destination offset, opening a new member if one will be
+ * needed. The first member is extended to the logical member size
+ * but other members might be smaller if they end with a hole.
+ */
+ dst_offset = dst_offset + (off_t)n;
if (dst_is_family && dst_offset == dst_size) {
if (0 == dst_membno) {
- if (HDlseek (dst, dst_size-1, SEEK_SET) < 0) {
+ if (HDlseek(dst, dst_size - 1, SEEK_SET) < 0) {
HDperror("HDHDlseek");
HDexit(EXIT_FAILURE);
}
- if (HDread (dst, buf, 1) < 0) {
+ if (HDread(dst, buf, 1) < 0) {
HDperror("read");
HDexit(EXIT_FAILURE);
}
- if (HDlseek (dst, dst_size-1, SEEK_SET) < 0) {
+ if (HDlseek(dst, dst_size - 1, SEEK_SET) < 0) {
HDperror("HDlseek");
HDexit(EXIT_FAILURE);
}
- if (HDwrite (dst, buf, 1) < 0) {
+ if (HDwrite(dst, buf, 1) < 0) {
HDperror("write");
HDexit(EXIT_FAILURE);
}
@@ -405,7 +410,7 @@ main (int argc, char *argv[])
HDexit(EXIT_FAILURE);
}
dst_offset = 0;
- need_seek = FALSE;
+ need_seek = FALSE;
if (verbose)
HDfprintf(stderr, "> %s\n", dst_name);
}
@@ -417,56 +422,56 @@ main (int argc, char *argv[])
* family has been truncated.
*/
if (need_seek) {
- if (HDlseek (dst, dst_offset-1, SEEK_SET)<0) {
- HDperror ("HDlseek");
- HDexit (EXIT_FAILURE);
+ if (HDlseek(dst, dst_offset - 1, SEEK_SET) < 0) {
+ HDperror("HDlseek");
+ HDexit(EXIT_FAILURE);
}
- if (HDread (dst, buf, 1)<0) {
- HDperror ("read");
- HDexit (EXIT_FAILURE);
+ if (HDread(dst, buf, 1) < 0) {
+ HDperror("read");
+ HDexit(EXIT_FAILURE);
}
- if (HDlseek (dst, dst_offset-1, SEEK_SET)<0) {
- HDperror ("HDlseek");
- HDexit (EXIT_FAILURE);
+ if (HDlseek(dst, dst_offset - 1, SEEK_SET) < 0) {
+ HDperror("HDlseek");
+ HDexit(EXIT_FAILURE);
}
- if (HDwrite (dst, buf, 1)<0) {
- HDperror ("write");
- HDexit (EXIT_FAILURE);
+ if (HDwrite(dst, buf, 1) < 0) {
+ HDperror("write");
+ HDexit(EXIT_FAILURE);
}
}
- HDclose (dst);
+ HDclose(dst);
/* Modify family driver information saved in superblock through private property.
* These private properties are for this tool only. */
- if ((fapl=H5Pcreate(H5P_FILE_ACCESS)) < 0) {
- HDperror ("H5Pcreate");
- HDexit (EXIT_FAILURE);
+ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
+ HDperror("H5Pcreate");
+ HDexit(EXIT_FAILURE);
}
- if(family_to_single) {
+ if (family_to_single) {
/* The user wants to change file driver from family to a single-file VFD.
* Open the file with the sec2, windows, etc. driver. This property signals
* the library to ignore the family driver information saved in the superblock.
*/
- if(H5Pset(fapl, H5F_ACS_FAMILY_TO_SINGLE_NAME, &family_to_single) < 0) {
- HDperror ("H5Pset");
- HDexit (EXIT_FAILURE);
+ if (H5Pset(fapl, H5F_ACS_FAMILY_TO_SINGLE_NAME, &family_to_single) < 0) {
+ HDperror("H5Pset");
+ HDexit(EXIT_FAILURE);
}
}
else {
/* Modify family size saved in superblock through private property. It signals
* library to save the new member size(specified in command line) in superblock.
* This private property is for this tool only. */
- if(H5Pset_fapl_family(fapl, H5F_FAMILY_DEFAULT, H5P_DEFAULT) < 0) {
- HDperror ("H5Pset_fapl_family");
- HDexit (EXIT_FAILURE);
+ if (H5Pset_fapl_family(fapl, H5F_FAMILY_DEFAULT, H5P_DEFAULT) < 0) {
+ HDperror("H5Pset_fapl_family");
+ HDexit(EXIT_FAILURE);
}
/* Set the property of the new member size as hsize_t */
hdsize = (hsize_t)dst_size;
- if(H5Pset(fapl, H5F_ACS_FAMILY_NEWSIZE_NAME, &hdsize) < 0) {
- HDperror ("H5Pset");
- HDexit (EXIT_FAILURE);
+ if (H5Pset(fapl, H5F_ACS_FAMILY_NEWSIZE_NAME, &hdsize) < 0) {
+ HDperror("H5Pset");
+ HDexit(EXIT_FAILURE);
}
}
@@ -478,18 +483,20 @@ main (int argc, char *argv[])
* file and the new file can only be a single file, reopen the new file should fail.
* There's nothing to do in this case.
*/
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
file = H5Fopen(dst_gen_name, H5F_ACC_RDWR, fapl);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
- if(file >= 0) {
- if(H5Fclose(file) < 0) {
+ if (file >= 0) {
+ if (H5Fclose(file) < 0) {
HDperror("H5Fclose");
HDexit(EXIT_FAILURE);
} /* end if */
- } /* end if */
+ } /* end if */
- if(H5Pclose(fapl) < 0) {
+ if (H5Pclose(fapl) < 0) {
HDperror("H5Pclose");
HDexit(EXIT_FAILURE);
} /* end if */