summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/CMakeLists.txt118
-rw-r--r--tools/lib/Makefile.am15
-rw-r--r--tools/lib/Makefile.in940
-rw-r--r--tools/lib/h5diff.c2610
-rw-r--r--tools/lib/h5diff.h414
-rw-r--r--tools/lib/h5diff_array.c8231
-rw-r--r--tools/lib/h5diff_attr.c793
-rw-r--r--tools/lib/h5diff_dset.c1712
-rw-r--r--tools/lib/h5diff_util.c462
-rw-r--r--tools/lib/h5tools.c2726
-rw-r--r--tools/lib/h5tools.h505
-rw-r--r--tools/lib/h5tools_dump.c5035
-rw-r--r--tools/lib/h5tools_dump.h107
-rw-r--r--tools/lib/h5tools_error.h274
-rw-r--r--tools/lib/h5tools_filters.c354
-rw-r--r--tools/lib/h5tools_ref.c243
-rw-r--r--tools/lib/h5tools_ref.h24
-rw-r--r--tools/lib/h5tools_str.c2008
-rw-r--r--tools/lib/h5tools_str.h65
-rw-r--r--tools/lib/h5tools_type.c273
-rw-r--r--tools/lib/h5tools_utils.c1187
-rw-r--r--tools/lib/h5tools_utils.h168
-rw-r--r--tools/lib/h5trav.c1183
-rw-r--r--tools/lib/h5trav.h127
-rw-r--r--tools/lib/io_timer.c226
-rw-r--r--tools/lib/io_timer.h69
-rw-r--r--tools/lib/ph5diff.h52
27 files changed, 14284 insertions, 15637 deletions
diff --git a/tools/lib/CMakeLists.txt b/tools/lib/CMakeLists.txt
index 837a14e..7d139ee 100644
--- a/tools/lib/CMakeLists.txt
+++ b/tools/lib/CMakeLists.txt
@@ -1,11 +1,11 @@
-cmake_minimum_required (VERSION 2.8.6)
-PROJECT (HDF5_TOOLS_LIB)
+cmake_minimum_required (VERSION 3.18)
+project (HDF5_TOOLS_LIB C)
#-----------------------------------------------------------------------------
# Define Sources
#-----------------------------------------------------------------------------
-SET (H5_TOOLS_LIB_SRCS
+set (H5_TOOLS_LIB_SOURCES
${HDF5_TOOLS_LIB_SOURCE_DIR}/h5diff.c
${HDF5_TOOLS_LIB_SOURCE_DIR}/h5diff_array.c
${HDF5_TOOLS_LIB_SOURCE_DIR}/h5diff_attr.c
@@ -19,28 +19,74 @@ SET (H5_TOOLS_LIB_SRCS
${HDF5_TOOLS_LIB_SOURCE_DIR}/h5tools_type.c
${HDF5_TOOLS_LIB_SOURCE_DIR}/h5tools_utils.c
${HDF5_TOOLS_LIB_SOURCE_DIR}/h5trav.c
+ ${HDF5_TOOLS_LIB_SOURCE_DIR}/io_timer.c
)
-SET (H5_TOOLS_LIB_HDRS
+set (H5_TOOLS_LIB_HDRS
${HDF5_TOOLS_LIB_SOURCE_DIR}/h5trav.h
${HDF5_TOOLS_LIB_SOURCE_DIR}/h5tools.h
${HDF5_TOOLS_LIB_SOURCE_DIR}/h5tools_dump.h
+ ${HDF5_TOOLS_LIB_SOURCE_DIR}/h5tools_error.h
${HDF5_TOOLS_LIB_SOURCE_DIR}/h5tools_utils.h
${HDF5_TOOLS_LIB_SOURCE_DIR}/h5tools_str.h
${HDF5_TOOLS_LIB_SOURCE_DIR}/h5tools_ref.h
${HDF5_TOOLS_LIB_SOURCE_DIR}/h5diff.h
+ ${HDF5_TOOLS_LIB_SOURCE_DIR}/io_timer.h
)
-ADD_LIBRARY (${HDF5_TOOLS_LIB_TARGET} ${LIB_TYPE} ${H5_TOOLS_LIB_SRCS} ${H5_TOOLS_LIB_HDRS})
-TARGET_LINK_LIBRARIES (${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
-SET_GLOBAL_VARIABLE( HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_TOOLS_LIB_TARGET}")
-H5_SET_LIB_OPTIONS (
- ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TOOLS_LIB_NAME}
- ${LIB_TYPE}
- HDF5_TOOLS_LIB_NAME_RELEASE
- HDF5_TOOLS_LIB_NAME_DEBUG
-)
-SET_TARGET_PROPERTIES (hdf5_tools PROPERTIES FOLDER libraries/tools)
+if (NOT ONLY_SHARED_LIBS)
+ add_library (${HDF5_TOOLS_LIB_TARGET} STATIC ${H5_TOOLS_LIB_SOURCES} ${H5_TOOLS_LIB_HDRS})
+ target_include_directories (${HDF5_TOOLS_LIB_TARGET}
+ PRIVATE "${HDF5_TOOLS_LIB_SOURCE_DIR};${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>"
+ INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
+ )
+ target_compile_options(${HDF5_TOOLS_LIB_TARGET} PRIVATE "${HDF5_CMAKE_C_FLAGS}")
+ #target_compile_definitions(${HDF5_TOOLS_LIB_TARGET} PRIVATE H5_TOOLS_DEBUG)
+ #target_compile_definitions(${HDF5_TOOLS_LIB_TARGET} PRIVATE H5DIFF_DEBUG)
+ TARGET_C_PROPERTIES (${HDF5_TOOLS_LIB_TARGET} STATIC)
+ target_link_libraries (${HDF5_TOOLS_LIB_TARGET}
+ PUBLIC ${HDF5_LIB_TARGET}
+ PRIVATE "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:MPI::MPI_C>"
+ )
+ set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_TOOLS_LIB_TARGET}")
+ H5_SET_LIB_OPTIONS (${HDF5_TOOLS_LIB_TARGET} ${HDF5_TOOLS_LIB_NAME} STATIC 0)
+ set_target_properties (${HDF5_TOOLS_LIB_TARGET} PROPERTIES FOLDER libraries/tools)
+ set (install_targets ${HDF5_TOOLS_LIB_TARGET})
+endif ()
+
+if (BUILD_SHARED_LIBS)
+ add_library (${HDF5_TOOLS_LIBSH_TARGET} SHARED ${H5_TOOLS_LIB_SOURCES} ${H5_TOOLS_LIB_HDRS})
+ target_include_directories (${HDF5_TOOLS_LIBSH_TARGET}
+ PRIVATE "${HDF5_TOOLS_LIB_SOURCE_DIR};${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>"
+ INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
+ )
+ target_compile_options(${HDF5_TOOLS_LIBSH_TARGET} PRIVATE "${HDF5_CMAKE_C_FLAGS}")
+ target_compile_definitions(${HDF5_TOOLS_LIBSH_TARGET}
+ PUBLIC "H5_BUILT_AS_DYNAMIC_LIB"
+ #PRIVATE H5_TOOLS_DEBUG
+ #PRIVATE H5DIFF_DEBUG
+ )
+ TARGET_C_PROPERTIES (${HDF5_TOOLS_LIBSH_TARGET} SHARED)
+ target_link_libraries (${HDF5_TOOLS_LIBSH_TARGET}
+ PUBLIC ${HDF5_LIBSH_TARGET}
+ PRIVATE "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:MPI::MPI_C>"
+ )
+ set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_TOOLS_LIBSH_TARGET}")
+ H5_SET_LIB_OPTIONS (${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_TOOLS_LIB_NAME} SHARED "TOOLS")
+ set_target_properties (${HDF5_TOOLS_LIBSH_TARGET} PROPERTIES FOLDER libraries/tools)
+ set (install_targets ${install_targets} ${HDF5_TOOLS_LIBSH_TARGET})
+endif ()
+
+#-----------------------------------------------------------------------------
+# Add Target to clang-format
+#-----------------------------------------------------------------------------
+if (HDF5_ENABLE_FORMATTERS)
+ if (NOT ONLY_SHARED_LIBS)
+ clang_format (HDF5_TOOLS_SRC_FORMAT ${HDF5_TOOLS_LIB_TARGET})
+ else ()
+ clang_format (HDF5_TOOLS_SRC_FORMAT ${HDF5_TOOLS_LIBSH_TARGET})
+ endif ()
+endif ()
##############################################################################
##############################################################################
@@ -49,43 +95,25 @@ SET_TARGET_PROPERTIES (hdf5_tools PROPERTIES FOLDER libraries/tools)
##############################################################################
#-----------------------------------------------------------------------------
-# Add file(s) to CMake Install
-#-----------------------------------------------------------------------------
-INSTALL (
- FILES
- ${H5_TOOLS_LIB_HDRS}
- DESTINATION
- ${HDF5_INSTALL_INCLUDE_DIR}
- COMPONENT
- toolsheaders
-)
-
-#-----------------------------------------------------------------------------
-# Because tools are installed into bin/tools we need to make sure the hdf5tools
-# library will be installed into the proper location.
-#-----------------------------------------------------------------------------
-IF (APPLE)
- OPTION (HDF5_BUILD_WITH_INSTALL_NAME "Build with library install_name set to the installation path" OFF)
- IF (HDF5_BUILD_WITH_INSTALL_NAME)
- SET_TARGET_PROPERTIES(${HDF5_TOOLS_LIB_TARGET} PROPERTIES
- LINK_FLAGS "-current_version ${HDF5_PACKAGE_VERSION} -compatibility_version ${HDF5_PACKAGE_VERSION}"
- INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib"
- BUILD_WITH_INSTALL_RPATH ${HDF5_BUILD_WITH_INSTALL_NAME}
- )
- ENDIF (HDF5_BUILD_WITH_INSTALL_NAME)
-ENDIF (APPLE)
-
-#-----------------------------------------------------------------------------
# Add Target(s) to CMake Install for import into other projects
#-----------------------------------------------------------------------------
-IF (HDF5_EXPORTED_TARGETS)
- INSTALL (
+if (HDF5_EXPORTED_TARGETS)
+ if (BUILD_SHARED_LIBS)
+ INSTALL_TARGET_PDB (${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_INSTALL_BIN_DIR} toolslibraries)
+ endif ()
+ if (NOT ONLY_SHARED_LIBS)
+ INSTALL_TARGET_PDB (${HDF5_TOOLS_LIB_TARGET} ${HDF5_INSTALL_LIB_DIR} toolslibraries)
+ endif ()
+
+ install (
TARGETS
- ${HDF5_TOOLS_LIB_TARGET}
+ ${install_targets}
EXPORT
${HDF5_EXPORTED_TARGETS}
LIBRARY DESTINATION ${HDF5_INSTALL_LIB_DIR} COMPONENT toolslibraries
ARCHIVE DESTINATION ${HDF5_INSTALL_LIB_DIR} COMPONENT toolslibraries
RUNTIME DESTINATION ${HDF5_INSTALL_BIN_DIR} COMPONENT toolslibraries
+ FRAMEWORK DESTINATION ${HDF5_INSTALL_FWRK_DIR} COMPONENT toolslibraries
+ INCLUDES DESTINATION include
)
-ENDIF (HDF5_EXPORTED_TARGETS)
+endif ()
diff --git a/tools/lib/Makefile.am b/tools/lib/Makefile.am
index e364b47..12427d9 100644
--- a/tools/lib/Makefile.am
+++ b/tools/lib/Makefile.am
@@ -1,16 +1,13 @@
#
# 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 files COPYING and Copyright.html. COPYING can be found at the root
-# of the source code distribution tree; Copyright.html can be found at the
-# root level of an installed copy of the electronic HDF5 document set and
-# is linked from the top-level documents page. It can also be found at
-# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have
-# access to either file, you may request a copy from help@hdfgroup.org.
+# 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.
@@ -21,14 +18,14 @@
include $(top_srcdir)/config/commence.am
# Include files in /src directory
-INCLUDES=-I$(top_srcdir)/src
+AM_CPPFLAGS+=-I$(top_srcdir)/src
# This is our main target, the h5tools library.
noinst_LTLIBRARIES=libh5tools.la
libh5tools_la_SOURCES=h5tools.c h5tools_dump.c h5tools_str.c h5tools_utils.c h5diff.c \
h5diff_array.c h5diff_attr.c h5diff_dset.c h5diff_util.c h5trav.c \
- h5tools_filters.c h5tools_ref.c h5tools_type.c
+ h5tools_filters.c h5tools_ref.c h5tools_type.c io_timer.c
# Test program. Link using libhdf5 and libh5tools
TEST_PROG=
diff --git a/tools/lib/Makefile.in b/tools/lib/Makefile.in
deleted file mode 100644
index beeb42f..0000000
--- a/tools/lib/Makefile.in
+++ /dev/null
@@ -1,940 +0,0 @@
-# Makefile.in generated by automake 1.11.1 from Makefile.am.
-# @configure_input@
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
-# Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
-@SET_MAKE@
-
-#
-# 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 files COPYING and Copyright.html. COPYING can be found at the root
-# of the source code distribution tree; Copyright.html can be found at the
-# root level of an installed copy of the electronic HDF5 document set and
-# is linked from the top-level documents page. It can also be found at
-# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have
-# access to either file, you may request a copy from help@hdfgroup.org.
-#
-# HDF5 Library Makefile(.in)
-#
-
-VPATH = @srcdir@
-pkgdatadir = $(datadir)/@PACKAGE@
-pkgincludedir = $(includedir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
-pkglibexecdir = $(libexecdir)/@PACKAGE@
-am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
-install_sh_DATA = $(install_sh) -c -m 644
-install_sh_PROGRAM = $(install_sh) -c
-install_sh_SCRIPT = $(install_sh) -c
-INSTALL_HEADER = $(INSTALL_DATA)
-transform = $(program_transform_name)
-NORMAL_INSTALL = :
-PRE_INSTALL = :
-POST_INSTALL = :
-NORMAL_UNINSTALL = :
-PRE_UNINSTALL = :
-POST_UNINSTALL = :
-build_triplet = @build@
-host_triplet = @host@
-DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
- $(top_srcdir)/config/commence.am \
- $(top_srcdir)/config/conclude.am
-check_PROGRAMS = $(am__EXEEXT_1)
-TESTS = $(check_PROGRAMS)
-subdir = tools/lib
-ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/configure.in
-am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
- $(ACLOCAL_M4)
-mkinstalldirs = $(SHELL) $(top_srcdir)/bin/mkinstalldirs
-CONFIG_HEADER = $(top_builddir)/src/H5config.h
-CONFIG_CLEAN_FILES =
-CONFIG_CLEAN_VPATH_FILES =
-LTLIBRARIES = $(noinst_LTLIBRARIES)
-libh5tools_la_LIBADD =
-am_libh5tools_la_OBJECTS = h5tools.lo h5tools_dump.lo h5tools_str.lo \
- h5tools_utils.lo h5diff.lo h5diff_array.lo h5diff_attr.lo \
- h5diff_dset.lo h5diff_util.lo h5trav.lo h5tools_filters.lo \
- h5tools_ref.lo h5tools_type.lo
-libh5tools_la_OBJECTS = $(am_libh5tools_la_OBJECTS)
-AM_V_lt = $(am__v_lt_$(V))
-am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
-am__v_lt_0 = --silent
-am__EXEEXT_1 =
-DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
-depcomp = $(SHELL) $(top_srcdir)/bin/depcomp
-am__depfiles_maybe = depfiles
-am__mv = mv -f
-COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
- $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
- $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
- $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
- $(AM_CFLAGS) $(CFLAGS)
-AM_V_CC = $(am__v_CC_$(V))
-am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
-am__v_CC_0 = @echo " CC " $@;
-AM_V_at = $(am__v_at_$(V))
-am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
-am__v_at_0 = @
-CCLD = $(CC)
-LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
- $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
- $(AM_LDFLAGS) $(LDFLAGS) -o $@
-AM_V_CCLD = $(am__v_CCLD_$(V))
-am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
-am__v_CCLD_0 = @echo " CCLD " $@;
-AM_V_GEN = $(am__v_GEN_$(V))
-am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
-am__v_GEN_0 = @echo " GEN " $@;
-SOURCES = $(libh5tools_la_SOURCES)
-DIST_SOURCES = $(libh5tools_la_SOURCES)
-ETAGS = etags
-CTAGS = ctags
-am__tty_colors = \
-red=; grn=; lgn=; blu=; std=
-DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-ACLOCAL = /home1/packages/automake/automake-1.9.6/bin/aclocal-1.9 -I /afs/ncsa/projects/hdf/packages/libtool_1.5.14/Linux_2.4/share/aclocal
-ADD_PARALLEL_FILES = @ADD_PARALLEL_FILES@
-AMTAR = @AMTAR@
-
-# H5_CFLAGS holds flags that should be used when building hdf5,
-# but which should not be exported to h5cc for building other programs.
-# AM_CFLAGS is an automake construct which should be used by Makefiles
-# instead of CFLAGS, as CFLAGS is reserved solely for the user to define.
-# This applies to FCFLAGS, CXXFLAGS, CPPFLAGS, and LDFLAGS as well.
-AM_CFLAGS = @AM_CFLAGS@ @H5_CFLAGS@
-AM_CPPFLAGS = @AM_CPPFLAGS@ @H5_CPPFLAGS@
-AM_CXXFLAGS = @AM_CXXFLAGS@ @H5_CXXFLAGS@
-AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
-AM_FCFLAGS = @AM_FCFLAGS@ @H5_FCFLAGS@
-AM_LDFLAGS = @AM_LDFLAGS@ @H5_LDFLAGS@
-AM_MAKEFLAGS = @AM_MAKEFLAGS@
-AR = @AR@
-AS = @AS@
-
-# Set the paths for AFS installs of autotools for Linux machines
-# Ideally, these tools should never be needed during the build.
-AUTOCONF = /home1/packages/autoconf/autoconf-2.60/bin/autoconf
-AUTOHEADER = /home1/packages/autoconf/autoconf-2.60/bin/autoheader
-AUTOMAKE = /home1/packages/automake/automake-1.9.6/bin/automake-1.9
-AWK = @AWK@
-BYTESEX = @BYTESEX@
-CC = @CC@
-CCDEPMODE = @CCDEPMODE@
-CC_VERSION = @CC_VERSION@
-CFLAGS = @CFLAGS@
-CLEARFILEBUF = @CLEARFILEBUF@
-CODESTACK = @CODESTACK@
-CONFIG_DATE = @CONFIG_DATE@
-CONFIG_MODE = @CONFIG_MODE@
-CONFIG_USER = @CONFIG_USER@
-CPP = @CPP@
-CPPFLAGS = @CPPFLAGS@
-CXX = @CXX@
-CXXCPP = @CXXCPP@
-CXXDEPMODE = @CXXDEPMODE@
-CXXFLAGS = @CXXFLAGS@
-CXX_VERSION = @CXX_VERSION@
-CYGPATH_W = @CYGPATH_W@
-DEBUG_PKG = @DEBUG_PKG@
-DEFAULT_API_VERSION = @DEFAULT_API_VERSION@
-DEFS = @DEFS@
-DEPDIR = @DEPDIR@
-DEPRECATED_SYMBOLS = @DEPRECATED_SYMBOLS@
-DIRECT_VFD = @DIRECT_VFD@
-DLLTOOL = @DLLTOOL@
-DSYMUTIL = @DSYMUTIL@
-DUMPBIN = @DUMPBIN@
-DYNAMIC_DIRS = @DYNAMIC_DIRS@
-ECHO_C = @ECHO_C@
-ECHO_N = @ECHO_N@
-ECHO_T = @ECHO_T@
-EGREP = @EGREP@
-EXEEXT = @EXEEXT@
-EXTERNAL_FILTERS = @EXTERNAL_FILTERS@
-
-# Make sure that these variables are exported to the Makefiles
-F9XMODEXT = @F9XMODEXT@
-F9XMODFLAG = @F9XMODFLAG@
-F9XSUFFIXFLAG = @F9XSUFFIXFLAG@
-FC = @FC@
-FC2003 = @FC2003@
-FCFLAGS = @FCFLAGS@
-FCFLAGS_f90 = @FCFLAGS_f90@
-FCLIBS = @FCLIBS@
-FC_VERSION = @FC_VERSION@
-FGREP = @FGREP@
-FILTERS = @FILTERS@
-FSEARCH_DIRS = @FSEARCH_DIRS@
-GPFS = @GPFS@
-GREP = @GREP@
-H5_CFLAGS = @H5_CFLAGS@
-H5_CPPFLAGS = @H5_CPPFLAGS@
-H5_CXXFLAGS = @H5_CXXFLAGS@
-H5_CXX_SHARED = @H5_CXX_SHARED@
-H5_FCFLAGS = @H5_FCFLAGS@
-H5_FORTRAN_SHARED = @H5_FORTRAN_SHARED@
-H5_LDFLAGS = @H5_LDFLAGS@
-H5_LONE_COLON = @H5_LONE_COLON@
-H5_VERSION = @H5_VERSION@
-HADDR_T = @HADDR_T@
-HAVE_DMALLOC = @HAVE_DMALLOC@
-HAVE_FORTRAN_2003 = @HAVE_FORTRAN_2003@
-HDF5_HL = @HDF5_HL@
-HDF5_INTERFACES = @HDF5_INTERFACES@
-HDF_CXX = @HDF_CXX@
-HDF_FORTRAN = @HDF_FORTRAN@
-HDF_FORTRAN2003 = @HDF_FORTRAN2003@
-HID_T = @HID_T@
-HL = @HL@
-HL_FOR = @HL_FOR@
-HSIZE_T = @HSIZE_T@
-HSSIZE_T = @HSSIZE_T@
-INSTALL = @INSTALL@
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-INSTRUMENT = @INSTRUMENT@
-INSTRUMENT_LIBRARY = @INSTRUMENT_LIBRARY@
-LARGEFILE = @LARGEFILE@
-LD = @LD@
-LDFLAGS = @LDFLAGS@
-LIBOBJS = @LIBOBJS@
-LIBS = @LIBS@
-LIBTOOL = @LIBTOOL@
-LIPO = @LIPO@
-LL_PATH = @LL_PATH@
-LN_S = @LN_S@
-LTLIBOBJS = @LTLIBOBJS@
-LT_STATIC_EXEC = @LT_STATIC_EXEC@
-MAINT = @MAINT@
-MAKEINFO = @MAKEINFO@
-MANIFEST_TOOL = @MANIFEST_TOOL@
-MKDIR_P = @MKDIR_P@
-MPE = @MPE@
-MPI_GET_SIZE = @MPI_GET_SIZE@
-NM = @NM@
-NMEDIT = @NMEDIT@
-OBJDUMP = @OBJDUMP@
-OBJECT_NAMELEN_DEFAULT_F = @OBJECT_NAMELEN_DEFAULT_F@
-OBJEXT = @OBJEXT@
-OTOOL = @OTOOL@
-OTOOL64 = @OTOOL64@
-PACKAGE = @PACKAGE@
-PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
-PACKAGE_NAME = @PACKAGE_NAME@
-PACKAGE_STRING = @PACKAGE_STRING@
-PACKAGE_TARNAME = @PACKAGE_TARNAME@
-PACKAGE_URL = @PACKAGE_URL@
-PACKAGE_VERSION = @PACKAGE_VERSION@
-PARALLEL = @PARALLEL@
-PATH_SEPARATOR = @PATH_SEPARATOR@
-PERL = @PERL@
-PTHREAD = @PTHREAD@
-RANLIB = @RANLIB@
-ROOT = @ROOT@
-RUNPARALLEL = @RUNPARALLEL@
-RUNSERIAL = @RUNSERIAL@
-R_INTEGER = @R_INTEGER@
-R_LARGE = @R_LARGE@
-SEARCH = @SEARCH@
-SED = @SED@
-SETX = @SETX@
-SET_MAKE = @SET_MAKE@
-SHELL = @SHELL@
-SIZE_T = @SIZE_T@
-STATIC_EXEC = @STATIC_EXEC@
-STATIC_SHARED = @STATIC_SHARED@
-STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@
-STRIP = @STRIP@
-TESTPARALLEL = @TESTPARALLEL@
-THREADSAFE = @THREADSAFE@
-TIME = @TIME@
-TR = @TR@
-TRACE_API = @TRACE_API@
-UNAME_INFO = @UNAME_INFO@
-USE_FILTER_DEFLATE = @USE_FILTER_DEFLATE@
-USE_FILTER_FLETCHER32 = @USE_FILTER_FLETCHER32@
-USE_FILTER_NBIT = @USE_FILTER_NBIT@
-USE_FILTER_SCALEOFFSET = @USE_FILTER_SCALEOFFSET@
-USE_FILTER_SHUFFLE = @USE_FILTER_SHUFFLE@
-USE_FILTER_SZIP = @USE_FILTER_SZIP@
-USINGMEMCHECKER = @USINGMEMCHECKER@
-VERSION = @VERSION@
-WORDS_BIGENDIAN = @WORDS_BIGENDIAN@
-abs_builddir = @abs_builddir@
-abs_srcdir = @abs_srcdir@
-abs_top_builddir = @abs_top_builddir@
-abs_top_srcdir = @abs_top_srcdir@
-ac_ct_AR = @ac_ct_AR@
-ac_ct_CC = @ac_ct_CC@
-ac_ct_CXX = @ac_ct_CXX@
-ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
-ac_ct_FC = @ac_ct_FC@
-am__include = @am__include@
-am__leading_dot = @am__leading_dot@
-am__quote = @am__quote@
-am__tar = @am__tar@
-am__untar = @am__untar@
-bindir = @bindir@
-build = @build@
-build_alias = @build_alias@
-build_cpu = @build_cpu@
-build_os = @build_os@
-build_vendor = @build_vendor@
-builddir = @builddir@
-datadir = @datadir@
-datarootdir = @datarootdir@
-
-# Install directories that automake doesn't know about
-docdir = $(exec_prefix)/doc
-dvidir = @dvidir@
-enable_shared = @enable_shared@
-enable_static = @enable_static@
-exec_prefix = @exec_prefix@
-host = @host@
-host_alias = @host_alias@
-host_cpu = @host_cpu@
-host_os = @host_os@
-host_vendor = @host_vendor@
-htmldir = @htmldir@
-includedir = @includedir@
-infodir = @infodir@
-install_sh = @install_sh@
-libdir = @libdir@
-libexecdir = @libexecdir@
-localedir = @localedir@
-localstatedir = @localstatedir@
-mandir = @mandir@
-mkdir_p = @mkdir_p@
-oldincludedir = @oldincludedir@
-pdfdir = @pdfdir@
-prefix = @prefix@
-program_transform_name = @program_transform_name@
-psdir = @psdir@
-sbindir = @sbindir@
-sharedstatedir = @sharedstatedir@
-srcdir = @srcdir@
-sysconfdir = @sysconfdir@
-target_alias = @target_alias@
-top_build_prefix = @top_build_prefix@
-top_builddir = @top_builddir@
-top_srcdir = @top_srcdir@
-
-# Shell commands used in Makefiles
-RM = rm -f
-CP = cp
-
-# Some machines need a command to run executables; this is that command
-# so that our tests will run.
-# We use RUNEXEC instead of RUNSERIAL directly because it may be that
-# some tests need to be run with a different command. Older versions
-# of the makefiles used the command
-# $(LIBTOOL) --mode=execute
-# in some directories, for instance.
-RUNEXEC = $(RUNSERIAL)
-
-# Libraries to link to while building
-LIBHDF5 = $(top_builddir)/src/libhdf5.la
-LIBH5TEST = $(top_builddir)/test/libh5test.la
-LIBH5F = $(top_builddir)/fortran/src/libhdf5_fortran.la
-LIBH5FTEST = $(top_builddir)/fortran/test/libh5test_fortran.la
-LIBH5CPP = $(top_builddir)/c++/src/libhdf5_cpp.la
-LIBH5TOOLS = $(top_builddir)/tools/lib/libh5tools.la
-LIBH5_HL = $(top_builddir)/hl/src/libhdf5_hl.la
-LIBH5F_HL = $(top_builddir)/hl/fortran/src/libhdf5hl_fortran.la
-LIBH5CPP_HL = $(top_builddir)/hl/c++/src/libhdf5_hl_cpp.la
-
-# Note that in svn revision 19400 the '/' after DESTDIR in H5* variables below
-# has been removed. According to the official description of DESTDIR by Gnu at
-# http://www.gnu.org/prep/standards/html_node/DESTDIR.html, DESTDIR is
-# prepended to the normal and complete install path that it precedes for the
-# purpose of installing in a temporary directory which is useful for building
-# rpms and other packages. The '/' after ${DESTDIR} will be followed by another
-# '/' at the beginning of the normal install path. When DESTDIR is empty the
-# path then begins with '//', which is incorrect and causes problems at least for
-# Cygwin.
-
-# Scripts used to build examples
-# If only shared libraries have been installed, have h5cc build examples with
-# shared libraries instead of static libraries
-H5CC = ${DESTDIR}$(bindir)/h5cc
-H5CC_PP = ${DESTDIR}$(bindir)/h5pcc
-H5FC = ${DESTDIR}$(bindir)/h5fc
-H5FC_PP = ${DESTDIR}$(bindir)/h5pfc
-H5CPP = ${DESTDIR}$(bindir)/h5c++
-ACLOCAL_AMFLAGS = "-I m4"
-
-# The trace script; this is used on source files from the C library to
-# insert tracing macros.
-TRACE = perl $(top_srcdir)/bin/trace
-
-# .chkexe files are used to mark tests that have run successfully.
-# .chklog files are output from those tests.
-# *.clog are from the MPE option.
-CHECK_CLEANFILES = *.chkexe *.chklog *.clog
-
-# Include files in /src directory
-INCLUDES = -I$(top_srcdir)/src
-
-# This is our main target, the h5tools library.
-noinst_LTLIBRARIES = libh5tools.la
-libh5tools_la_SOURCES = h5tools.c h5tools_dump.c h5tools_str.c h5tools_utils.c h5diff.c \
- h5diff_array.c h5diff_attr.c h5diff_dset.c h5diff_util.c h5trav.c \
- h5tools_filters.c h5tools_ref.c h5tools_type.c
-
-
-# Test program. Link using libhdf5 and libh5tools
-TEST_PROG =
-
-# Name libh5tools.la so that dependencies work out. Automake knows how
-# to build 'libh5tools.la', but not '../../tools/lib/libh5tools.la'.
-LDADD = libh5tools.la $(LIBHDF5)
-
-# Automake needs to be taught how to build lib, progs, and tests targets.
-# These will be filled in automatically for the most part (e.g.,
-# lib_LIBRARIES are built for lib target), but EXTRA_LIB, EXTRA_PROG, and
-# EXTRA_TEST variables are supplied to allow the user to force targets to
-# be built at certain times.
-LIB = $(lib_LIBRARIES) $(lib_LTLIBRARIES) $(noinst_LIBRARIES) \
- $(noinst_LTLIBRARIES) $(check_LIBRARIES) $(check_LTLIBRARIES) $(EXTRA_LIB)
-
-PROGS = $(bin_PROGRAMS) $(bin_SCRIPTS) $(noinst_PROGRAMS) $(noinst_SCRIPTS) \
- $(EXTRA_PROG)
-
-TEST_PROG_CHKEXE = $(TEST_PROG:=.chkexe_)
-TEST_PROG_PARA_CHKEXE = $(TEST_PROG_PARA:=.chkexe_)
-TEST_SCRIPT_CHKSH = $(TEST_SCRIPT:=.chkexe_)
-TEST_SCRIPT_PARA_CHKSH = $(TEST_SCRIPT_PARA:=.chkexe_)
-all: all-am
-
-.SUFFIXES:
-.SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/config/commence.am $(top_srcdir)/config/conclude.am $(am__configure_deps)
- @for dep in $?; do \
- case '$(am__configure_deps)' in \
- *$$dep*) \
- ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
- && { if test -f $@; then exit 0; else break; fi; }; \
- exit 1;; \
- esac; \
- done; \
- echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tools/lib/Makefile'; \
- $(am__cd) $(top_srcdir) && \
- $(AUTOMAKE) --foreign tools/lib/Makefile
-.PRECIOUS: Makefile
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
- @case '$?' in \
- *config.status*) \
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
- *) \
- echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
- cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
- esac;
-
-$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-
-$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(am__aclocal_m4_deps):
-
-clean-noinstLTLIBRARIES:
- -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
- @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
- dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
- test "$$dir" != "$$p" || dir=.; \
- echo "rm -f \"$${dir}/so_locations\""; \
- rm -f "$${dir}/so_locations"; \
- done
-libh5tools.la: $(libh5tools_la_OBJECTS) $(libh5tools_la_DEPENDENCIES)
- $(AM_V_CCLD)$(LINK) $(libh5tools_la_OBJECTS) $(libh5tools_la_LIBADD) $(LIBS)
-
-clean-checkPROGRAMS:
- @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \
- echo " rm -f" $$list; \
- rm -f $$list || exit $$?; \
- test -n "$(EXEEXT)" || exit 0; \
- list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
- echo " rm -f" $$list; \
- rm -f $$list
-
-mostlyclean-compile:
- -rm -f *.$(OBJEXT)
-
-distclean-compile:
- -rm -f *.tab.c
-
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5diff.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5diff_array.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5diff_attr.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5diff_dset.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5diff_util.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5tools.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5tools_dump.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5tools_filters.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5tools_ref.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5tools_str.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5tools_type.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5tools_utils.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5trav.Plo@am__quote@
-
-.c.o:
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(COMPILE) -c $<
-
-.c.obj:
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
-
-.c.lo:
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
-
-mostlyclean-libtool:
- -rm -f *.lo
-
-clean-libtool:
- -rm -rf .libs _libs
-
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
- list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
- END { if (nonempty) { for (i in files) print i; }; }'`; \
- mkid -fID $$unique
-tags: TAGS
-
-TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
- $(TAGS_FILES) $(LISP)
- set x; \
- here=`pwd`; \
- list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
- END { if (nonempty) { for (i in files) print i; }; }'`; \
- shift; \
- if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
- test -n "$$unique" || unique=$$empty_fix; \
- if test $$# -gt 0; then \
- $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
- "$$@" $$unique; \
- else \
- $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
- $$unique; \
- fi; \
- fi
-ctags: CTAGS
-CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
- $(TAGS_FILES) $(LISP)
- list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
- END { if (nonempty) { for (i in files) print i; }; }'`; \
- test -z "$(CTAGS_ARGS)$$unique" \
- || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
- $$unique
-
-GTAGS:
- here=`$(am__cd) $(top_builddir) && pwd` \
- && $(am__cd) $(top_srcdir) \
- && gtags -i $(GTAGS_ARGS) "$$here"
-
-distclean-tags:
- -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
-distdir: $(DISTFILES)
- @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
- topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
- list='$(DISTFILES)'; \
- dist_files=`for file in $$list; do echo $$file; done | \
- sed -e "s|^$$srcdirstrip/||;t" \
- -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
- case $$dist_files in \
- */*) $(MKDIR_P) `echo "$$dist_files" | \
- sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
- sort -u` ;; \
- esac; \
- for file in $$dist_files; do \
- if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
- if test -d $$d/$$file; then \
- dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
- if test -d "$(distdir)/$$file"; then \
- find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
- fi; \
- if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
- cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
- find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
- fi; \
- cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
- else \
- test -f "$(distdir)/$$file" \
- || cp -p $$d/$$file "$(distdir)/$$file" \
- || exit 1; \
- fi; \
- done
-check-am: all-am
- $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
- $(MAKE) $(AM_MAKEFLAGS) check-TESTS
-check: check-am
-all-am: Makefile $(LTLIBRARIES) all-local
-installdirs:
-install: install-am
-install-exec: install-exec-am
-install-data: install-data-am
-uninstall: uninstall-am
-
-install-am: all-am
- @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-
-installcheck: installcheck-am
-install-strip:
- $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
- install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
- `test -z '$(STRIP)' || \
- echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
-mostlyclean-generic:
-
-clean-generic:
-
-distclean-generic:
- -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
- -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
-
-maintainer-clean-generic:
- @echo "This command is intended for maintainers to use"
- @echo "it deletes files that may require special tools to rebuild."
-clean: clean-am
-
-clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
- clean-noinstLTLIBRARIES mostlyclean-am
-
-distclean: distclean-am
- -rm -rf ./$(DEPDIR)
- -rm -f Makefile
-distclean-am: clean-am distclean-compile distclean-generic \
- distclean-tags
-
-dvi: dvi-am
-
-dvi-am:
-
-html: html-am
-
-html-am:
-
-info: info-am
-
-info-am:
-
-install-data-am:
-
-install-dvi: install-dvi-am
-
-install-dvi-am:
-
-install-exec-am:
-
-install-html: install-html-am
-
-install-html-am:
-
-install-info: install-info-am
-
-install-info-am:
-
-install-man:
-
-install-pdf: install-pdf-am
-
-install-pdf-am:
-
-install-ps: install-ps-am
-
-install-ps-am:
-
-installcheck-am:
-
-maintainer-clean: maintainer-clean-am
- -rm -rf ./$(DEPDIR)
- -rm -f Makefile
-maintainer-clean-am: distclean-am maintainer-clean-generic
-
-mostlyclean: mostlyclean-am
-
-mostlyclean-am: mostlyclean-compile mostlyclean-generic \
- mostlyclean-libtool mostlyclean-local
-
-pdf: pdf-am
-
-pdf-am:
-
-ps: ps-am
-
-ps-am:
-
-uninstall-am:
-
-.MAKE: check-am install-am install-strip
-
-.PHONY: CTAGS GTAGS all all-am all-local check check-TESTS check-am \
- clean clean-checkPROGRAMS clean-generic clean-libtool \
- clean-noinstLTLIBRARIES ctags distclean distclean-compile \
- distclean-generic distclean-libtool distclean-tags distdir dvi \
- dvi-am html html-am info info-am install install-am \
- install-data install-data-am install-dvi install-dvi-am \
- install-exec install-exec-am install-html install-html-am \
- install-info install-info-am install-man install-pdf \
- install-pdf-am install-ps install-ps-am install-strip \
- installcheck installcheck-am installdirs maintainer-clean \
- maintainer-clean-generic mostlyclean mostlyclean-compile \
- mostlyclean-generic mostlyclean-libtool mostlyclean-local pdf \
- pdf-am ps ps-am tags uninstall uninstall-am
-
-
-# List all build rules defined by HDF5 Makefiles as "PHONY" targets here.
-# This tells the Makefiles that these targets are not files to be built but
-# commands that should be executed even if a file with the same name already
-# exists.
-.PHONY: build-check-clean build-check-p build-check-s build-lib build-progs \
- build-tests check-clean check-install check-p check-s check-vfd \
- install-doc lib progs tests uninstall-doc _exec_check-s _test help
-
-help:
- @$(top_srcdir)/bin/makehelp
-
-# lib/progs/tests targets recurse into subdirectories. build-* targets
-# build files in this directory.
-build-lib: $(LIB)
-build-progs: $(LIB) $(PROGS)
-build-tests: $(LIB) $(PROGS) $(TESTS)
-
-# General rule for recursive building targets.
-# BUILT_SOURCES contain targets that need to be built before anything else
-# in the directory (e.g., for Fortran type detection)
-lib progs tests check-s check-p :: $(BUILT_SOURCES)
- @$(MAKE) $(AM_MAKEFLAGS) build-$@ || exit 1;
- @for d in X $(SUBDIRS); do \
- if test $$d != X && test $$d != .; then \
- (set -x; cd $$d && $(MAKE) $(AM_MAKEFLAGS) $@) || exit 1; \
- fi; \
- done
-
-# General rule for recursive cleaning targets. Like the rule above,
-# but doesn't require building BUILT_SOURCES.
-check-clean ::
- @$(MAKE) $(AM_MAKEFLAGS) build-$@ || exit 1;
- @for d in X $(SUBDIRS); do \
- if test $$d != X && test $$d != .; then \
- (set -x; cd $$d && $(MAKE) $(AM_MAKEFLAGS) $@) || exit 1; \
- fi; \
- done
-
-# Tell Automake to build tests when the user types `make all' (this is
-# not its default behavior). Also build EXTRA_LIB and EXTRA_PROG since
-# Automake won't build them automatically, either.
-all-local: $(EXTRA_LIB) $(EXTRA_PROG) $(TESTS)
-
-# make install-doc doesn't do anything outside of doc directory, but
-# Makefiles should recognize it.
-# UPDATE: docs no longer reside in this build tree, so this target
-# is depreciated.
-install-doc uninstall-doc:
- @echo "Nothing to be done."
-
-# clean up files generated by tests so they can be re-run.
-build-check-clean:
- $(RM) -rf $(CHECK_CLEANFILES)
-
-# run check-clean whenever mostlyclean is run
-mostlyclean-local: build-check-clean
-
-# check-install is just a synonym for installcheck
-check-install: installcheck
-
-# Run each test in order, passing $(TEST_FLAGS) to the program.
-# Since tests are done in a shell loop, "make -i" does apply inside it.
-# Set HDF5_Make_Ignore to a non-blank string to ignore errors inside the loop.
-# The timestamps give a rough idea how much time the tests use.
-#
-# Note that targets in TESTS (defined above) will be built when the user
-# types 'make tests' or 'make check', but only programs in TEST_PROG,
-# TEST_PROG_PARA, or TEST_SCRIPT will actually be executed.
-check-TESTS: test
-
-test _test:
- @$(MAKE) build-check-s
- @$(MAKE) build-check-p
-
-# Actual execution of check-s.
-build-check-s: $(LIB) $(PROGS) $(TESTS)
- @if test -n "$(TEST_PROG)$(TEST_SCRIPT)"; then \
- echo "===Serial tests in `echo ${PWD} | sed -e s:.*/::` begin `date`==="; \
- fi
- @$(MAKE) $(AM_MAKEFLAGS) _exec_check-s
- @if test -n "$(TEST_PROG)$(TEST_SCRIPT)"; then \
- echo "===Serial tests in `echo ${PWD} | sed -e s:.*/::` ended `date`===";\
- fi
-
-_exec_check-s: $(TEST_PROG_CHKEXE) $(TEST_SCRIPT_CHKSH)
-
-# The dummy.chkexe here prevents the target from being
-# empty if there are no tests in the current directory.
-# $${log} is the log file.
-# $${tname} is the name of test.
-$(TEST_PROG_CHKEXE) $(TEST_PROG_PARA_CHKEXE) dummy.chkexe_:
- @if test "X$@" != "X.chkexe_" && test "X$@" != "Xdummy.chkexe_"; then \
- tname=$(@:.chkexe_=)$(EXEEXT);\
- log=$(@:.chkexe_=.chklog); \
- echo "============================"; \
- if $(top_srcdir)/bin/newer $(@:.chkexe_=.chkexe) $${tname}; then \
- echo "No need to test $${tname} again."; \
- else \
- echo "============================" > $${log}; \
- if test "X$(FORTRAN_API)" = "Xyes"; then \
- echo "Fortran API: Testing $(HDF5_DRIVER) $${tname} $(TEST_FLAGS)"; \
- echo "Fortran API: $(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" >> $${log}; \
- elif test "X$(CXX_API)" = "Xyes"; then \
- echo "C++ API: Testing $(HDF5_DRIVER) $${tname} $(TEST_FLAGS)"; \
- echo "C++ API: $(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" >> $${log};\
- else \
- echo "Testing $(HDF5_DRIVER) $${tname} $(TEST_FLAGS)"; \
- echo "$(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" >> $${log}; \
- fi; \
- echo "============================" >> $${log}; \
- srcdir="$(srcdir)" \
- $(TIME) $(RUNEXEC) ./$${tname} $(TEST_FLAGS) >> $${log} 2>&1 \
- && touch $(@:.chkexe_=.chkexe) || \
- (test $$HDF5_Make_Ignore && echo "*** Error ignored") || \
- (cat $${log} && false) || exit 1; \
- echo "" >> $${log}; \
- echo "Finished testing $${tname} $(TEST_FLAGS)" >> $${log}; \
- echo "============================" >> $${log}; \
- echo "Finished testing $${tname} $(TEST_FLAGS)"; \
- cat $${log}; \
- fi; \
- fi
-
-# The dummysh.chkexe here prevents the target from being
-# empty if there are no tests in the current directory.
-# $${log} is the log file.
-# $${tname} is the name of test.
-$(TEST_SCRIPT_CHKSH) $(TEST_SCRIPT_PARA_CHKSH) dummysh.chkexe_:
- @if test "X$@" != "X.chkexe_" && test "X$@" != "Xdummysh.chkexe_"; then \
- cmd=$(@:.chkexe_=);\
- tname=`basename $$cmd`;\
- chkname=`basename $(@:.chkexe_=.chkexe)`;\
- log=`basename $(@:.chkexe_=.chklog)`; \
- echo "============================"; \
- if $(top_srcdir)/bin/newer $${chkname} $$cmd $(SCRIPT_DEPEND); then \
- echo "No need to test $${tname} again."; \
- else \
- echo "============================" > $${log}; \
- if test "X$(FORTRAN_API)" = "Xyes"; then \
- echo "Fortran API: Testing $${tname} $(TEST_FLAGS)"; \
- echo "Fortran API: $${tname} $(TEST_FLAGS) Test Log" >> $${log}; \
- elif test "X$(CXX_API)" = "Xyes"; then \
- echo "C++ API: Testing $${tname} $(TEST_FLAGS)"; \
- echo "C++ API: $${tname} $(TEST_FLAGS) Test Log" >> $${log}; \
- else \
- echo "Testing $${tname} $(TEST_FLAGS)"; \
- echo "$${tname} $(TEST_FLAGS) Test Log" >> $${log}; \
- fi; \
- echo "============================" >> $${log}; \
- RUNSERIAL="$(RUNSERIAL)" RUNPARALLEL="$(RUNPARALLEL)" \
- srcdir="$(srcdir)" \
- $(TIME) $(SHELL) $$cmd $(TEST_FLAGS) >> $${log} 2>&1 \
- && touch $${chkname} || \
- (test $$HDF5_Make_Ignore && echo "*** Error ignored") || \
- (cat $${log} && false) || exit 1; \
- echo "" >> $${log}; \
- echo "Finished testing $${tname} $(TEST_FLAGS)" >> $${log}; \
- echo "============================" >> $${log}; \
- echo "Finished testing $${tname} $(TEST_FLAGS)"; \
- cat $${log}; \
- fi; \
- echo "============================"; \
- fi
-
-# Actual execution of check-p.
-build-check-p: $(LIB) $(PROGS) $(TESTS)
- @if test -n "$(TEST_PROG_PARA)$(TEST_SCRIPT_PARA)"; then \
- echo "===Parallel tests in `echo ${PWD} | sed -e s:.*/::` begin `date`==="; \
- fi
- @if test -n "$(TEST_PROG_PARA)"; then \
- echo "**** Hint ****"; \
- echo "Parallel test files reside in the current directory" \
- "by default."; \
- echo "Set HDF5_PARAPREFIX to use another directory. E.g.,"; \
- echo " HDF5_PARAPREFIX=/PFS/user/me"; \
- echo " export HDF5_PARAPREFIX"; \
- echo " make check"; \
- echo "**** end of Hint ****"; \
- fi
- @for test in $(TEST_PROG_PARA) dummy; do \
- if test $$test != dummy; then \
- $(MAKE) $(AM_MAKEFLAGS) $$test.chkexe_ \
- RUNEXEC="$(RUNPARALLEL)" || exit 1; \
- fi; \
- done
- @for test in $(TEST_SCRIPT_PARA) dummy; do \
- if test $$test != dummy; then \
- $(MAKE) $(AM_MAKEFLAGS) $$test.chkexe_ || exit 1; \
- fi; \
- done
- @if test -n "$(TEST_PROG_PARA)$(TEST_SCRIPT_PARA)"; then \
- echo "===Parallel tests in `echo ${PWD} | sed -e s:.*/::` ended `date`===";\
- fi
-
-# Run test with different Virtual File Driver
-check-vfd: $(LIB) $(PROGS) $(TESTS)
- @for vfd in $(VFD_LIST) dummy; do \
- if test $$vfd != dummy; then \
- echo "============================"; \
- echo "Testing Virtual File Driver $$vfd"; \
- echo "============================"; \
- $(MAKE) $(AM_MAKEFLAGS) check-clean || exit 1; \
- HDF5_DRIVER=$$vfd $(MAKE) $(AM_MAKEFLAGS) check || exit 1; \
- fi; \
- done
-
-# Tell versions [3.59,3.63) of GNU make to not export all variables.
-# Otherwise a system limit (for SysV at least) may be exceeded.
-.NOEXPORT:
diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c
index 306f914..1ab9236 100644
--- a/tools/lib/h5diff.c
+++ b/tools/lib/h5diff.c
@@ -1,71 +1,49 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#include <stdlib.h>
-
#include "H5private.h"
#include "h5tools.h"
#include "h5tools_utils.h"
#include "h5diff.h"
#include "ph5diff.h"
-/*
- * Debug printf macros. The prefix allows output filtering by test scripts.
- */
-#ifdef H5DIFF_DEBUG
-#define h5diffdebug(x) HDfprintf(stderr, "h5diff debug: " x)
-#define h5diffdebug2(x1, x2) HDfprintf(stderr, "h5diff debug: " x1, x2)
-#define h5diffdebug3(x1, x2, x3) HDfprintf(stderr, "h5diff debug: " x1, x2, x3)
-#define h5diffdebug4(x1, x2, x3, x4) HDfprintf(stderr, "h5diff debug: " x1, x2, x3, x4)
-#define h5diffdebug5(x1, x2, x3, x4, x5) HDfprintf(stderr, "h5diff debug: " x1, x2, x3, x4, x5)
-#else
-#define h5diffdebug(x)
-#define h5diffdebug2(x1, x2)
-#define h5diffdebug3(x1, x2, x3)
-#define h5diffdebug4(x1, x2, x3, x4)
-#define h5diffdebug5(x1, x2, x3, x4, x5)
-#endif
-
-
/*-------------------------------------------------------------------------
* Function: print_objname
*
- * Purpose: check if object name is to be printed, only when:
- * 1) verbose mode
- * 2) when diff was found (normal mode)
+ * Purpose: check if object name is to be printed, only when:
+ * 1) verbose mode
+ * 2) when diff was found (normal mode)
*-------------------------------------------------------------------------
*/
-int print_objname (diff_opt_t * options, hsize_t nfound)
+H5_ATTR_PURE int
+print_objname(diff_opt_t *opts, hsize_t nfound)
{
- return ((options->m_verbose || nfound) && !options->m_quiet) ? 1 : 0;
+ return ((opts->mode_verbose || nfound) && !opts->mode_quiet) ? 1 : 0;
}
/*-------------------------------------------------------------------------
* Function: do_print_objname
*
- * Purpose: print object name
- *
+ * Purpose: print object name
*-------------------------------------------------------------------------
*/
-void do_print_objname (const char *OBJ, const char *path1, const char *path2, diff_opt_t * opts)
+void
+do_print_objname(const char *OBJ, const char *path1, const char *path2, diff_opt_t *opts)
{
/* if verbose level is higher than 0, put space line before
* displaying any object or symbolic links. This improves
- * readability of the output.
+ * readability of the output.
*/
- if (opts->m_verbose_level >= 1)
+ if (opts->mode_verbose_level >= 1)
parallel_print("\n");
parallel_print("%-7s: <%s> and <%s>\n", OBJ, path1, path2);
}
@@ -73,12 +51,11 @@ void do_print_objname (const char *OBJ, const char *path1, const char *path2, di
/*-------------------------------------------------------------------------
* Function: do_print_attrname
*
- * Purpose: print attribute name
- *
+ * Purpose: print attribute name
*-------------------------------------------------------------------------
*/
void
-do_print_attrname (const char *attr, const char *path1, const char *path2)
+do_print_attrname(const char *attr, const char *path1, const char *path2)
{
parallel_print("%-7s: <%s> and <%s>\n", attr, path1, path2);
}
@@ -86,221 +63,151 @@ do_print_attrname (const char *attr, const char *path1, const char *path2)
/*-------------------------------------------------------------------------
* Function: print_warn
*
- * Purpose: check print warning condition.
- * Return:
- * 1 if verbose mode
- * 0 if not verbos mode
- * Programmer: Jonathan Kim
- * Date: Feb 4, 2010
+ * Purpose: check print warning condition.
+ * Return:
+ * 1 if verbose mode
+ * 0 if not verbos mode
*-------------------------------------------------------------------------
*/
-static int print_warn(diff_opt_t *options)
+static int
+print_warn(diff_opt_t *opts)
{
- return ((options->m_verbose))?1:0;
+ return ((opts->mode_verbose)) ? 1 : 0;
}
-
#ifdef H5_HAVE_PARALLEL
/*-------------------------------------------------------------------------
* Function: phdiff_dismiss_workers
*
- * Purpose: tell all workers to end.
- *
- * Return: none
- *
- * Programmer: Albert Cheng
- *
- * Date: Feb 6, 2005
+ * Purpose: tell all workers to end.
*
+ * Return: none
*-------------------------------------------------------------------------
*/
-void phdiff_dismiss_workers(void)
+void
+phdiff_dismiss_workers(void)
{
int i;
- for(i=1; i<g_nTasks; i++)
+ for (i = 1; i < g_nTasks; i++)
MPI_Send(NULL, 0, MPI_BYTE, i, MPI_TAG_END, MPI_COMM_WORLD);
}
-
-/*-------------------------------------------------------------------------
- * Function: print_manager_output
- *
- * Purpose: special function that prints any output accumulated by the
- * manager task.
- *
- * Return: none
- *
- * Programmer: Leon Arber
- *
- * Date: Feb 7, 2005
- *
- *-------------------------------------------------------------------------
- */
-void print_manager_output(void)
-{
- /* If there was something we buffered, let's print it now */
- if( (outBuffOffset>0) && g_Parallel)
- {
- printf("%s", outBuff);
-
- if(overflow_file)
- {
- int tmp;
- rewind(overflow_file);
- while((tmp = getc(overflow_file)) >= 0)
- putchar(tmp);
- fclose(overflow_file);
- overflow_file = NULL;
- }
-
- HDfflush(stdout);
- HDmemset(outBuff, 0, OUTBUFF_SIZE);
- outBuffOffset = 0;
- }
- else if( (outBuffOffset>0) && !g_Parallel)
- {
- HDfprintf(stderr, "h5diff error: outBuffOffset>0, but we're not in parallel!\n");
- }
-}
-
/*-------------------------------------------------------------------------
* Function: print_incoming_data
*
- * Purpose: special function that prints any output that has been sent to the manager
- * and is currently sitting in the incoming message queue
- *
- * Return: none
- *
- * Programmer: Leon Arber
- *
- * Date: March 7, 2005
+ * Purpose: special function that prints any output that has been sent to the manager
+ * and is currently sitting in the incoming message queue
*
+ * Return: none
*-------------------------------------------------------------------------
*/
-static void print_incoming_data(void)
+static void
+print_incoming_data(void)
{
- char data[PRINT_DATA_MAX_SIZE+1];
- int incomingMessage;
+ char data[PRINT_DATA_MAX_SIZE + 1];
+ int incomingMessage;
MPI_Status Status;
- do
- {
+ do {
MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_PRINT_DATA, MPI_COMM_WORLD, &incomingMessage, &Status);
- if(incomingMessage)
- {
- HDmemset(data, 0, PRINT_DATA_MAX_SIZE+1);
- MPI_Recv(data, PRINT_DATA_MAX_SIZE, MPI_CHAR, Status.MPI_SOURCE, MPI_TAG_PRINT_DATA, MPI_COMM_WORLD, &Status);
+ if (incomingMessage) {
+ HDmemset(data, 0, PRINT_DATA_MAX_SIZE + 1);
+ MPI_Recv(data, PRINT_DATA_MAX_SIZE, MPI_CHAR, Status.MPI_SOURCE, MPI_TAG_PRINT_DATA,
+ MPI_COMM_WORLD, &Status);
- printf("%s", data);
+ HDprintf("%s", data);
}
- } while(incomingMessage);
+ } while (incomingMessage);
}
#endif
/*-------------------------------------------------------------------------
* Function: is_valid_options
*
- * Purpose: check if options are valid
- *
- * Return:
- * 1 : Valid
- * 0 : Not valid
- *
- * Programmer: Jonathan Kim
- *
- * Date: Feb 17, 2010
+ * Purpose: check if options are valid
*
+ * Return:
+ * 1 : Valid
+ * 0 : Not valid
*------------------------------------------------------------------------*/
-static int is_valid_options(diff_opt_t *options)
+static int
+is_valid_options(diff_opt_t *opts)
{
- int ret=1; /* init to valid */
+ int ret_value = 1; /* init to valid */
/*-----------------------------------------------
* no -q(quiet) with -v (verbose) or -r (report) */
- if(options->m_quiet && (options->m_verbose || options->m_report))
- {
+ if (opts->mode_quiet && (opts->mode_verbose || opts->mode_report)) {
parallel_print("Error: -q (quiet mode) cannot be added to verbose or report modes\n");
- options->err_stat=1;
- ret = 0;
- goto out;
+ opts->err_stat = H5DIFF_ERR;
+ H5TOOLS_GOTO_DONE(0);
}
/* -------------------------------------------------------
* only allow --no-dangling-links along with --follow-symlinks */
- if(options->no_dangle_links && !options->follow_links)
- {
+ if (opts->no_dangle_links && !opts->follow_links) {
parallel_print("Error: --no-dangling-links must be used along with --follow-symlinks option.\n");
- options->err_stat=1;
- ret = 0;
- goto out;
+ opts->err_stat = H5DIFF_ERR;
+ H5TOOLS_GOTO_DONE(0);
}
-out:
-
- return ret;
+done:
+ return ret_value;
}
/*-------------------------------------------------------------------------
* Function: is_exclude_path
*
- * Purpose: check if 'paths' are part of exclude path list
+ * Purpose: check if 'paths' are part of exclude path list
*
- * Return:
- * 1 - excluded path
- * 0 - not excluded path
- *
- * Programmer: Jonathan Kim
- * Date: Aug 23, 2010
+ * Return:
+ * 1 - excluded path
+ * 0 - not excluded path
*------------------------------------------------------------------------*/
-static int is_exclude_path (char * path, h5trav_type_t type, diff_opt_t *options)
+static int
+is_exclude_path(char *path, h5trav_type_t type, diff_opt_t *opts)
{
- struct exclude_path_list * exclude_path_ptr;
- int ret_cmp;
- int ret = 0;
- int len_grp;
+ struct exclude_path_list *exclude_path_ptr;
+ int ret_cmp;
+ int ret_value = 0;
/* check if exclude path option is given */
- if (!options->exclude_path)
- goto out;
+ if (!opts->exclude_path)
+ H5TOOLS_GOTO_DONE(0);
/* assign to local exclude list pointer */
- exclude_path_ptr = options->exclude;
+ exclude_path_ptr = opts->exclude;
/* search objects in exclude list */
- while (NULL != exclude_path_ptr)
- {
- /* if exclude path is is group, exclude its members as well */
- if (exclude_path_ptr->obj_type == H5TRAV_TYPE_GROUP)
- {
- ret_cmp = HDstrncmp(exclude_path_ptr->obj_path, path,
- HDstrlen(exclude_path_ptr->obj_path));
- if (ret_cmp == 0) /* found matching members */
- {
- /* check if given path belong to an excluding group, if so
+ while (NULL != exclude_path_ptr) {
+ /* if exclude path is in group, exclude its members as well */
+ if (exclude_path_ptr->obj_type == H5TRAV_TYPE_GROUP) {
+ ret_cmp = HDstrncmp(exclude_path_ptr->obj_path, path, HDstrlen(exclude_path_ptr->obj_path));
+ if (ret_cmp == 0) { /* found matching members */
+ size_t len_grp;
+
+ /* check if given path belong to an excluding group, if so
* exclude it as well.
* This verifies if “/grp1/dset1” is only under “/grp1”, but
- * not under “/grp1xxx/” group.
- */
+ * not under “/grp1xxx/” group.
+ */
len_grp = HDstrlen(exclude_path_ptr->obj_path);
- if (path[len_grp] == '/')
- {
+ if (path[len_grp] == '/') {
/* belong to excluded group! */
- ret = 1;
- break; /* while */
+ ret_value = 1;
+ break; /* while */
}
}
}
/* exclude target is not group, just exclude the object */
- else
- {
+ else {
ret_cmp = HDstrcmp(exclude_path_ptr->obj_path, path);
- if (ret_cmp == 0) /* found matching object */
- {
+ if (ret_cmp == 0) { /* found matching object */
/* excluded non-group object */
- ret = 1;
- /* remember the type of this maching object.
- * if it's group, it can be used for excluding its member
+ ret_value = 1;
+ /* remember the type of this matching object.
+ * if it's group, it can be used for excluding its member
* objects in this while() loop */
exclude_path_ptr->obj_type = type;
break; /* while */
@@ -309,26 +216,104 @@ static int is_exclude_path (char * path, h5trav_type_t type, diff_opt_t *options
exclude_path_ptr = exclude_path_ptr->next;
}
-out:
- return ret;
+done:
+ return ret_value;
}
+/*-------------------------------------------------------------------------
+ * Function: is_exclude_attr
+ *
+ * Purpose: check if 'paths' are part of exclude path list
+ *
+ * Return:
+ * 1 - excluded path
+ * 0 - not excluded path
+ *------------------------------------------------------------------------*/
+static int
+is_exclude_attr(const char *path, h5trav_type_t type, diff_opt_t *opts)
+{
+ struct exclude_path_list *exclude_ptr;
+ int ret_cmp;
+ int ret_value = 0;
+
+ /* check if exclude attr option is given */
+ if (!opts->exclude_attr_path)
+ H5TOOLS_GOTO_DONE(0);
+
+ /* assign to local exclude list pointer */
+ exclude_ptr = opts->exclude_attr;
+
+ /* search objects in exclude list */
+ while (NULL != exclude_ptr) {
+ /* if exclude path is in group, exclude its members as well */
+ if (exclude_ptr->obj_type == H5TRAV_TYPE_GROUP) {
+ ret_cmp = HDstrncmp(exclude_ptr->obj_path, path, HDstrlen(exclude_ptr->obj_path));
+ if (ret_cmp == 0) { /* found matching members */
+ size_t len_grp;
+
+ /* check if given path belong to an excluding group, if so
+ * exclude it as well.
+ * This verifies if “/grp1/dset1” is only under “/grp1”, but
+ * not under “/grp1xxx/” group.
+ */
+ len_grp = HDstrlen(exclude_ptr->obj_path);
+ if (path[len_grp] == '/') {
+ /* belong to excluded group! */
+ ret_value = 1;
+ break; /* while */
+ }
+ }
+ }
+ /* exclude target is not group, just exclude the object */
+ else {
+ ret_cmp = HDstrcmp(exclude_ptr->obj_path, path);
+ if (ret_cmp == 0) { /* found matching object */
+ /* excluded non-group object */
+ ret_value = 1;
+ /* remember the type of this matching object.
+ * if it's group, it can be used for excluding its member
+ * objects in this while() loop */
+ exclude_ptr->obj_type = type;
+ break; /* while */
+ }
+ }
+ exclude_ptr = exclude_ptr->next;
+ }
+
+done:
+ return ret_value;
+}
/*-------------------------------------------------------------------------
* Function: free_exclude_path_list
*
- * Purpose: free exclud object list from diff options
+ * Purpose: free exclude object list from diff options
+ *------------------------------------------------------------------------*/
+static void
+free_exclude_path_list(diff_opt_t *opts)
+{
+ struct exclude_path_list *curr = opts->exclude;
+ struct exclude_path_list *next;
+
+ while (NULL != curr) {
+ next = curr->next;
+ HDfree(curr);
+ curr = next;
+ }
+}
+
+/*-------------------------------------------------------------------------
+ * Function: free_exclude_attr_list
*
- * Programmer: Jonathan Kim
- * Date: Aug 23, 2010
+ * Purpose: free exclude object attribute list from diff options
*------------------------------------------------------------------------*/
-static void free_exclude_path_list(diff_opt_t *options)
+static void
+free_exclude_attr_list(diff_opt_t *opts)
{
- struct exclude_path_list * curr = options->exclude;
- struct exclude_path_list * next;
+ struct exclude_path_list *curr = opts->exclude_attr;
+ struct exclude_path_list *next;
- while (NULL != curr)
- {
+ while (NULL != curr) {
next = curr->next;
HDfree(curr);
curr = next;
@@ -338,117 +323,120 @@ static void free_exclude_path_list(diff_opt_t *options)
/*-------------------------------------------------------------------------
* Function: build_match_list
*
- * Purpose: get list of matching path_name from info1 and info2
+ * Purpose: get list of matching path_name from info1 and info2
*
* Note:
- * Find common objects; the algorithm used for this search is the
- * cosequential match algorithm and is described in
- * Folk, Michael; Zoellick, Bill. (1992). File Structures. Addison-Wesley.
- * Moved out from diff_match() to make code more flexible.
+ * Find common objects; the algorithm used for this search is the
+ * cosequential match algorithm and is described in
+ * Folk, Michael; Zoellick, Bill. (1992). File Structures. Addison-Wesley.
+ * Moved out from diff_match() to make code more flexible.
*
* Parameter:
- * table_out [OUT] : return the list
- *
- * Programmer: Jonathan Kim
- *
- * Date: Aug 18, 2010
+ * table_out [OUT] : return the list
*------------------------------------------------------------------------*/
-static void build_match_list (const char *objname1, trav_info_t *info1, const char *objname2, trav_info_t *info2, trav_table_t ** table_out, diff_opt_t *options)
+static void
+build_match_list(const char *objname1, trav_info_t *info1, const char *objname2, trav_info_t *info2,
+ trav_table_t **table_out, diff_opt_t *opts)
{
- unsigned i;
- size_t curr1 = 0;
- size_t curr2 = 0;
- unsigned infile[2];
- char * path1_lp;
- char * path2_lp;
+ size_t curr1 = 0;
+ size_t curr2 = 0;
+ unsigned infile[2];
+ char *path1_lp = NULL;
+ char *path2_lp = NULL;
h5trav_type_t type1_l;
h5trav_type_t type2_l;
- int path1_offset = 0;
- int path2_offset = 0;
- int cmp;
- trav_table_t *table;
- size_t idx;
+ size_t path1_offset = 0;
+ size_t path2_offset = 0;
+ int cmp;
+ trav_table_t *table = NULL;
+ size_t idx;
+ H5TOOLS_START_DEBUG(" - errstat:%d", opts->err_stat);
/* init */
- trav_table_init( &table );
+ trav_table_init(info1->fid, &table);
+ if (table == NULL) {
+ H5TOOLS_INFO("Cannot create traverse table");
+ H5TOOLS_GOTO_DONE_NO_RET();
+ }
/*
* This is necessary for the case that given objects are group and
* have different names (ex: obj1 is /grp1 and obj2 is /grp5).
- * All the objects belong to given groups are the cadidates.
+ * All the objects belong to given groups are the candidates.
* So prepare to compare paths without the group names.
*/
+ H5TOOLS_DEBUG("objname1 = %s objname2 = %s ", objname1, objname2);
+
/* if obj1 is not root */
- if (HDstrcmp (objname1,"/") != 0)
+ if (HDstrcmp(objname1, "/") != 0)
path1_offset = HDstrlen(objname1);
/* if obj2 is not root */
- if (HDstrcmp (objname2,"/") != 0)
+ if (HDstrcmp(objname2, "/") != 0)
path2_offset = HDstrlen(objname2);
/*--------------------------------------------------
- * build the list
- */
- while(curr1 < info1->nused && curr2 < info2->nused)
- {
-
+ * build the list
+ */
+ while (curr1 < info1->nused && curr2 < info2->nused) {
path1_lp = (info1->paths[curr1].path) + path1_offset;
path2_lp = (info2->paths[curr2].path) + path2_offset;
- type1_l = info1->paths[curr1].type;
- type2_l = info2->paths[curr2].type;
-
+ type1_l = info1->paths[curr1].type;
+ type2_l = info2->paths[curr2].type;
+
/* criteria is string compare */
cmp = HDstrcmp(path1_lp, path2_lp);
-
- if(cmp == 0) {
- if(!is_exclude_path(path1_lp, type1_l, options))
- {
+ if (cmp == 0) {
+ if (!is_exclude_path(path1_lp, type1_l, opts)) {
infile[0] = 1;
infile[1] = 1;
trav_table_addflags(infile, path1_lp, info1->paths[curr1].type, table);
/* if the two point to the same target object,
* mark that in table */
- if (info1->paths[curr1].fileno == info2->paths[curr2].fileno &&
- info1->paths[curr1].objno == info2->paths[curr2].objno )
- {
- idx = table->nobjs - 1;
- table->objs[idx].is_same_trgobj = 1;
+ if (info1->paths[curr1].fileno == info2->paths[curr2].fileno) {
+ int token_cmp;
+
+ if (H5Otoken_cmp(info1->fid, &info1->paths[curr1].obj_token,
+ &info2->paths[curr2].obj_token, &token_cmp) < 0) {
+ H5TOOLS_INFO("Failed to compare object tokens");
+ opts->err_stat = H5DIFF_ERR;
+ H5TOOLS_GOTO_DONE_NO_RET();
+ }
+
+ if (!token_cmp) {
+ idx = table->nobjs - 1;
+ table->objs[idx].is_same_trgobj = 1;
+ }
}
}
curr1++;
curr2++;
} /* end if */
- else if(cmp < 0)
- {
- if(!is_exclude_path(path1_lp, type1_l, options))
- {
+ else if (cmp < 0) {
+ if (!is_exclude_path(path1_lp, type1_l, opts)) {
infile[0] = 1;
infile[1] = 0;
trav_table_addflags(infile, path1_lp, info1->paths[curr1].type, table);
}
curr1++;
} /* end else-if */
- else
- {
- if (!is_exclude_path(path2_lp, type2_l, options))
- {
+ else {
+ if (!is_exclude_path(path2_lp, type2_l, opts)) {
infile[0] = 0;
infile[1] = 1;
trav_table_addflags(infile, path2_lp, info2->paths[curr2].type, table);
}
curr2++;
} /* end else */
- } /* end while */
+ } /* end while */
/* list1 did not end */
infile[0] = 1;
infile[1] = 0;
- while(curr1 < info1->nused)
- {
+ while (curr1 < info1->nused) {
path1_lp = (info1->paths[curr1].path) + path1_offset;
- type1_l = info1->paths[curr1].type;
+ type1_l = info1->paths[curr1].type;
- if(!is_exclude_path(path1_lp, type1_l, options))
- {
+ if (!is_exclude_path(path1_lp, type1_l, opts)) {
trav_table_addflags(infile, path1_lp, info1->paths[curr1].type, table);
}
curr1++;
@@ -457,346 +445,345 @@ static void build_match_list (const char *objname1, trav_info_t *info1, const ch
/* list2 did not end */
infile[0] = 0;
infile[1] = 1;
- while(curr2 < info2->nused)
- {
+ while (curr2 < info2->nused) {
path2_lp = (info2->paths[curr2].path) + path2_offset;
- type2_l = info2->paths[curr2].type;
+ type2_l = info2->paths[curr2].type;
- if (!is_exclude_path(path2_lp, type2_l, options))
- {
+ if (!is_exclude_path(path2_lp, type2_l, opts)) {
trav_table_addflags(infile, path2_lp, info2->paths[curr2].type, table);
- }
+ }
curr2++;
} /* end while */
- free_exclude_path_list (options);
- /*------------------------------------------------------
- * print the list
- */
- if(options->m_verbose)
- {
- parallel_print("\n");
- /* if given objects is group under root */
- if (HDstrcmp (objname1,"/") || HDstrcmp (objname2,"/"))
- parallel_print("group1 group2\n");
- else
- parallel_print("file1 file2\n");
- parallel_print("---------------------------------------\n");
- for(i = 0; i < table->nobjs; i++)
- {
- char c1, c2;
- c1 = (table->objs[i].flags[0]) ? 'x' : ' ';
- c2 = (table->objs[i].flags[1]) ? 'x' : ' ';
- parallel_print("%5c %6c %-15s\n", c1, c2, table->objs[i].name);
- } /* end for */
- parallel_print ("\n");
- } /* end if */
+ free_exclude_path_list(opts);
+done:
*table_out = table;
-}
+ H5TOOLS_ENDDEBUG(" ");
+}
/*-------------------------------------------------------------------------
* Function: trav_grp_objs
*
- * Purpose:
- * Call back function from h5trav_visit().
- *
- * Programmer: Jonathan Kim
- *
- * Date: Aug 16, 2010
+ * Purpose: Call back function from h5trav_visit().
*------------------------------------------------------------------------*/
-static herr_t trav_grp_objs(const char *path, const H5O_info_t *oinfo,
- const char *already_visited, void *udata)
+static herr_t
+trav_grp_objs(const char *path, const H5O_info2_t *oinfo, const char *already_visited, void *udata)
{
trav_info_visit_obj(path, oinfo, already_visited, udata);
return 0;
-}
+}
/*-------------------------------------------------------------------------
* Function: trav_grp_symlinks
*
- * Purpose:
- * Call back function from h5trav_visit().
- * Track and extra checkings while visiting all symbolic-links.
- *
- * Programmer: Jonathan Kim
- *
- * Date: Aug 16, 2010
+ * Purpose: Call back function from h5trav_visit().
+ * Track and extra checkings while visiting all symbolic-links.
*------------------------------------------------------------------------*/
-static herr_t trav_grp_symlinks(const char *path, const H5L_info_t *linfo,
- void *udata)
-{
- trav_info_t *tinfo = (trav_info_t *)udata;
- diff_opt_t *opts = (diff_opt_t *)tinfo->opts;
- int ret;
+static herr_t
+trav_grp_symlinks(const char *path, const H5L_info2_t *linfo, void *udata)
+{
+ trav_info_t *tinfo = (trav_info_t *)udata;
+ diff_opt_t *opts = (diff_opt_t *)tinfo->opts;
h5tool_link_info_t lnk_info;
- const char *ext_fname;
- const char *ext_path;
+ const char *ext_fname;
+ const char *ext_path;
+ herr_t ret_value = SUCCEED;
+ H5TOOLS_START_DEBUG(" ");
/* init linkinfo struct */
HDmemset(&lnk_info, 0, sizeof(h5tool_link_info_t));
- if (!opts->follow_links)
- {
+ if (!opts->follow_links) {
trav_info_visit_lnk(path, linfo, tinfo);
- goto done;
+ H5TOOLS_GOTO_DONE(SUCCEED);
}
- switch(linfo->type)
- {
- case H5L_TYPE_SOFT:
- ret = H5tools_get_symlink_info(tinfo->fid, path, &lnk_info, opts->follow_links);
- /* error */
- if (ret < 0)
- goto done;
- /* no dangling link option given and detect dangling link */
- else if (ret == 0)
- {
- tinfo->symlink_visited.dangle_link = TRUE;
- trav_info_visit_lnk(path, linfo, tinfo);
- if (opts->no_dangle_links)
- opts->err_stat = 1; /* make dgangling link is error */
- goto done;
- }
+ switch (linfo->type) {
+ case H5L_TYPE_SOFT:
+ if ((ret_value = H5tools_get_symlink_info(tinfo->fid, path, &lnk_info, opts->follow_links)) < 0) {
+ H5TOOLS_GOTO_DONE(FAIL);
+ }
+ else if (ret_value == 0) {
+ /* no dangling link option given and detect dangling link */
+ tinfo->symlink_visited.dangle_link = TRUE;
+ trav_info_visit_lnk(path, linfo, tinfo);
+ if (opts->no_dangle_links)
+ opts->err_stat = H5DIFF_ERR; /* make dangling link is error */
+ H5TOOLS_GOTO_DONE(SUCCEED);
+ }
- /* check if already visit the target object */
- if(symlink_is_visited( &(tinfo->symlink_visited), linfo->type, NULL, lnk_info.trg_path))
- goto done;
-
- /* add this link as visited link */
- if(symlink_visit_add( &(tinfo->symlink_visited), linfo->type, NULL, lnk_info.trg_path) < 0)
- goto done;
-
- if(h5trav_visit(tinfo->fid, path, TRUE, TRUE,
- trav_grp_objs,trav_grp_symlinks, tinfo) < 0)
- {
- parallel_print("Error: Could not get file contents\n");
- opts->err_stat = 1;
- goto done;
- }
- break;
-
- case H5L_TYPE_EXTERNAL:
- ret = H5tools_get_symlink_info(tinfo->fid, path, &lnk_info, opts->follow_links);
- /* error */
- if (ret < 0)
- goto done;
- /* no dangling link option given and detect dangling link */
- else if (ret == 0)
- {
- tinfo->symlink_visited.dangle_link = TRUE;
- trav_info_visit_lnk(path, linfo, tinfo);
- if (opts->no_dangle_links)
- opts->err_stat = 1; /* make dgangling link is error */
- goto done;
- }
+ /* check if already visit the target object */
+ if (symlink_is_visited(&(tinfo->symlink_visited), linfo->type, NULL, lnk_info.trg_path))
+ H5TOOLS_GOTO_DONE(SUCCEED);
- if(H5Lunpack_elink_val(lnk_info.trg_path, linfo->u.val_size, NULL, &ext_fname, &ext_path) < 0)
- goto done;
+ /* add this link as visited link */
+ if (symlink_visit_add(&(tinfo->symlink_visited), linfo->type, NULL, lnk_info.trg_path) < 0)
+ H5TOOLS_GOTO_DONE(SUCCEED);
- /* check if already visit the target object */
- if(symlink_is_visited( &(tinfo->symlink_visited), linfo->type, ext_fname, ext_path))
- goto done;
+ if (h5trav_visit(tinfo->fid, path, TRUE, TRUE, trav_grp_objs, trav_grp_symlinks, tinfo,
+ H5O_INFO_BASIC) < 0) {
+ parallel_print("Error: Could not get file contents\n");
+ opts->err_stat = H5DIFF_ERR;
+ H5TOOLS_GOTO_ERROR(FAIL, "Error: Could not get file contents");
+ }
+ break;
- /* add this link as visited link */
- if(symlink_visit_add( &(tinfo->symlink_visited), linfo->type, ext_fname, ext_path) < 0)
- goto done;
-
- if(h5trav_visit(tinfo->fid, path, TRUE, TRUE,
- trav_grp_objs,trav_grp_symlinks, tinfo) < 0)
- {
- parallel_print("Error: Could not get file contents\n");
- opts->err_stat = 1;
- goto done;
- }
- break;
- default:
- ;
- break;
+ case H5L_TYPE_EXTERNAL:
+ if ((ret_value = H5tools_get_symlink_info(tinfo->fid, path, &lnk_info, opts->follow_links)) < 0) {
+ H5TOOLS_GOTO_DONE(FAIL);
+ }
+ else if (ret_value == 0) {
+ /* no dangling link option given and detect dangling link */
+ tinfo->symlink_visited.dangle_link = TRUE;
+ trav_info_visit_lnk(path, linfo, tinfo);
+ if (opts->no_dangle_links)
+ opts->err_stat = H5DIFF_ERR; /* make dangling link is error */
+ H5TOOLS_GOTO_DONE(SUCCEED);
+ }
+
+ if (H5Lunpack_elink_val(lnk_info.trg_path, linfo->u.val_size, NULL, &ext_fname, &ext_path) < 0)
+ H5TOOLS_GOTO_DONE(SUCCEED);
+
+ /* check if already visit the target object */
+ if (symlink_is_visited(&(tinfo->symlink_visited), linfo->type, ext_fname, ext_path))
+ H5TOOLS_GOTO_DONE(SUCCEED);
+
+ /* add this link as visited link */
+ if (symlink_visit_add(&(tinfo->symlink_visited), linfo->type, ext_fname, ext_path) < 0)
+ H5TOOLS_GOTO_DONE(SUCCEED);
+
+ if (h5trav_visit(tinfo->fid, path, TRUE, TRUE, trav_grp_objs, trav_grp_symlinks, tinfo,
+ H5O_INFO_BASIC) < 0) {
+ parallel_print("Error: Could not get file contents\n");
+ opts->err_stat = H5DIFF_ERR;
+ H5TOOLS_GOTO_ERROR(FAIL, "Error: Could not get file contents\n");
+ }
+ break;
+
+ case H5L_TYPE_HARD:
+ case H5L_TYPE_MAX:
+ case H5L_TYPE_ERROR:
+ default:
+ parallel_print("Error: Invalid link type\n");
+ opts->err_stat = H5DIFF_ERR;
+ H5TOOLS_GOTO_ERROR(FAIL, "Error: Invalid link type");
+ break;
} /* end of switch */
-done:
+done:
if (lnk_info.trg_path)
- HDfree((char *)lnk_info.trg_path);
- return 0;
-}
-
+ HDfree(lnk_info.trg_path);
+ H5TOOLS_ENDDEBUG(" ");
+ return ret_value;
+}
/*-------------------------------------------------------------------------
* Function: h5diff
*
- * Purpose: public function, can be called in an application program.
- * return differences between 2 HDF5 files
- *
- * Return: Number of differences found.
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: October 22, 2003
+ * Purpose: public function, can be called in an application program.
+ * return differences between 2 HDF5 files
*
+ * Return: Number of differences found.
*-------------------------------------------------------------------------
*/
-hsize_t h5diff(const char *fname1,
- const char *fname2,
- const char *objname1,
- const char *objname2,
- diff_opt_t *options)
+hsize_t
+h5diff(const char *fname1, const char *fname2, const char *objname1, const char *objname2, diff_opt_t *opts)
{
- hid_t file1_id = (-1);
- hid_t file2_id = (-1);
- char filenames[2][MAX_FILENAME];
- hsize_t nfound = 0;
- int i;
- int l_ret1 = -1;
- int l_ret2 = -1;
- const char * obj1fullname = NULL;
- const char * obj2fullname = NULL;
+ hid_t file1_id = H5I_INVALID_HID;
+ hid_t file2_id = H5I_INVALID_HID;
+ hid_t fapl1_id = H5P_DEFAULT;
+ hid_t fapl2_id = H5P_DEFAULT;
+ char filenames[2][MAX_FILENAME];
+ hsize_t nfound = 0;
+ int l_ret1 = -1;
+ int l_ret2 = -1;
+ char *obj1fullname = NULL;
+ char *obj2fullname = NULL;
+ int both_objs_grp = 0;
/* init to group type */
h5trav_type_t obj1type = H5TRAV_TYPE_GROUP;
h5trav_type_t obj2type = H5TRAV_TYPE_GROUP;
/* for single object */
- H5O_info_t oinfo1, oinfo2; /* object info */
- trav_info_t *info1_obj = NULL;
- trav_info_t *info2_obj = NULL;
+ H5O_info2_t oinfo1, oinfo2; /* object info */
+ trav_info_t *info1_obj = NULL;
+ trav_info_t *info2_obj = NULL;
/* for group object */
- trav_info_t *info1_grp = NULL;
- trav_info_t *info2_grp = NULL;
+ trav_info_t *info1_grp = NULL;
+ trav_info_t *info2_grp = NULL;
/* local pointer */
- trav_info_t *info1_lp;
- trav_info_t *info2_lp;
+ trav_info_t *info1_lp = NULL;
+ trav_info_t *info2_lp = NULL;
/* link info from specified object */
- H5L_info_t src_linfo1;
- H5L_info_t src_linfo2;
+ H5L_info2_t src_linfo1;
+ H5L_info2_t src_linfo2;
/* link info from member object */
h5tool_link_info_t trg_linfo1;
h5tool_link_info_t trg_linfo2;
/* list for common objects */
trav_table_t *match_list = NULL;
+ diff_err_t ret_value = H5DIFF_NO_ERR;
+ H5TOOLS_START_DEBUG(" ");
/* init filenames */
HDmemset(filenames, 0, MAX_FILENAME * 2);
/* init link info struct */
HDmemset(&trg_linfo1, 0, sizeof(h5tool_link_info_t));
HDmemset(&trg_linfo2, 0, sizeof(h5tool_link_info_t));
- /*-------------------------------------------------------------------------
- * check invalid combination of options
- *-----------------------------------------------------------------------*/
- if(!is_valid_options(options))
- goto out;
+ /*-------------------------------------------------------------------------
+ * check invalid combination of options
+ *-----------------------------------------------------------------------*/
+ if (!is_valid_options(opts))
+ H5TOOLS_GOTO_DONE(0);
- options->cmn_objs = 1; /* eliminate warning */
+ opts->cmn_objs = 1; /* eliminate warning */
+ opts->err_stat = H5DIFF_NO_ERR; /* initialize error status */
/*-------------------------------------------------------------------------
- * open the files first; if they are not valid, no point in continuing
- *-------------------------------------------------------------------------
- */
+ * open the files first; if they are not valid, no point in continuing
+ *-------------------------------------------------------------------------
+ */
+ /* open file 1 */
+ if (opts->vfd_info[0].u.name) {
+ if ((fapl1_id = h5tools_get_fapl(H5P_DEFAULT, NULL, &(opts->vfd_info[0]))) < 0) {
+ parallel_print("h5diff: unable to create fapl for input file\n");
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "unable to create input fapl\n");
+ }
+ }
- /* disable error reporting */
- H5E_BEGIN_TRY
- {
- /* open file 1 */
- if((file1_id = h5tools_fopen(fname1, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0)
- {
- parallel_print("h5diff: <%s>: unable to open file\n", fname1);
- options->err_stat = 1;
- goto out;
- } /* end if */
+ if (opts->custom_vol[0] || opts->custom_vfd[0]) {
+ if ((fapl1_id = h5tools_get_fapl(fapl1_id, opts->custom_vol[0] ? &(opts->vol_info[0]) : NULL,
+ opts->custom_vfd[0] ? &(opts->vfd_info[0]) : NULL)) < 0) {
+ parallel_print("h5diff: unable to create fapl for input file\n");
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "unable to create input fapl\n");
+ }
+ }
+ if ((file1_id = h5tools_fopen(fname1, H5F_ACC_RDONLY, fapl1_id, (fapl1_id != H5P_DEFAULT), NULL,
+ (size_t)0)) < 0) {
+ parallel_print("h5diff: <%s>: unable to open file\n", fname1);
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "<%s>: unable to open file\n", fname1);
+ }
+ H5TOOLS_DEBUG("file1_id = %s", fname1);
- /* open file 2 */
- if((file2_id = h5tools_fopen(fname2, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0)
- {
- parallel_print("h5diff: <%s>: unable to open file\n", fname2);
- options->err_stat = 1;
- goto out;
- } /* end if */
- /* enable error reporting */
- } H5E_END_TRY;
+ /* open file 2 */
+ if (opts->vfd_info[1].u.name) {
+ if ((fapl2_id = h5tools_get_fapl(H5P_DEFAULT, NULL, &(opts->vfd_info[1]))) < 0) {
+ parallel_print("h5diff: unable to create fapl for output file\n");
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "unable to create output fapl\n");
+ }
+ }
+
+ if (opts->custom_vol[1] || opts->custom_vfd[1]) {
+ if ((fapl2_id = h5tools_get_fapl(fapl2_id, opts->custom_vol[1] ? &(opts->vol_info[1]) : NULL,
+ opts->custom_vfd[1] ? &(opts->vfd_info[1]) : NULL)) < 0) {
+ parallel_print("h5diff: unable to create fapl for output file\n");
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "unable to create output fapl\n");
+ }
+ }
+
+ if ((file2_id = h5tools_fopen(fname2, H5F_ACC_RDONLY, fapl2_id, (fapl2_id != H5P_DEFAULT), NULL,
+ (size_t)0)) < 0) {
+ parallel_print("h5diff: <%s>: unable to open file\n", fname2);
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "<%s>: unable to open file\n", fname2);
+ }
+ H5TOOLS_DEBUG("file2_id = %s", fname2);
/*-------------------------------------------------------------------------
- * Initialize the info structs
- *-------------------------------------------------------------------------
- */
+ * Initialize the info structs
+ *-------------------------------------------------------------------------
+ */
trav_info_init(fname1, file1_id, &info1_obj);
trav_info_init(fname2, file2_id, &info2_obj);
+ H5TOOLS_DEBUG("trav_info_init initialized");
/* if any object is specified */
- if (objname1)
- {
- /* malloc 2 more for "/" and end-of-line */
- obj1fullname = (char*)HDcalloc(HDstrlen(objname1) + 2, sizeof(char));
- obj2fullname = (char*)HDcalloc(HDstrlen(objname2) + 2, sizeof(char));
-
+ if (objname1) {
/* make the given object1 fullpath, start with "/" */
- if (HDstrncmp(objname1, "/", 1))
- {
- HDstrcpy((char *)obj1fullname, "/");
- HDstrcat((char *)obj1fullname, objname1);
+ if (HDstrncmp(objname1, "/", 1) != 0) {
+#ifdef H5_HAVE_ASPRINTF
+ /* Use the asprintf() routine, since it does what we're trying to do below */
+ if (HDasprintf(&obj1fullname, "/%s", objname1) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "name buffer allocation failed");
+#else /* H5_HAVE_ASPRINTF */
+ /* (malloc 2 more for "/" and end-of-line) */
+ if ((obj1fullname = (char *)HDmalloc(HDstrlen(objname1) + 2)) == NULL)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "name buffer allocation failed");
+
+ HDstrcpy(obj1fullname, "/");
+ HDstrcat(obj1fullname, objname1);
+#endif /* H5_HAVE_ASPRINTF */
}
else
- HDstrcpy((char *)obj1fullname, objname1);
+ obj1fullname = HDstrdup(objname1);
+ H5TOOLS_DEBUG("obj1fullname = %s", obj1fullname);
/* make the given object2 fullpath, start with "/" */
- if (HDstrncmp(objname2, "/", 1))
- {
- HDstrcpy((char *)obj2fullname, "/");
- HDstrcat((char *)obj2fullname, objname2);
+ if (HDstrncmp(objname2, "/", 1) != 0) {
+#ifdef H5_HAVE_ASPRINTF
+ /* Use the asprintf() routine, since it does what we're trying to do below */
+ if (HDasprintf(&obj2fullname, "/%s", objname2) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "name buffer allocation failed");
+#else /* H5_HAVE_ASPRINTF */
+ /* (malloc 2 more for "/" and end-of-line) */
+ if ((obj2fullname = (char *)HDmalloc(HDstrlen(objname2) + 2)) == NULL)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "name buffer allocation failed");
+ HDstrcpy(obj2fullname, "/");
+ HDstrcat(obj2fullname, objname2);
+#endif /* H5_HAVE_ASPRINTF */
}
else
- HDstrcpy((char *)obj2fullname, objname2);
+ obj2fullname = HDstrdup(objname2);
+ H5TOOLS_DEBUG("obj2fullname = %s", obj2fullname);
/*----------------------------------------------------------
* check if obj1 is root, group, single object or symlink
*/
- if(!HDstrcmp((char *)obj1fullname, "/"))
- {
+ H5TOOLS_DEBUG("h5diff check if obj1=%s is root, group, single object or symlink", obj1fullname);
+ if (!HDstrcmp(obj1fullname, "/")) {
obj1type = H5TRAV_TYPE_GROUP;
}
- else
- {
+ else {
/* check if link itself exist */
- if(H5Lexists(file1_id, obj1fullname, H5P_DEFAULT) <= 0)
- {
- parallel_print ("Object <%s> could not be found in <%s>\n", obj1fullname, fname1);
- options->err_stat = 1;
- goto out;
+ if (H5Lexists(file1_id, obj1fullname, H5P_DEFAULT) <= 0) {
+ parallel_print("Object <%s> could not be found in <%s>\n", obj1fullname, fname1);
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Error: Object could not be found");
}
/* get info from link */
- if(H5Lget_info(file1_id, obj1fullname, &src_linfo1, H5P_DEFAULT) < 0)
- {
+ if (H5Lget_info2(file1_id, obj1fullname, &src_linfo1, H5P_DEFAULT) < 0) {
parallel_print("Unable to get link info from <%s>\n", obj1fullname);
- goto out;
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Lget_info failed");
}
info1_lp = info1_obj;
- /*
+ /*
* check the type of specified path for hard and symbolic links
*/
- if(src_linfo1.type == H5L_TYPE_HARD)
- {
+ if (src_linfo1.type == H5L_TYPE_HARD) {
+ size_t idx;
+
/* optional data pass */
- info1_obj->opts = (diff_opt_t*)options;
+ info1_obj->opts = (diff_opt_t *)opts;
- if(H5Oget_info_by_name(file1_id, obj1fullname, &oinfo1, H5P_DEFAULT) < 0)
- {
+ if (H5Oget_info_by_name3(file1_id, obj1fullname, &oinfo1, H5O_INFO_BASIC, H5P_DEFAULT) < 0) {
parallel_print("Error: Could not get file contents\n");
- options->err_stat = 1;
- goto out;
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Error: Could not get file contents");
}
- obj1type = oinfo1.type;
+ obj1type = (h5trav_type_t)oinfo1.type;
trav_info_add(info1_obj, obj1fullname, obj1type);
+ idx = info1_obj->nused - 1;
+ HDmemcpy(&info1_obj->paths[idx].obj_token, &oinfo1.token, sizeof(H5O_token_t));
+ info1_obj->paths[idx].fileno = oinfo1.fileno;
}
- else if (src_linfo1.type == H5L_TYPE_SOFT)
- {
+ else if (src_linfo1.type == H5L_TYPE_SOFT) {
obj1type = H5TRAV_TYPE_LINK;
trav_info_add(info1_obj, obj1fullname, obj1type);
}
- else if (src_linfo1.type == H5L_TYPE_EXTERNAL)
- {
+ else if (src_linfo1.type == H5L_TYPE_EXTERNAL) {
obj1type = H5TRAV_TYPE_UDLINK;
trav_info_add(info1_obj, obj1fullname, obj1type);
}
@@ -805,246 +792,266 @@ hsize_t h5diff(const char *fname1,
/*----------------------------------------------------------
* check if obj2 is root, group, single object or symlink
*/
- if(!HDstrcmp(obj2fullname, "/"))
- {
+ H5TOOLS_DEBUG("h5diff check if obj2=%s is root, group, single object or symlink", obj2fullname);
+ if (!HDstrcmp(obj2fullname, "/")) {
obj2type = H5TRAV_TYPE_GROUP;
}
- else
- {
+ else {
/* check if link itself exist */
- if(H5Lexists(file2_id, obj2fullname, H5P_DEFAULT) <= 0)
- {
- parallel_print ("Object <%s> could not be found in <%s>\n", obj2fullname, fname2);
- options->err_stat = 1;
- goto out;
+ if (H5Lexists(file2_id, obj2fullname, H5P_DEFAULT) <= 0) {
+ parallel_print("Object <%s> could not be found in <%s>\n", obj2fullname, fname2);
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Error: Object could not be found");
}
/* get info from link */
- if(H5Lget_info(file2_id, obj2fullname, &src_linfo2, H5P_DEFAULT) < 0)
- {
+ if (H5Lget_info2(file2_id, obj2fullname, &src_linfo2, H5P_DEFAULT) < 0) {
parallel_print("Unable to get link info from <%s>\n", obj2fullname);
- goto out;
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Lget_info failed");
}
info2_lp = info2_obj;
- /*
+ /*
* check the type of specified path for hard and symbolic links
*/
- if(src_linfo2.type == H5L_TYPE_HARD)
- {
+ if (src_linfo2.type == H5L_TYPE_HARD) {
+ size_t idx;
+
/* optional data pass */
- info2_obj->opts = (diff_opt_t*)options;
+ info2_obj->opts = (diff_opt_t *)opts;
- if(H5Oget_info_by_name(file2_id, obj2fullname, &oinfo2, H5P_DEFAULT) < 0)
- {
+ if (H5Oget_info_by_name3(file2_id, obj2fullname, &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) {
parallel_print("Error: Could not get file contents\n");
- options->err_stat = 1;
- goto out;
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Error: Could not get file contents");
}
- obj2type = oinfo2.type;
+ obj2type = (h5trav_type_t)oinfo2.type;
trav_info_add(info2_obj, obj2fullname, obj2type);
+ idx = info2_obj->nused - 1;
+ HDmemcpy(&info2_obj->paths[idx].obj_token, &oinfo2.token, sizeof(H5O_token_t));
+ info2_obj->paths[idx].fileno = oinfo2.fileno;
}
- else if (src_linfo2.type == H5L_TYPE_SOFT)
- {
+ else if (src_linfo2.type == H5L_TYPE_SOFT) {
obj2type = H5TRAV_TYPE_LINK;
trav_info_add(info2_obj, obj2fullname, obj2type);
}
- else if (src_linfo2.type == H5L_TYPE_EXTERNAL)
- {
+ else if (src_linfo2.type == H5L_TYPE_EXTERNAL) {
obj2type = H5TRAV_TYPE_UDLINK;
trav_info_add(info2_obj, obj2fullname, obj2type);
}
- }
+ }
}
/* if no object specified */
- else
- {
+ else {
+ H5TOOLS_DEBUG("h5diff no object specified");
/* set root group */
- obj1fullname = (char*)HDcalloc(2, sizeof(char));
- HDstrcat((char *)obj1fullname, "/");
- obj2fullname = (char*)HDcalloc(2, sizeof(char));
- HDstrcat((char *)obj2fullname, "/");
+ obj1fullname = (char *)HDstrdup("/");
+ obj1type = H5TRAV_TYPE_GROUP;
+ obj2fullname = (char *)HDstrdup("/");
+ obj2type = H5TRAV_TYPE_GROUP;
}
-
+ H5TOOLS_DEBUG("get any symbolic links info - errstat:%d", opts->err_stat);
/* get any symbolic links info */
- l_ret1 = H5tools_get_symlink_info(file1_id, obj1fullname, &trg_linfo1, TRUE);
- l_ret2 = H5tools_get_symlink_info(file2_id, obj2fullname, &trg_linfo2, TRUE);
+ l_ret1 = H5tools_get_symlink_info(file1_id, obj1fullname, &trg_linfo1, opts->follow_links);
+ l_ret2 = H5tools_get_symlink_info(file2_id, obj2fullname, &trg_linfo2, opts->follow_links);
/*---------------------------------------------
- * check for following symlinks
+ * check for following symlinks
*/
- if (options->follow_links)
- {
+ if (opts->follow_links) {
/* pass how to handle printing warning to linkinfo option */
- if(print_warn(options))
+ if (print_warn(opts))
trg_linfo1.opt.msg_mode = trg_linfo2.opt.msg_mode = 1;
/*-------------------------------
* check symbolic link (object1)
*/
+ H5TOOLS_DEBUG("h5diff check symbolic link (object1)");
/* dangling link */
- if (l_ret1 == 0)
- {
- if (options->no_dangle_links)
- {
- /* treat dangling link is error */
- if(options->m_verbose)
+ if (l_ret1 == 0) {
+ H5TOOLS_DEBUG("h5diff ... dangling link");
+ if (opts->no_dangle_links) {
+ /* treat dangling link as error */
+ if (opts->mode_verbose)
parallel_print("Warning: <%s> is a dangling link.\n", obj1fullname);
- options->err_stat = 1;
- goto out;
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "treat dangling link as error");
}
- else
- {
- if(options->m_verbose)
+ else {
+ if (opts->mode_verbose)
parallel_print("obj1 <%s> is a dangling link.\n", obj1fullname);
- if (l_ret1 != 0 || l_ret2 != 0)
- {
+ if (l_ret1 != 0 || l_ret2 != 0) {
nfound++;
print_found(nfound);
- goto out;
+ H5TOOLS_GOTO_DONE(H5DIFF_NO_ERR);
}
}
}
- else if(l_ret1 < 0) /* fail */
- {
- parallel_print ("Object <%s> could not be found in <%s>\n", obj1fullname, fname1);
- options->err_stat = 1;
- goto out;
+ else if (l_ret1 < 0) { /* fail */
+ parallel_print("Object <%s> could not be found in <%s>\n", obj1fullname, fname1);
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Object could not be found");
+ }
+ else if (l_ret1 != 2) { /* symbolic link */
+ obj1type = (h5trav_type_t)trg_linfo1.trg_type;
+ H5TOOLS_DEBUG("h5diff ... ... trg_linfo1.trg_type == H5L_TYPE_HARD");
+ if (info1_lp != NULL) {
+ size_t idx = info1_lp->nused - 1;
+
+ H5TOOLS_DEBUG("h5diff ... ... ... info1_obj not null");
+ HDmemcpy(&info1_lp->paths[idx].obj_token, &trg_linfo1.obj_token, sizeof(H5O_token_t));
+ info1_lp->paths[idx].type = (h5trav_type_t)trg_linfo1.trg_type;
+ info1_lp->paths[idx].fileno = trg_linfo1.fileno;
+ }
+ H5TOOLS_DEBUG("h5diff check symbolic link (object1) finished");
}
- else if(l_ret1 != 2) /* symbolic link */
- obj1type = trg_linfo1.trg_type;
/*-------------------------------
* check symbolic link (object2)
*/
-
+ H5TOOLS_DEBUG("h5diff check symbolic link (object2)");
/* dangling link */
- if (l_ret2 == 0)
- {
- if (options->no_dangle_links)
- {
- /* treat dangling link is error */
- if(options->m_verbose)
+ if (l_ret2 == 0) {
+ H5TOOLS_DEBUG("h5diff ... dangling link");
+ if (opts->no_dangle_links) {
+ /* treat dangling link as error */
+ if (opts->mode_verbose)
parallel_print("Warning: <%s> is a dangling link.\n", obj2fullname);
- options->err_stat = 1;
- goto out;
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "treat dangling link as error");
}
- else
- {
- if(options->m_verbose)
+ else {
+ if (opts->mode_verbose)
parallel_print("obj2 <%s> is a dangling link.\n", obj2fullname);
- if (l_ret1 != 0 || l_ret2 != 0)
- {
+ if (l_ret1 != 0 || l_ret2 != 0) {
nfound++;
print_found(nfound);
- goto out;
+ H5TOOLS_GOTO_DONE(H5DIFF_NO_ERR);
}
}
}
- else if(l_ret2 < 0) /* fail */
- {
- parallel_print ("Object <%s> could not be found in <%s>\n", obj2fullname, fname2);
- options->err_stat = 1;
- goto out;
+ else if (l_ret2 < 0) { /* fail */
+ parallel_print("Object <%s> could not be found in <%s>\n", obj2fullname, fname2);
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Object could not be found");
+ }
+ else if (l_ret2 != 2) { /* symbolic link */
+ obj2type = (h5trav_type_t)trg_linfo2.trg_type;
+ if (info2_lp != NULL) {
+ size_t idx = info2_lp->nused - 1;
+
+ H5TOOLS_DEBUG("h5diff ... ... ... info2_obj not null");
+ HDmemcpy(&info2_lp->paths[idx].obj_token, &trg_linfo2.obj_token, sizeof(H5O_token_t));
+ info2_lp->paths[idx].type = (h5trav_type_t)trg_linfo2.trg_type;
+ info2_lp->paths[idx].fileno = trg_linfo2.fileno;
+ }
+ H5TOOLS_DEBUG("h5diff check symbolic link (object1) finished");
}
- else if(l_ret2 != 2) /* symbolic link */
- obj2type = trg_linfo2.trg_type;
} /* end of if follow symlinks */
- /*
- * If verbose options is not used, don't need to traverse thorugh the list
- * of objects in the group to display objects information,
- * So use h5tools_is_obj_same() to improve performance by skipping
- * comparing details of same objects.
- */
+ /*
+ * If verbose options is not used, don't need to traverse through the list
+ * of objects in the group to display objects information,
+ * So use h5tools_is_obj_same() to improve performance by skipping
+ * comparing details of same objects.
+ */
- if(!(options->m_verbose || options->m_report))
- {
+ if (!(opts->mode_verbose || opts->mode_report)) {
+ H5TOOLS_DEBUG("h5diff NOT (opts->mode_verbose || opts->mode_report)");
/* if no danglink links */
- if ( l_ret1 > 0 && l_ret2 > 0 )
- if (h5tools_is_obj_same(file1_id,obj1fullname,file2_id,obj2fullname)!=0)
- goto out;
+ if (l_ret1 > 0 && l_ret2 > 0)
+ if (h5tools_is_obj_same(file1_id, obj1fullname, file2_id, obj2fullname) != 0)
+ H5TOOLS_GOTO_DONE(H5DIFF_NO_ERR);
}
-
- /* if both obj1 and obj2 are group */
- if (obj1type == H5TRAV_TYPE_GROUP && obj2type == H5TRAV_TYPE_GROUP)
- {
-
- /*
- * traverse group1
+ both_objs_grp = (obj1type == H5TRAV_TYPE_GROUP && obj2type == H5TRAV_TYPE_GROUP);
+ if (both_objs_grp) {
+ H5TOOLS_DEBUG("h5diff both_objs_grp TRUE");
+ /*
+ * traverse group1
*/
trav_info_init(fname1, file1_id, &info1_grp);
/* optional data pass */
- info1_grp->opts = (diff_opt_t*)options;
+ info1_grp->opts = (diff_opt_t *)opts;
- if(h5trav_visit(file1_id,obj1fullname,TRUE,TRUE,
- trav_grp_objs,trav_grp_symlinks, info1_grp) < 0)
- {
+ if (h5trav_visit(file1_id, obj1fullname, TRUE, TRUE, trav_grp_objs, trav_grp_symlinks, info1_grp,
+ H5O_INFO_BASIC) < 0) {
parallel_print("Error: Could not get file contents\n");
- options->err_stat = 1;
- goto out;
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Could not get file contents");
}
info1_lp = info1_grp;
- /*
- * traverse group2
+ /*
+ * traverse group2
*/
trav_info_init(fname2, file2_id, &info2_grp);
/* optional data pass */
- info2_grp->opts = (diff_opt_t*)options;
+ info2_grp->opts = (diff_opt_t *)opts;
- if(h5trav_visit(file2_id,obj2fullname,TRUE,TRUE,
- trav_grp_objs,trav_grp_symlinks, info2_grp) < 0)
- {
+ if (h5trav_visit(file2_id, obj2fullname, TRUE, TRUE, trav_grp_objs, trav_grp_symlinks, info2_grp,
+ H5O_INFO_BASIC) < 0) {
parallel_print("Error: Could not get file contents\n");
- options->err_stat = 1;
- goto out;
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Could not get file contents");
} /* end if */
info2_lp = info2_grp;
-
+ }
+ H5TOOLS_DEBUG("groups traversed - errstat:%d", opts->err_stat);
#ifdef H5_HAVE_PARALLEL
- if(g_Parallel)
- {
- if((HDstrlen(fname1) > MAX_FILENAME) ||
- (HDstrlen(fname2) > MAX_FILENAME))
- {
- HDfprintf(stderr, "The parallel diff only supports path names up to %d characters\n", MAX_FILENAME);
- MPI_Abort(MPI_COMM_WORLD, 0);
- } /* end if */
-
- HDstrcpy(filenames[0], fname1);
- HDstrcpy(filenames[1], fname2);
+ if (g_Parallel) {
+ int i;
- /* Alert the worker tasks that there's going to be work. */
- for(i = 1; i < g_nTasks; i++)
- MPI_Send(filenames, (MAX_FILENAME * 2), MPI_CHAR, i, MPI_TAG_PARALLEL, MPI_COMM_WORLD);
+ if ((HDstrlen(fname1) > MAX_FILENAME) || (HDstrlen(fname2) > MAX_FILENAME)) {
+ HDfprintf(stderr, "The parallel diff only supports path names up to %d characters\n",
+ MAX_FILENAME);
+ MPI_Abort(MPI_COMM_WORLD, 0);
} /* end if */
+
+ HDstrcpy(filenames[0], fname1);
+ HDstrcpy(filenames[1], fname2);
+
+ /* Alert the worker tasks that there's going to be work. */
+ for (i = 1; i < g_nTasks; i++)
+ MPI_Send(filenames, (MAX_FILENAME * 2), MPI_CHAR, i, MPI_TAG_PARALLEL, MPI_COMM_WORLD);
+ } /* end if */
#endif
- build_match_list (obj1fullname, info1_lp, obj2fullname, info2_lp,
- &match_list, options);
- nfound = diff_match(file1_id, obj1fullname, info1_lp,
- file2_id, obj2fullname, info2_lp,
- match_list, options);
- }
- else
- {
-#ifdef H5_HAVE_PARALLEL
- if(g_Parallel)
- /* Only single object diff, parallel workers won't be needed */
- phdiff_dismiss_workers();
-#endif
- nfound = diff_compare(file1_id, fname1, obj1fullname, info1_lp,
- file2_id, fname2, obj2fullname, info2_lp,
- options);
+ H5TOOLS_DEBUG("build_match_list next - errstat:%d", opts->err_stat);
+ /* process the objects */
+ build_match_list(obj1fullname, info1_lp, obj2fullname, info2_lp, &match_list, opts);
+ H5TOOLS_DEBUG("build_match_list finished - errstat:%d", opts->err_stat);
+ if (both_objs_grp) {
+ /*------------------------------------------------------
+ * print the list
+ */
+ if (opts->mode_verbose) {
+ unsigned u;
+
+ if (opts->mode_verbose_level > 2) {
+ parallel_print("file1: %s\n", fname1);
+ parallel_print("file2: %s\n", fname2);
+ }
+
+ parallel_print("\n");
+ /* if given objects is group under root */
+ if (HDstrcmp(obj1fullname, "/") != 0 || HDstrcmp(obj2fullname, "/") != 0)
+ parallel_print("group1 group2\n");
+ else
+ parallel_print("file1 file2\n");
+ parallel_print("---------------------------------------\n");
+ for (u = 0; u < match_list->nobjs; u++) {
+ int c1, c2;
+ c1 = (match_list->objs[u].flags[0]) ? 'x' : ' ';
+ c2 = (match_list->objs[u].flags[1]) ? 'x' : ' ';
+ parallel_print("%5c %6c %-15s\n", c1, c2, match_list->objs[u].name);
+ } /* end for */
+ parallel_print("\n");
+ } /* end if */
}
+ H5TOOLS_DEBUG("diff_match next - errstat:%d", opts->err_stat);
+ nfound = diff_match(file1_id, obj1fullname, info1_lp, file2_id, obj2fullname, info2_lp, match_list, opts);
+ H5TOOLS_DEBUG("diff_match nfound: %d - errstat:%d", nfound, opts->err_stat);
+
+done:
+ opts->err_stat = opts->err_stat | ret_value;
-out:
#ifdef H5_HAVE_PARALLEL
- if(g_Parallel)
+ if (g_Parallel)
/* All done at this point, let tasks know that they won't be needed */
phdiff_dismiss_workers();
#endif
@@ -1061,917 +1068,792 @@ out:
/* free buffers */
if (obj1fullname)
- HDfree((char *)obj1fullname);
+ HDfree(obj1fullname);
if (obj2fullname)
- HDfree((char *)obj2fullname);
+ HDfree(obj2fullname);
/* free link info buffer */
if (trg_linfo1.trg_path)
- HDfree((char *)trg_linfo1.trg_path);
+ HDfree(trg_linfo1.trg_path);
if (trg_linfo2.trg_path)
- HDfree((char *)trg_linfo2.trg_path);
+ HDfree(trg_linfo2.trg_path);
/* close */
H5E_BEGIN_TRY
{
H5Fclose(file1_id);
H5Fclose(file2_id);
- } H5E_END_TRY;
+ if (fapl1_id != H5P_DEFAULT)
+ H5Pclose(fapl1_id);
+ if (fapl2_id != H5P_DEFAULT)
+ H5Pclose(fapl2_id);
+ }
+ H5E_END_TRY;
+
+ H5TOOLS_ENDDEBUG(" - errstat:%d", opts->err_stat);
return nfound;
}
-
-
/*-------------------------------------------------------------------------
* Function: diff_match
*
- * Purpose:
- * Compare common objects in given groups according to table structure.
- * The table structure has flags which can be used to find common objects
- * and will be compared.
- * Common object means same name (absolute path) objects in both location.
- *
- * Return: Number of differences found
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ * Purpose: Compare common objects in given groups according to table structure.
+ * The table structure has flags which can be used to find common objects
+ * and will be compared.
+ * Common object means same name (absolute path) objects in both location.
*
- * Date: May 9, 2003
+ * Return: Number of differences found
*
- * Modifications: Jan 2005 Leon Arber, larber@uiuc.edu
- * Added support for parallel diffing
- *
- * Pedro Vicente, pvn@hdfgroup.org, Nov 4, 2008
- * Compare the graph and make h5diff return 1 for difference if
- * 1) the number of objects in file1 is not the same as in file2
- * 2) the graph does not match, i.e same names (absolute path)
- * 3) objects with the same name are not of the same type
+ * Modifications: Compare the graph and make h5diff return 1 for difference if
+ * 1) the number of objects in file1 is not the same as in file2
+ * 2) the graph does not match, i.e same names (absolute path)
+ * 3) objects with the same name are not of the same type
*-------------------------------------------------------------------------
*/
-hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1,
- hid_t file2_id, const char *grp2, trav_info_t *info2,
- trav_table_t *table, diff_opt_t *options)
+hsize_t
+diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, hid_t file2_id, const char *grp2,
+ trav_info_t *info2, trav_table_t *table, diff_opt_t *opts)
{
- hsize_t nfound = 0;
- unsigned i;
-
- char * grp1_path = "";
- char * grp2_path = "";
- char * obj1_fullpath = NULL;
- char * obj2_fullpath = NULL;
- h5trav_type_t objtype;
+ hsize_t nfound = 0;
+ unsigned i;
+ const char *grp1_path = "";
+ const char *grp2_path = "";
+ char *obj1_fullpath = NULL;
+ char *obj2_fullpath = NULL;
diff_args_t argdata;
- size_t idx1 = 0;
- size_t idx2 = 0;
-
+ size_t idx1 = 0;
+ size_t idx2 = 0;
+ diff_err_t ret_value = opts->err_stat;
- /*
+ H5TOOLS_START_DEBUG(" - errstat:%d", opts->err_stat);
+ /*
* if not root, prepare object name to be pre-appended to group path to
* make full path
*/
- if (HDstrcmp (grp1, "/"))
- grp1_path = (char *)grp1;
- if (HDstrcmp (grp2, "/"))
- grp2_path = (char *)grp2;
+ if (HDstrcmp(grp1, "/") != 0)
+ grp1_path = grp1;
+ if (HDstrcmp(grp2, "/") != 0)
+ grp2_path = grp2;
/*-------------------------------------------------------------------------
- * regarding the return value of h5diff (0, no difference in files, 1 difference )
- * 1) the number of objects in file1 must be the same as in file2
- * 2) the graph must match, i.e same names (absolute path)
- * 3) objects with the same name must be of the same type
- *-------------------------------------------------------------------------
- */
-
- /* not valid compare nused when --exclude-path option is used */
- if (!options->exclude_path)
- {
+ * regarding the return value of h5diff (0, no difference in files, 1 difference )
+ * 1) the number of objects in file1 must be the same as in file2
+ * 2) the graph must match, i.e same names (absolute path)
+ * 3) objects with the same name must be of the same type
+ *-------------------------------------------------------------------------
+ */
+
+ H5TOOLS_DEBUG("exclude_path opts->contents:%d", opts->contents);
+ /* not valid compare used when --exclude-path option is used */
+ if (!opts->exclude_path) {
/* number of different objects */
- if ( info1->nused != info2->nused )
- {
- options->contents = 0;
+ if (info1->nused != info2->nused) {
+ opts->contents = 0;
}
+ H5TOOLS_DEBUG("opts->exclude_path opts->contents:%d", opts->contents);
}
-
+
/* objects in one file and not the other */
- for( i = 0; i < table->nobjs; i++)
- {
- if( table->objs[i].flags[0] != table->objs[i].flags[1] )
- {
- options->contents = 0;
+ for (i = 0; i < table->nobjs; i++) {
+ if (table->objs[i].flags[0] != table->objs[i].flags[1]) {
+ opts->contents = 0;
break;
}
+ H5TOOLS_DEBUG("table->nobjs[%d] opts->contents:%d", i, opts->contents);
}
-
/*-------------------------------------------------------------------------
- * do the diff for common objects
- *-------------------------------------------------------------------------
- */
+ * do the diff for common objects
+ *-------------------------------------------------------------------------
+ */
#ifdef H5_HAVE_PARALLEL
{
- char *workerTasks = (char*)HDmalloc((g_nTasks - 1) * sizeof(char));
- int n;
- int busyTasks = 0;
- struct diffs_found nFoundbyWorker;
- struct diff_mpi_args args;
- int havePrintToken = 1;
- MPI_Status Status;
-
- /*set all tasks as free */
- HDmemset(workerTasks, 1, (g_nTasks - 1));
+ char *workerTasks = (char *)HDmalloc((size_t)(g_nTasks - 1) * sizeof(char));
+ int n;
+ int busyTasks = 0;
+ struct diffs_found nFoundbyWorker;
+ struct diff_mpi_args args;
+ int havePrintToken = 1;
+ MPI_Status Status;
+
+ /*set all tasks as free */
+ HDmemset(workerTasks, 1, (size_t)(g_nTasks - 1) * sizeof(char));
#endif
- for(i = 0; i < table->nobjs; i++)
- {
- if( table->objs[i].flags[0] && table->objs[i].flags[1])
- {
- objtype = table->objs[i].type;
- /* make full path for obj1 */
- obj1_fullpath = (char*)HDcalloc (HDstrlen(grp1_path) + strlen (table->objs[i].name) + 1, sizeof (char));
- HDstrcpy(obj1_fullpath, grp1_path);
- HDstrcat(obj1_fullpath, table->objs[i].name);
-
- /* make full path for obj2 */
- obj2_fullpath = (char*)HDcalloc (HDstrlen(grp2_path) + strlen (table->objs[i].name) + 1, sizeof (char));
- HDstrcpy(obj2_fullpath, grp2_path);
- HDstrcat(obj2_fullpath, table->objs[i].name);
-
- /* get index to figure out type of the object in file1 */
- while ( info1->paths[idx1].path &&
- (HDstrcmp (obj1_fullpath, info1->paths[idx1].path) != 0) )
- idx1++;
- /* get index to figure out type of the object in file2 */
- while ( info2->paths[idx2].path &&
- (HDstrcmp (obj2_fullpath, info2->paths[idx2].path) != 0) )
- idx2++;
-
- /* Set argdata to pass other args into diff() */
- argdata.type[0] = info1->paths[idx1].type;
- argdata.type[1] = info2->paths[idx2].type;
- argdata.is_same_trgobj = table->objs[i].is_same_trgobj;
-
- options->cmn_objs = 1;
- if(!g_Parallel)
- {
- nfound += diff(file1_id, obj1_fullpath,
- file2_id, obj2_fullpath,
- options, &argdata);
- } /* end if */
-#ifdef H5_HAVE_PARALLEL
- else
- {
- int workerFound = 0;
-
- h5diffdebug("beginning of big else block\n");
- /* We're in parallel mode */
- /* Since the data type of diff value is hsize_t which can
- * be arbitary large such that there is no MPI type that
- * matches it, the value is passed between processes as
- * an array of bytes in order to be portable. But this
- * may not work in non-homogeneous MPI environments.
- */
-
- /*Set up args to pass to worker task. */
- if(HDstrlen(obj1_fullpath) > 255 ||
- HDstrlen(obj2_fullpath) > 255)
- {
- printf("The parallel diff only supports object names up to 255 characters\n");
- MPI_Abort(MPI_COMM_WORLD, 0);
+ for (i = 0; i < table->nobjs; i++) {
+ H5TOOLS_DEBUG("diff for common objects[%d] - errstat:%d", i, opts->err_stat);
+ if (table->objs[i].flags[0] && table->objs[i].flags[1]) {
+ /* make full path for obj1 */
+#ifdef H5_HAVE_ASPRINTF
+ /* Use the asprintf() routine, since it does what we're trying to do below */
+ if (HDasprintf(&obj1_fullpath, "%s%s", grp1_path, table->objs[i].name) < 0) {
+ H5TOOLS_ERROR(H5DIFF_ERR, "name buffer allocation failed");
+ }
+#else /* H5_HAVE_ASPRINTF */
+ if ((obj1_fullpath = (char *)HDmalloc(HDstrlen(grp1_path) + HDstrlen(table->objs[i].name) + 1)) ==
+ NULL) {
+ H5TOOLS_ERROR(H5DIFF_ERR, "name buffer allocation failed");
+ }
+ else {
+ HDstrcpy(obj1_fullpath, grp1_path);
+ HDstrcat(obj1_fullpath, table->objs[i].name);
+ }
+#endif /* H5_HAVE_ASPRINTF */
+ H5TOOLS_DEBUG("diff_match path1 - %s", obj1_fullpath);
+
+ /* make full path for obj2 */
+#ifdef H5_HAVE_ASPRINTF
+ /* Use the asprintf() routine, since it does what we're trying to do below */
+ if (HDasprintf(&obj2_fullpath, "%s%s", grp2_path, table->objs[i].name) < 0) {
+ H5TOOLS_ERROR(H5DIFF_ERR, "name buffer allocation failed");
+ }
+#else /* H5_HAVE_ASPRINTF */
+ if ((obj2_fullpath = (char *)HDmalloc(HDstrlen(grp2_path) + HDstrlen(table->objs[i].name) + 1)) ==
+ NULL) {
+ H5TOOLS_ERROR(H5DIFF_ERR, "name buffer allocation failed");
+ }
+ else {
+ HDstrcpy(obj2_fullpath, grp2_path);
+ HDstrcat(obj2_fullpath, table->objs[i].name);
+ }
+#endif /* H5_HAVE_ASPRINTF */
+ H5TOOLS_DEBUG("diff_match path2 - %s", obj2_fullpath);
+
+ /* get index to figure out type of the object in file1 */
+ while (info1->paths[idx1].path && (HDstrcmp(obj1_fullpath, info1->paths[idx1].path) != 0))
+ idx1++;
+ /* get index to figure out type of the object in file2 */
+ while (info2->paths[idx2].path && (HDstrcmp(obj2_fullpath, info2->paths[idx2].path) != 0))
+ idx2++;
+
+ /* Set argdata to pass other args into diff() */
+ argdata.type[0] = info1->paths[idx1].type;
+ argdata.type[1] = info2->paths[idx2].type;
+ argdata.is_same_trgobj = table->objs[i].is_same_trgobj;
+
+ opts->cmn_objs = 1;
+ if (!g_Parallel) {
+ H5TOOLS_DEBUG("diff paths - errstat:%d", opts->err_stat);
+ nfound += diff(file1_id, obj1_fullpath, file2_id, obj2_fullpath, opts, &argdata);
} /* end if */
+#ifdef H5_HAVE_PARALLEL
+ else {
+ int workerFound = 0;
+
+ H5TOOLS_DEBUG("Beginning of big else block");
+ /* We're in parallel mode */
+ /* Since the data type of diff value is hsize_t which can
+ * be arbitrary large such that there is no MPI type that
+ * matches it, the value is passed between processes as
+ * an array of bytes in order to be portable. But this
+ * may not work in non-homogeneous MPI environments.
+ */
- /* set args struct to pass */
- HDstrcpy(args.name1, obj1_fullpath);
- HDstrcpy(args.name2, obj2_fullpath);
- args.options = *options;
- args.argdata.type[0] = info1->paths[idx1].type;
- args.argdata.type[1] = info2->paths[idx2].type;
- args.argdata.is_same_trgobj = table->objs[i].is_same_trgobj;
-
- h5diffdebug2("busyTasks=%d\n", busyTasks);
- /* if there are any outstanding print requests, let's handle one. */
- if(busyTasks > 0)
- {
- int incomingMessage;
-
- /* check if any tasks freed up, and didn't need to print. */
- MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &incomingMessage, &Status);
-
- /* first block*/
- if(incomingMessage)
- {
- workerTasks[Status.MPI_SOURCE - 1] = 1;
- MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &Status);
- nfound += nFoundbyWorker.nfound;
- options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp;
- busyTasks--;
+ /*Set up args to pass to worker task. */
+ if (HDstrlen(obj1_fullpath) > 255 || HDstrlen(obj2_fullpath) > 255) {
+ HDprintf("The parallel diff only supports object names up to 255 characters\n");
+ MPI_Abort(MPI_COMM_WORLD, 0);
} /* end if */
- /* check to see if the print token was returned. */
- if(!havePrintToken)
- {
- /* If we don't have the token, someone is probably sending us output */
- print_incoming_data();
+ /* set args struct to pass */
+ HDstrcpy(args.name1, obj1_fullpath);
+ HDstrcpy(args.name2, obj2_fullpath);
+ args.opts = *opts;
+ args.argdata.type[0] = info1->paths[idx1].type;
+ args.argdata.type[1] = info2->paths[idx2].type;
+ args.argdata.is_same_trgobj = table->objs[i].is_same_trgobj;
- /* check incoming queue for token */
- MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status);
+ /* if there are any outstanding print requests, let's handle one. */
+ if (busyTasks > 0) {
+ int incomingMessage;
- /* incoming token implies free task. */
- if(incomingMessage) {
+ /* check if any tasks freed up, and didn't need to print. */
+ MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &incomingMessage, &Status);
+
+ /* first block*/
+ if (incomingMessage) {
workerTasks[Status.MPI_SOURCE - 1] = 1;
- MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status);
+ MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE,
+ MPI_TAG_DONE, MPI_COMM_WORLD, &Status);
nfound += nFoundbyWorker.nfound;
- options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp;
+ opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp;
busyTasks--;
- havePrintToken = 1;
} /* end if */
- } /* end if */
- /* check to see if anyone needs the print token. */
- if(havePrintToken)
- {
- /* check incoming queue for print token requests */
- MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD, &incomingMessage, &Status);
- if(incomingMessage)
- {
- MPI_Recv(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD, &Status);
- MPI_Send(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD);
- havePrintToken = 0;
+ /* check to see if the print token was returned. */
+ if (!havePrintToken) {
+ /* If we don't have the token, someone is probably sending us output */
+ print_incoming_data();
+
+ /* check incoming queue for token */
+ MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage,
+ &Status);
+
+ /* incoming token implies free task. */
+ if (incomingMessage) {
+ workerTasks[Status.MPI_SOURCE - 1] = 1;
+ MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE,
+ MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status);
+ nfound += nFoundbyWorker.nfound;
+ opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp;
+ busyTasks--;
+ havePrintToken = 1;
+ } /* end if */
+ } /* end if */
+
+ /* check to see if anyone needs the print token. */
+ if (havePrintToken) {
+ /* check incoming queue for print token requests */
+ MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD, &incomingMessage,
+ &Status);
+ if (incomingMessage) {
+ MPI_Recv(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_REQUEST,
+ MPI_COMM_WORLD, &Status);
+ MPI_Send(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_PRINT_TOK,
+ MPI_COMM_WORLD);
+ havePrintToken = 0;
+ } /* end if */
+ } /* end if */
+ } /* end if */
+
+ /* check array of tasks to see which ones are free.
+ * Manager task never does work, so freeTasks[0] is really
+ * worker task 0. */
+ for (n = 1; (n < g_nTasks) && !workerFound; n++) {
+ if (workerTasks[n - 1]) {
+ /* send file id's and names to first free worker */
+ MPI_Send(&args, sizeof(args), MPI_BYTE, n, MPI_TAG_ARGS, MPI_COMM_WORLD);
+
+ /* increment counter for total number of prints. */
+ busyTasks++;
+
+ /* mark worker as busy */
+ workerTasks[n - 1] = 0;
+ workerFound = 1;
} /* end if */
- } /* end if */
- } /* end if */
+ } /* end for */
- /* check array of tasks to see which ones are free.
- * Manager task never does work, so freeTasks[0] is really
- * worker task 0. */
- for(n = 1; (n < g_nTasks) && !workerFound; n++)
- {
- if(workerTasks[n-1])
- {
- /* send file id's and names to first free worker */
- MPI_Send(&args, sizeof(args), MPI_BYTE, n, MPI_TAG_ARGS, MPI_COMM_WORLD);
-
- /* increment counter for total number of prints. */
- busyTasks++;
-
- /* mark worker as busy */
- workerTasks[n - 1] = 0;
- workerFound = 1;
- } /* end if */
- } /* end for */
-
- h5diffdebug2("workerfound is %d \n", workerFound);
- if(!workerFound)
- {
- /* if they were all busy, we've got to wait for one free up
- * before we can move on. If we don't have the token, some
- * task is currently printing so we'll wait for that task to
- * return it.
- */
+ if (!workerFound) {
+ /* if they were all busy, we've got to wait for one free up
+ * before we can move on. If we don't have the token, some
+ * task is currently printing so we'll wait for that task to
+ * return it.
+ */
- if(!havePrintToken)
- {
- while(!havePrintToken)
- {
- int incomingMessage;
+ if (!havePrintToken) {
+ while (!havePrintToken) {
+ int incomingMessage;
+ print_incoming_data();
+ MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD,
+ &incomingMessage, &Status);
+ if (incomingMessage) {
+ MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE,
+ MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status);
+ havePrintToken = 1;
+ nfound += nFoundbyWorker.nfound;
+ opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp;
+ /* send this task the work unit. */
+ MPI_Send(&args, sizeof(args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS,
+ MPI_COMM_WORLD);
+ } /* end if */
+ } /* end while */
+ } /* end if */
+ /* if we do have the token, check for task to free up, or wait for a task to request
+ * it */
+ else {
+ /* But first print all the data in our incoming queue */
print_incoming_data();
- MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status);
- if(incomingMessage)
- {
- MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status);
- havePrintToken = 1;
+ MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &Status);
+ if (Status.MPI_TAG == MPI_TAG_DONE) {
+ MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE,
+ MPI_TAG_DONE, MPI_COMM_WORLD, &Status);
nfound += nFoundbyWorker.nfound;
- options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp;
- /* send this task the work unit. */
- MPI_Send(&args, sizeof(args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, MPI_COMM_WORLD);
+ opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp;
+ MPI_Send(&args, sizeof(args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS,
+ MPI_COMM_WORLD);
} /* end if */
- } /* end while */
- } /* end if */
- /* if we do have the token, check for task to free up, or wait for a task to request it */
- else
- {
- /* But first print all the data in our incoming queue */
- print_incoming_data();
- MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &Status);
- if(Status.MPI_TAG == MPI_TAG_DONE)
- {
- MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &Status);
- nfound += nFoundbyWorker.nfound;
- options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp;
- MPI_Send(&args, sizeof(args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, MPI_COMM_WORLD);
- } /* end if */
- else if(Status.MPI_TAG == MPI_TAG_TOK_REQUEST)
- {
- int incomingMessage;
+ else if (Status.MPI_TAG == MPI_TAG_TOK_REQUEST) {
+ int incomingMessage;
- MPI_Recv(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD, &Status);
- MPI_Send(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD);
+ MPI_Recv(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_REQUEST,
+ MPI_COMM_WORLD, &Status);
+ MPI_Send(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_PRINT_TOK,
+ MPI_COMM_WORLD);
- do
- {
- MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status);
+ do {
+ MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD,
+ &incomingMessage, &Status);
- print_incoming_data();
- } while(!incomingMessage);
+ print_incoming_data();
+ } while (!incomingMessage);
- MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status);
- nfound += nFoundbyWorker.nfound;
- options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp;
- MPI_Send(&args, sizeof(args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, MPI_COMM_WORLD);
- } /* end else-if */
- else
- {
- printf("ERROR: Invalid tag (%d) received \n", Status.MPI_TAG);
- MPI_Abort(MPI_COMM_WORLD, 0);
- MPI_Finalize();
- } /* end else */
- } /* end else */
- } /* end if */
- } /* end else */
-#endif /* H5_HAVE_PARALLEL */
- if (obj1_fullpath)
- HDfree (obj1_fullpath);
- if (obj2_fullpath)
- HDfree (obj2_fullpath);
- } /* end if */
- } /* end for */
- h5diffdebug("done with for loop\n");
+ MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE,
+ MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status);
+ nfound += nFoundbyWorker.nfound;
+ opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp;
+ MPI_Send(&args, sizeof(args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS,
+ MPI_COMM_WORLD);
+ } /* end else-if */
+ else {
+ HDprintf("ERROR: Invalid tag (%d) received \n", Status.MPI_TAG);
+ MPI_Abort(MPI_COMM_WORLD, 0);
+ MPI_Finalize();
+ } /* end else */
+ } /* end else */
+ } /* end if */
+ } /* end else */
+#endif /* H5_HAVE_PARALLEL */
+ if (obj1_fullpath)
+ HDfree(obj1_fullpath);
+ if (obj2_fullpath)
+ HDfree(obj2_fullpath);
+ } /* end if */
+ } /* end for */
+ H5TOOLS_DEBUG("done with for loop - errstat:%d", opts->err_stat);
#ifdef H5_HAVE_PARALLEL
- if(g_Parallel)
- {
- /* make sure all tasks are done */
- while(busyTasks > 0)
- {
- MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &Status);
- if(Status.MPI_TAG == MPI_TAG_DONE)
- {
- MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &Status);
- nfound += nFoundbyWorker.nfound;
- options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp;
- busyTasks--;
- } /* end if */
- else if(Status.MPI_TAG == MPI_TAG_TOK_RETURN)
- {
- MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &Status);
- nfound += nFoundbyWorker.nfound;
- options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp;
- busyTasks--;
- havePrintToken = 1;
- } /* end else-if */
- else if(Status.MPI_TAG == MPI_TAG_TOK_REQUEST)
- {
- MPI_Recv(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD, &Status);
- if(havePrintToken)
- {
- int incomingMessage;
-
- MPI_Send(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD);
-
- do {
- MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status);
-
- print_incoming_data();
- } while(!incomingMessage);
-
- MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status);
+ if (g_Parallel) {
+ /* make sure all tasks are done */
+ while (busyTasks > 0) {
+ MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &Status);
+ if (Status.MPI_TAG == MPI_TAG_DONE) {
+ MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE,
+ MPI_TAG_DONE, MPI_COMM_WORLD, &Status);
nfound += nFoundbyWorker.nfound;
- options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp;
+ opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp;
busyTasks--;
} /* end if */
- /* someone else must have it...wait for them to return it, then give it to the task that just asked for it. */
- else
- {
- int source = Status.MPI_SOURCE;
- int incomingMessage;
+ else if (Status.MPI_TAG == MPI_TAG_TOK_REQUEST) {
+ MPI_Recv(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD,
+ &Status);
+ if (havePrintToken) {
+ int incomingMessage;
- do
- {
- MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status);
+ MPI_Send(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD);
- print_incoming_data();
- } while(!incomingMessage);
+ do {
+ MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage,
+ &Status);
+ print_incoming_data();
+ } while (!incomingMessage);
- MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status);
+ MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE,
+ MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status);
+ nfound += nFoundbyWorker.nfound;
+ opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp;
+ busyTasks--;
+ } /* end if */
+ /* someone else must have it...wait for them to return it, then give it to the task that
+ * just asked for it. */
+ else {
+ int source = Status.MPI_SOURCE;
+ int incomingMessage;
+
+ do {
+ MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage,
+ &Status);
+
+ print_incoming_data();
+ } while (!incomingMessage);
+
+ MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, MPI_ANY_SOURCE,
+ MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status);
+ nfound += nFoundbyWorker.nfound;
+ opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp;
+ busyTasks--;
+ MPI_Send(NULL, 0, MPI_BYTE, source, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD);
+ } /* end else */
+ } /* end else-if */
+ else if (Status.MPI_TAG == MPI_TAG_TOK_RETURN) {
+ MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE,
+ MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status);
nfound += nFoundbyWorker.nfound;
- options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp;
+ opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp;
busyTasks--;
- MPI_Send(NULL, 0, MPI_BYTE, source, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD);
+ havePrintToken = 1;
+ } /* end else-if */
+ else if (Status.MPI_TAG == MPI_TAG_PRINT_DATA) {
+ char data[PRINT_DATA_MAX_SIZE + 1];
+ HDmemset(data, 0, PRINT_DATA_MAX_SIZE + 1);
+
+ MPI_Recv(data, PRINT_DATA_MAX_SIZE, MPI_CHAR, Status.MPI_SOURCE, MPI_TAG_PRINT_DATA,
+ MPI_COMM_WORLD, &Status);
+
+ HDprintf("%s", data);
+ } /* end else-if */
+ else {
+ HDprintf("ph5diff-manager: ERROR!! Invalid tag (%d) received \n", Status.MPI_TAG);
+ MPI_Abort(MPI_COMM_WORLD, 0);
} /* end else */
- } /* end else-if */
- else if(Status.MPI_TAG == MPI_TAG_TOK_RETURN)
- {
- MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status);
- nfound += nFoundbyWorker.nfound;
- options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp;
- busyTasks--;
- havePrintToken = 1;
- } /* end else-if */
- else if(Status.MPI_TAG == MPI_TAG_PRINT_DATA)
- {
- char data[PRINT_DATA_MAX_SIZE + 1];
- HDmemset(data, 0, PRINT_DATA_MAX_SIZE + 1);
-
- MPI_Recv(data, PRINT_DATA_MAX_SIZE, MPI_CHAR, Status.MPI_SOURCE, MPI_TAG_PRINT_DATA, MPI_COMM_WORLD, &Status);
-
- printf("%s", data);
- } /* end else-if */
- else
- {
- printf("ph5diff-manager: ERROR!! Invalid tag (%d) received \n", Status.MPI_TAG);
- MPI_Abort(MPI_COMM_WORLD, 0);
- } /* end else */
- } /* end while */
+ } /* end while */
- for(i = 1; i < g_nTasks; i++)
- MPI_Send(NULL, 0, MPI_BYTE, i, MPI_TAG_END, MPI_COMM_WORLD);
+ for (i = 1; (int)i < g_nTasks; i++)
+ MPI_Send(NULL, 0, MPI_BYTE, (int)i, MPI_TAG_END, MPI_COMM_WORLD);
- /* Print any final data waiting in our queue */
- print_incoming_data();
- } /* end if */
- h5diffdebug("done with if block\n");
+ /* Print any final data waiting in our queue */
+ print_incoming_data();
+ } /* end if */
+ H5TOOLS_DEBUG("done with if block");
- HDfree(workerTasks);
+ HDfree(workerTasks);
}
#endif /* H5_HAVE_PARALLEL */
+ opts->err_stat = opts->err_stat | ret_value;
+
+ free_exclude_attr_list(opts);
+
/* free table */
if (table)
trav_table_free(table);
- return nfound;
-}
-
-
-/*-------------------------------------------------------------------------
- * Function: diff_compare
- *
- * Purpose: get objects from list, and check for the same type
- *
- * Return: Number of differences found
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- * Date: May 9, 2003
- *
- * Programmer: Jonathan Kim
- * - add following links feature (Feb 11,2010)
- *-------------------------------------------------------------------------
- */
-
-hsize_t diff_compare(hid_t file1_id,
- const char *file1_name,
- const char *obj1_name,
- trav_info_t *info1,
- hid_t file2_id,
- const char *file2_name,
- const char *obj2_name,
- trav_info_t *info2,
- diff_opt_t *options)
-{
- int f1 = 0;
- int f2 = 0;
- hsize_t nfound = 0;
- ssize_t i,j;
- int l_ret;
- int is_dangle_link1 = 0;
- int is_dangle_link2 = 0;
- const char *obj1name = obj1_name;
- const char *obj2name = obj2_name;
- diff_args_t argdata;
-
- /* local variables for diff() */
- h5trav_type_t obj1type, obj2type;
-
- /* to get link info */
- h5tool_link_info_t linkinfo1;
- h5tool_link_info_t linkinfo2;
-
- /* init link info struct */
- HDmemset(&linkinfo1, 0, sizeof(h5tool_link_info_t));
- HDmemset(&linkinfo2, 0, sizeof(h5tool_link_info_t));
-
- i = h5trav_getindex (info1, obj1name);
- j = h5trav_getindex (info2, obj2name);
-
- if (i == -1)
- {
- parallel_print ("Object <%s> could not be found in <%s>\n", obj1name,
- file1_name);
- f1 = 1;
- }
- if (j == -1)
- {
- parallel_print ("Object <%s> could not be found in <%s>\n", obj2name,
- file2_name);
- f2 = 1;
- }
- if (f1 || f2)
- {
- options->err_stat = 1;
- return 0;
- }
- /* use the name with "/" first, as obtained by iterator function */
- obj1name = info1->paths[i].path;
- obj2name = info2->paths[j].path;
-
- obj1type = info1->paths[i].type;
- obj2type = info2->paths[j].type;
-
- /* Set argdata to pass other args into diff() */
- argdata.type[0] = obj1type;
- argdata.type[1] = obj2type;
- argdata.is_same_trgobj = 0;
-
- nfound = diff(file1_id, obj1name,
- file2_id, obj2name,
- options, &argdata);
-
-out:
- /*-------------------------------
- * handle dangling link(s) */
- /* both obj1 and obj2 are dangling links */
- if(is_dangle_link1 && is_dangle_link2)
- {
- if(print_objname(options, nfound))
- {
- do_print_objname("dangling link", obj1name, obj2name, options);
- print_found(nfound);
- }
- }
- /* obj1 is dangling link */
- else if (is_dangle_link1)
- {
- if(options->m_verbose)
- parallel_print("obj1 <%s> is a dangling link.\n", obj1name);
- nfound++;
- if(print_objname(options, nfound))
- print_found(nfound);
- }
- /* obj2 is dangling link */
- else if (is_dangle_link2)
- {
- if(options->m_verbose)
- parallel_print("obj2 <%s> is a dangling link.\n", obj2name);
- nfound++;
- if(print_objname(options, nfound))
- print_found(nfound);
- }
-
- /* free link info buffer */
- if (linkinfo1.trg_path)
- HDfree((char *)linkinfo1.trg_path);
- if (linkinfo2.trg_path)
- HDfree((char *)linkinfo2.trg_path);
+ H5TOOLS_ENDDEBUG(" diffs=%d - errstat:%d", nfound, opts->err_stat);
return nfound;
}
-
/*-------------------------------------------------------------------------
* Function: diff
*
- * Purpose: switch between types and choose the diff function
- * TYPE is either
- * H5G_GROUP Object is a group
- * H5G_DATASET Object is a dataset
- * H5G_TYPE Object is a named data type
- * H5G_LINK Object is a symbolic link
- *
- * Return: Number of differences found
+ * Purpose: switch between types and choose the diff function
+ * TYPE is either
+ * H5G_GROUP Object is a group
+ * H5G_DATASET Object is a dataset
+ * H5G_TYPE Object is a named data type
+ * H5G_LINK Object is a symbolic link
*
- * Programmer: Jonathan Kim
- * - Move follow symlinks code toward top. (March 2812)
- * - Add following symlinks feature (Feb 11,2010)
- * - Change to use diff_args_t to pass the rest of args.
- * Passing through it instead of individual args provides smoother
- * extensibility through its members along with MPI code update for ph5diff
- * as it doesn't require interface change.
- * (May 6,2011)
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- * Date: May 9, 2003
+ * Return: Number of differences found
*-------------------------------------------------------------------------
*/
-
-hsize_t diff(hid_t file1_id,
- const char *path1,
- hid_t file2_id,
- const char *path2,
- diff_opt_t * options,
- diff_args_t *argdata)
+hsize_t
+diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_opt_t *opts,
+ diff_args_t *argdata)
{
- hid_t type1_id = (-1);
- hid_t type2_id = (-1);
- hid_t grp1_id = (-1);
- hid_t grp2_id = (-1);
- int ret;
- int is_dangle_link1 = 0;
- int is_dangle_link2 = 0;
- int is_hard_link = 0;
- hsize_t nfound = 0;
+ int status = -1;
+ hid_t dset1_id = H5I_INVALID_HID;
+ hid_t dset2_id = H5I_INVALID_HID;
+ hid_t type1_id = H5I_INVALID_HID;
+ hid_t type2_id = H5I_INVALID_HID;
+ hid_t grp1_id = H5I_INVALID_HID;
+ hid_t grp2_id = H5I_INVALID_HID;
+ hbool_t is_dangle_link1 = FALSE;
+ hbool_t is_dangle_link2 = FALSE;
+ hbool_t is_hard_link = FALSE;
+ hsize_t nfound = 0;
h5trav_type_t object_type;
-
+ diff_err_t ret_value = opts->err_stat;
/* to get link info */
h5tool_link_info_t linkinfo1;
h5tool_link_info_t linkinfo2;
+ H5TOOLS_START_DEBUG(" - errstat:%d", opts->err_stat);
+
/*init link info struct */
- HDmemset(&linkinfo1,0,sizeof(h5tool_link_info_t));
- HDmemset(&linkinfo2,0,sizeof(h5tool_link_info_t));
+ HDmemset(&linkinfo1, 0, sizeof(h5tool_link_info_t));
+ HDmemset(&linkinfo2, 0, sizeof(h5tool_link_info_t));
/* pass how to handle printing warnings to linkinfo option */
- if(print_warn(options))
+ if (print_warn(opts))
linkinfo1.opt.msg_mode = linkinfo2.opt.msg_mode = 1;
- /* for symbolic links, take care follow symlink and no dangling link
+ /* for symbolic links, take care follow symlink and no dangling link
* options */
- if (argdata->type[0] == H5TRAV_TYPE_LINK ||
- argdata->type[0] == H5TRAV_TYPE_UDLINK ||
- argdata->type[1] == H5TRAV_TYPE_LINK ||
- argdata->type[1] == H5TRAV_TYPE_UDLINK )
- {
- /*
+ if (argdata->type[0] == H5TRAV_TYPE_LINK || argdata->type[0] == H5TRAV_TYPE_UDLINK ||
+ argdata->type[1] == H5TRAV_TYPE_LINK || argdata->type[1] == H5TRAV_TYPE_UDLINK) {
+ /*
* check dangling links for path1 and path2
*/
+ H5TOOLS_DEBUG("diff links");
/* target object1 - get type and name */
- ret = H5tools_get_symlink_info(file1_id, path1, &linkinfo1, TRUE);
+ if ((status = H5tools_get_symlink_info(file1_id, path1, &linkinfo1, opts->follow_links)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5tools_get_symlink_info failed");
+
/* dangling link */
- if (ret == 0)
- {
- if (options->no_dangle_links)
- {
- /* gangling link is error */
- if(options->m_verbose)
+ if (status == 0) {
+ if (opts->no_dangle_links) {
+ /* dangling link is error */
+ if (opts->mode_verbose)
parallel_print("Warning: <%s> is a dangling link.\n", path1);
- goto out;
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "dangling link is error");
}
else
- is_dangle_link1 = 1;
+ is_dangle_link1 = TRUE;
}
- else if (ret < 0)
- goto out;
/* target object2 - get type and name */
- ret = H5tools_get_symlink_info(file2_id, path2, &linkinfo2, TRUE);
+ if ((status = H5tools_get_symlink_info(file2_id, path2, &linkinfo2, opts->follow_links)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5tools_get_symlink_info failed");
/* dangling link */
- if (ret == 0)
- {
- if (options->no_dangle_links)
- {
- /* gangling link is error */
- if(options->m_verbose)
+ if (status == 0) {
+ if (opts->no_dangle_links) {
+ /* dangling link is error */
+ if (opts->mode_verbose)
parallel_print("Warning: <%s> is a dangling link.\n", path2);
- goto out;
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "dangling link is error");
}
else
- is_dangle_link2 = 1;
+ is_dangle_link2 = TRUE;
}
- else if (ret < 0)
- goto out;
-
+
/* found dangling link */
- if (is_dangle_link1 || is_dangle_link2)
- goto out2;
+ if (is_dangle_link1 || is_dangle_link2) {
+ H5TOOLS_GOTO_DONE(H5DIFF_NO_ERR);
+ }
/* follow symbolic link option */
- if (options->follow_links)
- {
- if (linkinfo1.linfo.type == H5L_TYPE_SOFT ||
- linkinfo1.linfo.type == H5L_TYPE_EXTERNAL)
- argdata->type[0] = linkinfo1.trg_type;
-
- if (linkinfo2.linfo.type == H5L_TYPE_SOFT ||
- linkinfo2.linfo.type == H5L_TYPE_EXTERNAL)
- argdata->type[1] = linkinfo2.trg_type;
+ if (opts->follow_links) {
+ if (linkinfo1.linfo.type == H5L_TYPE_SOFT || linkinfo1.linfo.type == H5L_TYPE_EXTERNAL)
+ argdata->type[0] = (h5trav_type_t)linkinfo1.trg_type;
+
+ if (linkinfo2.linfo.type == H5L_TYPE_SOFT || linkinfo2.linfo.type == H5L_TYPE_EXTERNAL)
+ argdata->type[1] = (h5trav_type_t)linkinfo2.trg_type;
}
}
/* if objects are not the same type */
- if (argdata->type[0] != argdata->type[1])
- {
- if (options->m_verbose||options->m_list_not_cmp)
- {
- parallel_print("Not comparable: <%s> is of type %s and <%s> is of type %s\n",
- path1, get_type(argdata->type[0]),
- path2, get_type(argdata->type[1]));
+ if (argdata->type[0] != argdata->type[1]) {
+ H5TOOLS_DEBUG("diff objects are not the same");
+ if (opts->mode_verbose || opts->mode_list_not_cmp) {
+ parallel_print("Not comparable: <%s> is of type %s and <%s> is of type %s\n", path1,
+ get_type(argdata->type[0]), path2, get_type(argdata->type[1]));
}
- options->not_cmp=1;
+
+ opts->not_cmp = 1;
/* TODO: will need to update non-comparable is different
- * options->contents = 0;
+ * opts->contents = 0;
*/
- goto out2;
+ H5TOOLS_GOTO_DONE(H5DIFF_NO_ERR);
}
else /* now both object types are same */
object_type = argdata->type[0];
-
- /*
+
+ /*
* If both points to the same target object, skip comparing details inside
* of the objects to improve performance.
- * Always check for the hard links, otherwise if follow symlink option is
+ * Always check for the hard links, otherwise if follow symlink option is
* specified.
*
* Perform this to match the outputs as bypassing.
*/
- if (argdata->is_same_trgobj)
- {
- is_hard_link = (object_type == H5TRAV_TYPE_DATASET ||
- object_type == H5TRAV_TYPE_NAMED_DATATYPE ||
+ if (argdata->is_same_trgobj) {
+ H5TOOLS_DEBUG("argdata->is_same_trgobj");
+ is_hard_link = (object_type == H5TRAV_TYPE_DATASET || object_type == H5TRAV_TYPE_NAMED_DATATYPE ||
object_type == H5TRAV_TYPE_GROUP);
- if (options->follow_links || is_hard_link)
- {
+ if (opts->follow_links || is_hard_link) {
/* print information is only verbose option is used */
- if(options->m_verbose || options->m_report)
- {
- switch(object_type)
- {
- case H5TRAV_TYPE_DATASET:
- do_print_objname("dataset", path1, path2, options);
- break;
- case H5TRAV_TYPE_NAMED_DATATYPE:
- do_print_objname("datatype", path1, path2, options);
- break;
- case H5TRAV_TYPE_GROUP:
- do_print_objname("group", path1, path2, options);
- break;
- case H5TRAV_TYPE_LINK:
- do_print_objname("link", path1, path2, options);
- break;
- case H5TRAV_TYPE_UDLINK:
- if(linkinfo1.linfo.type == H5L_TYPE_EXTERNAL && linkinfo2.linfo.type == H5L_TYPE_EXTERNAL)
- do_print_objname("external link", path1, path2, options);
- else
- do_print_objname ("user defined link", path1, path2, options);
- break;
- default:
- parallel_print("Comparison not supported: <%s> and <%s> are of type %s\n",
- path1, path2, get_type(object_type) );
- options->not_cmp = 1;
- break;
+ if (opts->mode_verbose || opts->mode_report) {
+ switch (object_type) {
+ case H5TRAV_TYPE_DATASET:
+ do_print_objname("dataset", path1, path2, opts);
+ break;
+ case H5TRAV_TYPE_NAMED_DATATYPE:
+ do_print_objname("datatype", path1, path2, opts);
+ break;
+ case H5TRAV_TYPE_GROUP:
+ do_print_objname("group", path1, path2, opts);
+ break;
+ case H5TRAV_TYPE_LINK:
+ do_print_objname("link", path1, path2, opts);
+ break;
+ case H5TRAV_TYPE_UDLINK:
+ if (linkinfo1.linfo.type == H5L_TYPE_EXTERNAL &&
+ linkinfo2.linfo.type == H5L_TYPE_EXTERNAL)
+ do_print_objname("external link", path1, path2, opts);
+ else
+ do_print_objname("user defined link", path1, path2, opts);
+ break;
+ case H5TRAV_TYPE_UNKNOWN:
+ default:
+ parallel_print("Comparison not supported: <%s> and <%s> are of type %s\n", path1,
+ path2, get_type(object_type));
+ opts->not_cmp = 1;
+ break;
} /* switch(type)*/
print_found(nfound);
- } /* if(options->m_verbose || options->m_report) */
+ } /* if(opts->mode_verbose || opts->mode_report) */
/* exact same, so comparison is done */
- goto out2;
+ H5TOOLS_GOTO_DONE(H5DIFF_NO_ERR);
}
}
- switch(object_type)
- {
- /*----------------------------------------------------------------------
- * H5TRAV_TYPE_DATASET
- *----------------------------------------------------------------------
- */
+ switch (object_type) {
+ /*----------------------------------------------------------------------
+ * H5TRAV_TYPE_DATASET
+ *----------------------------------------------------------------------
+ */
case H5TRAV_TYPE_DATASET:
- /* verbose (-v) and report (-r) mode */
- if(options->m_verbose || options->m_report)
- {
- do_print_objname("dataset", path1, path2, options);
- nfound = diff_dataset(file1_id, file2_id, path1, path2, options);
+ H5TOOLS_DEBUG("diff object type H5TRAV_TYPE_DATASET - errstat:%d", opts->err_stat);
+ if ((dset1_id = H5Dopen2(file1_id, path1, H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dopen2 failed");
+ if ((dset2_id = H5Dopen2(file2_id, path2, H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dopen2 failed");
+ H5TOOLS_DEBUG("paths: %s - %s", path1, path2);
+ /* verbose (-v) and report (-r) mode */
+ if (opts->mode_verbose || opts->mode_report) {
+ do_print_objname("dataset", path1, path2, opts);
+ H5TOOLS_DEBUG("call diff_dataset 1:%s 2:%s ", path1, path2);
+ nfound = diff_dataset(file1_id, file2_id, path1, path2, opts);
print_found(nfound);
}
/* quiet mode (-q), just count differences */
- else if(options->m_quiet)
- {
- nfound = diff_dataset(file1_id, file2_id, path1, path2, options);
+ else if (opts->mode_quiet) {
+ nfound = diff_dataset(file1_id, file2_id, path1, path2, opts);
}
- /* the rest (-c, none, ...) */
- else
- {
- nfound = diff_dataset(file1_id, file2_id, path1, path2, options);
+ /* the rest (-c, none, ...) */
+ else {
+ nfound = diff_dataset(file1_id, file2_id, path1, path2, opts);
/* print info if difference found */
- if (nfound)
- {
- do_print_objname("dataset", path1, path2, options);
- print_found(nfound);
+ if (nfound) {
+ do_print_objname("dataset", path1, path2, opts);
+ print_found(nfound);
}
}
+ H5TOOLS_DEBUG("diff after dataset:%d - errstat:%d", nfound, opts->err_stat);
+
+ /*---------------------------------------------------------
+ * compare attributes
+ * if condition refers to cases when the dataset is a
+ * referenced object
+ *---------------------------------------------------------
+ */
+ if (path1 && !is_exclude_attr(path1, object_type, opts)) {
+ H5TOOLS_DEBUG("call diff_attr 1:%s 2:%s ", path1, path2);
+ nfound += diff_attr(dset1_id, dset2_id, path1, path2, opts);
+ }
+
+ if (H5Dclose(dset1_id) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dclose failed");
+ if (H5Dclose(dset2_id) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dclose failed");
break;
- /*----------------------------------------------------------------------
- * H5TRAV_TYPE_NAMED_DATATYPE
- *----------------------------------------------------------------------
- */
+ /*----------------------------------------------------------------------
+ * H5TRAV_TYPE_NAMED_DATATYPE
+ *----------------------------------------------------------------------
+ */
case H5TRAV_TYPE_NAMED_DATATYPE:
- if((type1_id = H5Topen2(file1_id, path1, H5P_DEFAULT)) < 0)
- goto out;
- if((type2_id = H5Topen2(file2_id, path2, H5P_DEFAULT)) < 0)
- goto out;
+ H5TOOLS_DEBUG("H5TRAV_TYPE_NAMED_DATATYPE 1:%s 2:%s ", path1, path2);
+ if ((type1_id = H5Topen2(file1_id, path1, H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Topen2 failed");
+ if ((type2_id = H5Topen2(file2_id, path2, H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Topen2 failed");
- if((ret = H5Tequal(type1_id, type2_id)) < 0)
- goto out;
+ if ((status = H5Tequal(type1_id, type2_id)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tequal failed");
/* if H5Tequal is > 0 then the datatypes refer to the same datatype */
- nfound = (ret > 0) ? 0 : 1;
+ nfound = (status > 0) ? 0 : 1;
- if(print_objname(options,nfound))
- do_print_objname("datatype", path1, path2, options);
+ if (print_objname(opts, nfound))
+ do_print_objname("datatype", path1, path2, opts);
/* always print the number of differences found in verbose mode */
- if(options->m_verbose)
+ if (opts->mode_verbose)
print_found(nfound);
/*-----------------------------------------------------------------
* compare attributes
- * the if condition refers to cases when the dataset is a
+ * the if condition refers to cases when the dataset is a
* referenced object
*-----------------------------------------------------------------
*/
- if(path1)
- nfound += diff_attr(type1_id, type2_id, path1, path2, options);
+ if (path1 && !is_exclude_attr(path1, object_type, opts)) {
+ H5TOOLS_DEBUG("call diff_attr 1:%s 2:%s ", path1, path2);
+ nfound += diff_attr(type1_id, type2_id, path1, path2, opts);
+ }
- if(H5Tclose(type1_id) < 0)
- goto out;
- if(H5Tclose(type2_id) < 0)
- goto out;
+ if (H5Tclose(type1_id) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tclose failed");
+ if (H5Tclose(type2_id) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tclose failed");
break;
- /*----------------------------------------------------------------------
- * H5TRAV_TYPE_GROUP
- *----------------------------------------------------------------------
- */
+ /*----------------------------------------------------------------------
+ * H5TRAV_TYPE_GROUP
+ *----------------------------------------------------------------------
+ */
case H5TRAV_TYPE_GROUP:
- if(print_objname(options, nfound))
- do_print_objname("group", path1, path2, options);
+ H5TOOLS_DEBUG("H5TRAV_TYPE_GROUP 1:%s 2:%s ", path1, path2);
+ if (print_objname(opts, nfound))
+ do_print_objname("group", path1, path2, opts);
/* always print the number of differences found in verbose mode */
- if(options->m_verbose)
+ if (opts->mode_verbose)
print_found(nfound);
- if((grp1_id = H5Gopen2(file1_id, path1, H5P_DEFAULT)) < 0)
- goto out;
- if((grp2_id = H5Gopen2(file2_id, path2, H5P_DEFAULT)) < 0)
- goto out;
+ if ((grp1_id = H5Gopen2(file1_id, path1, H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Gclose failed");
+ if ((grp2_id = H5Gopen2(file2_id, path2, H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Gclose failed");
/*-----------------------------------------------------------------
* compare attributes
- * the if condition refers to cases when the dataset is a
+ * the if condition refers to cases when the dataset is a
* referenced object
*-----------------------------------------------------------------
*/
- if(path1)
- nfound += diff_attr(grp1_id, grp2_id, path1, path2, options);
+ if (path1 && !is_exclude_attr(path1, object_type, opts)) {
+ H5TOOLS_DEBUG("call diff_attr 1:%s 2:%s ", path1, path2);
+ nfound += diff_attr(grp1_id, grp2_id, path1, path2, opts);
+ }
- if(H5Gclose(grp1_id) < 0)
- goto out;
- if(H5Gclose(grp2_id) < 0)
- goto out;
+ if (H5Gclose(grp1_id) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Gclose failed");
+ if (H5Gclose(grp2_id) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Gclose failed");
break;
-
- /*----------------------------------------------------------------------
- * H5TRAV_TYPE_LINK
- *----------------------------------------------------------------------
- */
- case H5TRAV_TYPE_LINK:
- {
- ret = HDstrcmp(linkinfo1.trg_path, linkinfo2.trg_path);
+ /*----------------------------------------------------------------------
+ * H5TRAV_TYPE_LINK
+ *----------------------------------------------------------------------
+ */
+ case H5TRAV_TYPE_LINK: {
+ H5TOOLS_DEBUG("H5TRAV_TYPE_LINK 1:%s 2:%s ", path1, path2);
+ status = HDstrcmp(linkinfo1.trg_path, linkinfo2.trg_path);
/* if the target link name is not same then the links are "different" */
- nfound = (ret != 0) ? 1 : 0;
+ nfound = (status != 0) ? 1 : 0;
- if(print_objname(options, nfound))
- do_print_objname("link", path1, path2, options);
+ if (print_objname(opts, nfound))
+ do_print_objname("link", path1, path2, opts);
/* always print the number of differences found in verbose mode */
- if(options->m_verbose)
+ if (opts->mode_verbose)
print_found(nfound);
+ } break;
- }
- break;
-
- /*----------------------------------------------------------------------
- * H5TRAV_TYPE_UDLINK
- *----------------------------------------------------------------------
- */
- case H5TRAV_TYPE_UDLINK:
- {
+ /*----------------------------------------------------------------------
+ * H5TRAV_TYPE_UDLINK
+ *----------------------------------------------------------------------
+ */
+ case H5TRAV_TYPE_UDLINK: {
+ H5TOOLS_DEBUG("H5TRAV_TYPE_UDLINK 1:%s 2:%s ", path1, path2);
/* Only external links will have a query function registered */
- if(linkinfo1.linfo.type == H5L_TYPE_EXTERNAL && linkinfo2.linfo.type == H5L_TYPE_EXTERNAL)
- {
+ if (linkinfo1.linfo.type == H5L_TYPE_EXTERNAL && linkinfo2.linfo.type == H5L_TYPE_EXTERNAL) {
/* If the buffers are the same size, compare them */
- if(linkinfo1.linfo.u.val_size == linkinfo2.linfo.u.val_size)
- {
- ret = HDmemcmp(linkinfo1.trg_path, linkinfo2.trg_path, linkinfo1.linfo.u.val_size);
+ if (linkinfo1.linfo.u.val_size == linkinfo2.linfo.u.val_size) {
+ status = HDmemcmp(linkinfo1.trg_path, linkinfo2.trg_path, linkinfo1.linfo.u.val_size);
}
else
- ret = 1;
+ status = 1;
/* if "linkinfo1.trg_path" != "linkinfo2.trg_path" then the links
- * are "different" extlinkinfo#.path is combination string of
+ * are "different" extlinkinfo#.path is combination string of
* file_name and obj_name
*/
- nfound = (ret != 0) ? 1 : 0;
+ nfound = (status != 0) ? 1 : 0;
- if(print_objname(options, nfound))
- do_print_objname("external link", path1, path2, options);
+ if (print_objname(opts, nfound))
+ do_print_objname("external link", path1, path2, opts);
} /* end if */
- else
- {
+ else {
/* If one or both of these links isn't an external link, we can only
* compare information from H5Lget_info since we don't have a query
* function registered for them.
@@ -1979,89 +1861,81 @@ hsize_t diff(hid_t file1_id,
* If the link classes or the buffer length are not the
* same, the links are "different"
*/
- if((linkinfo1.linfo.type != linkinfo2.linfo.type) ||
- (linkinfo1.linfo.u.val_size != linkinfo2.linfo.u.val_size))
+ if ((linkinfo1.linfo.type != linkinfo2.linfo.type) ||
+ (linkinfo1.linfo.u.val_size != linkinfo2.linfo.u.val_size))
nfound = 1;
else
nfound = 0;
- if (print_objname (options, nfound))
- do_print_objname ("user defined link", path1, path2, options);
+ if (print_objname(opts, nfound))
+ do_print_objname("user defined link", path1, path2, opts);
} /* end else */
/* always print the number of differences found in verbose mode */
- if(options->m_verbose)
+ if (opts->mode_verbose)
print_found(nfound);
- }
- break;
+ } break;
+ case H5TRAV_TYPE_UNKNOWN:
default:
- if(options->m_verbose)
- parallel_print("Comparison not supported: <%s> and <%s> are of type %s\n",
- path1, path2, get_type(object_type) );
- options->not_cmp = 1;
+ if (opts->mode_verbose)
+ parallel_print("Comparison not supported: <%s> and <%s> are of type %s\n", path1, path2,
+ get_type(object_type));
+ opts->not_cmp = 1;
break;
- }
-
- /* free link info buffer */
- if (linkinfo1.trg_path)
- HDfree((char *)linkinfo1.trg_path);
- if (linkinfo2.trg_path)
- HDfree((char *)linkinfo2.trg_path);
-
- return nfound;
+ }
-out:
- options->err_stat = 1;
+done:
+ opts->err_stat = opts->err_stat | ret_value;
-out2:
/*-----------------------------------
- * handle dangling link(s)
+ * handle dangling link(s)
*/
/* both path1 and path2 are dangling links */
- if(is_dangle_link1 && is_dangle_link2)
- {
- if(print_objname(options, nfound))
- {
- do_print_objname("dangling link", path1, path2, options);
+ if (is_dangle_link1 && is_dangle_link2) {
+ if (print_objname(opts, nfound)) {
+ do_print_objname("dangling link", path1, path2, opts);
print_found(nfound);
}
}
/* path1 is dangling link */
- else if (is_dangle_link1)
- {
- if(options->m_verbose)
- parallel_print("obj1 <%s> is a dangling link.\n", path1);
+ else if (is_dangle_link1) {
+ if (opts->mode_verbose)
+ parallel_print("obj1 <%s> is a dangling link.\n", path1);
nfound++;
- if(print_objname(options, nfound))
+ if (print_objname(opts, nfound))
print_found(nfound);
}
/* path2 is dangling link */
- else if (is_dangle_link2)
- {
- if(options->m_verbose)
+ else if (is_dangle_link2) {
+ if (opts->mode_verbose)
parallel_print("obj2 <%s> is a dangling link.\n", path2);
nfound++;
- if(print_objname(options, nfound))
+ if (print_objname(opts, nfound))
print_found(nfound);
}
/* free link info buffer */
if (linkinfo1.trg_path)
- HDfree((char *)linkinfo1.trg_path);
+ HDfree(linkinfo1.trg_path);
if (linkinfo2.trg_path)
- HDfree((char *)linkinfo2.trg_path);
+ HDfree(linkinfo2.trg_path);
/* close */
/* disable error reporting */
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
+ H5Dclose(dset1_id);
+ H5Dclose(dset2_id);
H5Tclose(type1_id);
H5Tclose(type2_id);
H5Gclose(grp1_id);
- H5Tclose(grp2_id);
+ H5Gclose(grp2_id);
/* enable error reporting */
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
+
+ H5TOOLS_ENDDEBUG(": %d - errstat:%d", nfound, opts->err_stat);
return nfound;
}
-
diff --git a/tools/lib/h5diff.h b/tools/lib/h5diff.h
index 6985b68..917ea6a 100644
--- a/tools/lib/h5diff.h
+++ b/tools/lib/h5diff.h
@@ -1,35 +1,33 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * 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 H5DIFF_H__
-#define H5DIFF_H__
+#ifndef H5DIFF_H
+#define H5DIFF_H
#include "hdf5.h"
+#include "h5tools.h"
#include "h5trav.h"
#define MAX_FILENAME 1024
/*-------------------------------------------------------------------------
* This is used to pass multiple args into diff().
- * Passing this instead of several each arg provides smoother extensibility
+ * Passing this instead of several each arg provides smoother extensibility
* through its members along with MPI code for ph5diff
* as it doesn't require interface change.
*------------------------------------------------------------------------*/
typedef struct {
- h5trav_type_t type[2];
- hbool_t is_same_trgobj;
+ h5trav_type_t type[2];
+ hbool_t is_same_trgobj;
} diff_args_t;
/*-------------------------------------------------------------------------
* command line options
@@ -37,36 +35,64 @@ typedef struct {
*/
/* linked list to keep exclude path list */
struct exclude_path_list {
- char *obj_path;
- h5trav_type_t obj_type;
- struct exclude_path_list * next;
+ const char *obj_path;
+ h5trav_type_t obj_type;
+ struct exclude_path_list *next;
};
+/* Enumeration value for keeping track of whether an error occurred or differences were found */
+typedef enum {
+ H5DIFF_NO_ERR, /* No error occurred */
+ H5DIFF_ERR_DIFF, /* Differences were found */
+ H5DIFF_ERR /* An error occurred */
+} diff_err_t;
+
typedef struct {
- int m_quiet; /* quiet mide: no output at all */
- int m_report; /* report mode: print the data */
- int m_verbose; /* verbose mode: print the data, list of objcets, warnings */
- int m_verbose_level; /* control verbose details */
- int d; /* delta, absolute value to compare */
- double delta; /* delta value */
- int p; /* relative error to compare*/
- int use_system_epsilon; /* flag to use system epsilon (1 or 0) */
- double percent; /* relative error value */
- int n; /* count, compare up to count */
- hsize_t count; /* count value */
- int follow_links; /* follow symbolic links */
- int no_dangle_links; /* return error when find dangling link */
- int err_stat; /* an error ocurred (1, error, 0, no error) */
- int cmn_objs; /* do we have common objects */
- int not_cmp; /* are the objects comparable */
- int contents; /* equal contents */
- int do_nans; /* consider Nans while diffing floats */
- int m_list_not_cmp; /* list not comparable messages */
- int exclude_path; /* exclude path to an object */
- struct exclude_path_list * exclude; /* keep exclude path list */
+ int mode_quiet; /* quiet mode: no output at all */
+ int mode_report; /* report mode: print the data */
+ int mode_verbose; /* verbose mode: print the data, list of objcets, warnings */
+ int mode_verbose_level; /* control verbose details */
+ int mode_list_not_cmp; /* list not comparable messages */
+ int print_header; /* print header */
+ int print_percentage; /* print percentage */
+ int print_dims; /* print dimension index */
+ int delta_bool; /* delta, absolute value to compare */
+ double delta; /* delta value */
+ int use_system_epsilon; /* flag to use system epsilon (1 or 0) */
+ int percent_bool; /* relative error to compare*/
+ double percent; /* relative error value */
+ hbool_t follow_links; /* follow symbolic links */
+ int no_dangle_links; /* return error when find dangling link */
+ int cmn_objs; /* do we have common objects */
+ int not_cmp; /* are the objects comparable */
+ int contents; /* equal contents */
+ int do_nans; /* consider Nans while diffing floats */
+ int exclude_path; /* exclude path to an object */
+ int exclude_attr_path; /* exclude path to an object */
+ struct exclude_path_list *exclude; /* keep exclude path list */
+ struct exclude_path_list *exclude_attr; /* keep exclude attribute list */
+ int count_bool; /* count, compare up to count */
+ hsize_t count; /* count value */
+ diff_err_t err_stat; /* an error occurred (2, error, 1, differences, 0, no error) */
+ hsize_t nelmts; /* total number of elements */
+ hsize_t hs_nelmts; /* number of elements to read at a time*/
+ int rank; /* dimensionality */
+ size_t m_size; /* m_size for diff */
+ hid_t m_tid; /* m_tid for diff */
+ hsize_t dims[H5S_MAX_RANK]; /* dimensions of object */
+ hsize_t p_min_idx[H5S_MAX_RANK]; /* min selected index */
+ hsize_t p_max_idx[H5S_MAX_RANK]; /* max selected index */
+ hsize_t acc[H5S_MAX_RANK]; /* accumulator position */
+ hsize_t pos[H5S_MAX_RANK]; /* matrix position */
+ hsize_t sm_pos[H5S_MAX_RANK]; /* stripmine position */
+ char *obj_name[2]; /* name for object */
+ struct subset_t *sset[2]; /* subsetting parameters */
+ h5tools_vol_info_t vol_info[2]; /* VOL information for input file, output file */
+ h5tools_vfd_info_t vfd_info[2]; /* VFD information for input file, output file */
+ hbool_t custom_vol[2]; /* Using a custom input, output VOL? */
+ hbool_t custom_vfd[2]; /* Using a custom input, output VFD? */
} diff_opt_t;
-
/*-------------------------------------------------------------------------
* public functions
*-------------------------------------------------------------------------
@@ -76,18 +102,11 @@ typedef struct {
extern "C" {
#endif
-H5TOOLS_DLL hsize_t h5diff(const char *fname1,
- const char *fname2,
- const char *objname1,
- const char *objname2,
- diff_opt_t *options);
+H5TOOLS_DLL hsize_t h5diff(const char *fname1, const char *fname2, const char *objname1, const char *objname2,
+ diff_opt_t *opts);
-H5TOOLS_DLL hsize_t diff( hid_t file1_id,
- const char *path1,
- hid_t file2_id,
- const char *path2,
- diff_opt_t *options,
- diff_args_t *argdata);
+H5TOOLS_DLL hsize_t diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2,
+ diff_opt_t *opts, diff_args_t *argdata);
#ifdef H5_HAVE_PARALLEL
H5TOOLS_DLL void phdiff_dismiss_workers(void);
@@ -98,295 +117,48 @@ H5TOOLS_DLL void print_manager_output(void);
}
#endif
-
-
/*-------------------------------------------------------------------------
* private functions
*-------------------------------------------------------------------------
*/
+hsize_t diff_dataset(hid_t file1_id, hid_t file2_id, const char *obj1_name, const char *obj2_name,
+ diff_opt_t *opts);
-hsize_t diff_dataset( hid_t file1_id,
- hid_t file2_id,
- const char *obj1_name,
- const char *obj2_name,
- diff_opt_t *options);
-
-hsize_t diff_datasetid( hid_t dset1_id,
- hid_t dset2_id,
- const char *obj1_name,
- const char *obj2_name,
- diff_opt_t *options);
+hsize_t diff_datasetid(hid_t dset1_id, hid_t dset2_id, const char *obj1_name, const char *obj2_name,
+ diff_opt_t *opts);
-hsize_t diff_compare( hid_t file1_id,
- const char *file1_name,
- const char *obj1_name,
- trav_info_t *info1,
- hid_t file2_id,
- const char *file2_name,
- const char *obj2_name,
- trav_info_t *info2,
- diff_opt_t *options );
+hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, hid_t file2_id, const char *grp2,
+ trav_info_t *info2, trav_table_t *table, diff_opt_t *opts);
-hsize_t diff_match( hid_t file1_id, const char *grp1, trav_info_t *info1,
- hid_t file2_id, const char *grp2, trav_info_t *info2,
- trav_table_t *table, diff_opt_t *options );
+hsize_t diff_array(void *_mem1, void *_mem2, diff_opt_t *opts, hid_t container1_id, hid_t container2_id);
-hsize_t diff_array( void *_mem1,
- void *_mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- diff_opt_t *options,
- const char *name1,
- const char *name2,
- hid_t m_type,
- hid_t container1_id,
- hid_t container2_id); /* dataset where the reference came from*/
+int diff_can_type(hid_t f_type1, hid_t f_type2, int rank1, int rank2, hsize_t *dims1, hsize_t *dims2,
+ hsize_t *maxdim1, hsize_t *maxdim2, diff_opt_t *opts, int is_compound);
+hsize_t diff_attr_data(hid_t attr1_id, hid_t attr2_id, const char *name1, const char *name2,
+ const char *path1, const char *path2, diff_opt_t *opts);
-int diff_can_type( hid_t f_type1, /* file data type */
- hid_t f_type2, /* file data type */
- int rank1,
- int rank2,
- hsize_t *dims1,
- hsize_t *dims2,
- hsize_t *maxdim1,
- hsize_t *maxdim2,
- const char *obj1_name,
- const char *obj2_name,
- diff_opt_t *options,
- int is_compound);
-
-
-hsize_t diff_attr(hid_t loc1_id,
- hid_t loc2_id,
- const char *path1,
- const char *path2,
- diff_opt_t *options);
-
+hsize_t diff_attr(hid_t loc1_id, hid_t loc2_id, const char *path1, const char *path2, diff_opt_t *opts);
/*-------------------------------------------------------------------------
* utility functions
*-------------------------------------------------------------------------
*/
+/* in h5diff_util.c */
void print_found(hsize_t nfound);
void print_type(hid_t type);
-const char* diff_basename(const char *name);
-const char* get_type(h5trav_type_t type);
-const char* get_class(H5T_class_t tclass);
-const char* get_sign(H5T_sign_t sign);
-void print_dimensions (int rank, hsize_t *dims);
-int print_objname(diff_opt_t *options, hsize_t nfound);
-void do_print_objname (const char *OBJ, const char *path1, const char *path2, diff_opt_t * opts);
-void do_print_attrname (const char *attr, const char *path1, const char *path2);
-
-
-/*-------------------------------------------------------------------------
- * XCAO, 11/10/2010
- * added to improve performance for compound datasets
- */
-typedef struct mcomp_t
-{
- int n; /* number of members */
- hid_t *ids; /* member type id */
- unsigned char *flags;
- size_t *offsets;
- struct mcomp_t **m; /* members */
-}mcomp_t;
-
-hsize_t diff_datum(void *_mem1,
- void *_mem2,
- hid_t m_type,
- hsize_t i,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- hid_t container1_id,
- hid_t container2_id, /*where the reference came from*/
- int *ph, /*print header */
- mcomp_t *members); /*compound members */
-
-
-
-hsize_t diff_float(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph);
-
-hsize_t diff_double(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph);
-
-#if H5_SIZEOF_LONG_DOUBLE !=0
-
-hsize_t diff_ldouble(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph);
-
-#endif
-
-hsize_t diff_schar(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph);
-
-hsize_t diff_uchar(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph);
-
-hsize_t diff_short(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph);
-
-hsize_t diff_ushort(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph);
-
-hsize_t diff_int(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph);
-
-hsize_t diff_uint(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph);
-
-hsize_t diff_long(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph);
-
-hsize_t diff_ulong(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph);
-
-hsize_t diff_llong(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph);
-
-hsize_t diff_ullong(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph);
-
-#endif /* H5DIFF_H__ */
-
+const char *diff_basename(const char *name);
+const char *get_type(h5trav_type_t type);
+const char *get_class(H5T_class_t tclass);
+const char *get_sign(H5T_sign_t sign);
+void print_dimensions(int rank, hsize_t *dims);
+herr_t match_up_memsize(hid_t f_tid1_id, hid_t f_tid2_id, hid_t *m_tid1, hid_t *m_tid2, size_t *m_size1,
+ size_t *m_size2);
+/* in h5diff.c */
+int print_objname(diff_opt_t *opts, hsize_t nfound);
+void do_print_objname(const char *OBJ, const char *path1, const char *path2, diff_opt_t *opts);
+void do_print_attrname(const char *attr, const char *path1, const char *path2);
+
+#endif /* H5DIFF_H */
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c
index 604a825..3f504eb 100644
--- a/tools/lib/h5diff_array.c
+++ b/tools/lib/h5diff_array.c
@@ -1,81 +1,61 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#include <math.h>
-#include <time.h>
-#include <sys/timeb.h>
-
#include "H5private.h"
#include "h5tools.h"
#include "h5tools_utils.h"
#include "h5diff.h"
#include "ph5diff.h"
+#define ATTR_NAME_MAX 255
/*-------------------------------------------------------------------------
* printf formatting
*-------------------------------------------------------------------------
*/
-#define F_FORMAT "%-15g %-15g %-15g\n"
-
-#if H5_SIZEOF_LONG_DOUBLE !=0
-#define LD_FORMAT "%-15Lf %-15Lf %-15Lf\n"
-#endif
-
-#define I_FORMAT "%-15d %-15d %-15d\n"
-#define C_FORMAT "%-16c %-17c\n"
-#define S_FORMAT "%-16s %-17s\n"
-#define UI_FORMAT "%-15u %-15u %-15u\n"
-#define LI_FORMAT "%-15ld %-15ld %-15ld\n"
-#define ULI_FORMAT "%-15lu %-15lu %-15lu\n"
-#define LLI_FORMAT "%-15"H5_PRINTF_LL_WIDTH"d %-15"H5_PRINTF_LL_WIDTH"d %-15"H5_PRINTF_LL_WIDTH"d\n"
-#define ULLI_FORMAT "%-15"H5_PRINTF_LL_WIDTH"u %-15"H5_PRINTF_LL_WIDTH"u %-15"H5_PRINTF_LL_WIDTH"u\n"
+#define F_FORMAT "%-15g %-15g %-15g\n"
+#define LD_FORMAT "%-15Lg %-15Lg %-15Lg\n"
+#define I_FORMAT "%-15d %-15d %-15d\n"
+#define S_FORMAT "%-16s %-17s\n"
+#define UI_FORMAT "%-15u %-15u %-15u\n"
+#define LI_FORMAT "%-15ld %-15ld %-15ld\n"
+#define ULI_FORMAT "%-15lu %-15lu %-15lu\n"
+#define LLI_FORMAT "%-15lld %-15lld %-15lld\n"
+#define ULLI_FORMAT "%-15llu %-15llu %-15llu\n"
/* with -p option */
#define F_FORMAT_P "%-15.10g %-15.10g %-15.10g %-14.10g\n"
-
-#if H5_SIZEOF_LONG_DOUBLE !=0
-#define LD_FORMAT_P "%-15.10Lf %-15.10Lf %-15.10Lf %-14.10Lf\n"
-#endif
-
+#define LD_FORMAT_P "%-15.10Lg %-15.10Lg %-15.10Lg %-14.10Lg\n"
#define I_FORMAT_P "%-15d %-15d %-15d %-14f\n"
#define UI_FORMAT_P "%-15u %-15u %-15u %-14f\n"
#define LI_FORMAT_P "%-15ld %-15ld %-15ld %-14f\n"
#define ULI_FORMAT_P "%-15lu %-15lu %-15lu %-14f\n"
-#define LLI_FORMAT_P "%-15"H5_PRINTF_LL_WIDTH"d %-15"H5_PRINTF_LL_WIDTH"d %-15"H5_PRINTF_LL_WIDTH"d %-14f\n"
-#define ULLI_FORMAT_P "%-15"H5_PRINTF_LL_WIDTH"u %-15"H5_PRINTF_LL_WIDTH"u %-15"H5_PRINTF_LL_WIDTH"d %-14f\n"
+#define LLI_FORMAT_P "%-15lld %-15lld %-15lld %-14f\n"
+#define ULLI_FORMAT_P "%-15llu %-15llu %-15lld %-14f\n"
#define SPACES " "
/* not comparable */
-#define F_FORMAT_P_NOTCOMP "%-15.10g %-15.10g %-15.10g not comparable\n"
-
-#if H5_SIZEOF_LONG_DOUBLE !=0
-#define LD_FORMAT_P_NOTCOMP "%-15.10Lf %-15.10Lf %-15.10Lf not comparable\n"
-#endif
-
-#define I_FORMAT_P_NOTCOMP "%-15d %-15d %-15d not comparable\n"
+#define F_FORMAT_P_NOTCOMP "%-15.10g %-15.10g %-15.10g not comparable\n"
+#define LD_FORMAT_P_NOTCOMP "%-15.10Lg %-15.10Lg %-15.10Lg not comparable\n"
+#define I_FORMAT_P_NOTCOMP "%-15d %-15d %-15d not comparable\n"
#define UI_FORMAT_P_NOTCOMP "%-15u %-15u %-15u not comparable\n"
#define LI_FORMAT_P_NOTCOMP "%-15ld %-15ld %-15ld not comparable\n"
#define ULI_FORMAT_P_NOTCOMP "%-15lu %-15lu %-15lu not comparable\n"
-#define LLI_FORMAT_P_NOTCOMP "%-15"H5_PRINTF_LL_WIDTH"d %-15"H5_PRINTF_LL_WIDTH"d %-15"H5_PRINTF_LL_WIDTH"d not comparable\n"
-#define ULLI_FORMAT_P_NOTCOMP "%-15"H5_PRINTF_LL_WIDTH"u %-15"H5_PRINTF_LL_WIDTH"u %-15"H5_PRINTF_LL_WIDTH"d not comparable\n"
-
+#define LLI_FORMAT_P_NOTCOMP "%-15lld %-15lld %-15lld not comparable\n"
+#define ULLI_FORMAT_P_NOTCOMP "%-15llu %-15llu %-15lld not comparable\n"
/* if system EPSILON is defined, use the system EPSILON; otherwise, use
- constants that are close to most EPSILON values */
+ constants that are close to most EPSILON values */
#ifndef FLT_EPSILON
#define FLT_EPSILON 1.19209E-07
@@ -85,7 +65,6 @@
#define DBL_EPSILON 2.22045E-16
#endif
-
/*-------------------------------------------------------------------------
* -p relative error formula
*
@@ -101,86 +80,97 @@
*-------------------------------------------------------------------------
*/
-static int not_comparable;
-
-#define PER(A,B) { per=-1; \
- not_comparable=0; \
- both_zero=0; \
- if (A==0 && B==0) \
- both_zero=1; \
- if (A!=0) \
- per = (double)ABS( ( double)(B-A) / (double)A ); \
- else \
- not_comparable=1; \
-}
-
-
-#define PER_UNSIGN(TYPE,A,B) { per=-1; \
- not_comparable=0; \
- both_zero=0; \
- if (A==0 && B==0) \
- both_zero=1; \
- if (A!=0) \
- per = ABS((double)((TYPE)(B-A)) / (double)A) ; \
- else \
- not_comparable=1; \
-}
+static hbool_t not_comparable;
+
+#define PER(A, B) \
+ { \
+ per = -1; \
+ not_comparable = FALSE; \
+ both_zero = FALSE; \
+ if (H5_DBL_ABS_EQUAL(0, (double)(A)) && H5_DBL_ABS_EQUAL(0, (double)(B))) \
+ both_zero = TRUE; \
+ if (!H5_DBL_ABS_EQUAL(0, (double)(A))) \
+ per = (double)ABS((double)((B) - (A)) / (double)(A)); \
+ else \
+ not_comparable = TRUE; \
+ }
+#define PER_UNSIGN(TYPE, A, B) \
+ { \
+ per = -1; \
+ not_comparable = FALSE; \
+ both_zero = FALSE; \
+ if (H5_DBL_ABS_EQUAL(0, (double)(A)) && H5_DBL_ABS_EQUAL(0, (double)(B))) \
+ both_zero = TRUE; \
+ if (!H5_DBL_ABS_EQUAL(0, (double)(A))) \
+ per = ABS((double)((TYPE)((B) - (A))) / (double)(A)); \
+ else \
+ not_comparable = TRUE; \
+ }
-#define BOTH_ZERO(A,B) { both_zero=0; \
- if (A==0 && B==0) \
- both_zero=1; \
-}
+#define PDIFF(a, b) (((b) > (a)) ? ((b) - (a)) : ((a) - (b)))
-#define IS_ZERO(A) { is_zero=0; \
- if (A==0) \
- is_zero=1; \
-}
-
-# define PDIFF(a,b) ( (b>a) ? (b-a) : (a-b))
+typedef struct mcomp_t {
+ unsigned n; /* number of members */
+ hid_t *ids; /* member type id */
+ size_t *offsets;
+ struct mcomp_t **m; /* members */
+} mcomp_t;
/*-------------------------------------------------------------------------
* local prototypes
*-------------------------------------------------------------------------
*/
-static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id,hid_t region1_id, hid_t region2_id, diff_opt_t *options);
static hbool_t all_zero(const void *_mem, size_t size);
static int ull2float(unsigned long long ull_value, float *f_value);
-static hsize_t character_compare(unsigned char *mem1,unsigned char *mem2,hsize_t i,unsigned u,int rank,hsize_t *dims,hsize_t *acc,hsize_t *pos,diff_opt_t *options,const char *obj1,const char *obj2,int *ph);
-static hsize_t character_compare_opt(unsigned char *mem1,unsigned char *mem2,hsize_t i,int rank,hsize_t *dims,hsize_t *acc,hsize_t *pos,diff_opt_t *options,const char *obj1,const char *obj2,int *ph);
-static hbool_t equal_float(float value, float expected, diff_opt_t *options);
-static hbool_t equal_double(double value, double expected, diff_opt_t *options);
-#if H5_SIZEOF_LONG_DOUBLE !=0
-static hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *options);
-#endif
-static int print_data(diff_opt_t *options);
-static void print_pos(int *ph,int pp,hsize_t curr_pos,hsize_t *acc,hsize_t *pos,int rank,hsize_t *dims,const char *obj1,const char *obj2 );
-static void print_char_pos(int *ph,int pp,hsize_t curr_pos,unsigned u,hsize_t *acc,hsize_t *pos,int rank,hsize_t *dims,const char *obj1,const char *obj2 );
+static hsize_t character_compare(char *mem1, char *mem2, hsize_t elemtno, size_t u, diff_opt_t *opts);
+static hsize_t character_compare_opt(unsigned char *mem1, unsigned char *mem2, hsize_t elemtno,
+ diff_opt_t *opts);
+static hbool_t equal_float(float value, float expected, diff_opt_t *opts);
+static hbool_t equal_double(double value, double expected, diff_opt_t *opts);
+static hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *opts);
+
+static int print_data(diff_opt_t *opts);
+static void print_pos(diff_opt_t *opts, hsize_t elemtno, size_t u);
static void h5diff_print_char(char ch);
+static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t region2_id,
+ diff_opt_t *opts);
+static hsize_t diff_datum(void *_mem1, void *_mem2, hsize_t elemtno, diff_opt_t *opts, hid_t container1_id,
+ hid_t container2_id, mcomp_t *members);
+/* element diffs */
+static hsize_t diff_float_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx,
+ diff_opt_t *opts);
+static hsize_t diff_double_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx,
+ diff_opt_t *opts);
+static hsize_t diff_ldouble_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx,
+ diff_opt_t *opts);
+static hsize_t diff_schar_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx,
+ diff_opt_t *opts);
+static hsize_t diff_uchar_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx,
+ diff_opt_t *opts);
+static hsize_t diff_short_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx,
+ diff_opt_t *opts);
+static hsize_t diff_ushort_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx,
+ diff_opt_t *opts);
+static hsize_t diff_int_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts);
+static hsize_t diff_uint_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx,
+ diff_opt_t *opts);
+static hsize_t diff_long_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx,
+ diff_opt_t *opts);
+static hsize_t diff_ulong_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx,
+ diff_opt_t *opts);
+static hsize_t diff_llong_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx,
+ diff_opt_t *opts);
+static hsize_t diff_ullong_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx,
+ diff_opt_t *opts);
/*-------------------------------------------------------------------------
* NaN detection
*-------------------------------------------------------------------------
*/
-#if H5_SIZEOF_LONG_DOUBLE !=0
-typedef enum dtype_t
-{
- FLT_FLOAT,
- FLT_DOUBLE,
- FLT_LDOUBLE
-} dtype_t;
-#else
-
-typedef enum dtype_t
-{
- FLT_FLOAT,
- FLT_DOUBLE
-} dtype_t;
-#endif
-
-static int my_isnan(dtype_t type, void *val);
+typedef enum dtype_t { FLT_FLOAT, FLT_DOUBLE, FLT_LDOUBLE } dtype_t;
/*-------------------------------------------------------------------------
* XCAO, 11/10/2010
@@ -189,162 +179,221 @@ static int my_isnan(dtype_t type, void *val);
static void get_member_types(hid_t tid, mcomp_t *members);
static void close_member_types(mcomp_t *members);
-
-
/*-------------------------------------------------------------------------
* Function: diff_array
*
* Purpose: compare two memory buffers;
*
* Return: number of differences found
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 12, 2003
- *
*-------------------------------------------------------------------------
*/
-hsize_t diff_array( void *_mem1,
- void *_mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- diff_opt_t *options,
- const char *name1,
- const char *name2,
- hid_t m_type,
- hid_t container1_id,
- hid_t container2_id) /* dataset where the reference came from*/
+hsize_t
+diff_array(void *_mem1, void *_mem2, diff_opt_t *opts, hid_t container1_id, hid_t container2_id)
{
- hsize_t nfound=0; /* number of differences found */
- size_t size; /* size of datum */
- unsigned char *mem1 = (unsigned char*)_mem1;
- unsigned char *mem2 = (unsigned char*)_mem2;
- hsize_t acc[32]; /* accumulator position */
- hsize_t pos[32]; /* matrix position */
- int ph=1; /* print header */
- hsize_t i;
- int j;
- mcomp_t members;
- H5T_class_t type_class;
+ hsize_t nfound = 0; /* number of differences found */
+ size_t size; /* size of datum */
+ unsigned char *mem1 = (unsigned char *)_mem1;
+ unsigned char *mem2 = (unsigned char *)_mem2;
+ hsize_t i;
+ mcomp_t members;
+ H5T_class_t type_class;
+
+ H5TOOLS_START_DEBUG(" - rank:%d hs_nelmts:%" PRIuHSIZE " errstat:%d", opts->rank, opts->hs_nelmts,
+ opts->err_stat);
+ opts->print_header = 1; /* enable print header */
/* get the size. */
- size = H5Tget_size( m_type );
- type_class = H5Tget_class(m_type);
+ size = H5Tget_size(opts->m_tid);
+ type_class = H5Tget_class(opts->m_tid);
/* Fast comparison first for atomic type by memcmp().
* It is OK not to list non-atomic type here because it will not be caught
* by the condition, but it gives more clarity for code planning
*/
- if (type_class != H5T_REFERENCE &&
- type_class != H5T_COMPOUND &&
- type_class != H5T_STRING &&
- type_class != H5T_VLEN &&
- HDmemcmp(mem1, mem2, size*nelmts)==0)
+ if (type_class != H5T_REFERENCE && type_class != H5T_COMPOUND && type_class != H5T_STRING &&
+ type_class != H5T_VLEN && HDmemcmp(mem1, mem2, size * opts->hs_nelmts) == 0) {
+ H5TOOLS_ENDDEBUG(":Fast comparison - errstat:%d", opts->err_stat);
return 0;
-
- if ( rank > 0 )
- {
-
- acc[rank-1]=1;
- for(j=(rank-2); j>=0; j--)
- {
- acc[j]=acc[j+1]*dims[j+1];
- }
- for ( j = 0; j < rank; j++)
- pos[j]=0;
}
- switch (type_class)
- {
- default:
- HDassert(0);
- break;
-
- /*-------------------------------------------------------------------------
- * float and integer atomic types
- *-------------------------------------------------------------------------
- */
-
- case H5T_FLOAT:
- if (H5Tequal(m_type, H5T_NATIVE_FLOAT))
- nfound=diff_float(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
- else if (H5Tequal(m_type, H5T_NATIVE_DOUBLE))
- nfound=diff_double(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
-#if H5_SIZEOF_LONG_DOUBLE !=0
- else if (H5Tequal(m_type, H5T_NATIVE_LDOUBLE))
- nfound=diff_ldouble(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
-#endif
- break;
-
- case H5T_INTEGER:
-
- if (H5Tequal(m_type, H5T_NATIVE_SCHAR))
- nfound=diff_schar(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
- else if (H5Tequal(m_type, H5T_NATIVE_UCHAR))
- nfound=diff_uchar(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
- else if (H5Tequal(m_type, H5T_NATIVE_SHORT))
- nfound=diff_short(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
- else if (H5Tequal(m_type, H5T_NATIVE_USHORT))
- nfound=diff_ushort(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
- else if (H5Tequal(m_type, H5T_NATIVE_INT))
- nfound=diff_int(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
- else if (H5Tequal(m_type, H5T_NATIVE_UINT))
- nfound=diff_uint(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
- else if (H5Tequal(m_type, H5T_NATIVE_LONG))
- nfound=diff_long(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
- else if (H5Tequal(m_type, H5T_NATIVE_ULONG))
- nfound=diff_ulong(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
- else if (H5Tequal(m_type, H5T_NATIVE_LLONG))
- nfound=diff_llong(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
- else if (H5Tequal(m_type, H5T_NATIVE_ULLONG))
- nfound=diff_ullong(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
-
- break;
+ H5TOOLS_DEBUG("type_class:%d", type_class);
+ switch (type_class) {
+ case H5T_NO_CLASS:
+ case H5T_TIME:
+ case H5T_NCLASSES:
+ default:
+ H5TOOLS_DEBUG("type_class:INVALID");
+ HDassert(0);
+ break;
- /*-------------------------------------------------------------------------
- * Other types than float and integer
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * float and integer atomic types
+ *-------------------------------------------------------------------------
+ */
+ case H5T_FLOAT:
+ H5TOOLS_DEBUG("type_class:H5T_FLOAT");
+ if (H5Tequal(opts->m_tid, H5T_NATIVE_FLOAT)) {
+ for (i = 0; i < opts->hs_nelmts; i++) {
+ nfound += diff_float_element(mem1, mem2, i, opts);
+
+ mem1 += sizeof(float);
+ mem2 += sizeof(float);
+ if (opts->count_bool && nfound >= opts->count)
+ return nfound;
+ } /* nelmts */
+ }
+ else if (H5Tequal(opts->m_tid, H5T_NATIVE_DOUBLE)) {
+ for (i = 0; i < opts->hs_nelmts; i++) {
+ nfound += diff_double_element(mem1, mem2, i, opts);
+
+ mem1 += sizeof(double);
+ mem2 += sizeof(double);
+ if (opts->count_bool && nfound >= opts->count)
+ return nfound;
+ } /* nelmts */
+ }
+ else if (H5Tequal(opts->m_tid, H5T_NATIVE_LDOUBLE)) {
+ for (i = 0; i < opts->hs_nelmts; i++) {
+ nfound += diff_ldouble_element(mem1, mem2, i, opts);
+
+ mem1 += sizeof(long double);
+ mem2 += sizeof(long double);
+ if (opts->count_bool && nfound >= opts->count)
+ return nfound;
+ } /* nelmts */
+ }
+ break;
+
+ case H5T_INTEGER:
+ H5TOOLS_DEBUG("type_class:H5T_INTEGER");
+ if (H5Tequal(opts->m_tid, H5T_NATIVE_SCHAR)) {
+ for (i = 0; i < opts->hs_nelmts; i++) {
+ nfound += diff_schar_element(mem1, mem2, i, opts);
+ mem1 += sizeof(char);
+ mem2 += sizeof(char);
+ if (opts->count_bool && nfound >= opts->count)
+ return nfound;
+ } /* nelmts */
+ }
+ else if (H5Tequal(opts->m_tid, H5T_NATIVE_UCHAR)) {
+ for (i = 0; i < opts->hs_nelmts; i++) {
+ nfound += diff_uchar_element(mem1, mem2, i, opts);
+
+ mem1 += sizeof(unsigned char);
+ mem2 += sizeof(unsigned char);
+ if (opts->count_bool && nfound >= opts->count)
+ return nfound;
+ } /* nelmts */
+ }
+ else if (H5Tequal(opts->m_tid, H5T_NATIVE_SHORT)) {
+ for (i = 0; i < opts->hs_nelmts; i++) {
+ nfound += diff_short_element(mem1, mem2, i, opts);
+
+ mem1 += sizeof(short);
+ mem2 += sizeof(short);
+ if (opts->count_bool && nfound >= opts->count)
+ return nfound;
+ } /* nelmts */
+ }
+ else if (H5Tequal(opts->m_tid, H5T_NATIVE_USHORT)) {
+ for (i = 0; i < opts->hs_nelmts; i++) {
+ nfound += diff_ushort_element(mem1, mem2, i, opts);
+
+ mem1 += sizeof(unsigned short);
+ mem2 += sizeof(unsigned short);
+ if (opts->count_bool && nfound >= opts->count)
+ return nfound;
+ } /* nelmts */
+ }
+ else if (H5Tequal(opts->m_tid, H5T_NATIVE_INT)) {
+ for (i = 0; i < opts->hs_nelmts; i++) {
+ nfound += diff_int_element(mem1, mem2, i, opts);
+
+ mem1 += sizeof(int);
+ mem2 += sizeof(int);
+ if (opts->count_bool && nfound >= opts->count)
+ return nfound;
+ } /* nelmts */
+ }
+ else if (H5Tequal(opts->m_tid, H5T_NATIVE_UINT)) {
+ for (i = 0; i < opts->hs_nelmts; i++) {
+ nfound += diff_int_element(mem1, mem2, i, opts);
+
+ mem1 += sizeof(unsigned int);
+ mem2 += sizeof(unsigned int);
+ if (opts->count_bool && nfound >= opts->count)
+ return nfound;
+ } /* nelmts */
+ }
+ else if (H5Tequal(opts->m_tid, H5T_NATIVE_LONG)) {
+ for (i = 0; i < opts->hs_nelmts; i++) {
+ nfound += diff_long_element(mem1, mem2, i, opts);
+
+ mem1 += sizeof(long);
+ mem2 += sizeof(long);
+ if (opts->count_bool && nfound >= opts->count)
+ return nfound;
+ } /* nelmts */
+ }
+ else if (H5Tequal(opts->m_tid, H5T_NATIVE_ULONG)) {
+ for (i = 0; i < opts->hs_nelmts; i++) {
+ nfound += diff_ulong_element(mem1, mem2, i, opts);
+
+ mem1 += sizeof(unsigned long);
+ mem2 += sizeof(unsigned long);
+ if (opts->count_bool && nfound >= opts->count)
+ return nfound;
+ } /* nelmts */
+ }
+ else if (H5Tequal(opts->m_tid, H5T_NATIVE_LLONG)) {
+ for (i = 0; i < opts->hs_nelmts; i++) {
+ nfound += diff_llong_element(mem1, mem2, i, opts);
+
+ mem1 += sizeof(long long);
+ mem2 += sizeof(long long);
+ if (opts->count_bool && nfound >= opts->count)
+ return nfound;
+ } /* nelmts */
+ }
+ else if (H5Tequal(opts->m_tid, H5T_NATIVE_ULLONG)) {
+ for (i = 0; i < opts->hs_nelmts; i++) {
+ nfound += diff_ullong_element(mem1, mem2, i, opts);
+
+ mem1 += sizeof(unsigned long long);
+ mem2 += sizeof(unsigned long long);
+ if (opts->count_bool && nfound >= opts->count)
+ return nfound;
+ } /* nelmts */
+ }
+ break;
- case H5T_COMPOUND:
- case H5T_STRING:
- case H5T_BITFIELD:
- case H5T_OPAQUE:
- case H5T_ENUM:
- case H5T_ARRAY:
- case H5T_VLEN:
- case H5T_REFERENCE:
- HDmemset(&members, 0, sizeof (mcomp_t));
- get_member_types(m_type, &members);
- for ( i = 0; i < nelmts; i++)
- {
- nfound+=diff_datum(
- mem1 + i * size,
- mem2 + i * size, /* offset */
- m_type,
- i,
- rank,
- dims,
- acc,
- pos,
- options,
- name1,
- name2,
- container1_id,
- container2_id,
- &ph, &members);
- if (options->n && nfound>=options->count)
- {
- close_member_types(&members);
- return nfound;
- }
- } /* i */
- close_member_types(&members);
+ /*-------------------------------------------------------------------------
+ * Other types than float and integer
+ *-------------------------------------------------------------------------
+ */
+ case H5T_COMPOUND:
+ case H5T_STRING:
+ case H5T_BITFIELD:
+ case H5T_OPAQUE:
+ case H5T_ENUM:
+ case H5T_ARRAY:
+ case H5T_VLEN:
+ case H5T_REFERENCE:
+ H5TOOLS_DEBUG("type_class:OTHER");
+ HDmemset(&members, 0, sizeof(mcomp_t));
+ get_member_types(opts->m_tid, &members);
+ for (i = 0; i < opts->hs_nelmts; i++) {
+ H5TOOLS_DEBUG("opts->pos[%" PRIuHSIZE "]:%" PRIuHSIZE " - nelmts:%" PRIuHSIZE, i,
+ opts->pos[i], opts->hs_nelmts);
+ nfound += diff_datum(mem1 + i * size, mem2 + i * size, i, opts, container1_id, container2_id,
+ &members);
+ if (opts->count_bool && nfound >= opts->count)
+ break;
+ } /* i */
+ close_member_types(&members);
} /* switch */
-
+ H5TOOLS_ENDDEBUG(":%" PRIuHSIZE " - errstat:%d", nfound, opts->err_stat);
return nfound;
}
@@ -355,10 +404,6 @@ hsize_t diff_array( void *_mem1,
*
* Return: number of differences found
*
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: October 29, 2003
- *
* The comparison of the 2 buffers read from the files is made datum by datum.
*
* H5T_INTEGER and H5T_FLOAT
@@ -372,7 +417,7 @@ hsize_t diff_array( void *_mem1,
* Recursively call this function for each element
* H5T_STRING
* compare byte by byte in a cycle from 0 to type_size. this type_size is the
- * value obtained by the get_size function but it is the string lenght for
+ * value obtained by the get_size function but it is the string length for
* variable sized strings
* H5T_OPAQUE
* compare byte by byte in a cycle from 0 to type_size
@@ -385,2160 +430,839 @@ hsize_t diff_array( void *_mem1,
* Dereference the object and compare the type (basic object type).
*-------------------------------------------------------------------------
*/
-hsize_t diff_datum(void *_mem1,
- void *_mem2,
- hid_t m_type,
- hsize_t i,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- hid_t container1_id,
- hid_t container2_id, /*where the reference came from*/
- int *ph, /*print header */
- mcomp_t *members) /*compound members */
+static hsize_t
+diff_datum(void *_mem1, void *_mem2, hsize_t elemtno, diff_opt_t *opts, hid_t container1_id,
+ hid_t container2_id, mcomp_t *members)
{
- unsigned char *mem1 = (unsigned char*)_mem1;
- unsigned char *mem2 = (unsigned char*)_mem2;
- unsigned u;
- hid_t memb_type;
- size_t type_size;
- H5T_sign_t type_sign;
- H5T_class_t type_class;
- size_t offset;
- int nmembs;
- int j;
- hsize_t nelmts;
- size_t size=0;
- int iszero1;
- int iszero2;
- hid_t obj1_id;
- hid_t obj2_id;
- hsize_t nfound=0; /* differences found */
- int ret=0; /* check return error */
- float f1, f2;
- double per;
- int both_zero;
-
- type_size = H5Tget_size( m_type );
- type_class = H5Tget_class(m_type);
+ unsigned char *mem1 = (unsigned char *)_mem1;
+ unsigned char *mem2 = (unsigned char *)_mem2;
+ size_t u;
+ size_t type_size;
+ H5T_sign_t type_sign;
+ H5T_class_t type_class;
+ size_t offset;
+ unsigned nmembs;
+ unsigned j;
+ size_t size = 0;
+ hbool_t iszero1;
+ hbool_t iszero2;
+ hsize_t nfound = 0; /* differences found */
+ diff_err_t ret_value = opts->err_stat;
+
+ H5TOOLS_START_DEBUG("ph:%d elemtno:%" PRIuHSIZE " - errstat:%d", opts->print_header, elemtno,
+ opts->err_stat);
+
+ type_size = H5Tget_size(opts->m_tid);
+ type_class = H5Tget_class(opts->m_tid);
/* Fast comparison first for atomic type by memcmp().
* It is OK not to list non-atomic type here because it will not be caught
- * by the confition, but it gives more clarity for code planning
- */
- if (type_class != H5T_REFERENCE &&
- type_class != H5T_COMPOUND &&
- type_class != H5T_STRING &&
- type_class != H5T_VLEN &&
- HDmemcmp(mem1, mem2, type_size)==0)
- return 0;
-
- switch (H5Tget_class(m_type))
- {
- default:
- HDassert(0);
- break;
- case H5T_TIME:
- HDassert(0);
- break;
-
- /*-------------------------------------------------------------------------
- * H5T_COMPOUND
- *-------------------------------------------------------------------------
- */
- case H5T_COMPOUND:
-
- nmembs = members->n;
-
-
- for (j = 0; j < nmembs; j++)
- {
- offset = members->offsets[j];
- memb_type = members->ids[j];
-
- nfound+=diff_datum(
- mem1+offset,
- mem2+offset,
- memb_type,
- i,
- rank,
- dims,
- acc,
- pos,
- options,
- obj1,
- obj2,
- container1_id,
- container2_id,
- ph, members->m[j]);
- }
- break;
-
- /*-------------------------------------------------------------------------
- * H5T_STRING
- *-------------------------------------------------------------------------
- */
- case H5T_STRING:
-
- {
- H5T_str_t pad;
- char *s;
- char *s1;
- char *s2;
- size_t size1;
- size_t size2;
-
- /* if variable length string */
- if(H5Tis_variable_str(m_type))
- {
- /* Get pointer to first string */
- s1 = *(char**) mem1;
- size1 = HDstrlen(s1);
- /* Get pointer to second string */
- s2 = *(char**) mem2;
- size2 = HDstrlen(s2);
- }
- else
- {
- /* Get pointer to first string */
- s1 = mem1;
- size1 = H5Tget_size(m_type);
- /* Get pointer to second string */
- s2 = mem2;
- size2 = H5Tget_size(m_type);
- }
-
- /*
- * compare for shorter string
- * TODO: this code need to be improved to handle the difference
- * of length of strings.
- * For now mimic the previous way.
- */
- if(size1 < size2)
- {
- size = size1;
- s = s1;
- }
- else
- {
- size = size2;
- s = s2;
- }
-
- /* check for NULL pointer for string */
- if(s!=NULL)
- {
- /* try fast compare first */
- if (HDmemcmp(s1, s2, size)==0)
- break;
-
- pad = H5Tget_strpad(m_type);
-
- for (u=0; u<size && (s[u] || pad!=H5T_STR_NULLTERM); u++)
- nfound+=character_compare(
- s1 + u,
- s2 + u, /* offset */
- i, /* index position */
- u, /* string character position */
- rank,
- dims,
- acc,
- pos,
- options,
- obj1,
- obj2,
- ph);
- }
-
- }
- break;
-
- /*-------------------------------------------------------------------------
- * H5T_BITFIELD
- *-------------------------------------------------------------------------
- */
- case H5T_BITFIELD:
-
- /* byte-by-byte comparison */
- for (u=0; u<type_size; u++)
- nfound+=character_compare_opt(
- mem1 + u,
- mem2 + u, /* offset */
- i, /* index position */
- rank,
- dims,
- acc,
- pos,
- options,
- obj1,
- obj2,
- ph);
-
- break;
-
- /*-------------------------------------------------------------------------
- * H5T_OPAQUE
- *-------------------------------------------------------------------------
+ * by the condition, but it gives more clarity for code planning
*/
- case H5T_OPAQUE:
-
- /* byte-by-byte comparison */
- for (u=0; u<type_size; u++)
- nfound+=character_compare_opt(
- mem1 + u,
- mem2 + u, /* offset */
- i, /* index position */
- rank,
- dims,
- acc,
- pos,
- options,
- obj1,
- obj2,
- ph);
-
- break;
-
-
- /*-------------------------------------------------------------------------
- * H5T_ENUM
- *-------------------------------------------------------------------------
- */
- case H5T_ENUM:
-
- /* For enumeration types we compare the names instead of the
- integer values. For each pair of elements being
- compared, we convert both bit patterns to their corresponding
- enumeration constant and do a string comparison
- */
-
- {
- char enum_name1[1024];
- char enum_name2[1024];
-
- herr_t err1;
- herr_t err2;
-
- /* disable error reporting */
- H5E_BEGIN_TRY {
-
- /* If the enum value cannot be converted to a string
- * it is set to an error string for later output.
- */
- err1 = H5Tenum_nameof(m_type, mem1, enum_name1, sizeof enum_name1);
- if(err1 < 0)
- strcpy(enum_name1, "**INVALID VALUE**");
-
- err2 = H5Tenum_nameof(m_type, mem2, enum_name2, sizeof enum_name2);
- if(err2 < 0)
- strcpy(enum_name2, "**INVALID VALUE**");
-
- if(err1 < 0 || err2 < 0)
- {
- /* One or more bad enum values */
-
- /* If the two values cannot be converted to a string
- * (probably due to them being invalid enum values),
- * don't attempt to convert them - just report errors.
- */
- nfound += 1;
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(S_FORMAT,enum_name1,enum_name2);
- }
- }
- else
- {
- /* Both enum values were valid */
-
- if (HDstrcmp(enum_name1,enum_name2)!=0)
- {
- nfound=1;
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(S_FORMAT,enum_name1,enum_name2);
- }
- }
- else
- {
- for (u=0; u<type_size; u++)
- nfound+=character_compare_opt(
- mem1 + u,
- mem2 + u, /* offset */
- i, /* index position */
- rank,
- dims,
- acc,
- pos,
- options,
- obj1,
- obj2,
- ph);
- }
- }
- /* enable error reporting */
- } H5E_END_TRY;
- }
-
-
- break;
-
- /*-------------------------------------------------------------------------
- * H5T_ARRAY
- *-------------------------------------------------------------------------
- */
- case H5T_ARRAY:
-
- {
- hsize_t adims[H5S_MAX_RANK];
- hsize_t ndims;
- /* get the array's base datatype for each element */
- memb_type = H5Tget_super(m_type);
- size = H5Tget_size(memb_type);
- ndims = H5Tget_array_ndims(m_type);
- H5Tget_array_dims2(m_type, adims);
- HDassert(ndims >= 1 && ndims <= H5S_MAX_RANK);
-
- /* calculate the number of array elements */
- for (u = 0, nelmts = 1; u <ndims; u++)
- nelmts *= adims[u];
- for (u = 0; u < nelmts; u++)
- {
- nfound+=diff_datum(
- mem1 + u * size,
- mem2 + u * size, /* offset */
- memb_type,
- i, /* index position */
- rank,
- dims,
- acc,
- pos,
- options,
- obj1,
- obj2,
- container1_id,
- container2_id,
- ph, members);
- }
- H5Tclose(memb_type);
- }
- break;
-
-
-
- /*-------------------------------------------------------------------------
- * H5T_REFERENCE
- *-------------------------------------------------------------------------
- */
-
- case H5T_REFERENCE:
-
- iszero1=all_zero(_mem1, H5Tget_size(m_type));
- iszero2=all_zero(_mem2, H5Tget_size(m_type));
- if (iszero1 != iszero2)
- {
- return 1;
- }
- else if (!iszero1 && !iszero2)
- {
+ if (type_class != H5T_REFERENCE && type_class != H5T_COMPOUND && type_class != H5T_STRING &&
+ type_class != H5T_VLEN && HDmemcmp(mem1, mem2, type_size) == 0)
+ H5TOOLS_GOTO_DONE(opts->err_stat);
+
+ switch (H5Tget_class(opts->m_tid)) {
+ case H5T_NO_CLASS:
+ case H5T_TIME:
+ case H5T_NCLASSES:
+ default:
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Invalid type class");
+ break;
/*-------------------------------------------------------------------------
- * H5T_STD_REF_DSETREG
- * Dataset region reference
- *-------------------------------------------------------------------------
- */
- if (type_size==H5R_DSET_REG_REF_BUF_SIZE)
+ * H5T_COMPOUND
+ *-------------------------------------------------------------------------
+ */
+ case H5T_COMPOUND:
+ H5TOOLS_DEBUG("H5T_COMPOUND");
{
- hid_t region1_id;
- hid_t region2_id;
-
- if ((obj1_id = H5Rdereference2(container1_id, H5P_DEFAULT, H5R_DATASET_REGION, _mem1))<0)
- ret= -1;
- if ((obj2_id = H5Rdereference2(container2_id, H5P_DEFAULT, H5R_DATASET_REGION, _mem2))<0)
- ret= -1;
- if ((region1_id = H5Rget_region(container1_id, H5R_DATASET_REGION, _mem1))<0)
- ret= -1;
- if ((region2_id = H5Rget_region(container2_id, H5R_DATASET_REGION, _mem2))<0)
- ret= -1;
-
- if (ret==-1) {
- options->err_stat=1;
- return 0;
- }
-
- nfound = diff_region(obj1_id,obj2_id,region1_id,region2_id,options);
-
- H5Oclose(obj1_id);
- H5Oclose(obj2_id);
- H5Sclose(region1_id);
- H5Sclose(region2_id);
+ diff_opt_t cmpd_opts;
- }/*dataset reference*/
+ cmpd_opts = *opts;
+ nmembs = members->n;
+ for (j = 0; j < nmembs; j++) {
+ offset = members->offsets[j];
+ cmpd_opts.m_tid = members->ids[j];
- /*-------------------------------------------------------------------------
- * H5T_STD_REF_OBJ
- * Object references. get the type and OID of the referenced object
- *-------------------------------------------------------------------------
- */
- else if (type_size == H5R_OBJ_REF_BUF_SIZE)
- {
- H5O_type_t obj1_type;
- H5O_type_t obj2_type;
-
- if(H5Rget_obj_type2(container1_id, H5R_OBJECT, _mem1, &obj1_type) < 0)
- ret = -1;
- if(H5Rget_obj_type2(container2_id, H5R_OBJECT, _mem2, &obj2_type) < 0)
- ret = -1;
- if(ret == -1) {
- options->err_stat = 1;
- return 0;
- } /* end if */
-
- /* check object type */
- if(obj1_type != obj2_type)
- {
- parallel_print("Different object types referenced: <%s> and <%s>", obj1, obj2);
- options->not_cmp = 1;
- return 0;
+ nfound += diff_datum(mem1 + offset, mem2 + offset, elemtno, &cmpd_opts, container1_id,
+ container2_id, members->m[j]);
}
-
- if((obj1_id = H5Rdereference2(container1_id, H5P_DEFAULT, H5R_OBJECT, _mem1)) < 0)
- ret = -1;
- if((obj2_id = H5Rdereference2(container2_id, H5P_DEFAULT, H5R_OBJECT, _mem2)) < 0)
- ret = -1;
- if(ret == -1) {
- options->err_stat = 1;
- return 0;
- } /* end if */
-
- /* compare */
- if(obj1_type == H5O_TYPE_DATASET)
- nfound = diff_datasetid(obj1_id,
- obj2_id,
- NULL,
- NULL,
- options);
- else {
- if(options->m_verbose)
- parallel_print("Warning: Comparison not possible of object types referenced: <%s> and <%s>\n",
- obj1, obj2);
- options->not_cmp = 1;
- }
-
- H5Oclose(obj1_id);
- H5Oclose(obj2_id);
-
- }/*object reference*/
-
- }/*is zero*/
-
-
- break;
-
- /*-------------------------------------------------------------------------
- * H5T_VLEN
- *-------------------------------------------------------------------------
- */
-
- case H5T_VLEN:
-
- /* get the VL sequences's base datatype for each element */
- memb_type = H5Tget_super(m_type);
- size = H5Tget_size(memb_type);
-
- /* get the number of sequence elements */
- nelmts = ((hvl_t *)mem1)->len;
-
- for (j = 0; j < (int)nelmts; j++)
- nfound+=diff_datum(
- ((char *)(((hvl_t *)mem1)->p)) + j * size,
- ((char *)(((hvl_t *)mem2)->p)) + j * size, /* offset */
- memb_type,
- i, /* index position */
- rank,
- dims,
- acc,
- pos,
- options,
- obj1,
- obj2,
- container1_id,
- container2_id,
- ph, members);
-
- H5Tclose(memb_type);
-
- break;
-
-
-
- /*-------------------------------------------------------------------------
- * H5T_INTEGER
- *-------------------------------------------------------------------------
- */
-
- case H5T_INTEGER:
- type_sign = H5Tget_sign(m_type);
-
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_SCHAR
- *-------------------------------------------------------------------------
- */
- if (type_size==1 && type_sign!=H5T_SGN_NONE)
- {
- char temp1_char;
- char temp2_char;
- HDassert(type_size==sizeof(char));
- HDmemcpy(&temp1_char, mem1, sizeof(char));
- HDmemcpy(&temp2_char, mem2, sizeof(char));
- /* -d and !-p */
- if (options->d && !options->p)
- {
- if (ABS(temp1_char-temp2_char) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_char,temp2_char,ABS(temp1_char-temp2_char));
- }
- nfound++;
- }
- }
- /* !-d and -p */
- else if (!options->d && options->p)
- {
- PER(temp1_char,temp2_char);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_char,temp2_char,ABS(temp1_char-temp2_char));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_char,temp2_char,ABS(temp1_char-temp2_char),per);
- }
- nfound++;
- }
- }
- /* -d and -p */
- else if ( options->d && options->p)
- {
- PER(temp1_char,temp2_char);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_char,temp2_char,ABS(temp1_char-temp2_char));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent && ABS(temp1_char-temp2_char) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_char,temp2_char,ABS(temp1_char-temp2_char),per);
- }
- nfound++;
- }
- }
- else if (temp1_char != temp2_char)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_char,temp2_char,ABS(temp1_char-temp2_char));
- }
- nfound++;
- }
-
- } /*H5T_NATIVE_SCHAR*/
-
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_UCHAR
- *-------------------------------------------------------------------------
- */
- else if (type_size==1 && type_sign==H5T_SGN_NONE)
- {
- unsigned char temp1_uchar;
- unsigned char temp2_uchar;
- HDassert(type_size==sizeof(unsigned char));
-
- HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
- HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
- /* -d and !-p */
- if (options->d && !options->p)
- {
- if ( PDIFF(temp1_uchar,temp2_uchar) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar));
- }
- nfound++;
- }
- }
- /* !-d and -p */
- else if (!options->d && options->p)
- {
- PER_UNSIGN(signed char,temp1_uchar,temp2_uchar);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar),per);
- }
- nfound++;
- }
- }
- /* -d and -p */
- else if ( options->d && options->p)
- {
- PER_UNSIGN(signed char,temp1_uchar,temp2_uchar);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent && PDIFF(temp1_uchar,temp2_uchar) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar),per);
- }
- nfound++;
- }
- }
- else if (temp1_uchar != temp2_uchar)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar));
- }
- nfound++;
+ opts->err_stat = opts->err_stat | cmpd_opts.err_stat;
+ opts->print_header = cmpd_opts.print_header;
+ opts->not_cmp = cmpd_opts.not_cmp;
}
+ break;
- } /*H5T_NATIVE_UCHAR*/
-
-
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_SHORT
- *-------------------------------------------------------------------------
- */
-
- else if (type_size==2 && type_sign!=H5T_SGN_NONE)
- {
- short temp1_short;
- short temp2_short;
- HDassert(type_size==sizeof(short));
-
- HDmemcpy(&temp1_short, mem1, sizeof(short));
- HDmemcpy(&temp2_short, mem2, sizeof(short));
- /* -d and !-p */
- if (options->d && !options->p)
- {
- if (ABS(temp1_short-temp2_short) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_short,temp2_short,ABS(temp1_short-temp2_short));
- }
- nfound++;
- }
- }
- /* !-d and -p */
- else if (!options->d && options->p)
- {
- PER(temp1_short,temp2_short);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_short,temp2_short,ABS(temp1_short-temp2_short));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_short,temp2_short,ABS(temp1_short-temp2_short),per);
- }
- nfound++;
- }
- }
- /* -d and -p */
- else if ( options->d && options->p)
- {
- PER(temp1_short,temp2_short);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_short,temp2_short,ABS(temp1_short-temp2_short));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent && ABS(temp1_short-temp2_short) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_short,temp2_short,ABS(temp1_short-temp2_short),per);
- }
- nfound++;
- }
- }
- else if (temp1_short != temp2_short)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_short,temp2_short,ABS(temp1_short-temp2_short));
- }
- nfound++;
- }
-
-
- } /*H5T_NATIVE_SHORT*/
-
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_USHORT
- *-------------------------------------------------------------------------
- */
-
- else if (type_size==2 && type_sign==H5T_SGN_NONE)
- {
- unsigned short temp1_ushort;
- unsigned short temp2_ushort;
- HDassert(type_size==sizeof(short));
-
- HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short));
- HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short));
- /* -d and !-p */
- if (options->d && !options->p)
- {
- if ( PDIFF(temp1_ushort,temp2_ushort) > options->delta)
- {
-
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_ushort,temp2_ushort,PDIFF(temp1_ushort,temp2_ushort));
- }
- nfound++;
- }
- }
- /* !-d and -p */
- else if (!options->d && options->p)
- {
- PER_UNSIGN(signed short,temp1_ushort,temp2_ushort);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_ushort,temp2_ushort,
- PDIFF(temp1_ushort,temp2_ushort));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_ushort,temp2_ushort,PDIFF(temp1_ushort,temp2_ushort),per);
- }
- nfound++;
- }
- }
- /* -d and -p */
- else if ( options->d && options->p)
- {
- PER_UNSIGN(signed short,temp1_ushort,temp2_ushort);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_ushort,temp2_ushort,PDIFF(temp1_ushort,temp2_ushort));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent && PDIFF(temp1_ushort,temp2_ushort) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_ushort,temp2_ushort,PDIFF(temp1_ushort,temp2_ushort),per);
- }
- nfound++;
- }
- }
- else if (temp1_ushort != temp2_ushort)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_ushort,temp2_ushort,PDIFF(temp1_ushort,temp2_ushort));
- }
- nfound++;
- }
- } /*H5T_NATIVE_USHORT*/
-
-
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_INT
- *-------------------------------------------------------------------------
- */
-
- else if (type_size==4 && type_sign!=H5T_SGN_NONE)
- {
- int temp1_int;
- int temp2_int;
- HDassert(type_size==sizeof(int));
-
- HDmemcpy(&temp1_int, mem1, sizeof(int));
- HDmemcpy(&temp2_int, mem2, sizeof(int));
- /* -d and !-p */
- if (options->d && !options->p)
- {
- if (ABS(temp1_int-temp2_int) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_int,temp2_int,ABS(temp1_int-temp2_int));
- }
- nfound++;
- }
- }
- /* !-d and -p */
- else if (!options->d && options->p)
- {
- PER(temp1_int,temp2_int);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_int,temp2_int,ABS(temp1_int-temp2_int));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_int,temp2_int,ABS(temp1_int-temp2_int),per);
- }
- nfound++;
- }
- }
- /* -d and -p */
- else if ( options->d && options->p)
- {
- PER(temp1_int,temp2_int);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_int,temp2_int,ABS(temp1_int-temp2_int));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent && ABS(temp1_int-temp2_int) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_int,temp2_int,ABS(temp1_int-temp2_int),per);
- }
- nfound++;
- }
- }
- else if (temp1_int != temp2_int)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_int,temp2_int,ABS(temp1_int-temp2_int));
- }
- nfound++;
- }
- } /*H5T_NATIVE_INT*/
-
-
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_UINT
- *-------------------------------------------------------------------------
- */
-
- else if (type_size==4 && type_sign==H5T_SGN_NONE)
- {
- unsigned int temp1_uint;
- unsigned int temp2_uint;
- HDassert(type_size==sizeof(int));
-
- HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int));
- HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int));
- /* -d and !-p */
- if (options->d && !options->p)
- {
- if ( PDIFF(temp1_uint,temp2_uint) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(UI_FORMAT,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint));
- }
- nfound++;
- }
- }
- /* !-d and -p */
- else if (!options->d && options->p)
- {
- PER_UNSIGN(signed int,temp1_uint,temp2_uint);
+ /*-------------------------------------------------------------------------
+ * H5T_STRING
+ *-------------------------------------------------------------------------
+ */
+ case H5T_STRING:
+ H5TOOLS_DEBUG("H5T_STRING");
+ {
+ char *s = NULL;
+ char *sx = NULL;
+ char *s1 = NULL;
+ char *s2 = NULL;
+ size_t size1;
+ size_t size2;
+ size_t sizex;
+ size_t size_mtype = H5Tget_size(opts->m_tid);
+ H5T_str_t pad = H5Tget_strpad(opts->m_tid);
+
+ /* if variable length string */
+ if (H5Tis_variable_str(opts->m_tid)) {
+ H5TOOLS_DEBUG("H5T_STRING variable");
+ /* Get pointer to first string */
+ s1 = *(char **)((void *)mem1);
+ if (s1)
+ size1 = HDstrlen(s1);
+ else
+ size1 = 0;
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint));
- }
- nfound++;
- }
+ /* Get pointer to second string */
+ s2 = *(char **)((void *)mem2);
+ if (s2)
+ size2 = HDstrlen(s2);
+ else
+ size2 = 0;
+ }
+ else if (H5T_STR_NULLTERM == pad) {
+ H5TOOLS_DEBUG("H5T_STRING null term");
+ /* Get pointer to first string */
+ s1 = (char *)mem1;
+ if (s1)
+ size1 = HDstrlen(s1);
+ else
+ size1 = 0;
- else
+ if (size1 > size_mtype)
+ size1 = size_mtype;
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint),per);
- }
- nfound++;
- }
- }
- /* -d and -p */
- else if ( options->d && options->p)
- {
- PER_UNSIGN(signed int,temp1_uint,temp2_uint);
+ /* Get pointer to second string */
+ s2 = (char *)mem2;
+ if (s2)
+ size2 = HDstrlen(s2);
+ else
+ size2 = 0;
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint));
- }
- nfound++;
+ if (size2 > size_mtype)
+ size2 = size_mtype;
}
+ else {
+ /* Get pointer to first string */
+ s1 = (char *)mem1;
+ size1 = size_mtype;
- else
-
- if ( per > options->percent && PDIFF(temp1_uint,temp2_uint) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint),per);
- }
- nfound++;
- }
- }
- else if (temp1_uint != temp2_uint)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(UI_FORMAT,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint));
+ /* Get pointer to second string */
+ s2 = (char *)mem2;
+ size2 = size_mtype;
}
- nfound++;
- }
- } /*H5T_NATIVE_UINT*/
-
-
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_LONG
- *-------------------------------------------------------------------------
- */
-
- else if (type_size==8 && type_sign!=H5T_SGN_NONE)
- {
- long temp1_long;
- long temp2_long;
- HDassert(type_size==sizeof(long));
- HDmemcpy(&temp1_long, mem1, sizeof(long));
- HDmemcpy(&temp2_long, mem2, sizeof(long));
- /* -d and !-p */
- if (options->d && !options->p)
- {
- if (ABS(temp1_long-temp2_long) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT,temp1_long,temp2_long,ABS(temp1_long-temp2_long));
- }
+ /*
+ * compare for shorter string
+ * TODO: this code need to be improved to handle the difference
+ * of length of strings.
+ * For now mimic the previous way.
+ */
+ H5TOOLS_DEBUG("string size:%ld", size1);
+ H5TOOLS_DEBUG("string size:%ld", size2);
+ if (size1 != size2) {
+ H5TOOLS_DEBUG("string sizes difference");
nfound++;
}
- }
- /* !-d and -p */
- else if (!options->d && options->p)
- {
- PER(temp1_long,temp2_long);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT_P_NOTCOMP,temp1_long,temp2_long,
- ABS(temp1_long-temp2_long));
- }
- nfound++;
+ if (size1 < size2) {
+ size = size1;
+ s = s1;
+ sizex = size2;
+ sx = s2;
}
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT_P,temp1_long,temp2_long,ABS(temp1_long-temp2_long),per);
- }
- nfound++;
- }
- }
- /* -d and -p */
- else if ( options->d && options->p)
- {
- PER(temp1_long,temp2_long);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT_P_NOTCOMP,temp1_long,temp2_long,ABS(temp1_long-temp2_long));
- }
- nfound++;
+ else {
+ size = size2;
+ s = s2;
+ sizex = size1;
+ sx = s1;
}
- else
-
- if ( per > options->percent && ABS(temp1_long-temp2_long) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT_P,temp1_long,temp2_long,
- ABS(temp1_long-temp2_long),
- per);
- }
- nfound++;
- }
- }
- else if (temp1_long != temp2_long)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT,temp1_long,temp2_long,ABS(temp1_long-temp2_long));
- }
- nfound++;
- }
- } /*H5T_NATIVE_LONG*/
-
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_ULONG
- *-------------------------------------------------------------------------
- */
-
- else if (type_size==8 && type_sign==H5T_SGN_NONE)
- {
- unsigned long temp1_ulong;
- unsigned long temp2_ulong;
- HDassert(type_size==sizeof(unsigned long));
-
- HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long));
- HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long));
- /* -d and !-p */
- if (options->d && !options->p)
- {
- if ( PDIFF(temp1_ulong,temp2_ulong) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULI_FORMAT,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong));
+ /* check for NULL pointer for string */
+ if (s != NULL) {
+ /* try fast compare first */
+ if ((HDmemcmp(s, sx, size) == 0) && (size1 != size2)) {
+ for (u = size; u < sizex; u++)
+ character_compare(s + u, sx + u, elemtno, u, opts);
}
- nfound++;
- }
+ else
+ for (u = 0; u < size; u++)
+ nfound += character_compare(s + u, sx + u, elemtno, u, opts);
+ } /* end check for NULL pointer for string */
}
- /* !-d and -p */
- else if (!options->d && options->p)
- {
- PER_UNSIGN(signed long,temp1_ulong,temp2_ulong);
+ break;
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULI_FORMAT_P_NOTCOMP,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong));
- }
- nfound++;
- }
+ /*-------------------------------------------------------------------------
+ * H5T_BITFIELD
+ *-------------------------------------------------------------------------
+ */
+ case H5T_BITFIELD:
+ H5TOOLS_DEBUG("H5T_BITFIELD");
+ /* byte-by-byte comparison */
+ for (u = 0; u < type_size; u++)
+ nfound += character_compare_opt(mem1 + u, mem2 + u, elemtno, opts);
+ break;
- else
+ /*-------------------------------------------------------------------------
+ * H5T_OPAQUE
+ *-------------------------------------------------------------------------
+ */
+ case H5T_OPAQUE:
+ H5TOOLS_DEBUG("H5T_OPAQUE");
+ /* byte-by-byte comparison */
+ for (u = 0; u < type_size; u++)
+ nfound += character_compare_opt(mem1 + u, mem2 + u, elemtno, opts);
+ break;
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULI_FORMAT_P,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong),per);
- }
- nfound++;
- }
- }
- /* -d and -p */
- else if ( options->d && options->p)
+ /*-------------------------------------------------------------------------
+ * H5T_ENUM
+ *-------------------------------------------------------------------------
+ */
+ case H5T_ENUM:
+ /* For enumeration types we compare the names instead of the
+ * integer values. For each pair of elements being
+ * compared, we convert both bit patterns to their corresponding
+ * enumeration constant and do a string comparison
+ */
+ H5TOOLS_DEBUG("H5T_ENUM");
{
- PER_UNSIGN(signed long,temp1_ulong,temp2_ulong);
+ char enum_name1[1024];
+ char enum_name2[1024];
+ herr_t err1;
+ herr_t err2;
- if (not_comparable && !both_zero) /* not comparable */
+ /* disable error reporting */
+ H5E_BEGIN_TRY
{
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULI_FORMAT_P_NOTCOMP,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong));
- }
- nfound++;
- }
+ /* If the enum value cannot be converted to a string
+ * it is set to an error string for later output.
+ */
+ err1 = H5Tenum_nameof(opts->m_tid, mem1, enum_name1, sizeof enum_name1);
+ if (err1 < 0)
+ HDsnprintf(enum_name1, sizeof(enum_name1), "**INVALID VALUE**");
- else
+ err2 = H5Tenum_nameof(opts->m_tid, mem2, enum_name2, sizeof enum_name2);
+ if (err2 < 0)
+ HDsnprintf(enum_name2, sizeof(enum_name2), "**INVALID VALUE**");
- if ( per > options->percent && PDIFF(temp1_ulong,temp2_ulong) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULI_FORMAT_P,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong),per);
+ /* One or more bad enum values */
+ if (err1 < 0 || err2 < 0) {
+ /* If the two values cannot be converted to a string
+ * (probably due to them being invalid enum values),
+ * don't attempt to convert them - just report errors.
+ */
+ nfound += 1;
+ opts->print_percentage = 0;
+ print_pos(opts, elemtno, 0);
+ if (print_data(opts)) {
+ parallel_print(S_FORMAT, enum_name1, enum_name2);
}
- nfound++;
- }
- }
- else if (temp1_ulong != temp2_ulong)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULI_FORMAT,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong));
- }
- nfound++;
- }
-
-
- } /*H5T_NATIVE_ULONG*/
-
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_LLONG
- *-------------------------------------------------------------------------
- */
-
- else if (type_size==8 && type_sign!=H5T_SGN_NONE)
- {
- long long temp1_llong;
- long long temp2_llong;
- HDassert(type_size==sizeof(long long));
-
- HDmemcpy(&temp1_llong, mem1, sizeof(long long));
- HDmemcpy(&temp2_llong, mem2, sizeof(long long));
- /* -d and !-p */
- if (options->d && !options->p)
- {
- if (ABS(temp1_llong-temp2_llong) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LLI_FORMAT,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong));
}
- nfound++;
- }
- }
- /* !-d and -p */
- else if (!options->d && options->p)
- {
- PER(temp1_llong,temp2_llong);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LLI_FORMAT_P_NOTCOMP,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LLI_FORMAT_P,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong),per);
+ else {
+ /* Both enum values were valid */
+ if (HDstrcmp(enum_name1, enum_name2) != 0) {
+ nfound = 1;
+ opts->print_percentage = 0;
+ print_pos(opts, elemtno, 0);
+ if (print_data(opts)) {
+ parallel_print(S_FORMAT, enum_name1, enum_name2);
+ }
}
- nfound++;
- }
- }
- /* -d and -p */
- else if ( options->d && options->p)
- {
- PER(temp1_llong,temp2_llong);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LLI_FORMAT_P_NOTCOMP,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent && ABS(temp1_llong-temp2_llong) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LLI_FORMAT_P,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong),per);
+ else {
+ for (u = 0; u < type_size; u++)
+ nfound += character_compare_opt(mem1 + u, mem2 + u, elemtno, opts);
}
- nfound++;
}
- }
- else if (temp1_llong != temp2_llong)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LLI_FORMAT,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong));
+ /* enable error reporting */
}
- nfound++;
+ H5E_END_TRY;
}
+ break;
- } /*H5T_NATIVE_LLONG*/
-
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_ULLONG
- *-------------------------------------------------------------------------
- */
-
- else if (type_size==8 && type_sign==H5T_SGN_NONE)
- {
- unsigned long long temp1_ullong;
- unsigned long long temp2_ullong;
- HDassert(type_size==sizeof(unsigned long long));
-
- HDmemcpy(&temp1_ullong, mem1, sizeof(unsigned long long));
- HDmemcpy(&temp2_ullong, mem2, sizeof(unsigned long long));
- /* -d and !-p */
- if (options->d && !options->p)
- {
- if ( PDIFF(temp1_ullong,temp2_ullong) > (unsigned long long)options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULLI_FORMAT,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong));
- }
- nfound++;
- }
- }
- /* !-d and -p */
- else if (!options->d && options->p)
- {
- ull2float(temp1_ullong,&f1);
- ull2float(temp2_ullong,&f2);
- PER(f1,f2);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULLI_FORMAT_P_NOTCOMP,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
-
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULLI_FORMAT_P,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong),per);
- }
- nfound++;
- }
- }
- /* -d and -p */
- else if ( options->d && options->p)
- {
- ull2float(temp1_ullong,&f1);
- ull2float(temp2_ullong,&f2);
- PER(f1,f2);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULLI_FORMAT_P_NOTCOMP,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent && PDIFF(temp1_ullong,temp2_ullong) > (unsigned long long)options->delta )
- {
+ /*-------------------------------------------------------------------------
+ * H5T_ARRAY
+ *-------------------------------------------------------------------------
+ */
+ case H5T_ARRAY: {
+ hsize_t adims[H5S_MAX_RANK];
+ int ndims;
+ diff_opt_t arr_opts;
+
+ H5TOOLS_DEBUG("H5T_ARRAY ph=%d", opts->print_header);
+
+ arr_opts = *opts;
+ H5TOOLS_DEBUG("Check opts: hs_nelmts:%" PRIuHSIZE " to %" PRIuHSIZE " rank:%d to %d",
+ opts->hs_nelmts, arr_opts.hs_nelmts, opts->rank, arr_opts.rank);
+ /* get the array's base datatype for each element */
+ arr_opts.m_tid = H5Tget_super(opts->m_tid);
+ size = H5Tget_size(arr_opts.m_tid);
+ ndims = H5Tget_array_ndims(opts->m_tid);
+ H5Tget_array_dims2(opts->m_tid, adims);
+ HDassert(ndims >= 1 && ndims <= H5S_MAX_RANK);
+ H5TOOLS_DEBUG("attr ph=%d", arr_opts.print_header);
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
+ /* calculate the number of array elements */
+ for (u = 0, arr_opts.hs_nelmts = 1; u < (unsigned)ndims; u++)
+ arr_opts.hs_nelmts *= adims[u];
+ for (u = 0; u < arr_opts.hs_nelmts; u++) {
+ nfound += diff_datum(mem1 + u * size, mem2 + u * size, elemtno, &arr_opts, container1_id,
+ container2_id, members);
+ }
+ opts->err_stat = opts->err_stat | arr_opts.err_stat;
+ opts->print_header = arr_opts.print_header;
+ opts->not_cmp = arr_opts.not_cmp;
+ H5Tclose(arr_opts.m_tid);
+ } break;
- parallel_print(SPACES);
- parallel_print(ULLI_FORMAT_P,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong),per);
- }
- nfound++;
- }
- }
- else if (temp1_ullong != temp2_ullong)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULLI_FORMAT,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong));
- }
+ /*-------------------------------------------------------------------------
+ * H5T_REFERENCE
+ *-------------------------------------------------------------------------
+ */
+ case H5T_REFERENCE:
+ H5TOOLS_DEBUG("H5T_REFERENCE");
+ iszero1 = all_zero(_mem1, H5Tget_size(opts->m_tid));
+ iszero2 = all_zero(_mem2, H5Tget_size(opts->m_tid));
+ if (iszero1 != iszero2) {
nfound++;
+ H5TOOLS_GOTO_DONE(opts->err_stat);
}
+ else if (!iszero1 && !iszero2) {
+ hid_t obj1_id = H5I_INVALID_HID;
+ hid_t obj2_id = H5I_INVALID_HID;
+ diff_opt_t ref_opts;
- } /*H5T_NATIVE_ULLONG*/
-
-
- break; /* H5T_INTEGER class */
-
-
- /*-------------------------------------------------------------------------
- * H5T_FLOAT
- *-------------------------------------------------------------------------
- */
-
- case H5T_FLOAT:
-
-
-
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_FLOAT
- *-------------------------------------------------------------------------
- */
- if (type_size==4)
- {
- float temp1_float;
- float temp2_float;
- int isnan1=0;
- int isnan2=0;
-
- HDassert(type_size==sizeof(float));
-
- HDmemcpy(&temp1_float, mem1, sizeof(float));
- HDmemcpy(&temp2_float, mem2, sizeof(float));
-
- /* logic for detecting NaNs is different with options -d, -p and no options */
-
- /*-------------------------------------------------------------------------
- * -d and !-p
- *-------------------------------------------------------------------------
- */
- if (options->d && !options->p)
- {
-
-
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if ( options->do_nans )
- {
- isnan1 = my_isnan(FLT_FLOAT,&temp1_float);
- isnan2 = my_isnan(FLT_FLOAT,&temp2_float);
- }
-
- /* both not NaN, do the comparison */
- if ( isnan1==0 && isnan2==0)
- {
-
- if (ABS(temp1_float-temp2_float) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float));
- }
- nfound++;
- }
-
- }
- /* only one is NaN, assume difference */
- else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float));
- }
- nfound++;
-
- }
- }
- /*-------------------------------------------------------------------------
- * !-d and -p
- *-------------------------------------------------------------------------
- */
- else if (!options->d && options->p)
- {
-
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if ( options->do_nans )
- {
- isnan1 = my_isnan(FLT_FLOAT,&temp1_float);
- isnan2 = my_isnan(FLT_FLOAT,&temp2_float);
- }
-
- /* both not NaN, do the comparison */
- if ( isnan1==0 && isnan2==0)
- {
-
- PER(temp1_float,temp2_float);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P_NOTCOMP,temp1_float,temp2_float,ABS(temp1_float-temp2_float));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent && ABS(temp1_float-temp2_float) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P,temp1_float,temp2_float,
- ABS(temp1_float-temp2_float),
- ABS(1-temp2_float/temp1_float));
+ /*-------------------------------------------------------------------------
+ * H5T_STD_REF
+ * Reference
+ *-------------------------------------------------------------------------
+ */
+ ref_opts = *opts;
+ ref_opts.obj_name[0] = NULL;
+ ref_opts.obj_name[1] = NULL;
+ if (H5Tequal(ref_opts.m_tid, H5T_STD_REF)) {
+ /* if (type_size == H5R_STD_REF_SIZE) */
+ hid_t region1_id = H5I_INVALID_HID;
+ hid_t region2_id = H5I_INVALID_HID;
+ H5R_ref_t *ref1_buf = (H5R_ref_t *)_mem1;
+ H5R_ref_t *ref2_buf = (H5R_ref_t *)_mem2;
+ H5O_type_t obj1_type = -1; /* Object type */
+ H5O_type_t obj2_type = -1; /* Object type */
+ H5R_type_t ref_type; /* Reference type */
+
+ H5TOOLS_DEBUG("H5T_REFERENCE - H5T_STD_REF");
+ ref_type = H5Rget_type(ref1_buf);
+ switch (ref_type) {
+ case H5R_OBJECT1:
+ H5TOOLS_DEBUG("ref_type is H5R_OBJECT1");
+ if (H5Rget_obj_type3(ref1_buf, H5P_DEFAULT, &obj1_type) >= 0) {
+ if (H5Rget_obj_type3(ref2_buf, H5P_DEFAULT, &obj2_type) >= 0) {
+ /* check object type */
+ if (obj1_type == obj2_type) {
+ switch (obj1_type) {
+ case H5O_TYPE_DATASET:
+ if ((obj1_id = H5Ropen_object(ref1_buf, H5P_DEFAULT,
+ H5P_DEFAULT)) >= 0) {
+ if ((obj2_id = H5Ropen_object(ref2_buf, H5P_DEFAULT,
+ H5P_DEFAULT)) >= 0) {
+ nfound = diff_datasetid(obj1_id, obj2_id,
+ opts->obj_name[0],
+ opts->obj_name[1], &ref_opts);
+ if (H5Dclose(obj2_id) < 0) {
+ ref_opts.err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("H5Dclose H5R_OBJECT1 failed");
+ }
+ }
+ else {
+ ref_opts.err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("H5Ropen_object object 2 failed");
+ }
+ if (H5Dclose(obj1_id) < 0) {
+ ref_opts.err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("H5Dclose H5R_OBJECT1 failed");
+ }
+ }
+ else {
+ ref_opts.err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("H5Ropen_object object 1 failed");
+ }
+ break;
+
+ case H5O_TYPE_GROUP:
+ case H5O_TYPE_NAMED_DATATYPE:
+ case H5O_TYPE_MAP:
+ case H5O_TYPE_UNKNOWN:
+ case H5O_TYPE_NTYPES:
+ default:
+ if (ref_opts.mode_verbose)
+ parallel_print("Warning: Comparison not possible of "
+ "object types referenced: <%s> and <%s>\n",
+ opts->obj_name[0], opts->obj_name[1]);
+ ref_opts.not_cmp = 1;
+ break;
+ } /* end switch */
+ }
+ else {
+ parallel_print("Different object types referenced: <%s> and <%s>",
+ opts->obj_name[0], opts->obj_name[1]);
+ ref_opts.not_cmp = 1;
+ ref_opts.err_stat = H5DIFF_ERR;
+ }
+ }
+ else {
+ ref_opts.err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("H5Rget_obj_type3 object 2 failed");
+ }
}
- nfound++;
- }
-
- }
- /* only one is NaN, assume difference */
- else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float));
- }
- nfound++;
-
- }
- }
-
- /*-------------------------------------------------------------------------
- * -d and -p
- *-------------------------------------------------------------------------
- */
-
- else if ( options->d && options->p)
- {
-
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if ( options->do_nans )
- {
- isnan1 = my_isnan(FLT_FLOAT,&temp1_float);
- isnan2 = my_isnan(FLT_FLOAT,&temp2_float);
- }
-
- /* both not NaN, do the comparison */
- if ( isnan1==0 && isnan2==0)
- {
-
- PER(temp1_float,temp2_float);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P_NOTCOMP,temp1_float,temp2_float,
- ABS(temp1_float-temp2_float));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P,temp1_float,temp2_float,
- ABS(temp1_float-temp2_float),
- ABS(1-temp2_float/temp1_float));
+ else {
+ ref_opts.err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("H5Rget_obj_type3 object 1 failed");
}
- nfound++;
- }
-
- }
- /* only one is NaN, assume difference */
- else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float));
- }
- nfound++;
-
- }
- }
-
- /*-------------------------------------------------------------------------
- * no -d and -p
- *-------------------------------------------------------------------------
- */
- else if (equal_float(temp1_float,temp2_float,options)==FALSE)
- {
-
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float));
- }
- nfound++;
- }
- } /*H5T_NATIVE_FLOAT*/
-
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_DOUBLE
- *-------------------------------------------------------------------------
- */
-
- else if (type_size==8)
- {
- double temp1_double;
- double temp2_double;
- int isnan1=0;
- int isnan2=0;
-
- HDassert(type_size==sizeof(double));
-
- HDmemcpy(&temp1_double, mem1, sizeof(double));
- HDmemcpy(&temp2_double, mem2, sizeof(double));
-
- /* logic for detecting NaNs is different with options -d, -p and no options */
-
- /*-------------------------------------------------------------------------
- * -d and !-p
- *-------------------------------------------------------------------------
- */
- if (options->d && !options->p)
- {
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if ( options->do_nans )
- {
- isnan1 = my_isnan(FLT_DOUBLE,&temp1_double);
- isnan2 = my_isnan(FLT_DOUBLE,&temp2_double);
- }
-
- /* both not NaN, do the comparison */
- if ( isnan1==0 && isnan2==0)
- {
-
- if (ABS(temp1_double-temp2_double) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double));
- }
- nfound++;
- }
-
- }
- /* only one is NaN, assume difference */
- else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double));
- }
- nfound++;
-
- }
- } /* options->d && !options->p */
-
- /*-------------------------------------------------------------------------
- * !-d and -p
- *-------------------------------------------------------------------------
- */
- else if (!options->d && options->p)
- {
-
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if ( options->do_nans )
- {
- isnan1 = my_isnan(FLT_DOUBLE,&temp1_double);
- isnan2 = my_isnan(FLT_DOUBLE,&temp2_double);
- }
-
- /* both not NaN, do the comparison */
- if ( isnan1==0 && isnan2==0)
- {
-
- PER(temp1_double,temp2_double);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P_NOTCOMP,temp1_double,temp2_double,
- ABS(temp1_double-temp2_double));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P,temp1_double,temp2_double,
- ABS(temp1_double-temp2_double),
- ABS(1-temp2_double/temp1_double));
+ break;
+ case H5R_DATASET_REGION1:
+ H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION1");
+ if ((obj1_id = H5Ropen_object(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ if ((obj2_id = H5Ropen_object(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ if ((region1_id = H5Ropen_region(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) >=
+ 0) {
+ if ((region2_id =
+ H5Ropen_region(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ nfound = diff_region(obj1_id, obj2_id, region1_id, region2_id,
+ &ref_opts);
+ if (H5Sclose(region2_id) < 0)
+ H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION1 failed");
+ }
+ if (H5Sclose(region1_id) < 0)
+ H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION1 failed");
+ }
+ if (H5Dclose(obj2_id) < 0)
+ H5TOOLS_INFO("H5Oclose H5R_DATASET_REGION1 failed");
+ }
+ else {
+ H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION1 failed");
+ }
+ if (H5Dclose(obj1_id) < 0)
+ H5TOOLS_INFO("H5Oclose H5R_DATASET_REGION1 failed");
}
- nfound++;
- }
-
- }
- /* only one is NaN, assume difference */
- else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double));
- }
- nfound++;
-
- }
- }
-
- /*-------------------------------------------------------------------------
- * -d and -p
- *-------------------------------------------------------------------------
- */
- else if ( options->d && options->p)
- {
-
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if ( options->do_nans )
- {
- isnan1 = my_isnan(FLT_DOUBLE,&temp1_double);
- isnan2 = my_isnan(FLT_DOUBLE,&temp2_double);
- }
-
- /* both not NaN, do the comparison */
- if ( isnan1==0 && isnan2==0)
- {
-
- PER(temp1_double,temp2_double);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P_NOTCOMP,temp1_double,temp2_double,
- ABS(temp1_double-temp2_double));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent &&
- ABS(temp1_double-temp2_double) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P,temp1_double,temp2_double,
- ABS(temp1_double-temp2_double),
- ABS(1-temp2_double/temp1_double));
+ else {
+ H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION1 failed");
}
- nfound++;
- }
-
- }
- /* only one is NaN, assume difference */
- else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double));
- }
- nfound++;
- }
- }
-
- /*-------------------------------------------------------------------------
- * no -d and -p
- *-------------------------------------------------------------------------
- */
- else if (equal_double(temp1_double,temp2_double,options)==FALSE)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double));
- }
- nfound++;
- }
- } /*H5T_NATIVE_DOUBLE*/
+ break;
+ case H5R_OBJECT2:
+ H5TOOLS_DEBUG("ref_type is H5R_OBJECT2");
+ if (H5Rget_obj_type3(ref1_buf, H5P_DEFAULT, &obj1_type) >= 0) {
+ if (H5Rget_obj_type3(ref2_buf, H5P_DEFAULT, &obj2_type) >= 0) {
+ /* check object type */
+ if (obj1_type == obj2_type) {
+ if ((obj1_id = H5Ropen_object(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) >=
+ 0) {
+ if ((obj2_id = H5Ropen_object(ref2_buf, H5P_DEFAULT,
+ H5P_DEFAULT)) >= 0) {
+ switch (obj1_type) {
+ case H5O_TYPE_DATASET:
+ H5TOOLS_DEBUG("ref_type is H5R_OBJECT2 : DATASET");
+ nfound = diff_datasetid(obj1_id, obj2_id,
+ opts->obj_name[0],
+ opts->obj_name[1], &ref_opts);
+ break;
+
+ case H5O_TYPE_GROUP:
+ H5TOOLS_DEBUG("ref_type is H5R_OBJECT2 : GROUP");
+ if (ref_opts.mode_verbose)
+ parallel_print(
+ "Warning: Comparison not possible of group "
+ "object types referenced: <%s> and <%s>\n",
+ opts->obj_name[0], opts->obj_name[1]);
+ ref_opts.not_cmp = 1;
+ break;
+
+ case H5O_TYPE_NAMED_DATATYPE:
+ H5TOOLS_DEBUG("ref_type is H5R_OBJECT2 : NAMED");
+ if (ref_opts.mode_verbose)
+ parallel_print("Warning: Comparison not possible "
+ "of named datatypes object types "
+ "referenced: <%s> and <%s>\n",
+ opts->obj_name[0],
+ opts->obj_name[1]);
+ ref_opts.not_cmp = 1;
+ break;
+
+ case H5O_TYPE_MAP:
+ case H5O_TYPE_UNKNOWN:
+ case H5O_TYPE_NTYPES:
+ default:
+ if (ref_opts.mode_verbose)
+ parallel_print(
+ "Warning: Comparison not possible of object "
+ "types referenced: <%s> and <%s>\n",
+ opts->obj_name[0], opts->obj_name[1]);
+ ref_opts.not_cmp = 1;
+ break;
+ } /* end switch */
+ if (H5Oclose(obj2_id) < 0) {
+ ref_opts.err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("H5Oclose H5R_OBJECT2 failed");
+ }
+ }
+ else {
+ ref_opts.err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("H5Ropen_object object 2 failed");
+ }
+ if (H5Oclose(obj1_id) < 0) {
+ ref_opts.err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("H5Oclose H5R_OBJECT2 failed");
+ }
+ }
+ else {
+ ref_opts.err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("H5Ropen_object object 1 failed");
+ }
+ }
+ else {
+ parallel_print("Different object types referenced: <%s> and <%s>",
+ opts->obj_name[0], opts->obj_name[1]);
+ ref_opts.not_cmp = 1;
+ ref_opts.err_stat = H5DIFF_ERR;
+ }
+ }
+ else {
+ ref_opts.err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("H5Rget_obj_type3 object 2 failed");
+ }
+ }
+ else {
+ ref_opts.err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("H5Rget_obj_type3 object 1 failed");
+ }
+ break;
+ case H5R_DATASET_REGION2:
+ H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION2");
+
+ /* if (obj_id < 0) - could mean that no reference was written do not throw failure
+ */
+ if ((obj1_id = H5Ropen_object(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
+ H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION2 object 1 failed");
+ }
+ else {
+ if ((obj2_id = H5Ropen_object(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ H5TOOLS_DEBUG("open_region - H5R_DATASET_REGION2");
+ if ((region1_id = H5Ropen_region(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) >=
+ 0) {
+ if (h5tools_is_zero(ref1_buf, H5Tget_size(H5T_STD_REF))) {
+ H5TOOLS_DEBUG("NULL H5R_DATASET_REGION2");
+ }
+ else {
+ if ((region2_id = H5Ropen_region(ref2_buf, H5P_DEFAULT,
+ H5P_DEFAULT)) >= 0) {
+ if (h5tools_is_zero(ref2_buf, H5Tget_size(H5T_STD_REF))) {
+ H5TOOLS_DEBUG("NULL H5R_DATASET_REGION2");
+ }
+ else {
+ nfound = diff_region(obj1_id, obj2_id, region1_id,
+ region2_id, &ref_opts);
+ }
+ if (H5Sclose(region2_id) < 0)
+ H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION2 failed");
+ }
+ else
+ H5TOOLS_INFO("H5Ropen_region H5R_DATASET_REGION2 failed");
+ } /* end else to if (h5tools_is_zero(... */
+ if (H5Sclose(region1_id) < 0)
+ H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION2 failed");
+ }
+ else
+ H5TOOLS_ERROR(H5DIFF_ERR,
+ "H5Ropen_region H5R_DATASET_REGION2 failed");
+ if (H5Dclose(obj2_id) < 0) {
+ ref_opts.err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION2 failed");
+ }
+ }
+ else {
+ H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION2 object 2 failed");
+ }
+ if (H5Dclose(obj1_id) < 0) {
+ ref_opts.err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION2 failed");
+ }
+ }
+ break;
+ case H5R_ATTR: {
+ char name1[ATTR_NAME_MAX];
+ char name2[ATTR_NAME_MAX];
+
+ H5TOOLS_DEBUG("ref_type is H5R_ATTR");
+ if ((obj1_id = H5Ropen_attr(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ if ((obj2_id = H5Ropen_attr(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ /* get name */
+ if (H5Aget_name(obj1_id, (size_t)ATTR_NAME_MAX, name1) >= 0) {
+ /* get name */
+ if (H5Aget_name(obj2_id, (size_t)ATTR_NAME_MAX, name2) >= 0) {
+ H5TOOLS_DEBUG("H5R_ATTR diff_attr_data - name1=%s, name2=%s",
+ name1, name2);
+ nfound = diff_attr_data(obj1_id, obj2_id, name1, name2,
+ opts->obj_name[0], opts->obj_name[1],
+ &ref_opts);
+ }
+ else {
+ ref_opts.err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("H5Aget_name second attribute failed");
+ }
+ }
+ else {
+ ref_opts.err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("H5Aget_name first attribute failed");
+ }
+
+ if (H5Aclose(obj2_id) < 0) {
+ ref_opts.err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("H5Aclose H5R_ATTR failed");
+ }
+ }
+ else {
+ parallel_print("Warning: Cannot open referenced attribute2\n");
+ H5TOOLS_INFO("H5Ropen_attr object 2 failed");
+ }
+ if (H5Aclose(obj1_id) < 0) {
+ H5TOOLS_INFO("H5Aclose H5R_ATTR failed");
+ }
+ }
+ else {
+ parallel_print("Warning: Cannot open referenced attribute1\n");
+ H5TOOLS_INFO("H5Ropen_attr object 1 failed");
+ }
+ } break;
+ case H5R_BADTYPE:
+ case H5R_MAXTYPE:
+ default:
+ break;
+ } /* end switch */
+ if (H5Rdestroy(ref2_buf) < 0)
+ H5TOOLS_INFO("H5Rdestroy H5R_OBJECT1 failed");
+ if (H5Rdestroy(ref1_buf) < 0)
+ H5TOOLS_INFO("H5Rdestroy H5R_OBJECT1 failed");
+ H5TOOLS_DEBUG("H5T_REFERENCE - H5T_STD_REF complete nfound:%" PRIuHSIZE " - errstat:%d",
+ nfound, ref_opts.err_stat);
+ }
+ /*-------------------------------------------------------------------------
+ * H5T_STD_REF_DSETREG
+ * Dataset region reference
+ *-------------------------------------------------------------------------
+ */
+ else if (H5Tequal(ref_opts.m_tid, H5T_STD_REF_DSETREG)) {
+ /* if (type_size == H5R_DSET_REG_REF_BUF_SIZE) */
+ H5TOOLS_DEBUG("H5T_STD_REF_DSETREG");
+ } /*dataset reference*/
+
+ /*-------------------------------------------------------------------------
+ * H5T_STD_REF_OBJ
+ * Object references. get the type and OID of the referenced object
+ *-------------------------------------------------------------------------
+ */
+ else if (H5Tequal(ref_opts.m_tid, H5T_STD_REF_OBJ)) {
+ /* if (type_size == H5R_OBJ_REF_BUF_SIZE) */
+ H5TOOLS_DEBUG("H5T_STD_REF_OBJ");
+ } /*object reference*/
+ opts->print_header = ref_opts.print_header;
+ opts->not_cmp = ref_opts.not_cmp;
+ opts->err_stat = ref_opts.err_stat | ret_value;
+ } /*is zero*/
+ H5TOOLS_DEBUG("H5T_REFERENCE complete");
+ break;
-#if H5_SIZEOF_LONG_DOUBLE !=0
+ /*-------------------------------------------------------------------------
+ * H5T_VLEN
+ *-------------------------------------------------------------------------
+ */
+ case H5T_VLEN: {
+ diff_opt_t vl_opts;
+
+ H5TOOLS_DEBUG("H5T_VLEN");
+
+ vl_opts = *opts;
+ /* get the VL sequences's base datatype for each element */
+ vl_opts.m_tid = H5Tget_super(opts->m_tid);
+ size = H5Tget_size(vl_opts.m_tid);
+
+ /* get the number of sequence elements */
+ vl_opts.hs_nelmts = ((hvl_t *)((void *)mem1))->len;
+
+ for (j = 0; j < vl_opts.hs_nelmts; j++)
+ nfound += diff_datum(((char *)(((hvl_t *)((void *)mem1))->p)) + j * size,
+ ((char *)(((hvl_t *)((void *)mem2))->p)) + j * size,
+ elemtno, /* Extra (void *) cast to quiet "cast to create alignment"
+ warning - 2019/07/05, QAK */
+ &vl_opts, container1_id, container2_id, members);
+ opts->print_header = vl_opts.print_header;
+ opts->not_cmp = vl_opts.not_cmp;
+ opts->err_stat = opts->err_stat | vl_opts.err_stat;
+
+ H5Tclose(vl_opts.m_tid);
+ } break;
+ /*-------------------------------------------------------------------------
+ * H5T_INTEGER
+ *-------------------------------------------------------------------------
+ */
+ case H5T_INTEGER:
+ H5TOOLS_DEBUG("H5T_INTEGER");
+ type_sign = H5Tget_sign(opts->m_tid);
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_SCHAR
+ *-------------------------------------------------------------------------
+ */
+ if (type_size == 1 && type_sign != H5T_SGN_NONE) {
+ if (type_size != sizeof(char))
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not char size");
+ nfound += diff_schar_element(mem1, mem2, elemtno, opts);
+ } /*H5T_NATIVE_SCHAR*/
- /*-------------------------------------------------------------------------
- * H5T_NATIVE_LDOUBLE
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_UCHAR
+ *-------------------------------------------------------------------------
+ */
+ else if (type_size == 1 && type_sign == H5T_SGN_NONE) {
+ if (type_size != sizeof(unsigned char))
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not unsigned char size");
+ nfound += diff_uchar_element(mem1, mem2, elemtno, opts);
+ } /*H5T_NATIVE_UCHAR*/
- else if (type_size==8)
- {
- long double temp1_double;
- long double temp2_double;
- int isnan1=0;
- int isnan2=0;
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_SHORT
+ *-------------------------------------------------------------------------
+ */
+ else if (type_size == 2 && type_sign != H5T_SGN_NONE) {
+ if (type_size != sizeof(short))
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not short size");
+ nfound += diff_short_element(mem1, mem2, elemtno, opts);
+ } /*H5T_NATIVE_SHORT*/
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_USHORT
+ *-------------------------------------------------------------------------
+ */
+ else if (type_size == 2 && type_sign == H5T_SGN_NONE) {
+ if (type_size != sizeof(unsigned short))
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not unsigned short size");
+ nfound += diff_ushort_element(mem1, mem2, elemtno, opts);
+ } /*H5T_NATIVE_USHORT*/
- HDassert(type_size==sizeof(long double));
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_INT
+ *-------------------------------------------------------------------------
+ */
+ else if (type_size == 4 && type_sign != H5T_SGN_NONE) {
+ if (type_size != sizeof(int))
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not int size");
+ nfound += diff_int_element(mem1, mem2, elemtno, opts);
+ } /*H5T_NATIVE_INT*/
- HDmemcpy(&temp1_double, mem1, sizeof(long double));
- HDmemcpy(&temp2_double, mem2, sizeof(long double));
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_UINT
+ *-------------------------------------------------------------------------
+ */
+ else if (type_size == 4 && type_sign == H5T_SGN_NONE) {
+ if (type_size != sizeof(unsigned int))
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not unsigned int size");
+ nfound += diff_uint_element(mem1, mem2, elemtno, opts);
+ } /*H5T_NATIVE_UINT*/
- /* logic for detecting NaNs is different with options -d, -p and no options */
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_LONG
+ *-------------------------------------------------------------------------
+ */
+ else if (type_size == 8 && type_sign != H5T_SGN_NONE) {
+ if (type_size != sizeof(long))
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not long size");
+ nfound += diff_long_element(mem1, mem2, elemtno, opts);
+ } /*H5T_NATIVE_LONG*/
- /*-------------------------------------------------------------------------
- * -d and !-p
- *-------------------------------------------------------------------------
- */
- if (options->d && !options->p)
- {
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_ULONG
+ *-------------------------------------------------------------------------
+ */
+ else if (type_size == 8 && type_sign == H5T_SGN_NONE) {
+ if (type_size != sizeof(unsigned long))
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not unsigned long size");
+ nfound += diff_ulong_element(mem1, mem2, elemtno, opts);
+ } /*H5T_NATIVE_ULONG*/
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if ( options->do_nans )
- {
- isnan1 = my_isnan(FLT_LDOUBLE,&temp1_double);
- isnan2 = my_isnan(FLT_LDOUBLE,&temp2_double);
- }
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_LLONG
+ *-------------------------------------------------------------------------
+ */
+ else if (type_size == 16 && type_sign != H5T_SGN_NONE) {
+ if (type_size != sizeof(long long))
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not long long size");
+ nfound += diff_llong_element(mem1, mem2, elemtno, opts);
+ } /*H5T_NATIVE_LLONG*/
- /* both not NaN, do the comparison */
- if ( isnan1==0 && isnan2==0)
- {
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_ULLONG
+ *-------------------------------------------------------------------------
+ */
+ else if (type_size == 16 && type_sign == H5T_SGN_NONE) {
+ if (type_size != sizeof(unsigned long long))
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not unsigned long long size");
+ nfound += diff_ullong_element(mem1, mem2, elemtno, opts);
+ } /*H5T_NATIVE_ULLONG*/
+ break; /* H5T_INTEGER class */
- if (ABS(temp1_double-temp2_double) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LD_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double));
- }
- nfound++;
- }
- } /* NaN */
- /* only one is NaN, assume difference */
- else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double));
- }
- nfound++;
- }
+ /*-------------------------------------------------------------------------
+ * H5T_FLOAT
+ *-------------------------------------------------------------------------
+ */
+ case H5T_FLOAT:
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_FLOAT
+ *-------------------------------------------------------------------------
+ */
+ H5TOOLS_DEBUG("H5T_FLOAT");
+ if (type_size == 4) {
+ if (type_size != sizeof(float))
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not float size");
+ nfound += diff_float_element(mem1, mem2, elemtno, opts);
}
-
- /*-------------------------------------------------------------------------
- * !-d and -p
- *-------------------------------------------------------------------------
- */
- else if (!options->d && options->p)
- {
-
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if ( options->do_nans )
- {
- isnan1 = my_isnan(FLT_LDOUBLE,&temp1_double);
- isnan2 = my_isnan(FLT_LDOUBLE,&temp2_double);
- }
-
- /* both not NaN, do the comparison */
- if ( isnan1==0 && isnan2==0)
- {
-
- PER(temp1_double,temp2_double);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LD_FORMAT_P_NOTCOMP,temp1_double,temp2_double,
- ABS(temp1_double-temp2_double));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LD_FORMAT_P,temp1_double,temp2_double,
- ABS(temp1_double-temp2_double),
- ABS(1-temp2_double/temp1_double));
- }
- nfound++;
- }
-
- } /* NaN */
- /* only one is NaN, assume difference */
- else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double));
- }
- nfound++;
- }
- }
-
- /*-------------------------------------------------------------------------
- * -d and -p
- *-------------------------------------------------------------------------
- */
- else if ( options->d && options->p)
- {
-
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if ( options->do_nans )
- {
- isnan1 = my_isnan(FLT_LDOUBLE,&temp1_double);
- isnan2 = my_isnan(FLT_LDOUBLE,&temp2_double);
- }
-
- /* both not NaN, do the comparison */
- if ( isnan1==0 && isnan2==0)
- {
-
- PER(temp1_double,temp2_double);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LD_FORMAT_P_NOTCOMP,temp1_double,temp2_double,
- ABS(temp1_double-temp2_double));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent &&
- ABS(temp1_double-temp2_double) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LD_FORMAT_P,temp1_double,temp2_double,
- ABS(temp1_double-temp2_double),
- ABS(1-temp2_double/temp1_double));
- }
- nfound++;
- }
-
- } /* NaN */
- /* only one is NaN, assume difference */
- else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double));
- }
- nfound++;
- }
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_DOUBLE
+ *-------------------------------------------------------------------------
+ */
+ else if (type_size == 8) {
+ if (type_size != sizeof(double))
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not double size");
+ nfound += diff_double_element(mem1, mem2, elemtno, opts);
}
+#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE
- /*-------------------------------------------------------------------------
- * no -d and -p
- *-------------------------------------------------------------------------
- */
- else if (equal_ldouble(temp1_double,temp2_double,options)==FALSE)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LD_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double));
+ /*-------------------------------------------------------------------------
+ * H5T_NATIVE_LDOUBLE
+ *-------------------------------------------------------------------------
+ */
+ else if (type_size == H5_SIZEOF_LONG_DOUBLE) {
+ if (type_size != sizeof(long double)) {
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not long double size");
}
- nfound++;
- }
- } /*H5T_NATIVE_DOUBLE*/
-
-
-#endif /* H5_SIZEOF_LONG_DOUBLE */
-
+ nfound += diff_ldouble_element(mem1, mem2, elemtno, opts);
+ } /*H5T_NATIVE_LDOUBLE*/
+#endif /* H5_SIZEOF_LONG_DOUBLE */
+ break; /* H5T_FLOAT class */
- break; /* H5T_FLOAT class */
+ } /* switch */
- } /* switch */
+done:
+ opts->err_stat = opts->err_stat | ret_value;
- return nfound;
+ H5TOOLS_ENDDEBUG(":%" PRIuHSIZE " - errstat:%d", nfound, opts->err_stat);
+ return nfound;
}
/*-------------------------------------------------------------------------
@@ -2547,16 +1271,16 @@ hsize_t diff_datum(void *_mem1,
* Purpose: Determines if memory is initialized to all zero bytes.
*
* Return: TRUE if all bytes are zero; FALSE otherwise
- *
*-------------------------------------------------------------------------
*/
-static hbool_t all_zero(const void *_mem, size_t size)
+static hbool_t
+all_zero(const void *_mem, size_t size)
{
const unsigned char *mem = (const unsigned char *)_mem;
- while(size-- > 0)
- if(mem[size])
+ while (size-- > 0)
+ if (mem[size])
return FALSE;
return TRUE;
@@ -2568,48 +1292,40 @@ static hbool_t all_zero(const void *_mem, size_t size)
* Purpose: print start coordinates and opposite corner of a region block
*
* Return: void
- *
*-------------------------------------------------------------------------
*/
-static
-void print_region_block(int i, hsize_t *ptdata, int ndims)
+static void
+print_region_block(int i, hsize_t *ptdata, int ndims)
{
int j;
parallel_print(" ");
for (j = 0; j < ndims; j++)
- parallel_print("%s%lu", j ? "," : " (",
- (unsigned long)ptdata[i * 2 * ndims + j]);
+ parallel_print("%s%lu", j ? "," : " (", (unsigned long)ptdata[i * 2 * ndims + j]);
for (j = 0; j < ndims; j++)
- parallel_print("%s%lu", j ? "," : ")-(",
- (unsigned long)ptdata[i * 2 * ndims + j + ndims]);
+ parallel_print("%s%lu", j ? "," : ")-(", (unsigned long)ptdata[i * 2 * ndims + j + ndims]);
parallel_print(")");
-
}
-
/*-------------------------------------------------------------------------
* Function: print_points
*
* Purpose: print points of a region reference
*
* Return: void
- *
*-------------------------------------------------------------------------
*/
-static
-void print_points(int i, hsize_t *ptdata, int ndims)
+static void
+print_points(int i, hsize_t *ptdata, int ndims)
{
int j;
parallel_print(" ");
for (j = 0; j < ndims; j++)
- parallel_print("%s%lu", j ? "," : "(",
- (unsigned long)(ptdata[i * ndims + j]));
+ parallel_print("%s%lu", j ? "," : "(", (unsigned long)(ptdata[i * ndims + j]));
parallel_print(")");
-
}
/*-------------------------------------------------------------------------
@@ -2618,217 +1334,238 @@ void print_points(int i, hsize_t *ptdata, int ndims)
* Purpose: diff a dataspace region
*
* Return: number of differences
- *
*-------------------------------------------------------------------------
*/
-static
-hsize_t diff_region(hid_t obj1_id,
- hid_t obj2_id,
- hid_t region1_id,
- hid_t region2_id,
- diff_opt_t *options)
+static hsize_t
+diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t region2_id, diff_opt_t *opts)
{
- hssize_t nblocks1, npoints1;
- hssize_t nblocks2, npoints2;
- hsize_t alloc_size;
- hsize_t *ptdata1;
- hsize_t *ptdata2;
- int ndims1;
- int ndims2;
- int i, j;
- hsize_t nfound_b = 0; /* block differences found */
- hsize_t nfound_p = 0; /* point differences found */
+ hssize_t nblocks1, npoints1;
+ hssize_t nblocks2, npoints2;
+ hsize_t alloc_size;
+ hsize_t *ptdata1 = NULL;
+ hsize_t *ptdata2 = NULL;
+ int ndims1;
+ int ndims2;
+ int i, j;
+ hsize_t nfound_b = 0; /* block differences found */
+ hsize_t nfound_p = 0; /* point differences found */
+ hsize_t ret_value = 0;
+
+ H5TOOLS_START_DEBUG(" ");
ndims1 = H5Sget_simple_extent_ndims(region1_id);
ndims2 = H5Sget_simple_extent_ndims(region2_id);
/*
- * These two functions fail if the region does not have blocks or points,
- * respectively. They do not currently know how to translate from one to
- * the other.
- */
- H5E_BEGIN_TRY {
+ * These two functions fail if the region does not have blocks or points,
+ * respectively. They do not currently know how to translate from one to
+ * the other.
+ */
+ H5E_BEGIN_TRY
+ {
nblocks1 = H5Sget_select_hyper_nblocks(region1_id);
nblocks2 = H5Sget_select_hyper_nblocks(region2_id);
npoints1 = H5Sget_select_elem_npoints(region1_id);
npoints2 = H5Sget_select_elem_npoints(region2_id);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
+ H5TOOLS_DEBUG("blocks: 1=%" PRIdHSIZE "-2=%" PRIdHSIZE, nblocks1, nblocks2);
+ H5TOOLS_DEBUG("points: 1=%" PRIdHSIZE "-2=%" PRIdHSIZE, npoints1, npoints2);
- if(nblocks1 != nblocks2 || npoints1 != npoints2 || ndims1 != ndims2) {
- options->not_cmp = 1;
- return 0;
+ if (nblocks1 != nblocks2 || npoints1 != npoints2 || ndims1 != ndims2) {
+ opts->not_cmp = 1;
+ H5TOOLS_GOTO_DONE(0);
}
/*-------------------------------------------------------------------------
- * compare block information
- *-------------------------------------------------------------------------
- */
- if(nblocks1 > 0) {
- alloc_size = nblocks1 * ndims1 * 2 * sizeof(ptdata1[0]);
+ * compare block information
+ *-------------------------------------------------------------------------
+ */
+ if (nblocks1 > 0) {
+ H5TOOLS_DEBUG("region compare blocks");
+ HDassert(ndims1 > 0);
+ alloc_size = (hsize_t)nblocks1 * (unsigned)ndims1 * 2 * sizeof(ptdata1[0]);
HDassert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/
- ptdata1 = HDmalloc((size_t)alloc_size);
- H5_CHECK_OVERFLOW(nblocks1, hssize_t, hsize_t);
- H5Sget_select_hyper_blocklist(region1_id, (hsize_t)0, (hsize_t)nblocks1, ptdata1);
-
- ptdata2 = HDmalloc((size_t)alloc_size);
- H5_CHECK_OVERFLOW(nblocks2, hssize_t, hsize_t);
- H5Sget_select_hyper_blocklist(region2_id, (hsize_t)0, (hsize_t)nblocks2, ptdata2);
-
- for (i = 0; i < nblocks1; i++) {
- /* start coordinates and opposite corner */
- for (j = 0; j < ndims1; j++) {
- hsize_t start1, start2, end1, end2;
-
- start1 = ptdata1[i * 2 * ndims1 + j];
- start2 = ptdata2[i * 2 * ndims1 + j];
- end1 = ptdata1[i * 2 * ndims1 + j + ndims1];
- end2 = ptdata2[i * 2 * ndims1 + j + ndims1];
- if (start1 != start2 || end1 != end2)
- nfound_b++;
- }
+ if ((ptdata1 = (hsize_t *)HDmalloc((size_t)alloc_size)) == NULL) {
+ opts->err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("Buffer allocation failed");
}
+ else {
+ H5_CHECK_OVERFLOW(nblocks1, hssize_t, hsize_t);
+ H5Sget_select_hyper_blocklist(region1_id, (hsize_t)0, (hsize_t)nblocks1, ptdata1);
+ if ((ptdata2 = (hsize_t *)HDmalloc((size_t)alloc_size)) == NULL) {
+ opts->err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("Buffer allocation failed");
+ }
+ else {
+ H5_CHECK_OVERFLOW(nblocks2, hssize_t, hsize_t);
+ H5Sget_select_hyper_blocklist(region2_id, (hsize_t)0, (hsize_t)nblocks2, ptdata2);
- /* print differences if found */
- if (nfound_b && options->m_verbose) {
- H5O_info_t oi1, oi2;
+ for (i = 0; i < nblocks1; i++) {
+ /* start coordinates and opposite corner */
+ for (j = 0; j < ndims1; j++) {
+ hsize_t start1, start2, end1, end2;
- H5Oget_info(obj1_id, &oi1);
- H5Oget_info(obj2_id, &oi2);
+ start1 = ptdata1[i * 2 * ndims1 + j];
+ start2 = ptdata2[i * 2 * ndims1 + j];
+ end1 = ptdata1[i * 2 * ndims1 + j + ndims1];
+ end2 = ptdata2[i * 2 * ndims1 + j + ndims1];
+ if (start1 != start2 || end1 != end2)
+ nfound_b++;
+ }
+ }
- parallel_print("Referenced dataset %lu %lu\n",
- (unsigned long)oi1.addr, (unsigned long)oi2.addr);
- parallel_print("------------------------------------------------------------\n");
+ /* print differences if found */
+ if (nfound_b && opts->mode_verbose) {
+ H5O_info2_t oi1, oi2;
+ char *obj1_str = NULL, *obj2_str = NULL;
- parallel_print("Region blocks\n");
- for (i = 0; i < nblocks1; i++) {
- parallel_print("block #%d", i);
- print_region_block(i, ptdata1, ndims1);
- print_region_block(i, ptdata2, ndims1);
- parallel_print("\n");
- }
- }
+ H5Oget_info3(obj1_id, &oi1, H5O_INFO_BASIC);
+ H5Oget_info3(obj2_id, &oi2, H5O_INFO_BASIC);
- HDfree(ptdata1);
- HDfree(ptdata2);
+ /* Convert object tokens into printable output */
+ H5Otoken_to_str(obj1_id, &oi1.token, &obj1_str);
+ H5Otoken_to_str(obj2_id, &oi2.token, &obj2_str);
+
+ parallel_print("Referenced dataset %s %s\n", obj1_str, obj2_str);
+ parallel_print("------------------------------------------------------------\n");
+
+ H5free_memory(obj1_str);
+ H5free_memory(obj2_str);
+
+ parallel_print("Region blocks\n");
+ for (i = 0; i < nblocks1; i++) {
+ parallel_print("block #%d", i);
+ print_region_block(i, ptdata1, ndims1);
+ print_region_block(i, ptdata2, ndims1);
+ parallel_print("\n");
+ }
+ }
+ HDfree(ptdata2);
+ } /* else ptdata2 */
+
+ HDfree(ptdata1);
+ } /* else ptdata1 */
}
/*-------------------------------------------------------------------------
- * compare point information
- *-------------------------------------------------------------------------
- */
- if(npoints1 > 0) {
- alloc_size = npoints1 * ndims1 * sizeof(ptdata1[0]);
+ * compare point information
+ *-------------------------------------------------------------------------
+ */
+ if (npoints1 > 0) {
+ H5TOOLS_DEBUG("region compare points");
+ alloc_size = (hsize_t)npoints1 * (unsigned)ndims1 * sizeof(ptdata1[0]);
HDassert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/
- ptdata1 = HDmalloc((size_t)alloc_size);
- H5_CHECK_OVERFLOW(npoints1,hssize_t,hsize_t);
- H5Sget_select_elem_pointlist(region1_id, (hsize_t)0, (hsize_t)npoints1, ptdata1);
-
- ptdata2 = HDmalloc((size_t)alloc_size);
- H5_CHECK_OVERFLOW(npoints1,hssize_t,hsize_t);
- H5Sget_select_elem_pointlist(region2_id, (hsize_t)0, (hsize_t)npoints2, ptdata2);
-
- for(i = 0; i < npoints1; i++) {
- hsize_t pt1, pt2;
+ if ((ptdata1 = (hsize_t *)HDmalloc((size_t)alloc_size)) == NULL) {
+ opts->err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("Buffer allocation failed");
+ }
+ else {
+ H5_CHECK_OVERFLOW(npoints1, hssize_t, hsize_t);
+ H5Sget_select_elem_pointlist(region1_id, (hsize_t)0, (hsize_t)npoints1, ptdata1);
- for(j = 0; j < ndims1; j++) {
- pt1 = ptdata1[i * ndims1 + j];
- pt2 = ptdata2[i * ndims1 + j];
- if(pt1 != pt2)
- nfound_p++;
+ if ((ptdata2 = (hsize_t *)HDmalloc((size_t)alloc_size)) == NULL) {
+ opts->err_stat = H5DIFF_ERR;
+ H5TOOLS_INFO("Buffer allocation failed");
}
- }
+ else {
+ H5_CHECK_OVERFLOW(npoints1, hssize_t, hsize_t);
+ H5Sget_select_elem_pointlist(region2_id, (hsize_t)0, (hsize_t)npoints2, ptdata2);
+
+ for (i = 0; i < npoints1; i++) {
+ hsize_t pt1, pt2;
- if(nfound_p && options->m_verbose) {
- parallel_print("Region points\n");
- for(i = 0; i < npoints1; i++) {
- hsize_t pt1, pt2;
- int diff_data = 0;
-
- for(j = 0; j < ndims1; j++) {
- pt1 = ptdata1[i * ndims1 + j];
- pt2 = ptdata2[i * ndims1 + j];
- if(pt1 != pt2) {
- diff_data = 1;
- break;
+ for (j = 0; j < ndims1; j++) {
+ pt1 = ptdata1[i * ndims1 + j];
+ pt2 = ptdata2[i * ndims1 + j];
+ if (pt1 != pt2)
+ nfound_p++;
}
}
- if(diff_data) {
- parallel_print("point #%d", i);
- print_points(i, ptdata1, ndims1);
- print_points(i, ptdata2, ndims1);
- parallel_print("\n");
- }
- }
- }
+ if (nfound_p && opts->mode_verbose) {
+ parallel_print("Region points\n");
+ for (i = 0; i < npoints1; i++) {
+ hsize_t pt1, pt2;
+ int diff_data = 0;
-#if defined (H5DIFF_DEBUG)
- for (i = 0; i < npoints1; i++) {
- int j;
+ for (j = 0; j < ndims1; j++) {
+ pt1 = ptdata1[i * ndims1 + j];
+ pt2 = ptdata2[i * ndims1 + j];
+ if (pt1 != pt2) {
+ diff_data = 1;
+ break;
+ }
+ }
+ if (diff_data) {
+ parallel_print("point #%d", i);
+ print_points(i, ptdata1, ndims1);
+ print_points(i, ptdata2, ndims1);
+ parallel_print("\n");
+ }
+ }
+ }
+ HDfree(ptdata2);
+ } /* else ptdata2 */
- parallel_print("%sPt%lu: " , i ? "," : "", (unsigned long)i);
+#if defined(H5DIFF_DEBUG)
+ for (i = 0; i < npoints1; i++) {
+ parallel_print("%sPt%d: ", i ? "," : "", i);
- for (j = 0; j < ndims1; j++)
- parallel_print("%s%lu", j ? "," : "(",
- (unsigned long)(ptdata1[i * ndims1 + j]));
+ for (j = 0; j < ndims1; j++)
+ parallel_print("%s%" PRIuHSIZE, j ? "," : "(", ptdata1[i * ndims1 + j]);
- parallel_print(")");
- }
+ parallel_print(")");
+ }
+ parallel_print("\n");
#endif
- HDfree(ptdata1);
- HDfree(ptdata2);
+ HDfree(ptdata1);
+ } /* else ptdata1 */
}
- nfound_b = nfound_b/ndims1;
- nfound_p = nfound_p/ndims1;
- return (nfound_p + nfound_b);
-}
+ nfound_b = nfound_b / (unsigned)ndims1;
+ nfound_p = nfound_p / (unsigned)ndims1;
+ ret_value = nfound_p + nfound_b;
+
+done:
+ H5TOOLS_ENDDEBUG(" with diffs:%" PRIuHSIZE, ret_value);
+ return ret_value;
+}
/*-------------------------------------------------------------------------
* Function: character_compare
*
- * Purpose: do a byte-by-byte comparison and print in char format
- *
- * Return: number of differences found
+ * Purpose: do a byte-by-byte comparison and print in char format
*
+ * Return: number of differences found
*-------------------------------------------------------------------------
*/
-static
-hsize_t character_compare(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t i,
- unsigned u,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph)
+static hsize_t
+character_compare(char *mem1, char *mem2, hsize_t elemtno, size_t u, diff_opt_t *opts)
{
- hsize_t nfound=0; /* differences found */
- unsigned char temp1_uchar;
- unsigned char temp2_uchar;
+ hsize_t nfound = 0; /* differences found */
+ char temp1_uchar;
+ char temp2_uchar;
HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
-
- if (temp1_uchar != temp2_uchar)
- {
- if ( print_data(options) )
- {
- print_char_pos(ph,0,i,u,acc,pos,rank,dims,obj1,obj2);
- parallel_print(" ");
+ H5TOOLS_START_DEBUG(" %d=%d", temp1_uchar, temp2_uchar);
+
+ if (temp1_uchar != temp2_uchar) {
+ if (print_data(opts)) {
+ opts->print_percentage = 0;
+ opts->print_dims = 1;
+ print_pos(opts, elemtno, u);
+ parallel_print(" ");
h5diff_print_char(temp1_uchar);
parallel_print(" ");
h5diff_print_char(temp2_uchar);
@@ -2836,2824 +1573,1599 @@ hsize_t character_compare(unsigned char *mem1,
}
nfound++;
}
-
+ H5TOOLS_ENDDEBUG(": %" PRIuHSIZE, nfound);
return nfound;
}
-
/*-------------------------------------------------------------------------
* Function: character_compare_opt
*
- * Purpose: do a byte-by-byte comparison and print in numerical format
- *
- * Return: number of differences found
+ * Purpose: do a byte-by-byte comparison and print in numerical format
*
+ * Return: number of differences found
*-------------------------------------------------------------------------
*/
-hsize_t character_compare_opt(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t i,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph)
+static hsize_t
+character_compare_opt(unsigned char *mem1, unsigned char *mem2, hsize_t elemtno, diff_opt_t *opts)
{
- hsize_t nfound=0; /* differences found */
- unsigned char temp1_uchar;
- unsigned char temp2_uchar;
- double per;
- int both_zero;
+ hsize_t nfound = 0; /* differences found */
+ unsigned char temp1_uchar;
+ unsigned char temp2_uchar;
+ hbool_t both_zero = FALSE;
+ double per;
+
+ /* both_zero is set in the PER_UNSIGN macro but not used in this function */
+ (void)both_zero;
HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
+ H5TOOLS_START_DEBUG(" %d=%d", temp1_uchar, temp2_uchar);
/* -d and !-p */
- if (options->d && !options->p)
- {
- if ( PDIFF(temp1_uchar,temp2_uchar) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar));
+ if (opts->delta_bool && !opts->percent_bool) {
+ if (PDIFF(temp1_uchar, temp2_uchar) > opts->delta) {
+ opts->print_percentage = 0;
+ print_pos(opts, elemtno, 0);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar));
}
nfound++;
}
}
/* !-d and -p */
- else if (!options->d && options->p)
- {
- PER_UNSIGN(signed char,temp1_uchar,temp2_uchar);
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar),per);
+ else if (!opts->delta_bool && opts->percent_bool) {
+ PER_UNSIGN(signed char, temp1_uchar, temp2_uchar);
+ if (per > opts->percent) {
+ opts->print_percentage = 1;
+ print_pos(opts, elemtno, 0);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar), per);
}
nfound++;
}
}
/* -d and -p */
- else if ( options->d && options->p)
- {
- PER_UNSIGN(signed char,temp1_uchar,temp2_uchar);
- if ( per > options->percent && PDIFF(temp1_uchar,temp2_uchar) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar),per);
+ else if (opts->delta_bool && opts->percent_bool) {
+ PER_UNSIGN(signed char, temp1_uchar, temp2_uchar);
+ if (per > opts->percent && PDIFF(temp1_uchar, temp2_uchar) > opts->delta) {
+ opts->print_percentage = 1;
+ print_pos(opts, elemtno, 0);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar), per);
}
nfound++;
}
}
- else if (temp1_uchar != temp2_uchar)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar));
+ else if (temp1_uchar != temp2_uchar) {
+ opts->print_percentage = 0;
+ print_pos(opts, elemtno, 0);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar));
}
nfound++;
}
+ H5TOOLS_ENDDEBUG(": %" PRIuHSIZE " zero:%d", nfound, both_zero);
return nfound;
-
}
-
/*-------------------------------------------------------------------------
- * Function: diff_float
+ * Function: diff_float_element
*
- * Purpose: diff a H5T_NATIVE_FLOAT type
+ * Purpose: diff a single H5T_NATIVE_FLOAT type
*
- * Return: number of differences found
+ * Return: number of differences found
*
*-------------------------------------------------------------------------
*/
-hsize_t diff_float(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph)
-
+static hsize_t
+diff_float_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts)
{
- hsize_t nfound=0; /* number of differences found */
- float temp1_float;
- float temp2_float;
- hsize_t i;
- double per;
- int both_zero;
- int isnan1=0;
- int isnan2=0;
+ hsize_t nfound = 0; /* number of differences found */
+ float temp1_float;
+ float temp2_float;
+ double per;
+ hbool_t both_zero = FALSE;
+ hbool_t isnan1 = FALSE;
+ hbool_t isnan2 = FALSE;
+ H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool);
- /*-------------------------------------------------------------------------
- * -d and !-p
- *-------------------------------------------------------------------------
- */
+ HDmemcpy(&temp1_float, mem1, sizeof(float));
+ HDmemcpy(&temp2_float, mem2, sizeof(float));
- if (options->d && !options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_float, mem1, sizeof(float));
- HDmemcpy(&temp2_float, mem2, sizeof(float));
-
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if ( options->do_nans )
- {
- isnan1 = my_isnan(FLT_FLOAT,&temp1_float);
- isnan2 = my_isnan(FLT_FLOAT,&temp2_float);
+ /* logic for detecting NaNs is different with opts -d, -p and no opts */
+
+ /*-------------------------------------------------------------------------
+ * -d and !-p
+ *-------------------------------------------------------------------------
+ */
+ if (opts->delta_bool && !opts->percent_bool) {
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ if (opts->do_nans) {
+ isnan1 = HDisnan(temp1_float);
+ isnan2 = HDisnan(temp2_float);
+ }
+
+ /* both not NaN, do the comparison */
+ if (!isnan1 && !isnan2) {
+ if ((double)ABS(temp1_float - temp2_float) > opts->delta) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(F_FORMAT, (double)temp1_float, (double)temp2_float,
+ (double)ABS(temp1_float - temp2_float));
+ }
+ nfound++;
+ }
+ }
+ /* only one is NaN, assume difference */
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(F_FORMAT, (double)temp1_float, (double)temp2_float,
+ (double)ABS(temp1_float - temp2_float));
}
+ nfound++;
+ }
+ }
+ /*-------------------------------------------------------------------------
+ * !-d and -p
+ *-------------------------------------------------------------------------
+ */
+ else if (!opts->delta_bool && opts->percent_bool) {
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ if (opts->do_nans) {
+ isnan1 = HDisnan(temp1_float);
+ isnan2 = HDisnan(temp2_float);
+ }
+ /* both not NaN, do the comparison */
+ if ((!isnan1 && !isnan2)) {
+ PER(temp1_float, temp2_float);
- /* both not NaN, do the comparison */
- if ( isnan1==0 && isnan2==0)
- {
- if (ABS(temp1_float-temp2_float) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float));
- }
- nfound++;
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(F_FORMAT_P_NOTCOMP, (double)temp1_float, (double)temp2_float,
+ (double)ABS(temp1_float - temp2_float));
}
+ nfound++;
}
- /* only one is NaN, assume difference */
- else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float));
+ else if (per > opts->percent) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(F_FORMAT_P, (double)temp1_float, (double)temp2_float,
+ (double)ABS(temp1_float - temp2_float),
+ (double)ABS(1 - temp2_float / temp1_float));
}
nfound++;
-
}
- mem1+=sizeof(float);
- mem2+=sizeof(float);
- if (options->n && nfound>=options->count)
- return nfound;
- } /* i */
- }
-
- /*-------------------------------------------------------------------------
- * !-d and -p
- *-------------------------------------------------------------------------
- */
- else if (!options->d && options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_float, mem1, sizeof(float));
- HDmemcpy(&temp2_float, mem2, sizeof(float));
-
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if ( options->do_nans )
- {
- isnan1 = my_isnan(FLT_FLOAT,&temp1_float);
- isnan2 = my_isnan(FLT_FLOAT,&temp2_float);
+ }
+ /* only one is NaN, assume difference */
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(F_FORMAT, (double)temp1_float, (double)temp2_float,
+ (double)ABS(temp1_float - temp2_float));
}
- /* both not NaN, do the comparison */
- if ( isnan1==0 && isnan2==0)
- {
+ nfound++;
+ }
+ }
+ /*-------------------------------------------------------------------------
+ * -d and -p
+ *-------------------------------------------------------------------------
+ */
+ else if (opts->delta_bool && opts->percent_bool) {
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ if (opts->do_nans) {
+ isnan1 = HDisnan(temp1_float);
+ isnan2 = HDisnan(temp2_float);
+ }
- PER(temp1_float,temp2_float);
+ /* both not NaN, do the comparison */
+ if (!isnan1 && !isnan2) {
+ PER(temp1_float, temp2_float);
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P_NOTCOMP,temp1_float,temp2_float,
- ABS(temp1_float-temp2_float));
- }
- nfound++;
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(F_FORMAT_P_NOTCOMP, (double)temp1_float, (double)temp2_float,
+ (double)ABS(temp1_float - temp2_float));
}
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P,temp1_float,temp2_float,
- ABS(temp1_float-temp2_float),
- ABS(1-temp2_float/temp1_float));
- }
- nfound++;
- }
+ nfound++;
}
- /* only one is NaN, assume difference */
- else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float));
+ else if (per > opts->percent && (double)ABS(temp1_float - temp2_float) > opts->delta) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(F_FORMAT_P, (double)temp1_float, (double)temp2_float,
+ (double)ABS(temp1_float - temp2_float),
+ (double)ABS(1 - temp2_float / temp1_float));
}
nfound++;
-
}
- mem1+=sizeof(float);
- mem2+=sizeof(float);
- if (options->n && nfound>=options->count)
- return nfound;
- } /* i */
+ }
+ /* only one is NaN, assume difference */
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(F_FORMAT, (double)temp1_float, (double)temp2_float,
+ (double)ABS(temp1_float - temp2_float));
+ }
+ nfound++;
+ }
+ }
+ /*-------------------------------------------------------------------------
+ * no -d and -p
+ *-------------------------------------------------------------------------
+ */
+ else {
+ if (equal_float(temp1_float, temp2_float, opts) == FALSE) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(F_FORMAT, (double)temp1_float, (double)temp2_float,
+ (double)ABS(temp1_float - temp2_float));
+ }
+ nfound++;
+ }
}
- /*-------------------------------------------------------------------------
- * -d and -p
- *-------------------------------------------------------------------------
- */
- else if ( options->d && options->p)
- {
+ H5TOOLS_ENDDEBUG(": %" PRIuHSIZE " zero:%d", nfound, both_zero);
+ return nfound;
+}
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_float, mem1, sizeof(float));
- HDmemcpy(&temp2_float, mem2, sizeof(float));
+/*-------------------------------------------------------------------------
+ * Function: diff_double_element
+ *
+ * Purpose: diff a single H5T_NATIVE_DOUBLE type
+ *
+ * Return: number of differences found
+ *-------------------------------------------------------------------------
+ */
+static hsize_t
+diff_double_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts)
+{
+ hsize_t nfound = 0; /* number of differences found */
+ double temp1_double;
+ double temp2_double;
+ double per;
+ hbool_t both_zero = FALSE;
+ hbool_t isnan1 = FALSE;
+ hbool_t isnan2 = FALSE;
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if ( options->do_nans )
- {
- isnan1 = my_isnan(FLT_FLOAT,&temp1_float);
- isnan2 = my_isnan(FLT_FLOAT,&temp2_float);
- }
+ H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool);
- /* both not NaN, do the comparison */
- if ( isnan1==0 && isnan2==0)
- {
+ HDmemcpy(&temp1_double, mem1, sizeof(double));
+ HDmemcpy(&temp2_double, mem2, sizeof(double));
- PER(temp1_float,temp2_float);
+ /*-------------------------------------------------------------------------
+ * -d and !-p
+ *-------------------------------------------------------------------------
+ */
+ if (opts->delta_bool && !opts->percent_bool) {
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ if (opts->do_nans) {
+ isnan1 = HDisnan(temp1_double);
+ isnan2 = HDisnan(temp2_double);
+ }
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P_NOTCOMP,temp1_float,temp2_float,
- ABS(temp1_float-temp2_float));
- }
- nfound++;
+ /* both not NaN, do the comparison */
+ if (!isnan1 && !isnan2) {
+ if (ABS(temp1_double - temp2_double) > opts->delta) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
+ nfound++;
+ }
+ }
+ /* only one is NaN, assume difference */
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
+ }
+ nfound++;
+ }
+ }
- else
-
- if ( per > options->percent && ABS(temp1_float-temp2_float) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P,temp1_float,temp2_float,
- ABS(temp1_float-temp2_float),
- ABS(1-temp2_float/temp1_float));
- }
- nfound++;
- }
+ /*-------------------------------------------------------------------------
+ * !-d and -p
+ *-------------------------------------------------------------------------
+ */
+ else if (!opts->delta_bool && opts->percent_bool) {
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ if (opts->do_nans) {
+ isnan1 = HDisnan(temp1_double);
+ isnan2 = HDisnan(temp2_double);
+ }
+ /* both not NaN, do the comparison */
+ if (!isnan1 && !isnan2) {
+ PER(temp1_double, temp2_double);
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(F_FORMAT_P_NOTCOMP, temp1_double, temp2_double,
+ ABS(temp1_double - temp2_double));
+ }
+ nfound++;
}
- /* only one is NaN, assume difference */
- else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float));
+ else if (per > opts->percent) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(F_FORMAT_P, temp1_double, temp2_double, ABS(temp1_double - temp2_double),
+ ABS(1 - temp2_double / temp1_double));
}
nfound++;
-
}
- mem1+=sizeof(float);
- mem2+=sizeof(float);
- if (options->n && nfound>=options->count)
- return nfound;
- } /* i */
+ }
+ /* only one is NaN, assume difference */
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
+ }
+ nfound++;
+ }
}
+ /*-------------------------------------------------------------------------
+ * -d and -p
+ *-------------------------------------------------------------------------
+ */
+ else if (opts->delta_bool && opts->percent_bool) {
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ if (opts->do_nans) {
+ isnan1 = HDisnan(temp1_double);
+ isnan2 = HDisnan(temp2_double);
+ }
- /*-------------------------------------------------------------------------
- * no -d and -p
- *-------------------------------------------------------------------------
- */
- else
- {
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_float, mem1, sizeof(float));
- HDmemcpy(&temp2_float, mem2, sizeof(float));
+ /* both not NaN, do the comparison */
+ if (!isnan1 && !isnan2) {
+ PER(temp1_double, temp2_double);
- if (equal_float(temp1_float,temp2_float,options)==FALSE)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float));
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(F_FORMAT_P_NOTCOMP, temp1_double, temp2_double,
+ ABS(temp1_double - temp2_double));
}
nfound++;
}
-
- mem1+=sizeof(float);
- mem2+=sizeof(float);
- if (options->n && nfound>=options->count)
- return nfound;
-
- } /* nelmts */
-
-
-
-
-
+ else if (per > opts->percent && ABS(temp1_double - temp2_double) > opts->delta) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(F_FORMAT_P, temp1_double, temp2_double, ABS(temp1_double - temp2_double),
+ ABS(1 - temp2_double / temp1_double));
+ }
+ nfound++;
+ }
+ }
+ /* only one is NaN, assume difference */
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
+ }
+ nfound++;
+ }
+ }
+ /*-------------------------------------------------------------------------
+ * no -d and -p
+ *-------------------------------------------------------------------------
+ */
+ else {
+ if (equal_double(temp1_double, temp2_double, opts) == FALSE) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
+ }
+ nfound++;
+ }
}
+ H5TOOLS_ENDDEBUG(":%" PRIuHSIZE " - errstat:%d", nfound, opts->err_stat);
return nfound;
}
-
/*-------------------------------------------------------------------------
- * Function: diff_double
- *
- * Purpose: diff a H5T_NATIVE_DOUBLE type
+ * Function: diff_ldouble_element
*
- * Return: number of differences found
+ * Purpose: diff a single H5T_NATIVE_LDOUBLE type
*
+ * Return: number of differences found
*-------------------------------------------------------------------------
*/
-hsize_t diff_double(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph)
+static hsize_t
+diff_ldouble_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts)
{
- hsize_t nfound=0; /* number of differences found */
- double temp1_double;
- double temp2_double;
- hsize_t i;
+ hsize_t nfound = 0; /* number of differences found */
+ long double temp1_double;
+ long double temp2_double;
double per;
- int both_zero;
- int isnan1=0;
- int isnan2=0;
+ hbool_t both_zero = FALSE;
+ hbool_t isnan1 = FALSE;
+ hbool_t isnan2 = FALSE;
- /*-------------------------------------------------------------------------
- * -d and !-p
- *-------------------------------------------------------------------------
- */
+ H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool);
- if (options->d && !options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_double, mem1, sizeof(double));
- HDmemcpy(&temp2_double, mem2, sizeof(double));
-
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if ( options->do_nans )
- {
- isnan1 = my_isnan(FLT_DOUBLE,&temp1_double);
- isnan2 = my_isnan(FLT_DOUBLE,&temp2_double);
- }
+ HDmemcpy(&temp1_double, mem1, sizeof(long double));
+ HDmemcpy(&temp2_double, mem2, sizeof(long double));
- /* both not NaN, do the comparison */
- if ( isnan1==0 && isnan2==0)
- {
- if (ABS(temp1_double-temp2_double) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double));
- }
- nfound++;
- }
- }
- /* only one is NaN, assume difference */
- else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double));
+ /* logic for detecting NaNs is different with options -d, -p and no options */
+
+ /*-------------------------------------------------------------------------
+ * -d and !-p
+ *-------------------------------------------------------------------------
+ */
+ if (opts->delta_bool && !opts->percent_bool) {
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ if (opts->do_nans) {
+ isnan1 = HDisnan(temp1_double);
+ isnan2 = HDisnan(temp2_double);
+ }
+
+ /* both not NaN, do the comparison */
+ if (!isnan1 && !isnan2) {
+ if ((double)ABS(temp1_double - temp2_double) > opts->delta) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(LD_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
nfound++;
-
}
- mem1+=sizeof(double);
- mem2+=sizeof(double);
- if (options->n && nfound>=options->count)
- return nfound;
- } /* i */
- }
-
- /*-------------------------------------------------------------------------
- * !-d and -p
- *-------------------------------------------------------------------------
- */
- else if (!options->d && options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_double, mem1, sizeof(double));
- HDmemcpy(&temp2_double, mem2, sizeof(double));
-
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if ( options->do_nans )
- {
- isnan1 = my_isnan(FLT_DOUBLE,&temp1_double);
- isnan2 = my_isnan(FLT_DOUBLE,&temp2_double);
+ } /* NaN */
+ /* only one is NaN, assume difference */
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(LD_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
- /* both not NaN, do the comparison */
- if ( isnan1==0 && isnan2==0)
- {
+ nfound++;
+ }
+ }
+ /*-------------------------------------------------------------------------
+ * !-d and -p
+ *-------------------------------------------------------------------------
+ */
+ else if (!opts->delta_bool && opts->percent_bool) {
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ if (opts->do_nans) {
+ isnan1 = HDisnan(temp1_double);
+ isnan2 = HDisnan(temp2_double);
+ }
- PER(temp1_double,temp2_double);
+ /* both not NaN, do the comparison */
+ if (!isnan1 && !isnan2) {
+ PER(temp1_double, temp2_double);
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P_NOTCOMP,temp1_double,temp2_double,
- ABS(temp1_double-temp2_double));
- }
- nfound++;
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(LD_FORMAT_P_NOTCOMP, temp1_double, temp2_double,
+ ABS(temp1_double - temp2_double));
}
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P,temp1_double,temp2_double,
- ABS(temp1_double-temp2_double),
- ABS(1-temp2_double/temp1_double));
- }
- nfound++;
- }
+ nfound++;
}
- /* only one is NaN, assume difference */
- else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double));
+ else if (per > opts->percent) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(LD_FORMAT_P, temp1_double, temp2_double, ABS(temp1_double - temp2_double),
+ ABS(1 - temp2_double / temp1_double));
}
nfound++;
-
}
- mem1+=sizeof(double);
- mem2+=sizeof(double);
- if (options->n && nfound>=options->count)
- return nfound;
- } /* i */
- }
-
- /*-------------------------------------------------------------------------
- * -d and -p
- *-------------------------------------------------------------------------
- */
- else if ( options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_double, mem1, sizeof(double));
- HDmemcpy(&temp2_double, mem2, sizeof(double));
-
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if ( options->do_nans )
- {
- isnan1 = my_isnan(FLT_DOUBLE,&temp1_double);
- isnan2 = my_isnan(FLT_DOUBLE,&temp2_double);
+ } /* NaN */
+ /* only one is NaN, assume difference */
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(LD_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
}
+ nfound++;
+ }
+ }
+ /*-------------------------------------------------------------------------
+ * -d and -p
+ *-------------------------------------------------------------------------
+ */
+ else if (opts->delta_bool && opts->percent_bool) {
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ if (opts->do_nans) {
+ isnan1 = HDisnan(temp1_double);
+ isnan2 = HDisnan(temp2_double);
+ }
- /* both not NaN, do the comparison */
- if ( isnan1==0 && isnan2==0)
- {
-
- PER(temp1_double,temp2_double);
+ /* both not NaN, do the comparison */
+ if (!isnan1 && !isnan2) {
+ PER(temp1_double, temp2_double);
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P_NOTCOMP,temp1_double,temp2_double,
- ABS(temp1_double-temp2_double));
- }
- nfound++;
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(LD_FORMAT_P_NOTCOMP, temp1_double, temp2_double,
+ ABS(temp1_double - temp2_double));
}
-
- else
-
- if ( per > options->percent && ABS(temp1_double-temp2_double) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P,temp1_double,temp2_double,
- ABS(temp1_double-temp2_double),
- ABS(1-temp2_double/temp1_double));
- }
- nfound++;
- }
-
+ nfound++;
}
- /* only one is NaN, assume difference */
- else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double));
+ else if (per > opts->percent && (double)ABS(temp1_double - temp2_double) > opts->delta) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(LD_FORMAT_P, temp1_double, temp2_double, ABS(temp1_double - temp2_double),
+ ABS(1 - temp2_double / temp1_double));
}
nfound++;
-
}
- mem1+=sizeof(double);
- mem2+=sizeof(double);
- if (options->n && nfound>=options->count)
- return nfound;
- } /* i */
+ } /* NaN */
+ /* only one is NaN, assume difference */
+ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(LD_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
+ }
+ nfound++;
+ }
+ }
+ /*-------------------------------------------------------------------------
+ * no -d and -p
+ *-------------------------------------------------------------------------
+ */
+ else if (equal_ldouble(temp1_double, temp2_double, opts) == FALSE) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(LD_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double));
+ }
+ nfound++;
}
- /*-------------------------------------------------------------------------
- * no -d and -p
- *-------------------------------------------------------------------------
- */
- else
- {
-
+ H5TOOLS_ENDDEBUG(":%" PRIuHSIZE " - errstat:%d", nfound, opts->err_stat);
+ return nfound;
+}
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_double, mem1, sizeof(double));
- HDmemcpy(&temp2_double, mem2, sizeof(double));
+/*-------------------------------------------------------------------------
+ * Function: diff_schar_element
+ *
+ * Purpose: diff a single H5T_NATIVE_SCHAR type
+ *
+ * Return: number of differences found
+ *-------------------------------------------------------------------------
+ */
+static hsize_t
+diff_schar_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts)
+{
+ hsize_t nfound = 0; /* number of differences found */
+ char temp1_char;
+ char temp2_char;
+ double per;
+ hbool_t both_zero = FALSE;
+ H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool);
+ HDmemcpy(&temp1_char, mem1, sizeof(char));
+ HDmemcpy(&temp2_char, mem2, sizeof(char));
- if (equal_double(temp1_double,temp2_double,options)==FALSE)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double));
- }
- nfound++;
+ /* -d and !-p */
+ if (opts->delta_bool && !opts->percent_bool) {
+ if (ABS(temp1_char - temp2_char) > opts->delta) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT, temp1_char, temp2_char, ABS(temp1_char - temp2_char));
}
+ nfound++;
+ }
+ }
+ /* !-d and -p */
+ else if (!opts->delta_bool && opts->percent_bool) {
+ PER(temp1_char, temp2_char);
- mem1+=sizeof(double);
- mem2+=sizeof(double);
- if (options->n && nfound>=options->count)
- return nfound;
-
- } /* nelmts */
-
-
-
-
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_char, temp2_char, ABS(temp1_char - temp2_char));
+ }
+ nfound++;
+ }
+ else if (per > opts->percent) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P, temp1_char, temp2_char, ABS(temp1_char - temp2_char), per);
+ }
+ nfound++;
+ }
+ }
+ /* -d and -p */
+ else if (opts->delta_bool && opts->percent_bool) {
+ PER(temp1_char, temp2_char);
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_char, temp2_char, ABS(temp1_char - temp2_char));
+ }
+ nfound++;
+ }
+ else if (per > opts->percent && ABS(temp1_char - temp2_char) > opts->delta) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P, temp1_char, temp2_char, ABS(temp1_char - temp2_char), per);
+ }
+ nfound++;
+ }
+ }
+ else if (temp1_char != temp2_char) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT, temp1_char, temp2_char, ABS(temp1_char - temp2_char));
+ }
+ nfound++;
}
+ H5TOOLS_ENDDEBUG(":%" PRIuHSIZE " - errstat:%d", nfound, opts->err_stat);
+
return nfound;
}
-
-
-
-
/*-------------------------------------------------------------------------
- * Function: diff_ldouble
- *
- * Purpose: diff a H5T_NATIVE_LDOUBLE type
+ * Function: diff_uchar_element
*
- * Return: number of differences found
+ * Purpose: diff a single H5T_NATIVE_UCHAR type
*
+ * Return: number of differences found
*-------------------------------------------------------------------------
*/
-#if H5_SIZEOF_LONG_DOUBLE !=0
-
-hsize_t diff_ldouble(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph)
-
+static hsize_t
+diff_uchar_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts)
{
- hsize_t nfound=0; /* number of differences found */
- long double temp1_double;
- long double temp2_double;
- hsize_t i;
- double per;
- int both_zero;
- int isnan1=0;
- int isnan2=0;
-
+ hsize_t nfound = 0; /* number of differences found */
+ unsigned char temp1_uchar;
+ unsigned char temp2_uchar;
+ double per;
+ hbool_t both_zero = FALSE;
- /*-------------------------------------------------------------------------
- * -d and !-p
- *-------------------------------------------------------------------------
- */
+ H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool);
- if (options->d && !options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_double, mem1, sizeof(long double));
- HDmemcpy(&temp2_double, mem2, sizeof(long double));
-
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if ( options->do_nans )
- {
- isnan1 = my_isnan(FLT_LDOUBLE,&temp1_double);
- isnan2 = my_isnan(FLT_LDOUBLE,&temp2_double);
+ HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
+ HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
+ /* -d and !-p */
+ if (opts->delta_bool && !opts->percent_bool) {
+ if (PDIFF(temp1_uchar, temp2_uchar) > opts->delta) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar));
}
+ nfound++;
+ }
+ }
+ /* !-d and -p */
+ else if (!opts->delta_bool && opts->percent_bool) {
+ PER_UNSIGN(signed char, temp1_uchar, temp2_uchar);
- /* both not NaN, do the comparison */
- if ( isnan1==0 && isnan2==0)
- {
- if (ABS(temp1_double-temp2_double) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double));
- }
- nfound++;
- }
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar));
}
- /* only one is NaN, assume difference */
- else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double));
- }
- nfound++;
-
+ nfound++;
+ }
+ else if (per > opts->percent) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar), per);
}
- mem1+=sizeof(long double);
- mem2+=sizeof(long double);
- if (options->n && nfound>=options->count)
- return nfound;
- } /* i */
+ nfound++;
+ }
}
+ /* -d and -p */
+ else if (opts->delta_bool && opts->percent_bool) {
+ PER_UNSIGN(signed char, temp1_uchar, temp2_uchar);
- /*-------------------------------------------------------------------------
- * !-d and -p
- *-------------------------------------------------------------------------
- */
- else if (!options->d && options->p)
- {
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_double, mem1, sizeof(long double));
- HDmemcpy(&temp2_double, mem2, sizeof(long double));
-
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if ( options->do_nans )
- {
- isnan1 = my_isnan(FLT_LDOUBLE,&temp1_double);
- isnan2 = my_isnan(FLT_LDOUBLE,&temp2_double);
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar));
}
- /* both not NaN, do the comparison */
- if ( isnan1==0 && isnan2==0)
- {
+ nfound++;
+ }
+ else if (per > opts->percent && PDIFF(temp1_uchar, temp2_uchar) > opts->delta) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar), per);
+ }
+ nfound++;
+ }
+ }
+ else if (temp1_uchar != temp2_uchar) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar));
+ }
+ nfound++;
+ }
- PER(temp1_double,temp2_double);
+ H5TOOLS_ENDDEBUG(":%" PRIuHSIZE " - errstat:%d", nfound, opts->err_stat);
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P_NOTCOMP,temp1_double,temp2_double,
- ABS(temp1_double-temp2_double));
- }
- nfound++;
- }
+ return nfound;
+}
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P,temp1_double,temp2_double,
- ABS(temp1_double-temp2_double),
- ABS(1-temp2_double/temp1_double));
- }
- nfound++;
- }
- }
- /* only one is NaN, assume difference */
- else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double));
- }
- nfound++;
+/*-------------------------------------------------------------------------
+ * Function: diff_short_element
+ *
+ * Purpose: diff a H5T_NATIVE_SHORT type
+ *
+ * Return: number of differences found
+ *-------------------------------------------------------------------------
+ */
+static hsize_t
+diff_short_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts)
+{
+ hsize_t nfound = 0; /* number of differences found */
+ short temp1_short;
+ short temp2_short;
+ double per;
+ hbool_t both_zero = FALSE;
+ H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool);
+
+ HDmemcpy(&temp1_short, mem1, sizeof(short));
+ HDmemcpy(&temp2_short, mem2, sizeof(short));
+ /* -d and !-p */
+ if (opts->delta_bool && !opts->percent_bool) {
+ if (ABS(temp1_short - temp2_short) > opts->delta) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT, temp1_short, temp2_short, ABS(temp1_short - temp2_short));
}
- mem1+=sizeof(long double);
- mem2+=sizeof(long double);
- if (options->n && nfound>=options->count)
- return nfound;
- } /* i */
+ nfound++;
+ }
}
+ /* !-d and -p */
+ else if (!opts->delta_bool && opts->percent_bool) {
+ PER(temp1_short, temp2_short);
- /*-------------------------------------------------------------------------
- * -d and -p
- *-------------------------------------------------------------------------
- */
- else if ( options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_double, mem1, sizeof(long double));
- HDmemcpy(&temp2_double, mem2, sizeof(long double));
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_short, temp2_short, ABS(temp1_short - temp2_short));
+ }
+ nfound++;
+ }
+ else if (per > opts->percent) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P, temp1_short, temp2_short, ABS(temp1_short - temp2_short), per);
+ }
+ nfound++;
+ }
+ }
+ /* -d and -p */
+ else if (opts->delta_bool && opts->percent_bool) {
+ PER(temp1_short, temp2_short);
- /*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- if ( options->do_nans )
- {
- isnan1 = my_isnan(FLT_LDOUBLE,&temp1_double);
- isnan2 = my_isnan(FLT_LDOUBLE,&temp2_double);
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_short, temp2_short, ABS(temp1_short - temp2_short));
+ }
+ nfound++;
+ }
+ else if (per > opts->percent && ABS(temp1_short - temp2_short) > opts->delta) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P, temp1_short, temp2_short, ABS(temp1_short - temp2_short), per);
}
+ nfound++;
+ }
+ }
+ else if (temp1_short != temp2_short) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT, temp1_short, temp2_short, ABS(temp1_short - temp2_short));
+ }
+ nfound++;
+ }
- /* both not NaN, do the comparison */
- if ( isnan1==0 && isnan2==0)
- {
+ H5TOOLS_ENDDEBUG(":%" PRIuHSIZE " - errstat:%d", nfound, opts->err_stat);
- PER(temp1_double,temp2_double);
+ return nfound;
+}
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P_NOTCOMP,temp1_double,temp2_double,
- ABS(temp1_double-temp2_double));
- }
- nfound++;
- }
+/*-------------------------------------------------------------------------
+ * Function: diff_ushort_element
+ *
+ * Purpose: diff a single H5T_NATIVE_USHORT type
+ *
+ * Return: number of differences found
+ *-------------------------------------------------------------------------
+ */
+static hsize_t
+diff_ushort_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts)
+{
+ hsize_t nfound = 0; /* number of differences found */
+ unsigned short temp1_ushort;
+ unsigned short temp2_ushort;
+ double per;
+ hbool_t both_zero = FALSE;
- else
-
- if ( per > options->percent && ABS(temp1_double-temp2_double) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P,temp1_double,temp2_double,
- ABS(temp1_double-temp2_double),
- ABS(1-temp2_double/temp1_double));
- }
- nfound++;
- }
+ H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool);
+ HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short));
+ HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short));
+ /* -d and !-p */
+ if (opts->delta_bool && !opts->percent_bool) {
+ if (PDIFF(temp1_ushort, temp2_ushort) > opts->delta) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort));
}
- /* only one is NaN, assume difference */
- else if (isnan1==1 && isnan2==0 || isnan1==0 && isnan2==1)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double));
- }
- nfound++;
+ nfound++;
+ }
+ }
+ /* !-d and -p */
+ else if (!opts->delta_bool && opts->percent_bool) {
+ PER_UNSIGN(signed short, temp1_ushort, temp2_ushort);
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_ushort, temp2_ushort,
+ PDIFF(temp1_ushort, temp2_ushort));
+ }
+ nfound++;
+ }
+ else if (per > opts->percent) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort),
+ per);
}
- mem1+=sizeof(long double);
- mem2+=sizeof(long double);
- if (options->n && nfound>=options->count)
- return nfound;
- } /* i */
+ nfound++;
+ }
}
+ /* -d and -p */
+ else if (opts->delta_bool && opts->percent_bool) {
+ PER_UNSIGN(signed short, temp1_ushort, temp2_ushort);
- /*-------------------------------------------------------------------------
- * no -d and -p
- *-------------------------------------------------------------------------
- */
- else
- {
-
-
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_double, mem1, sizeof(long double));
- HDmemcpy(&temp2_double, mem2, sizeof(long double));
-
-
- if (equal_ldouble(temp1_double,temp2_double,options)==FALSE)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double));
- }
- nfound++;
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_ushort, temp2_ushort,
+ PDIFF(temp1_ushort, temp2_ushort));
+ }
+ nfound++;
+ }
+ else if (per > opts->percent && PDIFF(temp1_ushort, temp2_ushort) > opts->delta) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort),
+ per);
}
+ nfound++;
+ }
+ }
+ else if (temp1_ushort != temp2_ushort) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort));
+ }
+ nfound++;
+ }
- mem1+=sizeof(long double);
- mem2+=sizeof(long double);
- if (options->n && nfound>=options->count)
- return nfound;
+ H5TOOLS_ENDDEBUG(":%" PRIuHSIZE " - errstat:%d", nfound, opts->err_stat);
- } /* nelmts */
+ return nfound;
+}
+/*-------------------------------------------------------------------------
+ * Function: diff_int_element
+ *
+ * Purpose: diff a single H5T_NATIVE_INT type
+ *
+ * Return: number of differences found
+ *-------------------------------------------------------------------------
+ */
+static hsize_t
+diff_int_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts)
+{
+ hsize_t nfound = 0; /* number of differences found */
+ int temp1_int;
+ int temp2_int;
+ double per;
+ hbool_t both_zero = FALSE;
+ H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool);
+ HDmemcpy(&temp1_int, mem1, sizeof(int));
+ HDmemcpy(&temp2_int, mem2, sizeof(int));
+ /* -d and !-p */
+ if (opts->delta_bool && !opts->percent_bool) {
+ if (ABS(temp1_int - temp2_int) > opts->delta) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT, temp1_int, temp2_int, ABS(temp1_int - temp2_int));
+ }
+ nfound++;
+ }
+ }
+ /* !-d and -p */
+ else if (!opts->delta_bool && opts->percent_bool) {
+ PER(temp1_int, temp2_int);
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_int, temp2_int, ABS(temp1_int - temp2_int));
+ }
+ nfound++;
+ }
+ else if (per > opts->percent) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P, temp1_int, temp2_int, ABS(temp1_int - temp2_int), per);
+ }
+ nfound++;
+ }
+ }
+ /* -d and -p */
+ else if (opts->delta_bool && opts->percent_bool) {
+ PER(temp1_int, temp2_int);
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P_NOTCOMP, temp1_int, temp2_int, ABS(temp1_int - temp2_int));
+ }
+ nfound++;
+ }
+ else if (per > opts->percent && ABS(temp1_int - temp2_int) > opts->delta) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT_P, temp1_int, temp2_int, ABS(temp1_int - temp2_int), per);
+ }
+ nfound++;
+ }
}
+ else if (temp1_int != temp2_int) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(I_FORMAT, temp1_int, temp2_int, ABS(temp1_int - temp2_int));
+ }
+ nfound++;
+ }
+
+ H5TOOLS_ENDDEBUG(":%" PRIuHSIZE " - errstat:%d", nfound, opts->err_stat);
return nfound;
}
-#endif /* H5_SIZEOF_LONG_DOUBLE */
-
-
-
-
-
/*-------------------------------------------------------------------------
- * Function: diff_schar
- *
- * Purpose: diff a H5T_NATIVE_SCHAR type
+ * Function: diff_uint_element
*
- * Return: number of differences found
+ * Purpose: diff a single H5T_NATIVE_UINT type
*
+ * Return: number of differences found
*-------------------------------------------------------------------------
*/
-hsize_t diff_schar(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph)
-
+static hsize_t
+diff_uint_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts)
{
- hsize_t nfound=0; /* number of differences found */
- char temp1_char;
- char temp2_char;
- hsize_t i;
- double per;
- int both_zero;
-
-
- /* -d and !-p */
- if (options->d && !options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_char, mem1, sizeof(char));
- HDmemcpy(&temp2_char, mem2, sizeof(char));
-
- if (ABS(temp1_char-temp2_char) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_char,temp2_char,ABS(temp1_char-temp2_char));
- }
- nfound++;
- }
- mem1+=sizeof(char);
- mem2+=sizeof(char);
- if (options->n && nfound>=options->count)
- return nfound;
- }
- }
-
- /* !-d and -p */
- else if (!options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_char, mem1, sizeof(char));
- HDmemcpy(&temp2_char, mem2, sizeof(char));
-
- PER(temp1_char,temp2_char);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_char,temp2_char,
- ABS(temp1_char-temp2_char));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_char,temp2_char,
- ABS(temp1_char-temp2_char),
- per);
- }
- nfound++;
- }
- mem1+=sizeof(char);
- mem2+=sizeof(char);
- if (options->n && nfound>=options->count)
- return nfound;
- }
- }
-
- /* -d and -p */
- else if ( options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_char, mem1, sizeof(char));
- HDmemcpy(&temp2_char, mem2, sizeof(char));
-
- PER(temp1_char,temp2_char);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_char,temp2_char,
- ABS(temp1_char-temp2_char));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent && ABS(temp1_char-temp2_char) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_char,temp2_char,
- ABS(temp1_char-temp2_char),
- per);
- }
- nfound++;
- }
- mem1+=sizeof(char);
- mem2+=sizeof(char);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
- }
- else
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_char, mem1, sizeof(char));
- HDmemcpy(&temp2_char, mem2, sizeof(char));
-
- if (temp1_char != temp2_char)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_char,temp2_char,ABS(temp1_char-temp2_char));
- }
- nfound++;
- }
-
- mem1+=sizeof(char);
- mem2+=sizeof(char);
- if (options->n && nfound>=options->count)
- return nfound;
- } /* nelmts */
-
- }
-
- return nfound;
-}
+ hsize_t nfound = 0; /* number of differences found */
+ unsigned int temp1_uint;
+ unsigned int temp2_uint;
+ double per;
+ hbool_t both_zero = FALSE;
+ H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool);
+ HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int));
+ HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int));
+ /* -d and !-p */
+ if (opts->delta_bool && !opts->percent_bool) {
+ if (PDIFF(temp1_uint, temp2_uint) > opts->delta) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(UI_FORMAT, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint));
+ }
+ nfound++;
+ }
+ }
+ /* !-d and -p */
+ else if (!opts->delta_bool && opts->percent_bool) {
+ PER_UNSIGN(signed int, temp1_uint, temp2_uint);
-/*-------------------------------------------------------------------------
- * Function: diff_uchar
- *
- * Purpose: diff a H5T_NATIVE_UCHAR type
- *
- * Return: number of differences found
- *
- *-------------------------------------------------------------------------
- */
-hsize_t diff_uchar(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph)
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(UI_FORMAT_P_NOTCOMP, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint));
+ }
+ nfound++;
+ }
+ else if (per > opts->percent) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(UI_FORMAT_P, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint), per);
+ }
+ nfound++;
+ }
+ }
+ /* -d and -p */
+ else if (opts->delta_bool && opts->percent_bool) {
+ PER_UNSIGN(signed int, temp1_uint, temp2_uint);
-{
- hsize_t nfound=0; /* number of differences found */
- unsigned char temp1_uchar;
- unsigned char temp2_uchar;
- hsize_t i;
- double per;
- int both_zero;
-
-
- /* -d and !-p */
- if (options->d && !options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
- HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
-
- if ( PDIFF(temp1_uchar,temp2_uchar) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar));
- }
- nfound++;
- }
- mem1+=sizeof(unsigned char);
- mem2+=sizeof(unsigned char);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
- }
-
- /* !-d and -p */
- else if (!options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
- HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
-
- PER_UNSIGN(signed char,temp1_uchar,temp2_uchar);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_uchar,temp2_uchar,
- PDIFF(temp1_uchar,temp2_uchar));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_uchar,temp2_uchar,
- PDIFF(temp1_uchar,temp2_uchar),
- per);
- }
- nfound++;
- }
- mem1+=sizeof(unsigned char);
- mem2+=sizeof(unsigned char);
- if (options->n && nfound>=options->count)
- return nfound;
- }
- }
-
- /* -d and -p */
- else if ( options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
- HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
-
- PER_UNSIGN(signed char,temp1_uchar,temp2_uchar);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_uchar,temp2_uchar,
- PDIFF(temp1_uchar,temp2_uchar));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent && PDIFF(temp1_uchar,temp2_uchar) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_uchar,temp2_uchar,
- PDIFF(temp1_uchar,temp2_uchar),
- per);
- }
- nfound++;
- }
- mem1+=sizeof(unsigned char);
- mem2+=sizeof(unsigned char);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
- }
- else
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
- HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
-
- if (temp1_uchar != temp2_uchar)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_uchar,temp2_uchar,PDIFF(temp1_uchar,temp2_uchar));
- }
- nfound++;
- }
-
- mem1+=sizeof(unsigned char);
- mem2+=sizeof(unsigned char);
- if (options->n && nfound>=options->count)
- return nfound;
- } /* nelmts */
-
- }
-
- return nfound;
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(UI_FORMAT_P_NOTCOMP, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint));
+ }
+ nfound++;
+ }
+ else if (per > opts->percent && PDIFF(temp1_uint, temp2_uint) > opts->delta) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(UI_FORMAT_P, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint), per);
+ }
+ nfound++;
+ }
+ }
+ else if (temp1_uint != temp2_uint) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(UI_FORMAT, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint));
+ }
+ nfound++;
+ }
+
+ H5TOOLS_ENDDEBUG(":%" PRIuHSIZE " - errstat:%d", nfound, opts->err_stat);
+
+ return nfound;
}
/*-------------------------------------------------------------------------
- * Function: diff_short
+ * Function: diff_long_element
*
- * Purpose: diff a H5T_NATIVE_SHORT type
- *
- * Return: number of differences found
+ * Purpose: diff a single H5T_NATIVE_LONG type
*
+ * Return: number of differences found
*-------------------------------------------------------------------------
*/
-hsize_t diff_short(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph)
-
+static hsize_t
+diff_long_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts)
{
- hsize_t nfound=0; /* number of differences found */
- short temp1_short;
- short temp2_short;
- hsize_t i;
- double per;
- int both_zero;
-
- /* -d and !-p */
- if (options->d && !options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_short, mem1, sizeof(short));
- HDmemcpy(&temp2_short, mem2, sizeof(short));
-
- if (ABS(temp1_short-temp2_short) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_short,temp2_short,ABS(temp1_short-temp2_short));
- }
- nfound++;
- }
- mem1+=sizeof(short);
- mem2+=sizeof(short);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
- }
-
- /* !-d and -p */
- else if (!options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_short, mem1, sizeof(short));
- HDmemcpy(&temp2_short, mem2, sizeof(short));
-
- PER(temp1_short,temp2_short);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_short,temp2_short,
- ABS(temp1_short-temp2_short));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_short,temp2_short,
- ABS(temp1_short-temp2_short),
- per);
- }
- nfound++;
- }
- mem1+=sizeof(short);
- mem2+=sizeof(short);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
-
- }
-
- /* -d and -p */
- else if ( options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_short, mem1, sizeof(short));
- HDmemcpy(&temp2_short, mem2, sizeof(short));
-
- PER(temp1_short,temp2_short);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_short,temp2_short,
- ABS(temp1_short-temp2_short));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent && ABS(temp1_short-temp2_short) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_short,temp2_short,
- ABS(temp1_short-temp2_short),
- per);
- }
- nfound++;
- }
- mem1+=sizeof(short);
- mem2+=sizeof(short);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
- }
- else
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_short, mem1, sizeof(short));
- HDmemcpy(&temp2_short, mem2, sizeof(short));
-
- if (temp1_short != temp2_short)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_short,temp2_short,ABS(temp1_short-temp2_short));
- }
- nfound++;
- }
-
- mem1+=sizeof(short);
- mem2+=sizeof(short);
- if (options->n && nfound>=options->count)
- return nfound;
- } /* nelmts */
-
- }
-
- return nfound;
-}
+ hsize_t nfound = 0; /* number of differences found */
+ long temp1_long;
+ long temp2_long;
+ double per;
+ hbool_t both_zero = FALSE;
+ H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool);
-/*-------------------------------------------------------------------------
- * Function: diff_ushort
- *
- * Purpose: diff a H5T_NATIVE_USHORT type
- *
- * Return: number of differences found
- *
- *-------------------------------------------------------------------------
- */
-hsize_t diff_ushort(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph)
+ HDmemcpy(&temp1_long, mem1, sizeof(long));
+ HDmemcpy(&temp2_long, mem2, sizeof(long));
+ /* -d and !-p */
+ if (opts->delta_bool && !opts->percent_bool) {
+ if (ABS(temp1_long - temp2_long) > (long)opts->delta) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(LI_FORMAT, temp1_long, temp2_long, ABS(temp1_long - temp2_long));
+ }
+ nfound++;
+ }
+ }
+ /* !-d and -p */
+ else if (!opts->delta_bool && opts->percent_bool) {
+ PER(temp1_long, temp2_long);
-{
- hsize_t nfound=0; /* number of differences found */
- unsigned short temp1_ushort;
- unsigned short temp2_ushort;
- hsize_t i;
- double per;
- int both_zero;
-
- /* -d and !-p */
- if (options->d && !options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short));
- HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short));
-
- if ( PDIFF(temp1_ushort,temp2_ushort) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_ushort,temp2_ushort,PDIFF(temp1_ushort,temp2_ushort));
- }
- nfound++;
- }
- mem1+=sizeof(unsigned short);
- mem2+=sizeof(unsigned short);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
- }
-
- /* !-d and -p */
- else if (!options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short));
- HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short));
-
- PER_UNSIGN(signed short,temp1_ushort,temp2_ushort);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_ushort,temp2_ushort,
- PDIFF(temp1_ushort,temp2_ushort));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_ushort,temp2_ushort,
- PDIFF(temp1_ushort,temp2_ushort),
- per);
- }
- nfound++;
- }
- mem1+=sizeof(unsigned short);
- mem2+=sizeof(unsigned short);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
-
- }
-
- /* -d and -p */
- else if ( options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short));
- HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short));
-
- PER_UNSIGN(signed short,temp1_ushort,temp2_ushort);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_ushort,temp2_ushort,
- PDIFF(temp1_ushort,temp2_ushort));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent && PDIFF(temp1_ushort,temp2_ushort) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_ushort,temp2_ushort,
- PDIFF(temp1_ushort,temp2_ushort),
- per);
- }
- nfound++;
- }
- mem1+=sizeof(unsigned short);
- mem2+=sizeof(unsigned short);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
- }
- else
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short));
- HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short));
-
- if (temp1_ushort != temp2_ushort)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_ushort,temp2_ushort,PDIFF(temp1_ushort,temp2_ushort));
- }
- nfound++;
- }
-
- mem1+=sizeof(unsigned short);
- mem2+=sizeof(unsigned short);
- if (options->n && nfound>=options->count)
- return nfound;
- } /* nelmts */
-
- }
-
- return nfound;
-}
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(LI_FORMAT_P_NOTCOMP, temp1_long, temp2_long, ABS(temp1_long - temp2_long));
+ }
+ nfound++;
+ }
+ else if (per > opts->percent) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(LI_FORMAT_P, temp1_long, temp2_long, ABS(temp1_long - temp2_long), per);
+ }
+ nfound++;
+ }
+ }
+ /* -d and -p */
+ else if (opts->delta_bool && opts->percent_bool) {
+ PER(temp1_long, temp2_long);
+
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(LI_FORMAT_P_NOTCOMP, temp1_long, temp2_long, ABS(temp1_long - temp2_long));
+ }
+ nfound++;
+ }
+ else if (per > opts->percent && ABS(temp1_long - temp2_long) > (long)opts->delta) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(LI_FORMAT_P, temp1_long, temp2_long, ABS(temp1_long - temp2_long), per);
+ }
+ nfound++;
+ }
+ }
+ else if (temp1_long != temp2_long) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(LI_FORMAT, temp1_long, temp2_long, ABS(temp1_long - temp2_long));
+ }
+ nfound++;
+ }
+ H5TOOLS_ENDDEBUG(":%" PRIuHSIZE " - errstat:%d", nfound, opts->err_stat);
+ return nfound;
+}
/*-------------------------------------------------------------------------
- * Function: diff_int
+ * Function: diff_ulong_element
*
- * Purpose: diff a H5T_NATIVE_INT type
- *
- * Return: number of differences found
+ * Purpose: diff a single H5T_NATIVE_ULONG type
*
+ * Return: number of differences found
*-------------------------------------------------------------------------
*/
-hsize_t diff_int(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph)
-
+static hsize_t
+diff_ulong_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts)
{
- hsize_t nfound=0; /* number of differences found */
- int temp1_int;
- int temp2_int;
- hsize_t i;
- double per;
- int both_zero;
-
- /* -d and !-p */
- if (options->d && !options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_int, mem1, sizeof(int));
- HDmemcpy(&temp2_int, mem2, sizeof(int));
-
- if (ABS(temp1_int-temp2_int) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_int,temp2_int,ABS(temp1_int-temp2_int));
- }
- nfound++;
- }
- mem1+=sizeof(int);
- mem2+=sizeof(int);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
- }
-
- /* !-d and -p */
- else if (!options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_int, mem1, sizeof(int));
- HDmemcpy(&temp2_int, mem2, sizeof(int));
-
- PER(temp1_int,temp2_int);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_int,temp2_int,
- ABS(temp1_int-temp2_int));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_int,temp2_int,
- ABS(temp1_int-temp2_int),
- per);
- }
- nfound++;
- }
- mem1+=sizeof(int);
- mem2+=sizeof(int);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
-
- }
-
- /* -d and -p */
- else if ( options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_int, mem1, sizeof(int));
- HDmemcpy(&temp2_int, mem2, sizeof(int));
-
- PER(temp1_int,temp2_int);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_int,temp2_int,
- ABS(temp1_int-temp2_int));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent && ABS(temp1_int-temp2_int) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_int,temp2_int,
- ABS(temp1_int-temp2_int),
- per);
- }
- nfound++;
- }
- mem1+=sizeof(int);
- mem2+=sizeof(int);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
- }
- else
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_int, mem1, sizeof(int));
- HDmemcpy(&temp2_int, mem2, sizeof(int));
-
- if (temp1_int != temp2_int)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_int,temp2_int,ABS(temp1_int-temp2_int));
- }
- nfound++;
- }
-
- mem1+=sizeof(int);
- mem2+=sizeof(int);
- if (options->n && nfound>=options->count)
- return nfound;
- } /* nelmts */
-
- }
-
- return nfound;
-}
+ hsize_t nfound = 0; /* number of differences found */
+ unsigned long temp1_ulong;
+ unsigned long temp2_ulong;
+ double per;
+ hbool_t both_zero = FALSE;
+ H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool);
+ HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long));
+ HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long));
+ /* -d and !-p */
+ if (opts->delta_bool && !opts->percent_bool) {
+ if (PDIFF(temp1_ulong, temp2_ulong) > (unsigned long)opts->delta) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(ULI_FORMAT, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong));
+ }
+ nfound++;
+ }
+ }
+ /* !-d and -p */
+ else if (!opts->delta_bool && opts->percent_bool) {
+ PER_UNSIGN(signed long, temp1_ulong, temp2_ulong);
-/*-------------------------------------------------------------------------
- * Function: diff_uint
- *
- * Purpose: diff a H5T_NATIVE_UINT type
- *
- * Return: number of differences found
- *
- *-------------------------------------------------------------------------
- */
-hsize_t diff_uint(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph)
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(ULI_FORMAT_P_NOTCOMP, temp1_ulong, temp2_ulong,
+ PDIFF(temp1_ulong, temp2_ulong));
+ }
+ nfound++;
+ }
+ else if (per > opts->percent) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(ULI_FORMAT_P, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong), per);
+ }
+ nfound++;
+ }
+ }
+ /* -d and -p */
+ else if (opts->delta_bool && opts->percent_bool) {
+ PER_UNSIGN(signed long, temp1_ulong, temp2_ulong);
-{
- hsize_t nfound=0; /* number of differences found */
- unsigned int temp1_uint;
- unsigned int temp2_uint;
- hsize_t i;
- double per;
- int both_zero;
-
- /* -d and !-p */
- if (options->d && !options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int));
- HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int));
-
- if ( PDIFF(temp1_uint,temp2_uint) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint));
- }
- nfound++;
- }
- mem1+=sizeof(unsigned int);
- mem2+=sizeof(unsigned int);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
- }
-
- /* !-d and -p */
- else if (!options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int));
- HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int));
-
- PER_UNSIGN(signed int,temp1_uint,temp2_uint);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_uint,temp2_uint,
- PDIFF(temp1_uint,temp2_uint),
- per);
- }
- nfound++;
- }
- mem1+=sizeof(unsigned int);
- mem2+=sizeof(unsigned int);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
-
- }
-
- /* -d and -p */
- else if ( options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int));
- HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int));
-
- PER_UNSIGN(signed int,temp1_uint,temp2_uint);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P_NOTCOMP,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent && PDIFF(temp1_uint,temp2_uint) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT_P,temp1_uint,temp2_uint,
- PDIFF(temp1_uint,temp2_uint),
- per);
- }
- nfound++;
- }
- mem1+=sizeof(unsigned int);
- mem2+=sizeof(unsigned int);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
- }
- else
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int));
- HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int));
-
- if (temp1_uint != temp2_uint)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(I_FORMAT,temp1_uint,temp2_uint,PDIFF(temp1_uint,temp2_uint));
- }
- nfound++;
- }
-
- mem1+=sizeof(unsigned int);
- mem2+=sizeof(unsigned int);
- if (options->n && nfound>=options->count)
- return nfound;
- } /* nelmts */
-
- }
-
- return nfound;
-}
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(ULI_FORMAT_P_NOTCOMP, temp1_ulong, temp2_ulong,
+ PDIFF(temp1_ulong, temp2_ulong));
+ }
+ nfound++;
+ }
+ else if (per > opts->percent && PDIFF(temp1_ulong, temp2_ulong) > (unsigned long)opts->delta) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(ULI_FORMAT_P, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong), per);
+ }
+ nfound++;
+ }
+ }
+ else if (temp1_ulong != temp2_ulong) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(ULI_FORMAT, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong));
+ }
+ nfound++;
+ }
+ H5TOOLS_ENDDEBUG(":%" PRIuHSIZE " - errstat:%d", nfound, opts->err_stat);
+ return nfound;
+}
/*-------------------------------------------------------------------------
- * Function: diff_long
- *
- * Purpose: diff a H5T_NATIVE_LONG type
+ * Function: diff_llong_element
*
- * Return: number of differences found
+ * Purpose: diff a single H5T_NATIVE_LLONG type
*
+ * Return: number of differences found
*-------------------------------------------------------------------------
*/
-hsize_t diff_long(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph)
-
+static hsize_t
+diff_llong_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts)
{
- hsize_t nfound=0; /* number of differences found */
- long temp1_long;
- long temp2_long;
- hsize_t i;
- double per;
- int both_zero;
-
- /* -d and !-p */
- if (options->d && !options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_long, mem1, sizeof(long));
- HDmemcpy(&temp2_long, mem2, sizeof(long));
-
- if (ABS(temp1_long-temp2_long) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT,temp1_long,temp2_long,ABS(temp1_long-temp2_long));
- }
- nfound++;
- }
- mem1+=sizeof(long);
- mem2+=sizeof(long);
- if (options->n && nfound>=options->count)
- return nfound;
- }
- }
- }
-
- /* !-d and -p */
- else if (!options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_long, mem1, sizeof(long));
- HDmemcpy(&temp2_long, mem2, sizeof(long));
-
- PER(temp1_long,temp2_long);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT_P_NOTCOMP,temp1_long,temp2_long,
- ABS(temp1_long-temp2_long));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT_P,temp1_long,temp2_long,
- ABS(temp1_long-temp2_long),
- per);
- }
- nfound++;
- }
- mem1+=sizeof(long);
- mem2+=sizeof(long);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
-
- }
-
- /* -d and -p */
- else if ( options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_long, mem1, sizeof(long));
- HDmemcpy(&temp2_long, mem2, sizeof(long));
-
- PER(temp1_long,temp2_long);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT_P_NOTCOMP,temp1_long,temp2_long,
- ABS(temp1_long-temp2_long));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent && ABS(temp1_long-temp2_long) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT_P,temp1_long,temp2_long,
- ABS(temp1_long-temp2_long),
- per);
- }
- nfound++;
- }
- mem1+=sizeof(long);
- mem2+=sizeof(long);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
- }
- else
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_long, mem1, sizeof(long));
- HDmemcpy(&temp2_long, mem2, sizeof(long));
-
- if (temp1_long != temp2_long)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT,temp1_long,temp2_long,ABS(temp1_long-temp2_long));
- }
- nfound++;
- }
-
- mem1+=sizeof(long);
- mem2+=sizeof(long);
- if (options->n && nfound>=options->count)
- return nfound;
- } /* nelmts */
-
- }
-
- return nfound;
-}
+ hsize_t nfound = 0; /* number of differences found */
+ long long temp1_llong;
+ long long temp2_llong;
+ double per;
+ hbool_t both_zero = FALSE;
+ H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool);
+ HDmemcpy(&temp1_llong, mem1, sizeof(long long));
+ HDmemcpy(&temp2_llong, mem2, sizeof(long long));
+ /* -d and !-p */
+ if (opts->delta_bool && !opts->percent_bool) {
+ if (ABS(temp1_llong - temp2_llong) > (long long)opts->delta) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(LLI_FORMAT, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong));
+ }
+ nfound++;
+ }
+ }
+ /* !-d and -p */
+ else if (!opts->delta_bool && opts->percent_bool) {
+ PER(temp1_llong, temp2_llong);
-/*-------------------------------------------------------------------------
- * Function: diff_ulong
- *
- * Purpose: diff a H5T_NATIVE_ULONG type
- *
- * Return: number of differences found
- *
- *-------------------------------------------------------------------------
- */
-hsize_t diff_ulong(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph)
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(LLI_FORMAT_P_NOTCOMP, temp1_llong, temp2_llong,
+ ABS(temp1_llong - temp2_llong));
+ }
+ nfound++;
+ }
+ else if (per > opts->percent) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(LLI_FORMAT_P, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong), per);
+ }
+ nfound++;
+ }
+ }
+ /* -d and -p */
+ else if (opts->delta_bool && opts->percent_bool) {
+ PER(temp1_llong, temp2_llong);
-{
- hsize_t nfound=0; /* number of differences found */
- unsigned long temp1_ulong;
- unsigned long temp2_ulong;
- hsize_t i;
- double per;
- int both_zero;
-
-
- /* -d and !-p */
- if (options->d && !options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long));
- HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long));
-
- if ( PDIFF(temp1_ulong,temp2_ulong) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong));
- }
- nfound++;
- }
- mem1+=sizeof(unsigned long);
- mem2+=sizeof(unsigned long);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
- }
-
- }
-
- /* !-d and -p */
- else if (!options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long));
- HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long));
-
- PER_UNSIGN(signed long,temp1_ulong,temp2_ulong);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULI_FORMAT_P_NOTCOMP,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT_P,temp1_ulong,temp2_ulong,
- PDIFF(temp1_ulong,temp2_ulong),
- per);
- }
- nfound++;
- }
- mem1+=sizeof(unsigned long);
- mem2+=sizeof(unsigned long);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
-
- }
-
- /* -d and -p */
- else if ( options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long));
- HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long));
-
- PER_UNSIGN(signed long,temp1_ulong,temp2_ulong);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULI_FORMAT_P_NOTCOMP,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent && PDIFF(temp1_ulong,temp2_ulong) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT_P,temp1_ulong,temp2_ulong,
- PDIFF(temp1_ulong,temp2_ulong),
- per);
- }
- nfound++;
- }
- mem1+=sizeof(unsigned long);
- mem2+=sizeof(unsigned long);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
- }
- else
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long));
- HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long));
-
- if (temp1_ulong != temp2_ulong)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LI_FORMAT,temp1_ulong,temp2_ulong,PDIFF(temp1_ulong,temp2_ulong));
- }
- nfound++;
- }
-
- mem1+=sizeof(unsigned long);
- mem2+=sizeof(unsigned long);
- if (options->n && nfound>=options->count)
- return nfound;
- } /* nelmts */
-
- }
-
- return nfound;
-}
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(LLI_FORMAT_P_NOTCOMP, temp1_llong, temp2_llong,
+ ABS(temp1_llong - temp2_llong));
+ }
+ nfound++;
+ }
+ else if (per > opts->percent && ABS(temp1_llong - temp2_llong) > (long long)opts->delta) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(LLI_FORMAT_P, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong), per);
+ }
+ nfound++;
+ }
+ }
+ else {
+ if (temp1_llong != temp2_llong) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(LLI_FORMAT, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong));
+ }
+ nfound++;
+ }
+ }
+ H5TOOLS_ENDDEBUG(":%" PRIuHSIZE " - errstat:%d", nfound, opts->err_stat);
+ return nfound;
+}
/*-------------------------------------------------------------------------
- * Function: diff_llong
- *
- * Purpose: diff a H5T_NATIVE_LLONG type
+ * Function: diff_ullong_element
*
- * Return: number of differences found
+ * Purpose: diff a single H5T_NATIVE_ULLONG type
*
+ * Return: number of differences found
*-------------------------------------------------------------------------
*/
-hsize_t diff_llong(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph)
-
+static hsize_t
+diff_ullong_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts)
{
- hsize_t nfound=0; /* number of differences found */
- long long temp1_llong;
- long long temp2_llong;
- hsize_t i;
- double per;
- int both_zero;
-
- /* -d and !-p */
- if (options->d && !options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_llong, mem1, sizeof(long long));
- HDmemcpy(&temp2_llong, mem2, sizeof(long long));
-
- if (ABS( temp1_llong-temp2_llong) > options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LLI_FORMAT,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong));
- }
- nfound++;
- }
- mem1+=sizeof(long long);
- mem2+=sizeof(long long);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
- }
-
- /* !-d and -p */
- else if (!options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_llong, mem1, sizeof(long long));
- HDmemcpy(&temp2_llong, mem2, sizeof(long long));
-
- PER(temp1_llong,temp2_llong);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LLI_FORMAT_P_NOTCOMP,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LLI_FORMAT_P,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong),per);
- }
- nfound++;
- }
- mem1+=sizeof(long long);
- mem2+=sizeof(long long);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
-
- }
-
- /* -d and -p */
- else if ( options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_llong, mem1, sizeof(long long));
- HDmemcpy(&temp2_llong, mem2, sizeof(long long));
-
- PER(temp1_llong,temp2_llong);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LLI_FORMAT_P_NOTCOMP,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent && ABS(temp1_llong-temp2_llong) > options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LLI_FORMAT_P,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong),per);
- }
- nfound++;
- }
- mem1+=sizeof(long long);
- mem2+=sizeof(long long);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
- }
- else
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_llong, mem1, sizeof(long long));
- HDmemcpy(&temp2_llong, mem2, sizeof(long long));
-
- if (temp1_llong != temp2_llong)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(LLI_FORMAT,temp1_llong,temp2_llong,ABS(temp1_llong-temp2_llong));
- }
- nfound++;
- }
-
- mem1+=sizeof(long long);
- mem2+=sizeof(long long);
- if (options->n && nfound>=options->count)
- return nfound;
- } /* nelmts */
-
- }
-
- return nfound;
-}
+ hsize_t nfound = 0; /* number of differences found */
+ unsigned long long temp1_ullong;
+ unsigned long long temp2_ullong;
+ float f1, f2;
+ double per;
+ hbool_t both_zero = FALSE;
+ H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool);
+ HDmemcpy(&temp1_ullong, mem1, sizeof(unsigned long long));
+ HDmemcpy(&temp2_ullong, mem2, sizeof(unsigned long long));
-/*-------------------------------------------------------------------------
- * Function: diff_ullong
- *
- * Purpose: diff a H5T_NATIVE_ULLONG type
- *
- * Return: number of differences found
- *
- *-------------------------------------------------------------------------
- */
-hsize_t diff_ullong(unsigned char *mem1,
- unsigned char *mem2,
- hsize_t nelmts,
- hsize_t hyper_start,
- int rank,
- hsize_t *dims,
- hsize_t *acc,
- hsize_t *pos,
- diff_opt_t *options,
- const char *obj1,
- const char *obj2,
- int *ph)
+ /* -d and !-p */
+ if (opts->delta_bool && !opts->percent_bool) {
+ if (PDIFF(temp1_ullong, temp2_ullong) > (unsigned long long)opts->delta) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(ULLI_FORMAT, temp1_ullong, temp2_ullong, PDIFF(temp1_ullong, temp2_ullong));
+ }
+ nfound++;
+ }
+ }
+ /* !-d and -p */
+ else if (!opts->delta_bool && opts->percent_bool) {
+ ull2float(temp1_ullong, &f1);
+ ull2float(temp2_ullong, &f2);
+ PER(f1, f2);
+
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(ULLI_FORMAT_P_NOTCOMP, temp1_ullong, temp2_ullong,
+ PDIFF(temp1_ullong, temp2_ullong));
+ }
+ nfound++;
+ }
+ else if (per > opts->percent) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(ULLI_FORMAT_P, temp1_ullong, temp2_ullong, PDIFF(temp1_ullong, temp2_ullong),
+ per);
+ }
+ nfound++;
+ }
+ }
+ /* -d and -p */
+ else if (opts->delta_bool && opts->percent_bool) {
+ ull2float(temp1_ullong, &f1);
+ ull2float(temp2_ullong, &f2);
+ PER(f1, f2);
+
+ if (not_comparable && !both_zero) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(ULLI_FORMAT_P_NOTCOMP, temp1_ullong, temp2_ullong,
+ PDIFF(temp1_ullong, temp2_ullong));
+ }
+ nfound++;
+ }
+ else if (per > opts->percent && PDIFF(temp1_ullong, temp2_ullong) > (unsigned long long)opts->delta) {
+ opts->print_percentage = 1;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(ULLI_FORMAT_P, temp1_ullong, temp2_ullong, PDIFF(temp1_ullong, temp2_ullong),
+ per);
+ }
+ nfound++;
+ }
+ }
+ else {
+ if (temp1_ullong != temp2_ullong) {
+ opts->print_percentage = 0;
+ print_pos(opts, elem_idx, 0);
+ if (print_data(opts)) {
+ parallel_print(ULLI_FORMAT, temp1_ullong, temp2_ullong, PDIFF(temp1_ullong, temp2_ullong));
+ }
+ nfound++;
+ }
+ }
-{
- hsize_t nfound=0; /* number of differences found */
- unsigned long long temp1_ullong;
- unsigned long long temp2_ullong;
- hsize_t i;
- float f1, f2;
- double per;
- int both_zero;
-
- /* -d and !-p */
- if (options->d && !options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_ullong, mem1, sizeof(unsigned long long));
- HDmemcpy(&temp2_ullong, mem2, sizeof(unsigned long long));
-
- if ( PDIFF(temp1_ullong,temp2_ullong) > (unsigned long long) options->delta)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULLI_FORMAT,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong));
- }
- nfound++;
- }
- mem1+=sizeof(unsigned long long);
- mem2+=sizeof(unsigned long long);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
- }
-
- /* !-d and -p */
- else if (!options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_ullong, mem1, sizeof(unsigned long long));
- HDmemcpy(&temp2_ullong, mem2, sizeof(unsigned long long));
-
- ull2float(temp1_ullong,&f1);
- ull2float(temp2_ullong,&f2);
- PER(f1,f2);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULLI_FORMAT_P_NOTCOMP,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULLI_FORMAT_P,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong),per);
- }
- nfound++;
- }
- mem1+=sizeof(unsigned long long);
- mem2+=sizeof(unsigned long long);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
-
- }
-
- /* -d and -p */
- else if ( options->d && options->p)
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_ullong, mem1, sizeof(unsigned long long));
- HDmemcpy(&temp2_ullong, mem2, sizeof(unsigned long long));
-
- ull2float(temp1_ullong,&f1);
- ull2float(temp2_ullong,&f2);
- PER(f1,f2);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULLI_FORMAT_P_NOTCOMP,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong));
- }
- nfound++;
- }
-
- else
-
- if ( per > options->percent && PDIFF(temp1_ullong,temp2_ullong) > (unsigned long long)options->delta )
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULLI_FORMAT_P,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong),per);
- }
- nfound++;
- }
- mem1+=sizeof(unsigned long long);
- mem2+=sizeof(unsigned long long);
- if (options->n && nfound>=options->count)
- return nfound;
- }
-
- }
- else
- {
-
- for ( i = 0; i < nelmts; i++)
- {
- HDmemcpy(&temp1_ullong, mem1, sizeof(unsigned long long));
- HDmemcpy(&temp2_ullong, mem2, sizeof(unsigned long long));
-
- if (temp1_ullong != temp2_ullong)
- {
- if ( print_data(options) )
- {
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(ULLI_FORMAT,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong));
- }
- nfound++;
- }
-
- mem1+=sizeof(unsigned long long);
- mem2+=sizeof(unsigned long long);
- if (options->n && nfound>=options->count)
- return nfound;
- } /* nelmts */
-
- }
-
- return nfound;
+ H5TOOLS_ENDDEBUG(": %" PRIuHSIZE " zero:%d", nfound, both_zero);
+ return nfound;
}
-
-
/*-------------------------------------------------------------------------
* Function: ull2float
*
* Purpose: convert unsigned long long to float
- *
- * Programmer: pvn
- * Mar 22, 2006
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
-static
-int ull2float(unsigned long long ull_value, float *f_value)
+static int
+ull2float(unsigned long long ull_value, float *f_value)
{
- hid_t dxpl_id;
- unsigned char *buf;
- size_t src_size;
- size_t dst_size;
+ hid_t dxpl_id = H5I_INVALID_HID;
+ unsigned char *buf = NULL;
+ size_t src_size;
+ size_t dst_size;
+ int ret_value = 0;
- if((dxpl_id = H5Pcreate(H5P_DATASET_XFER))<0)
- return -1;
+ H5TOOLS_START_DEBUG(" ");
+ if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Pcreate failed");
- src_size = H5Tget_size(H5T_NATIVE_ULLONG);
- dst_size = H5Tget_size(H5T_NATIVE_FLOAT);
- buf = (unsigned char*)HDcalloc(1, MAX(src_size, dst_size));
+ src_size = H5Tget_size(H5T_NATIVE_ULLONG);
+ dst_size = H5Tget_size(H5T_NATIVE_FLOAT);
+ if ((buf = (unsigned char *)HDcalloc((size_t)1, MAX(src_size, dst_size))) == NULL)
+ H5TOOLS_GOTO_ERROR(FAIL, "Could not allocate buffer for dims");
- HDmemcpy(buf, &ull_value, src_size);
+ HDmemcpy(buf, &ull_value, src_size);
- /* do conversion */
- if(H5Tconvert(H5T_NATIVE_ULLONG, H5T_NATIVE_FLOAT, 1, buf, NULL, dxpl_id)<0)
- goto error;
+ /* do conversion */
+ if (H5Tconvert(H5T_NATIVE_ULLONG, H5T_NATIVE_FLOAT, (size_t)1, buf, NULL, dxpl_id) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Tconvert failed");
- HDmemcpy(f_value, buf, dst_size);
+ HDmemcpy(f_value, buf, dst_size);
- if(buf)
- HDfree(buf);
-
- return 0;
+done:
+ H5E_BEGIN_TRY
+ {
+ H5Pclose(dxpl_id);
+ }
+ H5E_END_TRY;
-error:
- H5E_BEGIN_TRY {
- H5Pclose(dxpl_id);
- } H5E_END_TRY;
- if(buf)
- HDfree(buf);
+ if (buf)
+ HDfree(buf);
- return -1;
+ H5TOOLS_ENDDEBUG(" ");
+ return ret_value;
}
-
/*-------------------------------------------------------------------------
* Function: equal_double
*
- * Purpose: use a absolute error formula to deal with floating point
- * uncertainty
- *
- * Modifications:
- * 8/1/2007. handle NaNs
- *
+ * Purpose: use a absolute error formula to deal with floating point uncertainty
*-------------------------------------------------------------------------
*/
-static
-hbool_t equal_double(double value, double expected, diff_opt_t *options)
+static hbool_t
+equal_double(double value, double expected, diff_opt_t *opts)
{
- if ( options->do_nans )
- {
-
+ if (opts->do_nans) {
/*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- int isnan1 = my_isnan(FLT_DOUBLE,&value);
- int isnan2 = my_isnan(FLT_DOUBLE,&expected);
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ hbool_t isnan1 = HDisnan(value);
+ hbool_t isnan2 = HDisnan(expected);
/*-------------------------------------------------------------------------
- * we consider NaN == NaN to be true
- *-------------------------------------------------------------------------
- */
- if ( isnan1 && isnan2 )
- {
+ * we consider NaN == NaN to be true
+ *-------------------------------------------------------------------------
+ */
+ if (isnan1 && isnan2)
return TRUE;
- }
/*-------------------------------------------------------------------------
- * one is a NaN, do not compare but assume difference
- *-------------------------------------------------------------------------
- */
- if ( (isnan1 && !isnan2) || ( !isnan1 && isnan2 ) )
- {
+ * one is a NaN, do not compare but assume difference
+ *-------------------------------------------------------------------------
+ */
+ if ((isnan1 && !isnan2) || (!isnan1 && isnan2))
return FALSE;
- }
}
- if (value == expected)
- return TRUE;
-
- if (options->use_system_epsilon) {
- if ( ABS( (value-expected) ) < DBL_EPSILON)
+ if (opts->use_system_epsilon) {
+ /* Check equality within some epsilon */
+ if (H5_DBL_ABS_EQUAL(value, expected))
+ return TRUE;
+ }
+ else {
+ /* Check bits */
+ if (!HDmemcmp(&value, &expected, sizeof(double)))
return TRUE;
}
@@ -5663,244 +3175,96 @@ hbool_t equal_double(double value, double expected, diff_opt_t *options)
/*-------------------------------------------------------------------------
* Function: equal_ldouble
*
- * Purpose: use a absolute error formula to deal with floating point
- * uncertainty
- *
+ * Purpose: use a absolute error formula to deal with floating point uncertainty
*-------------------------------------------------------------------------
*/
-#if H5_SIZEOF_LONG_DOUBLE !=0
-static
-hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *options)
+static hbool_t
+equal_ldouble(long double value, long double expected, diff_opt_t *opts)
{
- if ( options->do_nans )
- {
-
+ if (opts->do_nans) {
/*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- int isnan1 = my_isnan(FLT_LDOUBLE,&value);
- int isnan2 = my_isnan(FLT_LDOUBLE,&expected);
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ hbool_t isnan1 = HDisnan(value);
+ hbool_t isnan2 = HDisnan(expected);
/*-------------------------------------------------------------------------
- * we consider NaN == NaN to be true
- *-------------------------------------------------------------------------
- */
- if ( isnan1 && isnan2 )
- {
+ * we consider NaN == NaN to be true
+ *-------------------------------------------------------------------------
+ */
+ if (isnan1 && isnan2)
return TRUE;
- }
/*-------------------------------------------------------------------------
- * one is a NaN, do not compare but assume difference
- *-------------------------------------------------------------------------
- */
- if ( (isnan1 && !isnan2) || ( !isnan1 && isnan2 ) )
- {
+ * one is a NaN, do not compare but assume difference
+ *-------------------------------------------------------------------------
+ */
+ if ((isnan1 && !isnan2) || (!isnan1 && isnan2))
return FALSE;
- }
}
- if (value == expected)
- return TRUE;
-
- if (options->use_system_epsilon) {
- if ( ABS( (value-expected) ) < DBL_EPSILON)
+ if (opts->use_system_epsilon) {
+ /* Check equality within some epsilon */
+ if (H5_LDBL_ABS_EQUAL(value, expected))
+ return TRUE;
+ }
+ else {
+ /* Check bits */
+ if (!HDmemcmp(&value, &expected, sizeof(long double)))
return TRUE;
}
return FALSE;
}
-#endif /* #if H5_SIZEOF_LONG_DOUBLE !=0 */
-
-
/*-------------------------------------------------------------------------
* Function: equal_float
*
- * Purpose: use a absolute error formula to deal with floating point
- * uncertainty
- *
- * Modifications:
- * 8/1/2007. handle NaNs
- *
+ * Purpose: use a absolute error formula to deal with floating point uncertainty
*-------------------------------------------------------------------------
*/
-static
-hbool_t equal_float(float value, float expected, diff_opt_t *options)
+static hbool_t
+equal_float(float value, float expected, diff_opt_t *opts)
{
- if ( options->do_nans )
- {
-
+ if (opts->do_nans) {
/*-------------------------------------------------------------------------
- * detect NaNs
- *-------------------------------------------------------------------------
- */
- int isnan1 = my_isnan(FLT_FLOAT,&value);
- int isnan2 = my_isnan(FLT_FLOAT,&expected);
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ hbool_t isnan1 = HDisnan(value);
+ hbool_t isnan2 = HDisnan(expected);
/*-------------------------------------------------------------------------
- * we consider NaN == NaN to be true
- *-------------------------------------------------------------------------
- */
- if ( isnan1 && isnan2 )
- {
+ * we consider NaN == NaN to be true
+ *-------------------------------------------------------------------------
+ */
+ if (isnan1 && isnan2)
return TRUE;
- }
/*-------------------------------------------------------------------------
- * one is a NaN, do not compare but assume difference
- *-------------------------------------------------------------------------
- */
- if ( (isnan1 && !isnan2) || ( !isnan1 && isnan2 ) )
- {
+ * one is a NaN, do not compare but assume difference
+ *-------------------------------------------------------------------------
+ */
+ if ((isnan1 && !isnan2) || (!isnan1 && isnan2))
return FALSE;
- }
}
- if (value == expected)
- return TRUE;
-
- if (options->use_system_epsilon) {
- if ( ABS( (value-expected) ) < FLT_EPSILON)
+ if (opts->use_system_epsilon) {
+ /* Check equality within some epsilon */
+ if (H5_FLT_ABS_EQUAL(value, expected))
return TRUE;
}
-
- return FALSE;
-
-}
-
-
-
-/*-------------------------------------------------------------------------
- * Function: my_isnan
- *
- * Purpose: Determines whether VAL points to NaN.
- *
- * Return: TRUE or FALSE
- *
- * Programmer: Robb Matzke
- * Monday, July 6, 1998
- *
- * Modifications:
- * Pedro Vicente, 12 October 2007.
- * Add a string detection type for WIN32
- *
- *-------------------------------------------------------------------------
- */
-static int
-my_isnan(dtype_t type, void *val)
-{
- int retval = 0;
- char s[256];
-
- if (FLT_FLOAT==type)
- {
- float x;
- HDmemcpy(&x, val, sizeof(float));
- retval = (x!=x);
-
-
-
- }
- else if (FLT_DOUBLE==type)
- {
- double x;
- HDmemcpy(&x, val, sizeof(double));
- retval = (x!=x);
-
-#if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE!=0
- }
- else if (FLT_LDOUBLE==type)
- {
- long double x;
- HDmemcpy(&x, val, sizeof(long double));
- retval = (x!=x);
-#endif
- }
- else
- {
- return 0;
- }
-
- /*
- * Sometimes NaN==NaN (e.g., DEC Alpha) so we try to print it and see if
- * the result contains a NaN string.
- */
- if (!retval)
- {
- if (FLT_FLOAT==type)
- {
- float x;
- HDmemcpy(&x, val, sizeof(float));
- sprintf(s, "%g", x);
-
-
- }
- else if (FLT_DOUBLE==type)
- {
- double x;
- HDmemcpy(&x, val, sizeof(double));
- sprintf(s, "%g", x);
-#if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE!=0
- }
- else if (FLT_LDOUBLE==type)
- {
- long double x;
- HDmemcpy(&x, val, sizeof(long double));
- sprintf(s, "%Lg", x);
-#endif
- }
- else
- {
- return 0;
- }
-
-
- if ( HDstrstr(s, "NaN") ||
- HDstrstr(s, "NAN") ||
- HDstrstr(s, "nan") ||
- HDstrstr(s, "-1.#IND") /* WIN32 */
- )
- {
-
- retval = 1;
- }
-
-
-
-
- }
-
-#ifdef H5_VMS
- /* For "float" and "double" on OpenVMS/Alpha, NaN is
- * actually a valid value of maximal value.*/
- if(!retval)
- {
- if (FLT_FLOAT==type)
- {
- float x;
- HDmemcpy(&x, val, sizeof(float));
- retval = (x==FLT_MAX || x==-FLT_MAX);
- } else if (FLT_DOUBLE==type) {
- double x;
- HDmemcpy(&x, val, sizeof(double));
- retval = (x==DBL_MAX || x==-DBL_MAX);
- } else
- {
- return 0;
- }
+ else {
+ /* Check bits */
+ if (!HDmemcmp(&value, &expected, sizeof(float)))
+ return TRUE;
}
-#endif /*H5_VMS*/
- return retval;
+ return FALSE;
}
-
-
-
-
/*-------------------------------------------------------------------------
*
* Local functions
@@ -5911,52 +3275,39 @@ my_isnan(dtype_t type, void *val)
/*-------------------------------------------------------------------------
* Function: print_data
*
- * Purpose: print data only in report or verbose modes, and do not print in quiet mode
+ * Purpose: print data only in report or verbose modes, and do not print in quiet mode
*-------------------------------------------------------------------------
*/
-static
-int print_data(diff_opt_t *options)
+static int
+print_data(diff_opt_t *opts)
{
- return ( (options->m_report || options->m_verbose) && !options->m_quiet)?1:0;
+ return ((opts->mode_report || opts->mode_verbose) && !opts->mode_quiet) ? 1 : 0;
}
/*-------------------------------------------------------------------------
* Function: print_header
*
- * Purpose: print header for difference
- *
+ * Purpose: print header for difference
*-------------------------------------------------------------------------
*/
-
-static
-void print_header(int pp, /* print percentage */
- int rank,
- hsize_t *dims,
- const char *obj1,
- const char *obj2 )
+static void
+print_header(diff_opt_t *opts)
{
/* print header */
- parallel_print("%-16s","size:");
- print_dimensions (rank,dims);
- parallel_print("%-11s","");
- print_dimensions (rank,dims);
+ parallel_print("%-16s", "size:");
+ print_dimensions(opts->rank, opts->dims);
+ parallel_print("%-11s", "");
+ print_dimensions(opts->rank, opts->dims);
parallel_print("\n");
- if(pp) {
- parallel_print("%-15s %-15s %-15s %-15s %-15s\n",
- "position",
- (obj1!=NULL) ? obj1 : " ",
- (obj2!=NULL) ? obj2 : " ",
- "difference",
- "relative");
+ if (opts->print_percentage) {
+ parallel_print("%-15s %-15s %-15s %-15s %-15s\n", "position", opts->obj_name[0], opts->obj_name[1],
+ "difference", "relative");
parallel_print("------------------------------------------------------------------------\n");
}
else {
- parallel_print("%-15s %-15s %-15s %-20s\n",
- "position",
- (obj1!=NULL) ? obj1 : " ",
- (obj2!=NULL) ? obj2 : " ",
- "difference");
+ parallel_print("%-15s %-15s %-15s %-20s\n", "position", opts->obj_name[0], opts->obj_name[1],
+ "difference");
parallel_print("------------------------------------------------------------\n");
}
}
@@ -5964,226 +3315,220 @@ void print_header(int pp, /* print percentage */
/*-------------------------------------------------------------------------
* Function: print_pos
*
- * Purpose: print in matrix notation, converting from an array index position
- *
+ * Purpose: print in matrix notation, converting from an array index position
*-------------------------------------------------------------------------
*/
-
-static
-void print_pos( int *ph, /* print header */
- int pp, /* print percentage */
- hsize_t curr_pos,
- hsize_t *acc,
- hsize_t *pos,
- int rank,
- hsize_t *dims,
- const char *obj1,
- const char *obj2 )
+static void
+print_pos(diff_opt_t *opts, hsize_t idx, size_t u)
{
- int i;
-
- /* print header */
- if ( *ph==1 )
- {
- *ph=0;
-
- print_header(pp, rank, dims, obj1, obj2);
- } /* end print header */
-
- for ( i = 0; i < rank; i++)
- {
- pos[i] = curr_pos/acc[i];
- curr_pos -= acc[i]*pos[i];
- }
- HDassert( curr_pos == 0 );
+ H5TOOLS_START_DEBUG(" -- idx:%" PRIuHSIZE, idx);
+
+ if (print_data(opts)) {
+ hsize_t curr_pos = idx;
+ /* print header */
+ if (opts->print_header == 1) {
+ opts->print_header = 0;
+ print_header(opts);
+ } /* end print header */
+
+ H5TOOLS_DEBUG("rank=%d", opts->rank);
+ if (opts->rank > 0) {
+ parallel_print("[ ");
+ H5TOOLS_DEBUG("do calc_acc_pos[%" PRIuHSIZE "] nelmts:%" PRIuHSIZE " - errstat:%d", idx,
+ opts->hs_nelmts, opts->err_stat);
+ if (opts->sset[0] != NULL) {
+ /* Subsetting is used - calculate total position */
+ hsize_t curr_idx = 0; /* current pos in the selection space for each dimension */
+
+ curr_pos = 0; /* current position in full space */
+ if (curr_idx < idx) {
+ int j;
+ hsize_t count;
+ hsize_t block;
+ hsize_t stride;
+ hsize_t tmp = 0;
+ hsize_t k0 = 0; /* whole location beyond current dimension */
+ hsize_t k1 = 0; /* partial location within dimension */
+ hsize_t dim_size = 0; /* previous dim size */
+ hsize_t prev_dim_size = 0; /* previous dim size */
+ hsize_t total_dim_size = 1; /* current dim size */
+ hsize_t prev_total_dim_size = 1; /* current dim size */
+
+ prev_dim_size = 1;
+ total_dim_size = 1;
+ curr_idx = idx;
+ /* begin with fastest changing dimension */
+ for (int i = 0; i < opts->rank; i++) {
+ j = opts->rank - i - 1;
+ prev_total_dim_size *= prev_dim_size;
+ dim_size = opts->dims[j];
+ H5TOOLS_DEBUG("j=%d, dim_size=%" PRIuHSIZE ", prev_dim_size=%" PRIuHSIZE
+ ", total_dim_size=%" PRIuHSIZE ", "
+ "prev_total_dim_size=%" PRIuHSIZE,
+ j, dim_size, prev_dim_size, total_dim_size, prev_total_dim_size);
+ count = opts->sset[0]->count.data[j];
+ block = opts->sset[0]->block.data[j];
+ stride = opts->sset[0]->stride.data[j];
+ H5TOOLS_DEBUG("stride=%" PRIuHSIZE ", count=%" PRIuHSIZE ", block=%" PRIuHSIZE,
+ stride, count, block);
+ tmp = count * block;
+ k0 = curr_idx / tmp;
+ k1 = curr_idx % tmp;
+ curr_pos += k1 * stride * prev_total_dim_size;
+ H5TOOLS_DEBUG("curr_idx=%" PRIuHSIZE ", k0=%" PRIuHSIZE ", k1=%" PRIuHSIZE
+ ", curr_pos=%" PRIuHSIZE,
+ curr_idx, k0, k1, curr_pos);
+ if (k0 > 0)
+ curr_idx = k0 * total_dim_size;
+ H5TOOLS_DEBUG("curr_idx=%" PRIuHSIZE ", tmp=%" PRIuHSIZE, curr_idx, tmp);
+ total_dim_size *= dim_size;
+ /* if last calculation exists within in current dimension */
+ if (k0 == 0)
+ break;
+ H5TOOLS_DEBUG("j=%d, curr_pos=%" PRIuHSIZE, j, curr_pos);
+ prev_dim_size = dim_size;
+ }
+ /* check if there is a final calculation needed for slowest changing dimension */
+ if (k0 > 0)
+ curr_pos += k0 * stride * prev_total_dim_size;
+ H5TOOLS_DEBUG("4:curr_idx=%" PRIuHSIZE ", curr_pos=%" PRIuHSIZE, curr_idx, curr_pos);
+ }
+ }
+ /*
+ * Calculate the number of elements represented by a unit change in a
+ * certain index position.
+ */
+ calc_acc_pos((unsigned)opts->rank, curr_pos, opts->acc, opts->pos);
- if ( rank > 0 )
- {
- parallel_print("[ " );
- for ( i = 0; i < rank; i++)
- {
- parallel_print(HSIZE_T_FORMAT, (unsigned long long)pos[i]);
- parallel_print(" ");
+ for (int i = 0; i < opts->rank; i++) {
+ H5TOOLS_DEBUG("pos loop:%d with opts->pos=%" PRIuHSIZE " opts->sm_pos=%" PRIuHSIZE, i,
+ opts->pos[i], opts->sm_pos[i]);
+ opts->pos[i] += (unsigned long)opts->sm_pos[i];
+ H5TOOLS_DEBUG("pos loop:%d with opts->pos=%" PRIuHSIZE, i, opts->pos[i]);
+ parallel_print("%" PRIuHSIZE, opts->pos[i]);
+ parallel_print(" ");
+ }
+ parallel_print("]");
}
- parallel_print("]" );
- }
- else
- {
- parallel_print(" ");
- }
-}
-
-/*-------------------------------------------------------------------------
- * Function: print_char_pos
- *
- * Purpose: print character position in string
- *
- *-------------------------------------------------------------------------
- */
-
-static
-void print_char_pos( int *ph, /* print header */
- int pp, /* print percentage */
- hsize_t curr_pos,
- unsigned u,
- hsize_t *acc,
- hsize_t *pos,
- int rank,
- hsize_t *dims,
- const char *obj1,
- const char *obj2 )
-{
- int i;
-
- /* print header */
- if ( *ph==1 )
- {
- *ph=0;
-
- print_header(pp, rank, dims, obj1, obj2);
- } /* end print header */
-
- for ( i = 0; i < rank; i++)
- {
- pos[i] = curr_pos/acc[i];
- curr_pos -= acc[i]*pos[i];
- }
- HDassert( curr_pos == 0 );
-
- parallel_print("[ " );
- if ( rank > 0 )
- {
-
- for ( i = 0; i < rank; i++)
- {
- parallel_print(HSIZE_T_FORMAT, (unsigned long long)pos[i]);
- parallel_print(" ");
+ else {
+ if (opts->print_dims) {
+ parallel_print("[ ");
+ parallel_print("%zu", u);
+ parallel_print("]");
+ opts->print_dims = 0;
+ }
+ else
+ parallel_print(" ");
}
-
+ parallel_print(SPACES);
}
- else
- {
- parallel_print("%u", (unsigned)u);
- }
- parallel_print("]" );
+
+ H5TOOLS_ENDDEBUG(" ");
}
/*-------------------------------------------------------------------------
- * Function: h5diff_print_char. Adapted from h5tools_print_char
- *
- * Purpose: Print a char
+ * Function: h5diff_print_char. Adapted from h5tools_print_char
*
+ * Purpose: Print a char
*-------------------------------------------------------------------------
*/
-static void h5diff_print_char(char ch)
+static void
+h5diff_print_char(char ch)
{
-
- switch (ch)
- {
- case '"':
- parallel_print("\\\"");
- break;
- case '\\':
- parallel_print( "\\\\");
- break;
- case '\b':
- parallel_print("\\b");
- break;
- case '\f':
- parallel_print("\\f");
- break;
- case '\n':
- parallel_print("\\n");
- break;
- case '\r':
- parallel_print("\\r");
- break;
- case '\t':
- parallel_print("\\t");
- break;
- default:
- if (isprint(ch))
- parallel_print( "%c", ch);
- else
- parallel_print( "\\%03o", ch);
-
- break;
+ switch (ch) {
+ case '"':
+ parallel_print("\\\"");
+ break;
+ case '\\':
+ parallel_print("\\\\");
+ break;
+ case '\b':
+ parallel_print("\\b");
+ break;
+ case '\f':
+ parallel_print("\\f");
+ break;
+ case '\n':
+ parallel_print("\\n");
+ break;
+ case '\r':
+ parallel_print("\\r");
+ break;
+ case '\t':
+ parallel_print("\\t");
+ break;
+ default:
+ if (isprint(ch))
+ parallel_print("%c", ch);
+ else
+ parallel_print("\\%03o", ch);
+ break;
}
}
-
/*-------------------------------------------------------------------------
- * XCAO, 11/10/2010
* added to improve performance for compound datasets
* set up compound datatype structures.
+ *-------------------------------------------------------------------------
*/
-static void get_member_types(hid_t tid, mcomp_t *members)
+static void
+get_member_types(hid_t tid, mcomp_t *members)
{
- int i;
- int tclass;
+ int tclass;
+ unsigned u;
- if (tid <=0 || !members)
+ if (tid <= 0 || !members)
return;
tclass = H5Tget_class(tid);
- if (tclass == H5T_ARRAY || tclass == H5T_VLEN)
- {
+ if (tclass == H5T_ARRAY || tclass == H5T_VLEN) {
hid_t base_tid = H5Tget_super(tid);
get_member_types(base_tid, members);
H5Tclose(base_tid);
- }
- else if (tclass == H5T_COMPOUND)
- {
- members->n = H5Tget_nmembers( tid );
- if (members->n <=0)
- return;
-
- members->ids = HDcalloc(members->n, sizeof(hid_t));
- members->flags = HDcalloc(members->n, sizeof(unsigned char));
- members->offsets = HDcalloc(members->n, sizeof(size_t));
- members->m = HDcalloc(members->n, sizeof(mcomp_t *));
-
- for (i=0; i< members->n; i++)
- {
- members->ids[i] = H5Tget_member_type( tid, i );
- members->flags[i] = H5Tis_variable_str( members->ids[i] );
- members->offsets[i] = H5Tget_member_offset( tid, i );
- members->m[i] = (mcomp_t *)HDmalloc(sizeof(mcomp_t));
- HDmemset(members->m[i], 0, sizeof(mcomp_t));
- get_member_types(members->ids[i], members->m[i]);
- }
}
-
- return;
-
+ else if (tclass == H5T_COMPOUND) {
+ int nmembs;
+ if ((nmembs = H5Tget_nmembers(tid)) <= 0)
+ return;
+ members->n = (unsigned)nmembs;
+
+ members->ids = (hid_t *)HDcalloc((size_t)members->n, sizeof(hid_t));
+ members->offsets = (size_t *)HDcalloc((size_t)members->n, sizeof(size_t));
+ members->m = (mcomp_t **)HDcalloc((size_t)members->n, sizeof(mcomp_t *));
+
+ for (u = 0; u < members->n; u++) {
+ members->ids[u] = H5Tget_member_type(tid, u);
+ members->offsets[u] = H5Tget_member_offset(tid, u);
+ members->m[u] = (mcomp_t *)HDmalloc(sizeof(mcomp_t));
+ HDmemset(members->m[u], 0, sizeof(mcomp_t));
+ get_member_types(members->ids[u], members->m[u]);
+ }
+ }
}
/*-------------------------------------------------------------------------
- * XCAO, 11/10/2010
* added to improve performance for compound datasets
* clean and close compound members.
+ *-------------------------------------------------------------------------
*/
-static void close_member_types(mcomp_t *members)
+static void
+close_member_types(mcomp_t *members)
{
- int i;
+ unsigned u;
- if (!members || members->n<=0 || !members->ids)
+ if (!members || members->n <= 0 || !members->ids)
return;
- for (i=0; i<members->n; i++)
- {
- if (members->m[i])
- {
- close_member_types(members->m[i]);
- HDfree(members->m[i]);
+ for (u = 0; u < members->n; u++) {
+ if (members->m[u]) {
+ close_member_types(members->m[u]);
+ HDfree(members->m[u]);
}
- H5Tclose(members->ids[i]);
+ H5Tclose(members->ids[u]);
}
- HDfree (members->m);
- HDfree (members->ids);
- HDfree (members->flags);
- HDfree (members->offsets);
+ HDfree(members->m);
+ HDfree(members->ids);
+ HDfree(members->offsets);
}
-
diff --git a/tools/lib/h5diff_attr.c b/tools/lib/h5diff_attr.c
index 85cd01f..aa64fa5 100644
--- a/tools/lib/h5diff_attr.c
+++ b/tools/lib/h5diff_attr.c
@@ -1,16 +1,13 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "H5private.h"
@@ -21,19 +18,18 @@
#define ATTR_NAME_MAX 255
typedef struct table_attr_t {
- char *name;
- unsigned exist[2];
+ char *name;
+ unsigned exist[2];
} match_attr_t;
typedef struct table_attrs_t {
- size_t size;
- size_t nattrs;
- size_t nattrs_only1;
- size_t nattrs_only2;
+ size_t size;
+ size_t nattrs;
+ size_t nattrs_only1;
+ size_t nattrs_only2;
match_attr_t *attrs;
} table_attrs_t;
-
/*-------------------------------------------------------------------------
* Function: table_attrs_init
*
@@ -46,15 +42,16 @@ typedef struct table_attrs_t {
*
* Date: March 15, 2011
*------------------------------------------------------------------------*/
-static void table_attrs_init(table_attrs_t **tbl)
+static void
+table_attrs_init(table_attrs_t **tbl)
{
- table_attrs_t* table_attrs = (table_attrs_t*) HDmalloc(sizeof(table_attrs_t));
+ table_attrs_t *table_attrs = (table_attrs_t *)HDmalloc(sizeof(table_attrs_t));
- table_attrs->size = 0;
- table_attrs->nattrs = 0;
+ table_attrs->size = 0;
+ table_attrs->nattrs = 0;
table_attrs->nattrs_only1 = 0;
table_attrs->nattrs_only2 = 0;
- table_attrs->attrs = NULL;
+ table_attrs->attrs = NULL;
*tbl = table_attrs;
}
@@ -71,18 +68,17 @@ static void table_attrs_init(table_attrs_t **tbl)
*
* Date: March 15, 2011
*------------------------------------------------------------------------*/
-static void table_attrs_free( table_attrs_t *table )
+static void
+table_attrs_free(table_attrs_t *table)
{
unsigned int i;
- if (table)
- {
- if(table->attrs)
- {
- for(i = 0; i < table->nattrs; i++)
- {
- if(table->attrs[i].name)
- HDfree(table->attrs[i].name );
+ if (table) {
+ if (table->attrs) {
+ for (i = 0; i < table->nattrs; i++) {
+ if (table->attrs[i].name) {
+ HDfree(table->attrs[i].name);
+ }
} /* end for */
HDfree(table->attrs);
table->attrs = NULL;
@@ -95,7 +91,7 @@ static void table_attrs_free( table_attrs_t *table )
/*-------------------------------------------------------------------------
* Function: table_attr_mark_exist
*
- * Purpose: mark given attribute name to table as sign of exsit
+ * Purpose: mark given attribute name to table as sign of exist
*
* Parameter:
* - exist [IN]
@@ -106,19 +102,28 @@ static void table_attrs_free( table_attrs_t *table )
*
* Date: March 15, 2011
*------------------------------------------------------------------------*/
-static void table_attr_mark_exist(unsigned *exist, char *name, table_attrs_t *table)
+static void
+table_attr_mark_exist(const unsigned *exist, char *name, table_attrs_t *table)
{
- unsigned int new;
+ if (table->nattrs == table->size) {
+ match_attr_t *new_attrs;
- if(table->nattrs == table->size) {
table->size = MAX(1, table->size * 2);
- table->attrs = (match_attr_t *)HDrealloc(table->attrs, table->size * sizeof(match_attr_t));
+ new_attrs = (match_attr_t *)HDrealloc(table->attrs, table->size * sizeof(match_attr_t));
+ if (new_attrs)
+ table->attrs = new_attrs;
} /* end if */
- new = table->nattrs++;
- table->attrs[new].exist[0] = exist[0];
- table->attrs[new].exist[1] = exist[1];
- table->attrs[new].name = (char *)HDstrdup(name);
+ if (table->nattrs < table->size) {
+ size_t curr_val;
+
+ curr_val = table->nattrs;
+ table->attrs[curr_val].exist[0] = exist[0];
+ table->attrs[curr_val].exist[1] = exist[1];
+ if (name)
+ table->attrs[curr_val].name = (char *)HDstrdup(name);
+ table->nattrs++;
+ }
}
/*-------------------------------------------------------------------------
@@ -127,408 +132,554 @@ static void table_attr_mark_exist(unsigned *exist, char *name, table_attrs_t *ta
* Purpose: get list of matching attribute name from obj1 and obj2
*
* Note:
- * Find common attribute; the algorithm for search is referred from
+ * Find common attribute; the algorithm for search is referred from
* build_match_list() in h5diff.c .
*
* Parameter:
* table_out [OUT] : return the list
- *
- * Programmer: Jonathan Kim
- *
- * Date: March 15, 2011
*------------------------------------------------------------------------*/
-static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t ** table_out, diff_opt_t *options)
+static herr_t
+build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t **table_out, diff_opt_t *opts)
{
- H5O_info_t oinfo1, oinfo2; /* Object info */
- hid_t attr1_id=-1; /* attr ID */
- hid_t attr2_id=-1; /* attr ID */
- size_t curr1 = 0;
- size_t curr2 = 0;
- unsigned infile[2];
- char name1[ATTR_NAME_MAX];
- char name2[ATTR_NAME_MAX];
- int cmp;
- unsigned i;
table_attrs_t *table_lp = NULL;
+ H5O_info2_t oinfo1, oinfo2; /* Object info */
+ hid_t attr1_id = H5I_INVALID_HID; /* attr ID */
+ hid_t attr2_id = H5I_INVALID_HID; /* attr ID */
+ size_t curr1 = 0;
+ size_t curr2 = 0;
+ unsigned infile[2];
+ char name1[ATTR_NAME_MAX];
+ char name2[ATTR_NAME_MAX];
+ int cmp;
+ unsigned i;
+ herr_t ret_value = SUCCEED;
+
+ H5TOOLS_START_DEBUG(" - errstat:%d", opts->err_stat);
+
+ if (H5Oget_info3(loc1_id, &oinfo1, H5O_INFO_NUM_ATTRS) < 0) {
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Oget_info first object failed");
+ }
+ H5TOOLS_DEBUG("H5Oget_info3 loc1id=%d", oinfo1.num_attrs);
+ if (H5Oget_info3(loc2_id, &oinfo2, H5O_INFO_NUM_ATTRS) < 0) {
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Oget_info second object failed");
+ }
+ H5TOOLS_DEBUG("H5Oget_info3 loc2id=%d", oinfo2.num_attrs);
- if(H5Oget_info(loc1_id, &oinfo1) < 0)
- goto error;
- if(H5Oget_info(loc2_id, &oinfo2) < 0)
- goto error;
+ table_attrs_init(&table_lp);
+ if (table_lp == NULL)
+ H5TOOLS_GOTO_ERROR(FAIL, "Table allocation failed");
- table_attrs_init( &table_lp );
+ /*--------------------------------------------------
+ * build the list
+ */
+ while (curr1 < oinfo1.num_attrs && curr2 < oinfo2.num_attrs) {
+ H5TOOLS_DEBUG("list_attrs 1: %ld - %ld", curr1, oinfo1.num_attrs);
+ H5TOOLS_DEBUG("list_attrs 2: %ld - %ld", curr2, oinfo2.num_attrs);
-
- /*--------------------------------------------------
- * build the list
- */
- while(curr1 < oinfo1.num_attrs && curr2 < oinfo2.num_attrs)
- {
- /*------------------
+ /*------------------
* open attribute1 */
- if((attr1_id = H5Aopen_by_idx(loc1_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)curr1, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- goto error;
+ if ((attr1_id = H5Aopen_by_idx(loc1_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)curr1, H5P_DEFAULT,
+ H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Aopen_by_idx first attribute failed");
/* get name */
- if(H5Aget_name(attr1_id, ATTR_NAME_MAX, name1) < 0)
- goto error;
+ if (H5Aget_name(attr1_id, (size_t)ATTR_NAME_MAX, name1) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Aget_name first attribute failed");
- /*------------------
+ /*------------------
* open attribute2 */
- if((attr2_id = H5Aopen_by_idx(loc2_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)curr2, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- goto error;
+ if ((attr2_id = H5Aopen_by_idx(loc2_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)curr2, H5P_DEFAULT,
+ H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Aopen_by_idx second attribute failed");
/* get name */
- if(H5Aget_name(attr2_id, ATTR_NAME_MAX, name2) < 0)
- goto error;
+ if (H5Aget_name(attr2_id, (size_t)ATTR_NAME_MAX, name2) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Aget_name second attribute failed");
/* criteria is string compare */
cmp = HDstrcmp(name1, name2);
- if(cmp == 0)
- {
+ if (cmp == 0) {
infile[0] = 1;
infile[1] = 1;
table_attr_mark_exist(infile, name1, table_lp);
curr1++;
curr2++;
}
- else if(cmp < 0)
- {
+ else if (cmp < 0) {
infile[0] = 1;
infile[1] = 0;
table_attr_mark_exist(infile, name1, table_lp);
table_lp->nattrs_only1++;
curr1++;
}
- else
- {
+ else {
infile[0] = 0;
infile[1] = 1;
table_attr_mark_exist(infile, name2, table_lp);
table_lp->nattrs_only2++;
curr2++;
}
+
+ /* close for next turn */
+ H5Aclose(attr1_id);
+ attr1_id = H5I_INVALID_HID;
+ H5Aclose(attr2_id);
+ attr2_id = H5I_INVALID_HID;
} /* end while */
/* list1 did not end */
infile[0] = 1;
infile[1] = 0;
- while(curr1 < oinfo1.num_attrs)
- {
- /*------------------
+ while (curr1 < oinfo1.num_attrs) {
+ H5TOOLS_DEBUG("list_attrs 1: %ld - %ld", curr1, oinfo1.num_attrs);
+
+ /*------------------
* open attribute1 */
- if((attr1_id = H5Aopen_by_idx(loc1_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)curr1, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- goto error;
+ if ((attr1_id = H5Aopen_by_idx(loc1_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)curr1, H5P_DEFAULT,
+ H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Aopen_by_idx first attribute failed");
/* get name */
- if(H5Aget_name(attr1_id, ATTR_NAME_MAX, name1) < 0)
- goto error;
+ if (H5Aget_name(attr1_id, (size_t)ATTR_NAME_MAX, name1) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Aget_name first attribute failed");
+ H5TOOLS_DEBUG("list_attrs 1 name - %s", name1);
table_attr_mark_exist(infile, name1, table_lp);
table_lp->nattrs_only1++;
curr1++;
+
+ /* close for next turn */
+ H5Aclose(attr1_id);
+ attr1_id = H5I_INVALID_HID;
}
/* list2 did not end */
infile[0] = 0;
infile[1] = 1;
- while(curr2 < oinfo2.num_attrs)
- {
- /*------------------
+ while (curr2 < oinfo2.num_attrs) {
+ H5TOOLS_DEBUG("list_attrs 2: %ld - %ld", curr2, oinfo2.num_attrs);
+ /*------------------
* open attribute2 */
- if((attr2_id = H5Aopen_by_idx(loc2_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)curr2, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- goto error;
+ if ((attr2_id = H5Aopen_by_idx(loc2_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)curr2, H5P_DEFAULT,
+ H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Aopen_by_idx second attribute failed");
/* get name */
- if(H5Aget_name(attr2_id, ATTR_NAME_MAX, name2) < 0)
- goto error;
+ if (H5Aget_name(attr2_id, (size_t)ATTR_NAME_MAX, name2) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Aget_name second attribute failed");
+ H5TOOLS_DEBUG("list_attrs 2 name - %s", name2);
table_attr_mark_exist(infile, name2, table_lp);
table_lp->nattrs_only2++;
curr2++;
+
+ /* close for next turn */
+ H5Aclose(attr2_id);
+ attr2_id = H5I_INVALID_HID;
}
/*------------------------------------------------------
- * print the list
- */
- if(options->m_verbose_level == 2)
- {
+ * print the list
+ */
+ if (opts->mode_verbose_level == 2) {
/* if '-v2' is detected */
parallel_print(" obj1 obj2\n");
parallel_print(" --------------------------------------\n");
- for(i = 0; i < (unsigned int) table_lp->nattrs; i++)
- {
- char c1, c2;
+ for (i = 0; i < (unsigned int)table_lp->nattrs; i++) {
+ int c1, c2;
c1 = (table_lp->attrs[i].exist[0]) ? 'x' : ' ';
c2 = (table_lp->attrs[i].exist[1]) ? 'x' : ' ';
parallel_print("%5c %6c %-15s\n", c1, c2, table_lp->attrs[i].name);
} /* end for */
}
- if(options->m_verbose_level >= 1)
- {
- parallel_print("Attributes status: %d common, %d only in obj1, %d only in obj2\n", table_lp->nattrs - table_lp->nattrs_only1 - table_lp->nattrs_only2, table_lp->nattrs_only1, table_lp->nattrs_only2 );
- }
+ if (opts->mode_verbose_level >= 1)
+ parallel_print("Attributes status: %zu common, %zu only in obj1, %zu only in obj2\n",
+ table_lp->nattrs - table_lp->nattrs_only1 - table_lp->nattrs_only2,
+ table_lp->nattrs_only1, table_lp->nattrs_only2);
+done:
*table_out = table_lp;
- return 0;
+ /* disable error reporting */
+ H5E_BEGIN_TRY
+ {
+ H5Aclose(attr1_id);
+ H5Aclose(attr2_id);
+ }
+ H5E_END_TRY;
+
+ H5TOOLS_ENDDEBUG(" - errstat:%d", opts->err_stat);
-error:
- return -1;
+ return ret_value;
}
/*-------------------------------------------------------------------------
- * Function: diff_attr
- *
- * Purpose: compare attributes located in LOC1_ID and LOC2_ID, which are
- * obtained either from
- * loc_id = H5Gopen2(fid, name, H5P_DEFAULT);
- * loc_id = H5Dopen2(fid, name);
- * loc_id = H5Topen2(fid, name, H5P_DEFAULT);
- *
- * Return: number of differences found
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ * Function: diff_attr_data
*
- * Date: November, 03, 2003
- *
- * Modifications:
- * March, 02, 2007: return the number of differences found
+ * Purpose: compare attribute data located in attr1_id and attr2_id, which are
+ * obtained from open attributes
*
+ * Return: number of differences found
*-------------------------------------------------------------------------
*/
-hsize_t diff_attr(hid_t loc1_id,
- hid_t loc2_id,
- const char *path1,
- const char *path2,
- diff_opt_t *options)
+hsize_t
+diff_attr_data(hid_t attr1_id, hid_t attr2_id, const char *name1, const char *name2, const char *path1,
+ const char *path2, diff_opt_t *opts)
{
- hid_t attr1_id=-1; /* attr ID */
- hid_t attr2_id=-1; /* attr ID */
- hid_t space1_id=-1; /* space ID */
- hid_t space2_id=-1; /* space ID */
- hid_t ftype1_id=-1; /* file data type ID */
- hid_t ftype2_id=-1; /* file data type ID */
- hid_t mtype1_id=-1; /* memory data type ID */
- hid_t mtype2_id=-1; /* memory data type ID */
- size_t msize1; /* memory size of memory type */
- size_t msize2; /* memory size of memory type */
- void *buf1=NULL; /* data buffer */
- void *buf2=NULL; /* data buffer */
- hsize_t nelmts1; /* number of elements in dataset */
- int rank1; /* rank of dataset */
- int rank2; /* rank of dataset */
- hsize_t dims1[H5S_MAX_RANK];/* dimensions of dataset */
- hsize_t dims2[H5S_MAX_RANK];/* dimensions of dataset */
- char *name1;
- char *name2;
- char np1[512];
- char np2[512];
- unsigned u; /* Local index variable */
+ hid_t space1_id = H5I_INVALID_HID; /* space ID */
+ hid_t space2_id = H5I_INVALID_HID; /* space ID */
+ hid_t ftype1_id = H5I_INVALID_HID; /* file data type ID */
+ hid_t ftype2_id = H5I_INVALID_HID; /* file data type ID */
+ hid_t mtype1_id = H5I_INVALID_HID; /* memory data type ID */
+ hid_t mtype2_id = H5I_INVALID_HID; /* memory data type ID */
+ size_t msize1; /* memory size of memory type */
+ size_t msize2; /* memory size of memory type */
+ void *buf1 = NULL; /* data buffer */
+ void *buf2 = NULL; /* data buffer */
+ hbool_t buf1hasdata = FALSE; /* buffer has data */
+ hbool_t buf2hasdata = FALSE; /* buffer has data */
+ int rank1; /* rank of dataset */
+ int rank2; /* rank of dataset */
+ hsize_t dims1[H5S_MAX_RANK]; /* dimensions of dataset */
+ hsize_t dims2[H5S_MAX_RANK]; /* dimensions of dataset */
hsize_t nfound = 0;
- hsize_t nfound_total = 0;
- int j;
+ size_t sz;
+ diff_err_t ret_value = opts->err_stat;
+
+ H5TOOLS_START_DEBUG(" - errstat:%d", opts->err_stat);
+ /* get the datatypes */
+ if ((ftype1_id = H5Aget_type(attr1_id)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_type first attribute failed");
+ if ((ftype2_id = H5Aget_type(attr2_id)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_type second attribute failed");
+
+ if (H5Tget_class(ftype1_id) == H5T_REFERENCE) {
+ if ((mtype1_id = H5Tcopy(H5T_STD_REF)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tcopy(H5T_STD_REF) first attribute ftype failed");
+ }
+ else {
+ if ((mtype1_id = H5Tget_native_type(ftype1_id, H5T_DIR_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tget_native_type first attribute ftype failed");
+ }
+ if (H5Tget_class(ftype2_id) == H5T_REFERENCE) {
+ if ((mtype2_id = H5Tcopy(H5T_STD_REF)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tcopy(H5T_STD_REF) second attribute ftype failed");
+ }
+ else {
+ if ((mtype2_id = H5Tget_native_type(ftype2_id, H5T_DIR_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tget_native_type second attribute ftype failed");
+ }
+ if ((msize1 = H5Tget_size(mtype1_id)) == 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tget_size first attribute mtype failed");
+ if ((msize2 = H5Tget_size(mtype2_id)) == 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tget_size second attribute mtype failed");
+
+ /* get the dataspace */
+ if ((space1_id = H5Aget_space(attr1_id)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_space first attribute failed");
+ if ((space2_id = H5Aget_space(attr2_id)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_space second attribute failed");
+
+ /* get dimensions */
+ if ((rank1 = H5Sget_simple_extent_dims(space1_id, dims1, NULL)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sget_simple_extent_dims first attribute failed");
+ if ((rank2 = H5Sget_simple_extent_dims(space2_id, dims2, NULL)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sget_simple_extent_dims second attribute failed");
+
+ /*----------------------------------------------------------------------
+ * check for comparable TYPE and SPACE
+ *----------------------------------------------------------------------
+ */
+ H5TOOLS_DEBUG("Check for comparable TYPE and SPACE");
+
+ H5TOOLS_DEBUG("attr_names: %s - %s", name1, name2);
+ if (name1) {
+ sz = HDstrlen(name1);
+ H5TOOLS_DEBUG("attr1_name: %s - %d", name1, sz);
+ if (sz > 0) {
+ opts->obj_name[0] = (char *)HDmalloc(sz + 1);
+ HDstrncpy(opts->obj_name[0], name1, sz + 1);
+ }
+ }
+ if (name2) {
+ sz = HDstrlen(name2);
+ H5TOOLS_DEBUG("attr2_name: %s - %d", name2, sz);
+ if (sz > 0) {
+ opts->obj_name[1] = (char *)HDmalloc(sz + 1);
+ HDstrncpy(opts->obj_name[1], name2, sz + 1);
+ }
+ }
+ H5TOOLS_DEBUG("attr_names: %s - %s", opts->obj_name[0], opts->obj_name[1]);
- table_attrs_t * match_list_attrs = NULL;
- if( build_match_list_attrs(loc1_id, loc2_id, &match_list_attrs, options) < 0)
- goto error;
+ /* pass dims1 and dims2 for maxdims as well since attribute's maxdims
+ * are always same */
+ if (diff_can_type(ftype1_id, ftype2_id, rank1, rank2, dims1, dims2, dims1, dims2, opts, 0) == 1) {
- for(u = 0; u < (unsigned)match_list_attrs->nattrs; u++)
- {
- if( (match_list_attrs->attrs[u].exist[0]) && (match_list_attrs->attrs[u].exist[1]) )
- {
- name1 = name2 = match_list_attrs->attrs[u].name;
-
- /*--------------
- * attribute 1 */
- if((attr1_id = H5Aopen(loc1_id, name1, H5P_DEFAULT)) < 0)
- goto error;
-
- /*--------------
- * attribute 2 */
- if((attr2_id = H5Aopen(loc2_id, name2, H5P_DEFAULT)) < 0)
- goto error;
-
- /* get the datatypes */
- if((ftype1_id = H5Aget_type(attr1_id)) < 0)
- goto error;
- if((ftype2_id = H5Aget_type(attr2_id)) < 0)
- goto error;
- if((mtype1_id = h5tools_get_native_type(ftype1_id))<0)
- goto error;
- if((mtype2_id = h5tools_get_native_type(ftype2_id))<0)
- goto error;
- if((msize1 = H5Tget_size(mtype1_id))==0)
- goto error;
- if((msize2 = H5Tget_size(mtype2_id))==0)
- goto error;
-
- /* get the dataspace */
- if((space1_id = H5Aget_space(attr1_id)) < 0)
- goto error;
- if((space2_id = H5Aget_space(attr2_id)) < 0)
- goto error;
-
- /* get dimensions */
- if((rank1 = H5Sget_simple_extent_dims(space1_id, dims1, NULL)) < 0)
- goto error;
- if((rank2 = H5Sget_simple_extent_dims(space2_id, dims2, NULL)) < 0)
- goto error;
-
-
- /*----------------------------------------------------------------------
- * check for comparable TYPE and SPACE
- *----------------------------------------------------------------------
- */
-
- /* pass dims1 and dims2 for maxdims as well since attribute's maxdims
- * are always same */
- if( diff_can_type(ftype1_id, ftype2_id, rank1, rank2, dims1, dims2,
- dims1, dims2, name1, name2, options, 0) != 1 )
- {
- if(H5Tclose(ftype1_id) < 0)
- goto error;
- if(H5Tclose(ftype2_id) < 0)
- goto error;
- if(H5Sclose(space1_id) < 0)
- goto error;
- if(H5Sclose(space2_id) < 0)
- goto error;
- if(H5Aclose(attr1_id) < 0)
- goto error;
- if(H5Aclose(attr2_id) < 0)
- goto error;
- if(H5Tclose(mtype1_id) < 0)
- goto error;
- if(H5Tclose(mtype2_id) < 0)
- goto error;
-
- continue;
- }
+ int j;
+ /*-----------------------------------------------------------------
+ * "upgrade" the smaller memory size
+ *------------------------------------------------------------------
+ */
+ if (FAIL == match_up_memsize(ftype1_id, ftype2_id, &mtype1_id, &mtype2_id, &msize1, &msize2))
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "match_up_memsize failed");
+ H5TOOLS_DEBUG("initialize read");
/*---------------------------------------------------------------------
- * read
- *----------------------------------------------------------------------
- */
- nelmts1 = 1;
- for(j = 0; j < rank1; j++)
- nelmts1 *= dims1[j];
-
- buf1 = (void *)HDmalloc((unsigned)(nelmts1 * msize1));
- buf2 = (void *)HDmalloc((unsigned)(nelmts1 * msize2));
- if(buf1 == NULL || buf2 == NULL) {
- parallel_print( "cannot read into memory\n" );
- goto error;
+ * initialize diff_opt_t structure for dimensions
+ *----------------------------------------------------------------------
+ */
+ opts->nelmts = 1;
+ for (j = 0; j < rank1; j++) {
+ opts->dims[j] = dims1[j];
+ opts->nelmts *= dims1[j];
}
- if(H5Aread(attr1_id,mtype1_id,buf1) < 0)
- goto error;
- if(H5Aread(attr2_id,mtype2_id,buf2) < 0)
- goto error;
+ opts->rank = rank1;
+ init_acc_pos((unsigned)opts->rank, opts->dims, opts->acc, opts->pos, opts->p_min_idx);
+
+ /*---------------------------------------------------------------------
+ * read
+ *----------------------------------------------------------------------
+ */
+ buf1 = (void *)HDcalloc((size_t)(opts->nelmts), msize1);
+ buf2 = (void *)HDcalloc((size_t)(opts->nelmts), msize2);
+ H5TOOLS_DEBUG("attr buffer size %ld * %ld", opts->nelmts, msize1);
+ if (buf1 == NULL || buf2 == NULL) {
+ parallel_print("cannot read into memory\n");
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "buffer allocation failed");
+ }
+ if (H5Aread(attr1_id, mtype1_id, buf1) < 0) {
+ parallel_print("Failed reading attribute1 %s\n", name1);
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_type first attribute failed");
+ }
+ else
+ buf1hasdata = TRUE;
+ H5TOOLS_DEBUG("attr H5Aread 1");
+
+ if (H5Aread(attr2_id, mtype2_id, buf2) < 0) {
+ parallel_print("Failed reading attribute2 %s\n", name2);
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_type second attribute failed");
+ }
+ else
+ buf2hasdata = TRUE;
+ H5TOOLS_DEBUG("attr H5Aread 2");
/* format output string */
- sprintf(np1,"%s of <%s>",name1,path1);
- sprintf(np2,"%s of <%s>",name2,path2);
+ if (opts->obj_name[0] != NULL)
+ HDfree(opts->obj_name[0]);
+ opts->obj_name[0] = NULL;
+ if (opts->obj_name[1] != NULL)
+ HDfree(opts->obj_name[1]);
+ opts->obj_name[1] = NULL;
+
+ H5TOOLS_DEBUG("attr_names: %s - %s : %s - %s", name1, name2, path1, path2);
+ if (name1) {
+ sz = HDstrlen(name1) + HDstrlen(path1) + 7;
+ H5TOOLS_DEBUG("attr1_name: %s - %d", name1, sz);
+ opts->obj_name[0] = (char *)HDcalloc(sz + 1, sizeof(char));
+ HDsnprintf(opts->obj_name[0], sz, "%s of <%s>", name1, path1);
+ opts->obj_name[0][sz] = '\0';
+ }
+ if (name2) {
+ sz = HDstrlen(name2) + HDstrlen(path2) + 7;
+ H5TOOLS_DEBUG("attr2_name: %s - %d", name2, sz);
+ opts->obj_name[1] = (char *)HDcalloc(sz + 1, sizeof(char));
+ HDsnprintf(opts->obj_name[1], sz, "%s of <%s>", name2, path2);
+ opts->obj_name[1][sz] = '\0';
+ }
/*---------------------------------------------------------------------
- * array compare
- *----------------------------------------------------------------------
- */
+ * array compare
+ *----------------------------------------------------------------------
+ */
+ H5TOOLS_DEBUG("array compare %s - %s", opts->obj_name[0], opts->obj_name[1]);
+
+ opts->hs_nelmts = opts->nelmts;
+ opts->m_tid = mtype1_id;
+
+ /* initialize the current stripmine position; this is necessary to print the array indices */
+ for (j = 0; j < opts->rank; j++)
+ opts->sm_pos[j] = (hsize_t)0;
/* always print name */
/* verbose (-v) and report (-r) mode */
- if(options->m_verbose || options->m_report) {
- do_print_attrname("attribute", np1, np2);
+ if (opts->mode_verbose || opts->mode_report) {
+ do_print_attrname("attribute", opts->obj_name[0], opts->obj_name[1]);
- nfound = diff_array(buf1, buf2, nelmts1, (hsize_t)0, rank1, dims1,
- options, np1, np2, mtype1_id, attr1_id, attr2_id);
+ nfound = diff_array(buf1, buf2, opts, attr1_id, attr2_id);
print_found(nfound);
}
/* quiet mode (-q), just count differences */
- else if(options->m_quiet) {
- nfound = diff_array(buf1, buf2, nelmts1, (hsize_t)0, rank1, dims1,
- options, np1, np2, mtype1_id, attr1_id, attr2_id);
+ else if (opts->mode_quiet) {
+ nfound = diff_array(buf1, buf2, opts, attr1_id, attr2_id);
}
/* the rest (-c, none, ...) */
else {
- nfound = diff_array(buf1, buf2, nelmts1, (hsize_t)0, rank1, dims1,
- options, np1, np2, mtype1_id, attr1_id, attr2_id);
-
- /* print info if compatible and difference found */
- if(nfound) {
- do_print_attrname("attribute", np1, np2);
- print_found(nfound);
- } /* end if */
- } /* end else */
-
-
- /*----------------------------------------------------------------------
- * close
- *----------------------------------------------------------------------
- */
-
- /* Free buf1 and buf2, check both VLEN-data VLEN-string to reclaim any
- * VLEN memory first */
- if(TRUE == h5tools_detect_vlen(mtype1_id))
- H5Dvlen_reclaim(mtype1_id, space1_id, H5P_DEFAULT, buf1);
- HDfree(buf1);
-
- buf1 = NULL;
- if(TRUE == h5tools_detect_vlen(mtype2_id))
- H5Dvlen_reclaim(mtype2_id, space2_id, H5P_DEFAULT, buf2);
- HDfree(buf2);
- buf2 = NULL;
-
- if(H5Tclose(ftype1_id) < 0)
- goto error;
- if(H5Tclose(ftype2_id) < 0)
- goto error;
- if(H5Sclose(space1_id) < 0)
- goto error;
- if(H5Sclose(space2_id) < 0)
- goto error;
- if(H5Aclose(attr1_id) < 0)
- goto error;
- if(H5Aclose(attr2_id) < 0)
- goto error;
- if(H5Tclose(mtype1_id) < 0)
- goto error;
- if(H5Tclose(mtype2_id) < 0)
- goto error;
-
- nfound_total += nfound;
- }
- } /* u */
-
- table_attrs_free(match_list_attrs);
-
- return nfound_total;
-
-error:
- H5E_BEGIN_TRY {
- if(buf1) {
- if(TRUE == h5tools_detect_vlen(mtype1_id))
- H5Dvlen_reclaim(mtype1_id, space1_id, H5P_DEFAULT, buf1);
+ nfound = diff_array(buf1, buf2, opts, attr1_id, attr2_id);
+
+ /* print info if compatible and difference found */
+ if (nfound) {
+ do_print_attrname("attribute", opts->obj_name[0], opts->obj_name[1]);
+ print_found(nfound);
+ } /* end if */
+ } /* end else */
+ }
+ H5TOOLS_DEBUG("check for comparable TYPE and SPACE complete nfound:%d - errstat:%d", nfound,
+ opts->err_stat);
+
+ /*----------------------------------------------------------------------
+ * close
+ *----------------------------------------------------------------------
+ */
+ if (opts->obj_name[0] != NULL)
+ HDfree(opts->obj_name[0]);
+ opts->obj_name[0] = NULL;
+ if (opts->obj_name[1] != NULL)
+ HDfree(opts->obj_name[1]);
+ opts->obj_name[1] = NULL;
+
+ /* Free buf1 and buf2, check both VLEN-data VLEN-string to reclaim any
+ * VLEN memory first */
+ if (TRUE == h5tools_detect_vlen(mtype1_id))
+ H5Treclaim(mtype1_id, space1_id, H5P_DEFAULT, buf1);
+ HDfree(buf1);
+ buf1 = NULL;
+
+ if (TRUE == h5tools_detect_vlen(mtype2_id))
+ H5Treclaim(mtype2_id, space2_id, H5P_DEFAULT, buf2);
+ HDfree(buf2);
+ buf2 = NULL;
+
+ if (H5Tclose(ftype1_id) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_type first attribute failed");
+ if (H5Tclose(ftype2_id) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_type second attribute failed");
+ if (H5Sclose(space1_id) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_type first attribute failed");
+ if (H5Sclose(space2_id) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_type second attribute failed");
+ if (H5Tclose(mtype1_id) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tclose first attribute mtype failed");
+ if (H5Tclose(mtype2_id) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tclose second attribute mtype failed");
+
+done:
+ opts->err_stat = opts->err_stat | ret_value;
+
+ H5E_BEGIN_TRY
+ {
+ if (buf1) {
+ if (buf1hasdata && TRUE == h5tools_detect_vlen(mtype1_id))
+ H5Treclaim(mtype1_id, space1_id, H5P_DEFAULT, buf1);
HDfree(buf1);
} /* end if */
- if(buf2) {
- if(TRUE == h5tools_detect_vlen(mtype2_id))
- H5Dvlen_reclaim(mtype2_id, space2_id, H5P_DEFAULT, buf2);
+ if (buf2) {
+ if (buf2hasdata && TRUE == h5tools_detect_vlen(mtype2_id))
+ H5Treclaim(mtype2_id, space2_id, H5P_DEFAULT, buf2);
HDfree(buf2);
} /* end if */
- table_attrs_free(match_list_attrs);
-
H5Tclose(ftype1_id);
H5Tclose(ftype2_id);
H5Tclose(mtype1_id);
H5Tclose(mtype2_id);
H5Sclose(space1_id);
H5Sclose(space2_id);
+ }
+ H5E_END_TRY;
+
+ H5TOOLS_ENDDEBUG(" - errstat:%d", opts->err_stat);
+
+ return nfound;
+}
+
+/*-------------------------------------------------------------------------
+ * Function: diff_attr
+ *
+ * Purpose: compare attributes located in LOC1_ID and LOC2_ID, which are
+ * obtained either from
+ * loc_id = H5Gopen2(fid, name, H5P_DEFAULT);
+ * loc_id = H5Dopen2(fid, name);
+ * loc_id = H5Topen2(fid, name, H5P_DEFAULT);
+ *
+ * Return: number of differences found
+ *-------------------------------------------------------------------------
+ */
+
+hsize_t
+diff_attr(hid_t loc1_id, hid_t loc2_id, const char *path1, const char *path2, diff_opt_t *opts)
+{
+ table_attrs_t *match_list_attrs = NULL;
+ hid_t attr1_id = H5I_INVALID_HID; /* attr ID */
+ hid_t attr2_id = H5I_INVALID_HID; /* attr ID */
+ char *name1 = NULL;
+ char *name2 = NULL;
+ unsigned u; /* Local index variable */
+ hsize_t nfound = 0;
+ hsize_t nfound_total = 0;
+ diff_opt_t attr_opts;
+ diff_err_t ret_value = opts->err_stat;
+
+ H5TOOLS_START_DEBUG(" - errstat:%d", opts->err_stat);
+ attr_opts = *opts;
+ attr_opts.obj_name[0] = NULL;
+ attr_opts.obj_name[1] = NULL;
+
+ if (build_match_list_attrs(loc1_id, loc2_id, &match_list_attrs, &attr_opts) < 0) {
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "build_match_list_attrs failed");
+ }
+ H5TOOLS_DEBUG("check match_list_attrs - opts->contents:%d - errstat:%d", attr_opts.contents,
+ attr_opts.err_stat);
+
+ /* if detect any unique extra attr */
+ if (match_list_attrs->nattrs_only1 || match_list_attrs->nattrs_only2) {
+ H5TOOLS_DEBUG("attributes only in one file");
+ /* exit will be 1 */
+ attr_opts.contents = 0;
+ }
+ H5TOOLS_DEBUG("match_list_attrs info - opts->contents:%d", attr_opts.contents);
+
+ for (u = 0; u < (unsigned)match_list_attrs->nattrs; u++) {
+ H5TOOLS_DEBUG("match_list_attrs loop[%d] - errstat:%d", u, attr_opts.err_stat);
+ if ((match_list_attrs->attrs[u].exist[0]) && (match_list_attrs->attrs[u].exist[1])) {
+ name1 = name2 = match_list_attrs->attrs[u].name;
+ H5TOOLS_DEBUG("name - %s", name1);
+
+ /*--------------
+ * attribute 1 */
+ if ((attr1_id = H5Aopen(loc1_id, name1, H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aopen first attribute failed");
+
+ /*--------------
+ * attribute 2 */
+ if ((attr2_id = H5Aopen(loc2_id, name2, H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aopen second attribute failed");
+
+ H5TOOLS_DEBUG("got attributes");
+ nfound = diff_attr_data(attr1_id, attr2_id, name1, name2, path1, path2, &attr_opts);
+ if (H5Aclose(attr1_id) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_type first attribute failed");
+ if (H5Aclose(attr2_id) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_type second attribute failed");
+
+ nfound_total += nfound;
+ }
+ } /* u */
+
+done:
+ opts->print_header = attr_opts.print_header;
+ opts->contents = attr_opts.contents;
+ opts->not_cmp = attr_opts.not_cmp;
+ opts->err_stat = attr_opts.err_stat | ret_value;
+
+ H5E_BEGIN_TRY
+ {
+ table_attrs_free(match_list_attrs);
+
H5Aclose(attr1_id);
H5Aclose(attr2_id);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
- options->err_stat = 1;
+ H5TOOLS_ENDDEBUG(" - errstat:%d", opts->err_stat);
return nfound_total;
}
-
diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c
index c1ed429..b5c3290 100644
--- a/tools/lib/h5diff_dset.c
+++ b/tools/lib/h5diff_dset.c
@@ -1,17 +1,14 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-* 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 files COPYING and Copyright.html. COPYING can be found at the root *
-* of the source code distribution tree; Copyright.html can be found at the *
-* root level of an installed copy of the electronic HDF5 document set and *
-* is linked from the top-level documents page. It can also be found at *
-* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
-* access to either file, you may request a copy from help@hdfgroup.org. *
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+ * 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. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "H5private.h"
#include "h5tools.h"
@@ -19,957 +16,1214 @@
#include "h5diff.h"
#include "ph5diff.h"
-
/*-------------------------------------------------------------------------
-* Function: diff_dataset
-*
-* Purpose: check for comparable datasets and read into a compatible
-* memory type
-*
-* Return: Number of differences found
-*
-* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
-*
-* Date: May 9, 2003
-*
-*-------------------------------------------------------------------------
-*/
-hsize_t diff_dataset( hid_t file1_id,
- hid_t file2_id,
- const char *obj1_name,
- const char *obj2_name,
- diff_opt_t *options)
+ * Function: diff_dataset
+ *
+ * Purpose: check for comparable datasets and read into a compatible
+ * memory type
+ *
+ * Return: Number of differences found
+ *-------------------------------------------------------------------------
+ */
+hsize_t
+diff_dataset(hid_t file1_id, hid_t file2_id, const char *obj1_name, const char *obj2_name, diff_opt_t *opts)
{
- hid_t did1 = -1;
- hid_t did2 = -1;
- hid_t dcpl1 = -1;
- hid_t dcpl2 = -1;
- hsize_t nfound = 0;
-
+ int status = -1;
+ hid_t did1 = H5I_INVALID_HID;
+ hid_t did2 = H5I_INVALID_HID;
+ hid_t dcpl1 = H5I_INVALID_HID;
+ hid_t dcpl2 = H5I_INVALID_HID;
+ hsize_t nfound = 0;
+ diff_opt_t diff_opts;
+ diff_err_t ret_value = opts->err_stat;
+
+ H5TOOLS_START_DEBUG(" - errstat:%d", opts->err_stat);
+ diff_opts = *opts;
+ diff_opts.obj_name[0] = NULL;
+ diff_opts.obj_name[1] = NULL;
+
+ H5TOOLS_DEBUG("obj_names: %s - %s", obj1_name, obj2_name);
/*-------------------------------------------------------------------------
- * open the handles
- *-------------------------------------------------------------------------
- */
- /* disable error reporting */
- H5E_BEGIN_TRY
- {
- /* Open the datasets */
- if((did1 = H5Dopen2(file1_id, obj1_name, H5P_DEFAULT)) < 0)
- {
- parallel_print("Cannot open dataset <%s>\n", obj1_name);
- goto error;
- }
- if((did2 = H5Dopen2(file2_id, obj2_name, H5P_DEFAULT)) < 0)
- {
- parallel_print("Cannot open dataset <%s>\n", obj2_name);
- goto error;
- }
- /* enable error reporting */
- } H5E_END_TRY;
-
-
- if((dcpl1 = H5Dget_create_plist(did1)) < 0)
- goto error;
- if((dcpl2 = H5Dget_create_plist(did2)) < 0)
- {
- goto error;
+ * open the handles
+ *-------------------------------------------------------------------------
+ */
+ /* Open the datasets */
+ if ((did1 = H5Dopen2(file1_id, obj1_name, H5P_DEFAULT)) < 0) {
+ parallel_print("Cannot open dataset <%s>\n", obj1_name);
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dopen2 first dataset failed");
+ }
+ if ((did2 = H5Dopen2(file2_id, obj2_name, H5P_DEFAULT)) < 0) {
+ parallel_print("Cannot open dataset <%s>\n", obj2_name);
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dopen2 second dataset failed");
}
+ if ((dcpl1 = H5Dget_create_plist(did1)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dget_create_plist first dataset failed");
+ if ((dcpl2 = H5Dget_create_plist(did2)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dget_create_plist second dataset 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
- *-------------------------------------------------------------------------
- */
- if ((h5tools_canreadf((options->m_verbose?obj1_name:NULL),dcpl1)==1) &&
- (h5tools_canreadf((options->m_verbose?obj2_name:NULL),dcpl2)==1))
- {
- nfound=diff_datasetid(did1,
- did2,
- obj1_name,
- obj2_name,
- options);
+ * 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
+ *-------------------------------------------------------------------------
+ */
+ H5TOOLS_DEBUG("h5tools_canreadf then diff_datasetid");
+ if ((status = h5tools_canreadf((opts->mode_verbose ? obj1_name : NULL), dcpl1) == 1) &&
+ (status = h5tools_canreadf((opts->mode_verbose ? obj2_name : NULL), dcpl2) == 1))
+ nfound = diff_datasetid(did1, did2, obj1_name, obj2_name, &diff_opts);
+ else if (status < 0) {
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "h5tools_canreadf failed");
+ }
+ else {
+ ret_value = 1;
+ diff_opts.not_cmp = 1;
}
- /*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
- /* disable error reporting */
- H5E_BEGIN_TRY {
- H5Pclose(dcpl1);
- H5Pclose(dcpl2);
- H5Dclose(did1);
- H5Dclose(did2);
- /* enable error reporting */
- } H5E_END_TRY;
+done:
+ opts->print_header = diff_opts.print_header;
+ opts->not_cmp = diff_opts.not_cmp;
+ opts->err_stat = diff_opts.err_stat | ret_value;
- return nfound;
-
-error:
- options->err_stat=1;
/* disable error reporting */
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Pclose(dcpl1);
H5Pclose(dcpl2);
H5Dclose(did1);
H5Dclose(did2);
/* enable error reporting */
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
+ H5TOOLS_ENDDEBUG(":%d - errstat:%d", nfound, opts->err_stat);
return nfound;
}
/*-------------------------------------------------------------------------
-* Function: diff_datasetid
-*
-* Purpose: check for comparable datasets and read into a compatible
-* memory type
-*
-* Return: Number of differences found
-*
-* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
-*
-* Date: May 9, 2003
-*
-* Modifications:
-*
-*
-* October 2006: Read by hyperslabs for big datasets.
-*
-* A threshold of H5TOOLS_MALLOCSIZE (128 MB) is the limit upon which I/O hyperslab is done
-* i.e., if the memory needed to read a dataset is greater than this limit,
-* then hyperslab I/O is done instead of one operation I/O
-* For each dataset, the memory needed is calculated according to
-*
-* memory needed = number of elements * size of each element
-*
-* if the memory needed is lower than H5TOOLS_MALLOCSIZE, then the following operations
-* are done
-*
-* H5Dread( input_dataset1 )
-* H5Dread( input_dataset2 )
-*
-* with all elements in the datasets selected. If the memory needed is greater than
-* H5TOOLS_MALLOCSIZE, then the following operations are done instead:
-*
-* a strip mine is defined for each dimension k (a strip mine is defined as a
-* hyperslab whose size is memory manageable) according to the formula
-*
-* (1) strip_mine_size[k ] = MIN(dimension[k ], H5TOOLS_BUFSIZE / size of memory type)
-*
-* where H5TOOLS_BUFSIZE is a constant currently defined as 1MB. This formula assures
-* that for small datasets (small relative to the H5TOOLS_BUFSIZE constant), the strip
-* mine size k is simply defined as its dimension k, but for larger datasets the
-* hyperslab size is still memory manageable.
-* a cycle is done until the number of elements in the dataset is reached. In each
-* iteration, two parameters are defined for the function H5Sselect_hyperslab,
-* the start and size of each hyperslab, according to
-*
-* (2) hyperslab_size [k] = MIN(dimension[k] - hyperslab_offset[k], strip_mine_size [k])
-*
-* where hyperslab_offset [k] is initially set to zero, and later incremented in
-* hyperslab_size[k] offsets. The reason for the operation
-*
-* dimension[k] - hyperslab_offset[k]
-*
-* 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.
-*
-*-------------------------------------------------------------------------
-*/
-hsize_t diff_datasetid( hid_t did1,
- hid_t did2,
- const char *obj1_name,
- const char *obj2_name,
- diff_opt_t *options)
+ * Function: diff_datasetid
+ *
+ * Purpose: check for comparable datasets and read into a compatible
+ * memory type
+ *
+ * Return: Number of differences found
+ *
+ * October 2006: Read by hyperslabs for big datasets.
+ *
+ * A threshold of H5TOOLS_MALLOCSIZE (128 MB) is the limit upon which I/O hyperslab is done
+ * i.e., if the memory needed to read a dataset is greater than this limit,
+ * then hyperslab I/O is done instead of one operation I/O
+ * For each dataset, the memory needed is calculated according to
+ *
+ * memory needed = number of elements * size of each element
+ *
+ * if the memory needed is lower than H5TOOLS_MALLOCSIZE, then the following operations
+ * are done
+ *
+ * H5Dread( input_dataset1 )
+ * H5Dread( input_dataset2 )
+ *
+ * with all elements in the datasets selected. If the memory needed is greater than
+ * H5TOOLS_MALLOCSIZE, then the following operations are done instead:
+ *
+ * a strip mine is defined for each dimension k (a strip mine is defined as a
+ * hyperslab whose size is memory manageable) according to the formula
+ *
+ * (1) strip_mine_size[k ] = MIN(dimension[k ], H5TOOLS_BUFSIZE / size of memory type)
+ *
+ * where H5TOOLS_BUFSIZE is a constant currently defined as 1MB. This formula assures
+ * that for small datasets (small relative to the H5TOOLS_BUFSIZE constant), the strip
+ * mine size k is simply defined as its dimension k, but for larger datasets the
+ * hyperslab size is still memory manageable.
+ * a cycle is done until the number of elements in the dataset is reached. In each
+ * iteration, two parameters are defined for the function H5Sselect_hyperslab,
+ * the start and size of each hyperslab, according to
+ *
+ * (2) hyperslab_size [k] = MIN(dimension[k] - hyperslab_offset[k], strip_mine_size [k])
+ *
+ * where hyperslab_offset [k] is initially set to zero, and later incremented in
+ * hyperslab_size[k] offsets. The reason for the operation
+ *
+ * dimension[k] - hyperslab_offset[k]
+ *
+ * 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.
+ *
+ *-------------------------------------------------------------------------
+ */
+hsize_t
+diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char *obj2_name, diff_opt_t *opts)
{
- hid_t sid1=-1;
- hid_t sid2=-1;
- hid_t f_tid1=-1;
- hid_t f_tid2=-1;
- hid_t m_tid1=-1;
- hid_t m_tid2=-1;
- size_t m_size1;
- size_t m_size2;
- H5T_sign_t sign1;
- H5T_sign_t sign2;
- int rank1;
- int rank2;
- hsize_t nelmts1;
- hsize_t nelmts2;
- hsize_t dims1[H5S_MAX_RANK];
- hsize_t dims2[H5S_MAX_RANK];
- hsize_t maxdim1[H5S_MAX_RANK];
- hsize_t maxdim2[H5S_MAX_RANK];
- const char *name1=NULL; /* relative names */
- const char *name2=NULL;
- hsize_t storage_size1;
- hsize_t storage_size2;
- hsize_t nfound=0; /* number of differences found */
- int can_compare=1; /* do diff or not */
- void *buf1=NULL;
- void *buf2=NULL;
- void *sm_buf1=NULL;
- void *sm_buf2=NULL;
- hid_t sm_space; /*stripmine data space */
- size_t need; /* bytes needed for malloc */
- int i;
- unsigned int vl_data = 0; /*contains VL datatypes */
-
+ hid_t sid1 = H5I_INVALID_HID;
+ hid_t sid2 = H5I_INVALID_HID;
+ hid_t f_tid1 = H5I_INVALID_HID;
+ hid_t f_tid2 = H5I_INVALID_HID;
+ hid_t m_tid1 = H5I_INVALID_HID;
+ hid_t m_tid2 = H5I_INVALID_HID;
+ hid_t dcpl1 = H5I_INVALID_HID;
+ hid_t dcpl2 = H5I_INVALID_HID;
+ H5D_layout_t stl1 = -1;
+ H5D_layout_t stl2 = -1;
+ size_t m_size1;
+ size_t m_size2;
+ H5T_sign_t sign1;
+ H5T_sign_t sign2;
+ int rank1;
+ int rank2;
+ hsize_t nelmts1;
+ hsize_t nelmts2;
+ hsize_t dims1[H5S_MAX_RANK];
+ hsize_t dims2[H5S_MAX_RANK];
+ hsize_t maxdim1[H5S_MAX_RANK];
+ hsize_t maxdim2[H5S_MAX_RANK];
+ hsize_t storage_size1;
+ hsize_t storage_size2;
+ hsize_t nfound = 0; /* number of differences found */
+ int can_compare = 1; /* do diff or not */
+ void *buf1 = NULL;
+ void *buf2 = NULL;
+ void *sm_buf1 = NULL;
+ void *sm_buf2 = NULL;
+ hid_t sm_space1 = H5I_INVALID_HID; /*stripmine data space */
+ hid_t sm_space2 = H5I_INVALID_HID; /*stripmine data space */
+ size_t need; /* bytes needed for malloc */
+ int i, j;
+ unsigned int vl_data1 = 0; /*contains VL datatypes */
+ unsigned int vl_data2 = 0; /*contains VL datatypes */
+ diff_err_t ret_value = opts->err_stat;
+
+ H5TOOLS_START_DEBUG(" - errstat:%d", opts->err_stat);
/* Get the dataspace handle */
- if ( (sid1 = H5Dget_space(did1)) < 0 )
- goto error;
+ if ((sid1 = H5Dget_space(did1)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dget_space failed");
/* Get rank */
- if ( (rank1 = H5Sget_simple_extent_ndims(sid1)) < 0 )
- goto error;
+ if ((rank1 = H5Sget_simple_extent_ndims(sid1)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sget_simple_extent_ndims failed");
/* Get the dataspace handle */
- if ( (sid2 = H5Dget_space(did2)) < 0 )
- goto error;
+ if ((sid2 = H5Dget_space(did2)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dget_space failed");
/* Get rank */
- if ( (rank2 = H5Sget_simple_extent_ndims(sid2)) < 0 )
- goto error;
+ if ((rank2 = H5Sget_simple_extent_ndims(sid2)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sget_simple_extent_ndims failed");
/* Get dimensions */
- if ( H5Sget_simple_extent_dims(sid1,dims1,maxdim1) < 0 )
- goto error;
+ if (H5Sget_simple_extent_dims(sid1, dims1, maxdim1) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sget_simple_extent_dims failed");
/* Get dimensions */
- if ( H5Sget_simple_extent_dims(sid2,dims2,maxdim2) < 0 )
- {
- goto error;
- }
+ if (H5Sget_simple_extent_dims(sid2, dims2, maxdim2) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sget_simple_extent_dims failed");
+ H5TOOLS_DEBUG("rank: %ld - %ld", rank1, rank2);
/*-------------------------------------------------------------------------
- * get the file data type
- *-------------------------------------------------------------------------
- */
+ * get the file data type
+ *-------------------------------------------------------------------------
+ */
/* Get the data type */
- if ( (f_tid1 = H5Dget_type(did1)) < 0 )
- goto error;
+ if ((f_tid1 = H5Dget_type(did1)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dget_type failed");
/* Get the data type */
- if ( (f_tid2 = H5Dget_type(did2)) < 0 )
- {
- goto error;
- }
+ if ((f_tid2 = H5Dget_type(did2)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dget_type failed");
/*-------------------------------------------------------------------------
- * check for empty datasets
- *-------------------------------------------------------------------------
- */
+ * get the storage layout type
+ *-------------------------------------------------------------------------
+ */
+ if ((dcpl1 = H5Dget_create_plist(did1)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dget_create_plist failed");
+ if ((stl1 = H5Pget_layout(dcpl1)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Pget_layout failed");
+ H5Pclose(dcpl1);
+
+ if ((dcpl2 = H5Dget_create_plist(did2)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dget_create_plist failed");
+ if ((stl2 = H5Pget_layout(dcpl2)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Pget_layout failed");
+ H5Pclose(dcpl2);
- storage_size1=H5Dget_storage_size(did1);
- storage_size2=H5Dget_storage_size(did2);
+ /*-------------------------------------------------------------------------
+ * check for empty datasets
+ *-------------------------------------------------------------------------
+ */
+ H5TOOLS_DEBUG("check for empty datasets");
- if (storage_size1==0 || storage_size2==0)
- {
- if ( (options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name)
- parallel_print("Not comparable: <%s> or <%s> is an empty dataset\n", obj1_name, obj2_name);
- can_compare=0;
- options->not_cmp=1;
+ storage_size1 = H5Dget_storage_size(did1);
+ storage_size2 = H5Dget_storage_size(did2);
+ H5TOOLS_DEBUG("storage size: %ld - %ld", storage_size1, storage_size2);
+
+ if (storage_size1 == 0 || storage_size2 == 0) {
+ if (stl1 == H5D_VIRTUAL || stl2 == H5D_VIRTUAL) {
+ if ((opts->mode_verbose || opts->mode_list_not_cmp) && obj1_name && obj2_name)
+ parallel_print("Warning: <%s> or <%s> is a virtual dataset\n", obj1_name, obj2_name);
+ }
+ else {
+ if ((opts->mode_verbose || opts->mode_list_not_cmp) && obj1_name && obj2_name)
+ parallel_print("Not comparable: <%s> or <%s> is an empty dataset\n", obj1_name, obj2_name);
+ can_compare = 0;
+ opts->not_cmp = 1;
+ }
}
- /*-------------------------------------------------------------------------
- * check for comparable TYPE and SPACE
- *-------------------------------------------------------------------------
- */
-
- if (diff_can_type(f_tid1,
- f_tid2,
- rank1,
- rank2,
- dims1,
- dims2,
- maxdim1,
- maxdim2,
- obj1_name,
- obj2_name,
- options,
- 0)!=1)
- {
- can_compare=0;
+ H5TOOLS_DEBUG("obj_names: %s - %s", obj1_name, obj2_name);
+ opts->obj_name[0] = NULL;
+ if (obj1_name) {
+ j = (int)HDstrlen(obj1_name);
+ H5TOOLS_DEBUG("obj1_name: %s - %d", obj1_name, j);
+ if (j > 0) {
+ opts->obj_name[0] = (char *)HDmalloc((size_t)j + 1);
+ HDstrncpy(opts->obj_name[0], obj1_name, (size_t)j + 1);
+ }
+ }
+
+ opts->obj_name[1] = NULL;
+ if (obj2_name) {
+ j = (int)HDstrlen(obj2_name);
+ H5TOOLS_DEBUG("obj2_name: %s - %d", obj2_name, j);
+ if (j > 0) {
+ opts->obj_name[1] = (char *)HDmalloc((size_t)j + 1);
+ HDstrncpy(opts->obj_name[1], obj2_name, (size_t)j + 1);
+ }
}
/*-------------------------------------------------------------------------
- * memory type and sizes
- *-------------------------------------------------------------------------
- */
- if ((m_tid1=h5tools_get_native_type(f_tid1)) < 0)
- goto error;
+ * check for comparable TYPE and SPACE
+ *-------------------------------------------------------------------------
+ */
+ if (diff_can_type(f_tid1, f_tid2, rank1, rank2, dims1, dims2, maxdim1, maxdim2, opts, 0) != 1)
+ can_compare = 0;
+ H5TOOLS_DEBUG("diff_can_type returned errstat:%d", opts->err_stat);
- if ((m_tid2=h5tools_get_native_type(f_tid2)) < 0)
- goto error;
+ /*-------------------------------------------------------------------------
+ * memory type and sizes
+ *-------------------------------------------------------------------------
+ */
+ H5TOOLS_DEBUG("check for memory type and sizes");
+ if (H5Tget_class(f_tid1) == H5T_REFERENCE) {
+ if ((m_tid1 = H5Tcopy(H5T_STD_REF)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tcopy(H5T_STD_REF) first ftype failed");
+ }
+ else {
+ if ((m_tid1 = H5Tget_native_type(f_tid1, H5T_DIR_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tget_native_type first ftype failed");
+ }
+
+ if (H5Tget_class(f_tid2) == H5T_REFERENCE) {
+ if ((m_tid2 = H5Tcopy(H5T_STD_REF)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tcopy(H5T_STD_REF) second ftype failed");
+ }
+ else {
+ if ((m_tid2 = H5Tget_native_type(f_tid2, H5T_DIR_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tget_native_type second ftype failed");
+ }
- m_size1 = H5Tget_size( m_tid1 );
- m_size2 = H5Tget_size( m_tid2 );
+ m_size1 = H5Tget_size(m_tid1);
+ m_size2 = H5Tget_size(m_tid2);
+ H5TOOLS_DEBUG("type size: %ld - %ld", m_size1, m_size2);
/*-------------------------------------------------------------------------
- * check for different signed/unsigned types
- *-------------------------------------------------------------------------
- */
- if (can_compare)
- {
- sign1=H5Tget_sign(m_tid1);
- sign2=H5Tget_sign(m_tid2);
- if ( sign1 != sign2 )
- {
- if ((options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name)
- {
+ * check for different signed/unsigned types
+ *-------------------------------------------------------------------------
+ */
+ if (can_compare) {
+ H5TOOLS_DEBUG("can_compare for sign");
+ sign1 = H5Tget_sign(m_tid1);
+ sign2 = H5Tget_sign(m_tid2);
+ if (sign1 != sign2) {
+ H5TOOLS_DEBUG("sign1 != sign2");
+ if ((opts->mode_verbose || opts->mode_list_not_cmp) && obj1_name && obj2_name) {
parallel_print("Not comparable: <%s> has sign %s ", obj1_name, get_sign(sign1));
parallel_print("and <%s> has sign %s\n", obj2_name, get_sign(sign2));
}
-
- can_compare=0;
- options->not_cmp=1;
+
+ can_compare = 0;
+ opts->not_cmp = 1;
}
+ H5TOOLS_DEBUG("can_compare for sign - can_compare=%d opts->not_cmp=%d", can_compare, opts->not_cmp);
}
/* Check if type is either VLEN-data or VLEN-string to reclaim any
- * VLEN memory buffer later */
- if( TRUE == h5tools_detect_vlen(m_tid1) )
- vl_data = TRUE;
+ * VLEN memory buffer later
+ */
+ if (TRUE == h5tools_detect_vlen(m_tid1))
+ vl_data1 = TRUE;
+ if (TRUE == h5tools_detect_vlen(m_tid2))
+ vl_data2 = TRUE;
+ H5TOOLS_DEBUG("h5tools_detect_vlen %d:%d - errstat:%d", vl_data1, vl_data2, opts->err_stat);
/*------------------------------------------------------------------------
- * only attempt to compare if possible
- *-------------------------------------------------------------------------
- */
- if(can_compare) /* it is possible to compare */
- {
+ * only attempt to compare if possible
+ *-------------------------------------------------------------------------
+ */
+ if (can_compare) { /* it is possible to compare */
+ H5T_class_t tclass = H5Tget_class(f_tid1);
+ H5TOOLS_DEBUG("can_compare attempt");
/*-----------------------------------------------------------------
- * get number of elements
- *------------------------------------------------------------------
- */
+ * get number of elements
+ *------------------------------------------------------------------
+ */
nelmts1 = 1;
- for(i = 0; i < rank1; i++)
+ for (i = 0; i < rank1; i++)
nelmts1 *= dims1[i];
nelmts2 = 1;
- for(i = 0; i < rank2; i++)
+ for (i = 0; i < rank2; i++)
nelmts2 *= dims2[i];
- HDassert(nelmts1 == nelmts2);
-
- /*-----------------------------------------------------------------
- * "upgrade" the smaller memory size
- *------------------------------------------------------------------
- */
+ H5TOOLS_DEBUG("nelmts: %ld - %ld", nelmts1, nelmts2);
- if(m_size1 != m_size2) {
- if(m_size1 < m_size2) {
- H5Tclose(m_tid1);
-
- if((m_tid1 = h5tools_get_native_type(f_tid2)) < 0)
- goto error;
-
- m_size1 = H5Tget_size(m_tid1);
- } /* end if */
+ if (tclass != H5T_ARRAY) {
+ /*-----------------------------------------------------------------
+ * "upgrade" the smaller memory size
+ *------------------------------------------------------------------
+ */
+ H5TOOLS_DEBUG("NOT H5T_ARRAY, upgrade the smaller memory size?");
+ if (FAIL == match_up_memsize(f_tid1, f_tid2, &m_tid1, &m_tid2, &m_size1, &m_size2))
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "match_up_memsize failed");
+ H5TOOLS_DEBUG("m_size: %ld - %ld", m_size1, m_size2);
+ opts->rank = rank1;
+ for (i = 0; i < rank1; i++)
+ opts->dims[i] = dims1[i];
+ opts->m_size = m_size1;
+ opts->m_tid = m_tid1;
+ opts->nelmts = nelmts1;
+ need = (size_t)(nelmts1 * m_size1); /* bytes needed */
+ }
+ else {
+ H5TOOLS_DEBUG("Array dims: %d - %d", dims1[0], dims2[0]);
+ /* Compare the smallest array, but create the largest buffer */
+ if (m_size1 <= m_size2) {
+ opts->rank = rank1;
+ for (i = 0; i < rank1; i++)
+ opts->dims[i] = dims1[i];
+ opts->m_size = m_size1;
+ opts->m_tid = m_tid1;
+ opts->nelmts = nelmts1;
+ need = (size_t)(nelmts2 * m_size2); /* bytes needed */
+ }
else {
- H5Tclose(m_tid2);
-
- if((m_tid2 = h5tools_get_native_type(f_tid1)) < 0)
- goto error;
-
- m_size2 = H5Tget_size(m_tid2);
- } /* end else */
- } /* end if */
- HDassert(m_size1 == m_size2);
-
+ opts->rank = rank2;
+ for (i = 0; i < rank2; i++)
+ opts->dims[i] = dims2[i];
+ opts->m_size = m_size2;
+ opts->m_tid = m_tid2;
+ opts->nelmts = nelmts2;
+ need = (size_t)(nelmts1 * m_size1); /* bytes needed */
+ }
+ }
+ opts->hs_nelmts = opts->nelmts;
+ H5TOOLS_DEBUG("need: %ld", need);
/* print names */
- if(obj1_name)
- name1 = diff_basename(obj1_name);
- if(obj2_name)
- name2 = diff_basename(obj2_name);
-
-
+ H5TOOLS_DEBUG("obj_names: %s - %s", obj1_name, obj2_name);
+
+ if (opts->obj_name[0] != NULL)
+ HDfree(opts->obj_name[0]);
+ opts->obj_name[0] = NULL;
+ if (opts->obj_name[1] != NULL)
+ HDfree(opts->obj_name[1]);
+ opts->obj_name[1] = NULL;
+
+ if (obj1_name)
+ opts->obj_name[0] = HDstrdup(diff_basename(obj1_name));
+ if (obj2_name)
+ opts->obj_name[1] = HDstrdup(diff_basename(obj2_name));
+ H5TOOLS_DEBUG("obj_names: %s - %s", opts->obj_name[0], opts->obj_name[1]);
+
+ H5TOOLS_DEBUG("read/compare");
/*----------------------------------------------------------------
- * read/compare
- *-----------------------------------------------------------------
- */
- need = (size_t)(nelmts1 * m_size1); /* bytes needed */
- if(need < H5TOOLS_MALLOCSIZE) {
+ * read/compare
+ *-----------------------------------------------------------------
+ */
+ if (need < H5TOOLS_MALLOCSIZE) {
buf1 = HDmalloc(need);
buf2 = HDmalloc(need);
} /* end if */
- if(buf1 != NULL && buf2 != NULL) {
- if(H5Dread(did1, m_tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1) < 0)
- goto error;
- if(H5Dread(did2, m_tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2) < 0)
- goto error;
+ /* Assume entire data space to be printed */
+ init_acc_pos((unsigned)opts->rank, opts->dims, opts->acc, opts->pos, opts->p_min_idx);
+
+ for (i = 0; i < opts->rank; i++) {
+ opts->p_max_idx[i] = opts->dims[i];
+ }
+
+ if (buf1 != NULL && buf2 != NULL && opts->sset[0] == NULL && opts->sset[1] == NULL) {
+ H5TOOLS_DEBUG("buf1 != NULL && buf2 != NULL");
+ H5TOOLS_DEBUG("H5Dread did1");
+ if (H5Dread(did1, m_tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dread failed");
+ H5TOOLS_DEBUG("H5Dread did2");
+ if (H5Dread(did2, m_tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dread failed");
+
+ /* initialize the current stripmine position; this is necessary to print the array indices */
+ for (j = 0; j < opts->rank; j++)
+ opts->sm_pos[j] = (hsize_t)0;
/* array diff */
- nfound = diff_array(buf1, buf2, nelmts1, (hsize_t)0, rank1, dims1,
- options, name1, name2, m_tid1, did1, did2);
+ nfound = diff_array(buf1, buf2, opts, did1, did2);
+ H5TOOLS_DEBUG("diff_array ret nfound:%d - errstat:%d", nfound, opts->err_stat);
/* reclaim any VL memory, if necessary */
- if(vl_data) {
- H5Dvlen_reclaim(m_tid1, sid1, H5P_DEFAULT, buf1);
- H5Dvlen_reclaim(m_tid2, sid2, H5P_DEFAULT, buf2);
- } /* end if */
- } /* end if */
- else /* possibly not enough memory, read/compare by hyperslabs */
- {
- size_t p_type_nbytes = m_size1; /*size of memory type */
- hsize_t p_nelmts = nelmts1; /*total selected elmts */
- hsize_t elmtno; /*counter */
- int carry; /*counter carry value */
+ H5TOOLS_DEBUG("check vl_data1:%d", vl_data1);
+ if (vl_data1)
+ H5Treclaim(m_tid1, sid1, H5P_DEFAULT, buf1);
+ H5TOOLS_DEBUG("check vl_data2:%d", vl_data2);
+ if (vl_data2)
+ H5Treclaim(m_tid2, sid2, H5P_DEFAULT, buf2);
+ if (buf1 != NULL) {
+ HDfree(buf1);
+ buf1 = NULL;
+ }
+ if (buf2 != NULL) {
+ HDfree(buf2);
+ buf2 = NULL;
+ }
+ } /* end if */
+ else { /* possibly not enough memory, read/compare by hyperslabs */
+ hsize_t elmtno; /* counter */
+ int carry; /* counter carry value */
/* stripmine info */
- hsize_t sm_size[H5S_MAX_RANK]; /*stripmine size */
- hsize_t sm_nbytes; /*bytes per stripmine */
- hsize_t sm_nelmts; /*elements per stripmine*/
+ hsize_t sm_size[H5S_MAX_RANK]; /* stripmine size */
+ hsize_t sm_block[H5S_MAX_RANK]; /* stripmine block size */
+ hsize_t sm_nbytes; /* bytes per stripmine */
+ hsize_t sm_nelmts1; /* elements per stripmine */
+ hsize_t sm_nelmts2; /* elements per stripmine */
+ hssize_t ssm_nelmts; /* elements temp */
/* hyperslab info */
- hsize_t hs_offset[H5S_MAX_RANK]; /*starting offset */
- hsize_t hs_size[H5S_MAX_RANK]; /*size this pass */
- hsize_t hs_nelmts; /*elements in request */
- hsize_t zero[8]; /*vector of zeros */
+ hsize_t hs_offset1[H5S_MAX_RANK]; /* starting offset */
+ hsize_t hs_count1[H5S_MAX_RANK]; /* number of blocks */
+ hsize_t hs_block1[H5S_MAX_RANK]; /* size of blocks */
+ hsize_t hs_stride1[H5S_MAX_RANK]; /* stride */
+ hsize_t hs_size1[H5S_MAX_RANK]; /* size this pass */
+ hsize_t hs_offset2[H5S_MAX_RANK]; /* starting offset */
+ hsize_t hs_count2[H5S_MAX_RANK]; /* number of blocks */
+ hsize_t hs_block2[H5S_MAX_RANK]; /* size of blocks */
+ hsize_t hs_stride2[H5S_MAX_RANK]; /* stride */
+ hsize_t hs_size2[H5S_MAX_RANK]; /* size this pass */
+ hsize_t hs_nelmts1 = 0; /* elements in request */
+ hsize_t hs_nelmts2 = 0; /* elements in request */
+ hsize_t zero[8]; /* vector of zeros */
+ hsize_t low[H5S_MAX_RANK]; /* low bound of hyperslab */
+ hsize_t high[H5S_MAX_RANK]; /* higher bound of hyperslab */
+
+ H5TOOLS_DEBUG("reclaim any VL memory and free unused buffers");
+ if (buf1 != NULL) {
+ /* reclaim any VL memory, if necessary */
+ if (vl_data1)
+ H5Treclaim(m_tid1, sid1, H5P_DEFAULT, buf1);
+ HDfree(buf1);
+ buf1 = NULL;
+ }
+ if (buf2 != NULL) {
+ /* reclaim any VL memory, if necessary */
+ if (vl_data2)
+ H5Treclaim(m_tid2, sid2, H5P_DEFAULT, buf2);
+ HDfree(buf2);
+ buf2 = NULL;
+ }
+
+ /* the stripmine loop */
+ HDmemset(hs_offset1, 0, sizeof hs_offset1);
+ HDmemset(hs_stride1, 0, sizeof hs_stride1);
+ HDmemset(hs_count1, 0, sizeof hs_count1);
+ HDmemset(hs_block1, 0, sizeof hs_block1);
+ HDmemset(hs_size1, 0, sizeof hs_size1);
+ HDmemset(hs_offset2, 0, sizeof hs_offset2);
+ HDmemset(hs_stride2, 0, sizeof hs_stride2);
+ HDmemset(hs_count2, 0, sizeof hs_count2);
+ HDmemset(hs_block2, 0, sizeof hs_block2);
+ HDmemset(hs_size2, 0, sizeof hs_size2);
+ HDmemset(zero, 0, sizeof zero);
+
+ /* if subsetting was requested - initialize the subsetting variables */
+ H5TOOLS_DEBUG("compare by hyperslabs: opts->nelmts=%ld - opts->m_size=%ld", opts->nelmts,
+ opts->m_size);
+ if (opts->sset[0] != NULL) {
+ H5TOOLS_DEBUG("opts->sset[0] != NULL");
+
+ /* Check for valid settings - default if not specified */
+ if (!opts->sset[0]->start.data || !opts->sset[0]->stride.data || !opts->sset[0]->count.data ||
+ !opts->sset[0]->block.data) {
+ /* they didn't specify a ``stride'' or ``block''. default to 1 in all
+ * dimensions */
+ if (!opts->sset[0]->start.data) {
+ /* default to (0, 0, ...) for the start coord */
+ opts->sset[0]->start.data = (hsize_t *)HDcalloc((size_t)rank1, sizeof(hsize_t));
+ opts->sset[0]->start.len = (unsigned)rank1;
+ }
+
+ if (!opts->sset[0]->stride.data) {
+ opts->sset[0]->stride.data = (hsize_t *)HDcalloc((size_t)rank1, sizeof(hsize_t));
+ opts->sset[0]->stride.len = (unsigned)rank1;
+ for (i = 0; i < rank1; i++)
+ opts->sset[0]->stride.data[i] = 1;
+ }
+
+ if (!opts->sset[0]->count.data) {
+ opts->sset[0]->count.data = (hsize_t *)HDcalloc((size_t)rank1, sizeof(hsize_t));
+ opts->sset[0]->count.len = (unsigned)rank1;
+ for (i = 0; i < rank1; i++)
+ opts->sset[0]->count.data[i] = 1;
+ }
+
+ if (!opts->sset[0]->block.data) {
+ opts->sset[0]->block.data = (hsize_t *)HDcalloc((size_t)rank1, sizeof(hsize_t));
+ opts->sset[0]->block.len = (unsigned)rank1;
+ for (i = 0; i < rank1; i++)
+ opts->sset[0]->block.data[i] = 1;
+ }
+
+ /*-------------------------------------------------------------------------
+ * check for block overlap
+ *-------------------------------------------------------------------------
+ */
+ for (i = 0; i < rank1; i++) {
+ if (opts->sset[0]->count.data[i] > 1) {
+ if (opts->sset[0]->stride.data[i] < opts->sset[0]->block.data[i]) {
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "wrong subset selection[0]; blocks overlap");
+ } /* end if */
+ } /* end if */
+ } /* end for */
+ }
+
+ /* Reset the total number of elements to the subset from the command */
+ opts->nelmts = 1;
+ for (i = 0; i < rank1; i++) {
+ hs_offset1[i] = opts->sset[0]->start.data[i];
+ hs_stride1[i] = opts->sset[0]->stride.data[i];
+ hs_count1[i] = opts->sset[0]->count.data[i];
+ hs_block1[i] = opts->sset[0]->block.data[i];
+ opts->nelmts *= hs_count1[i] * hs_block1[i];
+ hs_size1[i] = 0;
+ H5TOOLS_DEBUG("[%d]hs_offset1:%ld, hs_stride1:%ld, hs_count1:%ld, hs_block1:%ld", i,
+ hs_offset1[i], hs_stride1[i], hs_count1[i], hs_block1[i]);
+ }
+ }
+ if (opts->sset[1] != NULL) {
+ H5TOOLS_DEBUG("opts->sset[1] != NULL");
+
+ /* Check for valid settings - default if not specified */
+ if (!opts->sset[1]->start.data || !opts->sset[1]->stride.data || !opts->sset[1]->count.data ||
+ !opts->sset[1]->block.data) {
+ /* they didn't specify a ``stride'' or ``block''. default to 1 in all
+ * dimensions */
+ if (!opts->sset[1]->start.data) {
+ /* default to (0, 0, ...) for the start coord */
+ opts->sset[1]->start.data = (hsize_t *)HDcalloc((size_t)rank2, sizeof(hsize_t));
+ opts->sset[1]->start.len = (unsigned)rank2;
+ }
+
+ if (!opts->sset[1]->stride.data) {
+ opts->sset[1]->stride.data = (hsize_t *)HDcalloc((size_t)rank2, sizeof(hsize_t));
+ opts->sset[1]->stride.len = (unsigned)rank2;
+ for (i = 0; i < rank2; i++)
+ opts->sset[1]->stride.data[i] = 1;
+ }
+
+ if (!opts->sset[1]->count.data) {
+ opts->sset[1]->count.data = (hsize_t *)HDcalloc((size_t)rank2, sizeof(hsize_t));
+ opts->sset[1]->count.len = (unsigned)rank2;
+ for (i = 0; i < rank2; i++)
+ opts->sset[1]->count.data[i] = 1;
+ }
+
+ if (!opts->sset[1]->block.data) {
+ opts->sset[1]->block.data = (hsize_t *)HDcalloc((size_t)rank2, sizeof(hsize_t));
+ opts->sset[1]->block.len = (unsigned)rank2;
+ for (i = 0; i < rank2; i++)
+ opts->sset[1]->block.data[i] = 1;
+ }
+
+ /*-------------------------------------------------------------------------
+ * check for block overlap
+ *-------------------------------------------------------------------------
+ */
+ for (i = 0; i < rank2; i++) {
+ if (opts->sset[1]->count.data[i] > 1) {
+ if (opts->sset[1]->stride.data[i] < opts->sset[1]->block.data[i]) {
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "wrong subset selection[1]; blocks overlap");
+ } /* end if */
+ } /* end if */
+ } /* end for */
+ }
+
+ for (i = 0; i < rank2; i++) {
+ hs_offset2[i] = opts->sset[1]->start.data[i];
+ hs_stride2[i] = opts->sset[1]->stride.data[i];
+ hs_count2[i] = opts->sset[1]->count.data[i];
+ hs_block2[i] = opts->sset[1]->block.data[i];
+ hs_size2[i] = 0;
+ H5TOOLS_DEBUG("[%d]hs_offset2:%ld, hs_stride2:%ld, hs_count2:%ld, hs_block2:%ld", i,
+ hs_offset2[i], hs_stride2[i], hs_count2[i], hs_block2[i]);
+ }
+ }
/*
* determine the strip mine size and allocate a buffer. The strip mine is
* a hyperslab whose size is manageable.
*/
- sm_nbytes = p_type_nbytes;
-
- for(i = rank1; i > 0; --i) {
- hsize_t size = H5TOOLS_BUFSIZE / sm_nbytes;
-
- if(size == 0) /* datum size > H5TOOLS_BUFSIZE */
- size = 1;
- sm_size[i - 1] = MIN(dims1[i - 1], size);
- sm_nbytes *= sm_size[i - 1];
- HDassert(sm_nbytes > 0);
- } /* end for */
-
- /* malloc return code should be verified.
- * If fail, need to handle the error.
- * This else branch should be recoded as a separate function.
- * Note that there are many "goto error" within this branch
- * that fails to address freeing other objects created here.
- * E.g., sm_space.
- */
- sm_buf1 = HDmalloc((size_t)sm_nbytes);
- HDassert(sm_buf1);
- sm_buf2 = HDmalloc((size_t)sm_nbytes);
- HDassert(sm_buf2);
-
- sm_nelmts = sm_nbytes / p_type_nbytes;
- sm_space = H5Screate_simple(1, &sm_nelmts, NULL);
+ sm_nbytes = opts->m_size;
+ if (opts->rank > 0) {
+ for (i = opts->rank; i > 0; --i) {
+ hsize_t size = H5TOOLS_BUFSIZE / sm_nbytes;
+ if (size == 0) /* datum size > H5TOOLS_BUFSIZE */
+ size = 1;
+ H5TOOLS_DEBUG("opts->dims[%d]: %ld - size: %ld", i - 1, opts->dims[i - 1], size);
+ if (opts->sset[1] != NULL) {
+ sm_size[i - 1] = MIN(hs_block1[i - 1] * hs_count1[i - 1], size);
+ sm_block[i - 1] = MIN(hs_block1[i - 1], sm_size[i - 1]);
+ }
+ else {
+ sm_size[i - 1] = MIN(opts->dims[i - 1], size);
+ sm_block[i - 1] = sm_size[i - 1];
+ }
+ H5TOOLS_DEBUG("sm_size[%d]: %ld - sm_block:%ld", i - 1, sm_size[i - 1], sm_block[i - 1]);
+ sm_nbytes *= sm_size[i - 1];
+ H5TOOLS_DEBUG("sm_nbytes: %ld", sm_nbytes);
+ }
+ }
- /* the stripmine loop */
- HDmemset(hs_offset, 0, sizeof hs_offset);
- HDmemset(zero, 0, sizeof zero);
+ H5TOOLS_DEBUG("opts->nelmts: %ld", opts->nelmts);
+ for (elmtno = 0; elmtno < opts->nelmts; elmtno += opts->hs_nelmts) {
+ H5TOOLS_DEBUG("elmtno: %ld - hs_nelmts1: %ld", elmtno, hs_nelmts1);
+
+ if (NULL == (sm_buf1 = (unsigned char *)HDmalloc((size_t)sm_nbytes)))
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Could not allocate buffer for strip-mine");
+ if (NULL == (sm_buf2 = (unsigned char *)HDmalloc((size_t)sm_nbytes)))
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Could not allocate buffer for strip-mine");
- for(elmtno = 0; elmtno < p_nelmts; elmtno += hs_nelmts) {
/* calculate the hyperslab size */
- if(rank1 > 0) {
- for(i = 0, hs_nelmts = 1; i < rank1; i++) {
- hs_size[i] = MIN(dims1[i] - hs_offset[i], sm_size[i]);
- hs_nelmts *= hs_size[i];
- } /* end for */
- if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0)
- goto error;
- if(H5Sselect_hyperslab(sid2, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0)
- goto error;
- if(H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &hs_nelmts, NULL) < 0)
- goto error;
- } /* end if */
+ /* initialize subset */
+ if (opts->rank > 0) {
+ if (opts->sset[0] != NULL) {
+ H5TOOLS_DEBUG("sset1 has data");
+ /* calculate the potential number of elements */
+ for (i = 0; i < rank1; i++) {
+ H5TOOLS_DEBUG("[%d]opts->dims: %ld - hs_offset1: %ld - sm_block: %ld", i,
+ opts->dims[i], hs_offset1[i], sm_block[i]);
+ hs_size1[i] = MIN(opts->dims[i] - hs_offset1[i], sm_block[i]);
+ H5TOOLS_DEBUG("hs_size1[%d]: %ld", i, hs_size1[i]);
+ }
+ if (H5Sselect_hyperslab(sid1, H5S_SELECT_SET, hs_offset1, hs_stride1, hs_count1,
+ hs_size1) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sselect_hyperslab sid1 failed");
+ }
+ else {
+ for (i = 0, hs_nelmts1 = 1; i < rank1; i++) {
+ H5TOOLS_DEBUG("[%d]opts->dims: %ld - hs_offset1: %ld - sm_block: %ld", i,
+ opts->dims[i], hs_offset1[i], sm_block[i]);
+ hs_size1[i] = MIN(opts->dims[i] - hs_offset1[i], sm_block[i]);
+ H5TOOLS_DEBUG("hs_size1[%d]: %ld", i, hs_size1[i]);
+ hs_nelmts1 *= hs_size1[i];
+ H5TOOLS_DEBUG("hs_nelmts1:%ld *= hs_size1[%d]: %ld", hs_nelmts1, i, hs_size1[i]);
+ }
+ if (H5Sselect_hyperslab(sid1, H5S_SELECT_SET, hs_offset1, NULL, hs_size1, NULL) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sselect_hyperslab sid1 failed");
+ }
+
+ if ((ssm_nelmts = H5Sget_select_npoints(sid1)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sget_select_npoints failed");
+ sm_nelmts1 = (hsize_t)ssm_nelmts;
+ H5TOOLS_DEBUG("sm_nelmts1: %ld", sm_nelmts1);
+ hs_nelmts1 = sm_nelmts1;
+
+ if ((sm_space1 = H5Screate_simple(1, &sm_nelmts1, NULL)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Screate_simple failed");
+
+ if (H5Sselect_hyperslab(sm_space1, H5S_SELECT_SET, zero, NULL, &sm_nelmts1, NULL) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sselect_hyperslab failed");
+
+ if (opts->sset[1] != NULL) {
+ H5TOOLS_DEBUG("sset2 has data");
+ for (i = 0; i < rank2; i++) {
+ H5TOOLS_DEBUG("[%d]opts->dims: %ld - hs_offset2: %ld - sm_block: %ld", i,
+ opts->dims[i], hs_offset2[i], sm_block[i]);
+ hs_size2[i] = MIN(opts->dims[i] - hs_offset2[i], sm_block[i]);
+ H5TOOLS_DEBUG("hs_size2[%d]: %ld", i, hs_size2[i]);
+ }
+ if (H5Sselect_hyperslab(sid2, H5S_SELECT_SET, hs_offset2, hs_stride2, hs_count2,
+ hs_size2) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sselect_hyperslab sid2 failed");
+ }
+ else {
+ for (i = 0, hs_nelmts2 = 1; i < rank2; i++) {
+ H5TOOLS_DEBUG("[%d]opts->dims: %ld - hs_offset2: %ld - sm_block: %ld", i,
+ opts->dims[i], hs_offset2[i], sm_block[i]);
+ hs_size2[i] = MIN(opts->dims[i] - hs_offset2[i], sm_block[i]);
+ H5TOOLS_DEBUG("hs_size2[%d]: %ld", i, hs_size2[i]);
+ hs_nelmts2 *= hs_size2[i];
+ H5TOOLS_DEBUG("hs_nelmts2:%ld *= hs_size2[%d]: %ld", hs_nelmts2, i, hs_size2[i]);
+ }
+ if (H5Sselect_hyperslab(sid2, H5S_SELECT_SET, hs_offset2, NULL, hs_size2, NULL) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sselect_hyperslab sid2 failed");
+ }
+
+ if ((ssm_nelmts = H5Sget_select_npoints(sid2)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sget_select_npoints failed");
+ sm_nelmts2 = (hsize_t)ssm_nelmts;
+ H5TOOLS_DEBUG("sm_nelmts2: %ld", sm_nelmts2);
+ hs_nelmts2 = sm_nelmts2;
+
+ if ((sm_space2 = H5Screate_simple(1, &sm_nelmts2, NULL)) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Screate_simple failed");
+
+ if (H5Sselect_hyperslab(sm_space2, H5S_SELECT_SET, zero, NULL, &sm_nelmts2, NULL) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sselect_hyperslab failed");
+ }
else
- hs_nelmts = 1;
-
- if(H5Dread(did1,m_tid1,sm_space,sid1,H5P_DEFAULT,sm_buf1) < 0)
- goto error;
- if(H5Dread(did2,m_tid2,sm_space,sid2,H5P_DEFAULT,sm_buf2) < 0)
- goto error;
+ hs_nelmts1 = 1;
+ opts->hs_nelmts = hs_nelmts1;
+ H5TOOLS_DEBUG("hs_nelmts: %ld", opts->hs_nelmts);
+
+ /* read the data */
+ if (H5Dread(did1, m_tid1, sm_space1, sid1, H5P_DEFAULT, sm_buf1) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dread failed");
+ if (H5Dread(did2, m_tid2, sm_space2, sid2, H5P_DEFAULT, sm_buf2) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dread failed");
+
+ /* print array indices. get the lower bound of the hyperslab and calculate
+ the element position at the start of hyperslab */
+ if (H5Sget_select_bounds(sid1, low, high) < 0)
+ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sget_select_bounds failed");
+ /* initialize the current stripmine position; this is necessary to print the array indices */
+ for (j = 0; j < opts->rank; j++)
+ opts->sm_pos[j] = low[j];
+
+ /* Assume entire data space to be printed */
+ init_acc_pos((unsigned)opts->rank, opts->dims, opts->acc, opts->pos, opts->p_min_idx);
/* get array differences. in the case of hyperslab read, increment the number of differences
- found in each hyperslab and pass the position at the beggining for printing */
- nfound += diff_array(sm_buf1, sm_buf2, hs_nelmts, elmtno, rank1,
- dims1, options, name1, name2, m_tid1, did1, did2);
-
- /* reclaim any VL memory, if necessary */
- if(vl_data) {
- H5Dvlen_reclaim(m_tid1, sm_space, H5P_DEFAULT, sm_buf1);
- H5Dvlen_reclaim(m_tid1, sm_space, H5P_DEFAULT, sm_buf2);
- } /* end if */
+ found in each hyperslab and pass the position at the beginning for printing */
+ nfound += diff_array(sm_buf1, sm_buf2, opts, did1, did2);
+
+ if (sm_buf1 != NULL) {
+ /* reclaim any VL memory, if necessary */
+ if (vl_data1)
+ H5Treclaim(m_tid1, sm_space1, H5P_DEFAULT, sm_buf1);
+ HDfree(sm_buf1);
+ sm_buf1 = NULL;
+ }
+ if (sm_buf2 != NULL) {
+ /* reclaim any VL memory, if necessary */
+ if (vl_data2)
+ H5Treclaim(m_tid2, sm_space2, H5P_DEFAULT, sm_buf2);
+ HDfree(sm_buf2);
+ sm_buf2 = NULL;
+ }
+
+ H5Sclose(sm_space1);
+ H5Sclose(sm_space2);
/* calculate the next hyperslab offset */
- for(i = rank1, carry = 1; i > 0 && carry; --i) {
- hs_offset[i - 1] += hs_size[i - 1];
- if(hs_offset[i - 1] == dims1[i - 1])
- hs_offset[i - 1] = 0;
+ for (i = opts->rank, carry = 1; i > 0 && carry; --i) {
+ if (opts->sset[0] != NULL) {
+ H5TOOLS_DEBUG("[%d]hs_size1:%ld - hs_block1:%ld - hs_stride1:%ld", i - 1,
+ hs_size1[i - 1], hs_block1[i - 1], hs_stride1[i - 1]);
+ if (hs_size1[i - 1] >= hs_block1[i - 1]) {
+ hs_offset1[i - 1] += hs_size1[i - 1];
+ }
+ else {
+ hs_offset1[i - 1] += hs_stride1[i - 1];
+ }
+ }
+ else
+ hs_offset1[i - 1] += hs_size1[i - 1];
+ H5TOOLS_DEBUG("[%d]hs_offset1:%ld - opts->dims:%ld", i - 1, hs_offset1[i - 1],
+ opts->dims[i - 1]);
+ if (hs_offset1[i - 1] >= opts->dims[i - 1])
+ hs_offset1[i - 1] = 0;
else
carry = 0;
- } /* i */
- } /* elmtno */
-
- H5Sclose(sm_space);
- } /* hyperslab read */
+ H5TOOLS_DEBUG("[%d]hs_offset1:%ld", i - 1, hs_offset1[i - 1]);
+ if (opts->sset[1] != NULL) {
+ H5TOOLS_DEBUG("[%d]hs_size2:%ld - hs_block2:%ld - hs_stride2:%ld", i - 1,
+ hs_size2[i - 1], hs_block2[i - 1], hs_stride2[i - 1]);
+ if (hs_size2[i - 1] >= hs_block2[i - 1]) {
+ hs_offset2[i - 1] += hs_size2[i - 1];
+ }
+ else {
+ hs_offset2[i - 1] += hs_stride2[i - 1];
+ }
+ }
+ else
+ hs_offset2[i - 1] += hs_size2[i - 1];
+ H5TOOLS_DEBUG("[%d]hs_offset2:%ld - opts->dims:%ld", i - 1, hs_offset2[i - 1],
+ opts->dims[i - 1]);
+ if (hs_offset2[i - 1] >= opts->dims[i - 1])
+ hs_offset2[i - 1] = 0;
+ H5TOOLS_DEBUG("[%d]hs_offset2:%ld", i - 1, hs_offset2[i - 1]);
+ }
+ } /* elmtno for loop */
+ } /* hyperslab read */
+ H5TOOLS_DEBUG("can compare complete");
} /*can_compare*/
/*-------------------------------------------------------------------------
- * compare attributes
- * the if condition refers to cases when the dataset is a referenced object
- *-------------------------------------------------------------------------
- */
- if(obj1_name)
- nfound += diff_attr(did1,did2,obj1_name,obj2_name,options);
-
- /*-------------------------------------------------------------------------
* close
*-------------------------------------------------------------------------
*/
- /* free */
- if(buf1 != NULL) {
- HDfree(buf1);
- buf1 = NULL;
- } /* end if */
- if(buf2 != NULL) {
- HDfree(buf2);
- buf2 = NULL;
- } /* end if */
- if(sm_buf1 != NULL) {
- HDfree(sm_buf1);
- sm_buf1 = NULL;
- } /* end if */
- if(sm_buf2 != NULL) {
- HDfree(sm_buf2);
- sm_buf2 = NULL;
- } /* end if */
-
- H5E_BEGIN_TRY {
- H5Sclose(sid1);
- H5Sclose(sid2);
- H5Tclose(f_tid1);
- H5Tclose(f_tid2);
- H5Tclose(m_tid1);
- H5Tclose(m_tid2);
- } H5E_END_TRY;
-
- return nfound;
-
-error:
- options->err_stat=1;
+done:
+ opts->err_stat = opts->err_stat | ret_value;
+ H5TOOLS_DEBUG("free names - errstat:%d", opts->err_stat);
/* free */
- if (buf1!=NULL)
- {
+ if (opts->obj_name[0] != NULL)
+ HDfree(opts->obj_name[0]);
+ opts->obj_name[0] = NULL;
+ if (opts->obj_name[1] != NULL)
+ HDfree(opts->obj_name[1]);
+ opts->obj_name[1] = NULL;
+
+ H5TOOLS_DEBUG("reclaim any VL memory");
+ if (buf1 != NULL) {
/* reclaim any VL memory, if necessary */
- if(vl_data)
- H5Dvlen_reclaim(m_tid1, sid1, H5P_DEFAULT, buf1);
+ if (vl_data1)
+ H5Treclaim(m_tid1, sid1, H5P_DEFAULT, buf1);
HDfree(buf1);
- buf1=NULL;
+ buf1 = NULL;
}
- if (buf2!=NULL)
- {
+ if (buf2 != NULL) {
/* reclaim any VL memory, if necessary */
- if(vl_data)
- H5Dvlen_reclaim(m_tid2, sid2, H5P_DEFAULT, buf2);
+ if (vl_data2)
+ H5Treclaim(m_tid2, sid2, H5P_DEFAULT, buf2);
HDfree(buf2);
- buf2=NULL;
+ buf2 = NULL;
}
- if (sm_buf1!=NULL)
- {
+ H5TOOLS_DEBUG("reclaim any stripmine VL memory");
+ if (sm_buf1 != NULL) {
/* reclaim any VL memory, if necessary */
- if(vl_data)
- H5Dvlen_reclaim(m_tid1, sm_space, H5P_DEFAULT, sm_buf1);
+ if (vl_data1)
+ H5Treclaim(m_tid1, sm_space1, H5P_DEFAULT, sm_buf1);
HDfree(sm_buf1);
- sm_buf1=NULL;
+ sm_buf1 = NULL;
}
- if (sm_buf2!=NULL)
- {
+ if (sm_buf2 != NULL) {
/* reclaim any VL memory, if necessary */
- if(vl_data)
- H5Dvlen_reclaim(m_tid1, sm_space, H5P_DEFAULT, sm_buf2);
+ if (vl_data2)
+ H5Treclaim(m_tid2, sm_space2, H5P_DEFAULT, sm_buf2);
HDfree(sm_buf2);
- sm_buf2=NULL;
+ sm_buf2 = NULL;
}
+ H5TOOLS_DEBUG("close ids");
/* disable error reporting */
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Sclose(sid1);
H5Sclose(sid2);
+ H5Sclose(sm_space1);
+ H5Sclose(sm_space2);
+ H5Pclose(dcpl1);
+ H5Pclose(dcpl2);
H5Tclose(f_tid1);
H5Tclose(f_tid2);
H5Tclose(m_tid1);
H5Tclose(m_tid2);
/* enable error reporting */
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
+ H5TOOLS_ENDDEBUG(": %d with nfound:%d", ret_value, nfound);
return nfound;
}
/*-------------------------------------------------------------------------
-* Function: diff_can_type
-*
-* Purpose: check for comparable TYPE and SPACE
-*
-* Return:
-* 1, can compare
-* 0, cannot compare
-* -1, error
-*
-* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
-*
-* Date: November 3, 2003
-*
-*-------------------------------------------------------------------------
-*/
-
-int diff_can_type( hid_t f_tid1, /* file data type */
- hid_t f_tid2, /* file data type */
- int rank1,
- int rank2,
- hsize_t *dims1,
- hsize_t *dims2,
- hsize_t *maxdim1,
- hsize_t *maxdim2,
- const char *obj1_name,
- const char *obj2_name,
- diff_opt_t *options,
- int is_compound)
+ * Function: diff_can_type
+ *
+ * Purpose: check for comparable TYPE and SPACE
+ *
+ * Return:
+ * 1, can compare
+ * 0, cannot compare
+ * -1, error
+ *-------------------------------------------------------------------------
+ */
+
+int
+diff_can_type(hid_t f_tid1, hid_t f_tid2, int rank1, int rank2, hsize_t *dims1, hsize_t *dims2,
+ hsize_t *maxdim1, hsize_t *maxdim2, diff_opt_t *opts, int is_compound)
{
-
-
- H5T_class_t tclass1;
- H5T_class_t tclass2;
- int maxdim_diff=0; /* maximum dimensions are different */
- int dim_diff=0; /* current dimensions are different */
- int i;
- int can_compare = 1; /* return value */
-
+ H5T_class_t tclass1;
+ H5T_class_t tclass2;
+ int maxdim_diff = 0; /* maximum dimensions are different */
+ int dim_diff = 0; /* current dimensions are different */
+ int i;
+ int ret_value = 1;
+
+ H5TOOLS_START_DEBUG(" ");
/*-------------------------------------------------------------------------
- * check for the same class
- *-------------------------------------------------------------------------
- */
-
- if ((tclass1=H5Tget_class(f_tid1)) < 0)
- return -1;
-
- if ((tclass2=H5Tget_class(f_tid2)) < 0)
- return -1;
-
- if ( tclass1 != tclass2 )
- {
-
- if ( (options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name)
- {
-
- if ( is_compound )
- {
-
+ * check for the same class
+ *-------------------------------------------------------------------------
+ */
+ if ((tclass1 = H5Tget_class(f_tid1)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Tget_class first object failed");
+ if ((tclass2 = H5Tget_class(f_tid2)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Tget_class second object failed");
+
+ H5TOOLS_DEBUG("obj_names: %s - %s", opts->obj_name[0], opts->obj_name[1]);
+ if (tclass1 != tclass2) {
+ if ((opts->mode_verbose || opts->mode_list_not_cmp) && opts->obj_name[0] && opts->obj_name[1]) {
+ if (is_compound) {
parallel_print("Not comparable: <%s> has a class %s and <%s> has a class %s\n",
- obj1_name, get_class(tclass1),
- obj2_name, get_class(tclass2) );
-
+ opts->obj_name[0], get_class(tclass1), opts->obj_name[1], get_class(tclass2));
}
-
- else
-
- {
-
+ else {
parallel_print("Not comparable: <%s> is of class %s and <%s> is of class %s\n",
- obj1_name, get_class(tclass1),
- obj2_name, get_class(tclass2) );
-
+ opts->obj_name[0], get_class(tclass1), opts->obj_name[1], get_class(tclass2));
}
-
}
-
- can_compare = 0;
- options->not_cmp = 1;
- return can_compare;
+ opts->not_cmp = 1;
+ H5TOOLS_GOTO_DONE(0);
}
/*-------------------------------------------------------------------------
- * check for non supported classes
- *-------------------------------------------------------------------------
- */
+ * check for non supported classes
+ *-------------------------------------------------------------------------
+ */
+ switch (tclass1) {
+ case H5T_TIME:
+ if ((opts->mode_verbose || opts->mode_list_not_cmp) && opts->obj_name[0] && opts->obj_name[1]) {
+ parallel_print("Not comparable: <%s> and <%s> are of class %s\n", opts->obj_name[0],
+ opts->obj_name[1], get_class(tclass2));
+ } /* end if */
- HDassert(tclass1==tclass2);
- switch (tclass1)
- {
- case H5T_INTEGER:
- case H5T_FLOAT:
- case H5T_COMPOUND:
- case H5T_STRING:
- case H5T_ARRAY:
- case H5T_BITFIELD:
- case H5T_OPAQUE:
- case H5T_ENUM:
- case H5T_VLEN:
- case H5T_REFERENCE:
-
- break;
-
- default: /*H5T_TIME */
-
-
- if ( (options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name)
- {
- parallel_print("Not comparable: <%s> and <%s> are of class %s\n",
- obj1_name,obj2_name,get_class(tclass2) );
- }
- can_compare = 0;
- options->not_cmp = 1;
- return can_compare;
- }
+ opts->not_cmp = 1;
+ H5TOOLS_GOTO_DONE(0);
+ break;
+
+ case H5T_INTEGER:
+ case H5T_FLOAT:
+ case H5T_COMPOUND:
+ case H5T_STRING:
+ case H5T_ARRAY:
+ case H5T_BITFIELD:
+ case H5T_OPAQUE:
+ case H5T_ENUM:
+ case H5T_VLEN:
+ case H5T_REFERENCE:
+ case H5T_NO_CLASS:
+ case H5T_NCLASSES:
+ default:
+ H5TOOLS_DEBUG("class - %s", get_class(tclass1));
+ break;
+ } /* end switch */
/*-------------------------------------------------------------------------
- * check for equal file datatype; warning only
- *-------------------------------------------------------------------------
- */
-
- if ( (H5Tequal(f_tid1, f_tid2)==0) &&
- (options->m_verbose) && obj1_name && obj2_name)
- {
-
+ * check for equal file datatype; warning only
+ *-------------------------------------------------------------------------
+ */
+ if ((H5Tequal(f_tid1, f_tid2) == 0) && (opts->mode_verbose) && opts->obj_name[0] && opts->obj_name[1]) {
H5T_class_t cl = H5Tget_class(f_tid1);
-
parallel_print("Warning: different storage datatype\n");
- if ( cl == H5T_INTEGER || cl == H5T_FLOAT )
- {
- parallel_print("<%s> has file datatype ", obj1_name);
+ if (cl == H5T_INTEGER || cl == H5T_FLOAT) {
+ parallel_print("<%s> has file datatype ", opts->obj_name[0]);
print_type(f_tid1);
parallel_print("\n");
- parallel_print("<%s> has file datatype ", obj2_name);
+ parallel_print("<%s> has file datatype ", opts->obj_name[1]);
print_type(f_tid2);
parallel_print("\n");
}
-
-
-
}
/*-------------------------------------------------------------------------
- * check for the same rank
- *-------------------------------------------------------------------------
- */
-
-
- if ( rank1 != rank2 )
- {
-
- if ( (options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name)
- {
- parallel_print("Not comparable: <%s> has rank %d, dimensions ", obj1_name, rank1);
- print_dimensions(rank1,dims1);
+ * check for the same rank
+ *-------------------------------------------------------------------------
+ */
+ if (rank1 != rank2) {
+ if ((opts->mode_verbose || opts->mode_list_not_cmp) && opts->obj_name[0] && opts->obj_name[1]) {
+ parallel_print("Not comparable: <%s> has rank %d, dimensions ", opts->obj_name[0], rank1);
+ print_dimensions(rank1, dims1);
parallel_print(", max dimensions ");
- print_dimensions(rank1,maxdim1);
- parallel_print("\n" );
- parallel_print("and <%s> has rank %d, dimensions ", obj2_name, rank2);
- print_dimensions(rank2,dims2);
+ print_dimensions(rank1, maxdim1);
+ parallel_print("\n");
+ parallel_print("and <%s> has rank %d, dimensions ", opts->obj_name[1], rank2);
+ print_dimensions(rank2, dims2);
parallel_print(", max dimensions ");
- print_dimensions(rank2,maxdim2);
+ print_dimensions(rank2, maxdim2);
parallel_print("\n");
}
- can_compare = 0;
- options->not_cmp = 1;
- return can_compare;
+ opts->not_cmp = 1;
+ H5TOOLS_GOTO_DONE(0);
}
/*-------------------------------------------------------------------------
- * check for different dimensions
- *-------------------------------------------------------------------------
- */
-
- HDassert(rank1==rank2);
- for ( i=0; i<rank1; i++)
- {
- if (maxdim1 && maxdim2)
- {
- if ( maxdim1[i] != maxdim2[i] )
- maxdim_diff=1;
+ * check for different dimensions
+ *-------------------------------------------------------------------------
+ */
+ for (i = 0; i < rank1; i++) {
+ if (maxdim1 && maxdim2) {
+ if (maxdim1[i] != maxdim2[i])
+ maxdim_diff = 1;
}
- if ( dims1[i] != dims2[i] )
- dim_diff=1;
+ if (dims1[i] != dims2[i])
+ dim_diff = 1;
}
/*-------------------------------------------------------------------------
- * current dimensions
- *-------------------------------------------------------------------------
- */
-
- if (dim_diff==1)
- {
- if ( (options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name)
- {
- parallel_print("Not comparable: <%s> has rank %d, dimensions ", obj1_name, rank1);
- print_dimensions(rank1,dims1);
- if (maxdim1 && maxdim2)
- {
+ * current dimensions
+ *-------------------------------------------------------------------------
+ */
+ if (dim_diff == 1) {
+ if ((opts->mode_verbose || opts->mode_list_not_cmp) && opts->obj_name[0] && opts->obj_name[1]) {
+ parallel_print("Not comparable: <%s> has rank %d, dimensions ", opts->obj_name[0], rank1);
+ print_dimensions(rank1, dims1);
+ if (maxdim1 && maxdim2) {
parallel_print(", max dimensions ");
- print_dimensions(rank1,maxdim1);
- parallel_print("\n" );
- parallel_print("and <%s> has rank %d, dimensions ", obj2_name, rank2);
- print_dimensions(rank2,dims2);
+ print_dimensions(rank1, maxdim1);
+ parallel_print("\n");
+ parallel_print("and <%s> has rank %d, dimensions ", opts->obj_name[1], rank2);
+ print_dimensions(rank2, dims2);
parallel_print(", max dimensions ");
- print_dimensions(rank2,maxdim2);
+ print_dimensions(rank2, maxdim2);
parallel_print("\n");
}
}
-
- can_compare = 0;
- options->not_cmp = 1;
- return can_compare;
-
-
-
+ opts->not_cmp = 1;
+ H5TOOLS_GOTO_DONE(0);
}
/*-------------------------------------------------------------------------
- * maximum dimensions; just give a warning
- *-------------------------------------------------------------------------
- */
- if (maxdim1 && maxdim2 && maxdim_diff==1 && obj1_name )
- {
- if (options->m_verbose) {
- parallel_print( "Warning: different maximum dimensions\n");
- parallel_print("<%s> has max dimensions ", obj1_name);
- print_dimensions(rank1,maxdim1);
+ * maximum dimensions; just give a warning
+ *-------------------------------------------------------------------------
+ */
+ if (maxdim1 && maxdim2 && maxdim_diff == 1 && opts->obj_name[0]) {
+ if (opts->mode_verbose) {
+ parallel_print("Warning: different maximum dimensions\n");
+ parallel_print("<%s> has max dimensions ", opts->obj_name[0]);
+ print_dimensions(rank1, maxdim1);
parallel_print("\n");
- parallel_print("<%s> has max dimensions ", obj2_name);
- print_dimensions(rank2,maxdim2);
+ parallel_print("<%s> has max dimensions ", opts->obj_name[1]);
+ print_dimensions(rank2, maxdim2);
parallel_print("\n");
}
}
+ if (tclass1 == H5T_STRING) {
+ htri_t vstrtype1 = -1;
+ htri_t vstrtype2 = -1;
+ H5TOOLS_DEBUG(" - H5T_STRING");
- if ( tclass1 == H5T_COMPOUND )
- {
+ vstrtype1 = H5Tis_variable_str(f_tid1);
+ vstrtype2 = H5Tis_variable_str(f_tid2);
+ /* no compare if either one but not both are variable string type */
+ if (vstrtype1 != vstrtype2) {
+ if ((opts->mode_verbose || opts->mode_list_not_cmp) && opts->obj_name[0] && opts->obj_name[1])
+ parallel_print("Not comparable: <%s> or <%s> is of mixed string type\n", opts->obj_name[0],
+ opts->obj_name[1]);
+
+ opts->not_cmp = 1;
+ H5TOOLS_GOTO_DONE(0);
+ }
+ }
+
+ if (tclass1 == H5T_COMPOUND) {
int nmembs1;
int nmembs2;
int j;
- hid_t memb_type1;
- hid_t memb_type2;
+ hid_t memb_type1 = H5I_INVALID_HID;
+ hid_t memb_type2 = H5I_INVALID_HID;
+ H5TOOLS_DEBUG(" - H5T_COMPOUND");
nmembs1 = H5Tget_nmembers(f_tid1);
nmembs2 = H5Tget_nmembers(f_tid2);
- if ( nmembs1 != nmembs2 )
- {
-
- if ( (options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name)
- {
- parallel_print("Not comparable: <%s> has %d members ", obj1_name, nmembs1);
- parallel_print("<%s> has %d members ", obj2_name, nmembs2);
+ if (nmembs1 != nmembs2) {
+ if ((opts->mode_verbose || opts->mode_list_not_cmp) && opts->obj_name[0] && opts->obj_name[1]) {
+ parallel_print("Not comparable: <%s> has %d members ", opts->obj_name[0], nmembs1);
+ parallel_print("<%s> has %d members ", opts->obj_name[1], nmembs2);
parallel_print("\n");
}
- can_compare = 0;
- options->not_cmp = 1;
- return can_compare;
+ opts->not_cmp = 1;
+ H5TOOLS_GOTO_DONE(0);
}
- for (j = 0; j < nmembs1; j++)
- {
+ for (j = 0; j < nmembs1; j++) {
memb_type1 = H5Tget_member_type(f_tid1, (unsigned)j);
memb_type2 = H5Tget_member_type(f_tid2, (unsigned)j);
- if (diff_can_type(memb_type1,
- memb_type2,
- rank1,
- rank2,
- dims1,
- dims2,
- maxdim1,
- maxdim2,
- obj1_name,
- obj2_name,
- options,
- 1)!=1)
- {
- can_compare = 0;
- options->not_cmp = 1;
+ if (diff_can_type(memb_type1, memb_type2, rank1, rank2, dims1, dims2, maxdim1, maxdim2, opts,
+ 1) != 1) {
+ opts->not_cmp = 1;
H5Tclose(memb_type1);
H5Tclose(memb_type2);
- return can_compare;
+ H5TOOLS_GOTO_DONE(0);
}
-
H5Tclose(memb_type1);
H5Tclose(memb_type2);
-
}
-
-
-
-
-
}
+done:
+ if (ret_value < 0)
+ opts->err_stat = H5DIFF_ERR;
-
-
-
-
- return can_compare;
+ H5TOOLS_ENDDEBUG(" - %d", ret_value);
+ return ret_value;
}
-
-
-
+#if defined(H5DIFF_DEBUG_UNUSED)
+/* this function is not currently used, but could be useful */
/*-------------------------------------------------------------------------
-* Function: print_sizes
-*
-* Purpose: Print datatype sizes
-*
-*-------------------------------------------------------------------------
-*/
-#if defined (H5DIFF_DEBUG)
-void print_sizes( const char *obj1,
- const char *obj2,
- hid_t f_tid1,
- hid_t f_tid2,
- hid_t m_tid1,
- hid_t m_tid2 )
+ * Function: print_sizes
+ *
+ * Purpose: Print datatype sizes
+ *-------------------------------------------------------------------------
+ */
+void print_sizes(const char *obj1, const char *obj2, hid_t f_tid1, hid_t f_tid2, hid_t m_tid1, hid_t m_tid2);
+
+void
+print_sizes(const char *obj1, const char *obj2, hid_t f_tid1, hid_t f_tid2, hid_t m_tid1, hid_t m_tid2)
{
- size_t f_size1, f_size2; /* size of type in file */
- size_t m_size1, m_size2; /* size of type in memory */
+ size_t f_size1, f_size2; /* size of type in file */
+ size_t m_size1, m_size2; /* size of type in memory */
- f_size1 = H5Tget_size( f_tid1 );
- f_size2 = H5Tget_size( f_tid2 );
- m_size1 = H5Tget_size( m_tid1 );
- m_size2 = H5Tget_size( m_tid2 );
+ f_size1 = H5Tget_size(f_tid1);
+ f_size2 = H5Tget_size(f_tid2);
+ m_size1 = H5Tget_size(m_tid1);
+ m_size2 = H5Tget_size(m_tid2);
parallel_print("\n");
parallel_print("------------------\n");
- parallel_print("sizeof(char) %u\n", sizeof(char) );
- parallel_print("sizeof(short) %u\n", sizeof(short) );
- parallel_print("sizeof(int) %u\n", sizeof(int) );
- parallel_print("sizeof(long) %u\n", sizeof(long) );
+ parallel_print("sizeof(char) %u\n", sizeof(char));
+ parallel_print("sizeof(short) %u\n", sizeof(short));
+ parallel_print("sizeof(int) %u\n", sizeof(int));
+ parallel_print("sizeof(long) %u\n", sizeof(long));
parallel_print("<%s> ------------------\n", obj1);
parallel_print("type on file ");
print_type(f_tid1);
parallel_print("\n");
- parallel_print("size on file %u\n", f_size1 );
+ parallel_print("size on file %u\n", f_size1);
parallel_print("type on memory ");
print_type(m_tid1);
parallel_print("\n");
- parallel_print("size on memory %u\n", m_size1 );
+ parallel_print("size on memory %u\n", m_size1);
parallel_print("<%s> ------------------\n", obj2);
parallel_print("type on file ");
print_type(f_tid2);
parallel_print("\n");
- parallel_print("size on file %u\n", f_size2 );
+ parallel_print("size on file %u\n", f_size2);
parallel_print("type on memory ");
print_type(m_tid2);
parallel_print("\n");
- parallel_print("size on memory %u\n", m_size2 );
+ parallel_print("size on memory %u\n", m_size2);
parallel_print("\n");
}
#endif /* H5DIFF_DEBUG */
diff --git a/tools/lib/h5diff_util.c b/tools/lib/h5diff_util.c
index 0d476b6..17b8d3c 100644
--- a/tools/lib/h5diff_util.c
+++ b/tools/lib/h5diff_util.c
@@ -1,16 +1,13 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "H5private.h"
@@ -19,296 +16,349 @@
#include "h5diff.h"
#include "ph5diff.h"
-
/* global variables */
-int g_nTasks = 1;
+int g_nTasks = 1;
/*-------------------------------------------------------------------------
* Function: print_dimensions
*
- * Purpose: print dimensions
- *
+ * Purpose: print dimensions
*-------------------------------------------------------------------------
*/
void
-print_dimensions (int rank, hsize_t *dims)
+print_dimensions(int rank, hsize_t *dims)
{
- int i;
+ int i;
- if ( rank <= 0 )
- {
- parallel_print("H5S_SCALAR" );
- }
- else
- {
+ if (rank <= 0)
+ parallel_print("H5S_SCALAR");
+ else {
if (!dims)
parallel_print("dimension is NULL");
- else
- {
+ else {
parallel_print("[");
- for ( i = 0; i < rank-1; i++)
- {
- parallel_print(HSIZE_T_FORMAT, dims[i]);
+ for (i = 0; i < rank - 1; i++) {
+ parallel_print("%" PRIuHSIZE, dims[i]);
parallel_print("x");
}
- parallel_print(HSIZE_T_FORMAT, dims[rank-1]);
- parallel_print("]" );
+ parallel_print("%" PRIuHSIZE, dims[rank - 1]);
+ parallel_print("]");
}
}
}
-
/*-------------------------------------------------------------------------
* Function: print_type
*
- * Purpose: Print name of datatype
+ * Purpose: Print name of datatype
*
- * Return: void
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: May 9, 2003
- *
- * Comments: Adapted from h5dump for H5T_INTEGER and H5T_FLOAT classes only
+ * Return: void
*
+ * Comments: Adapted from h5dump for H5T_INTEGER and H5T_FLOAT classes only
*-------------------------------------------------------------------------
*/
-void print_type(hid_t type)
+void
+print_type(hid_t type)
{
- switch (H5Tget_class(type))
- {
- default:
- return;
- case H5T_INTEGER:
- if (H5Tequal(type, H5T_STD_I8BE)) {
- parallel_print("H5T_STD_I8BE");
- } else if (H5Tequal(type, H5T_STD_I8LE)) {
- parallel_print("H5T_STD_I8LE");
- } else if (H5Tequal(type, H5T_STD_I16BE)) {
- parallel_print("H5T_STD_I16BE");
- } else if (H5Tequal(type, H5T_STD_I16LE)) {
- parallel_print("H5T_STD_I16LE");
- } else if (H5Tequal(type, H5T_STD_I32BE)) {
- parallel_print("H5T_STD_I32BE");
- } else if (H5Tequal(type, H5T_STD_I32LE)) {
- parallel_print("H5T_STD_I32LE");
- } else if (H5Tequal(type, H5T_STD_I64BE)) {
- parallel_print("H5T_STD_I64BE");
- } else if (H5Tequal(type, H5T_STD_I64LE)) {
- parallel_print("H5T_STD_I64LE");
- } else if (H5Tequal(type, H5T_STD_U8BE)) {
- parallel_print("H5T_STD_U8BE");
- } else if (H5Tequal(type, H5T_STD_U8LE)) {
- parallel_print("H5T_STD_U8LE");
- } else if (H5Tequal(type, H5T_STD_U16BE)) {
- parallel_print("H5T_STD_U16BE");
- } else if (H5Tequal(type, H5T_STD_U16LE)) {
- parallel_print("H5T_STD_U16LE");
- } else if (H5Tequal(type, H5T_STD_U32BE)) {
- parallel_print("H5T_STD_U32BE");
- } else if (H5Tequal(type, H5T_STD_U32LE)) {
- parallel_print("H5T_STD_U32LE");
- } else if (H5Tequal(type, H5T_STD_U64BE)) {
- parallel_print("H5T_STD_U64BE");
- } else if (H5Tequal(type, H5T_STD_U64LE)) {
- parallel_print("H5T_STD_U64LE");
- } else if (H5Tequal(type, H5T_NATIVE_SCHAR)) {
- parallel_print("H5T_NATIVE_SCHAR");
- } else if (H5Tequal(type, H5T_NATIVE_UCHAR)) {
- parallel_print("H5T_NATIVE_UCHAR");
- } else if (H5Tequal(type, H5T_NATIVE_SHORT)) {
- parallel_print("H5T_NATIVE_SHORT");
- } else if (H5Tequal(type, H5T_NATIVE_USHORT)) {
- parallel_print("H5T_NATIVE_USHORT");
- } else if (H5Tequal(type, H5T_NATIVE_INT)) {
- parallel_print("H5T_NATIVE_INT");
- } else if (H5Tequal(type, H5T_NATIVE_UINT)) {
- parallel_print("H5T_NATIVE_UINT");
- } else if (H5Tequal(type, H5T_NATIVE_LONG)) {
- parallel_print("H5T_NATIVE_LONG");
- } else if (H5Tequal(type, H5T_NATIVE_ULONG)) {
- parallel_print("H5T_NATIVE_ULONG");
- } else if (H5Tequal(type, H5T_NATIVE_LLONG)) {
- parallel_print("H5T_NATIVE_LLONG");
- } else if (H5Tequal(type, H5T_NATIVE_ULLONG)) {
- parallel_print("H5T_NATIVE_ULLONG");
- } else {
- parallel_print("undefined integer");
- }
- break;
-
- case H5T_FLOAT:
- if (H5Tequal(type, H5T_IEEE_F32BE)) {
- parallel_print("H5T_IEEE_F32BE");
- } else if (H5Tequal(type, H5T_IEEE_F32LE)) {
- parallel_print("H5T_IEEE_F32LE");
- } else if (H5Tequal(type, H5T_IEEE_F64BE)) {
- parallel_print("H5T_IEEE_F64BE");
- } else if (H5Tequal(type, H5T_IEEE_F64LE)) {
- parallel_print("H5T_IEEE_F64LE");
- } else if (H5Tequal(type, H5T_NATIVE_FLOAT)) {
- parallel_print("H5T_NATIVE_FLOAT");
- } else if (H5Tequal(type, H5T_NATIVE_DOUBLE)) {
- parallel_print("H5T_NATIVE_DOUBLE");
-#if H5_SIZEOF_LONG_DOUBLE !=0
- } else if (H5Tequal(type, H5T_NATIVE_LDOUBLE)) {
- parallel_print("H5T_NATIVE_LDOUBLE");
-#endif
- } else {
- parallel_print("undefined float");
- }
- break;
+ switch (H5Tget_class(type)) {
+ case H5T_INTEGER:
+ if (H5Tequal(type, H5T_STD_I8BE))
+ parallel_print("H5T_STD_I8BE");
+ else if (H5Tequal(type, H5T_STD_I8LE))
+ parallel_print("H5T_STD_I8LE");
+ else if (H5Tequal(type, H5T_STD_I16BE))
+ parallel_print("H5T_STD_I16BE");
+ else if (H5Tequal(type, H5T_STD_I16LE))
+ parallel_print("H5T_STD_I16LE");
+ else if (H5Tequal(type, H5T_STD_I32BE))
+ parallel_print("H5T_STD_I32BE");
+ else if (H5Tequal(type, H5T_STD_I32LE))
+ parallel_print("H5T_STD_I32LE");
+ else if (H5Tequal(type, H5T_STD_I64BE))
+ parallel_print("H5T_STD_I64BE");
+ else if (H5Tequal(type, H5T_STD_I64LE))
+ parallel_print("H5T_STD_I64LE");
+ else if (H5Tequal(type, H5T_STD_U8BE))
+ parallel_print("H5T_STD_U8BE");
+ else if (H5Tequal(type, H5T_STD_U8LE))
+ parallel_print("H5T_STD_U8LE");
+ else if (H5Tequal(type, H5T_STD_U16BE))
+ parallel_print("H5T_STD_U16BE");
+ else if (H5Tequal(type, H5T_STD_U16LE))
+ parallel_print("H5T_STD_U16LE");
+ else if (H5Tequal(type, H5T_STD_U32BE))
+ parallel_print("H5T_STD_U32BE");
+ else if (H5Tequal(type, H5T_STD_U32LE))
+ parallel_print("H5T_STD_U32LE");
+ else if (H5Tequal(type, H5T_STD_U64BE))
+ parallel_print("H5T_STD_U64BE");
+ else if (H5Tequal(type, H5T_STD_U64LE))
+ parallel_print("H5T_STD_U64LE");
+ else if (H5Tequal(type, H5T_NATIVE_SCHAR))
+ parallel_print("H5T_NATIVE_SCHAR");
+ else if (H5Tequal(type, H5T_NATIVE_UCHAR))
+ parallel_print("H5T_NATIVE_UCHAR");
+ else if (H5Tequal(type, H5T_NATIVE_SHORT))
+ parallel_print("H5T_NATIVE_SHORT");
+ else if (H5Tequal(type, H5T_NATIVE_USHORT))
+ parallel_print("H5T_NATIVE_USHORT");
+ else if (H5Tequal(type, H5T_NATIVE_INT))
+ parallel_print("H5T_NATIVE_INT");
+ else if (H5Tequal(type, H5T_NATIVE_UINT))
+ parallel_print("H5T_NATIVE_UINT");
+ else if (H5Tequal(type, H5T_NATIVE_LONG))
+ parallel_print("H5T_NATIVE_LONG");
+ else if (H5Tequal(type, H5T_NATIVE_ULONG))
+ parallel_print("H5T_NATIVE_ULONG");
+ else if (H5Tequal(type, H5T_NATIVE_LLONG))
+ parallel_print("H5T_NATIVE_LLONG");
+ else if (H5Tequal(type, H5T_NATIVE_ULLONG))
+ parallel_print("H5T_NATIVE_ULLONG");
+ else
+ parallel_print("undefined integer");
+ break;
+
+ case H5T_FLOAT:
+ if (H5Tequal(type, H5T_IEEE_F32BE))
+ parallel_print("H5T_IEEE_F32BE");
+ else if (H5Tequal(type, H5T_IEEE_F32LE))
+ parallel_print("H5T_IEEE_F32LE");
+ else if (H5Tequal(type, H5T_IEEE_F64BE))
+ parallel_print("H5T_IEEE_F64BE");
+ else if (H5Tequal(type, H5T_IEEE_F64LE))
+ parallel_print("H5T_IEEE_F64LE");
+ else if (H5Tequal(type, H5T_NATIVE_FLOAT))
+ parallel_print("H5T_NATIVE_FLOAT");
+ else if (H5Tequal(type, H5T_NATIVE_DOUBLE))
+ parallel_print("H5T_NATIVE_DOUBLE");
+ else if (H5Tequal(type, H5T_NATIVE_LDOUBLE))
+ parallel_print("H5T_NATIVE_LDOUBLE");
+ else
+ parallel_print("undefined float");
+ break;
+
+ case H5T_BITFIELD:
+ if (H5Tequal(type, H5T_STD_B8BE))
+ parallel_print("H5T_STD_B8BE");
+ else if (H5Tequal(type, H5T_STD_B8LE))
+ parallel_print("H5T_STD_B8LE");
+ else if (H5Tequal(type, H5T_STD_B16BE))
+ parallel_print("H5T_STD_B16BE");
+ else if (H5Tequal(type, H5T_STD_B16LE))
+ parallel_print("H5T_STD_B16LE");
+ else if (H5Tequal(type, H5T_STD_B32BE))
+ parallel_print("H5T_STD_B32BE");
+ else if (H5Tequal(type, H5T_STD_B32LE))
+ parallel_print("H5T_STD_B32LE");
+ else if (H5Tequal(type, H5T_STD_B64BE))
+ parallel_print("H5T_STD_B64BE");
+ else if (H5Tequal(type, H5T_STD_B64LE))
+ parallel_print("H5T_STD_B64LE");
+ else
+ parallel_print("undefined bitfield");
+ break;
- }/*switch*/
+ case H5T_TIME:
+ case H5T_STRING:
+ case H5T_OPAQUE:
+ case H5T_COMPOUND:
+ case H5T_REFERENCE:
+ case H5T_ENUM:
+ case H5T_VLEN:
+ case H5T_ARRAY:
+ case H5T_NO_CLASS:
+ case H5T_NCLASSES:
+ default:
+ return;
+
+ } /* end switch */
}
/*-------------------------------------------------------------------------
* Function: diff_basename
*
- * Purpose: Returns a pointer to the last component absolute name
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: May 9, 2003
- *
+ * Purpose: Returns a pointer to the last component absolute name
*-------------------------------------------------------------------------
*/
-const char*
+H5_ATTR_PURE const char *
diff_basename(const char *name)
{
size_t i;
- if (name==NULL)
+ if (name == NULL)
return NULL;
/* Find the end of the base name */
i = HDstrlen(name);
- while (i>0 && '/'==name[i-1])
+ while (i > 0 && '/' == name[i - 1])
--i;
/* Skip backward over base name */
- while (i>0 && '/'!=name[i-1])
+ while (i > 0 && '/' != name[i - 1])
--i;
- return(name+i);
+ return (name + i);
}
/*-------------------------------------------------------------------------
* Function: get_type
*
- * Purpose: Returns the type as a string
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: May 9, 2003
- *
+ * Purpose: Returns the type as a string
*-------------------------------------------------------------------------
*/
-const char*
+H5_ATTR_CONST const char *
get_type(h5trav_type_t type)
{
- switch(type) {
+ switch (type) {
case H5TRAV_TYPE_DATASET:
- return("H5G_DATASET");
+ return ("H5G_DATASET");
+
case H5TRAV_TYPE_GROUP:
- return("H5G_GROUP");
+ return ("H5G_GROUP");
+
case H5TRAV_TYPE_NAMED_DATATYPE:
- return("H5G_TYPE");
+ return ("H5G_TYPE");
+
case H5TRAV_TYPE_LINK:
- return("H5G_LINK");
+ return ("H5G_LINK");
+
case H5TRAV_TYPE_UDLINK:
- return("H5G_UDLINK");
+ return ("H5G_UDLINK");
+
+ case H5TRAV_TYPE_UNKNOWN:
default:
- return("unknown type");
+ return ("unknown type");
}
}
/*-------------------------------------------------------------------------
* Function: get_sign
*
- * Purpose: Returns the sign as a string
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: May 9, 2003
- *
- * Comments:
- *
+ * Purpose: Returns the sign as a string
*-------------------------------------------------------------------------
*/
-const char*
+H5_ATTR_CONST const char *
get_sign(H5T_sign_t sign)
{
- switch (sign)
- {
- default:
- return("H5T_SGN_ERROR");
- case H5T_SGN_NONE:
- return("H5T_SGN_NONE");
- case H5T_SGN_2:
- return("H5T_SGN_2");
- }
-}
+ switch (sign) {
+ case H5T_SGN_NONE:
+ return "H5T_SGN_NONE";
+
+ case H5T_SGN_2:
+ return "H5T_SGN_2";
+ case H5T_SGN_ERROR:
+ return "H5T_SGN_ERROR";
+
+ case H5T_NSGN:
+ return "H5T_NSGN";
+
+ default:
+ return "unknown sign value";
+ } /* end switch */
+}
/*-------------------------------------------------------------------------
* Function: get_class
*
- * Purpose: Returns the class as a string
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: May 9, 2003
- *
+ * Purpose: Returns the class as a string
*-------------------------------------------------------------------------
*/
-const char*
+H5_ATTR_CONST const char *
get_class(H5T_class_t tclass)
{
- switch (tclass)
- {
- default:
- return("Invalid class");
- case H5T_TIME:
- return("H5T_TIME");
- case H5T_INTEGER:
- return("H5T_INTEGER");
- case H5T_FLOAT:
- return("H5T_FLOAT");
- case H5T_STRING:
- return("H5T_STRING");
- case H5T_BITFIELD:
- return("H5T_BITFIELD");
- case H5T_OPAQUE:
- return("H5T_OPAQUE");
- case H5T_COMPOUND:
- return("H5T_COMPOUND");
- case H5T_REFERENCE:
- return("H5T_REFERENCE");
- case H5T_ENUM:
- return("H5T_ENUM");
- case H5T_VLEN:
- return("H5T_VLEN");
- case H5T_ARRAY:
- return("H5T_ARRAY");
- }
-}
+ switch (tclass) {
+ case H5T_TIME:
+ return ("H5T_TIME");
+
+ case H5T_INTEGER:
+ return ("H5T_INTEGER");
+
+ case H5T_FLOAT:
+ return ("H5T_FLOAT");
+
+ case H5T_STRING:
+ return ("H5T_STRING");
+
+ case H5T_BITFIELD:
+ return ("H5T_BITFIELD");
+
+ case H5T_OPAQUE:
+ return ("H5T_OPAQUE");
+
+ case H5T_COMPOUND:
+ return ("H5T_COMPOUND");
+
+ case H5T_REFERENCE:
+ return ("H5T_REFERENCE");
+
+ case H5T_ENUM:
+ return ("H5T_ENUM");
+
+ case H5T_VLEN:
+ return ("H5T_VLEN");
+
+ case H5T_ARRAY:
+ return ("H5T_ARRAY");
+
+ case H5T_NO_CLASS:
+ case H5T_NCLASSES:
+ default:
+ return ("Invalid class");
+ } /* end switch */
+} /* end get_class() */
/*-------------------------------------------------------------------------
* Function: print_found
*
- * Purpose: print number of differences found
- *
+ * Purpose: print number of differences found
*-------------------------------------------------------------------------
*/
-void print_found(hsize_t nfound)
+void
+print_found(hsize_t nfound)
{
- if(g_Parallel)
- parallel_print("%"H5_PRINTF_LL_WIDTH"u differences found\n", (unsigned long long)nfound);
- else
- HDfprintf(stdout,"%Hu differences found\n",nfound);
+ if (g_Parallel)
+ parallel_print("%" PRIuHSIZE " differences found\n", nfound);
+ else
+ HDfprintf(stdout, "%" PRIuHSIZE " differences found\n", nfound);
}
+/*-----------------------------------------------------------------
+ * Function: match_up_memsize
+ *
+ * Purpose: match smaller memory size up to bigger memory size
+ *------------------------------------------------------------------
+ */
+herr_t
+match_up_memsize(hid_t f_tid1_id, hid_t f_tid2_id, hid_t *m_tid1, hid_t *m_tid2, size_t *m_size1,
+ size_t *m_size2)
+{
+ herr_t ret_value = SUCCEED;
+
+ H5TOOLS_START_DEBUG(" ");
+ if ((*m_size1) != (*m_size2)) {
+ if ((*m_size1) < (*m_size2)) {
+ H5Tclose(*m_tid1);
+
+ if (((*m_tid1) = H5Tget_native_type(f_tid2_id, H5T_DIR_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Tget_native_type failed");
+ *m_size1 = H5Tget_size(*m_tid1);
+ } /* end if */
+ else {
+ H5Tclose(*m_tid2);
+ if (((*m_tid2) = H5Tget_native_type(f_tid1_id, H5T_DIR_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Tget_native_type failed");
+
+ *m_size2 = H5Tget_size(*m_tid2);
+ } /* end else */
+ } /* end if */
+ if ((*m_size1) != (*m_size2))
+ H5TOOLS_GOTO_ERROR(FAIL, "native type sizes do not compare");
+
+done:
+ H5TOOLS_ENDDEBUG(" ");
+ return ret_value;
+}
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index 17639bc..189aafd 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -1,126 +1,130 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Programmer: Robb Matzke <matzke@llnl.gov>
- * Thursday, July 23, 1998
- *
- * Purpose: A library for displaying the values of a dataset in a human
- * readable format.
+ * Purpose: A library for routines that are common
+ * amongst the various HDF5 tools.
*/
-#include <stdio.h>
-#include <stdlib.h>
-
#include "h5tools.h"
#include "h5tools_dump.h"
#include "h5tools_ref.h"
#include "h5tools_utils.h"
#include "H5private.h"
-#define SANITY_CHECK
-
-#define ALIGN(A,Z) ((((A) + (Z) - 1) / (Z)) * (Z))
+#ifdef H5_TOOLS_DEBUG
+/* global debug variables */
+int H5tools_INDENT_g = 0;
+#endif
/* global variables */
-hid_t H5tools_ERR_STACK_g = 0;
-hid_t H5tools_ERR_CLS_g = -1;
-hid_t H5E_tools_g = -1;
-hid_t H5E_tools_min_id_g = -1;
-int compound_data;
-FILE *rawdatastream; /* should initialize to stdout but gcc moans about it */
-FILE *rawoutstream; /* should initialize to stdout but gcc moans about it */
-FILE *rawerrorstream; /* should initialize to stderr but gcc moans about it */
-int bin_output; /* binary output */
-int bin_form; /* binary form */
-int region_output; /* region output */
-int oid_output; /* oid output */
-int data_output; /* data output */
-int attr_data_output; /* attribute data output */
-int packed_bits_num; /* number of packed bits to display */
-int packed_data_offset; /* offset of packed bits to display */
-int packed_data_length; /* lengtht of packed bits to display */
-unsigned long long packed_data_mask; /* mask in which packed bits to display */
+H5E_auto2_t lib_func;
+H5E_auto2_t tools_func;
+void *lib_edata;
+void *tools_edata;
+
+hid_t H5tools_ERR_STACK_g = H5I_INVALID_HID;
+hid_t H5tools_ERR_CLS_g = H5I_INVALID_HID;
+hid_t H5E_tools_g = H5I_INVALID_HID;
+hid_t H5E_tools_min_id_g = H5I_INVALID_HID;
+hid_t H5E_tools_min_info_id_g = H5I_INVALID_HID;
+hid_t H5E_tools_min_dbg_id_g = H5I_INVALID_HID;
+
+FILE *rawattrstream = NULL; /* should initialize to stdout but gcc moans about it */
+FILE *rawdatastream = NULL; /* should initialize to stdout but gcc moans about it */
+FILE *rawinstream = NULL; /* should initialize to stdin but gcc moans about it */
+FILE *rawoutstream = NULL; /* should initialize to stdout but gcc moans about it */
+FILE *rawerrorstream = NULL; /* should initialize to stderr but gcc moans about it */
+
+int bin_output; /* binary output */
+int bin_form = 0; /* binary form, default NATIVE */
+int region_output; /* region output */
+int oid_output; /* oid output */
+int data_output; /* data output */
+int attr_data_output; /* attribute data output */
+int compound_data;
+
+unsigned packed_bits_num; /* number of packed bits to display */
+unsigned packed_data_offset; /* offset of packed bits to display */
+unsigned packed_data_length; /* length of packed bits to display */
+unsigned long long packed_data_mask; /* mask in which packed bits to display */
+
+int enable_error_stack = 0; /* re-enable error stack; disable=0 enable=1 */
+
+/* sort parameters */
+H5_index_t sort_by = H5_INDEX_NAME; /* sort_by [creation_order | name] */
+H5_iter_order_t sort_order = H5_ITER_INC; /* sort_order [ascending | descending] */
/* module-scoped variables */
-static int h5tools_init_g; /* if h5tools lib has been initialized */
-#ifdef H5_HAVE_PARALLEL
-static int h5tools_mpi_init_g; /* if MPI_Init() has been called */
-#endif /* H5_HAVE_PARALLEL */
+static int h5tools_init_g; /* if h5tools lib has been initialized */
-/* Names of VFDs */
-static const char *drivernames[]={
- "sec2",
- "family",
- "split",
- "multi",
-#ifdef H5_HAVE_STREAM
- "stream",
-#endif /* H5_HAVE_STREAM */
-#ifdef H5_HAVE_PARALLEL
- "mpio",
- "mpiposix"
-#endif /* H5_HAVE_PARALLEL */
+/* Names of VOL connectors */
+const char *volnames[] = {
+ H5VL_NATIVE_NAME,
+ H5VL_PASSTHRU_NAME,
};
-/* This enum should match the entries in the above drivers_list since they
- * are indexes into the drivers_list array. */
-enum {
- SEC2_IDX = 0
- ,FAMILY_IDX
- ,SPLIT_IDX
- ,MULTI_IDX
-#ifdef H5_HAVE_STREAM
- ,STREAM_IDX
-#endif /* H5_HAVE_STREAM */
-#ifdef H5_HAVE_PARALLEL
- ,MPIO_IDX
- ,MPIPOSIX_IDX
-#endif /* H5_HAVE_PARALLEL */
-} driver_idx;
-#define NUM_DRIVERS (sizeof(drivernames) / sizeof(drivernames[0]))
+/* Names of VFDs. These names are always available so that
+ * the tools can emit special messages when a VFD is asked
+ * for by name but is not compiled into the library or is
+ * somehow otherwise not enabled.
+ *
+ */
+const char *drivernames[] = {
+ [SEC2_VFD_IDX] = "sec2",
+ [DIRECT_VFD_IDX] = "direct",
+ [LOG_VFD_IDX] = "log",
+ [WINDOWS_VFD_IDX] = "windows",
+ [STDIO_VFD_IDX] = "stdio",
+ [CORE_VFD_IDX] = "core",
+ [FAMILY_VFD_IDX] = "family",
+ [SPLIT_VFD_IDX] = "split",
+ [MULTI_VFD_IDX] = "multi",
+ [MPIO_VFD_IDX] = "mpio",
+ [ROS3_VFD_IDX] = "ros3",
+ [HDFS_VFD_IDX] = "hdfs",
+ [SUBFILING_VFD_IDX] = H5FD_SUBFILING_NAME,
+ [ONION_VFD_IDX] = "onion",
+};
+
+#define NUM_VOLS (sizeof(volnames) / sizeof(volnames[0]))
+#define NUM_DRIVERS (sizeof(drivernames) / sizeof(drivernames[0]))
/*-------------------------------------------------------------------------
- * Audience: Public
- * Chapter: H5Tools Library
- * Purpose: Initialize the H5 Tools library
- * Description:
- * This should be called before any other h5tools function is called.
- * Effect of any h5tools function called before this has been called is
- * undetermined.
- * Return:
- * None
- * Programmer:
- * Albert Cheng, 2000-10-31
- * Modifications:
+ * Function: h5tools_init
+ *
+ * Purpose: This should be called before any other h5tools function is called.
+ * Effect of any h5tools function called before this has been called is
+ * undetermined.
+ *
+ * Return None
*-------------------------------------------------------------------------
*/
void
h5tools_init(void)
{
- char lib_str[256];
+ /* Disable error reporting */
+ H5Eget_auto2(H5E_DEFAULT, &lib_func, &lib_edata);
+ H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
if (!h5tools_init_g) {
- /* register the error class */
- HDsnprintf(lib_str, sizeof(lib_str), "%d.%d.%d",H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE);
-
- H5tools_ERR_STACK_g = H5Ecreate_stack();
- H5TOOLS_INIT_ERROR()
+ H5TOOLS_INIT_ERROR();
+ if (!rawattrstream)
+ rawattrstream = stdout;
if (!rawdatastream)
rawdatastream = stdout;
+ if (!rawinstream)
+ rawinstream = stdin;
if (!rawoutstream)
rawoutstream = stdout;
if (!rawerrorstream)
@@ -130,39 +134,71 @@ h5tools_init(void)
h5tools_init_g++;
}
+
+ /* Disable tools error reporting */
+ H5Eget_auto2(H5tools_ERR_STACK_g, &tools_func, &tools_edata);
+ H5Eset_auto2(H5tools_ERR_STACK_g, NULL, NULL);
}
/*-------------------------------------------------------------------------
- * Audience: Public
- * Chapter: H5Tools Library
- * Purpose: Close the H5 Tools library
- * Description:
- * Close or release resources such as files opened by the library. This
- * should be called after all other h5tools functions have been called.
- * Effect of any h5tools function called after this has been called is
- * undetermined.
- * Return:
- * None
- * Programmer:
- * Albert Cheng, 2000-10-31
- * Modifications:
+ * Function: h5tools_error_report
+ *
+ * Purpose: Enable error stack reporting after command line is parsed.
+ *
+ * Return: None
+ *-------------------------------------------------------------------------
+ */
+void
+h5tools_error_report(void)
+{
+ if (h5tools_init_g) {
+ if (enable_error_stack > 0) {
+ H5Eset_auto2(H5E_DEFAULT, lib_func, lib_edata);
+ H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata);
+ }
+ }
+}
+
+/*-------------------------------------------------------------------------
+ * Function: h5tools_close
+ *
+ * Purpose: Close or release resources such as files opened by the library. This
+ * should be called after all other h5tools functions have been called.
+ * Effect of any h5tools function called after this has been called is
+ * undetermined.
+ *
+ * Return: None
*-------------------------------------------------------------------------
*/
void
h5tools_close(void)
{
- H5E_auto2_t tools_func;
- void *tools_edata;
if (h5tools_init_g) {
- H5Eget_auto2(H5tools_ERR_STACK_g, &tools_func, &tools_edata);
- if(tools_func!=NULL)
+ /* special case where only data is output to stdout */
+ if ((rawoutstream == NULL) && rawdatastream && (rawdatastream == stdout))
+ HDfprintf(rawdatastream, "\n");
+
+ if (tools_func)
H5Eprint2(H5tools_ERR_STACK_g, rawerrorstream);
+
+ if (rawattrstream && rawattrstream != stdout) {
+ if (fclose(rawattrstream))
+ perror("closing rawattrstream");
+ else
+ rawattrstream = NULL;
+ }
if (rawdatastream && rawdatastream != stdout) {
if (fclose(rawdatastream))
perror("closing rawdatastream");
else
rawdatastream = NULL;
}
+ if (rawinstream && rawinstream != stdin) {
+ if (fclose(rawinstream))
+ perror("closing rawinstream");
+ else
+ rawinstream = NULL;
+ }
if (rawoutstream && rawoutstream != stdout) {
if (fclose(rawoutstream))
perror("closing rawoutstream");
@@ -179,8 +215,12 @@ h5tools_close(void)
/* Clean up the reference path table, if it's been used */
term_ref_path_table();
- H5TOOLS_CLOSE_ERROR()
- H5Eclose_stack(H5tools_ERR_STACK_g);
+ /* Restore error stacks from init */
+ H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata);
+ H5Eset_auto2(H5E_DEFAULT, lib_func, lib_edata);
+
+ H5TOOLS_CLOSE_ERROR();
+
/* Shut down the library */
H5close();
@@ -189,258 +229,882 @@ h5tools_close(void)
}
/*-------------------------------------------------------------------------
- * Audience: Private
- * Chapter: H5Tools Library
- * Purpose: Get a FAPL for a driver
- * Description:
- * Get a FAPL for a given VFL driver name.
- * Return:
- * None
- * Programmer:
- * Quincey Koziol, 2004-02-04
- * Modifications:
- * Pedro Vicente Nunes, Thursday, July 27, 2006
- * Added error return conditions for the H5Pset_fapl calls
+ * Function: h5tools_set_data_output_file
+ *
+ * Purpose: Open fname as the output file for dataset raw data.
+ * Set rawdatastream as its file stream.
+ *
+ * Return: 0 -- succeeded
+ * negative -- failed
*-------------------------------------------------------------------------
*/
-static hid_t
-h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum)
+int
+h5tools_set_data_output_file(const char *fname, int is_bin)
{
- hid_t new_fapl; /* Copy of file access property list passed in, or new property list */
+ int retvalue = FAIL;
+ FILE *f; /* temporary holding place for the stream pointer
+ * so that rawdatastream is changed only when succeeded */
+
+ if (rawdatastream && rawdatastream != stdout) {
+ if (HDfclose(rawdatastream))
+ HDperror("closing rawdatastream");
+ else
+ rawdatastream = NULL;
+ }
- /* Make a copy of the FAPL, for the file open call to use, eventually */
- if (fapl == H5P_DEFAULT) {
- if ((new_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
- goto error;
- } /* end if */
+ /* First check if filename is string "NULL" */
+ if (fname != NULL) {
+ /* binary output */
+ if (is_bin) {
+ if ((f = HDfopen(fname, "wb")) != NULL) {
+ rawdatastream = f;
+ retvalue = SUCCEED;
+ }
+ }
+ else {
+ if ((f = HDfopen(fname, "w")) != NULL) {
+ rawdatastream = f;
+ retvalue = SUCCEED;
+ }
+ }
+ }
else {
- if ((new_fapl = H5Pcopy(fapl)) < 0)
- goto error;
- } /* end else */
-
- /* Determine which driver the user wants to open the file with. Try
- * that driver. If it can't open it, then fail. */
- if (!HDstrcmp(driver, drivernames[SEC2_IDX])) {
- /* SEC2 driver */
- if (H5Pset_fapl_sec2(new_fapl) < 0)
- goto error;
-
- if (drivernum)
- *drivernum = SEC2_IDX;
+ rawdatastream = NULL;
+ retvalue = SUCCEED;
}
- else if (!HDstrcmp(driver, drivernames[FAMILY_IDX])) {
- /* FAMILY Driver */
- /* Set member size to be 0 to indicate the current first member size
- * is the member size.
- */
- if (H5Pset_fapl_family(new_fapl, (hsize_t) 0, H5P_DEFAULT) < 0)
- goto error;
+ return retvalue;
+}
- if (drivernum)
- *drivernum = FAMILY_IDX;
+/*-------------------------------------------------------------------------
+ * Function: h5tools_set_attr_output_file
+ *
+ * Purpose: Open fname as the output file for attribute raw data.
+ * Set rawattrstream as its file stream.
+ *
+ * Return: 0 -- succeeded
+ * negative -- failed
+ *-------------------------------------------------------------------------
+ */
+int
+h5tools_set_attr_output_file(const char *fname, int is_bin)
+{
+ int retvalue = FAIL;
+ FILE *f; /* temporary holding place for the stream pointer
+ * so that rawattrstream is changed only when succeeded */
+
+ if (rawattrstream && rawattrstream != stdout) {
+ if (HDfclose(rawattrstream))
+ HDperror("closing rawattrstream");
+ else
+ rawattrstream = NULL;
+ }
+
+ /* First check if filename is string "NULL" */
+ if (fname != NULL) {
+ /* binary output */
+ if (is_bin) {
+ if ((f = HDfopen(fname, "wb")) != NULL) {
+ rawattrstream = f;
+ retvalue = SUCCEED;
+ }
+ }
+ else {
+ if ((f = HDfopen(fname, "w")) != NULL) {
+ rawattrstream = f;
+ retvalue = SUCCEED;
+ }
+ }
}
- else if (!HDstrcmp(driver, drivernames[SPLIT_IDX])) {
- /* SPLIT Driver */
- if (H5Pset_fapl_split(new_fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT) < 0)
- goto error;
+ else {
+ rawattrstream = NULL;
+ retvalue = SUCCEED;
+ }
+
+ return retvalue;
+}
- if (drivernum)
- *drivernum = SPLIT_IDX;
+/*-------------------------------------------------------------------------
+ * Function: h5tools_set_input_file
+ *
+ * Purpose: Open fname as the input file for raw input.
+ * Set rawinstream as its file stream.
+ *
+ * Return: 0 -- succeeded
+ * negative -- failed
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+h5tools_set_input_file(const char *fname, int is_bin)
+{
+ int retvalue = FAIL;
+ FILE *f; /* temporary holding place for the stream pointer
+ * so that rawinstream is changed only when succeeded */
+
+ if (rawinstream && rawinstream != stdin) {
+ if (HDfclose(rawinstream))
+ HDperror("closing rawinstream");
+ else
+ rawinstream = NULL;
}
- else if (!HDstrcmp(driver, drivernames[MULTI_IDX])) {
- /* MULTI Driver */
- if (H5Pset_fapl_multi(new_fapl, NULL, NULL, NULL, NULL, TRUE) < 0)
- goto error;
-
- if(drivernum)
- *drivernum = MULTI_IDX;
-#ifdef H5_HAVE_STREAM
+ /* First check if filename is string "NULL" */
+ if (fname != NULL) {
+ /* binary output */
+ if (is_bin) {
+ if ((f = HDfopen(fname, "rb")) != NULL) {
+ rawinstream = f;
+ retvalue = SUCCEED;
}
- else if(!HDstrcmp(driver, drivernames[STREAM_IDX])) {
- /* STREAM Driver */
- if(H5Pset_fapl_stream(new_fapl, NULL) < 0)
- goto error;
-
- if(drivernum)
- *drivernum = STREAM_IDX;
-#endif /* H5_HAVE_STREAM */
-#ifdef H5_HAVE_PARALLEL
+ }
+ else {
+ if ((f = HDfopen(fname, "r")) != NULL) {
+ rawinstream = f;
+ retvalue = SUCCEED;
}
- else if(!HDstrcmp(driver, drivernames[MPIO_IDX])) {
- /* MPI-I/O Driver */
- /* check if MPI has been initialized. */
- if(!h5tools_mpi_init_g)
- MPI_Initialized(&h5tools_mpi_init_g);
- if(h5tools_mpi_init_g) {
- if(H5Pset_fapl_mpio(new_fapl, MPI_COMM_WORLD, MPI_INFO_NULL) < 0)
- goto error;
-
- if(drivernum)
- *drivernum = MPIO_IDX;
- } /* end if */
+ }
}
- else if (!HDstrcmp(driver, drivernames[MPIPOSIX_IDX])) {
- /* MPI-I/O Driver */
- /* check if MPI has been initialized. */
- if(!h5tools_mpi_init_g)
- MPI_Initialized(&h5tools_mpi_init_g);
- if(h5tools_mpi_init_g) {
- if(H5Pset_fapl_mpiposix(new_fapl, MPI_COMM_WORLD, TRUE) < 0)
- goto error;
-
- if(drivernum)
- *drivernum = MPIPOSIX_IDX;
- } /* end if */
-#endif /* H5_HAVE_PARALLEL */
+ else {
+ rawinstream = NULL;
+ retvalue = SUCCEED;
+ }
+
+ return retvalue;
+}
+
+/*-------------------------------------------------------------------------
+ * Function: h5tools_set_output_file
+ *
+ * Purpose: Open fname as the output file for raw output.
+ * Set rawoutstream as its file stream.
+ *
+ * Return: 0 -- succeeded
+ * negative -- failed
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+h5tools_set_output_file(const char *fname, int is_bin)
+{
+ int retvalue = FAIL;
+ FILE *f; /* temporary holding place for the stream pointer
+ * so that rawoutstream is changed only when succeeded */
+
+ if (rawoutstream && rawoutstream != stdout) {
+ if (HDfclose(rawoutstream))
+ HDperror("closing rawoutstream");
+ else
+ rawoutstream = NULL;
+ }
+ /* First check if filename is string "NULL" */
+ if (fname != NULL) {
+ /* binary output */
+ if (is_bin) {
+ if ((f = HDfopen(fname, "wb")) != NULL) {
+ rawoutstream = f;
+ retvalue = SUCCEED;
+ }
+ }
+ else {
+ if ((f = HDfopen(fname, "w")) != NULL) {
+ rawoutstream = f;
+ retvalue = SUCCEED;
+ }
+ }
}
else {
- goto error;
+ rawoutstream = NULL;
+ retvalue = SUCCEED;
}
- return(new_fapl);
+ return retvalue;
+}
-error:
- if(new_fapl != H5P_DEFAULT)
- H5Pclose(new_fapl);
- return -1;
+/*-------------------------------------------------------------------------
+ * Function: h5tools_set_error_file
+ *
+ * Purpose: Open fname as the error output file for dataset raw error.
+ * Set rawerrorstream as its file stream.
+ *
+ * Return: 0 -- succeeded
+ * negative -- failed
+ *-------------------------------------------------------------------------
+ */
+int
+h5tools_set_error_file(const char *fname, int is_bin)
+{
+ int retvalue = FAIL;
+ FILE *f; /* temporary holding place for the stream pointer
+ * so that rawerrorstream is changed only when succeeded */
+
+ if (rawerrorstream && rawerrorstream != stderr) {
+ if (HDfclose(rawerrorstream))
+ HDperror("closing rawerrorstream");
+ else
+ rawerrorstream = NULL;
+ }
+
+ /* First check if filename is string "NULL" */
+ if (fname != NULL) {
+ /* binary output */
+ if (is_bin) {
+ if ((f = HDfopen(fname, "wb")) != NULL) {
+ rawerrorstream = f;
+ retvalue = SUCCEED;
+ }
+ }
+ else {
+ if ((f = HDfopen(fname, "w")) != NULL) {
+ rawerrorstream = f;
+ retvalue = SUCCEED;
+ }
+ }
+ }
+ else {
+ rawerrorstream = NULL;
+ retvalue = SUCCEED;
+ }
+
+ return retvalue;
}
/*-------------------------------------------------------------------------
- * Audience: Public
- * Chapter: H5Tools Library
- * Purpose: Open a file with various VFL drivers.
- * Description:
- * Loop through the various types of VFL drivers trying to open FNAME.
- * If the HDF5 library is version 1.2 or less, then we have only the SEC2
- * driver to try out. If the HDF5 library is greater than version 1.2,
- * then we have the FAMILY, SPLIT, and MULTI drivers to play with (and
- * the STREAM driver if H5_HAVE_STREAM is defined, that is).
- *
- * If DRIVER is non-NULL, then it will try to open the file with that
- * driver first. We assume that the user knows what they are doing so, if
- * we fail, then we won't try other file drivers.
- * Return:
- * On success, returns a file id for the opened file. If DRIVERNAME is
- * non-null then the first DRIVERNAME_SIZE-1 characters of the driver
- * name are copied into the DRIVERNAME array and null terminated.
- *
- * Otherwise, the function returns FAIL. If DRIVERNAME is non-null then
- * the first byte is set to the null terminator.
- * Programmer:
- * Lost in the mists of time.
- * Modifications:
- * Robb Matzke, 2000-06-23
- * We only have to initialize driver[] on the first call, thereby
- * preventing memory leaks from repeated calls to H5Pcreate().
- *
- * Robb Matzke, 2000-06-23
- * Added DRIVERNAME_SIZE arg to prevent overflows when writing to
- * DRIVERNAME.
- *
- * Robb Matzke, 2000-06-23
- * Added test to prevent coredump when the file could not be opened by
- * any driver.
- *
- * Robb Matzke, 2000-06-23
- * Changed name from H5ToolsFopen() so it jives better with the names we
- * already have at the top of this source file.
- *
- * Thomas Radke, 2000-09-12
- * Added Stream VFD to the driver[] array.
- *
- * Bill Wendling, 2001-01-10
- * Changed macro behavior so that if we have a version other than 1.2.x
- * (i.e., > 1.2), then we do the drivers check.
- *
- * Bill Wendling, 2001-07-30
- * Added DRIVER parameter so that the user can specify "try this driver"
- * instead of the default behaviour. If it fails to open the file with
- * that driver, this will fail completely (i.e., we won't try the other
- * drivers). We're assuming the user knows what they're doing. How UNIX
- * of us.
+ * Function: h5tools_set_fapl_vfd
+ *
+ * Purpose: Given a VFL driver name or ID, sets the appropriate driver on
+ * the specified FAPL.
+ *
+ * Return: positive - succeeded
+ * negative - failed
*-------------------------------------------------------------------------
*/
-hid_t
-h5tools_fopen(const char *fname, unsigned flags, hid_t fapl, const char *driver,
- char *drivername, size_t drivername_size)
+static herr_t
+h5tools_set_fapl_vfd(hid_t fapl_id, h5tools_vfd_info_t *vfd_info)
{
- unsigned drivernum;
- hid_t fid = FAIL;
- hid_t my_fapl = H5P_DEFAULT;
+ herr_t ret_value = SUCCEED;
+
+ switch (vfd_info->type) {
+ case VFD_BY_NAME:
+ /* Determine which driver the user wants to open the file with */
+ if (!HDstrcmp(vfd_info->u.name, drivernames[SEC2_VFD_IDX])) {
+ /* SEC2 Driver */
+ if (H5Pset_fapl_sec2(fapl_id) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_sec2 failed");
+ }
+ else if (!HDstrcmp(vfd_info->u.name, drivernames[DIRECT_VFD_IDX])) {
+#ifdef H5_HAVE_DIRECT
+ /* Direct Driver */
+ if (H5Pset_fapl_direct(fapl_id, 1024, 4096, 8 * 4096) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_direct failed");
+#else
+ H5TOOLS_GOTO_ERROR(FAIL, "Direct VFD is not enabled");
+#endif
+ }
+ else if (!HDstrcmp(vfd_info->u.name, drivernames[LOG_VFD_IDX])) {
+ unsigned long long log_flags = H5FD_LOG_LOC_IO | H5FD_LOG_ALLOC;
- if (driver && *driver) {
- /* Get the correct FAPL for the given driver */
- if ((my_fapl = h5tools_get_fapl(fapl, driver, &drivernum)) < 0)
- goto done;
+ /* Log Driver */
+ if (H5Pset_fapl_log(fapl_id, NULL, log_flags, (size_t)0) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_log failed");
+ }
+ else if (!HDstrcmp(vfd_info->u.name, drivernames[WINDOWS_VFD_IDX])) {
+#ifdef H5_HAVE_WINDOWS
+ /* There is no Windows VFD - use SEC2 */
+ if (H5Pset_fapl_sec2(fapl_id) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_sec2 failed");
+#else
+ H5TOOLS_GOTO_ERROR(FAIL, "Windows VFD is not enabled");
+#endif
+ }
+ else if (!HDstrcmp(vfd_info->u.name, drivernames[STDIO_VFD_IDX])) {
+ /* Stdio Driver */
+ if (H5Pset_fapl_stdio(fapl_id) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_stdio failed");
+ }
+ else if (!HDstrcmp(vfd_info->u.name, drivernames[CORE_VFD_IDX])) {
+ /* Core Driver */
+ if (H5Pset_fapl_core(fapl_id, (size_t)H5_MB, TRUE) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_core failed");
+ }
+ else if (!HDstrcmp(vfd_info->u.name, drivernames[FAMILY_VFD_IDX])) {
+ /* FAMILY Driver */
+ /* Set member size to be 0 to indicate the current first member size
+ * is the member size.
+ */
+ if (H5Pset_fapl_family(fapl_id, (hsize_t)0, H5P_DEFAULT) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_family failed");
+ }
+ else if (!HDstrcmp(vfd_info->u.name, drivernames[SPLIT_VFD_IDX])) {
+ /* SPLIT Driver */
+ if (H5Pset_fapl_split(fapl_id, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_split failed");
+ }
+ else if (!HDstrcmp(vfd_info->u.name, drivernames[MULTI_VFD_IDX])) {
+ /* MULTI Driver */
+ if (H5Pset_fapl_multi(fapl_id, NULL, NULL, NULL, NULL, TRUE) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_multi failed");
+ }
+ else if (!HDstrcmp(vfd_info->u.name, drivernames[MPIO_VFD_IDX])) {
+#ifdef H5_HAVE_PARALLEL
+ int mpi_initialized, mpi_finalized;
- H5E_BEGIN_TRY {
- fid = H5Fopen(fname, flags, my_fapl);
- } H5E_END_TRY;
+ /* MPI-I/O Driver */
- if (fid == FAIL)
- goto done;
+ /* check if MPI is available. */
+ MPI_Initialized(&mpi_initialized);
+ MPI_Finalized(&mpi_finalized);
+ if (mpi_initialized && !mpi_finalized) {
+ if (H5Pset_fapl_mpio(fapl_id, MPI_COMM_WORLD, MPI_INFO_NULL) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_mpio failed");
+ }
+#else
+ H5TOOLS_GOTO_ERROR(FAIL, "MPI-I/O VFD is not enabled");
+#endif /* H5_HAVE_PARALLEL */
+ }
+ else if (!HDstrcmp(vfd_info->u.name, drivernames[ROS3_VFD_IDX])) {
+#ifdef H5_HAVE_ROS3_VFD
+ if (!vfd_info->info)
+ H5TOOLS_GOTO_ERROR(FAIL, "Read-only S3 VFD info is invalid");
+ if (H5Pset_fapl_ros3(fapl_id, (const H5FD_ros3_fapl_t *)vfd_info->info) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_ros3() failed");
+#else
+ H5TOOLS_GOTO_ERROR(FAIL, "Read-only S3 VFD is not enabled");
+#endif
+ }
+ else if (!HDstrcmp(vfd_info->u.name, drivernames[HDFS_VFD_IDX])) {
+#ifdef H5_HAVE_LIBHDFS
+ if (!vfd_info->info)
+ H5TOOLS_GOTO_ERROR(FAIL, "HDFS VFD info is invalid");
+ if (H5Pset_fapl_hdfs(fapl_id, (H5FD_hdfs_fapl_t *)vfd_info->info) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_hdfs() failed");
+#else
+ H5TOOLS_GOTO_ERROR(FAIL, "The HDFS VFD is not enabled");
+#endif
+ }
+ else if (!HDstrcmp(vfd_info->u.name, drivernames[SUBFILING_VFD_IDX])) {
+#if defined(H5_HAVE_PARALLEL) && defined(H5_HAVE_SUBFILING_VFD)
+ int mpi_initialized, mpi_finalized;
+
+ /* check if MPI is available. */
+ MPI_Initialized(&mpi_initialized);
+ MPI_Finalized(&mpi_finalized);
+
+ if (mpi_initialized && !mpi_finalized) {
+ if (H5Pset_fapl_subfiling(fapl_id, (const H5FD_subfiling_config_t *)vfd_info->info) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_subfiling() failed");
+ }
+#else
+ H5TOOLS_GOTO_ERROR(FAIL, "The Subfiling VFD is not enabled");
+#endif
+ }
+ else if (!HDstrcmp(vfd_info->u.name, drivernames[ONION_VFD_IDX])) {
+ /* Onion driver */
+ if (!vfd_info->info)
+ H5TOOLS_GOTO_ERROR(FAIL, "Onion VFD info is invalid");
+ if (H5Pset_fapl_onion(fapl_id, (const H5FD_onion_fapl_info_t *)vfd_info->info) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_onion() failed");
+ }
+ else {
+ /*
+ * Try to load VFD plugin.
+ *
+ * Currently, driver configuration strings are unsupported.
+ */
+ if (H5Pset_driver_by_name(fapl_id, vfd_info->u.name, (const char *)vfd_info->info) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "can't load VFD plugin by driver name '%s'", vfd_info->u.name);
+ }
+
+ break;
+
+ case VFD_BY_VALUE:
+ /*
+ * Try to load VFD plugin.
+ *
+ * Currently, driver configuration strings are unsupported.
+ */
+ if (H5Pset_driver_by_value(fapl_id, vfd_info->u.value, (const char *)vfd_info->info) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "can't load VFD plugin by driver value '%ld'",
+ (long int)vfd_info->u.value);
+ break;
+
+ default:
+ H5TOOLS_GOTO_ERROR(FAIL, "invalid VFD retrieval type");
}
- else {
- /* Try to open the file using each of the drivers */
- for (drivernum = 0; drivernum < NUM_DRIVERS; drivernum++) {
- /* Get the correct FAPL for the given driver */
- if((my_fapl = h5tools_get_fapl(fapl, drivernames[drivernum], NULL)) < 0)
- goto done;
- H5E_BEGIN_TRY {
- fid = H5Fopen(fname, flags, my_fapl);
- } H5E_END_TRY;
+done:
+ if (ret_value < 0) {
+ /* Clear error message unless asked for */
+ if ((H5tools_ERR_STACK_g >= 0) && (enable_error_stack <= 1))
+ H5Epop(H5tools_ERR_STACK_g, 1);
+ }
- if (fid != FAIL)
- break;
+ return ret_value;
+}
+
+/*-------------------------------------------------------------------------
+ * Function: h5tools_set_fapl_vol
+ *
+ * Purpose: Given a VOL connector name or ID, sets the appropriate
+ * connector on the specified FAPL.
+ *
+ * Return: positive - succeeded
+ * negative - failed
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+h5tools_set_fapl_vol(hid_t fapl_id, h5tools_vol_info_t *vol_info)
+{
+ htri_t connector_is_registered;
+ hid_t connector_id = H5I_INVALID_HID;
+ void *connector_info = NULL;
+ herr_t ret_value = SUCCEED;
+
+ switch (vol_info->type) {
+ case VOL_BY_NAME:
+ /* Retrieve VOL connector by name */
+ if ((connector_is_registered = H5VLis_connector_registered_by_name(vol_info->u.name)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "can't check if VOL connector is registered");
+ if (connector_is_registered) {
+ if ((connector_id = H5VLget_connector_id_by_name(vol_info->u.name)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "can't get VOL connector ID");
+ }
else {
- /* Close the FAPL */
- H5Pclose(my_fapl);
- my_fapl = H5P_DEFAULT;
- } /* end else */
+ /* Check for VOL connectors that ship with the library, then try
+ * registering by name if that fails.
+ */
+ if (!HDstrcmp(vol_info->u.name, H5VL_NATIVE_NAME)) {
+ connector_id = H5VL_NATIVE;
+ }
+ else if (!HDstrcmp(vol_info->u.name, H5VL_PASSTHRU_NAME)) {
+ connector_id = H5VL_PASSTHRU;
+ }
+ else {
+ /* NOTE: Not being able to pass in a VIPL may be a limitation for some
+ * connectors.
+ */
+ if ((connector_id = H5VLregister_connector_by_name(vol_info->u.name, H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "can't register VOL connector");
+ }
+ }
+
+ break;
+
+ case VOL_BY_VALUE:
+ /* Retrieve VOL connector by ID */
+ if ((connector_is_registered = H5VLis_connector_registered_by_value(vol_info->u.value)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "can't check if VOL connector is registered");
+ if (connector_is_registered) {
+ if ((connector_id = H5VLget_connector_id_by_value(vol_info->u.value)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "can't get VOL connector ID");
+ }
+ else {
+ /* Check for VOL connectors that ship with the library */
+ if (vol_info->u.value == H5VL_NATIVE_VALUE) {
+ connector_id = H5VL_NATIVE;
+ }
+ else if (vol_info->u.value == H5VL_PASSTHRU_VALUE) {
+ connector_id = H5VL_PASSTHRU;
+ }
+ else {
+ /* NOTE: Not being able to pass in a VIPL may be a limitation for some
+ * connectors.
+ */
+ if ((connector_id = H5VLregister_connector_by_value(vol_info->u.value, H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "can't register VOL connector");
+ }
+ }
+
+ break;
+
+ default:
+ H5TOOLS_GOTO_ERROR(FAIL, "invalid VOL retrieval type");
+ }
+
+ /* Convert the info string, if provided */
+ if (vol_info->info_string)
+ if (H5VLconnector_str_to_info(vol_info->info_string, connector_id, &connector_info) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "can't get VOL connector info from string");
+
+ /* Set the VOL connector on the fapl */
+ if (H5Pset_vol(fapl_id, connector_id, connector_info) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "can't set VOL connector on FAPL");
+
+done:
+ if (connector_info)
+ if (H5VLfree_connector_info(connector_id, connector_info))
+ H5TOOLS_ERROR(FAIL, "failed to free VOL connector-specific info");
+
+ if (ret_value < 0) {
+ if (connector_id >= 0 && H5Idec_ref(connector_id) < 0)
+ H5TOOLS_ERROR(FAIL, "failed to decrement refcount on VOL connector ID");
+
+ /* Clear error message unless asked for */
+ if ((H5tools_ERR_STACK_g >= 0) && (enable_error_stack <= 1))
+ H5Epop(H5tools_ERR_STACK_g, 1);
+ }
+
+ return ret_value;
+}
+
+/*-------------------------------------------------------------------------
+ * Function: h5tools_get_fapl
+ *
+ * Purpose: Copies an input fapl and then sets a VOL and/or a VFD on it.
+ *
+ * The returned fapl must be closed by the caller.
+ *
+ * Return: positive - succeeded
+ * negative - failed
+ *-------------------------------------------------------------------------
+ */
+hid_t
+h5tools_get_fapl(hid_t prev_fapl_id, h5tools_vol_info_t *vol_info, h5tools_vfd_info_t *vfd_info)
+{
+ hid_t new_fapl_id = H5I_INVALID_HID;
+ hid_t ret_value = H5I_INVALID_HID;
+
+ if (prev_fapl_id < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "invalid FAPL");
+
+ /* Make a copy of the FAPL or create one if H5P_DEFAULT is specified. */
+ if (H5P_DEFAULT == prev_fapl_id) {
+ if ((new_fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "H5Pcreate failed");
+ }
+ else {
+ if ((new_fapl_id = H5Pcopy(prev_fapl_id)) < 0)
+ H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "H5Pcopy failed");
+ }
+
+ /* Set non-default VOL connector, if requested */
+ if (vol_info)
+ if (h5tools_set_fapl_vol(new_fapl_id, vol_info) < 0)
+ H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "failed to set VOL on FAPL");
+
+ /* Set non-default virtual file driver, if requested */
+ if (vfd_info)
+ if (h5tools_set_fapl_vfd(new_fapl_id, vfd_info) < 0)
+ H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "failed to set VFD on FAPL");
+
+ ret_value = new_fapl_id;
+
+done:
+ if (ret_value < 0) {
+ if (new_fapl_id >= 0) {
+ H5Pclose(new_fapl_id);
+ new_fapl_id = H5I_INVALID_HID;
}
+
+ /* Clear error message unless asked for */
+ if ((H5tools_ERR_STACK_g >= 0) && (enable_error_stack <= 1))
+ H5Epop(H5tools_ERR_STACK_g, 1);
}
- /* Save the driver name */
- if (drivername && drivername_size) {
- if (fid != FAIL) {
- HDstrncpy(drivername, drivernames[drivernum], drivername_size);
- drivername[drivername_size - 1] = '\0';
+ return ret_value;
+}
+
+/*-------------------------------------------------------------------------
+ * Function: h5tools_get_vfd_name
+ *
+ * Purpose: Given a FAPL, retrieves the name of the VFL driver set on it
+ * if using a native-terminal VOL connector. If a
+ * non-native-terminal VOL connector is set on the FAPL, the
+ * first byte of the returned driver name will be set to the null
+ * terminator.
+ *
+ * Return: SUCCEED/FAIL
+ *-------------------------------------------------------------------------
+ */
+herr_t
+h5tools_get_vfd_name(hid_t fid, hid_t fapl_id, char *drivername, size_t drivername_size)
+{
+ hid_t fapl_vol_id = H5I_INVALID_HID;
+ hbool_t is_native = FALSE;
+ herr_t ret_value = SUCCEED;
+
+ if (fapl_id < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "invalid FAPL");
+ if (!drivername)
+ H5TOOLS_GOTO_ERROR(FAIL, "drivername is NULL");
+ if (drivername && !drivername_size)
+ H5TOOLS_GOTO_ERROR(FAIL, "drivername_size must be non-zero");
+
+ /* Initialize the driver name */
+ drivername[0] = '\0';
+
+ if (fapl_id == H5P_DEFAULT)
+ fapl_id = H5P_FILE_ACCESS_DEFAULT;
+
+ /* Retrieve ID of the VOL connector set on the FAPL */
+ if (H5Pget_vol_id(fapl_id, &fapl_vol_id) < 0)
+ H5TOOLS_ERROR(FAIL, "failed to retrieve VOL ID from FAPL");
+
+ /* Query if the file ID is native-terminal */
+ if (H5VLobject_is_native(fid, &is_native) < 0)
+ H5TOOLS_ERROR(FAIL, "failed to determine if file ID is native-terminal");
+
+ if (is_native) {
+ const char *driver_name;
+ hid_t driver_id;
+
+ if ((driver_id = H5Pget_driver(fapl_id)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "failed to retrieve VFL driver ID from FAPL");
+
+ if (driver_id == H5FD_SEC2)
+ driver_name = drivernames[SEC2_VFD_IDX];
+#ifdef H5_HAVE_DIRECT
+ else if (driver_id == H5FD_DIRECT)
+ driver_name = drivernames[DIRECT_VFD_IDX];
+#endif
+ else if (driver_id == H5FD_LOG)
+ driver_name = drivernames[LOG_VFD_IDX];
+#ifdef H5_HAVE_WINDOWS
+ else if (driver_id == H5FD_WINDOWS)
+ driver_name = drivernames[WINDOWS_VFD_IDX];
+#endif
+ else if (driver_id == H5FD_STDIO)
+ driver_name = drivernames[STDIO_VFD_IDX];
+ else if (driver_id == H5FD_CORE)
+ driver_name = drivernames[CORE_VFD_IDX];
+ else if (driver_id == H5FD_FAMILY)
+ driver_name = drivernames[FAMILY_VFD_IDX];
+ else if (driver_id == H5FD_MULTI)
+ driver_name = drivernames[MULTI_VFD_IDX];
+#ifdef H5_HAVE_PARALLEL
+ else if (driver_id == H5FD_MPIO)
+ driver_name = drivernames[MPIO_VFD_IDX];
+#endif
+#ifdef H5_HAVE_ROS3_VFD
+ else if (driver_id == H5FD_ROS3)
+ driver_name = drivernames[ROS3_VFD_IDX];
+#endif
+#ifdef H5_HAVE_LIBHDFS
+ else if (driver_id == H5FD_HDFS)
+ driver_name = drivernames[HDFS_VFD_IDX];
+#endif
+#ifdef H5_HAVE_SUBFILING_VFD
+ else if (driver_id == H5FD_SUBFILING)
+ driver_name = drivernames[SUBFILING_VFD_IDX];
+#endif
+ else if (driver_id == H5FD_ONION)
+ driver_name = drivernames[ONION_VFD_IDX];
+ else
+ driver_name = "unknown";
+
+ HDstrncpy(drivername, driver_name, drivername_size);
+ drivername[drivername_size - 1] = '\0';
+ }
+
+done:
+ /* Close retrieved VOL ID */
+ if (fapl_vol_id >= 0)
+ if (H5VLclose(fapl_vol_id) < 0)
+ H5TOOLS_ERROR(FAIL, "failed to close VOL ID");
+
+ return ret_value;
+}
+
+/*-------------------------------------------------------------------------
+ * Function: h5tools_fopen
+ *
+ * Purpose: Opens file FNAME using the specified flags and FAPL.
+ *
+ * The 'use_specific_driver' parameter is used to control the
+ * VFD/VOL connector that this routine uses to open the file
+ * with. If 'use_specific_driver' is set to TRUE, this routine
+ * assumes that the caller has already set a specific VFD or VOL
+ * connector on the given FAPL and will attempt to directly use
+ * the FAPL for opening the file. We assume that the caller knows
+ * what they are doing; if the file is unable to be opened using
+ * that FAPL, this routine will return H5I_INVALID_HID.
+ *
+ * However, if 'use_specific_driver' is set to FALSE, this
+ * routine assumes that the caller HAS NOT set a specific VFD or
+ * VOL connector on the given FAPL and will instead loop through
+ * the various available VFL drivers and VOL connectors trying to
+ * open FNAME.
+ *
+ * The list of available VFL drivers is as follows:
+ * - If the HDF5 library is version 1.2 or less, then we have
+ * only the SEC2 driver to try out.
+ * - If the HDF5 library is greater than version 1.2, then we
+ * have the FAMILY, SPLIT, and MULTI drivers to play with.
+ *
+ * The list of available VOL connectors is as follows:
+ * - "Native" VOL connector
+ * - Pass-through VOL connector
+ *
+ * Return:
+ * On success, returns a file ID for the opened file. If DRIVERNAME is
+ * non-null and the native VOL connector is the terminal connector,
+ * then the first DRIVERNAME_SIZE-1 characters of the driver name are
+ * copied into the DRIVERNAME array and null terminated. If the
+ * native VOL connector is NOT the terminal connector, then the first
+ * byte of DRIVERNAME will be set to the null terminator.
+ *
+ * On failure, the function returns H5I_INVALID_HID and DRIVERNAME
+ * will not be set.
+ *-------------------------------------------------------------------------
+ */
+hid_t
+h5tools_fopen(const char *fname, unsigned flags, hid_t fapl_id, hbool_t use_specific_driver, char *drivername,
+ size_t drivername_size)
+{
+ hid_t fid = H5I_INVALID_HID;
+ hid_t tmp_fapl_id = H5I_INVALID_HID;
+ hid_t used_fapl_id = H5I_INVALID_HID;
+ unsigned volnum, drivernum;
+ hid_t ret_value = H5I_INVALID_HID;
+
+ /*
+ * First try to open the file using just the given FAPL. If the
+ * HDF5_VOL_CONNECTOR environment variable has been set, this will
+ * allow us to attempt to open the file using the specified VOL
+ * connector before we go looping through all available ones,
+ * which will override any VOL connector set by use of the
+ * environment variable.
+ */
+
+ /* Allow error stack display if --enable-error-stack has optional arg number */
+ if (enable_error_stack > 1) {
+ fid = H5Fopen(fname, flags, fapl_id);
+ }
+ else {
+ H5E_BEGIN_TRY
+ {
+ fid = H5Fopen(fname, flags, fapl_id);
+ }
+ H5E_END_TRY;
+ }
+
+ /* If we succeeded in opening the file, we're done. */
+ if (fid >= 0) {
+ used_fapl_id = fapl_id;
+ H5TOOLS_GOTO_DONE(fid);
+ }
+
+ /*
+ * If we failed to open the file and the caller specified 'use_specific_driver'
+ * as TRUE, we should return failure now since the file couldn't be opened with
+ * the VFL driver/VOL connector that was set on the FAPL by the caller.
+ */
+ if (use_specific_driver)
+ H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "failed to open file using specified FAPL");
+
+ /*
+ * As a final resort, try to open the file using each of the available
+ * VOL connectors. When the native VOL connector is the current "terminal"
+ * connector being looked at, also try using each of the available VFL drivers.
+ */
+ for (volnum = 0; volnum < NUM_VOLS; volnum++) {
+ h5tools_vol_info_t vol_info;
+
+ vol_info.type = VOL_BY_NAME;
+ vol_info.info_string = NULL;
+ vol_info.u.name = volnames[volnum];
+
+ /* TODO: For now, we have no way of determining if an arbitrary
+ * VOL connector is native-terminal so we only try VFDs with the
+ * actual native VOL connector.
+ */
+ if (NATIVE_VOL_IDX == volnum) {
+ /*
+ * If using the native VOL connector, or a VOL connector which has the
+ * native connector as its terminal connector, loop through all of the
+ * VFL drivers as well.
+ */
+ for (drivernum = 0; drivernum < NUM_DRIVERS; drivernum++) {
+ h5tools_vfd_info_t vfd_info;
+
+ /* Skip the log VFD as it prints out to standard out
+ * and is fundamentally SEC2 anyway.
+ */
+ if (drivernum == LOG_VFD_IDX)
+ continue;
+
+ vfd_info.type = VFD_BY_NAME;
+ vfd_info.info = NULL;
+ vfd_info.u.name = drivernames[drivernum];
+
+ /* Get a fapl reflecting the selected VOL connector and VFD */
+ if ((tmp_fapl_id = h5tools_get_fapl(fapl_id, &vol_info, &vfd_info)) < 0)
+ continue;
+
+ /* Can we open the file with this combo? */
+ H5E_BEGIN_TRY
+ {
+ fid = h5tools_fopen(fname, flags, tmp_fapl_id, TRUE, drivername, drivername_size);
+ }
+ H5E_END_TRY;
+
+ if (fid >= 0) {
+ used_fapl_id = tmp_fapl_id;
+ H5TOOLS_GOTO_DONE(fid);
+ }
+ else {
+ /* Close the temporary fapl */
+ H5Pclose(tmp_fapl_id);
+ tmp_fapl_id = H5I_INVALID_HID;
+ }
+ }
}
else {
- /*no file opened*/
- drivername[0] = '\0';
+ /* NOT the native VOL connector */
+
+ /* Get a FAPL for the current VOL connector */
+ if ((tmp_fapl_id = h5tools_get_fapl(fapl_id, &vol_info, NULL)) < 0)
+ continue;
+
+ /* Can we open the file with this connector? */
+ if ((fid = h5tools_fopen(fname, flags, tmp_fapl_id, TRUE, drivername, drivername_size)) >= 0) {
+ used_fapl_id = tmp_fapl_id;
+ H5TOOLS_GOTO_DONE(fid);
+ }
+ else {
+ /* Close the temporary VOL FAPL */
+ H5Pclose(tmp_fapl_id);
+ tmp_fapl_id = H5I_INVALID_HID;
+ }
}
}
+ /* File was unable to be opened at all */
+ ret_value = H5I_INVALID_HID;
+
done:
- if(my_fapl != H5P_DEFAULT)
- H5Pclose(my_fapl);
+ /* Save the driver name if using a native-terminal VOL connector */
+ if (drivername && drivername_size && ret_value >= 0)
+ if (used_fapl_id >= 0 &&
+ h5tools_get_vfd_name(ret_value, used_fapl_id, drivername, drivername_size) < 0)
+ H5TOOLS_ERROR(H5I_INVALID_HID, "failed to retrieve name of VFD used to open file");
+
+ if (tmp_fapl_id >= 0)
+ H5Pclose(tmp_fapl_id);
+
+ /* Clear error message unless asked for */
+ if (ret_value < 0) {
+ if ((H5tools_ERR_STACK_g >= 0) && (enable_error_stack <= 1))
+ H5Epop(H5tools_ERR_STACK_g, 1);
+ }
- return fid;
+ return ret_value;
}
/*-------------------------------------------------------------------------
- * Audience: Public
- * Chapter: H5Tools Library
- * Purpose: Count the number of columns in a string.
- * Description:
- * Count the number of columns in a string. This is the number of
- * characters in the string not counting line-control characters.
- * Return:
- * On success, returns the width of the string. Otherwise this function
- * returns 0.
- * Programmer:
- * Robb Matzke, Tuesday, April 27, 1999
- * Modifications:
+ * Function: h5tools_count_ncols
+ *
+ * Purpose: Count the number of columns in a string. This is the number of
+ * characters in the string not counting line-control characters.
+ *
+ * Return: success - returns the width of the string.
+ * failure - 0.
*-------------------------------------------------------------------------
*/
-static size_t
+H5_ATTR_PURE static size_t
h5tools_count_ncols(const char *s)
{
- register size_t i;
+ size_t i;
for (i = 0; *s; s++)
if (*s >= ' ')
@@ -452,29 +1116,26 @@ h5tools_count_ncols(const char *s)
/*-------------------------------------------------------------------------
* Function: h5tools_detect_vlen
*
- * Purpose: Recursive check for any variable length data in given type.
- *
- * Return:
- * TRUE : type conatains any variable length data
- * FALSE : type doesn't contain any variable length data
- * Negative value: error occur
+ * Purpose: Recursive check for any variable length data in given type.
*
- * Programmer: Jonathan Kim March 18, 2011
+ * Return: TRUE : type contains any variable length data
+ * FALSE : type doesn't contain any variable length data
+ * Negative value: failed
*-------------------------------------------------------------------------
*/
htri_t
h5tools_detect_vlen(hid_t tid)
{
- htri_t ret;
+ htri_t ret = FALSE;
/* recursive detect any vlen data values in type (compound, array ...) */
ret = H5Tdetect_class(tid, H5T_VLEN);
- if((ret == TRUE) || (ret < 0))
+ if ((ret == TRUE) || (ret < 0))
goto done;
/* recursive detect any vlen string in type (compound, array ...) */
ret = h5tools_detect_vlen_str(tid);
- if((ret == TRUE) || (ret < 0))
+ if ((ret == TRUE) || (ret < 0))
goto done;
done:
@@ -484,53 +1145,53 @@ done:
/*-------------------------------------------------------------------------
* Function: h5tools_detect_vlen_str
*
- * Purpose: Recursive check for variable length string of a datatype.
- *
- * Return:
- * TRUE : type conatains any variable length string
- * FALSE : type doesn't contain any variable length string
- * Negative value: error occur
+ * Purpose: Recursive check for variable length string of a datatype.
*
+ * Return: TRUE : type contains any variable length string
+ * FALSE : type doesn't contain any variable length string
+ * Negative value: failed
*-------------------------------------------------------------------------
*/
htri_t
h5tools_detect_vlen_str(hid_t tid)
{
H5T_class_t tclass = -1;
- htri_t ret = FALSE;
+ htri_t ret = FALSE;
ret = H5Tis_variable_str(tid);
- if((ret == TRUE) || (ret < 0))
+ if ((ret == TRUE) || (ret < 0))
goto done;
tclass = H5Tget_class(tid);
- if(tclass == H5T_ARRAY || tclass == H5T_VLEN) {
+ if (tclass == H5T_ARRAY || tclass == H5T_VLEN) {
hid_t btid = H5Tget_super(tid);
- if(btid < 0) {
+ if (btid < 0) {
ret = (htri_t)btid;
goto done;
}
ret = h5tools_detect_vlen_str(btid);
- if((ret == TRUE) || (ret < 0)) {
+ if ((ret == TRUE) || (ret < 0)) {
H5Tclose(btid);
goto done;
}
}
- else if(tclass == H5T_COMPOUND) {
- int i = 0;
- int n = H5Tget_nmembers(tid);
+ else if (tclass == H5T_COMPOUND) {
+ unsigned nmembs;
+ int snmembs = H5Tget_nmembers(tid);
+ unsigned u;
- if(n < 0) {
- n = ret;
+ if (snmembs < 0) {
+ ret = FAIL;
goto done;
}
+ nmembs = (unsigned)snmembs;
- for(i = 0; i < n; i++) {
- hid_t mtid = H5Tget_member_type(tid, i);
+ for (u = 0; u < nmembs; u++) {
+ hid_t mtid = H5Tget_member_type(tid, u);
ret = h5tools_detect_vlen_str(mtid);
- if((ret == TRUE) || (ret < 0)) {
+ if ((ret == TRUE) || (ret < 0)) {
H5Tclose(mtid);
goto done;
}
@@ -543,57 +1204,53 @@ done:
}
/*-------------------------------------------------------------------------
- * Audience: Public
- * Chapter: H5Tools Library
- * Purpose: Emit a simple prefix to STREAM.
- * Description:
- * If /ctx->need_prefix/ is set then terminate the current line (if
- * applicable), calculate the prefix string, and display it at the start
- * of a line.
- * Return:
- * None
- * Programmer:
- * Robb Matzke, Monday, April 26, 1999
- * Modifications:
- * Robb Matzke, 1999-09-29
- * If a new prefix is printed then the current element number is set back
- * to zero.
- * pvn, 2004-07-08
- * Added support for printing array indices:
- * the indentation is printed before the prefix (printed one indentation
- * level before)
+ * Function: h5tools_simple_prefix
+ *
+ * Purpose: If /ctx->need_prefix/ is set then terminate the current line (if
+ * applicable), calculate the prefix string, and display it at the start
+ * of a line.
+ *
+ * Return: None
*-------------------------------------------------------------------------
*/
void
-h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx, hsize_t elmtno, int secnum)
+h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hsize_t elmtno,
+ int secnum)
{
h5tools_str_t prefix;
h5tools_str_t str; /*temporary for indentation */
- size_t templength = 0;
- int i, indentlevel = 0;
+ size_t templength = 0;
+ unsigned u, indentlevel = 0;
+
+ if (stream == NULL)
+ return;
if (!ctx->need_prefix)
return;
+ H5TOOLS_START_DEBUG(" ");
+
HDmemset(&prefix, 0, sizeof(h5tools_str_t));
HDmemset(&str, 0, sizeof(h5tools_str_t));
/* Terminate previous line, if any */
+ H5TOOLS_DEBUG("before CR elmtno=%ld, ctx->cur_column=%d, info->idx_fmt=%s, info->line_suf=%s", elmtno,
+ ctx->cur_column, info->idx_fmt, info->line_suf);
if (ctx->cur_column) {
- HDfputs(OPT(info->line_suf, ""), stream);
+ PUTSTREAM(OPT(info->line_suf, ""), stream);
HDputc('\n', stream);
- HDfputs(OPT(info->line_sep, ""), stream);
+ PUTSTREAM(OPT(info->line_sep, ""), stream);
}
+ H5TOOLS_DEBUG("after CR elmtno=%ld, ctx->ndims=%d", elmtno, ctx->ndims);
/* Calculate new prefix */
- h5tools_str_prefix(&prefix, info, elmtno, ctx->ndims, ctx);
+ h5tools_str_prefix(&prefix, info, elmtno, ctx);
+ H5TOOLS_DEBUG("prefix=%s - str=%s", prefix.s, str.s);
/* Write new prefix to output */
- if (ctx->indent_level >= 0) {
+ if (ctx->indent_level > 0)
indentlevel = ctx->indent_level;
- }
- else {
+ else
/*
* This is because sometimes we don't print out all the header
* info for the data (like the tattr-2.ddl example). If that happens
@@ -601,29 +1258,27 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info,
* just print out the default indent levels.
*/
indentlevel = ctx->default_indent_level;
- }
/* when printing array indices, print the indentation before the prefix
the prefix is printed one indentation level before */
- if (info->pindex) {
- for (i = 0; i < indentlevel - 1; i++) {
- HDfputs(h5tools_str_fmt(&str, 0, info->line_indent), stream);
- }
- }
+ if (info->pindex)
+ for (u = 0; u < indentlevel - 1; u++)
+ PUTSTREAM(h5tools_str_fmt(&str, (size_t)0, info->line_indent), stream);
if (elmtno == 0 && secnum == 0 && info->line_1st)
- HDfputs(h5tools_str_fmt(&prefix, 0, info->line_1st), stream);
+ PUTSTREAM(h5tools_str_fmt(&prefix, (size_t)0, info->line_1st), stream);
else if (secnum && info->line_cont)
- HDfputs(h5tools_str_fmt(&prefix, 0, info->line_cont), stream);
+ PUTSTREAM(h5tools_str_fmt(&prefix, (size_t)0, info->line_cont), stream);
else
- HDfputs(h5tools_str_fmt(&prefix, 0, info->line_pre), stream);
+ PUTSTREAM(h5tools_str_fmt(&prefix, (size_t)0, info->line_pre), stream);
templength = h5tools_str_len(&prefix);
+ H5TOOLS_DEBUG("prefix=%s - templength=%d", prefix.s, templength);
- for (i = 0; i < indentlevel; i++) {
+ for (u = 0; u < indentlevel; u++) {
/*we already made the indent for the array indices case */
if (!info->pindex) {
- HDfputs(h5tools_str_fmt(&prefix, 0, info->line_indent), stream);
+ PUTSTREAM(h5tools_str_fmt(&prefix, (size_t)0, info->line_indent), stream);
templength += h5tools_str_len(&prefix);
}
else {
@@ -631,36 +1286,41 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info,
templength += h5tools_str_len(&str);
}
}
+ H5TOOLS_DEBUG("prefix=%s - templength=%d", prefix.s, templength);
ctx->cur_column = ctx->prev_prefix_len = templength;
- ctx->cur_elmt = 0;
- ctx->need_prefix = 0;
+ ctx->cur_elmt = 0;
+ ctx->need_prefix = 0;
+ H5TOOLS_DEBUG("prefix=%s - str=%s", prefix.s, str.s);
/* Free string */
h5tools_str_close(&prefix);
h5tools_str_close(&str);
+
+ H5TOOLS_ENDDEBUG(" ");
}
/*-------------------------------------------------------------------------
- * Audience: Public
- * Chapter: H5Tools Library
- * Purpose: Emit a simple prefix to STREAM.
- * Description:
- * If /ctx->need_prefix/ is set then terminate the current line (if
- * applicable), calculate the prefix string, and display it at the start
- * of a line. Calls region specific function.
- * Return:
- * None
+ * Function: h5tools_region_simple_prefix
+ *
+ * Purpose: If /ctx->need_prefix/ is set then terminate the current line (if
+ * applicable), calculate the prefix string, and display it at the start
+ * of a line. Calls region specific function.
+ *
+ * Return: None
*-------------------------------------------------------------------------
*/
void
-h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx, hsize_t elmtno, hsize_t *ptdata, int secnum)
+h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
+ hsize_t elmtno, hsize_t *ptdata, int secnum)
{
h5tools_str_t prefix;
h5tools_str_t str; /*temporary for indentation */
- size_t templength = 0;
- int i, indentlevel = 0;
+ size_t templength = 0;
+ unsigned u, indentlevel = 0;
+
+ if (stream == NULL)
+ return;
if (!ctx->need_prefix)
return;
@@ -670,19 +1330,18 @@ h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info,
/* Terminate previous line, if any */
if (ctx->cur_column) {
- HDfputs(OPT(info->line_suf, ""), stream);
+ PUTSTREAM(OPT(info->line_suf, ""), stream);
HDputc('\n', stream);
- HDfputs(OPT(info->line_sep, ""), stream);
+ PUTSTREAM(OPT(info->line_sep, ""), stream);
}
/* Calculate new prefix */
- h5tools_str_region_prefix(&prefix, info, elmtno, ptdata, ctx->ndims, ctx->p_max_idx, ctx);
+ h5tools_str_region_prefix(&prefix, info, elmtno, ptdata, ctx);
/* Write new prefix to output */
- if (ctx->indent_level >= 0) {
+ if (ctx->indent_level > 0)
indentlevel = ctx->indent_level;
- }
- else {
+ else
/*
* This is because sometimes we don't print out all the header
* info for the data (like the tattr-2.ddl example). If that happens
@@ -690,40 +1349,36 @@ h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info,
* just print out the default indent levels.
*/
indentlevel = ctx->default_indent_level;
- }
/* when printing array indices, print the indentation before the prefix
the prefix is printed one indentation level before */
- if (info->pindex) {
- for (i = 0; i < indentlevel - 1; i++) {
- HDfputs(h5tools_str_fmt(&str, 0, info->line_indent), stream);
- }
- }
+ if (info->pindex)
+ for (u = 0; u < indentlevel - 1; u++)
+ PUTSTREAM(h5tools_str_fmt(&str, (size_t)0, info->line_indent), stream);
if (elmtno == 0 && secnum == 0 && info->line_1st)
- HDfputs(h5tools_str_fmt(&prefix, 0, info->line_1st), stream);
+ PUTSTREAM(h5tools_str_fmt(&prefix, (size_t)0, info->line_1st), stream);
else if (secnum && info->line_cont)
- HDfputs(h5tools_str_fmt(&prefix, 0, info->line_cont), stream);
+ PUTSTREAM(h5tools_str_fmt(&prefix, (size_t)0, info->line_cont), stream);
else
- HDfputs(h5tools_str_fmt(&prefix, 0, info->line_pre), stream);
+ PUTSTREAM(h5tools_str_fmt(&prefix, (size_t)0, info->line_pre), stream);
templength = h5tools_str_len(&prefix);
- for (i = 0; i < indentlevel; i++) {
+ for (u = 0; u < indentlevel; u++)
/*we already made the indent for the array indices case */
if (!info->pindex) {
- HDfputs(h5tools_str_fmt(&prefix, 0, info->line_indent), stream);
+ PUTSTREAM(h5tools_str_fmt(&prefix, (size_t)0, info->line_indent), stream);
templength += h5tools_str_len(&prefix);
}
else {
/*we cannot count the prefix for the array indices case */
templength += h5tools_str_len(&str);
}
- }
ctx->cur_column = ctx->prev_prefix_len = templength;
- ctx->cur_elmt = 0;
- ctx->need_prefix = 0;
+ ctx->cur_elmt = 0;
+ ctx->need_prefix = 0;
/* Free string */
h5tools_str_close(&prefix);
@@ -731,51 +1386,55 @@ h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info,
}
/*-------------------------------------------------------------------------
- * Audience: Public
- * Chapter: H5Tools Library
- * Purpose: Render an element to output STREAM.
- * Description:
- * Prints the string buffer to the output STREAM. The string is
- * printed according to the format described in INFO. The CTX struct
- * contains context information shared between calls to this function.
+ * Function: h5tools_render_element
*
- * Return:
- * False if a dimension end is reached, otherwise true
+ * Purpose: Prints the string buffer to the output STREAM. The string is
+ * printed according to the format described in INFO. The CTX struct
+ * contains context information shared between calls to this function.
+ *
+ * Return: False if a dimension end is reached
+ * True otherwise
*
* In/Out:
- * h5tools_context_t *ctx
- * h5tools_str_t *buffer
- * hsize_t *curr_pos
+ * h5tools_context_t *ctx
+ * h5tools_str_t *buffer
+ * hsize_t *curr_pos
*
* Parameters Description:
- * h5tools_str_t *buffer is the string into which to render
- * hsize_t curr_pos is the total data element position
- * size_t ncols
- * hsize_t local_elmt_counter is the local element loop counter
- * hsize_t elmt_count is the data element loop counter
+ * h5tools_str_t *buffer is the string into which to render
+ * hsize_t curr_pos is the total data element position
+ * size_t ncols
+ * hsize_t local_elmt_counter is the local element loop counter
+ * hsize_t elmt_count is the data element loop counter
*-------------------------------------------------------------------------
*/
hbool_t
-h5tools_render_element(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx, h5tools_str_t *buffer, hsize_t *curr_pos,
- size_t ncols, hsize_t local_elmt_counter, hsize_t elmt_counter)
+h5tools_render_element(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
+ h5tools_str_t *buffer, hsize_t *curr_pos, size_t ncols, hsize_t local_elmt_counter,
+ hsize_t elmt_counter)
{
- hbool_t dimension_break = TRUE;
- char *s;
- char *section; /*a section of output */
- int secnum; /*section sequence number */
- int multiline; /*datum was multiline */
+ hbool_t dimension_break = TRUE;
+ char *s = NULL;
+ char *section = NULL; /* a section of output */
+ int secnum; /* section sequence number */
+ int multiline; /* datum was multiline */
+
+ if (stream == NULL)
+ return dimension_break;
- s = h5tools_str_fmt(buffer, 0, "%s");
+ H5TOOLS_START_DEBUG(" need_prefix=%d", ctx->need_prefix);
+ H5TOOLS_DEBUG("elmt_counter=%ld - local_elmt_counter=%ld", elmt_counter, local_elmt_counter);
+
+ s = h5tools_str_fmt(buffer, (size_t)0, "%s");
+ H5TOOLS_DEBUG("s=%s", s);
/*
* If the element would split on multiple lines if printed at our
* current location...
*/
if (info->line_multi_new == 1 &&
- (ctx->cur_column + h5tools_count_ncols(s) +
- HDstrlen(OPT(info->elmt_suf2, " ")) +
- HDstrlen(OPT(info->line_suf, ""))) > ncols) {
+ (ctx->cur_column + h5tools_count_ncols(s) + HDstrlen(OPT(info->elmt_suf2, " ")) +
+ HDstrlen(OPT(info->line_suf, ""))) > ncols) {
if (ctx->prev_multiline) {
/*
* ... and the previous element also occupied more than one
@@ -783,9 +1442,8 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info,
*/
ctx->need_prefix = TRUE;
}
- else if ((ctx->prev_prefix_len + h5tools_count_ncols(s) +
- HDstrlen(OPT(info->elmt_suf2, " ")) +
- HDstrlen(OPT(info->line_suf, ""))) <= ncols) {
+ else if ((ctx->prev_prefix_len + h5tools_count_ncols(s) + HDstrlen(OPT(info->elmt_suf2, " ")) +
+ HDstrlen(OPT(info->line_suf, ""))) <= ncols) {
/*
* ...but *could* fit on one line otherwise, then we
* should end the current line and start this element on its
@@ -793,6 +1451,7 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info,
*/
ctx->need_prefix = TRUE;
}
+ H5TOOLS_DEBUG("ctx->need_prefix=%d", ctx->need_prefix);
}
/*
@@ -806,22 +1465,23 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info,
if (elmt_counter == ctx->size_last_dim) {
ctx->need_prefix = TRUE;
- dimension_break = FALSE;
+ dimension_break = FALSE;
}
+ H5TOOLS_DEBUG("ctx->need_prefix=%d", ctx->need_prefix);
}
+ H5TOOLS_DEBUG("elmt_counter=%ld - ctx->size_last_dim=%ld info->line_suf=%s", elmt_counter,
+ ctx->size_last_dim, info->line_suf);
/*
* If the previous element occupied multiple lines and this element
* is too long to fit on a line then start this element at the
* beginning of the line.
*/
- if (info->line_multi_new == 1 &&
- ctx->prev_multiline &&
- (ctx->cur_column +
- h5tools_count_ncols(s) +
- HDstrlen(OPT(info->elmt_suf2, " ")) +
- HDstrlen(OPT(info->line_suf, ""))) > ncols)
+ if (info->line_multi_new == 1 && ctx->prev_multiline &&
+ (ctx->cur_column + h5tools_count_ncols(s) + HDstrlen(OPT(info->elmt_suf2, " ")) +
+ HDstrlen(OPT(info->line_suf, ""))) > ncols)
ctx->need_prefix = TRUE;
+ H5TOOLS_DEBUG("ctx->need_prefix=%d", ctx->need_prefix);
/*
* If too many elements have already been printed then we need to
@@ -829,6 +1489,7 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info,
*/
if (info->line_per_line > 0 && ctx->cur_elmt >= info->line_per_line)
ctx->need_prefix = TRUE;
+ H5TOOLS_DEBUG("ctx->need_prefix=%d", ctx->need_prefix);
/*
* Each OPTIONAL_LINE_BREAK embedded in the rendered string can cause
@@ -836,9 +1497,7 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info,
* one-at a time.
*/
multiline = 0;
- for (secnum = 0, multiline = 0;
- (section = HDstrtok(secnum ? NULL : s, OPTIONAL_LINE_BREAK));
- secnum++) {
+ for (secnum = 0, multiline = 0; (section = HDstrtok(secnum ? NULL : s, OPTIONAL_LINE_BREAK)); secnum++) {
/*
* If the current section plus possible suffix and end-of-line
* information would cause the output to wrap then we need to
@@ -848,15 +1507,15 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info,
/*
* check for displaying prefix for each section
*/
- if ( (ctx->cur_column + HDstrlen(section) +
- HDstrlen(OPT(info->elmt_suf2, " ")) +
- HDstrlen(OPT(info->line_suf, ""))) > ncols)
+ if ((ctx->cur_column + HDstrlen(section) + HDstrlen(OPT(info->elmt_suf2, " ")) +
+ HDstrlen(OPT(info->line_suf, ""))) > ncols)
ctx->need_prefix = 1;
/*
* Print the prefix or separate the beginning of this element
* from the previous element.
*/
+ H5TOOLS_DEBUG("ctx->need_prefix=%d", ctx->need_prefix);
if (ctx->need_prefix) {
if (secnum)
multiline++;
@@ -866,70 +1525,77 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info,
* this is necessary to print the array indices
*/
*curr_pos = ctx->sm_pos + local_elmt_counter;
+ H5TOOLS_DEBUG("curr_pos=%ld - ctx->sm_pos=%ld - ctx->ndims=%ld", *curr_pos, ctx->sm_pos,
+ ctx->ndims);
h5tools_simple_prefix(stream, info, ctx, *curr_pos, secnum);
}
else if ((local_elmt_counter || ctx->continuation) && secnum == 0) {
- HDfputs(OPT(info->elmt_suf2, " "), stream);
+ PUTSTREAM(OPT(info->elmt_suf2, " "), stream);
ctx->cur_column += HDstrlen(OPT(info->elmt_suf2, " "));
}
+ H5TOOLS_DEBUG("section=%s", section);
/* Print the section */
- HDfputs(section, stream);
+ PUTSTREAM(section, stream);
ctx->cur_column += HDstrlen(section);
}
ctx->prev_multiline = multiline;
+
+ H5TOOLS_ENDDEBUG(" ");
+
return dimension_break;
}
/*-------------------------------------------------------------------------
- * Audience: Public
- * Chapter: H5Tools Library
- * Purpose: Render a region element to output STREAM.
- * Description:
- * Prints the string buffer to the output STREAM. The string is
- * printed according to the format described in INFO. The CTX struct
- * contains context information shared between calls to this function.
+ * Function: h5tools_render_region_element
+ *
+ * Purpose: Prints the string buffer to the output STREAM. The string is
+ * printed according to the format described in INFO. The CTX struct
+ * contains context information shared between calls to this function.
*
* Return:
- * False if a dimension end is reached, otherwise true
+ * False if a dimension end is reached
+ * True otherwise
*
* In/Out:
- * h5tools_context_t *ctx
- * h5tools_str_t *buffer
- * hsize_t *curr_pos
+ * h5tools_context_t *ctx
+ * h5tools_str_t *buffer
+ * hsize_t *curr_pos
*
* Parameters Description:
- * h5tools_str_t *buffer is the string into which to render
- * hsize_t curr_pos is the total data element position
- * size_t ncols
- * hsize_t *ptdata
- * hsize_t local_elmt_counter is the local element loop counter
- * hsize_t elmt_count is the data element loop counter
+ * h5tools_str_t *buffer is the string into which to render
+ * hsize_t curr_pos is the total data element position
+ * size_t ncols
+ * hsize_t *ptdata
+ * hsize_t local_elmt_counter is the local element loop counter
+ * hsize_t elmt_count is the data element loop counter
*-------------------------------------------------------------------------
*/
hbool_t
-h5tools_render_region_element(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx, h5tools_str_t *buffer, hsize_t *curr_pos,
- size_t ncols, hsize_t *ptdata, hsize_t local_elmt_counter, hsize_t elmt_counter)
+h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
+ h5tools_str_t *buffer, hsize_t *curr_pos, size_t ncols, hsize_t *ptdata,
+ hsize_t local_elmt_counter, hsize_t elmt_counter)
{
- hbool_t dimension_break = TRUE;
- char *s;
- char *section; /*a section of output */
- int secnum; /*section sequence number */
- int multiline; /*datum was multiline */
+ hbool_t dimension_break = TRUE;
+ char *s = NULL;
+ char *section = NULL; /* a section of output */
+ int secnum; /* section sequence number */
+ int multiline; /* datum was multiline */
- s = h5tools_str_fmt(buffer, 0, "%s");
+ H5TOOLS_START_DEBUG(" ");
+ H5TOOLS_DEBUG("elmt_counter=%ld - local_elmt_counter=%ld", elmt_counter, local_elmt_counter);
+
+ s = h5tools_str_fmt(buffer, (size_t)0, "%s");
/*
* If the element would split on multiple lines if printed at our
* current location...
*/
if (info->line_multi_new == 1 &&
- (ctx->cur_column + h5tools_count_ncols(s) +
- HDstrlen(OPT(info->elmt_suf2, " ")) +
- HDstrlen(OPT(info->line_suf, ""))) > ncols) {
+ (ctx->cur_column + h5tools_count_ncols(s) + HDstrlen(OPT(info->elmt_suf2, " ")) +
+ HDstrlen(OPT(info->line_suf, ""))) > ncols) {
if (ctx->prev_multiline) {
/*
* ... and the previous element also occupied more than one
@@ -937,9 +1603,8 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info,
*/
ctx->need_prefix = TRUE;
}
- else if ((ctx->prev_prefix_len + h5tools_count_ncols(s) +
- HDstrlen(OPT(info->elmt_suf2, " ")) +
- HDstrlen(OPT(info->line_suf, ""))) <= ncols) {
+ else if ((ctx->prev_prefix_len + h5tools_count_ncols(s) + HDstrlen(OPT(info->elmt_suf2, " ")) +
+ HDstrlen(OPT(info->line_suf, ""))) <= ncols) {
/*
* ...but *could* fit on one line otherwise, then we
* should end the current line and start this element on its
@@ -960,7 +1625,7 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info,
if (elmt_counter == ctx->size_last_dim) {
ctx->need_prefix = TRUE;
- dimension_break = FALSE;
+ dimension_break = FALSE;
}
}
@@ -969,12 +1634,9 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info,
* is too long to fit on a line then start this element at the
* beginning of the line.
*/
- if (info->line_multi_new == 1 &&
- ctx->prev_multiline &&
- (ctx->cur_column +
- h5tools_count_ncols(s) +
- HDstrlen(OPT(info->elmt_suf2, " ")) +
- HDstrlen(OPT(info->line_suf, ""))) > ncols)
+ if (info->line_multi_new == 1 && ctx->prev_multiline &&
+ (ctx->cur_column + h5tools_count_ncols(s) + HDstrlen(OPT(info->elmt_suf2, " ")) +
+ HDstrlen(OPT(info->line_suf, ""))) > ncols)
ctx->need_prefix = TRUE;
/*
@@ -990,8 +1652,7 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info,
* one-at a time.
*/
multiline = 0;
- for (secnum = 0, multiline = 0; (section = HDstrtok(secnum ? NULL : s,
- OPTIONAL_LINE_BREAK)); secnum++) {
+ for (secnum = 0, multiline = 0; (section = HDstrtok(secnum ? NULL : s, OPTIONAL_LINE_BREAK)); secnum++) {
/*
* If the current section plus possible suffix and end-of-line
* information would cause the output to wrap then we need to
@@ -1003,10 +1664,8 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info,
* this check to happen for the first line
*/
if ((!info->skip_first || local_elmt_counter) &&
- (ctx->cur_column +
- HDstrlen(section) +
- HDstrlen(OPT(info->elmt_suf2, " ")) +
- HDstrlen(OPT(info->line_suf, ""))) > ncols)
+ (ctx->cur_column + HDstrlen(section) + HDstrlen(OPT(info->elmt_suf2, " ")) +
+ HDstrlen(OPT(info->line_suf, ""))) > ncols)
ctx->need_prefix = 1;
/*
@@ -1017,524 +1676,401 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info,
if (secnum)
multiline++;
- /* pass to the prefix in h5tools_simple_prefix the total
+ /* pass to the prefix in h5tools_region_simple_prefix the total
* position instead of the current stripmine position i;
* this is necessary to print the array indices
*/
*curr_pos = ctx->sm_pos + local_elmt_counter;
+ H5TOOLS_DEBUG("curr_pos=%ld - ctx->sm_pos=%ld", *curr_pos, ctx->sm_pos);
h5tools_region_simple_prefix(stream, info, ctx, local_elmt_counter, ptdata, secnum);
}
else if ((local_elmt_counter || ctx->continuation) && secnum == 0) {
- HDfputs(OPT(info->elmt_suf2, " "), stream);
+ PUTSTREAM(OPT(info->elmt_suf2, " "), stream);
ctx->cur_column += HDstrlen(OPT(info->elmt_suf2, " "));
}
/* Print the section */
- HDfputs(section, stream);
+ PUTSTREAM(section, stream);
ctx->cur_column += HDstrlen(section);
}
ctx->prev_multiline = multiline;
+
+ H5TOOLS_ENDDEBUG(" ");
+
return dimension_break;
}
/*-------------------------------------------------------------------------
- * Function: init_acc_pos
+ * Function: init_acc_pos
*
- * Purpose: initialize accumulator and matrix position
+ * Purpose: initialize accumulator and matrix position
*
- * Return: void
+ * Return: void
*-------------------------------------------------------------------------
*/
void
-init_acc_pos(h5tools_context_t *ctx, hsize_t *dims)
+init_acc_pos(unsigned ndims, const hsize_t *dims, hsize_t *acc, hsize_t *pos, hsize_t *p_min_idx)
{
- int i;
+ int i;
+ unsigned j;
+
+ H5TOOLS_START_DEBUG(" ");
- HDassert(ctx->ndims);
+ for (i = 0; (unsigned)i < ndims; i++)
+ p_min_idx[i] = 0;
- ctx->acc[ctx->ndims - 1] = 1;
- for (i = (ctx->ndims - 2); i >= 0; i--) {
- ctx->acc[i] = ctx->acc[i + 1] * dims[i + 1];
+ if (ndims > 0) {
+ acc[ndims - 1] = 1;
+ for (i = ((int)ndims - 2); i >= 0; i--) {
+ acc[i] = acc[i + 1] * dims[i + 1];
+ H5TOOLS_DEBUG("acc[%d]=%ld", i, acc[i]);
+ }
+ for (j = 0; j < ndims; j++)
+ pos[j] = 0;
}
- for (i = 0; i < ctx->ndims; i++)
- ctx->pos[i] = 0;
+
+ H5TOOLS_ENDDEBUG(" ");
}
/*-------------------------------------------------------------------------
- * Function: do_bin_output
+ * Function: calc_acc_pos
*
- * Purpose: Dump memory buffer to a binary file stream
+ * Purpose: Calculate the number of elements represented by a unit change
+ * in a certain index position.
*
- * Return: Success: SUCCEED
- * Failure: FAIL
+ * Return: void
*-------------------------------------------------------------------------
*/
-int
-do_bin_output(FILE *stream, FILE *err_stream, hid_t container, hsize_t nelmts, hid_t tid, void *_mem)
+hsize_t
+calc_acc_pos(unsigned ndims, hsize_t elmtno, const hsize_t *acc, hsize_t *pos)
{
- HERR_INIT(int, SUCCEED)
- unsigned char *mem = (unsigned char*)_mem;
- size_t size; /* datum size */
- hsize_t i; /* element counter */
+ int i;
+ hsize_t curr_pos = elmtno;
- if((size = H5Tget_size(tid)) == 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
+ H5TOOLS_START_DEBUG(" ");
- for (i = 0; i < nelmts; i++) {
- if (render_bin_output(stream, container, tid, mem + i * size) < 0) {
- HDfprintf(err_stream,"\nError in writing binary stream\n");
- return FAIL;
- }
+ if (ndims > 0) {
+ for (i = 0; i < (int)ndims; i++) {
+ if (curr_pos > 0) {
+ H5TOOLS_DEBUG("curr_pos=%ld - ctx->acc[%d]=%ld", curr_pos, i, acc[i]);
+ pos[i] = curr_pos / acc[i];
+ curr_pos -= acc[i] * pos[i];
+ }
+ else
+ pos[i] = 0;
+ H5TOOLS_DEBUG("curr_pos=%ld - pos[%d]=%ld - acc[%d]=%ld", curr_pos, i, pos[i], i, acc[i]);
+ }
}
-CATCH
- return ret_value;
+ H5TOOLS_ENDDEBUG(" ");
+
+ return curr_pos;
}
/*-------------------------------------------------------------------------
* Function: render_bin_output
*
- * Purpose: Write one element of memory buffer to a binary file stream
+ * Purpose: Write one element of memory buffer to a binary file stream
*
- * Return: Success: SUCCEED
- * Failure: FAIL
+ * Return: Success: SUCCEED
+ * Failure: FAIL
*-------------------------------------------------------------------------
*/
int
-render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem)
+render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t block_nelmts)
{
- HERR_INIT(int, SUCCEED)
- unsigned char *mem = (unsigned char*)_mem;
- size_t size; /* datum size */
- float tempfloat;
- double tempdouble;
- unsigned long long tempullong;
- long long templlong;
- unsigned long tempulong;
- long templong;
- unsigned int tempuint;
- int tempint;
- unsigned short tempushort;
- short tempshort;
- unsigned char tempuchar;
- char tempschar;
-#if H5_SIZEOF_LONG_DOUBLE !=0
- long double templdouble;
-#endif
-#ifdef DEBUG_H5DUMP_BIN
- static char fmt_llong[8], fmt_ullong[8];
- if (!fmt_llong[0]) {
- HDsprintf(fmt_llong, "%%%sd", H5_PRINTF_LL_WIDTH);
- HDsprintf(fmt_ullong, "%%%su", H5_PRINTF_LL_WIDTH);
- }
-#endif
-
- if((size = H5Tget_size(tid)) == 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
-
- if (H5Tequal(tid, H5T_NATIVE_FLOAT)) {
- HDmemcpy(&tempfloat, mem, sizeof(float));
-#ifdef DEBUG_H5DUMP_BIN
- HDfprintf(stream, "%g ", tempfloat);
-#else
- if (1 != HDfwrite(&tempfloat, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
- }
- else if (H5Tequal(tid, H5T_NATIVE_DOUBLE)) {
- HDmemcpy(&tempdouble, mem, sizeof(double));
-#ifdef DEBUG_H5DUMP_BIN
- HDfprintf(stream, "%g ", tempdouble);
-#else
- if (1 != HDfwrite(&tempdouble, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
- }
-#if H5_SIZEOF_LONG_DOUBLE !=0
- else if (H5Tequal(tid, H5T_NATIVE_LDOUBLE)) {
- HDmemcpy(&templdouble, mem, sizeof(long double));
-#ifdef DEBUG_H5DUMP_BIN
- HDfprintf(stream, "%Lf ", templdouble);
-#else
- if (1 != HDfwrite(&templdouble, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
- }
-#endif
- else if (H5T_STRING == H5Tget_class(tid)) {
- unsigned int i;
- H5T_str_t pad;
- char *s;
-
- pad = H5Tget_strpad(tid);
-
- if (H5Tis_variable_str(tid)) {
- s = *(char**) mem;
- if (s != NULL)
- size = HDstrlen(s);
- }
- else {
- s = (char *) mem;
- if((size = H5Tget_size(tid)) == 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
- }
- for (i = 0; i < size && (s[i] || pad != H5T_STR_NULLTERM); i++) {
- HDmemcpy(&tempuchar, &s[i], sizeof(unsigned char));
-#ifdef DEBUG_H5DUMP_BIN
- HDfprintf(stream, "%d", tempuchar);
-#else
- if (1 != HDfwrite(&tempuchar, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
- } /* i */
- }
- else if (H5Tequal(tid, H5T_NATIVE_INT)) {
- HDmemcpy(&tempint, mem, sizeof(int));
-#ifdef DEBUG_H5DUMP_BIN
- HDfprintf(stream, "%d ", tempint);
-#else
- if (1 != HDfwrite(&tempint, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
- }
- else if (H5Tequal(tid, H5T_NATIVE_UINT)) {
- HDmemcpy(&tempuint, mem, sizeof(unsigned int));
-#ifdef DEBUG_H5DUMP_BIN
- HDfprintf(stream, "%u ", tempuint);
-#else
- if (1 != HDfwrite(&tempuint, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
- }
- else if (H5Tequal(tid, H5T_NATIVE_SCHAR)) {
- HDmemcpy(&tempschar, mem, sizeof(char));
-#ifdef DEBUG_H5DUMP_BIN
- HDfprintf(stream, "%d ", tempschar);
-#else
- if (1 != HDfwrite(&tempschar, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
- }
- else if (H5Tequal(tid, H5T_NATIVE_UCHAR)) {
- HDmemcpy(&tempuchar, mem, sizeof(unsigned char));
-#ifdef DEBUG_H5DUMP_BIN
- HDfprintf(stream, "%u ", tempuchar);
-#else
- if (1 != HDfwrite(&tempuchar, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
- }
- else if (H5Tequal(tid, H5T_NATIVE_SHORT)) {
- HDmemcpy(&tempshort, mem, sizeof(short));
-#ifdef DEBUG_H5DUMP_BIN
- HDfprintf(stream, "%d ", tempshort);
-#else
- if (1 != HDfwrite(&tempshort, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
- }
- else if (H5Tequal(tid, H5T_NATIVE_USHORT)) {
- HDmemcpy(&tempushort, mem, sizeof(unsigned short));
-#ifdef DEBUG_H5DUMP_BIN
- HDfprintf(stream, "%u ", tempushort);
-#else
- if (1 != HDfwrite(&tempushort, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
- }
- else if (H5Tequal(tid, H5T_NATIVE_LONG)) {
- HDmemcpy(&templong, mem, sizeof(long));
-#ifdef DEBUG_H5DUMP_BIN
- HDfprintf(stream, "%ld ", templong);
-#else
- if (1 != HDfwrite(&templong, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
- }
- else if (H5Tequal(tid, H5T_NATIVE_ULONG)) {
- HDmemcpy(&tempulong, mem, sizeof(unsigned long));
-#ifdef DEBUG_H5DUMP_BIN
- HDfprintf(stream, "%lu ", tempulong);
-#else
- if (1 != HDfwrite(&tempulong, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
- }
- else if (H5Tequal(tid, H5T_NATIVE_LLONG)) {
- HDmemcpy(&templlong, mem, sizeof(long long));
-#ifdef DEBUG_H5DUMP_BIN
- HDfprintf(stream, fmt_llong, templlong);
-#else
- if (1 != HDfwrite(&templlong, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
- }
- else if (H5Tequal(tid, H5T_NATIVE_ULLONG)) {
- HDmemcpy(&tempullong, mem, sizeof(unsigned long long));
-#ifdef DEBUG_H5DUMP_BIN
- HDfprintf(stream, fmt_ullong, tempullong);
-#else
- if (1 != HDfwrite(&tempullong, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
- }
- else if (H5Tequal(tid, H5T_NATIVE_HSSIZE)) {
- if (sizeof(hssize_t) == sizeof(int)) {
- HDmemcpy(&tempint, mem, sizeof(int));
-#ifdef DEBUG_H5DUMP_BIN
- HDfprintf(stream, "%d ", tempint);
-#else
- if (1 != HDfwrite(&tempint, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
- }
- else if (sizeof(hssize_t) == sizeof(long)) {
- HDmemcpy(&templong, mem, sizeof(long));
-#ifdef DEBUG_H5DUMP_BIN
- HDfprintf(stream, "%ld ", templong);
-#else
- if (1 != HDfwrite(&templong, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
- }
- else {
- HDmemcpy(&templlong, mem, sizeof(long long));
-#ifdef DEBUG_H5DUMP_BIN
- HDfprintf(stream, fmt_llong, templlong);
-#else
- if (1 != HDfwrite(&templlong, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
- }
- }
- else if (H5Tequal(tid, H5T_NATIVE_HSIZE)) {
- if (sizeof(hsize_t) == sizeof(int)) {
- HDmemcpy(&tempuint, mem, sizeof(unsigned int));
-#ifdef DEBUG_H5DUMP_BIN
- HDfprintf(stream, "%u ", tempuint);
-#else
- if (1 != HDfwrite(&tempuint, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
- }
- else if (sizeof(hsize_t) == sizeof(long)) {
- HDmemcpy(&tempulong, mem, sizeof(unsigned long));
-#ifdef DEBUG_H5DUMP_BIN
- HDfprintf(stream, "%lu ", tempulong);
-#else
- if (1 != HDfwrite(&tempulong, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
- }
- else {
- HDmemcpy(&tempullong, mem, sizeof(unsigned long long));
-#ifdef DEBUG_H5DUMP_BIN
- HDfprintf(stream, fmt_ullong, tempullong);
-#else
- if (1 != HDfwrite(&tempullong, size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
- }
- }
- else if (H5Tget_class(tid) == H5T_COMPOUND) {
- unsigned j;
- hid_t memb;
- unsigned nmembs;
- size_t offset;
-
- nmembs = H5Tget_nmembers(tid);
-
- for (j = 0; j < nmembs; j++) {
- offset = H5Tget_member_offset(tid, j);
- memb = H5Tget_member_type(tid, j);
-
- if (render_bin_output(stream, container, memb, mem + offset) < 0)
- return FAIL;
-
- H5Tclose(memb);
- }
- }
- else if (H5Tget_class(tid) == H5T_ENUM) {
- unsigned int i;
- if (1 == size) {
-#ifdef DEBUG_H5DUMP_BIN
- HDfprintf(stream, "0x%02x", mem[0]);
-#else
- if (1 != HDfwrite(&mem[0], size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
- }
- else {
- for (i = 0; i < size; i++) {
-#ifdef DEBUG_H5DUMP_BIN
- HDfprintf(stream, "%s%02x", i?":":"", mem[i]);
-#else
- if (1 != HDfwrite(&mem[i], sizeof(char), 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
- } /*i*/
- }/*else 1 */
- }
- else if (H5Tget_class(tid) == H5T_ARRAY) {
- int k, ndims;
- hsize_t i, dims[H5S_MAX_RANK], temp_nelmts, nelmts;
- hid_t memb;
-
- /* get the array's base datatype for each element */
- memb = H5Tget_super(tid);
- size = H5Tget_size(memb);
- ndims = H5Tget_array_ndims(tid);
- H5Tget_array_dims2(tid, dims);
- HDassert(ndims >= 1 && ndims <= H5S_MAX_RANK);
-
- /* calculate the number of array elements */
- for (k = 0, nelmts = 1; k < ndims; k++) {
- temp_nelmts = nelmts;
- temp_nelmts *= dims[k];
- nelmts = (size_t) temp_nelmts;
- }
-
- /* dump the array element */
- for (i = 0; i < nelmts; i++) {
- if (render_bin_output(stream, container, memb, mem + i * size) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "render_bin_output failed");
- }
-
- H5Tclose(memb);
- }
- else if (H5Tget_class(tid) == H5T_VLEN) {
- unsigned int i;
- hsize_t nelmts;
- hid_t memb;
-
- /* get the VL sequences's base datatype for each element */
- memb = H5Tget_super(tid);
- size = H5Tget_size(memb);
-
- /* Get the number of sequence elements */
- nelmts = ((hvl_t *) mem)->len;
-
- for (i = 0; i < nelmts; i++) {
- /* dump the array element */
- if (render_bin_output(stream, container, memb, ((char *) (((hvl_t *) mem)->p)) + i * size) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "render_bin_output failed");
- }
- H5Tclose(memb);
- }
- else if (H5Tequal(tid, H5T_STD_REF_DSETREG)) {
- if (region_output) {
- /* region data */
- hid_t region_id, region_space;
- H5S_sel_type region_type;
-
- region_id = H5Rdereference2(container, H5P_DEFAULT, H5R_DATASET_REGION, mem);
- if (region_id >= 0) {
- region_space = H5Rget_region(container, H5R_DATASET_REGION, mem);
- if (region_space >= 0) {
- region_type = H5Sget_select_type(region_space);
- if(region_type == H5S_SEL_POINTS)
- render_bin_output_region_points(region_space, region_id, stream, container);
+ unsigned char *mem = (unsigned char *)_mem;
+ size_t size; /* datum size */
+ hsize_t block_index;
+ H5T_class_t type_class;
+ hbool_t past_catch = FALSE;
+ int ret_value = 0;
+
+ H5TOOLS_START_DEBUG(" ");
+ if ((size = H5Tget_size(tid)) == 0)
+ H5TOOLS_THROW((-1), "H5Tget_size failed");
+
+ if ((type_class = H5Tget_class(tid)) < 0)
+ H5TOOLS_THROW((-1), "H5Tget_class failed");
+
+ switch (type_class) {
+ case H5T_INTEGER:
+ case H5T_FLOAT:
+ case H5T_ENUM:
+ case H5T_BITFIELD:
+ H5TOOLS_DEBUG("numbers");
+ block_index = block_nelmts * size;
+ while (block_index > 0) {
+ size_t bytes_in = 0; /* # of bytes to write */
+ size_t bytes_wrote = 0; /* # of bytes written */
+
+ if (block_index > sizeof(size_t))
+ bytes_in = sizeof(size_t);
+ else
+ bytes_in = (size_t)block_index;
+
+ bytes_wrote = HDfwrite(mem, 1, bytes_in, stream);
+
+ if (bytes_wrote != bytes_in || (0 == bytes_wrote && HDferror(stream)))
+ H5TOOLS_THROW((-1), "fwrite failed");
+
+ block_index -= (hsize_t)bytes_wrote;
+ mem = mem + bytes_wrote;
+ }
+ break;
+ case H5T_STRING: {
+ unsigned int i;
+ H5T_str_t pad;
+ char *s = NULL;
+ unsigned char tempuchar;
+
+ H5TOOLS_DEBUG("H5T_STRING");
+ pad = H5Tget_strpad(tid);
+
+ for (block_index = 0; block_index < block_nelmts; block_index++) {
+ mem = ((unsigned char *)_mem) + block_index * size;
+
+ if (H5Tis_variable_str(tid)) {
+ s = *(char **)((void *)mem);
+ if (s != NULL)
+ size = HDstrlen(s);
else
- render_bin_output_region_blocks(region_space, region_id, stream, container);
- H5Sclose(region_space);
- } /* end if (region_space >= 0) */
- H5Dclose(region_id);
- } /* end if (region_id >= 0) */
- } /* end if (region_output... */
- }
- else if (H5Tequal(tid, H5T_STD_REF_OBJ)) {
- }
- else {
- size_t i;
- if (1 == size) {
-#ifdef DEBUG_H5DUMP_BIN
- HDfprintf(stream, "0x%02x", mem[0]);
-#else
- if (1 != HDfwrite(&mem[0], size, 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
- }
- else {
- for (i = 0; i < size; i++) {
-#ifdef DEBUG_H5DUMP_BIN
- HDfprintf(stream, "%s%02x", i?":":"", mem[i]);
-#else
- if (1 != HDfwrite(&mem[i], sizeof(char), 1, stream))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
-#endif
- } /*i*/
- }/*else 1 */
- }
+ H5TOOLS_THROW((-1), "NULL string");
+ }
+ else {
+ s = (char *)mem;
+ }
+ for (i = 0; i < size && (s[i] || pad != H5T_STR_NULLTERM); i++) {
+ HDmemcpy(&tempuchar, &s[i], sizeof(unsigned char));
+ if (1 != HDfwrite(&tempuchar, sizeof(unsigned char), 1, stream))
+ H5TOOLS_THROW((-1), "fwrite failed");
+ } /* i */
+ } /* for (block_index = 0; block_index < block_nelmts; block_index++) */
+ } break;
+ case H5T_COMPOUND: {
+ int snmembs;
+ unsigned nmembs;
+
+ H5TOOLS_DEBUG("H5T_COMPOUND");
+ if ((snmembs = H5Tget_nmembers(tid)) < 0)
+ H5TOOLS_THROW((-1), "H5Tget_nmembers of compound failed");
+ nmembs = (unsigned)snmembs;
+
+ for (block_index = 0; block_index < block_nelmts; block_index++) {
+ unsigned j;
+
+ mem = ((unsigned char *)_mem) + block_index * size;
+ for (j = 0; j < nmembs; j++) {
+ hid_t memb = H5I_INVALID_HID;
+ size_t offset;
+
+ offset = H5Tget_member_offset(tid, j);
+ memb = H5Tget_member_type(tid, j);
+
+ if (render_bin_output(stream, container, memb, mem + offset, 1) < 0) {
+ H5Tclose(memb);
+ H5TOOLS_THROW((-1), "render_bin_output of compound member failed");
+ }
+
+ H5Tclose(memb);
+ }
+ }
+ } break;
+ case H5T_ARRAY: {
+ int k, ndims;
+ hsize_t dims[H5S_MAX_RANK], temp_nelmts, nelmts = 0;
+ hid_t memb = H5I_INVALID_HID;
+
+ H5TOOLS_DEBUG("H5T_ARRAY");
+ /* get the array's base datatype for each element */
+ memb = H5Tget_super(tid);
+ ndims = H5Tget_array_ndims(tid);
+ H5Tget_array_dims2(tid, dims);
+ if (ndims >= 1 && ndims <= H5S_MAX_RANK) {
+ /* calculate the number of array elements */
+ for (k = 0, nelmts = 1; k < ndims; k++) {
+ temp_nelmts = nelmts;
+ temp_nelmts *= dims[k];
+ nelmts = (size_t)temp_nelmts;
+ }
+ }
+ else {
+ H5Tclose(memb);
+ H5TOOLS_THROW((-1), "calculate the number of array elements failed");
+ }
-CATCH
+ for (block_index = 0; block_index < block_nelmts; block_index++) {
+ mem = ((unsigned char *)_mem) + block_index * size;
+ /* dump the array element */
+ if (render_bin_output(stream, container, memb, mem, nelmts) < 0) {
+ H5Tclose(memb);
+ H5TOOLS_THROW((-1), "render_bin_output failed");
+ }
+ }
+ H5Tclose(memb);
+ } break;
+ case H5T_VLEN: {
+ hsize_t nelmts;
+ hid_t memb = H5I_INVALID_HID;
+
+ H5TOOLS_DEBUG("H5T_VLEN");
+ /* get the VL sequences's base datatype for each element */
+ memb = H5Tget_super(tid);
+
+ for (block_index = 0; block_index < block_nelmts; block_index++) {
+ mem = ((unsigned char *)_mem) + block_index * size;
+ /* Get the number of sequence elements */
+ nelmts = ((hvl_t *)((void *)mem))->len;
+
+ /* dump the array element */
+ if (render_bin_output(stream, container, memb, ((char *)(((hvl_t *)((void *)mem))->p)),
+ nelmts) < 0) {
+ H5Tclose(memb);
+ H5TOOLS_THROW((-1), "render_bin_output failed");
+ }
+ }
+ H5Tclose(memb);
+ } break;
+ case H5T_REFERENCE: {
+ H5TOOLS_DEBUG("reference class type");
+ if (H5Tequal(tid, H5T_STD_REF)) {
+ H5TOOLS_DEBUG("H5T_STD_REF");
+ if (region_output) {
+ /* region data */
+ hid_t region_id = H5I_INVALID_HID;
+ hid_t region_space = H5I_INVALID_HID;
+ H5S_sel_type region_type;
+ H5R_ref_t tref;
+
+ if (size > sizeof(tref))
+ H5TOOLS_THROW((-1), "unexpectedly large ref");
+
+ HDmemset(&tref, 0, sizeof(tref));
+
+ for (block_index = 0; block_index < block_nelmts; block_index++) {
+ mem = ((unsigned char *)_mem) + block_index * size;
+ HDmemcpy(&tref, mem, size);
+ if ((region_id = H5Ropen_object(&tref, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ H5TOOLS_INFO("H5Ropen_object H5T_STD_REF failed");
+ else {
+ if ((region_space = H5Ropen_region(&tref, H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ if (!h5tools_is_zero(&tref, H5Tget_size(H5T_STD_REF))) {
+
+ region_type = H5Sget_select_type(region_space);
+ if (region_type == H5S_SEL_POINTS)
+ render_bin_output_region_points(region_space, region_id, stream,
+ container);
+ else
+ render_bin_output_region_blocks(region_space, region_id, stream,
+ container);
+ }
+ else {
+ H5TOOLS_INFO("H5Ropen_object H5T_STD_REF NULL");
+ }
+ H5Sclose(region_space);
+ } /* end if (region_space >= 0) */
+ H5Dclose(region_id);
+ }
+ }
+ } /* end if (region_output... */
+ }
+ else if (H5Tequal(tid, H5T_STD_REF_DSETREG)) {
+ /* if (size == H5R_DSET_REG_REF_BUF_SIZE) */
+ H5TOOLS_DEBUG("H5T_STD_REF_DSETREG");
+ }
+ else if (H5Tequal(tid, H5T_STD_REF_OBJ)) {
+ /* if (size == H5R_OBJ_REF_BUF_SIZE) */
+ H5TOOLS_DEBUG("H5T_STD_REF_OBJ");
+ }
+ } break;
+
+ case H5T_TIME:
+ case H5T_OPAQUE:
+ H5TOOLS_DEBUG("H5T_OPAQUE");
+ for (block_index = 0; block_index < block_nelmts; block_index++) {
+ mem = ((unsigned char *)_mem) + block_index * size;
+ if (size != HDfwrite(mem, sizeof(char), size, stream))
+ H5TOOLS_THROW((-1), "fwrite failed");
+ } /* end for */
+ break;
+
+ case H5T_NO_CLASS:
+ case H5T_NCLASSES:
+ default:
+ /* Badness */
+ H5TOOLS_THROW((-1), "bad type class");
+ break;
+ } /* end switch */
+
+ CATCH
+ H5TOOLS_ENDDEBUG(" ");
return ret_value;
}
/*-------------------------------------------------------------------------
- * Audience: Public
- * Chapter: H5Tools Library
- * Purpose: Print the data values from a dataset referenced by region blocks.
+ * Function: render_bin_output_region_data_blocks
*
- * Description:
- * This is a special case subfunction to print the data in a region reference of type blocks.
+ * Purpose: Print the data values from a dataset referenced by region blocks.
+ * This is a special case subfunction to print the data in a region reference of type blocks.
*
- * Return:
- * The function returns FAIL if there was an error, otherwise SUCEED
+ * Return: FAIL if there was an error
+ * SUCCEED otherwise
*
*-------------------------------------------------------------------------
*/
int
-render_bin_output_region_data_blocks(hid_t region_id, FILE *stream,
- hid_t container, int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata)
+render_bin_output_region_data_blocks(hid_t region_id, FILE *stream, hid_t container, unsigned ndims,
+ hid_t type_id, hsize_t nblocks, const hsize_t *ptdata)
{
- hsize_t *dims1 = NULL;
- hsize_t *start = NULL;
- hsize_t *count = NULL;
- hsize_t numelem;
- hsize_t numindex;
- hsize_t total_size[H5S_MAX_RANK];
- int jndx;
- int type_size;
- hid_t mem_space = -1;
- void *region_buf = NULL;
- int blkndx;
- hid_t sid1 = -1;
- int ret_value = SUCCEED;
+ hsize_t *dims1 = NULL;
+ hsize_t *start = NULL;
+ hsize_t *count = NULL;
+ hsize_t numelem;
+ hsize_t total_size[H5S_MAX_RANK];
+ unsigned jndx;
+ size_t type_size;
+ hid_t mem_space = H5I_INVALID_HID;
+ void *region_buf = NULL;
+ hbool_t past_catch = FALSE;
+ hsize_t blkndx;
+ hid_t sid1 = H5I_INVALID_HID;
+ int ret_value = -1;
+ H5TOOLS_START_DEBUG(" ");
/* Get the dataspace of the dataset */
- if((sid1 = H5Dget_space(region_id)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
+ if ((sid1 = H5Dget_space(region_id)) < 0)
+ H5TOOLS_THROW((-1), "H5Dget_space failed");
/* Allocate space for the dimension array */
- if((dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for dims");
+ if ((dims1 = (hsize_t *)HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
+ H5TOOLS_THROW((-1), "Could not allocate buffer for dims");
/* find the dimensions of each data space from the block coordinates */
numelem = 1;
for (jndx = 0; jndx < ndims; jndx++) {
dims1[jndx] = ptdata[jndx + ndims] - ptdata[jndx] + 1;
- numelem = dims1[jndx] * numelem;
+ numelem = dims1[jndx] * numelem;
}
/* Create dataspace for reading buffer */
- if((mem_space = H5Screate_simple(ndims, dims1, NULL)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Screate_simple failed");
+ if ((mem_space = H5Screate_simple((int)ndims, dims1, NULL)) < 0)
+ H5TOOLS_THROW((-1), "H5Screate_simple failed");
- if((type_size = H5Tget_size(type_id)) == 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
+ if ((type_size = H5Tget_size(type_id)) == 0)
+ H5TOOLS_THROW((-1), "H5Tget_size failed");
- if((region_buf = HDmalloc(type_size * numelem)) == NULL)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate region buffer");
+ if ((region_buf = HDmalloc(type_size * (size_t)numelem)) == NULL)
+ H5TOOLS_THROW((-1), "Could not allocate region buffer");
/* Select (x , x , ..., x ) x (y , y , ..., y ) hyperslab for reading memory dataset */
/* 1 2 n 1 2 n */
- if((start = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for start");
+ if ((start = (hsize_t *)HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
+ H5TOOLS_THROW((-1), "Could not allocate buffer for start");
- if((count = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for count");
+ if ((count = (hsize_t *)HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
+ H5TOOLS_THROW((-1), "Could not allocate buffer for count");
for (blkndx = 0; blkndx < nblocks; blkndx++) {
for (jndx = 0; jndx < ndims; jndx++) {
@@ -1542,104 +2078,102 @@ render_bin_output_region_data_blocks(hid_t region_id, FILE *stream,
count[jndx] = dims1[jndx];
}
- if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
-
- if(H5Dread(region_id, type_id, mem_space, sid1, H5P_DEFAULT, region_buf) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dread failed");
+ if (H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Sselect_hyperslab failed");
- if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
+ if (H5Dread(region_id, type_id, mem_space, sid1, H5P_DEFAULT, region_buf) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dread failed");
- for (numindex = 0; numindex < numelem; numindex++) {
+ if (H5Sget_simple_extent_dims(mem_space, total_size, NULL) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_dims failed");
- render_bin_output(stream, container, type_id,
- ((char*)region_buf + numindex * type_size));
- /* Render the region data element end */
- } /* end for (jndx = 0; jndx < numelem; jndx++) */
+ if (render_bin_output(stream, container, type_id, (char *)region_buf, numelem) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "render_bin_output of data region failed");
+ /* Render the region data element end */
+done:;
} /* end for (blkndx = 0; blkndx < nblocks; blkndx++) */
- done:
+ CATCH
HDfree(start);
HDfree(count);
HDfree(region_buf);
HDfree(dims1);
- if(H5Sclose(mem_space) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
- if(H5Sclose(sid1) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
+ if (H5Sclose(mem_space) < 0)
+ H5TOOLS_ERROR((-1), "H5Sclose failed");
+ if (H5Sclose(sid1) < 0)
+ H5TOOLS_ERROR((-1), "H5Sclose failed");
+ H5TOOLS_ENDDEBUG(" ");
return ret_value;
}
/*-------------------------------------------------------------------------
- * Audience: Public
- * Chapter: H5Tools Library
- * Purpose: Print some values from a dataset referenced by region blocks.
+ * Function: render_bin_output_region_blocks
*
- * Description:
- * This is a special case subfunction to dump a region reference using blocks.
- *
- * Return:
- * The function returns False if ERROR, otherwise True
+ * Purpose: Print some values from a dataset referenced by region blocks.
+ * This is a special case subfunction to dump a region reference using blocks.
*
+ * Return: False if ERROR
+ * True otherwise
*-------------------------------------------------------------------------
*/
hbool_t
-render_bin_output_region_blocks(hid_t region_space, hid_t region_id,
- FILE *stream, hid_t container)
+render_bin_output_region_blocks(hid_t region_space, hid_t region_id, FILE *stream, hid_t container)
{
- HERR_INIT(hbool_t, TRUE)
- hssize_t nblocks;
- hsize_t alloc_size;
- hsize_t *ptdata = NULL;
- int ndims;
- hid_t dtype;
- hid_t type_id;
-
- if((nblocks = H5Sget_select_hyper_nblocks(region_space)) <= 0)
- H5E_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_select_hyper_nblocks failed");
+ hssize_t snblocks;
+ hsize_t nblocks;
+ hsize_t alloc_size;
+ hsize_t *ptdata = NULL;
+ int sndims;
+ unsigned ndims;
+ hid_t dtype = H5I_INVALID_HID;
+ hid_t type_id = H5I_INVALID_HID;
+ hbool_t past_catch = FALSE;
+ hbool_t ret_value = TRUE;
+
+ H5TOOLS_START_DEBUG(" ");
+ if ((snblocks = H5Sget_select_hyper_nblocks(region_space)) <= 0)
+ H5TOOLS_THROW(FALSE, "H5Sget_select_hyper_nblocks failed");
+ nblocks = (hsize_t)snblocks;
/* Print block information */
- if((ndims = H5Sget_simple_extent_ndims(region_space)) < 0)
- H5E_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
+ if ((sndims = H5Sget_simple_extent_ndims(region_space)) < 0)
+ H5TOOLS_THROW(FALSE, "H5Sget_simple_extent_ndims failed");
+ ndims = (unsigned)sndims;
alloc_size = nblocks * ndims * 2 * sizeof(ptdata[0]);
- HDassert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/
- if((ptdata = (hsize_t*) HDmalloc((size_t) alloc_size)) == NULL)
- HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "Could not allocate buffer for ptdata");
+ if ((ptdata = (hsize_t *)HDmalloc((size_t)alloc_size)) == NULL)
+ H5TOOLS_GOTO_ERROR(FALSE, "Could not allocate buffer for ptdata");
- H5_CHECK_OVERFLOW(nblocks, hssize_t, hsize_t);
- if(H5Sget_select_hyper_blocklist(region_space, (hsize_t) 0, (hsize_t) nblocks, ptdata) < 0)
- HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Rget_select_hyper_blocklist failed");
+ if (H5Sget_select_hyper_blocklist(region_space, (hsize_t)0, nblocks, ptdata) < 0)
+ H5TOOLS_GOTO_ERROR(FALSE, "H5Rget_select_hyper_blocklist failed");
- if((dtype = H5Dget_type(region_id)) < 0)
- HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Dget_type failed");
- if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0)
- HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Tget_native_type failed");
+ if ((dtype = H5Dget_type(region_id)) < 0)
+ H5TOOLS_GOTO_ERROR(FALSE, "H5Dget_type failed");
+ if ((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR(FALSE, "H5Tget_native_type failed");
- render_bin_output_region_data_blocks(region_id, stream, container, ndims,
- type_id, nblocks, ptdata);
+ render_bin_output_region_data_blocks(region_id, stream, container, ndims, type_id, nblocks, ptdata);
- done:
+done:
HDfree(ptdata);
- if(H5Tclose(type_id) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+ if (type_id > 0 && H5Tclose(type_id) < 0)
+ H5TOOLS_ERROR(FALSE, "H5Tclose failed");
- if(H5Tclose(dtype) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+ if (dtype > 0 && H5Tclose(dtype) < 0)
+ H5TOOLS_ERROR(FALSE, "H5Tclose failed");
H5_LEAVE(TRUE)
- CATCH
+ CATCH
+ H5TOOLS_ENDDEBUG(" ");
return ret_value;
}
/*-------------------------------------------------------------------------
- * Audience: Public
- * Chapter: H5Tools Library
+ * Function: H5Tools Library
* Purpose: Print the data values from a dataset referenced by region points.
*
* Description:
@@ -1656,126 +2190,115 @@ render_bin_output_region_blocks(hid_t region_space, hid_t region_id,
*-------------------------------------------------------------------------
*/
int
-render_bin_output_region_data_points(hid_t region_space, hid_t region_id,
- FILE *stream, hid_t container,
- int ndims, hid_t type_id, hssize_t npoints, hsize_t *ptdata)
+render_bin_output_region_data_points(hid_t region_space, hid_t region_id, FILE *stream, hid_t container,
+ unsigned ndims, hid_t type_id, hsize_t npoints)
{
hsize_t *dims1 = NULL;
- int jndx;
- int type_size;
- hid_t mem_space = -1;
+ size_t type_size;
+ hid_t mem_space = H5I_INVALID_HID;
void *region_buf = NULL;
- int ret_value = SUCCEED;
+ int ret_value = 0;
- if((type_size = H5Tget_size(type_id)) == 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
+ H5TOOLS_START_DEBUG(" ");
+ if ((type_size = H5Tget_size(type_id)) == 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Tget_size failed");
- if((region_buf = HDmalloc(type_size * npoints)) == NULL)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for region");
+ if ((region_buf = HDmalloc(type_size * (size_t)npoints)) == NULL)
+ H5TOOLS_GOTO_ERROR((-1), "Could not allocate buffer for region");
/* Allocate space for the dimension array */
- if((dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for dims");
+ if ((dims1 = (hsize_t *)HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
+ H5TOOLS_GOTO_ERROR((-1), "Could not allocate buffer for dims");
dims1[0] = npoints;
- if((mem_space = H5Screate_simple(1, dims1, NULL)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Screate_simple failed");
+ if ((mem_space = H5Screate_simple(1, dims1, NULL)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Screate_simple failed");
- if(H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed");
- for (jndx = 0; jndx < npoints; jndx++) {
- if(H5Sget_simple_extent_dims(region_space, dims1, NULL) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
+ if (H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dread failed");
+ if (H5Sget_simple_extent_dims(region_space, dims1, NULL) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_dims failed");
- render_bin_output(stream, container, type_id, ((char*)region_buf + jndx * type_size));
- } /* end for (jndx = 0; jndx < npoints; jndx++) */
+ if (render_bin_output(stream, container, type_id, (char *)region_buf, npoints) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "render_bin_output of data points failed");
- done:
+done:
HDfree(region_buf);
HDfree(dims1);
- if(H5Sclose(mem_space) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
+ if (H5Sclose(mem_space) < 0)
+ H5TOOLS_ERROR((-1), "H5Sclose failed");
+ H5TOOLS_ENDDEBUG(" ");
return ret_value;
}
/*-------------------------------------------------------------------------
- * Audience: Public
- * Chapter: H5Tools Library
- * Purpose: Print some values from a dataset referenced by region points.
+ * Function: render_bin_output_region_points
*
- * Description:
- * This is a special case subfunction to dump a region reference using points.
- *
- * Return:
- * The function returns False if the last dimension has been reached, otherwise True
+ * Purpose: Print some values from a dataset referenced by region points.
+ * This is a special case function to dump a region reference using points.
*
+ * Return: False if the last dimension has been reached
+ * True otherwise
*-------------------------------------------------------------------------
*/
hbool_t
-render_bin_output_region_points(hid_t region_space, hid_t region_id,
- FILE *stream, hid_t container)
+render_bin_output_region_points(hid_t region_space, hid_t region_id, FILE *stream, hid_t container)
{
- HERR_INIT(hbool_t, TRUE)
- hssize_t npoints;
- hsize_t alloc_size;
- hsize_t *ptdata;
- int ndims;
- hid_t dtype;
- hid_t type_id;
-
- if((npoints = H5Sget_select_elem_npoints(region_space)) <= 0)
- H5E_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_select_elem_npoints failed");
+ hssize_t snpoints;
+ hsize_t npoints;
+ int sndims;
+ unsigned ndims;
+ hid_t dtype = H5I_INVALID_HID;
+ hid_t type_id = H5I_INVALID_HID;
+ hbool_t past_catch = FALSE;
+ hbool_t ret_value = TRUE;
+
+ H5TOOLS_START_DEBUG(" ");
+ if ((snpoints = H5Sget_select_elem_npoints(region_space)) <= 0)
+ H5TOOLS_THROW(FALSE, "H5Sget_select_elem_npoints failed");
+ npoints = (hsize_t)snpoints;
/* Allocate space for the dimension array */
- if((ndims = H5Sget_simple_extent_ndims(region_space)) < 0)
- H5E_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
+ if ((sndims = H5Sget_simple_extent_ndims(region_space)) < 0)
+ H5TOOLS_THROW(FALSE, "H5Sget_simple_extent_ndims failed");
+ ndims = (unsigned)sndims;
- alloc_size = npoints * ndims * sizeof(ptdata[0]);
- HDassert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/
- if(NULL == (ptdata = (hsize_t *)HDmalloc((size_t) alloc_size)))
- HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "Could not allocate buffer for ptdata");
+ if ((dtype = H5Dget_type(region_id)) < 0)
+ H5TOOLS_GOTO_ERROR(FALSE, "H5Dget_type failed");
- H5_CHECK_OVERFLOW(npoints, hssize_t, hsize_t);
- if(H5Sget_select_elem_pointlist(region_space, (hsize_t) 0, (hsize_t) npoints, ptdata) < 0)
- HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Sget_select_elem_pointlist failed");
+ if ((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR(FALSE, "H5Tget_native_type failed");
- if((dtype = H5Dget_type(region_id)) < 0)
- HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Dget_type failed");
-
- if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0)
- HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Tget_native_type failed");
-
- render_bin_output_region_data_points(region_space, region_id,
- stream, container, ndims, type_id, npoints, ptdata);
-
- done:
- HDfree(ptdata);
+ render_bin_output_region_data_points(region_space, region_id, stream, container, ndims, type_id, npoints);
- if(H5Tclose(type_id) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+done:
+ if (type_id > 0 && H5Tclose(type_id) < 0)
+ H5TOOLS_ERROR(FALSE, "H5Tclose failed");
- if(H5Tclose(dtype) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+ if (dtype > 0 && H5Tclose(dtype) < 0)
+ H5TOOLS_ERROR(FALSE, "H5Tclose failed");
H5_LEAVE(ret_value)
-CATCH
+ CATCH
+ H5TOOLS_ENDDEBUG(" ");
return ret_value;
}
/*-------------------------------------------------------------------------
- * Function: h5tools_is_zero
+ * Function: h5tools_is_zero
*
- * Purpose: Determines if memory is initialized to all zero bytes.
+ * Purpose: Determines if memory is initialized to all zero bytes.
*
- * Return: TRUE if all bytes are zero; FALSE otherwise
+ * Return: TRUE if all bytes are zero
+ * FALSE otherwise
*-------------------------------------------------------------------------
*/
-hbool_t
+H5_ATTR_PURE hbool_t
h5tools_is_zero(const void *_mem, size_t size)
{
- const unsigned char *mem = (const unsigned char *) _mem;
+ const unsigned char *mem = (const unsigned char *)_mem;
while (size-- > 0)
if (mem[size])
@@ -1785,45 +2308,46 @@ h5tools_is_zero(const void *_mem, size_t size)
}
/*-------------------------------------------------------------------------
- * Function: h5tools_is_obj_same
+ * Function: h5tools_is_obj_same
*
- * Purpose: Check if two given object IDs or link names point to the same object.
+ * Purpose: Check if two given object IDs or link names point to the same object.
*
* Parameters:
- * hid_t loc_id1: location of the first object
- * char *name1: link name of the first object.
- * Use "." or NULL if loc_id1 is the object to be compared.
- * hid_t loc_id2: location of the second object
- * char *name1: link name of the first object.
- * Use "." or NULL if loc_id2 is the object to be compared.
- *
- * Return: TRUE if it is the same object; FALSE otherwise.
- *
- * Programmer: Peter Cao
- * 4/27/2011
- *
+ * hid_t loc_id1: location of the first object
+ * char *name1: link name of the first object.
+ * Use "." or NULL if loc_id1 is the object to be compared.
+ * hid_t loc_id2: location of the second object
+ * char *name1: link name of the first object.
+ * Use "." or NULL if loc_id2 is the object to be compared.
+ *
+ * Return: TRUE if it is the same object
+ * FALSE otherwise.
*-------------------------------------------------------------------------
*/
hbool_t
-h5tools_is_obj_same(hid_t loc_id1, const char *name1,
- hid_t loc_id2, const char *name2)
+h5tools_is_obj_same(hid_t loc_id1, const char *name1, hid_t loc_id2, const char *name2)
{
- H5O_info_t oinfo1, oinfo2;
- hbool_t ret_val = 0;
+ H5O_info2_t oinfo1, oinfo2;
+ hbool_t ret_val = FALSE;
- if ( name1 && HDstrcmp(name1, "."))
- H5Oget_info_by_name(loc_id1, name1, &oinfo1, H5P_DEFAULT);
+ if (name1 && HDstrcmp(name1, ".") != 0)
+ H5Oget_info_by_name3(loc_id1, name1, &oinfo1, H5O_INFO_BASIC, H5P_DEFAULT);
else
- H5Oget_info(loc_id1, &oinfo1);
+ H5Oget_info3(loc_id1, &oinfo1, H5O_INFO_BASIC);
- if ( name2 && HDstrcmp(name2, "."))
- H5Oget_info_by_name(loc_id2, name2, &oinfo2, H5P_DEFAULT);
+ if (name2 && HDstrcmp(name2, ".") != 0)
+ H5Oget_info_by_name3(loc_id2, name2, &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT);
else
- H5Oget_info(loc_id2, &oinfo2);
+ H5Oget_info3(loc_id2, &oinfo2, H5O_INFO_BASIC);
+
+ if (oinfo1.fileno == oinfo2.fileno) {
+ int token_cmp_val;
- if (oinfo1.fileno == oinfo2.fileno && oinfo1.addr==oinfo2.addr)
- ret_val = 1;
+ H5Otoken_cmp(loc_id1, &oinfo1.token, &oinfo2.token, &token_cmp_val);
+
+ if (!token_cmp_val)
+ ret_val = TRUE;
+ }
return ret_val;
}
-
diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h
index 0f4b271..753a83b 100644
--- a/tools/lib/h5tools.h
+++ b/tools/lib/h5tools.h
@@ -1,95 +1,116 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Programmer: Robb Matzke <matzke@llnl.gov>
+ * Programmer: Robb Matzke
* Thursday, July 23, 1998
*
* Purpose: Support functions for the various tools.
*/
-#ifndef H5TOOLS_H__
-#define H5TOOLS_H__
+#ifndef H5TOOLS_H
+#define H5TOOLS_H
#include "hdf5.h"
#include "h5tools_error.h"
-#define ESCAPE_HTML 1
-#define OPT(X,S) ((X) ? (X) : (S))
-#define OPTIONAL_LINE_BREAK "\001" /* Special strings embedded in the output */
+#define ESCAPE_HTML 1
+#define OPT(X, S) ((X) ? (X) : (S))
+#define OPTIONAL_LINE_BREAK "\001" /* Special strings embedded in the output */
#define START_OF_DATA 0x0001
-#define END_OF_DATA 0x0002
-
-/* format for hsize_t */
-#define HSIZE_T_FORMAT "%"H5_PRINTF_LL_WIDTH"u"
-
-#define H5TOOLS_DUMP_MAX_RANK H5S_MAX_RANK
+#define END_OF_DATA 0x0002
+
+#define H5TOOLS_DUMP_MAX_RANK H5S_MAX_RANK
+
+/* Stream macros */
+#define FLUSHSTREAM(S) \
+ if (S != NULL) \
+ HDfflush(S)
+#define PRINTSTREAM(S, F, ...) \
+ if (S != NULL) \
+ HDfprintf(S, F, __VA_ARGS__)
+#define PRINTVALSTREAM(S, V) \
+ if (S != NULL) \
+ HDfprintf(S, V)
+#define PUTSTREAM(X, S) \
+ do { \
+ if (S != NULL) \
+ HDfputs(X, S); \
+ } while (0)
/*
* Strings for output - these were duplicated from the h5dump.h
* file in order to support region reference data display
*/
-#define ATTRIBUTE "ATTRIBUTE"
-#define BLOCK "BLOCK"
-#define SUPER_BLOCK "SUPER_BLOCK"
-#define COMPRESSION "COMPRESSION"
-#define CONCATENATOR "//"
-#define COMPLEX "COMPLEX"
-#define COUNT "COUNT"
-#define CSET "CSET"
-#define CTYPE "CTYPE"
-#define DATA "DATA"
-#define DATASPACE "DATASPACE"
-#define EXTERNAL "EXTERNAL"
-#define FILENO "FILENO"
-#define HARDLINK "HARDLINK"
-#define NLINK "NLINK"
-#define OBJID "OBJECTID"
-#define OBJNO "OBJNO"
-#define S_SCALAR "SCALAR"
-#define S_SIMPLE "SIMPLE"
-#define S_NULL "NULL"
-#define SOFTLINK "SOFTLINK"
-#define EXTLINK "EXTERNAL_LINK"
-#define UDLINK "USERDEFINED_LINK"
-#define START "START"
-#define STRIDE "STRIDE"
-#define STRSIZE "STRSIZE"
-#define STRPAD "STRPAD"
-#define SUBSET "SUBSET"
-#define FILTERS "FILTERS"
-#define DEFLATE "COMPRESSION DEFLATE"
-#define DEFLATE_LEVEL "LEVEL"
-#define SHUFFLE "PREPROCESSING SHUFFLE"
-#define FLETCHER32 "CHECKSUM FLETCHER32"
-#define SZIP "COMPRESSION SZIP"
-#define NBIT "COMPRESSION NBIT"
-#define SCALEOFFSET "COMPRESSION SCALEOFFSET"
-#define SCALEOFFSET_MINBIT "MIN BITS"
-#define STORAGE_LAYOUT "STORAGE_LAYOUT"
-#define CONTIGUOUS "CONTIGUOUS"
-#define COMPACT "COMPACT"
-#define CHUNKED "CHUNKED"
-#define EXTERNAL_FILE "EXTERNAL_FILE"
-#define FILLVALUE "FILLVALUE"
-#define FILE_CONTENTS "FILE_CONTENTS"
-#define PACKED_BITS "PACKED_BITS"
-#define PACKED_OFFSET "OFFSET"
-#define PACKED_LENGTH "LENGTH"
-
-#define BEGIN "{"
-#define END "}"
+#define ATTRIBUTE "ATTRIBUTE"
+#define BLOCK "BLOCK"
+#define SUPER_BLOCK "SUPER_BLOCK"
+#define COMPRESSION "COMPRESSION"
+#define CONCATENATOR "//"
+#define COMPLEX "COMPLEX"
+#define COUNT "COUNT"
+#define CSET "CSET"
+#define CTYPE "CTYPE"
+#define DATA "DATA"
+#define DATASPACE "DATASPACE"
+#define EXTERNAL "EXTERNAL"
+#define FILENO "FILENO"
+#define HARDLINK "HARDLINK"
+#define NLINK "NLINK"
+#define OBJID "OBJECTID"
+#define OBJNO "OBJNO"
+#define S_SCALAR "SCALAR"
+#define S_SIMPLE "SIMPLE"
+#define S_NULL "NULL"
+#define SOFTLINK "SOFTLINK"
+#define EXTLINK "EXTERNAL_LINK"
+#define UDLINK "USERDEFINED_LINK"
+#define START "START"
+#define STRIDE "STRIDE"
+#define STRSIZE "STRSIZE"
+#define STRPAD "STRPAD"
+#define SUBSET "SUBSET"
+#define FILTERS "FILTERS"
+#define DEFLATE "COMPRESSION DEFLATE"
+#define DEFLATE_LEVEL "LEVEL"
+#define SHUFFLE "PREPROCESSING SHUFFLE"
+#define FLETCHER32 "CHECKSUM FLETCHER32"
+#define SZIP "COMPRESSION SZIP"
+#define NBIT "COMPRESSION NBIT"
+#define SCALEOFFSET "COMPRESSION SCALEOFFSET"
+#define SCALEOFFSET_MINBIT "MIN BITS"
+#define STORAGE_LAYOUT "STORAGE_LAYOUT"
+#define CONTIGUOUS "CONTIGUOUS"
+#define COMPACT "COMPACT"
+#define CHUNKED "CHUNKED"
+#define EXTERNAL_FILE "EXTERNAL_FILE"
+#define FILLVALUE "FILLVALUE"
+#define FILE_CONTENTS "FILE_CONTENTS"
+#define PACKED_BITS "PACKED_BITS"
+#define PACKED_OFFSET "OFFSET"
+#define PACKED_LENGTH "LENGTH"
+#define REGION "REGION"
+#define VDS_VIRTUAL "VIRTUAL"
+#define VDS_MAPPING "MAPPING"
+#define VDS_SOURCE "SOURCE"
+#define VDS_REG_HYPERSLAB "SELECTION REGULAR_HYPERSLAB"
+#define VDS_IRR_HYPERSLAB "SELECTION IRREGULAR_HYPERSLAB"
+#define VDS_POINT "POINT"
+#define VDS_SRC_FILE "FILE"
+#define VDS_SRC_DATASET "DATASET"
+#define VDS_NONE "SELECTION NONE"
+#define VDS_ALL "SELECTION ALL"
+
+#define BEGIN "{"
+#define END "}"
/*
* dump structure for output - this was duplicated from the h5dump.h
@@ -176,8 +197,20 @@ typedef struct h5tools_dump_header_t {
const char *dataspacedimbegin;
const char *dataspacedimend;
+ const char *virtualselectionbegin;
+ const char *virtualselectionend;
+ const char *virtualselectionblockbegin;
+ const char *virtualselectionblockend;
+ const char *virtualfilenamebegin;
+ const char *virtualfilenameend;
+ const char *virtualdatasetnamebegin;
+ const char *virtualdatasetnameend;
+
} h5tools_dump_header_t;
+/* Forward declaration (see declaration in h5tools_str.c) */
+struct H5LD_memb_t;
+
/*
* Information about how to format output.
*/
@@ -203,7 +236,7 @@ typedef struct h5tool_format_t {
*
* fmt_schar: The printf() format to use when rendering data which is
* typed `signed char'. The default is `%d'. This format is
- * used ony if the `ascii' field is zero.
+ * used only if the `ascii' field is zero.
*
* fmt_uchar: The printf() format to use when rendering data which is
* typed `unsigned char'. The default is `%u'. This format
@@ -254,22 +287,22 @@ typedef struct h5tool_format_t {
* Numeric data is also subject to the formats for individual elements.
*/
hbool_t raw;
- const char *fmt_raw;
- const char *fmt_int;
- const char *fmt_uint;
- const char *fmt_schar;
- const char *fmt_uchar;
- const char *fmt_short;
- const char *fmt_ushort;
- const char *fmt_long;
- const char *fmt_ulong;
- const char *fmt_llong;
- const char *fmt_ullong;
- const char *fmt_double;
- const char *fmt_float;
+ const char *fmt_raw;
+ const char *fmt_int;
+ const char *fmt_uint;
+ const char *fmt_schar;
+ const char *fmt_uchar;
+ const char *fmt_short;
+ const char *fmt_ushort;
+ const char *fmt_long;
+ const char *fmt_ulong;
+ const char *fmt_llong;
+ const char *fmt_ullong;
+ const char *fmt_double;
+ const char *fmt_float;
int ascii;
int str_locale;
- int str_repeat;
+ unsigned str_repeat;
/*
* Fields associated with compound array members.
@@ -287,9 +320,9 @@ typedef struct h5tool_format_t {
* linebreaks: a boolean value to determine if we want to break the line
* after each row of an array.
*/
- const char *arr_pre;
- const char *arr_sep;
- const char *arr_suf;
+ const char *arr_pre;
+ const char *arr_sep;
+ const char *arr_suf;
int arr_linebreak;
/*
@@ -313,12 +346,15 @@ typedef struct h5tool_format_t {
*
* end: a string to print after we reach the last element of
* each compound type. prints out before the suf.
+ *
+ * listv: h5watch: vector containing info about the list of compound fields to be printed.
*/
- const char *cmpd_name;
- const char *cmpd_sep;
- const char *cmpd_pre;
- const char *cmpd_suf;
- const char *cmpd_end;
+ const char *cmpd_name;
+ const char *cmpd_sep;
+ const char *cmpd_pre;
+ const char *cmpd_suf;
+ const char *cmpd_end;
+ const struct H5LD_memb_t *const *cmpd_listv;
/*
* Fields associated with vlen data types.
@@ -337,10 +373,10 @@ typedef struct h5tool_format_t {
* end: a string to print after we reach the last element of
* each compound type. prints out before the suf.
*/
- const char *vlen_sep;
- const char *vlen_pre;
- const char *vlen_suf;
- const char *vlen_end;
+ const char *vlen_sep;
+ const char *vlen_pre;
+ const char *vlen_suf;
+ const char *vlen_end;
/*
* Fields associated with the individual elements.
@@ -356,9 +392,9 @@ typedef struct h5tool_format_t {
* are followed on the same line by another element. The
* default is a single space.
*/
- const char *elmt_fmt;
- const char *elmt_suf1;
- const char *elmt_suf2;
+ const char *elmt_fmt;
+ const char *elmt_suf1;
+ const char *elmt_suf2;
/*
* Fields associated with the index values printed at the left edge of
@@ -371,15 +407,15 @@ typedef struct h5tool_format_t {
* sep: Each integer in the index list will be separated from the
* others by this string, which defaults to a comma.
*
- * fmt: After the index values are formated individually and
+ * fmt: After the index values are formatted individually and
* separated from one another by some string, the entire
- * resulting string will be formated according to this
+ * resulting string will be formatted according to this
* printf(3c) format which should include a format for a
* character string. The default is "%s".
*/
- const char *idx_n_fmt; /*index number format */
- const char *idx_sep; /*separator between numbers */
- const char *idx_fmt; /*entire index format */
+ const char *idx_n_fmt; /*index number format */
+ const char *idx_sep; /*separator between numbers */
+ const char *idx_fmt; /*entire index format */
/*
* Fields associated with entire lines.
@@ -435,23 +471,23 @@ typedef struct h5tool_format_t {
* indentlevel: a string that shows how far to indent if extra spacing
* is needed. dumper uses it.
*/
- int line_ncols; /*columns of output */
- size_t line_per_line; /*max elements per line */
- const char *line_pre; /*prefix at front of each line */
- const char *line_1st; /*alternate pre. on first line */
- const char *line_cont; /*alternate pre. on continuation*/
- const char *line_suf; /*string to append to each line */
- const char *line_sep; /*separates lines */
- int line_multi_new; /*split multi-line outputs? */
- const char *line_indent; /*for extra identation if we need it*/
+ unsigned line_ncols; /*columns of output */
+ size_t line_per_line; /*max elements per line */
+ const char *line_pre; /*prefix at front of each line */
+ const char *line_1st; /*alternate pre. on first line */
+ const char *line_cont; /*alternate pre. on continuation*/
+ const char *line_suf; /*string to append to each line */
+ const char *line_sep; /*separates lines */
+ int line_multi_new; /*split multi-line outputs? */
+ const char *line_indent; /*for extra indentation if we need it*/
/*used to skip the first set of checks for line length*/
int skip_first;
- /*flag used to hide or show the file number for obj refs*/
+ /*flag used to hide or show the file number for object refs*/
int obj_hidefileno;
- /*string used to format the output for the obje refs*/
+ /*string used to format the output for the object refs*/
const char *obj_format;
/*flag used to hide or show the file number for dataset regions*/
@@ -472,27 +508,6 @@ typedef struct h5tool_format_t {
} h5tool_format_t;
-typedef struct h5tools_context_t {
- size_t cur_column; /*current column for output */
- size_t cur_elmt; /*current element/output line */
- int need_prefix; /*is line prefix needed? */
- unsigned ndims; /*dimensionality */
- hsize_t p_min_idx[H5S_MAX_RANK]; /*min selected index */
- hsize_t p_max_idx[H5S_MAX_RANK]; /*max selected index */
- int prev_multiline; /*was prev datum multiline? */
- size_t prev_prefix_len; /*length of previous prefix */
- int continuation; /*continuation of previous data?*/
- hsize_t size_last_dim; /*the size of the last dimension,
- *needed so we can break after each
- *row */
- int indent_level; /*the number of times we need some
- *extra indentation */
- int default_indent_level; /*this is used when the indent level gets changed */
- hsize_t acc[H5S_MAX_RANK]; /* accumulator position */
- hsize_t pos[H5S_MAX_RANK]; /* matrix position */
- hsize_t sm_pos; /* current stripmine element position */
-} h5tools_context_t;
-
typedef struct subset_d {
hsize_t *data;
unsigned int len;
@@ -506,83 +521,195 @@ struct subset_t {
subset_d block;
};
+typedef struct h5tools_context_t {
+ size_t cur_column; /* current column for output */
+ size_t cur_elmt; /* current element/output line */
+ int need_prefix; /* is line prefix needed? */
+ unsigned ndims; /* dimensionality */
+ hsize_t p_min_idx[H5S_MAX_RANK]; /* min selected index */
+ hsize_t p_max_idx[H5S_MAX_RANK]; /* max selected index */
+ int prev_multiline; /* was prev datum multiline? */
+ size_t prev_prefix_len; /* length of previous prefix */
+ int continuation; /* continuation of previous data?*/
+ hsize_t size_last_dim; /* the size of the last dimension, needed so we can break after each row */
+ unsigned indent_level; /* the number of times we need some extra indentation */
+ unsigned default_indent_level; /* this is used when the indent level gets changed */
+ hsize_t acc[H5S_MAX_RANK]; /* accumulator position */
+ hsize_t pos[H5S_MAX_RANK]; /* matrix position */
+ hsize_t sm_pos; /* current stripmine element position */
+ const struct H5LD_memb_t *const
+ *cmpd_listv; /* h5watch: vector containing info about the list of compound fields to be printed */
+ struct subset_t *sset; /* subsetting parameters */
+ int display_index; /* */
+ int display_char; /* */
+} h5tools_context_t;
+
+/* VOL and VFD info structs used to set the file access property
+ * lists in the tools.
+ */
+
+typedef enum { VOL_BY_NAME, VOL_BY_VALUE } h5tools_vol_info_type_t;
+typedef enum { VFD_BY_NAME, VFD_BY_VALUE } h5tools_vfd_info_type_t;
+
+typedef struct h5tools_vol_info_t {
+ h5tools_vol_info_type_t type;
+
+ /* Pointer to information string to be passed to the connector for its setup */
+ const char *info_string;
+
+ /* Field specifying either the connector's name or value (ID) */
+ union {
+ const char *name;
+ H5VL_class_value_t value;
+ } u;
+} h5tools_vol_info_t;
+
+typedef struct h5tools_vfd_info_t {
+ h5tools_vfd_info_type_t type;
+
+ /* Pointer to information to be passed to the driver for its setup */
+ const void *info;
+
+ /* Field specifying either the driver's name or value (ID) */
+ union {
+ const char *name;
+ H5FD_class_value_t value;
+ } u;
+} h5tools_vfd_info_t;
+
+/* This enum should match the entries in the 'volnames'
+ * array since they are indices into that array. */
+typedef enum {
+ NATIVE_VOL_IDX = 0,
+ PASS_THROUGH_VOL_IDX,
+} vol_idx;
+
+/* This enum should match the entries in the 'drivernames'
+ * array since they are indices into that array. */
+typedef enum {
+ SEC2_VFD_IDX = 0,
+ DIRECT_VFD_IDX,
+ LOG_VFD_IDX,
+ WINDOWS_VFD_IDX,
+ STDIO_VFD_IDX,
+ CORE_VFD_IDX,
+ FAMILY_VFD_IDX,
+ SPLIT_VFD_IDX,
+ MULTI_VFD_IDX,
+ MPIO_VFD_IDX,
+ ROS3_VFD_IDX,
+ HDFS_VFD_IDX,
+ SUBFILING_VFD_IDX,
+ ONION_VFD_IDX,
+} driver_idx;
+
/* The following include, h5tools_str.h, must be after the
- * above stucts are defined. There is a dependency in the following
+ * above structs are defined. There is a dependency in the following
* include that hasn't been identified yet. */
#include "h5tools_str.h"
-H5TOOLS_DLLVAR h5tool_format_t h5tools_dataformat;
-H5TOOLS_DLLVAR const h5tools_dump_header_t h5tools_standardformat;
-H5TOOLS_DLLVAR const h5tools_dump_header_t* h5tools_dump_header_format;
-
#ifdef __cplusplus
extern "C" {
#endif
-H5TOOLS_DLLVAR int packed_bits_num; /* number of packed bits to display */
-H5TOOLS_DLLVAR int packed_data_offset; /* offset of packed bits to display */
-H5TOOLS_DLLVAR int packed_data_length; /* lengtht of packed bits to display */
-H5TOOLS_DLLVAR unsigned long long packed_data_mask; /* mask in which packed bits to display */
-H5TOOLS_DLLVAR FILE *rawdatastream; /* output stream for raw data */
-H5TOOLS_DLLVAR FILE *rawoutstream; /* output stream for raw output */
-H5TOOLS_DLLVAR FILE *rawerrorstream; /* output stream for raw error */
-H5TOOLS_DLLVAR int bin_output; /* binary output */
-H5TOOLS_DLLVAR int bin_form; /* binary form */
-H5TOOLS_DLLVAR int region_output; /* region output */
-H5TOOLS_DLLVAR int oid_output; /* oid output */
-H5TOOLS_DLLVAR int data_output; /* data output */
-H5TOOLS_DLLVAR int attr_data_output; /* attribute data output */
+H5TOOLS_DLLVAR const char *volnames[];
+H5TOOLS_DLLVAR const char *drivernames[];
+
+H5TOOLS_DLLVAR h5tool_format_t h5tools_dataformat;
+H5TOOLS_DLLVAR const h5tools_dump_header_t h5tools_standardformat;
+H5TOOLS_DLLVAR const h5tools_dump_header_t *h5tools_dump_header_format;
+H5TOOLS_DLLVAR H5E_auto2_t lib_func;
+H5TOOLS_DLLVAR H5E_auto2_t tools_func;
+H5TOOLS_DLLVAR void *lib_edata;
+H5TOOLS_DLLVAR void *tools_edata;
+
+H5TOOLS_DLLVAR unsigned packed_bits_num; /* number of packed bits to display */
+H5TOOLS_DLLVAR unsigned packed_data_offset; /* offset of packed bits to display */
+H5TOOLS_DLLVAR unsigned packed_data_length; /* length of packed bits to display */
+H5TOOLS_DLLVAR unsigned long long packed_data_mask; /* mask in which packed bits to display */
+H5TOOLS_DLLVAR FILE *rawattrstream; /* output stream for raw attribute data */
+H5TOOLS_DLLVAR FILE *rawdatastream; /* output stream for raw data */
+H5TOOLS_DLLVAR FILE *rawinstream; /* input stream for raw input */
+H5TOOLS_DLLVAR FILE *rawoutstream; /* output stream for raw output */
+H5TOOLS_DLLVAR FILE *rawerrorstream; /* output stream for raw error */
+H5TOOLS_DLLVAR int bin_output; /* binary output */
+H5TOOLS_DLLVAR int bin_form; /* binary form */
+H5TOOLS_DLLVAR int region_output; /* region output */
+H5TOOLS_DLLVAR int oid_output; /* oid output */
+H5TOOLS_DLLVAR int data_output; /* data output */
+H5TOOLS_DLLVAR int attr_data_output; /* attribute data output */
+
+/* sort parameters */
+H5TOOLS_DLLVAR H5_index_t sort_by; /* sort_by [creation_order | name] */
+H5TOOLS_DLLVAR H5_iter_order_t sort_order; /* sort_order [ascending | descending] */
+
+/* things to display or which are set via command line parameters */
+H5TOOLS_DLLVAR int enable_error_stack; /* re-enable error stack; disable=0 enable=1 */
/* Strings for output */
-#define H5_TOOLS_GROUP "GROUP"
-#define H5_TOOLS_DATASET "DATASET"
-#define H5_TOOLS_DATATYPE "DATATYPE"
+#define H5_TOOLS_GROUP "GROUP"
+#define H5_TOOLS_DATASET "DATASET"
+#define H5_TOOLS_DATATYPE "DATATYPE"
+#define H5_TOOLS_ATTRIBUTE "ATTRIBUTE"
+#define H5_TOOLS_UNKNOWN "UNKNOWN"
/* Definitions of useful routines */
-H5TOOLS_DLL void h5tools_init(void);
-H5TOOLS_DLL void h5tools_close(void);
-H5TOOLS_DLL hid_t h5tools_fopen(const char *fname, unsigned flags, hid_t fapl,
- const char *driver, char *drivername, size_t drivername_len);
-H5TOOLS_DLL hid_t h5tools_get_native_type(hid_t type);
+H5TOOLS_DLL void h5tools_init(void);
+H5TOOLS_DLL void h5tools_close(void);
+
+H5TOOLS_DLL void h5tools_error_report(void);
+H5TOOLS_DLL int h5tools_set_data_output_file(const char *fname, int is_bin);
+H5TOOLS_DLL int h5tools_set_attr_output_file(const char *fname, int is_bin);
+H5TOOLS_DLL int h5tools_set_input_file(const char *fname, int is_bin);
+H5TOOLS_DLL int h5tools_set_output_file(const char *fname, int is_bin);
+H5TOOLS_DLL int h5tools_set_error_file(const char *fname, int is_bin);
+
+H5TOOLS_DLL hid_t h5tools_get_fapl(hid_t prev_fapl_id, h5tools_vol_info_t *vol_info,
+ h5tools_vfd_info_t *vfd_info);
+H5TOOLS_DLL herr_t h5tools_get_vfd_name(hid_t fid, hid_t fapl_id, char *drivername, size_t drivername_size);
+H5TOOLS_DLL hid_t h5tools_fopen(const char *fname, unsigned flags, hid_t fapl, hbool_t use_specific_driver,
+ char *drivername, size_t drivername_size);
H5TOOLS_DLL hid_t h5tools_get_little_endian_type(hid_t type);
H5TOOLS_DLL hid_t h5tools_get_big_endian_type(hid_t type);
H5TOOLS_DLL htri_t h5tools_detect_vlen(hid_t tid);
H5TOOLS_DLL htri_t h5tools_detect_vlen_str(hid_t tid);
H5TOOLS_DLL hbool_t h5tools_is_obj_same(hid_t loc_id1, const char *name1, hid_t loc_id2, const char *name2);
-H5TOOLS_DLL void init_acc_pos(h5tools_context_t *ctx, hsize_t *dims);
+H5TOOLS_DLL void init_acc_pos(unsigned ndims, const hsize_t *dims, hsize_t *acc, hsize_t *pos,
+ hsize_t *p_min_idx);
+H5TOOLS_DLL hsize_t calc_acc_pos(unsigned ndims, hsize_t elemtno, const hsize_t *acc, hsize_t *pos);
H5TOOLS_DLL hbool_t h5tools_is_zero(const void *_mem, size_t size);
-H5TOOLS_DLL int h5tools_canreadf(const char* name, hid_t dcpl_id);
+H5TOOLS_DLL int h5tools_canreadf(const char *name, hid_t dcpl_id);
H5TOOLS_DLL int h5tools_can_encode(H5Z_filter_t filtn);
-H5TOOLS_DLL void h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx, hsize_t elmtno, int secnum);
-H5TOOLS_DLL void h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx, hsize_t elmtno, hsize_t *ptdata, int secnum);
-
-H5TOOLS_DLL int do_bin_output(FILE *stream, FILE *err_stream, hid_t container, hsize_t nelmts, hid_t tid, void *_mem);
-H5TOOLS_DLL int render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem);
-H5TOOLS_DLL int render_bin_output_region_data_blocks(hid_t region_id, FILE *stream,
- hid_t container, int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata);
-H5TOOLS_DLL hbool_t render_bin_output_region_blocks(hid_t region_space, hid_t region_id,
- FILE *stream, hid_t container);
-H5TOOLS_DLL hbool_t render_bin_output_region_points(hid_t region_space, hid_t region_id,
- FILE *stream, hid_t container);
-
-H5TOOLS_DLL hbool_t h5tools_render_element(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx, h5tools_str_t *buffer, hsize_t *curr_pos,
- size_t ncols, hsize_t local_elmt_counter, hsize_t elmt_counter);
+H5TOOLS_DLL void h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
+ hsize_t elmtno, int secnum);
+H5TOOLS_DLL void h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info,
+ h5tools_context_t *ctx, hsize_t elmtno, hsize_t *ptdata,
+ int secnum);
+
+H5TOOLS_DLL int render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t nelmts);
+H5TOOLS_DLL int render_bin_output_region_data_blocks(hid_t region_id, FILE *stream, hid_t container,
+ unsigned ndims, hid_t type_id, hsize_t nblocks,
+ const hsize_t *ptdata);
+H5TOOLS_DLL hbool_t render_bin_output_region_blocks(hid_t region_space, hid_t region_id, FILE *stream,
+ hid_t container);
+H5TOOLS_DLL int render_bin_output_region_data_points(hid_t region_space, hid_t region_id, FILE *stream,
+ hid_t container, unsigned ndims, hid_t type_id,
+ hsize_t npoints);
+H5TOOLS_DLL hbool_t render_bin_output_region_points(hid_t region_space, hid_t region_id, FILE *stream,
+ hid_t container);
+
+H5TOOLS_DLL hbool_t h5tools_render_element(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
+ h5tools_str_t *buffer, hsize_t *curr_pos, size_t ncols,
+ hsize_t local_elmt_counter, hsize_t elmt_counter);
H5TOOLS_DLL hbool_t h5tools_render_region_element(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx/*in,out*/,
- h5tools_str_t *buffer/*string into which to render */,
- hsize_t *curr_pos/*total data element position*/,
- size_t ncols, hsize_t *ptdata,
- hsize_t local_elmt_counter/*element counter*/,
- hsize_t elmt_counter);
+ h5tools_context_t *ctx, h5tools_str_t *buffer,
+ hsize_t *curr_pos, size_t ncols, hsize_t *ptdata,
+ hsize_t local_elmt_counter, hsize_t elmt_counter);
#ifdef __cplusplus
}
#endif
-#endif /* H5TOOLS_H__ */
-
+#endif /* H5TOOLS_H */
diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c
index 9188225..d80ef1f 100644
--- a/tools/lib/h5tools_dump.c
+++ b/tools/lib/h5tools_dump.c
@@ -1,219 +1,215 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Programmer: Robb Matzke <matzke@llnl.gov>
- * Thursday, July 23, 1998
- *
* Purpose: A library for displaying the values of a dataset in a human
* readable format.
*/
-#include <stdio.h>
-#include <stdlib.h>
-
#include "h5tools.h"
#include "h5tools_dump.h"
#include "h5tools_ref.h"
#include "h5tools_utils.h"
#include "H5private.h"
-#define SANITY_CHECK
-
-#define ALIGN(A,Z) ((((A) + (Z) - 1) / (Z)) * (Z))
-
h5tool_format_t h5tools_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 */
-",\n", /*cmpd_sep */
-"{", /*cmpd_pre */
-"}", /*cmpd_suf */
-"\n", /*cmpd_end */
-
-", ", /*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 */
-"%s", /*line_cont */
-"", /*line_suf */
-"", /*line_sep */
-1, /*line_multi_new */
-" ", /*line_indent */
-
-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 */
-1, /*array indices */
-1 /*escape non printable characters */
+ 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 */
+ ",\n", /*cmpd_sep */
+ "{", /*cmpd_pre */
+ "}", /*cmpd_suf */
+ "\n", /*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 */
+ "%s", /*line_cont */
+ "", /*line_suf */
+ "", /*line_sep */
+ 1, /*line_multi_new */
+ " ", /*line_indent */
+
+ 1, /*skip_first */
+
+ 1, /*obj_hidefileno */
+ " %" PRIuHADDR, /*obj_format */
+
+ 1, /*dset_hidefileno */
+ "DATASET %s ", /*dset_format */
+ "%s", /*dset_blockformat_pre */
+ "%s", /*dset_ptformat_pre */
+ "%s", /*dset_ptformat */
+ 1, /*array indices */
+ 1 /*escape non printable characters */
};
const h5tools_dump_header_t h5tools_standardformat = {
-"standardformat", /*name */
-"HDF5", /*fileebgin */
-"", /*fileend */
-SUPER_BLOCK, /*bootblockbegin */
-"", /*bootblockend */
-H5_TOOLS_GROUP, /*groupbegin */
-"", /*groupend */
-H5_TOOLS_DATASET, /*datasetbegin */
-"", /*datasetend */
-ATTRIBUTE, /*attributebegin */
-"", /*attributeend */
-H5_TOOLS_DATATYPE, /*datatypebegin */
-"", /*datatypeend */
-DATASPACE, /*dataspacebegin */
-"", /*dataspaceend */
-DATA, /*databegin */
-"", /*dataend */
-SOFTLINK, /*softlinkbegin */
-"", /*softlinkend */
-EXTLINK, /*extlinkbegin */
-"", /*extlinkend */
-UDLINK, /*udlinkbegin */
-"", /*udlinkend */
-SUBSET, /*subsettingbegin */
-"", /*subsettingend */
-START, /*startbegin */
-"", /*startend */
-STRIDE, /*stridebegin */
-"", /*strideend */
-COUNT, /*countbegin */
-"", /*countend */
-BLOCK, /*blockbegin */
-"", /*blockend */
-
-"{", /*fileblockbegin */
-"}", /*fileblockend */
-"{", /*bootblockblockbegin */
-"}", /*bootblockblockend */
-"{", /*groupblockbegin */
-"}", /*groupblockend */
-"{", /*datasetblockbegin */
-"}", /*datasetblockend */
-"{", /*attributeblockbegin */
-"}", /*attributeblockend */
-"", /*datatypeblockbegin */
-"", /*datatypeblockend */
-"", /*dataspaceblockbegin */
-"", /*dataspaceblockend */
-"{", /*datablockbegin */
-"}", /*datablockend */
-"{", /*softlinkblockbegin */
-"}", /*softlinkblockend */
-"{", /*extlinkblockbegin */
-"}", /*extlinkblockend */
-"{", /*udlinkblockbegin */
-"}", /*udlinkblockend */
-"{", /*strblockbegin */
-"}", /*strblockend */
-"{", /*enumblockbegin */
-"}", /*enumblockend */
-"{", /*structblockbegin */
-"}", /*structblockend */
-"{", /*vlenblockbegin */
-"}", /*vlenblockend */
-"{", /*subsettingblockbegin */
-"}", /*subsettingblockend */
-"(", /*startblockbegin */
-");", /*startblockend */
-"(", /*strideblockbegin */
-");", /*strideblockend */
-"(", /*countblockbegin */
-");", /*countblockend */
-"(", /*blockblockbegin */
-");", /*blockblockend */
-
-"", /*dataspacedescriptionbegin */
-"", /*dataspacedescriptionend */
-"(", /*dataspacedimbegin */
-")", /*dataspacedimend */
+ "standardformat", /*name */
+ "HDF5", /*filebegin */
+ "", /*fileend */
+ SUPER_BLOCK, /*bootblockbegin */
+ "", /*bootblockend */
+ H5_TOOLS_GROUP, /*groupbegin */
+ "", /*groupend */
+ H5_TOOLS_DATASET, /*datasetbegin */
+ "", /*datasetend */
+ ATTRIBUTE, /*attributebegin */
+ "", /*attributeend */
+ H5_TOOLS_DATATYPE, /*datatypebegin */
+ "", /*datatypeend */
+ DATASPACE, /*dataspacebegin */
+ "", /*dataspaceend */
+ DATA, /*databegin */
+ "", /*dataend */
+ SOFTLINK, /*softlinkbegin */
+ "", /*softlinkend */
+ EXTLINK, /*extlinkbegin */
+ "", /*extlinkend */
+ UDLINK, /*udlinkbegin */
+ "", /*udlinkend */
+ SUBSET, /*subsettingbegin */
+ "", /*subsettingend */
+ START, /*startbegin */
+ "", /*startend */
+ STRIDE, /*stridebegin */
+ "", /*strideend */
+ COUNT, /*countbegin */
+ "", /*countend */
+ BLOCK, /*blockbegin */
+ "", /*blockend */
+
+ "{", /*fileblockbegin */
+ "}", /*fileblockend */
+ "{", /*bootblockblockbegin */
+ "}", /*bootblockblockend */
+ "{", /*groupblockbegin */
+ "}", /*groupblockend */
+ "{", /*datasetblockbegin */
+ "}", /*datasetblockend */
+ "{", /*attributeblockbegin */
+ "}", /*attributeblockend */
+ "", /*datatypeblockbegin */
+ "", /*datatypeblockend */
+ "", /*dataspaceblockbegin */
+ "", /*dataspaceblockend */
+ "{", /*datablockbegin */
+ "}", /*datablockend */
+ "{", /*softlinkblockbegin */
+ "}", /*softlinkblockend */
+ "{", /*extlinkblockbegin */
+ "}", /*extlinkblockend */
+ "{", /*udlinkblockbegin */
+ "}", /*udlinkblockend */
+ "{", /*strblockbegin */
+ "}", /*strblockend */
+ "{", /*enumblockbegin */
+ "}", /*enumblockend */
+ "{", /*structblockbegin */
+ "}", /*structblockend */
+ "{", /*vlenblockbegin */
+ "}", /*vlenblockend */
+ "{", /*subsettingblockbegin */
+ "}", /*subsettingblockend */
+ "(", /*startblockbegin */
+ ");", /*startblockend */
+ "(", /*strideblockbegin */
+ ");", /*strideblockend */
+ "(", /*countblockbegin */
+ ");", /*countblockend */
+ "(", /*blockblockbegin */
+ ");", /*blockblockend */
+
+ "", /*dataspacedescriptionbegin */
+ "", /*dataspacedescriptionend */
+ "(", /*dataspacedimbegin */
+ ")", /*dataspacedimend */
+
+ "", /*virtualselectionbegin */
+ "", /*virtualselectionend */
+ "{", /*virtualselectionblockbegin */
+ "}", /*virtualselectionblockend */
+ "\"", /*virtualfilenamebeginbegin */
+ "\"", /*virtualfilenamebeginend */
+ "\"", /*virtualdatasetnamebegin */
+ "\"", /*virtualdtatasetnameend */
};
-const h5tools_dump_header_t* h5tools_dump_header_format;
-table_t *h5dump_type_table = NULL; /*type table reference for datatype dump */
+const h5tools_dump_header_t *h5tools_dump_header_format;
+table_t *h5dump_type_table = NULL; /* type table reference for datatype dump */
/* local prototypes */
-static int h5tools_print_region_data_blocks(hid_t region_id,
- FILE *stream, const h5tool_format_t *info, h5tools_context_t *cur_ctx,
- h5tools_str_t *buffer/*string into which to render */, size_t ncols,
- int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata);
-
-hbool_t h5tools_dump_region_data_points(hid_t region_space, hid_t region_id,
- FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx/*in,out*/,
- h5tools_str_t *buffer/*string into which to render */,
- hsize_t *curr_pos/*total data element position*/,
- size_t ncols, hsize_t region_elmt_counter/*element counter*/,
- hsize_t elmt_counter);
-
-int h5tools_print_region_data_points(hid_t region_space, hid_t region_id,
- FILE *stream, const h5tool_format_t *info, h5tools_context_t *cur_ctx,
- h5tools_str_t *buffer, size_t ncols,
- int ndims, hid_t type_id, hssize_t npoints, hsize_t *ptdata);
-
-hbool_t h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id,
- FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx/*in,out*/,
- h5tools_str_t *buffer/*string into which to render */,
- hsize_t *curr_pos/*total data element position*/,
- size_t ncols, hsize_t region_elmt_counter/*element counter*/,
- hsize_t elmt_counter);
+
+static int h5tools_print_region_data_blocks(hid_t region_id, FILE *stream, const h5tool_format_t *info,
+ h5tools_context_t *cur_ctx,
+ h5tools_str_t *buffer, /* string into which to render */
+ size_t ncols, unsigned ndims, hid_t type_id, hsize_t nblocks,
+ hsize_t *ptdata);
+
+static int h5tools_print_region_data_points(hid_t region_space, hid_t region_id, FILE *stream,
+ const h5tool_format_t *info, h5tools_context_t *cur_ctx,
+ h5tools_str_t *buffer, size_t ncols, unsigned ndims,
+ hid_t type_id, hsize_t npoints, hsize_t *ptdata);
+
+void h5tools_print_dims(h5tools_str_t *buffer, hsize_t *s, int dims);
+
+void h5tools_dump_subsetting_header(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
+ int dims);
+
+static void h5tools_print_virtual_selection(hid_t vspace, FILE *stream, const h5tool_format_t *info,
+ h5tools_context_t *ctx, /* in,out */
+ h5tools_str_t *buffer, /* string into which to render */
+ hsize_t *curr_pos, /* total data element position */
+ size_t ncols);
+
void
h5tools_dump_init(void)
{
@@ -257,37 +253,39 @@ h5tools_dump_init(void)
*-------------------------------------------------------------------------
*/
int
-h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t container,
- h5tools_context_t *ctx/*in,out*/, unsigned flags,
- hsize_t nelmts, hid_t type, void *_mem)
+h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, /* in,out */
+ hid_t container, unsigned flags, hsize_t nelmts, hid_t type, void *_mem)
{
- HERR_INIT(int, SUCCEED)
- unsigned char *mem = (unsigned char*) _mem;
- hsize_t i; /*element counter */
- size_t size; /*size of each datum */
- hid_t region_space = -1;
- hid_t region_id = -1;
+ unsigned char *mem = (unsigned char *)_mem;
+ hsize_t i; /* element counter */
+ size_t size; /* size of each datum */
hbool_t dimension_break = TRUE;
- H5S_sel_type region_type;
- size_t ncols = 80; /*available output width */
- h5tools_str_t buffer; /*string into which to render */
- hsize_t curr_pos = 0; /* total data element position */
- hsize_t elmt_counter = 0;/*counts the # elements printed.
- *I (ptl?) needed something that
- *isn't going to get reset when a new
- *line is formed. I'm going to use
- *this var to count elements and
- *break after we see a number equal
- *to the ctx->size_last_dim. */
-
+ size_t ncols = 80; /* available output width */
+ h5tools_str_t buffer; /* string into which to render */
+ hsize_t curr_pos = 0; /* total data element position */
+ hsize_t elmt_counter = 0; /* counts the # elements printed.
+ * I (ptl?) needed something that
+ * isn't going to get reset when a new
+ * line is formed. I'm going to use
+ * this var to count elements and
+ * break after we see a number equal
+ * to the ctx->size_last_dim. */
+ int ret_value = 0;
+
+ H5TOOLS_START_DEBUG(" file=%p", (void *)stream);
+ H5TOOLS_DEBUG("rawdata file=%p", (void *)rawdatastream);
/* binary dump */
- if (bin_output) {
- do_bin_output(rawdatastream, rawoutstream, container, nelmts, type, _mem);
+ if (bin_output && (rawdatastream != NULL)) {
+ H5TOOLS_DEBUG("render_bin_output");
+ if (render_bin_output(rawdatastream, container, type, _mem, nelmts) < 0) {
+ PRINTVALSTREAM(rawoutstream, "\nError in writing binary stream\n");
+ }
} /* end if */
else {
/* setup */
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
size = H5Tget_size(type);
+ H5TOOLS_DEBUG("type size is %ld", size);
if (info->line_ncols > 0)
ncols = info->line_ncols;
@@ -298,99 +296,175 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai
*/
curr_pos = ctx->sm_pos;
- if (region_output && H5Tequal(type, H5T_STD_REF_DSETREG)) {
- for (i = 0; i < nelmts; i++, ctx->cur_elmt++, elmt_counter++) {
- void* memref = mem + i * size;
- char ref_name[1024];
-
- /* region data */
- region_id = H5Rdereference2(container, H5P_DEFAULT, H5R_DATASET_REGION, memref);
- if (region_id >= 0) {
- region_space = H5Rget_region(container, H5R_DATASET_REGION, memref);
- if (region_space >= 0) {
- if (h5tools_is_zero(memref, H5Tget_size(type))) {
- ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
+ H5TOOLS_DEBUG("data render start:%ld", nelmts);
+ for (i = 0; i < nelmts; i++, ctx->cur_elmt++, elmt_counter++) {
+ void *memref = mem + i * size;
- /* Render the region element begin */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "NULL");
+ /* Render the data element begin*/
+ h5tools_str_reset(&buffer);
+ h5tools_str_sprint(&buffer, info, container, type, memref, ctx);
- dimension_break = h5tools_render_element(stream, info,
- ctx, &buffer, &curr_pos, ncols, i, elmt_counter);
- }
- else {
- if(H5Rget_name(region_id, H5R_DATASET_REGION, memref, (char*) ref_name, 1024)<0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rget_name failed");
+ if (i + 1 < nelmts || (flags & END_OF_DATA) == 0)
+ h5tools_str_append(&buffer, "%s", OPT(info->elmt_suf1, ","));
- ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos+i, 0);
+ dimension_break =
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, i, elmt_counter);
+ /* Render the data element end*/
+ if (FALSE == dimension_break)
+ elmt_counter = 0;
+ } /* end for (i = 0; i < nelmts... */
+ H5TOOLS_DEBUG("data render finish");
- /* Render the region element begin */
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, info->dset_format, ref_name);
+ h5tools_str_close(&buffer);
+ } /* else bin */
- dimension_break = h5tools_render_element(stream, info,
- ctx, &buffer, &curr_pos, ncols, i, elmt_counter);
+ H5TOOLS_ENDDEBUG("exit");
+ return ret_value;
+}
- region_type = H5Sget_select_type(region_space);
- if(region_type == H5S_SEL_POINTS)
- /* Print point information */
- dimension_break = h5tools_dump_region_data_points(
- region_space, region_id, stream, info, ctx,
- &buffer, &curr_pos, ncols, i, elmt_counter);
- else if(region_type == H5S_SEL_HYPERSLABS)
- /* Print block information */
- dimension_break = h5tools_dump_region_data_blocks(
- region_space, region_id, stream, info, ctx,
- &buffer, &curr_pos, ncols, i, elmt_counter);
- else
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "invalid region type");
- /* Render the region element end */
+/*-------------------------------------------------------------------------
+ * Audience: Public
+ * Chapter: H5Tools Library
+ * Purpose: Print some values from an attribute referenced by object reference.
+ *
+ * Description:
+ * This is a special case subfunction to dump an attribute reference.
+ *
+ * Return:
+ * The function returns False if the last dimension has been reached, otherwise True
+ *
+ * In/Out:
+ * h5tools_context_t *ctx
+ * hsize_t *curr_pos
+ *
+ * Parameters Description:
+ * h5tools_str_t *buffer is the string into which to render
+ * hsize_t curr_pos is the total data element position
+ * size_t ncols
+ * hsize_t region_elmt_counter is the region element loop counter
+ * hsize_t elmt_count is the data element loop counter
+ *-------------------------------------------------------------------------
+ */
+hbool_t
+h5tools_dump_region_attribute(hid_t region_id, FILE *stream, const h5tool_format_t *info,
+ h5tools_context_t *ctx, /* in,out */
+ h5tools_str_t *buffer, /* string into which to render */
+ hsize_t *curr_pos, /* total data element position */
+ size_t ncols, hsize_t region_elmt_counter, /* element counter */
+ hsize_t elmt_counter)
+{
+ hbool_t dimension_break = TRUE;
+ hid_t atype = H5I_INVALID_HID;
+ hid_t type_id = H5I_INVALID_HID;
+ hid_t region_space = H5I_INVALID_HID;
+ h5tool_format_t outputformat; /* Use to disable prefix for DATA attribute display */
+ hbool_t past_catch = FALSE;
+ hbool_t ret_value = TRUE;
- } /* end else to if (h5tools_is_zero(... */
- if(H5Sclose(region_space) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
- } /* end if (region_space >= 0) */
- else
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rget_region failed");
- if(H5Dclose(region_id) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dclose failed");
+ HDassert(info);
+ HDassert(ctx);
+ HDassert(buffer);
- } /* if (region_id >= 0) */
- else {
- /* if (region_id < 0) - could mean that no reference was written do not throw failure */
- H5Epush2(H5tools_ERR_STACK_g, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_id_g, "H5Rdereference failed");
- }
+ outputformat = *info;
+ outputformat.idx_fmt = "";
+ outputformat.idx_n_fmt = "";
+ outputformat.idx_sep = "";
+ outputformat.line_pre = "";
- ctx->need_prefix = TRUE;
-
- if(FALSE == dimension_break)
- elmt_counter = 0;
- } /* end for (i = 0; i < nelmts... */
- } /* end if (region_output... */
- else {
- for (i = 0; i < nelmts; i++, ctx->cur_elmt++, elmt_counter++) {
- void* memref = mem + i * size;
- /* Render the data element begin*/
- h5tools_str_reset(&buffer);
- h5tools_str_sprint(&buffer, info, container, type, memref, ctx);
+ H5TOOLS_DEBUG("enter file=%p", (void *)stream);
+ H5TOOLS_DEBUG("rawdata file=%p", (void *)rawdatastream);
- if (i + 1 < nelmts || (flags & END_OF_DATA) == 0)
- h5tools_str_append(&buffer, "%s", OPT(info->elmt_suf1, ","));
+ /* Render the region { element begin */
+ h5tools_str_reset(buffer);
- dimension_break = h5tools_render_element(stream, info, ctx, &buffer,
- &curr_pos, ncols, i, elmt_counter);
- /* Render the data element end*/
- if(FALSE == dimension_break)
- elmt_counter = 0;
- } /* end for (i = 0; i < nelmts... */
- }
+ h5tools_str_append(buffer, " {");
+ dimension_break = h5tools_render_element(stream, &outputformat, ctx, buffer, curr_pos, ncols,
+ region_elmt_counter, elmt_counter);
+ /* Render the region { element end */
- h5tools_str_close(&buffer);
- }/* else bin */
+ if ((region_space = H5Aget_space(region_id)) < 0)
+ H5TOOLS_GOTO_ERROR(dimension_break, "H5Aget_space failed");
+ if ((atype = H5Aget_type(region_id)) < 0)
+ H5TOOLS_GOTO_ERROR(dimension_break, "H5Aget_type failed");
+ if ((type_id = H5Tget_native_type(atype, H5T_DIR_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR(dimension_break, "H5Tget_native_type failed");
+
+ ctx->indent_level++;
+ ctx->need_prefix = TRUE;
+
+ /* Render the datatype element begin */
+ h5tools_str_reset(buffer);
+ h5tools_str_append(buffer, "%s %s ", h5tools_dump_header_format->datatypebegin,
+ h5tools_dump_header_format->datatypeblockbegin);
+
+ ctx->need_prefix = TRUE;
+ ctx->indent_level++;
+ h5tools_print_datatype(stream, buffer, info, ctx, atype, TRUE);
+ ctx->indent_level--;
+
+ if (HDstrlen(h5tools_dump_header_format->datatypeblockend)) {
+ h5tools_str_append(buffer, "%s", h5tools_dump_header_format->datatypeblockend);
+ if (HDstrlen(h5tools_dump_header_format->datatypeend))
+ h5tools_str_append(buffer, " ");
+ }
+ if (HDstrlen(h5tools_dump_header_format->datatypeend))
+ h5tools_str_append(buffer, "%s", h5tools_dump_header_format->datatypeend);
+
+ dimension_break =
+ h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
+ /* Render the datatype element end */
+
+ ctx->need_prefix = TRUE;
+
+ /* Render the dataspace element begin */
+ h5tools_str_reset(buffer);
+ h5tools_str_append(buffer, "%s ", h5tools_dump_header_format->dataspacebegin);
+
+ h5tools_print_dataspace(buffer, region_space);
+
+ if (HDstrlen(h5tools_dump_header_format->dataspaceblockend)) {
+ h5tools_str_append(buffer, "%s", h5tools_dump_header_format->dataspaceblockend);
+ if (HDstrlen(h5tools_dump_header_format->dataspaceend))
+ h5tools_str_append(buffer, " ");
+ }
+ if (HDstrlen(h5tools_dump_header_format->dataspaceend))
+ h5tools_str_append(buffer, "%s", h5tools_dump_header_format->dataspaceblockend);
+
+ dimension_break =
+ h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
+ /* Render the dataspace element end */
+
+ if (region_output) {
+ ctx->need_prefix = TRUE;
+
+ h5tools_dump_data(stream, &outputformat, ctx, region_id, FALSE);
+ }
+
+done:
+ if (H5Tclose(type_id) < 0)
+ H5TOOLS_ERROR(dimension_break, "H5Tclose failed");
+
+ if (H5Tclose(atype) < 0)
+ H5TOOLS_ERROR(dimension_break, "H5Tclose failed");
+
+ if (H5Sclose(region_space) < 0)
+ H5TOOLS_ERROR(dimension_break, "H5Sclose failed");
-CATCH
+ ctx->indent_level--;
+ ctx->need_prefix = TRUE;
+
+ /* Render the region } element begin */
+ h5tools_str_reset(buffer);
+ h5tools_str_append(buffer, "}");
+ dimension_break =
+ h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
+ /* Render the region } element end */
+
+ H5_LEAVE(dimension_break)
+
+ CATCH
+
+ H5TOOLS_ENDDEBUG(" ");
return ret_value;
}
@@ -403,7 +477,7 @@ CATCH
* This is a special case subfunction to print the data in a region reference of type blocks.
*
* Return:
- * The function returns FAIL if there was an error, otherwise SUCEED
+ * The function returns FAIL if there was an error, otherwise SUCCEED
*
* Parameters Description:
* h5tools_str_t *buffer is the string into which to render
@@ -413,30 +487,32 @@ CATCH
*-------------------------------------------------------------------------
*/
static int
-h5tools_print_region_data_blocks(hid_t region_id,
- FILE *stream, const h5tool_format_t *info, h5tools_context_t *cur_ctx,
- h5tools_str_t *buffer/*string into which to render */, size_t ncols,
- int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata)
+h5tools_print_region_data_blocks(hid_t region_id, FILE *stream, const h5tool_format_t *info,
+ h5tools_context_t *cur_ctx,
+ h5tools_str_t *buffer, /* string into which to render */
+ size_t ncols, unsigned ndims, hid_t type_id, hsize_t nblocks,
+ hsize_t *ptdata)
{
- hbool_t dimension_break = TRUE;
- hsize_t *dims1 = NULL;
- hsize_t *start = NULL;
- hsize_t *count = NULL;
- hsize_t blkndx;
- hsize_t total_size[H5S_MAX_RANK];
- hsize_t elmtno; /* elemnt index */
- hsize_t curr_pos = 0;
- unsigned int region_flags; /* buffer extent flags */
- hsize_t numelem;
- hsize_t numindex;
- size_t jndx;
- int indx;
- int type_size;
- int ret_value = SUCCEED;
- hid_t mem_space = -1;
- hid_t sid1 = -1;
+ hbool_t dimension_break = TRUE;
+ hsize_t *dims1 = NULL;
+ hsize_t *start = NULL;
+ hsize_t *count = NULL;
+ hsize_t blkndx;
+ hsize_t total_size[H5S_MAX_RANK];
+ hsize_t elmtno; /* element index */
+ hsize_t curr_pos = 0;
+ unsigned int region_flags; /* buffer extent flags */
+ hsize_t numelem;
+ hsize_t numindex;
+ unsigned indx;
+ unsigned jndx;
+ hbool_t past_catch = FALSE;
+ size_t type_size;
+ hid_t mem_space = H5I_INVALID_HID;
+ hid_t sid1 = H5I_INVALID_HID;
h5tools_context_t ctx;
- void *region_buf = NULL;
+ void *region_buf = NULL;
+ int ret_value = 0;
HDassert(info);
HDassert(cur_ctx);
@@ -444,114 +520,128 @@ h5tools_print_region_data_blocks(hid_t region_id,
HDassert(ptdata);
HDmemset(&ctx, 0, sizeof(ctx));
+
+ H5TOOLS_START_DEBUG(" ");
+
+ if ((type_size = H5Tget_size(type_id)) == 0)
+ H5TOOLS_THROW(FAIL, "H5Tget_size failed");
+
/* Get the dataspace of the dataset */
- if((sid1 = H5Dget_space(region_id)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
+ if ((sid1 = H5Dget_space(region_id)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Dget_space failed");
/* Allocate space for the dimension array */
- if((dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for dims");
+ if ((dims1 = (hsize_t *)HDmalloc((size_t)(sizeof(hsize_t) * ndims))) == NULL)
+ H5TOOLS_GOTO_ERROR(FAIL, "Could not allocate buffer for dims");
/* find the dimensions of each data space from the block coordinates */
numelem = 1;
for (jndx = 0; jndx < ndims; jndx++) {
dims1[jndx] = ptdata[jndx + ndims] - ptdata[jndx] + 1;
- numelem = dims1[jndx] * numelem;
+ numelem = dims1[jndx] * numelem;
}
/* Create dataspace for reading buffer */
- if((mem_space = H5Screate_simple(ndims, dims1, NULL)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Screate_simple failed");
-
- if((type_size = H5Tget_size(type_id)) == 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
+ if ((mem_space = H5Screate_simple((int)ndims, dims1, NULL)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Screate_simple failed");
- if((region_buf = HDmalloc(type_size * numelem)) == NULL)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate region buffer");
+ if ((region_buf = HDmalloc(type_size * (size_t)numelem)) == NULL)
+ H5TOOLS_GOTO_ERROR(FAIL, "Could not allocate region buffer");
/* Select (x , x , ..., x ) x (y , y , ..., y ) hyperslab for reading memory dataset */
/* 1 2 n 1 2 n */
- if((start = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for start");
+ if ((start = (hsize_t *)HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
+ H5TOOLS_GOTO_ERROR(FAIL, "Could not allocate buffer for start");
- if((count = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for count");
+ if ((count = (hsize_t *)HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
+ H5TOOLS_GOTO_ERROR(FAIL, "Could not allocate buffer for count");
- curr_pos = 0;
- ctx.indent_level = cur_ctx->indent_level;
- ctx.cur_column = cur_ctx->cur_column;
+ curr_pos = 0;
+ ctx.indent_level = cur_ctx->indent_level;
+ ctx.cur_column = cur_ctx->cur_column;
ctx.prev_multiline = cur_ctx->prev_multiline;
- ctx.ndims = ndims;
+ ctx.ndims = ndims;
for (blkndx = 0; blkndx < nblocks; blkndx++) {
ctx.need_prefix = TRUE;
- ctx.cur_elmt = 0;
+ ctx.cur_elmt = 0;
for (indx = 0; indx < ndims; indx++) {
start[indx] = ptdata[indx + blkndx * ndims * 2];
count[indx] = dims1[indx];
}
- if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
+ if (H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL) >= 0) {
+ if (H5Dread(region_id, type_id, mem_space, sid1, H5P_DEFAULT, region_buf) >= 0) {
+ ctx.indent_level++;
+ if (H5Sget_simple_extent_dims(mem_space, total_size, NULL) >= 0) {
+ /* assume entire data space to be printed */
+ init_acc_pos(ctx.ndims, total_size, ctx.acc, ctx.pos, ctx.p_min_idx);
- if(H5Dread(region_id, type_id, mem_space, sid1, H5P_DEFAULT, region_buf) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dread failed");
+ /* reset data space to be printed */
+ for (indx = 0; indx < (unsigned)ctx.ndims; indx++)
+ ctx.p_min_idx[indx] = start[indx];
- ctx.indent_level++;
- if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
-
- /* assume entire data space to be printed */
- for (indx = 0; indx < (size_t) ctx.ndims; indx++)
- ctx.p_min_idx[indx] = start[indx];
- init_acc_pos(&ctx, total_size);
+ /* print the data */
+ region_flags = START_OF_DATA;
+ if (blkndx == nblocks - 1)
+ region_flags |= END_OF_DATA;
- /* print the data */
- region_flags = START_OF_DATA;
- if (blkndx == nblocks - 1)
- region_flags |= END_OF_DATA;
+ for (indx = 0; indx < (unsigned)ctx.ndims; indx++)
+ ctx.p_max_idx[indx] = dims1[indx];
- for (indx = 0; indx < (size_t)ctx.ndims; indx++)
- ctx.p_max_idx[indx] = dims1[indx];
+ curr_pos = 0;
+ ctx.sm_pos = blkndx * 2 * ndims;
+ ctx.size_last_dim = dims1[ndims - 1];
- curr_pos = 0;
- ctx.sm_pos = blkndx*2*ndims;
- ctx.size_last_dim = dims1[ndims-1];
+ h5tools_region_simple_prefix(stream, info, &ctx, curr_pos, ptdata, 0);
- h5tools_region_simple_prefix(stream, info, &ctx, curr_pos, ptdata, 0);
-
- elmtno = 0;
- for (numindex = 0; numindex < numelem; numindex++, elmtno++, ctx.cur_elmt++) {
- /* Render the region data element begin */
- h5tools_str_reset(buffer);
+ H5TOOLS_DEBUG("data render start:%ld", numelem);
+ elmtno = 0;
+ for (numindex = 0; numindex < numelem; numindex++, elmtno++, ctx.cur_elmt++) {
+ /* Render the region data element begin */
+ h5tools_str_reset(buffer);
- h5tools_str_append(buffer, "%s", numindex ? OPTIONAL_LINE_BREAK "" : "");
- h5tools_str_sprint(buffer, info, region_id, type_id,
- ((char*)region_buf + numindex * type_size), &ctx);
+ h5tools_str_append(buffer, "%s", numindex ? OPTIONAL_LINE_BREAK "" : "");
+ h5tools_str_sprint(buffer, info, region_id, type_id,
+ ((char *)region_buf + numindex * type_size), &ctx);
- if (numindex + 1 < numelem || (region_flags & END_OF_DATA) == 0)
- h5tools_str_append(buffer, "%s", OPT(info->elmt_suf1, ","));
+ if (numindex + 1 < numelem || (region_flags & END_OF_DATA) == 0)
+ h5tools_str_append(buffer, "%s", OPT(info->elmt_suf1, ","));
- dimension_break = h5tools_render_region_element(stream, info, &ctx, buffer, &curr_pos,
- ncols, ptdata, numindex, elmtno);
- /* Render the region data element end */
+ dimension_break = h5tools_render_region_element(stream, info, &ctx, buffer, &curr_pos,
+ ncols, ptdata, numindex, elmtno);
+ /* Render the region data element end */
- if(FALSE == dimension_break)
- elmtno = 0;
- } /* end for (jndx = 0; jndx < numelem; jndx++, region_elmtno++, ctx.cur_elmt++) */
+ if (FALSE == dimension_break)
+ elmtno = 0;
+ } /* end for (numindex = 0; numindex < numelem; numindex++, elmtno++, ctx.cur_elmt++) */
+ }
+ else {
+ H5TOOLS_ERROR(FAIL, "H5Sget_simple_extent_dims failed");
+ }
+ ctx.indent_level--;
+ }
+ else {
+ H5TOOLS_ERROR(FAIL, "H5Dread failed");
+ }
+ }
+ else {
+ H5TOOLS_ERROR(FAIL, "H5Sselect_hyperslab failed");
+ }
- ctx.indent_level--;
} /* end for (blkndx = 0; blkndx < nblocks; blkndx++) */
- done:
+done:
HDfree(start);
HDfree(count);
HDfree(region_buf);
HDfree(dims1);
- if(H5Sclose(mem_space) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
- if(H5Sclose(sid1) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
+ if (H5Sclose(mem_space) < 0)
+ H5TOOLS_ERROR(FAIL, "H5Sclose failed");
+ if (H5Sclose(sid1) < 0)
+ H5TOOLS_ERROR(FAIL, "H5Sclose failed");
+ CATCH
+ H5TOOLS_ENDDEBUG(" ");
return ret_value;
}
@@ -580,40 +670,55 @@ h5tools_print_region_data_blocks(hid_t region_id,
*-------------------------------------------------------------------------
*/
hbool_t
-h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id,
- FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx/*in,out*/,
- h5tools_str_t *buffer/*string into which to render */,
- hsize_t *curr_pos/*total data element position*/,
- size_t ncols, hsize_t region_elmt_counter/*element counter*/,
- hsize_t elmt_counter)
+h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, FILE *stream,
+ const h5tool_format_t *info, h5tools_context_t *ctx, /* in,out */
+ h5tools_str_t *buffer, /* string into which to render */
+ hsize_t *curr_pos, /* total data element position */
+ size_t ncols, hsize_t region_elmt_counter, /* element counter */
+ hsize_t elmt_counter)
{
- HERR_INIT(hbool_t, TRUE)
- hbool_t dimension_break = TRUE;
- hssize_t nblocks;
- hsize_t alloc_size;
- hsize_t *ptdata = NULL;
- int ndims;
- hid_t dtype = -1;
- hid_t type_id = -1;
- int i;
+ hbool_t dimension_break = TRUE;
+ hssize_t snblocks;
+ hsize_t nblocks;
+ hsize_t alloc_size;
+ hsize_t *ptdata = NULL;
+ int sndims;
+ unsigned ndims;
+ hsize_t indx;
+ hid_t dtype = H5I_INVALID_HID;
+ hid_t type_id = H5I_INVALID_HID;
+ h5tool_format_t outputformat; /* Use to disable prefix for DATA attribute display */
+ hbool_t past_catch = FALSE;
+ hbool_t ret_value = TRUE;
HDassert(info);
HDassert(ctx);
HDassert(buffer);
- if((nblocks = H5Sget_select_hyper_nblocks(region_space)) <= 0)
- H5E_THROW(dimension_break, H5E_tools_min_id_g, "H5Sget_select_hyper_nblocks failed");
+ H5TOOLS_START_DEBUG(" ");
+ outputformat = *info;
+ outputformat.idx_fmt = "";
+ outputformat.idx_n_fmt = "";
+ outputformat.idx_sep = "";
+ outputformat.line_pre = "";
+
+ if ((snblocks = H5Sget_select_hyper_nblocks(region_space)) <= 0)
+ H5TOOLS_THROW(dimension_break, "H5Sget_select_hyper_nblocks failed");
+ nblocks = (hsize_t)snblocks;
/* Print block information */
- if((ndims = H5Sget_simple_extent_ndims(region_space)) < 0)
- H5E_THROW(dimension_break, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
+ if ((sndims = H5Sget_simple_extent_ndims(region_space)) < 0)
+ H5TOOLS_THROW(dimension_break, "H5Sget_simple_extent_ndims failed");
+ ndims = (unsigned)sndims;
+
+ H5TOOLS_DEBUG("enter ndims=%d", ndims);
/* Render the region { element begin */
h5tools_str_reset(buffer);
- h5tools_str_append(buffer, "{");
- dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
+ h5tools_str_append(buffer, " {");
+ dimension_break = h5tools_render_element(stream, &outputformat, ctx, buffer, curr_pos, ncols,
+ region_elmt_counter, elmt_counter);
/* Render the region { element end */
ctx->indent_level++;
@@ -624,47 +729,48 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id,
h5tools_str_append(buffer, "REGION_TYPE BLOCK ");
alloc_size = nblocks * ndims * 2 * sizeof(ptdata[0]);
- HDassert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/
- if((ptdata = (hsize_t*) HDmalloc((size_t) alloc_size)) == NULL)
- HGOTO_ERROR(dimension_break, H5E_tools_min_id_g, "Could not allocate buffer for ptdata");
+ HDassert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/
+ if ((ptdata = (hsize_t *)HDmalloc((size_t)alloc_size)) == NULL)
+ H5TOOLS_GOTO_ERROR(dimension_break, "Could not allocate buffer for ptdata");
- H5_CHECK_OVERFLOW(nblocks, hssize_t, hsize_t);
- if(H5Sget_select_hyper_blocklist(region_space, (hsize_t) 0, (hsize_t) nblocks, ptdata) < 0)
- HGOTO_ERROR(dimension_break, H5E_tools_min_id_g, "H5Rget_select_hyper_blocklist failed");
+ if (H5Sget_select_hyper_blocklist(region_space, (hsize_t)0, nblocks, ptdata) < 0)
+ H5TOOLS_GOTO_ERROR(dimension_break, "H5Rget_select_hyper_blocklist failed");
- for (i = 0; i < nblocks; i++) {
- int j;
+ for (indx = 0; indx < nblocks; indx++) {
+ unsigned loop_indx;
- h5tools_str_append(buffer, info->dset_blockformat_pre,
- i ? "," OPTIONAL_LINE_BREAK " " : "", (unsigned long) i);
+ H5_GCC_CLANG_DIAG_OFF("format-nonliteral")
+ h5tools_str_append(buffer, outputformat.dset_blockformat_pre, indx ? "," OPTIONAL_LINE_BREAK " " : "",
+ (unsigned long)indx);
+ H5_GCC_CLANG_DIAG_ON("format-nonliteral")
/* Start coordinates and opposite corner */
- for (j = 0; j < ndims; j++)
- h5tools_str_append(buffer, "%s" HSIZE_T_FORMAT, j ? "," : "(",
- ptdata[i * 2 * ndims + j]);
+ for (loop_indx = 0; loop_indx < ndims; loop_indx++)
+ h5tools_str_append(buffer, "%s%" PRIuHSIZE, loop_indx ? "," : "(",
+ ptdata[indx * 2 * ndims + loop_indx]);
- for (j = 0; j < ndims; j++)
- h5tools_str_append(buffer, "%s" HSIZE_T_FORMAT, j ? "," : ")-(",
- ptdata[i * 2 * ndims + j + ndims]);
+ for (loop_indx = 0; loop_indx < ndims; loop_indx++)
+ h5tools_str_append(buffer, "%s%" PRIuHSIZE, loop_indx ? "," : ")-(",
+ ptdata[indx * 2 * ndims + loop_indx + ndims]);
h5tools_str_append(buffer, ")");
- } /* end for (i = 0; i < nblocks; i++) */
+ } /* end for (indx = 0; indx < nblocks; indx++) */
- dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
+ dimension_break =
+ h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
/* Render the region datatype info and indices element end */
ctx->need_prefix = TRUE;
- if((dtype = H5Dget_type(region_id)) < 0)
- HGOTO_ERROR(dimension_break, H5E_tools_min_id_g, "H5Dget_type failed");
- if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0)
- HGOTO_ERROR(dimension_break, H5E_tools_min_id_g, "H5Tget_native_type failed");
+ if ((dtype = H5Dget_type(region_id)) < 0)
+ H5TOOLS_GOTO_ERROR(dimension_break, "H5Dget_type failed");
+ if ((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR(dimension_break, "H5Tget_native_type failed");
/* Render the datatype element begin */
h5tools_str_reset(buffer);
- h5tools_str_append(buffer, "%s %s ",
- h5tools_dump_header_format->datatypebegin,
- h5tools_dump_header_format->datatypeblockbegin);
+ h5tools_str_append(buffer, "%s %s ", h5tools_dump_header_format->datatypebegin,
+ h5tools_dump_header_format->datatypeblockbegin);
ctx->indent_level++;
h5tools_print_datatype(stream, buffer, info, ctx, dtype, TRUE);
@@ -678,7 +784,8 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id,
if (HDstrlen(h5tools_dump_header_format->datatypeend))
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->datatypeend);
- dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
+ dimension_break =
+ h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
/* Render the datatype element end */
ctx->need_prefix = TRUE;
@@ -687,7 +794,7 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id,
h5tools_str_reset(buffer);
h5tools_str_append(buffer, "%s ", h5tools_dump_header_format->dataspacebegin);
- h5tools_print_dataspace(stream, buffer, info, ctx, region_space);
+ h5tools_print_dataspace(buffer, region_space);
if (HDstrlen(h5tools_dump_header_format->dataspaceblockend)) {
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->dataspaceblockend);
@@ -697,43 +804,53 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id,
if (HDstrlen(h5tools_dump_header_format->dataspaceend))
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->dataspaceblockend);
- dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
+ dimension_break =
+ h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
/* Render the dataspace element end */
- ctx->need_prefix = TRUE;
+ if (region_output) {
+ ctx->need_prefix = TRUE;
- /* Render the databegin element begin */
- h5tools_str_reset(buffer);
- h5tools_str_append(buffer, "%s %s ",
- h5tools_dump_header_format->databegin,
- h5tools_dump_header_format->datablockbegin);
- dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
- /* Render the databegin element end */
+ /* Render the databegin element begin */
+ h5tools_str_reset(buffer);
+ h5tools_str_append(buffer, "%s %s", h5tools_dump_header_format->databegin,
+ h5tools_dump_header_format->datablockbegin);
+ dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols,
+ region_elmt_counter, elmt_counter);
+ /* Render the databegin element end */
- ctx->need_prefix = TRUE;
+ ctx->need_prefix = TRUE;
- h5tools_print_region_data_blocks(region_id, rawdatastream, info, ctx,
- buffer, ncols, ndims, type_id, nblocks, ptdata);
+ h5tools_print_region_data_blocks(region_id, rawdatastream, info, ctx, buffer, ncols, ndims, type_id,
+ nblocks, ptdata);
+ }
- done:
+done:
HDfree(ptdata);
- if(H5Tclose(type_id) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+ if (type_id > 0 && H5Tclose(type_id) < 0)
+ H5TOOLS_ERROR(dimension_break, "H5Tclose failed");
- if(H5Tclose(dtype) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+ if (dtype > 0 && H5Tclose(dtype) < 0)
+ H5TOOLS_ERROR(dimension_break, "H5Tclose failed");
- ctx->need_prefix = TRUE;
+ if (region_output) {
+ ctx->need_prefix = TRUE;
- /* Render the dataend element begin */
- h5tools_str_reset(buffer);
- h5tools_str_append(buffer, "%s %s ",
- h5tools_dump_header_format->dataend,
- h5tools_dump_header_format->datablockend);
- dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos,
- ncols, region_elmt_counter, elmt_counter);
- /* Render the dataend element end */
+ /* Render the dataend element begin */
+ h5tools_str_reset(buffer);
+ if (HDstrlen(h5tools_dump_header_format->datablockend)) {
+ h5tools_str_append(buffer, "%s", h5tools_dump_header_format->datablockend);
+ if (HDstrlen(h5tools_dump_header_format->dataend))
+ h5tools_str_append(buffer, " ");
+ }
+
+ if (HDstrlen(h5tools_dump_header_format->dataend))
+ h5tools_str_append(buffer, "%s", h5tools_dump_header_format->dataend);
+ dimension_break = h5tools_render_element(stream, &outputformat, ctx, buffer, curr_pos, ncols,
+ region_elmt_counter, elmt_counter);
+ /* Render the dataend element end */
+ }
ctx->indent_level--;
ctx->need_prefix = TRUE;
@@ -741,13 +858,16 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id,
/* Render the region } element begin */
h5tools_str_reset(buffer);
h5tools_str_append(buffer, "}");
- dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos,
- ncols, region_elmt_counter, elmt_counter);
+ dimension_break =
+ h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
/* Render the region } element end */
H5_LEAVE(dimension_break)
- CATCH
+ CATCH
+
+ H5TOOLS_ENDDEBUG(" ");
+
return ret_value;
}
@@ -769,114 +889,120 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id,
* hssize_t npoints is the number of points in the region
*-------------------------------------------------------------------------
*/
-int
-h5tools_print_region_data_points(hid_t region_space, hid_t region_id,
- FILE *stream, const h5tool_format_t *info, h5tools_context_t *cur_ctx,
- h5tools_str_t *buffer, size_t ncols,
- int ndims, hid_t type_id, hssize_t npoints, hsize_t *ptdata)
+static int
+h5tools_print_region_data_points(hid_t region_space, hid_t region_id, FILE *stream,
+ const h5tool_format_t *info, h5tools_context_t *cur_ctx,
+ h5tools_str_t *buffer, size_t ncols, unsigned ndims, hid_t type_id,
+ hsize_t npoints, hsize_t *ptdata)
{
- hbool_t dimension_break = TRUE;
- hsize_t *dims1 = NULL;
- hsize_t elmtno; /* elemnt index */
- hsize_t curr_pos = 0;
- hsize_t total_size[H5S_MAX_RANK];
- size_t jndx;
- int indx;
- int type_size;
- int ret_value = SUCCEED;
- unsigned int region_flags; /* buffer extent flags */
- hid_t mem_space = -1;
- void *region_buf = NULL;
+ hbool_t dimension_break = TRUE;
+ hsize_t *dims1 = NULL;
+ hsize_t elmtno; /* element index */
+ hsize_t curr_pos = 0;
+ hsize_t total_size[H5S_MAX_RANK];
+ hsize_t jndx;
+ unsigned indx;
+ size_t type_size;
+ unsigned int region_flags; /* buffer extent flags */
+ hid_t mem_space = H5I_INVALID_HID;
+ void *region_buf = NULL;
h5tools_context_t ctx;
+ hbool_t past_catch = FALSE;
+ int ret_value = 0;
HDassert(info);
HDassert(cur_ctx);
HDassert(buffer);
HDassert(ptdata);
+ HDassert(ndims > 0);
+
+ H5TOOLS_START_DEBUG(" ");
HDmemset(&ctx, 0, sizeof(ctx));
/* Allocate space for the dimension array */
- if((dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for dims");
+ if ((dims1 = (hsize_t *)HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
+ H5TOOLS_THROW((-1), "Could not allocate buffer for dims");
dims1[0] = npoints;
-
+
/* Create dataspace for reading buffer */
- if((mem_space = H5Screate_simple(1, dims1, NULL)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Screate_simple failed");
+ if ((mem_space = H5Screate_simple(1, dims1, NULL)) < 0)
+ H5TOOLS_THROW((-1), "H5Screate_simple failed");
- if((type_size = H5Tget_size(type_id)) == 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
+ if ((type_size = H5Tget_size(type_id)) == 0)
+ H5TOOLS_THROW((-1), "H5Tget_size failed");
- if((region_buf = HDmalloc(type_size * npoints)) == NULL)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for region");
+ if ((region_buf = HDmalloc(type_size * (size_t)npoints)) == NULL)
+ H5TOOLS_THROW((-1), "Could not allocate buffer for region");
- curr_pos = 0;
- ctx.indent_level = cur_ctx->indent_level;
- ctx.cur_column = cur_ctx->cur_column;
+ curr_pos = 0;
+ ctx.indent_level = cur_ctx->indent_level;
+ ctx.cur_column = cur_ctx->cur_column;
ctx.prev_multiline = cur_ctx->prev_multiline;
- ctx.ndims = ndims;
+ ctx.ndims = ndims;
- if(H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed");
+ if (H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dread failed");
+ H5TOOLS_DEBUG("data render start:%ld", npoints);
elmtno = 0;
for (jndx = 0; jndx < npoints; jndx++, elmtno++) {
ctx.need_prefix = TRUE;
- ctx.cur_elmt = 0; /* points are always 0 */
-
+ ctx.cur_elmt = 0; /* points are always 0 */
ctx.indent_level++;
- if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
- /* assume entire data space to be printed */
- for (indx = 0; indx < (size_t) ctx.ndims; indx++)
- ctx.p_min_idx[indx] = 0;
- init_acc_pos(&ctx, total_size);
+ if (H5Sget_simple_extent_dims(mem_space, total_size, NULL) >= 0) {
+ /* assume entire data space to be printed */
+ init_acc_pos(ctx.ndims, total_size, ctx.acc, ctx.pos, ctx.p_min_idx);
- /* print the data */
- region_flags = START_OF_DATA;
- if (jndx == npoints - 1)
- region_flags |= END_OF_DATA;
+ /* print the data */
+ region_flags = START_OF_DATA;
+ if (jndx == npoints - 1)
+ region_flags |= END_OF_DATA;
- for (indx = 0; indx < (size_t)ctx.ndims; indx++)
- ctx.p_max_idx[indx] = cur_ctx->p_max_idx[indx];
+ for (indx = 0; indx < ctx.ndims; indx++)
+ ctx.p_max_idx[indx] = cur_ctx->p_max_idx[indx];
- ctx.sm_pos = jndx * ndims;
- if (ctx.ndims > 0) {
- ctx.size_last_dim = (int) (ctx.p_max_idx[ctx.ndims - 1]);
- }
- else
- ctx.size_last_dim = 0;
-
- curr_pos = 0; /* points requires constant 0 */
- h5tools_region_simple_prefix(stream, info, &ctx, curr_pos, ptdata, 0);
+ ctx.sm_pos = jndx * ndims;
+ if (ctx.ndims > 0)
+ ctx.size_last_dim = ctx.p_max_idx[ctx.ndims - 1];
+ else
+ ctx.size_last_dim = 0;
- /* Render the point element begin */
- h5tools_str_reset(buffer);
+ curr_pos = 0; /* points requires constant 0 */
+ h5tools_region_simple_prefix(stream, info, &ctx, curr_pos, ptdata, 0);
- h5tools_str_append(buffer, "%s", jndx ? OPTIONAL_LINE_BREAK "" : "");
- h5tools_str_sprint(buffer, info, region_id, type_id,
- ((char*)region_buf + jndx * type_size), &ctx);
+ /* Render the point element begin */
+ h5tools_str_reset(buffer);
- if (jndx + 1 < npoints || (region_flags & END_OF_DATA) == 0)
- h5tools_str_append(buffer, "%s", OPT(info->elmt_suf1, ","));
+ h5tools_str_append(buffer, "%s", jndx ? OPTIONAL_LINE_BREAK "" : "");
+ h5tools_str_sprint(buffer, info, region_id, type_id, ((char *)region_buf + jndx * type_size),
+ &ctx);
- dimension_break = h5tools_render_region_element(stream, info, &ctx, buffer, &curr_pos,
- ncols, ptdata, (hsize_t)0, elmtno);
- /* Render the point element end */
- if(FALSE == dimension_break)
- elmtno = 0;
+ if (jndx + 1 < npoints || (region_flags & END_OF_DATA) == 0)
+ h5tools_str_append(buffer, "%s", OPT(info->elmt_suf1, ","));
+ dimension_break = h5tools_render_region_element(stream, info, &ctx, buffer, &curr_pos, ncols,
+ ptdata, (hsize_t)0, elmtno);
+ /* Render the point element end */
+ if (FALSE == dimension_break)
+ elmtno = 0;
+ }
+ else {
+ H5TOOLS_ERROR((-1), "H5Sget_simple_extent_dims failed");
+ }
ctx.indent_level--;
} /* end for (jndx = 0; jndx < npoints; jndx++, elmtno++) */
- done:
+done:
HDfree(region_buf);
+ CATCH
HDfree(dims1);
- if(H5Sclose(mem_space) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
+ if (H5Sclose(mem_space) < 0)
+ H5TOOLS_ERROR((-1), "H5Sclose failed");
+
+ H5TOOLS_ENDDEBUG(" ");
return ret_value;
}
@@ -905,83 +1031,100 @@ h5tools_print_region_data_points(hid_t region_space, hid_t region_id,
*-------------------------------------------------------------------------
*/
hbool_t
-h5tools_dump_region_data_points(hid_t region_space, hid_t region_id,
- FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
- h5tools_str_t *buffer, hsize_t *curr_pos, size_t ncols, hsize_t region_elmt_counter,
- hsize_t elmt_counter) {
- HERR_INIT(hbool_t, TRUE)
- hbool_t dimension_break = TRUE;
- hssize_t npoints;
- hsize_t alloc_size;
- hsize_t *ptdata;
- int ndims;
- hssize_t indx;
- hid_t dtype;
- hid_t type_id;
+h5tools_dump_region_data_points(hid_t region_space, hid_t region_id, FILE *stream,
+ const h5tool_format_t *info, h5tools_context_t *ctx, h5tools_str_t *buffer,
+ hsize_t *curr_pos, size_t ncols, hsize_t region_elmt_counter,
+ hsize_t elmt_counter)
+{
+ hbool_t dimension_break = TRUE;
+ hssize_t snpoints;
+ hsize_t npoints;
+ hsize_t alloc_size;
+ hsize_t *ptdata;
+ int sndims;
+ unsigned ndims;
+ hsize_t indx;
+ hid_t dtype = H5I_INVALID_HID;
+ hid_t type_id = H5I_INVALID_HID;
+ h5tool_format_t outputformat; /* Use to disable prefix for DATA attribute display */
+ hbool_t past_catch = FALSE;
+ hbool_t ret_value = TRUE;
HDassert(info);
HDassert(ctx);
HDassert(buffer);
- if((npoints = H5Sget_select_elem_npoints(region_space)) <= 0)
- H5E_THROW(dimension_break, H5E_tools_min_id_g, "H5Sget_select_elem_npoints failed");
+ H5TOOLS_START_DEBUG(" ");
+ outputformat = *info;
+ outputformat.idx_fmt = "";
+ outputformat.idx_n_fmt = "";
+ outputformat.idx_sep = "";
+ outputformat.line_pre = "";
+
+ if ((snpoints = H5Sget_select_elem_npoints(region_space)) <= 0)
+ H5TOOLS_THROW(dimension_break, "H5Sget_select_elem_npoints failed");
+ npoints = (hsize_t)snpoints;
/* Allocate space for the dimension array */
- if((ndims = H5Sget_simple_extent_ndims(region_space)) < 0)
- H5E_THROW(dimension_break, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
+ if ((sndims = H5Sget_simple_extent_ndims(region_space)) < 0)
+ H5TOOLS_THROW(dimension_break, "H5Sget_simple_extent_ndims failed");
+ ndims = (unsigned)sndims;
+
+ H5TOOLS_DEBUG("enter ndims=%d", ndims);
/* Render the region { element begin */
h5tools_str_reset(buffer);
h5tools_str_append(buffer, "{");
- dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
+ dimension_break = h5tools_render_element(stream, &outputformat, ctx, buffer, curr_pos, ncols,
+ region_elmt_counter, elmt_counter);
/* Render the region { element end */
- /* Render the region datatype info and indices element begin */
- h5tools_str_reset(buffer);
-
ctx->indent_level++;
ctx->need_prefix = TRUE;
+
+ /* Render the region datatype info and indices element begin */
+ h5tools_str_reset(buffer);
h5tools_str_append(buffer, "REGION_TYPE POINT ");
alloc_size = npoints * ndims * sizeof(ptdata[0]);
- HDassert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/
- if(NULL == (ptdata = (hsize_t *)HDmalloc((size_t) alloc_size)))
- HGOTO_ERROR(dimension_break, H5E_tools_min_id_g, "Could not allocate buffer for ptdata");
+ HDassert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/
+ if (NULL == (ptdata = (hsize_t *)HDmalloc((size_t)alloc_size)))
+ H5TOOLS_GOTO_ERROR(dimension_break, "Could not allocate buffer for ptdata");
- H5_CHECK_OVERFLOW(npoints, hssize_t, hsize_t);
- if(H5Sget_select_elem_pointlist(region_space, (hsize_t) 0, (hsize_t) npoints, ptdata) < 0)
- HGOTO_ERROR(dimension_break, H5E_tools_min_id_g, "H5Sget_select_elem_pointlist failed");
+ if (H5Sget_select_elem_pointlist(region_space, (hsize_t)0, npoints, ptdata) < 0)
+ H5TOOLS_GOTO_ERROR(dimension_break, "H5Sget_select_elem_pointlist failed");
for (indx = 0; indx < npoints; indx++) {
- int loop_indx;
+ unsigned loop_indx;
- h5tools_str_append(buffer, info->dset_ptformat_pre,
- indx ? "," OPTIONAL_LINE_BREAK " " : "", (unsigned long) indx);
+ H5_GCC_CLANG_DIAG_OFF("format-nonliteral")
+ h5tools_str_append(buffer, outputformat.dset_ptformat_pre, indx ? "," OPTIONAL_LINE_BREAK " " : "",
+ (unsigned long)indx);
+ H5_GCC_CLANG_DIAG_ON("format-nonliteral")
for (loop_indx = 0; loop_indx < ndims; loop_indx++)
- h5tools_str_append(buffer, "%s" HSIZE_T_FORMAT, loop_indx ? "," : "(",
- ptdata[indx * ndims + loop_indx]);
+ h5tools_str_append(buffer, "%s%" PRIuHSIZE, loop_indx ? "," : "(",
+ ptdata[indx * ndims + loop_indx]);
h5tools_str_append(buffer, ")");
} /* end for (indx = 0; indx < npoints; indx++) */
- dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
+ dimension_break =
+ h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
/* Render the region datatype info and indices element end */
ctx->need_prefix = TRUE;
- if((dtype = H5Dget_type(region_id)) < 0)
- HGOTO_ERROR(dimension_break, H5E_tools_min_id_g, "H5Dget_type failed");
-
- if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0)
- HGOTO_ERROR(dimension_break, H5E_tools_min_id_g, "H5Tget_native_type failed");
+ if ((dtype = H5Dget_type(region_id)) < 0)
+ H5TOOLS_GOTO_ERROR(dimension_break, "H5Dget_type failed");
+ if ((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR(dimension_break, "H5Tget_native_type failed");
/* Render the datatype element begin */
h5tools_str_reset(buffer);
- h5tools_str_append(buffer, "%s %s ",
- h5tools_dump_header_format->datatypebegin,
- h5tools_dump_header_format->datatypeblockbegin);
+ h5tools_str_append(buffer, "%s %s ", h5tools_dump_header_format->datatypebegin,
+ h5tools_dump_header_format->datatypeblockbegin);
ctx->indent_level++;
h5tools_print_datatype(stream, buffer, info, ctx, dtype, TRUE);
@@ -995,18 +1138,17 @@ h5tools_dump_region_data_points(hid_t region_space, hid_t region_id,
if (HDstrlen(h5tools_dump_header_format->datatypeend))
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->datatypeend);
- dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
+ dimension_break =
+ h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
/* Render the datatype element end */
ctx->need_prefix = TRUE;
/* Render the dataspace element begin */
h5tools_str_reset(buffer);
-
- ctx->need_prefix = TRUE;
h5tools_str_append(buffer, "%s ", h5tools_dump_header_format->dataspacebegin);
- h5tools_print_dataspace(stream, buffer, info, ctx, region_space);
+ h5tools_print_dataspace(buffer, region_space);
if (HDstrlen(h5tools_dump_header_format->dataspaceblockend)) {
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->dataspaceblockend);
@@ -1016,44 +1158,54 @@ h5tools_dump_region_data_points(hid_t region_space, hid_t region_id,
if (HDstrlen(h5tools_dump_header_format->dataspaceend))
h5tools_str_append(buffer, "%s", h5tools_dump_header_format->dataspaceblockend);
- dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
+ dimension_break =
+ h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
/* Render the dataspace element end */
- ctx->need_prefix = TRUE;
+ if (region_output) {
+ ctx->need_prefix = TRUE;
- /* Render the databegin element begin */
- h5tools_str_reset(buffer);
+ /* Render the databegin element begin */
+ h5tools_str_reset(buffer);
- h5tools_str_append(buffer, "%s %s ",
- h5tools_dump_header_format->databegin,
- h5tools_dump_header_format->datablockbegin);
+ h5tools_str_append(buffer, "%s %s", h5tools_dump_header_format->databegin,
+ h5tools_dump_header_format->datablockbegin);
- dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
+ dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols,
+ region_elmt_counter, elmt_counter);
- ctx->need_prefix = TRUE;
+ ctx->need_prefix = TRUE;
- h5tools_print_region_data_points(region_space, region_id,
- rawdatastream, info, ctx, buffer, ncols, ndims, type_id, npoints, ptdata);
+ h5tools_print_region_data_points(region_space, region_id, rawdatastream, info, ctx, buffer, ncols,
+ ndims, type_id, npoints, ptdata);
+ }
- done:
+done:
HDfree(ptdata);
- if(H5Tclose(type_id) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+ if (type_id > 0 && H5Tclose(type_id) < 0)
+ H5TOOLS_ERROR(dimension_break, "H5Tclose failed");
- if(H5Tclose(dtype) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+ if (dtype > 0 && H5Tclose(dtype) < 0)
+ H5TOOLS_ERROR(dimension_break, "H5Tclose failed");
- ctx->need_prefix = TRUE;
+ if (region_output) {
+ ctx->need_prefix = TRUE;
- /* Render the dataend element begin */
- h5tools_str_reset(buffer);
- h5tools_str_append(buffer, "%s %s ",
- h5tools_dump_header_format->dataend,
- h5tools_dump_header_format->datablockend);
- dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos,
- ncols, region_elmt_counter, elmt_counter);
- /* Render the dataend element end*/
+ /* Render the dataend element begin */
+ h5tools_str_reset(buffer);
+ if (HDstrlen(h5tools_dump_header_format->datablockend)) {
+ h5tools_str_append(buffer, "%s", h5tools_dump_header_format->datablockend);
+ if (HDstrlen(h5tools_dump_header_format->dataend))
+ h5tools_str_append(buffer, " ");
+ }
+
+ if (HDstrlen(h5tools_dump_header_format->dataend))
+ h5tools_str_append(buffer, "%s", h5tools_dump_header_format->dataend);
+ dimension_break = h5tools_render_element(stream, &outputformat, ctx, buffer, curr_pos, ncols,
+ region_elmt_counter, elmt_counter);
+ /* Render the dataend element end*/
+ }
ctx->indent_level--;
ctx->need_prefix = TRUE;
@@ -1061,12 +1213,15 @@ h5tools_dump_region_data_points(hid_t region_space, hid_t region_id,
/* Render the region } element begin */
h5tools_str_reset(buffer);
h5tools_str_append(buffer, "}");
- dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos,
- ncols, region_elmt_counter, elmt_counter);
+ dimension_break =
+ h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter);
/* Render the region } element end */
H5_LEAVE(dimension_break)
-CATCH
+ CATCH
+
+ H5TOOLS_ENDDEBUG(" ");
+
return ret_value;
}
@@ -1103,60 +1258,53 @@ CATCH
*-------------------------------------------------------------------------
*/
static herr_t
-h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
- hid_t dset, hid_t p_type, struct subset_t *sset,
- hid_t f_space, hsize_t hyperslab_count,
- hsize_t *temp_start,/* start inside offset count loop */
- hsize_t *temp_count,/* count inside offset count loop */
- hsize_t *temp_block,/* block size used in loop */
- hsize_t *temp_stride,/* stride size used in loop */
- hsize_t *total_size,/* total size of dataset */
- unsigned int row_dim/* index of row_counter dimension */)
+h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t dset,
+ hid_t p_type, hid_t f_space, hsize_t hyperslab_count,
+ hsize_t *temp_start, /* start inside offset count loop */
+ hsize_t *temp_count, /* count inside offset count loop */
+ hsize_t *temp_block, /* block size used in loop */
+ hsize_t *temp_stride, /* stride size used in loop */
+ const hsize_t *total_size, /* total size of dataset */
+ unsigned int row_dim) /* index of row_counter dimension */
{
- HERR_INIT(herr_t, SUCCEED)
- size_t i; /* counters */
- size_t j; /* counters */
- hsize_t zero[1] = {0}; /* vector of zeros */
- unsigned int flags; /* buffer extent flags */
- hsize_t elmtno; /* elemnt index */
- hsize_t low[H5S_MAX_RANK]; /* low bound of hyperslab */
- hsize_t high[H5S_MAX_RANK]; /* higher bound of hyperslab */
- size_t p_type_nbytes; /* size of memory type */
- hsize_t sm_size[H5S_MAX_RANK]; /* stripmine size */
- hsize_t sm_nbytes; /* bytes per stripmine */
- hssize_t ssm_nelmts; /* elements per stripmine*/
- hsize_t sm_nelmts; /* elements per stripmine*/
- unsigned char *sm_buf = NULL; /* buffer for raw data */
- hid_t sm_space = -1; /* stripmine data space */
- hsize_t size_row_block; /* size for blocks along rows */
- hsize_t row_counter = 0;
-
+ size_t i; /* counters */
+ size_t j; /* counters */
+ hsize_t zero[1] = {0}; /* vector of zeros */
+ unsigned int flags; /* buffer extent flags */
+ hsize_t low[H5S_MAX_RANK]; /* low bound of hyperslab */
+ hsize_t high[H5S_MAX_RANK]; /* higher bound of hyperslab */
+ size_t p_type_nbytes; /* size of memory type */
+ hsize_t sm_size[H5S_MAX_RANK]; /* stripmine size */
+ hsize_t sm_nbytes; /* bytes per stripmine */
+ hssize_t ssm_nelmts; /* elements per stripmine*/
+ hsize_t sm_nelmts; /* elements per stripmine*/
+ unsigned char *sm_buf = NULL; /* buffer for raw data */
+ hid_t sm_space = H5I_INVALID_HID; /* stripmine data space */
+ hsize_t size_row_block; /* size for blocks along rows */
+ hsize_t row_counter = 0;
+ hbool_t past_catch = FALSE;
/* VL data special information */
- unsigned int vl_data = 0; /* contains VL datatypes */
+ unsigned int vl_data = 0; /* contains VL datatypes */
+ herr_t ret_value = SUCCEED;
- if ((size_t) ctx->ndims > NELMTS(sm_size))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "ndims and sm_size comparision failed");
+ H5TOOLS_START_DEBUG(" ");
+ if ((size_t)ctx->ndims > NELMTS(sm_size))
+ H5TOOLS_THROW(FAIL, "ndims and sm_size comparison failed");
- if (ctx->ndims > 0)
- init_acc_pos(ctx, total_size);
-
- size_row_block = sset->block.data[row_dim];
+ size_row_block = ctx->sset->block.data[row_dim];
/* Check if we have VL data in the dataset's datatype */
- if (h5tools_detect_vlen_str(p_type) == TRUE)
- vl_data = TRUE;
- if (H5Tdetect_class(p_type, H5T_VLEN) == TRUE)
+ if (h5tools_detect_vlen(p_type) == TRUE)
vl_data = TRUE;
/* display loop */
for (; hyperslab_count > 0; temp_start[row_dim] += temp_stride[row_dim], hyperslab_count--) {
/* jump rows if size of block exceeded
cases where block > 1 only and stride > block */
- if (size_row_block > 1
- && row_counter == size_row_block
- && sset->stride.data[row_dim] > sset->block.data[row_dim]) {
+ if (size_row_block > 1 && row_counter == size_row_block &&
+ ctx->sset->stride.data[row_dim] > ctx->sset->block.data[row_dim]) {
- hsize_t increase_rows = sset->stride.data[row_dim] - sset->block.data[row_dim];
+ hsize_t increase_rows = ctx->sset->stride.data[row_dim] - ctx->sset->block.data[row_dim];
temp_start[row_dim] += increase_rows;
row_counter = 0;
}
@@ -1164,11 +1312,11 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c
row_counter++;
/* calculate the potential number of elements we're going to print */
- if(H5Sselect_hyperslab(f_space, H5S_SELECT_SET, temp_start, temp_stride, temp_count, temp_block) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
+ if (H5Sselect_hyperslab(f_space, H5S_SELECT_SET, temp_start, temp_stride, temp_count, temp_block) < 0)
+ H5TOOLS_THROW(FAIL, "H5Sselect_hyperslab failed");
- if((ssm_nelmts = H5Sget_select_npoints(f_space)) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_select_npoints failed");
+ if ((ssm_nelmts = H5Sget_select_npoints(f_space)) < 0)
+ H5TOOLS_THROW(FAIL, "H5Sget_select_npoints failed");
sm_nelmts = (hsize_t)ssm_nelmts;
if (sm_nelmts > 0) {
@@ -1176,8 +1324,8 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c
* determine the strip mine size and allocate a buffer. the strip mine is
* a hyperslab whose size is manageable.
*/
- if((sm_nbytes = p_type_nbytes = H5Tget_size(p_type)) == 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
+ if ((sm_nbytes = p_type_nbytes = H5Tget_size(p_type)) == 0)
+ H5TOOLS_THROW(FAIL, "H5Tget_size failed");
if (ctx->ndims > 0)
for (i = ctx->ndims; i > 0; --i) {
@@ -1189,19 +1337,19 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c
HDassert(sm_nbytes > 0);
}
- HDassert(sm_nbytes == (hsize_t) ((size_t) sm_nbytes)); /*check for overflow*/
- if(NULL == (sm_buf = (unsigned char *)HDmalloc((size_t) sm_nelmts * p_type_nbytes)))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for strip-mine");
+ HDassert(sm_nbytes == (hsize_t)((size_t)sm_nbytes)); /*check for overflow*/
+ if (NULL == (sm_buf = (unsigned char *)HDmalloc((size_t)sm_nelmts * p_type_nbytes)))
+ H5TOOLS_THROW(FAIL, "Could not allocate buffer for strip-mine");
- if((sm_space = H5Screate_simple(1, &sm_nelmts, NULL)) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Screate_simple failed");
+ if ((sm_space = H5Screate_simple(1, &sm_nelmts, NULL)) < 0)
+ H5TOOLS_THROW(FAIL, "H5Screate_simple failed");
- if(H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &sm_nelmts, NULL) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
+ if (H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &sm_nelmts, NULL) < 0)
+ H5TOOLS_THROW(FAIL, "H5Sselect_hyperslab failed");
/* read the data */
- if(H5Dread(dset, p_type, sm_space, f_space, H5P_DEFAULT, sm_buf) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Dread failed");
+ if (H5Dread(dset, p_type, sm_space, f_space, H5P_DEFAULT, sm_buf) < 0)
+ H5TOOLS_THROW(FAIL, "H5Dread failed");
/* print the data */
flags = START_OF_DATA;
@@ -1212,50 +1360,48 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c
for (i = 0; i < ctx->ndims; i++)
ctx->p_max_idx[i] = ctx->p_min_idx[i] + MIN(total_size[i], sm_size[i]);
- /* print array indices. get the lower bound of the hyperslab and calulate
- the element position at the start of hyperslab */
- if(H5Sget_select_bounds(f_space, low, high) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_select_bounds failed");
+ /* print array indices. get the lower bound of the hyperslab and calculate
+ the element position at the start of hyperslab */
+ if (H5Sget_select_bounds(f_space, low, high) < 0)
+ H5TOOLS_THROW(FAIL, "H5Sget_select_bounds failed");
- elmtno = 0;
- for (i = 0; i < (size_t) ctx->ndims - 1; i++) {
+ /* initialize the current stripmine position; this is necessary to print the array indices */
+ ctx->sm_pos = 0;
+ for (i = 0; i < (size_t)ctx->ndims - 1; i++) {
hsize_t offset = 1; /* accumulation of the previous dimensions */
- for (j = i + 1; j < (size_t) ctx->ndims; j++)
+ for (j = i + 1; j < (size_t)ctx->ndims; j++)
offset *= total_size[j];
- elmtno += low[i] * offset;
+ ctx->sm_pos += low[i] * offset;
}
- elmtno += low[ctx->ndims - 1];
-
- /* initialize the current stripmine position; this is necessary to print the array
- indices */
- ctx->sm_pos = elmtno;
+ ctx->sm_pos += low[ctx->ndims - 1];
ctx->need_prefix = TRUE;
- if(h5tools_dump_simple_data(stream, info, dset, ctx, flags, sm_nelmts, p_type, sm_buf) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "h5tools_dump_simple_data failed");
+ if (h5tools_dump_simple_data(stream, info, ctx, dset, flags, sm_nelmts, p_type, sm_buf) < 0)
+ H5TOOLS_THROW(FAIL, "h5tools_dump_simple_data failed");
/* Reclaim any VL memory, if necessary */
if (vl_data)
- H5Dvlen_reclaim(p_type, sm_space, H5P_DEFAULT, sm_buf);
+ H5Treclaim(p_type, sm_space, H5P_DEFAULT, sm_buf);
- if(H5Sclose(sm_space) < 0)
- H5E_THROW(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
- if(sm_buf)
+ if (H5Sclose(sm_space) < 0)
+ H5TOOLS_THROW(FAIL, "H5Sclose failed");
+ if (sm_buf)
HDfree(sm_buf);
sm_buf = NULL;
}
else
- H5E_THROW(SUCCEED, H5E_tools_min_id_g, "nothing to print");
+ H5TOOLS_THROW(SUCCEED, "nothing to print");
ctx->continuation++;
} /* hyperslab_count loop */
-CATCH
- if(sm_buf)
+ CATCH
+ if (sm_buf)
HDfree(sm_buf);
+ H5TOOLS_ENDDEBUG(" ");
return ret_value;
}
@@ -1292,23 +1438,22 @@ CATCH
*-------------------------------------------------------------------------
*/
static herr_t
-h5tools_display_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
- hid_t dset, hid_t p_type, struct subset_t *sset,
- hid_t f_space, hsize_t *total_size)
+h5tools_display_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t dset,
+ hid_t p_type, hid_t f_space, hsize_t *total_size)
{
- size_t i; /* counters */
- hsize_t n; /* counters */
- hsize_t count; /* hyperslab count */
- hsize_t outer_count; /* offset count */
- unsigned int row_dim; /* index of row_counter dimension */
- int current_outer_dim; /* dimension for start */
- hsize_t temp_start[H5S_MAX_RANK];/* temporary start inside offset count loop */
- hsize_t max_start[H5S_MAX_RANK]; /* maximum start inside offset count loop */
- hsize_t temp_count[H5S_MAX_RANK];/* temporary count inside offset count loop */
- hsize_t temp_block[H5S_MAX_RANK];/* temporary block size used in loop */
- hsize_t temp_stride[H5S_MAX_RANK];/* temporary stride size used in loop */
- int reset_dim;
- herr_t ret_value = SUCCEED;
+ size_t i; /* counters */
+ hsize_t n; /* counters */
+ hsize_t count; /* hyperslab count */
+ hsize_t outer_count; /* offset count */
+ unsigned int row_dim; /* index of row_counter dimension */
+ int current_outer_dim; /* dimension for start */
+ hsize_t temp_start[H5S_MAX_RANK]; /* temporary start inside offset count loop */
+ hsize_t max_start[H5S_MAX_RANK]; /* maximum start inside offset count loop */
+ hsize_t temp_count[H5S_MAX_RANK]; /* temporary count inside offset count loop */
+ hsize_t temp_block[H5S_MAX_RANK]; /* temporary block size used in loop */
+ hsize_t temp_stride[H5S_MAX_RANK]; /* temporary stride size used in loop */
+ int reset_dim;
+ herr_t ret_value = SUCCEED;
if (ctx->ndims == 1)
row_dim = 0;
@@ -1318,23 +1463,23 @@ h5tools_display_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools
/* get the offset count */
outer_count = 1;
if (ctx->ndims > 2)
- for (i = 0; i < (size_t) ctx->ndims - 2; i++) {
+ for (i = 0; i < (size_t)ctx->ndims - 2; i++) {
/* block size is handled by containing h5tools_print_simple_subset call */
- outer_count = outer_count * sset->count.data[i];
+ outer_count = outer_count * ctx->sset->count.data[i];
}
/* initialize temporary start, count and maximum start */
- for (i = 0; i < (size_t) ctx->ndims; i++) {
- temp_start[i] = sset->start.data[i];
- temp_count[i] = sset->count.data[i];
- temp_block[i] = sset->block.data[i];
- temp_stride[i] = sset->stride.data[i];
- max_start[i] = 0;
+ for (i = 0; i < ctx->ndims; i++) {
+ temp_start[i] = ctx->sset->start.data[i];
+ temp_count[i] = ctx->sset->count.data[i];
+ temp_block[i] = ctx->sset->block.data[i];
+ temp_stride[i] = ctx->sset->stride.data[i];
+ max_start[i] = 0;
}
if (ctx->ndims > 2) {
- for (i = 0; i < (size_t) ctx->ndims - 2; i++) {
- max_start[i] = temp_start[i] + sset->count.data[i];
+ for (i = 0; i < (size_t)ctx->ndims - 2; i++) {
+ max_start[i] = temp_start[i] + ctx->sset->count.data[i] * ctx->sset->stride.data[i];
temp_count[i] = 1;
}
}
@@ -1345,14 +1490,14 @@ h5tools_display_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools
if (ctx->ndims > 1) {
/* count is the number of iterations to display all the rows,
the block size count times */
- count = sset->count.data[row_dim] * sset->block.data[row_dim];
+ count = ctx->sset->count.data[row_dim] * ctx->sset->block.data[row_dim];
/* always 1 row_counter at a time, that is a block of size 1, 1 time */
temp_count[row_dim] = 1;
temp_block[row_dim] = 1;
/* advance 1 row_counter at a time */
- if (sset->block.data[row_dim] > 1)
+ if (ctx->sset->block.data[row_dim] > 1)
temp_stride[row_dim] = 1;
}
/* for the 1D case */
@@ -1360,29 +1505,23 @@ h5tools_display_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools
count = 1;
}
- h5tools_print_simple_subset(stream, info, ctx, dset, p_type, sset,
- f_space, count, temp_start, temp_count,
- temp_block, temp_stride, total_size, row_dim);
+ h5tools_print_simple_subset(stream, info, ctx, dset, p_type, f_space, count, temp_start, temp_count,
+ temp_block, temp_stride, total_size, row_dim);
if (ctx->ndims > 2) {
/* dimension for start */
- current_outer_dim = (ctx->ndims - 2) - 1;
+ current_outer_dim = (int)(ctx->ndims - 2) - 1;
/* set start to original from current_outer_dim up */
- for (i = current_outer_dim + 1; i < ctx->ndims; i++) {
- temp_start[i] = sset->start.data[i];
- }
+ for (i = (size_t)(current_outer_dim + 1); i < ctx->ndims; i++)
+ temp_start[i] = ctx->sset->start.data[i];
/* increment start dimension */
do {
reset_dim = 0;
- temp_start[current_outer_dim]++;
+ temp_start[current_outer_dim] += ctx->sset->stride.data[current_outer_dim];
if (temp_start[current_outer_dim] >= max_start[current_outer_dim]) {
- temp_start[current_outer_dim] = sset->start.data[current_outer_dim];
-
- /* consider block */
- if (sset->block.data[current_outer_dim] > 1)
- temp_start[current_outer_dim]++;
+ temp_start[current_outer_dim] = ctx->sset->start.data[current_outer_dim];
current_outer_dim--;
reset_dim = 1;
@@ -1439,36 +1578,39 @@ h5tools_display_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools
*/
static herr_t
h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t dset,
- hid_t p_type, struct subset_t *sset)
+ hid_t p_type)
{
- HERR_INIT(herr_t, SUCCEED)
- int sndims;
- hid_t f_space = -1; /* file data space */
- size_t i; /* counters */
- hsize_t total_size[H5S_MAX_RANK];/* total size of dataset*/
-
- if((f_space = H5Dget_space(dset)) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
-
- if((sndims = H5Sget_simple_extent_ndims(f_space)) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
+ int sndims;
+ hid_t f_space = H5I_INVALID_HID; /* file data space */
+ hsize_t total_size[H5S_MAX_RANK]; /* total size of dataset*/
+ hbool_t past_catch = FALSE;
+ herr_t ret_value = SUCCEED;
+
+ H5TOOLS_START_DEBUG(" ");
+ if ((f_space = H5Dget_space(dset)) < 0)
+ H5TOOLS_THROW(FAIL, "H5Dget_space failed");
+
+ if ((sndims = H5Sget_simple_extent_ndims(f_space)) < 0)
+ H5TOOLS_THROW(FAIL, "H5Sget_simple_extent_ndims failed");
ctx->ndims = (unsigned)sndims;
/* assume entire data space to be printed */
- if (ctx->ndims > 0)
- for (i = 0; i < (size_t) ctx->ndims; i++)
- ctx->p_min_idx[i] = 0;
+ if (H5Sget_simple_extent_dims(f_space, total_size, NULL) < 0)
+ H5TOOLS_THROW(FAIL, "H5Sget_simple_extent_dims failed");
+ init_acc_pos(ctx->ndims, total_size, ctx->acc, ctx->pos, ctx->p_min_idx);
- if(H5Sget_simple_extent_dims(f_space, total_size, NULL) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
ctx->size_last_dim = total_size[ctx->ndims - 1];
- h5tools_display_simple_subset(stream, info, ctx, dset, p_type, sset, f_space, total_size);
+ /* Set the compound datatype field list for display */
+ ctx->cmpd_listv = info->cmpd_listv;
-CATCH
- if(f_space >= 0 && H5Sclose(f_space) < 0)
- H5E_THROW(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
+ h5tools_display_simple_subset(stream, info, ctx, dset, p_type, f_space, total_size);
+ CATCH
+ if (f_space >= 0 && H5Sclose(f_space) < 0)
+ H5TOOLS_THROW(FAIL, "H5Sclose failed");
+
+ H5TOOLS_ENDDEBUG(" ");
return ret_value;
}
@@ -1488,54 +1630,55 @@ CATCH
*-------------------------------------------------------------------------
*/
static int
-h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
- hid_t dset, hid_t p_type)
+h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t dset,
+ hid_t p_type)
{
- HERR_INIT(herr_t, SUCCEED)
- hid_t f_space = -1; /* file data space */
- hsize_t elmtno; /* counter */
- size_t i; /* counter */
- int carry; /* counter carry value */
- hsize_t zero[8]; /* vector of zeros */
- unsigned int flags; /* buffer extent flags */
- hsize_t total_size[H5S_MAX_RANK]; /* total size of dataset*/
+ hid_t f_space = H5I_INVALID_HID; /* file data space */
+ hsize_t elmtno; /* counter */
+ size_t i = 0; /* counter */
+ int sndims; /* rank of dataspace */
+ int carry; /* counter carry value */
+ hsize_t zero[8]; /* vector of zeros */
+ unsigned int flags; /* buffer extent flags */
+ hsize_t total_size[H5S_MAX_RANK]; /* total size of dataset*/
+ hbool_t past_catch = FALSE;
/* Print info */
- size_t p_type_nbytes; /* size of memory type */
- hsize_t p_nelmts; /* total selected elmts */
+ size_t p_type_nbytes; /* size of memory type */
+ hsize_t p_nelmts; /* total selected elmts */
/* Stripmine info */
- hsize_t sm_size[H5S_MAX_RANK]; /* stripmine size */
- hsize_t sm_nbytes; /* bytes per stripmine */
- hsize_t sm_nelmts; /* elements per stripmine*/
- unsigned char *sm_buf = NULL; /* buffer for raw data */
- hid_t sm_space = -1; /* stripmine data space */
+ hsize_t sm_size[H5S_MAX_RANK]; /* stripmine size */
+ hsize_t sm_nbytes; /* bytes per stripmine */
+ hsize_t sm_nelmts; /* elements per stripmine*/
+ unsigned char *sm_buf = NULL; /* buffer for raw data */
+ hid_t sm_space = H5I_INVALID_HID; /* stripmine data space */
/* Hyperslab info */
- hsize_t hs_offset[H5S_MAX_RANK]; /* starting offset */
- hsize_t hs_size[H5S_MAX_RANK]; /* size this pass */
- hsize_t hs_nelmts; /* elements in request */
+ hsize_t hs_offset[H5S_MAX_RANK]; /* starting offset */
+ hsize_t hs_size[H5S_MAX_RANK]; /* size this pass */
+ hsize_t hs_nelmts; /* elements in request */
/* VL data special information */
- unsigned int vl_data = 0; /* contains VL datatypes */
-
- f_space = H5Dget_space(dset);
+ unsigned int vl_data = 0; /* contains VL datatypes */
+ int ret_value = 0;
- if (f_space == FAIL)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
+ H5TOOLS_START_DEBUG(" ");
+ if (H5I_INVALID_HID == (f_space = H5Dget_space(dset)))
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed");
- ctx->ndims = H5Sget_simple_extent_ndims(f_space);
+ sndims = H5Sget_simple_extent_ndims(f_space);
+ if (sndims < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_simple_extent_ndims failed");
+ ctx->ndims = (unsigned)sndims;
+ H5TOOLS_DEBUG("sndims:%d", sndims);
- if ((size_t)ctx->ndims > NELMTS(sm_size)) {
- H5E_THROW(FAIL, H5E_tools_min_id_g, "ctx->ndims > NELMTS(sm_size) failed");
- }
+ if ((size_t)ctx->ndims > NELMTS(sm_size))
+ H5TOOLS_GOTO_ERROR((-1), "ctx->ndims > NELMTS(sm_size) failed");
/* Assume entire data space to be printed */
- if (ctx->ndims > 0)
- for (i = 0; i < (size_t)ctx->ndims; i++)
- ctx->p_min_idx[i] = 0;
-
H5Sget_simple_extent_dims(f_space, total_size, NULL);
+ init_acc_pos(ctx->ndims, total_size, ctx->acc, ctx->pos, ctx->p_min_idx);
/* calculate the number of elements we're going to print */
p_nelmts = 1;
@@ -1553,9 +1696,7 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont
}
/* Check if we have VL data in the dataset's datatype */
- if (h5tools_detect_vlen_str(p_type) == TRUE)
- vl_data = TRUE;
- if (H5Tdetect_class(p_type, H5T_VLEN) == TRUE)
+ if (h5tools_detect_vlen(p_type) == TRUE)
vl_data = TRUE;
/*
@@ -1563,96 +1704,101 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont
* a hyperslab whose size is manageable.
*/
sm_nbytes = p_type_nbytes = H5Tget_size(p_type);
-
if (ctx->ndims > 0) {
for (i = ctx->ndims; i > 0; --i) {
hsize_t size = H5TOOLS_BUFSIZE / sm_nbytes;
- if ( size == 0) /* datum size > H5TOOLS_BUFSIZE */
+ if (size == 0) /* datum size > H5TOOLS_BUFSIZE */
size = 1;
sm_size[i - 1] = MIN(total_size[i - 1], size);
sm_nbytes *= sm_size[i - 1];
- HDassert(sm_nbytes > 0);
}
}
-
- if(!sm_nbytes)
+ if (!sm_nbytes)
goto done;
HDassert(sm_nbytes == (hsize_t)((size_t)sm_nbytes)); /*check for overflow*/
- sm_buf = (unsigned char *)HDmalloc((size_t)sm_nbytes);
-
- sm_nelmts = sm_nbytes / p_type_nbytes;
- sm_space = H5Screate_simple(1, &sm_nelmts, NULL);
-
- if (ctx->ndims > 0)
- init_acc_pos(ctx, total_size);
-
- /* The stripmine loop */
- HDmemset(hs_offset, 0, sizeof hs_offset);
- HDmemset(zero, 0, sizeof zero);
+ if (NULL != (sm_buf = (unsigned char *)HDmalloc((size_t)sm_nbytes))) {
+ H5TOOLS_DEBUG("stripmine size:%ld", sm_nbytes);
+
+ sm_nelmts = sm_nbytes / p_type_nbytes;
+ sm_space = H5Screate_simple(1, &sm_nelmts, NULL);
+ H5TOOLS_DEBUG("sm_nelmts size:%ld", sm_nelmts);
+
+ H5TOOLS_DEBUG("ctx->ndims:%d", ctx->ndims);
+
+ /* The stripmine loop */
+ HDmemset(hs_offset, 0, sizeof hs_offset);
+ HDmemset(zero, 0, sizeof zero);
+
+ for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_nelmts) {
+ H5TOOLS_DEBUG("stripmine read loop:%d", i);
+ /* Calculate the hyperslab size */
+ if (ctx->ndims > 0) {
+ for (i = 0, hs_nelmts = 1; i < ctx->ndims; i++) {
+ hs_size[i] = MIN(total_size[i] - hs_offset[i], sm_size[i]);
+ ctx->p_max_idx[i] = ctx->p_min_idx[i] + hs_size[i];
+ hs_nelmts *= hs_size[i];
+ }
- for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_nelmts) {
- /* Calculate the hyperslab size */
- if (ctx->ndims > 0) {
- for (i = 0, hs_nelmts = 1; i < ctx->ndims; i++) {
- hs_size[i] = MIN(total_size[i] - hs_offset[i], sm_size[i]);
- ctx->p_max_idx[i] = ctx->p_min_idx[i] + hs_size[i];
- hs_nelmts *= hs_size[i];
+ if (H5Sselect_hyperslab(f_space, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0)
+ H5TOOLS_ERROR((-1), "H5Sselect_hyperslab hs_offset failed");
+ if (H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &hs_nelmts, NULL) < 0)
+ H5TOOLS_ERROR((-1), "H5Sselect_hyperslab zero failed");
+ }
+ else {
+ if (H5Sselect_all(f_space) < 0)
+ H5TOOLS_ERROR((-1), "H5Sselect_all f_space failed");
+ if (H5Sselect_all(sm_space) < 0)
+ H5TOOLS_ERROR((-1), "H5Sselect_all sm_space failed");
+ hs_nelmts = 1;
}
- H5Sselect_hyperslab(f_space, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL);
- H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &hs_nelmts, NULL);
- }
- else {
- H5Sselect_all(f_space);
- H5Sselect_all(sm_space);
- hs_nelmts = 1;
- }
-
- /* Read the data */
- if (H5Dread(dset, p_type, sm_space, f_space, H5P_DEFAULT, sm_buf) < 0) {
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Dread failed");
- }
-
- /* Print the data */
- flags = (elmtno == 0) ? START_OF_DATA : 0;
- flags |= ((elmtno + hs_nelmts) >= p_nelmts) ? END_OF_DATA : 0;
+ H5TOOLS_DEBUG("Read the data");
+ /* Read the data */
+ if (H5Dread(dset, p_type, sm_space, f_space, H5P_DEFAULT, sm_buf) >= 0) {
+ /* Print the data */
+ flags = (elmtno == 0) ? START_OF_DATA : 0;
+ flags |= ((elmtno + hs_nelmts) >= p_nelmts) ? END_OF_DATA : 0;
- /* initialize the current stripmine position; this is necessary to print the array
- indices */
- ctx->sm_pos = elmtno;
+ /* initialize the current stripmine position; this is necessary to print the array
+ indices */
+ ctx->sm_pos = elmtno;
- if(h5tools_dump_simple_data(stream, info, dset, ctx, flags, hs_nelmts, p_type, sm_buf) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "h5tools_dump_simple_data failed");
+ if (h5tools_dump_simple_data(stream, info, ctx, dset, flags, hs_nelmts, p_type, sm_buf) < 0)
+ H5TOOLS_ERROR((-1), "h5tools_dump_simple_data failed");
- /* Reclaim any VL memory, if necessary */
- if (vl_data)
- H5Dvlen_reclaim(p_type, sm_space, H5P_DEFAULT, sm_buf);
+ /* Reclaim any VL memory, if necessary */
+ if (vl_data)
+ H5Treclaim(p_type, sm_space, H5P_DEFAULT, sm_buf);
- /* Calculate the next hyperslab offset */
- for (i = ctx->ndims, carry = 1; i > 0 && carry; --i) {
- ctx->p_min_idx[i - 1] = ctx->p_max_idx[i - 1];
- hs_offset[i - 1] += hs_size[i - 1];
+ H5TOOLS_DEBUG("Calculate the next hyperslab offset");
+ /* Calculate the next hyperslab offset */
+ for (i = ctx->ndims, carry = 1; i > 0 && carry; --i) {
+ ctx->p_min_idx[i - 1] = ctx->p_max_idx[i - 1];
+ hs_offset[i - 1] += hs_size[i - 1];
- if (hs_offset[i - 1] == total_size[i - 1])
- hs_offset[i - 1] = 0;
+ if (hs_offset[i - 1] == total_size[i - 1])
+ hs_offset[i - 1] = 0;
+ else
+ carry = 0;
+ }
+ }
else
- carry = 0;
- }
-
- ctx->continuation++;
- }
+ H5TOOLS_ERROR((-1), "H5Dread failed");
-CATCH
- if(sm_buf)
+ ctx->continuation++;
+ H5TOOLS_DEBUG("stripmine read loop:%d complete", i);
+ }
HDfree(sm_buf);
+ } /* if (NULL != (sm_buf...)) */
done:
- if(sm_space >= 0 && H5Sclose(sm_space) < 0)
- H5E_THROW(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
- if(f_space >= 0 && H5Sclose(f_space) < 0)
- H5E_THROW(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
-
+ if (sm_space >= 0 && H5Sclose(sm_space) < 0)
+ H5TOOLS_ERROR((-1), "H5Sclose failed");
+ if (f_space >= 0 && H5Sclose(f_space) < 0)
+ H5TOOLS_ERROR((-1), "H5Sclose failed");
+ CATCH
+ H5TOOLS_ENDDEBUG(" ");
return ret_value;
}
@@ -1664,47 +1810,85 @@ done:
*
* Return: Success: SUCCEED
* Failure: FAIL
- *
*-------------------------------------------------------------------------
*/
static int
-h5tools_dump_simple_mem(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t obj_id,
- hid_t type, hid_t space, void *mem)
+h5tools_dump_simple_mem(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t attr_id,
+ hid_t p_type)
{
- HERR_INIT(herr_t, SUCCEED)
- int i; /*counters */
- hsize_t nelmts; /*total selected elmts */
+ hid_t f_space = H5I_INVALID_HID; /* file data space */
+ hsize_t alloc_size;
+ int sndims; /* rank of dataspace */
+ unsigned i; /* counters */
+ hsize_t total_size[H5S_MAX_RANK]; /* total size of dataset*/
+ hsize_t p_nelmts; /* total selected elmts */
+ hbool_t past_catch = FALSE;
+ unsigned char *buf = NULL; /* buffer for raw data */
+ int ret_value = 0;
- ctx->ndims = H5Sget_simple_extent_ndims(space);
+ /* VL data special information */
+ unsigned int vl_data = 0; /* contains VL datatypes */
- if ((size_t) ctx->ndims > NELMTS(ctx->p_min_idx))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "ctx->ndims > NELMTS(ctx->p_min_idx) failed");
+ H5TOOLS_START_DEBUG(" ");
+ if (H5I_INVALID_HID == (f_space = H5Aget_space(attr_id)))
+ H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed");
- /* Assume entire data space to be printed */
- for (i = 0; i < ctx->ndims; i++)
- ctx->p_min_idx[i] = 0;
+ sndims = H5Sget_simple_extent_ndims(f_space);
+ if (sndims < 0)
+ H5TOOLS_THROW((-1), "H5Dget_simple_extent_ndims failed");
+ ctx->ndims = (unsigned)sndims;
+ H5TOOLS_DEBUG("sndims:%d", sndims);
- H5Sget_simple_extent_dims(space, ctx->p_max_idx, NULL);
+ if ((size_t)ctx->ndims > NELMTS(ctx->p_min_idx))
+ H5TOOLS_THROW((-1), "ctx->ndims > NELMTS(ctx->p_min_idx) failed");
- for (i = 0, nelmts = 1; ctx->ndims != 0 && i < ctx->ndims; i++)
- nelmts *= ctx->p_max_idx[i] - ctx->p_min_idx[i];
+ /* Assume entire data space to be printed */
+ H5Sget_simple_extent_dims(f_space, total_size, NULL);
+ init_acc_pos(ctx->ndims, total_size, ctx->acc, ctx->pos, ctx->p_min_idx);
+
+ /* calculate the number of elements we're going to print */
+ p_nelmts = 1;
- if (nelmts == 0)
- H5_LEAVE(SUCCEED); /* nothing to print */
if (ctx->ndims > 0) {
- HDassert(ctx->p_max_idx[ctx->ndims - 1] == (hsize_t) ((int) ctx->p_max_idx[ctx->ndims - 1]));
- ctx->size_last_dim = (int) (ctx->p_max_idx[ctx->ndims - 1]);
+ for (i = 0; i < ctx->ndims; i++)
+ p_nelmts *= total_size[i];
+ ctx->size_last_dim = (total_size[ctx->ndims - 1]);
} /* end if */
else
ctx->size_last_dim = 0;
- if (ctx->ndims > 0)
- init_acc_pos(ctx, ctx->p_max_idx);
+ if (p_nelmts == 0)
+ H5_LEAVE(SUCCEED); /* nothing to print */
+
+ /* Check if we have VL data in the dataset's datatype */
+ if (h5tools_detect_vlen(p_type) == TRUE)
+ vl_data = TRUE;
+
+ alloc_size = p_nelmts * H5Tget_size(p_type);
+ HDassert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/
+ if (NULL != (buf = (unsigned char *)HDmalloc((size_t)alloc_size))) {
+ H5TOOLS_DEBUG("ctx->ndims:%d", ctx->ndims);
- if(h5tools_dump_simple_data(stream, info, obj_id, ctx, START_OF_DATA | END_OF_DATA, nelmts, type, mem) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "h5tools_dump_simple_data failed");
+ H5TOOLS_DEBUG("Read the data");
+ /* Read the data */
+ if (H5Aread(attr_id, p_type, buf) >= 0) {
+ if (h5tools_dump_simple_data(stream, info, ctx, attr_id, START_OF_DATA | END_OF_DATA, p_nelmts,
+ p_type, buf) < 0)
+ H5TOOLS_ERROR((-1), "h5tools_dump_simple_data failed");
-CATCH
+ /* Reclaim any VL memory, if necessary */
+ if (vl_data)
+ H5Treclaim(p_type, f_space, H5P_DEFAULT, buf);
+ }
+ else
+ H5TOOLS_ERROR((-1), "H5Aread failed");
+ HDfree(buf);
+ } /* if (NULL != (buf...)) */
+done:
+ if (f_space >= 0 && H5Sclose(f_space) < 0)
+ H5TOOLS_ERROR((-1), "H5Sclose failed");
+ CATCH
+ H5TOOLS_ENDDEBUG(" ");
return ret_value;
}
@@ -1724,28 +1908,19 @@ CATCH
*
* Return: Success: SUCCEED
* Failure: FAIL
- *
- * Modifications:
- * Robb Matzke, 1999-06-07
- * If info->raw is set then the memory datatype will be the same
- * as the file datatype.
- *
- * Bill Wendling, 2001-02-27
- * Renamed to ``h5tools_dump_dset'' and added the subsetting
- * parameter.
- *
*-------------------------------------------------------------------------
*/
int
-h5tools_dump_dset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
- hid_t dset, hid_t _p_type, struct subset_t *sset)
+h5tools_dump_dset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t dset)
{
- hid_t f_space;
- hid_t p_type = _p_type;
- hid_t f_type;
- H5S_class_t space_type;
- int status = FAIL;
+ hid_t f_space = H5I_INVALID_HID;
+ hid_t p_type = H5I_INVALID_HID;
+ hid_t f_type = H5I_INVALID_HID;
+ H5S_class_t space_type;
h5tool_format_t info_dflt;
+ int ret_value = 0;
+
+ H5TOOLS_START_DEBUG(" ");
/* Use default values */
if (!stream)
stream = rawoutstream;
@@ -1755,48 +1930,50 @@ h5tools_dump_dset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *
info = &info_dflt;
}
- if (p_type < 0) {
- f_type = H5Dget_type(dset);
-
- if (info->raw || bin_form == 1)
- p_type = H5Tcopy(f_type);
- else if (bin_form == 2)
- p_type = h5tools_get_little_endian_type(f_type);
- else if (bin_form == 3)
- p_type = h5tools_get_big_endian_type(f_type);
- else
- p_type = h5tools_get_native_type(f_type);
+ f_type = H5Dget_type(dset);
+ if (f_type < 0)
+ goto done;
- H5Tclose(f_type);
+ if (info->raw || bin_form == 1)
+ p_type = H5Tcopy(f_type);
+ else if (bin_form == 2)
+ p_type = h5tools_get_little_endian_type(f_type);
+ else if (bin_form == 3)
+ p_type = h5tools_get_big_endian_type(f_type);
+ else
+ p_type = H5Tget_native_type(f_type, H5T_DIR_DEFAULT);
- if (p_type < 0)
- goto done;
- }
+ if (p_type < 0)
+ goto done;
/* Check the data space */
f_space = H5Dget_space(dset);
+ if (f_space < 0)
+ goto done;
space_type = H5Sget_simple_extent_type(f_space);
/* Print the data */
if (space_type == H5S_SIMPLE || space_type == H5S_SCALAR) {
- if(!sset)
- status = h5tools_dump_simple_dset(rawdatastream, info, ctx, dset, p_type);
+ if (!ctx->sset)
+ ret_value = h5tools_dump_simple_dset(rawdatastream, info, ctx, dset, p_type);
else
- status = h5tools_dump_simple_subset(stream, info, ctx, dset, p_type, sset);
+ ret_value = h5tools_dump_simple_subset(rawdatastream, info, ctx, dset, p_type);
}
- else
+ else {
/* space is H5S_NULL */
- status = SUCCEED;
-
- /* Close the dataspace */
- H5Sclose(f_space);
-
+ ret_value = SUCCEED;
+ }
done:
- if (p_type != _p_type)
+ if (f_type > 0)
+ H5Tclose(f_type);
+ if (p_type > 0)
H5Tclose(p_type);
+ if (f_space > 0)
+ H5Sclose(f_space);
- return status;
+ H5TOOLS_ENDDEBUG(" ");
+ return ret_value;
}
/*-------------------------------------------------------------------------
@@ -1808,16 +1985,18 @@ done:
*
* Return: Success: SUCCEED
* Failure: FAIL
- *
*-------------------------------------------------------------------------
*/
int
-h5tools_dump_mem(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
- hid_t obj_id, hid_t type, hid_t space, void *mem)
+h5tools_dump_mem(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t attr_id)
{
- HERR_INIT(int, SUCCEED)
- h5tool_format_t info_dflt;
+ hid_t f_space = H5I_INVALID_HID;
+ hid_t p_type = H5I_INVALID_HID;
+ hid_t f_type = H5I_INVALID_HID;
+ h5tool_format_t info_dflt;
+ int ret_value = 0;
+ H5TOOLS_START_DEBUG(" ");
/* Use default values */
if (!stream)
stream = rawoutstream;
@@ -1827,13 +2006,43 @@ h5tools_dump_mem(FILE *stream, const h5tool_format_t *info, h5tools_context_t *c
info = &info_dflt;
}
+ f_type = H5Aget_type(attr_id);
+ if (f_type < 0)
+ goto done;
+
+ if (info->raw || bin_form == 1)
+ p_type = H5Tcopy(f_type);
+ else if (bin_form == 2)
+ p_type = h5tools_get_little_endian_type(f_type);
+ else if (bin_form == 3)
+ p_type = h5tools_get_big_endian_type(f_type);
+ else
+ p_type = H5Tget_native_type(f_type, H5T_DIR_DEFAULT);
+
+ if (p_type < 0)
+ goto done;
+
/* Check the data space */
- if (H5Sis_simple(space) <= 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sis_simple failed")
+ f_space = H5Aget_space(attr_id);
+ if (f_space < 0)
+ goto done;
- H5_LEAVE(h5tools_dump_simple_mem(stream, info, ctx, obj_id, type, space, mem))
+ /* Check the data space */
+ if (H5Sis_simple(f_space) <= 0) {
+ H5TOOLS_ERROR((-1), "H5Sis_simple failed");
+ }
+ else {
+ ret_value = h5tools_dump_simple_mem(rawattrstream, info, ctx, attr_id, p_type);
+ }
+done:
+ if (f_type > 0)
+ H5Tclose(f_type);
+ if (p_type > 0)
+ H5Tclose(p_type);
+ if (f_space > 0)
+ H5Sclose(f_space);
-CATCH
+ H5TOOLS_ENDDEBUG(" ");
return ret_value;
}
@@ -1846,575 +2055,595 @@ CATCH
*
* In/Out: h5tools_str_t *buffer
* h5tools_context_t *ctx
- *
*-------------------------------------------------------------------------
*/
int
h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_t *info,
- h5tools_context_t *ctx, hid_t type, int object_search)
+ h5tools_context_t *ctx, hid_t type, int object_search)
{
- HERR_INIT(int, SUCCEED)
- char *mname;
- hid_t mtype = -1;
- hid_t str_type = -1;
- hid_t super = -1;
- hid_t tmp_type = -1;
- int snmembers;
- int sndims;
- unsigned nmembers;
- unsigned i;
- size_t size = 0;
- size_t ncols = 80; /*available output width */
- hsize_t dims[H5TOOLS_DUMP_MAX_RANK];
- hsize_t curr_pos = 0; /* total data element position */
- H5T_str_t str_pad;
- H5T_cset_t cset;
- H5T_order_t order;
- H5T_class_t type_class;
- H5T_sign_t sign; /* sign scheme value */
- htri_t is_vlstr = FALSE;
- const char *sign_s = NULL; /* sign scheme string */
- const char *order_s = NULL; /* byte order string */
-
- if((type_class = H5Tget_class(type)) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_class failed");
+ char *mname;
+ hid_t mtype = H5I_INVALID_HID;
+ hid_t str_type = H5I_INVALID_HID;
+ hid_t super = H5I_INVALID_HID;
+ hid_t tmp_type = H5I_INVALID_HID;
+ int snmembers;
+ int sndims;
+ unsigned nmembers;
+ unsigned i;
+ size_t size = 0;
+ size_t ncols = 80; /*available output width */
+ hsize_t dims[H5TOOLS_DUMP_MAX_RANK];
+ hsize_t curr_pos = 0; /* total data element position */
+ H5T_str_t str_pad;
+ H5T_cset_t cset;
+ H5T_order_t order;
+ H5T_class_t type_class;
+ H5T_sign_t sign; /* sign scheme value */
+ htri_t is_vlstr = FALSE;
+ hbool_t past_catch = FALSE;
+ const char *sign_s = NULL; /* sign scheme string */
+ const char *order_s = NULL; /* byte order string */
+ int ret_value = 0;
+
+ H5TOOLS_START_DEBUG(" ");
+ if ((type_class = H5Tget_class(type)) < 0)
+ H5TOOLS_THROW((-1), "H5Tget_class failed");
if (object_search && H5Tcommitted(type) > 0) {
- H5O_info_t oinfo;
- obj_t *obj = NULL; /* Found object */
+ H5O_info2_t oinfo;
+ obj_t *obj = NULL; /* Found object */
+
+ H5Oget_info3(type, &oinfo, H5O_INFO_BASIC);
+ obj = search_obj(h5dump_type_table, &oinfo.token);
- H5Oget_info(type, &oinfo);
- obj = search_obj(h5dump_type_table, oinfo.addr);
+ if (obj) {
+ if (!obj->recorded) {
+ char *obj_tok_str = NULL;
- if(obj) {
- if(!obj->recorded) {
- h5tools_str_append(buffer,"\"/#"H5_PRINTF_HADDR_FMT"\"", obj->objno);
+ H5Otoken_to_str(type, &oinfo.token, &obj_tok_str);
+ h5tools_str_append(buffer, "\"/#%s\"", obj_tok_str);
+ H5free_memory(obj_tok_str);
}
else
h5tools_str_append(buffer, "\"%s\"", obj->objname);
- }
+ }
else {
error_msg("unknown committed type.\n");
h5tools_setstatus(EXIT_FAILURE);
}
return ret_value;
- }
-
+ }
+
if (info->line_ncols > 0)
ncols = info->line_ncols;
-
- switch (type_class) {
- case H5T_INTEGER:
- if (H5Tequal(type, H5T_STD_I8BE) == TRUE) {
- h5tools_str_append(buffer, "H5T_STD_I8BE");
- }
- else if (H5Tequal(type, H5T_STD_I8LE) == TRUE) {
- h5tools_str_append(buffer, "H5T_STD_I8LE");
- }
- else if (H5Tequal(type, H5T_STD_I16BE) == TRUE) {
- h5tools_str_append(buffer, "H5T_STD_I16BE");
- }
- else if (H5Tequal(type, H5T_STD_I16LE) == TRUE) {
- h5tools_str_append(buffer, "H5T_STD_I16LE");
- }
- else if (H5Tequal(type, H5T_STD_I32BE) == TRUE) {
- h5tools_str_append(buffer, "H5T_STD_I32BE");
- }
- else if (H5Tequal(type, H5T_STD_I32LE) == TRUE) {
- h5tools_str_append(buffer, "H5T_STD_I32LE");
- }
- else if (H5Tequal(type, H5T_STD_I64BE) == TRUE) {
- h5tools_str_append(buffer, "H5T_STD_I64BE");
- }
- else if (H5Tequal(type, H5T_STD_I64LE) == TRUE) {
- h5tools_str_append(buffer, "H5T_STD_I64LE");
- }
- else if (H5Tequal(type, H5T_STD_U8BE) == TRUE) {
- h5tools_str_append(buffer, "H5T_STD_U8BE");
- }
- else if (H5Tequal(type, H5T_STD_U8LE) == TRUE) {
- h5tools_str_append(buffer, "H5T_STD_U8LE");
- }
- else if (H5Tequal(type, H5T_STD_U16BE) == TRUE) {
- h5tools_str_append(buffer, "H5T_STD_U16BE");
- }
- else if (H5Tequal(type, H5T_STD_U16LE) == TRUE) {
- h5tools_str_append(buffer, "H5T_STD_U16LE");
- }
- else if (H5Tequal(type, H5T_STD_U32BE) == TRUE) {
- h5tools_str_append(buffer, "H5T_STD_U32BE");
- }
- else if (H5Tequal(type, H5T_STD_U32LE) == TRUE) {
- h5tools_str_append(buffer, "H5T_STD_U32LE");
- }
- else if (H5Tequal(type, H5T_STD_U64BE) == TRUE) {
- h5tools_str_append(buffer, "H5T_STD_U64BE");
- }
- else if (H5Tequal(type, H5T_STD_U64LE) == TRUE) {
- h5tools_str_append(buffer, "H5T_STD_U64LE");
- }
- else if (H5Tequal(type, H5T_NATIVE_SCHAR) == TRUE) {
- h5tools_str_append(buffer, "H5T_NATIVE_SCHAR");
- }
- else if (H5Tequal(type, H5T_NATIVE_UCHAR) == TRUE) {
- h5tools_str_append(buffer, "H5T_NATIVE_UCHAR");
- }
- else if (H5Tequal(type, H5T_NATIVE_SHORT) == TRUE) {
- h5tools_str_append(buffer, "H5T_NATIVE_SHORT");
- }
- else if (H5Tequal(type, H5T_NATIVE_USHORT) == TRUE) {
- h5tools_str_append(buffer, "H5T_NATIVE_USHORT");
- }
- else if (H5Tequal(type, H5T_NATIVE_INT) == TRUE) {
- h5tools_str_append(buffer, "H5T_NATIVE_INT");
- }
- else if (H5Tequal(type, H5T_NATIVE_UINT) == TRUE) {
- h5tools_str_append(buffer, "H5T_NATIVE_UINT");
- }
- else if (H5Tequal(type, H5T_NATIVE_LONG) == TRUE) {
- h5tools_str_append(buffer, "H5T_NATIVE_LONG");
- }
- else if (H5Tequal(type, H5T_NATIVE_ULONG) == TRUE) {
- h5tools_str_append(buffer, "H5T_NATIVE_ULONG");
- }
- else if (H5Tequal(type, H5T_NATIVE_LLONG) == TRUE) {
- h5tools_str_append(buffer, "H5T_NATIVE_LLONG");
- }
- else if (H5Tequal(type, H5T_NATIVE_ULLONG) == TRUE) {
- h5tools_str_append(buffer, "H5T_NATIVE_ULLONG");
- }
- else {
- /* byte order */
- if (H5Tget_size(type) > 1) {
- order = H5Tget_order(type);
- if (H5T_ORDER_LE == order) {
- order_s = " little-endian";
- }
- else if (H5T_ORDER_BE == order) {
- order_s = " big-endian";
- }
- else if (H5T_ORDER_VAX == order) {
- order_s = " mixed-endian";
- }
- else {
- order_s = " unknown-byte-order";
- }
- }
+ switch (type_class) {
+ case H5T_INTEGER:
+ if (H5Tequal(type, H5T_STD_I8BE) == TRUE)
+ h5tools_str_append(buffer, "H5T_STD_I8BE");
+ else if (H5Tequal(type, H5T_STD_I8LE) == TRUE)
+ h5tools_str_append(buffer, "H5T_STD_I8LE");
+ else if (H5Tequal(type, H5T_STD_I16BE) == TRUE)
+ h5tools_str_append(buffer, "H5T_STD_I16BE");
+ else if (H5Tequal(type, H5T_STD_I16LE) == TRUE)
+ h5tools_str_append(buffer, "H5T_STD_I16LE");
+ else if (H5Tequal(type, H5T_STD_I32BE) == TRUE)
+ h5tools_str_append(buffer, "H5T_STD_I32BE");
+ else if (H5Tequal(type, H5T_STD_I32LE) == TRUE)
+ h5tools_str_append(buffer, "H5T_STD_I32LE");
+ else if (H5Tequal(type, H5T_STD_I64BE) == TRUE)
+ h5tools_str_append(buffer, "H5T_STD_I64BE");
+ else if (H5Tequal(type, H5T_STD_I64LE) == TRUE)
+ h5tools_str_append(buffer, "H5T_STD_I64LE");
+ else if (H5Tequal(type, H5T_STD_U8BE) == TRUE)
+ h5tools_str_append(buffer, "H5T_STD_U8BE");
+ else if (H5Tequal(type, H5T_STD_U8LE) == TRUE)
+ h5tools_str_append(buffer, "H5T_STD_U8LE");
+ else if (H5Tequal(type, H5T_STD_U16BE) == TRUE)
+ h5tools_str_append(buffer, "H5T_STD_U16BE");
+ else if (H5Tequal(type, H5T_STD_U16LE) == TRUE)
+ h5tools_str_append(buffer, "H5T_STD_U16LE");
+ else if (H5Tequal(type, H5T_STD_U32BE) == TRUE)
+ h5tools_str_append(buffer, "H5T_STD_U32BE");
+ else if (H5Tequal(type, H5T_STD_U32LE) == TRUE)
+ h5tools_str_append(buffer, "H5T_STD_U32LE");
+ else if (H5Tequal(type, H5T_STD_U64BE) == TRUE)
+ h5tools_str_append(buffer, "H5T_STD_U64BE");
+ else if (H5Tequal(type, H5T_STD_U64LE) == TRUE)
+ h5tools_str_append(buffer, "H5T_STD_U64LE");
+ else if (H5Tequal(type, H5T_NATIVE_SCHAR) == TRUE)
+ h5tools_str_append(buffer, "H5T_NATIVE_SCHAR");
+ else if (H5Tequal(type, H5T_NATIVE_UCHAR) == TRUE)
+ h5tools_str_append(buffer, "H5T_NATIVE_UCHAR");
+ else if (H5Tequal(type, H5T_NATIVE_SHORT) == TRUE)
+ h5tools_str_append(buffer, "H5T_NATIVE_SHORT");
+ else if (H5Tequal(type, H5T_NATIVE_USHORT) == TRUE)
+ h5tools_str_append(buffer, "H5T_NATIVE_USHORT");
+ else if (H5Tequal(type, H5T_NATIVE_INT) == TRUE)
+ h5tools_str_append(buffer, "H5T_NATIVE_INT");
+ else if (H5Tequal(type, H5T_NATIVE_UINT) == TRUE)
+ h5tools_str_append(buffer, "H5T_NATIVE_UINT");
+ else if (H5Tequal(type, H5T_NATIVE_LONG) == TRUE)
+ h5tools_str_append(buffer, "H5T_NATIVE_LONG");
+ else if (H5Tequal(type, H5T_NATIVE_ULONG) == TRUE)
+ h5tools_str_append(buffer, "H5T_NATIVE_ULONG");
+ else if (H5Tequal(type, H5T_NATIVE_LLONG) == TRUE)
+ h5tools_str_append(buffer, "H5T_NATIVE_LLONG");
+ else if (H5Tequal(type, H5T_NATIVE_ULLONG) == TRUE)
+ h5tools_str_append(buffer, "H5T_NATIVE_ULLONG");
else {
- order_s = "";
- }
- /* sign */
- if ((sign = H5Tget_sign(type)) >= 0) {
- if (H5T_SGN_NONE == sign) {
- sign_s = " unsigned";
+ /* byte order */
+ if (H5Tget_size(type) > 1) {
+ order = H5Tget_order(type);
+ if (H5T_ORDER_LE == order)
+ order_s = " little-endian";
+ else if (H5T_ORDER_BE == order)
+ order_s = " big-endian";
+ else if (H5T_ORDER_VAX == order)
+ order_s = " mixed-endian";
+ else
+ order_s = " unknown-byte-order";
}
- else if (H5T_SGN_2 == sign) {
- sign_s = "";
+ else
+ order_s = "";
+
+ /* sign */
+ if ((sign = H5Tget_sign(type)) >= 0) {
+ if (H5T_SGN_NONE == sign)
+ sign_s = " unsigned";
+ else if (H5T_SGN_2 == sign)
+ sign_s = "";
+ else
+ sign_s = " unknown-sign";
}
- else {
+ else
sign_s = " unknown-sign";
- }
+
+ /* print size, order, sign, and precision */
+ h5tools_str_append(buffer, "%zu-bit%s%s integer %zu-bit precision", 8 * H5Tget_size(type),
+ order_s, sign_s, H5Tget_precision(type));
}
+ break;
+
+ case H5T_FLOAT:
+ if (H5Tequal(type, H5T_IEEE_F32BE) == TRUE)
+ h5tools_str_append(buffer, "H5T_IEEE_F32BE");
+ else if (H5Tequal(type, H5T_IEEE_F32LE) == TRUE)
+ h5tools_str_append(buffer, "H5T_IEEE_F32LE");
+ else if (H5Tequal(type, H5T_IEEE_F64BE) == TRUE)
+ h5tools_str_append(buffer, "H5T_IEEE_F64BE");
+ else if (H5Tequal(type, H5T_IEEE_F64LE) == TRUE)
+ h5tools_str_append(buffer, "H5T_IEEE_F64LE");
+ else if (H5Tequal(type, H5T_VAX_F32) == TRUE)
+ h5tools_str_append(buffer, "H5T_VAX_F32");
+ else if (H5Tequal(type, H5T_VAX_F64) == TRUE)
+ h5tools_str_append(buffer, "H5T_VAX_F64");
+ else if (H5Tequal(type, H5T_NATIVE_FLOAT) == TRUE)
+ h5tools_str_append(buffer, "H5T_NATIVE_FLOAT");
+ else if (H5Tequal(type, H5T_NATIVE_DOUBLE) == TRUE)
+ h5tools_str_append(buffer, "H5T_NATIVE_DOUBLE");
else {
- sign_s = " unknown-sign";
+ /* print what the library knows */
+ /* byte order */
+ if (H5Tget_size(type) > 1) {
+ order = H5Tget_order(type);
+ if (H5T_ORDER_LE == order)
+ order_s = " little-endian";
+ else if (H5T_ORDER_BE == order)
+ order_s = " big-endian";
+ else if (H5T_ORDER_VAX == order)
+ order_s = " mixed-endian";
+ else
+ order_s = " unknown-byte-order";
+ }
+ else
+ order_s = "";
+
+ /* print size. byte order, and precision */
+ h5tools_str_append(buffer, "%zu-bit%s floating-point %zu-bit precision",
+ 8 * H5Tget_size(type), order_s, H5Tget_precision(type));
}
+ break;
- /* print size, order, and sign */
- h5tools_str_append(buffer, "%lu-bit%s%s integer",
- (unsigned long) (8 * H5Tget_size(type)), order_s, sign_s);
- }
- break;
+ case H5T_TIME:
+ h5tools_str_append(buffer, "H5T_TIME: not yet implemented");
+ break;
- case H5T_FLOAT:
- if (H5Tequal(type, H5T_IEEE_F32BE) == TRUE) {
- h5tools_str_append(buffer, "H5T_IEEE_F32BE");
- }
- else if (H5Tequal(type, H5T_IEEE_F32LE) == TRUE) {
- h5tools_str_append(buffer, "H5T_IEEE_F32LE");
- }
- else if (H5Tequal(type, H5T_IEEE_F64BE) == TRUE) {
- h5tools_str_append(buffer, "H5T_IEEE_F64BE");
- }
- else if (H5Tequal(type, H5T_IEEE_F64LE) == TRUE) {
- h5tools_str_append(buffer, "H5T_IEEE_F64LE");
- }
- else if (H5Tequal(type, H5T_VAX_F32) == TRUE) {
- h5tools_str_append(buffer, "H5T_VAX_F32");
- }
- else if (H5Tequal(type, H5T_VAX_F64) == TRUE) {
- h5tools_str_append(buffer, "H5T_VAX_F64");
- }
- else if (H5Tequal(type, H5T_NATIVE_FLOAT) == TRUE) {
- h5tools_str_append(buffer, "H5T_NATIVE_FLOAT");
- }
- else if (H5Tequal(type, H5T_NATIVE_DOUBLE) == TRUE) {
- h5tools_str_append(buffer, "H5T_NATIVE_DOUBLE");
-#if H5_SIZEOF_LONG_DOUBLE !=0
- }
- else if (H5Tequal(type, H5T_NATIVE_LDOUBLE) == TRUE) {
- h5tools_str_append(buffer, "H5T_NATIVE_LDOUBLE");
-#endif
- }
- else {
+ case H5T_STRING:
+ /* Make a copy of type in memory in case when TYPE is on disk, the size
+ * will be bigger than in memory. This makes it easier to compare
+ * types in memory. */
+ tmp_type = H5Tcopy(type);
+ size = H5Tget_size(tmp_type);
+ str_pad = H5Tget_strpad(tmp_type);
+ cset = H5Tget_cset(tmp_type);
+ is_vlstr = H5Tis_variable_str(tmp_type);
+
+ curr_pos = ctx->cur_column;
+ h5tools_str_append(buffer, "H5T_STRING %s", h5tools_dump_header_format->strblockbegin);
+ h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
- /* byte order */
- if (H5Tget_size(type) > 1) {
- order = H5Tget_order(type);
- if (H5T_ORDER_LE == order) {
- order_s = " little-endian";
- }
- else if (H5T_ORDER_BE == order) {
- order_s = " big-endian";
- }
- else if (H5T_ORDER_VAX == order) {
- order_s = " mixed-endian";
- }
- else {
- order_s = " unknown-byte-order";
- }
- }
- else {
- order_s = "";
- }
+ ctx->indent_level++;
- /* print size and byte order */
- h5tools_str_append(buffer, "%lu-bit%s floating-point",
- (unsigned long) (8 * H5Tget_size(type)), order_s);
+ ctx->need_prefix = TRUE;
- }
- break;
-
- case H5T_TIME:
- h5tools_str_append(buffer, "H5T_TIME: not yet implemented");
- break;
-
- case H5T_STRING:
- /* Make a copy of type in memory in case when TYPE is on disk, the size
- * will be bigger than in memory. This makes it easier to compare
- * types in memory. */
- tmp_type = H5Tcopy(type);
- size = H5Tget_size(tmp_type);
- str_pad = H5Tget_strpad(tmp_type);
- cset = H5Tget_cset(tmp_type);
- is_vlstr = H5Tis_variable_str(tmp_type);
-
- curr_pos = ctx->cur_column;
- h5tools_str_append(buffer, "H5T_STRING %s", h5tools_dump_header_format->strblockbegin);
- h5tools_render_element(stream, info, ctx, buffer, &curr_pos, ncols, 0, 0);
+ h5tools_str_reset(buffer);
- ctx->indent_level++;
+ if (is_vlstr)
+ h5tools_str_append(buffer, "%s H5T_VARIABLE;", STRSIZE);
+ else
+ h5tools_str_append(buffer, "%s %d;", STRSIZE, (int)size);
+ h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
- ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, 0, 0);
+ ctx->need_prefix = TRUE;
- h5tools_str_reset(buffer);
+ h5tools_str_reset(buffer);
- if (is_vlstr)
- h5tools_str_append(buffer, "%s H5T_VARIABLE;", STRSIZE);
- else
- h5tools_str_append(buffer, "%s %d;", STRSIZE, (int) size);
- h5tools_render_element(stream, info, ctx, buffer, &curr_pos, ncols, 0, 0);
+ h5tools_str_append(buffer, "%s ", STRPAD);
+ switch (str_pad) {
+ case H5T_STR_NULLTERM:
+ h5tools_str_append(buffer, "H5T_STR_NULLTERM;");
+ break;
+ case H5T_STR_NULLPAD:
+ h5tools_str_append(buffer, "H5T_STR_NULLPAD;");
+ break;
+ case H5T_STR_SPACEPAD:
+ h5tools_str_append(buffer, "H5T_STR_SPACEPAD;");
+ break;
+ case H5T_STR_RESERVED_3:
+ case H5T_STR_RESERVED_4:
+ case H5T_STR_RESERVED_5:
+ case H5T_STR_RESERVED_6:
+ case H5T_STR_RESERVED_7:
+ case H5T_STR_RESERVED_8:
+ case H5T_STR_RESERVED_9:
+ case H5T_STR_RESERVED_10:
+ case H5T_STR_RESERVED_11:
+ case H5T_STR_RESERVED_12:
+ case H5T_STR_RESERVED_13:
+ case H5T_STR_RESERVED_14:
+ case H5T_STR_RESERVED_15:
+ h5tools_str_append(buffer, "H5T_STR_UNKNOWN;");
+ break;
+ case H5T_STR_ERROR:
+ h5tools_str_append(buffer, "H5T_STR_ERROR;");
+ break;
+ default:
+ h5tools_str_append(buffer, "ERROR;");
+ break;
+ }
+ h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
- ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, 0, 0);
+ ctx->need_prefix = TRUE;
- h5tools_str_reset(buffer);
+ h5tools_str_reset(buffer);
- h5tools_str_append(buffer, "%s ", STRPAD);
- if (str_pad == H5T_STR_NULLTERM)
- h5tools_str_append(buffer, "H5T_STR_NULLTERM;");
- else if (str_pad == H5T_STR_NULLPAD)
- h5tools_str_append(buffer, "H5T_STR_NULLPAD;");
- else if (str_pad == H5T_STR_SPACEPAD)
- h5tools_str_append(buffer, "H5T_STR_SPACEPAD;");
- else
- h5tools_str_append(buffer, "H5T_STR_ERROR;");
- h5tools_render_element(stream, info, ctx, buffer, &curr_pos, ncols, 0, 0);
+ h5tools_str_append(buffer, "%s ", CSET);
- ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, 0, 0);
+ switch (cset) {
+ case H5T_CSET_ASCII:
+ h5tools_str_append(buffer, "H5T_CSET_ASCII;");
+ break;
+ case H5T_CSET_UTF8:
+ h5tools_str_append(buffer, "H5T_CSET_UTF8;");
+ break;
+ case H5T_CSET_RESERVED_2:
+ case H5T_CSET_RESERVED_3:
+ case H5T_CSET_RESERVED_4:
+ case H5T_CSET_RESERVED_5:
+ case H5T_CSET_RESERVED_6:
+ case H5T_CSET_RESERVED_7:
+ case H5T_CSET_RESERVED_8:
+ case H5T_CSET_RESERVED_9:
+ case H5T_CSET_RESERVED_10:
+ case H5T_CSET_RESERVED_11:
+ case H5T_CSET_RESERVED_12:
+ case H5T_CSET_RESERVED_13:
+ case H5T_CSET_RESERVED_14:
+ case H5T_CSET_RESERVED_15:
+ h5tools_str_append(buffer, "H5T_CSET_UNKNOWN;");
+ break;
+ case H5T_CSET_ERROR:
+ h5tools_str_append(buffer, "H5T_CSET_ERROR;");
+ break;
+ default:
+ h5tools_str_append(buffer, "ERROR;");
+ break;
+ }
+ h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
- h5tools_str_reset(buffer);
+ ctx->need_prefix = TRUE;
- h5tools_str_append(buffer, "%s ", CSET);
+ h5tools_str_reset(buffer);
- if (cset == H5T_CSET_ASCII)
- h5tools_str_append(buffer, "H5T_CSET_ASCII;");
- else
- h5tools_str_append(buffer, "unknown_cset;");
- h5tools_render_element(stream, info, ctx, buffer, &curr_pos, ncols, 0, 0);
+ str_type = H5Tcopy(H5T_C_S1);
+ if (is_vlstr)
+ H5Tset_size(str_type, H5T_VARIABLE);
+ else
+ H5Tset_size(str_type, size);
+ H5Tset_cset(str_type, cset);
+ H5Tset_strpad(str_type, str_pad);
- ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, 0, 0);
+ h5tools_str_append(buffer, "%s ", CTYPE);
- h5tools_str_reset(buffer);
+ /* Check C variable-length string first. Are the two types equal? */
+ if (H5Tequal(tmp_type, str_type)) {
+ h5tools_str_append(buffer, "H5T_C_S1;");
+ goto found_string_type;
+ }
- str_type = H5Tcopy(H5T_C_S1);
- if (is_vlstr)
- H5Tset_size(str_type, H5T_VARIABLE);
- else
+ /* Change the endianness and see if they're equal. */
+ order = H5Tget_order(tmp_type);
+ if (order == H5T_ORDER_LE) {
+ if (H5Tset_order(str_type, H5T_ORDER_LE) < 0)
+ H5TOOLS_ERROR((-1), "H5Tset_order failed");
+ } /* end if */
+ else if (order == H5T_ORDER_BE) {
+ if (H5Tset_order(str_type, H5T_ORDER_BE) < 0)
+ H5TOOLS_ERROR((-1), "H5Tset_order failed");
+ } /* end if */
+
+ if (H5Tequal(tmp_type, str_type)) {
+ h5tools_str_append(buffer, "H5T_C_S1;");
+ goto found_string_type;
+ }
+
+ /* If not equal to C variable-length string, check Fortran type. */
+ if (H5Tclose(str_type) < 0)
+ H5TOOLS_ERROR((-1), "H5Tclose failed");
+ str_type = H5Tcopy(H5T_FORTRAN_S1);
+
+ H5Tset_cset(str_type, cset);
H5Tset_size(str_type, size);
- H5Tset_cset(str_type, cset);
- H5Tset_strpad(str_type, str_pad);
+ H5Tset_strpad(str_type, str_pad);
+
+ /* Are the two types equal? */
+ if (H5Tequal(tmp_type, str_type)) {
+ h5tools_str_append(buffer, "H5T_FORTRAN_S1;");
+ goto found_string_type;
+ }
- h5tools_str_append(buffer, "%s ", CTYPE);
+ /* Change the endianness and see if they're equal. */
+ order = H5Tget_order(tmp_type);
+ if (order == H5T_ORDER_LE) {
+ if (H5Tset_order(str_type, H5T_ORDER_LE) < 0)
+ H5TOOLS_ERROR((-1), "H5Tset_order failed");
+ } /* end if */
+ else if (order == H5T_ORDER_BE) {
+ if (H5Tset_order(str_type, H5T_ORDER_BE) < 0)
+ H5TOOLS_ERROR((-1), "H5Tset_order failed");
+ } /* end if */
- /* Check C variable-length string first. Are the two types equal? */
- if (H5Tequal(tmp_type, str_type)) {
- h5tools_str_append(buffer, "H5T_C_S1;");
- goto done;
- }
+ if (H5Tequal(tmp_type, str_type)) {
+ h5tools_str_append(buffer, "H5T_FORTRAN_S1;");
+ goto found_string_type;
+ }
- /* Change the endianness and see if they're equal. */
- order = H5Tget_order(tmp_type);
- if (order == H5T_ORDER_LE)
- H5Tset_order(str_type, H5T_ORDER_LE);
- else if (order == H5T_ORDER_BE)
- H5Tset_order(str_type, H5T_ORDER_BE);
+ /* Type doesn't match any of above. */
+ h5tools_str_append(buffer, "unknown_one_character_type;");
- if (H5Tequal(tmp_type, str_type)) {
- h5tools_str_append(buffer, "H5T_C_S1;");
- goto done;
- }
+found_string_type:
+ h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
+ ctx->indent_level--;
- /* If not equal to C variable-length string, check Fortran type. */
- if(H5Tclose(str_type) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
- str_type = H5Tcopy(H5T_FORTRAN_S1);
+ ctx->need_prefix = TRUE;
- H5Tset_cset(str_type, cset);
- H5Tset_size(str_type, size);
- H5Tset_strpad(str_type, str_pad);
+ h5tools_str_reset(buffer);
+ if (H5Tclose(str_type) < 0)
+ H5TOOLS_ERROR((-1), "H5Tclose failed");
+ if (H5Tclose(tmp_type) < 0)
+ H5TOOLS_ERROR((-1), "H5Tclose failed");
- /* Are the two types equal? */
- if (H5Tequal(tmp_type, str_type)) {
- h5tools_str_append(buffer, "H5T_FORTRAN_S1;");
- goto done;
- }
+ h5tools_str_append(buffer, "%s", h5tools_dump_header_format->strblockend);
+ break;
- /* Change the endianness and see if they're equal. */
- order = H5Tget_order(tmp_type);
- if (order == H5T_ORDER_LE)
- H5Tset_order(str_type, H5T_ORDER_LE);
- else if (order == H5T_ORDER_BE)
- H5Tset_order(str_type, H5T_ORDER_BE);
+ case H5T_BITFIELD:
+ if (H5Tequal(type, H5T_STD_B8BE) == TRUE)
+ h5tools_str_append(buffer, "H5T_STD_B8BE");
+ else if (H5Tequal(type, H5T_STD_B8LE) == TRUE)
+ h5tools_str_append(buffer, "H5T_STD_B8LE");
+ else if (H5Tequal(type, H5T_STD_B16BE) == TRUE)
+ h5tools_str_append(buffer, "H5T_STD_B16BE");
+ else if (H5Tequal(type, H5T_STD_B16LE) == TRUE)
+ h5tools_str_append(buffer, "H5T_STD_B16LE");
+ else if (H5Tequal(type, H5T_STD_B32BE) == TRUE)
+ h5tools_str_append(buffer, "H5T_STD_B32BE");
+ else if (H5Tequal(type, H5T_STD_B32LE) == TRUE)
+ h5tools_str_append(buffer, "H5T_STD_B32LE");
+ else if (H5Tequal(type, H5T_STD_B64BE) == TRUE)
+ h5tools_str_append(buffer, "H5T_STD_B64BE");
+ else if (H5Tequal(type, H5T_STD_B64LE) == TRUE)
+ h5tools_str_append(buffer, "H5T_STD_B64LE");
+ else
+ h5tools_str_append(buffer, "undefined bitfield");
+ break;
- if (H5Tequal(tmp_type, str_type)) {
- h5tools_str_append(buffer, "H5T_FORTRAN_S1;");
- goto done;
- }
+ case H5T_OPAQUE:
+ h5tools_str_append(buffer, "H5T_OPAQUE %s", h5tools_dump_header_format->structblockbegin);
+ h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
+ ctx->indent_level++;
+ {
+ char *ttag;
- /* Type doesn't match any of above. */
- h5tools_str_append(buffer, "unknown_one_character_type;");
+ if (NULL == (ttag = H5Tget_tag(type)))
+ H5TOOLS_THROW((-1), "H5Tget_tag failed");
- done:
- h5tools_render_element(stream, info, ctx, buffer, &curr_pos, ncols, 0, 0);
- ctx->indent_level--;
+ ctx->need_prefix = TRUE;
- ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, 0, 0);
+ h5tools_str_reset(buffer);
+ h5tools_str_append(buffer, "OPAQUE_TAG \"%s\";", ttag);
+ h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
- h5tools_str_reset(buffer);
- if(H5Tclose(str_type) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
- if(H5Tclose(tmp_type) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+ H5free_memory(ttag);
- h5tools_str_append(buffer, "%s", h5tools_dump_header_format->strblockend);
- break;
+ if ((size = H5Tget_size(type)) <= 0) {
+ ctx->need_prefix = TRUE;
- case H5T_BITFIELD:
- if (H5Tequal(type, H5T_STD_B8BE) == TRUE) {
- h5tools_str_append(buffer, "H5T_STD_B8BE");
- }
- else if (H5Tequal(type, H5T_STD_B8LE) == TRUE) {
- h5tools_str_append(buffer, "H5T_STD_B8LE");
- }
- else if (H5Tequal(type, H5T_STD_B16BE) == TRUE) {
- h5tools_str_append(buffer, "H5T_STD_B16BE");
- }
- else if (H5Tequal(type, H5T_STD_B16LE) == TRUE) {
- h5tools_str_append(buffer, "H5T_STD_B16LE");
- }
- else if (H5Tequal(type, H5T_STD_B32BE) == TRUE) {
- h5tools_str_append(buffer, "H5T_STD_B32BE");
- }
- else if (H5Tequal(type, H5T_STD_B32LE) == TRUE) {
- h5tools_str_append(buffer, "H5T_STD_B32LE");
- }
- else if (H5Tequal(type, H5T_STD_B64BE) == TRUE) {
- h5tools_str_append(buffer, "H5T_STD_B64BE");
- }
- else if (H5Tequal(type, H5T_STD_B64LE) == TRUE) {
- h5tools_str_append(buffer, "H5T_STD_B64LE");
- }
- else {
- h5tools_str_append(buffer, "undefined bitfield");
- }
- break;
+ h5tools_str_reset(buffer);
+ h5tools_str_append(buffer, "OPAQUE_SIZE \"%zu\";", size);
+ h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
+ }
+ }
+ ctx->indent_level--;
- case H5T_OPAQUE:
- h5tools_str_append(buffer, "H5T_OPAQUE %s", h5tools_dump_header_format->structblockbegin);
- h5tools_render_element(stream, info, ctx, buffer, &curr_pos, ncols, 0, 0);
- ctx->indent_level++;
- {
- char *ttag = H5Tget_tag(type);
-
- ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, 0, 0);
-
- h5tools_str_reset(buffer);
- h5tools_str_append(buffer, "OPAQUE_TAG \"%s\";", ttag);
- h5tools_render_element(stream, info, ctx, buffer, &curr_pos, ncols, 0, 0);
-
- if (ttag)
- HDfree(ttag);
- }
- ctx->indent_level--;
+ ctx->need_prefix = TRUE;
- ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, 0, 0);
+ h5tools_str_reset(buffer);
+ h5tools_str_append(buffer, "%s", h5tools_dump_header_format->structblockend);
+ break;
- h5tools_str_reset(buffer);
- h5tools_str_append(buffer, "%s", h5tools_dump_header_format->structblockend);
- break;
+ case H5T_COMPOUND:
+ if ((snmembers = H5Tget_nmembers(type)) < 0)
+ H5TOOLS_THROW((-1), "H5Tget_nmembers failed");
+ nmembers = (unsigned)snmembers;
- case H5T_COMPOUND:
- if((snmembers = H5Tget_nmembers(type)) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_nmembers failed");
- nmembers = (unsigned)snmembers;
-
- h5tools_str_append(buffer, "H5T_COMPOUND %s", h5tools_dump_header_format->structblockbegin);
- h5tools_render_element(stream, info, ctx, buffer, &curr_pos, ncols, 0, 0);
+ h5tools_str_append(buffer, "H5T_COMPOUND %s", h5tools_dump_header_format->structblockbegin);
+ h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
- ctx->indent_level++;
- for (i = 0; i < nmembers; i++) {
- mname = H5Tget_member_name(type, i);
- if((mtype = H5Tget_member_type(type, i))>=0) {
- ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, 0, 0);
+ ctx->indent_level++;
+ for (i = 0; i < nmembers; i++) {
+ mname = H5Tget_member_name(type, i);
+ if ((mtype = H5Tget_member_type(type, i)) >= 0) {
+ ctx->need_prefix = TRUE;
- h5tools_str_reset(buffer);
- h5tools_print_datatype(stream, buffer, info, ctx, mtype, TRUE);
+ h5tools_str_reset(buffer);
+ h5tools_print_datatype(stream, buffer, info, ctx, mtype, TRUE);
- h5tools_str_append(buffer, " \"%s\";", mname);
- h5tools_render_element(stream, info, ctx, buffer, &curr_pos, ncols, 0, 0);
- if(H5Tclose(mtype) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+ h5tools_str_append(buffer, " \"%s\";", mname);
+ h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
+ if (H5Tclose(mtype) < 0)
+ H5TOOLS_ERROR((-1), "H5Tclose failed");
+ }
+ else
+ H5TOOLS_ERROR((-1), "H5Tget_member_type failed");
+ H5free_memory(mname);
}
- else
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tget_member_type failed");
- HDfree(mname);
- }
- ctx->indent_level--;
+ ctx->indent_level--;
- ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, 0, 0);
+ ctx->need_prefix = TRUE;
- h5tools_str_reset(buffer);
- h5tools_str_append(buffer, "%s", h5tools_dump_header_format->structblockend);
- break;
+ h5tools_str_reset(buffer);
+ h5tools_str_append(buffer, "%s", h5tools_dump_header_format->structblockend);
+ break;
- case H5T_REFERENCE:
- h5tools_str_append(buffer, "H5T_REFERENCE");
- if (H5Tequal(type, H5T_STD_REF_DSETREG) == TRUE) {
- h5tools_str_append(buffer, " { H5T_STD_REF_DSETREG }");
- }
- else {
- h5tools_str_append(buffer, " { H5T_STD_REF_OBJECT }");
- }
- break;
+ case H5T_REFERENCE:
+ h5tools_str_append(buffer, "H5T_REFERENCE");
+ if (H5Tequal(type, H5T_STD_REF_DSETREG) == TRUE) {
+ h5tools_str_append(buffer, " { H5T_STD_REF_DSETREG }");
+ }
+ else if (H5Tequal(type, H5T_STD_REF_OBJ) == TRUE) {
+ h5tools_str_append(buffer, " { H5T_STD_REF_OBJECT }");
+ }
+ else if (H5Tequal(type, H5T_STD_REF) == TRUE) {
+ h5tools_str_append(buffer, " { H5T_STD_REF }");
+ }
+ else {
+ h5tools_str_append(buffer, " { UNDEFINED }");
+ }
+ break;
- case H5T_ENUM:
- if((super = H5Tget_super(type)) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_nmembers failed");
+ case H5T_ENUM:
+ if ((super = H5Tget_super(type)) < 0)
+ H5TOOLS_THROW((-1), "H5Tget_super failed");
- h5tools_str_append(buffer, "H5T_ENUM %s", h5tools_dump_header_format->enumblockbegin);
- h5tools_render_element(stream, info, ctx, buffer, &curr_pos, ncols, 0, 0);
- ctx->indent_level++;
+ h5tools_str_append(buffer, "H5T_ENUM %s", h5tools_dump_header_format->enumblockbegin);
+ h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
+ ctx->indent_level++;
- ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, 0, 0);
+ ctx->need_prefix = TRUE;
- h5tools_str_reset(buffer);
- h5tools_print_datatype(stream, buffer, info, ctx, super, TRUE);
-
- if(H5Tclose(super) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+ h5tools_str_reset(buffer);
+ h5tools_print_datatype(stream, buffer, info, ctx, super, TRUE);
- h5tools_str_append(buffer, ";");
- h5tools_render_element(stream, info, ctx, buffer, &curr_pos, ncols, 0, 0);
+ if (H5Tclose(super) < 0)
+ H5TOOLS_ERROR((-1), "H5Tclose failed");
- h5tools_print_enum(stream, buffer, info, ctx, type);
+ h5tools_str_append(buffer, ";");
+ h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
- ctx->indent_level--;
+ h5tools_print_enum(stream, buffer, info, ctx, type);
- ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, 0, 0);
+ ctx->indent_level--;
- h5tools_str_reset(buffer);
- h5tools_str_append(buffer, "%s", h5tools_dump_header_format->enumblockend);
+ ctx->need_prefix = TRUE;
- break;
+ h5tools_str_reset(buffer);
+ h5tools_str_append(buffer, "%s", h5tools_dump_header_format->enumblockend);
+
+ break;
- case H5T_VLEN:
- if((super = H5Tget_super(type)) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_nmembers failed");
+ case H5T_VLEN:
+ if ((super = H5Tget_super(type)) < 0)
+ H5TOOLS_THROW((-1), "H5Tget_super failed");
- h5tools_str_append(buffer, "H5T_VLEN %s ", h5tools_dump_header_format->vlenblockbegin);
+ h5tools_str_append(buffer, "H5T_VLEN %s ", h5tools_dump_header_format->vlenblockbegin);
- h5tools_print_datatype(stream, buffer, info, ctx, super, TRUE);
+ h5tools_print_datatype(stream, buffer, info, ctx, super, TRUE);
- if(H5Tclose(super) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
+ if (H5Tclose(super) < 0)
+ H5TOOLS_ERROR((-1), "H5Tclose failed");
- h5tools_str_append(buffer, "%s", h5tools_dump_header_format->vlenblockend);
+ h5tools_str_append(buffer, "%s", h5tools_dump_header_format->vlenblockend);
- break;
+ break;
- case H5T_ARRAY:
- h5tools_str_append(buffer, "H5T_ARRAY { ");
+ case H5T_ARRAY:
+ h5tools_str_append(buffer, "H5T_ARRAY { ");
- /* Get array information */
- if((sndims = H5Tget_array_ndims(type)) >= 0) {
- unsigned ndims = (unsigned)sndims;
+ /* Get array information */
+ if ((sndims = H5Tget_array_ndims(type)) >= 0) {
+ unsigned ndims = (unsigned)sndims;
- if(H5Tget_array_dims2(type, dims) >= 0) {
- /* Print array dimensions */
- for (i = 0; i < ndims; i++)
- h5tools_str_append(buffer, "[" HSIZE_T_FORMAT "]", dims[i]);
+ if (H5Tget_array_dims2(type, dims) >= 0) {
+ /* Print array dimensions */
+ for (i = 0; i < ndims; i++)
+ h5tools_str_append(buffer, "[%" PRIuHSIZE "]", dims[i]);
- h5tools_str_append(buffer, " ");
+ h5tools_str_append(buffer, " ");
+ }
+ else
+ H5TOOLS_ERROR((-1), "H5Tget_array_dims2 failed");
}
else
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tget_array_dims2 failed");
- }
- else
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tget_array_ndims failed");
-
- /* Get array base type */
- if((super = H5Tget_super(type)) >= 0) {
- /* Print base type */
- h5tools_print_datatype(stream, buffer, info, ctx, super, TRUE);
- /* Close array base type */
- if(H5Tclose(super) < 0)
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
- }
- else
- HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tget_super failed");
+ H5TOOLS_ERROR((-1), "H5Tget_array_ndims failed");
+
+ /* Get array base type */
+ if ((super = H5Tget_super(type)) >= 0) {
+ /* Print base type */
+ h5tools_print_datatype(stream, buffer, info, ctx, super, TRUE);
+ /* Close array base type */
+ if (H5Tclose(super) < 0)
+ H5TOOLS_ERROR((-1), "H5Tclose failed");
+ }
+ else
+ H5TOOLS_ERROR((-1), "H5Tget_super failed");
- h5tools_str_append(buffer, " }");
+ h5tools_str_append(buffer, " }");
- break;
+ break;
- default:
- h5tools_str_append(buffer, "unknown datatype");
- break;
+ case H5T_NO_CLASS:
+ case H5T_NCLASSES:
+ default:
+ h5tools_str_append(buffer, "unknown datatype");
+ break;
}
-CATCH
+ CATCH
+ H5TOOLS_ENDDEBUG(" ");
return ret_value;
}
@@ -2427,75 +2656,77 @@ CATCH
*
* In/Out: h5tools_str_t *buffer
* h5tools_context_t *ctx
- *
*-------------------------------------------------------------------------
*/
int
-h5tools_print_dataspace(FILE *stream, h5tools_str_t *buffer, const h5tool_format_t *info,
- h5tools_context_t *ctx, hid_t space)
+h5tools_print_dataspace(h5tools_str_t *buffer, hid_t space)
{
- HERR_INIT(int, SUCCEED)
hsize_t size[H5TOOLS_DUMP_MAX_RANK];
hsize_t maxsize[H5TOOLS_DUMP_MAX_RANK];
- int ndims = -1;
+ int ndims = -1;
H5S_class_t space_type = -1;
+ hbool_t past_catch = FALSE;
int i;
+ int ret_value = 0;
- if((ndims = H5Sget_simple_extent_dims(space, size, maxsize)) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
-
- if((space_type = H5Sget_simple_extent_type(space)) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_type failed");
+ H5TOOLS_START_DEBUG(" ");
+ if ((ndims = H5Sget_simple_extent_dims(space, size, maxsize)) < 0)
+ H5TOOLS_THROW((-1), "H5Sget_simple_extent_dims failed");
- switch(space_type) {
- case H5S_SCALAR:
- /* scalar dataspace */
- h5tools_str_append(buffer, "%s %s", h5tools_dump_header_format->dataspacedescriptionbegin, S_SCALAR);
- break;
+ if ((space_type = H5Sget_simple_extent_type(space)) < 0)
+ H5TOOLS_THROW((-1), "H5Sget_simple_extent_type failed");
- case H5S_SIMPLE:
- /* simple dataspace */
- h5tools_str_append(buffer, "%s %s { %s " HSIZE_T_FORMAT,
- h5tools_dump_header_format->dataspacedescriptionbegin, S_SIMPLE,
- h5tools_dump_header_format->dataspacedimbegin, size[0]);
+ switch (space_type) {
+ case H5S_SCALAR:
+ /* scalar dataspace */
+ h5tools_str_append(buffer, "%s %s", h5tools_dump_header_format->dataspacedescriptionbegin,
+ S_SCALAR);
+ break;
- for(i = 1; i < ndims; i++)
- h5tools_str_append(buffer, ", " HSIZE_T_FORMAT, size[i]);
+ case H5S_SIMPLE:
+ /* simple dataspace */
+ h5tools_str_append(buffer, "%s %s { %s %" PRIuHSIZE,
+ h5tools_dump_header_format->dataspacedescriptionbegin, S_SIMPLE,
+ h5tools_dump_header_format->dataspacedimbegin, size[0]);
- h5tools_str_append(buffer, " %s / ", h5tools_dump_header_format->dataspacedimend);
+ for (i = 1; i < ndims; i++)
+ h5tools_str_append(buffer, ", %" PRIuHSIZE, size[i]);
- if(maxsize[0] == H5S_UNLIMITED)
- h5tools_str_append(buffer, "%s %s",
- h5tools_dump_header_format->dataspacedimbegin, "H5S_UNLIMITED");
- else
- h5tools_str_append(buffer, "%s " HSIZE_T_FORMAT,
- h5tools_dump_header_format->dataspacedimbegin, maxsize[0]);
+ h5tools_str_append(buffer, " %s / ", h5tools_dump_header_format->dataspacedimend);
- for(i = 1; i < ndims; i++)
- if(maxsize[i] == H5S_UNLIMITED)
- h5tools_str_append(buffer, ", %s", "H5S_UNLIMITED");
+ if (maxsize[0] == H5S_UNLIMITED)
+ h5tools_str_append(buffer, "%s %s", h5tools_dump_header_format->dataspacedimbegin,
+ "H5S_UNLIMITED");
else
- h5tools_str_append(buffer, ", " HSIZE_T_FORMAT, maxsize[i]);
+ h5tools_str_append(buffer, "%s %" PRIuHSIZE, h5tools_dump_header_format->dataspacedimbegin,
+ maxsize[0]);
- h5tools_str_append(buffer, " %s }", h5tools_dump_header_format->dataspacedimend);
- break;
+ for (i = 1; i < ndims; i++)
+ if (maxsize[i] == H5S_UNLIMITED)
+ h5tools_str_append(buffer, ", %s", "H5S_UNLIMITED");
+ else
+ h5tools_str_append(buffer, ", %" PRIuHSIZE, maxsize[i]);
+
+ h5tools_str_append(buffer, " %s }", h5tools_dump_header_format->dataspacedimend);
+ break;
- case H5S_NULL:
- /* null dataspace */
- h5tools_str_append(buffer, "%s %s", h5tools_dump_header_format->dataspacedescriptionbegin, S_NULL);
- break;
+ case H5S_NULL:
+ /* null dataspace */
+ h5tools_str_append(buffer, "%s %s", h5tools_dump_header_format->dataspacedescriptionbegin,
+ S_NULL);
+ break;
- case H5S_NO_CLASS:
- default:
- h5tools_str_append(buffer, "%s unknown dataspace %s\n", BEGIN, END);
- break;
+ case H5S_NO_CLASS:
+ default:
+ h5tools_str_append(buffer, "%s unknown dataspace %s\n", BEGIN, END);
+ break;
} /* end switch */
-CATCH
+ CATCH
+ H5TOOLS_ENDDEBUG(" ");
return ret_value;
}
-
/*-------------------------------------------------------------------------
* Function: print_enum
*
@@ -2508,38 +2739,38 @@ CATCH
*
*-----------------------------------------------------------------------*/
int
-h5tools_print_enum(FILE *stream, h5tools_str_t *buffer, const h5tool_format_t *info,
- h5tools_context_t *ctx, hid_t type)
+h5tools_print_enum(FILE *stream, h5tools_str_t *buffer, const h5tool_format_t *info, h5tools_context_t *ctx,
+ hid_t type)
{
- HERR_INIT(int, SUCCEED)
- char **name = NULL; /*member names */
+ char **name = NULL; /*member names */
unsigned char *value = NULL; /*value array */
- unsigned char *copy = NULL; /*a pointer to value array */
unsigned i;
- unsigned nmembs = 0; /*number of members */
+ unsigned nmembs = 0; /*number of members */
int snmembs;
- int nchars; /*number of output characters */
- hid_t super = -1; /*enum base integer type */
- hid_t native = -1; /*native integer datatype */
- H5T_sign_t sign_type; /*sign of value type */
- size_t type_size; /*value type size */
- size_t dst_size; /*destination value type size */
- size_t ncols = 80; /*available output width */
- hsize_t curr_pos = 0; /* total data element position */
-
+ hid_t super = H5I_INVALID_HID; /*enum base integer type */
+ hid_t native = H5I_INVALID_HID; /*native integer datatype */
+ H5T_sign_t sign_type; /*sign of value type */
+ size_t type_size; /*value type size */
+ size_t dst_size; /*destination value type size */
+ size_t ncols = 80; /*available output width */
+ hsize_t curr_pos = 0; /* total data element position */
+ hbool_t past_catch = FALSE;
+ int ret_value = 0;
+
+ H5TOOLS_START_DEBUG(" ");
if (info->line_ncols > 0)
ncols = info->line_ncols;
-
- if((snmembs = H5Tget_nmembers(type)) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_nmembers failed");
+
+ if ((snmembs = H5Tget_nmembers(type)) < 0)
+ H5TOOLS_THROW((-1), "H5Tget_nmembers failed");
nmembs = (unsigned)snmembs;
HDassert(nmembs > 0);
- if((super = H5Tget_super(type)) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_super failed");
+ if ((super = H5Tget_super(type)) < 0)
+ H5TOOLS_THROW((-1), "H5Tget_super failed");
- if((type_size = H5Tget_size(type)) <= 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size(type) failed");
+ if ((type_size = H5Tget_size(type)) <= 0)
+ H5TOOLS_THROW((-1), "H5Tget_size(type) failed");
/*
* Determine what datatype to use for the native values. To simplify
@@ -2548,12 +2779,12 @@ h5tools_print_enum(FILE *stream, h5tools_str_t *buffer, const h5tool_format_t *i
* 2. unsigned long long -- the largest native unsigned integer
* 3. raw format
*/
- if(type_size <= sizeof(long long)) {
+ if (type_size <= sizeof(long long)) {
dst_size = sizeof(long long);
- if((sign_type = H5Tget_sign(type))<0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_sign failed");
- if(H5T_SGN_NONE == sign_type)
+ if ((sign_type = H5Tget_sign(type)) < 0)
+ H5TOOLS_THROW((-1), "H5Tget_sign failed");
+ if (H5T_SGN_NONE == sign_type)
native = H5T_NATIVE_ULLONG;
else
native = H5T_NATIVE_LLONG;
@@ -2562,21 +2793,21 @@ h5tools_print_enum(FILE *stream, h5tools_str_t *buffer, const h5tool_format_t *i
dst_size = type_size;
/* Get the names and raw values of all members */
- if(NULL == (name = (char **)HDcalloc(nmembs, sizeof(char *))))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for member name");
- if(NULL == (value = (unsigned char *)HDcalloc(nmembs, MAX(type_size, dst_size))))
- H5E_THROW(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for member value");
+ if (NULL == (name = (char **)HDcalloc((size_t)nmembs, sizeof(char *))))
+ H5TOOLS_THROW((-1), "Could not allocate buffer for member name");
+ if (NULL == (value = (unsigned char *)HDcalloc((size_t)nmembs, MAX(type_size, dst_size))))
+ H5TOOLS_THROW((-1), "Could not allocate buffer for member value");
for (i = 0; i < nmembs; i++) {
name[i] = H5Tget_member_name(type, i);
- if(H5Tget_member_value(type, i, value + i * type_size) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_member_value failed");
+ if (H5Tget_member_value(type, i, value + i * type_size) < 0)
+ H5TOOLS_THROW((-1), "H5Tget_member_value failed");
}
/* Convert values to native datatype */
if (native > 0)
- if(H5Tconvert(super, native, nmembs, value, NULL, H5P_DEFAULT) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tconvert failed");
+ if (H5Tconvert(super, native, (size_t)nmembs, value, NULL, H5P_DEFAULT) < 0)
+ H5TOOLS_THROW((-1), "H5Tconvert failed");
/*
* Sort members by increasing value
@@ -2585,12 +2816,14 @@ h5tools_print_enum(FILE *stream, h5tools_str_t *buffer, const h5tool_format_t *i
/* Print members */
for (i = 0; i < nmembs; i++) {
+ int nchars; /*number of output characters */
+
ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, 0, 0);
+ h5tools_simple_prefix(stream, info, ctx, (hsize_t)0, 0);
h5tools_str_reset(buffer);
h5tools_str_append(buffer, "\"%s\"", name[i]);
- nchars = HDstrlen(name[i]);
+ nchars = (int)HDstrlen(name[i]);
h5tools_str_append(buffer, "%*s ", MAX(0, 16 - nchars), "");
if (native < 0) {
@@ -2602,40 +2835,41 @@ h5tools_print_enum(FILE *stream, h5tools_str_t *buffer, const h5tool_format_t *i
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);
}
h5tools_str_append(buffer, ";");
- h5tools_render_element(stream, info, ctx, buffer, &curr_pos, ncols, 0, 0);
+ h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
}
-CATCH
- if(name) {
+ CATCH
+ if (name) {
/* Release resources */
- for(i = 0; i < nmembs; i++)
- if(name[i])
- HDfree(name[i]);
+ for (i = 0; i < nmembs; i++)
+ if (name[i])
+ H5free_memory(name[i]);
HDfree(name);
} /* end if */
- if(value)
+ if (value)
HDfree(value);
- if(super >= 0 && H5Tclose(super) < 0)
- H5E_THROW(FAIL, H5E_tools_min_id_g, "Could not close datatype's super class");
+ if (super >= 0 && H5Tclose(super) < 0)
+ H5TOOLS_THROW((-1), "Could not close datatype's super class");
- if(0 == nmembs)
+ if (0 == nmembs)
h5tools_str_append(buffer, "\n<empty>");
+ H5TOOLS_ENDDEBUG(" ");
return ret_value;
}
@@ -2651,16 +2885,15 @@ CATCH
*-------------------------------------------------------------------------
*/
void
-h5tools_dump_datatype(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx, hid_t type)
+h5tools_dump_datatype(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t type)
{
- h5tools_str_t buffer; /* string into which to render */
- size_t ncols = 80; /* available output width */
- hsize_t curr_pos = ctx->sm_pos; /* total data element position */
- /* pass to the prefix in h5tools_simple_prefix the total position
- * instead of the current stripmine position i; this is necessary
- * to print the array indices
- */
+ h5tools_str_t buffer; /* string into which to render */
+ size_t ncols = 80; /* available output width */
+ hsize_t curr_pos = ctx->sm_pos; /* total data element position */
+ /* pass to the prefix in h5tools_simple_prefix the total position
+ * instead of the current stripmine position i; this is necessary
+ * to print the array indices
+ */
/* setup */
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
@@ -2669,11 +2902,10 @@ h5tools_dump_datatype(FILE *stream, const h5tool_format_t *info,
ncols = info->line_ncols;
ctx->need_prefix = TRUE;
-
+
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s %s ",
- h5tools_dump_header_format->datatypebegin,
- h5tools_dump_header_format->datatypeblockbegin);
+ h5tools_str_append(&buffer, "%s %s ", h5tools_dump_header_format->datatypebegin,
+ h5tools_dump_header_format->datatypeblockbegin);
h5tools_print_datatype(stream, &buffer, info, ctx, type, TRUE);
if (HDstrlen(h5tools_dump_header_format->datatypeblockend)) {
h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datatypeblockend);
@@ -2683,7 +2915,7 @@ h5tools_dump_datatype(FILE *stream, const h5tool_format_t *info,
if (HDstrlen(h5tools_dump_header_format->datatypeend))
h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datatypeend);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
h5tools_str_close(&buffer);
}
@@ -2691,7 +2923,7 @@ h5tools_dump_datatype(FILE *stream, const h5tool_format_t *info,
/*-------------------------------------------------------------------------
* Function: dump_dataspace
*
- * Purpose: Dump the dataspace.
+ * Purpose: Dump the dataspace.
*
* Return: void
*
@@ -2699,16 +2931,15 @@ h5tools_dump_datatype(FILE *stream, const h5tool_format_t *info,
*-------------------------------------------------------------------------
*/
void
-h5tools_dump_dataspace(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx, hid_t type)
+h5tools_dump_dataspace(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t type)
{
- h5tools_str_t buffer; /* string into which to render */
- size_t ncols = 80; /* available output width */
- hsize_t curr_pos = ctx->sm_pos; /* total data element position */
- /* pass to the prefix in h5tools_simple_prefix the total position
- * instead of the current stripmine position i; this is necessary
- * to print the array indices
- */
+ h5tools_str_t buffer; /* string into which to render */
+ size_t ncols = 80; /* available output width */
+ hsize_t curr_pos = ctx->sm_pos; /* total data element position */
+ /* pass to the prefix in h5tools_simple_prefix the total position
+ * instead of the current stripmine position i; this is necessary
+ * to print the array indices
+ */
/* setup */
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
@@ -2717,12 +2948,11 @@ h5tools_dump_dataspace(FILE *stream, const h5tool_format_t *info,
ncols = info->line_ncols;
ctx->need_prefix = TRUE;
-
+
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s ",
- h5tools_dump_header_format->dataspacebegin);
+ h5tools_str_append(&buffer, "%s ", h5tools_dump_header_format->dataspacebegin);
- h5tools_print_dataspace(stream, &buffer, info, ctx, type);
+ h5tools_print_dataspace(&buffer, type);
if (HDstrlen(h5tools_dump_header_format->dataspaceblockend)) {
h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->dataspaceblockend);
@@ -2732,7 +2962,7 @@ h5tools_dump_dataspace(FILE *stream, const h5tool_format_t *info,
if (HDstrlen(h5tools_dump_header_format->dataspaceend))
h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->dataspaceend);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
h5tools_str_close(&buffer);
}
@@ -2748,16 +2978,15 @@ h5tools_dump_dataspace(FILE *stream, const h5tool_format_t *info,
*-------------------------------------------------------------------------
*/
void
-h5tools_dump_oid(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx, hid_t oid)
+h5tools_dump_oid(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t oid)
{
- h5tools_str_t buffer; /* string into which to render */
- size_t ncols = 80; /* available output width */
- hsize_t curr_pos = ctx->sm_pos; /* total data element position */
- /* pass to the prefix in h5tools_simple_prefix the total position
- * instead of the current stripmine position i; this is necessary
- * to print the array indices
- */
+ h5tools_str_t buffer; /* string into which to render */
+ size_t ncols = 80; /* available output width */
+ hsize_t curr_pos = ctx->sm_pos; /* total data element position */
+ /* pass to the prefix in h5tools_simple_prefix the total position
+ * instead of the current stripmine position i; this is necessary
+ * to print the array indices
+ */
/* setup */
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
@@ -2766,15 +2995,89 @@ h5tools_dump_oid(FILE *stream, const h5tool_format_t *info,
ncols = info->line_ncols;
ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
+
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s %s %d %s", OBJID, BEGIN, oid, END);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
+ h5tools_str_append(&buffer, "%s %s %" PRId64 " %s", OBJID, BEGIN, oid, END);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
h5tools_str_close(&buffer);
}
+/*-------------------------------------------------------------------------
+ * Function: print_virtual_selection
+ *
+ * Purpose: Print the virtual dataset selection.
+ *
+ * Return: void
+ *-------------------------------------------------------------------------
+ */
+static void
+h5tools_print_virtual_selection(hid_t vspace, FILE *stream, const h5tool_format_t *info,
+ h5tools_context_t *ctx, /* in,out*/
+ h5tools_str_t *buffer, /* string into which to render */
+ hsize_t *curr_pos, /* total data element position */
+ size_t ncols)
+{
+ switch (H5Sget_select_type(vspace)) {
+ case H5S_SEL_NONE: /* Nothing selected */
+ ctx->need_prefix = TRUE;
+
+ h5tools_str_reset(buffer);
+ h5tools_str_append(buffer, "%s", VDS_NONE);
+ break;
+ case H5S_SEL_POINTS: /* Sequence of points selected */
+ h5tools_str_reset(buffer);
+ h5tools_str_append(buffer, "%s %s ", VDS_POINT,
+ h5tools_dump_header_format->virtualselectionblockbegin);
+ h5tools_str_dump_space_points(buffer, vspace, info);
+ h5tools_str_append(buffer, " %s", h5tools_dump_header_format->virtualselectionblockend);
+ break;
+ case H5S_SEL_HYPERSLABS: /* "New-style" hyperslab selection defined */
+ ctx->need_prefix = TRUE;
+
+ h5tools_str_reset(buffer);
+ if (H5Sis_regular_hyperslab(vspace)) {
+ h5tools_str_append(buffer, "%s %s ", VDS_REG_HYPERSLAB,
+ h5tools_dump_header_format->virtualselectionblockbegin);
+ h5tools_render_element(stream, info, ctx, buffer, curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
+
+ h5tools_str_reset(buffer);
+ h5tools_str_dump_space_slabs(buffer, vspace, info, ctx);
+ }
+ else {
+ h5tools_str_append(buffer, "%s %s ", VDS_IRR_HYPERSLAB,
+ h5tools_dump_header_format->virtualselectionblockbegin);
+ h5tools_render_element(stream, info, ctx, buffer, curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
+ ctx->indent_level++;
+ ctx->need_prefix = TRUE;
+ h5tools_simple_prefix(stream, info, ctx, *curr_pos, 0);
+
+ h5tools_str_reset(buffer);
+ h5tools_str_dump_space_blocks(buffer, vspace, info);
+ ctx->indent_level--;
+ }
+ h5tools_render_element(stream, info, ctx, buffer, curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
+ ctx->need_prefix = TRUE;
+
+ h5tools_str_reset(buffer);
+ h5tools_str_append(buffer, "%s", h5tools_dump_header_format->virtualselectionblockend);
+ break;
+ case H5S_SEL_ALL: /* Entire extent selected */
+ ctx->need_prefix = TRUE;
+
+ h5tools_str_reset(buffer);
+ h5tools_str_append(buffer, "%s", VDS_ALL);
+ break;
+ case H5S_SEL_ERROR:
+ case H5S_SEL_N:
+ default:
+ h5tools_str_append(buffer, "Unknown Selection");
+ }
+ h5tools_render_element(stream, info, ctx, buffer, curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
+}
/*-------------------------------------------------------------------------
* Function: dump_fill_value
@@ -2782,25 +3085,20 @@ h5tools_dump_oid(FILE *stream, const h5tool_format_t *info,
* Purpose: prints the fill value
*
* Return: void
- *
- * Programmer: pvn
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void
-h5tools_print_fill_value(h5tools_str_t *buffer/*in,out*/, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, hid_t dcpl, hid_t type_id, hid_t obj_id)
+h5tools_print_fill_value(h5tools_str_t *buffer /*in,out*/, const h5tool_format_t *info,
+ h5tools_context_t *ctx /*in,out*/, hid_t dcpl, hid_t type_id, hid_t obj_id)
{
- size_t size;
- hid_t n_type;
- hsize_t nelmts = 1;
- void *buf = NULL;
+ size_t size;
+ hid_t n_type = H5I_INVALID_HID;
+ void *buf = NULL;
- n_type = h5tools_get_native_type(type_id);
+ n_type = H5Tget_native_type(type_id, H5T_DIR_DEFAULT);
size = H5Tget_size(n_type);
- buf = HDmalloc(size);
+ buf = HDmalloc(size);
H5Pget_fill_value(dcpl, n_type, buf);
@@ -2809,7 +3107,7 @@ h5tools_print_fill_value(h5tools_str_t *buffer/*in,out*/, const h5tool_format_t
H5Tclose(n_type);
if (buf)
- HDfree (buf);
+ HDfree(buf);
}
/*-------------------------------------------------------------------------
@@ -2818,461 +3116,557 @@ h5tools_print_fill_value(h5tools_str_t *buffer/*in,out*/, const h5tool_format_t
* Purpose: prints several dataset create property list properties
*
* Return: void
- *
- * Modifications: pvn, March 28, 2008
- * Add a COMPRESSION ratio information for cases when filters are present
- *
*-------------------------------------------------------------------------
*/
void
-h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx, hid_t dcpl_id,hid_t type_id, hid_t obj_id)
+h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t dcpl_id,
+ hid_t type_id, hid_t dset_id)
{
- int nfilters; /* number of filters */
- int rank; /* rank */
+ int nfilters; /* number of filters */
+ int rank; /* rank */
int i;
unsigned j;
- unsigned filt_flags; /* filter flags */
- unsigned cd_values[20]; /* filter client data values */
+ unsigned filt_flags; /* filter flags */
+ unsigned cd_values[20]; /* filter client data values */
unsigned szip_options_mask;
unsigned szip_pixels_per_block;
- H5Z_filter_t filtn; /* filter identification number */
+ H5Z_filter_t filtn; /* filter identification number */
H5D_fill_value_t fvstatus;
H5D_alloc_time_t at;
H5D_fill_time_t ft;
- size_t ncols = 80; /* available output width */
- size_t cd_nelmts; /* filter client number of values */
- off_t offset; /* offset of external file */
- char f_name[256]; /* filter name */
- char name[256]; /* external file name */
- hsize_t chsize[64]; /* chunk size in elements */
- hsize_t size; /* size of external file */
+ H5D_layout_t stl;
+ size_t ncols = 80; /* available output width */
+ size_t cd_nelmts; /* filter client number of values */
+ off_t offset; /* offset of external file */
+ char f_name[256]; /* filter name */
+ char name[256]; /* external or virtual file name */
+ hsize_t chsize[64]; /* chunk size in elements */
+ hsize_t size; /* size of external file */
hsize_t storage_size;
- hsize_t curr_pos = 0; /* total data element position */
- hsize_t elmt_counter = 0;/* counts the # elements printed.*/
- haddr_t ioffset;
- h5tools_str_t buffer; /* string into which to render */
+ hsize_t curr_pos = 0; /* total data element position */
+ h5tools_str_t buffer; /* string into which to render */
/* setup */
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
if (info->line_ncols > 0)
ncols = info->line_ncols;
- storage_size = H5Dget_storage_size(obj_id);
- nfilters = H5Pget_nfilters(dcpl_id);
- ioffset = H5Dget_offset(obj_id);
- HDstrcpy(f_name,"\0");
+ storage_size = H5Dget_storage_size(dset_id);
+ nfilters = H5Pget_nfilters(dcpl_id);
+ HDstrcpy(f_name, "\0");
/*-------------------------------------------------------------------------
- * STORAGE_LAYOUT
- *-------------------------------------------------------------------------
- */
+ * STORAGE_LAYOUT
+ *-------------------------------------------------------------------------
+ */
ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
+
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "%s %s", STORAGE_LAYOUT, BEGIN);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
- if(H5D_CHUNKED == H5Pget_layout(dcpl_id)) {
- ctx->indent_level++;
+ stl = H5Pget_layout(dcpl_id);
+ switch (stl) {
+ case H5D_CHUNKED:
+ ctx->indent_level++;
+ ctx->need_prefix = TRUE;
- ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s ", CHUNKED);
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "%s ", CHUNKED);
- rank = H5Pget_chunk(dcpl_id,NELMTS(chsize),chsize);
- h5tools_str_append(&buffer, "%s " HSIZE_T_FORMAT, h5tools_dump_header_format->dataspacedimbegin, chsize[0]);
- for(i = 1; i < rank; i++)
- h5tools_str_append(&buffer, ", " HSIZE_T_FORMAT, chsize[i]);
- h5tools_str_append(&buffer, " %s", h5tools_dump_header_format->dataspacedimend);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
+ rank = H5Pget_chunk(dcpl_id, (int)NELMTS(chsize), chsize);
+ h5tools_str_append(&buffer, "%s %" PRIuHSIZE, h5tools_dump_header_format->dataspacedimbegin,
+ chsize[0]);
+ for (i = 1; i < rank; i++)
+ h5tools_str_append(&buffer, ", %" PRIuHSIZE, chsize[i]);
+ h5tools_str_append(&buffer, " %s", h5tools_dump_header_format->dataspacedimend);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
- ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
- h5tools_str_reset(&buffer);
+ ctx->need_prefix = TRUE;
- /* if there are filters, print a compression ratio */
- if(nfilters) {
- hsize_t dims[H5S_MAX_RANK];
- hsize_t nelmts = 1;
- double ratio = 0;
- int ok = 0;
-
- hid_t tid = H5Dget_type(obj_id);
- hid_t sid = H5Dget_space(obj_id);
- size_t datum_size = H5Tget_size(tid);
- int ndims = H5Sget_simple_extent_dims(sid, dims, NULL);
-
- /* only print the compression ratio for these filters */
- for(i = 0; i < nfilters; i++) {
- cd_nelmts = NELMTS(cd_values);
- filtn = H5Pget_filter2(dcpl_id, (unsigned)i, &filt_flags, &cd_nelmts,
- cd_values, sizeof(f_name), f_name, NULL);
-
- switch(filtn) {
- case H5Z_FILTER_DEFLATE:
- case H5Z_FILTER_SZIP:
- case H5Z_FILTER_NBIT:
- case H5Z_FILTER_SCALEOFFSET:
- ok = 1;
- break;
+ h5tools_str_reset(&buffer);
+
+ /* if there are filters, print a compression ratio */
+ if (nfilters) {
+ hsize_t dims[H5S_MAX_RANK];
+ hsize_t nelmts = 1;
+ double ratio = 0;
+ int ok = 0;
+
+ hid_t tid = H5Dget_type(dset_id);
+ hid_t sid = H5Dget_space(dset_id);
+ size_t datum_size = H5Tget_size(tid);
+ int ndims = H5Sget_simple_extent_dims(sid, dims, NULL);
+
+ /* only print the compression ratio for these filters */
+ for (i = 0; i < nfilters && !ok; i++) {
+ cd_nelmts = NELMTS(cd_values);
+ filtn = H5Pget_filter2(dcpl_id, (unsigned)i, &filt_flags, &cd_nelmts, cd_values,
+ sizeof(f_name), f_name, NULL);
+ ok = (filtn >= 0);
}
- }
- if(ndims && ok) {
- hsize_t uncomp_size;
+ if (ndims && ok) {
+ hsize_t uncomp_size;
- for(i = 0; i < ndims; i++) {
- nelmts *= dims[i];
- }
- uncomp_size = nelmts * datum_size;
+ for (i = 0; i < ndims; i++) {
+ nelmts *= dims[i];
+ }
+ uncomp_size = nelmts * datum_size;
- /* compression ratio = uncompressed size / compressed size */
+ /* compression ratio = uncompressed size / compressed size */
- if(storage_size != 0)
- ratio = (double) uncomp_size / (double) storage_size;
+ if (storage_size != 0)
+ ratio = (double)uncomp_size / (double)storage_size;
- h5tools_str_append(&buffer, "SIZE " HSIZE_T_FORMAT" (%.3f:1 COMPRESSION)", storage_size, ratio);
+ h5tools_str_append(&buffer, "SIZE %" PRIuHSIZE " (%.3f:1 COMPRESSION)", storage_size,
+ ratio);
+ }
+ else
+ h5tools_str_append(&buffer, "SIZE %" PRIuHSIZE, storage_size);
+ H5Sclose(sid);
+ H5Tclose(tid);
}
- else
- h5tools_str_append(&buffer, "SIZE " HSIZE_T_FORMAT, storage_size);
+ else {
+ h5tools_str_append(&buffer, "SIZE %" PRIuHSIZE, storage_size);
+ }
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
+ ctx->indent_level--;
+ break;
+ case H5D_COMPACT:
+ ctx->indent_level++;
+ ctx->need_prefix = TRUE;
- H5Sclose(sid);
- H5Tclose(tid);
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "%s", COMPACT);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
- }
- else {
- h5tools_str_append(&buffer, "SIZE " HSIZE_T_FORMAT, storage_size);
- }
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
+ ctx->need_prefix = TRUE;
- ctx->indent_level--;
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "SIZE %" PRIuHSIZE, storage_size);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
+ ctx->indent_level--;
+ break;
+ case H5D_CONTIGUOUS: {
+ int n_external;
- ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s",END);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
- }
- else if(H5D_COMPACT == H5Pget_layout(dcpl_id)) {
- ctx->indent_level++;
+ n_external = H5Pget_external_count(dcpl_id);
- ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s", COMPACT);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
+ ctx->indent_level++;
+ if (n_external) {
- ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "SIZE " HSIZE_T_FORMAT, storage_size);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
+ /* EXTERNAL FILE */
- ctx->indent_level--;
+ ctx->need_prefix = TRUE;
- ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s",END);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
- }
- else if(H5D_CONTIGUOUS == H5Pget_layout(dcpl_id)) {
- int next;
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "%s", CONTIGUOUS);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
- next = H5Pget_external_count(dcpl_id);
+ ctx->need_prefix = TRUE;
- /*-------------------------------------------------------------------------
- * EXTERNAL_FILE
- *-------------------------------------------------------------------------
- */
- if(next) {
- ctx->indent_level++;
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "%s %s", EXTERNAL, BEGIN);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
- ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s", CONTIGUOUS);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
+ ctx->indent_level++;
+ for (j = 0; j < (unsigned)n_external; j++) {
+ H5Pget_external(dcpl_id, j, sizeof(name), name, &offset, &size);
- ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s %s", EXTERNAL, BEGIN);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
+ ctx->need_prefix = TRUE;
- ctx->indent_level++;
- for(j = 0; j < (unsigned)next; j++) {
- H5Pget_external(dcpl_id, j, sizeof(name), name, &offset, &size);
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "FILENAME %s SIZE %" PRIuHSIZE, name, size);
+ /* Using %lld with a cast to (long long) is probably the only portable
+ * way to print off_t values. There's no real standard for off_t other
+ * than it must be signed, according to POSIX.
+ */
+ h5tools_str_append(&buffer, " OFFSET %lld", (long long)offset);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
+ }
+ ctx->indent_level--;
ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
+
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "FILENAME %s SIZE " HSIZE_T_FORMAT, name, size);
- h5tools_str_append(&buffer, " OFFSET %ld", offset);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
+ h5tools_str_append(&buffer, "%s", END);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
}
- ctx->indent_level--;
+ else {
+ haddr_t ioffset;
+ uint64_t supported = 0;
- ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s",END);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
+ /* NORMAL FILE */
- ctx->indent_level--;
+ ctx->need_prefix = TRUE;
- ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s",END);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
- }
- else {
- ctx->indent_level++;
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "%s", CONTIGUOUS);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
- ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s", CONTIGUOUS);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
+ ctx->need_prefix = TRUE;
- ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer,"SIZE " HSIZE_T_FORMAT, storage_size);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "SIZE %" PRIuHSIZE, storage_size);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
- ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer,"OFFSET "H5_PRINTF_HADDR_FMT, ioffset);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
+ /* Only dump the offset if the VOL connector implements
+ * the functionality.
+ */
+ H5VLquery_optional(dset_id, H5VL_SUBCLS_DATASET, H5VL_NATIVE_DATASET_GET_OFFSET, &supported);
+
+ if (supported & H5VL_OPT_QUERY_SUPPORTED) {
+ ctx->need_prefix = TRUE;
+
+ h5tools_str_reset(&buffer);
+ ioffset = H5Dget_offset(dset_id);
+ if (HADDR_UNDEF == ioffset)
+ h5tools_str_append(&buffer, "OFFSET HADDR_UNDEF");
+ else
+ h5tools_str_append(&buffer, "OFFSET %" PRIuHADDR, ioffset);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
+ }
+ }
ctx->indent_level--;
+ } break;
- ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
+ case H5D_VIRTUAL: {
+ char dsetname[256]; /* virtual dataset name */
+ size_t n_vmaps;
+
+ H5Pget_virtual_count(dcpl_id, &n_vmaps);
+
+ if (n_vmaps) {
+ size_t curr_vmap;
+ ssize_t H5_ATTR_NDEBUG_UNUSED ssize_out;
+
+ ctx->indent_level++;
+ for (curr_vmap = 0; curr_vmap < n_vmaps; curr_vmap++) {
+ hid_t virtual_vspace = H5Pget_virtual_vspace(dcpl_id, curr_vmap);
+ hid_t virtual_srcspace = H5Pget_virtual_srcspace(dcpl_id, curr_vmap);
+
+ ctx->need_prefix = TRUE;
+
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "%s %zu %s ", VDS_MAPPING, curr_vmap, BEGIN);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
+
+ ctx->indent_level++;
+
+ ctx->need_prefix = TRUE;
+
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "%s %s", VDS_VIRTUAL, BEGIN);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
+
+ ctx->indent_level++;
+
+ h5tools_print_virtual_selection(virtual_vspace, stream, info, ctx, &buffer, &curr_pos,
+ (size_t)ncols);
+
+ ctx->indent_level--;
+
+ ctx->need_prefix = TRUE;
+
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "%s", END);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
+
+ ctx->need_prefix = TRUE;
+
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "%s %s", VDS_SOURCE, BEGIN);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
+
+ ctx->indent_level++;
+
+ ssize_out = H5Pget_virtual_filename(dcpl_id, curr_vmap, NULL, 0);
+ HDassert(ssize_out > 0);
+ HDassert((size_t)ssize_out < sizeof(name));
+ H5Pget_virtual_filename(dcpl_id, curr_vmap, name, sizeof(name));
+ ssize_out = H5Pget_virtual_dsetname(dcpl_id, curr_vmap, NULL, 0);
+ HDassert(ssize_out > 0);
+ HDassert((size_t)ssize_out < sizeof(name));
+ H5Pget_virtual_dsetname(dcpl_id, curr_vmap, dsetname, sizeof(dsetname));
+
+ ctx->need_prefix = TRUE;
+
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "%s %s", VDS_SRC_FILE,
+ h5tools_dump_header_format->virtualfilenamebegin);
+ h5tools_str_append(&buffer, "%s", name);
+ h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->virtualfilenameend);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
+
+ ctx->need_prefix = TRUE;
+
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "%s %s", VDS_SRC_DATASET,
+ h5tools_dump_header_format->virtualdatasetnamebegin);
+ h5tools_str_append(&buffer, "%s", dsetname);
+ h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->virtualdatasetnameend);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
+
+ h5tools_print_virtual_selection(virtual_srcspace, stream, info, ctx, &buffer, &curr_pos,
+ (size_t)ncols);
+
+ ctx->indent_level--;
+
+ ctx->need_prefix = TRUE;
+
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "%s", END);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
+
+ ctx->indent_level--;
+
+ ctx->need_prefix = TRUE;
+
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "%s", END);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
+ }
+ ctx->indent_level--;
+ }
+ } break;
+
+ case H5D_LAYOUT_ERROR:
+ case H5D_NLAYOUTS:
+ default:
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s",END);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
- }
- }
- /*-------------------------------------------------------------------------
- * FILTERS
- *-------------------------------------------------------------------------
- */
+ h5tools_str_append(&buffer, "%s", "Unknown layout");
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
+ } /*switch*/
ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
+
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s %s", FILTERS, BEGIN);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
+ h5tools_str_append(&buffer, "%s", END);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
- ctx->indent_level++;
+ /*-------------------------------------------------------------------------
+ * FILTERS
+ *-------------------------------------------------------------------------
+ */
+ if (H5D_VIRTUAL != stl) {
+ ctx->need_prefix = TRUE;
- if(nfilters) {
- for(i = 0; i < nfilters; i++) {
- cd_nelmts = NELMTS(cd_values);
- filtn = H5Pget_filter2(dcpl_id, (unsigned)i, &filt_flags, &cd_nelmts,
- cd_values, sizeof(f_name), f_name, NULL);
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "%s %s", FILTERS, BEGIN);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
- ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
- h5tools_str_reset(&buffer);
- switch(filtn) {
- case H5Z_FILTER_DEFLATE:
- h5tools_str_append(&buffer, "%s %s %s %d %s", DEFLATE, BEGIN, DEFLATE_LEVEL, cd_values[0], END);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
- break;
- case H5Z_FILTER_SHUFFLE:
- h5tools_str_append(&buffer, "%s", SHUFFLE);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
- break;
- case H5Z_FILTER_FLETCHER32:
- h5tools_str_append(&buffer, "%s", FLETCHER32);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
- break;
- case H5Z_FILTER_SZIP:
- {
- szip_options_mask = cd_values[0];;
+ ctx->indent_level++;
+
+ if (nfilters) {
+ for (i = 0; i < nfilters; i++) {
+ cd_nelmts = NELMTS(cd_values);
+ filtn = H5Pget_filter2(dcpl_id, (unsigned)i, &filt_flags, &cd_nelmts, cd_values,
+ sizeof(f_name), f_name, NULL);
+
+ if (filtn < 0)
+ continue; /* nothing to print for invalid filter */
+
+ ctx->need_prefix = TRUE;
+
+ h5tools_str_reset(&buffer);
+ switch (filtn) {
+ case H5Z_FILTER_DEFLATE:
+ h5tools_str_append(&buffer, "%s %s %s %d %s", DEFLATE, BEGIN, DEFLATE_LEVEL,
+ cd_values[0], END);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols,
+ (hsize_t)0, (hsize_t)0);
+ break;
+ case H5Z_FILTER_SHUFFLE:
+ h5tools_str_append(&buffer, "%s", SHUFFLE);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols,
+ (hsize_t)0, (hsize_t)0);
+ break;
+ case H5Z_FILTER_FLETCHER32:
+ h5tools_str_append(&buffer, "%s", FLETCHER32);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols,
+ (hsize_t)0, (hsize_t)0);
+ break;
+ case H5Z_FILTER_SZIP:
+ szip_options_mask = cd_values[0];
+ ;
szip_pixels_per_block = cd_values[1];
- h5tools_str_append(&buffer, "%s %s",SZIP, BEGIN);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
+ h5tools_str_append(&buffer, "%s %s", SZIP, BEGIN);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols,
+ (hsize_t)0, (hsize_t)0);
ctx->indent_level++;
ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
+
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "PIXELS_PER_BLOCK %d", szip_pixels_per_block);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols,
+ (hsize_t)0, (hsize_t)0);
ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
+
h5tools_str_reset(&buffer);
- if(szip_options_mask & H5_SZIP_CHIP_OPTION_MASK)
+ if (szip_options_mask & H5_SZIP_CHIP_OPTION_MASK)
h5tools_str_append(&buffer, "MODE %s", "HARDWARE");
- else if(szip_options_mask & H5_SZIP_ALLOW_K13_OPTION_MASK)
+ else if (szip_options_mask & H5_SZIP_ALLOW_K13_OPTION_MASK)
h5tools_str_append(&buffer, "MODE %s", "K13");
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols,
+ (hsize_t)0, (hsize_t)0);
ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
+
h5tools_str_reset(&buffer);
- if(szip_options_mask & H5_SZIP_EC_OPTION_MASK)
+ if (szip_options_mask & H5_SZIP_EC_OPTION_MASK)
h5tools_str_append(&buffer, "CODING %s", "ENTROPY");
- else if(szip_options_mask & H5_SZIP_NN_OPTION_MASK)
+ else if (szip_options_mask & H5_SZIP_NN_OPTION_MASK)
h5tools_str_append(&buffer, "CODING %s", "NEAREST NEIGHBOUR");
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols,
+ (hsize_t)0, (hsize_t)0);
ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
+
h5tools_str_reset(&buffer);
- if(szip_options_mask & H5_SZIP_LSB_OPTION_MASK)
+ if (szip_options_mask & H5_SZIP_LSB_OPTION_MASK)
h5tools_str_append(&buffer, "BYTE_ORDER %s", "LSB");
- else if(szip_options_mask & H5_SZIP_MSB_OPTION_MASK)
+ else if (szip_options_mask & H5_SZIP_MSB_OPTION_MASK)
h5tools_str_append(&buffer, "BYTE_ORDER %s", "MSB");
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols,
+ (hsize_t)0, (hsize_t)0);
- if(szip_options_mask & H5_SZIP_RAW_OPTION_MASK) {
+ if (szip_options_mask & H5_SZIP_RAW_OPTION_MASK) {
ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
+
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "HEADER %s", "RAW");
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols,
+ (hsize_t)0, (hsize_t)0);
}
ctx->indent_level--;
ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
+
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s",END);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
- }
- break;
- case H5Z_FILTER_NBIT:
- h5tools_str_append(&buffer, "%s", NBIT);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
- break;
- case H5Z_FILTER_SCALEOFFSET:
- h5tools_str_append(&buffer, "%s %s %s %d %s", SCALEOFFSET, BEGIN, SCALEOFFSET_MINBIT, cd_values[0], END);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
- break;
- default:
- if(H5Zfilter_avail(filtn))
- h5tools_str_append(&buffer, "%s %s", "USER_REGISTERED_FILTER", BEGIN);
- else
- h5tools_str_append(&buffer, "%s %s", "UNKNOWN_FILTER", BEGIN);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
+ h5tools_str_append(&buffer, "%s", END);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols,
+ (hsize_t)0, (hsize_t)0);
+ break;
+ case H5Z_FILTER_NBIT:
+ h5tools_str_append(&buffer, "%s", NBIT);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols,
+ (hsize_t)0, (hsize_t)0);
+ break;
+ case H5Z_FILTER_SCALEOFFSET:
+ h5tools_str_append(&buffer, "%s %s %s %d %s", SCALEOFFSET, BEGIN, SCALEOFFSET_MINBIT,
+ cd_values[0], END);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols,
+ (hsize_t)0, (hsize_t)0);
+ break;
+ default:
+ h5tools_str_append(&buffer, "%s %s", "USER_DEFINED_FILTER", BEGIN);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols,
+ (hsize_t)0, (hsize_t)0);
- ctx->indent_level++;
+ ctx->indent_level++;
- ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "FILTER_ID %d", filtn);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
-
- if(f_name[0] != '\0') {
ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
+
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "COMMENT %s", f_name);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
- }
- if (cd_nelmts) {
+ h5tools_str_append(&buffer, "FILTER_ID %d", filtn);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols,
+ (hsize_t)0, (hsize_t)0);
+
+ if (f_name[0] != '\0') {
+ ctx->need_prefix = TRUE;
+
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "COMMENT %s", f_name);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols,
+ (hsize_t)0, (hsize_t)0);
+ }
+ if (cd_nelmts) {
+ ctx->need_prefix = TRUE;
+
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "%s %s ", "PARAMS", BEGIN);
+ for (j = 0; j < cd_nelmts; j++)
+ h5tools_str_append(&buffer, "%d ", cd_values[j]);
+ h5tools_str_append(&buffer, "%s", END);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols,
+ (hsize_t)0, (hsize_t)0);
+ }
+ ctx->indent_level--;
+
ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
+
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s %s ","PARAMS", BEGIN);
- for (j=0; j<cd_nelmts; j++)
- h5tools_str_append(&buffer, "%d ", cd_values[j]);
h5tools_str_append(&buffer, "%s", END);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
- }
- ctx->indent_level--;
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols,
+ (hsize_t)0, (hsize_t)0);
+ break;
+ } /*switch*/
+ } /*i*/
+ } /*nfilters*/
+ else {
+ ctx->need_prefix = TRUE;
- ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s",END);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
- break;
- }/*switch*/
- } /*i*/
- }/*nfilters*/
- else {
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "NONE");
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
+ }
+ ctx->indent_level--;
ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "NONE");
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
- }
- ctx->indent_level--;
- ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s",END);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "%s", END);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
+ } /* end if (H5D_VIRTUAL != stl) */
/*-------------------------------------------------------------------------
- * FILLVALUE
- *-------------------------------------------------------------------------
- */
+ * FILLVALUE
+ *-------------------------------------------------------------------------
+ */
ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
+
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "%s %s", FILLVALUE, BEGIN);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
ctx->indent_level++;
ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
+
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "FILL_TIME ");
-
+
H5Pget_fill_time(dcpl_id, &ft);
- switch(ft) {
+ switch (ft) {
case H5D_FILL_TIME_ALLOC:
h5tools_str_append(&buffer, "%s", "H5D_FILL_TIME_ALLOC");
break;
@@ -3282,77 +3676,87 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info,
case H5D_FILL_TIME_IFSET:
h5tools_str_append(&buffer, "%s", "H5D_FILL_TIME_IFSET");
break;
+ case H5D_FILL_TIME_ERROR:
default:
HDassert(0);
break;
}
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
+
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "%s ", "VALUE ");
H5Pfill_value_defined(dcpl_id, &fvstatus);
- if(fvstatus == H5D_FILL_VALUE_UNDEFINED)
- h5tools_str_append(&buffer, "%s", "H5D_FILL_VALUE_UNDEFINED");
- else {
- ctx->indent_level--;
- h5tools_print_fill_value(&buffer, info, ctx, dcpl_id, type_id, obj_id);
- ctx->indent_level++;
- }
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
- ctx->indent_level--;
-
- ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s", END);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
-
- /*-------------------------------------------------------------------------
- * ALLOCATION_TIME
- *-------------------------------------------------------------------------
- */
- ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "ALLOCATION_TIME %s", BEGIN);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
-
- ctx->indent_level++;
-
- ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
- h5tools_str_reset(&buffer);
- H5Pget_alloc_time(dcpl_id, &at);
- switch(at) {
- case H5D_ALLOC_TIME_EARLY:
- h5tools_str_append(&buffer, "%s", "H5D_ALLOC_TIME_EARLY");
+ switch (fvstatus) {
+ case H5D_FILL_VALUE_UNDEFINED:
+ h5tools_str_append(&buffer, "%s", "H5D_FILL_VALUE_UNDEFINED");
break;
- case H5D_ALLOC_TIME_INCR:
- h5tools_str_append(&buffer, "%s", "H5D_ALLOC_TIME_INCR");
+ case H5D_FILL_VALUE_DEFAULT:
+ h5tools_str_append(&buffer, "%s", "H5D_FILL_VALUE_DEFAULT");
break;
- case H5D_ALLOC_TIME_LATE:
- h5tools_str_append(&buffer, "%s", "H5D_ALLOC_TIME_LATE");
+ case H5D_FILL_VALUE_USER_DEFINED:
+ ctx->indent_level--;
+ h5tools_print_fill_value(&buffer, info, ctx, dcpl_id, type_id, dset_id);
+ ctx->indent_level++;
break;
+ case H5D_FILL_VALUE_ERROR:
default:
HDassert(0);
break;
}
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
-
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
ctx->indent_level--;
ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
+
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "%s", END);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
+
+ /*-------------------------------------------------------------------------
+ * ALLOCATION_TIME
+ *-------------------------------------------------------------------------
+ */
+ if (H5D_VIRTUAL != stl) {
+ ctx->need_prefix = TRUE;
+
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "ALLOCATION_TIME %s", BEGIN);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
+
+ ctx->indent_level++;
+
+ ctx->need_prefix = TRUE;
+
+ h5tools_str_reset(&buffer);
+ H5Pget_alloc_time(dcpl_id, &at);
+ switch (at) {
+ case H5D_ALLOC_TIME_EARLY:
+ h5tools_str_append(&buffer, "%s", "H5D_ALLOC_TIME_EARLY");
+ break;
+ case H5D_ALLOC_TIME_INCR:
+ h5tools_str_append(&buffer, "%s", "H5D_ALLOC_TIME_INCR");
+ break;
+ case H5D_ALLOC_TIME_LATE:
+ h5tools_str_append(&buffer, "%s", "H5D_ALLOC_TIME_LATE");
+ break;
+ case H5D_ALLOC_TIME_ERROR:
+ case H5D_ALLOC_TIME_DEFAULT:
+ default:
+ HDassert(0);
+ break;
+ }
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
+
+ ctx->indent_level--;
+
+ ctx->need_prefix = TRUE;
+
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "%s", END);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
+ } /* end if (H5D_VIRTUAL != stl) */
h5tools_str_close(&buffer);
}
@@ -3363,24 +3767,28 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info,
* Purpose: prints the comment for the the object name
*
* Return: void
- *
*-------------------------------------------------------------------------
*/
void
-h5tools_dump_comment(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx, hid_t obj_id)
+h5tools_dump_comment(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t obj_id)
{
- char *comment = NULL;
+ char *comment = NULL;
ssize_t cmt_bufsize = -1;
- size_t buf_size = 0;
- size_t ncols = 80; /* available output width */
- h5tools_str_t buffer; /* string into which to render */
- hsize_t elmt_counter = 0;/* counts the # elements printed.*/
- hsize_t curr_pos = ctx->sm_pos; /* total data element position */
- /* pass to the prefix in h5tools_simple_prefix the total position
- * instead of the current stripmine position i; this is necessary
- * to print the array indices
- */
+ size_t buf_size = 0;
+ size_t ncols = 80; /* available output width */
+ h5tools_str_t buffer; /* string into which to render */
+ hsize_t curr_pos = ctx->sm_pos; /* total data element position */
+ /* pass to the prefix in h5tools_simple_prefix the total position
+ * instead of the current stripmine position i; this is necessary
+ * to print the array indices
+ */
+ uint64_t supported = 0;
+
+ /* Check if comments are supported and return if not */
+ H5VLquery_optional(obj_id, H5VL_SUBCLS_OBJECT, H5VL_NATIVE_OBJECT_GET_COMMENT, &supported);
+
+ if (!(supported & H5VL_OPT_QUERY_SUPPORTED))
+ return;
/* setup */
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
@@ -3390,23 +3798,23 @@ h5tools_dump_comment(FILE *stream, const h5tool_format_t *info,
cmt_bufsize = H5Oget_comment(obj_id, comment, buf_size);
- /* call H5Oget_comment again with the correct value.
- * If the call to H5Oget_comment returned an error, skip this block */
+ /* 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, cmt_bufsize);
- 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'; /* necessary because null char is not returned */
ctx->need_prefix = TRUE;
-
+
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "COMMENT \"%s\"", comment);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
h5tools_str_close(&buffer);
- } /* end if */
+ }
HDfree(comment);
}
}
@@ -3415,7 +3823,7 @@ h5tools_dump_comment(FILE *stream, const h5tool_format_t *info,
/*-------------------------------------------------------------------------
* Function: dump_attribute
*
- * Purpose: Dump the attribute.
+ * Purpose: Dump the attribute.
*
* Return: void
*
@@ -3423,18 +3831,16 @@ h5tools_dump_comment(FILE *stream, const h5tool_format_t *info,
*-------------------------------------------------------------------------
*/
void
-h5tools_dump_attribute(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx, hid_t oid, const char *attr_name, hid_t attr_id,
- int display_index, int display_char)
+h5tools_dump_attribute(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
+ const char *attr_name, hid_t attr_id)
{
- h5tools_str_t buffer; /* string into which to render */
- size_t ncols = 80; /* available output width */
- hsize_t elmt_counter = 0;/* counts the # elements printed.*/
- hsize_t curr_pos = ctx->sm_pos; /* total data element position */
- /* pass to the prefix in h5tools_simple_prefix the total position
- * instead of the current stripmine position i; this is necessary
- * to print the array indices
- */
+ h5tools_str_t buffer; /* string into which to render */
+ size_t ncols = 80; /* available output width */
+ hsize_t curr_pos = ctx->sm_pos; /* total data element position */
+ /* pass to the prefix in h5tools_simple_prefix the total position
+ * instead of the current stripmine position i; this is necessary
+ * to print the array indices
+ */
/* setup */
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
@@ -3443,19 +3849,18 @@ h5tools_dump_attribute(FILE *stream, const h5tool_format_t *info,
ncols = info->line_ncols;
ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
+
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s \"%s\" %s",
- h5tools_dump_header_format->attributebegin, attr_name,
- h5tools_dump_header_format->attributeblockbegin);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
+ h5tools_str_append(&buffer, "%s \"%s\" %s", h5tools_dump_header_format->attributebegin, attr_name,
+ h5tools_dump_header_format->attributeblockbegin);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
- if(attr_id < 0) {
+ if (attr_id < 0) {
error_msg("unable to open attribute \"%s\"\n", attr_name);
- }
+ }
else {
- hid_t type, space;
+ hid_t type = H5I_INVALID_HID;
+ hid_t space = H5I_INVALID_HID;
ctx->indent_level++;
@@ -3465,11 +3870,11 @@ h5tools_dump_attribute(FILE *stream, const h5tool_format_t *info,
space = H5Aget_space(attr_id);
h5tools_dump_dataspace(stream, info, ctx, space);
- if(oid_output)
+ if (oid_output)
h5tools_dump_oid(stream, info, ctx, attr_id);
- if(data_output || attr_data_output)
- h5tools_dump_data(stream, info, ctx, attr_id, FALSE, NULL, display_index, display_char);
+ if (data_output || attr_data_output)
+ h5tools_dump_data(stream, info, ctx, attr_id, FALSE);
ctx->indent_level--;
@@ -3479,8 +3884,7 @@ h5tools_dump_attribute(FILE *stream, const h5tool_format_t *info,
}
ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, 0, 0);
-
+
h5tools_str_reset(&buffer);
if (HDstrlen(h5tools_dump_header_format->attributeblockend)) {
@@ -3491,7 +3895,7 @@ h5tools_dump_attribute(FILE *stream, const h5tool_format_t *info,
if (HDstrlen(h5tools_dump_header_format->attributeend))
h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->attributeend);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
h5tools_str_close(&buffer);
}
@@ -3502,12 +3906,6 @@ h5tools_dump_attribute(FILE *stream, const h5tool_format_t *info,
* Purpose: Dump the dimensions handed to it in a comma separated list
*
* Return: void
- *
- * Programmer: Bill Wendling
- * Tuesday, 27. February 2001
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void
@@ -3516,9 +3914,10 @@ h5tools_print_dims(h5tools_str_t *buffer, hsize_t *s, int dims)
int i;
for (i = 0; i < dims; i++) {
- h5tools_str_append(buffer, HSIZE_T_FORMAT, s[i]);
+ h5tools_str_append(buffer, "%" PRIuHSIZE, s[i]);
- if (i + 1 != dims) h5tools_str_append(buffer, ", ");
+ if (i + 1 != dims)
+ h5tools_str_append(buffer, ", ");
}
}
@@ -3528,55 +3927,46 @@ h5tools_print_dims(h5tools_str_t *buffer, hsize_t *s, int dims)
* Purpose: Prints the packed bits offset and length
*
* Return: void
- *
*-------------------------------------------------------------------------
*/
void
h5tools_print_packed_bits(h5tools_str_t *buffer, hid_t type)
{
- int packed_bits_size = 0;
-
- hid_t n_type = h5tools_get_native_type(type);
- if(H5Tget_class(n_type)==H5T_INTEGER) {
- if(H5Tequal(n_type, H5T_NATIVE_SCHAR) == TRUE) {
+ unsigned packed_bits_size = 0;
+ hid_t n_type = H5Tget_native_type(type, H5T_DIR_DEFAULT);
+
+ if (H5Tget_class(n_type) == H5T_INTEGER) {
+ if (H5Tequal(n_type, H5T_NATIVE_SCHAR) == TRUE)
packed_bits_size = 8 * sizeof(char);
- }
- else if(H5Tequal(n_type, H5T_NATIVE_UCHAR) == TRUE) {
+ else if (H5Tequal(n_type, H5T_NATIVE_UCHAR) == TRUE)
packed_bits_size = 8 * sizeof(unsigned char);
- }
- else if(H5Tequal(n_type, H5T_NATIVE_SHORT) == TRUE) {
+ else if (H5Tequal(n_type, H5T_NATIVE_SHORT) == TRUE)
packed_bits_size = 8 * sizeof(short);
- }
- else if(H5Tequal(n_type, H5T_NATIVE_USHORT) == TRUE) {
+ else if (H5Tequal(n_type, H5T_NATIVE_USHORT) == TRUE)
packed_bits_size = 8 * sizeof(unsigned short);
- }
- else if(H5Tequal(n_type, H5T_NATIVE_INT) == TRUE) {
+ else if (H5Tequal(n_type, H5T_NATIVE_INT) == TRUE)
packed_bits_size = 8 * sizeof(int);
- }
- else if(H5Tequal(n_type, H5T_NATIVE_UINT) == TRUE) {
+ else if (H5Tequal(n_type, H5T_NATIVE_UINT) == TRUE)
packed_bits_size = 8 * sizeof(unsigned int);
- }
- else if(H5Tequal(n_type, H5T_NATIVE_LONG) == TRUE) {
+ else if (H5Tequal(n_type, H5T_NATIVE_LONG) == TRUE)
packed_bits_size = 8 * sizeof(long);
- }
- else if(H5Tequal(n_type, H5T_NATIVE_ULONG) == TRUE) {
+ else if (H5Tequal(n_type, H5T_NATIVE_ULONG) == TRUE)
packed_bits_size = 8 * sizeof(unsigned long);
- }
- else if(H5Tequal(n_type, H5T_NATIVE_LLONG) == TRUE) {
+ else if (H5Tequal(n_type, H5T_NATIVE_LLONG) == TRUE)
packed_bits_size = 8 * sizeof(long long);
- }
- else if(H5Tequal(n_type, H5T_NATIVE_ULLONG) == TRUE) {
+ else if (H5Tequal(n_type, H5T_NATIVE_ULLONG) == TRUE)
packed_bits_size = 8 * sizeof(unsigned long long);
- }
else
error_msg("Packed Bit not valid for this datatype");
}
- if ((packed_bits_size>0) && (packed_data_offset + packed_data_length) > packed_bits_size) {
- error_msg("Packed Bit offset+length value(%d) too large. Max is %d\n", packed_data_offset+packed_data_length, packed_bits_size);
+ if ((packed_bits_size > 0) && (packed_data_offset + packed_data_length) > packed_bits_size) {
+ error_msg("Packed Bit offset+length value(%u) too large. Max is %d\n",
+ packed_data_offset + packed_data_length, packed_bits_size);
packed_data_mask = 0;
};
- h5tools_str_append(buffer, "%s %s=%d %s=%d", PACKED_BITS, PACKED_OFFSET, packed_data_offset, PACKED_LENGTH, packed_data_length);
+ h5tools_str_append(buffer, "%s %s=%u %s=%u", PACKED_BITS, PACKED_OFFSET, packed_data_offset,
+ PACKED_LENGTH, packed_data_length);
}
/*-------------------------------------------------------------------------
@@ -3585,176 +3975,431 @@ h5tools_print_packed_bits(h5tools_str_t *buffer, hid_t type)
* Purpose: Dump the subsetting header like specified in the DDL.
*
* Return: void
- *
- * Programmer: Bill Wendling
- * Tuesday, 27. February 2001
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void
-h5tools_dump_subsetting_header(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx, struct subset_t *sset, int dims)
+h5tools_dump_subsetting_header(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, int dims)
{
- h5tools_str_t buffer; /* string into which to render */
- hsize_t curr_pos = 0; /* total data element position */
- size_t ncols = 80; /* available output width */
+ h5tools_str_t buffer; /* string into which to render */
+ hsize_t curr_pos = 0; /* total data element position */
+ size_t ncols = 80; /* available output width */
/* setup */
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
if (info->line_ncols > 0)
ncols = info->line_ncols;
-
+
ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, 0, 0);
-
+
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s %s", h5tools_dump_header_format->subsettingbegin, h5tools_dump_header_format->subsettingblockbegin);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
+ h5tools_str_append(&buffer, "%s %s", h5tools_dump_header_format->subsettingbegin,
+ h5tools_dump_header_format->subsettingblockbegin);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
ctx->indent_level++;
-
+
ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, 0, 0);
-
+
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s %s ", h5tools_dump_header_format->startbegin, h5tools_dump_header_format->startblockbegin);
- h5tools_print_dims(&buffer, sset->start.data, dims);
- h5tools_str_append(&buffer, "%s %s", h5tools_dump_header_format->startend, h5tools_dump_header_format->startblockend);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
-
+ h5tools_str_append(&buffer, "%s %s ", h5tools_dump_header_format->startbegin,
+ h5tools_dump_header_format->startblockbegin);
+ h5tools_print_dims(&buffer, ctx->sset->start.data, dims);
+ h5tools_str_append(&buffer, "%s %s", h5tools_dump_header_format->startend,
+ h5tools_dump_header_format->startblockend);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
+
ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, 0, 0);
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s %s ", h5tools_dump_header_format->stridebegin, h5tools_dump_header_format->strideblockbegin);
- h5tools_print_dims(&buffer, sset->stride.data, dims);
- h5tools_str_append(&buffer, "%s %s", h5tools_dump_header_format->strideend, h5tools_dump_header_format->strideblockend);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
-
+ h5tools_str_append(&buffer, "%s %s ", h5tools_dump_header_format->stridebegin,
+ h5tools_dump_header_format->strideblockbegin);
+ h5tools_print_dims(&buffer, ctx->sset->stride.data, dims);
+ h5tools_str_append(&buffer, "%s %s", h5tools_dump_header_format->strideend,
+ h5tools_dump_header_format->strideblockend);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
+
ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, 0, 0);
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s %s ", h5tools_dump_header_format->countbegin, h5tools_dump_header_format->countblockbegin);
+ h5tools_str_append(&buffer, "%s %s ", h5tools_dump_header_format->countbegin,
+ h5tools_dump_header_format->countblockbegin);
- if(sset->count.data)
- h5tools_print_dims(&buffer, sset->count.data, dims);
+ if (ctx->sset->count.data)
+ h5tools_print_dims(&buffer, ctx->sset->count.data, dims);
else
h5tools_str_append(&buffer, "DEFAULT");
- h5tools_str_append(&buffer, "%s %s", h5tools_dump_header_format->countend, h5tools_dump_header_format->countblockend);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
-
+ h5tools_str_append(&buffer, "%s %s", h5tools_dump_header_format->countend,
+ h5tools_dump_header_format->countblockend);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
+
ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, ctx, 0, 0);
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s %s ", h5tools_dump_header_format->blockbegin, h5tools_dump_header_format->blockblockbegin);
+ h5tools_str_append(&buffer, "%s %s ", h5tools_dump_header_format->blockbegin,
+ h5tools_dump_header_format->blockblockbegin);
- if(sset->block.data)
- h5tools_print_dims(&buffer, sset->block.data, dims);
+ if (ctx->sset->block.data)
+ h5tools_print_dims(&buffer, ctx->sset->block.data, dims);
else
h5tools_str_append(&buffer, "DEFAULT");
- h5tools_str_append(&buffer, "%s %s", h5tools_dump_header_format->blockend, h5tools_dump_header_format->blockblockend);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, ncols, 0, 0);
-
+ h5tools_str_append(&buffer, "%s %s", h5tools_dump_header_format->blockend,
+ h5tools_dump_header_format->blockblockend);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
+
ctx->indent_level--;
h5tools_str_close(&buffer);
}
/*-------------------------------------------------------------------------
- * Function: dump_data
+ * Function: dump_reference
*
- * Purpose: Dump attribute or dataset data
+ * Purpose: Dump reference data
*
* Return: void
- *
*-------------------------------------------------------------------------
*/
void
-h5tools_dump_data(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx, hid_t obj_id, int obj_data, struct subset_t *sset,
- int display_index, int display_char)
+h5tools_dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t container,
+ H5R_ref_t *ref_buf, int ndims)
{
- H5S_class_t space_type;
- int ndims;
- int i;
- hid_t space;
- hid_t type;
- hid_t p_type;
- hsize_t size[64];
- hsize_t alloc_size;
- hsize_t nelmts = 1;
- int status = -1;
- void *buf = NULL;
- h5tools_str_t buffer; /* string into which to render */
- hsize_t curr_pos = 0; /* total data element position */
- size_t ncols = 80; /* available output width */
- h5tool_format_t string_dataformat;
- h5tool_format_t outputformat;
+ hid_t new_obj_id = H5I_INVALID_HID;
+ hid_t new_obj_sid = H5I_INVALID_HID;
+ hsize_t elmt_counter = 0; /*counts the # elements printed. */
+ size_t ncols = 80; /* available output width */
+ int i;
+ hsize_t curr_pos = 0; /* total data element position */
+ h5tools_str_t buffer; /* string into which to render */
+ h5tools_context_t datactx; /* print context */
+
+ H5TOOLS_START_DEBUG(" ");
+
+ datactx = *ctx; /* print context */
+ /* Assume entire data space to be printed */
+ datactx.need_prefix = TRUE;
+
+ HDmemset(&buffer, 0, sizeof(h5tools_str_t));
+ for (i = 0; i < ndims; i++, datactx.cur_elmt++, elmt_counter++) {
+ H5O_type_t obj_type = -1; /* Object type */
+ H5R_type_t ref_type; /* Reference type */
+
+ H5TOOLS_DEBUG("reference loop:%d with curr_pos=%ld", i, curr_pos);
+
+ datactx.need_prefix = TRUE;
+ h5tools_str_reset(&buffer);
+ H5TOOLS_DEBUG("reference loop - h5tools_str_sprint with H5T_STD_REF:%d", i);
+ h5tools_str_sprint(&buffer, info, container, H5T_STD_REF, &ref_buf[i], &datactx);
+ h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)i,
+ (hsize_t)ndims);
+
+ ref_type = H5Rget_type((const H5R_ref_t *)&ref_buf[i]);
+ switch (ref_type) {
+ case H5R_OBJECT1:
+ H5TOOLS_DEBUG("ref_type is H5R_OBJECT1");
+ if (H5Rget_obj_type3(&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) {
+ switch (obj_type) {
+ case H5O_TYPE_DATASET:
+ if ((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ datactx.indent_level++;
+ h5tools_dump_data(stream, info, &datactx, new_obj_id, TRUE);
+ // h5tools_dump_dset(stream, info, &datactx, new_obj_id);
+ datactx.indent_level--;
+ if (H5Dclose(new_obj_id) < 0)
+ H5TOOLS_INFO("H5Dclose H5R_OBJECT1:H5O_TYPE_DATASET failed");
+ }
+ else
+ H5TOOLS_INFO("H5Ropen_object H5R_OBJECT1:H5O_TYPE_DATASET failed");
+ break;
+
+ case H5O_TYPE_GROUP:
+ case H5O_TYPE_NAMED_DATATYPE:
+ case H5O_TYPE_MAP:
+ case H5O_TYPE_UNKNOWN:
+ case H5O_TYPE_NTYPES:
+ default:
+ break;
+ } /* end switch */
+ }
+ else
+ H5TOOLS_INFO("H5Rget_obj_type3 H5R_OBJECT1 failed");
+ break;
+ case H5R_DATASET_REGION1:
+ H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION1");
+ if ((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ datactx.indent_level++;
+ h5tools_dump_data(stream, info, &datactx, new_obj_id, TRUE);
+ // h5tools_dump_dset(stream, info, &datactx, new_obj_id);
+ datactx.indent_level--;
+ if (H5Dclose(new_obj_id) < 0)
+ H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION1 failed");
+ }
+ else
+ H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION1 failed");
+ break;
+ case H5R_OBJECT2:
+ H5TOOLS_DEBUG("ref_type is H5R_OBJECT2");
+ if (H5Rget_obj_type3(&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) {
+ switch (obj_type) {
+ case H5O_TYPE_GROUP:
+ break;
+
+ case H5O_TYPE_DATASET:
+ if ((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ datactx.indent_level++;
+ h5tools_dump_data(stream, info, &datactx, new_obj_id, TRUE);
+ // h5tools_dump_dset(stream, info, &datactx, new_obj_id);
+ datactx.indent_level--;
+ if (H5Oclose(new_obj_id) < 0)
+ H5TOOLS_INFO("H5Oclose H5R_OBJECT2 failed");
+ }
+ else
+ H5TOOLS_INFO("H5Ropen_object H5R_OBJECT2 failed");
+ break;
+
+ case H5O_TYPE_NAMED_DATATYPE:
+ break;
+
+ case H5O_TYPE_MAP:
+ case H5O_TYPE_UNKNOWN:
+ case H5O_TYPE_NTYPES:
+ default:
+ break;
+ } /* end switch */
+ }
+ else
+ H5TOOLS_INFO("H5Rget_obj_type3 H5R_OBJECT2 failed");
+ break;
+ case H5R_DATASET_REGION2:
+ H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION2");
+
+ if (info->line_ncols > 0)
+ ncols = info->line_ncols;
+
+ /* if (new_obj_id < 0) - could mean that no reference was written do not throw failure */
+ if ((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION2 failed");
+ else {
+ if ((new_obj_sid = H5Ropen_region(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ if (h5tools_is_zero(&ref_buf[i], H5Tget_size(H5T_STD_REF))) {
+ H5TOOLS_DEBUG("NULL H5R_DATASET_REGION2");
+
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, " {");
+ h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols,
+ (hsize_t)0, (hsize_t)0);
+
+ datactx.need_prefix = TRUE;
+ datactx.indent_level++;
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "NULL");
+ h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols,
+ (hsize_t)0, (hsize_t)0);
+ datactx.indent_level--;
+ datactx.need_prefix = TRUE;
+
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "}");
+ h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols,
+ (hsize_t)0, (hsize_t)0);
+ }
+ else {
+ H5S_sel_type region_type;
+
+ region_type = H5Sget_select_type(new_obj_sid);
+ if (region_type == H5S_SEL_POINTS) {
+ /* Print point information */
+ H5TOOLS_DEBUG("H5S_SEL_POINTS H5R_DATASET_REGION2");
+ h5tools_dump_region_data_points(new_obj_sid, new_obj_id, stream, info,
+ &datactx, &buffer, &curr_pos, ncols,
+ (hsize_t)i, elmt_counter);
+ }
+ else if (region_type == H5S_SEL_HYPERSLABS) {
+ /* Print block information */
+ H5TOOLS_DEBUG("H5S_SEL_HYPERSLABS H5R_DATASET_REGION2");
+ h5tools_dump_region_data_blocks(new_obj_sid, new_obj_id, stream, info,
+ &datactx, &buffer, &curr_pos, ncols,
+ (hsize_t)i, elmt_counter);
+ }
+ else
+ H5TOOLS_INFO("invalid region type");
+ } /* end else to if (h5tools_is_zero(... */
+ if (H5Sclose(new_obj_sid) < 0)
+ H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION2 failed");
+ }
+ else
+ H5TOOLS_INFO("H5Ropen_region H5R_DATASET_REGION2 failed");
+ if (H5Dclose(new_obj_id) < 0)
+ H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION2 failed");
+ }
+ break;
+ case H5R_ATTR:
+ H5TOOLS_DEBUG("ref_type is H5R_ATTR");
+ if ((new_obj_id = H5Ropen_attr(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ h5tools_dump_region_attribute(new_obj_id, stream, info, &datactx, &buffer, &curr_pos,
+ (size_t)ncols, (hsize_t)0, (hsize_t)0);
+ if (H5Aclose(new_obj_id) < 0)
+ H5TOOLS_INFO("H5Aclose H5R_ATTR failed");
+ }
+ else {
+ H5TOOLS_DEBUG("NULL H5R_ATTR");
+
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, " {");
+ h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols,
+ (hsize_t)0, (hsize_t)0);
+
+ datactx.need_prefix = TRUE;
+ datactx.indent_level++;
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "NULL");
+ h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols,
+ (hsize_t)0, (hsize_t)0);
+ datactx.indent_level--;
+ datactx.need_prefix = TRUE;
+
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "}");
+ h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols,
+ (hsize_t)0, (hsize_t)0);
+ H5TOOLS_INFO("H5Ropen_attr H5R_ATTR failed");
+ }
+ break;
+ case H5R_BADTYPE:
+ case H5R_MAXTYPE:
+ default:
+ break;
+ } /* end switch */
+
+ if (H5Rdestroy(&ref_buf[i]) < 0)
+ H5TOOLS_INFO("H5Rdestroy failed");
+
+ H5TOOLS_DEBUG("finished reference loop:%d", i);
+ } /* end for(i = 0; i < ndims; i++, ctx->cur_elmt++, elmt_counter++) */
+
+ h5tools_str_close(&buffer);
+
+ H5TOOLS_ENDDEBUG(" ");
+}
+
+/*-------------------------------------------------------------------------
+ * Function: dump_data
+ *
+ * Purpose: Dump attribute, obj_data is FALSE, or dataset data, obj_data is TRUE
+ *
+ * Return: void
+ *-------------------------------------------------------------------------
+ */
+void
+h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t obj_id,
+ int obj_data)
+{
+ H5S_class_t space_type;
+ int ndims;
+ hid_t space = H5I_INVALID_HID;
+ hid_t f_type = H5I_INVALID_HID;
+ hsize_t total_size[H5S_MAX_RANK];
+ int status = -1;
+ h5tools_context_t datactx; /* print context */
+ h5tools_str_t buffer; /* string into which to render */
+ hsize_t curr_pos = 0; /* total data element position */
+ size_t ncols = 80; /* available output width */
+ h5tool_format_t string_dataformat;
+ h5tool_format_t outputformat;
+ H5R_ref_t *ref_buf = NULL;
+
+ H5TOOLS_START_DEBUG(" file=%p", (void *)stream);
+ H5TOOLS_DEBUG("rawdata file=%p", (void *)rawdatastream);
/* setup */
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
if (info->line_ncols > 0)
ncols = info->line_ncols;
- outputformat = *info;
+ outputformat = *info;
string_dataformat = *info;
/* print the matrix indices */
- string_dataformat.pindex = display_index;
-
- /* do not print indices for regions */
- if(obj_data) {
- hid_t f_type = H5Dget_type(obj_id);
-
- if (H5Tequal(f_type, H5T_STD_REF_DSETREG)) {
- /* For the region option, correct the display of indices */
- if (region_output) {
- if (!string_dataformat.pindex) {
- string_dataformat.idx_fmt = "";
- string_dataformat.idx_n_fmt = "";
- string_dataformat.idx_sep = "";
- string_dataformat.line_pre = "";
- }
- }
- else
- string_dataformat.pindex = 0;
- }
- H5Tclose(f_type);
+ string_dataformat.pindex = ctx->display_index;
+
+ if (obj_data) {
+ H5TOOLS_DEBUG("dataset");
+ f_type = H5Dget_type(obj_id);
+ space = H5Dget_space(obj_id);
+ }
+ else {
+ H5TOOLS_DEBUG("attribute");
+ f_type = H5Aget_type(obj_id);
+ space = H5Aget_space(obj_id);
}
if (string_dataformat.pindex) {
string_dataformat.idx_fmt = "(%s): ";
- string_dataformat.idx_n_fmt = HSIZE_T_FORMAT;
+ string_dataformat.idx_n_fmt = "%" PRIuHSIZE;
string_dataformat.idx_sep = ",";
string_dataformat.line_pre = "%s";
}
info = &string_dataformat;
- if (sset && obj_data) {
- hid_t f_space = H5Dget_space(obj_id);
+ if (ctx->sset && obj_data) {
+
+ h5tools_dump_subsetting_header(stream, &outputformat, ctx, H5Sget_simple_extent_ndims(space));
- h5tools_dump_subsetting_header(stream, &outputformat, ctx, sset, H5Sget_simple_extent_ndims(f_space));
- H5Sclose(f_space);
-
ctx->indent_level++;
}
-
+
ctx->need_prefix = TRUE;
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s %s", h5tools_dump_header_format->databegin, h5tools_dump_header_format->datablockbegin);
- h5tools_render_element(stream, &outputformat, ctx, &buffer, &curr_pos, ncols, 0, 0);
+ h5tools_str_append(&buffer, "%s %s", h5tools_dump_header_format->databegin,
+ h5tools_dump_header_format->datablockbegin);
+ h5tools_render_element(stream, &outputformat, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
+
+ if (H5Tget_class(f_type) == H5T_REFERENCE) {
+ ctx->indent_level++;
+ datactx = *ctx;
+ 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 - datactx.ndims=%d", ndims, datactx.ndims);
- /* Print all the values. */
- if(obj_data) {
- h5tools_context_t datactx = *ctx; /* print context */
- hid_t f_type = H5Dget_type(obj_id);
+ /* Assume entire data space to be printed */
+ H5Sget_simple_extent_dims(space, total_size, NULL);
+ init_acc_pos(datactx.ndims, total_size, datactx.acc, datactx.pos, datactx.p_min_idx);
- if((display_char && H5Tget_size(f_type) == 1) && (H5Tget_class(f_type) == H5T_INTEGER)) {
+ datactx.need_prefix = TRUE;
+
+ if (NULL !=
+ (ref_buf = (H5R_ref_t *)HDcalloc(MAX(sizeof(unsigned), sizeof(H5R_ref_t)), (size_t)ndims))) {
+ if (obj_data) {
+ if (H5Dread(obj_id, 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();
+ }
+ }
+ else {
+ if (H5Aread(obj_id, H5T_STD_REF, ref_buf) < 0) {
+ HDfree(ref_buf);
+ H5TOOLS_INFO("H5Aread reference failed");
+ H5TOOLS_GOTO_DONE_NO_RET();
+ }
+ }
+ h5tools_dump_reference(stream, &outputformat, &datactx, obj_id, ref_buf, ndims);
+ HDfree(ref_buf);
+ }
+ ctx->indent_level--;
+ }
+ else {
+ H5TOOLS_DEBUG("Print all the values");
+ datactx = *ctx;
+ string_dataformat = *info;
+ if ((datactx.display_char && H5Tget_size(f_type) == 1) && (H5Tget_class(f_type) == H5T_INTEGER)) {
+ H5TOOLS_DEBUG("Print 1-byte integer data as an ASCII character string");
/*
* Print 1-byte integer data as an ASCII character string
* instead of integers if the `-r' or `--string' command-line
@@ -3763,153 +4408,95 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info,
* We don't want to modify the global dataformat, so make a
* copy of it instead.
*/
- string_dataformat = *info;
string_dataformat.idx_fmt = "\"";
- info = &string_dataformat;
datactx.indent_level++;
datactx.need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, &datactx, 0, 0);
-
- string_dataformat = *info;
- string_dataformat.idx_fmt = "\"";
+ h5tools_simple_prefix(stream, &string_dataformat, &datactx, (hsize_t)0, 0);
+
string_dataformat.line_multi_new = 1;
- string_dataformat.str_repeat = 8;
- string_dataformat.ascii = TRUE;
- string_dataformat.elmt_suf1 = "";
- string_dataformat.elmt_suf2 = "";
- string_dataformat.line_suf = "\"";
- info = &string_dataformat;
+ string_dataformat.str_repeat = 8;
+ string_dataformat.ascii = TRUE;
+ string_dataformat.elmt_suf1 = "";
+ string_dataformat.elmt_suf2 = "";
+ string_dataformat.line_suf = "\"";
}
- else
+ else {
datactx.need_prefix = TRUE;
- status = h5tools_dump_dset(stream, info, &datactx, obj_id, -1, sset);
- if((display_char && H5Tget_size(f_type) == 1) && (H5Tget_class(f_type) == H5T_INTEGER)) {
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "\"");
- h5tools_render_element(stream, &outputformat, ctx, &buffer, &curr_pos, ncols, 0, 0);
}
- H5Tclose(f_type);
- }
- else {
- h5tools_context_t datactx = *ctx; /* print context */
- /* need to call h5tools_dump_mem for the attribute data */
- space = H5Aget_space(obj_id);
- space_type = H5Sget_simple_extent_type(space);
- if(space_type == H5S_NULL || space_type == H5S_NO_CLASS) {
- status = SUCCEED;
+
+ /* Print all the values. */
+ if (obj_data) {
+ H5TOOLS_DEBUG("h5tools_dump_dset");
+ status = h5tools_dump_dset(stream, &string_dataformat, &datactx, obj_id);
}
else {
- /* VL data special information */
- unsigned int vl_data = 0; /* contains VL datatypes */
-
- type = H5Aget_type(obj_id);
- p_type = h5tools_get_native_type(type);
-
- ndims = H5Sget_simple_extent_dims(space, size, NULL);
-
- /* Check if we have VL data in the dataset's datatype */
- if (h5tools_detect_vlen_str(p_type) == TRUE)
- vl_data = TRUE;
- if (H5Tdetect_class(p_type, H5T_VLEN) == TRUE)
- vl_data = TRUE;
-
- for (i = 0; i < ndims; i++)
- nelmts *= size[i];
-
- alloc_size = nelmts * MAX(H5Tget_size(type), H5Tget_size(p_type));
- HDassert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/
-
- if(alloc_size) {
- buf = HDmalloc((size_t)alloc_size);
- HDassert(buf);
-
- if (H5Aread(obj_id, p_type, buf) >= 0)
- if (display_char && H5Tget_size(type) == 1 && H5Tget_class(type) == H5T_INTEGER) {
- /*
- * Print 1-byte integer data as an ASCII character string
- * instead of integers if the `-r' or `--string' command-line
- * option was given.
- *
- * We don't want to modify the global dataformat, so make a
- * copy of it instead.
- */
- string_dataformat = *info;
- string_dataformat.idx_fmt = "\"";
- info = &string_dataformat;
- datactx.indent_level++;
- datactx.need_prefix = TRUE;
- h5tools_simple_prefix(stream, info, &datactx, 0, 0);
-
- string_dataformat = *info;
- string_dataformat.idx_fmt = "\"";
- string_dataformat.line_multi_new = 1;
- string_dataformat.str_repeat = 8;
- string_dataformat.ascii = TRUE;
- string_dataformat.elmt_suf1 = "";
- string_dataformat.elmt_suf2 = "";
- string_dataformat.line_suf = "\"";
- info = &string_dataformat;
- }
- else
- datactx.need_prefix = TRUE;
-
- status = h5tools_dump_mem(stream, info, &datactx, obj_id, p_type, space, buf);
- if (display_char && H5Tget_size(type) == 1 && H5Tget_class(type) == H5T_INTEGER) {
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "\"");
- h5tools_render_element(stream, &outputformat, ctx, &buffer, &curr_pos, ncols, 0, 0);
- }
-
- /* Reclaim any VL memory, if necessary */
- if (vl_data)
- H5Dvlen_reclaim(p_type, space, H5P_DEFAULT, buf);
-
- HDfree(buf);
- }
- else
+ /* need to call h5tools_dump_mem for the attribute data */
+ space_type = H5Sget_simple_extent_type(space);
+ if (space_type == H5S_NULL || space_type == H5S_NO_CLASS) {
status = SUCCEED;
-
- H5Tclose(p_type);
- H5Tclose(type);
+ }
+ else {
+ H5TOOLS_DEBUG("call h5tools_dump_mem");
+ status = h5tools_dump_mem(stream, &string_dataformat, &datactx, obj_id);
+ }
}
- H5Sclose(space);
- }
+ if (datactx.display_char && H5Tget_size(f_type) == 1 && H5Tget_class(f_type) == H5T_INTEGER) {
+ H5TOOLS_DEBUG("Print 1-byte integer data as an ASCII character string eol=%s",
+ string_dataformat.line_suf);
+ datactx.need_prefix = FALSE;
+ string_dataformat.arr_linebreak = 0;
+ string_dataformat.idx_fmt = "";
+ string_dataformat.line_multi_new = 0;
+ string_dataformat.line_suf = "";
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, "\"");
+ h5tools_render_element(stream, &string_dataformat, &datactx, &buffer, &curr_pos, (size_t)ncols,
+ (hsize_t)0, (hsize_t)0);
+ }
+ H5TOOLS_DEBUG("Print all the values Complete");
- if (status == FAIL) {
- error_msg("unable to print data\n");
- h5tools_setstatus(EXIT_FAILURE);
+ if (status == FAIL) {
+ error_msg("unable to print data\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ }
}
+done:
+ H5Sclose(space);
+ H5Tclose(f_type);
ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, &outputformat, ctx, 0, 0);
+ h5tools_simple_prefix(stream, &outputformat, ctx, (hsize_t)0, 0);
h5tools_str_reset(&buffer);
- if(HDstrlen(h5tools_dump_header_format->datablockend)) {
+ if (HDstrlen(h5tools_dump_header_format->datablockend)) {
h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datablockend);
- if(HDstrlen(h5tools_dump_header_format->dataend))
+ if (HDstrlen(h5tools_dump_header_format->dataend))
h5tools_str_append(&buffer, " ");
}
- if(HDstrlen(h5tools_dump_header_format->dataend))
+
+ if (HDstrlen(h5tools_dump_header_format->dataend))
h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->dataend);
- h5tools_render_element(stream, &outputformat, ctx, &buffer, &curr_pos, ncols, 0, 0);
+ h5tools_render_element(stream, &outputformat, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
- if (sset && obj_data) {
+ if (ctx->sset && obj_data) {
ctx->indent_level--;
-
+
ctx->need_prefix = TRUE;
- h5tools_simple_prefix(stream, &outputformat, ctx, 0, 0);
-
+ h5tools_simple_prefix(stream, &outputformat, ctx, (hsize_t)0, 0);
+
h5tools_str_reset(&buffer);
- if(HDstrlen(h5tools_dump_header_format->subsettingblockend)) {
+ if (HDstrlen(h5tools_dump_header_format->subsettingblockend)) {
h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->subsettingblockend);
- if(HDstrlen(h5tools_dump_header_format->subsettingend))
+ if (HDstrlen(h5tools_dump_header_format->subsettingend))
h5tools_str_append(&buffer, " ");
}
- if(HDstrlen(h5tools_dump_header_format->subsettingend))
+ if (HDstrlen(h5tools_dump_header_format->subsettingend))
h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->subsettingend);
- h5tools_render_element(stream, &outputformat, ctx, &buffer, &curr_pos, ncols, 0, 0);
+ h5tools_render_element(stream, &outputformat, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0,
+ (hsize_t)0);
}
h5tools_str_close(&buffer);
+ H5TOOLS_ENDDEBUG(" ");
}
-
diff --git a/tools/lib/h5tools_dump.h b/tools/lib/h5tools_dump.h
index 55e046b..c8e1992 100644
--- a/tools/lib/h5tools_dump.h
+++ b/tools/lib/h5tools_dump.h
@@ -1,23 +1,20 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Purpose: Support h5dump functions for the various tools.
*/
-#ifndef H5TOOLS_DUMP_H__
-#define H5TOOLS_DUMP_H__
+#ifndef H5TOOLS_DUMP_H
+#define H5TOOLS_DUMP_H
#include "h5tools_utils.h"
@@ -25,61 +22,75 @@
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
#ifdef __cplusplus
extern "C" {
#endif
-H5TOOLS_DLLVAR table_t *h5dump_type_table; /*type table reference for datatype dump */
+H5TOOLS_DLLVAR table_t *h5dump_type_table; /*type table reference for datatype dump */
/* Definitions of useful routines */
-H5TOOLS_DLL void h5tools_dump_init(void);
+H5TOOLS_DLL void h5tools_dump_init(void);
-H5TOOLS_DLL int h5tools_dump_dset(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx/*in,out*/, hid_t dset,
- hid_t p_typ, struct subset_t *sset);
-H5TOOLS_DLL int h5tools_dump_mem(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx/*in,out*/, hid_t obj_id,
- hid_t type, hid_t space, void *mem);
-H5TOOLS_DLL int h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t container,
- h5tools_context_t *ctx/*in,out*/, unsigned flags,
- hsize_t nelmts, hid_t type, void *_mem);
+H5TOOLS_DLL int h5tools_dump_dset(FILE *stream, const h5tool_format_t *info,
+ h5tools_context_t *ctx /*in,out*/, hid_t dset);
+H5TOOLS_DLL int h5tools_dump_mem(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx /*in,out*/,
+ hid_t obj_id);
+H5TOOLS_DLL int h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info,
+ h5tools_context_t *ctx /*in,out*/, hid_t container, unsigned flags,
+ hsize_t nelmts, hid_t type, void *_mem);
H5TOOLS_DLL void h5tools_dump_datatype(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx/*in,out*/, hid_t type);
+ h5tools_context_t *ctx /*in,out*/, hid_t type);
H5TOOLS_DLL void h5tools_dump_dataspace(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx/*in,out*/, hid_t space);
+ h5tools_context_t *ctx /*in,out*/, hid_t space);
H5TOOLS_DLL void h5tools_dump_attribute(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx/*in,out*/, hid_t oid, const char *attr_name,
- hid_t attr_id, int display_index, int display_char);
+ h5tools_context_t *ctx /*in,out*/, const char *attr_name,
+ hid_t attr_id);
H5TOOLS_DLL void h5tools_dump_oid(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx/*in,out*/, hid_t oid);
+ h5tools_context_t *ctx /*in,out*/, hid_t oid);
H5TOOLS_DLL void h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx/*in,out*/, hid_t dcpl, hid_t type_id, hid_t obj_id);
+ h5tools_context_t *ctx /*in,out*/, hid_t dcpl, hid_t type_id,
+ hid_t obj_id);
H5TOOLS_DLL void h5tools_dump_comment(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx/*in,out*/, hid_t obj_id);
-H5TOOLS_DLL void h5tools_dump_data(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx, hid_t obj_id,
- int obj_data, struct subset_t *sset, int display_index, int display_char);
+ h5tools_context_t *ctx /*in,out*/, hid_t obj_id);
+H5TOOLS_DLL void h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
+ hid_t obj_id, int obj_data);
+H5TOOLS_DLL void h5tools_dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx,
+ hid_t container, H5R_ref_t *ref_buf, int ndims);
+H5TOOLS_DLL hbool_t h5tools_dump_region_attribute(hid_t region_id, FILE *stream, const h5tool_format_t *info,
+ h5tools_context_t *ctx /*in,out*/, h5tools_str_t *buffer,
+ hsize_t *curr_pos, size_t ncols,
+ hsize_t region_elmt_counter, hsize_t elmt_counter);
+
+H5TOOLS_DLL hbool_t h5tools_dump_region_data_points(hid_t region_space, hid_t region_id, FILE *stream,
+ const h5tool_format_t *info,
+ h5tools_context_t *ctx /*in,out*/, h5tools_str_t *buffer,
+ hsize_t *curr_pos, size_t ncols,
+ hsize_t region_elmt_counter, hsize_t elmt_counter);
+
+H5TOOLS_DLL hbool_t h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, FILE *stream,
+ const h5tool_format_t *info,
+ h5tools_context_t *ctx /*in,out*/, h5tools_str_t *buffer,
+ hsize_t *curr_pos, size_t ncols,
+ hsize_t region_elmt_counter, hsize_t elmt_counter);
+
+H5TOOLS_DLL int h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer /*in,out*/,
+ const h5tool_format_t *info, h5tools_context_t *ctx /*in,out*/,
+ hid_t type, int object_search);
+H5TOOLS_DLL int h5tools_print_dataspace(h5tools_str_t *buffer /*in,out*/, hid_t space);
+H5TOOLS_DLL int h5tools_print_enum(FILE *stream, h5tools_str_t *buffer /*in,out*/,
+ const h5tool_format_t *info, h5tools_context_t *ctx /*in,out*/,
+ hid_t type);
+H5TOOLS_DLL void h5tools_print_fill_value(h5tools_str_t *buffer /*in,out*/, const h5tool_format_t *info,
+ h5tools_context_t *ctx /*in,out*/, hid_t dcpl, hid_t type_id,
+ hid_t obj_id);
+H5TOOLS_DLL void h5tools_print_packed_bits(h5tools_str_t *buffer /*in,out*/, hid_t type);
-H5TOOLS_DLL int h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer/*in,out*/,
- const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/,
- hid_t type, int object_search);
-H5TOOLS_DLL int h5tools_print_dataspace(FILE *stream, h5tools_str_t *buffer/*in,out*/,
- const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/,
- hid_t space);
-H5TOOLS_DLL int h5tools_print_enum(FILE *stream, h5tools_str_t *buffer/*in,out*/,
- const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/,
- hid_t type);
-H5TOOLS_DLL void h5tools_print_fill_value(h5tools_str_t *buffer/*in,out*/,
- const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/,
- hid_t dcpl, hid_t type_id, hid_t obj_id);
-H5TOOLS_DLL void h5tools_print_packed_bits(h5tools_str_t *buffer/*in,out*/, hid_t type);
#ifdef __cplusplus
}
#endif
-#endif /* H5TOOLS_DUMP_H__ */
-
+#endif /* H5TOOLS_DUMP_H */
diff --git a/tools/lib/h5tools_error.h b/tools/lib/h5tools_error.h
index ae549fd..5417eb9 100644
--- a/tools/lib/h5tools_error.h
+++ b/tools/lib/h5tools_error.h
@@ -1,124 +1,244 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Header file for error values, etc.
*/
-#ifndef H5TOOLS_ERROR_H_
-#define H5TOOLS_ERROR_H_
+#ifndef H5TOOLS_ERROR_H
+#define H5TOOLS_ERROR_H
#include "H5Epublic.h"
+#include "H5Eprivate.h" /* Error handling */
/* tools-HDF5 Error variables */
+H5TOOLS_DLLVAR int H5tools_INDENT_g;
H5TOOLS_DLLVAR hid_t H5tools_ERR_STACK_g;
H5TOOLS_DLLVAR hid_t H5tools_ERR_CLS_g;
H5TOOLS_DLLVAR hid_t H5E_tools_g;
H5TOOLS_DLLVAR hid_t H5E_tools_min_id_g;
-
-/* Use FUNC to safely handle variations of C99 __func__ keyword handling */
-#ifdef H5_HAVE_C99_FUNC
-#define FUNC __func__
-#elif defined(H5_HAVE_FUNCTION)
-#define FUNC __FUNCTION__
-#else
-#error "We need __func__ or __FUNCTION__ to test function names!"
-#endif
+H5TOOLS_DLLVAR hid_t H5E_tools_min_info_id_g;
+H5TOOLS_DLLVAR hid_t H5E_tools_min_dbg_id_g;
/*
* H5TOOLS_INIT_ERROR macro, used to initialize error reporting.
*/
-#define H5TOOLS_INIT_ERROR() { \
- H5tools_ERR_CLS_g = H5Eregister_class("H5tools", "HDF5:tools", lib_str); \
- H5E_tools_g= H5Ecreate_msg(H5tools_ERR_CLS_g, H5E_MAJOR, "Failure in tools library"); \
- H5E_tools_min_id_g = H5Ecreate_msg(H5tools_ERR_CLS_g, H5E_MINOR, "error in function"); \
-}
+#define H5TOOLS_INIT_ERROR() \
+ do { \
+ char lib_str[256]; \
+ \
+ /* Initialize library version string for error class */ \
+ HDsnprintf(lib_str, sizeof(lib_str), "%d.%d.%d", H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE); \
+ \
+ /* Create new HDF5 error stack for the tools to use */ \
+ if ((H5tools_ERR_STACK_g = H5Ecreate_stack()) < 0) \
+ HDfprintf(stderr, "Failed to create HDF5 tools error stack\n"); \
+ \
+ /* Register errors from the HDF5 tools as a new error class */ \
+ if ((H5tools_ERR_CLS_g = H5Eregister_class("H5tools", "HDF5:tools", lib_str)) < 0) \
+ HDfprintf(stderr, "Failed to register HDF5 tools error class\n"); \
+ \
+ /* Create a new HDF5 major error message for errors from the tools library */ \
+ if ((H5E_tools_g = H5Ecreate_msg(H5tools_ERR_CLS_g, H5E_MAJOR, "Failure in tools library")) < 0) \
+ HDfprintf(stderr, "Failed to register major error message for tools library errors\n"); \
+ \
+ /* Create a new HDF5 minor error message for errors from the tools library */ \
+ if ((H5E_tools_min_id_g = H5Ecreate_msg(H5tools_ERR_CLS_g, H5E_MINOR, "error in function")) < 0) \
+ HDfprintf(stderr, "Failed to register minor error message for tools library errors\n"); \
+ \
+ /* Create a new HDF5 minor error message for info messages from the tools library */ \
+ if ((H5E_tools_min_info_id_g = H5Ecreate_msg(H5tools_ERR_CLS_g, H5E_MINOR, "function info")) < 0) \
+ HDfprintf(stderr, "Failed to register minor error message for tools library info messages\n"); \
+ \
+ /* Create a new HDF5 minor error message for debug messages from the tools library */ \
+ if ((H5E_tools_min_dbg_id_g = H5Ecreate_msg(H5tools_ERR_CLS_g, H5E_MINOR, "function debug")) < 0) \
+ HDfprintf(stderr, "Failed to register minor error message for tools library debug messages\n"); \
+ } while (0)
/*
- * H5TOOLS_CLOSE_ERROR macro, used to initialize error reporting.
+ * H5TOOLS_CLOSE_ERROR macro, used to terminate error reporting.
*/
-#define H5TOOLS_CLOSE_ERROR() { \
- H5Eclose_msg(H5E_tools_min_id_g); \
- H5Eclose_msg(H5E_tools_g); \
- H5Eunregister_class(H5tools_ERR_CLS_g); \
-}
+#define H5TOOLS_CLOSE_ERROR() \
+ do { \
+ /* Close all error messages created by H5TOOLS_INIT_ERROR() */ \
+ if (H5Eclose_msg(H5E_tools_min_dbg_id_g) < 0) \
+ HDfprintf(stderr, "Failed to close minor error message for tools library debug messages\n"); \
+ if (H5Eclose_msg(H5E_tools_min_info_id_g) < 0) \
+ HDfprintf(stderr, "Failed to close minor error message for tools library info messages\n"); \
+ if (H5Eclose_msg(H5E_tools_min_id_g) < 0) \
+ HDfprintf(stderr, "Failed to close minor error message for tools library errors\n"); \
+ if (H5Eclose_msg(H5E_tools_g) < 0) \
+ HDfprintf(stderr, "Failed to close major error message for tools library errors\n"); \
+ \
+ /* Unregister the HDF5 tools error class */ \
+ if (H5Eunregister_class(H5tools_ERR_CLS_g) < 0) \
+ HDfprintf(stderr, "Failed to unregister the HDF5 tools error class\n"); \
+ \
+ /* Close the tools error stack */ \
+ if (H5Eclose_stack(H5tools_ERR_STACK_g) < 0) \
+ HDfprintf(stderr, "Failed to close HDF5 tools error stack\n"); \
+ } while (0)
/*
- * HERR_INIT macro, used to facilitate error reporting. Declaration and assignments of error variables.
- * Use at the beginning of a function using error handling macros.
+ * H5TOOLS_PUSH_ERROR macro, used to push an error to an error stack. Not meant to
+ * be called directly.
*/
-#define HERR_INIT(ret_typ, ret_init) \
- hbool_t past_catch = FALSE; \
- ret_typ ret_value = ret_init;
-
+#define H5TOOLS_PUSH_ERROR(estack_id, err_cls, maj_err_id, min_err_id, ...) \
+ do { \
+ if (enable_error_stack > 0) { \
+ if (estack_id >= 0 && err_cls >= 0) \
+ H5Epush2(estack_id, __FILE__, __func__, __LINE__, err_cls, maj_err_id, min_err_id, \
+ __VA_ARGS__); \
+ else { \
+ HDfprintf(stderr, __VA_ARGS__); \
+ HDfprintf(stderr, "\n"); \
+ } \
+ } \
+ } while (0)
/*
- * HERROR macro, used to facilitate error reporting . The arguments are the major
- * error number, the minor error number, and a description of the error.
+ * H5TOOLS_ERROR macro, used to facilitate error reporting within a function body.
+ * The arguments are the return value and an error string. The return value is assigned
+ * to a variable `ret_value'. This macro is meant to be used for reporting an error without
+ * having control branch to the `done' label. This is often used when an error occurs
+ * after the `done' label, in which case an infinite loop would ensue if control branched
+ * backwards.
*/
-#define HERROR(maj_id, min_id, str) { \
- H5Epush2(H5tools_ERR_STACK_g, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, maj_id, min_id, str); \
- ret_value = FAIL; \
-}
+#define H5TOOLS_ERROR(ret_val, ...) \
+ do { \
+ H5TOOLS_PUSH_ERROR(H5tools_ERR_STACK_g, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_id_g, \
+ __VA_ARGS__); \
+ ret_value = ret_val; \
+ } while (0)
-
-/* Macro for "catching" flow of control when an error occurs. Note that the
- * H5_LEAVE macro won't jump back here once it's past this point.
+/*
+ * H5TOOLS_GOTO_ERROR macro, used to facilitate error reporting within a function body.
+ * The arguments are the return value and an error string. The return value is assigned
+ * to a variable `ret_value' and control branches to the `done' label.
*/
-#define CATCH catch_except:; past_catch = TRUE;
+#define H5TOOLS_GOTO_ERROR(ret_val, ...) \
+ do { \
+ H5TOOLS_PUSH_ERROR(H5tools_ERR_STACK_g, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_id_g, \
+ __VA_ARGS__); \
+ H5TOOLS_GOTO_DONE(ret_val); \
+ } while (0)
/*
- * H5_LEAVE macro, used to facilitate control flow between a
- * BEGIN_FUNC() and an END_FUNC() within a function body. The argument is
- * the return value.
- * The return value is assigned to a variable `ret_value' and control branches
- * to the `catch_except' label, if we're not already past it.
+ * H5TOOLS_GOTO_DONE macro, used to facilitate normal return within a function body.
+ * The argument is the return value which is assigned to the `ret_value'
+ * variable. Control branches to the `done' label.
*/
-#define H5_LEAVE(v) { \
- ret_value = v; \
- if(!past_catch) \
- goto catch_except; \
-}
+#define H5TOOLS_GOTO_DONE(ret_val) \
+ do { \
+ ret_value = ret_val; \
+ goto done; \
+ } while (0)
/*
- * H5E_THROW macro, used to facilitate error reporting within a function body.
- * The arguments are the minor error number, and an error string.
- * The return value is assigned to a variable `ret_value' and control branches
- * to the `catch_except' label, if we're not already past it.
+ * H5TOOLS_GOTO_DONE_NO_RET macro, used to facilitate normal return within a function body.
+ * Control simply branches to the `done' label without setting any return value.
*/
-#define H5E_THROW(fail_value, min_id, str) { \
- HERROR(H5E_tools_g, min_id, str); \
- H5_LEAVE(fail_value) \
-}
+#define H5TOOLS_GOTO_DONE_NO_RET() \
+ do { \
+ goto done; \
+ } while (0)
/*
- * HGOTO_ERROR macro, used to facilitate error reporting within a function body. The arguments are
- * the major error number, the minor error number, the return value, and an
- * error string. The return value is assigned to a variable `ret_value' and
- * control branches to the `done' label.
+ * H5TOOLS_INFO macro, used to facilitate error reporting. The arguments are
+ * a description of the error.
*/
-#define HGOTO_ERROR(fail_value, min_id, str) { \
- HERROR(H5E_tools_g, min_id, str); \
- HGOTO_DONE(fail_value) \
-}
+#define H5TOOLS_INFO(...) \
+ do { \
+ H5TOOLS_PUSH_ERROR(H5tools_ERR_STACK_g, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_info_id_g, \
+ __VA_ARGS__); \
+ } while (0)
+
+#ifdef H5_TOOLS_DEBUG
+
+#define H5TOOLS_START_DEBUG(...) \
+ do { \
+ H5tools_INDENT_g += 2; \
+ HDfprintf(stderr, "%*sENTER %s:%d in %s()...", H5tools_INDENT_g, "", __FILE__, __LINE__, __func__); \
+ HDfprintf(stderr, __VA_ARGS__); \
+ HDfprintf(stderr, "\n"); \
+ HDfflush(stderr); \
+ } while (0)
+
+#define H5TOOLS_DEBUG(...) \
+ do { \
+ HDfprintf(stderr, "%*s %s:%d in %s()...", H5tools_INDENT_g, "", __FILE__, __LINE__, __func__); \
+ HDfprintf(stderr, __VA_ARGS__); \
+ HDfprintf(stderr, "\n"); \
+ HDfflush(stderr); \
+ } while (0)
+
+#define H5TOOLS_ENDDEBUG(...) \
+ do { \
+ HDfprintf(stderr, "%*sEXIT %s:%d in %s()...", H5tools_INDENT_g, "", __FILE__, __LINE__, __func__); \
+ HDfprintf(stderr, __VA_ARGS__); \
+ HDfprintf(stderr, "\n"); \
+ H5tools_INDENT_g -= 2; \
+ HDfflush(stderr); \
+ } while (0)
-/*
- * HGOTO_DONE macro, used to facilitate normal return within a function body.
- * The argument is the return value which is assigned to the `ret_value'
- * variable. Control branches to the `done' label.
+#else
+
+#define H5TOOLS_START_DEBUG(...) \
+ do { \
+ ; \
+ } while (0)
+
+#define H5TOOLS_DEBUG(...) \
+ do { \
+ ; \
+ } while (0)
+
+#define H5TOOLS_ENDDEBUG(...) \
+ do { \
+ ; \
+ } while (0)
+
+#endif
+
+/* Macro for "catching" flow of control when an error occurs. Note that the
+ * H5_LEAVE macro won't jump back here once it's past this point.
*/
-#define HGOTO_DONE(ret_val) {ret_value = ret_val; goto done;}
+#define CATCH \
+catch_except:; \
+ past_catch = TRUE;
-#endif /* H5TOOLS_ERROR_H_ */
+/*
+ * H5_LEAVE macro, used to facilitate control flow in a function. The argument
+ * is the return value. The return value is assigned to a variable `ret_value'
+ * and control branches to the `catch_except' label, if we're not already past
+ * it.
+ */
+#define H5_LEAVE(v) \
+ { \
+ ret_value = v; \
+ if (!past_catch) \
+ goto catch_except; \
+ }
+/*
+ * H5TOOLS_THROW macro, used to facilitate error reporting within a function body.
+ * The arguments are the minor error number, and an error string.
+ * The return value is assigned to a variable `ret_value' and control branches
+ * to the `catch_except' label, if we're not already past it.
+ */
+#define H5TOOLS_THROW(ret_val, ...) \
+ do { \
+ H5TOOLS_PUSH_ERROR(H5tools_ERR_STACK_g, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_id_g, \
+ __VA_ARGS__); \
+ H5_LEAVE(ret_val) \
+ } while (0)
+
+#endif /* H5TOOLS_ERROR_H */
diff --git a/tools/lib/h5tools_filters.c b/tools/lib/h5tools_filters.c
index 341a5c9..899b7be 100644
--- a/tools/lib/h5tools_filters.c
+++ b/tools/lib/h5tools_filters.c
@@ -1,234 +1,208 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#include "hdf5.h"
+#include "H5private.h"
#include "h5tools.h"
/*-------------------------------------------------------------------------
* print a warning message
*-------------------------------------------------------------------------
*/
-static void print_warning(const char *dname, const char *fname)
+static void
+print_filter_warning(const char *dname, const char *fname)
{
- fprintf(stderr,"warning: dataset <%s> cannot be read, %s filter is not available\n",
- dname,fname);
+ HDfprintf(stderr, "Warning: dataset <%s> cannot be read, %s filter is not available\n", dname, fname);
}
/*-------------------------------------------------------------------------
* Function: h5tools_canreadf
*
- * Purpose: 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
- *
- * Return: 1, can read, 0, cannot, -1 error
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: March 1, 2004
+ * Purpose: 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
*
+ * Return:
+ * 1 can read,
+ * 0 cannot,
+ * -1 error
*-------------------------------------------------------------------------
*/
-int h5tools_canreadf(const char* name, /* object name, serves also as boolean print */
- hid_t dcpl_id) /* dataset creation property list */
+int
+h5tools_canreadf(const char *name, /* object name, serves also as boolean print */
+ hid_t dcpl_id) /* dataset creation property list */
{
-
- int nfilters; /* number of filters */
- H5Z_filter_t filtn; /* filter identification number */
- int i; /* index */
-
-
- /* get information about filters */
- if ((nfilters = H5Pget_nfilters(dcpl_id))<0)
- return -1;
-
- /* if we do not have filters, we can read the dataset safely */
- if (!nfilters)
- return 1;
-
- /* check availability of filters */
- for(i = 0; i < nfilters; i++)
- {
- if((filtn = H5Pget_filter2(dcpl_id, (unsigned)i, 0, 0, 0, 0, 0, NULL)) < 0)
- return -1;
-
- switch(filtn)
- {
-/*-------------------------------------------------------------------------
- * user defined filter
- *-------------------------------------------------------------------------
- */
- default:
- if(name)
- print_warning(name, "user defined");
- return 0;
-
-/*-------------------------------------------------------------------------
- * H5Z_FILTER_DEFLATE 1 , deflation like gzip
- *-------------------------------------------------------------------------
- */
- case H5Z_FILTER_DEFLATE:
+ int nfilters; /* number of filters */
+ H5Z_filter_t filtn; /* filter identification number */
+ int i; /* index */
+ int udfilter_avail; /* index */
+ int ret_value = 1;
+
+ /* get information about filters */
+ if ((nfilters = H5Pget_nfilters(dcpl_id)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Pget_nfilters failed");
+
+ /* if we do not have filters, we can read the dataset safely */
+ if (!nfilters)
+ H5TOOLS_GOTO_DONE(1);
+
+ /* check availability of filters */
+ for (i = 0; i < nfilters; i++) {
+ if ((filtn = H5Pget_filter2(dcpl_id, (unsigned)i, 0, 0, 0, (size_t)0, 0, NULL)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Pget_filter2 failed");
+
+ switch (filtn) {
+ /*-------------------------------------------------------------------------
+ * user defined filter
+ *-------------------------------------------------------------------------
+ */
+ default:
+ if ((udfilter_avail = H5Zfilter_avail(filtn)) < 0) {
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Zfilter_avail failed");
+ }
+ else if (!udfilter_avail) {
+ if (name)
+ print_filter_warning(name, "user defined");
+ ret_value = 0;
+ }
+ break;
+
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_DEFLATE 1 , deflation like gzip
+ *-------------------------------------------------------------------------
+ */
+ case H5Z_FILTER_DEFLATE:
#ifndef H5_HAVE_FILTER_DEFLATE
- if (name)
- print_warning(name,"deflate");
- return 0;
+ if (name)
+ print_filter_warning(name, "deflate");
+ ret_value = 0;
#endif
- break;
-/*-------------------------------------------------------------------------
- * H5Z_FILTER_SZIP 4 , szip compression
- *-------------------------------------------------------------------------
- */
- case H5Z_FILTER_SZIP:
+ break;
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_SZIP 4 , szip compression
+ *-------------------------------------------------------------------------
+ */
+ case H5Z_FILTER_SZIP:
#ifndef H5_HAVE_FILTER_SZIP
- if (name)
- print_warning(name,"SZIP");
- return 0;
-#endif
- break;
-/*-------------------------------------------------------------------------
- * H5Z_FILTER_SHUFFLE 2 , shuffle the data
- *-------------------------------------------------------------------------
- */
- case H5Z_FILTER_SHUFFLE:
-#ifndef H5_HAVE_FILTER_SHUFFLE
- if (name)
- print_warning(name,"shuffle");
- return 0;
-#endif
- break;
-/*-------------------------------------------------------------------------
- * H5Z_FILTER_FLETCHER32 3 , fletcher32 checksum of EDC
- *-------------------------------------------------------------------------
- */
- case H5Z_FILTER_FLETCHER32:
-#ifndef H5_HAVE_FILTER_FLETCHER32
- if (name)
- print_warning(name,"fletcher32");
- return 0;
+ if (name)
+ print_filter_warning(name, "SZIP");
+ ret_value = 0;
#endif
- break;
-/*-------------------------------------------------------------------------
- * H5Z_FILTER_NBIT
- *-------------------------------------------------------------------------
- */
- case H5Z_FILTER_NBIT:
-#ifndef H5_HAVE_FILTER_NBIT
- if (name)
- print_warning(name,"nbit");
- return 0;
-#endif
- break;
-/*-------------------------------------------------------------------------
- * H5Z_FILTER_SCALEOFFSET
- *-------------------------------------------------------------------------
- */
- case H5Z_FILTER_SCALEOFFSET:
-#ifndef H5_HAVE_FILTER_SCALEOFFSET
- if (name)
- print_warning(name,"scaleoffset");
- return 0;
-#endif
- break;
- }/*switch*/
- }/*for*/
-
- return 1;
+ break;
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_SHUFFLE 2 , shuffle the data
+ *-------------------------------------------------------------------------
+ */
+ case H5Z_FILTER_SHUFFLE:
+ break;
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_FLETCHER32 3 , fletcher32 checksum of EDC
+ *-------------------------------------------------------------------------
+ */
+ case H5Z_FILTER_FLETCHER32:
+ break;
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_NBIT
+ *-------------------------------------------------------------------------
+ */
+ case H5Z_FILTER_NBIT:
+ break;
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_SCALEOFFSET
+ *-------------------------------------------------------------------------
+ */
+ case H5Z_FILTER_SCALEOFFSET:
+ break;
+ } /*switch*/
+ } /*for*/
+
+done:
+ return ret_value;
}
-
/*-------------------------------------------------------------------------
* Function: h5tools_canwritef
*
- * Purpose: check if the filter is available and can write data.
- * At this time, all filters that are available can write data,
- * except SZIP, which may be configured decoder-only.
- *
- * Return: 1, can write, 0, cannot, -1 error
- *
- * Programmer:
- *
- * Date: October 5, 2004
+ * Purpose: check if the filter is available and can write data.
*
+ * Return: 1 can write,
+ * 0 cannot,
+ * -1 error
*-------------------------------------------------------------------------
*/
-int h5tools_can_encode( H5Z_filter_t filtn)
+H5_ATTR_CONST int
+h5tools_can_encode(H5Z_filter_t filtn)
{
- switch (filtn)
- {
- /* user defined filter */
- default:
- return 0;
-
- case H5Z_FILTER_DEFLATE:
+ int ret_value = 1;
+
+ switch (filtn) {
+ /* user defined filter */
+ default:
+ H5TOOLS_GOTO_DONE(0);
+ break;
+ case H5Z_FILTER_DEFLATE:
#ifndef H5_HAVE_FILTER_DEFLATE
- return 0;
+ H5TOOLS_GOTO_DONE(0);
#endif
- break;
- case H5Z_FILTER_SZIP:
+ break;
+
+ case H5Z_FILTER_SZIP:
#ifndef H5_HAVE_FILTER_SZIP
- return 0;
+ H5TOOLS_GOTO_DONE(0);
#else
- {
- unsigned int filter_config_flags;
-
- if(H5Zget_filter_info(filtn, &filter_config_flags)<0)
- return -1;
- if ((filter_config_flags &
- (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) == 0) {
- /* filter present but neither encode nor decode is supported (???) */
- return -1;
- } else if ((filter_config_flags &
- (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) ==
- H5Z_FILTER_CONFIG_DECODE_ENABLED) {
- /* decoder only: read but not write */
- return 0;
- } else if ((filter_config_flags &
- (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) ==
- H5Z_FILTER_CONFIG_ENCODE_ENABLED) {
- /* encoder only: write but not read (???) */
- return -1;
- } else if ((filter_config_flags &
- (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) ==
- (H5Z_FILTER_CONFIG_ENCODE_ENABLED|H5Z_FILTER_CONFIG_DECODE_ENABLED)) {
- return 1;
- }
- }
-#endif
- break;
- case H5Z_FILTER_SHUFFLE:
-#ifndef H5_HAVE_FILTER_SHUFFLE
- return 0;
-#endif
- break;
- case H5Z_FILTER_FLETCHER32:
-#ifndef H5_HAVE_FILTER_FLETCHER32
- return 0;
+ {
+ unsigned int filter_config_flags;
+
+ if (H5Zget_filter_info(filtn, &filter_config_flags) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Zget_filter_info failed");
+ if ((filter_config_flags &
+ (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) == 0) {
+ /* filter present but neither encode nor decode is supported (???) */
+ H5TOOLS_GOTO_ERROR(FAIL, "neither encode nor decode is supported");
+ }
+ else if ((filter_config_flags &
+ (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) ==
+ H5Z_FILTER_CONFIG_DECODE_ENABLED) {
+ /* decoder only: read but not write */
+ H5TOOLS_GOTO_DONE(0);
+ }
+ else if ((filter_config_flags &
+ (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) ==
+ H5Z_FILTER_CONFIG_ENCODE_ENABLED) {
+ /* encoder only: write but not read (???) */
+ H5TOOLS_GOTO_ERROR(FAIL, "encoder only: write but not read");
+ }
+ else if ((filter_config_flags &
+ (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) ==
+ (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) {
+ H5TOOLS_GOTO_DONE(1);
+ }
+ }
#endif
- break;
- case H5Z_FILTER_NBIT:
-#ifndef H5_HAVE_FILTER_NBIT
- return 0;
-#endif
- break;
- case H5Z_FILTER_SCALEOFFSET:
-#ifndef H5_HAVE_FILTER_SCALEOFFSET
- return 0;
-#endif
- break;
- }/*switch*/
+ break;
+
+ case H5Z_FILTER_SHUFFLE:
+ break;
+
+ case H5Z_FILTER_FLETCHER32:
+ break;
+
+ case H5Z_FILTER_NBIT:
+ break;
+
+ case H5Z_FILTER_SCALEOFFSET:
+ break;
+ } /*switch*/
- return 1;
+done:
+ return ret_value;
}
diff --git a/tools/lib/h5tools_ref.c b/tools/lib/h5tools_ref.c
index caf71df..d5c1cf9 100644
--- a/tools/lib/h5tools_ref.c
+++ b/tools/lib/h5tools_ref.c
@@ -1,27 +1,22 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#include <stdio.h>
-#include <stdlib.h>
#include "h5tools_ref.h"
#include "H5private.h"
#include "H5SLprivate.h"
#include "h5tools.h"
#include "h5tools_utils.h"
#include "h5trav.h"
-
+#include "H5VLnative_private.h"
/*
* Table to look up a path name for an object
@@ -38,14 +33,14 @@
*/
typedef struct {
- haddr_t objno; /* Object ID (i.e. address) */
- const char *path; /* Object path */
+ H5O_token_t obj_token; /* Object token */
+ char *path; /* Object path */
} ref_path_node_t;
-static H5SL_t *ref_path_table = NULL; /* the "table" (implemented with a skip list) */
-static hid_t thefile = (-1);
+static H5SL_t *ref_path_table = NULL; /* the "table" (implemented with a skip list) */
+static hid_t thefile = (-1);
-static int ref_path_table_put(const char *, haddr_t objno);
+static int ref_path_table_put(const char *, const H5O_token_t *token);
/*-------------------------------------------------------------------------
* Function: free_ref_path_info
@@ -61,20 +56,20 @@ static int ref_path_table_put(const char *, haddr_t objno);
*-------------------------------------------------------------------------
*/
static herr_t
-free_ref_path_info(void *item, void UNUSED *key, void UNUSED *operator_data/*in,out*/)
+free_ref_path_info(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED *operator_data /*in,out*/)
{
ref_path_node_t *node = (ref_path_node_t *)item;
- HDfree((void *)node->path);
+ HDfree(node->path);
HDfree(node);
- return(0);
+ return (0);
}
/*-------------------------------------------------------------------------
* Function: init_ref_path_cb
*
- * Purpose: Called by interator to create references for
+ * Purpose: Called by iterator to create references for
* all objects and enter them in the table.
*
* Return: Error status.
@@ -84,22 +79,50 @@ free_ref_path_info(void *item, void UNUSED *key, void UNUSED *operator_data/*in,
*-------------------------------------------------------------------------
*/
static herr_t
-init_ref_path_cb(const char *obj_name, const H5O_info_t *oinfo,
- const char *already_seen, void UNUSED *_udata)
+init_ref_path_cb(const char *obj_name, const H5O_info2_t *oinfo, const char *already_seen,
+ void H5_ATTR_UNUSED *_udata)
{
/* Check if the object is already in the path table */
- if(NULL == already_seen) {
+ if (NULL == already_seen) {
/* Insert the object into the path table */
- ref_path_table_put(obj_name, oinfo->addr);
+ ref_path_table_put(obj_name, &oinfo->token);
} /* end if */
return 0;
}
/*-------------------------------------------------------------------------
+ * Function: ref_path_table_cmp
+ *
+ * Purpose: Skip list key comparison function which compares two
+ * H5O_token_t objects.
+ *
+ * Return: Negative (if token2 is greater than token1)
+ * 0 (if tokens are equal)
+ * or
+ * Positive (if token1 is greater than token2)
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+ref_path_table_cmp(const void *key1, const void *key2)
+{
+ const H5O_token_t *token1 = (const H5O_token_t *)key1;
+ const H5O_token_t *token2 = (const H5O_token_t *)key2;
+ int cmp_value = 0;
+
+ if (thefile > 0)
+ H5Otoken_cmp(thefile, token1, token2, &cmp_value);
+ else
+ cmp_value = HDmemcmp(token1, token2, sizeof(H5O_token_t));
+
+ return cmp_value;
+}
+
+/*-------------------------------------------------------------------------
* Function: init_ref_path_table
*
- * Purpose: Initalize the reference path table
+ * Purpose: Initialize the reference path table
*
* Return: Non-negative on success, negative on failure
*
@@ -111,19 +134,21 @@ static int
init_ref_path_table(void)
{
/* Sanity check */
- HDassert(thefile > 0);
-
- /* Create skip list to store reference path information */
- if((ref_path_table = H5SL_create(H5SL_TYPE_HADDR, NULL))==NULL)
+ if (thefile > 0) {
+ /* Create skip list to store reference path information */
+ if ((ref_path_table = H5SL_create(H5SL_TYPE_GENERIC, ref_path_table_cmp)) == NULL)
+ return (-1);
+
+ /* Iterate over objects in this file */
+ if (h5trav_visit(thefile, "/", TRUE, TRUE, init_ref_path_cb, NULL, NULL, H5O_INFO_BASIC) < 0) {
+ error_msg("unable to construct reference path table\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ } /* end if */
+
+ return (0);
+ }
+ else
return (-1);
-
- /* Iterate over objects in this file */
- if(h5trav_visit(thefile, "/", TRUE, TRUE, init_ref_path_cb, NULL, NULL) < 0) {
- error_msg("unable to construct reference path table\n");
- h5tools_setstatus(EXIT_FAILURE);
- } /* end if */
-
- return(0);
}
/*-------------------------------------------------------------------------
@@ -143,10 +168,10 @@ int
term_ref_path_table(void)
{
/* Destroy reference path table, freeing all memory */
- if(ref_path_table)
+ if (ref_path_table)
H5SL_destroy(ref_path_table, free_ref_path_info, NULL);
- return(0);
+ return (0);
}
/*-------------------------------------------------------------------------
@@ -155,8 +180,10 @@ term_ref_path_table(void)
* Purpose: Looks up a table entry given a path name.
* Used during construction of the table.
*
- * Return: The table entre (pte) or NULL if not in the
- * table.
+ * Return: Negative on failure, Non-negative on success. The object
+ * token for the table entry is returned through the token
+ * parameter if the table entry is found by the given path
+ * name.
*
* Programmer: REMcG
*
@@ -164,31 +191,35 @@ term_ref_path_table(void)
*
*-------------------------------------------------------------------------
*/
-haddr_t
-ref_path_table_lookup(const char *thepath)
+int
+ref_path_table_lookup(const char *thepath, H5O_token_t *token)
{
- H5O_info_t oi;
+ H5O_info2_t oi;
+ if ((thepath == NULL) || (HDstrlen(thepath) == 0))
+ return -1;
/* Allow lookups on the root group, even though it doesn't have any link info */
- if(HDstrcmp(thepath, "/")) {
- H5L_info_t li;
+ if (HDstrcmp(thepath, "/") != 0) {
+ H5L_info2_t li;
/* Check for external link first, so we don't return the OID of an object in another file */
- if(H5Lget_info(thefile, thepath, &li, H5P_DEFAULT) < 0)
- return HADDR_UNDEF;
+ if (H5Lget_info2(thefile, thepath, &li, H5P_DEFAULT) < 0)
+ return -1;
/* UD links can't be followed, so they always "dangle" like soft links. */
- if(li.type >= H5L_TYPE_UD_MIN)
- return HADDR_UNDEF;
+ if (li.type >= H5L_TYPE_UD_MIN)
+ return -1;
} /* end if */
/* Get the object info now */
/* (returns failure for dangling soft links) */
- if(H5Oget_info_by_name(thefile, thepath, &oi, H5P_DEFAULT) < 0)
- return HADDR_UNDEF;
+ if (H5Oget_info_by_name3(thefile, thepath, &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0)
+ return -1;
+
+ /* Return object token through parameter */
+ HDmemcpy(token, &oi.token, sizeof(H5O_token_t));
- /* Return OID */
- return(oi.addr);
+ return 0;
}
/*-------------------------------------------------------------------------
@@ -211,20 +242,21 @@ ref_path_table_lookup(const char *thepath)
*-------------------------------------------------------------------------
*/
static int
-ref_path_table_put(const char *path, haddr_t objno)
+ref_path_table_put(const char *path, const H5O_token_t *token)
{
ref_path_node_t *new_node;
- HDassert(ref_path_table);
- HDassert(path);
-
- if((new_node = HDmalloc(sizeof(ref_path_node_t))) == NULL)
- return(-1);
+ if (ref_path_table && path) {
+ if ((new_node = (ref_path_node_t *)HDmalloc(sizeof(ref_path_node_t))) == NULL)
+ return (-1);
- new_node->objno = objno;
- new_node->path = HDstrdup(path);
+ HDmemcpy(&new_node->obj_token, token, sizeof(H5O_token_t));
+ new_node->path = HDstrdup(path);
- return(H5SL_insert(ref_path_table, new_node, &(new_node->objno)));
+ return (H5SL_insert(ref_path_table, new_node, &(new_node->obj_token)));
+ }
+ else
+ return (-1);
}
/*
@@ -232,52 +264,59 @@ ref_path_table_put(const char *path, haddr_t objno)
*/
int xid = 1;
-int get_next_xid(void) {
+int
+get_next_xid(void)
+{
return xid++;
}
/*
* This counter is used to create fake object ID's
- * The idea is to set it to the largest possible offest, which
+ * The idea is to set it to the largest possible offset, which
* minimizes the chance of collision with a real object id.
*
*/
haddr_t fake_xid = HADDR_MAX;
-haddr_t
-get_fake_xid (void) {
- return (fake_xid--);
+
+void
+get_fake_token(H5O_token_t *token)
+{
+ if (thefile > 0) {
+ /* TODO: potential for this to be called with non-native connector objects */
+ if (H5VLnative_addr_to_token(thefile, fake_xid, token) < 0)
+ *token = H5O_TOKEN_UNDEF;
+ fake_xid--;
+ }
+ else
+ *token = H5O_TOKEN_UNDEF;
}
/*
- * for an object that does not have an object id (e.g., soft link),
- * create a table entry with a fake object id as the key.
+ * for an object that does not have an object token (e.g., soft link),
+ * create a table entry with a fake object token as the key.
*
* Assumes 'path' is for an object that is not in the table.
*
*/
-haddr_t
-ref_path_table_gen_fake(const char *path)
+void
+ref_path_table_gen_fake(const char *path, H5O_token_t *token)
{
- haddr_t fake_objno;
-
- /* Generate fake ID for string */
- fake_objno = get_fake_xid();
+ /* Generate fake object token for string */
+ get_fake_token(token);
/* Create ref path table, if it hasn't already been created */
- if(ref_path_table == NULL)
+ if (ref_path_table == NULL)
init_ref_path_table();
/* Insert "fake" object into table */
- ref_path_table_put(path, fake_objno);
-
- return(fake_objno);
+ ref_path_table_put(path, token);
}
/*-------------------------------------------------------------------------
* Function: lookup_ref_path
*
- * Purpose: Lookup the path to the object with refernce 'ref'.
+ * Purpose: Lookup the path to the object with the reference 'refbuf'.
*
* Return: Return a path to the object, or NULL if not found.
*
@@ -288,27 +327,56 @@ ref_path_table_gen_fake(const char *path)
*-------------------------------------------------------------------------
*/
const char *
-lookup_ref_path(haddr_t ref)
+lookup_ref_path(H5R_ref_t refbuf)
{
+ H5O_info2_t oinfo;
+ H5R_type_t ref_type;
+ hid_t ref_object;
ref_path_node_t *node;
/* Be safer for h5ls */
- if(thefile < 0)
- return(NULL);
+ if (thefile < 0)
+ return (NULL);
+
+ /* Retrieve reference type */
+ if (H5R_BADTYPE == (ref_type = H5Rget_type(&refbuf)))
+ return (NULL);
+
+ /* Open the referenced object */
+ switch (ref_type) {
+ case H5R_OBJECT1:
+ case H5R_OBJECT2:
+ if ((ref_object = H5Ropen_object(&refbuf, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ return (NULL);
+ break;
+
+ /* Invalid referenced object type */
+ case H5R_DATASET_REGION1:
+ case H5R_DATASET_REGION2:
+ case H5R_ATTR:
+ case H5R_MAXTYPE:
+ case H5R_BADTYPE:
+ default:
+ return (NULL);
+ }
+
+ /* Retrieve info about the referenced object */
+ if (H5Oget_info3(ref_object, &oinfo, H5O_INFO_ALL) < 0)
+ return (NULL);
/* Create ref path table, if it hasn't already been created */
- if(ref_path_table == NULL)
+ if (ref_path_table == NULL)
init_ref_path_table();
- node = H5SL_search(ref_path_table, &ref);
+ node = (ref_path_node_t *)H5SL_search(ref_path_table, &oinfo.token);
- return(node ? node->path : NULL);
+ return (node ? node->path : NULL);
}
/*-------------------------------------------------------------------------
* Function: fill_ref_path_table
*
- * Purpose: Called by interator to create references for
+ * Purpose: Called by iterator to create references for
* all objects and enter them in the table.
*
* Return: Error status.
@@ -327,4 +395,3 @@ fill_ref_path_table(hid_t fid)
return 0;
}
-
diff --git a/tools/lib/h5tools_ref.h b/tools/lib/h5tools_ref.h
index 7ddb91a..c747337 100644
--- a/tools/lib/h5tools_ref.h
+++ b/tools/lib/h5tools_ref.h
@@ -1,20 +1,17 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * 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 H5TOOLS_REF_H__
-#define H5TOOLS_REF_H__
+#ifndef H5TOOLS_REF_H
+#define H5TOOLS_REF_H
#include "hdf5.h"
@@ -23,11 +20,11 @@ extern "C" {
#endif
H5TOOLS_DLL herr_t fill_ref_path_table(hid_t fid);
-H5TOOLS_DLL const char *lookup_ref_path(haddr_t ref);
+H5TOOLS_DLL const char *lookup_ref_path(H5R_ref_t refbuf);
H5TOOLS_DLL int get_next_xid(void);
-H5TOOLS_DLL haddr_t get_fake_xid(void);
-H5TOOLS_DLL haddr_t ref_path_table_lookup(const char *);
-H5TOOLS_DLL haddr_t ref_path_table_gen_fake(const char *);
+H5TOOLS_DLL void get_fake_token(H5O_token_t *token);
+H5TOOLS_DLL int ref_path_table_lookup(const char *thepath, H5O_token_t *token);
+H5TOOLS_DLL void ref_path_table_gen_fake(const char *path, H5O_token_t *token);
H5TOOLS_DLL int term_ref_path_table(void);
#ifdef __cplusplus
@@ -35,4 +32,3 @@ H5TOOLS_DLL int term_ref_path_table(void);
#endif
#endif
-
diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c
index 0de126d..d9e26e7 100644
--- a/tools/lib/h5tools_str.c
+++ b/tools/lib/h5tools_str.c
@@ -1,39 +1,37 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Programmer: Bill Wendling <wendling@ncsa.uiuc.edu>
- * Monday, 19. February 2001
- *
* Purpose: These are string functions for us to use and abuse.
*/
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
#include "H5private.h"
-#include "h5tools.h" /*for h5tool_format_t structure */
+#include "h5tools.h" /* for h5tool_format_t structure */
#include "h5tools_ref.h"
-#include "h5tools_str.h" /*function prototypes */
+#include "h5tools_str.h" /* function prototypes */
+
+/* Copied from hl/src/H5LDprivate.h */
+/* Info about the list of comma-separated compound fields */
+typedef struct H5LD_memb_t {
+ size_t tot_offset;
+ size_t last_tsize;
+ hid_t last_tid;
+ char **names;
+} H5LD_memb_t;
/*
* If REPEAT_VERBOSE is defined then character strings will be printed so
* that repeated character sequences like "AAAAAAAAAA" are displayed as
*
- * 'A' repeates 9 times
+ * 'A' repeats 9 times
*
* Otherwise the format is more Perl-like
*
@@ -43,25 +41,23 @@
#define REPEAT_VERBOSE
/* Variable length string datatype */
-#define STR_INIT_LEN 4096 /*initial length */
+#define STR_INIT_LEN 4096 /*initial length */
-static char *h5tools_escape(char *s, size_t size);
-static hbool_t h5tools_str_is_zero(const void *_mem, size_t size);
-static void h5tools_print_char(h5tools_str_t *str, const h5tool_format_t *info, char ch);
+static char *h5tools_escape(char *s, size_t size);
+static hbool_t h5tools_str_is_zero(const void *_mem, size_t size);
+static void h5tools_print_char(h5tools_str_t *str, const h5tool_format_t *info, char ch);
+void h5tools_str_indent(h5tools_str_t *str, const h5tool_format_t *info, h5tools_context_t *ctx);
/*-------------------------------------------------------------------------
* Function: h5tools_str_close
*
* Purpose: Closes a string by releasing it's memory and setting the size
- * information to zero.
+ * information to zero.
*
* Return: void
*
* Programmer: Robb Matzke
* Monday, April 26, 1999
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void
@@ -77,20 +73,17 @@ h5tools_str_close(h5tools_str_t *str)
* Function: h5tools_str_len
*
* Purpose: Returns the length of the string, not counting the null
- * terminator.
+ * terminator.
*
* Return: Success: Length of string
*
- * Failure: 0
+ * Failure: 0
*
* Programmer: Robb Matzke
* Monday, April 26, 1999
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
-size_t
+H5_ATTR_PURE size_t
h5tools_str_len(h5tools_str_t *str)
{
return str->len;
@@ -100,86 +93,70 @@ h5tools_str_len(h5tools_str_t *str)
* Function: h5tools_str_append
*
* Purpose: Formats variable arguments according to printf() format
- * string and appends the result to variable length string STR.
+ * string and appends the result to variable length string STR.
*
* Return: Success: Pointer to buffer containing result.
*
- * Failure: NULL
+ * Failure: NULL
*
* Programmer: Robb Matzke
* Monday, April 26, 1999
- *
- * Modifications:
- *
- * Major change: need to check results of vsnprintf to
- * handle errors, empty format, and overflows.
- *
- * Programmer: REMcG Matzke
- * June 16, 2004
- *
*-------------------------------------------------------------------------
*/
char *
-h5tools_str_append(h5tools_str_t *str/*in,out*/, const char *fmt, ...)
+h5tools_str_append(h5tools_str_t *str /*in,out*/, const char *fmt, ...)
{
va_list ap;
/* Make sure we have some memory into which to print */
- if (!str->s || str->nalloc <= 0) {
+ if (!str->s || str->nalloc <= 0)
h5tools_str_reset(str);
- }
- if (HDstrlen(fmt) == 0) {
+ if (HDstrlen(fmt) == 0)
/* nothing to print */
return str->s;
- }
/* Format the arguments and append to the value already in `str' */
while (1) {
/* How many bytes available for new value, counting the new NUL */
- size_t avail = str->nalloc - str->len;
- int nchars = -1;
+ int nchars = -1;
+ size_t avail = str->nalloc - str->len;
HDva_start(ap, fmt);
nchars = HDvsnprintf(str->s + str->len, avail, fmt, ap);
HDva_end(ap);
- /* Note: HDvsnprintf() behaves differently on Windows as Unix, when
- * buffer is smaller than source string. On Unix, this function
- * returns length of the source string and copy string upto the
- * buffer size with NULL at the end of the buffer. However on
- * Windows with the same condition, this function returns -1 and
+ /* Note: HDvsnprintf() behaves differently on Windows as Unix, when
+ * buffer is smaller than source string. On Unix, this function
+ * returns length of the source string and copy string up to the
+ * buffer size with NULL at the end of the buffer. However on
+ * Windows with the same condition, this function returns -1 and
* doesn't add NULL at the end of the buffer.
* Because of this different return results, the strlen of the new string
* is used to handle when HDvsnprintf() returns -1 on Windows due
* to lack of buffer size, so try one more time after realloc more
- * buffer size before return NULL.
+ * buffer size before return NULL.
*/
- if (nchars < 0
-#ifndef H5_VSNPRINTF_WORKS
- && (HDstrlen(str->s) < str->nalloc)
-#endif
- ) {
+ if (nchars < 0)
/* failure, such as bad format */
return NULL;
- }
- if (nchars < 0 || (size_t) nchars >= avail || (0 == nchars && (HDstrcmp(fmt, "%s")))) {
+ if ((size_t)nchars >= avail || (0 == nchars && (HDstrcmp(fmt, "%s") != 0))) {
/* Truncation return value as documented by C99, or zero return value with either of the
* following conditions, each of which indicates that the proper C99 return value probably
* should have been positive when the format string is
* something other than "%s"
- * Alocate at least twice as much space and try again.
+ * Allocate at least twice as much space and try again.
*/
- size_t newsize = MAX(str->len + nchars + 1, 2 * str->nalloc);
+ size_t newsize = MAX(str->len + (size_t)nchars + 1, 2 * str->nalloc);
HDassert(newsize > str->nalloc); /*overflow*/
- str->s = (char*)HDrealloc(str->s, newsize);
+ str->s = (char *)HDrealloc(str->s, newsize);
HDassert(str->s);
str->nalloc = newsize;
}
else {
/* Success */
- str->len += nchars;
+ str->len += (size_t)nchars;
break;
}
}
@@ -190,31 +167,28 @@ h5tools_str_append(h5tools_str_t *str/*in,out*/, const char *fmt, ...)
* Function: h5tools_str_reset
*
* Purpose: Reset the string to the empty value. If no memory is
- * allocated yet then initialize the h5tools_str_t struct.
+ * allocated yet then initialize the h5tools_str_t struct.
*
* Return: Success: Ptr to the buffer which contains a null
- * character as the first element.
+ * character as the first element.
*
- * Failure: NULL
+ * Failure: NULL
*
* Programmer: Robb Matzke
* Monday, April 26, 1999
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
char *
-h5tools_str_reset(h5tools_str_t *str/*in,out*/)
+h5tools_str_reset(h5tools_str_t *str /*in,out*/)
{
if (!str->s || str->nalloc <= 0) {
str->nalloc = STR_INIT_LEN;
- str->s = (char*)HDmalloc(str->nalloc);
+ str->s = (char *)HDmalloc(str->nalloc);
HDassert(str->s);
}
str->s[0] = '\0';
- str->len = 0;
+ str->len = 0;
return str->s;
}
@@ -225,20 +199,17 @@ h5tools_str_reset(h5tools_str_t *str/*in,out*/)
*
* Return: Success: Pointer to the string
*
- * Failure: NULL
+ * Failure: NULL
*
* Programmer: Robb Matzke
* Monday, April 26, 1999
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
char *
-h5tools_str_trunc(h5tools_str_t *str/*in,out*/, size_t size)
+h5tools_str_trunc(h5tools_str_t *str /*in,out*/, size_t size)
{
if (size < str->len) {
- str->len = size;
+ str->len = size;
str->s[size] = '\0';
}
@@ -249,27 +220,27 @@ h5tools_str_trunc(h5tools_str_t *str/*in,out*/, size_t size)
* Function: h5tools_str_fmt
*
* Purpose: Reformat a string contents beginning at character START
- * according to printf format FMT. FMT should contain no format
- * specifiers except possibly the `%s' variety. For example, if
- * the input string is `hello' and the format is "<<%s>>" then
- * the output value will be "<<hello>>".
+ * according to printf format FMT. FMT should contain no format
+ * specifiers except possibly the `%s' variety. For example, if
+ * the input string is `hello' and the format is "<<%s>>" then
+ * the output value will be "<<hello>>".
*
* Return: Success: A pointer to the resulting string.
*
- * Failure: NULL
+ * Failure: NULL
*
* Programmer: Robb Matzke
* Monday, April 26, 1999
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
char *
-h5tools_str_fmt(h5tools_str_t *str/*in,out*/, size_t start, const char *fmt)
+h5tools_str_fmt(h5tools_str_t *str /*in,out*/, size_t start, const char *fmt)
{
char _temp[1024], *temp = _temp;
+ HDassert(str);
+ HDassert(fmt);
+
/* If the format string is simply "%s" then don't bother doing anything */
if (!HDstrcmp(fmt, "%s"))
return str->s;
@@ -281,17 +252,20 @@ h5tools_str_fmt(h5tools_str_t *str/*in,out*/, size_t start, const char *fmt)
if (HDstrchr(fmt, '%')) {
size_t n = sizeof(_temp);
if (str->len - start + 1 > n) {
- n = str->len - start + 1;
- temp = (char*)HDmalloc(n);
+ n = str->len - start + 1;
+ temp = (char *)HDmalloc(n);
HDassert(temp);
}
- HDstrncpy(temp, str->s + start, n);
+ HDstrncpy(temp, str->s + start, n - 1);
+ temp[n - 1] = '\0';
}
/* Reset the output string and append a formatted version */
h5tools_str_trunc(str, start);
+ H5_GCC_CLANG_DIAG_OFF("format-nonliteral")
h5tools_str_append(str, fmt, temp);
+ H5_GCC_CLANG_DIAG_ON("format-nonliteral")
/* Free the temp buffer if we allocated one */
if (temp != _temp)
@@ -306,53 +280,45 @@ h5tools_str_fmt(h5tools_str_t *str/*in,out*/, size_t start, const char *fmt)
* Purpose: Renders the line prefix value into string STR.
*
* Return: Success: Pointer to the prefix.
- *
- * Failure: NULL
- *
- * Programmer: Robb Matzke
- * Thursday, July 23, 1998
- *
- * Modifications:
- *
+ * Failure: NULL
*-------------------------------------------------------------------------
*/
char *
-h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info,
- hsize_t elmtno, unsigned ndims, h5tools_context_t *ctx)
+h5tools_str_prefix(h5tools_str_t *str /*in,out*/, const h5tool_format_t *info, hsize_t elmtno,
+ h5tools_context_t *ctx)
{
size_t i = 0;
- hsize_t curr_pos = elmtno;
- h5tools_str_reset(str);
+ H5TOOLS_START_DEBUG(" ");
- if (ndims > 0) {
- /*
- * Calculate the number of elements represented by a unit change in a
- * certain index position.
- */
- for (i = 0; i < (size_t) ndims; i++) {
- ctx->pos[i] = curr_pos / ctx->acc[i];
- curr_pos -= ctx->acc[i] * ctx->pos[i];
- }
- HDassert(curr_pos == 0);
+ H5TOOLS_DEBUG("elmtno=%ld, ctx->ndims=%d", elmtno, ctx->ndims);
+ h5tools_str_reset(str);
+ calc_acc_pos(ctx->ndims, elmtno, ctx->acc, ctx->pos);
+ if (ctx->ndims > 0) {
/* Print the index values */
- for (i = 0; i < (size_t) ndims; i++) {
+ for (i = 0; i < (size_t)ctx->ndims; i++) {
if (i)
h5tools_str_append(str, "%s", OPT(info->idx_sep, ","));
- h5tools_str_append(str, OPT(info->idx_n_fmt, HSIZE_T_FORMAT),
- (hsize_t) ctx->pos[i]);
-
+ H5_GCC_CLANG_DIAG_OFF("format-nonliteral")
+ h5tools_str_append(str, OPT(info->idx_n_fmt, "%" PRIuHSIZE), (hsize_t)ctx->pos[i]);
+ H5_GCC_CLANG_DIAG_ON("format-nonliteral")
}
}
else {
/* Scalar */
- h5tools_str_append(str, OPT(info->idx_n_fmt, HSIZE_T_FORMAT), (hsize_t) 0);
+ H5_GCC_CLANG_DIAG_OFF("format-nonliteral")
+ h5tools_str_append(str, OPT(info->idx_n_fmt, "%" PRIuHSIZE), (hsize_t)elmtno);
+ H5_GCC_CLANG_DIAG_ON("format-nonliteral")
}
+ H5TOOLS_DEBUG("str=%s", str->s);
+
+ H5TOOLS_ENDDEBUG(" ");
+
/* Add prefix and suffix to the index */
- return h5tools_str_fmt(str, 0, OPT(info->idx_fmt, "%s: "));
+ return h5tools_str_fmt(str, (size_t)0, OPT(info->idx_fmt, "%s: "));
}
/*-------------------------------------------------------------------------
@@ -362,63 +328,51 @@ h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info,
*
* Return: Success: Pointer to the prefix.
* Failure: NULL
- *
- * In/Out:
- * h5tools_context_t *ctx
- * h5tools_str_t *str
*-------------------------------------------------------------------------
*/
char *
-h5tools_str_region_prefix(h5tools_str_t *str, const h5tool_format_t *info,
- hsize_t elmtno, hsize_t *ptdata, unsigned ndims, hsize_t max_idx[],
- h5tools_context_t *ctx)
+h5tools_str_region_prefix(h5tools_str_t *str /*in,out*/, const h5tool_format_t *info, hsize_t elmtno,
+ const hsize_t *ptdata, h5tools_context_t *ctx)
{
- hsize_t p_prod[H5S_MAX_RANK];
size_t i = 0;
- hsize_t curr_pos = elmtno;
-
- h5tools_str_reset(str);
- if (ndims > 0) {
- /*
- * Calculate the number of elements represented by a unit change in a
- * certain index position.
- */
- for (i = ndims - 1, p_prod[ndims - 1] = 1; i > 0; --i)
- p_prod[i - 1] = (max_idx[i]) * p_prod[i];
+ H5TOOLS_START_DEBUG(" ");
- for (i = 0; i < (size_t) ndims; i++) {
- if(curr_pos > 0) {
- ctx->pos[i] = curr_pos / p_prod[i];
- curr_pos -= p_prod[i] * ctx->pos[i];
- }
- else
- ctx->pos[i] = 0;
- ctx->pos[i] += (unsigned long) ptdata[ctx->sm_pos+i];
- }
+ H5TOOLS_DEBUG("elmtno=%ld, ctx->ndims=%d", elmtno, ctx->ndims);
+ h5tools_str_reset(str);
+ calc_acc_pos(ctx->ndims, elmtno, ctx->acc, ctx->pos);
+ if (ctx->ndims > 0) {
/* Print the index values */
- for (i = 0; i < (size_t) ndims; i++) {
+ for (i = 0; i < (size_t)ctx->ndims; i++) {
+ ctx->pos[i] += (unsigned long)ptdata[ctx->sm_pos + i];
if (i)
h5tools_str_append(str, "%s", OPT(info->idx_sep, ","));
- h5tools_str_append(str, OPT(info->idx_n_fmt, HSIZE_T_FORMAT), (hsize_t) ctx->pos[i]);
-
+ H5_GCC_CLANG_DIAG_OFF("format-nonliteral")
+ h5tools_str_append(str, OPT(info->idx_n_fmt, "%" PRIuHSIZE), (hsize_t)ctx->pos[i]);
+ H5_GCC_CLANG_DIAG_ON("format-nonliteral")
}
- } /* if (ndims > 0) */
+ }
else {
/* Scalar */
- h5tools_str_append(str, OPT(info->idx_n_fmt, HSIZE_T_FORMAT), (hsize_t) 0);
+ H5_GCC_CLANG_DIAG_OFF("format-nonliteral")
+ h5tools_str_append(str, OPT(info->idx_n_fmt, "%" PRIuHSIZE), (hsize_t)0);
+ H5_GCC_CLANG_DIAG_ON("format-nonliteral")
}
+ H5TOOLS_DEBUG("str=%s", str->s);
+
+ H5TOOLS_ENDDEBUG(" ");
+
/* Add prefix and suffix to the index */
- return h5tools_str_fmt(str, 0, OPT(info->idx_fmt, "%s: "));
+ return h5tools_str_fmt(str, (size_t)0, OPT(info->idx_fmt, "%s: "));
}
/*-------------------------------------------------------------------------
- * Function: h5tools_str_dump_region_blocks
+ * Function: h5tools_str_dump_space_slabs
*
- * Purpose: Prints information about a dataspace region by appending
+ * Purpose: Prints information about a dataspace selection by appending
* the information to the specified string.
*
* Return: none
@@ -429,47 +383,114 @@ h5tools_str_region_prefix(h5tools_str_t *str, const h5tool_format_t *info,
*-------------------------------------------------------------------------
*/
void
-h5tools_str_dump_region_blocks(h5tools_str_t *str, hid_t region,
- const h5tool_format_t *info)
+h5tools_str_dump_space_slabs(h5tools_str_t *str, hid_t rspace, const h5tool_format_t *info,
+ h5tools_context_t *ctx)
+{
+ hsize_t start[H5S_MAX_RANK];
+ hsize_t stride[H5S_MAX_RANK];
+ hsize_t count[H5S_MAX_RANK];
+ hsize_t block[H5S_MAX_RANK];
+ int j;
+ int ndims = H5Sget_simple_extent_ndims(rspace);
+
+ H5Sget_regular_hyperslab(rspace, start, stride, count, block);
+
+ /* Print hyperslab information */
+
+ /* Start coordinates */
+ h5tools_str_append(str, "%s%s ", info->line_indent, START);
+ for (j = 0; j < ndims; j++)
+ h5tools_str_append(str, "%s%" PRIuHSIZE, j ? "," : "(", start[j]);
+ h5tools_str_append(str, ")");
+ h5tools_str_append(str, "%s", "\n");
+ h5tools_str_indent(str, info, ctx);
+
+ /* Stride coordinates */
+ h5tools_str_append(str, "%s ", STRIDE);
+ for (j = 0; j < ndims; j++)
+ h5tools_str_append(str, "%s%" PRIuHSIZE, j ? "," : "(", stride[j]);
+ h5tools_str_append(str, ")");
+ h5tools_str_append(str, "%s", "\n");
+ h5tools_str_indent(str, info, ctx);
+
+ /* Count coordinates */
+ h5tools_str_append(str, "%s ", COUNT);
+ for (j = 0; j < ndims; j++) {
+ if (count[j] == H5S_UNLIMITED)
+ h5tools_str_append(str, "%s%s", j ? "," : "(", "H5S_UNLIMITED");
+ else
+ h5tools_str_append(str, "%s%" PRIuHSIZE, j ? "," : "(", count[j]);
+ }
+ h5tools_str_append(str, ")");
+ h5tools_str_append(str, "%s", "\n");
+ h5tools_str_indent(str, info, ctx);
+
+ /* Block coordinates */
+ h5tools_str_append(str, "%s ", BLOCK);
+ for (j = 0; j < ndims; j++) {
+ if (block[j] == H5S_UNLIMITED)
+ h5tools_str_append(str, "%s%s", j ? "," : "(", "H5S_UNLIMITED");
+ else
+ h5tools_str_append(str, "%s%" PRIuHSIZE, j ? "," : "(", block[j]);
+ }
+ h5tools_str_append(str, ")");
+}
+
+/*-------------------------------------------------------------------------
+ * Function: h5tools_str_dump_space_blocks
+ *
+ * Purpose: Prints information about a dataspace selection by appending
+ * the information to the specified string.
+ *
+ * Return: none
+ *
+ * In/Out: h5tools_str_t *str
+ *-------------------------------------------------------------------------
+ */
+void
+h5tools_str_dump_space_blocks(h5tools_str_t *str, hid_t rspace, const h5tool_format_t *info)
{
- hssize_t nblocks;
- hsize_t alloc_size;
- hsize_t *ptdata;
- int ndims = H5Sget_simple_extent_ndims(region);
+ hssize_t snblocks;
/*
- * This function fails if the region does not have blocks.
+ * This function fails if the rspace does not have blocks.
*/
- H5E_BEGIN_TRY {
- nblocks = H5Sget_select_hyper_nblocks(region);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY
+ {
+ snblocks = H5Sget_select_hyper_nblocks(rspace);
+ }
+ H5E_END_TRY;
/* Print block information */
- if (nblocks > 0) {
- int i;
-
+ if (snblocks > 0) {
+ hsize_t alloc_size;
+ hsize_t nblocks;
+ hsize_t *ptdata;
+ hsize_t u;
+ unsigned ndims = (unsigned)H5Sget_simple_extent_ndims(rspace);
+
+ nblocks = (hsize_t)snblocks;
alloc_size = nblocks * ndims * 2 * sizeof(ptdata[0]);
- HDassert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/
- ptdata = (hsize_t *)HDmalloc((size_t) alloc_size);
- H5_CHECK_OVERFLOW(nblocks, hssize_t, hsize_t);
- H5Sget_select_hyper_blocklist(region, (hsize_t)0, (hsize_t)nblocks, ptdata);
+ HDassert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/
+ ptdata = (hsize_t *)HDmalloc((size_t)alloc_size);
+ H5Sget_select_hyper_blocklist(rspace, (hsize_t)0, nblocks, ptdata);
- for (i = 0; i < nblocks; i++) {
- int j;
+ for (u = 0; u < nblocks; u++) {
+ unsigned v;
- h5tools_str_append(str, info->dset_blockformat_pre, i ? "," OPTIONAL_LINE_BREAK " " : "",
- (unsigned long)i);
+ H5_GCC_CLANG_DIAG_OFF("format-nonliteral")
+ h5tools_str_append(str, info->dset_blockformat_pre, u ? "," OPTIONAL_LINE_BREAK " " : "",
+ (unsigned long)u);
/* Start coordinates and opposite corner */
- for (j = 0; j < ndims; j++)
- h5tools_str_append(str, "%s" HSIZE_T_FORMAT, j ? "," : "(",
- ptdata[i * 2 * ndims + j]);
+ for (v = 0; v < ndims; v++)
+ h5tools_str_append(str, "%s%" PRIuHSIZE, v ? "," : "(", ptdata[u * 2 * ndims + v]);
- for (j = 0; j < ndims; j++)
- h5tools_str_append(str, "%s" HSIZE_T_FORMAT, j ? "," : ")-(",
- ptdata[i * 2 * ndims + j + ndims]);
+ for (v = 0; v < ndims; v++)
+ h5tools_str_append(str, "%s%" PRIuHSIZE, v ? "," : ")-(", ptdata[u * 2 * ndims + v + ndims]);
h5tools_str_append(str, ")");
+ H5_GCC_CLANG_DIAG_ON("format-nonliteral")
}
HDfree(ptdata);
@@ -477,55 +498,56 @@ h5tools_str_dump_region_blocks(h5tools_str_t *str, hid_t region,
}
/*-------------------------------------------------------------------------
- * Function: h5tools_str_dump_region_points
+ * Function: h5tools_str_dump_space_points
*
- * Purpose: Prints information about a dataspace region by appending
+ * Purpose: Prints information about a dataspace selection by appending
* the information to the specified string.
*
* Return: none
*
- * In/Out:
- * h5tools_context_t *ctx
- * h5tools_str_t *str
+ * In/Out: h5tools_str_t *str
*-------------------------------------------------------------------------
*/
void
-h5tools_str_dump_region_points(h5tools_str_t *str, hid_t region,
- const h5tool_format_t *info)
+h5tools_str_dump_space_points(h5tools_str_t *str, hid_t rspace, const h5tool_format_t *info)
{
- hssize_t npoints;
- hsize_t alloc_size;
- hsize_t *ptdata;
- int ndims = H5Sget_simple_extent_ndims(region);
+ hssize_t snpoints;
/*
- * This function fails if the region does not have points.
+ * This function fails if the rspace does not have points.
*/
- H5E_BEGIN_TRY {
- npoints = H5Sget_select_elem_npoints(region);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY
+ {
+ snpoints = H5Sget_select_elem_npoints(rspace);
+ }
+ H5E_END_TRY;
/* Print point information */
- if (npoints > 0) {
- int i;
-
+ if (snpoints > 0) {
+ hsize_t alloc_size;
+ hsize_t npoints;
+ hsize_t *ptdata;
+ hsize_t u;
+ unsigned ndims = (unsigned)H5Sget_simple_extent_ndims(rspace);
+
+ npoints = (hsize_t)snpoints;
alloc_size = npoints * ndims * sizeof(ptdata[0]);
- HDassert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/
- ptdata = (hsize_t *)HDmalloc((size_t) alloc_size);
- H5_CHECK_OVERFLOW(npoints, hssize_t, hsize_t);
- H5Sget_select_elem_pointlist(region, (hsize_t)0, (hsize_t)npoints, ptdata);
+ HDassert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/
+ ptdata = (hsize_t *)HDmalloc((size_t)alloc_size);
+ H5Sget_select_elem_pointlist(rspace, (hsize_t)0, npoints, ptdata);
- for (i = 0; i < npoints; i++) {
- int j;
+ for (u = 0; u < npoints; u++) {
+ unsigned v;
- h5tools_str_append(str, info->dset_ptformat_pre, i ? "," OPTIONAL_LINE_BREAK " " : "",
- (unsigned long)i);
+ H5_GCC_CLANG_DIAG_OFF("format-nonliteral")
+ h5tools_str_append(str, info->dset_ptformat_pre, u ? "," OPTIONAL_LINE_BREAK " " : "",
+ (unsigned long)u);
- for (j = 0; j < ndims; j++)
- h5tools_str_append(str, "%s" HSIZE_T_FORMAT, j ? "," : "(",
- (ptdata[i * ndims + j]));
+ for (v = 0; v < ndims; v++)
+ h5tools_str_append(str, "%s%" PRIuHSIZE, v ? "," : "(", (ptdata[u * ndims + v]));
h5tools_str_append(str, ")");
+ H5_GCC_CLANG_DIAG_ON("format-nonliteral")
}
HDfree(ptdata);
@@ -552,73 +574,71 @@ h5tools_print_char(h5tools_str_t *str, const h5tool_format_t *info, char ch)
}
else {
switch (ch) {
- case '"':
- if (!info->do_escape)
- h5tools_str_append(str, "\"");
- else
- h5tools_str_append(str, "\\\"");
- break;
- case '\\':
- if (!info->do_escape)
- h5tools_str_append(str, "\\");
- else
- h5tools_str_append(str, "\\\\");
- break;
- case '\b':
- if (!info->do_escape)
- h5tools_str_append(str, "\b");
- else
- h5tools_str_append(str, "\\b");
- break;
- case '\f':
- if (!info->do_escape)
- h5tools_str_append(str, "\f");
- else
- h5tools_str_append(str, "\\f");
- break;
- case '\n':
- if (!info->do_escape) {
- h5tools_str_append(str, "\n");
- h5tools_str_append(str, " ");
- }
- else
- h5tools_str_append(str, "\\n");
- break;
- case '\r':
- if (!info->do_escape) {
- h5tools_str_append(str, "\r");
- h5tools_str_append(str, " ");
- }
- else
- h5tools_str_append(str, "\\r");
- break;
- case '\t':
- if (!info->do_escape)
- h5tools_str_append(str, "\t");
- else
- h5tools_str_append(str, "\\t");
- break;
- default:
- if (isprint(ch))
- h5tools_str_append(str, "%c", ch);
- else
- h5tools_str_append(str, "\\%03o", ch);
+ case '"':
+ if (!info->do_escape)
+ h5tools_str_append(str, "\"");
+ else
+ h5tools_str_append(str, "\\\"");
+ break;
+ case '\\':
+ if (!info->do_escape)
+ h5tools_str_append(str, "\\");
+ else
+ h5tools_str_append(str, "\\\\");
+ break;
+ case '\b':
+ if (!info->do_escape)
+ h5tools_str_append(str, "\b");
+ else
+ h5tools_str_append(str, "\\b");
+ break;
+ case '\f':
+ if (!info->do_escape)
+ h5tools_str_append(str, "\f");
+ else
+ h5tools_str_append(str, "\\f");
+ break;
+ case '\n':
+ if (!info->do_escape) {
+ h5tools_str_append(str, "\n");
+ h5tools_str_append(str, " ");
+ }
+ else
+ h5tools_str_append(str, "\\n");
+ break;
+ case '\r':
+ if (!info->do_escape) {
+ h5tools_str_append(str, "\r");
+ h5tools_str_append(str, " ");
+ }
+ else
+ h5tools_str_append(str, "\\r");
+ break;
+ case '\t':
+ if (!info->do_escape)
+ h5tools_str_append(str, "\t");
+ else
+ h5tools_str_append(str, "\\t");
+ break;
+ default:
+ if (isprint(ch))
+ h5tools_str_append(str, "%c", ch);
+ else
+ h5tools_str_append(str, "\\%03o", ch);
- break;
+ break;
}
}
}
void
-h5tools_str_indent(h5tools_str_t *str, const h5tool_format_t *info,
- h5tools_context_t *ctx)
+h5tools_str_indent(h5tools_str_t *str, const h5tool_format_t *info, h5tools_context_t *ctx)
{
- int i, indentlevel = 0;
+ unsigned u, indentlevel = 0;
/* Write new prefix */
- if (ctx->indent_level >= 0) {
+ if (ctx->indent_level > 0)
indentlevel = ctx->indent_level;
- }
- else {
+ else
/*
* This is because sometimes we don't print out all the header
* info for the data (like the tattr-2.ddl example). If that happens
@@ -626,699 +646,925 @@ h5tools_str_indent(h5tools_str_t *str, const h5tool_format_t *info,
* just print out the default indent levels.
*/
indentlevel = ctx->default_indent_level;
- }
- for (i = 0; i < indentlevel; i++) {
+ for (u = 0; u < indentlevel; u++)
h5tools_str_append(str, "%s", OPT(info->line_indent, ""));
- }
-
-// ctx->need_prefix = 0;
}
/*-------------------------------------------------------------------------
* Function: h5tools_str_sprint
*
- * Purpose: Renders the value pointed to by VP of type TYPE into variable
- * length string STR.
- *
- * Return: A pointer to memory containing the result or NULL on error.
- *
- * Programmer: Robb Matzke
- * Thursday, July 23, 1998
- *
- * Modifications:
- * Robb Matzke, 1999-04-26
- * Made this function safe from overflow problems by allowing it
- * to reallocate the output string.
- *
- * Robb Matzke, 1999-06-04
- * Added support for object references. The new `container'
- * argument is the dataset where the reference came from.
+ * Purpose: Renders the value pointed to by VP of type TYPE into variable
+ * length string STR.
*
- * Robb Matzke, 1999-06-07
- * Added support for printing raw data. If info->raw is non-zero
- * then data is printed in hexadecimal format.
- *
- * Robb Matzke, 2003-01-10
- * Binary output format is dd:dd:... instead of 0xdddd... so it
- * doesn't look like a hexadecimal integer, and thus users will
- * be less likely to complain that HDF5 didn't properly byte
- * swap their data during type conversion.
- *
- * Robb Matzke, LLNL, 2003-06-05
- * If TYPE is a variable length string then the pointer to
- * the value to pring (VP) is a pointer to a `char*'.
- *
- * PVN, 28 March 2006
- * added H5T_NATIVE_LDOUBLE case
- *
- * Raymond Lu, 2011-09-01
- * CLANG compiler complained about the line (about 800):
- * tempint = (tempint >> packed_data_offset) & packed_data_mask;
- * The right shift may cause undefined behavior if PACKED_DATA_OFFSET is
- * 32-bit or more. For every kind of native integers, I changed the code
- * to make it zero if PACKED_DATA_OFFSET is greater than or equal to the
- * size of integer.
+ * Return: A pointer to memory containing the result or NULL on error.
*-------------------------------------------------------------------------
*/
char *
-h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t container,
- hid_t type, void *vp, h5tools_context_t *ctx)
+h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t container, hid_t type, void *vp,
+ h5tools_context_t *ctx)
{
- size_t n, offset, size=0, nelmts, start;
- char *name;
+ size_t nsize, offset, size = 0, nelmts, start;
+ H5T_sign_t nsign;
+ char *name = NULL;
unsigned char *ucp_vp = (unsigned char *)vp;
- char *cp_vp = (char *)vp;
- hid_t memb, obj;
- unsigned nmembs;
+ char *cp_vp = (char *)vp;
+ hid_t memb = H5I_INVALID_HID;
+ hid_t obj = H5I_INVALID_HID;
static char fmt_llong[8], fmt_ullong[8];
H5T_str_t pad;
+ H5T_class_t type_class;
+ char *ret_value = NULL;
- /*
- * some tempvars to store the value before we append it to the string to
- * get rid of the memory alignment problem
- */
- unsigned long long tempullong;
- long long templlong;
- unsigned long tempulong;
- long templong;
- unsigned int tempuint;
- int tempint;
+ H5_GCC_CLANG_DIAG_OFF("format-nonliteral")
+ H5TOOLS_START_DEBUG(" ");
/* Build default formats for long long types */
if (!fmt_llong[0]) {
- HDsnprintf(fmt_llong, sizeof(fmt_llong), "%%%sd", H5_PRINTF_LL_WIDTH);
- HDsnprintf(fmt_ullong, sizeof(fmt_ullong), "%%%su", H5_PRINTF_LL_WIDTH);
+ HDsnprintf(fmt_llong, sizeof(fmt_llong), "%%lld");
+ HDsnprintf(fmt_ullong, sizeof(fmt_ullong), "%%llu");
}
/* Append value depending on data type */
start = h5tools_str_len(str);
+ nsize = H5Tget_size(type);
+ nsign = H5Tget_sign(type);
if (info->raw) {
size_t i;
- n = H5Tget_size(type);
- if (1 == n) {
+ H5TOOLS_DEBUG("info->raw");
+ if (1 == nsize)
h5tools_str_append(str, OPT(info->fmt_raw, "0x%02x"), ucp_vp[0]);
- }
- else {
- for (i = 0; i < n; i++) {
+ else
+ for (i = 0; i < nsize; i++) {
if (i)
h5tools_str_append(str, ":");
h5tools_str_append(str, OPT(info->fmt_raw, "%02x"), ucp_vp[i]);
}
- }
}
- else if (H5Tequal(type, H5T_NATIVE_FLOAT)) {
- float tempfloat;
-
- HDmemcpy(&tempfloat, vp, sizeof(float));
- h5tools_str_append(str, OPT(info->fmt_float, "%g"), tempfloat);
- }
- else if (H5Tequal(type, H5T_NATIVE_DOUBLE)) {
- double tempdouble;
-
- HDmemcpy(&tempdouble, vp, sizeof(double));
- h5tools_str_append(str, OPT(info->fmt_double, "%g"), tempdouble);
-#if H5_SIZEOF_LONG_DOUBLE !=0
- }
- else if (H5Tequal(type, H5T_NATIVE_LDOUBLE)) {
- long double templdouble;
-
- HDmemcpy(&templdouble, vp, sizeof(long double));
- h5tools_str_append(str, "%Lf", templdouble);
-#endif
- }
- else if (info->ascii && (H5Tequal(type, H5T_NATIVE_SCHAR) ||
- H5Tequal(type, H5T_NATIVE_UCHAR))) {
- h5tools_print_char(str, info, (char) (*ucp_vp));
- }
- else if (H5T_STRING == H5Tget_class(type)) {
- unsigned int i;
- char quote = '\0';
- char *s;
-
- quote = '\0';
- if (H5Tis_variable_str(type)) {
- /* cp_vp is the pointer into the struct where a `char*' is stored. So we have
- * to dereference the pointer to get the `char*' to pass to HDstrlen(). */
- s = *(char**) cp_vp;
- if (s != NULL)
- size = HDstrlen(s);
- }
- else {
- s = cp_vp;
- size = H5Tget_size(type);
+ else {
+ H5TOOLS_DEBUG("H5Tget_class(type)");
+ if ((type_class = H5Tget_class(type)) < 0) {
+ H5TOOLS_ENDDEBUG(" with %s", "NULL");
+ return NULL;
}
- pad = H5Tget_strpad(type);
+ switch (type_class) {
+ case H5T_FLOAT:
+ H5TOOLS_DEBUG("H5T_FLOAT");
+ if (sizeof(float) == nsize) {
+ /* if (H5Tequal(type, H5T_NATIVE_FLOAT)) */
+ float tempfloat;
+
+ HDmemcpy(&tempfloat, vp, sizeof(float));
+ h5tools_str_append(str, OPT(info->fmt_float, "%g"), (double)tempfloat);
+ }
+ else if (sizeof(double) == nsize) {
+ /* if (H5Tequal(type, H5T_NATIVE_DOUBLE)) */
+ double tempdouble;
- /* Check for NULL pointer for string */
- if (s == NULL) {
- h5tools_str_append(str, "NULL");
- }
- else {
- for (i = 0; i < size && (s[i] || pad != H5T_STR_NULLTERM); i++) {
- int j = 1;
-
- /*
- * Count how many times the next character repeats. If the
- * threshold is zero then that means it can repeat any number
- * of times.
- */
- if (info->str_repeat > 0)
- while (i + j < size && s[i] == s[i + j])
- j++;
-
- /*
- * Print the opening quote. If the repeat count is high enough to
- * warrant printing the number of repeats instead of enumerating
- * the characters, then make sure the character to be repeated is
- * in it's own quote.
- */
- if (info->str_repeat > 0 && j > info->str_repeat) {
- if (quote)
- h5tools_str_append(str, "%c", quote);
+ HDmemcpy(&tempdouble, vp, sizeof(double));
+ h5tools_str_append(str, OPT(info->fmt_double, "%g"), tempdouble);
+ }
+ else if (sizeof(long double) == nsize) {
+ /* if (H5Tequal(type, H5T_NATIVE_LDOUBLE)) */
+ long double templdouble;
- quote = '\'';
- h5tools_str_append(str, "%s%c", i ? " " : "", quote);
+ HDmemcpy(&templdouble, vp, sizeof(long double));
+ h5tools_str_append(str, "%Lg", templdouble);
}
- else if (!quote) {
- quote = '"';
- h5tools_str_append(str, "%s%c", i ? " " : "", quote);
+ else {
+ size_t i;
+
+ for (i = 0; i < nsize; i++) {
+ if (i)
+ h5tools_str_append(str, ":");
+ h5tools_str_append(str, OPT(info->fmt_raw, "%02x"), ucp_vp[i]);
+ }
}
+ break;
- /* Print the character */
- h5tools_print_char(str, info, s[i]);
-
- /* Print the repeat count */
- if (info->str_repeat && j > info->str_repeat) {
+ case H5T_STRING: {
+ unsigned int i;
+ char quote = '\0';
+ char *s;
+
+ H5TOOLS_DEBUG("H5T_STRING");
+ quote = '\0';
+ if (H5Tis_variable_str(type)) {
+ /* cp_vp is the pointer into the struct where a `char*' is stored. So we have
+ * to dereference the pointer to get the `char*' to pass to HDstrlen(). */
+ s = *(char **)((void *)cp_vp);
+ if (s != NULL)
+ size = HDstrlen(s);
+ }
+ else {
+ s = cp_vp;
+ size = H5Tget_size(type);
+ }
+ pad = H5Tget_strpad(type);
+
+ /* Check for NULL pointer for string */
+ if (s == NULL)
+ h5tools_str_append(str, "NULL");
+ else {
+ for (i = 0; i < size && (s[i] || pad != H5T_STR_NULLTERM); i++) {
+ unsigned j = 1;
+
+ /*
+ * Count how many times the next character repeats. If the
+ * threshold is zero then that means it can repeat any number
+ * of times.
+ */
+ if (info->str_repeat > 0)
+ while (i + j < size && s[i] == s[i + j])
+ j++;
+
+ /*
+ * Print the opening quote. If the repeat count is high enough to
+ * warrant printing the number of repeats instead of enumerating
+ * the characters, then make sure the character to be repeated is
+ * in it's own quote.
+ */
+ if (info->str_repeat > 0 && j > info->str_repeat) {
+ if (quote)
+ h5tools_str_append(str, "%c", quote);
+
+ quote = '\'';
+ h5tools_str_append(str, "%s%c", i ? " " : "", quote);
+ }
+ else if (!quote) {
+ quote = '"';
+ h5tools_str_append(str, "%s%c", i ? " " : "", quote);
+ }
+
+ /* Print the character */
+ h5tools_print_char(str, info, s[i]);
+
+ /* Print the repeat count */
+ if (info->str_repeat && j > info->str_repeat) {
#ifdef REPEAT_VERBOSE
- h5tools_str_append(str, "%c repeats %d times", quote, j - 1);
+ h5tools_str_append(str, "%c repeats %d times", quote, j - 1);
#else
- h5tools_str_append(str, "%c*%d", quote, j - 1);
-#endif /* REPEAT_VERBOSE */
- quote = '\0';
- i += j - 1;
+ h5tools_str_append(str, "%c*%d", quote, j - 1);
+#endif /* REPEAT_VERBOSE */
+ quote = '\0';
+ i += j - 1;
+ }
+ }
+
+ if (quote)
+ h5tools_str_append(str, "%c", quote);
+
+ if (i == 0)
+ /*empty string*/
+ h5tools_str_append(str, "\"\"");
+ } /* end else */
+ } break;
+
+ case H5T_INTEGER:
+ H5TOOLS_DEBUG("H5T_INTEGER");
+ if (sizeof(char) == nsize) {
+ if (info->ascii)
+ h5tools_print_char(str, info, (char)(*ucp_vp));
+ else if (H5T_SGN_NONE == nsign) {
+ unsigned char tempuchar;
+
+ HDmemcpy(&tempuchar, ucp_vp, sizeof(unsigned char));
+ if (packed_bits_num) {
+ if (packed_data_offset >= 8 * sizeof(unsigned char))
+ tempuchar = 0;
+ else
+ tempuchar =
+ (unsigned char)((unsigned long long)(tempuchar >> packed_data_offset) &
+ packed_data_mask);
+ }
+ h5tools_str_append(str, OPT(info->fmt_uchar, "%hhu"), tempuchar);
+ }
+ else {
+ signed char tempchar;
+
+ HDmemcpy(&tempchar, cp_vp, sizeof(char));
+ if (packed_bits_num) {
+ if (packed_data_offset >= 8 * sizeof(char))
+ tempchar = 0;
+ else
+ tempchar =
+ (signed char)((unsigned long long)(tempchar >> packed_data_offset) &
+ packed_data_mask);
+ }
+ h5tools_str_append(str, OPT(info->fmt_schar, "%hhd"), tempchar);
+ }
+ } /* end if (sizeof(char) == nsize) */
+ else if (sizeof(int) == nsize) {
+ if (H5T_SGN_NONE == nsign) {
+ unsigned int tempuint;
+
+ HDmemcpy(&tempuint, vp, sizeof(unsigned int));
+ if (packed_bits_num) {
+ if (packed_data_offset >= 8 * sizeof(unsigned int))
+ tempuint = 0;
+ else
+ tempuint = (unsigned)((tempuint >> packed_data_offset) & packed_data_mask);
+ }
+ h5tools_str_append(str, OPT(info->fmt_uint, "%u"), tempuint);
+ }
+ else {
+ int tempint;
+
+ HDmemcpy(&tempint, vp, sizeof(int));
+ if (packed_bits_num) {
+ if (packed_data_offset >= 8 * sizeof(int))
+ tempint = 0;
+ else
+ tempint = (int)((unsigned long long)(tempint >> packed_data_offset) &
+ packed_data_mask);
+ }
+ h5tools_str_append(str, OPT(info->fmt_int, "%d"), tempint);
+ }
+ } /* end if (sizeof(int) == nsize) */
+ else if (sizeof(short) == nsize) {
+ if (H5T_SGN_NONE == nsign) {
+ unsigned short tempushort;
+
+ HDmemcpy(&tempushort, vp, sizeof(unsigned short));
+ if (packed_bits_num) {
+ if (packed_data_offset >= 8 * sizeof(unsigned short))
+ tempushort = 0;
+ else
+ tempushort =
+ (unsigned short)((unsigned long long)(tempushort >> packed_data_offset) &
+ packed_data_mask);
+ }
+ h5tools_str_append(str, OPT(info->fmt_ushort, "%hu"), tempushort);
+ }
+ else {
+ short tempshort;
+
+ HDmemcpy(&tempshort, vp, sizeof(short));
+ if (packed_bits_num) {
+ if (packed_data_offset >= 8 * sizeof(short))
+ tempshort = 0;
+ else
+ tempshort = (short)((unsigned long long)(tempshort >> packed_data_offset) &
+ packed_data_mask);
+ }
+ h5tools_str_append(str, OPT(info->fmt_short, "%hd"), tempshort);
+ }
+ } /* end if (sizeof(short) == nsize) */
+ else if (sizeof(long) == nsize) {
+ if (H5T_SGN_NONE == nsign) {
+ unsigned long tempulong;
+
+ HDmemcpy(&tempulong, vp, sizeof(unsigned long));
+ if (packed_bits_num) {
+ if (packed_data_offset >= 8 * sizeof(unsigned long))
+ tempulong = 0;
+ else
+ tempulong = (tempulong >> packed_data_offset) & packed_data_mask;
+ }
+ h5tools_str_append(str, OPT(info->fmt_ulong, "%lu"), tempulong);
+ }
+ else {
+ long templong;
+
+ HDmemcpy(&templong, vp, sizeof(long));
+ if (packed_bits_num) {
+ if (packed_data_offset >= 8 * sizeof(long))
+ templong = 0;
+ else
+ templong = (long)((unsigned long long)(templong >> packed_data_offset) &
+ packed_data_mask);
+ }
+ h5tools_str_append(str, OPT(info->fmt_long, "%ld"), templong);
+ }
+ } /* end if (sizeof(long) == nsize) */
+#if H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG
+ else if (sizeof(long long) == nsize) {
+ if (H5T_SGN_NONE == nsign) {
+ unsigned long long tempullong;
+
+ HDmemcpy(&tempullong, vp, sizeof(unsigned long long));
+ if (packed_bits_num) {
+ if (packed_data_offset >= 8 * sizeof(unsigned long long))
+ tempullong = 0;
+ else
+ tempullong = (tempullong >> packed_data_offset) & packed_data_mask;
+ }
+ h5tools_str_append(str, OPT(info->fmt_ullong, fmt_ullong), tempullong);
+ }
+ else {
+ long long templlong;
+
+ HDmemcpy(&templlong, vp, sizeof(long long));
+ if (packed_bits_num) {
+ if (packed_data_offset >= 8 * sizeof(long long))
+ templlong = 0;
+ else
+ templlong = (templlong >> packed_data_offset) & packed_data_mask;
+ }
+ h5tools_str_append(str, OPT(info->fmt_llong, fmt_llong), templlong);
+ }
+ } /* end if (sizeof(long long) == nsize) */
+#endif /* H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG */
+ break;
+
+ case H5T_COMPOUND:
+ H5TOOLS_DEBUG("H5T_COMPOUND");
+ if (ctx->cmpd_listv) { /* there is <list_of_fields> */
+ unsigned save_indent_level; /* The indentation level */
+ size_t curr_field; /* Current field to display */
+ int i = 0; /* Local index variable */
+ unsigned x = 0; /* Local index variable */
+ const H5LD_memb_t *const *listv; /* Vector of information for <list_of_fields> */
+
+ listv = ctx->cmpd_listv;
+ ctx->cmpd_listv = NULL;
+
+ h5tools_str_append(str, "%s", OPT(info->cmpd_pre, "{"));
+
+ /*
+ * Go through the vector containing info about the comma-separated list of
+ * compound fields and then members in each field:
+ * put in "{", "}", ",", member name and value accordingly.
+ */
+ save_indent_level = ctx->indent_level;
+ for (curr_field = 0; listv[curr_field] != NULL; curr_field++) {
+ if (curr_field)
+ h5tools_str_append(str, "%s", OPT(info->cmpd_sep, ", " OPTIONAL_LINE_BREAK));
+ else
+ h5tools_str_append(str, "%s", OPT(info->cmpd_end, ""));
+
+ if (info->arr_linebreak)
+ h5tools_str_indent(str, info, ctx);
+
+ /* Process members of each field */
+ for (i = 0; listv[curr_field]->names[i] != NULL; i++) {
+ h5tools_str_append(str, OPT(info->cmpd_name, ""), listv[curr_field]->names[i]);
+ if (i) {
+ ctx->indent_level++;
+ h5tools_str_append(str, "%s", OPT(info->cmpd_pre, "{"));
+ }
+ }
+ h5tools_str_sprint(str, info, container, listv[curr_field]->last_tid,
+ cp_vp + listv[curr_field]->tot_offset, ctx);
+ if (ctx->indent_level > 0)
+ for (x = ctx->indent_level; x > 0; x--)
+ h5tools_str_append(str, "%s", OPT(info->cmpd_suf, "}"));
+ ctx->indent_level = save_indent_level;
+ }
+
+ if (info->arr_linebreak) {
+ h5tools_str_append(str, "%s", OPT(info->cmpd_end, ""));
+ h5tools_str_indent(str, info, ctx);
+ }
+ h5tools_str_append(str, "%s", OPT(info->cmpd_suf, "}"));
+
+ ctx->cmpd_listv = info->cmpd_listv;
}
+ else {
+ int retvalue;
- }
+ retvalue = H5Tget_nmembers(type);
+ if (retvalue >= 0) {
+ unsigned j;
+ unsigned nmembs = (unsigned)retvalue;
- if (quote)
- h5tools_str_append(str, "%c", quote);
+ h5tools_str_append(str, "%s", OPT(info->cmpd_pre, "{"));
- if (i == 0)
- /*empty string*/
- h5tools_str_append(str, "\"\"");
- } /* end else */
- }
- else if (H5Tequal(type, H5T_NATIVE_INT)) {
- HDmemcpy(&tempint, vp, sizeof(int));
- if(packed_bits_num) {
- if(packed_data_offset >= 8*sizeof(int))
- tempint = 0;
- else
- tempint = (tempint >> packed_data_offset) & packed_data_mask;
- }
- h5tools_str_append(str, OPT(info->fmt_int, "%d"), tempint);
- }
- else if (H5Tequal(type, H5T_NATIVE_UINT)) {
- HDmemcpy(&tempuint, vp, sizeof(unsigned int));
- if(packed_bits_num) {
- if(packed_data_offset >= 8*sizeof(unsigned int))
- tempuint = 0;
- else
- tempuint = (tempuint >> packed_data_offset) & packed_data_mask;
- }
- h5tools_str_append(str, OPT(info->fmt_uint, "%u"), tempuint);
- }
- else if (H5Tequal(type, H5T_NATIVE_SCHAR)) {
- signed char tempchar;
- HDmemcpy(&tempchar, cp_vp, sizeof(char));
- if(packed_bits_num) {
- if(packed_data_offset >= 8*sizeof(char))
- tempchar = 0;
- else
- tempchar = (tempchar >> packed_data_offset) & packed_data_mask;
- }
-#ifdef H5_VMS
- h5tools_str_append(str, OPT(info->fmt_schar, "%hd"), tempchar);
-#else
- h5tools_str_append(str, OPT(info->fmt_schar, "%hhd"), tempchar);
-#endif
- }
- else if (H5Tequal(type, H5T_NATIVE_UCHAR)) {
- unsigned char tempuchar;
- HDmemcpy(&tempuchar, ucp_vp, sizeof(unsigned char));
- if(packed_bits_num) {
- if(packed_data_offset >= 8*sizeof(unsigned char))
- tempuchar = 0;
- else
- tempuchar = (tempuchar >> packed_data_offset) & packed_data_mask;
- }
- h5tools_str_append(str, OPT(info->fmt_uchar, "%u"), tempuchar);
- }
- else if (H5Tequal(type, H5T_NATIVE_SHORT)) {
- short tempshort;
-
- HDmemcpy(&tempshort, vp, sizeof(short));
- if(packed_bits_num) {
- if(packed_data_offset >= 8*sizeof(short))
- tempshort = 0;
- else
- tempshort = (tempshort >> packed_data_offset) & packed_data_mask;
- }
- h5tools_str_append(str, OPT(info->fmt_short, "%d"), tempshort);
- }
- else if (H5Tequal(type, H5T_NATIVE_USHORT)) {
- unsigned short tempushort;
-
- HDmemcpy(&tempushort, vp, sizeof(unsigned short));
- if(packed_bits_num) {
- if(packed_data_offset >= 8*sizeof(unsigned short))
- tempushort = 0;
- else
- tempushort = (tempushort >> packed_data_offset) & packed_data_mask;
- }
- h5tools_str_append(str, OPT(info->fmt_ushort, "%u"), tempushort);
- }
- else if (H5Tequal(type, H5T_NATIVE_LONG)) {
- HDmemcpy(&templong, vp, sizeof(long));
- if(packed_bits_num) {
- if(packed_data_offset >= 8*sizeof(long))
- templong = 0;
- else
- templong = (templong >> packed_data_offset) & packed_data_mask;
- }
- h5tools_str_append(str, OPT(info->fmt_long, "%ld"), templong);
- }
- else if (H5Tequal(type, H5T_NATIVE_ULONG)) {
- HDmemcpy(&tempulong, vp, sizeof(unsigned long));
- if(packed_bits_num) {
- if(packed_data_offset >= 8*sizeof(unsigned long))
- tempulong = 0;
- else
- tempulong = (tempulong >> packed_data_offset) & packed_data_mask;
- }
- h5tools_str_append(str, OPT(info->fmt_ulong, "%lu"), tempulong);
- }
- else if (H5Tequal(type, H5T_NATIVE_LLONG)) {
- HDmemcpy(&templlong, vp, sizeof(long long));
- if(packed_bits_num) {
- if(packed_data_offset >= 8*sizeof(long long))
- templlong = 0;
- else
- templlong = (templlong >> packed_data_offset) & packed_data_mask;
- }
- h5tools_str_append(str, OPT(info->fmt_llong, fmt_llong), templlong);
- }
- else if (H5Tequal(type, H5T_NATIVE_ULLONG)) {
- HDmemcpy(&tempullong, vp, sizeof(unsigned long long));
- if(packed_bits_num) {
- if(packed_data_offset >= 8*sizeof(unsigned long long))
- tempullong = 0;
- else
- tempullong = (tempullong >> packed_data_offset) & packed_data_mask;
- }
- h5tools_str_append(str, OPT(info->fmt_ullong, fmt_ullong), tempullong);
- }
- else if (H5Tequal(type, H5T_NATIVE_HSSIZE)) {
- if (sizeof(hssize_t) == sizeof(int)) {
- HDmemcpy(&tempint, vp, sizeof(int));
- h5tools_str_append(str, OPT(info->fmt_int, "%d"), tempint);
- }
- else if (sizeof(hssize_t) == sizeof(long)) {
- HDmemcpy(&templong, vp, sizeof(long));
- h5tools_str_append(str, OPT(info->fmt_long, "%ld"), templong);
- }
- else {
- HDmemcpy(&templlong, vp, sizeof(long long));
- h5tools_str_append(str, OPT(info->fmt_llong, fmt_llong), templlong);
- }
- }
- else if (H5Tequal(type, H5T_NATIVE_HSIZE)) {
- if (sizeof(hsize_t) == sizeof(int)) {
- HDmemcpy(&tempuint, vp, sizeof(unsigned int));
- h5tools_str_append(str, OPT(info->fmt_uint, "%u"), tempuint);
- }
- else if (sizeof(hsize_t) == sizeof(long)) {
- HDmemcpy(&tempulong, vp, sizeof(long));
- h5tools_str_append(str, OPT(info->fmt_ulong, "%lu"), tempulong);
- }
- else {
- HDmemcpy(&tempullong, vp, sizeof(unsigned long long));
- h5tools_str_append(str, OPT(info->fmt_ullong, fmt_ullong), tempullong);
- }
- }
- else if (H5Tget_class(type) == H5T_COMPOUND) {
- unsigned j;
+ ctx->indent_level++;
- nmembs = H5Tget_nmembers(type);
- h5tools_str_append(str, "%s", OPT(info->cmpd_pre, "{"));
+ for (j = 0; j < nmembs; j++) {
+ if (j)
+ h5tools_str_append(str, "%s", OPT(info->cmpd_sep, ", " OPTIONAL_LINE_BREAK));
+ else
+ h5tools_str_append(str, "%s", OPT(info->cmpd_end, ""));
- ctx->indent_level++;
+ if (info->arr_linebreak)
+ h5tools_str_indent(str, info, ctx);
- for (j = 0; j < nmembs; j++) {
- if (j)
- h5tools_str_append(str, "%s", OPT(info->cmpd_sep, ", "OPTIONAL_LINE_BREAK));
- else
- h5tools_str_append(str, "%s", OPT(info->cmpd_end, ""));
+ /* The name */
+ name = H5Tget_member_name(type, j);
+ h5tools_str_append(str, OPT(info->cmpd_name, ""), name);
+ H5free_memory(name);
- if(info->arr_linebreak)
- h5tools_str_indent(str, info, ctx);
-
- /* The name */
- name = H5Tget_member_name(type, j);
- h5tools_str_append(str, OPT(info->cmpd_name, ""), name);
- HDfree(name);
+ /* The value */
+ offset = H5Tget_member_offset(type, j);
+ memb = H5Tget_member_type(type, j);
- /* The value */
- offset = H5Tget_member_offset(type, j);
- memb = H5Tget_member_type(type, j);
+ h5tools_str_sprint(str, info, container, memb, cp_vp + offset, ctx);
- h5tools_str_sprint(str, info, container, memb, cp_vp + offset, ctx);
+ H5Tclose(memb);
+ }
+ ctx->indent_level--;
- H5Tclose(memb);
- }
- ctx->indent_level--;
+ if (info->arr_linebreak) {
+ h5tools_str_append(str, "%s", OPT(info->cmpd_end, ""));
+ h5tools_str_indent(str, info, ctx);
+ }
+ h5tools_str_append(str, "%s", OPT(info->cmpd_suf, "}"));
+ }
+ }
+ break;
+ case H5T_ENUM: {
+ char enum_name[1024];
+
+ H5TOOLS_DEBUG("H5T_ENUM");
+ if (H5Tenum_nameof(type, vp, enum_name, sizeof enum_name) >= 0)
+ h5tools_str_append(str, "%s", h5tools_escape(enum_name, sizeof(enum_name)));
+ else {
+ size_t i;
+ if (1 == nsize)
+ h5tools_str_append(str, "0x%02x", ucp_vp[0]);
+ else
+ for (i = 0; i < nsize; i++)
+ h5tools_str_append(str, "%s%02x", i ? ":" : "", ucp_vp[i]);
+ }
+ } break;
+
+ case H5T_REFERENCE:
+ H5TOOLS_DEBUG("H5T_REFERENCE");
+ if (h5tools_str_is_zero(vp, nsize))
+ h5tools_str_append(str, "NULL");
+ else {
+ if (H5Tequal(type, H5T_STD_REF)) {
+ H5O_type_t obj_type = -1; /* Object type */
+ H5R_type_t ref_type; /* Reference type */
+ H5R_ref_t *ref_vp = (H5R_ref_t *)vp;
+
+ H5TOOLS_DEBUG("H5T_REFERENCE:H5T_STD_REF");
+ ref_type = H5Rget_type(ref_vp);
+ H5Rget_obj_type3(ref_vp, H5P_DEFAULT, &obj_type);
+ switch (ref_type) {
+ case H5R_OBJECT1: {
+ /* Object references -- show the type and OID of the referenced object. */
+ H5O_info2_t oi;
+ char *obj_tok_str = NULL;
+
+ H5TOOLS_DEBUG("ref_type is H5R_OBJECT1");
+ if ((obj = H5Ropen_object(ref_vp, H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ H5Oget_info3(obj, &oi, H5O_INFO_BASIC);
+ H5Otoken_to_str(obj, &oi.token, &obj_tok_str);
+ }
+ else
+ H5TOOLS_ERROR(NULL, "H5Ropen_object H5R_OBJECT1 failed");
+
+ /* Print object type and close object */
+ switch (obj_type) {
+ case H5O_TYPE_GROUP:
+ h5tools_str_append(str, "%u-%s", (unsigned)oi.type, H5_TOOLS_GROUP);
+ break;
+
+ case H5O_TYPE_DATASET:
+ h5tools_str_append(str, "%u-%s", (unsigned)oi.type, H5_TOOLS_DATASET);
+ break;
+
+ case H5O_TYPE_NAMED_DATATYPE:
+ h5tools_str_append(str, "%u-%s", (unsigned)oi.type,
+ H5_TOOLS_DATATYPE);
+ break;
+
+ case H5O_TYPE_MAP:
+ case H5O_TYPE_UNKNOWN:
+ case H5O_TYPE_NTYPES:
+ default:
+ h5tools_str_append(str, "%u-%s", (unsigned)oi.type, H5_TOOLS_UNKNOWN);
+ break;
+ } /* end switch */
+
+ h5tools_str_sprint_reference(str, ref_vp);
+
+ /* Print OID */
+ if (info->obj_hidefileno)
+ h5tools_str_append(str, info->obj_format, obj_tok_str);
+ else
+ h5tools_str_append(str, info->obj_format, oi.fileno, obj_tok_str);
+
+ if (obj_tok_str) {
+ H5free_memory(obj_tok_str);
+ obj_tok_str = NULL;
+ }
+
+ if (obj >= 0)
+ if (H5Oclose(obj) < 0)
+ H5TOOLS_ERROR(NULL, "H5Oclose H5R_OBJECT1 failed");
+ }
+
+ break;
+ case H5R_DATASET_REGION1:
+ H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION1");
+ h5tools_str_append(str, H5_TOOLS_DATASET);
+ h5tools_str_sprint_reference(str, ref_vp);
+ break;
+ case H5R_OBJECT2:
+ H5TOOLS_DEBUG("ref_type is H5R_OBJECT2");
+ switch (obj_type) {
+ case H5O_TYPE_GROUP:
+ h5tools_str_append(str, H5_TOOLS_GROUP);
+ break;
+
+ case H5O_TYPE_DATASET:
+ h5tools_str_append(str, H5_TOOLS_DATASET);
+ break;
+
+ case H5O_TYPE_NAMED_DATATYPE:
+ h5tools_str_append(str, H5_TOOLS_DATATYPE);
+ break;
+
+ case H5O_TYPE_MAP:
+ case H5O_TYPE_UNKNOWN:
+ case H5O_TYPE_NTYPES:
+ default:
+ h5tools_str_append(str, H5_TOOLS_UNKNOWN);
+ break;
+ } /* end switch */
+ h5tools_str_sprint_reference(str, ref_vp);
+ break;
+ case H5R_DATASET_REGION2:
+ H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION2");
+ h5tools_str_append(str, H5_TOOLS_DATASET);
+ h5tools_str_sprint_reference(str, ref_vp);
+ break;
+ case H5R_ATTR:
+ H5TOOLS_DEBUG("ref_type is H5R_ATTR");
+ h5tools_str_append(str, H5_TOOLS_ATTRIBUTE);
+ h5tools_str_sprint_reference(str, ref_vp);
+ break;
+ case H5R_BADTYPE:
+ case H5R_MAXTYPE:
+ default:
+ break;
+ }
+ H5TOOLS_DEBUG("H5T_REFERENCE:H5T_STD_REF end");
+ }
+ else if (H5Tequal(type, H5T_STD_REF_DSETREG)) {
+ /* if(nsize == H5R_DSET_REG_REF_BUF_SIZE) */
+ H5TOOLS_DEBUG("H5T_REFERENCE:H5T_STD_REF_DSETREG");
+ h5tools_str_append(str, H5_TOOLS_DATASET);
+ h5tools_str_sprint_old_reference(str, container, H5R_DATASET_REGION, vp);
+ }
+ else if (H5Tequal(type, H5T_STD_REF_OBJ)) {
+ /* if (nsize == H5R_OBJ_REF_BUF_SIZE) */
+ /*
+ * Object references -- show the type and OID of the referenced object.
+ */
+ H5O_info2_t oi;
+ char *obj_tok_str = NULL;
+
+ H5TOOLS_DEBUG("H5T_REFERENCE:H5T_STD_REF_OBJ");
+ obj = H5Rdereference2(container, H5P_DEFAULT, H5R_OBJECT, vp);
+ H5Oget_info3(obj, &oi, H5O_INFO_BASIC);
+
+ /* Print object type and close object */
+ switch (oi.type) {
+ case H5O_TYPE_GROUP:
+ h5tools_str_append(str, H5_TOOLS_GROUP);
+ break;
+
+ case H5O_TYPE_DATASET:
+ h5tools_str_append(str, H5_TOOLS_DATASET);
+ break;
+
+ case H5O_TYPE_NAMED_DATATYPE:
+ h5tools_str_append(str, H5_TOOLS_DATATYPE);
+ break;
+
+ case H5O_TYPE_UNKNOWN:
+ case H5O_TYPE_NTYPES:
+ default:
+ h5tools_str_append(str, "%u-", (unsigned)oi.type);
+ break;
+ }
+ H5Oclose(obj);
+
+ /* Print OID */
+ H5Otoken_to_str(obj, &oi.token, &obj_tok_str);
+
+ if (info->obj_hidefileno)
+ h5tools_str_append(str, info->obj_format, obj_tok_str);
+ else
+ h5tools_str_append(str, info->obj_format, oi.fileno, obj_tok_str);
+
+ if (obj_tok_str) {
+ H5free_memory(obj_tok_str);
+ obj_tok_str = NULL;
+ }
+
+ h5tools_str_sprint_old_reference(str, container, H5R_OBJECT, vp);
+ } /* end else if (H5Tequal(type, H5T_STD_REF_OBJ)) */
+ }
+ break;
- if(info->arr_linebreak) {
- h5tools_str_append(str, "%s", OPT(info->cmpd_end, ""));
- h5tools_str_indent(str, info, ctx);
- }
- h5tools_str_append(str, "%s", OPT(info->cmpd_suf, "}"));
+ case H5T_ARRAY: {
+ int k, ndims;
+ hsize_t i, dims[H5S_MAX_RANK], temp_nelmts;
+ static int is_next_arry_elmt = 0;
+
+ H5TOOLS_DEBUG("H5T_ARRAY");
+ /* Get the array's base datatype for each element */
+ memb = H5Tget_super(type);
+ size = H5Tget_size(memb);
+ ndims = H5Tget_array_ndims(type);
+ H5Tget_array_dims2(type, dims);
+ HDassert(ndims >= 1 && ndims <= H5S_MAX_RANK);
+
+ /* Calculate the number of array elements */
+ for (k = 0, nelmts = 1; k < ndims; k++) {
+ temp_nelmts = nelmts;
+ temp_nelmts *= dims[k];
+ HDassert(temp_nelmts == (hsize_t)((size_t)temp_nelmts));
+ nelmts = (size_t)temp_nelmts;
+ }
+ /* Print the opening bracket */
+ h5tools_str_append(str, "%s", OPT(info->arr_pre, "["));
- }
- else if (H5Tget_class(type) == H5T_ENUM) {
- char enum_name[1024];
+ ctx->indent_level++;
- if (H5Tenum_nameof(type, vp, enum_name, sizeof enum_name) >= 0) {
- h5tools_str_append(str, h5tools_escape(enum_name, sizeof(enum_name)));
- }
- else {
- size_t i;
- n = H5Tget_size(type);
- if (1 == n) {
- h5tools_str_append(str, "0x%02x", ucp_vp[0]);
- }
- else {
- for (i = 0; i < n; i++)
- h5tools_str_append(str, "%s%02x", i ? ":" : "", ucp_vp[i]);
- }
- }
- }
- else if (H5Tequal(type, H5T_STD_REF_DSETREG)) {
- if (h5tools_str_is_zero(vp, H5Tget_size(type))) {
- h5tools_str_append(str, "NULL");
- }
- else {
- h5tools_str_sprint_region(str, info, container, vp);
- }
- }
- else if (H5Tequal(type, H5T_STD_REF_OBJ)) {
- /*
- * Object references -- show the type and OID of the referenced
- * object.
- */
- if (h5tools_str_is_zero(vp, H5Tget_size(type))) {
- h5tools_str_append(str, "NULL");
- }
- else {
- H5O_info_t oi;
- const char *path;
+ for (i = 0; i < nelmts; i++) {
+ if (i)
+ h5tools_str_append(str, "%s", OPT(info->arr_sep, "," OPTIONAL_LINE_BREAK));
- obj = H5Rdereference2(container, H5P_DEFAULT, H5R_OBJECT, vp);
- H5Oget_info(obj, &oi);
+ if (info->arr_linebreak && i && i % dims[ndims - 1] == 0) {
+ h5tools_str_append(str, "%s", "\n");
+ h5tools_str_indent(str, info, ctx);
- /* Print object type and close object */
- switch (oi.type) {
- case H5O_TYPE_GROUP:
- h5tools_str_append(str, H5_TOOLS_GROUP);
- break;
+ } /* end if */
+ else if (i && info->arr_sep) {
+ /* if next element begin, add next line with indent */
+ if (is_next_arry_elmt) {
+ is_next_arry_elmt = 0;
- case H5O_TYPE_DATASET:
- h5tools_str_append(str, H5_TOOLS_DATASET);
- break;
+ h5tools_str_append(str, "%s", "\n ");
+ h5tools_str_indent(str, info, ctx);
+ }
+ /* otherwise just add space */
+ else
+ h5tools_str_append(str, " ");
- case H5O_TYPE_NAMED_DATATYPE:
- h5tools_str_append(str, H5_TOOLS_DATATYPE);
- break;
+ } /* end else if */
- default:
- h5tools_str_append(str, "%u-", (unsigned) oi.type);
- break;
- } /* end switch */
- H5Oclose(obj);
-
- /* Print OID */
- if (info->obj_hidefileno)
- h5tools_str_append(str, info->obj_format, oi.addr);
- else
- h5tools_str_append(str, info->obj_format, oi.fileno, oi.addr);
-
- /* Print name */
- path = lookup_ref_path(*(haddr_t *) vp);
- if (path) {
- h5tools_str_append(str, " ");
- h5tools_str_append(str, path);
- h5tools_str_append(str, " ");
- } /* end if */
- } /* end else */
- }
- else if (H5Tget_class(type) == H5T_ARRAY) {
- int k, ndims;
- hsize_t i, dims[H5S_MAX_RANK], temp_nelmts;
- static int is_next_arry_elmt = 0;
-
- /* Get the array's base datatype for each element */
- memb = H5Tget_super(type);
- size = H5Tget_size(memb);
- ndims = H5Tget_array_ndims(type);
- H5Tget_array_dims2(type, dims);
- HDassert(ndims >= 1 && ndims <= H5S_MAX_RANK);
-
- /* Calculate the number of array elements */
- for (k = 0, nelmts = 1; k < ndims; k++) {
- temp_nelmts = nelmts;
- temp_nelmts *= dims[k];
- HDassert(temp_nelmts == (hsize_t) ((size_t) temp_nelmts));
- nelmts = (size_t) temp_nelmts;
- }
- /* Print the opening bracket */
- h5tools_str_append(str, "%s", OPT(info->arr_pre, "["));
+ /* Dump values in an array element */
+ is_next_arry_elmt = 0; /* dump all values in the array element, so turn it off */
+ h5tools_str_sprint(str, info, container, memb, cp_vp + i * size, ctx);
+ } /* end for */
- ctx->indent_level++;
+ ctx->indent_level--;
- for (i = 0; i < nelmts; i++) {
- if (i)
- h5tools_str_append(str, "%s", OPT(info->arr_sep, "," OPTIONAL_LINE_BREAK));
+ /* Print the closing bracket */
+ h5tools_str_append(str, "%s", OPT(info->arr_suf, "]"));
+ is_next_arry_elmt = 1; /* set for beginning of next array element */
+ H5Tclose(memb);
+ } break;
- if (info->arr_linebreak && i && i % dims[ndims - 1] == 0) {
- h5tools_str_append(str, "%s", "\n");
- h5tools_str_indent(str, info, ctx);
+ case H5T_VLEN: {
+ unsigned int i;
- } /* end if */
- else if (i && info->arr_sep) {
- /* if next element begin, add next line with indent */
- if (is_next_arry_elmt) {
- is_next_arry_elmt = 0;
+ H5TOOLS_DEBUG("H5T_VLEN");
+ /* Get the VL sequences's base datatype for each element */
+ memb = H5Tget_super(type);
+ size = H5Tget_size(memb);
- h5tools_str_append(str, "%s", "\n ");
- h5tools_str_indent(str, info, ctx);
+ /* Print the opening bracket */
+ h5tools_str_append(str, "%s", OPT(info->vlen_pre, "("));
- }
- /* otherwise just add space */
- else
- h5tools_str_append(str, " ");
-
- } /* end else if */
+ /* Get the number of sequence elements */
+ nelmts = ((hvl_t *)((void *)cp_vp))->len;
- /* Dump values in an array element */
- is_next_arry_elmt = 0; /* dump all values in the array element, so turn it off */
- h5tools_str_sprint(str, info, container, memb, cp_vp + i * size, ctx);
- } /* end for */
+ for (i = 0; i < nelmts; i++) {
+ H5TOOLS_DEBUG("H5T_VLEN %d of %ld", i, nelmts);
+ if (i)
+ h5tools_str_append(str, "%s", OPT(info->vlen_sep, "," OPTIONAL_LINE_BREAK));
- ctx->indent_level--;
+#ifdef LATER
+ /* Need to fix so VL data breaks at correct location on end of line -QAK */
+ if (info->arr_linebreak && h5tools_str_len(str) >= info->line_ncols) {
+ int x;
- /* Print the closing bracket */
- h5tools_str_append(str, "%s", OPT(info->arr_suf, "]"));
- is_next_arry_elmt = 1; /* set for begining of next array element */
- H5Tclose(memb);
- }
- else if (H5Tget_class(type) == H5T_VLEN) {
- unsigned int i;
+ h5tools_str_append(str, "%s", "\n");
- /* Get the VL sequences's base datatype for each element */
- memb = H5Tget_super(type);
- size = H5Tget_size(memb);
+ /* need to indent some more here */
+ if (ctx->indent_level >= 0)
+ h5tools_str_append(str, "%s", OPT(info->line_pre, ""));
- /* Print the opening bracket */
- h5tools_str_append(str, "%s", OPT(info->vlen_pre, "("));
+ for (x = 0; x < ctx->indent_level + 1; x++)
+ h5tools_str_append(str, "%s", OPT(info->line_indent, ""));
+ } /* end if */
+#endif /* LATER */
- /* Get the number of sequence elements */
- nelmts = ((hvl_t *) cp_vp)->len;
+ ctx->indent_level++;
- for (i = 0; i < nelmts; i++) {
- if (i)
- h5tools_str_append(str, "%s", OPT(info->vlen_sep, "," OPTIONAL_LINE_BREAK));
+ /* Dump the array element */
+ h5tools_str_sprint(str, info, container, memb,
+ ((char *)(((hvl_t *)((void *)cp_vp))->p)) + i * size, ctx);
-#ifdef LATER
- /* Need to fix so VL data breaks at correct location on end of line -QAK */
- if (info->arr_linebreak && h5tools_str_len(str)>=info->line_ncols) {
- int x;
+ ctx->indent_level--;
+ } /* end for */
- h5tools_str_append(str, "%s", "\n");
+ h5tools_str_append(str, "%s", OPT(info->vlen_suf, ")"));
+ H5Tclose(memb);
+ } break;
- /* need to indent some more here */
- if (ctx->indent_level >= 0)
- h5tools_str_append(str, "%s", OPT(info->line_pre, ""));
+ case H5T_TIME:
+ case H5T_BITFIELD:
+ case H5T_OPAQUE: {
+ /* All other types get printed as hexadecimal */
+ size_t i;
+
+ H5TOOLS_DEBUG("OTHER");
+ if (1 == nsize)
+ h5tools_str_append(str, "0x%02x", ucp_vp[0]);
+ else
+ for (i = 0; i < nsize; i++)
+ h5tools_str_append(str, "%s%02x", i ? ":" : "", ucp_vp[i]);
+ } break;
- for (x = 0; x < ctx->indent_level + 1; x++)
- h5tools_str_append(str,"%s",OPT(info->line_indent,""));
- } /* end if */
-#endif /* LATER */
+ case H5T_NO_CLASS:
+ case H5T_NCLASSES:
+ default:
+ h5tools_str_append(str, "invalid datatype");
+ break;
+ } /* end switch */
+ }
- ctx->indent_level++;
+ ret_value = h5tools_str_fmt(str, start, OPT(info->elmt_fmt, "%s"));
- /* Dump the array element */
- h5tools_str_sprint(str, info, container, memb,
- ((char *) (((hvl_t *) cp_vp)->p)) + i * size, ctx);
+ H5_GCC_CLANG_DIAG_ON("format-nonliteral")
- ctx->indent_level--;
- } /* end for */
+ H5TOOLS_ENDDEBUG(" with %s", ret_value);
+ return ret_value;
+}
- h5tools_str_append(str, "%s", OPT(info->vlen_suf, ")"));
- H5Tclose(memb);
+/*-------------------------------------------------------------------------
+ * Function: h5tools_str_sprint_old_reference
+ *
+ * Purpose: Object reference -- show the name of the old referenced object.
+ *
+ * Return: Nothing
+ *-------------------------------------------------------------------------
+ */
+void
+h5tools_str_sprint_old_reference(h5tools_str_t *str, hid_t container, H5R_type_t ref_type, void *vp)
+{
+ hid_t obj = H5I_INVALID_HID;
+ hid_t region = H5I_INVALID_HID;
+ char ref_name[1024];
+
+ H5TOOLS_START_DEBUG(" ");
+
+ h5tools_str_append(str, " \"");
+ if (ref_type == H5R_DATASET_REGION) {
+ obj = H5Rdereference2(container, H5P_DEFAULT, ref_type, vp);
+ if (obj >= 0) {
+ region = H5Rget_region(container, ref_type, vp);
+ if (region >= 0) {
+ H5Rget_name(obj, ref_type, vp, (char *)ref_name, 1024);
+ h5tools_str_append(str, "%s", ref_name);
+
+ H5Sclose(region);
+ } /* end if (region >= 0) */
+ H5Dclose(obj);
+ } /* end if (obj >= 0) */
}
- else {
- /* All other types get printed as hexadecimal */
- size_t i;
- n = H5Tget_size(type);
- if (1 == n) {
- h5tools_str_append(str, "0x%02x", ucp_vp[0]);
- }
- else {
- for (i = 0; i < n; i++)
- h5tools_str_append(str, "%s%02x", i ? ":" : "", ucp_vp[i]);
+ else if (ref_type == H5R_OBJECT) {
+ obj = H5Rdereference2(container, H5P_DEFAULT, ref_type, vp);
+ if (obj >= 0) {
+ H5Rget_name(obj, ref_type, vp, (char *)ref_name, 1024);
+ h5tools_str_append(str, "%s", ref_name);
+ H5Dclose(obj);
}
}
+ h5tools_str_append(str, "\"");
- return h5tools_str_fmt(str, start, OPT(info->elmt_fmt, "%s"));
+ H5TOOLS_ENDDEBUG(" ");
}
-
/*-------------------------------------------------------------------------
- * Function: h5tools_str_sprint_region
+ * Function: h5tools_str_sprint_reference
*
- * Purpose: Dataset region reference -- show the type and data of the referenced object.
+ * Purpose: Object reference -- show the name of the referenced object.
*
* Return: Nothing
*-------------------------------------------------------------------------
*/
void
-h5tools_str_sprint_region(h5tools_str_t *str, const h5tool_format_t *info,
- hid_t container, void *vp)
+h5tools_str_sprint_reference(h5tools_str_t *str, H5R_ref_t *ref_vp)
{
- hid_t obj, region;
- char ref_name[1024];
- H5S_sel_type region_type;
-
- obj = H5Rdereference2(container, H5P_DEFAULT, H5R_DATASET_REGION, vp);
- if (obj >= 0) {
- region = H5Rget_region(container, H5R_DATASET_REGION, vp);
- if (region >= 0) {
- H5Rget_name(obj, H5R_DATASET_REGION, vp, (char*) ref_name, 1024);
-
- h5tools_str_append(str, info->dset_format, ref_name);
-
- h5tools_str_append(str, "{");
+ ssize_t buf_size;
+
+ H5TOOLS_START_DEBUG(" ");
+
+ h5tools_str_append(str, " \"");
+ buf_size = H5Rget_file_name(ref_vp, NULL, 0);
+ H5TOOLS_DEBUG("buf_size=%ld", buf_size);
+ if (buf_size) {
+ char *file_name = (char *)HDmalloc(sizeof(char) * (size_t)buf_size + 1);
+ if (H5Rget_file_name(ref_vp, file_name, (size_t)buf_size + 1) >= 0) {
+ file_name[buf_size] = '\0';
+ H5TOOLS_DEBUG("name=%s", file_name);
+ h5tools_str_append(str, "%s", file_name);
+ }
+ HDfree(file_name);
+ }
- region_type = H5Sget_select_type(region);
- if(region_type==H5S_SEL_POINTS)
- h5tools_str_dump_region_points(str, region, info);
- else
- h5tools_str_dump_region_blocks(str, region, info);
+ buf_size = H5Rget_obj_name(ref_vp, H5P_DEFAULT, NULL, 0);
+ H5TOOLS_DEBUG("buf_size=%ld", buf_size);
+ if (buf_size) {
+ char *obj_name = (char *)HDmalloc(sizeof(char) * (size_t)buf_size + 1);
+ if (H5Rget_obj_name(ref_vp, H5P_DEFAULT, obj_name, (size_t)buf_size + 1) >= 0) {
+ obj_name[buf_size] = '\0';
+ H5TOOLS_DEBUG("name=%s", obj_name);
+ h5tools_str_append(str, "%s", obj_name);
+ }
+ HDfree(obj_name);
+ }
- h5tools_str_append(str, "}");
+ if (H5Rget_type(ref_vp) == H5R_ATTR) {
+ buf_size = H5Rget_attr_name(ref_vp, NULL, 0);
+ H5TOOLS_DEBUG("buf_size=%ld", buf_size);
+ if (buf_size) {
+ char *attr_name = (char *)HDmalloc(sizeof(char) * (size_t)buf_size + 1);
+ if (H5Rget_attr_name(ref_vp, attr_name, (size_t)buf_size + 1) >= 0) {
+ attr_name[buf_size] = '\0';
+ H5TOOLS_DEBUG("name=%s", attr_name);
+ h5tools_str_append(str, "/%s", attr_name);
+ }
+ HDfree(attr_name);
+ }
+ }
+ h5tools_str_append(str, "\"");
- H5Sclose(region);
- } /* end if (region >= 0) */
- H5Dclose(obj);
- } /* end if (obj >= 0) */
+ H5TOOLS_ENDDEBUG(" ");
}
/*-------------------------------------------------------------------------
- * Function: h5tools_escape
+ * Function: h5tools_escape
*
- * Purpose: Changes all "funny" characters in S into standard C escape
- * sequences.
+ * Purpose: Changes all "funny" characters in S into standard C escape
+ * sequences.
*
- * Return: Success: S
+ * Return: Success: S
*
- * Failure: NULL if the buffer would overflow. The
+ * Failure: NULL if the buffer would overflow. The
* buffer has as many left-to-right escapes as
* possible before overflow would have happened.
*
* Programmer: Robb Matzke
* Monday, April 26, 1999
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static char *
-h5tools_escape(char *s/*in,out*/, size_t size)
+h5tools_escape(char *s /*in,out*/, size_t size)
{
- register size_t i;
- size_t n = HDstrlen(s);
+ size_t i;
const char *escape;
- char octal[8];
+ char octal[8];
+ size_t n = HDstrlen(s);
for (i = 0; i < n; i++) {
switch (s[i]) {
- case '\'':
- escape = "\\\'";
- break;
- case '\"':
- escape = "\\\"";
- break;
- case '\\':
- escape = "\\\\";
- break;
- case '\?':
- escape = "\\\?";
- break;
- case '\a':
- escape = "\\a";
- break;
- case '\b':
- escape = "\\b";
- break;
- case '\f':
- escape = "\\f";
- break;
- case '\n':
- escape = "\\n";
- break;
- case '\r':
- escape = "\\r";
- break;
- case '\t':
- escape = "\\t";
- break;
- case '\v':
- escape = "\\v";
- break;
- default:
- if (!isprint(s[i])) {
- HDsnprintf(octal, sizeof(octal), "\\%03o", (unsigned char) s[i]);
- escape = octal;
- }
- else {
- escape = NULL;
- }
+ case '\'':
+ escape = "\\\'";
+ break;
+ case '\"':
+ escape = "\\\"";
+ break;
+ case '\\':
+ escape = "\\\\";
+ break;
+ case '\?':
+ escape = "\\\?";
+ break;
+ case '\a':
+ escape = "\\a";
+ break;
+ case '\b':
+ escape = "\\b";
+ break;
+ case '\f':
+ escape = "\\f";
+ break;
+ case '\n':
+ escape = "\\n";
+ break;
+ case '\r':
+ escape = "\\r";
+ break;
+ case '\t':
+ escape = "\\t";
+ break;
+ case '\v':
+ escape = "\\v";
+ break;
+ default:
+ if (!isprint(s[i])) {
+ HDsnprintf(octal, sizeof(octal), "\\%03o", (unsigned char)s[i]);
+ escape = octal;
+ }
+ else
+ escape = NULL;
- break;
+ break;
}
if (escape) {
@@ -1329,9 +1575,9 @@ h5tools_escape(char *s/*in,out*/, size_t size)
return NULL;
HDmemmove(s + i + esc_size, s + i + 1, n - i); /*make room*/
- HDmemcpy(s + i, escape, esc_size); /*insert*/
- n += esc_size - 1; /* adjust total string size */
- i += esc_size; /* adjust string position */
+ HDmemcpy(s + i, escape, esc_size); /*insert*/
+ n += esc_size - 1; /* adjust total string size */
+ i += esc_size; /* adjust string position */
}
}
@@ -1341,21 +1587,18 @@ h5tools_escape(char *s/*in,out*/, size_t size)
/*-------------------------------------------------------------------------
* Function: h5tools_str_is_zero
*
- * Purpose: Determines if memory is initialized to all zero bytes.
+ * Purpose: Determines if memory is initialized to all zero bytes.
*
- * Return: TRUE if all bytes are zero; FALSE otherwise
+ * Return: TRUE if all bytes are zero; FALSE otherwise
*
* Programmer: Robb Matzke
* Monday, June 7, 1999
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static hbool_t
h5tools_str_is_zero(const void *_mem, size_t size)
{
- const unsigned char *mem = (const unsigned char *) _mem;
+ const unsigned char *mem = (const unsigned char *)_mem;
while (size-- > 0)
if (mem[size])
@@ -1369,46 +1612,47 @@ h5tools_str_is_zero(const void *_mem, size_t size)
*
* Purpose: replace all occurrences of substring.
*
- * Return: char *
+ * Return: char *
*
* Programmer: Peter Cao
* March 8, 2012
*
* Notes:
- * Applications need to call free() to free the memoery allocated for
- * the return string
+ * Applications need to call free() to free the memory allocated for
+ * the return string
*
*-------------------------------------------------------------------------
*/
char *
-h5tools_str_replace ( const char *string, const char *substr, const char *replacement )
+h5tools_str_replace(const char *string, const char *substr, const char *replacement)
{
- char *tok = NULL;
- char *newstr = NULL;
- char *oldstr = NULL;
- char *head = NULL;
-
- if ( substr == NULL || replacement == NULL )
- return strdup (string);
-
- newstr = strdup (string);
- head = newstr;
- while ( (tok = strstr ( head, substr ))){
- oldstr = newstr;
- newstr = HDmalloc ( strlen ( oldstr ) - strlen ( substr ) + strlen ( replacement ) + 1 );
-
- if ( newstr == NULL ){
- HDfree (oldstr);
- return NULL;
+ char *tok = NULL;
+ char *newstr = NULL;
+ char *head = NULL;
+
+ if (substr == NULL || replacement == NULL)
+ return HDstrdup(string);
+ newstr = HDstrdup(string);
+ head = newstr;
+ while ((tok = HDstrstr(head, substr))) {
+ char *oldstr;
+
+ oldstr = newstr;
+ newstr = (char *)HDmalloc(HDstrlen(oldstr) - HDstrlen(substr) + HDstrlen(replacement) + 1);
+
+ if (newstr == NULL) {
+ HDfree(oldstr);
+ return NULL;
}
- memcpy ( newstr, oldstr, tok - oldstr );
- memcpy ( newstr + (tok - oldstr), replacement, strlen ( replacement ) );
- memcpy ( newstr + (tok - oldstr) + strlen( replacement ), tok + strlen ( substr ), strlen ( oldstr ) - strlen ( substr ) - ( tok - oldstr ) );
- memset ( newstr + strlen ( oldstr ) - strlen ( substr ) + strlen ( replacement ) , 0, 1 );
+ HDmemcpy(newstr, oldstr, (size_t)(tok - oldstr));
+ HDmemcpy(newstr + (tok - oldstr), replacement, HDstrlen(replacement));
+ HDmemcpy(newstr + (tok - oldstr) + HDstrlen(replacement), tok + HDstrlen(substr),
+ HDstrlen(oldstr) - HDstrlen(substr) - (size_t)(tok - oldstr));
+ HDmemset(newstr + HDstrlen(oldstr) - HDstrlen(substr) + HDstrlen(replacement), 0, 1);
/* move back head right after the last replacement */
- head = newstr + (tok - oldstr) + strlen( replacement );
- HDfree (oldstr);
+ head = newstr + (tok - oldstr) + HDstrlen(replacement);
+ HDfree(oldstr);
}
-
+
return newstr;
}
diff --git a/tools/lib/h5tools_str.h b/tools/lib/h5tools_str.h
index 38697c6..c0258ff 100644
--- a/tools/lib/h5tools_str.h
+++ b/tools/lib/h5tools_str.h
@@ -1,53 +1,50 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Programmer: Bill Wendling <wendling@ncsa.uiuc.edu>
+ * Programmer: Bill Wendling
* Monday, 19. February 2001
*/
-#ifndef H5TOOLS_STR_H__
-#define H5TOOLS_STR_H__
+#ifndef H5TOOLS_STR_H
+#define H5TOOLS_STR_H
typedef struct h5tools_str_t {
- char *s; /*allocate string */
- size_t len; /*length of actual value */
- size_t nalloc; /*allocated size of string */
+ char *s; /*allocate string */
+ size_t len; /*length of actual value */
+ size_t nalloc; /*allocated size of string */
} h5tools_str_t;
-H5TOOLS_DLL void h5tools_str_close(h5tools_str_t *str);
-H5TOOLS_DLL size_t h5tools_str_len(h5tools_str_t *str);
-H5TOOLS_DLL char *h5tools_str_append(h5tools_str_t *str, const char *fmt, ...);
-H5TOOLS_DLL char *h5tools_str_reset(h5tools_str_t *str);
-H5TOOLS_DLL char *h5tools_str_trunc(h5tools_str_t *str, size_t size);
-H5TOOLS_DLL char *h5tools_str_fmt(h5tools_str_t *str, size_t start, const char *fmt);
-H5TOOLS_DLL char *h5tools_str_prefix(h5tools_str_t *str, const h5tool_format_t *info,
- hsize_t elmtno, unsigned ndims, h5tools_context_t *ctx);
+H5TOOLS_DLL void h5tools_str_close(h5tools_str_t *str);
+H5TOOLS_DLL size_t h5tools_str_len(h5tools_str_t *str);
+H5TOOLS_DLL char *h5tools_str_append(h5tools_str_t *str, const char *fmt, ...) H5_ATTR_FORMAT(printf, 2, 3);
+H5TOOLS_DLL char *h5tools_str_reset(h5tools_str_t *str);
+H5TOOLS_DLL char *h5tools_str_trunc(h5tools_str_t *str, size_t size);
+H5TOOLS_DLL char *h5tools_str_fmt(h5tools_str_t *str, size_t start, const char *fmt);
+H5TOOLS_DLL char *h5tools_str_prefix(h5tools_str_t *str, const h5tool_format_t *info, hsize_t elmtno,
+ h5tools_context_t *ctx);
/*
* new functions needed to display region reference data
*/
-H5TOOLS_DLL char *h5tools_str_region_prefix(h5tools_str_t *str, const h5tool_format_t *info,
- hsize_t elmtno, hsize_t *ptdata, unsigned ndims,
- hsize_t max_idx[], h5tools_context_t *ctx);
-H5TOOLS_DLL void h5tools_str_dump_region_blocks(h5tools_str_t *, hid_t, const h5tool_format_t *);
-H5TOOLS_DLL void h5tools_str_dump_region_points(h5tools_str_t *, hid_t, const h5tool_format_t *);
-H5TOOLS_DLL void h5tools_str_sprint_region(h5tools_str_t *str, const h5tool_format_t *info, hid_t container,
- void *vp);
-H5TOOLS_DLL char *h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info,
- hid_t container, hid_t type, void *vp,
- h5tools_context_t *ctx);
-H5TOOLS_DLL char *h5tools_str_replace ( const char *string, const char *substr,
- const char *replacement );
+H5TOOLS_DLL char *h5tools_str_region_prefix(h5tools_str_t *str, const h5tool_format_t *info, hsize_t elmtno,
+ const hsize_t *ptdata, h5tools_context_t *ctx);
+H5TOOLS_DLL void h5tools_str_dump_space_slabs(h5tools_str_t *, hid_t, const h5tool_format_t *,
+ h5tools_context_t *ctx);
+H5TOOLS_DLL void h5tools_str_dump_space_blocks(h5tools_str_t *, hid_t, const h5tool_format_t *);
+H5TOOLS_DLL void h5tools_str_dump_space_points(h5tools_str_t *, hid_t, const h5tool_format_t *);
+H5TOOLS_DLL void h5tools_str_sprint_old_reference(h5tools_str_t *str, hid_t container, H5R_type_t ref_type,
+ void *vp);
+H5TOOLS_DLL void h5tools_str_sprint_reference(h5tools_str_t *str, H5R_ref_t *vp);
+H5TOOLS_DLL char *h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t container,
+ hid_t type, void *vp, h5tools_context_t *ctx);
+H5TOOLS_DLL char *h5tools_str_replace(const char *string, const char *substr, const char *replacement);
-#endif /* H5TOOLS_STR_H__ */
+#endif /* H5TOOLS_STR_H */
diff --git a/tools/lib/h5tools_type.c b/tools/lib/h5tools_type.c
index d68d3c5..7e9f6f7 100644
--- a/tools/lib/h5tools_type.c
+++ b/tools/lib/h5tools_type.c
@@ -1,72 +1,31 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+#include "H5private.h"
#include "h5tools.h"
/*-------------------------------------------------------------------------
- * Function: h5tools_get_native_type
- *
- * Purpose: Wrapper around H5Tget_native_type() to work around
- * Problems with bitfields.
- *
- * Return: Success: datatype ID
- *
- * Failure: FAIL
- *
- * Programmer: Quincey Koziol
- * Tuesday, October 5, 2004
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-hid_t
-h5tools_get_native_type(hid_t type)
-{
- hid_t p_type;
- H5T_class_t type_class;
-
- type_class = H5Tget_class(type);
- if(type_class==H5T_BITFIELD)
- p_type=H5Tcopy(type);
- else
- p_type = H5Tget_native_type(type,H5T_DIR_DEFAULT);
-
- return(p_type);
-}
-
-
-/*-------------------------------------------------------------------------
* Function: h5tools_get_little_endian_type
*
* Purpose: Get a little endian type from a file type
*
* Return: Success: datatype ID
* Failure: FAIL
- *
- * Programmer: Pedro Vicente Nunes
- * Tuesday, July 18, 2006
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
hid_t
h5tools_get_little_endian_type(hid_t tid)
{
- hid_t p_type=-1;
+ hid_t p_type = H5I_INVALID_HID;
H5T_class_t type_class;
size_t size;
H5T_sign_t sign;
@@ -75,55 +34,63 @@ h5tools_get_little_endian_type(hid_t tid)
size = H5Tget_size(tid);
sign = H5Tget_sign(tid);
- switch( type_class )
- {
- case H5T_INTEGER:
- {
- if ( size == 1 && sign == H5T_SGN_2)
- p_type=H5Tcopy(H5T_STD_I8LE);
- else if ( size == 2 && sign == H5T_SGN_2)
- p_type=H5Tcopy(H5T_STD_I16LE);
- else if ( size == 4 && sign == H5T_SGN_2)
- p_type=H5Tcopy(H5T_STD_I32LE);
- else if ( size == 8 && sign == H5T_SGN_2)
- p_type=H5Tcopy(H5T_STD_I64LE);
- else if ( size == 1 && sign == H5T_SGN_NONE)
- p_type=H5Tcopy(H5T_STD_U8LE);
- else if ( size == 2 && sign == H5T_SGN_NONE)
- p_type=H5Tcopy(H5T_STD_U16LE);
- else if ( size == 4 && sign == H5T_SGN_NONE)
- p_type=H5Tcopy(H5T_STD_U32LE);
- else if ( size == 8 && sign == H5T_SGN_NONE)
- p_type=H5Tcopy(H5T_STD_U64LE);
- }
- break;
-
- case H5T_FLOAT:
- if ( size == 4)
- p_type=H5Tcopy(H5T_IEEE_F32LE);
- else if ( size == 8)
- p_type=H5Tcopy(H5T_IEEE_F64LE);
- break;
-
- case H5T_TIME:
- case H5T_BITFIELD:
- case H5T_OPAQUE:
- case H5T_STRING:
- case H5T_COMPOUND:
- case H5T_REFERENCE:
- case H5T_ENUM:
- case H5T_VLEN:
- case H5T_ARRAY:
- break;
-
- default:
- break;
-
- }
-
- return(p_type);
-}
-
+ switch (type_class) {
+ case H5T_INTEGER:
+ if (size == 1 && sign == H5T_SGN_2)
+ p_type = H5Tcopy(H5T_STD_I8LE);
+ else if (size == 2 && sign == H5T_SGN_2)
+ p_type = H5Tcopy(H5T_STD_I16LE);
+ else if (size == 4 && sign == H5T_SGN_2)
+ p_type = H5Tcopy(H5T_STD_I32LE);
+ else if (size == 8 && sign == H5T_SGN_2)
+ p_type = H5Tcopy(H5T_STD_I64LE);
+ else if (size == 1 && sign == H5T_SGN_NONE)
+ p_type = H5Tcopy(H5T_STD_U8LE);
+ else if (size == 2 && sign == H5T_SGN_NONE)
+ p_type = H5Tcopy(H5T_STD_U16LE);
+ else if (size == 4 && sign == H5T_SGN_NONE)
+ p_type = H5Tcopy(H5T_STD_U32LE);
+ else if (size == 8 && sign == H5T_SGN_NONE)
+ p_type = H5Tcopy(H5T_STD_U64LE);
+ break;
+
+ case H5T_FLOAT:
+ if (size == 4)
+ p_type = H5Tcopy(H5T_IEEE_F32LE);
+ else if (size == 8)
+ p_type = H5Tcopy(H5T_IEEE_F64LE);
+ break;
+
+ case H5T_BITFIELD:
+ if (size == 1)
+ p_type = H5Tcopy(H5T_STD_B8LE);
+ else if (size == 2)
+ p_type = H5Tcopy(H5T_STD_B16LE);
+ else if (size == 4)
+ p_type = H5Tcopy(H5T_STD_B32LE);
+ else if (size == 8)
+ p_type = H5Tcopy(H5T_STD_B64LE);
+ break;
+
+ case H5T_TIME:
+ case H5T_OPAQUE:
+ case H5T_STRING:
+ case H5T_COMPOUND:
+ case H5T_REFERENCE:
+ case H5T_ENUM:
+ case H5T_VLEN:
+ case H5T_ARRAY:
+ break;
+
+ case H5T_NO_CLASS:
+ case H5T_NCLASSES:
+ default:
+ break;
+
+ } /* end switch */
+
+ return p_type;
+} /* end h5tools_get_little_endian_type() */
/*-------------------------------------------------------------------------
* Function: h5tools_get_big_endian_type
@@ -132,18 +99,12 @@ h5tools_get_little_endian_type(hid_t tid)
*
* Return: Success: datatype ID
* Failure: FAIL
- *
- * Programmer: Pedro Vicente Nunes
- * Tuesday, July 18, 2006
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
hid_t
h5tools_get_big_endian_type(hid_t tid)
{
- hid_t p_type=-1;
+ hid_t p_type = H5I_INVALID_HID;
H5T_class_t type_class;
size_t size;
H5T_sign_t sign;
@@ -152,53 +113,59 @@ h5tools_get_big_endian_type(hid_t tid)
size = H5Tget_size(tid);
sign = H5Tget_sign(tid);
- switch( type_class )
- {
- case H5T_INTEGER:
- {
- if ( size == 1 && sign == H5T_SGN_2)
- p_type=H5Tcopy(H5T_STD_I8BE);
- else if ( size == 2 && sign == H5T_SGN_2)
- p_type=H5Tcopy(H5T_STD_I16BE);
- else if ( size == 4 && sign == H5T_SGN_2)
- p_type=H5Tcopy(H5T_STD_I32BE);
- else if ( size == 8 && sign == H5T_SGN_2)
- p_type=H5Tcopy(H5T_STD_I64BE);
- else if ( size == 1 && sign == H5T_SGN_NONE)
- p_type=H5Tcopy(H5T_STD_U8BE);
- else if ( size == 2 && sign == H5T_SGN_NONE)
- p_type=H5Tcopy(H5T_STD_U16BE);
- else if ( size == 4 && sign == H5T_SGN_NONE)
- p_type=H5Tcopy(H5T_STD_U32BE);
- else if ( size == 8 && sign == H5T_SGN_NONE)
- p_type=H5Tcopy(H5T_STD_U64BE);
- }
- break;
-
- case H5T_FLOAT:
- if ( size == 4)
- p_type=H5Tcopy(H5T_IEEE_F32BE);
- else if ( size == 8)
- p_type=H5Tcopy(H5T_IEEE_F64BE);
- break;
-
- case H5T_TIME:
- case H5T_BITFIELD:
- case H5T_OPAQUE:
- case H5T_STRING:
- case H5T_COMPOUND:
- case H5T_REFERENCE:
- case H5T_ENUM:
- case H5T_VLEN:
- case H5T_ARRAY:
- break;
-
- default:
- break;
-
- }
-
-
- return(p_type);
-}
-
+ switch (type_class) {
+ case H5T_INTEGER:
+ if (size == 1 && sign == H5T_SGN_2)
+ p_type = H5Tcopy(H5T_STD_I8BE);
+ else if (size == 2 && sign == H5T_SGN_2)
+ p_type = H5Tcopy(H5T_STD_I16BE);
+ else if (size == 4 && sign == H5T_SGN_2)
+ p_type = H5Tcopy(H5T_STD_I32BE);
+ else if (size == 8 && sign == H5T_SGN_2)
+ p_type = H5Tcopy(H5T_STD_I64BE);
+ else if (size == 1 && sign == H5T_SGN_NONE)
+ p_type = H5Tcopy(H5T_STD_U8BE);
+ else if (size == 2 && sign == H5T_SGN_NONE)
+ p_type = H5Tcopy(H5T_STD_U16BE);
+ else if (size == 4 && sign == H5T_SGN_NONE)
+ p_type = H5Tcopy(H5T_STD_U32BE);
+ else if (size == 8 && sign == H5T_SGN_NONE)
+ p_type = H5Tcopy(H5T_STD_U64BE);
+ break;
+
+ case H5T_FLOAT:
+ if (size == 4)
+ p_type = H5Tcopy(H5T_IEEE_F32BE);
+ else if (size == 8)
+ p_type = H5Tcopy(H5T_IEEE_F64BE);
+ break;
+
+ case H5T_BITFIELD:
+ if (size == 1)
+ p_type = H5Tcopy(H5T_STD_B8BE);
+ else if (size == 2)
+ p_type = H5Tcopy(H5T_STD_B16BE);
+ else if (size == 4)
+ p_type = H5Tcopy(H5T_STD_B32BE);
+ else if (size == 8)
+ p_type = H5Tcopy(H5T_STD_B64BE);
+ break;
+
+ case H5T_TIME:
+ case H5T_OPAQUE:
+ case H5T_STRING:
+ case H5T_COMPOUND:
+ case H5T_REFERENCE:
+ case H5T_ENUM:
+ case H5T_VLEN:
+ case H5T_ARRAY:
+ break;
+
+ case H5T_NO_CLASS:
+ case H5T_NCLASSES:
+ default:
+ break;
+ } /* end switch */
+
+ return p_type;
+} /* end h5tools_get_big_endian_type() */
diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c
index 11ab5f3..c8b0644 100644
--- a/tools/lib/h5tools_utils.c
+++ b/tools/lib/h5tools_utils.c
@@ -1,46 +1,33 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Programmer: Bill Wendling <wendling@ncsa.uiuc.edu>
- * Tuesday, 6. March 2001
- */
-
-/*
* Portions of this work are derived from _Obfuscated C and Other Mysteries_,
* by Don Libes, copyright (c) 1993 by John Wiley & Sons, Inc.
*/
-#include <ctype.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-
#include "h5tools.h"
#include "h5tools_utils.h"
#include "H5private.h"
#include "h5trav.h"
-/* global variables */
-int h5tools_nCols = 80;
-/* ``get_option'' variables */
-int opt_err = 1; /*get_option prints errors if this is on */
-int opt_ind = 1; /*token pointer */
-const char *opt_arg; /*flag argument (or value) */
-static int h5tools_d_status = 0;
-static const char *h5tools_progname = "h5tools";
+#ifdef H5_HAVE_ROS3_VFD
+#include "H5FDros3.h"
+#endif
+
+/* Global variables */
+unsigned h5tools_nCols = 80;
+static int h5tools_d_status = 0;
+static const char *h5tools_progname = "h5tools";
/*
* The output functions need a temporary buffer to hold a piece of the
@@ -49,101 +36,72 @@ static const char *h5tools_progname = "h5tools";
* largest value suitable for your machine (for testing use a small value).
*/
/* Maximum size used in a call to malloc for a dataset */
-hsize_t H5TOOLS_MALLOCSIZE = (256 * 1024 * 1024); /* 256 MB */
+hsize_t H5TOOLS_MALLOCSIZE = (256 * 1024 * 1024); /* 256 MB */
/* size of hyperslab buffer when a dataset is bigger than H5TOOLS_MALLOCSIZE */
-hsize_t H5TOOLS_BUFSIZE = ( 32 * 1024 * 1024); /* 32 MB */
-
+hsize_t H5TOOLS_BUFSIZE = (32 * 1024 * 1024); /* 32 MB */
/* ``parallel_print'' variables */
-unsigned char g_Parallel = 0; /*0 for serial, 1 for parallel */
-char outBuff[OUTBUFF_SIZE];
-int outBuffOffset;
-FILE* overflow_file = NULL;
+unsigned char g_Parallel = 0; /*0 for serial, 1 for parallel */
+char outBuff[OUTBUFF_SIZE];
+unsigned outBuffOffset;
+FILE *overflow_file = NULL;
/* local functions */
-static void init_table(table_t **tbl);
+static void init_table(hid_t fid, table_t **tbl);
#ifdef H5DUMP_DEBUG
-static void dump_table(char* tablename, table_t *table);
-#endif /* H5DUMP_DEBUG */
-static void add_obj(table_t *table, haddr_t objno, const char *objname, hbool_t recorded);
+static void dump_table(hid_t fid, char *tablename, table_t *table);
+#endif /* H5DUMP_DEBUG */
+static void add_obj(table_t *table, const H5O_token_t *obj_token, const char *objname, hbool_t recorded);
/*-------------------------------------------------------------------------
* Function: parallel_print
*
- * Purpose: wrapper for printf for use in parallel mode.
- *
- * Programmer: Leon Arber
- *
- * Date: December 1, 2004
- *
+ * Purpose: wrapper for printf for use in parallel mode.
*-------------------------------------------------------------------------
*/
-void parallel_print(const char* format, ...)
+void
+parallel_print(const char *format, ...)
{
- int bytes_written;
+ int bytes_written;
va_list ap;
HDva_start(ap, format);
- if(!g_Parallel)
+ if (!g_Parallel)
HDvprintf(format, ap);
else {
- if(overflow_file == NULL) /*no overflow has occurred yet */ {
-#if 0
- printf("calling HDvsnprintf: OUTBUFF_SIZE=%ld, outBuffOffset=%ld, ", (long)OUTBUFF_SIZE, (long)outBuffOffset);
-#endif
- bytes_written = HDvsnprintf(outBuff+outBuffOffset, OUTBUFF_SIZE-outBuffOffset, format, ap);
-#if 0
- printf("bytes_written=%ld\n", (long)bytes_written);
-#endif
+ if (overflow_file == NULL) /*no overflow has occurred yet */ {
+ bytes_written = HDvsnprintf(outBuff + outBuffOffset, OUTBUFF_SIZE - outBuffOffset, format, ap);
HDva_end(ap);
HDva_start(ap, format);
-#if 0
- printf("Result: bytes_written=%ld, OUTBUFF_SIZE-outBuffOffset=%ld\n", (long)bytes_written, (long)OUTBUFF_SIZE-outBuffOffset);
-#endif
-
- if ((bytes_written < 0) ||
-#ifdef H5_VSNPRINTF_WORKS
- (bytes_written >= (OUTBUFF_SIZE-outBuffOffset))
-#else
- ((bytes_written+1) == (OUTBUFF_SIZE-outBuffOffset))
-#endif
- )
- {
+ if ((bytes_written < 0) || ((unsigned)bytes_written >= (OUTBUFF_SIZE - outBuffOffset))) {
/* Terminate the outbuff at the end of the previous output */
outBuff[outBuffOffset] = '\0';
overflow_file = HDtmpfile();
- if(overflow_file == NULL)
- HDfprintf(rawerrorstream, "warning: could not create overflow file. Output may be truncated.\n");
+ if (overflow_file == NULL)
+ HDfprintf(rawerrorstream,
+ "warning: could not create overflow file. Output may be truncated.\n");
else
bytes_written = HDvfprintf(overflow_file, format, ap);
}
else
- outBuffOffset += bytes_written;
+ outBuffOffset += (unsigned)bytes_written;
}
else
bytes_written = HDvfprintf(overflow_file, format, ap);
-
}
HDva_end(ap);
}
-
/*-------------------------------------------------------------------------
- * Function: error_msg
+ * Function: error_msg
*
- * Purpose: Print a nicely formatted error message to stderr flushing the
+ * Purpose: Print a nicely formatted error message to stderr flushing the
* stdout stream first.
*
- * Return: Nothing
- *
- * Programmer: Bill Wendling
- * Tuesday, 20. February 2001
- *
- * Modifications:
- *
+ * Return: Nothing
*-------------------------------------------------------------------------
*/
void
@@ -152,28 +110,22 @@ error_msg(const char *fmt, ...)
va_list ap;
HDva_start(ap, fmt);
- HDfflush(rawdatastream);
- HDfflush(rawoutstream);
+ FLUSHSTREAM(rawattrstream);
+ FLUSHSTREAM(rawdatastream);
+ FLUSHSTREAM(rawoutstream);
HDfprintf(rawerrorstream, "%s error: ", h5tools_getprogname());
HDvfprintf(rawerrorstream, fmt, ap);
HDva_end(ap);
}
-
/*-------------------------------------------------------------------------
- * Function: warn_msg
+ * Function: warn_msg
*
- * Purpose: Print a nicely formatted warning message to stderr flushing
+ * Purpose: Print a nicely formatted warning message to stderr flushing
* the stdout stream first.
*
- * Return: Nothing
- *
- * Programmer: Bill Wendling
- * Tuesday, 20. February 2001
- *
- * Modifications:
- *
+ * Return: Nothing
*-------------------------------------------------------------------------
*/
void
@@ -182,244 +134,279 @@ warn_msg(const char *fmt, ...)
va_list ap;
HDva_start(ap, fmt);
- HDfflush(rawdatastream);
- HDfflush(rawoutstream);
+ FLUSHSTREAM(rawattrstream);
+ FLUSHSTREAM(rawdatastream);
+ FLUSHSTREAM(rawoutstream);
HDfprintf(rawerrorstream, "%s warning: ", h5tools_getprogname());
HDvfprintf(rawerrorstream, fmt, ap);
HDva_end(ap);
}
/*-------------------------------------------------------------------------
- * Function: help_ref_msg
- *
- * Purpose: Print a message to refer help page
- *
- * Return: Nothing
+ * Function: help_ref_msg
*
- * Modifications:
+ * Purpose: Print a message to refer help page
*
+ * Return: Nothing
*-------------------------------------------------------------------------
*/
void
help_ref_msg(FILE *output)
{
HDfprintf(output, "Try '-h' or '--help' for more information or ");
- HDfprintf(output, "see the <%s> entry in the 'HDF5 Reference Manual'.\n",h5tools_getprogname());
+ HDfprintf(output, "see the <%s> entry in the 'HDF5 Reference Manual'.\n", h5tools_getprogname());
}
-
-/*-------------------------------------------------------------------------
- * Function: get_option
- *
- * Purpose: Determine the command-line options a user specified. We can
- * accept both short and long type command-lines.
- *
- * Return: Success: The short valued "name" of the command line
- * parameter or EOF if there are no more
- * parameters to process.
- *
- * Failure: A question mark.
- *
- * Programmer: Bill Wendling
- * Friday, 5. January 2001
- *
- * Modifications: Pedro Vicente
- * October, 27 2008
- * Wilcard "*" argument type
- *
- *-------------------------------------------------------------------------
+/*****************************************************************************
+ *
+ * Function: parse_tuple()
+ *
+ * Purpose:
+ *
+ * Create array of pointers to strings, identified as elements in a tuple
+ * of arbitrary length separated by provided character.
+ * ("tuple" because "nple" looks strange)
+ *
+ * * Receives pointer to start of tuple sequence string, '('.
+ * * Attempts to separate elements by token-character `sep`.
+ * * If the separator character is preceded by a backslash '\',
+ * the backslash is deleted and the separator is included in the
+ * element string as any other character.
+ * * To end an element with a backslash, escape the backslash, e.g.
+ * "(myelem\\,otherelem) -> {"myelem\", "otherelem"}
+ * * In all other cases, a backslash appearing not as part of "\\" or
+ * "\<sep>" digraph will be included berbatim.
+ * * Last two characters in the string MUST be ")\0".
+ *
+ * * Generates a copy of the input string `start`, (src..")\0"), replacing
+ * separators and close-paren with null characters.
+ * * This string is allocated at runtime and should be freed when done.
+ * * Generates array of char pointers, and directs start of each element
+ * (each pointer) into this copy.
+ * * Each tuple element points to the start of its string (substring)
+ * and ends with a null terminator.
+ * * This array is allocated at runtime and should be freed when done.
+ * * Reallocates and expands elements array during parsing.
+ * * Initially allocated for 2 (plus one null entry), and grows by
+ * powers of 2.
+ * * The final 'slot' in the element array (elements[nelements], e.g.)
+ * always points to NULL.
+ * * The number of elements found and stored are passed out through pointer
+ * to unsigned, `nelems`.
+ *
+ * Return:
+ *
+ * FAIL If malformed--does not look like a tuple "(...)"
+ * or major error was encountered while parsing.
+ * or
+ * SUCCEED String looks properly formed "(...)" and no major errors.
+ *
+ * Stores number of elements through pointer `nelems`.
+ * Stores list of pointers to char (first char in each element
+ * string) through pointer `ptrs_out`.
+ * NOTE: `ptrs_out[nelems] == NULL` should be true.
+ * NOTE: list is malloc'd by function, and should be freed
+ * when done.
+ * Stores "source string" for element pointers through `cpy_out`.
+ * NOTE: Each element substring is null-terminated.
+ * NOTE: There may be extra characters after the last element
+ * (past its null terminator), but is guaranteed to
+ * be null-terminated.
+ * NOTE: `cpy_out` string is malloc'd by function,
+ * and should be freed when done.
+ *
+ * Programmer: Jacob Smith
+ * 2017-11-10
+ *
+ *****************************************************************************
*/
-int
-get_option(int argc, const char **argv, const char *opts, const struct long_options *l_opts)
+herr_t
+parse_tuple(const char *start, int sep, char **cpy_out, unsigned *nelems, char ***ptrs_out)
{
- static int sp = 1; /* character index in current token */
- int opt_opt = '?'; /* option character passed back to user */
-
- if (sp == 1) {
- /* check for more flag-like tokens */
- if (opt_ind >= argc || argv[opt_ind][0] != '-' || argv[opt_ind][1] == '\0') {
- return EOF;
- }
- else if (HDstrcmp(argv[opt_ind], "--") == 0) {
- opt_ind++;
- return EOF;
- }
+ char *elem_ptr = NULL;
+ char *dest_ptr = NULL;
+ unsigned elems_count = 0;
+ char **elems = NULL; /* more like *elems[], but compiler... */
+ char **elems_re = NULL; /* temporary pointer, for realloc */
+ char *cpy = NULL;
+ herr_t ret_value = SUCCEED;
+ unsigned init_slots = 2;
+
+ /*****************
+ * SANITY-CHECKS *
+ *****************/
+
+ /* must start with "("
+ */
+ if (start[0] != '(') {
+ ret_value = FAIL;
+ goto done;
}
- if (sp == 1 && argv[opt_ind][0] == '-' && argv[opt_ind][1] == '-') {
- /* long command line option */
- const char *arg = &argv[opt_ind][2];
- int i;
-
- for (i = 0; l_opts && l_opts[i].name; i++) {
- size_t len = HDstrlen(l_opts[i].name);
-
- if (HDstrncmp(arg, l_opts[i].name, len) == 0) {
- /* we've found a matching long command line flag */
- opt_opt = l_opts[i].shortval;
-
- if (l_opts[i].has_arg != no_arg) {
- if (arg[len] == '=') {
- opt_arg = &arg[len + 1];
- }
- else if (l_opts[i].has_arg != optional_arg) {
- if (opt_ind < (argc - 1))
- if (argv[opt_ind + 1][0] != '-')
- opt_arg = argv[++opt_ind];
- }
- else if (l_opts[i].has_arg == require_arg) {
- if (opt_err)
- HDfprintf(rawerrorstream,
- "%s: option required for \"--%s\" flag\n",
- argv[0], arg);
-
- opt_opt = '?';
- }
- }
- else {
- if (arg[len] == '=') {
- if (opt_err)
- HDfprintf(rawerrorstream,
- "%s: no option required for \"%s\" flag\n",
- argv[0], arg);
-
- opt_opt = '?';
- }
- opt_arg = NULL;
- }
- break;
- }
- }
+ /* must end with ")"
+ */
+ while (start[elems_count] != '\0') {
+ elems_count++;
+ }
+ if (start[elems_count - 1] != ')') {
+ ret_value = FAIL;
+ goto done;
+ }
- if (l_opts[i].name == NULL) {
- /* exhausted all of the l_opts we have and still didn't match */
- if (opt_err)
- HDfprintf(rawerrorstream, "%s: unknown option \"%s\"\n", argv[0], arg);
+ elems_count = 0;
- opt_opt = '?';
- }
+ /***********
+ * PREPARE *
+ ***********/
- opt_ind++;
- sp = 1;
- }
- else {
- register char *cp; /* pointer into current token */
+ /* create list
+ */
+ elems = (char **)HDmalloc(sizeof(char *) * (init_slots + 1));
+ if (elems == NULL) {
+ ret_value = FAIL;
+ goto done;
+ } /* CANTALLOC */
- /* short command line option */
- opt_opt = argv[opt_ind][sp];
+ /* create destination string
+ */
+ start++; /* advance past opening paren '(' */
+ cpy = (char *)HDmalloc(sizeof(char) * (HDstrlen(start))); /* no +1; less '(' */
+ if (cpy == NULL) {
+ ret_value = FAIL;
+ goto done;
+ } /* CANTALLOC */
+
+ /* set pointers
+ */
+ dest_ptr = cpy; /* start writing copy here */
+ elem_ptr = cpy; /* first element starts here */
+ elems[elems_count++] = elem_ptr; /* set first element pointer into list */
- if (opt_opt == ':' || (cp = HDstrchr(opts, opt_opt)) == 0) {
- if (opt_err)
- HDfprintf(rawerrorstream, "%s: unknown option \"%c\"\n",
- argv[0], opt_opt);
+ /*********
+ * PARSE *
+ *********/
- /* if no chars left in this token, move to next token */
- if (argv[opt_ind][++sp] == '\0') {
- opt_ind++;
- sp = 1;
+ while (*start != '\0') {
+ /* For each character in the source string...
+ */
+ if (*start == '\\') {
+ /* Possibly an escape digraph.
+ */
+ if ((*(start + 1) == '\\') || (*(start + 1) == sep)) {
+ /* Valid escape digraph of "\\" or "\<sep>".
+ */
+ start++; /* advance past escape char '\' */
+ *(dest_ptr++) = *(start++); /* Copy subsequent char */
+ /* and advance pointers. */
}
- return '?';
- }
-
- if (*++cp == ':') {
- /* if a value is expected, get it */
- if (argv[opt_ind][sp + 1] != '\0') {
- /* flag value is rest of current token */
- opt_arg = &argv[opt_ind++][sp + 1];
- }
- else if (++opt_ind >= argc) {
- if (opt_err)
- HDfprintf(rawerrorstream,
- "%s: value expected for option \"%c\"\n",
- argv[0], opt_opt);
-
- opt_opt = '?';
- }
else {
- /* flag value is next token */
- opt_arg = argv[opt_ind++];
+ /* Not an accepted escape digraph.
+ * Copy backslash character.
+ */
+ *(dest_ptr++) = *(start++);
}
-
- sp = 1;
}
- /* wildcard argument */
- else if (*cp == '*') {
- /* check the next argument */
- opt_ind++;
- /* we do have an extra argument, check if not last */
- if ( argv[opt_ind][0] != '-' && (opt_ind+1) < argc ) {
- opt_arg = argv[opt_ind++];
- }
- else {
- opt_arg = NULL;
+ else if (*start == sep) {
+ /* Non-escaped separator.
+ * Terminate elements substring in copy, record element, advance.
+ * Expand elements list if appropriate.
+ */
+ *(dest_ptr++) = 0; /* Null-terminate elem substring in copy */
+ /* and advance pointer. */
+ start++; /* Advance src pointer past separator. */
+ elem_ptr = dest_ptr; /* Element pointer points to start of first */
+ /* character after null sep in copy. */
+ elems[elems_count++] = elem_ptr; /* Set elem pointer in list */
+ /* and increment count. */
+
+ /* Expand elements list, if necessary.
+ */
+ if (elems_count == init_slots) {
+ init_slots *= 2;
+ elems_re = (char **)realloc(elems, sizeof(char *) * (init_slots + 1));
+ if (elems_re == NULL) {
+ /* CANTREALLOC */
+ ret_value = FAIL;
+ goto done;
+ }
+ elems = elems_re;
}
}
+ else if (*start == ')' && *(start + 1) == '\0') {
+ /* Found terminal, non-escaped close-paren. Last element.
+ * Write null terminator to copy.
+ * Advance source pointer to gently break from loop.
+ * Required to prevent ")" from always being added to last element.
+ */
+ start++;
+ }
else {
- /* set up to look at next char in token, next time */
- if (argv[opt_ind][++sp] == '\0') {
- /* no more in current token, so setup next token */
- opt_ind++;
- sp = 1;
- }
- opt_arg = NULL;
+ /* Copy character into destination. Advance pointers.
+ */
+ *(dest_ptr++) = *(start++);
}
}
+ *dest_ptr = '\0'; /* Null-terminate destination string. */
+ elems[elems_count] = NULL; /* Null-terminate elements list. */
+
+ /********************
+ * PASS BACK VALUES *
+ ********************/
+
+ *ptrs_out = elems;
+ *nelems = elems_count;
+ *cpy_out = cpy;
+
+done:
+ if (ret_value == FAIL) {
+ /* CLEANUP */
+ if (cpy)
+ free(cpy);
+ if (elems)
+ free(elems);
+ }
- /* return the current flag character found */
- return opt_opt;
-}
+ return ret_value;
+
+} /* parse_tuple */
-
/*-------------------------------------------------------------------------
- * Function: indentation
+ * Function: indentation
*
- * Purpose: Print spaces for indentation
- *
- * Return: void
- *
- * Programmer: Ruey-Hsia Li
- *
- * Modifications:
+ * Purpose: Print spaces for indentation
*
+ * Return: void
*-------------------------------------------------------------------------
*/
void
-indentation(int x)
+indentation(unsigned x)
{
if (x < h5tools_nCols) {
while (x-- > 0)
- HDfprintf(rawoutstream, " ");
- }
+ PRINTVALSTREAM(rawoutstream, " ");
+ }
else {
HDfprintf(rawerrorstream, "error: the indentation exceeds the number of cols.\n");
HDexit(1);
}
}
-
/*-------------------------------------------------------------------------
- * Function: print_version
+ * Function: print_version
*
- * Purpose: Print the program name and the version information which is
- * defined the same as the HDF5 library version.
- *
- * Return: void
- *
- * Programmer: unknown
- *
- * Modifications:
+ * Purpose: Print the program name and the version information which is
+ * defined the same as the HDF5 library version.
*
+ * Return: void
*-------------------------------------------------------------------------
*/
void
print_version(const char *progname)
{
- HDfprintf(rawoutstream, "%s: Version %u.%u.%u%s%s\n",
- progname, H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE,
- ((char *)H5_VERS_SUBRELEASE)[0] ? "-" : "", H5_VERS_SUBRELEASE);
+ PRINTSTREAM(rawoutstream, "%s: Version %u.%u.%u%s%s\n", progname, H5_VERS_MAJOR, H5_VERS_MINOR,
+ H5_VERS_RELEASE, ((const char *)H5_VERS_SUBRELEASE)[0] ? "-" : "", H5_VERS_SUBRELEASE);
}
-
/*-------------------------------------------------------------------------
* Function: init_table
*
@@ -427,26 +414,21 @@ print_version(const char *progname)
* and committed types
*
* Return: void
- *
- * Programmer: Ruey-Hsia Li
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static void
-init_table(table_t **tbl)
+init_table(hid_t fid, table_t **tbl)
{
table_t *table = (table_t *)HDmalloc(sizeof(table_t));
- table->size = 20;
+ table->fid = fid;
+ table->size = 20;
table->nobjs = 0;
- table->objs = (obj_t *)HDmalloc(table->size * sizeof(obj_t));
+ table->objs = (obj_t *)HDmalloc(table->size * sizeof(obj_t));
*tbl = table;
}
-
/*-------------------------------------------------------------------------
* Function: free_table
*
@@ -454,77 +436,66 @@ init_table(table_t **tbl)
* and committed types
*
* Return: void
- *
- * Programmer: Paul Harten
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void
free_table(table_t *table)
{
- unsigned u; /* Local index value */
+ unsigned u; /* Local index value */
/* Free the names for the objects in the table */
- for(u = 0; u < table->nobjs; u++)
- if(table->objs[u].objname)
+ for (u = 0; u < table->nobjs; u++)
+ if (table->objs[u].objname)
HDfree(table->objs[u].objname);
HDfree(table->objs);
+ HDfree(table);
}
#ifdef H5DUMP_DEBUG
-
+
/*-------------------------------------------------------------------------
* Function: dump_table
*
* Purpose: display the contents of tables for debugging purposes
*
* Return: void
- *
- * Programmer: Ruey-Hsia Li
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static void
-dump_table(char* tablename, table_t *table)
+dump_table(hid_t fid, char *tablename, table_t *table)
{
unsigned u;
+ char *obj_tok_str = NULL;
- HDfprintf(rawoutstream,"%s: # of entries = %d\n", tablename,table->nobjs);
- for (u = 0; u < table->nobjs; u++)
- HDfprintf(rawoutstream,"%a %s %d %d\n", table->objs[u].objno,
- table->objs[u].objname,
- table->objs[u].displayed, table->objs[u].recorded);
+ PRINTSTREAM(rawoutstream, "%s: # of entries = %d\n", tablename, table->nobjs);
+ for (u = 0; u < table->nobjs; u++) {
+ H5VLconnector_token_to_str(fid, table->objs[u].obj_token, &obj_tok_str);
+
+ PRINTSTREAM(rawoutstream, "%s %s %d %d\n", obj_tok_str, table->objs[u].objname,
+ table->objs[u].displayed, table->objs[u].recorded);
+
+ H5VLfree_token_str(fid, obj_tok_str);
+ }
}
-
/*-------------------------------------------------------------------------
* Function: dump_tables
*
* Purpose: display the contents of tables for debugging purposes
*
* Return: void
- *
- * Programmer: Ruey-Hsia Li
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void
dump_tables(find_objs_t *info)
{
- dump_table("group_table", info->group_table);
- dump_table("dset_table", info->dset_table);
- dump_table("type_table", info->type_table);
+ dump_table(info->fid, "group_table", info->group_table);
+ dump_table(info->fid, "dset_table", info->dset_table);
+ dump_table(info->fid, "type_table", info->type_table);
}
-#endif /* H5DUMP_DEBUG */
+#endif /* H5DUMP_DEBUG */
-
/*-------------------------------------------------------------------------
* Function: search_obj
*
@@ -533,26 +504,24 @@ dump_tables(find_objs_t *info)
* Return: Success: an integer, the location of the object
*
* Failure: FAIL if object is not found
- *
- * Programmer: Ruey-Hsia Li
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
-obj_t *
-search_obj(table_t *table, haddr_t objno)
+H5_ATTR_PURE obj_t *
+search_obj(table_t *table, const H5O_token_t *obj_token)
{
unsigned u;
+ int token_cmp;
- for(u = 0; u < table->nobjs; u++)
- if(table->objs[u].objno == objno)
+ for (u = 0; u < table->nobjs; u++) {
+ if (H5Otoken_cmp(table->fid, &table->objs[u].obj_token, obj_token, &token_cmp) < 0)
+ return NULL;
+ if (!token_cmp)
return &(table->objs[u]);
+ }
return NULL;
}
-
/*-------------------------------------------------------------------------
* Function: find_objs_cb
*
@@ -561,43 +530,37 @@ search_obj(table_t *table, haddr_t objno)
* Return: Success: SUCCEED
*
* Failure: FAIL
- *
- * Programmer: Ruey-Hsia Li
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
-find_objs_cb(const char *name, const H5O_info_t *oinfo, const char *already_seen,
- void *op_data)
+find_objs_cb(const char *name, const H5O_info2_t *oinfo, const char *already_seen, void *op_data)
{
- find_objs_t *info = (find_objs_t*)op_data;
- herr_t ret_value = 0;
+ find_objs_t *info = (find_objs_t *)op_data;
+ herr_t ret_value = 0;
- switch(oinfo->type) {
+ switch (oinfo->type) {
case H5O_TYPE_GROUP:
- if(NULL == already_seen)
- add_obj(info->group_table, oinfo->addr, name, TRUE);
+ if (NULL == already_seen)
+ add_obj(info->group_table, &oinfo->token, name, TRUE);
break;
case H5O_TYPE_DATASET:
- if(NULL == already_seen) {
- hid_t dset;
+ if (NULL == already_seen) {
+ hid_t dset = H5I_INVALID_HID;
/* Add the dataset to the list of objects */
- add_obj(info->dset_table, oinfo->addr, name, TRUE);
+ add_obj(info->dset_table, &oinfo->token, name, TRUE);
/* Check for a dataset that uses a named datatype */
- if((dset = H5Dopen2(info->fid, name, H5P_DEFAULT)) >= 0) {
+ if ((dset = H5Dopen2(info->fid, name, H5P_DEFAULT)) >= 0) {
hid_t type = H5Dget_type(dset);
- if(H5Tcommitted(type) > 0) {
- H5O_info_t type_oinfo;
+ if (H5Tcommitted(type) > 0) {
+ H5O_info2_t type_oinfo;
- H5Oget_info(type, &type_oinfo);
- if(search_obj(info->type_table, type_oinfo.addr) == NULL)
- add_obj(info->type_table, type_oinfo.addr, name, FALSE);
+ H5Oget_info3(type, &type_oinfo, H5O_INFO_BASIC);
+ if (search_obj(info->type_table, &type_oinfo.token) == NULL)
+ add_obj(info->type_table, &type_oinfo.token, name, FALSE);
} /* end if */
H5Tclose(type);
@@ -609,11 +572,11 @@ find_objs_cb(const char *name, const H5O_info_t *oinfo, const char *already_seen
break;
case H5O_TYPE_NAMED_DATATYPE:
- if(NULL == already_seen) {
+ if (NULL == already_seen) {
obj_t *found_obj;
- if((found_obj = search_obj(info->type_table, oinfo->addr)) == NULL)
- add_obj(info->type_table, oinfo->addr, name, TRUE);
+ if ((found_obj = search_obj(info->type_table, &oinfo->token)) == NULL)
+ add_obj(info->type_table, &oinfo->token, name, TRUE);
else {
/* Use latest version of name */
HDfree(found_obj->objname);
@@ -622,9 +585,12 @@ find_objs_cb(const char *name, const H5O_info_t *oinfo, const char *already_seen
/* Mark named datatype as having valid name */
found_obj->recorded = TRUE;
} /* end else */
- } /* end if */
+ } /* end if */
break;
+ case H5O_TYPE_MAP:
+ case H5O_TYPE_UNKNOWN:
+ case H5O_TYPE_NTYPES:
default:
break;
} /* end switch */
@@ -632,7 +598,6 @@ find_objs_cb(const char *name, const H5O_info_t *oinfo, const char *already_seen
return ret_value;
}
-
/*-------------------------------------------------------------------------
* Function: init_objs
*
@@ -641,33 +606,41 @@ find_objs_cb(const char *name, const H5O_info_t *oinfo, const char *already_seen
* Return: Success: SUCCEED
*
* Failure: FAIL
- *
- * Programmer: Ruey-Hsia Li
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
herr_t
-init_objs(hid_t fid, find_objs_t *info, table_t **group_table,
- table_t **dset_table, table_t **type_table)
+init_objs(hid_t fid, find_objs_t *info, table_t **group_table, table_t **dset_table, table_t **type_table)
{
+ herr_t ret_value = SUCCEED;
+
/* Initialize the tables */
- init_table(group_table);
- init_table(dset_table);
- init_table(type_table);
+ init_table(fid, group_table);
+ init_table(fid, dset_table);
+ init_table(fid, type_table);
/* Init the find_objs_t */
- info->fid = fid;
+ info->fid = fid;
info->group_table = *group_table;
- info->type_table = *type_table;
- info->dset_table = *dset_table;
+ info->type_table = *type_table;
+ info->dset_table = *dset_table;
/* Find all shared objects */
- return(h5trav_visit(fid, "/", TRUE, TRUE, find_objs_cb, NULL, info));
+ if ((ret_value = h5trav_visit(fid, "/", TRUE, TRUE, find_objs_cb, NULL, info, H5O_INFO_BASIC)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "finding shared objects failed");
+
+done:
+ /* Release resources */
+ if (ret_value < 0) {
+ free_table(*group_table);
+ info->group_table = NULL;
+ free_table(*type_table);
+ info->type_table = NULL;
+ free_table(*dset_table);
+ info->dset_table = NULL;
+ }
+ return ret_value;
}
-
/*-------------------------------------------------------------------------
* Function: add_obj
*
@@ -675,20 +648,15 @@ init_objs(hid_t fid, find_objs_t *info, table_t **group_table,
* realloc the table if necessary
*
* Return: void
- *
- * Programmer: Ruey-Hsia Li
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static void
-add_obj(table_t *table, haddr_t objno, const char *objname, hbool_t record)
+add_obj(table_t *table, const H5O_token_t *obj_token, const char *objname, hbool_t record)
{
- unsigned u;
+ size_t u;
/* See if we need to make table larger */
- if(table->nobjs == table->size) {
+ if (table->nobjs == table->size) {
table->size *= 2;
table->objs = (struct obj_t *)HDrealloc(table->objs, table->size * sizeof(table->objs[0]));
} /* end if */
@@ -697,13 +665,12 @@ add_obj(table_t *table, haddr_t objno, const char *objname, hbool_t record)
u = table->nobjs++;
/* Set information about object */
- table->objs[u].objno = objno;
- table->objs[u].objname = HDstrdup(objname);
- table->objs[u].recorded = record;
+ HDmemcpy(&table->objs[u].obj_token, obj_token, sizeof(H5O_token_t));
+ table->objs[u].objname = HDstrdup(objname);
+ table->objs[u].recorded = record;
table->objs[u].displayed = 0;
}
-
#ifndef H5_HAVE_TMPFILE
/*-------------------------------------------------------------------------
* Function: tmpfile
@@ -713,11 +680,6 @@ add_obj(table_t *table, haddr_t objno, const char *objname, hbool_t record)
*
* Return: a stream description when succeeds.
* NULL if fails.
- *
- * Programmer: Albert Cheng, 2005/8/9
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
FILE *
@@ -731,207 +693,486 @@ tmpfile(void)
/*-------------------------------------------------------------------------
* Function: H5tools_get_symlink_info
*
- * Purpose: Get symbolic link (soft, external) info and its target object type
+ * Purpose: Get symbolic link (soft, external) info and its target object type
(dataset, group, named datatype) and path, if exist
*
- * Patameters:
+ * Parameters:
* - [IN] fileid : link file id
* - [IN] linkpath : link path
* - [OUT] link_info: returning target object info (h5tool_link_info_t)
*
- * Return:
- * 2 : given pathname is object
- * 1 : Succed to get link info.
+ * Return:
+ * 2 : given pathname is object
+ * 1 : Succeed to get link info.
* 0 : Detected as a dangling link
* -1 : H5 API failed.
*
* NOTE:
* link_info->trg_path must be freed out of this function
- *
- * Programmer: Jonathan Kim
- *
- * Date: Feb 8, 2010
*-------------------------------------------------------------------------*/
int
-H5tools_get_symlink_info(hid_t file_id, const char * linkpath, h5tool_link_info_t *link_info,
- hbool_t get_obj_type)
+H5tools_get_symlink_info(hid_t file_id, const char *linkpath, h5tool_link_info_t *link_info,
+ hbool_t get_obj_type)
{
- htri_t l_ret;
- H5O_info_t trg_oinfo;
- hid_t fapl = H5P_DEFAULT;
- hid_t lapl = H5P_DEFAULT;
- int ret = -1; /* init to fail */
+ htri_t l_ret;
+ H5O_info2_t trg_oinfo;
+ hid_t fapl = H5P_DEFAULT;
+ hid_t lapl = H5P_DEFAULT;
+ int ret_value = -1; /* init to fail */
/* init */
link_info->trg_type = H5O_TYPE_UNKNOWN;
/* if path is root, return group type */
- if(!HDstrcmp(linkpath,"/"))
- {
+ if (!HDstrcmp(linkpath, "/")) {
link_info->trg_type = H5O_TYPE_GROUP;
- ret = 2;
- goto out;
+ H5TOOLS_GOTO_DONE(2);
}
/* check if link itself exist */
- if(H5Lexists(file_id, linkpath, H5P_DEFAULT) <= 0) {
- if(link_info->opt.msg_mode == 1)
- parallel_print("Warning: link <%s> doesn't exist \n",linkpath);
- goto out;
+ if (H5Lexists(file_id, linkpath, H5P_DEFAULT) <= 0) {
+ if (link_info->opt.msg_mode == 1)
+ parallel_print("Warning: link <%s> doesn't exist \n", linkpath);
+ H5TOOLS_GOTO_DONE(FAIL);
} /* end if */
/* get info from link */
- if(H5Lget_info(file_id, linkpath, &(link_info->linfo), H5P_DEFAULT) < 0) {
- if(link_info->opt.msg_mode == 1)
- parallel_print("Warning: unable to get link info from <%s>\n",linkpath);
- goto out;
+ if (H5Lget_info2(file_id, linkpath, &(link_info->linfo), H5P_DEFAULT) < 0) {
+ if (link_info->opt.msg_mode == 1)
+ parallel_print("Warning: unable to get link info from <%s>\n", linkpath);
+ H5TOOLS_GOTO_DONE(FAIL);
} /* end if */
/* given path is hard link (object) */
- if(link_info->linfo.type == H5L_TYPE_HARD) {
- ret = 2;
- goto out;
- } /* end if */
+ if (link_info->linfo.type == H5L_TYPE_HARD)
+ H5TOOLS_GOTO_DONE(2);
/* trg_path must be freed out of this function when finished using */
- link_info->trg_path = (char*)HDcalloc(link_info->linfo.u.val_size, sizeof(char));
- HDassert(link_info->trg_path);
+ if ((link_info->trg_path = (char *)HDcalloc(link_info->linfo.u.val_size, sizeof(char))) == NULL) {
+ if (link_info->opt.msg_mode == 1)
+ parallel_print("Warning: unable to allocate buffer for <%s>\n", linkpath);
+ H5TOOLS_GOTO_DONE(FAIL);
+ } /* end if */
/* get link value */
- if(H5Lget_val(file_id, linkpath, (void *)link_info->trg_path, link_info->linfo.u.val_size, H5P_DEFAULT) < 0) {
- if(link_info->opt.msg_mode == 1)
- parallel_print("Warning: unable to get link value from <%s>\n",linkpath);
- goto out;
+ if (H5Lget_val(file_id, linkpath, (void *)link_info->trg_path, link_info->linfo.u.val_size, H5P_DEFAULT) <
+ 0) {
+ if (link_info->opt.msg_mode == 1)
+ parallel_print("Warning: unable to get link value from <%s>\n", linkpath);
+ H5TOOLS_GOTO_DONE(FAIL);
} /* end if */
/*-----------------------------------------------------
- * if link type is external link use different lapl to
+ * if link type is external link use different lapl to
* follow object in other file
*/
- if(link_info->linfo.type == H5L_TYPE_EXTERNAL) {
- if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
- goto out;
- if(H5Pset_fapl_sec2(fapl) < 0)
- goto out;
- if((lapl = H5Pcreate(H5P_LINK_ACCESS)) < 0)
- goto out;
- if(H5Pset_elink_fapl(lapl, fapl) < 0)
- goto out;
+ if (link_info->linfo.type == H5L_TYPE_EXTERNAL) {
+ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ H5TOOLS_GOTO_DONE(FAIL);
+ if (H5Pset_fapl_sec2(fapl) < 0)
+ H5TOOLS_GOTO_DONE(FAIL);
+ if ((lapl = H5Pcreate(H5P_LINK_ACCESS)) < 0)
+ H5TOOLS_GOTO_DONE(FAIL);
+ if (H5Pset_elink_fapl(lapl, fapl) < 0)
+ H5TOOLS_GOTO_DONE(FAIL);
} /* end if */
/* Check for retrieving object info */
- if(get_obj_type) {
+ if (get_obj_type) {
/*--------------------------------------------------------------
* if link's target object exist, get type
*/
- /* check if target object exist */
+ /* check if target object exist */
l_ret = H5Oexists_by_name(file_id, linkpath, lapl);
-
+
/* detect dangling link */
- if(l_ret == FALSE) {
- ret = 0;
- goto out;
- } /* end if */
- /* function failed */
- else if(l_ret < 0)
- goto out;
+ if (l_ret == FALSE) {
+ H5TOOLS_GOTO_DONE(0);
+ }
+ else if (l_ret < 0) { /* function failed */
+ H5TOOLS_GOTO_DONE(FAIL);
+ }
/* get target object info */
- if(H5Oget_info_by_name(file_id, linkpath, &trg_oinfo, lapl) < 0) {
- if(link_info->opt.msg_mode == 1)
+ if (H5Oget_info_by_name3(file_id, linkpath, &trg_oinfo, H5O_INFO_BASIC, lapl) < 0) {
+ if (link_info->opt.msg_mode == 1)
parallel_print("Warning: unable to get object information for <%s>\n", linkpath);
- goto out;
+ H5TOOLS_GOTO_DONE(FAIL);
} /* end if */
/* check unknown type */
- if(trg_oinfo.type < H5O_TYPE_GROUP || trg_oinfo.type >=H5O_TYPE_NTYPES) {
- if(link_info->opt.msg_mode == 1)
+ if (trg_oinfo.type < H5O_TYPE_GROUP || trg_oinfo.type >= H5O_TYPE_NTYPES) {
+ if (link_info->opt.msg_mode == 1)
parallel_print("Warning: target object of <%s> is unknown type\n", linkpath);
- goto out;
- } /* end if */
+ H5TOOLS_GOTO_DONE(FAIL);
+ } /* end if */
/* set target obj type to return */
+ HDmemcpy(&link_info->obj_token, &trg_oinfo.token, sizeof(H5O_token_t));
link_info->trg_type = trg_oinfo.type;
+ link_info->fileno = trg_oinfo.fileno;
} /* end if */
else
link_info->trg_type = H5O_TYPE_UNKNOWN;
/* succeed */
- ret = 1;
+ ret_value = 1;
-out:
- if(fapl != H5P_DEFAULT)
+done:
+ if (fapl != H5P_DEFAULT)
H5Pclose(fapl);
- if(lapl != H5P_DEFAULT)
+ if (lapl != H5P_DEFAULT)
H5Pclose(lapl);
- return ret;
+ return ret_value;
} /* end H5tools_get_symlink_info() */
/*-------------------------------------------------------------------------
* Audience: Public
- * Chapter: H5Tools Library
+ *
* Purpose: Initialize the name and operation status of the H5 Tools library
+ *
* Description:
* These are utility functions to set/get the program name and operation status.
*-------------------------------------------------------------------------
*/
-void h5tools_setprogname(const char *Progname)
+void
+h5tools_setprogname(const char *Progname)
{
h5tools_progname = Progname;
}
-void h5tools_setstatus(int D_status)
+void
+h5tools_setstatus(int D_status)
{
h5tools_d_status = D_status;
}
-const char*h5tools_getprogname(void)
+H5_ATTR_PURE const char *
+h5tools_getprogname(void)
{
- return h5tools_progname;
+ return h5tools_progname;
}
-int h5tools_getstatus(void)
+H5_ATTR_PURE int
+h5tools_getstatus(void)
{
- return h5tools_d_status;
+ return h5tools_d_status;
}
/*-----------------------------------------------------------
- * PURPOSE :
- * if environment variable H5TOOLS_BUFSIZE is set,
+ * PURPOSE :
+ * if environment variable H5TOOLS_BUFSIZE is set,
* update H5TOOLS_BUFSIZE and H5TOOLS_MALLOCSIZE from the env
* This can be called from each tools main() as part of initial act.
* Note: this is more of debugging purpose for now.
*/
-int h5tools_getenv_update_hyperslab_bufsize(void)
+int
+h5tools_getenv_update_hyperslab_bufsize(void)
{
const char *env_str = NULL;
- long hyperslab_bufsize_mb;
+ long hyperslab_bufsize_mb;
+ int ret_value = 1;
/* check if environment variable is set for the hyperslab buffer size */
- if (NULL != (env_str = HDgetenv ("H5TOOLS_BUFSIZE")))
- {
- errno = 0;
- hyperslab_bufsize_mb = HDstrtol(env_str, (char**)NULL, 10);
+ if (NULL != (env_str = HDgetenv("H5TOOLS_BUFSIZE"))) {
+ errno = 0;
+ hyperslab_bufsize_mb = HDstrtol(env_str, (char **)NULL, 10);
if (errno != 0 || hyperslab_bufsize_mb <= 0)
- {
-
- /* TODO: later when pubilshed
- HDfprintf(rawerrorstream,"Error: Invalid environment variable \"H5TOOLS_BUFSIZE\" : %s\n", env_str);
- */
-
- goto error;
- }
-
+ H5TOOLS_GOTO_ERROR(FAIL, "hyperslab buffer size failed");
/* convert MB to byte */
- H5TOOLS_BUFSIZE = hyperslab_bufsize_mb * 1024 * 1024;
+ H5TOOLS_BUFSIZE = (hsize_t)hyperslab_bufsize_mb * 1024 * 1024;
H5TOOLS_MALLOCSIZE = MAX(H5TOOLS_BUFSIZE, H5TOOLS_MALLOCSIZE);
}
+done:
+ return ret_value;
+}
+
+#ifdef H5_HAVE_ROS3_VFD
+/*----------------------------------------------------------------------------
+ *
+ * Function: h5tools_parse_ros3_fapl_tuple
+ *
+ * Purpose: A convenience function that parses a string containing a tuple
+ * of S3 VFD credential information and then passes the result to
+ * `h5tools_populate_ros3_fapl()` in order to setup a valid
+ * configuration for the S3 VFD.
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *----------------------------------------------------------------------------
+ */
+herr_t
+h5tools_parse_ros3_fapl_tuple(const char *tuple_str, int delim, H5FD_ros3_fapl_t *fapl_config_out)
+{
+ const char *ccred[3];
+ unsigned nelems = 0;
+ char *s3cred_src = NULL;
+ char **s3cred = NULL;
+ herr_t ret_value = SUCCEED;
+
+ /* Attempt to parse S3 credentials tuple */
+ if (parse_tuple(tuple_str, delim, &s3cred_src, &nelems, &s3cred) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "failed to parse S3 VFD info tuple");
+
+ /* Sanity-check tuple count */
+ if (nelems != 3)
+ H5TOOLS_GOTO_ERROR(FAIL, "invalid S3 VFD credentials");
+
+ ccred[0] = (const char *)s3cred[0];
+ ccred[1] = (const char *)s3cred[1];
+ ccred[2] = (const char *)s3cred[2];
+
+ if (0 == h5tools_populate_ros3_fapl(fapl_config_out, ccred))
+ H5TOOLS_GOTO_ERROR(FAIL, "failed to populate S3 VFD FAPL config");
+
+done:
+ if (s3cred)
+ HDfree(s3cred);
+ if (s3cred_src)
+ HDfree(s3cred_src);
+
+ return ret_value;
+}
+
+/*----------------------------------------------------------------------------
+ *
+ * Function: h5tools_populate_ros3_fapl()
+ *
+ * Purpose:
+ *
+ * Set the values of a ROS3 fapl configuration object.
+ *
+ * If the values pointer is NULL, sets fapl target `fa` to a default
+ * (valid, current-version, non-authenticating) fapl config.
+ *
+ * If `values` pointer is _not_ NULL, expects `values` to contain at least
+ * three non-null pointers to null-terminated strings, corresponding to:
+ * { aws_region,
+ * secret_id,
+ * secret_key,
+ * }
+ * If all three strings are empty (""), the default fapl will be default.
+ * Both aws_region and secret_id values must be both empty or both
+ * populated. If
+ * Only secret_key is allowed to be empty (the empty string, "").
+ * All values are checked against overflow as defined in the ros3 vfd
+ * header file; if a value overruns the permitted space, FAIL is returned
+ * and the function aborts without resetting the fapl to values initially
+ * present.
+ *
+ * Return:
+ *
+ * 0 (failure) if...
+ * * Read-Only S3 VFD is not enabled.
+ * * NULL fapl pointer: (NULL, {...} )
+ * * Warning: In all cases below, fapl will be set as "default"
+ * before error occurs.
+ * * NULL value strings: (&fa, {NULL?, NULL? NULL?, ...})
+ * * Incomplete fapl info:
+ * * empty region, non-empty id, key either way
+ * * (&fa, {"", "...", "?"})
+ * * empty id, non-empty region, key either way
+ * * (&fa, {"...", "", "?"})
+ * * "non-empty key and either id or region empty
+ * * (&fa, {"", "", "...")
+ * * (&fa, {"", "...", "...")
+ * * (&fa, {"...", "", "...")
+ * * Any string would overflow allowed space in fapl definition.
+ * or
+ * 1 (success)
+ * * Sets components in fapl_t pointer, copying strings as appropriate.
+ * * "Default" fapl (valid version, authenticate->False, empty strings)
+ * * `values` pointer is NULL
+ * * (&fa, NULL)
+ * * first three strings in `values` are empty ("")
+ * * (&fa, {"", "", "", ...}
+ * * Authenticating fapl
+ * * region, id, and optional key provided
+ * * (&fa, {"...", "...", ""})
+ * * (&fa, {"...", "...", "..."})
+ *
+ * Programmer: Jacob Smith
+ * 2017-11-13
+ *
+ *----------------------------------------------------------------------------
+ */
+int
+h5tools_populate_ros3_fapl(H5FD_ros3_fapl_t *fa, const char **values)
+{
+ int show_progress = 0; /* set to 1 for debugging */
+ int ret_value = 1; /* 1 for success, 0 for failure */
+ /* e.g.? if (!populate()) { then failed } */
+
+ if (show_progress) {
+ HDprintf("called h5tools_populate_ros3_fapl\n");
+ }
+
+ if (fa == NULL) {
+ if (show_progress) {
+ HDprintf(" ERROR: null pointer to fapl_t\n");
+ }
+ ret_value = 0;
+ goto done;
+ }
+
+ if (show_progress) {
+ HDprintf(" preset fapl with default values\n");
+ }
+ fa->version = H5FD_CURR_ROS3_FAPL_T_VERSION;
+ fa->authenticate = FALSE;
+ *(fa->aws_region) = '\0';
+ *(fa->secret_id) = '\0';
+ *(fa->secret_key) = '\0';
+
+ /* sanity-check supplied values
+ */
+ if (values != NULL) {
+ if (values[0] == NULL) {
+ if (show_progress) {
+ HDprintf(" ERROR: aws_region value cannot be NULL\n");
+ }
+ ret_value = 0;
+ goto done;
+ }
+ if (values[1] == NULL) {
+ if (show_progress) {
+ HDprintf(" ERROR: secret_id value cannot be NULL\n");
+ }
+ ret_value = 0;
+ goto done;
+ }
+ if (values[2] == NULL) {
+ if (show_progress) {
+ HDprintf(" ERROR: secret_key value cannot be NULL\n");
+ }
+ ret_value = 0;
+ goto done;
+ }
+
+ /* if region and ID are supplied (key optional), write to fapl...
+ * fail if value would overflow
+ */
+ if (*values[0] != '\0' && *values[1] != '\0') {
+ if (HDstrlen(values[0]) > H5FD_ROS3_MAX_REGION_LEN) {
+ if (show_progress) {
+ HDprintf(" ERROR: aws_region value too long\n");
+ }
+ ret_value = 0;
+ goto done;
+ }
+ HDmemcpy(fa->aws_region, values[0], (HDstrlen(values[0]) + 1));
+ if (show_progress) {
+ HDprintf(" aws_region set\n");
+ }
- return (1);
-error:
- return (-1);
+ if (HDstrlen(values[1]) > H5FD_ROS3_MAX_SECRET_ID_LEN) {
+ if (show_progress) {
+ HDprintf(" ERROR: secret_id value too long\n");
+ }
+ ret_value = 0;
+ goto done;
+ }
+ HDmemcpy(fa->secret_id, values[1], (HDstrlen(values[1]) + 1));
+ if (show_progress) {
+ HDprintf(" secret_id set\n");
+ }
+
+ if (HDstrlen(values[2]) > H5FD_ROS3_MAX_SECRET_KEY_LEN) {
+ if (show_progress) {
+ HDprintf(" ERROR: secret_key value too long\n");
+ }
+ ret_value = 0;
+ goto done;
+ }
+ HDmemcpy(fa->secret_key, values[2], (HDstrlen(values[2]) + 1));
+ if (show_progress) {
+ HDprintf(" secret_key set\n");
+ }
+
+ fa->authenticate = TRUE;
+ if (show_progress) {
+ HDprintf(" set to authenticate\n");
+ }
+ }
+ else if (*values[0] != '\0' || *values[1] != '\0' || *values[2] != '\0') {
+ if (show_progress) {
+ HDprintf(" ERROR: invalid assortment of empty/non-empty values\n");
+ }
+ ret_value = 0;
+ goto done;
+ }
+ } /* values != NULL */
+
+done:
+ return ret_value;
+} /* h5tools_populate_ros3_fapl */
+#endif /* H5_HAVE_ROS3_VFD */
+
+#ifdef H5_HAVE_LIBHDFS
+/*----------------------------------------------------------------------------
+ *
+ * Function: h5tools_parse_hdfs_fapl_tuple
+ *
+ * Purpose: A convenience function that parses a string containing a tuple
+ * of HDFS VFD configuration information.
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *----------------------------------------------------------------------------
+ */
+herr_t
+h5tools_parse_hdfs_fapl_tuple(const char *tuple_str, int delim, H5FD_hdfs_fapl_t *fapl_config_out)
+{
+ unsigned long k = 0;
+ unsigned nelems = 0;
+ char *props_src = NULL;
+ char **props = NULL;
+ herr_t ret_value = SUCCEED;
+
+ /* Attempt to parse HDFS configuration tuple */
+ if (parse_tuple(tuple_str, delim, &props_src, &nelems, &props) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "failed to parse HDFS VFD configuration tuple");
+
+ /* Sanity-check tuple count */
+ if (nelems != 5)
+ H5TOOLS_GOTO_ERROR(FAIL, "invalid HDFS VFD configuration");
+
+ /* 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)) {
+ HDstrncpy(fapl_config_out->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)
+ H5TOOLS_GOTO_ERROR(FAIL, "supposed port number wasn't");
+ fapl_config_out->namenode_port = (int32_t)k;
+ }
+ if (HDstrncmp(props[2], "", 1)) {
+ HDstrncpy(fapl_config_out->kerberos_ticket_cache, (const char *)props[2], HDstrlen(props[2]));
+ }
+ if (HDstrncmp(props[3], "", 1)) {
+ HDstrncpy(fapl_config_out->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)
+ H5TOOLS_GOTO_ERROR(FAIL, "supposed buffersize number wasn't");
+ fapl_config_out->stream_buffer_size = (int32_t)k;
+ }
+
+done:
+ if (props)
+ HDfree(props);
+ if (props_src)
+ HDfree(props_src);
+
+ return ret_value;
}
+#endif /* H5_HAVE_LIBHDFS */
diff --git a/tools/lib/h5tools_utils.h b/tools/lib/h5tools_utils.h
index f30974a..f28456e 100644
--- a/tools/lib/h5tools_utils.h
+++ b/tools/lib/h5tools_utils.h
@@ -1,26 +1,23 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Programmer: Bill Wendling <wendling@ncsa.uiuc.edu>
+ * Programmer: Bill Wendling
* Tuesday, 6. March 2001
*
* Purpose: Support functions for the various tools.
*/
-#ifndef H5TOOLS_UTILS_H__
-#define H5TOOLS_UTILS_H__
+#ifndef H5TOOLS_UTILS_H
+#define H5TOOLS_UTILS_H
#include "hdf5.h"
@@ -29,83 +26,31 @@ extern "C" {
#endif
/* ``parallel_print'' information */
-#define PRINT_DATA_MAX_SIZE 512
-#define OUTBUFF_SIZE (PRINT_DATA_MAX_SIZE*4)
+#define PRINT_DATA_MAX_SIZE 512
+#define OUTBUFF_SIZE (PRINT_DATA_MAX_SIZE * 4)
-H5TOOLS_DLLVAR int g_nTasks;
+H5TOOLS_DLLVAR int g_nTasks;
H5TOOLS_DLLVAR unsigned char g_Parallel;
-H5TOOLS_DLLVAR char outBuff[];
-H5TOOLS_DLLVAR int outBuffOffset;
-H5TOOLS_DLLVAR FILE * overflow_file;
+H5TOOLS_DLLVAR char outBuff[];
+H5TOOLS_DLLVAR unsigned outBuffOffset;
+H5TOOLS_DLLVAR FILE *overflow_file;
/* Maximum size used in a call to malloc for a dataset */
H5TOOLS_DLLVAR hsize_t H5TOOLS_MALLOCSIZE;
/* size of hyperslab buffer when a dataset is bigger than H5TOOLS_MALLOCSIZE */
H5TOOLS_DLLVAR hsize_t H5TOOLS_BUFSIZE;
-/*
- * begin get_option section
- */
-H5TOOLS_DLLVAR int opt_err; /* getoption prints errors if this is on */
-H5TOOLS_DLLVAR int opt_ind; /* token pointer */
-H5TOOLS_DLLVAR const char *opt_arg; /* flag argument (or value) */
-
-enum {
- no_arg = 0, /* doesn't take an argument */
- require_arg, /* requires an argument */
- optional_arg /* argument is optional */
-};
-
-/*
- * get_option determines which options are specified on the command line and
- * returns a pointer to any arguments possibly associated with the option in
- * the ``opt_arg'' variable. get_option returns the shortname equivalent of
- * the option. The long options are specified in the following way:
- *
- * struct long_options foo[] = {
- * { "filename", require_arg, 'f' },
- * { "append", no_arg, 'a' },
- * { "width", require_arg, 'w' },
- * { NULL, 0, 0 }
- * };
- *
- * Long named options can have arguments specified as either:
- *
- * ``--param=arg'' or ``--param arg''
- *
- * Short named options can have arguments specified as either:
- *
- * ``-w80'' or ``-w 80''
- *
- * and can have more than one short named option specified at one time:
- *
- * -aw80
- *
- * in which case those options which expect an argument need to come at the
- * end.
- */
-typedef struct long_options {
- const char *name; /* name of the long option */
- int has_arg; /* whether we should look for an arg */
- char shortval; /* the shortname equivalent of long arg
- * this gets returned from get_option */
-} long_options;
-
-H5TOOLS_DLL int get_option(int argc, const char **argv, const char *opt,
- const struct long_options *l_opt);
-/*
- * end get_option section
- */
/*struct taken from the dumper. needed in table struct*/
typedef struct obj_t {
- haddr_t objno;
- char *objname;
- hbool_t displayed; /* Flag to indicate that the object has been displayed */
- hbool_t recorded; /* Flag for named datatypes to indicate they were found in the group hierarchy */
+ H5O_token_t obj_token;
+ char *objname;
+ hbool_t displayed; /* Flag to indicate that the object has been displayed */
+ hbool_t recorded; /* Flag for named datatypes to indicate they were found in the group hierarchy */
} obj_t;
/*struct for the tables that the find_objs function uses*/
typedef struct table_t {
+ hid_t fid;
size_t size;
size_t nobjs;
obj_t *objs;
@@ -113,30 +58,32 @@ typedef struct table_t {
/*this struct stores the information that is passed to the find_objs function*/
typedef struct find_objs_t {
- hid_t fid;
+ hid_t fid;
table_t *group_table;
table_t *type_table;
table_t *dset_table;
} find_objs_t;
-H5TOOLS_DLLVAR int h5tools_nCols; /*max number of columns for outputting */
+H5TOOLS_DLLVAR unsigned h5tools_nCols; /*max number of columns for outputting */
/* Definitions of useful routines */
-H5TOOLS_DLL void indentation(int);
-H5TOOLS_DLL void print_version(const char *progname);
-H5TOOLS_DLL void parallel_print(const char* format, ... );
-H5TOOLS_DLL void error_msg(const char *fmt, ...);
-H5TOOLS_DLL void warn_msg(const char *fmt, ...);
-H5TOOLS_DLL void help_ref_msg(FILE *output);
-H5TOOLS_DLL void free_table(table_t *table);
+H5TOOLS_DLL void indentation(unsigned);
+H5TOOLS_DLL void print_version(const char *progname);
+H5TOOLS_DLL void parallel_print(const char *format, ...) H5_ATTR_FORMAT(printf, 1, 2);
+H5TOOLS_DLL herr_t parse_tuple(const char *start, int sep, char **cpy_out, unsigned *nelems,
+ char ***ptrs_out);
+H5TOOLS_DLL void error_msg(const char *fmt, ...) H5_ATTR_FORMAT(printf, 1, 2);
+H5TOOLS_DLL void warn_msg(const char *fmt, ...) H5_ATTR_FORMAT(printf, 1, 2);
+H5TOOLS_DLL void help_ref_msg(FILE *output);
+H5TOOLS_DLL void free_table(table_t *table);
#ifdef H5DUMP_DEBUG
-H5TOOLS_DLL void dump_tables(find_objs_t *info)
-#endif /* H5DUMP_DEBUG */
-H5TOOLS_DLL herr_t init_objs(hid_t fid, find_objs_t *info, table_t **group_table,
- table_t **dset_table, table_t **type_table);
-H5TOOLS_DLL obj_t *search_obj(table_t *temp, haddr_t objno);
+H5TOOLS_DLL void dump_tables(find_objs_t *info);
+#endif /* H5DUMP_DEBUG */
+H5TOOLS_DLL herr_t init_objs(hid_t fid, find_objs_t *info, table_t **group_table, table_t **dset_table,
+ table_t **type_table);
+H5TOOLS_DLL obj_t *search_obj(table_t *temp, const H5O_token_t *obj_token);
#ifndef H5_HAVE_TMPFILE
-H5TOOLS_DLL FILE * tmpfile(void);
+H5TOOLS_DLL FILE *tmpfile(void);
#endif
/*************************************************************
@@ -147,35 +94,48 @@ H5TOOLS_DLL FILE * tmpfile(void);
/* This code is layout for common code among tools */
typedef enum toolname_t {
- TOOL_H5DIFF, TOOL_H5LS, TOOL__H5DUMP /* add as necessary */
+ TOOL_H5DIFF,
+ TOOL_H5LS,
+ TOOL__H5DUMP /* add as necessary */
} h5tool_toolname_t;
-/* this struct can be used to differntiate among tools */
+/* this struct can be used to differentiate among tools */
typedef struct {
h5tool_toolname_t toolname;
- int msg_mode;
+ int msg_mode;
} h5tool_opt_t;
/* obtain link info from H5tools_get_symlink_info() */
typedef struct {
- H5O_type_t trg_type; /* OUT: target type */
- const char *trg_path; /* OUT: target obj path. This must be freed
- * when used with H5tools_get_symlink_info() */
- H5L_info_t linfo; /* OUT: link info */
- h5tool_opt_t opt; /* IN: options */
+ H5O_type_t trg_type; /* OUT: target type */
+ char *trg_path; /* OUT: target obj path. This must be freed
+ * when used with H5tools_get_symlink_info() */
+ H5O_token_t obj_token; /* OUT: target object token */
+ unsigned long fileno; /* OUT: File number that target object is located in */
+ H5L_info2_t linfo; /* OUT: link info */
+ h5tool_opt_t opt; /* IN: options */
} h5tool_link_info_t;
-
/* Definitions of routines */
-H5TOOLS_DLL int H5tools_get_symlink_info(hid_t file_id, const char * linkpath,
- h5tool_link_info_t *link_info, hbool_t get_obj_type);
+H5TOOLS_DLL int H5tools_get_symlink_info(hid_t file_id, const char *linkpath, h5tool_link_info_t *link_info,
+ hbool_t get_obj_type);
H5TOOLS_DLL const char *h5tools_getprogname(void);
-H5TOOLS_DLL void h5tools_setprogname(const char*progname);
-H5TOOLS_DLL int h5tools_getstatus(void);
-H5TOOLS_DLL void h5tools_setstatus(int d_status);
-H5TOOLS_DLL int h5tools_getenv_update_hyperslab_bufsize(void);
+H5TOOLS_DLL void h5tools_setprogname(const char *progname);
+H5TOOLS_DLL int h5tools_getstatus(void);
+H5TOOLS_DLL void h5tools_setstatus(int d_status);
+H5TOOLS_DLL int h5tools_getenv_update_hyperslab_bufsize(void);
+#ifdef H5_HAVE_ROS3_VFD
+H5TOOLS_DLL herr_t h5tools_parse_ros3_fapl_tuple(const char *tuple_str, int delim,
+ H5FD_ros3_fapl_t *fapl_config_out);
+H5TOOLS_DLL int h5tools_populate_ros3_fapl(H5FD_ros3_fapl_t *fa, const char **values);
+#endif /* H5_HAVE_ROS3_VFD */
+#ifdef H5_HAVE_LIBHDFS
+H5TOOLS_DLL herr_t h5tools_parse_hdfs_fapl_tuple(const char *tuple_str, int delim,
+ H5FD_hdfs_fapl_t *fapl_config_out);
+#endif
+
#ifdef __cplusplus
}
#endif
-#endif /* H5TOOLS_UTILS_H__ */
+#endif /* H5TOOLS_UTILS_H */
diff --git a/tools/lib/h5trav.c b/tools/lib/h5trav.c
index ad8b9fe..599cb22 100644
--- a/tools/lib/h5trav.c
+++ b/tools/lib/h5trav.c
@@ -1,452 +1,478 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
#include "h5trav.h"
+#include "h5tools.h"
#include "H5private.h"
/*-------------------------------------------------------------------------
* local typedefs
*-------------------------------------------------------------------------
*/
+typedef struct trav_addr_path_t {
+ H5O_token_t token;
+ char *path;
+} trav_addr_path_t;
+
typedef struct trav_addr_t {
- size_t nalloc;
- size_t nused;
- struct {
- haddr_t addr;
- char *path;
- } *objs;
+ size_t nalloc;
+ size_t nused;
+ trav_addr_path_t *objs;
} trav_addr_t;
typedef struct {
- h5trav_obj_func_t visit_obj; /* Callback for visiting objects */
- h5trav_lnk_func_t visit_lnk; /* Callback for visiting links */
- void *udata; /* User data to pass to callbacks */
+ h5trav_obj_func_t visit_obj; /* Callback for visiting objects */
+ h5trav_lnk_func_t visit_lnk; /* Callback for visiting links */
+ void *udata; /* User data to pass to callbacks */
} trav_visitor_t;
typedef struct {
- trav_addr_t *seen; /* List of addresses seen already */
- const trav_visitor_t *visitor; /* Information for visiting each link/object */
- hbool_t is_absolute; /* Whether the traversal has absolute paths */
- const char *base_grp_name; /* Name of the group that serves as the base
- * for iteration */
+ trav_addr_t *seen; /* List of addresses seen already */
+ const trav_visitor_t *visitor; /* Information for visiting each link/object */
+ hbool_t is_absolute; /* Whether the traversal has absolute paths */
+ const char *base_grp_name; /* Name of the group that serves as the base
+ * for iteration */
+ unsigned fields; /* Fields needed in H5O_info2_t struct */
} trav_ud_traverse_t;
typedef struct {
- hid_t fid; /* File ID being traversed */
+ hid_t fid; /* File ID being traversed */
} trav_print_udata_t;
+typedef struct trav_path_op_data_t {
+ const char *path;
+} trav_path_op_data_t;
+
/*-------------------------------------------------------------------------
* local functions
*-------------------------------------------------------------------------
*/
-static void trav_table_add(trav_table_t *table,
- const char *objname,
- const H5O_info_t *oinfo);
+static void trav_table_add(trav_table_t *table, const char *objname, const H5O_info2_t *oinfo);
-static void trav_table_addlink(trav_table_t *table,
- haddr_t objno,
- const char *path);
+static void trav_table_addlink(trav_table_t *table, const H5O_token_t *obj_token, const char *path);
/*-------------------------------------------------------------------------
- * "h5trav info" public functions. used in h5diff
+ * local variables
*-------------------------------------------------------------------------
*/
+static H5_index_t trav_index_by = H5_INDEX_NAME;
+static H5_iter_order_t trav_index_order = H5_ITER_INC;
+
+static int trav_verbosity = 0;
-
/*-------------------------------------------------------------------------
- * Function: trav_addr_add
+ * Function: h5trav_set_index
*
- * Purpose: Add a hardlink address to visited data structure
+ * Purpose: Set indexing properties for the objects & links in the file
*
- * Return: void
+ * Return: none
+ *-------------------------------------------------------------------------
+ */
+void
+h5trav_set_index(H5_index_t print_index_by, H5_iter_order_t print_index_order)
+{
+ trav_index_by = print_index_by;
+ trav_index_order = print_index_order;
+}
+
+/*-------------------------------------------------------------------------
+ * Function: h5trav_set_verbose
+ *
+ * Purpose: Set verbosity of file contents 1=>attributes
*
- * Programmer: Quincey Koziol, koziol@hdfgroup.org
+ * Return: none
+ *-------------------------------------------------------------------------
+ */
+void
+h5trav_set_verbose(int print_verbose)
+{
+ trav_verbosity = print_verbose;
+}
+
+/*-------------------------------------------------------------------------
+ * "h5trav info" public functions. used in h5diff
+ *-------------------------------------------------------------------------
+ */
+
+/*-------------------------------------------------------------------------
+ * Function: trav_token_add
*
- * Date: September 1, 2007
+ * Purpose: Add an object token to visited data structure
*
+ * Return: void
*-------------------------------------------------------------------------
*/
static void
-trav_addr_add(trav_addr_t *visited, haddr_t addr, const char *path)
+trav_token_add(trav_addr_t *visited, H5O_token_t *token, const char *path)
{
- size_t idx; /* Index of address to use */
+ size_t idx; /* Index of address to use */
/* Allocate space if necessary */
- if(visited->nused == visited->nalloc) {
- visited->nalloc = MAX(1, visited->nalloc * 2);;
- visited->objs = HDrealloc(visited->objs, visited->nalloc * sizeof(visited->objs[0]));
+ if (visited->nused == visited->nalloc) {
+ visited->nalloc = MAX(1, visited->nalloc * 2);
+ ;
+ visited->objs =
+ (trav_addr_path_t *)HDrealloc(visited->objs, visited->nalloc * sizeof(trav_addr_path_t));
} /* end if */
/* Append it */
idx = visited->nused++;
- visited->objs[idx].addr = addr;
+ HDmemcpy(&visited->objs[idx].token, token, sizeof(H5O_token_t));
visited->objs[idx].path = HDstrdup(path);
-} /* end trav_addr_add() */
+} /* end trav_token_add() */
-
/*-------------------------------------------------------------------------
- * Function: trav_addr_visited
- *
- * Purpose: Check if an address has already been visited
+ * Function: trav_token_visited
*
- * Return: TRUE/FALSE
- *
- * Programmer: Quincey Koziol, koziol@hdfgroup.org
- *
- * Date: September 1, 2007
+ * Purpose: Check if an object token has already been seen
*
+ * Return: TRUE/FALSE
*-------------------------------------------------------------------------
*/
-static const char *
-trav_addr_visited(trav_addr_t *visited, haddr_t addr)
+H5_ATTR_PURE static const char *
+trav_token_visited(hid_t loc_id, trav_addr_t *visited, H5O_token_t *token)
{
- size_t u; /* Local index variable */
+ size_t u; /* Local index variable */
+ int token_cmp;
/* Look for address */
- for(u = 0; u < visited->nused; u++)
+ for (u = 0; u < visited->nused; u++) {
/* Check for address already in array */
- if(visited->objs[u].addr == addr)
- return(visited->objs[u].path);
+ if (H5Otoken_cmp(loc_id, &visited->objs[u].token, token, &token_cmp) < 0)
+ return NULL;
+ if (!token_cmp)
+ return (visited->objs[u].path);
+ }
- /* Didn't find address */
- return(NULL);
-} /* end trav_addr_visited() */
+ /* Didn't find object token */
+ return (NULL);
+} /* end trav_token_visited() */
-
/*-------------------------------------------------------------------------
* Function: traverse_cb
*
- * Purpose: Iterator callback for traversing objects in file
- *
- * Programmer: Quincey Koziol, koziol@hdfgroup.org
- *
- * Date: September 1, 2007
- *
+ * Purpose: Iterator callback for traversing objects in file
*-------------------------------------------------------------------------
*/
static herr_t
-traverse_cb(hid_t loc_id, const char *path, const H5L_info_t *linfo,
- void *_udata)
+traverse_cb(hid_t loc_id, const char *path, const H5L_info2_t *linfo, void *_udata)
{
- trav_ud_traverse_t *udata = (trav_ud_traverse_t *)_udata; /* User data */
- char *new_name = NULL;
- const char *full_name;
- const char *already_visited = NULL; /* Whether the link/object was already visited */
+ trav_ud_traverse_t *udata = (trav_ud_traverse_t *)_udata; /* User data */
+ char *new_name = NULL;
+ const char *full_name;
+ const char *already_visited = NULL; /* Whether the link/object was already visited */
/* Create the full path name for the link */
- if(udata->is_absolute) {
- size_t base_len = HDstrlen(udata->base_grp_name);
- size_t add_slash = base_len ? ((udata->base_grp_name)[base_len-1] != '/') : 1;
-
- if(NULL == (new_name = (char*)HDmalloc(base_len + add_slash + HDstrlen(path) + 1)))
- return(H5_ITER_ERROR);
- HDstrcpy(new_name, udata->base_grp_name);
+ if (udata->is_absolute) {
+ size_t base_len = HDstrlen(udata->base_grp_name);
+ size_t add_slash = base_len ? ((udata->base_grp_name)[base_len - 1] != '/') : 1;
+ size_t new_name_len = base_len + add_slash + HDstrlen(path) + 1 +
+ 3; /* Extra "+3" to quiet GCC warning - 2019/07/05, QAK */
+
+ if (NULL == (new_name = (char *)HDmalloc(new_name_len)))
+ return (H5_ITER_ERROR);
if (add_slash)
- new_name[base_len] = '/';
- HDstrcpy(new_name + base_len + add_slash, path);
+ HDsnprintf(new_name, new_name_len, "%s/%s", udata->base_grp_name, path);
+ else
+ HDsnprintf(new_name, new_name_len, "%s%s", udata->base_grp_name, path);
full_name = new_name;
} /* end if */
else
full_name = path;
/* Perform the correct action for different types of links */
- if(linfo->type == H5L_TYPE_HARD) {
- H5O_info_t oinfo;
+ if (linfo->type == H5L_TYPE_HARD) {
+ H5O_info2_t oinfo;
/* Get information about the object */
- if(H5Oget_info_by_name(loc_id, path, &oinfo, H5P_DEFAULT) < 0) {
- if(new_name)
+ if (H5Oget_info_by_name3(loc_id, path, &oinfo, udata->fields, H5P_DEFAULT) < 0) {
+ if (new_name)
HDfree(new_name);
- return(H5_ITER_ERROR);
- }
+ return (H5_ITER_ERROR);
+ } /* end if */
/* If the object has multiple links, add it to the list of addresses
* already visited, if it isn't there already
*/
- if(oinfo.rc > 1)
- if(NULL == (already_visited = trav_addr_visited(udata->seen, oinfo.addr)))
- trav_addr_add(udata->seen, oinfo.addr, full_name);
+ if (oinfo.rc > 1)
+ if (NULL == (already_visited = trav_token_visited(loc_id, udata->seen, &oinfo.token)))
+ trav_token_add(udata->seen, &oinfo.token, full_name);
/* Make 'visit object' callback */
- if(udata->visitor->visit_obj)
- if((*udata->visitor->visit_obj)(full_name, &oinfo, already_visited, udata->visitor->udata) < 0) {
- if(new_name)
+ if (udata->visitor->visit_obj)
+ if ((*udata->visitor->visit_obj)(full_name, &oinfo, already_visited, udata->visitor->udata) < 0) {
+ if (new_name)
HDfree(new_name);
- return(H5_ITER_ERROR);
- }
- } /* end if */
+ return (H5_ITER_ERROR);
+ } /* end if */
+ } /* end if */
else {
/* Make 'visit link' callback */
- if(udata->visitor->visit_lnk)
- if((*udata->visitor->visit_lnk)(full_name, linfo, udata->visitor->udata) < 0) {
- if(new_name)
+ if (udata->visitor->visit_lnk)
+ if ((*udata->visitor->visit_lnk)(full_name, linfo, udata->visitor->udata) < 0) {
+ if (new_name)
HDfree(new_name);
- return(H5_ITER_ERROR);
- }
- } /* end else */
+ return (H5_ITER_ERROR);
+ } /* end if */
+ } /* end else */
- if(new_name)
+ if (new_name)
HDfree(new_name);
- return(H5_ITER_CONT);
+ return (H5_ITER_CONT);
} /* end traverse_cb() */
-
/*-------------------------------------------------------------------------
* Function: traverse
*
- * Purpose: Iterate over all the objects/links in a file. Conforms to the
- * "visitor" pattern.
- *
- * Return: 0 on success, -1 on failure
- *
- * Programmer: Quincey Koziol, koziol@hdfgroup.org
- *
- * Date: September 1, 2007
+ * Purpose: Iterate over all the objects/links in a file. Conforms to the
+ * "visitor" pattern.
*
+ * Return: 0 on success,
+ * -1 on failure
*-------------------------------------------------------------------------
*/
static int
-traverse(hid_t file_id, const char *grp_name, hbool_t visit_start,
- hbool_t recurse, const trav_visitor_t *visitor)
+traverse(hid_t file_id, const char *grp_name, hbool_t visit_start, hbool_t recurse,
+ const trav_visitor_t *visitor, unsigned fields)
{
- H5O_info_t oinfo; /* Object info for starting group */
+ H5O_info2_t oinfo; /* Object info for starting group */
+ int ret_value = 0;
/* Get info for starting object */
- if(H5Oget_info_by_name(file_id, grp_name, &oinfo, H5P_DEFAULT) < 0)
- return -1;
+ if (H5Oget_info_by_name3(file_id, grp_name, &oinfo, fields, H5P_DEFAULT) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Oget_info_by_name failed");
/* Visit the starting object */
- if(visit_start && visitor->visit_obj)
+ if (visit_start && visitor->visit_obj)
(*visitor->visit_obj)(grp_name, &oinfo, NULL, visitor->udata);
/* Go visiting, if the object is a group */
- if(oinfo.type == H5O_TYPE_GROUP) {
- trav_addr_t seen; /* List of addresses seen */
- trav_ud_traverse_t udata; /* User data for iteration callback */
+ if (oinfo.type == H5O_TYPE_GROUP) {
+ trav_addr_t seen; /* List of addresses seen */
+ trav_ud_traverse_t udata; /* User data for iteration callback */
/* Init addresses seen */
seen.nused = seen.nalloc = 0;
- seen.objs = NULL;
+ seen.objs = NULL;
/* Check for multiple links to top group */
- if(oinfo.rc > 1)
- trav_addr_add(&seen, oinfo.addr, grp_name);
+ if (oinfo.rc > 1)
+ trav_token_add(&seen, &oinfo.token, grp_name);
/* Set up user data structure */
- udata.seen = &seen;
- udata.visitor = visitor;
- udata.is_absolute = (*grp_name == '/');
+ udata.seen = &seen;
+ udata.visitor = visitor;
+ udata.is_absolute = (*grp_name == '/');
udata.base_grp_name = grp_name;
+ udata.fields = fields;
/* Check for iteration of links vs. visiting all links recursively */
- if(recurse) {
+ if (recurse) {
/* Visit all links in group, recursively */
- if(H5Lvisit_by_name(file_id, grp_name, H5_INDEX_NAME, H5_ITER_INC, traverse_cb, &udata, H5P_DEFAULT) < 0)
- return -1;
+ if (H5Lvisit_by_name2(file_id, grp_name, trav_index_by, trav_index_order, traverse_cb, &udata,
+ H5P_DEFAULT) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Lvisit_by_name failed");
} /* end if */
else {
/* Iterate over links in group */
- if(H5Literate_by_name(file_id, grp_name, H5_INDEX_NAME, H5_ITER_INC, NULL, traverse_cb, &udata, H5P_DEFAULT) < 0)
- return -1;
+ if (H5Literate_by_name2(file_id, grp_name, trav_index_by, trav_index_order, NULL, traverse_cb,
+ &udata, H5P_DEFAULT) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Literate_by_name failed");
} /* end else */
/* Free visited addresses table */
- if(seen.objs) {
- size_t u; /* Local index variable */
+ if (seen.objs) {
+ size_t u; /* Local index variable */
/* Free paths to objects */
- for(u = 0; u < seen.nused; u++)
+ for (u = 0; u < seen.nused; u++)
HDfree(seen.objs[u].path);
HDfree(seen.objs);
} /* end if */
- } /* end if */
+ } /* end if */
- return 0;
+done:
+ return ret_value;
}
-
/*-------------------------------------------------------------------------
* Function: trav_info_add
*
- * Purpose: Add a link path & type to info struct
- *
- * Return: void
- *
- * Programmer: Quincey Koziol, koziol@hdfgroup.org
- *
- * Date: September 1, 2007
+ * Purpose: Add a link path & type to info struct
*
+ * Return: void
*-------------------------------------------------------------------------
*/
void
trav_info_add(trav_info_t *info, const char *path, h5trav_type_t obj_type)
{
- size_t idx; /* Index of address to use */
+ size_t idx; /* Index of address to use */
+
+ if (info) {
+ /* Allocate space if necessary */
+ if (info->nused == info->nalloc) {
+ info->nalloc = MAX(1, info->nalloc * 2);
+ ;
+ info->paths = (trav_path_t *)HDrealloc(info->paths, info->nalloc * sizeof(trav_path_t));
+ } /* end if */
- /* Allocate space if necessary */
- if(info->nused == info->nalloc) {
- info->nalloc = MAX(1, info->nalloc * 2);;
- info->paths = (trav_path_t *)HDrealloc(info->paths, info->nalloc * sizeof(trav_path_t));
- } /* end if */
+ /* Append it */
+ idx = info->nused++;
+ info->paths[idx].path = HDstrdup(path);
+ info->paths[idx].type = obj_type;
+ info->paths[idx].fileno = 0;
- /* Append it */
- idx = info->nused++;
- info->paths[idx].path = HDstrdup(path);
- info->paths[idx].type = obj_type;
- info->paths[idx].fileno = 0;
- info->paths[idx].objno = HADDR_UNDEF;
+ /* Set token to 'undefined' values */
+ info->paths[idx].obj_token = H5O_TOKEN_UNDEF;
+ }
} /* end trav_info_add() */
-
/*-------------------------------------------------------------------------
- * Function: trav_info_visit_obj
+ * Function: trav_fileinfo_add
*
- * Purpose: Callback for visiting object, with 'info' structure
+ * Purpose: Add a file addr & fileno to info struct
*
- * Return: 0 on success, -1 on failure
- *
- * Programmer: Quincey Koziol, koziol@hdfgroup.org
+ * Return: void
+ *-------------------------------------------------------------------------
+ */
+void
+trav_fileinfo_add(trav_info_t *info, hid_t loc_id)
+{
+ H5O_info2_t oinfo;
+ size_t idx = info->nused - 1;
+
+ if (info->paths[idx].path && HDstrcmp(info->paths[idx].path, ".") != 0)
+ H5Oget_info_by_name3(loc_id, info->paths[idx].path, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT);
+ else
+ H5Oget_info3(loc_id, &oinfo, H5O_INFO_BASIC);
+
+ HDmemcpy(&info->paths[idx].obj_token, &oinfo.token, sizeof(H5O_token_t));
+ info->paths[idx].fileno = oinfo.fileno;
+} /* end trav_fileinfo_add() */
+
+/*-------------------------------------------------------------------------
+ * Function: trav_info_visit_obj
*
- * Date: September 1, 2007
+ * Purpose: Callback for visiting object, with 'info' structure
*
+ * Return: 0 on success,
+ * -1 on failure
*-------------------------------------------------------------------------
*/
int
-trav_info_visit_obj(const char *path, const H5O_info_t *oinfo,
- const char UNUSED *already_visited, void *udata)
+trav_info_visit_obj(const char *path, const H5O_info2_t *oinfo, const char H5_ATTR_UNUSED *already_visited,
+ void *udata)
{
- size_t idx;
+ size_t idx;
trav_info_t *info_p;
+
/* Add the object to the 'info' struct */
/* (object types map directly to "traversal" types) */
trav_info_add((trav_info_t *)udata, path, (h5trav_type_t)oinfo->type);
/* set object addr and fileno. These are for checking same object */
- info_p = (trav_info_t *) udata;
- idx = info_p->nused - 1;
- info_p->paths[idx].objno = oinfo->addr;
+ info_p = (trav_info_t *)udata;
+ idx = info_p->nused - 1;
+ HDmemcpy(&info_p->paths[idx].obj_token, &oinfo->token, sizeof(H5O_token_t));
info_p->paths[idx].fileno = oinfo->fileno;
- return(0);
+ return (0);
} /* end trav_info_visit_obj() */
-
/*-------------------------------------------------------------------------
* Function: trav_info_visit_lnk
*
- * Purpose: Callback for visiting link, with 'info' structure
- *
- * Return: 0 on success, -1 on failure
- *
- * Programmer: Quincey Koziol, koziol@hdfgroup.org
- *
- * Date: September 1, 2007
+ * Purpose: Callback for visiting link, with 'info' structure
*
+ * Return: 0 on success,
+ * -1 on failure
*-------------------------------------------------------------------------
*/
int
-trav_info_visit_lnk(const char *path, const H5L_info_t *linfo, void *udata)
+trav_info_visit_lnk(const char *path, const H5L_info2_t *linfo, void *udata)
{
/* Add the link to the 'info' struct */
- trav_info_add((trav_info_t *)udata, path, ((linfo->type == H5L_TYPE_SOFT) ? H5TRAV_TYPE_LINK : H5TRAV_TYPE_UDLINK));
+ trav_info_add((trav_info_t *)udata, path,
+ ((linfo->type == H5L_TYPE_SOFT) ? H5TRAV_TYPE_LINK : H5TRAV_TYPE_UDLINK));
- return(0);
+ return (0);
} /* end trav_info_visit_lnk() */
-
/*-------------------------------------------------------------------------
* Function: h5trav_getinfo
*
- * Purpose: get an array of "trav_info_t" , containing the name and type of
- * objects in the file
- *
- * Return: number of object names in file
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 6, 2002
+ * Purpose: get an array of "trav_info_t" , containing the name and type of
+ * objects in the file
*
+ * Return: 0 on success,
+ * -1 on failure
*-------------------------------------------------------------------------
*/
int
h5trav_getinfo(hid_t file_id, trav_info_t *info)
{
- trav_visitor_t info_visitor; /* Visitor structure for trav_info_t's */
+ trav_visitor_t info_visitor; /* Visitor structure for trav_info_t's */
+ int ret_value = 0;
/* Init visitor structure */
info_visitor.visit_obj = trav_info_visit_obj;
info_visitor.visit_lnk = trav_info_visit_lnk;
- info_visitor.udata = info;
+ info_visitor.udata = info;
/* Traverse all objects in the file, visiting each object & link */
- if(traverse(file_id, "/", TRUE, TRUE, &info_visitor) < 0)
- return -1;
+ if (traverse(file_id, "/", TRUE, TRUE, &info_visitor, H5O_INFO_BASIC) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "traverse failed");
- return 0;
+done:
+ return ret_value;
}
/*-------------------------------------------------------------------------
* Function: h5trav_getindex
*
- * Purpose: get index of OBJ in list
- *
- * Return: index, -1 if not found
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: May 9, 2003
+ * Purpose: get index of OBJ in list
*
+ * Return: index on success,
+ * -1 if not found
*-------------------------------------------------------------------------
*/
-
-ssize_t
+H5_ATTR_PURE ssize_t
h5trav_getindex(const trav_info_t *info, const char *obj)
{
- size_t u; /* Local index variable */
+ size_t u; /* Local index variable */
/* Loop over all paths in 'info' struct, looking for object */
- for(u = 0; u < info->nused; u++) {
+ for (u = 0; u < info->nused; u++) {
/* Check for object name having full path (with leading '/') */
- if(HDstrcmp(obj, info->paths[u].path) == 0)
- return((ssize_t)u);
+ if (HDstrcmp(obj, info->paths[u].path) == 0)
+ return ((ssize_t)u);
/* Check for object name without leading '/' */
- if(HDstrcmp(obj, (info->paths[u].path + 1)) == 0)
- return((ssize_t)u);
+ if (HDstrcmp(obj, (info->paths[u].path + 1)) == 0)
+ return ((ssize_t)u);
} /* end for */
- return((ssize_t)-1);
+ return ((ssize_t)-1);
} /* end h5trav_getindex() */
-
/*-------------------------------------------------------------------------
* Function: trav_info_init
*
- * Purpose: Initialize the info
- *
- * Return: void
- *
- * Programmer: Quincey Koziol, koziol@hdfgroup.org
- *
- * Date: September 6, 2007
+ * Purpose: Initialize the info
*
+ * Return: void
*-------------------------------------------------------------------------
*/
-
void
trav_info_init(const char *filename, hid_t fileid, trav_info_t **_info)
{
@@ -454,224 +480,198 @@ trav_info_init(const char *filename, hid_t fileid, trav_info_t **_info)
/* Init info structure */
info->nused = info->nalloc = 0;
- info->paths = NULL;
- info->fname = filename;
- info->fid = fileid;
+ info->paths = NULL;
+ info->fname = filename;
+ info->fid = fileid;
/* Initialize list of visited symbolic links */
- info->symlink_visited.nused = 0;
- info->symlink_visited.nalloc = 0;
- info->symlink_visited.objs = NULL;
+ info->symlink_visited.nused = 0;
+ info->symlink_visited.nalloc = 0;
+ info->symlink_visited.objs = NULL;
info->symlink_visited.dangle_link = FALSE;
- *_info = info;
+ *_info = info;
} /* end trav_info_init() */
-
/*-------------------------------------------------------------------------
* Function: trav_info_free
*
- * Purpose: free info memory
- *
+ * Purpose: free info memory
*-------------------------------------------------------------------------
*/
-
void
trav_info_free(trav_info_t *info)
{
- size_t u; /* Local index variable */
+ size_t u; /* Local index variable */
- if(info) {
+ if (info) {
/* Free visited symbolic links path and file (if alloc) */
- for(u=0; u < info->symlink_visited.nused; u++)
- {
+ for (u = 0; u < info->symlink_visited.nused; u++) {
if (info->symlink_visited.objs[u].file)
HDfree(info->symlink_visited.objs[u].file);
-
HDfree(info->symlink_visited.objs[u].path);
}
HDfree(info->symlink_visited.objs);
/* Free path names */
- for(u = 0; u < info->nused; u++)
+ for (u = 0; u < info->nused; u++)
HDfree(info->paths[u].path);
HDfree(info->paths);
HDfree(info);
} /* end if */
} /* end trav_info_free() */
-
/*-------------------------------------------------------------------------
* "h5trav table" public functions. used in h5repack
*-------------------------------------------------------------------------
*/
-
/*-------------------------------------------------------------------------
* Function: trav_table_visit_obj
*
- * Purpose: Callback for visiting object, with 'table' sructure
- *
- * Return: 0 on success, -1 on failure
- *
- * Programmer: Quincey Koziol, koziol@hdfgroup.org
- *
- * Date: September 1, 2007
+ * Purpose: Callback for visiting object, with 'table' structure
*
+ * Return: 0 on success,
+ * -1 on failure
*-------------------------------------------------------------------------
*/
static int
-trav_table_visit_obj(const char *path, const H5O_info_t *oinfo,
- const char *already_visited, void *udata)
+trav_table_visit_obj(const char *path, const H5O_info2_t *oinfo, const char *already_visited, void *udata)
{
trav_table_t *table = (trav_table_t *)udata;
/* Check if we've already seen this object */
- if(NULL == already_visited)
+ if (NULL == already_visited)
/* add object to table */
trav_table_add(table, path, oinfo);
else
/* Add alias for object to table */
- trav_table_addlink(table, oinfo->addr, path);
+ trav_table_addlink(table, &oinfo->token, path);
- return(0);
+ return 0;
} /* end trav_table_visit_obj() */
-
/*-------------------------------------------------------------------------
* Function: trav_table_visit_lnk
*
- * Purpose: Callback for visiting link, with 'table' sructure
- *
- * Return: 0 on success, -1 on failure
- *
- * Programmer: Quincey Koziol, koziol@hdfgroup.org
- *
- * Date: September 1, 2007
+ * Purpose: Callback for visiting link, with 'table' structure
*
+ * Return: 0 on success,
+ * -1 on failure
*-------------------------------------------------------------------------
*/
static int
-trav_table_visit_lnk(const char *path, const H5L_info_t UNUSED *linfo, void *udata)
+trav_table_visit_lnk(const char *path, const H5L_info2_t H5_ATTR_UNUSED *linfo, void *udata)
{
/* Add the link to the 'table' struct */
trav_table_add((trav_table_t *)udata, path, NULL);
- return(0);
+ return 0;
} /* end trav_table_visit_lnk() */
-
/*-------------------------------------------------------------------------
* Function: h5trav_gettable
*
- * Purpose: get the trav_table_t struct
- *
- * Return: 0, -1 on error
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: December 17, 2003
+ * Purpose: get the trav_table_t struct
*
+ * Return: 0 on success,
+ * -1 on failure
*-------------------------------------------------------------------------
*/
-
int
h5trav_gettable(hid_t fid, trav_table_t *table)
{
- trav_visitor_t table_visitor; /* Visitor structure for trav_table_t's */
+ trav_visitor_t table_visitor; /* Visitor structure for trav_table_t's */
+ int ret_value = 0;
/* Init visitor structure */
table_visitor.visit_obj = trav_table_visit_obj;
table_visitor.visit_lnk = trav_table_visit_lnk;
- table_visitor.udata = table;
+ table_visitor.udata = table;
/* Traverse all objects in the file, visiting each object & link */
- if(traverse(fid, "/", TRUE, TRUE, &table_visitor) < 0)
- return -1;
- return 0;
+ if (traverse(fid, "/", TRUE, TRUE, &table_visitor, H5O_INFO_BASIC) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "traverse failed");
+
+done:
+ return ret_value;
}
/*-------------------------------------------------------------------------
* Function: h5trav_getindext
*
- * Purpose: get index of NAME in list
- *
- * Return: index, -1 if not found
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: December 18, 2003
+ * Purpose: get index of NAME in list
*
+ * Return: index on success,
+ * -1 if not found
*-------------------------------------------------------------------------
*/
-
-int
+H5_ATTR_PURE int
h5trav_getindext(const char *name, const trav_table_t *table)
{
unsigned int i;
- for(i = 0; i < table->nobjs; i++) {
- /* Check for object name having full path (with leading '/') */
- if(HDstrcmp(name, table->objs[i].name) == 0)
- return(i);
+ if (table) {
+ for (i = 0; i < table->nobjs; i++) {
+ /* Check for object name having full path (with leading '/') */
+ if (HDstrcmp(name, table->objs[i].name) == 0)
+ return ((int)i);
- /* Check for object name without leading '/' */
- if(HDstrcmp(name, table->objs[i].name + 1) == 0)
- return(i);
-
- /* search also in the list of links */
- if(table->objs[i].nlinks) {
- unsigned int j;
-
- for ( j=0; j<table->objs[i].nlinks; j++) {
- /* Check for object name having full path (with leading '/') */
- if(HDstrcmp(name, table->objs[i].links[j].new_name) == 0)
- return(i);
-
- /* Check for object name without leading '/' */
- if(HDstrcmp(name, table->objs[i].links[j].new_name + 1) == 0)
- return(i);
- } /* end for */
- } /* end if */
- } /* end for */
+ /* Check for object name without leading '/' */
+ if (HDstrcmp(name, table->objs[i].name + 1) == 0)
+ return ((int)i);
+ /* search also in the list of links */
+ if (table->objs[i].nlinks) {
+ unsigned int j;
+
+ for (j = 0; j < table->objs[i].nlinks; j++) {
+ /* Check for object name having full path (with leading '/') */
+ if (HDstrcmp(name, table->objs[i].links[j].new_name) == 0)
+ return ((int)i);
+
+ /* Check for object name without leading '/' */
+ if (HDstrcmp(name, table->objs[i].links[j].new_name + 1) == 0)
+ return ((int)i);
+ } /* end for */
+ } /* end if */
+ } /* end for */
+ }
return -1;
}
/*-------------------------------------------------------------------------
* Function: trav_table_add
*
- * Purpose: Add OBJNO, NAME and TYPE of object to table
- *
- * Return: void
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 4, 2002
+ * Purpose: Add OBJNO, NAME and TYPE of object to table
*
+ * Return: void
*-------------------------------------------------------------------------
*/
-
static void
-trav_table_add(trav_table_t *table,
- const char *path,
- const H5O_info_t *oinfo)
+trav_table_add(trav_table_t *table, const char *path, const H5O_info2_t *oinfo)
{
- size_t new;
+ size_t new_obj;
- if(table->nobjs == table->size) {
- table->size = MAX(1, table->size * 2);
- table->objs = (trav_obj_t*)HDrealloc(table->objs, table->size * sizeof(trav_obj_t));
- } /* end if */
+ if (table) {
+ if (table->nobjs == table->size) {
+ table->size = MAX(1, table->size * 2);
+ table->objs = (trav_obj_t *)HDrealloc(table->objs, table->size * sizeof(trav_obj_t));
+ } /* end if */
- new = table->nobjs++;
- table->objs[new].objno = oinfo ? oinfo->addr : HADDR_UNDEF;
- table->objs[new].flags[0] = table->objs[new].flags[1] = 0;
- table->objs[new].is_same_trgobj = 0;
- table->objs[new].name = (char *)HDstrdup(path);
- table->objs[new].type = oinfo ? (h5trav_type_t)oinfo->type : H5TRAV_TYPE_LINK;
- table->objs[new].nlinks = 0;
- table->objs[new].sizelinks = 0;
- table->objs[new].links = NULL;
+ new_obj = table->nobjs++;
+ if (oinfo)
+ HDmemcpy(&table->objs[new_obj].obj_token, &oinfo->token, sizeof(H5O_token_t));
+ else
+ /* Set token to 'undefined' values */
+ table->objs[new_obj].obj_token = H5O_TOKEN_UNDEF;
+ table->objs[new_obj].flags[0] = table->objs[new_obj].flags[1] = 0;
+ table->objs[new_obj].is_same_trgobj = 0;
+ table->objs[new_obj].name = (char *)HDstrdup(path);
+ table->objs[new_obj].type = oinfo ? (h5trav_type_t)oinfo->type : H5TRAV_TYPE_LINK;
+ table->objs[new_obj].nlinks = 0;
+ table->objs[new_obj].sizelinks = 0;
+ table->objs[new_obj].links = NULL;
+ }
}
/*-------------------------------------------------------------------------
@@ -680,278 +680,335 @@ trav_table_add(trav_table_t *table,
* Purpose: Add a hardlink name to the object
*
* Return: void
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: December 17, 2003
- *
*-------------------------------------------------------------------------
*/
-
static void
-trav_table_addlink(trav_table_t *table, haddr_t objno, const char *path)
+trav_table_addlink(trav_table_t *table, const H5O_token_t *obj_token, const char *path)
{
- size_t i; /* Local index variable */
+ size_t i; /* Local index variable */
+ int token_cmp;
- for(i = 0; i < table->nobjs; i++) {
- if(table->objs[i].objno == objno) {
- size_t n;
-
- /* already inserted? */
- if(HDstrcmp(table->objs[i].name, path) == 0)
+ if (table) {
+ for (i = 0; i < table->nobjs; i++) {
+ if (H5Otoken_cmp(table->fid, &table->objs[i].obj_token, obj_token, &token_cmp) < 0)
return;
+ if (!token_cmp) {
+ size_t n;
- /* allocate space if necessary */
- if(table->objs[i].nlinks == (unsigned)table->objs[i].sizelinks) {
- table->objs[i].sizelinks = MAX(1, table->objs[i].sizelinks * 2);
- table->objs[i].links = (trav_link_t*)HDrealloc(table->objs[i].links, table->objs[i].sizelinks * sizeof(trav_link_t));
- } /* end if */
+ /* already inserted? */
+ if (HDstrcmp(table->objs[i].name, path) == 0)
+ return;
- /* insert it */
- n = table->objs[i].nlinks++;
- table->objs[i].links[n].new_name = (char *)HDstrdup(path);
+ /* allocate space if necessary */
+ if (table->objs[i].nlinks == (unsigned)table->objs[i].sizelinks) {
+ table->objs[i].sizelinks = MAX(1, table->objs[i].sizelinks * 2);
+ table->objs[i].links = (trav_link_t *)HDrealloc(
+ table->objs[i].links, table->objs[i].sizelinks * sizeof(trav_link_t));
+ } /* end if */
- return;
- } /* end for */
- } /* end for */
+ /* insert it */
+ n = table->objs[i].nlinks++;
+ table->objs[i].links[n].new_name = (char *)HDstrdup(path);
- HDassert(0 && "object not in table?!?");
+ return;
+ } /* end if */
+ } /* end for */
+ } /* end if */
}
-
-
/*-------------------------------------------------------------------------
* Function: trav_table_addflags
*
- * Purpose: Add FLAGS, NAME and TYPE of object to table
- *
- * Return: void
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 4, 2002
+ * Purpose: Add FLAGS, NAME and TYPE of object to table
*
+ * Return: void
*-------------------------------------------------------------------------
*/
-
-void trav_table_addflags(unsigned *flags,
- char *name,
- h5trav_type_t type,
- trav_table_t *table)
+void
+trav_table_addflags(const unsigned *flags, char *name, h5trav_type_t type, trav_table_t *table)
{
- unsigned int new;
+ size_t new_obj;
- if(table->nobjs == table->size) {
- table->size = MAX(1, table->size * 2);
- table->objs = (trav_obj_t *)HDrealloc(table->objs, table->size * sizeof(trav_obj_t));
- } /* end if */
+ if (table) {
+ if (table->nobjs == table->size) {
+ table->size = MAX(1, table->size * 2);
+ table->objs = (trav_obj_t *)HDrealloc(table->objs, table->size * sizeof(trav_obj_t));
+ } /* end if */
- new = table->nobjs++;
- table->objs[new].objno = 0;
- table->objs[new].flags[0] = flags[0];
- table->objs[new].flags[1] = flags[1];
- table->objs[new].is_same_trgobj = 0;
- table->objs[new].name = (char *)HDstrdup(name);
- table->objs[new].type = type;
- table->objs[new].nlinks = 0;
- table->objs[new].sizelinks = 0;
- table->objs[new].links = NULL;
-}
+ new_obj = table->nobjs++;
+ /* Set token to 'undefined' values */
+ table->objs[new_obj].obj_token = H5O_TOKEN_UNDEF;
+
+ table->objs[new_obj].flags[0] = flags[0];
+ table->objs[new_obj].flags[1] = flags[1];
+ table->objs[new_obj].is_same_trgobj = 0;
+ table->objs[new_obj].name = (char *)HDstrdup(name);
+ table->objs[new_obj].type = type;
+ table->objs[new_obj].nlinks = 0;
+ table->objs[new_obj].sizelinks = 0;
+ table->objs[new_obj].links = NULL;
+ }
+}
/*-------------------------------------------------------------------------
* Function: trav_table_init
*
- * Purpose: Initialize the table
- *
- * Return: void
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 4, 2002
+ * Purpose: Initialize the table
*
+ * Return: void
*-------------------------------------------------------------------------
*/
-
-void trav_table_init(trav_table_t **tbl)
+void
+trav_table_init(hid_t fid, trav_table_t **tbl)
{
- trav_table_t* table = (trav_table_t*) HDmalloc(sizeof(trav_table_t));
-
- table->size = 0;
- table->nobjs = 0;
- table->objs = NULL;
-
+ trav_table_t *table = (trav_table_t *)HDmalloc(sizeof(trav_table_t));
+ if (table) {
+ table->fid = fid;
+ table->size = 0;
+ table->nobjs = 0;
+ table->objs = NULL;
+ }
*tbl = table;
}
-
-
/*-------------------------------------------------------------------------
* Function: trav_table_free
*
- * Purpose: free table memory
- *
- * Return: void
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 4, 2002
+ * Purpose: free table memory
*
+ * Return: void
*-------------------------------------------------------------------------
*/
+void
+trav_table_free(trav_table_t *table)
+{
+ if (table) {
+ if (table->objs) {
+ unsigned int i;
+
+ for (i = 0; i < table->nobjs; i++) {
+ HDfree(table->objs[i].name);
+ if (table->objs[i].nlinks) {
+ unsigned int j;
+
+ for (j = 0; j < table->objs[i].nlinks; j++)
+ HDfree(table->objs[i].links[j].new_name);
+
+ HDfree(table->objs[i].links);
+ } /* end if */
+ } /* end for */
+ HDfree(table->objs);
+ } /* end if */
+ HDfree(table);
+ }
+}
-void trav_table_free( trav_table_t *table )
+static herr_t
+trav_attr(hid_t
+#ifndef H5TRAV_PRINT_SPACE
+ H5_ATTR_UNUSED
+#endif /* H5TRAV_PRINT_SPACE */
+ obj,
+ const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *ainfo, void *_op_data)
{
- if(table->objs) {
- unsigned int i;
+ trav_path_op_data_t *op_data = (trav_path_op_data_t *)_op_data;
+ const char *buf = op_data->path;
- for(i = 0; i < table->nobjs; i++) {
- HDfree(table->objs[i].name );
- if(table->objs[i].nlinks) {
- unsigned int j;
+ if ((strlen(buf) == 1) && (*buf == '/'))
+ HDprintf(" %-10s %s%s", "attribute", buf, attr_name);
+ else
+ HDprintf(" %-10s %s/%s", "attribute", buf, attr_name);
- for(j = 0; j < table->objs[i].nlinks; j++)
- HDfree(table->objs[i].links[j].new_name);
+#ifdef H5TRAV_PRINT_SPACE
+ if (trav_verbosity < 2) {
+#endif
+ HDprintf("\n");
+#ifdef H5TRAV_PRINT_SPACE
+ }
+ else {
+ hid_t attr = H5I_INVALID_HID;
+ hid_t space = H5I_INVALID_HID;
+ hsize_t size[H5S_MAX_RANK];
+ int ndims;
+ int i;
+ H5S_class_t space_type;
+
+ if ((attr = H5Aopen(obj, attr_name, H5P_DEFAULT))) {
+ space = H5Aget_space(attr);
+
+ /* Data space */
+ ndims = H5Sget_simple_extent_dims(space, size, NULL);
+ space_type = H5Sget_simple_extent_type(space);
+ switch (space_type) {
+ case H5S_SCALAR:
+ /* scalar dataspace */
+ HDprintf(" scalar\n");
+ break;
+
+ case H5S_SIMPLE:
+ /* simple dataspace */
+ HDprintf(" {");
+ for (i = 0; i < ndims; i++) {
+ HDprintf("%s%" PRIuHSIZE, i ? ", " : "", size[i]);
+ }
+ HDprintf("}\n");
+ break;
+
+ case H5S_NULL:
+ /* null dataspace */
+ HDprintf(" null\n");
+ break;
+
+ default:
+ /* Unknown dataspace type */
+ HDprintf(" unknown\n");
+ break;
+ } /* end switch */
+
+ H5Sclose(space);
+ H5Aclose(attr);
+ }
+ }
+#endif
- HDfree(table->objs[i].links);
- } /* end if */
- } /* end for */
- HDfree(table->objs);
- } /* end if */
- HDfree(table);
+ return (0);
}
-
/*-------------------------------------------------------------------------
* Function: trav_print_visit_obj
*
- * Purpose: Callback for visiting object, when printing info
- *
- * Return: 0 on success, -1 on failure
- *
- * Programmer: Quincey Koziol, koziol@hdfgroup.org
- *
- * Date: September 6, 2007
+ * Purpose: Callback for visiting object, when printing info
*
+ * Return: 0 on success,
+ * -1 on failure
*-------------------------------------------------------------------------
*/
static int
-trav_print_visit_obj(const char *path, const H5O_info_t *oinfo,
- const char *already_visited, void UNUSED *udata)
+trav_print_visit_obj(const char *path, const H5O_info2_t *oinfo, const char *already_visited, void *udata)
{
+ trav_print_udata_t *print_udata = (trav_print_udata_t *)udata;
/* Print the name of the object */
/* (no new-line, so that objects that we've encountered before can print
* the name of the original object)
*/
- switch(oinfo->type) {
+ switch (oinfo->type) {
case H5O_TYPE_GROUP:
- printf(" %-10s %s", "group", path);
+ HDprintf(" %-10s %s", "group", path);
break;
case H5O_TYPE_DATASET:
- printf(" %-10s %s", "dataset", path);
+ HDprintf(" %-10s %s", "dataset", path);
break;
case H5O_TYPE_NAMED_DATATYPE:
- printf(" %-10s %s", "datatype", path);
+ HDprintf(" %-10s %s", "datatype", path);
break;
+ case H5O_TYPE_MAP:
+ case H5O_TYPE_UNKNOWN:
+ case H5O_TYPE_NTYPES:
default:
- printf(" %-10s %s", "unknown object type", path);
+ HDprintf(" %-10s %s", "unknown object type", path);
break;
} /* end switch */
/* Check if we've already seen this object */
- if(NULL == already_visited)
+ if (NULL == already_visited) {
+ trav_path_op_data_t op_data;
+
+ op_data.path = path;
/* Finish printing line about object */
- printf("\n");
+ HDprintf("\n");
+ if (trav_verbosity > 0)
+ H5Aiterate_by_name(print_udata->fid, path, trav_index_by, trav_index_order, NULL, trav_attr,
+ &op_data, H5P_DEFAULT);
+ }
else
/* Print the link's original name */
- printf(" -> %s\n", already_visited);
+ HDprintf(" -> %s\n", already_visited);
- return(0);
+ return (0);
} /* end trav_print_visit_obj() */
-
/*-------------------------------------------------------------------------
* Function: trav_print_visit_lnk
*
- * Purpose: Callback for visiting link, when printing info
- *
- * Return: 0 on success, -1 on failure
- *
- * Programmer: Quincey Koziol, koziol@hdfgroup.org
- *
- * Date: September 6, 2007
+ * Purpose: Callback for visiting link, when printing info
*
+ * Return: 0 on success,
+ * -1 on failure
*-------------------------------------------------------------------------
*/
static int
-trav_print_visit_lnk(const char *path, const H5L_info_t *linfo, void *udata)
+trav_print_visit_lnk(const char *path, const H5L_info2_t *linfo, void *udata)
{
trav_print_udata_t *print_udata = (trav_print_udata_t *)udata;
/* Print appropriate information for the type of link */
- switch(linfo->type) {
+ switch (linfo->type) {
case H5L_TYPE_SOFT:
- if(linfo->u.val_size > 0) {
- char *targbuf = (char*)HDmalloc(linfo->u.val_size + 1);
- HDassert(targbuf);
-
- H5Lget_val(print_udata->fid, path, targbuf, linfo->u.val_size + 1, H5P_DEFAULT);
- printf(" %-10s %s -> %s\n", "link", path, targbuf);
- HDfree(targbuf);
+ if (linfo->u.val_size > 0) {
+ char *targbuf = (char *)HDmalloc(linfo->u.val_size + 1);
+ if (targbuf) {
+ if (H5Lget_val(print_udata->fid, path, targbuf, linfo->u.val_size + 1, H5P_DEFAULT) < 0)
+ targbuf[0] = 0;
+ HDprintf(" %-10s %s -> %s\n", "link", path, targbuf);
+ HDfree(targbuf);
+ }
} /* end if */
else
- printf(" %-10s %s ->\n", "link", path);
+ HDprintf(" %-10s %s ->\n", "link", path);
break;
case H5L_TYPE_EXTERNAL:
- if(linfo->u.val_size > 0) {
- char *targbuf;
- const char *filename;
- const char *objname;
-
- targbuf = (char*)HDmalloc(linfo->u.val_size + 1);
- HDassert(targbuf);
-
- H5Lget_val(print_udata->fid, path, targbuf, linfo->u.val_size + 1, H5P_DEFAULT);
- H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL, &filename, &objname);
- printf(" %-10s %s -> %s %s\n", "ext link", path, filename, objname);
- HDfree(targbuf);
+ if (linfo->u.val_size > 0) {
+ char *targbuf = NULL;
+ const char *filename = NULL;
+ const char *objname = NULL;
+
+ targbuf = (char *)HDmalloc(linfo->u.val_size + 1);
+ if (targbuf) {
+ if (H5Lget_val(print_udata->fid, path, targbuf, linfo->u.val_size + 1, H5P_DEFAULT) < 0)
+ targbuf[0] = 0;
+ if (H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL, &filename, &objname) >= 0)
+ HDprintf(" %-10s %s -> %s %s\n", "ext link", path, filename, objname);
+ HDfree(targbuf);
+ }
} /* end if */
else
- printf(" %-10s %s ->\n", "ext link", path);
+ HDprintf(" %-10s %s ->\n", "ext link", path);
break;
+ case H5L_TYPE_HARD:
+ /* Should be handled elsewhere */
+ return (-1);
+
+ case H5L_TYPE_ERROR:
+ case H5L_TYPE_MAX:
default:
- printf(" %-10s %s -> ???\n", "unknown type of UD link", path);
+ HDprintf(" %-10s %s -> ???\n", "unknown type of UD link", path);
break;
} /* end switch() */
- return(0);
+ return (0);
} /* end trav_print_visit_lnk() */
-
/*-------------------------------------------------------------------------
* Function: h5trav_print
*
- * Purpose: Print information about the objects & links in the file
- *
- * Return: 0, -1 on error
- *
- * Programmer: Quincey Koziol, koziol@hdfgroup.org
- *
- * Date: September 6, 2007
+ * Purpose: Print information about the objects & links in the file
*
+ * Return: 0 on success,
+ * -1 on failure
*-------------------------------------------------------------------------
*/
-
int
h5trav_print(hid_t fid)
{
- trav_print_udata_t print_udata; /* User data for traversal */
- trav_visitor_t print_visitor; /* Visitor structure for printing objects */
+ trav_print_udata_t print_udata; /* User data for traversal */
+ trav_visitor_t print_visitor; /* Visitor structure for printing objects */
+ int ret_value = 0;
/* Init user data for printing */
print_udata.fid = fid;
@@ -959,47 +1016,43 @@ h5trav_print(hid_t fid)
/* Init visitor structure */
print_visitor.visit_obj = trav_print_visit_obj;
print_visitor.visit_lnk = trav_print_visit_lnk;
- print_visitor.udata = &print_udata;
+ print_visitor.udata = &print_udata;
/* Traverse all objects in the file, visiting each object & link */
- if(traverse(fid, "/", TRUE, TRUE, &print_visitor) < 0)
- return -1;
+ if (traverse(fid, "/", TRUE, TRUE, &print_visitor, H5O_INFO_BASIC) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "traverse failed");
- return 0;
+done:
+ return ret_value;
}
-
/*-------------------------------------------------------------------------
* Function: h5trav_visit
*
* Purpose: Generic traversal routine for visiting objects and links
*
- * Return: 0, -1 on error
- *
- * Programmer: Quincey Koziol, koziol@hdfgroup.org
- *
- * Date: November 6, 2007
- *
+ * Return: 0 on success,
+ * -1 on failure
*-------------------------------------------------------------------------
*/
-
int
-h5trav_visit(hid_t fid, const char *grp_name, hbool_t visit_start,
- hbool_t recurse, h5trav_obj_func_t visit_obj, h5trav_lnk_func_t visit_lnk,
- void *udata)
+h5trav_visit(hid_t fid, const char *grp_name, hbool_t visit_start, hbool_t recurse,
+ h5trav_obj_func_t visit_obj, h5trav_lnk_func_t visit_lnk, void *udata, unsigned fields)
{
- trav_visitor_t visitor; /* Visitor structure for objects */
+ trav_visitor_t visitor; /* Visitor structure for objects */
+ int ret_value = 0;
/* Init visitor structure */
visitor.visit_obj = visit_obj;
visitor.visit_lnk = visit_lnk;
- visitor.udata = udata;
+ visitor.udata = udata;
/* Traverse all objects in the file, visiting each object & link */
- if(traverse(fid, grp_name, visit_start, recurse, &visitor) < 0)
- return -1;
+ if (traverse(fid, grp_name, visit_start, recurse, &visitor, fields) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "traverse failed");
- return 0;
+done:
+ return ret_value;
}
/*-------------------------------------------------------------------------
@@ -1007,38 +1060,24 @@ h5trav_visit(hid_t fid, const char *grp_name, hbool_t visit_start,
*
* Purpose: Add an symbolic link to visited data structure
*
- * Return: 0 on success, -1 on failure
- *
- * Programmer: Neil Fortner, nfortne2@hdfgroup.org
- * Adapted from trav_addr_add in h5trav.c by Quincey Koziol
- *
- * Date: September 5, 2008
- *
- * Modified:
- * Jonathan Kim
- * - Moved from h5ls.c to share among tools. (Sep 16, 2010)
- * - Renamed from elink_trav_add to symlink_visit_add for both soft and
- * external links. (May 25, 2010)
- * - Add type parameter to distingush between soft and external link for
- * sure, which prevent from mixing up visited link when the target names
- * are same between the soft and external link, as code marks with the
- * target name. (May 25,2010)
- *
+ * Return: 0 on success,
+ * -1 on failure
*-------------------------------------------------------------------------
*/
herr_t
symlink_visit_add(symlink_trav_t *visited, H5L_type_t type, const char *file, const char *path)
{
- size_t idx; /* Index of address to use */
- void *tmp_ptr;
+ size_t idx; /* Index of address to use */
+ herr_t ret_value = SUCCEED;
/* Allocate space if necessary */
- if(visited->nused == visited->nalloc)
- {
+ if (visited->nused == visited->nalloc) {
+ void *tmp_ptr;
+
visited->nalloc = MAX(1, visited->nalloc * 2);
- if(NULL == (tmp_ptr = HDrealloc(visited->objs, visited->nalloc * sizeof(visited->objs[0]))))
- return -1;
- visited->objs = tmp_ptr;
+ if (NULL == (tmp_ptr = HDrealloc(visited->objs, visited->nalloc * sizeof(symlink_trav_path_t))))
+ H5TOOLS_GOTO_ERROR(FAIL, "visited data structure realloc failed");
+ visited->objs = (symlink_trav_path_t *)tmp_ptr;
} /* end if */
/* Append it */
@@ -1048,73 +1087,51 @@ symlink_visit_add(symlink_trav_t *visited, H5L_type_t type, const char *file, co
visited->objs[idx].file = NULL;
visited->objs[idx].path = NULL;
- if (type == H5L_TYPE_EXTERNAL)
- {
- if(NULL == (visited->objs[idx].file = HDstrdup(file)))
- {
+ if (type == H5L_TYPE_EXTERNAL) {
+ if (NULL == (visited->objs[idx].file = HDstrdup(file))) {
visited->nused--;
- return -1;
- }
- }
+ H5TOOLS_GOTO_ERROR(FAIL, "visited data structure name allocation failed");
+ } /* end if */
+ } /* end if */
- if(NULL == (visited->objs[idx].path = HDstrdup(path)))
- {
+ if (NULL == (visited->objs[idx].path = HDstrdup(path))) {
visited->nused--;
if (visited->objs[idx].file)
- HDfree (visited->objs[idx].file);
- return -1;
- }
+ HDfree(visited->objs[idx].file);
+ H5TOOLS_GOTO_ERROR(FAIL, "visited data structure path allocation failed");
+ } /* end if */
- return 0;
+done:
+ return ret_value;
} /* end symlink_visit_add() */
-
/*-------------------------------------------------------------------------
* Function: symlink_is_visited
*
- * Purpose: Check if an symbolic link has already been visited
- *
- * Return: TRUE/FALSE
- *
- * Programmer: Neil Fortner, nfortne2@hdfgroup.org
- * Adapted from trav_addr_visited in h5trav.c by Quincey Koziol
- *
- * Date: September 5, 2008
- *
- * Modified:
- * Jonathan Kim
- * - Moved from h5ls.c to share among tools. (Sep 16, 2010)
- * - Renamed from elink_trav_visited to symlink_is_visited for both soft and
- * external links. (May 25, 2010)
- * - Add type parameter to distingush between soft and external link for
- * sure, which prevent from mixing up visited link when the target names
- * are same between the soft and external link, as code marks with the
- * target name. (May 25,2010)
+ * Purpose: Check if an symbolic link has already been visited
*
+ * Return: TRUE/FALSE
*-------------------------------------------------------------------------
*/
-hbool_t
+H5_ATTR_PURE hbool_t
symlink_is_visited(symlink_trav_t *visited, H5L_type_t type, const char *file, const char *path)
{
- size_t u; /* Local index variable */
+ size_t u; /* Local index variable */
/* Look for symlink */
- for(u = 0; u < visited->nused; u++)
- {
+ for (u = 0; u < visited->nused; u++) {
/* Check for symlink values already in array */
- /* check type and path pair to distingush between symbolic links */
- if ((visited->objs[u].type == type) && !HDstrcmp(visited->objs[u].path, path))
- {
+ /* check type and path pair to distinguish between symbolic links */
+ if ((visited->objs[u].type == type) && !HDstrcmp(visited->objs[u].path, path)) {
/* if external link, file need to be matched as well */
if (visited->objs[u].type == H5L_TYPE_EXTERNAL)
- {
if (!HDstrcmp(visited->objs[u].file, file))
return (TRUE);
- }
+
return (TRUE);
- }
- }
+ } /* end if */
+ } /* end for */
+
/* Didn't find symlink */
- return(FALSE);
+ return (FALSE);
} /* end symlink_is_visited() */
-
diff --git a/tools/lib/h5trav.h b/tools/lib/h5trav.h
index da8dc69..8f3e175 100644
--- a/tools/lib/h5trav.h
+++ b/tools/lib/h5trav.h
@@ -1,28 +1,24 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * 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 H5TRAV_H__
-#define H5TRAV_H__
+#ifndef H5TRAV_H
+#define H5TRAV_H
#include "hdf5.h"
/* Typedefs for visiting objects */
-typedef herr_t (*h5trav_obj_func_t)(const char *path_name, const H5O_info_t *oinfo,
- const char *first_seen, void *udata);
-typedef herr_t (*h5trav_lnk_func_t)(const char *path_name, const H5L_info_t *linfo,
- void *udata);
+typedef herr_t (*h5trav_obj_func_t)(const char *path_name, const H5O_info2_t *oinfo, const char *first_seen,
+ void *udata);
+typedef herr_t (*h5trav_lnk_func_t)(const char *path_name, const H5L_info2_t *linfo, void *udata);
/*-------------------------------------------------------------------------
* public enum to specify type of an object
@@ -36,7 +32,7 @@ typedef herr_t (*h5trav_lnk_func_t)(const char *path_name, const H5L_info_t *lin
*-------------------------------------------------------------------------
*/
typedef enum {
- H5TRAV_TYPE_UNKNOWN = -1, /* Unknown object type */
+ H5TRAV_TYPE_UNKNOWN = -1, /* Unknown object type */
H5TRAV_TYPE_GROUP, /* Object is a group */
H5TRAV_TYPE_DATASET, /* Object is a dataset */
H5TRAV_TYPE_NAMED_DATATYPE, /* Object is a named datatype */
@@ -51,73 +47,72 @@ typedef enum {
/* Struct to keep track of symbolic link targets visited.
* Functions: symlink_visit_add() and symlink_is_visited()
*/
+typedef struct symlink_trav_path_t {
+ H5L_type_t type;
+ char *file;
+ char *path;
+} symlink_trav_path_t;
+
typedef struct symlink_trav_t {
- size_t nalloc;
- size_t nused;
- struct {
- H5L_type_t type;
- char *file;
- char *path;
- } *objs;
- hbool_t dangle_link;
+ size_t nalloc;
+ size_t nused;
+ symlink_trav_path_t *objs;
+ hbool_t dangle_link;
} symlink_trav_t;
typedef struct trav_path_t {
- char *path;
+ char *path;
h5trav_type_t type;
- haddr_t objno; /* object address */
- unsigned long fileno; /* File number that object is located in */
+ H5O_token_t obj_token; /* object token */
+ unsigned long fileno; /* File number that object is located in */
} trav_path_t;
typedef struct trav_info_t {
- size_t nalloc;
- size_t nused;
- const char *fname;
- hid_t fid; /* File ID */
- trav_path_t *paths;
- symlink_trav_t symlink_visited; /* already visited symbolic links */
- void * opts; /* optional data passing */
+ size_t nalloc;
+ size_t nused;
+ const char *fname;
+ hid_t fid; /* File ID */
+ trav_path_t *paths;
+ symlink_trav_t symlink_visited; /* already visited symbolic links */
+ void *opts; /* optional data passing */
} trav_info_t;
-
/*-------------------------------------------------------------------------
* keep record of hard link information
*-------------------------------------------------------------------------
*/
typedef struct trav_link_t {
- char *new_name;
+ char *new_name;
} trav_link_t;
-
/*-------------------------------------------------------------------------
- * struct to store basic info needed for the h5trav table traversal algorythm
+ * struct to store basic info needed for the h5trav table traversal algorithm
*-------------------------------------------------------------------------
*/
typedef struct trav_obj_t {
- haddr_t objno; /* object address */
- unsigned flags[2]; /* h5diff.object is present or not in both files*/
- hbool_t is_same_trgobj; /* same target object? no need to compare */
- char *name; /* name */
- h5trav_type_t type; /* type of object */
- trav_link_t *links; /* array of possible link names */
- size_t sizelinks; /* size of links array */
- size_t nlinks; /* number of links */
+ H5O_token_t obj_token; /* object token */
+ unsigned flags[2]; /* h5diff.object is present or not in both files*/
+ hbool_t is_same_trgobj; /* same target object? no need to compare */
+ char *name; /* name */
+ h5trav_type_t type; /* type of object */
+ trav_link_t *links; /* array of possible link names */
+ size_t sizelinks; /* size of links array */
+ size_t nlinks; /* number of links */
} trav_obj_t;
-
/*-------------------------------------------------------------------------
* private struct that stores all objects
*-------------------------------------------------------------------------
*/
typedef struct trav_table_t {
+ hid_t fid;
size_t size;
size_t nobjs;
trav_obj_t *objs;
} trav_table_t;
-
/*-------------------------------------------------------------------------
* public functions
*-------------------------------------------------------------------------
@@ -131,34 +126,39 @@ extern "C" {
* "h5trav general" public functions
*-------------------------------------------------------------------------
*/
-H5TOOLS_DLL int h5trav_visit(hid_t file_id, const char *grp_name,
- hbool_t visit_start, hbool_t recurse, h5trav_obj_func_t visit_obj,
- h5trav_lnk_func_t visit_lnk, void *udata);
-H5TOOLS_DLL herr_t symlink_visit_add(symlink_trav_t *visited, H5L_type_t type, const char *file, const char *path);
-H5TOOLS_DLL hbool_t symlink_is_visited(symlink_trav_t *visited, H5L_type_t type, const char *file, const char *path);
+H5TOOLS_DLL void h5trav_set_index(H5_index_t print_index_by, H5_iter_order_t print_index_order);
+H5TOOLS_DLL int h5trav_visit(hid_t file_id, const char *grp_name, hbool_t visit_start, hbool_t recurse,
+ h5trav_obj_func_t visit_obj, h5trav_lnk_func_t visit_lnk, void *udata,
+ unsigned fields);
+H5TOOLS_DLL herr_t symlink_visit_add(symlink_trav_t *visited, H5L_type_t type, const char *file,
+ const char *path);
+H5TOOLS_DLL hbool_t symlink_is_visited(symlink_trav_t *visited, H5L_type_t type, const char *file,
+ const char *path);
/*-------------------------------------------------------------------------
* "h5trav info" public functions
*-------------------------------------------------------------------------
*/
-H5TOOLS_DLL int h5trav_getinfo(hid_t file_id, trav_info_t *info);
+H5TOOLS_DLL int h5trav_getinfo(hid_t file_id, trav_info_t *info);
H5TOOLS_DLL ssize_t h5trav_getindex(const trav_info_t *info, const char *obj);
-H5TOOLS_DLL int trav_info_visit_obj (const char *path, const H5O_info_t *oinfo, const char *already_visited, void *udata);
-H5TOOLS_DLL int trav_info_visit_lnk (const char *path, const H5L_info_t *linfo, void *udata);
+H5TOOLS_DLL int trav_info_visit_obj(const char *path, const H5O_info2_t *oinfo, const char *already_visited,
+ void *udata);
+H5TOOLS_DLL int trav_info_visit_lnk(const char *path, const H5L_info2_t *linfo, void *udata);
/*-------------------------------------------------------------------------
* "h5trav table" public functions
*-------------------------------------------------------------------------
*/
-H5TOOLS_DLL int h5trav_gettable(hid_t fid, trav_table_t *travt);
-H5TOOLS_DLL int h5trav_getindext(const char *obj, const trav_table_t *travt);
+H5TOOLS_DLL int h5trav_gettable(hid_t fid, trav_table_t *travt);
+H5TOOLS_DLL int h5trav_getindext(const char *obj, const trav_table_t *travt);
/*-------------------------------------------------------------------------
* "h5trav print" public functions
*-------------------------------------------------------------------------
*/
-H5TOOLS_DLL int h5trav_print(hid_t fid);
+H5TOOLS_DLL int h5trav_print(hid_t fid);
+H5TOOLS_DLL void h5trav_set_verbose(int print_verbose);
#ifdef __cplusplus
}
@@ -175,19 +175,18 @@ H5TOOLS_DLL void trav_info_free(trav_info_t *info);
H5TOOLS_DLL void trav_info_add(trav_info_t *info, const char *path, h5trav_type_t obj_type);
+H5TOOLS_DLL void trav_fileinfo_add(trav_info_t *info, hid_t loc_id);
+
/*-------------------------------------------------------------------------
* table private functions
*-------------------------------------------------------------------------
*/
-H5TOOLS_DLL void trav_table_init(trav_table_t **table);
+H5TOOLS_DLL void trav_table_init(hid_t fid, trav_table_t **table);
H5TOOLS_DLL void trav_table_free(trav_table_t *table);
-H5TOOLS_DLL void trav_table_addflags(unsigned *flags,
- char *objname,
- h5trav_type_t type,
- trav_table_t *table);
-
-#endif /* H5TRAV_H__ */
+H5TOOLS_DLL void trav_table_addflags(const unsigned *flags, char *objname, h5trav_type_t type,
+ trav_table_t *table);
+#endif /* H5TRAV_H */
diff --git a/tools/lib/io_timer.c b/tools/lib/io_timer.c
new file mode 100644
index 0000000..ce21b3e
--- /dev/null
+++ b/tools/lib/io_timer.c
@@ -0,0 +1,226 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+/* changes:
+ * rename pio_timer.c as io_timer.c;
+ * Removed pio_perf.h so that it is not dependent on it;
+ * Removed set_timer_type() and get_timer_type() since no one calls them;
+ * Merged sio_timer.c into io_timer.c;
+ */
+
+/*
+ * Purpose:
+ *
+ * This is a module of useful timing functions for performance testing.
+ */
+
+#include "H5private.h"
+
+#include "io_timer.h"
+
+/*
+ * The number to divide the tv_usec field with to get a nice decimal to add to
+ * the number of seconds.
+ */
+#define MICROSECOND 1000000.0F
+
+/* global variables */
+io_time_t *timer_g; /* timer: global for stub functions */
+
+/*
+ * Function: sub_time
+ * Purpose: Struct two time values, and return the difference, in microseconds
+ *
+ * Note that the function assumes that a > b
+ * Programmer: Leon Arber, 1/27/06
+ */
+static double
+sub_time(struct timeval *a, struct timeval *b)
+{
+ return (((double)a->tv_sec + ((double)a->tv_usec) / (double)MICROSECOND) -
+ ((double)b->tv_sec + ((double)b->tv_usec) / (double)MICROSECOND));
+}
+
+/*
+ * Function: io_time_new
+ * Purpose: Build us a brand, spankin', new performance time object.
+ * The object is a black box to the user. They just tell us
+ * what type of timer they want (MPI_CLOCK for MPI_Wtime or
+ * SYS_CLOCK for system time).
+ * Return: Pointer to io_time object
+ * Programmer: Bill Wendling, 01. October 2001
+ * Modifications:
+ */
+io_time_t *
+io_time_new(clock_type type)
+{
+ io_time_t *pt = (io_time_t *)HDcalloc(1, sizeof(struct io_time_t));
+
+ /* set global timer variable */
+ timer_g = pt;
+
+ pt->type = type;
+ return pt;
+}
+
+/*
+ * Function: io_time_destroy
+ * Purpose: Remove the memory allocated for the io_time object. Only
+ * need to call on a pointer allocated with the ``io_time_new''
+ * function.
+ * Return: Nothing
+ * Programmer: Bill Wendling, 01. October 2001
+ * Modifications:
+ */
+void
+io_time_destroy(io_time_t *pt)
+{
+ HDfree(pt);
+ /* reset the global timer pointer too. */
+ timer_g = NULL;
+}
+
+#if 0
+/* no one is calling set_timer_type or get_timer_type ???*/
+/*
+ * Function: set_timer_type
+ * Purpose: Set the type of the timer to either MPI_CLOCK or SYS_CLOCK.
+ * This really only needs to be called if you didn't construct a
+ * timer with the pio_timer_new function (shame!).
+ * Return: Nothing
+ * Programmer: Bill Wendling, 04. October 2001
+ * Modifications:
+ */
+void
+set_timer_type(io_time_t *pt, clock_type type)
+{
+ pt->type = type;
+}
+
+/*
+ * Function: get_timer_type
+ * Purpose: Get the type of the timer.
+ * Return: MPI_CLOCK or SYS_CLOCK.
+ * Programmer: Bill Wendling, 04. October 2001
+ * Modifications:
+ */
+clock_type
+get_timer_type(io_time_t *pt)
+{
+ return pt->type;
+}
+#endif
+
+/*
+ * Function: io_time_set
+ * Purpose: Set the time in a ``io_time_t'' object.
+ * Return: Pointer to the passed in ``io_time_t'' object if SUCCEED; Null otherwise.
+ * Programmer: Bill Wendling, 01. October 2001
+ * Modifications:
+ */
+io_time_t *
+io_time_set(io_time_t *pt, timer_type t, int start_stop)
+{
+ /* sanity check */
+ HDassert(pt);
+
+ switch (pt->type) {
+#ifdef H5_HAVE_PARALLEL
+ case MPI_CLOCK:
+ if (start_stop == TSTART) {
+ pt->mpi_timer[t] = MPI_Wtime();
+
+ /* When we start the timer for HDF5_FINE_WRITE_FIXED_DIMS or HDF5_FINE_READ_FIXED_DIMS
+ * we compute the time it took to only open the file */
+ if (t == HDF5_FINE_WRITE_FIXED_DIMS)
+ pt->total_time[HDF5_FILE_WRITE_OPEN] +=
+ pt->mpi_timer[t] - pt->mpi_timer[HDF5_GROSS_WRITE_FIXED_DIMS];
+ else if (t == HDF5_FINE_READ_FIXED_DIMS)
+ pt->total_time[HDF5_FILE_READ_OPEN] +=
+ pt->mpi_timer[t] - pt->mpi_timer[HDF5_GROSS_READ_FIXED_DIMS];
+ }
+ else {
+ pt->total_time[t] += MPI_Wtime() - pt->mpi_timer[t];
+ pt->mpi_timer[t] = MPI_Wtime();
+
+ /* When we stop the timer for HDF5_GROSS_WRITE_FIXED_DIMS or HDF5_GROSS_READ_FIXED_DIMS
+ * we compute the time it took to close the file after the last read/write finished */
+ if (t == HDF5_GROSS_WRITE_FIXED_DIMS)
+ pt->total_time[HDF5_FILE_WRITE_CLOSE] +=
+ pt->mpi_timer[t] - pt->mpi_timer[HDF5_FINE_WRITE_FIXED_DIMS];
+ else if (t == HDF5_GROSS_READ_FIXED_DIMS)
+ pt->total_time[HDF5_FILE_READ_CLOSE] +=
+ pt->mpi_timer[t] - pt->mpi_timer[HDF5_FINE_READ_FIXED_DIMS];
+ }
+ break;
+#else
+ case MPI_CLOCK:
+ HDfprintf(stderr, "MPI clock set in serial library\n");
+ return NULL;
+#endif /* H5_HAVE_PARALLEL */
+ case SYS_CLOCK:
+ if (start_stop == TSTART) {
+ HDgettimeofday(&pt->sys_timer[t], NULL);
+
+ /* When we start the timer for HDF5_FINE_WRITE_FIXED_DIMS or HDF5_FINE_READ_FIXED_DIMS
+ * we compute the time it took to only open the file */
+ if (t == HDF5_FINE_WRITE_FIXED_DIMS)
+ pt->total_time[HDF5_FILE_WRITE_OPEN] +=
+ sub_time(&(pt->sys_timer[t]), &(pt->sys_timer[HDF5_GROSS_WRITE_FIXED_DIMS]));
+ else if (t == HDF5_FINE_READ_FIXED_DIMS)
+ pt->total_time[HDF5_FILE_READ_OPEN] +=
+ sub_time(&(pt->sys_timer[t]), &(pt->sys_timer[HDF5_GROSS_READ_FIXED_DIMS]));
+ }
+ else {
+ struct timeval sys_t;
+
+ HDgettimeofday(&sys_t, NULL);
+ pt->total_time[t] += sub_time(&sys_t, &(pt->sys_timer[t]));
+
+ /* When we stop the timer for HDF5_GROSS_WRITE_FIXED_DIMS or HDF5_GROSS_READ_FIXED_DIMS
+ * we compute the time it took to close the file after the last read/write finished */
+ if (t == HDF5_GROSS_WRITE_FIXED_DIMS)
+ pt->total_time[HDF5_FILE_WRITE_CLOSE] +=
+ sub_time(&(pt->sys_timer[t]), &(pt->sys_timer[HDF5_FINE_WRITE_FIXED_DIMS]));
+ else if (t == HDF5_GROSS_READ_FIXED_DIMS)
+ pt->total_time[HDF5_FILE_READ_CLOSE] +=
+ sub_time(&(pt->sys_timer[t]), &(pt->sys_timer[HDF5_FINE_READ_FIXED_DIMS]));
+ }
+ break;
+
+ default:
+ HDfprintf(stderr, "Unknown time clock type (%d)\n", pt->type);
+ return NULL;
+ } /* end switch */
+
+#if 0
+ /* this does not belong here. Need fix in h5perf code when set_time() is called. -AKC- */
+ debug_start_stop_time(pt, t, start_stop);
+#endif
+
+ return pt;
+}
+
+/*
+ * Function: io_time_get
+ * Purpose: Get the time from a ``io_time_t'' object.
+ * Return: The number of seconds as a DOUBLE.
+ * Programmer: Bill Wendling, 01. October 2001
+ * Modifications:
+ */
+H5_ATTR_PURE double
+io_time_get(io_time_t *pt, timer_type t)
+{
+ /* sanity check */
+ HDassert(pt);
+
+ return pt->total_time[t];
+}
diff --git a/tools/lib/io_timer.h b/tools/lib/io_timer.h
new file mode 100644
index 0000000..575cc72
--- /dev/null
+++ b/tools/lib/io_timer.h
@@ -0,0 +1,69 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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 IO_TIMER
+#define IO_TIMER
+
+#include "H5private.h"
+
+/* The different types of timers we can have */
+typedef enum timer_type_ {
+ HDF5_FILE_OPENCLOSE,
+ HDF5_DATASET_CREATE,
+ HDF5_MPI_WRITE,
+ HDF5_MPI_READ,
+ HDF5_FILE_READ_OPEN,
+ HDF5_FILE_READ_CLOSE,
+ HDF5_FILE_WRITE_OPEN,
+ HDF5_FILE_WRITE_CLOSE,
+ HDF5_FINE_WRITE_FIXED_DIMS,
+ HDF5_FINE_READ_FIXED_DIMS,
+ HDF5_GROSS_WRITE_FIXED_DIMS,
+ HDF5_GROSS_READ_FIXED_DIMS,
+ HDF5_RAW_WRITE_FIXED_DIMS,
+ HDF5_RAW_READ_FIXED_DIMS,
+ NUM_TIMERS
+} timer_type;
+
+typedef enum clock_type_ {
+ SYS_CLOCK = 0, /* Use system clock to measure time */
+ MPI_CLOCK = 1 /* Use MPI clock to measure time */
+} clock_type;
+
+/* Miscellaneous identifiers */
+enum {
+ TSTART, /* Start a specified timer */
+ TSTOP /* Stop a specified timer */
+};
+
+/* The performance time structure */
+typedef struct io_time_t {
+ clock_type type;
+ double total_time[NUM_TIMERS];
+ double mpi_timer[NUM_TIMERS];
+ struct timeval sys_timer[NUM_TIMERS];
+} io_time_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+H5TOOLS_DLL io_time_t *io_time_new(clock_type t);
+H5TOOLS_DLL void io_time_destroy(io_time_t *pt);
+H5TOOLS_DLL io_time_t *io_time_set(io_time_t *pt, timer_type t, int start_stop);
+H5TOOLS_DLL double io_time_get(io_time_t *pt, timer_type t);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IO_TIMER */
diff --git a/tools/lib/ph5diff.h b/tools/lib/ph5diff.h
index becbd6c..e7d16da 100644
--- a/tools/lib/ph5diff.h
+++ b/tools/lib/ph5diff.h
@@ -1,52 +1,42 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * 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 _PH5DIFF_H__
-#define _PH5DIFF_H__
+#ifndef PH5DIFF_H
+#define PH5DIFF_H
/* Send from manager to workers */
-#define MPI_TAG_ARGS 1
-#define MPI_TAG_PRINT_TOK 2
+#define MPI_TAG_ARGS 1
+#define MPI_TAG_PRINT_TOK 2
/*Sent from workers to manager */
-#define MPI_TAG_TOK_REQUEST 3
-#define MPI_TAG_DONE 4
+#define MPI_TAG_TOK_REQUEST 3
+#define MPI_TAG_DONE 4
#define MPI_TAG_TOK_RETURN 5
#define MPI_TAG_PRINT_DATA 6
/* Operational tags used to init and complete diff */
-#define MPI_TAG_END 7
-#define MPI_TAG_PARALLEL 8
-
-struct diff_mpi_args
-{
- char name1[256];
- char name2[256];
- diff_opt_t options;
- diff_args_t argdata; /* rest args */
+#define MPI_TAG_END 7
+#define MPI_TAG_PARALLEL 8
+
+struct diff_mpi_args {
+ char name1[256];
+ char name2[256];
+ diff_opt_t opts;
+ diff_args_t argdata; /* rest args */
};
-struct diffs_found
-{
+struct diffs_found {
hsize_t nfound;
- int not_cmp;
+ int not_cmp;
};
-#ifdef H5_HAVE_PARALLEL
-#include <mpi.h>
-#endif
-
-#endif /* _PH5DIFF_H__ */
-
+#endif /* PH5DIFF_H */