From f75166dd98bf326440e7a1b503cb6df2edec1263 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Tue, 22 Sep 2009 12:49:17 -0500 Subject: [svn-r17505] Description: Bring r17416:17496 from trunk to revise_chunks branch Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode Mac OS X/32 10.5.8 (amazon) in debug mode Mac OS X/32 10.5.8 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode --- MANIFEST | 7 +- README.txt | 33 +- bin/chkconfigure | 2 +- c++/src/Makefile.in | 2 +- config/lt_vers.am | 2 +- configure | 122 +- configure.in | 49 +- fortran/src/H5Lf.c | 12 +- fortran/src/H5Lff.f90 | 43 +- fortran/src/H5Of.c | 25 + fortran/src/H5Off.f90 | 44 + fortran/src/H5f90global.f90 | 10 +- fortran/src/H5f90proto.h | 12 +- fortran/src/Makefile.in | 2 +- fortran/src/hdf5_fortrandll.def | 1 + fortran/test/tH5G_1_8.f90 | 75 +- hl/c++/src/Makefile.in | 2 +- hl/fortran/src/Makefile.in | 2 +- hl/src/Makefile.in | 2 +- release_docs/RELEASE.txt | 9 +- src/H5Abtree2.c | 51 - src/H5B2private.h | 3 +- src/H5B2test.c | 27 - src/H5C.c | 8 +- src/H5F.c | 1 - src/H5FD.c | 30 + src/H5FDprivate.h | 1 + src/H5FDspace.c | 15 +- src/H5Fdbg.c | 1 - src/H5Fpkg.h | 1 - src/H5Fsuper.c | 32 +- src/H5Fsuper_cache.c | 70 +- src/H5Gbtree2.c | 52 - src/H5HFbtree2.c | 104 - src/H5MFaggr.c | 58 +- src/H5Pfcpl.c | 37 +- src/H5SMbtree2.c | 30 - src/H5Z.c | 22 +- src/H5public.h | 4 +- src/Makefile.in | 2 +- test/testhdf5.h | 14 + test/tfile.c | 403 +- tools/h5diff/h5diff_common.c | 46 +- tools/h5diff/testfiles/h5diff_10.txt | 17 +- tools/h5diff/testfiles/h5diff_600.txt | 17 +- tools/h5diff/testfiles/h5diff_603.txt | 17 +- tools/h5diff/testfiles/h5diff_604.txt | 65 +- tools/h5diff/testfiles/h5diff_605.txt | 65 +- tools/h5diff/testfiles/h5diff_606.txt | 17 +- tools/h5diff/testfiles/h5diff_612.txt | 17 +- tools/h5diff/testfiles/h5diff_613.txt | 65 +- tools/h5diff/testfiles/h5diff_614.txt | 65 +- tools/h5diff/testfiles/h5diff_615.txt | 17 +- tools/h5diff/testfiles/h5diff_621.txt | 17 +- tools/h5diff/testfiles/h5diff_622.txt | 17 +- tools/h5diff/testfiles/h5diff_623.txt | 17 +- tools/h5diff/testfiles/h5diff_624.txt | 17 +- tools/h5diff/testh5diff.sh | 6 +- tools/h5dump/h5dump.c | 203 +- tools/h5dump/h5dumpgentest.c | 122 + tools/h5dump/testh5dump.sh.in | 3 + tools/lib/Makefile.am | 2 +- tools/lib/Makefile.in | 16 +- tools/lib/h5diff.h | 31 +- tools/lib/h5diff_array.c | 76 +- tools/lib/h5tools.c | 4247 ++++++++++++++------ tools/lib/h5tools.h | 162 +- tools/lib/h5tools_error.h | 118 + tools/lib/h5tools_str.c | 690 ++-- tools/lib/h5tools_str.h | 13 +- tools/lib/talign.c | 191 - tools/misc/Makefile.am | 2 +- tools/misc/Makefile.in | 16 +- tools/misc/talign.c | 222 + tools/testfiles/tattrreg.ddl | 38 + tools/testfiles/tattrreg.h5 | Bin 0 -> 8288 bytes tools/testfiles/tattrregR.ddl | 66 + tools/testfiles/tdataregR.ddl | 60 + tools/testfiles/tdset-3s.ddl | 21 +- tools/testfiles/tnofilename.ddl | 19 +- vms/src/h5pubconf.h | 6 +- vms/src/make.com | 4 +- windows/examples/allexamples/allexamples.vcproj | 65 +- .../proj/hdf5_f90cstubdll/hdf5_f90cstubdll.vcproj | 4 +- windows/src/H5pubconf.h | 6 +- windows/tools/h5diff/testh5diff.bat | 10 +- windows/tools/h5dump/testh5dump.bat | 8 +- windows/tools/talign/talign.vcproj | 10 +- windows/tools/taligndll/taligndll.vcproj | 10 +- 89 files changed, 5618 insertions(+), 2727 deletions(-) create mode 100644 tools/lib/h5tools_error.h delete mode 100644 tools/lib/talign.c create mode 100644 tools/misc/talign.c create mode 100644 tools/testfiles/tattrreg.ddl create mode 100644 tools/testfiles/tattrreg.h5 create mode 100644 tools/testfiles/tattrregR.ddl create mode 100644 tools/testfiles/tdataregR.ddl diff --git a/MANIFEST b/MANIFEST index 880c2c9..c23af7b 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1082,7 +1082,7 @@ ./tools/lib/h5tools_ref.h ./tools/lib/h5tools_type.c ./tools/lib/ph5diff.h -./tools/lib/talign.c +./tools/lib/h5tools_error.h ./tools/misc/Makefile.am ./tools/misc/Makefile.in @@ -1095,6 +1095,7 @@ ./tools/misc/repart_test.c ./tools/misc/testh5mkgrp.sh ./tools/misc/testh5repart.sh.in +./tools/misc/talign.c ./tools/h5stat/Makefile.am ./tools/h5stat/Makefile.in @@ -1161,6 +1162,9 @@ ./tools/testfiles/tattr-2.ddl ./tools/testfiles/tattr-3.ddl ./tools/testfiles/tattr.h5 +./tools/testfiles/tattrreg.h5 +./tools/testfiles/tattrreg.ddl +./tools/testfiles/tattrregR.ddl ./tools/testfiles/tbitfields.h5 ./tools/testfiles/tchar.h5 ./tools/testfiles/tchar1.ddl @@ -1173,6 +1177,7 @@ ./tools/testfiles/tcompound_complex.h5 ./tools/testfiles/tdatareg.h5 ./tools/testfiles/tdatareg.ddl +./tools/testfiles/tdataregR.ddl ./tools/testfiles/tdset-1.ddl ./tools/testfiles/tdset-2.ddl ./tools/testfiles/tdset-3s.ddl diff --git a/README.txt b/README.txt index 0067977..3b5e715 100644 --- a/README.txt +++ b/README.txt @@ -1,5 +1,34 @@ -HDF5 version 1.9.45-FA_a3 currently under development -==> README.txt <== +HDF5 version 1.9.46-FA_a3 currently under development +Please refer to the release_docs/INSTALL file for installation instructions. +------------------------------------------------------------------------------ + +This release is fully functional for the API described in the documentation. +See the RELEASE.txt file in the release_docs/ directory for information +specific to this release of the library. Several INSTALL* files can also be +found in the release_docs/ directory: INSTALL contains instructions for +compiling and installing the library; INSTALL_parallel contains instructions +for installing the parallel version of the library; similarly-named files +contain instructions for VMS and several environments on MS Windows systems. + +Documentation for this release can be found at the following URL: + http://www.hdfgroup.org/HDF5/doc/. + +The following mailing lists are currently set up for HDF5 Library users: + + news - For announcements of HDF5 related developments, + not a discussion list. + + hdf-forum - For general discussion of the HDF5 library with + other users. + + hdf5dev - For discussion of the HDF5 library development + with developers and other interested parties. + +To subscribe to a list, send mail to "-subscribe@hdfgroup.org". +where is the name of the list. For example, send a request +to subscribe to the 'news' mail list to the following address: + news-subscribe@hdfgroup.org + Messages to be sent to the list should be sent to "@hdfgroup.org". Periodic code snapshots are provided at the following URL: diff --git a/bin/chkconfigure b/bin/chkconfigure index b6ad055..67733ca 100755 --- a/bin/chkconfigure +++ b/bin/chkconfigure @@ -23,7 +23,7 @@ # variable initialization nerrors=0 -AUTOCONFVERSION=2.61 +AUTOCONFVERSION=2.64 AUTOCONFVERSIONLEAD='Generated by GNU Autoconf' CONFIGUREFILES="configure" diff --git a/c++/src/Makefile.in b/c++/src/Makefile.in index ce5ad91..39b128b 100644 --- a/c++/src/Makefile.in +++ b/c++/src/Makefile.in @@ -380,7 +380,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 35 +LT_VERS_REVISION = 36 LT_VERS_AGE = 0 # Include src directory diff --git a/config/lt_vers.am b/config/lt_vers.am index 7e14839..1069507 100644 --- a/config/lt_vers.am +++ b/config/lt_vers.am @@ -17,7 +17,7 @@ # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 35 +LT_VERS_REVISION = 36 LT_VERS_AGE = 0 ## If the API changes *at all*, increment LT_VERS_INTERFACE and diff --git a/configure b/configure index 6ba4da7..ca7e1e2 100755 --- a/configure +++ b/configure @@ -1,7 +1,7 @@ #! /bin/sh -# From configure.in Id: configure.in 17347 2009-08-12 22:04:35Z koziol . +# From configure.in Id: configure.in 17417 2009-08-25 14:14:21Z koziol . # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.64 for HDF5 1.9.45-FA_a3. +# Generated by GNU Autoconf 2.64 for HDF5 1.9.46-FA_a3. # # Report bugs to . # @@ -699,8 +699,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='HDF5' PACKAGE_TARNAME='hdf5' -PACKAGE_VERSION='1.9.45-FA_a3' -PACKAGE_STRING='HDF5 1.9.45-FA_a3' +PACKAGE_VERSION='1.9.46-FA_a3' +PACKAGE_STRING='HDF5 1.9.46-FA_a3' PACKAGE_BUGREPORT='help@hdfgroup.org' PACKAGE_URL='' @@ -794,6 +794,7 @@ LL_PATH USE_FILTER_SZIP USE_FILTER_DEFLATE AM_MAKEFLAGS +LT_STATIC_EXEC CPP OTOOL64 OTOOL @@ -825,7 +826,6 @@ TIME TR AR PERL -LT_STATIC_EXEC CXXCPP am__fastdepCXX_FALSE am__fastdepCXX_TRUE @@ -971,13 +971,13 @@ enable_maintainer_mode enable_dependency_tracking enable_fortran enable_cxx -enable_static_exec enable_shared enable_static with_pic enable_fast_install with_gnu_ld enable_libtool_lock +enable_static_exec enable_sharedlib_rpath enable_production enable_linux_lfs @@ -1566,7 +1566,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures HDF5 1.9.45-FA_a3 to adapt to many kinds of systems. +\`configure' configures HDF5 1.9.46-FA_a3 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1636,7 +1636,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of HDF5 1.9.45-FA_a3:";; + short | recursive ) echo "Configuration of HDF5 1.9.46-FA_a3:";; esac cat <<\_ACEOF @@ -1650,13 +1650,13 @@ Optional Features: --enable-dependency-tracking do not reject slow dependency extractors --enable-fortran Compile the Fortran interface [default=no] --enable-cxx Compile the C++ interface [default=no] - --enable-static-exec Build only statically linked executables - [default=no] --enable-shared[=PKGS] build shared libraries [default=yes] --enable-static[=PKGS] build static libraries [default=yes] --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) + --enable-static-exec Install only statically linked executables + [default=no] --disable-sharedlib-rpath Disable use of the '=Wl,-rpath' linker option --enable-production Determines how to run the compiler. @@ -1823,7 +1823,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -HDF5 configure 1.9.45-FA_a3 +HDF5 configure 1.9.46-FA_a3 generated by GNU Autoconf 2.64 Copyright (C) 2009 Free Software Foundation, Inc. @@ -2907,7 +2907,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by HDF5 $as_me 1.9.45-FA_a3, which was +It was created by HDF5 $as_me 1.9.46-FA_a3, which was generated by GNU Autoconf 2.64. Invocation command line was $ $0 $@ @@ -3720,7 +3720,7 @@ fi # Define the identity of the package. PACKAGE='hdf5' - VERSION='1.9.45-FA_a3' + VERSION='1.9.46-FA_a3' cat >>confdefs.h <<_ACEOF @@ -7131,23 +7131,6 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if should build only statically linked executables" >&5 -$as_echo_n "checking if should build only statically linked executables... " >&6; } -# Check whether --enable-static_exec was given. -if test "${enable_static_exec+set}" = set; then : - enableval=$enable_static_exec; STATIC_EXEC=$enableval -fi - - -if test "X$STATIC_EXEC" = "Xyes"; then - echo "yes" - LT_STATIC_EXEC="-all-static" -else - echo "no" - LT_STATIC_EXEC="" -fi - - PERL="" if test "X$GCC" = "Xyes"; then for ac_prog in perl @@ -8213,13 +8196,13 @@ if test "${lt_cv_nm_interface+set}" = set; then : else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:8216: $ac_compile\"" >&5) + (eval echo "\"\$as_me:8199: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:8219: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:8202: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:8222: output\"" >&5) + (eval echo "\"\$as_me:8205: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -9424,7 +9407,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 9427 "configure"' > conftest.$ac_ext + echo '#line 9410 "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -11743,11 +11726,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:11746: $lt_compile\"" >&5) + (eval echo "\"\$as_me:11729: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:11750: \$? = $ac_status" >&5 + echo "$as_me:11733: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -12082,11 +12065,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:12085: $lt_compile\"" >&5) + (eval echo "\"\$as_me:12068: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:12089: \$? = $ac_status" >&5 + echo "$as_me:12072: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -12187,11 +12170,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:12190: $lt_compile\"" >&5) + (eval echo "\"\$as_me:12173: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:12194: \$? = $ac_status" >&5 + echo "$as_me:12177: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -12242,11 +12225,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:12245: $lt_compile\"" >&5) + (eval echo "\"\$as_me:12228: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:12249: \$? = $ac_status" >&5 + echo "$as_me:12232: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -14673,7 +14656,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 14676 "configure" +#line 14659 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -14769,7 +14752,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 14772 "configure" +#line 14755 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -16741,11 +16724,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:16744: $lt_compile\"" >&5) + (eval echo "\"\$as_me:16727: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:16748: \$? = $ac_status" >&5 + echo "$as_me:16731: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -16840,11 +16823,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:16843: $lt_compile\"" >&5) + (eval echo "\"\$as_me:16826: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:16847: \$? = $ac_status" >&5 + echo "$as_me:16830: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -16892,11 +16875,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:16895: $lt_compile\"" >&5) + (eval echo "\"\$as_me:16878: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:16899: \$? = $ac_status" >&5 + echo "$as_me:16882: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -18409,11 +18392,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:18412: $lt_compile\"" >&5) + (eval echo "\"\$as_me:18395: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:18416: \$? = $ac_status" >&5 + echo "$as_me:18399: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -18508,11 +18491,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:18511: $lt_compile\"" >&5) + (eval echo "\"\$as_me:18494: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:18515: \$? = $ac_status" >&5 + echo "$as_me:18498: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -18560,11 +18543,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:18563: $lt_compile\"" >&5) + (eval echo "\"\$as_me:18546: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:18567: \$? = $ac_status" >&5 + echo "$as_me:18550: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -20459,6 +20442,27 @@ EOF ;; esac +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we should install only statically linked executables" >&5 +$as_echo_n "checking if we should install only statically linked executables... " >&6; } +# Check whether --enable-static_exec was given. +if test "${enable_static_exec+set}" = set; then : + enableval=$enable_static_exec; STATIC_EXEC=$enableval +fi + + +if test "X$STATIC_EXEC" = "Xyes"; then + echo "yes" + if test "X$lt_cv_prog_compiler_static_works" = "Xno"; then + echo " warning: -static flag not supported on this system; executable won't statically link shared system libraries." + fi + LT_STATIC_EXEC="-all-static" +else + echo "no" + LT_STATIC_EXEC="" +fi + + + case "$INSTALL" in *install-sh*) INSTALL='\${top_srcdir}/bin/install-sh -c' @@ -27061,7 +27065,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if accurately converting unsigned long to float values" >&5 $as_echo_n "checking if accurately converting unsigned long to float values... " >&6; } -if test "${hdf5_ulong_to_float_accurate+set}" = set; then : +if test "${hdf5_cv_ulong_to_float_accurate+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : @@ -28780,7 +28784,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by HDF5 $as_me 1.9.45-FA_a3, which was +This file was extended by HDF5 $as_me 1.9.46-FA_a3, which was generated by GNU Autoconf 2.64. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -28844,7 +28848,7 @@ Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_version="\\ -HDF5 config.status 1.9.45-FA_a3 +HDF5 config.status 1.9.46-FA_a3 configured by $0, generated by GNU Autoconf 2.64, with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" diff --git a/configure.in b/configure.in index 533ffb3..652fbf3 100644 --- a/configure.in +++ b/configure.in @@ -26,7 +26,7 @@ dnl dnl NOTE: Don't forget to change the version number here when we do a dnl release!!! dnl -AC_INIT([HDF5], [1.9.45-FA_a3], [help@hdfgroup.org]) +AC_INIT([HDF5], [1.9.46-FA_a3], [help@hdfgroup.org]) AC_CONFIG_SRCDIR([src/H5.c]) AM_CONFIG_HEADER([src/H5config.h]) @@ -565,25 +565,6 @@ dnl Change back to the C language AC_LANG_POP(C++) dnl ---------------------------------------------------------------------- -dnl If we should build only static executables -dnl -AC_MSG_CHECKING([if should build only statically linked executables]) -AC_ARG_ENABLE([static_exec], - [AC_HELP_STRING([--enable-static-exec], - [Build only statically linked executables - [default=no]])], - [STATIC_EXEC=$enableval]) - -if test "X$STATIC_EXEC" = "Xyes"; then - echo "yes" - LT_STATIC_EXEC="-all-static" -else - echo "no" - LT_STATIC_EXEC="" -fi -AC_SUBST([LT_STATIC_EXEC]) - -dnl ---------------------------------------------------------------------- dnl Check if they have Perl installed on their system. We only need Perl dnl if they're using a GNU compiler. dnl @@ -993,6 +974,32 @@ EOF ;; esac +dnl ---------------------------------------------------------------------- +dnl Check if we should install only statically linked executables. +dnl This check needs to occur after libtool is initialized because +dnl we check a libtool cache value and may issue a warning based +dnl on its result. +AC_MSG_CHECKING([if we should install only statically linked executables]) +AC_ARG_ENABLE([static_exec], + [AC_HELP_STRING([--enable-static-exec], + [Install only statically linked executables + [default=no]])], + [STATIC_EXEC=$enableval]) + +if test "X$STATIC_EXEC" = "Xyes"; then + echo "yes" + dnl Issue a warning if -static flag is not supported. + if test "X$lt_cv_prog_compiler_static_works" = "Xno"; then + echo " warning: -static flag not supported on this system; executable won't statically link shared system libraries." + fi + LT_STATIC_EXEC="-all-static" +else + echo "no" + LT_STATIC_EXEC="" +fi + +AC_SUBST([LT_STATIC_EXEC]) + dnl Fix up the INSTALL macro if it's a relative path. We want the dnl full-path to the binary instead. case "$INSTALL" in @@ -3061,7 +3068,7 @@ dnl the conversion to float.) dnl AC_MSG_CHECKING([if accurately converting unsigned long to float values]) -AC_CACHE_VAL([hdf5_ulong_to_float_accurate], +AC_CACHE_VAL([hdf5_cv_ulong_to_float_accurate], [AC_TRY_RUN([ int main(void) { diff --git a/fortran/src/H5Lf.c b/fortran/src/H5Lf.c index 4378f33..2832d44 100644 --- a/fortran/src/H5Lf.c +++ b/fortran/src/H5Lf.c @@ -396,7 +396,7 @@ done: int_f nh5lget_info_c (hid_t_f *link_loc_id, _fcd link_name, size_t_f *link_namelen, int_f *cset, int_f *corder, int_f *corder_valid, int_f *link_type, - int_f *address, hsize_t_f *val_size, + haddr_t_f *address, size_t_f *val_size, hid_t_f *lapl_id) { char *c_link_name = NULL; /* Buffer to hold C string */ @@ -421,8 +421,8 @@ nh5lget_info_c (hid_t_f *link_loc_id, _fcd link_name, size_t_f *link_namelen, *corder_valid = 0; if(link_buff.corder_valid > 0) *corder_valid = 1; *link_type = (int_f)link_buff.type; - *address = (int_f)link_buff.u.address; - *val_size = (hsize_t)link_buff.u.val_size; + *address = (haddr_t_f)link_buff.u.address; + *val_size = (size_t_f)link_buff.u.val_size; done: return ret_value; @@ -453,7 +453,7 @@ done: int_f nh5lget_info_by_idx_c(hid_t_f *loc_id, _fcd group_name, size_t_f *group_namelen, int_f *index_field, int_f *order, hsize_t_f *n, - int_f *corder_valid, int_f *corder, int_f *cset, hsize_t_f *data_size, hid_t_f *lapl_id) + int_f *link_type, int_f *corder_valid, int_f *corder, int_f *cset, haddr_t_f *address, size_t_f *val_size, hid_t_f *lapl_id) { char *c_group_name = NULL; /* Buffer to hold C string */ H5_index_t c_index_field; @@ -483,7 +483,9 @@ nh5lget_info_by_idx_c(hid_t_f *loc_id, _fcd group_name, size_t_f *group_namelen, *corder = (int_f)link_buff.corder; *cset = (int_f)link_buff.cset; - *data_size = (hsize_t)link_buff.u.val_size; + *link_type = (int_f)link_buff.type; + *address = (haddr_t_f)link_buff.u.address; + *val_size = (size_t_f)link_buff.u.val_size; done: return ret_value; diff --git a/fortran/src/H5Lff.f90 b/fortran/src/H5Lff.f90 index b1a0fd9..2f359e9 100644 --- a/fortran/src/H5Lff.f90 +++ b/fortran/src/H5Lff.f90 @@ -574,14 +574,15 @@ CONTAINS ! ! cset - indicates the character set used for link’s name. ! corder - specifies the link’s creation order position. -!corder_valid - indicates whether the value in corder is valid. +!f_corder_valid - indicates whether the value in corder is valid. ! link_type - specifies the link class: ! H5L_LINK_HARD_F - Hard link ! H5L_LINK_SOFT_F - Soft link ! H5L_LINK_EXTERNAL_F - External link ! H5L_LINK_ERROR_ F - Error ! address - If the link is a hard link, address specifies the file address that the link points to -! val_size - If the link is a symbolic link, val_size will be the length of the link value +! val_size - If the link is a symbolic link, val_size will be the length of the link value, e.g., +! the length of the name of the pointed-to object with a null terminator. ! hdferr - error code ! Success: 0 ! Failure: -1 @@ -612,8 +613,9 @@ CONTAINS ! H5L_LINK_SOFT_F - Soft link ! H5L_LINK_EXTERNAL_F - External link ! H5L_LINK_ERROR _F - Error - INTEGER, INTENT(OUT) :: address ! If the link is a hard link, address specifies the file address that the link points to - INTEGER(HSIZE_T), INTENT(OUT) :: val_size ! If the link is a symbolic link, val_size will be the length of the link value + INTEGER(HADDR_T), INTENT(OUT) :: address ! If the link is a hard link, address specifies the file address that the link points to + INTEGER(SIZE_T), INTENT(OUT) :: val_size ! If the link is a symbolic link, val_size will be the length of the link value, e.g., + ! the length of the name of the pointed-to object with a null terminator. INTEGER, INTENT(OUT) :: hdferr ! Error code: ! 0 on success and -1 on failure INTEGER(HID_T), OPTIONAL, INTENT(IN) :: lapl_id ! Link access property list @@ -638,8 +640,8 @@ CONTAINS INTEGER, INTENT(OUT) :: cset INTEGER, INTENT(OUT) :: corder INTEGER, INTENT(OUT) :: link_type - INTEGER, INTENT(OUT) :: address - INTEGER(HSIZE_T), INTENT(OUT) :: val_size + INTEGER(HADDR_T), INTENT(OUT) :: address + INTEGER(SIZE_T), INTENT(OUT) :: val_size INTEGER(HID_T) :: lapl_id_default INTEGER(SIZE_T) :: link_namelen INTEGER :: corder_valid @@ -676,8 +678,10 @@ CONTAINS ! Outputs: NOTE: In C these are defined as a structure: H5L_info_t ! corder_valid - indicates whether the creation order data is valid for this attribute ! corder - is a positive integer containing the creation order of the attribute -! cset - indicates the character set used for the attribute’s name -! data_size - indicates the size, in the number of characters, of the attribute +! cset - indicates the character set used for the attribute’s name +! address - If the link is a hard link, address specifies the file address that the link points to +! val_size - If the link is a symbolic link, val_size will be the length of the link value, e.g., +! the length of the name of the pointed-to object with a null terminator. ! hdferr - error code ! Success: 0 ! Failure: -1 @@ -691,7 +695,7 @@ CONTAINS ! !---------------------------------------------------------------------- SUBROUTINE h5lget_info_by_idx_f(loc_id, group_name, index_field, order, n, & - f_corder_valid, corder, cset, data_size, hdferr, lapl_id) + link_type, f_corder_valid, corder, cset, address, val_size, hdferr, lapl_id) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: loc_id ! File or group identifier specifying location of subject group CHARACTER(LEN=*), INTENT(IN) :: group_name ! Name of subject group @@ -706,10 +710,17 @@ CONTAINS ! H5_ITER_DEC_F - Decreasing order ! H5_ITER_NATIVE_F - No particular order, whatever is fastest INTEGER(HSIZE_T), INTENT(IN) :: n ! Attribute’s position in index + INTEGER, INTENT(OUT) :: link_type ! Specifies the link class: + ! H5L_LINK_HARD_F - Hard link + ! H5L_LINK_SOFT_F - Soft link + ! H5L_LINK_EXTERNAL_F - External link + ! H5L_LINK_ERROR _F - Error LOGICAL, INTENT(OUT) :: f_corder_valid ! Indicates whether the creation order data is valid for this attribute INTEGER, INTENT(OUT) :: corder ! Is a positive integer containing the creation order of the attribute INTEGER, INTENT(OUT) :: cset ! Indicates the character set used for the attribute’s name - INTEGER(HSIZE_T), INTENT(OUT) :: data_size ! Indicates the size, in the number of characters, of the attribute + INTEGER(HADDR_T), INTENT(OUT) :: address ! If the link is a hard link, address specifies the file address that the link points to + INTEGER(SIZE_T), INTENT(OUT) :: val_size ! If the link is a symbolic link, val_size will be the length of the link value, e.g., + ! the length of the name of the pointed-to object with a null terminator. INTEGER, INTENT(OUT) :: hdferr ! Error code: ! 0 on success and -1 on failure INTEGER(HID_T), OPTIONAL, INTENT(IN) :: lapl_id ! Link access property list @@ -721,22 +732,24 @@ CONTAINS ! INTERFACE INTEGER FUNCTION h5lget_info_by_idx_c(loc_id, group_name, group_namelen, index_field, order, n, & - corder_valid, corder, cset, data_size, lapl_id_default) + link_type, corder_valid, corder, cset, address, val_size, lapl_id_default) USE H5GLOBAL !DEC$IF DEFINED(HDF5F90_WINDOWS) !DEC$ATTRIBUTES C,reference,decorate,alias:'H5LGET_INFO_BY_IDX_C'::h5lget_info_by_idx_c !DEC$ENDIF !DEC$ATTRIBUTES reference :: group_name - INTEGER(HID_T), INTENT(IN) :: loc_id + INTEGER(HID_T), INTENT(IN) :: loc_id CHARACTER(LEN=*), INTENT(IN) :: group_name INTEGER(SIZE_T) :: group_namelen INTEGER, INTENT(IN) :: index_field INTEGER, INTENT(IN) :: order INTEGER(HSIZE_T), INTENT(IN) :: n - INTEGER :: corder_valid + INTEGER, INTENT(OUT) :: link_type + INTEGER :: corder_valid INTEGER, INTENT(OUT) :: corder INTEGER, INTENT(OUT) :: cset - INTEGER(HSIZE_T), INTENT(OUT) :: data_size + INTEGER(HADDR_T), INTENT(OUT) :: address + INTEGER(SIZE_T), INTENT(OUT) :: val_size INTEGER(HID_T) :: lapl_id_default END FUNCTION h5lget_info_by_idx_c END INTERFACE @@ -747,7 +760,7 @@ CONTAINS IF(PRESENT(lapl_id)) lapl_id_default = lapl_id hdferr = h5lget_info_by_idx_c(loc_id, group_name, group_namelen, index_field, order, n, & - corder_valid, corder, cset, data_size, lapl_id_default) + link_type, corder_valid, corder, cset, address, val_size, lapl_id_default) f_corder_valid =.FALSE. IF (corder_valid .EQ. 1) f_corder_valid =.TRUE. diff --git a/fortran/src/H5Of.c b/fortran/src/H5Of.c index 5282dd6..56cbfeb 100644 --- a/fortran/src/H5Of.c +++ b/fortran/src/H5Of.c @@ -97,3 +97,28 @@ nh5oopen_c (hid_t_f *loc_id, _fcd name, size_t_f *namelen, hid_t_f *lapl_id, hid return ret_value; } +/*---------------------------------------------------------------------------- + * Name: h5oopen_by_addr_c + * Purpose: Calls H5open_by_addr + * Inputs: loc_id - File or group identifier + * addr - Object’s address in the file + * Outputs: obj_id - Dataset identifier + * Returns: 0 on success, -1 on failure + * Programmer: M. Scot Breitenfeld + * September 14, 2009 + * Modifications: + *---------------------------------------------------------------------------*/ +int_f +nh5oopen_by_addr_c (hid_t_f *loc_id, haddr_t_f *addr, hid_t_f *obj_id) +{ + int_f ret_value = 0; /* Return value */ + + /* + * Call H5Oopen_by_address function. + */ + if((*obj_id = (hid_t_f)H5Oopen_by_addr((hid_t)*loc_id, (haddr_t)*addr)) < 0) + HGOTO_DONE(FAIL); + + done: + return ret_value; +} diff --git a/fortran/src/H5Off.f90 b/fortran/src/H5Off.f90 index a541502..0328fbc 100644 --- a/fortran/src/H5Off.f90 +++ b/fortran/src/H5Off.f90 @@ -153,5 +153,49 @@ CONTAINS END SUBROUTINE h5oopen_f +!---------------------------------------------------------------------- +! Name: h5oopen_by_addr_f +! +! Purpose: Opens an object using its address within an HDF5 file. +! +! Inputs: +! loc_id - File or group identifier +! addr - Object’s address in the file +! Outputs: +! obj_id - Object identifier for the opened object +! hdferr: - error code +! Success: 0 +! Failure: -1 +! +! Programmer: M. Scot Breitenfeld +! September 14, 2009 +! +! Modifications: N/A +! +!---------------------------------------------------------------------- + + SUBROUTINE h5oopen_by_addr_f(loc_id, addr, obj_id, hdferr) + IMPLICIT NONE + INTEGER(HID_T), INTENT(IN) :: loc_id ! File or group identifier + INTEGER(HADDR_T), INTENT(IN) :: addr ! Object’s address in the file + INTEGER(HID_T), INTENT(OUT) :: obj_id ! Object identifier for the opened object + INTEGER, INTENT(OUT) :: hdferr ! Error code + ! Success: 0 + ! Failure: -1 + INTERFACE + INTEGER FUNCTION h5oopen_by_addr_c(loc_id, addr, obj_id) + USE H5GLOBAL + !DEC$IF DEFINED(HDF5F90_WINDOWS) + !DEC$ATTRIBUTES C,reference,decorate,alias:'H5OOPEN_BY_ADDR_C'::h5oopen_by_addr_c + !DEC$ENDIF + INTEGER(HID_T), INTENT(IN) :: loc_id + INTEGER(HADDR_T), INTENT(IN) :: addr + INTEGER(HID_T), INTENT(OUT) :: obj_id + END FUNCTION h5oopen_by_addr_c + END INTERFACE + + hdferr = h5oopen_by_addr_c(loc_id, addr, obj_id) + + END SUBROUTINE h5oopen_by_addr_f END MODULE H5O diff --git a/fortran/src/H5f90global.f90 b/fortran/src/H5f90global.f90 index e037d12..3fc247f 100644 --- a/fortran/src/H5f90global.f90 +++ b/fortran/src/H5f90global.f90 @@ -473,10 +473,10 @@ MODULE H5GLOBAL INTEGER, PARAMETER :: H5L_FLAGS_LEN = 6 INTEGER :: H5L_flags(H5L_FLAGS_LEN) - INTEGER :: H5L_LINK_F INTEGER :: H5L_LINK_ERROR_F INTEGER :: H5L_LINK_HARD_F INTEGER :: H5L_LINK_SOFT_F + INTEGER :: H5L_LINK_EXTERNAL_F INTEGER :: H5L_SAME_LOC_F INTEGER :: H5L_LINK_CLASS_T_VERS_F @@ -485,10 +485,10 @@ MODULE H5GLOBAL !DEC$endif COMMON /H5L_FLAGS/ H5L_flags - EQUIVALENCE(H5L_flags(1), H5L_LINK_F) - EQUIVALENCE(H5L_flags(2), H5L_LINK_ERROR_F) - EQUIVALENCE(H5L_flags(3), H5L_LINK_HARD_F) - EQUIVALENCE(H5L_flags(4), H5L_LINK_SOFT_F) + EQUIVALENCE(H5L_flags(1), H5L_LINK_ERROR_F) + EQUIVALENCE(H5L_flags(2), H5L_LINK_HARD_F) + EQUIVALENCE(H5L_flags(3), H5L_LINK_SOFT_F) + EQUIVALENCE(H5L_flags(4), H5L_LINK_EXTERNAL_F) EQUIVALENCE(H5L_flags(5), H5L_SAME_LOC_F) EQUIVALENCE(H5L_flags(6), H5L_LINK_CLASS_T_VERS_F) ! diff --git a/fortran/src/H5f90proto.h b/fortran/src/H5f90proto.h index 15dc41d..7f16359 100644 --- a/fortran/src/H5f90proto.h +++ b/fortran/src/H5f90proto.h @@ -739,11 +739,13 @@ H5_FCDLL int_f nh5tget_native_type_c(hid_t_f *dtype_id, int_f *direction, hid_t_ * Functions from H5Of.c */ -# define nh5olink_c H5_FC_FUNC_(h5olink_c, H5OLINK_C) -# define nh5oopen_c H5_FC_FUNC_(h5oopen_c, H5OOPEN_C) +# define nh5olink_c H5_FC_FUNC_(h5olink_c, H5OLINK_C) +# define nh5oopen_c H5_FC_FUNC_(h5oopen_c, H5OOPEN_C) +# define nh5oopen_by_addr_c H5_FC_FUNC_(h5oopen_by_addr_c, H5OOPEN_BY_ADDR_C) H5_FCDLL int_f nh5oopen_c (hid_t_f *loc_id, _fcd name, size_t_f *namelen, hid_t_f *lapl_id, hid_t_f *obj_id); +H5_FCDLL int_f nh5oopen_by_addr_c (hid_t_f *loc_id, haddr_t_f *addr, hid_t_f *obj_id); H5_FCDLL int_f nh5olink_c (hid_t_f *object_id, hid_t_f *new_loc_id, _fcd name, size_t_f *namelen, hid_t_f *lcpl_id, hid_t_f *lapl_id); /* @@ -1201,11 +1203,11 @@ H5_FCDLL int_f nh5ldelete_by_idx_c (hid_t_f *loc_id, _fcd group_name, size_t_f * H5_FCDLL int_f nh5lexists_c (hid_t_f *loc_id, _fcd name, size_t_f *namelen, hid_t_f *lapl_id, int_f *link_exists); H5_FCDLL int_f nh5lget_info_c (hid_t_f *link_loc_id, _fcd link_name, size_t_f *link_namelen, int_f *cset, int_f *corder, int_f *corder_valid, int_f *link_type, - int_f *address, hsize_t_f *link_len, + haddr_t_f *address, size_t_f *val_size, hid_t_f *lapl_id); H5_FCDLL int_f nh5lget_info_by_idx_c(hid_t_f *loc_id, _fcd group_name, size_t_f *group_namelen, - int_f *index_field, int_f *order, hsize_t_f *n, - int_f *corder_valid, int_f *corder, int_f *cset, hsize_t_f *data_size, hid_t_f *lapl_id); + int_f *index_field, int_f *order, hsize_t_f *n, + int_f *link_type, int_f *corder_valid, int_f *corder, int_f *cset, haddr_t_f *address, size_t_f *val_size, hid_t_f *lapl_id); H5_FCDLL int_f nh5lis_registered_c(int_f *link_cls_id); H5_FCDLL int_f nh5lmove_c(hid_t_f *src_loc_id, _fcd src_name, size_t_f *src_namelen, hid_t_f *dest_loc_id, _fcd dest_name, size_t_f *dest_namelen, hid_t_f *lcpl_id, hid_t_f *lapl_id); diff --git a/fortran/src/Makefile.in b/fortran/src/Makefile.in index 625ac0c..a247323 100644 --- a/fortran/src/Makefile.in +++ b/fortran/src/Makefile.in @@ -411,7 +411,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 35 +LT_VERS_REVISION = 36 LT_VERS_AGE = 0 # Include src directory in both Fortran and C flags (C compiler is used diff --git a/fortran/src/hdf5_fortrandll.def b/fortran/src/hdf5_fortrandll.def index 057dc13..5f45350 100644 --- a/fortran/src/hdf5_fortrandll.def +++ b/fortran/src/hdf5_fortrandll.def @@ -286,6 +286,7 @@ H5L_mp_H5LGET_NAME_BY_IDX_F ; H5O H5O_mp_H5OLINK_F H5O_mp_H5OOPEN_F +H5O_mp_H5OOPEN_BY_ADDR_F ; H5P H5P_mp_H5PCREATE_F H5P_mp_H5PSET_PRESERVE_F diff --git a/fortran/test/tH5G_1_8.f90 b/fortran/test/tH5G_1_8.f90 index 42dd617..9c28f75 100644 --- a/fortran/test/tH5G_1_8.f90 +++ b/fortran/test/tH5G_1_8.f90 @@ -642,6 +642,18 @@ SUBROUTINE group_info(cleanup, fapl, total_error) INTEGER :: arank = 1 ! Attribure rank INTEGER :: error + INTEGER :: cset ! Indicates the character set used for the link’s name. + INTEGER :: corder ! Specifies the link’s creation order position. + LOGICAL :: f_corder_valid ! Indicates whether the value in corder is valid. + INTEGER :: link_type ! Specifies the link class: + ! H5L_LINK_HARD_F - Hard link + ! H5L_LINK_SOFT_F - Soft link + ! H5L_LINK_EXTERNAL_F - External link + ! H5L_LINK_ERROR _F - Error + INTEGER(HADDR_T) :: address ! If the link is a hard link, address specifies the file address that the link points to + INTEGER(SIZE_T) :: val_size ! If the link is a symbolic link, val_size will be the length of the link value + + ! WRITE(*,*) "link creation (w/new group format)" ! /* Create a file */ @@ -670,6 +682,18 @@ SUBROUTINE group_info(cleanup, fapl, total_error) CALL H5Lcreate_soft_f("/d1", file, "grp1/soft",error) CALL check("H5Lcreate_soft_f", error, total_error) + CALL H5Lget_info_f(file, "grp1/soft", & + cset, corder, f_corder_valid, link_type, address, val_size, & + error, H5P_DEFAULT_F) + CALL check("H5Lget_info_f",error,total_error) + +! CALL VerifyLogical("H5Lget_info_by_idx_f11", f_corder_valid, .TRUE., total_error) + + CALL VERIFY("H5Lget_info_by_idx_f", H5L_LINK_SOFT_F, link_type, total_error) + CALL VERIFY("H5Lget_info_by_idx_f", cset, H5T_CSET_ASCII_F, total_error) + ! should be '/d1' + NULL character = 4 + CALL VERIFY("H5Lget_info_by_idx_f", INT(val_size), 4, total_error) + !/* Create a symbolic link to something that doesn't exist */ CALL H5Lcreate_soft_f("foobar", file, "grp1/dangle",error) @@ -733,8 +757,8 @@ SUBROUTINE group_info(cleanup, fapl, total_error) ! H5L_LINK_SOFT_F - Soft link ! H5L_LINK_EXTERNAL_F - External link ! H5L_LINK_ERROR _F - Error - INTEGER :: address ! If the link is a hard link, address specifies the file address that the link points to - INTEGER(HSIZE_T) :: val_size ! If the link is a symbolic link, val_size will be the length of the link value + INTEGER(HADDR_T) :: address ! If the link is a hard link, address specifies the file address that the link points to + INTEGER(SIZE_T) :: val_size ! If the link is a symbolic link, val_size will be the length of the link value INTEGER :: error @@ -1147,15 +1171,18 @@ SUBROUTINE delete_by_idx(cleanup, fapl, total_error) LOGICAL :: f_corder_valid ! Indicates whether the creation order data is valid for this attribute INTEGER :: corder ! Is a positive integer containing the creation order of the attribute INTEGER :: cset ! Indicates the character set used for the attribute’s name - INTEGER(HSIZE_T) :: data_size ! Indicates the size, in the number of characters, of the attribute + INTEGER(SIZE_T) :: val_size + INTEGER :: link_type + INTEGER(HADDR_T) :: address INTEGER :: u ! /* Local index variable */ INTEGER :: Input1, i INTEGER(HID_T) :: group_id2 - + INTEGER(HID_T) :: grp INTEGER :: iorder ! /* Order within in the index */ CHARACTER(LEN=2) :: chr2 INTEGER :: error + INTEGER :: id_type ! ! ! @@ -1263,7 +1290,7 @@ SUBROUTINE delete_by_idx(cleanup, fapl, total_error) htmp =9 !EP CALL H5Ldelete_by_idx_f(group_id, ".", idx_type, iorder, INT(u,HSIZE_T), error) CALL H5Ldelete_by_idx_f(group_id, ".", idx_type, iorder, htmp, error) - CALL VERIFY("delete_by_idx.H5Ldelete_by_idx_f", error, -1, total_error) ! test should fail (error = -1) + CALL VERIFY("H5Ldelete_by_idx_f", error, -1, total_error) ! test should fail (error = -1) ! /* Delete links from compact group */ @@ -1271,19 +1298,37 @@ SUBROUTINE delete_by_idx(cleanup, fapl, total_error) DO u = 0, (max_compact - 1) -1 ! /* Delete first link in appropriate order */ CALL H5Ldelete_by_idx_f(group_id, ".", idx_type, iorder, INT(0,HSIZE_T), error) - CALL check("delete_by_idx.H5Ldelete_by_idx_f", error, total_error) + CALL check("H5Ldelete_by_idx_f", error, total_error) ! /* Verify the link information for first link in appropriate order */ ! HDmemset(&linfo, 0, sizeof(linfo)); CALL H5Lget_info_by_idx_f(group_id, ".", idx_type, iorder, INT(0,HSIZE_T), & - f_corder_valid, corder, cset, data_size, error) + link_type, f_corder_valid, corder, cset, address, val_size, error) + + CALL H5Oopen_by_addr_f(group_id, address, grp, error) + CALL check("H5Oopen_by_addr_f", error, total_error) + + CALL H5Iget_type_f(grp, id_type, error) + CALL check("H5Iget_type_f", error, total_error) + + CALL VERIFY("H5Iget_type_f", id_type, H5I_GROUP_F, total_error) + + CALL H5Gclose_f(grp, error) + CALL check("H5Gclose_f", error, total_error) + + CALL VerifyLogical("H5Lget_info_by_idx_f", f_corder_valid, .TRUE., total_error) + CALL VERIFY("H5Lget_info_by_idx_f", H5L_LINK_HARD_F, link_type, total_error) IF(iorder.EQ.H5_ITER_INC_F)THEN - CALL VERIFY("delete_by_idx.H5Lget_info_by_idx_f", corder, u+1, total_error) + CALL VERIFY("H5Lget_info_by_idx_f", corder, u+1, total_error) ELSE - CALL VERIFY("delete_by_idx.H5Lget_info_by_idx_f", corder, (max_compact - (u + 2)), total_error) + CALL VERIFY("H5Lget_info_by_idx_f", corder, (max_compact - (u + 2)), total_error) ENDIF + CALL VERIFY("H5Lget_info_by_idx_f",cset, H5T_CSET_ASCII_F, total_error) + + + ! /* Verify the name for first link in appropriate order */ ! HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); !!$ size_tmp = 20 @@ -1357,7 +1402,9 @@ SUBROUTINE link_info_by_idx_check(group_id, linkname, n, & LOGICAL :: f_corder_valid ! Indicates whether the creation order data is valid for this attribute INTEGER :: corder ! Is a positive integer containing the creation order of the attribute INTEGER :: cset ! Indicates the character set used for the attribute’s name - INTEGER(HSIZE_T) :: data_size ! Indicates the size, in the number of characters, of the attribute + INTEGER :: link_type + INTEGER(HADDR_T) :: address + INTEGER(SIZE_T) :: val_size ! Indicates the size, in the number of characters, of the attribute CHARACTER(LEN=7) :: tmpname !/* Temporary link name */ CHARACTER(LEN=3) :: tmpname_small !/* to small temporary link name */ @@ -1376,14 +1423,14 @@ SUBROUTINE link_info_by_idx_check(group_id, linkname, n, & ! /* Verify the link information for first link, in increasing creation order */ ! HDmemset(&linfo, 0, sizeof(linfo)); CALL H5Lget_info_by_idx_f(group_id, ".", H5_INDEX_CRT_ORDER_F, H5_ITER_INC_F, INT(0,HSIZE_T), & - f_corder_valid, corder, cset, data_size, error) + link_type, f_corder_valid, corder, cset, address, val_size, error) CALL check("H5Lget_info_by_idx_f", error, total_error) CALL VERIFY("H5Lget_info_by_idx_f", corder, 0, total_error) ! /* Verify the link information for new link, in increasing creation order */ ! HDmemset(&linfo, 0, sizeof(linfo)); CALL H5Lget_info_by_idx_f(group_id, ".", H5_INDEX_CRT_ORDER_F, H5_ITER_INC_F, INT(n,HSIZE_T), & - f_corder_valid, corder, cset, data_size, error) + link_type, f_corder_valid, corder, cset, address, val_size, error) CALL check("H5Lget_info_by_idx_f", error, total_error) CALL VERIFY("H5Lget_info_by_idx_f", corder, n, total_error) @@ -1468,8 +1515,8 @@ SUBROUTINE link_info_by_idx_check(group_id, linkname, n, & ! H5L_LINK_SOFT_F - Soft link ! H5L_LINK_EXTERNAL_F - External link ! H5L_LINK_ERROR _F - Error - INTEGER :: address ! If the link is a hard link, address specifies the file address that the link points to - INTEGER(HSIZE_T) :: val_size ! If the link is a symbolic link, val_size will be the length of the link value + INTEGER(HADDR_T) :: address ! If the link is a hard link, address specifies the file address that the link points to + INTEGER(SIZE_T) :: val_size ! If the link is a symbolic link, val_size will be the length of the link value CHARACTER(LEN=1024) :: filename = 'tempfile.h5' INTEGER, PARAMETER :: TEST6_DIM1 = 8, TEST6_DIM2 = 7 diff --git a/hl/c++/src/Makefile.in b/hl/c++/src/Makefile.in index a277088..6171c62 100644 --- a/hl/c++/src/Makefile.in +++ b/hl/c++/src/Makefile.in @@ -370,7 +370,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 35 +LT_VERS_REVISION = 36 LT_VERS_AGE = 0 # Include src directory diff --git a/hl/fortran/src/Makefile.in b/hl/fortran/src/Makefile.in index 867d143..e5adbc3 100644 --- a/hl/fortran/src/Makefile.in +++ b/hl/fortran/src/Makefile.in @@ -376,7 +376,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 35 +LT_VERS_REVISION = 36 LT_VERS_AGE = 0 INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/hl/src -I$(top_builddir)/hl/src \ -I$(top_srcdir)/fortran/src -I$(top_builddir)/fortran/src diff --git a/hl/src/Makefile.in b/hl/src/Makefile.in index c9d005b..59bc175 100644 --- a/hl/src/Makefile.in +++ b/hl/src/Makefile.in @@ -371,7 +371,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 35 +LT_VERS_REVISION = 36 LT_VERS_AGE = 0 # Add include directories to the C preprocessor flags diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 19f1606..93bfa00 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -1,4 +1,4 @@ -HDF5 version 1.9.45-FA_a3 currently under development +HDF5 version 1.9.46-FA_a3 currently under development ================================================================================ @@ -126,7 +126,10 @@ New Features Tools: ------ - - h5dump/h5ls display buffer resize fixed in tools library. (ADB - 2009/7/21 - 1520) + - h5dump subsetting now allows default for count. Also trailing ; in short form + can be omitted after last specified value. (ADB - 2009/09/04) + - h5dump/h5ls now can display data in region references + using new -R, --region flag. (ADB - 2009/09/04) - h5diff new flag, -c, --compare, list objects that are not comparable. (PVN - 2009/4/10 - 1368) - h5diff new flag, -N, --nan, avoids NaNs detection. (PVN - 2009/4/10) @@ -327,6 +330,8 @@ Bug Fixes since HDF5-1.8.0 release Tools ----- + - h5dump/h5ls display buffer resize fixed in tools library. + (ADB - 2009/07/21 - 1520) - Fixed many problems that could occur when using h5repack with named datatypes. (NAF - 2009/4/20 - 1516/1466) - h5dump, h5diff, h5repack were not reading (by hyperslabs) datasets diff --git a/src/H5Abtree2.c b/src/H5Abtree2.c index da4ad86..a0035b3 100644 --- a/src/H5Abtree2.c +++ b/src/H5Abtree2.c @@ -80,7 +80,6 @@ typedef struct H5A_fh_ud_cmp_t { /* v2 B-tree driver callbacks for 'creation order' index */ static herr_t H5A_dense_btree2_corder_store(void *native, const void *udata); -static herr_t H5A_dense_btree2_corder_retrieve(void *udata, const void *native); static herr_t H5A_dense_btree2_corder_compare(const void *rec1, const void *rec2); static herr_t H5A_dense_btree2_corder_encode(const H5F_t *f, uint8_t *raw, const void *native); @@ -112,7 +111,6 @@ const H5B2_class_t H5A_BT2_NAME[1]={{ /* B-tree class information */ H5B2_ATTR_DENSE_NAME_ID, /* Type of B-tree */ sizeof(H5A_dense_bt2_name_rec_t), /* Size of native record */ H5A_dense_btree2_name_store, /* Record storage callback */ - H5A_dense_btree2_name_retrieve, /* Record retrieval callback */ H5A_dense_btree2_name_compare, /* Record comparison callback */ H5A_dense_btree2_name_encode, /* Record encoding callback */ H5A_dense_btree2_name_decode, /* Record decoding callback */ @@ -124,7 +122,6 @@ const H5B2_class_t H5A_BT2_CORDER[1]={{ /* B-tree class information */ H5B2_ATTR_DENSE_CORDER_ID, /* Type of B-tree */ sizeof(H5A_dense_bt2_corder_rec_t),/* Size of native record */ H5A_dense_btree2_corder_store, /* Record storage callback */ - H5A_dense_btree2_corder_retrieve, /* Record retrieval callback */ H5A_dense_btree2_corder_compare, /* Record comparison callback */ H5A_dense_btree2_corder_encode, /* Record encoding callback */ H5A_dense_btree2_corder_decode, /* Record decoding callback */ @@ -229,30 +226,6 @@ H5A_dense_btree2_name_store(void *_nrecord, const void *_udata) /*------------------------------------------------------------------------- - * Function: H5A_dense_btree2_name_retrieve - * - * Purpose: Retrieve native information from record for v2 B-tree - * - * Return: Success: non-negative - * Failure: negative - * - * Programmer: Quincey Koziol - * Monday, December 4, 2006 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5A_dense_btree2_name_retrieve(void *udata, const void *nrecord) -{ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5A_dense_btree2_name_retrieve) - - *(H5A_dense_bt2_name_rec_t *)udata = *(const H5A_dense_bt2_name_rec_t *)nrecord; - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5A_dense_btree2_name_retrieve() */ - - -/*------------------------------------------------------------------------- * Function: H5A_dense_btree2_name_compare * * Purpose: Compare two native information records, according to some key @@ -443,30 +416,6 @@ H5A_dense_btree2_corder_store(void *_nrecord, const void *_udata) /*------------------------------------------------------------------------- - * Function: H5A_dense_btree2_corder_retrieve - * - * Purpose: Retrieve native information from record for v2 B-tree - * - * Return: Success: non-negative - * Failure: negative - * - * Programmer: Quincey Koziol - * Tuesday, February 6, 2007 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5A_dense_btree2_corder_retrieve(void *udata, const void *nrecord) -{ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5A_dense_btree2_corder_retrieve) - - *(H5A_dense_bt2_corder_rec_t *)udata = *(const H5A_dense_bt2_corder_rec_t *)nrecord; - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5A_dense_btree2_corder_retrieve() */ - - -/*------------------------------------------------------------------------- * Function: H5A_dense_btree2_corder_compare * * Purpose: Compare two native information records, according to some key diff --git a/src/H5B2private.h b/src/H5B2private.h index 0a18604..0a516d2 100644 --- a/src/H5B2private.h +++ b/src/H5B2private.h @@ -84,9 +84,8 @@ struct H5B2_class_t { H5B2_subid_t id; /* ID of B-tree class, as found in file */ size_t nrec_size; /* Size of native (memory) record */ - /* Store & retrieve record from application to B-tree 'native' form */ + /* Store record from application to B-tree 'native' form */ herr_t (*store)(void *nrecord, const void *udata); /* Store record in native record table */ - herr_t (*retrieve)(void *udata, const void *nrecord); /* Retrieve record in native record table */ /* Compare records, according to a key */ herr_t (*compare)(const void *rec1, const void *rec2); /* Compare two native records */ diff --git a/src/H5B2test.c b/src/H5B2test.c index 46cd510..3fa5d27 100644 --- a/src/H5B2test.c +++ b/src/H5B2test.c @@ -53,7 +53,6 @@ /* Local Prototypes */ /********************/ static herr_t H5B2_test_store(void *nrecord, const void *udata); -static herr_t H5B2_test_retrieve(void *udata, const void *nrecord); static herr_t H5B2_test_compare(const void *rec1, const void *rec2); static herr_t H5B2_test_encode(const H5F_t *f, uint8_t *raw, const void *nrecord); @@ -69,7 +68,6 @@ const H5B2_class_t H5B2_TEST[1]={{ /* B-tree class information */ H5B2_TEST_ID, /* Type of B-tree */ sizeof(hsize_t), /* Size of native record */ H5B2_test_store, /* Record storage callback */ - H5B2_test_retrieve, /* Record retrieval callback */ H5B2_test_compare, /* Record comparison callback */ H5B2_test_encode, /* Record encoding callback */ H5B2_test_decode, /* Record decoding callback */ @@ -112,31 +110,6 @@ H5B2_test_store(void *nrecord, const void *udata) /*------------------------------------------------------------------------- - * Function: H5B2_test_retrieve - * - * Purpose: Retrieve native information from record for B-tree - * - * Return: Success: non-negative - * - * Failure: negative - * - * Programmer: Quincey Koziol - * Friday, February 25, 2005 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5B2_test_retrieve(void *udata, const void *nrecord) -{ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_test_retrieve) - - *(hsize_t *)udata = *(const hsize_t *)nrecord; - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5B2_test_retrieve() */ - - -/*------------------------------------------------------------------------- * Function: H5B2_test_compare * * Purpose: Compare two native information records, according to some key diff --git a/src/H5C.c b/src/H5C.c index b90f963..7fc651b 100644 --- a/src/H5C.c +++ b/src/H5C.c @@ -6211,7 +6211,7 @@ H5C_protect(H5F_t * f, /* Check for trying to load the wrong type of entry from an address */ if(entry_ptr->type != type) - HGOTO_ERROR(H5E_CACHE, H5E_BADTYPE, NULL, "not a dataset creation property list") + HGOTO_ERROR(H5E_CACHE, H5E_BADTYPE, NULL, "incorrect cache entry type") hit = TRUE; thing = (void *)entry_ptr; @@ -10716,7 +10716,7 @@ end_of_inner_loop: */ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \ - "Can't unpin all pinned entries 1.") + "Pinned entry count not decreasing.") } else if ( ( cur_pel_len == 0 ) && ( old_pel_len == 0 ) ) { @@ -10759,7 +10759,7 @@ end_of_inner_loop: } else if ( cur_pel_len > 0 ) { HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \ - "Can't unpin all pinned entries 2.") + "Can't unpin all pinned entries.") } @@ -10994,7 +10994,7 @@ H5C_flush_single_entry(H5F_t * f, if ( NULL == (dxpl = H5I_object(primary_dxpl_id)) ) { HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, \ - "not a dataset creation property list") + "not a dataset transfer property list") } /* Get the transfer mode property */ diff --git a/src/H5F.c b/src/H5F.c index 3978154..6d16e73 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -867,7 +867,6 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf) if(NULL == (f->shared = H5FL_CALLOC(H5F_file_t))) HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate shared file structure") - f->shared->super_addr = HADDR_UNDEF; f->shared->sohm_addr = HADDR_UNDEF; f->shared->sohm_vers = HDF5_SHAREDHEADER_VERSION; for(u = 0; u < NELMTS(f->shared->fs_addr); u++) diff --git a/src/H5FD.c b/src/H5FD.c index 8de2a1a..8a0e230 100644 --- a/src/H5FD.c +++ b/src/H5FD.c @@ -2088,3 +2088,33 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_set_base_addr() */ + +/*-------------------------------------------------------------------------- + * Function: H5FD_get_base_addr + * + * Purpose: Get the base address for the file + * + * Return: Success: The absolute base address of the file + * Failure: The undefined address (HADDR_UNDEF) + * + * Programmer: Quincey Koziol + * Sept. 10, 2009 + * + *-------------------------------------------------------------------------- + */ +haddr_t +H5FD_get_base_addr(const H5FD_t *file) +{ + haddr_t ret_value; /* Return value */ + + FUNC_ENTER_NOAPI(H5FD_get_base_addr, HADDR_UNDEF) + + HDassert(file); + + /* Return the file's base address */ + ret_value = file->base_addr; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_get_base_addr() */ + diff --git a/src/H5FDprivate.h b/src/H5FDprivate.h index fc38566..cb40e5c 100644 --- a/src/H5FDprivate.h +++ b/src/H5FDprivate.h @@ -77,6 +77,7 @@ H5_DLL herr_t H5FD_truncate(H5FD_t *file, hid_t dxpl_id, hbool_t closing); H5_DLL herr_t H5FD_get_fileno(const H5FD_t *file, unsigned long *filenum); H5_DLL herr_t H5FD_get_vfd_handle(H5FD_t *file, hid_t fapl, void** file_handle); H5_DLL herr_t H5FD_set_base_addr(H5FD_t *file, haddr_t base_addr); +H5_DLL haddr_t H5FD_get_base_addr(const H5FD_t *file); #endif /* !_H5FDprivate_H */ diff --git a/src/H5FDspace.c b/src/H5FDspace.c index 5526b03..9895938 100644 --- a/src/H5FDspace.c +++ b/src/H5FDspace.c @@ -126,6 +126,7 @@ H5FD_space_init_interface(void) static haddr_t H5FD_extend(H5FD_t *file, H5FD_mem_t type, hbool_t new_block, hsize_t size, haddr_t *frag_addr, hsize_t *frag_size) { + hsize_t orig_size = size; /* Original allocation size */ haddr_t eoa; /* Address of end-of-allocated space */ hsize_t extra; /* Extra space to allocate, to align request */ haddr_t ret_value; /* Return value */ @@ -143,15 +144,17 @@ H5FD_extend(H5FD_t *file, H5FD_mem_t type, hbool_t new_block, hsize_t size, hadd /* Compute extra space to allocate, if this is a new block and should be aligned */ extra = 0; - if(new_block && file->alignment > 1 && size >= file->threshold) { + if(new_block && file->alignment > 1 && orig_size >= file->threshold) { hsize_t mis_align; /* Amount EOA is misaligned */ /* Check for EOA already aligned */ if((mis_align = (eoa % file->alignment)) > 0) { extra = file->alignment - mis_align; - if (frag_addr) *frag_addr = eoa; - if (frag_size) *frag_size = extra; - } + if(frag_addr) + *frag_addr = eoa - file->base_addr; /* adjust for file's base address */ + if(frag_size) + *frag_size = extra; + } /* end if */ } /* end if */ /* Add in extra allocation amount */ @@ -169,6 +172,10 @@ H5FD_extend(H5FD_t *file, H5FD_mem_t type, hbool_t new_block, hsize_t size, hadd if(file->cls->set_eoa(file, type, eoa) < 0) HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, HADDR_UNDEF, "file allocation request failed") + /* Post-condition sanity check */ + if(new_block && file->alignment && orig_size >= file->threshold) + HDassert(!(ret_value % file->alignment)); + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_extend() */ diff --git a/src/H5Fdbg.c b/src/H5Fdbg.c index 5f14357..2b13f11 100644 --- a/src/H5Fdbg.c +++ b/src/H5Fdbg.c @@ -60,7 +60,6 @@ H5F_debug(H5F_t *f, FILE *stream, int indent, int fwidth) HDassert(stream); HDassert(indent >= 0); HDassert(fwidth >= 0); - HDassert(f->shared->super_addr != HADDR_UNDEF); /* Get property list */ if(NULL == (plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 5fdde37..15946d4 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -192,7 +192,6 @@ typedef struct H5F_super_t { typedef struct H5F_file_t { H5FD_t *lf; /* Lower level file handle for I/O */ H5F_super_t *sblock; /* Pointer to (pinned) superblock for file */ - haddr_t super_addr; /* Address of superblock signature */ unsigned nrefs; /* Ref count for times file is opened */ unsigned flags; /* Access Permissions for file */ H5F_mtab_t mtab; /* File mount table */ diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c index 3be8069..e85c980 100644 --- a/src/H5Fsuper.c +++ b/src/H5Fsuper.c @@ -293,6 +293,7 @@ H5F_super_read(H5F_t *f, hid_t dxpl_id) { H5F_super_t * sblock = NULL; /* superblock structure */ unsigned sblock_flags = H5AC__NO_FLAGS_SET; /* flags used in superblock unprotect call */ + haddr_t super_addr; /* Absolute address of superblock */ H5AC_protect_t rw; /* read/write permissions for file */ hbool_t dirtied = FALSE; /* Bool for sblock protect call */ herr_t ret_value = SUCCEED; /* return value */ @@ -300,9 +301,16 @@ H5F_super_read(H5F_t *f, hid_t dxpl_id) FUNC_ENTER_NOAPI(H5F_super_read, FAIL) /* Find the superblock */ - if(HADDR_UNDEF == (f->shared->super_addr = H5F_locate_signature(f->shared->lf, dxpl_id))) + if(HADDR_UNDEF == (super_addr = H5F_locate_signature(f->shared->lf, dxpl_id))) HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable to find file signature") + /* Check for userblock present */ + if(H5F_addr_gt(super_addr, 0)) { + /* Set the base address for the file in the VFD now */ + if(H5FD_set_base_addr(f->shared->lf, super_addr) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "failed to set base address for file driver") + } /* end if */ + /* Determine file intent for superblock protect */ if(H5F_INTENT(f) & H5F_ACC_RDWR) rw = H5AC_WRITE; @@ -310,7 +318,7 @@ H5F_super_read(H5F_t *f, hid_t dxpl_id) rw = H5AC_READ; /* Look up the superblock */ - if(NULL == (sblock = (H5F_super_t *)H5AC_protect(f, dxpl_id, H5AC_SUPERBLOCK, f->shared->super_addr, NULL, &dirtied, rw))) + if(NULL == (sblock = (H5F_super_t *)H5AC_protect(f, dxpl_id, H5AC_SUPERBLOCK, (haddr_t)0, NULL, &dirtied, rw))) HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, FAIL, "unable to load superblock") /* Mark the superblock dirty if it was modified during loading or VFD indicated to do so */ @@ -326,7 +334,7 @@ H5F_super_read(H5F_t *f, hid_t dxpl_id) done: /* Release the superblock */ - if(sblock && H5AC_unprotect(f, dxpl_id, H5AC_SUPERBLOCK, f->shared->super_addr, sblock, sblock_flags) < 0) + if(sblock && H5AC_unprotect(f, dxpl_id, H5AC_SUPERBLOCK, (haddr_t)0, sblock, sblock_flags) < 0) HDONE_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "unable to close superblock") FUNC_LEAVE_NOAPI(ret_value) @@ -359,7 +367,6 @@ H5F_super_init(H5F_t *f, hid_t dxpl_id) hsize_t superblock_size; /* Size of superblock, in bytes */ size_t driver_size; /* Size of driver info block (bytes) */ unsigned super_vers = HDF5_SUPERBLOCK_VERSION_DEF; /* Superblock version for file */ - haddr_t super_addr; /* Address of superblock */ hbool_t need_ext; /* Whether the superblock extension is needed */ herr_t ret_value = SUCCEED; /* Return Value */ @@ -419,6 +426,14 @@ H5F_super_init(H5F_t *f, hid_t dxpl_id) if(H5P_get(plist, H5F_CRT_USER_BLOCK_NAME, &userblock_size) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get userblock size") + /* Sanity check the userblock size vs. the file's allocation alignment */ + if(userblock_size > 0) { + if(userblock_size < f->shared->alignment) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "userblock size must be > file object alignment") + if(0 != (userblock_size % f->shared->alignment)) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "userblock size must be an integral multiple of file object alignment") + } /* end if */ + sblock->base_addr = userblock_size; sblock->status_flags = 0; @@ -463,17 +478,13 @@ H5F_super_init(H5F_t *f, hid_t dxpl_id) if(H5FD_set_eoa(f->shared->lf, H5FD_MEM_SUPER, superblock_size) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to set EOA value for superblock") - /* Set the superblock's address, it must be immediately after any userblock */ - super_addr = (haddr_t)0; - /* Insert superblock into cache, pinned */ - if(H5AC_set(f, dxpl_id, H5AC_SUPERBLOCK, super_addr, sblock, H5AC__PIN_ENTRY_FLAG) < 0) + if(H5AC_set(f, dxpl_id, H5AC_SUPERBLOCK, (haddr_t)0, sblock, H5AC__PIN_ENTRY_FLAG) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "can't add superblock to cache") sblock_in_cache = TRUE; /* Keep a copy of the superblock info */ f->shared->sblock = sblock; - f->shared->super_addr = super_addr; /* * Determine if we will need a superblock extension @@ -577,7 +588,7 @@ done: HDONE_ERROR(H5E_FILE, H5E_CANTUNPIN, FAIL, "unable to unpin superblock") /* Evict the superblock from the cache */ - if(H5AC_expunge_entry(f, dxpl_id, H5AC_SUPERBLOCK, super_addr, H5AC__NO_FLAGS_SET) < 0) + if(H5AC_expunge_entry(f, dxpl_id, H5AC_SUPERBLOCK, (haddr_t)0, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTEXPUNGE, FAIL, "unable to expunge superblock") } /* end if */ else @@ -586,7 +597,6 @@ done: /* Reset variables in file structure */ f->shared->sblock = NULL; - f->shared->super_addr = HADDR_UNDEF; } /* end if */ } /* end if */ diff --git a/src/H5Fsuper_cache.c b/src/H5Fsuper_cache.c index 240ac9f..14454ef 100644 --- a/src/H5Fsuper_cache.c +++ b/src/H5Fsuper_cache.c @@ -111,9 +111,10 @@ H5FL_EXTERN(H5F_super_t); *------------------------------------------------------------------------- */ static H5F_super_t * -H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, const void UNUSED *udata1, void *udata2/*out*/) +H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *udata1, void *udata2/*out*/) { H5F_super_t *sblock = NULL; /* File's superblock */ + haddr_t base_addr = HADDR_UNDEF; /* Base address of file */ uint8_t sbuf[H5F_MAX_SUPERBLOCK_SIZE]; /* Buffer for superblock */ H5P_genplist_t *c_plist; /* File creation property list */ H5F_file_t *shared; /* shared part of `file' */ @@ -131,6 +132,10 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, const void UNUSED FUNC_ENTER_NOAPI_NOINIT(H5F_sblock_load) + /* check arguments */ + HDassert(f); + HDassert(H5F_addr_eq(addr, 0)); + /* Short cuts */ shared = f->shared; lf = shared->lf; @@ -139,15 +144,19 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, const void UNUSED if(NULL == (c_plist = (H5P_genplist_t *)H5I_object(shared->fcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "can't get property list") + /* Get the base address for the file in the VFD */ + if(HADDR_UNDEF == (base_addr = H5FD_get_base_addr(lf))) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "failed to get base address for file driver") + /* Allocate space for the superblock */ if(NULL == (sblock = H5FL_CALLOC(H5F_super_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Read fixed-size portion of the superblock */ p = sbuf; - if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, f->shared->super_addr + fixed_size) < 0) + if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, fixed_size) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "set end of space allocation request failed") - if(H5FD_read(lf, dxpl_id, H5FD_MEM_SUPER, f->shared->super_addr, fixed_size, p) < 0) + if(H5FD_read(lf, dxpl_id, H5FD_MEM_SUPER, (haddr_t)0, fixed_size, p) < 0) HGOTO_ERROR(H5E_FILE, H5E_READERROR, NULL, "unable to read superblock") /* Skip over signature (already checked when locating the superblock) */ @@ -172,10 +181,11 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, const void UNUSED HDassert(fixed_size + variable_size <= sizeof(sbuf)); /* Read in variable-sized portion of superblock */ - if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, f->shared->super_addr + fixed_size + variable_size) < 0) + if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, fixed_size + variable_size) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "set end of space allocation request failed") - if(H5FD_read(lf, dxpl_id, H5FD_MEM_SUPER, f->shared->super_addr + fixed_size, variable_size, p) < 0) + if(H5FD_read(lf, dxpl_id, H5FD_MEM_SUPER, (haddr_t)fixed_size, variable_size, p) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to read superblock") + /* Check for older version of superblock format */ if(super_vers < HDF5_SUPERBLOCK_VERSION_2) { uint32_t status_flags; /* File status flags */ @@ -284,22 +294,24 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, const void UNUSED * Check if superblock address is different from base address and * adjust base address and "end of address" address if so. */ - if(!H5F_addr_eq(f->shared->super_addr, sblock->base_addr)) { + if(!H5F_addr_eq(base_addr, sblock->base_addr)) { /* Check if the superblock moved earlier in the file */ - if(H5F_addr_lt(f->shared->super_addr, sblock->base_addr)) - stored_eoa -= (sblock->base_addr - f->shared->super_addr); + if(H5F_addr_lt(base_addr, sblock->base_addr)) + stored_eoa -= (sblock->base_addr - base_addr); else /* The superblock moved later in the file */ - stored_eoa += (f->shared->super_addr - sblock->base_addr); + stored_eoa += (base_addr - sblock->base_addr); - sblock->base_addr = f->shared->super_addr; - } /* end if */ + /* Adjust base address for offsets of the HDF5 data in the file */ + sblock->base_addr = base_addr; - /* Set the base address for the file in the VFD now, after adjusting - * space for possible offsets of the HDF5 data in the file. - */ - if(H5FD_set_base_addr(lf, sblock->base_addr) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "failed to set base address for file driver") + /* Set the base address for the file in the VFD now */ + if(H5FD_set_base_addr(lf, sblock->base_addr) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, NULL, "failed to set base address for file driver") + + /* Indicate that the superblock should be marked dirty */ + *dirtied = TRUE; + } /* end if */ /* This step is for h5repart tool only. If user wants to change file driver * from family to sec2 while using h5repart, set the driver address to @@ -412,22 +424,24 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, const void UNUSED * Check if superblock address is different from base address and * adjust base address and "end of address" address if so. */ - if(!H5F_addr_eq(f->shared->super_addr, sblock->base_addr)) { + if(!H5F_addr_eq(base_addr, sblock->base_addr)) { /* Check if the superblock moved earlier in the file */ - if(H5F_addr_lt(f->shared->super_addr, sblock->base_addr)) - stored_eoa -= (sblock->base_addr - f->shared->super_addr); + if(H5F_addr_lt(base_addr, sblock->base_addr)) + stored_eoa -= (sblock->base_addr - base_addr); else /* The superblock moved later in the file */ - stored_eoa += (f->shared->super_addr - sblock->base_addr); + stored_eoa += (base_addr - sblock->base_addr); - sblock->base_addr = f->shared->super_addr; - } /* end if */ + /* Adjust base address for offsets of the HDF5 data in the file */ + sblock->base_addr = base_addr; - /* Set the base address for the file in the VFD now, after adjusting - * space for possible offsets of the HDF5 data in the file. - */ - if(H5FD_set_base_addr(lf, sblock->base_addr) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "failed to set base address for file driver") + /* Set the base address for the file in the VFD now */ + if(H5FD_set_base_addr(lf, sblock->base_addr) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, NULL, "failed to set base address for file driver") + + /* Indicate that the superblock should be marked dirty */ + *dirtied = TRUE; + } /* end if */ /* Get the B-tree internal node values, etc */ if(H5P_get(c_plist, H5F_CRT_BTREE_RANK_NAME, sblock->btree_k) < 0) @@ -587,6 +601,7 @@ H5F_sblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5F_sup /* check arguments */ HDassert(f); + HDassert(H5F_addr_eq(addr, 0)); HDassert(sblock); if(sblock->cache_info.is_dirty) { @@ -729,7 +744,6 @@ H5F_sblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5F_sup H5O_drvinfo_t drvinfo; /* Driver info */ H5O_loc_t ext_loc; /* "Object location" for superblock extension */ uint8_t dbuf[H5F_MAX_DRVINFOBLOCK_SIZE]; /* Driver info block encoding buffer */ - htri_t status; /* Indicate whether the message exists or not */ /* Sanity check */ HDassert(driver_size <= H5F_MAX_DRVINFOBLOCK_SIZE); diff --git a/src/H5Gbtree2.c b/src/H5Gbtree2.c index 9afd882..5f7ad23 100644 --- a/src/H5Gbtree2.c +++ b/src/H5Gbtree2.c @@ -78,7 +78,6 @@ typedef struct H5G_fh_ud_cmp_t { /* v2 B-tree driver callbacks for 'creation order' index */ static herr_t H5G_dense_btree2_corder_store(void *native, const void *udata); -static herr_t H5G_dense_btree2_corder_retrieve(void *udata, const void *native); static herr_t H5G_dense_btree2_corder_compare(const void *rec1, const void *rec2); static herr_t H5G_dense_btree2_corder_encode(const H5F_t *f, uint8_t *raw, const void *native); @@ -89,7 +88,6 @@ static herr_t H5G_dense_btree2_corder_debug(FILE *stream, const H5F_t *f, hid_t /* v2 B-tree driver callbacks for 'name' index */ static herr_t H5G_dense_btree2_name_store(void *native, const void *udata); -static herr_t H5G_dense_btree2_name_retrieve(void *udata, const void *native); static herr_t H5G_dense_btree2_name_compare(const void *rec1, const void *rec2); static herr_t H5G_dense_btree2_name_encode(const H5F_t *f, uint8_t *raw, const void *native); @@ -110,7 +108,6 @@ const H5B2_class_t H5G_BT2_NAME[1]={{ /* B-tree class information */ H5B2_GRP_DENSE_NAME_ID, /* Type of B-tree */ sizeof(H5G_dense_bt2_name_rec_t), /* Size of native record */ H5G_dense_btree2_name_store, /* Record storage callback */ - H5G_dense_btree2_name_retrieve, /* Record retrieval callback */ H5G_dense_btree2_name_compare, /* Record comparison callback */ H5G_dense_btree2_name_encode, /* Record encoding callback */ H5G_dense_btree2_name_decode, /* Record decoding callback */ @@ -122,7 +119,6 @@ const H5B2_class_t H5G_BT2_CORDER[1]={{ /* B-tree class information */ H5B2_GRP_DENSE_CORDER_ID, /* Type of B-tree */ sizeof(H5G_dense_bt2_corder_rec_t), /* Size of native record */ H5G_dense_btree2_corder_store, /* Record storage callback */ - H5G_dense_btree2_corder_retrieve, /* Record retrieval callback */ H5G_dense_btree2_corder_compare, /* Record comparison callback */ H5G_dense_btree2_corder_encode, /* Record encoding callback */ H5G_dense_btree2_corder_decode, /* Record decoding callback */ @@ -214,30 +210,6 @@ H5G_dense_btree2_name_store(void *_nrecord, const void *_udata) /*------------------------------------------------------------------------- - * Function: H5G_dense_btree2_name_retrieve - * - * Purpose: Retrieve native information from record for v2 B-tree - * - * Return: Success: non-negative - * Failure: negative - * - * Programmer: Quincey Koziol - * Monday, September 11, 2006 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5G_dense_btree2_name_retrieve(void *udata, const void *nrecord) -{ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_dense_btree2_name_retrieve) - - *(H5G_dense_bt2_name_rec_t *)udata = *(const H5G_dense_bt2_name_rec_t *)nrecord; - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5G_dense_btree2_name_retrieve() */ - - -/*------------------------------------------------------------------------- * Function: H5G_dense_btree2_name_compare * * Purpose: Compare two native information records, according to some key @@ -428,30 +400,6 @@ H5G_dense_btree2_corder_store(void *_nrecord, const void *_udata) /*------------------------------------------------------------------------- - * Function: H5G_dense_btree2_corder_retrieve - * - * Purpose: Retrieve native information from record for v2 B-tree - * - * Return: Success: non-negative - * Failure: negative - * - * Programmer: Quincey Koziol - * Monday, October 30, 2006 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5G_dense_btree2_corder_retrieve(void *udata, const void *nrecord) -{ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_dense_btree2_corder_retrieve) - - *(H5G_dense_bt2_corder_rec_t *)udata = *(const H5G_dense_bt2_corder_rec_t *)nrecord; - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5G_dense_btree2_corder_retrieve() */ - - -/*------------------------------------------------------------------------- * Function: H5G_dense_btree2_corder_compare * * Purpose: Compare two native information records, according to some key diff --git a/src/H5HFbtree2.c b/src/H5HFbtree2.c index b750822..5958c03 100644 --- a/src/H5HFbtree2.c +++ b/src/H5HFbtree2.c @@ -61,7 +61,6 @@ /* v2 B-tree driver callbacks */ static herr_t H5HF_huge_btree2_indir_store(void *native, const void *udata); -static herr_t H5HF_huge_btree2_indir_retrieve(void *udata, const void *native); static herr_t H5HF_huge_btree2_indir_compare(const void *rec1, const void *rec2); static herr_t H5HF_huge_btree2_indir_encode(const H5F_t *f, uint8_t *raw, const void *native); @@ -71,7 +70,6 @@ static herr_t H5HF_huge_btree2_indir_debug(FILE *stream, const H5F_t *f, hid_t d int indent, int fwidth, const void *record, const void *_udata); static herr_t H5HF_huge_btree2_filt_indir_store(void *native, const void *udata); -static herr_t H5HF_huge_btree2_filt_indir_retrieve(void *udata, const void *native); static herr_t H5HF_huge_btree2_filt_indir_compare(const void *rec1, const void *rec2); static herr_t H5HF_huge_btree2_filt_indir_encode(const H5F_t *f, uint8_t *raw, const void *native); @@ -81,7 +79,6 @@ static herr_t H5HF_huge_btree2_filt_indir_debug(FILE *stream, const H5F_t *f, hi int indent, int fwidth, const void *record, const void *_udata); static herr_t H5HF_huge_btree2_dir_store(void *native, const void *udata); -static herr_t H5HF_huge_btree2_dir_retrieve(void *udata, const void *native); static herr_t H5HF_huge_btree2_dir_compare(const void *rec1, const void *rec2); static herr_t H5HF_huge_btree2_dir_encode(const H5F_t *f, uint8_t *raw, const void *native); @@ -91,7 +88,6 @@ static herr_t H5HF_huge_btree2_dir_debug(FILE *stream, const H5F_t *f, hid_t dxp int indent, int fwidth, const void *record, const void *_udata); static herr_t H5HF_huge_btree2_filt_dir_store(void *native, const void *udata); -static herr_t H5HF_huge_btree2_filt_dir_retrieve(void *udata, const void *native); static herr_t H5HF_huge_btree2_filt_dir_compare(const void *rec1, const void *rec2); static herr_t H5HF_huge_btree2_filt_dir_encode(const H5F_t *f, uint8_t *raw, const void *native); @@ -108,7 +104,6 @@ const H5B2_class_t H5HF_BT2_INDIR[1]={{ /* B-tree class information */ H5B2_FHEAP_HUGE_INDIR_ID, /* Type of B-tree */ sizeof(H5HF_huge_bt2_indir_rec_t), /* Size of native record */ H5HF_huge_btree2_indir_store, /* Record storage callback */ - H5HF_huge_btree2_indir_retrieve, /* Record retrieval callback */ H5HF_huge_btree2_indir_compare, /* Record comparison callback */ H5HF_huge_btree2_indir_encode, /* Record encoding callback */ H5HF_huge_btree2_indir_decode, /* Record decoding callback */ @@ -120,7 +115,6 @@ const H5B2_class_t H5HF_BT2_FILT_INDIR[1]={{ /* B-tree class information */ H5B2_FHEAP_HUGE_FILT_INDIR_ID, /* Type of B-tree */ sizeof(H5HF_huge_bt2_filt_indir_rec_t), /* Size of native record */ H5HF_huge_btree2_filt_indir_store, /* Record storage callback */ - H5HF_huge_btree2_filt_indir_retrieve, /* Record retrieval callback */ H5HF_huge_btree2_filt_indir_compare, /* Record comparison callback */ H5HF_huge_btree2_filt_indir_encode, /* Record encoding callback */ H5HF_huge_btree2_filt_indir_decode, /* Record decoding callback */ @@ -132,7 +126,6 @@ const H5B2_class_t H5HF_BT2_DIR[1]={{ /* B-tree class information */ H5B2_FHEAP_HUGE_DIR_ID, /* Type of B-tree */ sizeof(H5HF_huge_bt2_dir_rec_t), /* Size of native record */ H5HF_huge_btree2_dir_store, /* Record storage callback */ - H5HF_huge_btree2_dir_retrieve, /* Record retrieval callback */ H5HF_huge_btree2_dir_compare, /* Record comparison callback */ H5HF_huge_btree2_dir_encode, /* Record encoding callback */ H5HF_huge_btree2_dir_decode, /* Record decoding callback */ @@ -144,7 +137,6 @@ const H5B2_class_t H5HF_BT2_FILT_DIR[1]={{ /* B-tree class information */ H5B2_FHEAP_HUGE_FILT_DIR_ID, /* Type of B-tree */ sizeof(H5HF_huge_bt2_filt_dir_rec_t),/* Size of native record */ H5HF_huge_btree2_filt_dir_store, /* Record storage callback */ - H5HF_huge_btree2_filt_dir_retrieve, /* Record retrieval callback */ H5HF_huge_btree2_filt_dir_compare, /* Record comparison callback */ H5HF_huge_btree2_filt_dir_encode, /* Record encoding callback */ H5HF_huge_btree2_filt_dir_decode, /* Record decoding callback */ @@ -251,30 +243,6 @@ H5HF_huge_btree2_indir_store(void *nrecord, const void *udata) /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_indir_retrieve - * - * Purpose: Retrieve native information from record for v2 B-tree - * - * Return: Success: non-negative - * Failure: negative - * - * Programmer: Quincey Koziol - * Monday, August 7, 2006 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5HF_huge_btree2_indir_retrieve(void *udata, const void *nrecord) -{ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_indir_retrieve) - - *(H5HF_huge_bt2_indir_rec_t *)udata = *(const H5HF_huge_bt2_indir_rec_t *)nrecord; - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_huge_btree2_indir_retrieve() */ - - -/*------------------------------------------------------------------------- * Function: H5HF_huge_btree2_indir_compare * * Purpose: Compare two native information records, according to some key @@ -485,30 +453,6 @@ H5HF_huge_btree2_filt_indir_store(void *nrecord, const void *udata) /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_filt_indir_retrieve - * - * Purpose: Retrieve native information from record for v2 B-tree - * - * Return: Success: non-negative - * Failure: negative - * - * Programmer: Quincey Koziol - * Monday, August 7, 2006 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5HF_huge_btree2_filt_indir_retrieve(void *udata, const void *nrecord) -{ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_filt_indir_retrieve) - - *(H5HF_huge_bt2_filt_indir_rec_t *)udata = *(const H5HF_huge_bt2_filt_indir_rec_t *)nrecord; - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_huge_btree2_filt_indir_retrieve() */ - - -/*------------------------------------------------------------------------- * Function: H5HF_huge_btree2_filt_indir_compare * * Purpose: Compare two native information records, according to some key @@ -690,30 +634,6 @@ H5HF_huge_btree2_dir_store(void *nrecord, const void *udata) /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_dir_retrieve - * - * Purpose: Retrieve native information from record for v2 B-tree - * - * Return: Success: non-negative - * Failure: negative - * - * Programmer: Quincey Koziol - * Monday, August 7, 2006 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5HF_huge_btree2_dir_retrieve(void *udata, const void *nrecord) -{ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_dir_retrieve) - - *(H5HF_huge_bt2_dir_rec_t *)udata = *(const H5HF_huge_bt2_dir_rec_t *)nrecord; - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_huge_btree2_dir_retrieve() */ - - -/*------------------------------------------------------------------------- * Function: H5HF_huge_btree2_dir_compare * * Purpose: Compare two native information records, according to some key @@ -931,30 +851,6 @@ H5HF_huge_btree2_filt_dir_store(void *nrecord, const void *udata) /*------------------------------------------------------------------------- - * Function: H5HF_huge_btree2_filt_dir_retrieve - * - * Purpose: Retrieve native information from record for v2 B-tree - * - * Return: Success: non-negative - * Failure: negative - * - * Programmer: Quincey Koziol - * Tuesday, August 15, 2006 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5HF_huge_btree2_filt_dir_retrieve(void *udata, const void *nrecord) -{ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_huge_btree2_filt_dir_retrieve) - - *(H5HF_huge_bt2_filt_dir_rec_t *)udata = *(const H5HF_huge_bt2_filt_dir_rec_t *)nrecord; - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HF_huge_btree2_filt_dir_retrieve() */ - - -/*------------------------------------------------------------------------- * Function: H5HF_huge_btree2_filt_dir_compare * * Purpose: Compare two native information records, according to some key diff --git a/src/H5MFaggr.c b/src/H5MFaggr.c index 1435d18..aa982da 100644 --- a/src/H5MFaggr.c +++ b/src/H5MFaggr.c @@ -152,11 +152,9 @@ haddr_t H5MF_aggr_alloc(H5F_t *f, hid_t dxpl_id, H5F_blk_aggr_t *aggr, H5F_blk_aggr_t *other_aggr, H5FD_mem_t type, hsize_t size) { - hsize_t alignment = 0, mis_align = 0; - haddr_t frag_addr = 0, eoa_frag_addr = 0; - hsize_t frag_size = 0, eoa_frag_size = 0; - haddr_t eoa = 0; /* Initial EOA for the file */ - H5FD_mem_t alloc_type, other_alloc_type; + haddr_t eoa_frag_addr = HADDR_UNDEF; /* Address of fragment at EOA */ + hsize_t eoa_frag_size = 0; /* Size of fragment at EOA */ + haddr_t eoa = HADDR_UNDEF; /* Initial EOA for the file */ haddr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5MF_aggr_alloc, HADDR_UNDEF) @@ -174,6 +172,7 @@ HDfprintf(stderr, "%s: type = %u, size = %Hu\n", FUNC, (unsigned)type, size); HDassert(type >= H5FD_MEM_DEFAULT && type < H5FD_MEM_NTYPES); HDassert(size > 0); + /* Get the EOA for the file */ if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, type))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, HADDR_UNDEF, "Unable to get eoa") @@ -183,29 +182,37 @@ HDfprintf(stderr, "%s: type = %u, size = %Hu\n", FUNC, (unsigned)type, size); * through H5FD_alloc() */ if(f->shared->feature_flags & aggr->feature_flag) { + haddr_t aggr_frag_addr = HADDR_UNDEF; /* Address of aggregrator fragment */ + hsize_t aggr_frag_size = 0; /* Size of aggregator fragment */ + hsize_t alignment; /* Alignment of this section */ + hsize_t aggr_mis_align = 0; /* Mis-alignment of aggregator */ + H5FD_mem_t alloc_type, other_alloc_type;/* Current aggregator & 'other' aggregator types */ + #ifdef H5MF_AGGR_DEBUG HDfprintf(stderr, "%s: aggr = {%a, %Hu, %Hu}\n", FUNC, aggr->addr, aggr->tot_size, aggr->size); #endif /* H5MF_AGGR_DEBUG */ + /* Turn off alignment if allocation < threshold */ alignment = f->shared->alignment; if(!((alignment > 1) && (size >= f->shared->threshold))) alignment = 0; /* no alignment */ - if(alignment && aggr->addr > 0 && aggr->size > 0 && (mis_align = aggr->addr % alignment)) { - frag_addr = aggr->addr; - frag_size = alignment - mis_align; + /* Generate fragment if aggregator is mis-aligned */ + if(alignment && aggr->addr > 0 && aggr->size > 0 && (aggr_mis_align = (aggr->addr + H5FD_get_base_addr(f->shared->lf)) % alignment)) { + aggr_frag_addr = aggr->addr; + aggr_frag_size = alignment - aggr_mis_align; } /* end if */ alloc_type = aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA ? H5FD_MEM_DEFAULT : H5FD_MEM_DRAW; other_alloc_type = other_aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA ? H5FD_MEM_DEFAULT : H5FD_MEM_DRAW; /* Check if the space requested is larger than the space left in the block */ - if((size + frag_size) > aggr->size) { + if((size + aggr_frag_size) > aggr->size) { htri_t extended = FALSE; /* Whether the file was extended */ /* Check if the block asked for is too large for 'normal' aggregator block */ if(size >= aggr->alloc_size) { - hsize_t ext_size = size + frag_size; + hsize_t ext_size = size + aggr_frag_size; /* Check for overlapping into file's temporary allocation space */ if(H5F_addr_gt((aggr->addr + aggr->size + ext_size), f->shared->tmp_addr)) @@ -215,7 +222,7 @@ HDfprintf(stderr, "%s: aggr = {%a, %Hu, %Hu}\n", FUNC, aggr->addr, aggr->tot_siz HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't extending space") else if (extended) { /* aggr->size is unchanged */ - ret_value = aggr->addr + frag_size; + ret_value = aggr->addr + aggr_frag_size; aggr->addr += ext_size; aggr->tot_size += ext_size; } else { @@ -247,8 +254,8 @@ HDfprintf(stderr, "%s: aggr = {%a, %Hu, %Hu}\n", FUNC, aggr->addr, aggr->tot_siz HDfprintf(stderr, "%s: Allocating block\n", FUNC); #endif /* H5MF_AGGR_DEBUG */ - if(frag_size > (ext_size - size)) - ext_size += (frag_size - (ext_size - size)); + if(aggr_frag_size > (ext_size - size)) + ext_size += (aggr_frag_size - (ext_size - size)); /* Check for overlapping into file's temporary allocation space */ if(H5F_addr_gt((aggr->addr + aggr->size + ext_size), f->shared->tmp_addr)) @@ -257,8 +264,8 @@ HDfprintf(stderr, "%s: Allocating block\n", FUNC); if((aggr->addr > 0) && (extended = H5FD_try_extend(f->shared->lf, alloc_type, f, aggr->addr + aggr->size, ext_size)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't extending space") else if (extended) { - aggr->addr += frag_size; - aggr->size += (ext_size - frag_size); + aggr->addr += aggr_frag_size; + aggr->size += (ext_size - aggr_frag_size); aggr->tot_size += ext_size; } else { haddr_t new_space; /* Address of new space allocated */ @@ -304,19 +311,19 @@ HDfprintf(stderr, "%s: Allocating block\n", FUNC); HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free eoa fragment") /* Freeing any possible fragment due to alignment in the block after extension */ - if(extended && frag_size) - if(H5MF_xfree(f, type, dxpl_id, frag_addr, frag_size) < 0) + if(extended && aggr_frag_size) + if(H5MF_xfree(f, type, dxpl_id, aggr_frag_addr, aggr_frag_size) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free aggregation fragment") } /* end if */ else { /* Allocate space out of the block */ - ret_value = aggr->addr + frag_size; - aggr->size -= (size + frag_size); - aggr->addr += (size + frag_size); + ret_value = aggr->addr + aggr_frag_size; + aggr->size -= (size + aggr_frag_size); + aggr->addr += (size + aggr_frag_size); /* free any possible fragment */ - if (frag_size) - if(H5MF_xfree(f, type, dxpl_id, frag_addr, frag_size) < 0) + if(aggr_frag_size) + if(H5MF_xfree(f, type, dxpl_id, aggr_frag_addr, aggr_frag_size) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, HADDR_UNDEF, "can't free aggregation fragment") } /* end else */ } /* end if */ @@ -339,13 +346,14 @@ HDfprintf(stderr, "%s: Allocating block\n", FUNC); /* Sanity check for overlapping into file's temporary allocation space */ HDassert(H5F_addr_le((ret_value + size), f->shared->tmp_addr)); + /* Post-condition sanity check */ + if(f->shared->alignment && size >= f->shared->threshold) + HDassert(!((ret_value + H5FD_get_base_addr(f->shared->lf)) % f->shared->alignment)); + done: #ifdef H5MF_AGGR_DEBUG HDfprintf(stderr, "%s: ret_value = %a\n", FUNC, ret_value); #endif /* H5MF_AGGR_DEBUG */ - - if(alignment) - HDassert(!(ret_value % alignment)); FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF_aggr_alloc() */ diff --git a/src/H5Pfcpl.c b/src/H5Pfcpl.c index 4d576c6..406dbe1 100644 --- a/src/H5Pfcpl.c +++ b/src/H5Pfcpl.c @@ -261,44 +261,39 @@ done: * Programmer: Robb Matzke * Tuesday, January 6, 1998 * - * Modifications: - * - * Raymond Lu, Oct 14, 2001 - * Changed to the new generic property list. - * *------------------------------------------------------------------------- */ herr_t H5Pset_userblock(hid_t plist_id, hsize_t size) { - unsigned i; H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value=SUCCEED; /* return value */ + herr_t ret_value = SUCCEED; /* return value */ - FUNC_ENTER_API(H5Pset_userblock, FAIL); + FUNC_ENTER_API(H5Pset_userblock, FAIL) H5TRACE2("e", "ih", plist_id, size); - /* Check that the userblock size is a power of two */ - for (i=8; i<8*sizeof(hsize_t); i++) { - hsize_t p2 = 8==i ? 0 : ((hsize_t)1< 0) { + /* Check that the userblock size is >=512 */ + if(size < 512) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "userblock size is non-zero and less than 512") - if (size == p2) - break; - } - if (i>=8*sizeof(hsize_t)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "userblock size is not valid"); + /* Check that the userblock size is a power of two */ + if(!POWER_OF_TWO(size)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "userblock size is non-zero and not a power of two") + } /* end if */ /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); + if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Set value */ if(H5P_set(plist, H5F_CRT_USER_BLOCK_NAME, &size) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set user block"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set user block") done: - FUNC_LEAVE_API(ret_value); -} + FUNC_LEAVE_API(ret_value) +} /* end H5Pset_userblock() */ /*------------------------------------------------------------------------- diff --git a/src/H5SMbtree2.c b/src/H5SMbtree2.c index 8863287..3ddd3f2 100755 --- a/src/H5SMbtree2.c +++ b/src/H5SMbtree2.c @@ -53,7 +53,6 @@ typedef struct H5SM_compare_udata_t { /* v2 B-tree callbacks */ static herr_t H5SM_btree_compare_cb(const void *obj, size_t obj_len, void *_udata); static herr_t H5SM_btree_store(void *native, const void *udata); -static herr_t H5SM_btree_retrieve(void *udata, const void *native); static herr_t H5SM_btree_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, int indent, int fwidth, const void *record, const void *_udata); @@ -66,7 +65,6 @@ const H5B2_class_t H5SM_INDEX[1]={{ /* B-tree class information */ H5B2_SOHM_INDEX_ID, /* Type of B-tree */ sizeof(H5SM_sohm_t), /* Size of native record */ H5SM_btree_store, /* Record storage callback */ - H5SM_btree_retrieve, /* Record retrieval callback */ H5SM_message_compare, /* Record comparison callback */ H5SM_message_encode, /* Record encoding callback */ H5SM_message_decode, /* Record decoding callback */ @@ -309,34 +307,6 @@ H5SM_btree_store(void *native, const void *udata) /*------------------------------------------------------------------------- - * Function: H5SM_btree_retrieve - * - * Purpose: Retrieve a H5SM_sohm_t SOHM message from the B-tree by - * copying it from NATIVE to UDATA. - * - * Quincey said this function may no longer be used. - * - * Return: Non-negative on success - * Negative on failure - * - * Programmer: James Laird - * Monday, November 6, 2006 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5SM_btree_retrieve(void *udata, const void *native) -{ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_btree_retrieve) - - /* Copy the B-tree's native message to the udata buffer */ - *(H5SM_sohm_t *)udata = *(const H5SM_sohm_t *)native; - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5SM_btree_retrieve */ - - -/*------------------------------------------------------------------------- * Function: H5SM_btree_debug * * Purpose: Print debugging information for a H5SM_sohm_t. diff --git a/src/H5Z.c b/src/H5Z.c index 1c58ab0..dc1ad80 100644 --- a/src/H5Z.c +++ b/src/H5Z.c @@ -497,7 +497,8 @@ done: static herr_t H5Z_prelude_callback(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type_t prelude_type) { - herr_t ret_value = SUCCEED; /* Return value */ + hid_t space_id = -1; /* ID for dataspace describing chunk */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5Z_prelude_callback) @@ -529,7 +530,6 @@ H5Z_prelude_callback(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type_t prelude_ty if(dcpl_pline.nused > 0) { hsize_t chunk_dims[H5O_LAYOUT_NDIMS]; /* Size of chunk dimensions */ H5S_t *space; /* Dataspace describing chunk */ - hid_t space_id; /* ID for dataspace describing chunk */ size_t u; /* Local index variable */ /* Create a data space for a chunk & set the extent */ @@ -572,10 +572,6 @@ H5Z_prelude_callback(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type_t prelude_ty /* Check return value */ if(status <= 0) { - /* We're leaving, so close dataspace */ - if(H5I_dec_ref(space_id, FALSE) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTRELEASE, FAIL, "unable to close dataspace") - /* Indicate filter can't apply to this combination of parameters */ if(status == 0) HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "filter parameters not appropriate") @@ -590,14 +586,9 @@ H5Z_prelude_callback(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type_t prelude_ty /* Check if there is a "set local" callback */ if(fclass->set_local) { /* Make callback to filter's "set local" function */ - if((fclass->set_local)(dcpl_id, type_id, space_id)<0) { - /* We're leaving, so close dataspace */ - if(H5I_dec_ref(space_id, FALSE)<0) - HGOTO_ERROR (H5E_PLINE, H5E_CANTRELEASE, FAIL, "unable to close dataspace") - + if((fclass->set_local)(dcpl_id, type_id, space_id) < 0) /* Indicate error during filter callback */ HGOTO_ERROR(H5E_PLINE, H5E_SETLOCAL, FAIL, "error during user callback") - } /* end if */ } /* end if */ break; @@ -606,15 +597,14 @@ H5Z_prelude_callback(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type_t prelude_ty } /* end switch */ } /* end else */ } /* end for */ - - /* Close dataspace */ - if(H5I_dec_ref(space_id, FALSE) < 0) - HGOTO_ERROR (H5E_PLINE, H5E_CANTRELEASE, FAIL, "unable to close dataspace") } /* end if */ } /* end if */ } /* end if */ done: + if(space_id > 0 && H5I_dec_ref(space_id, FALSE) < 0) + HDONE_ERROR(H5E_PLINE, H5E_CANTRELEASE, FAIL, "unable to close dataspace") + FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_prelude_callback() */ diff --git a/src/H5public.h b/src/H5public.h index fddb903..61698d7 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -71,10 +71,10 @@ extern "C" { /* Version numbers */ #define H5_VERS_MAJOR 1 /* For major interface/format changes */ #define H5_VERS_MINOR 9 /* For minor interface/format changes */ -#define H5_VERS_RELEASE 45 /* For tweaks, bug-fixes, or development */ +#define H5_VERS_RELEASE 46 /* For tweaks, bug-fixes, or development */ #define H5_VERS_SUBRELEASE "FA_a3" /* For pre-releases like snap0 */ /* Empty string for real releases. */ -#define H5_VERS_INFO "HDF5 library version: 1.9.45-FA_a3" /* Full version string */ +#define H5_VERS_INFO "HDF5 library version: 1.9.46-FA_a3" /* Full version string */ #define H5check() H5check_version(H5_VERS_MAJOR,H5_VERS_MINOR, \ H5_VERS_RELEASE) diff --git a/src/Makefile.in b/src/Makefile.in index 96bd804..9c3cc5f 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -433,7 +433,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 35 +LT_VERS_REVISION = 36 LT_VERS_AGE = 0 H5detect_CFLAGS = -g diff --git a/test/testhdf5.h b/test/testhdf5.h index 86333d3..f2a820f 100644 --- a/test/testhdf5.h +++ b/test/testhdf5.h @@ -81,6 +81,20 @@ } \ } while(0) +/* Used to make certain a (non-'long' type's) return value _is_ a value */ +#define VERIFY_TYPE(_x, _val, _type, _format, where) do { \ + _type __x = (_type)_x, __val = (_type)_val; \ + if(GetTestVerbosity() >= VERBO_HI) { \ + print_func(" Call to routine: %15s at line %4d in %s had value " \ + _format " \n", (where), (int)__LINE__, __FILE__, __x); \ + } \ + if((__x) != (__val)) { \ + TestErrPrintf("*** UNEXPECTED VALUE from %s should be " _format ", but is " _format " at line %4d " \ + "in %s\n", (where), __val, __x, (int)__LINE__, __FILE__); \ + H5Eprint2(H5E_DEFAULT, stdout); \ + } \ +} while(0) + /* Used to make certain a string return value _is_ a value */ #define VERIFY_STR(x, val, where) do { \ if (GetTestVerbosity()>=VERBO_HI) { \ diff --git a/test/tfile.c b/test/tfile.c index 518138c..b0a84b6 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -35,6 +35,14 @@ #define H5F_TESTING #include "H5Fpkg.h" /* File access */ +#define BAD_USERBLOCK_SIZE1 (hsize_t)1 +#define BAD_USERBLOCK_SIZE2 (hsize_t)2 +#define BAD_USERBLOCK_SIZE3 (hsize_t)3 +#define BAD_USERBLOCK_SIZE4 (hsize_t)64 +#define BAD_USERBLOCK_SIZE5 (hsize_t)511 +#define BAD_USERBLOCK_SIZE6 (hsize_t)513 +#define BAD_USERBLOCK_SIZE7 (hsize_t)6144 + #define F1_USERBLOCK_SIZE (hsize_t)0 #define F1_OFFSET_SIZE sizeof(haddr_t) #define F1_LENGTH_SIZE sizeof(hsize_t) @@ -208,6 +216,36 @@ test_file_create(void) tmpl1 = H5Pcreate(H5P_FILE_CREATE); CHECK(tmpl1, FAIL, "H5Pcreate"); + /* Try setting some bad userblock sizes */ + H5E_BEGIN_TRY { + ret = H5Pset_userblock(tmpl1, BAD_USERBLOCK_SIZE1); + } H5E_END_TRY; + VERIFY(ret, FAIL, "H5Pset_userblock"); + H5E_BEGIN_TRY { + ret = H5Pset_userblock(tmpl1, BAD_USERBLOCK_SIZE2); + } H5E_END_TRY; + VERIFY(ret, FAIL, "H5Pset_userblock"); + H5E_BEGIN_TRY { + ret = H5Pset_userblock(tmpl1, BAD_USERBLOCK_SIZE3); + } H5E_END_TRY; + VERIFY(ret, FAIL, "H5Pset_userblock"); + H5E_BEGIN_TRY { + ret = H5Pset_userblock(tmpl1, BAD_USERBLOCK_SIZE4); + } H5E_END_TRY; + VERIFY(ret, FAIL, "H5Pset_userblock"); + H5E_BEGIN_TRY { + ret = H5Pset_userblock(tmpl1, BAD_USERBLOCK_SIZE5); + } H5E_END_TRY; + VERIFY(ret, FAIL, "H5Pset_userblock"); + H5E_BEGIN_TRY { + ret = H5Pset_userblock(tmpl1, BAD_USERBLOCK_SIZE6); + } H5E_END_TRY; + VERIFY(ret, FAIL, "H5Pset_userblock"); + H5E_BEGIN_TRY { + ret = H5Pset_userblock(tmpl1, BAD_USERBLOCK_SIZE7); + } H5E_END_TRY; + VERIFY(ret, FAIL, "H5Pset_userblock"); + /* Set the new file-creation parameters */ ret = H5Pset_userblock(tmpl1, F2_USERBLOCK_SIZE); CHECK(ret, FAIL, "H5Pset_userblock"); @@ -1949,7 +1987,7 @@ test_userblock_file_size(void) CHECK(ret, FAIL, "H5Fget_filesize"); /* Verify that the file sizes differ exactly by the userblock size */ - VERIFY(filesize2, filesize1 + USERBLOCK_SIZE, "H5Fget_filesize"); + VERIFY_TYPE((unsigned long long)filesize2, (unsigned long long)(filesize1 + USERBLOCK_SIZE), unsigned long long, "%llu", "H5Fget_filesize"); /* Close files */ ret = H5Fclose(file1_id); @@ -2035,7 +2073,18 @@ test_cached_stab_info(void) ** mamcgree@hdfgroup.org ** June 29, 2009 ** +** Modification: Raymond Lu +** Skip this function for OpenVMS. +** 17 September 2009 *****************************************************************/ +#ifdef H5_VMS +static void +test_rw_noupdate(void) +{ + /* Output message about test being performed */ + MESSAGE(1, ("Testing to verify that nothing is written if nothing is changed. This test is skipped on OpenVMS because the modification time from stat is the same as the last access time.\n")); +} /* end test_rw_noupdate() */ +#else static void test_rw_noupdate(void) { @@ -2076,6 +2125,357 @@ test_rw_noupdate(void) ret = (diff > 0.0); VERIFY(ret, 0, "Timestamp"); } /* end test_rw_noupdate() */ +#endif + +/**************************************************************** +** +** test_userblock_alignment_helper1(): helper routine for +** test_userblock_alignment() test, to handle common testing +** +** Programmer: Quincey Koziol +** koziol@hdfgroup.org +** Septmber 10, 2009 +** +*****************************************************************/ +static int +test_userblock_alignment_helper1(hid_t fcpl, hid_t fapl) +{ + hid_t fid; /* File ID */ + int curr_num_errs = GetTestNumErrs(); /* Retrieve the current # of errors */ + herr_t ret; /* Generic return value */ + + /* Create a file with FAPL & FCPL */ + fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, fcpl, fapl); + CHECK(fid, FAIL, "H5Fcreate"); + + /* Only proceed further if file ID is OK */ + if(fid > 0) { + hid_t gid; /* Group ID */ + hid_t sid; /* Dataspace ID */ + hid_t did; /* Dataset ID */ + int val = 2; /* Dataset value */ + + /* Create a group */ + gid = H5Gcreate2(fid, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(gid, FAIL, "H5Gcreate2"); + + /* Create a dataset */ + sid = H5Screate(H5S_SCALAR); + CHECK(sid, FAIL, "H5Screate"); + did = H5Dcreate2(gid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(did, FAIL, "H5Dcreate2"); + + /* Close dataspace */ + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); + + /* Write value to dataset */ + ret = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &val); + CHECK(ret, FAIL, "H5Dwrite"); + + /* Close dataset */ + ret = H5Dclose(did); + CHECK(ret, FAIL, "H5Dclose"); + + /* Close group */ + ret = H5Gclose(gid); + CHECK(ret, FAIL, "H5Gclose"); + + /* Close file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + } /* end if */ + + return((GetTestNumErrs() == curr_num_errs) ? 0 : -1); +} /* end test_userblock_alignment_helper1() */ + +/**************************************************************** +** +** test_userblock_alignment_helper2(): helper routine for +** test_userblock_alignment() test, to handle common testing +** +** Programmer: Quincey Koziol +** koziol@hdfgroup.org +** Septmber 10, 2009 +** +*****************************************************************/ +static int +test_userblock_alignment_helper2(hid_t fapl, hbool_t open_rw) +{ + hid_t fid; /* File ID */ + int curr_num_errs = GetTestNumErrs(); /* Retrieve the current # of errors */ + herr_t ret; /* Generic return value */ + + /* Re-open file */ + fid = H5Fopen(FILE1, (open_rw ? H5F_ACC_RDWR : H5F_ACC_RDONLY), fapl); + CHECK(fid, FAIL, "H5Fopen"); + + /* Only proceed further if file ID is OK */ + if(fid > 0) { + hid_t gid; /* Group ID */ + hid_t did; /* Dataset ID */ + int val = -1; /* Dataset value */ + + /* Open group */ + gid = H5Gopen2(fid, "group1", H5P_DEFAULT); + CHECK(gid, FAIL, "H5Gopen2"); + + /* Open dataset */ + did = H5Dopen2(gid, "dataset", H5P_DEFAULT); + CHECK(did, FAIL, "H5Dopen2"); + + /* Read value from dataset */ + ret = H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &val); + CHECK(ret, FAIL, "H5Dread"); + VERIFY(val, 2, "H5Dread"); + + /* Close dataset */ + ret = H5Dclose(did); + CHECK(ret, FAIL, "H5Dclose"); + + /* Only create new objects if file is open R/W */ + if(open_rw) { + hid_t gid2; /* Group ID */ + + /* Create a new group */ + gid2 = H5Gcreate2(gid, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(gid, FAIL, "H5Gcreate2"); + + /* Close new group */ + ret = H5Gclose(gid2); + CHECK(ret, FAIL, "H5Gclose"); + } /* end if */ + + /* Close group */ + ret = H5Gclose(gid); + CHECK(ret, FAIL, "H5Gclose"); + + /* Close file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + } /* end if */ + + return((GetTestNumErrs() == curr_num_errs) ? 0 : -1); +} /* end test_userblock_alignment_helper2() */ + +/**************************************************************** +** +** test_userblock_alignment(): low-level file test routine. +** This test checks to ensure that files with both a userblock and a +** object [allocation] alignment size set interact properly. +** +** Programmer: Quincey Koziol +** koziol@hdfgroup.org +** Septmber 8, 2009 +** +*****************************************************************/ +static void +test_userblock_alignment(void) +{ + hid_t fid; /* File ID */ + hid_t fcpl; /* File creation property list ID */ + hid_t fapl; /* File access property list ID */ + herr_t ret; /* Generic return value */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing that non-zero userblocks and object alignment interact correctly.\n")); + + /* Case 1: + * Userblock size = 0, alignment != 0 + * Outcome: + * Should succeed + */ + /* Create file creation property list with user block */ + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, FAIL, "H5Pcreate"); + ret = H5Pset_userblock(fcpl, (hsize_t)0); + CHECK(ret, FAIL, "H5Pset_userblock"); + + /* Create file access property list with alignment */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)3); + CHECK(ret, FAIL, "H5Pset_alignment"); + + /* Call helper routines to perform file manipulations */ + ret = test_userblock_alignment_helper1(fcpl, fapl); + CHECK(ret, FAIL, "test_userblock_alignment_helper1"); + ret = test_userblock_alignment_helper2(fapl, TRUE); + CHECK(ret, FAIL, "test_userblock_alignment_helper2"); + + /* Release property lists */ + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); + ret = H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); + + + /* Case 2: + * Userblock size = 512, alignment = 16 + * (userblock is integral mult. of alignment) + * Outcome: + * Should succeed + */ + /* Create file creation property list with user block */ + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, FAIL, "H5Pcreate"); + ret = H5Pset_userblock(fcpl, (hsize_t)512); + CHECK(ret, FAIL, "H5Pset_userblock"); + + /* Create file access property list with alignment */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)16); + CHECK(ret, FAIL, "H5Pset_alignment"); + + /* Call helper routines to perform file manipulations */ + ret = test_userblock_alignment_helper1(fcpl, fapl); + CHECK(ret, FAIL, "test_userblock_alignment_helper1"); + ret = test_userblock_alignment_helper2(fapl, TRUE); + CHECK(ret, FAIL, "test_userblock_alignment_helper2"); + + /* Release property lists */ + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); + ret = H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); + + + /* Case 3: + * Userblock size = 512, alignment = 512 + * (userblock is equal to alignment) + * Outcome: + * Should succeed + */ + /* Create file creation property list with user block */ + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, FAIL, "H5Pcreate"); + ret = H5Pset_userblock(fcpl, (hsize_t)512); + CHECK(ret, FAIL, "H5Pset_userblock"); + + /* Create file access property list with alignment */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)512); + CHECK(ret, FAIL, "H5Pset_alignment"); + + /* Call helper routines to perform file manipulations */ + ret = test_userblock_alignment_helper1(fcpl, fapl); + CHECK(ret, FAIL, "test_userblock_alignment_helper1"); + ret = test_userblock_alignment_helper2(fapl, TRUE); + CHECK(ret, FAIL, "test_userblock_alignment_helper2"); + + /* Release property lists */ + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); + ret = H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); + + + /* Case 4: + * Userblock size = 512, alignment = 3 + * (userblock & alignment each individually valid, but userblock is + * non-integral multiple of alignment) + * Outcome: + * Should fail at file creation + */ + /* Create file creation property list with user block */ + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, FAIL, "H5Pcreate"); + ret = H5Pset_userblock(fcpl, (hsize_t)512); + CHECK(ret, FAIL, "H5Pset_userblock"); + + /* Create file access property list with alignment */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)3); + CHECK(ret, FAIL, "H5Pset_alignment"); + + /* Create a file with FAPL & FCPL */ + H5E_BEGIN_TRY { + fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, fcpl, fapl); + } H5E_END_TRY; + VERIFY(fid, FAIL, "H5Fcreate"); + + /* Release property lists */ + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); + ret = H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); + + + /* Case 5: + * Userblock size = 512, alignment = 1024 + * (userblock & alignment each individually valid, but userblock is + * less than alignment) + * Outcome: + * Should fail at file creation + */ + /* Create file creation property list with user block */ + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, FAIL, "H5Pcreate"); + ret = H5Pset_userblock(fcpl, (hsize_t)512); + CHECK(ret, FAIL, "H5Pset_userblock"); + + /* Create file access property list with alignment */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)1024); + CHECK(ret, FAIL, "H5Pset_alignment"); + + /* Create a file with FAPL & FCPL */ + H5E_BEGIN_TRY { + fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, fcpl, fapl); + } H5E_END_TRY; + VERIFY(fid, FAIL, "H5Fcreate"); + + /* Release property lists */ + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); + ret = H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); + + + /* Case 6: + * File created with: + * Userblock size = 512, alignment = 512 + * File re-opened for read-only & read-write access with: + * Userblock size = 512, alignment = 1024 + * Outcome: + * Should succeed + */ + /* Create file creation property list with user block */ + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, FAIL, "H5Pcreate"); + ret = H5Pset_userblock(fcpl, (hsize_t)512); + CHECK(ret, FAIL, "H5Pset_userblock"); + + /* Create file access property list with alignment */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)512); + CHECK(ret, FAIL, "H5Pset_alignment"); + + /* Call helper routines to perform file manipulations */ + ret = test_userblock_alignment_helper1(fcpl, fapl); + CHECK(ret, FAIL, "test_userblock_alignment_helper1"); + + /* Change alignment in FAPL */ + ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)1024); + CHECK(ret, FAIL, "H5Pset_alignment"); + + /* Call helper routines to perform file manipulations */ + ret = test_userblock_alignment_helper2(fapl, FALSE); + CHECK(ret, FAIL, "test_userblock_alignment_helper2"); + ret = test_userblock_alignment_helper2(fapl, TRUE); + CHECK(ret, FAIL, "test_userblock_alignment_helper2"); + + /* Release property lists */ + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); + ret = H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); +} /* end test_userblock_alignment() */ /**************************************************************** ** @@ -2307,6 +2707,7 @@ test_file(void) test_userblock_file_size(); /* Tests that files created with a userblock have the correct size */ test_cached_stab_info(); /* Tests that files are created with cached stab info in the superblock */ test_rw_noupdate(); /* Test to ensure that RW permissions don't write the file unless dirtied */ + test_userblock_alignment(); /* Tests that files created with a userblock and alignment interact properly */ test_swmr_write(); /* Tests for SWMR write access flag */ test_swmr_read(); /* Tests for SWMR read access flag */ } /* test_file() */ diff --git a/tools/h5diff/h5diff_common.c b/tools/h5diff/h5diff_common.c index 8e7b181..3403935 100644 --- a/tools/h5diff/h5diff_common.c +++ b/tools/h5diff/h5diff_common.c @@ -43,6 +43,7 @@ static struct long_options l_opts[] = { { "relative", require_arg, 'p' }, { "nan", no_arg, 'N' }, { "compare", no_arg, 'c' }, + { "use-system-epsilon", no_arg, 'e' }, { NULL, 0, '\0' } }; @@ -109,6 +110,11 @@ void parse_command_line(int argc, h5diff_exit(EXIT_FAILURE); } options->delta = atof( opt_arg ); + + /* -d 0 is the same as default */ + if (options->delta == 0) + options->d=0; + break; case 'p': @@ -121,6 +127,11 @@ void parse_command_line(int argc, h5diff_exit(EXIT_FAILURE); } options->percent = atof( opt_arg ); + + /* -p 0 is the same as default */ + if (options->percent == 0) + options->p = 0; + break; case 'n': @@ -142,9 +153,16 @@ void parse_command_line(int argc, case 'c': options->m_list_not_cmp = 1; break; + case 'e': + options->use_system_epsilon = 1; + break; } } + /* if use system epsilon, unset -p and -d option */ + if (options->use_system_epsilon) + options->d = options->p = 0; + /* check for file names to be processed */ if (argc <= opt_ind || argv[ opt_ind + 1 ] == NULL) { @@ -277,7 +295,7 @@ check_p_input( const char *str ) return -1; x=atof(str); - if (x<=0) + if (x<0) return -1; return 1; @@ -311,7 +329,7 @@ check_d_input( const char *str ) return -1; x=atof(str); - if (x <=0) + if (x <0) return -1; return 1; @@ -344,18 +362,18 @@ void usage(void) printf(" -q, --quiet Quiet mode. Do not do output\n"); printf(" -c, --compare List objects that are not comparable\n"); printf(" -N, --nan Avoid NaNs detection\n"); - - printf(" -n C, --count=C Print differences up to C number\n"); - printf(" -d D, --delta=D Print difference when greater than limit D\n"); - printf(" -p R, --relative=R Print difference when greater than relative limit R\n"); - - - printf("\n"); - - printf(" C - is a positive integer\n"); - printf(" D - is a positive number. Compare criteria is |a - b| > D\n"); - printf(" R - is a positive number. Compare criteria is |(b-a)/a| > R\n"); - + printf(" -n C, --count=C Print differences up to C number, C is a positive integer.\n"); + + printf(" -d D, --delta=D Print difference if (|a-b| > D), D is a positive number.\n"); + printf(" -p R, --relative=R Print difference if (|(a-b)/b| > R), R is a positive number.\n"); + printf(" --use-system-epsilon Print difference if (|a-b| > EPSILON),\n"); + printf(" where EPSILON (FLT_EPSILON or FLT_EPSILON) is the system epsilon value. \n"); + printf(" If the system epsilon is not defined, use the value below:\n"); + printf(" FLT_EPSILON = 1.19209E-07 for float\n"); + printf(" DBL_EPSILON = 2.22045E-16 for double\n"); + + printf(" -d, -p, and --use-system-epsilon options are used for comparing floating point values.\n"); + printf(" By default, strict equality is used. Use -p or -d to set specific tolerance.\n"); printf("\n"); printf(" Modes of output:\n"); diff --git a/tools/h5diff/testfiles/h5diff_10.txt b/tools/h5diff/testfiles/h5diff_10.txt index 38246d9..4788a79 100644 --- a/tools/h5diff/testfiles/h5diff_10.txt +++ b/tools/h5diff/testfiles/h5diff_10.txt @@ -11,13 +11,16 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[obj2]] -q, --quiet Quiet mode. Do not do output -c, --compare List objects that are not comparable -N, --nan Avoid NaNs detection - -n C, --count=C Print differences up to C number - -d D, --delta=D Print difference when greater than limit D - -p R, --relative=R Print difference when greater than relative limit R - - C - is a positive integer - D - is a positive number. Compare criteria is |a - b| > D - R - is a positive number. Compare criteria is |(b-a)/a| > R + -n C, --count=C Print differences up to C number, C is a positive integer. + -d D, --delta=D Print difference if (|a-b| > D), D is a positive number. + -p R, --relative=R Print difference if (|(a-b)/b| > R), R is a positive number. + --use-system-epsilon Print difference if (|a-b| > EPSILON), + where EPSILON (FLT_EPSILON or FLT_EPSILON) is the system epsilon value. + If the system epsilon is not defined, use the value below: + FLT_EPSILON = 1.19209E-07 for float + DBL_EPSILON = 2.22045E-16 for double + -d, -p, and --use-system-epsilon options are used for comparing floating point values. + By default, strict equality is used. Use -p or -d to set specific tolerance. Modes of output: diff --git a/tools/h5diff/testfiles/h5diff_600.txt b/tools/h5diff/testfiles/h5diff_600.txt index 17af208..82c5240 100644 --- a/tools/h5diff/testfiles/h5diff_600.txt +++ b/tools/h5diff/testfiles/h5diff_600.txt @@ -11,13 +11,16 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[obj2]] -q, --quiet Quiet mode. Do not do output -c, --compare List objects that are not comparable -N, --nan Avoid NaNs detection - -n C, --count=C Print differences up to C number - -d D, --delta=D Print difference when greater than limit D - -p R, --relative=R Print difference when greater than relative limit R - - C - is a positive integer - D - is a positive number. Compare criteria is |a - b| > D - R - is a positive number. Compare criteria is |(b-a)/a| > R + -n C, --count=C Print differences up to C number, C is a positive integer. + -d D, --delta=D Print difference if (|a-b| > D), D is a positive number. + -p R, --relative=R Print difference if (|(a-b)/b| > R), R is a positive number. + --use-system-epsilon Print difference if (|a-b| > EPSILON), + where EPSILON (FLT_EPSILON or FLT_EPSILON) is the system epsilon value. + If the system epsilon is not defined, use the value below: + FLT_EPSILON = 1.19209E-07 for float + DBL_EPSILON = 2.22045E-16 for double + -d, -p, and --use-system-epsilon options are used for comparing floating point values. + By default, strict equality is used. Use -p or -d to set specific tolerance. Modes of output: diff --git a/tools/h5diff/testfiles/h5diff_603.txt b/tools/h5diff/testfiles/h5diff_603.txt index 30fe246..e115114 100644 --- a/tools/h5diff/testfiles/h5diff_603.txt +++ b/tools/h5diff/testfiles/h5diff_603.txt @@ -12,13 +12,16 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[obj2]] -q, --quiet Quiet mode. Do not do output -c, --compare List objects that are not comparable -N, --nan Avoid NaNs detection - -n C, --count=C Print differences up to C number - -d D, --delta=D Print difference when greater than limit D - -p R, --relative=R Print difference when greater than relative limit R - - C - is a positive integer - D - is a positive number. Compare criteria is |a - b| > D - R - is a positive number. Compare criteria is |(b-a)/a| > R + -n C, --count=C Print differences up to C number, C is a positive integer. + -d D, --delta=D Print difference if (|a-b| > D), D is a positive number. + -p R, --relative=R Print difference if (|(a-b)/b| > R), R is a positive number. + --use-system-epsilon Print difference if (|a-b| > EPSILON), + where EPSILON (FLT_EPSILON or FLT_EPSILON) is the system epsilon value. + If the system epsilon is not defined, use the value below: + FLT_EPSILON = 1.19209E-07 for float + DBL_EPSILON = 2.22045E-16 for double + -d, -p, and --use-system-epsilon options are used for comparing floating point values. + By default, strict equality is used. Use -p or -d to set specific tolerance. Modes of output: diff --git a/tools/h5diff/testfiles/h5diff_604.txt b/tools/h5diff/testfiles/h5diff_604.txt index 9357b26..554f2ed 100644 --- a/tools/h5diff/testfiles/h5diff_604.txt +++ b/tools/h5diff/testfiles/h5diff_604.txt @@ -1,63 +1,2 @@ -<-d 0> is not a valid option -usage: h5diff [OPTIONS] file1 file2 [obj1[obj2]] - file1 File name of the first HDF5 file - file2 File name of the second HDF5 file - [obj1] Name of an HDF5 object, in absolute path - [obj2] Name of an HDF5 object, in absolute path - OPTIONS - -h, --help Print a usage message and exit - -V, --version Print version number and exit - -r, --report Report mode. Print differences - -v, --verbose Verbose mode. Print differences, list of objects - -q, --quiet Quiet mode. Do not do output - -c, --compare List objects that are not comparable - -N, --nan Avoid NaNs detection - -n C, --count=C Print differences up to C number - -d D, --delta=D Print difference when greater than limit D - -p R, --relative=R Print difference when greater than relative limit R - - C - is a positive integer - D - is a positive number. Compare criteria is |a - b| > D - R - is a positive number. Compare criteria is |(b-a)/a| > R - - Modes of output: - - Default mode: print the number of differences found and where they occured - -r Report mode: print the above plus the differences - -v Verbose mode: print the above plus a list of objects and warnings - -q Quiet mode: do not print output - - Compare criteria - - If no objects [obj1[obj2]] are specified, h5diff only compares objects - with the same absolute path in both files - - The compare criteria is: - 1) datasets: numerical array differences 2) groups: name string difference - 3) datatypes: the return value of H5Tequal 4) links: name string difference - of the linked value - - Return exit code: - - 1 if differences found, 0 if no differences, 2 if error - - Examples of use: - - 1) h5diff file1 file2 /g1/dset1 /g1/dset2 - - Compares object '/g1/dset1' in file1 with '/g1/dset2' in file2 - - 2) h5diff file1 file2 /g1/dset1 - - Compares object '/g1/dset1' in both files - - 3) h5diff file1 file2 - - Compares all objects in both files - - Note) file1 and file2 can be the same file. Use - - h5diff file1 file1 /g1/dset1 /g1/dset2 - - to compare '/g1/dset1' and '/g1/dset2' in the same file - +dataset: and +6 differences found diff --git a/tools/h5diff/testfiles/h5diff_605.txt b/tools/h5diff/testfiles/h5diff_605.txt index 1c99713..554f2ed 100644 --- a/tools/h5diff/testfiles/h5diff_605.txt +++ b/tools/h5diff/testfiles/h5diff_605.txt @@ -1,63 +1,2 @@ -<-d u> is not a valid option -usage: h5diff [OPTIONS] file1 file2 [obj1[obj2]] - file1 File name of the first HDF5 file - file2 File name of the second HDF5 file - [obj1] Name of an HDF5 object, in absolute path - [obj2] Name of an HDF5 object, in absolute path - OPTIONS - -h, --help Print a usage message and exit - -V, --version Print version number and exit - -r, --report Report mode. Print differences - -v, --verbose Verbose mode. Print differences, list of objects - -q, --quiet Quiet mode. Do not do output - -c, --compare List objects that are not comparable - -N, --nan Avoid NaNs detection - -n C, --count=C Print differences up to C number - -d D, --delta=D Print difference when greater than limit D - -p R, --relative=R Print difference when greater than relative limit R - - C - is a positive integer - D - is a positive number. Compare criteria is |a - b| > D - R - is a positive number. Compare criteria is |(b-a)/a| > R - - Modes of output: - - Default mode: print the number of differences found and where they occured - -r Report mode: print the above plus the differences - -v Verbose mode: print the above plus a list of objects and warnings - -q Quiet mode: do not print output - - Compare criteria - - If no objects [obj1[obj2]] are specified, h5diff only compares objects - with the same absolute path in both files - - The compare criteria is: - 1) datasets: numerical array differences 2) groups: name string difference - 3) datatypes: the return value of H5Tequal 4) links: name string difference - of the linked value - - Return exit code: - - 1 if differences found, 0 if no differences, 2 if error - - Examples of use: - - 1) h5diff file1 file2 /g1/dset1 /g1/dset2 - - Compares object '/g1/dset1' in file1 with '/g1/dset2' in file2 - - 2) h5diff file1 file2 /g1/dset1 - - Compares object '/g1/dset1' in both files - - 3) h5diff file1 file2 - - Compares all objects in both files - - Note) file1 and file2 can be the same file. Use - - h5diff file1 file1 /g1/dset1 /g1/dset2 - - to compare '/g1/dset1' and '/g1/dset2' in the same file - +dataset: and +6 differences found diff --git a/tools/h5diff/testfiles/h5diff_606.txt b/tools/h5diff/testfiles/h5diff_606.txt index 0567106..db361fd 100644 --- a/tools/h5diff/testfiles/h5diff_606.txt +++ b/tools/h5diff/testfiles/h5diff_606.txt @@ -12,13 +12,16 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[obj2]] -q, --quiet Quiet mode. Do not do output -c, --compare List objects that are not comparable -N, --nan Avoid NaNs detection - -n C, --count=C Print differences up to C number - -d D, --delta=D Print difference when greater than limit D - -p R, --relative=R Print difference when greater than relative limit R - - C - is a positive integer - D - is a positive number. Compare criteria is |a - b| > D - R - is a positive number. Compare criteria is |(b-a)/a| > R + -n C, --count=C Print differences up to C number, C is a positive integer. + -d D, --delta=D Print difference if (|a-b| > D), D is a positive number. + -p R, --relative=R Print difference if (|(a-b)/b| > R), R is a positive number. + --use-system-epsilon Print difference if (|a-b| > EPSILON), + where EPSILON (FLT_EPSILON or FLT_EPSILON) is the system epsilon value. + If the system epsilon is not defined, use the value below: + FLT_EPSILON = 1.19209E-07 for float + DBL_EPSILON = 2.22045E-16 for double + -d, -p, and --use-system-epsilon options are used for comparing floating point values. + By default, strict equality is used. Use -p or -d to set specific tolerance. Modes of output: diff --git a/tools/h5diff/testfiles/h5diff_612.txt b/tools/h5diff/testfiles/h5diff_612.txt index 505705b..bbd6b00 100644 --- a/tools/h5diff/testfiles/h5diff_612.txt +++ b/tools/h5diff/testfiles/h5diff_612.txt @@ -12,13 +12,16 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[obj2]] -q, --quiet Quiet mode. Do not do output -c, --compare List objects that are not comparable -N, --nan Avoid NaNs detection - -n C, --count=C Print differences up to C number - -d D, --delta=D Print difference when greater than limit D - -p R, --relative=R Print difference when greater than relative limit R - - C - is a positive integer - D - is a positive number. Compare criteria is |a - b| > D - R - is a positive number. Compare criteria is |(b-a)/a| > R + -n C, --count=C Print differences up to C number, C is a positive integer. + -d D, --delta=D Print difference if (|a-b| > D), D is a positive number. + -p R, --relative=R Print difference if (|(a-b)/b| > R), R is a positive number. + --use-system-epsilon Print difference if (|a-b| > EPSILON), + where EPSILON (FLT_EPSILON or FLT_EPSILON) is the system epsilon value. + If the system epsilon is not defined, use the value below: + FLT_EPSILON = 1.19209E-07 for float + DBL_EPSILON = 2.22045E-16 for double + -d, -p, and --use-system-epsilon options are used for comparing floating point values. + By default, strict equality is used. Use -p or -d to set specific tolerance. Modes of output: diff --git a/tools/h5diff/testfiles/h5diff_613.txt b/tools/h5diff/testfiles/h5diff_613.txt index 1a89746..554f2ed 100644 --- a/tools/h5diff/testfiles/h5diff_613.txt +++ b/tools/h5diff/testfiles/h5diff_613.txt @@ -1,63 +1,2 @@ -<-p 0> is not a valid option -usage: h5diff [OPTIONS] file1 file2 [obj1[obj2]] - file1 File name of the first HDF5 file - file2 File name of the second HDF5 file - [obj1] Name of an HDF5 object, in absolute path - [obj2] Name of an HDF5 object, in absolute path - OPTIONS - -h, --help Print a usage message and exit - -V, --version Print version number and exit - -r, --report Report mode. Print differences - -v, --verbose Verbose mode. Print differences, list of objects - -q, --quiet Quiet mode. Do not do output - -c, --compare List objects that are not comparable - -N, --nan Avoid NaNs detection - -n C, --count=C Print differences up to C number - -d D, --delta=D Print difference when greater than limit D - -p R, --relative=R Print difference when greater than relative limit R - - C - is a positive integer - D - is a positive number. Compare criteria is |a - b| > D - R - is a positive number. Compare criteria is |(b-a)/a| > R - - Modes of output: - - Default mode: print the number of differences found and where they occured - -r Report mode: print the above plus the differences - -v Verbose mode: print the above plus a list of objects and warnings - -q Quiet mode: do not print output - - Compare criteria - - If no objects [obj1[obj2]] are specified, h5diff only compares objects - with the same absolute path in both files - - The compare criteria is: - 1) datasets: numerical array differences 2) groups: name string difference - 3) datatypes: the return value of H5Tequal 4) links: name string difference - of the linked value - - Return exit code: - - 1 if differences found, 0 if no differences, 2 if error - - Examples of use: - - 1) h5diff file1 file2 /g1/dset1 /g1/dset2 - - Compares object '/g1/dset1' in file1 with '/g1/dset2' in file2 - - 2) h5diff file1 file2 /g1/dset1 - - Compares object '/g1/dset1' in both files - - 3) h5diff file1 file2 - - Compares all objects in both files - - Note) file1 and file2 can be the same file. Use - - h5diff file1 file1 /g1/dset1 /g1/dset2 - - to compare '/g1/dset1' and '/g1/dset2' in the same file - +dataset: and +6 differences found diff --git a/tools/h5diff/testfiles/h5diff_614.txt b/tools/h5diff/testfiles/h5diff_614.txt index ec12818..554f2ed 100644 --- a/tools/h5diff/testfiles/h5diff_614.txt +++ b/tools/h5diff/testfiles/h5diff_614.txt @@ -1,63 +1,2 @@ -<-p u> is not a valid option -usage: h5diff [OPTIONS] file1 file2 [obj1[obj2]] - file1 File name of the first HDF5 file - file2 File name of the second HDF5 file - [obj1] Name of an HDF5 object, in absolute path - [obj2] Name of an HDF5 object, in absolute path - OPTIONS - -h, --help Print a usage message and exit - -V, --version Print version number and exit - -r, --report Report mode. Print differences - -v, --verbose Verbose mode. Print differences, list of objects - -q, --quiet Quiet mode. Do not do output - -c, --compare List objects that are not comparable - -N, --nan Avoid NaNs detection - -n C, --count=C Print differences up to C number - -d D, --delta=D Print difference when greater than limit D - -p R, --relative=R Print difference when greater than relative limit R - - C - is a positive integer - D - is a positive number. Compare criteria is |a - b| > D - R - is a positive number. Compare criteria is |(b-a)/a| > R - - Modes of output: - - Default mode: print the number of differences found and where they occured - -r Report mode: print the above plus the differences - -v Verbose mode: print the above plus a list of objects and warnings - -q Quiet mode: do not print output - - Compare criteria - - If no objects [obj1[obj2]] are specified, h5diff only compares objects - with the same absolute path in both files - - The compare criteria is: - 1) datasets: numerical array differences 2) groups: name string difference - 3) datatypes: the return value of H5Tequal 4) links: name string difference - of the linked value - - Return exit code: - - 1 if differences found, 0 if no differences, 2 if error - - Examples of use: - - 1) h5diff file1 file2 /g1/dset1 /g1/dset2 - - Compares object '/g1/dset1' in file1 with '/g1/dset2' in file2 - - 2) h5diff file1 file2 /g1/dset1 - - Compares object '/g1/dset1' in both files - - 3) h5diff file1 file2 - - Compares all objects in both files - - Note) file1 and file2 can be the same file. Use - - h5diff file1 file1 /g1/dset1 /g1/dset2 - - to compare '/g1/dset1' and '/g1/dset2' in the same file - +dataset: and +6 differences found diff --git a/tools/h5diff/testfiles/h5diff_615.txt b/tools/h5diff/testfiles/h5diff_615.txt index 8528c0e..9c8f0c7 100644 --- a/tools/h5diff/testfiles/h5diff_615.txt +++ b/tools/h5diff/testfiles/h5diff_615.txt @@ -12,13 +12,16 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[obj2]] -q, --quiet Quiet mode. Do not do output -c, --compare List objects that are not comparable -N, --nan Avoid NaNs detection - -n C, --count=C Print differences up to C number - -d D, --delta=D Print difference when greater than limit D - -p R, --relative=R Print difference when greater than relative limit R - - C - is a positive integer - D - is a positive number. Compare criteria is |a - b| > D - R - is a positive number. Compare criteria is |(b-a)/a| > R + -n C, --count=C Print differences up to C number, C is a positive integer. + -d D, --delta=D Print difference if (|a-b| > D), D is a positive number. + -p R, --relative=R Print difference if (|(a-b)/b| > R), R is a positive number. + --use-system-epsilon Print difference if (|a-b| > EPSILON), + where EPSILON (FLT_EPSILON or FLT_EPSILON) is the system epsilon value. + If the system epsilon is not defined, use the value below: + FLT_EPSILON = 1.19209E-07 for float + DBL_EPSILON = 2.22045E-16 for double + -d, -p, and --use-system-epsilon options are used for comparing floating point values. + By default, strict equality is used. Use -p or -d to set specific tolerance. Modes of output: diff --git a/tools/h5diff/testfiles/h5diff_621.txt b/tools/h5diff/testfiles/h5diff_621.txt index 96d6c3f..79eebed 100644 --- a/tools/h5diff/testfiles/h5diff_621.txt +++ b/tools/h5diff/testfiles/h5diff_621.txt @@ -12,13 +12,16 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[obj2]] -q, --quiet Quiet mode. Do not do output -c, --compare List objects that are not comparable -N, --nan Avoid NaNs detection - -n C, --count=C Print differences up to C number - -d D, --delta=D Print difference when greater than limit D - -p R, --relative=R Print difference when greater than relative limit R - - C - is a positive integer - D - is a positive number. Compare criteria is |a - b| > D - R - is a positive number. Compare criteria is |(b-a)/a| > R + -n C, --count=C Print differences up to C number, C is a positive integer. + -d D, --delta=D Print difference if (|a-b| > D), D is a positive number. + -p R, --relative=R Print difference if (|(a-b)/b| > R), R is a positive number. + --use-system-epsilon Print difference if (|a-b| > EPSILON), + where EPSILON (FLT_EPSILON or FLT_EPSILON) is the system epsilon value. + If the system epsilon is not defined, use the value below: + FLT_EPSILON = 1.19209E-07 for float + DBL_EPSILON = 2.22045E-16 for double + -d, -p, and --use-system-epsilon options are used for comparing floating point values. + By default, strict equality is used. Use -p or -d to set specific tolerance. Modes of output: diff --git a/tools/h5diff/testfiles/h5diff_622.txt b/tools/h5diff/testfiles/h5diff_622.txt index 9dc3751..09de51d 100644 --- a/tools/h5diff/testfiles/h5diff_622.txt +++ b/tools/h5diff/testfiles/h5diff_622.txt @@ -12,13 +12,16 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[obj2]] -q, --quiet Quiet mode. Do not do output -c, --compare List objects that are not comparable -N, --nan Avoid NaNs detection - -n C, --count=C Print differences up to C number - -d D, --delta=D Print difference when greater than limit D - -p R, --relative=R Print difference when greater than relative limit R - - C - is a positive integer - D - is a positive number. Compare criteria is |a - b| > D - R - is a positive number. Compare criteria is |(b-a)/a| > R + -n C, --count=C Print differences up to C number, C is a positive integer. + -d D, --delta=D Print difference if (|a-b| > D), D is a positive number. + -p R, --relative=R Print difference if (|(a-b)/b| > R), R is a positive number. + --use-system-epsilon Print difference if (|a-b| > EPSILON), + where EPSILON (FLT_EPSILON or FLT_EPSILON) is the system epsilon value. + If the system epsilon is not defined, use the value below: + FLT_EPSILON = 1.19209E-07 for float + DBL_EPSILON = 2.22045E-16 for double + -d, -p, and --use-system-epsilon options are used for comparing floating point values. + By default, strict equality is used. Use -p or -d to set specific tolerance. Modes of output: diff --git a/tools/h5diff/testfiles/h5diff_623.txt b/tools/h5diff/testfiles/h5diff_623.txt index a02f5ea..dc60b94 100644 --- a/tools/h5diff/testfiles/h5diff_623.txt +++ b/tools/h5diff/testfiles/h5diff_623.txt @@ -12,13 +12,16 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[obj2]] -q, --quiet Quiet mode. Do not do output -c, --compare List objects that are not comparable -N, --nan Avoid NaNs detection - -n C, --count=C Print differences up to C number - -d D, --delta=D Print difference when greater than limit D - -p R, --relative=R Print difference when greater than relative limit R - - C - is a positive integer - D - is a positive number. Compare criteria is |a - b| > D - R - is a positive number. Compare criteria is |(b-a)/a| > R + -n C, --count=C Print differences up to C number, C is a positive integer. + -d D, --delta=D Print difference if (|a-b| > D), D is a positive number. + -p R, --relative=R Print difference if (|(a-b)/b| > R), R is a positive number. + --use-system-epsilon Print difference if (|a-b| > EPSILON), + where EPSILON (FLT_EPSILON or FLT_EPSILON) is the system epsilon value. + If the system epsilon is not defined, use the value below: + FLT_EPSILON = 1.19209E-07 for float + DBL_EPSILON = 2.22045E-16 for double + -d, -p, and --use-system-epsilon options are used for comparing floating point values. + By default, strict equality is used. Use -p or -d to set specific tolerance. Modes of output: diff --git a/tools/h5diff/testfiles/h5diff_624.txt b/tools/h5diff/testfiles/h5diff_624.txt index 396a007..016ab77 100644 --- a/tools/h5diff/testfiles/h5diff_624.txt +++ b/tools/h5diff/testfiles/h5diff_624.txt @@ -12,13 +12,16 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[obj2]] -q, --quiet Quiet mode. Do not do output -c, --compare List objects that are not comparable -N, --nan Avoid NaNs detection - -n C, --count=C Print differences up to C number - -d D, --delta=D Print difference when greater than limit D - -p R, --relative=R Print difference when greater than relative limit R - - C - is a positive integer - D - is a positive number. Compare criteria is |a - b| > D - R - is a positive number. Compare criteria is |(b-a)/a| > R + -n C, --count=C Print differences up to C number, C is a positive integer. + -d D, --delta=D Print difference if (|a-b| > D), D is a positive number. + -p R, --relative=R Print difference if (|(a-b)/b| > R), R is a positive number. + --use-system-epsilon Print difference if (|a-b| > EPSILON), + where EPSILON (FLT_EPSILON or FLT_EPSILON) is the system epsilon value. + If the system epsilon is not defined, use the value below: + FLT_EPSILON = 1.19209E-07 for float + DBL_EPSILON = 2.22045E-16 for double + -d, -p, and --use-system-epsilon options are used for comparing floating point values. + By default, strict equality is used. Use -p or -d to set specific tolerance. Modes of output: diff --git a/tools/h5diff/testh5diff.sh b/tools/h5diff/testh5diff.sh index 4167243..b8e743d 100755 --- a/tools/h5diff/testh5diff.sh +++ b/tools/h5diff/testh5diff.sh @@ -461,9 +461,9 @@ TOOLTEST h5diff_606.txt -d 0x1 $FILE1 $FILE2 g1/dset3 g1/dset4 TESTING $H5DIFF -d "1" $SRCFILE1 $SRCFILE2 g1/dset3 g1/dset4 TOOLTEST h5diff_607.txt -d "1" $FILE1 $FILE2 g1/dset3 g1/dset4 -# 6.8: repeated option -TESTING $H5DIFF -d 1 -d 2 $SRCFILE1 $SRCFILE2 g1/dset3 g1/dset4 -TOOLTEST h5diff_608.txt -d 1 -d 2 $FILE1 $FILE2 g1/dset3 g1/dset4 +# 6.8: use system epsilon +TESTING $H5DIFF --use-system-epsilon $SRCFILE1 $SRCFILE2 g1/dset3 g1/dset4 +TOOLTEST h5diff_608.txt --use-system-epsilon $FILE1 $FILE2 g1/dset3 g1/dset4 # 6.9: number larger than biggest difference TESTING $H5DIFF -d 200 $SRCFILE1 $SRCFILE2 g1/dset3 g1/dset4 diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index beacdbb..c74c9f1 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -81,7 +81,6 @@ static const char *fp_format = NULL; const char *outfname=NULL; - /* things to display or which are set via command line parameters */ static int display_all = TRUE; static int display_oid = FALSE; @@ -94,6 +93,7 @@ static int display_dcpl = FALSE; /*dcpl */ static int display_fi = FALSE; /*file index */ static int display_ai = TRUE; /*array index */ static int display_escape = FALSE; /*escape non printable characters */ +static int display_region = FALSE; /*print region reference data */ /* sort parameters */ static H5_index_t sort_by = H5_INDEX_NAME; /*sort_by [creation_order | name] */ @@ -388,7 +388,7 @@ struct handler_t { * parameters. The long-named ones can be partially spelled. When * adding more, make sure that they don't clash with each other. */ -static const char *s_opts = "hnpeyBHirVa:c:d:f:g:k:l:t:w:xD:uX:o:b*F:s:S:Aq:z:m:"; +static const char *s_opts = "hnpeyBHirVa:c:d:f:g:k:l:t:w:xD:uX:o:b*F:s:S:Aq:z:m:R"; static struct long_options l_opts[] = { { "help", no_arg, 'h' }, { "hel", no_arg, 'h' }, @@ -500,6 +500,7 @@ static struct long_options l_opts[] = { { "sort_by", require_arg, 'q' }, { "sort_order", require_arg, 'z' }, { "format", require_arg, 'm' }, + { "region", no_arg, 'R' }, { NULL, 0, '\0' } }; @@ -655,6 +656,7 @@ usage(const char *prog) fprintf(stdout, " -m T, --format=T Set the floating point output format\n"); fprintf(stdout, " -q Q, --sort_by=Q Sort groups and attributes by index Q\n"); fprintf(stdout, " -z Z, --sort_order=Z Sort groups and attributes by order Z\n"); + fprintf(stdout, " -R, --region Print dataset pointed by region references\n"); fprintf(stdout, " -x, --xml Output in XML using Schema\n"); fprintf(stdout, " -u, --use-dtd Output in XML using DTD\n"); fprintf(stdout, " -D U, --xml-dtd=U Use the DTD or schema at U\n"); @@ -665,14 +667,16 @@ usage(const char *prog) fprintf(stdout, " Subsetting is available by using the following options with a dataset\n"); fprintf(stdout, " attribute. Subsetting is done by selecting a hyperslab from the data.\n"); fprintf(stdout, " Thus, the options mirror those for performing a hyperslab selection.\n"); - fprintf(stdout, " The START and COUNT parameters are mandatory if you do subsetting.\n"); - fprintf(stdout, " The STRIDE and BLOCK parameters are optional and will default to 1 in\n"); - fprintf(stdout, " each dimension.\n"); + fprintf(stdout, " One of the START, COUNT, STRIDE, or BLOCK parameters are mandatory if you do subsetting.\n"); + fprintf(stdout, " The STRIDE, COUNT, and BLOCK parameters are optional and will default to 1 in\n"); + fprintf(stdout, " each dimension. START is optional and will default to 0 in each dimension.\n"); fprintf(stdout, "\n"); - fprintf(stdout, " -s L, --start=L Offset of start of subsetting selection\n"); - fprintf(stdout, " -S L, --stride=L Hyperslab stride\n"); - fprintf(stdout, " -c L, --count=L Number of blocks to include in selection\n"); - fprintf(stdout, " -k L, --block=L Size of block in hyperslab\n"); + fprintf(stdout, " -s START, --start=START Offset of start of subsetting selection\n"); + fprintf(stdout, " -S STRIDE, --stride=STRIDE Hyperslab stride\n"); + fprintf(stdout, " -c COUNT, --count=COUNT Number of blocks to include in selection\n"); + fprintf(stdout, " -k BLOCK, --block=BLOCK Size of block in hyperslab\n"); + fprintf(stdout, " START, COUNT, STRIDE, and BLOCK - is a list of integers the number of which are equal to the\n"); + fprintf(stdout, " number of dimensions in the dataspace being queried\n"); fprintf(stdout, "\n"); fprintf(stdout, " D - is the file driver to use in opening the file. Acceptable values\n"); fprintf(stdout, " are \"sec2\", \"family\", \"split\", \"multi\", \"direct\", and \"stream\". Without\n"); @@ -683,8 +687,6 @@ usage(const char *prog) fprintf(stdout, " P - is the full path from the root group to the object.\n"); fprintf(stdout, " N - is an integer greater than 1.\n"); fprintf(stdout, " T - is a string containing the floating point format, e.g '%%.3f'\n"); - fprintf(stdout, " L - is a list of integers the number of which are equal to the\n"); - fprintf(stdout, " number of dimensions in the dataspace being queried\n"); fprintf(stdout, " U - is a URI reference (as defined in [IETF RFC 2396],\n"); fprintf(stdout, " updated by [IETF RFC 2732])\n"); fprintf(stdout, " B - is the form of binary output: NATIVE for a memory type, FILE for the\n"); @@ -1189,6 +1191,18 @@ print_datatype(hid_t type,unsigned in_group) case H5T_REFERENCE: printf("H5T_REFERENCE"); + /* The BNF document states that the type of reference should be + * displayed after "H5T_REFERENCE". Therefore add the missing + * reference type if the region command line option is used. This + * reference type will not be displayed if the region option is not used. */ + if(display_region) { + if (H5Tequal(type, H5T_STD_REF_DSETREG)==TRUE) { + printf(" { H5T_STD_REF_DSETREG }"); + } + else { + printf(" { H5T_STD_REF_OBJECT }"); + } + } break; case H5T_ENUM: @@ -2391,13 +2405,29 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_index) outputformat->pindex=display_index; /* do not print indices for regions */ - if(obj_data == DATASET_DATA) - { + if(obj_data == DATASET_DATA) { hid_t f_type = H5Dget_type(obj_id); - if (H5Tequal(f_type, H5T_STD_REF_DSETREG)) - { - outputformat->pindex = 0; + if (H5Tequal(f_type, H5T_STD_REF_DSETREG)) { + /* For the region option, correct the display of indices */ + if (display_region) { + if (display_index) { + outputformat->pindex = 1; + outputformat->idx_fmt = "(%s): "; + outputformat->idx_n_fmt = HSIZE_T_FORMAT; + outputformat->idx_sep = ","; + outputformat->line_pre = "%s"; + } + else { + outputformat->pindex = 0; + outputformat->idx_fmt = ""; + outputformat->idx_n_fmt = ""; + outputformat->idx_sep = ""; + outputformat->line_pre = ""; + } + } + else + outputformat->pindex = 0; } H5Tclose(f_type); } @@ -2470,13 +2500,15 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_index) status = h5tools_dump_dset(stdout, outputformat, obj_id, -1, sset, depth); H5Tclose(f_type); - } else { + } + else { /* 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; - } else { + } + else { char string_prefix[64]; h5tool_format_t string_dataformat; @@ -3516,21 +3548,13 @@ handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *dis } if (!sset->count) { - hsize_t dims[H5S_MAX_RANK]; - herr_t status = H5Sget_simple_extent_dims(sid, dims, NULL); unsigned int i; - if (status == FAIL) { - error_msg(progname, "unable to get dataset dimensions\n"); - d_status = EXIT_FAILURE; - H5Sclose(sid); - return; - } sset->count = calloc(ndims, sizeof(hsize_t)); for (i = 0; i < ndims; i++) - sset->count[i] = dims[i] - sset->start[i]; + sset->count[i] = 1; } if (!sset->block) { @@ -3872,6 +3896,10 @@ parse_command_line(int argc, const char *argv[]) while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { parse_start: switch ((char)opt) { + case 'R': + display_region = TRUE; + region_output = TRUE; + break; case 'B': display_bb = TRUE; last_was_dset = FALSE; @@ -3981,74 +4009,61 @@ parse_start: break; case 'o': + if ( bin_output ) { + if (set_output_file(opt_arg, 1) < 0) { + usage(progname); + leave(EXIT_FAILURE); + } + } + else { + if (set_output_file(opt_arg, 0) < 0) { + usage(progname); + leave(EXIT_FAILURE); + } + } + + usingdasho = TRUE; + last_was_dset = FALSE; + outfname = opt_arg; + break; + + case 'b': + if ( opt_arg != NULL) { + if ( ( bin_form = set_binary_form(opt_arg)) < 0) { + /* failed to set binary form */ + usage(progname); + leave(EXIT_FAILURE); + } + } + bin_output = TRUE; + if (outfname!=NULL) { + if (set_output_file(outfname, 1) < 0) { + /* failed to set output file */ + usage(progname); + leave(EXIT_FAILURE); + } + + last_was_dset = FALSE; + } + break; - if ( bin_output ) - { - if (set_output_file(opt_arg, 1) < 0){ - usage(progname); - leave(EXIT_FAILURE); - } - } - else - { - if (set_output_file(opt_arg, 0) < 0){ - usage(progname); - leave(EXIT_FAILURE); - } - } - - usingdasho = TRUE; - last_was_dset = FALSE; - outfname = opt_arg; - break; - - case 'b': - - if ( opt_arg != NULL) - { - if ( ( bin_form = set_binary_form(opt_arg)) < 0) - { - /* failed to set binary form */ - usage(progname); - leave(EXIT_FAILURE); - } - } - bin_output = TRUE; - if (outfname!=NULL) - { - if (set_output_file(outfname, 1) < 0) - { - /* failed to set output file */ - usage(progname); - leave(EXIT_FAILURE); - } - - last_was_dset = FALSE; - } - - break; - - case 'q': - - if ( ( sort_by = set_sort_by(opt_arg)) < 0) - { - /* failed to set "sort by" form */ - usage(progname); - leave(EXIT_FAILURE); - } - - break; - - case 'z': - - if ( ( sort_order = set_sort_order(opt_arg)) < 0) - { - /* failed to set "sort order" form */ - usage(progname); - leave(EXIT_FAILURE); - } - - break; + case 'q': + if ( ( sort_by = set_sort_by(opt_arg)) < 0) { + /* failed to set "sort by" form */ + usage(progname); + leave(EXIT_FAILURE); + } + break; + + case 'z': + if ( ( sort_order = set_sort_order(opt_arg)) < 0) { + /* failed to set "sort order" form */ + usage(progname); + leave(EXIT_FAILURE); + } + break; + + break; /** begin XML parameters **/ case 'x': diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c index c0d5801..b8ed41d 100644 --- a/tools/h5dump/h5dumpgentest.c +++ b/tools/h5dump/h5dumpgentest.c @@ -92,6 +92,7 @@ #define FILE62 "textlinktar.h5" #define FILE63 "textlinkfar.h5" #define FILE64 "tarray8.h5" +#define FILE65 "tattrreg.h5" @@ -1852,6 +1853,126 @@ static void gent_datareg(void) free(drbuf); } +static void gent_attrreg(void) +{ + /*some code is taken from enum.c in the test dir */ + + hid_t fid1; /* HDF5 File IDs */ + hid_t dset1; /* Dataset ID */ + hid_t dset2; /* Dereferenced dataset ID */ + hid_t sid1; /* Dataspace ID #1 */ + hid_t sid2; /* Dataspace ID #2 */ + hid_t sid3; /* Dataspace ID #3 */ + hid_t attr1; /* Attribute ID */ + hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; + hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ + hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */ + hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ + hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ + hsize_t coord1[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */ + hdset_reg_ref_t *wbuf; /* buffer to write to disk */ + hdset_reg_ref_t *rbuf; /* buffer read from disk */ + uint8_t *dwbuf; /* Buffer for writing numeric data to disk */ + uint8_t *drbuf; /* Buffer for reading numeric data from disk */ + uint8_t *tu8; /* Temporary pointer to uint8 data */ + int i; /* counting variables */ + + /* Allocate write & read buffers */ + wbuf=calloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1); + rbuf=malloc(sizeof(hdset_reg_ref_t)*SPACE1_DIM1); + dwbuf=malloc(sizeof(uint8_t)*SPACE2_DIM1*SPACE2_DIM2); + drbuf=calloc(sizeof(uint8_t),SPACE2_DIM1*SPACE2_DIM2); + + /* Create file */ + fid1 = H5Fcreate(FILE65, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + + /* Create dataspace for datasets */ + sid2 = H5Screate_simple(SPACE2_RANK, dims2, NULL); + + /* Create a dataset */ + dset2 = H5Dcreate2(fid1, "Dataset2", H5T_STD_U8BE, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + + for(tu8 = dwbuf, i = 0; i < SPACE2_DIM1 * SPACE2_DIM2; i++) + *tu8++=i*3; + + /* Write selection to disk */ + H5Dwrite(dset2, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, dwbuf); + + /* Close Dataset */ + H5Dclose(dset2); + + /* + * Create dataset with a null dataspace to serve as the parent for + * the attribute. + */ + sid1 = H5Screate (H5S_NULL); + dset1 = H5Dcreate2 (fid1, "Dataset1", H5T_STD_I32LE, sid1, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT); + H5Sclose (sid1); + + /* Create references */ + + /* Select 6x6 hyperslab for first reference */ + start[0] = 2; start[1] = 2; + stride[0] = 1; stride[1] = 1; + count[0] = 6; count[1] = 6; + block[0] = 1; block[1] = 1; + H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block); + + H5Sget_select_npoints(sid2); + + /* Store first dataset region */ + H5Rcreate(&wbuf[0], fid1, "/Dataset2", H5R_DATASET_REGION, sid2); + + /* Select sequence of ten points for second reference */ + coord1[0][0]=6; coord1[0][1]=9; + coord1[1][0]=2; coord1[1][1]=2; + coord1[2][0]=8; coord1[2][1]=4; + coord1[3][0]=1; coord1[3][1]=6; + coord1[4][0]=2; coord1[4][1]=8; + coord1[5][0]=3; coord1[5][1]=2; + coord1[6][0]=0; coord1[6][1]=4; + coord1[7][0]=9; coord1[7][1]=0; + coord1[8][0]=7; coord1[8][1]=1; + coord1[9][0]=3; coord1[9][1]=3; + H5Sselect_elements(sid2,H5S_SELECT_SET,POINT1_NPOINTS,(hsize_t *)coord1); + + H5Sget_select_npoints(sid2); + + /* Store second dataset region */ + H5Rcreate(&wbuf[1],fid1,"/Dataset2",H5R_DATASET_REGION,sid2); + + /* Create dataspace for the attribute */ + sid3 = H5Screate_simple(SPACE1_RANK, dims1, NULL); + + /* Create the attribute and write the region references to it. */ + attr1 = H5Acreate2 (dset1, "Attribute1", H5T_STD_REF_DSETREG, sid3, H5P_DEFAULT, + H5P_DEFAULT); + H5Awrite (attr1, H5T_STD_REF_DSETREG, wbuf); + + /* Close attribute dataspace */ + H5Sclose(sid3); + + /* Close attribute */ + H5Aclose (attr1); + + /* Close Dataset */ + H5Dclose(dset1); + + /* Close uint8 dataset dataspace */ + H5Sclose(sid2); + + /* Close file */ + H5Fclose(fid1); + + /* Free memory buffers */ + free(wbuf); + free(rbuf); + free(dwbuf); + free(drbuf); +} + /*taken from Elena's compound test file*/ static void gent_nestcomp(void) { @@ -6351,6 +6472,7 @@ int main(void) gent_enum(); gent_objref(); gent_datareg(); + gent_attrreg(); gent_nestcomp(); gent_opaque(); gent_bitfields(); diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in index 5bf7f75..3ffff50 100644 --- a/tools/h5dump/testh5dump.sh.in +++ b/tools/h5dump/testh5dump.sh.in @@ -489,6 +489,9 @@ fi # test for dataset region references TOOLTEST tdatareg.ddl tdatareg.h5 +TOOLTEST tdataregR.ddl -R tdatareg.h5 +TOOLTEST tattrreg.ddl tattrreg.h5 +TOOLTEST tattrregR.ddl -R tattrreg.h5 # tests for group creation order # "1" tracked, "2" name, root tracked diff --git a/tools/lib/Makefile.am b/tools/lib/Makefile.am index c7e26e0..43ee863 100644 --- a/tools/lib/Makefile.am +++ b/tools/lib/Makefile.am @@ -31,7 +31,7 @@ libh5tools_la_SOURCES=h5tools.c h5tools_str.c h5tools_utils.c h5diff.c \ h5tools_filters.c h5tools_ref.c h5tools_type.c # Test program. Link using libhdf5 and libh5tools -TEST_PROG=talign +TEST_PROG= check_PROGRAMS=$(TEST_PROG) # Name libh5tools.la so that dependencies work out. Automake knows how diff --git a/tools/lib/Makefile.in b/tools/lib/Makefile.in index 0236c82..55785c7 100644 --- a/tools/lib/Makefile.in +++ b/tools/lib/Makefile.in @@ -72,11 +72,7 @@ am_libh5tools_la_OBJECTS = h5tools.lo h5tools_str.lo h5tools_utils.lo \ h5diff_util.lo h5trav.lo h5tools_filters.lo h5tools_ref.lo \ h5tools_type.lo libh5tools_la_OBJECTS = $(am_libh5tools_la_OBJECTS) -am__EXEEXT_1 = talign$(EXEEXT) -talign_SOURCES = talign.c -talign_OBJECTS = talign.$(OBJEXT) -talign_LDADD = $(LDADD) -talign_DEPENDENCIES = libh5tools.la $(LIBHDF5) +am__EXEEXT_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src depcomp = $(SHELL) $(top_srcdir)/bin/depcomp am__depfiles_maybe = depfiles @@ -90,8 +86,8 @@ CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ -SOURCES = $(libh5tools_la_SOURCES) talign.c -DIST_SOURCES = $(libh5tools_la_SOURCES) talign.c +SOURCES = $(libh5tools_la_SOURCES) +DIST_SOURCES = $(libh5tools_la_SOURCES) ETAGS = etags CTAGS = ctags am__tty_colors = \ @@ -359,7 +355,7 @@ libh5tools_la_SOURCES = h5tools.c h5tools_str.c h5tools_utils.c h5diff.c \ # Test program. Link using libhdf5 and libh5tools -TEST_PROG = talign +TEST_PROG = # Name libh5tools.la so that dependencies work out. Automake knows how # to build 'libh5tools.la', but not '../../tools/lib/libh5tools.la'. @@ -434,9 +430,6 @@ clean-checkPROGRAMS: list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list -talign$(EXEEXT): $(talign_OBJECTS) $(talign_DEPENDENCIES) - @rm -f talign$(EXEEXT) - $(LINK) $(talign_OBJECTS) $(talign_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -456,7 +449,6 @@ distclean-compile: @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@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/talign.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< diff --git a/tools/lib/h5diff.h b/tools/lib/h5diff.h index e0f2ad0..df264dd 100644 --- a/tools/lib/h5diff.h +++ b/tools/lib/h5diff.h @@ -25,21 +25,22 @@ */ 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 d; /* delta, absolute value to compare */ - double delta; /* delta value */ - int p; /* relative error to compare*/ - double percent; /* relative error value */ - int n; /* count, compare up to count */ - hsize_t count; /* count value */ - 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 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 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 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 */ } diff_opt_t; diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index 735ea70..77ee74a 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -74,9 +74,16 @@ #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" -/* values for FLT_EPSILON same as C Reference manual */ -#define H5DIFF_FLT_EPSILON .00001 -#define H5DIFF_DBL_EPSILON .000000001 +/* if system EPSILON is defined, use the system EPSILON; otherwise, use + constants that are close to most EPSILON values */ + +#ifndef FLT_EPSILON +#define FLT_EPSILON 1.19209E-07 +#endif + +#ifndef DBL_EPSILON +#define DBL_EPSILON 2.22045E-16 +#endif /*------------------------------------------------------------------------- @@ -5502,10 +5509,6 @@ error: static hbool_t equal_double(double value, double expected, diff_opt_t *options) { - int both_zero; - int is_zero; - - if ( options->do_nans ) { @@ -5535,22 +5538,15 @@ hbool_t equal_double(double value, double expected, diff_opt_t *options) } } - BOTH_ZERO(value,expected) - if (both_zero) - return TRUE; - - IS_ZERO(expected) - if (is_zero) - return(equal_double(expected,value,options)); - if (value == expected) return TRUE; - if ( ABS( (value-expected) / expected) < H5DIFF_DBL_EPSILON) - return TRUE; - else - return FALSE; + if (options->use_system_epsilon) { + if ( ABS( (value-expected) ) < DBL_EPSILON) + return TRUE; + } + return FALSE; } /*------------------------------------------------------------------------- @@ -5566,10 +5562,6 @@ hbool_t equal_double(double value, double expected, diff_opt_t *options) static hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *options) { - int both_zero; - int is_zero; - - if ( options->do_nans ) { @@ -5599,22 +5591,15 @@ hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *optio } } - BOTH_ZERO(value,expected) - if (both_zero) - return TRUE; - - IS_ZERO(expected) - if (is_zero) - return(equal_ldouble(expected,value,options)); - if (value == expected) return TRUE; - if ( ABS( (value-expected) / expected) < H5DIFF_DBL_EPSILON) - return TRUE; - else - return FALSE; + if (options->use_system_epsilon) { + if ( ABS( (value-expected) / expected) < DBL_EPSILON) + return TRUE; + } + return FALSE; } #endif /* #if H5_SIZEOF_LONG_DOUBLE !=0 */ @@ -5634,9 +5619,6 @@ hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *optio static hbool_t equal_float(float value, float expected, diff_opt_t *options) { - int both_zero; - int is_zero; - if ( options->do_nans ) { @@ -5666,21 +5648,15 @@ hbool_t equal_float(float value, float expected, diff_opt_t *options) } } - BOTH_ZERO(value,expected) - if (both_zero) - return TRUE; - - IS_ZERO(expected) - if (is_zero) - return(equal_float(expected,value,options)); - if (value == expected) return TRUE; - if ( ABS( (value-expected) / expected) < H5DIFF_FLT_EPSILON) - return TRUE; - else - return FALSE; + if (options->use_system_epsilon) { + if ( ABS( (value-expected) / expected) < FLT_EPSILON) + return TRUE; + } + + return FALSE; } diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 4955f95..dc6b694 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -26,7 +26,6 @@ #include "h5tools.h" #include "h5tools_ref.h" -#include "h5tools_str.h" #include "h5tools_utils.h" #include "H5private.h" @@ -35,15 +34,213 @@ #define ALIGN(A,Z) ((((A) + (Z) - 1) / (Z)) * (Z)) /* global variables */ +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 */ int bin_output; /* binary output */ int bin_form; /* binary form */ +int region_output; /* region output */ + +static h5tool_format_t h5tools_dataformat = { +0, /*raw */ + +"", /*fmt_raw */ +"%d", /*fmt_int */ +"%u", /*fmt_uint */ +"%d", /*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 */ +"{\n", /*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 */ +}; + +static 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 */ +}; +static const h5tools_dump_header_t * h5tools_dump_header_format; /* local prototypes */ static int do_bin_output(FILE *stream, hsize_t nelmts, hid_t tid, void *_mem); static int render_bin_output(FILE *stream, hid_t tid, void *_mem); +static hbool_t h5tools_is_zero(const void *_mem, size_t size); + +hbool_t h5tools_render_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 local_elmt_counter/*element counter*/, + hsize_t elmt_counter); + +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); + +int h5tools_print_region_data_blocks(hid_t region_space, hid_t region_id, + FILE *stream, const h5tool_format_t *info, h5tools_context_t 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 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); /* module-scoped variables */ static int h5tools_init_g; /* if h5tools lib has been initialized */ @@ -101,11 +298,20 @@ enum { void h5tools_init(void) { + char lib_str[256]; + if (!h5tools_init_g) { - if (!rawdatastream) - rawdatastream = stdout; + /* register the error class */ + sprintf(lib_str, "%d.%d.%d",H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE); + + H5TOOLS_INIT_ERROR() + + if (!rawdatastream) + rawdatastream = stdout; + + h5tools_dump_header_format = &h5tools_standardformat; - h5tools_init_g++; + h5tools_init_g++; } } @@ -131,14 +337,16 @@ h5tools_close(void) if (h5tools_init_g) { if (rawdatastream && rawdatastream != stdout) { if (fclose(rawdatastream)) - perror("closing rawdatastream"); + perror("closing rawdatastream"); else - rawdatastream = NULL; + rawdatastream = NULL; } /* Clean up the reference path table, if it's been used */ term_ref_path_table(); + H5TOOLS_CLOSE_ERROR() + /* Shut down the library */ H5close(); @@ -164,88 +372,95 @@ h5tools_close(void) static hid_t h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum) { - hid_t new_fapl; /* Copy of file access property list passed in, or new property list */ + hid_t new_fapl; /* Copy of file access property list passed in, or new property list */ /* 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) + if (fapl == H5P_DEFAULT) { + if ((new_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; } /* end if */ else { - if((new_fapl = H5Pcopy(fapl)) < 0) + 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(!strcmp(driver, drivernames[SEC2_IDX])) { + if (!strcmp(driver, drivernames[SEC2_IDX])) { /* SEC2 driver */ - if(H5Pset_fapl_sec2(new_fapl) < 0) + if (H5Pset_fapl_sec2(new_fapl) < 0) goto error; - if(drivernum) + if (drivernum) *drivernum = SEC2_IDX; - } else if(!strcmp(driver, drivernames[FAMILY_IDX])) { + } + else if (!strcmp(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) + if (H5Pset_fapl_family(new_fapl, (hsize_t) 0, H5P_DEFAULT) < 0) goto error; - if(drivernum) + if (drivernum) *drivernum = FAMILY_IDX; - } else if(!strcmp(driver, drivernames[SPLIT_IDX])) { + } + else if (!strcmp(driver, drivernames[SPLIT_IDX])) { /* SPLIT Driver */ - if(H5Pset_fapl_split(new_fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT) < 0) + if (H5Pset_fapl_split(new_fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT) < 0) goto error; - if(drivernum) + if (drivernum) *drivernum = SPLIT_IDX; - } else if(!strcmp(driver, drivernames[MULTI_IDX])) { + } + else if (!strcmp(driver, drivernames[MULTI_IDX])) { /* MULTI Driver */ - if(H5Pset_fapl_multi(new_fapl, NULL, NULL, NULL, NULL, TRUE) < 0) - goto error; + if (H5Pset_fapl_multi(new_fapl, NULL, NULL, NULL, NULL, TRUE) < 0) + goto error; if(drivernum) - *drivernum = MULTI_IDX; + *drivernum = MULTI_IDX; #ifdef H5_HAVE_STREAM - } else if(!strcmp(driver, drivernames[STREAM_IDX])) { - /* STREAM Driver */ - if(H5Pset_fapl_stream(new_fapl, NULL) < 0) - goto error; + } + else if(!strcmp(driver, drivernames[STREAM_IDX])) { + /* STREAM Driver */ + if(H5Pset_fapl_stream(new_fapl, NULL) < 0) + goto error; - if(drivernum) - *drivernum = STREAM_IDX; + if(drivernum) + *drivernum = STREAM_IDX; #endif /* H5_HAVE_STREAM */ #ifdef H5_HAVE_PARALLEL - } else if(!strcmp(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; + } + else if(!strcmp(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 (!strcmp(driver, drivernames[MPIPOSIX_IDX])) { + } + else if (!strcmp(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); + /* 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; + goto error; if(drivernum) *drivernum = MPIPOSIX_IDX; } /* end if */ #endif /* H5_HAVE_PARALLEL */ - } else { + } + else { goto error; } @@ -320,21 +535,22 @@ h5tools_fopen(const char *fname, unsigned flags, hid_t fapl, const char *driver, hid_t fid = FAIL; hid_t my_fapl = H5P_DEFAULT; - if(driver && *driver) { + if (driver && *driver) { /* Get the correct FAPL for the given driver */ - if((my_fapl = h5tools_get_fapl(fapl, driver, &drivernum)) < 0) + if ((my_fapl = h5tools_get_fapl(fapl, driver, &drivernum)) < 0) goto done; H5E_BEGIN_TRY { fid = H5Fopen(fname, flags, my_fapl); } H5E_END_TRY; - if(fid == FAIL) + if (fid == FAIL) goto done; - } else { + } + else { /* Try to open the file using each of the drivers */ - for(drivernum = 0; drivernum < NUM_DRIVERS; drivernum++) { + 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; @@ -343,7 +559,7 @@ h5tools_fopen(const char *fname, unsigned flags, hid_t fapl, const char *driver, fid = H5Fopen(fname, flags, my_fapl); } H5E_END_TRY; - if(fid != FAIL) + if (fid != FAIL) break; else { /* Close the FAPL */ @@ -354,11 +570,12 @@ h5tools_fopen(const char *fname, unsigned flags, hid_t fapl, const char *driver, } /* Save the driver name */ - if(drivername && drivername_size) { - if(fid != FAIL) { + if (drivername && drivername_size) { + if (fid != FAIL) { strncpy(drivername, drivernames[drivernum], drivername_size); drivername[drivername_size - 1] = '\0'; - } else { + } + else { /*no file opened*/ drivername[0] = '\0'; } @@ -367,6 +584,7 @@ h5tools_fopen(const char *fname, unsigned flags, hid_t fapl, const char *driver, done: if(my_fapl != H5P_DEFAULT) H5Pclose(my_fapl); + return fid; } @@ -429,16 +647,16 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, int i, indentlevel = 0; if (!ctx->need_prefix) - return; + return; memset(&prefix, 0, sizeof(h5tools_str_t)); memset(&str, 0, sizeof(h5tools_str_t)); /* Terminate previous line, if any */ if (ctx->cur_column) { - fputs(OPT(info->line_suf, ""), stream); - putc('\n', stream); - fputs(OPT(info->line_sep, ""), stream); + fputs(OPT(info->line_suf, ""), stream); + putc('\n', stream); + fputs(OPT(info->line_sep, ""), stream); } /* Calculate new prefix */ @@ -448,22 +666,113 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, /* Write new prefix to output */ 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 + * the ctx->indent_level is negative so we need to skip the above and + * 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++) { + fputs(h5tools_str_fmt(&str, 0, info->line_indent), stream); + } + } + + if (elmtno == 0 && secnum == 0 && info->line_1st) + fputs(h5tools_str_fmt(&prefix, 0, info->line_1st), stream); + else if (secnum && info->line_cont) + fputs(h5tools_str_fmt(&prefix, 0, info->line_cont), stream); + else + fputs(h5tools_str_fmt(&prefix, 0, info->line_pre), stream); + + templength = h5tools_str_len(&prefix); + + for (i = 0; i < indentlevel; i++) { + /*we already made the indent for the array indices case */ + if (!info->pindex) { + fputs(h5tools_str_fmt(&prefix, 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; + + /* Free string */ + h5tools_str_close(&prefix); + h5tools_str_close(&str); +} + +/*------------------------------------------------------------------------- + * 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 + *------------------------------------------------------------------------- + */ +static 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_str_t prefix; + h5tools_str_t str; /*temporary for indentation */ + size_t templength = 0; + int i, indentlevel = 0; + + if (!ctx->need_prefix) + return; + + memset(&prefix, 0, sizeof(h5tools_str_t)); + memset(&str, 0, sizeof(h5tools_str_t)); + + /* Terminate previous line, if any */ + if (ctx->cur_column) { + fputs(OPT(info->line_suf, ""), stream); + putc('\n', stream); + fputs(OPT(info->line_sep, ""), stream); + } + + /* Calculate new prefix */ + h5tools_str_region_prefix(&prefix, info, elmtno, ptdata, ctx->ndims, ctx->p_min_idx, + ctx->p_max_idx, ctx); + + /* Write new prefix to output */ + if (ctx->indent_level >= 0) { + indentlevel = ctx->indent_level; + } + 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 * the ctx->indent_level is negative so we need to skip the above and * just print out the default indent levels. */ - indentlevel = ctx->default_indent_level; + 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++){ - fputs(h5tools_str_fmt(&str, 0, info->line_indent), stream); - } + for (i = 0; i < indentlevel - 1; i++) { + fputs(h5tools_str_fmt(&str, 0, info->line_indent), stream); + } } if (elmtno == 0 && secnum == 0 && info->line_1st) @@ -475,16 +784,16 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, templength = h5tools_str_len(&prefix); - for (i = 0; i < indentlevel; i++){ + for (i = 0; i < indentlevel; i++) { /*we already made the indent for the array indices case */ - if (!info->pindex) { - fputs(h5tools_str_fmt(&prefix, 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); - } + if (!info->pindex) { + fputs(h5tools_str_fmt(&prefix, 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; @@ -532,44 +841,41 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, * new field sm_pos in h5tools_context_t, the current stripmine element position *------------------------------------------------------------------------- */ -void +void 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) { - unsigned char *mem = (unsigned char*)_mem; - hsize_t i; /*element counter */ - char *s; - char *section; /*a section of output */ - int secnum; /*section sequence number */ - size_t size; /*size of each datum */ - size_t ncols = 80; /*available output width */ - h5tools_str_t buffer; /*string into which to render */ - int multiline; /*datum was multiline */ - hsize_t curr_pos; /* total data element position */ - int 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. */ - - /* binary dump */ - if(bin_output) - { + unsigned char *mem = (unsigned char*) _mem; + hsize_t i; /*element counter */ + size_t size; /*size of each datum */ + hid_t region_space; + hid_t region_id; + 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; /* 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. */ + + /* binary dump */ + if (bin_output) { do_bin_output(stream, nelmts, type, _mem); } /* end if */ - else - { + else { /* setup */ HDmemset(&buffer, 0, sizeof(h5tools_str_t)); size = H5Tget_size(type); - if(info->line_ncols > 0) + if (info->line_ncols > 0) ncols = info->line_ncols; - /* 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 @@ -579,903 +885,2567 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai h5tools_simple_prefix(stream, info, ctx, curr_pos, 0); for (i = 0; i < nelmts; i++, ctx->cur_elmt++, elmt_counter++) { - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_sprint(&buffer, info, container, type, mem + i * size, ctx); - - if (i + 1 < nelmts || (flags & END_OF_DATA) == 0) - h5tools_str_append(&buffer, "%s", OPT(info->elmt_suf1, ",")); + void* memref = mem + i * size; + if (region_output && H5Tequal(type, H5T_STD_REF_DSETREG)) { + char ref_name[1024]; + + /* region data */ + region_id = H5Rdereference(container, 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))) { + h5tools_str_append(&buffer, "NULL"); + } + 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"); + + /* Render the region element begin */ + h5tools_str_reset(&buffer); + + h5tools_str_append(&buffer, info->dset_format, ref_name); + + dimension_break = h5tools_render_element(stream, info, + ctx, &buffer, &curr_pos, ncols, i, elmt_counter); + + 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 */ + + } /* 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"); + + } /* if (region_id >= 0) */ + else + HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rdereference failed"); - s = h5tools_str_fmt(&buffer, 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_ncols(s) + - strlen(OPT(info->elmt_suf2, " ")) + - strlen(OPT(info->line_suf, ""))) > ncols) { - if (ctx->prev_multiline) { - /* - * ... and the previous element also occupied more than one - * line, then start this element at the beginning of a line. - */ - ctx->need_prefix = TRUE; - } else if ((ctx->prev_prefix_len + h5tools_ncols(s) + - strlen(OPT(info->elmt_suf2, " ")) + - strlen(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 - * own line. - */ - ctx->need_prefix = TRUE; - } - } - - /* - * We need to break after each row of a dimension---> we should - * break at the end of the each last dimension well that is the - * way the dumper did it before - */ - if (info->arr_linebreak && ctx->cur_elmt) { - if (ctx->size_last_dim && (ctx->cur_elmt % ctx->size_last_dim) == 0) - ctx->need_prefix = TRUE; - - if ((hsize_t)elmt_counter == ctx->size_last_dim) { - ctx->need_prefix = TRUE; - elmt_counter = 0; - } - } - - /* - * 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_ncols(s) + - strlen(OPT(info->elmt_suf2, " ")) + - strlen(OPT(info->line_suf, ""))) > ncols) ctx->need_prefix = TRUE; + } /* end if (region_output... */ + else { + /* Render the data element begin*/ + h5tools_str_reset(&buffer); + h5tools_str_sprint(&buffer, info, container, type, memref, ctx); - /* - * If too many elements have already been printed then we need to - * start a new line. - */ - if (info->line_per_line > 0 && ctx->cur_elmt >= info->line_per_line) - ctx->need_prefix = TRUE; + if (i + 1 < nelmts || (flags & END_OF_DATA) == 0) + h5tools_str_append(&buffer, "%s", OPT(info->elmt_suf1, ",")); - /* - * Each OPTIONAL_LINE_BREAK embedded in the rendered string can cause - * the data to split across multiple lines. We display the sections - * one-at a time. - */ - for (secnum = 0, multiline = 0; - (section = strtok(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 - * start a new line. - */ - - /* - * Added the info->skip_first because the dumper does not want - * this check to happen for the first line - */ - if ((!info->skip_first || i) && - (ctx->cur_column + strlen(section) + - strlen(OPT(info->elmt_suf2, " ")) + - strlen(OPT(info->line_suf, ""))) > ncols) - ctx->need_prefix = 1; - - /* - * Print the prefix or separate the beginning of this element - * from the previous element. - */ - if (ctx->need_prefix) { - if (secnum) - multiline++; - - /* 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 - */ - curr_pos = ctx->sm_pos + i; - - h5tools_simple_prefix(stream, info, ctx, curr_pos, secnum); - } else if ((i || ctx->continuation) && secnum == 0) { - fputs(OPT(info->elmt_suf2, " "), stream); - ctx->cur_column += strlen(OPT(info->elmt_suf2, " ")); - } + dimension_break = h5tools_render_element(stream, info, ctx, &buffer, + &curr_pos, ncols, i, elmt_counter); + /* Render the data element end*/ - /* Print the section */ - fputs(section, stream); - ctx->cur_column += strlen(section); } - - ctx->prev_multiline = multiline; - } + if(FALSE==dimension_break) + elmt_counter = 0; + } /* end for (i = 0; i < nelmts... */ h5tools_str_close(&buffer); }/* else bin */ } - /*------------------------------------------------------------------------- * Audience: Public * Chapter: H5Tools Library - * Purpose: Dump out a subset of a dataset. + * Purpose: Render an element to output STREAM. * Description: - * - * Select a hyperslab from the dataset DSET using the parameters - * specified in SSET. Dump this out to STREAM. - * - * Hyperslabs select "count" blocks of size "block", spaced "stride" elements - * from each other, starting at coordinate "start". - * + * 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: - * On success, return SUCCEED. Otherwise, the function returns FAIL. - * - * Original programmer: - * Bill Wendling, Wednesday, March 07, 2001 - * - * Rewritten with modified algorithm by: - * Pedro Vicente, Wednesday, January 16, 2008, contributions from Quincey Koziol - * - * Algorithm - * - * In a inner loop, the parameters from SSET are translated into temporary - * variables so that 1 row is printed at a time (getting the coordinate indices - * at each row). - * We define the stride, count and block to be 1 in the row dimension to achieve - * this and advance until all points are printed. - * An outer loop for cases where dimensionality is greater than 2D is made. - * In each iteration, the 2D block is displayed in the inner loop. The remaining - * slower dimensions above the first 2 are incremented one at a time in the outer loop - * - * The element position is obtained from the matrix according to: - * Given an index I(z,y,x) its position from the beginning of an array - * of sizes A(size_z, size_y,size_x) is given by - * Position of I(z,y,x) = index_z * size_y * size_x - * + index_y * size_x - * + index_x - * + * False if a dimension end is reached, otherwise true + * + * In/Out: + * 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 *------------------------------------------------------------------------- */ -static herr_t -h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, hid_t dset, - hid_t p_type, struct subset_t *sset, - int indentlevel) +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) { - herr_t ret; /* the value to return */ - hid_t f_space; /* file data space */ - size_t i; /* counters */ - size_t j; /* counters */ - hsize_t n; /* counters */ - hsize_t zero = 0; /* vector of zeros */ - unsigned int flags; /* buffer extent flags */ - hsize_t total_size[H5S_MAX_RANK];/* total size of dataset*/ - 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 */ - h5tools_context_t ctx; /* print context */ - 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 */ - hsize_t sm_nelmts; /* elements per stripmine*/ - unsigned char *sm_buf = NULL; /* buffer for raw data */ - hid_t sm_space; /* stripmine data space */ - 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; - hsize_t size_row_block; /* size for blocks along rows */ + hbool_t dimension_break = TRUE; + char *s; + char *section; /*a section of output */ + int secnum; /*section sequence number */ + int multiline; /*datum was multiline */ -#if defined (SANITY_CHECK) - hsize_t total_points = 1; /* to print */ - hsize_t printed_points = 0; /* printed */ -#endif + s = h5tools_str_fmt(buffer, 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_ncols(s) + + strlen(OPT(info->elmt_suf2, " ")) + + strlen(OPT(info->line_suf, ""))) > ncols) { + if (ctx->prev_multiline) { + /* + * ... and the previous element also occupied more than one + * line, then start this element at the beginning of a line. + */ + ctx->need_prefix = TRUE; + } + else if ((ctx->prev_prefix_len + h5tools_ncols(s) + + strlen(OPT(info->elmt_suf2, " ")) + + strlen(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 + * own line. + */ + ctx->need_prefix = TRUE; + } + } - ret = FAIL; /* be pessimistic */ - f_space = H5Dget_space(dset); + /* + * We need to break after each row of a dimension---> we should + * break at the end of the each last dimension well that is the + * way the dumper did it before + */ + if (info->arr_linebreak && ctx->cur_elmt) { + if (ctx->size_last_dim && (ctx->cur_elmt % ctx->size_last_dim) == 0) + ctx->need_prefix = TRUE; - if (f_space == FAIL) - goto done; + if (elmt_counter == ctx->size_last_dim) { + ctx->need_prefix = TRUE; + dimension_break = FALSE; + } + } /* - * check that everything looks okay. the dimensionality must not be too - * great and the dimensionality of the items selected for printing must - * match the dimensionality of the dataset. + * 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. */ - memset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = indentlevel; - ctx.need_prefix = 1; - ctx.ndims = H5Sget_simple_extent_ndims(f_space); + if (info->line_multi_new == 1 && + ctx->prev_multiline && + (ctx->cur_column + + h5tools_ncols(s) + + strlen(OPT(info->elmt_suf2, " ")) + + strlen(OPT(info->line_suf, ""))) > ncols) + ctx->need_prefix = TRUE; - if ((size_t)ctx.ndims > NELMTS(sm_size)) - goto done_close; + /* + * If too many elements have already been printed then we need to + * start a new line. + */ + if (info->line_per_line > 0 && ctx->cur_elmt >= info->line_per_line) + ctx->need_prefix = TRUE; - /* 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; + /* + * Each OPTIONAL_LINE_BREAK embedded in the rendered string can cause + * the data to split across multiple lines. We display the sections + * one-at a time. + */ + multiline = 0; + for (secnum = 0, multiline = 0; + (section = strtok(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 + * start a new line. + */ - H5Sget_simple_extent_dims(f_space, total_size, NULL); - ctx.size_last_dim = total_size[ctx.ndims - 1]; + /* + * Added the info->skip_first because the dumper does not want + * this check to happen for the first line + */ + if ((!info->skip_first || local_elmt_counter) && + (ctx->cur_column + + strlen(section) + + strlen(OPT(info->elmt_suf2, " ")) + + strlen(OPT(info->line_suf, ""))) > ncols) + ctx->need_prefix = 1; - if (ctx.ndims == 1) - row_dim = 0; - else - row_dim = ctx.ndims - 2; + /* + * Print the prefix or separate the beginning of this element + * from the previous element. + */ + if (ctx->need_prefix) { + if (secnum) + multiline++; - /* get the offset count */ - outer_count = 1; - if (ctx.ndims > 2) - for (i = 0; i < (size_t)ctx.ndims - 2; i++) - { - /* consider block size */ - outer_count = outer_count * sset->count[ i ] * sset->block[ i ]; + /* 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 + */ + *curr_pos = ctx->sm_pos + local_elmt_counter; + h5tools_simple_prefix(stream, info, ctx, *curr_pos, secnum); + } + else if ((local_elmt_counter || ctx->continuation) && secnum == 0) { + fputs(OPT(info->elmt_suf2, " "), stream); + ctx->cur_column += strlen(OPT(info->elmt_suf2, " ")); } - if(ctx.ndims>0) - init_acc_pos(&ctx,total_size); - - /* calculate total number of points to print */ -#if defined (SANITY_CHECK) - for (i = 0; i < (size_t)ctx.ndims; i++) - { - total_points *= sset->count[ i ] * sset->block[ i ];; + /* Print the section */ + fputs(section, stream); + ctx->cur_column += strlen(section); } -#endif + ctx->prev_multiline = multiline; + 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. + * + * Return: + * False if a dimension end is reached, otherwise true + * + * In/Out: + * 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 + *------------------------------------------------------------------------- + */ +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) +{ + hbool_t dimension_break = TRUE; + char *s; + char *section; /*a section of output */ + int secnum; /*section sequence number */ + int multiline; /*datum was multiline */ - /* initialize temporary start, count and maximum start */ - for (i = 0; i < (size_t)ctx.ndims; i++) - { - temp_start[ i ] = sset->start[ i ]; - temp_count[ i ] = sset->count[ i ]; - temp_block[ i ] = sset->block[ i ]; - temp_stride[ i ] = sset->stride[ 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[ i ]; - temp_count[ i ] = 1; + s = h5tools_str_fmt(buffer, 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_ncols(s) + + strlen(OPT(info->elmt_suf2, " ")) + + strlen(OPT(info->line_suf, ""))) > ncols) { + if (ctx->prev_multiline) { + /* + * ... and the previous element also occupied more than one + * line, then start this element at the beginning of a line. + */ + ctx->need_prefix = TRUE; + } + else if ((ctx->prev_prefix_len + h5tools_ncols(s) + + strlen(OPT(info->elmt_suf2, " ")) + + strlen(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 + * own line. + */ + ctx->need_prefix = TRUE; } } + /* + * We need to break after each row of a dimension---> we should + * break at the end of the each last dimension well that is the + * way the dumper did it before + */ + if (info->arr_linebreak && ctx->cur_elmt) { + if (ctx->size_last_dim && (ctx->cur_elmt % ctx->size_last_dim) == 0) + ctx->need_prefix = TRUE; - /* offset loop */ - for (n = 0; n < outer_count; n++) - { + if (elmt_counter == ctx->size_last_dim) { + ctx->need_prefix = TRUE; + dimension_break = FALSE; + } + } - hsize_t row_counter = 0; + /* + * 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_ncols(s) + + strlen(OPT(info->elmt_suf2, " ")) + + strlen(OPT(info->line_suf, ""))) > ncols) + ctx->need_prefix = TRUE; - /* number of read iterations in inner loop, read by rows, to match 2D display */ - if (ctx.ndims > 1) - { + /* + * If too many elements have already been printed then we need to + * start a new line. + */ + if (info->line_per_line > 0 && ctx->cur_elmt >= info->line_per_line) + ctx->need_prefix = TRUE; - /* count is the number of iterations to display all the rows, - the block size count times */ - count = sset->count[ row_dim ] * sset->block[ row_dim ]; + /* + * Each OPTIONAL_LINE_BREAK embedded in the rendered string can cause + * the data to split across multiple lines. We display the sections + * one-at a time. + */ + multiline = 0; + for (secnum = 0, multiline = 0; (section = strtok(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 + * start a new line. + */ - /* 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; + /* + * Added the info->skip_first because the dumper does not want + * this check to happen for the first line + */ + if ((!info->skip_first || local_elmt_counter) && + (ctx->cur_column + + strlen(section) + + strlen(OPT(info->elmt_suf2, " ")) + + strlen(OPT(info->line_suf, ""))) > ncols) + ctx->need_prefix = 1; - /* advance 1 row_counter at a time */ - if (sset->block[ row_dim ] > 1 ) - temp_stride[ row_dim ] = 1; + /* + * Print the prefix or separate the beginning of this element + * from the previous element. + */ + if (ctx->need_prefix) { + if (secnum) + multiline++; + /* 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 + */ + *curr_pos = ctx->sm_pos + local_elmt_counter; + h5tools_region_simple_prefix(stream, info, ctx, local_elmt_counter, ptdata, secnum); } - /* for the 1D case */ - else - { - count = 1; + else if ((local_elmt_counter || ctx->continuation) && secnum == 0) { + fputs(OPT(info->elmt_suf2, " "), stream); + ctx->cur_column += strlen(OPT(info->elmt_suf2, " ")); } + /* Print the section */ + fputs(section, stream); + ctx->cur_column += strlen(section); + } - size_row_block = sset->block[ row_dim ]; - - - /* display loop */ - for (; count > 0; - temp_start[ row_dim ] += temp_stride[ row_dim ], - 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[ row_dim ] > sset->block[ row_dim ] - ) - { - - hsize_t increase_rows = sset->stride[ row_dim ] - - sset->block[ row_dim ]; - - temp_start[ row_dim ] += increase_rows; - - row_counter = 0; - - } - - row_counter++; + ctx->prev_multiline = multiline; + return dimension_break; +} +/*------------------------------------------------------------------------- + * Audience: Public + * Chapter: H5Tools Library + * Purpose: Print the data values from a dataset referenced by region blocks. + * + * Description: + * 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 + * + * Parameters Description: + * h5tools_str_t *buffer is the string into which to render + * size_t ncols + * int ndims is the number of dimensions of the region element + * hssize_t nblocks is the number of blocks in the region + *------------------------------------------------------------------------- + */ +int +h5tools_print_region_data_blocks(hid_t region_space, hid_t region_id, + FILE *stream, const h5tool_format_t *info, h5tools_context_t 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) { + HERR_INIT(int, SUCCEED) + hbool_t dimension_break = TRUE; + hsize_t *dims1 = NULL; + hsize_t *start = NULL; + hsize_t *count = NULL; + size_t numelem; + hsize_t total_size[H5S_MAX_RANK]; + hsize_t elmtno; /* elemnt index */ + unsigned int region_flags; /* buffer extent flags */ + hsize_t curr_pos; + int jndx; + int type_size; + hid_t mem_space; + void *region_buf = NULL; + int blkndx; + hid_t sid1; + + /* Get the dataspace of the dataset */ + if((sid1 = H5Dget_space(region_id)) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed"); + + /* Allocate space for the dimension array */ + if((dims1 = (hsize_t *) malloc(sizeof(hsize_t) * ndims)) == NULL) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "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; + } - /* calculate the potential number of elements we're going to print */ - H5Sselect_hyperslab(f_space, H5S_SELECT_SET, - temp_start, - temp_stride, - temp_count, - temp_block); - sm_nelmts = H5Sget_select_npoints(f_space); + /* 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 (sm_nelmts == 0) { - /* nothing to print */ - ret = SUCCEED; - goto done_close; - } + if((type_size = H5Tget_size(type_id)) == 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed"); - /* - * determine the strip mine size and allocate a buffer. the strip mine is - * 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 */ - size = 1; - sm_size[i - 1] = MIN(total_size[i - 1], size); - sm_nbytes *= sm_size[i - 1]; - assert(sm_nbytes > 0); - } + if((region_buf = malloc(type_size * numelem)) == NULL) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate region buffer"); - assert(sm_nbytes == (hsize_t)((size_t)sm_nbytes)); /*check for overflow*/ - sm_buf = malloc((size_t)sm_nelmts * p_type_nbytes); - sm_space = H5Screate_simple(1, &sm_nelmts, NULL); + /* Select (x , x , ..., x ) x (y , y , ..., y ) hyperslab for reading memory dataset */ + /* 1 2 n 1 2 n */ + if((start = (hsize_t *) malloc(sizeof(hsize_t) * ndims)) == NULL) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for start"); - H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, &zero, NULL, &sm_nelmts, NULL); + if((count = (hsize_t *) malloc(sizeof(hsize_t) * ndims)) == NULL) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for count"); - /* read the data */ - if (H5Dread(dset, p_type, sm_space, f_space, H5P_DEFAULT, sm_buf) < 0) { - H5Sclose(f_space); - H5Sclose(sm_space); - free(sm_buf); - return FAIL; - } + curr_pos = 0; + for (blkndx = 0; blkndx < nblocks; blkndx++) { + ctx.ndims = ndims; + ctx.need_prefix = TRUE; + ctx.cur_elmt = 0; + for (jndx = 0; jndx < ndims; jndx++) { + start[jndx] = ptdata[jndx + blkndx * ndims * 2]; + count[jndx] = dims1[jndx]; + } - /* print the data */ - flags = START_OF_DATA; - - if (count == 1) - flags |= END_OF_DATA; - - 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 */ - H5Sget_select_bounds(f_space,low,high); - elmtno=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++) - offset *= total_size[j]; - elmtno+= low[i] * offset; - } - elmtno+= low[ctx.ndims - 1]; + 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"); + + 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 (jndx = 0; jndx < (size_t) ctx.ndims; jndx++) + ctx.p_min_idx[jndx] = start[jndx]; + init_acc_pos(&ctx, total_size); + + /* print the data */ + region_flags = START_OF_DATA; + if (blkndx == nblocks - 1) + region_flags |= END_OF_DATA; + + for (jndx = 0; jndx < ctx.ndims; jndx++) + ctx.p_max_idx[jndx] = dims1[jndx]; + + 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); + + elmtno = 0; + for (jndx = 0; jndx < numelem; jndx++, elmtno++, ctx.cur_elmt++) { + /* Render the region data element begin */ + h5tools_str_reset(buffer); + + 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); + + if (jndx + 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, jndx, 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++) */ + + ctx.indent_level--; + } /* end for (blkndx = 0; blkndx < nblocks; blkndx++) */ + + done: + free(start); + free(count); + free(region_buf); + free(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"); + +CATCH + return ret_value; +} - /* initialize the current stripmine position; this is necessary to print the array - indices */ - ctx.sm_pos = elmtno; +/*------------------------------------------------------------------------- + * Audience: Public + * Chapter: H5Tools Library + * Purpose: Print some values from a dataset referenced by region blocks. + * + * Description: + * This is a special case subfunction to dump a region reference using blocks. + * + * 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_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; + hid_t type_id; + int i; + + if((nblocks = H5Sget_select_hyper_nblocks(region_space)) <= 0) + H5E_THROW(dimension_break, H5E_tools_min_id_g, "H5Sget_select_hyper_nblocks failed"); + + /* 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"); + + /* 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 */ + + /* Render the region datatype info and indices element begin */ + h5tools_str_reset(buffer); + + ctx->indent_level++; + ctx->need_prefix = TRUE; + h5tools_str_append(buffer, "REGION_TYPE BLOCK "); + + alloc_size = nblocks * ndims * 2 * sizeof(ptdata[0]); + assert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/ + if((ptdata = (hsize_t*) malloc((size_t) alloc_size)) == NULL) + HGOTO_ERROR(dimension_break, H5E_tools_min_id_g, "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"); + + for (i = 0; i < nblocks; i++) { + int j; + + h5tools_str_append(buffer, info->dset_blockformat_pre, + i ? "," OPTIONAL_LINE_BREAK " " : "", (unsigned long) i); + + /* Start coordinates and opposite corner */ + for (j = 0; j < ndims; j++) + h5tools_str_append(buffer, "%s%lu", j ? "," : "(", + (unsigned long) ptdata[i * 2 * ndims + j]); + + for (j = 0; j < ndims; j++) + h5tools_str_append(buffer, "%s%lu", j ? "," : ")-(", + (unsigned long) ptdata[i * 2 * ndims + j + ndims]); + + h5tools_str_append(buffer, ")"); + } /* end for (i = 0; i < nblocks; i++) */ + + 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"); + + /* 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_print_datatype(buffer, info, ctx, dtype); + + 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); - h5tools_dump_simple_data(stream, info, dset, &ctx, flags, sm_nelmts, - p_type, sm_buf); - free(sm_buf); + dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); + /* Render the datatype element end */ - /* we need to jump to next line and update the index */ - ctx.need_prefix = 1; + ctx->need_prefix = TRUE; - ctx.continuation++; + /* Render the dataspace element begin */ + h5tools_str_reset(buffer); + ctx->need_prefix = TRUE; + h5tools_str_append(buffer, "%s ", h5tools_dump_header_format->dataspacebegin); -#if defined (SANITY_CHECK) - printed_points += sm_nelmts; -#endif + 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); - } /* count */ + dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); + /* Render the dataspace element end */ - if (ctx.ndims > 2) - { - /* dimension for start */ - current_outer_dim = (ctx.ndims - 2) -1; + ctx->need_prefix = TRUE; - /* set start to original from current_outer_dim up */ - for (i = current_outer_dim + 1; i < ctx.ndims; i++) - { - temp_start[ i ] = sset->start[ i ]; - } + /* 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); - /* increment start dimension */ - do - { - reset_dim = 0; - temp_start[ current_outer_dim ]++; - if (temp_start[ current_outer_dim ] >= max_start[ current_outer_dim ]) - { - temp_start[ current_outer_dim ] = sset->start[ current_outer_dim ]; + dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); + /* Render the databegin element end */ - /* consider block */ - if ( sset->block[ current_outer_dim ] > 1 ) - temp_start[ current_outer_dim ]++; + ctx->need_prefix = TRUE; - current_outer_dim--; - reset_dim = 1; - } - } - while (current_outer_dim >= 0 && reset_dim); + h5tools_print_region_data_blocks(region_space, region_id, + stream, info, *ctx, buffer, ncols, ndims, type_id, nblocks, ptdata); - } /* ctx.ndims > 1 */ + done: + free(ptdata); + + if(H5Tclose(dtype) < 0) + HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed"); - } /* outer_count */ + ctx->need_prefix = TRUE; -#if defined (SANITY_CHECK) - assert( printed_points == total_points ); -#endif + /* 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 */ + ctx->indent_level--; + ctx->need_prefix = TRUE; - /* Terminate the output */ - if (ctx.cur_column) { - fputs(OPT(info->line_suf, ""), stream); - putc('\n', stream); - fputs(OPT(info->line_sep, ""), stream); - } + /* 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 */ - ret = SUCCEED; + H5_LEAVE(dimension_break) -done_close: - H5Sclose(f_space); -done: - return ret; + CATCH + return ret_value; } +/*------------------------------------------------------------------------- + * Audience: Public + * Chapter: H5Tools Library + * Purpose: Print the data values from a dataset referenced by region points. + * + * Description: + * This is a special case subfunction to print the data in a region reference of type points. + * + * Return: + * The function returns FAIL on error, otherwise SUCCEED + * + * Parameters Description: + * h5tools_str_t *buffer is the string into which to render + * size_t ncols + * int ndims is the number of dimensions of the region element + * 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 ctx, + h5tools_str_t *buffer, size_t ncols, + int ndims, hid_t type_id, hssize_t npoints, hsize_t *ptdata) { + HERR_INIT(int, SUCCEED) + hbool_t dimension_break = TRUE; + hsize_t alloc_size; + hsize_t *dims1 = NULL; + h5tools_context_t region_ctx; /* print context */ + hsize_t elmtno; /* elemnt index */ + unsigned int region_flags; /* buffer extent flags */ + hsize_t curr_pos; + int indx; + int jndx; + int type_size; + hid_t mem_space; + hid_t dtype; + void *region_buf = NULL; + + if((type_size = H5Tget_size(type_id)) == 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed"); + + if((region_buf = malloc(type_size * npoints)) == NULL) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for region"); + + /* Allocate space for the dimension array */ + if((dims1 = (hsize_t *) malloc(sizeof(hsize_t) * ndims)) == NULL) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "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(H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed"); + + elmtno = 0; + curr_pos = 0; + for (jndx = 0; jndx < npoints; jndx++, elmtno++) { + ctx.ndims = ndims; + ctx.need_prefix = TRUE; + ctx.cur_elmt = 0; /* points are always 0 */ + + /* Render the point element begin */ + h5tools_str_reset(buffer); + + ctx.indent_level++; + + /* assume entire data space to be printed */ + for (indx = 0; indx < (size_t) ctx.ndims; indx++) + ctx.p_min_idx[indx] = 0; + if(H5Sget_simple_extent_dims(region_space, ctx.p_max_idx, NULL) < 0) + HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed"); + if (ctx.ndims > 0) { + ctx.size_last_dim = (int) (ctx.p_max_idx[ctx.ndims - 1]); + } + else + ctx.size_last_dim = 0; + + if (ctx.ndims > 0) + init_acc_pos(&ctx, ctx.p_max_idx); + + /* print the data */ + region_flags = START_OF_DATA; + if (jndx == npoints - 1) + region_flags |= END_OF_DATA; + + curr_pos = 0; /* points requires constant 0 */ + ctx.sm_pos = jndx * ndims; + + h5tools_region_simple_prefix(stream, info, &ctx, curr_pos, ptdata, 0); + + h5tools_str_sprint(buffer, info, region_id, type_id, + ((char*)region_buf + jndx * type_size), &ctx); + + 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, 0, elmtno); + /* Render the point element end */ + + ctx.indent_level--; + if(FALSE == dimension_break) + elmtno = 0; + } /* end for (jndx = 0; jndx < npoints; jndx++, region_elmtno++) */ + + done: + free(region_buf); + free(dims1); + + if(H5Sclose(mem_space) < 0) + HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed"); +CATCH + return ret_value; +} /*------------------------------------------------------------------------- * Audience: Public * Chapter: H5Tools Library - * Purpose: Print some values from a dataset with a simple data space. + * Purpose: Print some values from a dataset referenced by region points. + * * Description: - * This is a special case of h5tools_dump_dset(). This function only - * intended for dumping datasets -- it does strip mining and some other - * things which are unnecessary for smaller objects such as attributes - * (to print small objects like attributes simply read the attribute and - * call h5tools_dump_simple_mem()). + * This is a special case subfunction to dump a region reference using points. + * * Return: - * On success, the function returns SUCCEED. Otherwise, the function - * returns FAIL. - * Programmer: - * Robb Matzke, Thursday, July 23, 1998 - * Modifications: + * 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 *------------------------------------------------------------------------- */ -static int -h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, hid_t dset, - hid_t p_type, int indentlevel) -{ - hid_t f_space; /* 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*/ +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; + int indx; + hid_t dtype; + hid_t type_id; + + if((npoints = H5Sget_select_elem_npoints(region_space)) <= 0) + H5E_THROW(dimension_break, H5E_tools_min_id_g, "H5Sget_select_elem_npoints failed"); + + /* 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"); + + /* 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 */ + + /* Render the region datatype info and indices element begin */ + h5tools_str_reset(buffer); + + ctx->indent_level++; + ctx->need_prefix = TRUE; + h5tools_str_append(buffer, "REGION_TYPE POINT "); + + alloc_size = npoints * ndims * sizeof(ptdata[0]); + assert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/ + if((ptdata = malloc((size_t) alloc_size)) == NULL) + HGOTO_ERROR(dimension_break, H5E_tools_min_id_g, "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"); + + for (indx = 0; indx < npoints; indx++) { + int loop_indx; + + h5tools_str_append(buffer, info->dset_ptformat_pre, + indx ? "," OPTIONAL_LINE_BREAK " " : "", (unsigned long) indx); + + for (loop_indx = 0; loop_indx < ndims; loop_indx++) + h5tools_str_append(buffer, "%s%lu", loop_indx ? "," : "(", + (unsigned long) (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); + /* 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"); + + /* 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_print_datatype(buffer, info, ctx, dtype); + + 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); - /* Print info */ - h5tools_context_t ctx; /* print context */ - size_t p_type_nbytes; /* size of memory type */ - hsize_t p_nelmts; /* total selected elmts */ + dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); + /* Render the datatype element end */ - /* 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; /* stripmine data space */ + ctx->need_prefix = TRUE; - /* 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 */ + /* Render the dataspace element begin */ + h5tools_str_reset(buffer); - /* VL data special information */ - unsigned int vl_data = 0; /* contains VL datatypes */ + ctx->need_prefix = TRUE; + h5tools_str_append(buffer, "%s ", h5tools_dump_header_format->dataspacebegin); - f_space = H5Dget_space(dset); + h5tools_print_dataspace(buffer, region_space); - if (f_space == FAIL) - return FAIL; + 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); - /* - * Check that everything looks okay. The dimensionality must not be too - * great and the dimensionality of the items selected for printing must - * match the dimensionality of the dataset. - */ - memset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = indentlevel; - ctx.need_prefix = 1; - ctx.ndims = H5Sget_simple_extent_ndims(f_space); + dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); + /* Render the dataspace element end */ - if ((size_t)ctx.ndims > NELMTS(sm_size)) { - H5Sclose(f_space); - return FAIL; - } + ctx->need_prefix = TRUE; - /* 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; + /* Render the databegin element begin */ + h5tools_str_reset(buffer); - H5Sget_simple_extent_dims(f_space, total_size, NULL); + h5tools_str_append(buffer, "%s %s ", + h5tools_dump_header_format->databegin, + h5tools_dump_header_format->datablockbegin); - /* calculate the number of elements we're going to print */ - p_nelmts = 1; + dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); + /* Render the databegin element end */ - if (ctx.ndims > 0) { - 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; + ctx->need_prefix = TRUE; - if (p_nelmts == 0) { - /* nothing to print */ - H5Sclose(f_space); - return SUCCEED; - } + h5tools_print_region_data_points(region_space, region_id, + stream, info, *ctx, buffer, ncols, ndims, type_id, npoints, ptdata); - /* Check if we have VL data in the dataset's datatype */ - if (H5Tdetect_class(p_type, H5T_VLEN) == TRUE) - vl_data = TRUE; + done: + free(ptdata); - /* - * Determine the strip mine size and allocate a buffer. The strip mine is - * a hyperslab whose size is manageable. - */ - sm_nbytes = p_type_nbytes = H5Tget_size(p_type); + if(H5Tclose(dtype) < 0) + HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed"); - 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 */ - size = 1; - sm_size[i - 1] = MIN(total_size[i - 1], size); - sm_nbytes *= sm_size[i - 1]; - assert(sm_nbytes > 0); - } - } + ctx->need_prefix = TRUE; - assert(sm_nbytes == (hsize_t)((size_t)sm_nbytes)); /*check for overflow*/ - sm_buf = malloc((size_t)sm_nbytes); + /* 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*/ - sm_nelmts = sm_nbytes / p_type_nbytes; - sm_space = H5Screate_simple(1, &sm_nelmts, NULL); + ctx->indent_level--; + ctx->need_prefix = TRUE; - if(ctx.ndims>0) - init_acc_pos(&ctx,total_size); + /* 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 */ - /* The stripmine loop */ - memset(hs_offset, 0, sizeof hs_offset); - memset(zero, 0, sizeof zero); + H5_LEAVE(dimension_break) +CATCH + return ret_value; +} - 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]; - } +/*------------------------------------------------------------------------- + * Audience: Public + * Chapter: H5Tools Library + * Purpose: print out the data for a subset of a dataset. + * Description: + * + * Select a hyperslab from the dataset DSET using the parameters + * specified in SSET. Dump this out to STREAM. + * + * Hyperslabs select "count" blocks of size "block", spaced "stride" elements + * from each other, starting at coordinate "start". + * + * Return: + * On success, return SUCCEED. Otherwise, the function returns FAIL. + * + * Algorithm + * + * The parameters from SSET are translated into temporary + * variables so that 1 row is printed at a time (getting the coordinate indices + * at each row). + * We define the stride, count and block to be 1 in the row dimension to achieve + * this and advance until all points are printed. + * + * The element position is obtained from the matrix according to: + * Given an index I(z,y,x) its position from the beginning of an array + * of sizes A(size_z, size_y,size_x) is given by + * Position of I(z,y,x) = index_z * size_y * size_x + * + index_y * size_x + * + index_x + * + *------------------------------------------------------------------------- + */ +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 */) +{ + HERR_INIT(herr_t, SUCCEED) + size_t i; /* counters */ + size_t j; /* counters */ + hsize_t zero = 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 */ + hsize_t sm_nelmts; /* elements per stripmine*/ + unsigned char *sm_buf = NULL; /* buffer for raw data */ + hid_t sm_space; /* stripmine data space */ + hsize_t size_row_block; /* size for blocks along rows */ + hsize_t row_counter = 0; - 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; + if ((size_t) ctx->ndims > NELMTS(sm_size)) + H5E_THROW(FAIL, H5E_tools_min_id_g, "ndims and sm_size comparision failed"); + + if (ctx->ndims > 0) + init_acc_pos(ctx, total_size); + + size_row_block = sset->block[row_dim]; + + /* 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[row_dim] > sset->block[row_dim]) { + + hsize_t increase_rows = sset->stride[row_dim] - sset->block[row_dim]; + temp_start[row_dim] += increase_rows; + row_counter = 0; } - /* Read the data */ - if (H5Dread(dset, p_type, sm_space, f_space, H5P_DEFAULT, sm_buf) < 0) { - H5Sclose(f_space); - H5Sclose(sm_space); + 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) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed"); + + if((sm_nelmts = H5Sget_select_npoints(f_space)) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_select_npoints failed"); + + if (sm_nelmts > 0) { + /* + * 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) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed"); + + 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 */ + size = 1; + sm_size[i - 1] = MIN(total_size[i - 1], size); + sm_nbytes *= sm_size[i - 1]; + assert(sm_nbytes > 0); + } + + assert(sm_nbytes == (hsize_t) ((size_t) sm_nbytes)); /*check for overflow*/ + if((sm_buf = malloc((size_t) sm_nelmts * p_type_nbytes)) == NULL) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for strip-mine"); + + if((sm_space = H5Screate_simple(1, &sm_nelmts, NULL)) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Screate_simple failed"); + + if(H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, &zero, NULL, &sm_nelmts, NULL) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed"); + + /* read the data */ + if (H5Dread(dset, p_type, sm_space, f_space, H5P_DEFAULT, sm_buf) < 0) { + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed"); + } + + /* print the data */ + flags = START_OF_DATA; + + if (hyperslab_count == 1) + flags |= END_OF_DATA; + + 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) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_select_bounds failed"); + + elmtno = 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++) + offset *= total_size[j]; + elmtno += 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; + + h5tools_dump_simple_data(stream, info, dset, ctx, flags, sm_nelmts, p_type, sm_buf); +done: + if(H5Sclose(sm_space) < 0) + HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed"); free(sm_buf); - return FAIL; } + else + H5E_THROW(SUCCEED, H5E_tools_min_id_g, "nothing to print"); + /* we need to jump to next line and update the index */ + ctx->need_prefix = 1; - /* Print the data */ - flags = (elmtno == 0) ? START_OF_DATA : 0; - flags |= ((elmtno + hs_nelmts) >= p_nelmts) ? END_OF_DATA : 0; + ctx->continuation++; + + } /* hyperslab_count loop */ + +CATCH + return ret_value; +} + +/*------------------------------------------------------------------------- + * Audience: Public + * Chapter: H5Tools Library + * Purpose: print out the data for a subset of a dataset. + * Description: + * + * Select a hyperslab from the dataset DSET using the parameters + * specified in SSET. Dump this out to STREAM. + * + * Hyperslabs select "count" blocks of size "block", spaced "stride" elements + * from each other, starting at coordinate "start". + * + * Return: + * On success, return SUCCEED. Otherwise, the function returns FAIL. + * + * Algorithm + * + * The parameters from SSET are translated into temporary + * variables so that 1 row is printed at a time (getting the coordinate indices + * at each row). + * We define the stride, count and block to be 1 in the row dimension to achieve + * this and advance until all points are printed. + * + * The element position is obtained from the matrix according to: + * Given an index I(z,y,x) its position from the beginning of an array + * of sizes A(size_z, size_y,size_x) is given by + * Position of I(z,y,x) = index_z * size_y * size_x + * + index_y * size_x + * + index_x + * + *------------------------------------------------------------------------- + */ +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) +{ + HERR_INIT(herr_t, 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; + + if (ctx->ndims == 1) + row_dim = 0; + else + row_dim = ctx->ndims - 2; + + /* get the offset count */ + outer_count = 1; + if (ctx->ndims > 2) + for (i = 0; i < (size_t) ctx->ndims - 2; i++) { + /* consider block size */ + outer_count = outer_count * sset->count[i] * sset->block[i]; + + } + + /* initialize temporary start, count and maximum start */ + for (i = 0; i < (size_t) ctx->ndims; i++) { + temp_start[i] = sset->start[i]; + temp_count[i] = sset->count[i]; + temp_block[i] = sset->block[i]; + temp_stride[i] = sset->stride[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[i]; + temp_count[i] = 1; + + } + } + + /* offset loop */ + for (n = 0; n < outer_count; n++) { + /* number of read iterations in inner loop, read by rows, to match 2D display */ + if (ctx->ndims > 1) { + + /* count is the number of iterations to display all the rows, + the block size count times */ + count = sset->count[row_dim] * sset->block[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[row_dim] > 1) + temp_stride[row_dim] = 1; + + } + /* for the 1D case */ + else { + 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); + + if (ctx->ndims > 2) { + /* dimension for start */ + current_outer_dim = (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[i]; + } + + /* increment start dimension */ + do { + reset_dim = 0; + temp_start[current_outer_dim]++; + if (temp_start[current_outer_dim] >= max_start[current_outer_dim]) { + temp_start[current_outer_dim] = sset->start[current_outer_dim]; + + /* consider block */ + if (sset->block[current_outer_dim] > 1) + temp_start[current_outer_dim]++; + + current_outer_dim--; + reset_dim = 1; + } + } while (current_outer_dim >= 0 && reset_dim); + + } /* ctx.ndims > 1 */ + + } /* outer_count */ + +CATCH + return ret_value; +} + +/*------------------------------------------------------------------------- + * Audience: Public + * Chapter: H5Tools Library + * Purpose: Dump out a subset of a dataset. + * Description: + * + * Select a hyperslab from the dataset DSET using the parameters + * specified in SSET. Dump this out to STREAM. + * + * Hyperslabs select "count" blocks of size "block", spaced "stride" elements + * from each other, starting at coordinate "start". + * + * Return: + * On success, return SUCCEED. Otherwise, the function returns FAIL. + * + * Original programmer: + * Bill Wendling, Wednesday, March 07, 2001 + * + * Rewritten with modified algorithm by: + * Pedro Vicente, Wednesday, January 16, 2008, contributions from Quincey Koziol + * + * Algorithm + * + * In a inner loop, the parameters from SSET are translated into temporary + * variables so that 1 row is printed at a time (getting the coordinate indices + * at each row). + * We define the stride, count and block to be 1 in the row dimension to achieve + * this and advance until all points are printed. + * An outer loop for cases where dimensionality is greater than 2D is made. + * In each iteration, the 2D block is displayed in the inner loop. The remaining + * slower dimensions above the first 2 are incremented one at a time in the outer loop + * + * The element position is obtained from the matrix according to: + * Given an index I(z,y,x) its position from the beginning of an array + * of sizes A(size_z, size_y,size_x) is given by + * Position of I(z,y,x) = index_z * size_y * size_x + * + index_y * size_x + * + index_x + * + *------------------------------------------------------------------------- + */ +static herr_t +h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, hid_t dset, + hid_t p_type, struct subset_t *sset, int indentlevel) +{ + HERR_INIT(herr_t, SUCCEED) + hid_t f_space; /* file data space */ + size_t i; /* counters */ + hsize_t total_size[H5S_MAX_RANK];/* total size of dataset*/ + h5tools_context_t ctx; /* print context */ + + if((f_space = H5Dget_space(dset)) < 0) + H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Dget_space failed"); + + /* + * check that everything looks okay. the dimensionality must not be too + * great and the dimensionality of the items selected for printing must + * match the dimensionality of the dataset. + */ + memset(&ctx, 0, sizeof(ctx)); + ctx.indent_level = indentlevel; + ctx.need_prefix = 1; + if((ctx.ndims = H5Sget_simple_extent_ndims(f_space)) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims 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; + + if(H5Sget_simple_extent_dims(f_space, total_size, NULL) < 0) + HGOTO_ERROR(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); + /* Terminate the output */ + if (ctx.cur_column) { + fputs(OPT(info->line_suf, ""), stream); + putc('\n', stream); + fputs(OPT(info->line_sep, ""), stream); + } + +done: + if(H5Sclose(f_space) < 0) + HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed"); + +CATCH + return ret_value; +} + +/*------------------------------------------------------------------------- + * Audience: Public + * Chapter: H5Tools Library + * Purpose: Print some values from a dataset with a simple data space. + * Description: + * This is a special case of h5tools_dump_dset(). This function only + * intended for dumping datasets -- it does strip mining and some other + * things which are unnecessary for smaller objects such as attributes + * (to print small objects like attributes simply read the attribute and + * call h5tools_dump_simple_mem()). + * Return: + * On success, the function returns SUCCEED. Otherwise, the function + * returns FAIL. + *------------------------------------------------------------------------- + */ +static int +h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, + hid_t dset, hid_t p_type, int indentlevel) +{ + hid_t f_space; /* 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*/ + + /* Print info */ + h5tools_context_t ctx; /* print context */ + 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; /* 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 */ + + /* VL data special information */ + unsigned int vl_data = 0; /* contains VL datatypes */ + + f_space = H5Dget_space(dset); + + if (f_space == FAIL) + return FAIL; + + /* + * Check that everything looks okay. The dimensionality must not be too + * great and the dimensionality of the items selected for printing must + * match the dimensionality of the dataset. + */ + memset(&ctx, 0, sizeof(ctx)); + ctx.ndims = H5Sget_simple_extent_ndims(f_space); + + if ((size_t)ctx.ndims > NELMTS(sm_size)) { + H5Sclose(f_space); + return FAIL; + } + + ctx.indent_level = indentlevel; + ctx.need_prefix = 1; + + /* 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); + + /* calculate the number of elements we're going to print */ + p_nelmts = 1; + + if (ctx.ndims > 0) { + 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 (p_nelmts == 0) { + /* nothing to print */ + H5Sclose(f_space); + return SUCCEED; + } + + /* Check if we have VL data in the dataset's datatype */ + if (H5Tdetect_class(p_type, H5T_VLEN) == TRUE) + vl_data = TRUE; + + /* + * Determine the strip mine size and allocate a buffer. The strip mine is + * 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 */ + size = 1; + sm_size[i - 1] = MIN(total_size[i - 1], size); + sm_nbytes *= sm_size[i - 1]; + assert(sm_nbytes > 0); + } + } + + assert(sm_nbytes == (hsize_t)((size_t)sm_nbytes)); /*check for overflow*/ + sm_buf = malloc((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 */ + memset(hs_offset, 0, sizeof hs_offset); + memset(zero, 0, sizeof zero); + + 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]; + } + + 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) { + H5Sclose(f_space); + H5Sclose(sm_space); + free(sm_buf); + return FAIL; + } + + /* 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; + + h5tools_dump_simple_data(stream, info, dset, &ctx, flags, hs_nelmts, p_type, sm_buf); + + /* Reclaim any VL memory, if necessary */ + if (vl_data) + H5Dvlen_reclaim(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]; + + if (hs_offset[i - 1] == total_size[i - 1]) + hs_offset[i - 1] = 0; + else + carry = 0; + } + + ctx.continuation++; + } + + /* Terminate the output */ + if (ctx.cur_column) { + fputs(OPT(info->line_suf, ""), stream); + putc('\n', stream); + fputs(OPT(info->line_sep, ""), stream); + } + + H5Sclose(sm_space); + H5Sclose(f_space); + + free(sm_buf); + + return SUCCEED; +} + +/*------------------------------------------------------------------------- + * Function: h5tools_dump_simple_mem + * + * Purpose: Print some values from memory with a simple data space. + * This is a special case of h5tools_dump_mem(). + * + * Return: Success: SUCCEED + * Failure: FAIL + * + *------------------------------------------------------------------------- + */ +static int +h5tools_dump_simple_mem(FILE *stream, const h5tool_format_t *info, hid_t obj_id, + hid_t type, hid_t space, void *mem, int indentlevel) +{ + int i; /*counters */ + hsize_t nelmts; /*total selected elmts */ + h5tools_context_t ctx; /*printing context */ + + /* + * Check that everything looks okay. The dimensionality must not be too + * great and the dimensionality of the items selected for printing must + * match the dimensionality of the dataset. + */ + memset(&ctx, 0, sizeof(ctx)); + ctx.ndims = H5Sget_simple_extent_ndims(space); + + if ((size_t) ctx.ndims > NELMTS(ctx.p_min_idx)) + return FAIL; + + ctx.indent_level = indentlevel; + ctx.need_prefix = 1; + + /* Assume entire data space to be printed */ + for (i = 0; i < ctx.ndims; i++) + ctx.p_min_idx[i] = 0; + + H5Sget_simple_extent_dims(space, ctx.p_max_idx, NULL); + + for (i = 0, nelmts = 1; ctx.ndims != 0 && i < ctx.ndims; i++) + nelmts *= ctx.p_max_idx[i] - ctx.p_min_idx[i]; + + if (nelmts == 0) + return SUCCEED; /*nothing to print*/ + if (ctx.ndims > 0) { + assert(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]); + } /* end if */ + else + ctx.size_last_dim = 0; + + if (ctx.ndims > 0) + init_acc_pos(&ctx, ctx.p_max_idx); + + /* Print it */ + h5tools_dump_simple_data(stream, info, obj_id, &ctx, START_OF_DATA | END_OF_DATA, nelmts, type, mem); + + /* Terminate the output */ + if (ctx.cur_column) { + fputs(OPT(info->line_suf, ""), stream); + putc('\n', stream); + fputs(OPT(info->line_sep, ""), stream); + } + + return SUCCEED; +} + +/*------------------------------------------------------------------------- + * Function: h5tools_dump_dset + * + * Purpose: Print some values from a dataset DSET to the file STREAM + * after converting all types to P_TYPE (which should be a + * native type). If P_TYPE is a negative value then it will be + * computed from the dataset type using only native types. + * + * Note: This function is intended only for datasets since it does + * some things like strip mining which are unnecessary for + * smaller objects such as attributes. The easiest way to print + * small objects is to read the object into memory and call + * h5tools_dump_mem(). + * + * 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, hid_t dset, + hid_t _p_type, struct subset_t *sset, int indentlevel) +{ + hid_t f_space; + hid_t p_type = _p_type; + hid_t f_type; + H5S_class_t space_type; + int status = FAIL; + h5tool_format_t info_dflt; + + /* Use default values */ + if (!stream) + stream = stdout; + + if (!info) { + memset(&info_dflt, 0, sizeof info_dflt); + 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); + + H5Tclose(f_type); + + if (p_type < 0) + goto done; + } + + /* Check the data space */ + f_space = H5Dget_space(dset); + + 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, dset, p_type, indentlevel); + } + else { + status = h5tools_dump_simple_subset(rawdatastream, info, dset, p_type, sset, indentlevel); + } + } + else + /* space is H5S_NULL */ + status = SUCCEED; + + /* Close the dataspace */ + H5Sclose(f_space); + +done: + if (p_type != _p_type) + H5Tclose(p_type); + + return status; +} + +/*------------------------------------------------------------------------- + * Function: h5tools_dump_mem + * + * Purpose: Displays the data contained in MEM. MEM must have the + * specified data TYPE and SPACE. Currently only simple data + * spaces are allowed and only the `all' selection. + * + * Return: Success: SUCCEED + * Failure: FAIL + * + *------------------------------------------------------------------------- + */ +int +h5tools_dump_mem(FILE *stream, const h5tool_format_t *info, hid_t obj_id, hid_t type, + hid_t space, void *mem, int indentlevel) +{ + HERR_INIT(int, SUCCEED) + h5tool_format_t info_dflt; + + /* Use default values */ + if (!stream) + stream = stdout; + + if (!info) { + memset(&info_dflt, 0, sizeof(info_dflt)); + info = &info_dflt; + } + + /* Check the data space */ + if (H5Sis_simple(space) <= 0) + H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sis_simple failed") + + H5_LEAVE(h5tools_dump_simple_mem(stream, info, obj_id, type, space, mem, indentlevel)) +CATCH + return ret_value; +} + +/*------------------------------------------------------------------------- + * Function: print_datatype + * + * Purpose: print the datatype. + * + * Return: void + * + * In/Out: h5tools_str_t *buffer + * h5tools_context_t *ctx + * + *------------------------------------------------------------------------- + */ +int +h5tools_print_datatype(h5tools_str_t *buffer, const h5tool_format_t *info, + h5tools_context_t *ctx, hid_t type) +{ + HERR_INIT(int, FAIL) + char *mname; + hid_t mtype, str_type; + unsigned nmembers; + unsigned ndims; + unsigned i; + size_t size = 0; + hsize_t dims[H5TOOLS_DUMP_MAX_RANK]; + H5T_str_t str_pad; + H5T_cset_t cset; + H5T_order_t order; + H5T_class_t type_class; + hid_t super; + hid_t tmp_type; + htri_t is_vlstr = FALSE; + const char *order_s = NULL; /* byte order string */ + H5T_sign_t sign; /* sign scheme value */ + const char *sign_s = NULL; /* sign scheme string */ + + if((type_class = H5Tget_class(type)) < 0) + H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_class failed"); + 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"; + } + } + 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 { + sign_s = " unknown-sign"; + } + + /* 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_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 { + + /* 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 and byte order */ + h5tools_str_append(buffer, "%lu-bit%s floating-point", + (unsigned long) (8 * H5Tget_size(type)), order_s); + + } + 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); + + h5tools_str_append(buffer, "H5T_STRING %s\n", h5tools_dump_header_format->strblockbegin); + ctx->indent_level++; + + if (is_vlstr) + h5tools_str_append(buffer, "%s H5T_VARIABLE;\n", STRSIZE); + else + h5tools_str_append(buffer, "%s %d;\n", STRSIZE, (int) size); + + h5tools_str_append(buffer, "%s ", STRPAD); + if (str_pad == H5T_STR_NULLTERM) + h5tools_str_append(buffer, "H5T_STR_NULLTERM;\n"); + else if (str_pad == H5T_STR_NULLPAD) + h5tools_str_append(buffer, "H5T_STR_NULLPAD;\n"); + else if (str_pad == H5T_STR_SPACEPAD) + h5tools_str_append(buffer, "H5T_STR_SPACEPAD;\n"); + else + h5tools_str_append(buffer, "H5T_STR_ERROR;\n"); + + h5tools_str_append(buffer, "%s ", CSET); + + if (cset == H5T_CSET_ASCII) + h5tools_str_append(buffer, "H5T_CSET_ASCII;\n"); + else + h5tools_str_append(buffer, "unknown_cset;\n"); + + 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); + + h5tools_str_append(buffer, "%s ", CTYPE); + + /* Check C variable-length string first. Are the two types equal? */ + if (H5Tequal(tmp_type, str_type)) { + h5tools_str_append(buffer, "H5T_C_S1;\n"); + goto done; + } + + /* 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); + + if (H5Tequal(tmp_type, str_type)) { + h5tools_str_append(buffer, "H5T_C_S1;\n"); + goto done; + } + + /* 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); + + H5Tset_cset(str_type, cset); + H5Tset_size(str_type, size); + H5Tset_strpad(str_type, str_pad); + + /* Are the two types equal? */ + if (H5Tequal(tmp_type, str_type)) { + h5tools_str_append(buffer, "H5T_FORTRAN_S1;\n"); + goto done; + } + + /* 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); + + if (H5Tequal(tmp_type, str_type)) { + h5tools_str_append(buffer, "H5T_FORTRAN_S1;\n"); + goto done; + } + + /* Type doesn't match any of above. */ + h5tools_str_append(buffer, "unknown_one_character_type;\n "); + + done: + 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"); + + ctx->indent_level--; + h5tools_str_append(buffer, "%s", h5tools_dump_header_format->strblockend); + break; + + 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; + + case H5T_OPAQUE: + h5tools_str_append(buffer, "\n"); + h5tools_str_append(buffer, "H5T_OPAQUE;\n"); + h5tools_str_append(buffer, "OPAQUE_TAG \"%s\";\n", H5Tget_tag(type)); + break; + + case H5T_COMPOUND: + if((nmembers = H5Tget_nmembers(type)) < 0) + H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_nmembers failed"); + + h5tools_str_append(buffer, "H5T_COMPOUND %s\n", h5tools_dump_header_format->structblockbegin); + + for (i = 0; i < nmembers; i++) { + mname = H5Tget_member_name(type, i); + if((mtype = H5Tget_member_type(type, i))>=0) { + if (H5Tget_class(mtype) == H5T_COMPOUND) + ctx->indent_level++; + + h5tools_print_datatype(buffer, info, ctx, mtype); + + if (H5Tget_class(mtype) == H5T_COMPOUND) + ctx->indent_level--; + + h5tools_str_append(buffer, " \"%s\";\n", mname); + if(H5Tclose(mtype) < 0) + HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed"); + } + else + HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tget_member_type failed"); + free(mname); + } + + h5tools_str_append(buffer, "%s", h5tools_dump_header_format->structblockend); + break; + + case H5T_REFERENCE: + h5tools_str_append(buffer, "H5T_REFERENCE"); + if(region_output) { + 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_ENUM: + if((super = H5Tget_super(type)) < 0) + H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_nmembers failed"); + + h5tools_str_append(buffer, "H5T_ENUM %s\n", h5tools_dump_header_format->enumblockbegin); + ctx->indent_level++; + + h5tools_print_datatype(buffer, info, ctx, super); + if(H5Tclose(super) < 0) + HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed"); + + h5tools_str_append(buffer, ";\n"); + h5tools_print_enum(buffer, type); + + ctx->indent_level--; + h5tools_str_append(buffer, "%s", h5tools_dump_header_format->enumblockend); + + break; - /* initialize the current stripmine position; this is necessary to print the array - indices */ - ctx.sm_pos = elmtno; + case H5T_VLEN: + if((super = H5Tget_super(type)) < 0) + H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_nmembers failed"); - h5tools_dump_simple_data(stream, info, dset, &ctx, flags, hs_nelmts, - p_type, sm_buf); + h5tools_str_append(buffer, "H5T_VLEN %s ", h5tools_dump_header_format->vlenblockbegin); - /* Reclaim any VL memory, if necessary */ - if(vl_data) - H5Dvlen_reclaim(p_type, sm_space, H5P_DEFAULT, sm_buf); + h5tools_print_datatype(buffer, info, ctx, super); + if(H5Tclose(super) < 0) + HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed"); - /* 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_str_append(buffer, "%s", h5tools_dump_header_format->vlenblockend); - if (hs_offset[i - 1] == total_size[i - 1]) - hs_offset[i - 1] = 0; + break; + + case H5T_ARRAY: + h5tools_str_append(buffer, "H5T_ARRAY { "); + + /* Get array information */ + if((ndims = H5Tget_array_ndims(type)) >= 0) { + if(H5Tget_array_dims2(type, dims) >= 0) { + /* Print array dimensions */ + for (i = 0; i < ndims; i++) + h5tools_str_append(buffer, "[%d]", (int) dims[i]); + + h5tools_str_append(buffer, " "); + } else - carry = 0; + 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(buffer, info, ctx, super); + /* 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"); - ctx.continuation++; - } - - /* Terminate the output */ - if (ctx.cur_column) { - fputs(OPT(info->line_suf, ""), stream); - putc('\n', stream); - fputs(OPT(info->line_sep, ""), stream); - } + h5tools_str_append(buffer, " }"); - H5Sclose(sm_space); - H5Sclose(f_space); + break; - free(sm_buf); + default: + h5tools_str_append(buffer, "unknown datatype"); + break; + } - return SUCCEED; +CATCH + return ret_value; } /*------------------------------------------------------------------------- - * Function: h5tools_dump_simple_mem + * Function: print_dataspace * - * Purpose: Print some values from memory with a simple data space. - * This is a special case of h5tools_dump_mem(). - * - * Return: Success: SUCCEED + * Purpose: print the dataspace. * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Thursday, July 23, 1998 + * Return: void * - * Modifications: + * In/Out: h5tools_str_t *buffer + * h5tools_context_t *ctx * *------------------------------------------------------------------------- */ -static int -h5tools_dump_simple_mem(FILE *stream, const h5tool_format_t *info, hid_t obj_id, - hid_t type, hid_t space, void *mem, int indentlevel) +int +h5tools_print_dataspace(h5tools_str_t *buffer, hid_t space) { - int i; /*counters */ - hsize_t nelmts; /*total selected elmts */ - h5tools_context_t ctx; /*printing context */ - - /* - * Check that everything looks okay. The dimensionality must not be too - * great and the dimensionality of the items selected for printing must - * match the dimensionality of the dataset. - */ - memset(&ctx, 0, sizeof(ctx)); - ctx.ndims = H5Sget_simple_extent_ndims(space); - - if ((size_t)ctx.ndims > NELMTS(ctx.p_min_idx)) - return FAIL; - - ctx.indent_level = indentlevel; - ctx.need_prefix = 1; - - /* Assume entire data space to be printed */ - for (i = 0; i < ctx.ndims; i++) - ctx.p_min_idx[i] = 0; - - H5Sget_simple_extent_dims(space, ctx.p_max_idx, NULL); - - for (i = 0, nelmts = 1; ctx.ndims != 0 && i < ctx.ndims; i++) - nelmts *= ctx.p_max_idx[i] - ctx.p_min_idx[i]; + HERR_INIT(int, SUCCEED) + hsize_t size[H5TOOLS_DUMP_MAX_RANK]; + hsize_t maxsize[H5TOOLS_DUMP_MAX_RANK]; + int ndims = -1; + H5S_class_t space_type = -1; + int i; + + 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"); + + switch(space_type) { + case H5S_SCALAR: + /* scalar dataspace */ + h5tools_str_append(buffer, "%s %s", h5tools_dump_header_format->dataspacedescriptionbegin, S_SCALAR); + break; + + case H5S_SIMPLE: + /* simple dataspace */ + h5tools_str_append(buffer, "%s %s { %s %" H5_PRINTF_LL_WIDTH "u", + h5tools_dump_header_format->dataspacedescriptionbegin, S_SIMPLE, + h5tools_dump_header_format->dataspacedimbegin, size[0]); + + for(i = 1; i < ndims; i++) + h5tools_str_append(buffer, ", %" H5_PRINTF_LL_WIDTH "u", size[i]); + + h5tools_str_append(buffer, " %s / ", h5tools_dump_header_format->dataspacedimend); + + if(maxsize[0] == H5S_UNLIMITED) + h5tools_str_append(buffer, "%s %s", + h5tools_dump_header_format->dataspacedimbegin, "H5S_UNLIMITED"); + else + h5tools_str_append(buffer, "%s %" H5_PRINTF_LL_WIDTH "u", + h5tools_dump_header_format->dataspacedimbegin, maxsize[0]); - if (nelmts == 0) - return SUCCEED; /*nothing to print*/ - if(ctx.ndims>0) { - assert(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]); - } /* end if */ - else - ctx.size_last_dim = 0; + for(i = 1; i < ndims; i++) + if(maxsize[i] == H5S_UNLIMITED) + h5tools_str_append(buffer, ", %s", "H5S_UNLIMITED"); + else + h5tools_str_append(buffer, ", %" H5_PRINTF_LL_WIDTH "u", maxsize[i]); - if(ctx.ndims>0) - init_acc_pos(&ctx,ctx.p_max_idx); + h5tools_str_append(buffer, " %s }", h5tools_dump_header_format->dataspacedimend); + break; - /* Print it */ - h5tools_dump_simple_data(stream, info, obj_id, &ctx, - START_OF_DATA | END_OF_DATA, nelmts, type, mem); + case H5S_NULL: + /* null dataspace */ + h5tools_str_append(buffer, "%s %s", h5tools_dump_header_format->dataspacedescriptionbegin, S_NULL); + break; - /* Terminate the output */ - if (ctx.cur_column) { - fputs(OPT(info->line_suf, ""), stream); - putc('\n', stream); - fputs(OPT(info->line_sep, ""), stream); - } + case H5S_NO_CLASS: + default: + h5tools_str_append(buffer, "%s unknown dataspace %s\n", BEGIN, END); + break; + } /* end switch */ - return SUCCEED; +CATCH + return ret_value; } + /*------------------------------------------------------------------------- - * Function: h5tools_dump_dset - * - * Purpose: Print some values from a dataset DSET to the file STREAM - * after converting all types to P_TYPE (which should be a - * native type). If P_TYPE is a negative value then it will be - * computed from the dataset type using only native types. - * - * Note: This function is intended only for datasets since it does - * some things like strip mining which are unnecessary for - * smaller objects such as attributes. The easiest way to print - * small objects is to read the object into memory and call - * h5tools_dump_mem(). - * - * Return: Success: SUCCEED - * - * Failure: FAIL + * Function: print_enum * - * Programmer: Robb Matzke - * Thursday, July 23, 1998 + * Purpose: prints the enum data * - * Modifications: - * Robb Matzke, 1999-06-07 - * If info->raw is set then the memory datatype will be the same - * as the file datatype. + * Return: void * - * Bill Wendling, 2001-02-27 - * Renamed to ``h5tools_dump_dset'' and added the subsetting - * parameter. + * In/Out: h5tools_str_t *buffer + * h5tools_context_t *ctx * - *------------------------------------------------------------------------- - */ -int -h5tools_dump_dset(FILE *stream, const h5tool_format_t *info, hid_t dset, hid_t _p_type, - struct subset_t *sset, int indentlevel) + *-----------------------------------------------------------------------*/ +int +h5tools_print_enum(h5tools_str_t *buffer, hid_t type) { - hid_t f_space; - hid_t p_type = _p_type; - hid_t f_type; - H5S_class_t space_type; - int status = FAIL; - h5tool_format_t info_dflt; + HERR_INIT(int, SUCCEED) + char **name = NULL; /*member names */ + unsigned char *value = NULL; /*value array */ + unsigned char *copy = NULL; /*a pointer to value array */ + unsigned nmembs; /*number of members */ + 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 */ + unsigned i; + + if((nmembs = H5Tget_nmembers(type)) < 0) + H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_nmembers failed"); + assert(nmembs > 0); + + if((super = H5Tget_super(type)) < 0) + H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_super failed"); + + if((type_size = H5Tget_size(type)) <= 0) + H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size(type) failed"); + /* + * Determine what datatype to use for the native values. To simplify + * things we entertain three possibilities: + * 1. long long -- the largest native signed integer + * 2. unsigned long long -- the largest native unsigned integer + * 3. raw format + */ + if (type_size <= sizeof(long long)) { + dst_size = sizeof(long long); - /* Use default values */ - if (!stream) - stream = stdout; + if((sign_type = H5Tget_sign(type))<0) + H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_sign failed"); + if (H5T_SGN_NONE == sign_type) { + native = H5T_NATIVE_ULLONG; + } + else { + native = H5T_NATIVE_LLONG; + } + } + else { + dst_size = type_size; + } - if (!info) { - memset(&info_dflt, 0, sizeof info_dflt); - info = &info_dflt; + /* Get the names and raw values of all members */ + if((name = calloc(nmembs, sizeof(char *))) == NULL) + H5E_THROW(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for member name"); + if((value = calloc(nmembs, MAX(type_size, dst_size))) == NULL) + H5E_THROW(FAIL, H5E_tools_min_id_g, "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 (p_type < 0) { - f_type = H5Dget_type(dset); + /* 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 (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); + /* + * Sort members by increasing value + * ***not implemented yet*** + */ - H5Tclose(f_type); + /* Print members */ + for (i = 0; i < nmembs; i++) { + h5tools_str_append(buffer, "\"%s\"", name[i]); + nchars = strlen(name[i]); + h5tools_str_append(buffer, "%*s ", MAX(0, 16 - nchars), ""); - if (p_type < 0) - goto done; - } + if (native < 0) { + size_t j; - /* Check the data space */ - f_space = H5Dget_space(dset); + h5tools_str_append(buffer, "0x"); - space_type = H5Sget_simple_extent_type(f_space); + for (j = 0; j < dst_size; j++) + h5tools_str_append(buffer, "%02x", value[i * dst_size + j]); + } + else if (H5T_SGN_NONE == H5Tget_sign(native)) { + /*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size" + *strangely, unless use another pointer "copy".*/ + copy = value + i * dst_size; + h5tools_str_append(buffer, "%" H5_PRINTF_LL_WIDTH "u", *((unsigned long long *) ((void *) 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))); + } - /* Print the data */ - if (space_type == H5S_SIMPLE || space_type == H5S_SCALAR) { - if (!sset) - status = h5tools_dump_simple_dset(rawdatastream, info, dset, p_type, - indentlevel); - else - status = h5tools_dump_simple_subset(rawdatastream, info, dset, p_type, - sset, indentlevel); - } else /* space is H5S_NULL */ - status = SUCCEED; + h5tools_str_append(buffer, ";\n"); + } - /* Close the dataspace */ - H5Sclose(f_space); +CATCH -done: - if (p_type != _p_type) - H5Tclose(p_type); + /* Release resources */ + for (i = 0; i < nmembs; i++) + free(name[i]); - return status; + free(name); + free(value); + + if(H5Tclose(super) < 0) + H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); + + if (0 == nmembs) + h5tools_str_append(buffer, "\n"); + + return ret_value; } /*------------------------------------------------------------------------- - * Function: h5tools_dump_mem - * - * Purpose: Displays the data contained in MEM. MEM must have the - * specified data TYPE and SPACE. Currently only simple data - * spaces are allowed and only the `all' selection. + * Function: dump_datatype * - * Return: Success: SUCCEED - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Wednesday, January 20, 1999 - * - * Modifications: + * Purpose: Dump the datatype. Datatype can be HDF5 predefined + * atomic datatype or committed/transient datatype. * + * Return: void + * + * In/Out: h5tools_context_t *ctx *------------------------------------------------------------------------- */ -int -h5tools_dump_mem(FILE *stream, const h5tool_format_t *info, hid_t obj_id, hid_t type, - hid_t space, void *mem, int indentlevel) +void +h5tools_dump_datatype(FILE *stream, const h5tool_format_t *info, + h5tools_context_t *ctx, hid_t type) { - h5tool_format_t info_dflt; + size_t ncols = 80; /* available output width */ + h5tools_str_t buffer; /* string into which to render */ + hsize_t curr_pos; /* total data element position */ + hsize_t elmt_counter = 0;/* counts the # elements printed.*/ - /* Use default values */ - if (!stream) - stream = stdout; + /* setup */ + HDmemset(&buffer, 0, sizeof(h5tools_str_t)); - if (!info) { - memset(&info_dflt, 0, sizeof(info_dflt)); - info = &info_dflt; + if (info->line_ncols > 0) + ncols = info->line_ncols; + + /* 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 + */ + curr_pos = ctx->sm_pos; + + h5tools_simple_prefix(stream, info, ctx, curr_pos, 0); + /* Render the element */ + h5tools_str_reset(&buffer); + + ctx->indent_level++; + h5tools_str_append(&buffer, "%s %s ", + h5tools_dump_header_format->datatypebegin, + h5tools_dump_header_format->datatypeblockbegin); + + h5tools_print_datatype(&buffer, info, ctx, type); + + 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); + h5tools_str_append(&buffer, "\n"); - /* Check the data space */ - if (H5Sis_simple(space) <= 0) - return -1; + curr_pos = h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, + ncols, elmt_counter, 0); - return h5tools_dump_simple_mem(stream, info, obj_id, type, space, mem, - indentlevel); + ctx->need_prefix = TRUE; + ctx->indent_level--; } /*------------------------------------------------------------------------- @@ -1484,29 +3454,23 @@ h5tools_dump_mem(FILE *stream, const h5tool_format_t *info, hid_t obj_id, hid_t * Purpose: initialize accumulator and matrix position * * Return: void - * - * Programmer: pvn - * - * Modifications: - * *------------------------------------------------------------------------- */ -void init_acc_pos(h5tools_context_t *ctx, hsize_t *dims) +void +init_acc_pos(h5tools_context_t *ctx, hsize_t *dims) { - int i; + int i; - assert(ctx->ndims); + assert(ctx->ndims); - ctx->acc[ctx->ndims-1]=1; - for(i=(ctx->ndims-2); i>=0; i--) - { - ctx->acc[i]=ctx->acc[i+1] * dims[i+1]; - } - for ( i = 0; i < ctx->ndims; i++) - ctx->pos[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]; + } + for (i = 0; i < ctx->ndims; i++) + ctx->pos[i] = 0; } - /*------------------------------------------------------------------------- * Function: do_bin_output * @@ -1514,35 +3478,29 @@ void init_acc_pos(h5tools_context_t *ctx, hsize_t *dims) * * Return: Success: SUCCEED * Failure: FAIL - * - * Programmer: Pedro Vicente Nunes - * Friday, June 2, 2006 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int do_bin_output(FILE *stream, hsize_t nelmts, hid_t tid, void *_mem) { - unsigned char *mem = (unsigned char*)_mem; - size_t size; /* datum size */ - hsize_t i; /* element counter */ - - size = H5Tget_size(tid); - - for (i = 0; i < nelmts; i++) - { - if (render_bin_output(stream,tid,mem + i * size)<0) - { - printf("\nError in writing binary stream\n"); - return FAIL; - } - } - - return SUCCEED; -} + HERR_INIT(int, SUCCEED) + unsigned char *mem = (unsigned char*)_mem; + size_t size; /* datum size */ + hsize_t i; /* element counter */ + if((size = H5Tget_size(tid)) == 0) + H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed"); + + for (i = 0; i < nelmts; i++) { + if (render_bin_output(stream, tid, mem + i * size) < 0) { + printf("\nError in writing binary stream\n"); + return FAIL; + } + } + +CATCH + return ret_value; +} /*------------------------------------------------------------------------- * Function: render_bin_output @@ -1551,395 +3509,372 @@ int do_bin_output(FILE *stream, hsize_t nelmts, hid_t tid, void *_mem) * * Return: Success: SUCCEED * Failure: FAIL - * - * Programmer: Pedro Vicente Nunes - * Friday, June 2, 2006 - * - * Modifications: - * *------------------------------------------------------------------------- */ -static -int render_bin_output(FILE *stream, hid_t tid, void *_mem) +static int +render_bin_output(FILE *stream, hid_t tid, void *_mem) { - 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; + 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; + long double templdouble; #endif #ifdef DEBUG_H5DUMP_BIN - static char fmt_llong[8], fmt_ullong[8]; - if (!fmt_llong[0]) { - sprintf(fmt_llong, "%%%sd", H5_PRINTF_LL_WIDTH); - sprintf(fmt_ullong, "%%%su", H5_PRINTF_LL_WIDTH); - } + static char fmt_llong[8], fmt_ullong[8]; + if (!fmt_llong[0]) { + sprintf(fmt_llong, "%%%sd", H5_PRINTF_LL_WIDTH); + sprintf(fmt_ullong, "%%%su", H5_PRINTF_LL_WIDTH); + } #endif - size = H5Tget_size(tid); + if((size = H5Tget_size(tid)) == 0) + H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed"); - if (H5Tequal(tid, H5T_NATIVE_FLOAT)) - { - memcpy(&tempfloat, mem, sizeof(float)); + if (H5Tequal(tid, H5T_NATIVE_FLOAT)) { + memcpy(&tempfloat, mem, sizeof(float)); #ifdef DEBUG_H5DUMP_BIN - fprintf(stream, "%g ", tempfloat); + fprintf(stream, "%g ", tempfloat); #else - if (1 != fwrite(&tempfloat, size, 1, stream)) - return FAIL; + if (1 != fwrite(&tempfloat, size, 1, stream)) + H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); #endif - } - else if (H5Tequal(tid, H5T_NATIVE_DOUBLE)) - { - memcpy(&tempdouble, mem, sizeof(double)); + } + else if (H5Tequal(tid, H5T_NATIVE_DOUBLE)) { + memcpy(&tempdouble, mem, sizeof(double)); #ifdef DEBUG_H5DUMP_BIN - fprintf(stream, "%g ", tempdouble); + fprintf(stream, "%g ", tempdouble); #else - if (1 != fwrite(&tempdouble, size, 1, stream)) - return FAIL; + if (1 != fwrite(&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)) - { - memcpy(&templdouble, mem, sizeof(long double)); + else if (H5Tequal(tid, H5T_NATIVE_LDOUBLE)) { + memcpy(&templdouble, mem, sizeof(long double)); #ifdef DEBUG_H5DUMP_BIN - fprintf(stream, "%Lf ", templdouble); + fprintf(stream, "%Lf ", templdouble); #else - if (1 != fwrite(&templdouble, size, 1, stream)) - return FAIL; + if (1 != fwrite(&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; - size = H5Tget_size(tid); - } - for (i=0; i= 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,memb,mem + i * size)<0) - return FAIL; - } - - 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,memb,((char *)(((hvl_t *)mem)->p)) + i * size)<0) - return FAIL; - } - H5Tclose(memb); - } - else - { - size_t i; - if (1==size) - { + } /*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); + assert(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, 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, memb, ((char *) (((hvl_t *) mem)->p)) + i * size) < 0) + H5E_THROW(FAIL, H5E_tools_min_id_g, "render_bin_output failed"); + } + H5Tclose(memb); + } + else { + size_t i; + if (1 == size) { #ifdef DEBUG_H5DUMP_BIN - fprintf(stream, "0x%02x", mem[0]); + fprintf(stream, "0x%02x", mem[0]); #else - if (1 != fwrite(&mem[0], size, 1, stream)) - return FAIL; + if (1 != fwrite(&mem[0], size, 1, stream)) + H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); #endif - } - else - { - for (i = 0; i < size; i++) - { + } + else { + for (i = 0; i < size; i++) { #ifdef DEBUG_H5DUMP_BIN - fprintf(stream, "%s%02x", i?":":"", mem[i]); + fprintf(stream, "%s%02x", i?":":"", mem[i]); #else - if (1 != fwrite(&mem[i], sizeof(char), 1, stream)) - return FAIL; + if (1 != fwrite(&mem[i], sizeof(char), 1, stream)) + H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); #endif - } /*i*/ - }/*else 1 */ - } + } /*i*/ + }/*else 1 */ + } + +CATCH + return ret_value; +} + +/*------------------------------------------------------------------------- + * Function: h5tools_is_zero + * + * Purpose: Determines if memory is initialized to all zero bytes. + * + * Return: TRUE if all bytes are zero; FALSE otherwise + *------------------------------------------------------------------------- + */ +static +hbool_t h5tools_is_zero(const void *_mem, size_t size) +{ + const unsigned char *mem = (const unsigned char *) _mem; + while (size-- > 0) + if (mem[size]) + return FALSE; - return SUCCEED; + return TRUE; } diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h index fb24f76..2b1e4bf 100644 --- a/tools/lib/h5tools.h +++ b/tools/lib/h5tools.h @@ -23,6 +23,7 @@ #define H5TOOLS_H__ #include "hdf5.h" +#include "h5tools_error.h" #define ESCAPE_HTML 1 #define OPT(X,S) ((X) ? (X) : (S)) @@ -50,6 +51,147 @@ /* format for hsize_t */ #define HSIZE_T_FORMAT "%"H5_PRINTF_LL_WIDTH"u" +#define H5TOOLS_DUMP_MAX_RANK H5S_MAX_RANK + +/* + * 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 BEGIN "{" +#define END "}" + +/* + * dump structure for output - this was duplicated from the h5dump.h + * file in order to support region reference data display + */ +typedef struct h5tools_dump_header_t { + const char *name; + const char *filebegin; + const char *fileend; + const char *bootblockbegin; + const char *bootblockend; + const char *groupbegin; + const char *groupend; + const char *datasetbegin; + const char *datasetend; + const char *attributebegin; + const char *attributeend; + const char *datatypebegin; + const char *datatypeend; + const char *dataspacebegin; + const char *dataspaceend; + const char *databegin; + const char *dataend; + const char *softlinkbegin; + const char *softlinkend; + const char *extlinkbegin; + const char *extlinkend; + const char *udlinkbegin; + const char *udlinkend; + const char *subsettingbegin; + const char *subsettingend; + const char *startbegin; + const char *startend; + const char *stridebegin; + const char *strideend; + const char *countbegin; + const char *countend; + const char *blockbegin; + const char *blockend; + + const char *fileblockbegin; + const char *fileblockend; + const char *bootblockblockbegin; + const char *bootblockblockend; + const char *groupblockbegin; + const char *groupblockend; + const char *datasetblockbegin; + const char *datasetblockend; + const char *attributeblockbegin; + const char *attributeblockend; + const char *datatypeblockbegin; + const char *datatypeblockend; + const char *dataspaceblockbegin; + const char *dataspaceblockend; + const char *datablockbegin; + const char *datablockend; + const char *softlinkblockbegin; + const char *softlinkblockend; + const char *extlinkblockbegin; + const char *extlinkblockend; + const char *udlinkblockbegin; + const char *udlinkblockend; + const char *strblockbegin; + const char *strblockend; + const char *enumblockbegin; + const char *enumblockend; + const char *structblockbegin; + const char *structblockend; + const char *vlenblockbegin; + const char *vlenblockend; + const char *subsettingblockbegin; + const char *subsettingblockend; + const char *startblockbegin; + const char *startblockend; + const char *strideblockbegin; + const char *strideblockend; + const char *countblockbegin; + const char *countblockend; + const char *blockblockbegin; + const char *blockblockend; + + const char *dataspacedescriptionbegin; + const char *dataspacedescriptionend; + const char *dataspacedimbegin; + const char *dataspacedimend; + +} h5tools_dump_header_t; + /* * Information about how to format output. */ @@ -373,11 +515,16 @@ struct subset_t { hsize_t *block; }; +/* The following include, h5tools_str.h, must be after the + * above stucts are defined. There is a dependency in the following + * include that hasn't been identified yet. */ + +#include "h5tools_str.h" + extern FILE *rawdatastream; /* output stream for raw data */ extern int bin_output; /* binary output */ extern int bin_form; /* binary form */ - - +extern int region_output; /* region output */ /* Strings for output */ #define H5_TOOLS_GROUP "GROUP" @@ -407,6 +554,15 @@ extern int h5tools_canreadf(const char* name, extern int h5tools_can_encode(H5Z_filter_t filtn); void init_acc_pos(h5tools_context_t *ctx, hsize_t *dims); - +/* + * new functions needed to display region reference data + */ +void h5tools_dump_datatype(FILE *stream, const h5tool_format_t *info, + h5tools_context_t *ctx/*in,out*/, hid_t type); +int h5tools_print_dataspace(h5tools_str_t *buffer/*in,out*/, hid_t space); +int h5tools_print_datatype(h5tools_str_t *buffer/*in,out*/, + const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, + hid_t type); +int h5tools_print_enum(h5tools_str_t *buffer/*in,out*/, hid_t type); #endif /* H5TOOLS_H__ */ diff --git a/tools/lib/h5tools_error.h b/tools/lib/h5tools_error.h new file mode 100644 index 0000000..9efe223 --- /dev/null +++ b/tools/lib/h5tools_error.h @@ -0,0 +1,118 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Header file for error values, etc. + */ +#ifndef H5TOOLS_ERROR_H_ +#define H5TOOLS_ERROR_H_ + +#include "H5Epublic.h" + +/* tools-HDF5 Error variables */ +extern hid_t H5tools_ERR_CLS_g; +extern hid_t H5E_tools_g; +extern 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_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"); \ +} + +/* + * H5TOOLS_CLOSE_ERROR macro, used to initialize error reporting. + */ +#define H5TOOLS_CLOSE_ERROR() { \ + H5Eclose_msg(H5E_tools_min_id_g); \ + H5Eclose_msg(H5E_tools_g); \ + H5Eunregister_class(H5tools_ERR_CLS_g); \ +} + +/* + * 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. + */ +#define HERR_INIT(ret_typ, ret_init) \ + hbool_t past_catch = FALSE; \ + ret_typ ret_value = ret_init; + + +/* + * HERROR macro, used to facilitate error reporting . The arguments are the major + * error number, the minor error number, and a description of the error. + */ +#define HERROR(maj_id, min_id, str) H5Epush2(H5E_DEFAULT, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, maj_id, min_id, str) + +/* 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 CATCH past_catch = TRUE; catch_except:; + +/* + * 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. + */ +#define H5_LEAVE(v) { \ + ret_value = v; \ + if(!past_catch) \ + goto catch_except; \ +} + +/* + * 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. + */ +#define H5E_THROW(fail_value, min_id, str) { \ + HERROR(H5E_tools_g, min_id, str); \ + H5_LEAVE(fail_value) \ +} + +/* + * 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. + */ +#define HGOTO_ERROR(fail_value, min_id, str) { \ + HERROR(H5E_tools_g, min_id, str); \ + HGOTO_DONE(fail_value) \ +} + +/* + * 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. + */ +#define HGOTO_DONE(ret_val) {ret_value = ret_val; goto done;} + +#endif /* H5TOOLS_ERROR_H_ */ diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index 08ec5d7..3567975 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -29,7 +29,6 @@ #include "h5tools_ref.h" #include "h5tools_str.h" /*function prototypes */ - /* * If REPEAT_VERBOSE is defined then character strings will be printed so * that repeated character sequences like "AAAAAAAAAA" are displayed as @@ -47,7 +46,7 @@ #define STR_INIT_LEN 4096 /*initial length */ static char *h5tools_escape(char *s, size_t size); -static hbool_t h5tools_is_zero(const void *_mem, 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); /*------------------------------------------------------------------------- @@ -161,7 +160,7 @@ h5tools_str_append(h5tools_str_t *str/*in,out*/, const char *fmt, ...) * something other than "%s" * Alocate 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 + nchars + 1, 2 * str->nalloc); assert(newsize > str->nalloc); /*overflow*/ str->s = realloc(str->s, newsize); assert(str->s); @@ -198,9 +197,9 @@ char * h5tools_str_reset(h5tools_str_t *str/*in,out*/) { if (!str->s || str->nalloc <= 0) { - str->nalloc = STR_INIT_LEN; - str->s = malloc(str->nalloc); - assert(str->s); + str->nalloc = STR_INIT_LEN; + str->s = malloc(str->nalloc); + assert(str->s); } str->s[0] = '\0'; @@ -228,8 +227,8 @@ char * h5tools_str_trunc(h5tools_str_t *str/*in,out*/, size_t size) { if (size < str->len) { - str->len = size; - str->s[size] = '\0'; + str->len = size; + str->s[size] = '\0'; } return str->s; @@ -270,7 +269,7 @@ h5tools_str_fmt(h5tools_str_t *str/*in,out*/, size_t start, const char *fmt) */ if (strchr(fmt, '%')) { if (str->len - start + 1 > sizeof(_temp)) { - temp = malloc(str->len-start + 1); + temp = malloc(str->len - start + 1); assert(temp); } @@ -309,6 +308,59 @@ h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info, hsize_t elmtno, unsigned ndims, hsize_t min_idx[], hsize_t max_idx[], h5tools_context_t *ctx) { + 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 = 0; i < (size_t) ndims; i++) { + ctx->pos[i] = curr_pos / ctx->acc[i]; + curr_pos -= ctx->acc[i] * ctx->pos[i]; + } + assert(curr_pos == 0); + + /* Print the index values */ + for (i = 0; i < (size_t) 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]); + + } + } + else { + /* Scalar */ + h5tools_str_append(str, OPT(info->idx_n_fmt, HSIZE_T_FORMAT), (hsize_t) 0); + } + + /* Add prefix and suffix to the index */ + return h5tools_str_fmt(str, 0, OPT(info->idx_fmt, "%s: ")); +} + +/*------------------------------------------------------------------------- + * Function: h5tools_str_region_prefix + * + * Purpose: Renders the line prefix value into string STR. Region reference specific. + * + * 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 min_idx[], hsize_t max_idx[], + h5tools_context_t *ctx) +{ hsize_t p_prod[H5S_MAX_RANK]; size_t i = 0; hsize_t curr_pos = elmtno; @@ -321,26 +373,26 @@ h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info, * certain index position. */ for (i = ndims - 1, p_prod[ndims - 1] = 1; i > 0; --i) - p_prod[i - 1] = (max_idx[i] - min_idx[i]) * p_prod[i]; + p_prod[i - 1] = (max_idx[i]) * p_prod[i]; - for ( i = 0; i < (size_t)ndims; i++) { - ctx->pos[i] = curr_pos/ctx->acc[i]; - curr_pos -= ctx->acc[i]*ctx->pos[i]; + for (i = 0; i < (size_t) ndims; i++) { + ctx->pos[i] = curr_pos / p_prod[i]; + curr_pos -= p_prod[i] * ctx->pos[i]; + ctx->pos[i] += (unsigned long) ptdata[ctx->sm_pos+i]; } - assert( curr_pos == 0 ); /* Print the index values */ - for (i = 0; i < (size_t)ndims; i++) { + for (i = 0; i < (size_t) 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]); + h5tools_str_append(str, OPT(info->idx_n_fmt, HSIZE_T_FORMAT), (hsize_t) ctx->pos[i]); } - } else { + } /* if (ndims > 0) */ + else { /* Scalar */ - h5tools_str_append(str, OPT(info->idx_n_fmt, HSIZE_T_FORMAT), (hsize_t)0); + h5tools_str_append(str, OPT(info->idx_n_fmt, HSIZE_T_FORMAT), (hsize_t) 0); } /* Add prefix and suffix to the index */ @@ -348,103 +400,120 @@ h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info, } /*------------------------------------------------------------------------- - * Function: h5tools_str_dump_region + * Function: h5tools_str_dump_region_blocks * * Purpose: Prints information about a dataspace region by appending - * the information to the specified string. - * - * Return: Success: 0 - * - * Failure: NULL - * - * Programmer: Robb Matzke - * Monday, June 7, 1999 - * - * Modifications: + * the information to the specified string. * + * Return: none + * + * In/Out: + * h5tools_context_t *ctx + * h5tools_str_t *str *------------------------------------------------------------------------- */ -int -h5tools_str_dump_region(h5tools_str_t *str, hid_t region, const h5tool_format_t *info) +void +h5tools_str_dump_region_blocks(h5tools_str_t *str, hid_t region, + const h5tool_format_t *info, h5tools_context_t *ctx) { - hssize_t nblocks, npoints; - hsize_t alloc_size; - hsize_t *ptdata; - int ndims = H5Sget_simple_extent_ndims(region); + hssize_t nblocks; + hsize_t alloc_size; + hsize_t *ptdata; + int ndims = H5Sget_simple_extent_ndims(region); /* - * 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. + * This function fails if the region does not have blocks. */ H5E_BEGIN_TRY { nblocks = H5Sget_select_hyper_nblocks(region); - npoints = H5Sget_select_elem_npoints(region); } H5E_END_TRY; - h5tools_str_append(str, "{"); - /* Print block information */ if (nblocks > 0) { int i; alloc_size = nblocks * ndims * 2 * sizeof(ptdata[0]); - assert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/ - ptdata = malloc((size_t)alloc_size); + assert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/ + ptdata = malloc((size_t) alloc_size); H5_CHECK_OVERFLOW(nblocks, hssize_t, hsize_t); H5Sget_select_hyper_blocklist(region, (hsize_t)0, (hsize_t)nblocks, ptdata); for (i = 0; i < nblocks; i++) { int j; - h5tools_str_append(str, info->dset_blockformat_pre, - i ? "," OPTIONAL_LINE_BREAK " " : "", + h5tools_str_append(str, info->dset_blockformat_pre, i ? "," OPTIONAL_LINE_BREAK " " : "", (unsigned long)i); /* Start coordinates and opposite corner */ for (j = 0; j < ndims; j++) h5tools_str_append(str, "%s%lu", j ? "," : "(", - (unsigned long)ptdata[i * 2 * ndims + j]); + (unsigned long) ptdata[i * 2 * ndims + j]); for (j = 0; j < ndims; j++) h5tools_str_append(str, "%s%lu", j ? "," : ")-(", - (unsigned long)ptdata[i * 2 * ndims + j + ndims]); + (unsigned long) ptdata[i * 2 * ndims + j + ndims]); h5tools_str_append(str, ")"); } free(ptdata); - } + } /* end if (nblocks > 0) */ +} + +/*------------------------------------------------------------------------- + * Function: h5tools_str_dump_region_points + * + * Purpose: Prints information about a dataspace region by appending + * the information to the specified string. + * + * Return: none + * + * In/Out: + * h5tools_context_t *ctx + * h5tools_str_t *str + *------------------------------------------------------------------------- + */ +void +h5tools_str_dump_region_points(h5tools_str_t *str, hid_t region, + const h5tool_format_t *info, h5tools_context_t *ctx) +{ + hssize_t npoints; + hsize_t alloc_size; + hsize_t *ptdata; + int ndims = H5Sget_simple_extent_ndims(region); + + /* + * This function fails if the region does not have points. + */ + H5E_BEGIN_TRY { + npoints = H5Sget_select_elem_npoints(region); + } H5E_END_TRY; /* Print point information */ if (npoints > 0) { int i; alloc_size = npoints * ndims * sizeof(ptdata[0]); - assert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/ - ptdata = malloc((size_t)alloc_size); - H5_CHECK_OVERFLOW(npoints,hssize_t,hsize_t); + assert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/ + ptdata = malloc((size_t) alloc_size); + H5_CHECK_OVERFLOW(npoints, hssize_t, hsize_t); H5Sget_select_elem_pointlist(region, (hsize_t)0, (hsize_t)npoints, ptdata); for (i = 0; i < npoints; i++) { int j; - h5tools_str_append(str, info->dset_ptformat_pre , - i ? "," OPTIONAL_LINE_BREAK " " : "", + h5tools_str_append(str, info->dset_ptformat_pre, i ? "," OPTIONAL_LINE_BREAK " " : "", (unsigned long)i); for (j = 0; j < ndims; j++) h5tools_str_append(str, "%s%lu", j ? "," : "(", - (unsigned long)(ptdata[i * ndims + j])); + (unsigned long) (ptdata[i * ndims + j])); h5tools_str_append(str, ")"); } free(ptdata); - } - - h5tools_str_append(str, "}"); - return 0; + } /* end if (npoints > 0) */ } /*------------------------------------------------------------------------- @@ -454,11 +523,6 @@ h5tools_str_dump_region(h5tools_str_t *str, hid_t region, const h5tool_format_t * * Return: Nothing * - * Programmer: Bill Wendling - * Tuesday, 20. February 2001 - * - * Modifications: - * *------------------------------------------------------------------------- */ static void @@ -469,66 +533,66 @@ h5tools_print_char(h5tools_str_t *str, const h5tool_format_t *info, char ch) h5tools_str_append(str, "%%%02x", ch); else h5tools_str_append(str, "%c", ch); - } else { + } + else { switch (ch) { - case '"': - if (!info->do_escape) + case '"': + if (!info->do_escape) h5tools_str_append(str, "\""); - else + else h5tools_str_append(str, "\\\""); - break; - case '\\': - if (!info->do_escape) + break; + case '\\': + if (!info->do_escape) h5tools_str_append(str, "\\"); - else + else h5tools_str_append(str, "\\\\"); - break; - case '\b': - if (!info->do_escape) + break; + case '\b': + if (!info->do_escape) h5tools_str_append(str, "\b"); - else + 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 + 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 + 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; + 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; } } } - /*------------------------------------------------------------------------- * Function: h5tools_str_sprint * @@ -592,7 +656,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai int tempint; /* Build default formats for long long types */ - if(!fmt_llong[0]) { + if (!fmt_llong[0]) { sprintf(fmt_llong, "%%%sd", H5_PRINTF_LL_WIDTH); sprintf(fmt_ullong, "%%%su", H5_PRINTF_LL_WIDTH); } @@ -600,63 +664,70 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai /* Append value depending on data type */ start = h5tools_str_len(str); - if(info->raw) { + if (info->raw) { size_t i; n = H5Tget_size(type); - if (1==n) { + if (1 == n) { h5tools_str_append(str, OPT(info->fmt_raw, "0x%02x"), ucp_vp[0]); - } else { - for(i = 0; i < n; i++) { - if(i) + } + else { + for (i = 0; i < n; 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; + } + 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; + } + 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; + } + 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)) { + } + 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)) { + 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) + s = *(char**) cp_vp; + if (s != NULL) size = HDstrlen(s); - } else { + } + else { s = cp_vp; size = H5Tget_size(type); } pad = H5Tget_strpad(type); /* Check for NULL pointer for string */ - if(s==NULL) { + if (s == NULL) { h5tools_str_append(str, "NULL"); } else { - for (i=0; ifmt_int, "%d"), tempint); - } else if (H5Tequal(type, H5T_NATIVE_UINT)) { + } + else if (H5Tequal(type, H5T_NATIVE_UINT)) { HDmemcpy(&tempuint, vp, sizeof(unsigned int)); h5tools_str_append(str, OPT(info->fmt_uint, "%u"), tempuint); - } else if (H5Tequal(type, H5T_NATIVE_SCHAR)) { + } + else if (H5Tequal(type, H5T_NATIVE_SCHAR)) { h5tools_str_append(str, OPT(info->fmt_schar, "%d"), *cp_vp); - } else if (H5Tequal(type, H5T_NATIVE_UCHAR)) { + } + else if (H5Tequal(type, H5T_NATIVE_UCHAR)) { h5tools_str_append(str, OPT(info->fmt_uchar, "%u"), *ucp_vp); - } else if (H5Tequal(type, H5T_NATIVE_SHORT)) { - short tempshort; + } + else if (H5Tequal(type, H5T_NATIVE_SHORT)) { + short tempshort; HDmemcpy(&tempshort, vp, sizeof(short)); h5tools_str_append(str, OPT(info->fmt_short, "%d"), tempshort); - } else if (H5Tequal(type, H5T_NATIVE_USHORT)) { - unsigned short tempushort; + } + else if (H5Tequal(type, H5T_NATIVE_USHORT)) { + unsigned short tempushort; HDmemcpy(&tempushort, vp, sizeof(unsigned short)); h5tools_str_append(str, OPT(info->fmt_ushort, "%u"), tempushort); - } else if (H5Tequal(type, H5T_NATIVE_LONG)) { + } + else if (H5Tequal(type, H5T_NATIVE_LONG)) { HDmemcpy(&templong, vp, sizeof(long)); h5tools_str_append(str, OPT(info->fmt_long, "%ld"), templong); - } else if (H5Tequal(type, H5T_NATIVE_ULONG)) { + } + else if (H5Tequal(type, H5T_NATIVE_ULONG)) { HDmemcpy(&tempulong, vp, sizeof(unsigned long)); h5tools_str_append(str, OPT(info->fmt_ulong, "%lu"), tempulong); - } else if (H5Tequal(type, H5T_NATIVE_LLONG)) { + } + else if (H5Tequal(type, H5T_NATIVE_LLONG)) { HDmemcpy(&templlong, vp, sizeof(long long)); h5tools_str_append(str, OPT(info->fmt_llong, fmt_llong), templlong); - } else if (H5Tequal(type, H5T_NATIVE_ULLONG)) { + } + else if (H5Tequal(type, H5T_NATIVE_ULLONG)) { HDmemcpy(&tempullong, vp, sizeof(unsigned long long)); h5tools_str_append(str, OPT(info->fmt_ullong, fmt_ullong), tempullong); - } else if (H5Tequal(type, H5T_NATIVE_HSSIZE)) { + } + else if (H5Tequal(type, H5T_NATIVE_HSSIZE)) { if (sizeof(hssize_t) == sizeof(int)) { memcpy(&tempint, vp, sizeof(int)); h5tools_str_append(str, OPT(info->fmt_int, "%d"), tempint); - } else if (sizeof(hssize_t) == sizeof(long)) { + } + else if (sizeof(hssize_t) == sizeof(long)) { memcpy(&templong, vp, sizeof(long)); h5tools_str_append(str, OPT(info->fmt_long, "%ld"), templong); - } else { + } + else { memcpy(&templlong, vp, sizeof(long long)); h5tools_str_append(str, OPT(info->fmt_llong, fmt_llong), templlong); } - } else if (H5Tequal(type, H5T_NATIVE_HSIZE)) { + } + else if (H5Tequal(type, H5T_NATIVE_HSIZE)) { if (sizeof(hsize_t) == sizeof(int)) { memcpy(&tempuint, vp, sizeof(unsigned int)); h5tools_str_append(str, OPT(info->fmt_uint, "%u"), tempuint); - } else if (sizeof(hsize_t) == sizeof(long)) { + } + else if (sizeof(hsize_t) == sizeof(long)) { memcpy(&tempulong, vp, sizeof(long)); h5tools_str_append(str, OPT(info->fmt_ulong, "%lu"), tempulong); - } else { + } + else { memcpy(&tempullong, vp, sizeof(unsigned long long)); h5tools_str_append(str, OPT(info->fmt_ullong, fmt_ullong), tempullong); } - } else if (H5Tget_class(type) == H5T_COMPOUND) { + } + else if (H5Tget_class(type) == H5T_COMPOUND) { unsigned j; nmembs = H5Tget_nmembers(type); @@ -797,7 +886,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai memb = H5Tget_member_type(type, j); ctx->indent_level++; - h5tools_str_sprint(str, info, container, memb, cp_vp + offset , ctx); + h5tools_str_sprint(str, info, container, memb, cp_vp + offset, ctx); ctx->indent_level--; H5Tclose(memb); @@ -821,51 +910,42 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai } h5tools_str_append(str, "%s", OPT(info->cmpd_suf, "}")); - } else if (H5Tget_class(type) == H5T_ENUM) { + } + else if (H5Tget_class(type) == H5T_ENUM) { char enum_name[1024]; if (H5Tenum_nameof(type, vp, enum_name, sizeof enum_name) >= 0) { h5tools_str_append(str, h5tools_escape(enum_name, sizeof(enum_name))); - } else { + } + else { size_t i; n = H5Tget_size(type); - if (1==n) { + 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 { + for (i = 0; i < n; i++) + h5tools_str_append(str, "%s%02x", i ? ":" : "", ucp_vp[i]); } } - } else if (H5Tequal(type, H5T_STD_REF_DSETREG)) { - /* - * Dataset region reference -- show the type and OID of the referenced - * object, but we are unable to show the region yet because there - * isn't enough support in the data space layer. - rpm 19990604 - */ - if (h5tools_is_zero(vp, H5Tget_size(type))) { + } + else if (H5Tequal(type, H5T_STD_REF_DSETREG)) { + if (h5tools_str_is_zero(vp, H5Tget_size(type))) { h5tools_str_append(str, "NULL"); - } else { - char ref_name[1024]; - - obj = H5Rdereference(container, H5R_DATASET_REGION, vp); - region = H5Rget_region(container, H5R_DATASET_REGION, vp); - - /* get name of the dataset the region reference points to using H5Rget_name */ - H5Rget_name(obj, H5R_DATASET_REGION, vp, (char*)ref_name, 1024); - h5tools_str_append(str, info->dset_format, ref_name); - - h5tools_str_dump_region(str, region, info); - H5Sclose(region); - H5Dclose(obj); } - } else if (H5Tequal(type, H5T_STD_REF_OBJ)) { + else { + h5tools_str_sprint_region(str, info, container, vp, ctx); + } + } + else if (H5Tequal(type, H5T_STD_REF_OBJ)) { /* * Object references -- show the type and OID of the referenced * object. */ - if (h5tools_is_zero(vp, H5Tget_size(type))) { + if (h5tools_str_is_zero(vp, H5Tget_size(type))) { h5tools_str_append(str, "NULL"); - } else { + } + else { H5O_info_t oi; const char *path; @@ -873,42 +953,43 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai H5Oget_info(obj, &oi); /* 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; - - default: - h5tools_str_append(str, "%u-", (unsigned)oi.type); - break; + 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; + + default: + h5tools_str_append(str, "%u-", (unsigned) oi.type); + break; } /* end switch */ H5Oclose(obj); /* Print OID */ - if(info->obj_hidefileno) + 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); + /* 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) { + } + else if (H5Tget_class(type) == H5T_ARRAY) { int k, ndims; - hsize_t i, dims[H5S_MAX_RANK],temp_nelmts; + hsize_t i, dims[H5S_MAX_RANK], temp_nelmts; /* Get the array's base datatype for each element */ memb = H5Tget_super(type); @@ -918,34 +999,33 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai assert(ndims >= 1 && ndims <= H5S_MAX_RANK); /* Calculate the number of array elements */ - for (k = 0, nelmts = 1; k < ndims; k++){ + for (k = 0, nelmts = 1; k < ndims; k++) { temp_nelmts = nelmts; temp_nelmts *= dims[k]; - assert(temp_nelmts==(hsize_t)((size_t)temp_nelmts)); - nelmts = (size_t)temp_nelmts; + assert(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, "[")); - for(i = 0; i < nelmts; i++) { - if(i) - h5tools_str_append(str, "%s", - OPT(info->arr_sep, "," OPTIONAL_LINE_BREAK)); + for (i = 0; i < nelmts; i++) { + if (i) + h5tools_str_append(str, "%s", OPT(info->arr_sep, "," OPTIONAL_LINE_BREAK)); - if(info->arr_linebreak && i && i % dims[ndims - 1] == 0) { + if (info->arr_linebreak && i && i % dims[ndims - 1] == 0) { int x; h5tools_str_append(str, "%s", "\n"); /* need to indent some more here*/ - if(ctx->indent_level >= 0) - if(!info->pindex) + if (ctx->indent_level >= 0) + if (!info->pindex) h5tools_str_append(str, "%s", OPT(info->line_pre, "")); - for(x = 0; x < ctx->indent_level + 1; x++) + for (x = 0; x < ctx->indent_level + 1; x++) h5tools_str_append(str, "%s", OPT(info->line_indent, "")); } /* end if */ - else if(i && info->arr_sep) + else if (i && info->arr_sep) h5tools_str_append(str, " "); ctx->indent_level++; @@ -959,7 +1039,8 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai /* Print the closing bracket */ h5tools_str_append(str, "%s", OPT(info->arr_suf, "]")); H5Tclose(memb); - } else if (H5Tget_class(type) == H5T_VLEN) { + } + else if (H5Tget_class(type) == H5T_VLEN) { unsigned int i; /* Get the VL sequences's base datatype for each element */ @@ -970,15 +1051,14 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai h5tools_str_append(str, "%s", OPT(info->vlen_pre, "(")); /* Get the number of sequence elements */ - nelmts = ((hvl_t *)cp_vp)->len; + nelmts = ((hvl_t *) cp_vp)->len; for (i = 0; i < nelmts; i++) { if (i) - h5tools_str_append(str, "%s", - OPT(info->vlen_sep, "," OPTIONAL_LINE_BREAK)); + h5tools_str_append(str, "%s", OPT(info->vlen_sep, "," OPTIONAL_LINE_BREAK)); #ifdef LATER -/* Need to fix so VL data breaks at correct location on end of line -QAK */ + /* 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; @@ -997,28 +1077,71 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai /* Dump the array element */ h5tools_str_sprint(str, info, container, memb, - ((char *)(((hvl_t *)cp_vp)->p)) + i * size, ctx); + ((char *) (((hvl_t *) cp_vp)->p)) + i * size, ctx); ctx->indent_level--; } /* end for */ h5tools_str_append(str, "%s", OPT(info->vlen_suf, ")")); H5Tclose(memb); - } else { + } + else { /* All other types get printed as hexadecimal */ size_t i; n = H5Tget_size(type); - if (1==n) { + if (1 == n) { h5tools_str_append(str, "0x%02x", ucp_vp[0]); - } else { + } + else { for (i = 0; i < n; i++) - h5tools_str_append(str, "%s%02x", i?":":"", ucp_vp[i]); + h5tools_str_append(str, "%s%02x", i ? ":" : "", ucp_vp[i]); } } return h5tools_str_fmt(str, start, OPT(info->elmt_fmt, "%s")); } + +/*------------------------------------------------------------------------- + * Function: h5tools_str_sprint_region + * + * Purpose: Dataset region reference -- show the type and data 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_context_t *ctx) +{ + hid_t obj, region; + char ref_name[1024]; + H5S_sel_type region_type; + + obj = H5Rdereference(container, 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, "{"); + + region_type = H5Sget_select_type(region); + if(region_type==H5S_SEL_POINTS) + h5tools_str_dump_region_points(str, region, info, ctx); + else + h5tools_str_dump_region_blocks(str, region, info, ctx); + + h5tools_str_append(str, "}"); + + H5Sclose(region); + } /* end if (region >= 0) */ + H5Dclose(obj); + } /* end if (obj >= 0) */ +} + /*------------------------------------------------------------------------- * Function: h5tools_escape * @@ -1047,70 +1170,71 @@ h5tools_escape(char *s/*in,out*/, size_t size) char octal[8]; 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])) { - sprintf(octal, "\\%03o", (unsigned char)s[i]); - escape = octal; - } else { - escape = NULL; - } + 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])) { + sprintf(octal, "\\%03o", (unsigned char) s[i]); + escape = octal; + } + else { + escape = NULL; + } - break; - } + break; + } - if (escape) { - size_t esc_size = strlen(escape); + if (escape) { + size_t esc_size = strlen(escape); - if (n + esc_size + 1 > size) - /*would overflow*/ - return NULL; + if (n + esc_size + 1 > size) + /*would overflow*/ + return NULL; - memmove(s + i + esc_size, s + i + 1, n - i); /*make room*/ - memcpy(s + i, escape, esc_size); /*insert*/ - n += esc_size - 1; /* adjust total string size */ - i += esc_size; /* adjust string position */ - } + memmove(s + i + esc_size, s + i + 1, n - i); /*make room*/ + memcpy(s + i, escape, esc_size); /*insert*/ + n += esc_size - 1; /* adjust total string size */ + i += esc_size; /* adjust string position */ + } } return s; } /*------------------------------------------------------------------------- - * Function: h5tools_is_zero + * Function: h5tools_str_is_zero * * Purpose: Determines if memory is initialized to all zero bytes. * @@ -1124,13 +1248,13 @@ h5tools_escape(char *s/*in,out*/, size_t size) *------------------------------------------------------------------------- */ static hbool_t -h5tools_is_zero(const void *_mem, size_t size) +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]) - return FALSE; + if (mem[size]) + return FALSE; return TRUE; } diff --git a/tools/lib/h5tools_str.h b/tools/lib/h5tools_str.h index 607d412..61b7905 100644 --- a/tools/lib/h5tools_str.h +++ b/tools/lib/h5tools_str.h @@ -35,7 +35,18 @@ extern char *h5tools_str_fmt(h5tools_str_t *str, size_t start, const char *fm extern char *h5tools_str_prefix(h5tools_str_t *str, const h5tool_format_t *info, hsize_t elmtno, unsigned ndims, hsize_t min_idx[], hsize_t max_idx[], h5tools_context_t *ctx); -extern int h5tools_str_dump_region(h5tools_str_t *, hid_t, const h5tool_format_t *); +/* + * new functions needed to display region reference data + */ +extern char *h5tools_str_region_prefix(h5tools_str_t *str, const h5tool_format_t *info, + hsize_t elmtno, hsize_t *ptdata, unsigned ndims, hsize_t min_idx[], + hsize_t max_idx[], h5tools_context_t *ctx); +extern void h5tools_str_dump_region_blocks(h5tools_str_t *, hid_t, const h5tool_format_t *, + h5tools_context_t *ctx); +extern void h5tools_str_dump_region_points(h5tools_str_t *, hid_t, const h5tool_format_t *, + h5tools_context_t *ctx); +extern void h5tools_str_sprint_region(h5tools_str_t *str, const h5tool_format_t *info, hid_t container, + void *vp, h5tools_context_t *ctx); extern 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); diff --git a/tools/lib/talign.c b/tools/lib/talign.c deleted file mode 100644 index 6c1bd81..0000000 --- a/tools/lib/talign.c +++ /dev/null @@ -1,191 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * 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. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* - * Small program to illustrate the "misalignment" of members within a compound - * datatype, in a datatype fixed by H5Tget_native_type(). - */ -#include -#include -/*#include *//* Required for unlink() */ - -#include "hdf5.h" -#include "H5private.h" -#include "h5tools.h" - -const char *fname = "talign.h5"; -const char *setname = "align"; - -/* - * This program assumes that there is no extra space between the members 'Ok' - * and 'Not Ok', (there shouldn't be because they are of the same atomic type - * H5T_NATIVE_FLOAT, and they are placed within the compound next to one - * another per construction) - */ - -int main(void) -{ - hid_t fil,spc,set; - hid_t cs6, cmp, fix; - hid_t cmp1, cmp2, cmp3; - hid_t plist; - hid_t array_dt; - - hsize_t dim[2]; - hsize_t cdim[4]; - - char string5[5]; - float fok[2] = {1234., 2341.}; - float fnok[2] = {5678., 6785.}; - float *fptr; - - char *data; - char *mname; - - int result = 0; - - printf("%-70s", "Testing alignment in compound datatypes"); - - strcpy(string5, "Hi!"); - HDunlink(fname); - fil = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - if (fil < 0) { - puts("*FAILED*"); - return 1; - } - - H5E_BEGIN_TRY { - H5Ldelete(fil, setname, H5P_DEFAULT); - } H5E_END_TRY; - - cs6 = H5Tcopy(H5T_C_S1); - H5Tset_size(cs6, sizeof(string5)); - H5Tset_strpad(cs6, H5T_STR_NULLPAD); - - cmp = H5Tcreate(H5T_COMPOUND, sizeof(fok) + sizeof(string5) + sizeof(fnok)); - H5Tinsert(cmp, "Awkward length", 0, cs6); - - cdim[0] = sizeof(fok) / sizeof(float); - array_dt = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, cdim); - H5Tinsert(cmp, "Ok", sizeof(string5), array_dt); - H5Tclose(array_dt); - - cdim[0] = sizeof(fnok) / sizeof(float); - array_dt = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, cdim); - H5Tinsert(cmp, "Not Ok", sizeof(fok) + sizeof(string5), array_dt); - H5Tclose(array_dt); - - fix=h5tools_get_native_type(cmp); - - cmp1 = H5Tcreate(H5T_COMPOUND, sizeof(fok)); - - cdim[0] = sizeof(fok) / sizeof(float); - array_dt = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, cdim); - H5Tinsert(cmp1, "Ok", 0, array_dt); - H5Tclose(array_dt); - - cmp2 = H5Tcreate(H5T_COMPOUND, sizeof(string5)); - H5Tinsert(cmp2, "Awkward length", 0, cs6); - - cmp3 = H5Tcreate(H5T_COMPOUND, sizeof(fnok)); - - cdim[0] = sizeof(fnok) / sizeof(float); - array_dt = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, cdim); - H5Tinsert(cmp3, "Not Ok", 0, array_dt); - H5Tclose(array_dt); - - plist = H5Pcreate(H5P_DATASET_XFER); - H5Pset_preserve(plist, 1); - - /* - * Create a small dataset, and write data into it we write each field - * in turn so that we are avoid alignment issues at this point - */ - dim[0] = 1; - spc = H5Screate_simple(1, dim, NULL); - set = H5Dcreate2(fil, setname, cmp, spc, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - H5Dwrite(set, cmp1, spc, H5S_ALL, plist, fok); - H5Dwrite(set, cmp2, spc, H5S_ALL, plist, string5); - H5Dwrite(set, cmp3, spc, H5S_ALL, plist, fnok); - - H5Dclose(set); - - /* Now open the set, and read it back in */ - data = malloc(H5Tget_size(fix)); - - if(!data) { - perror("malloc() failed"); - abort(); - } - - set = H5Dopen2(fil, setname, H5P_DEFAULT); - - H5Dread(set, fix, spc, H5S_ALL, H5P_DEFAULT, data); - fptr = (float *)(data + H5Tget_member_offset(fix, 1)); - - if(fok[0] != fptr[0] || fok[1] != fptr[1] - || fnok[0] != fptr[2] || fnok[1] != fptr[3]) { - result = 1; - printf("%14s (%2d) %6s = %s\n", - mname = H5Tget_member_name(fix, 0), (int)H5Tget_member_offset(fix,0), - string5, (char *)(data + H5Tget_member_offset(fix, 0))); - free(mname); - fptr = (float *)(data + H5Tget_member_offset(fix, 1)); - printf("Data comparison:\n" - "%14s (%2d) %6f = %f\n" - " %6f = %f\n", - mname = H5Tget_member_name(fix, 1), (int)H5Tget_member_offset(fix,1), - fok[0], fptr[0], - fok[1], fptr[1]); - free(mname); - fptr = (float *)(data + H5Tget_member_offset(fix, 2)); - printf("%14s (%2d) %6f = %f\n" - " %6f = %6f\n", - mname = H5Tget_member_name(fix, 2), (int)H5Tget_member_offset(fix,2), - fnok[0], fptr[0], - fnok[1], fptr[1]); - free(mname); - - fptr = (float *)(data + H5Tget_member_offset(fix, 1)); - printf("\n" - "Short circuit\n" - " %6f = %f\n" - " %6f = %f\n" - " %6f = %f\n" - " %6f = %f\n", - fok[0], fptr[0], - fok[1], fptr[1], - fnok[0], fptr[2], - fnok[1], fptr[3]); - puts("*FAILED*"); - } else { - puts(" PASSED"); - } - - free(data); - H5Sclose(spc); - H5Tclose(cmp); - H5Tclose(cmp1); - H5Tclose(cmp2); - H5Tclose(cmp3); - H5Pclose(plist); - H5Fclose(fil); - HDunlink(fname); - fflush(stdout); - return result; -} - diff --git a/tools/misc/Makefile.am b/tools/misc/Makefile.am index 7f78465..fe1acbd 100644 --- a/tools/misc/Makefile.am +++ b/tools/misc/Makefile.am @@ -24,7 +24,7 @@ include $(top_srcdir)/config/commence.am INCLUDES=-I$(top_srcdir)/src -I$(top_srcdir)/tools/lib #test script and program -TEST_PROG=h5repart_gentest +TEST_PROG=h5repart_gentest talign TEST_SCRIPT=testh5repart.sh $(srcdir)/testh5mkgrp.sh check_PROGRAMS=$(TEST_PROG) repart_test diff --git a/tools/misc/Makefile.in b/tools/misc/Makefile.in index dd8fce6..78a42b8 100644 --- a/tools/misc/Makefile.in +++ b/tools/misc/Makefile.in @@ -69,7 +69,7 @@ CONFIG_HEADER = $(top_builddir)/src/H5config.h CONFIG_CLEAN_FILES = h5cc testh5repart.sh CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)" -am__EXEEXT_1 = h5repart_gentest$(EXEEXT) +am__EXEEXT_1 = h5repart_gentest$(EXEEXT) talign$(EXEEXT) PROGRAMS = $(bin_PROGRAMS) h5debug_SOURCES = h5debug.c h5debug_OBJECTS = h5debug.$(OBJEXT) @@ -100,6 +100,10 @@ repart_test_SOURCES = repart_test.c repart_test_OBJECTS = repart_test.$(OBJEXT) repart_test_LDADD = $(LDADD) repart_test_DEPENDENCIES = $(LIBH5TOOLS) $(LIBHDF5) +talign_SOURCES = talign.c +talign_OBJECTS = talign.$(OBJEXT) +talign_LDADD = $(LDADD) +talign_DEPENDENCIES = $(LIBH5TOOLS) $(LIBHDF5) am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ @@ -136,9 +140,9 @@ LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = h5debug.c h5mkgrp.c h5repart.c h5repart_gentest.c \ - repart_test.c + repart_test.c talign.c DIST_SOURCES = h5debug.c h5mkgrp.c h5repart.c h5repart_gentest.c \ - repart_test.c + repart_test.c talign.c ETAGS = etags CTAGS = ctags am__tty_colors = \ @@ -404,7 +408,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog *.h5 \ INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/tools/lib #test script and program -TEST_PROG = h5repart_gentest +TEST_PROG = h5repart_gentest talign TEST_SCRIPT = testh5repart.sh $(srcdir)/testh5mkgrp.sh check_SCRIPTS = $(TEST_SCRIPT) SCRIPT_DEPEND = h5repart$(EXEEXT) h5mkgrp$(EXEEXT) @@ -549,6 +553,9 @@ h5repart_gentest$(EXEEXT): $(h5repart_gentest_OBJECTS) $(h5repart_gentest_DEPEND repart_test$(EXEEXT): $(repart_test_OBJECTS) $(repart_test_DEPENDENCIES) @rm -f repart_test$(EXEEXT) $(LINK) $(repart_test_OBJECTS) $(repart_test_LDADD) $(LIBS) +talign$(EXEEXT): $(talign_OBJECTS) $(talign_DEPENDENCIES) + @rm -f talign$(EXEEXT) + $(LINK) $(talign_OBJECTS) $(talign_LDADD) $(LIBS) install-binSCRIPTS: $(bin_SCRIPTS) @$(NORMAL_INSTALL) test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @@ -595,6 +602,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5repart.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5repart_gentest.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/repart_test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/talign.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< diff --git a/tools/misc/talign.c b/tools/misc/talign.c new file mode 100644 index 0000000..24420bf --- /dev/null +++ b/tools/misc/talign.c @@ -0,0 +1,222 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Small program to illustrate the "misalignment" of members within a compound + * datatype, in a datatype fixed by H5Tget_native_type(). + */ +#include +#include +/*#include *//* Required for unlink() */ + +#include "hdf5.h" +#include "H5private.h" + +const char *fname = "talign.h5"; +const char *setname = "align"; + +/* + * This program assumes that there is no extra space between the members 'Ok' + * and 'Not Ok', (there shouldn't be because they are of the same atomic type + * H5T_NATIVE_FLOAT, and they are placed within the compound next to one + * another per construction) + */ + +int main(void) +{ + hid_t fil,spc,set; + hid_t cs6, cmp, fix; + hid_t cmp1, cmp2, cmp3; + hid_t plist; + hid_t array_dt; + + hsize_t dim[2]; + hsize_t cdim[4]; + + char string5[5]; + float fok[2] = {1234., 2341.}; + float fnok[2] = {5678., 6785.}; + float *fptr; + + char *data; + char *mname; + + int result = 0; + + printf("%-70s", "Testing alignment in compound datatypes"); + + strcpy(string5, "Hi!"); + HDunlink(fname); + fil = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + + if (fil < 0) { + puts("*FAILED*"); + return 1; + } + + H5E_BEGIN_TRY { + H5Ldelete(fil, setname, H5P_DEFAULT); + } H5E_END_TRY; + + cs6 = H5Tcopy(H5T_C_S1); + H5Tset_size(cs6, sizeof(string5)); + H5Tset_strpad(cs6, H5T_STR_NULLPAD); + + cmp = H5Tcreate(H5T_COMPOUND, sizeof(fok) + sizeof(string5) + sizeof(fnok)); + H5Tinsert(cmp, "Awkward length", 0, cs6); + + cdim[0] = sizeof(fok) / sizeof(float); + array_dt = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, cdim); + H5Tinsert(cmp, "Ok", sizeof(string5), array_dt); + H5Tclose(array_dt); + + cdim[0] = sizeof(fnok) / sizeof(float); + array_dt = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, cdim); + H5Tinsert(cmp, "Not Ok", sizeof(fok) + sizeof(string5), array_dt); + H5Tclose(array_dt); + + fix=h5tools_get_native_type(cmp); + + cmp1 = H5Tcreate(H5T_COMPOUND, sizeof(fok)); + + cdim[0] = sizeof(fok) / sizeof(float); + array_dt = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, cdim); + H5Tinsert(cmp1, "Ok", 0, array_dt); + H5Tclose(array_dt); + + cmp2 = H5Tcreate(H5T_COMPOUND, sizeof(string5)); + H5Tinsert(cmp2, "Awkward length", 0, cs6); + + cmp3 = H5Tcreate(H5T_COMPOUND, sizeof(fnok)); + + cdim[0] = sizeof(fnok) / sizeof(float); + array_dt = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, cdim); + H5Tinsert(cmp3, "Not Ok", 0, array_dt); + H5Tclose(array_dt); + + plist = H5Pcreate(H5P_DATASET_XFER); + H5Pset_preserve(plist, 1); + + /* + * Create a small dataset, and write data into it we write each field + * in turn so that we are avoid alignment issues at this point + */ + dim[0] = 1; + spc = H5Screate_simple(1, dim, NULL); + set = H5Dcreate2(fil, setname, cmp, spc, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + + H5Dwrite(set, cmp1, spc, H5S_ALL, plist, fok); + H5Dwrite(set, cmp2, spc, H5S_ALL, plist, string5); + H5Dwrite(set, cmp3, spc, H5S_ALL, plist, fnok); + + H5Dclose(set); + + /* Now open the set, and read it back in */ + data = malloc(H5Tget_size(fix)); + + if(!data) { + perror("malloc() failed"); + abort(); + } + + set = H5Dopen2(fil, setname, H5P_DEFAULT); + + H5Dread(set, fix, spc, H5S_ALL, H5P_DEFAULT, data); + fptr = (float *)(data + H5Tget_member_offset(fix, 1)); + + if(fok[0] != fptr[0] || fok[1] != fptr[1] + || fnok[0] != fptr[2] || fnok[1] != fptr[3]) { + result = 1; + printf("%14s (%2d) %6s = %s\n", + mname = H5Tget_member_name(fix, 0), (int)H5Tget_member_offset(fix,0), + string5, (char *)(data + H5Tget_member_offset(fix, 0))); + free(mname); + fptr = (float *)(data + H5Tget_member_offset(fix, 1)); + printf("Data comparison:\n" + "%14s (%2d) %6f = %f\n" + " %6f = %f\n", + mname = H5Tget_member_name(fix, 1), (int)H5Tget_member_offset(fix,1), + fok[0], fptr[0], + fok[1], fptr[1]); + free(mname); + fptr = (float *)(data + H5Tget_member_offset(fix, 2)); + printf("%14s (%2d) %6f = %f\n" + " %6f = %6f\n", + mname = H5Tget_member_name(fix, 2), (int)H5Tget_member_offset(fix,2), + fnok[0], fptr[0], + fnok[1], fptr[1]); + free(mname); + + fptr = (float *)(data + H5Tget_member_offset(fix, 1)); + printf("\n" + "Short circuit\n" + " %6f = %f\n" + " %6f = %f\n" + " %6f = %f\n" + " %6f = %f\n", + fok[0], fptr[0], + fok[1], fptr[1], + fnok[0], fptr[2], + fnok[1], fptr[3]); + puts("*FAILED*"); + } else { + puts(" PASSED"); + } + + free(data); + H5Sclose(spc); + H5Tclose(cmp); + H5Tclose(cmp1); + H5Tclose(cmp2); + H5Tclose(cmp3); + H5Pclose(plist); + H5Fclose(fil); + HDunlink(fname); + fflush(stdout); + return result; +} + +/*------------------------------------------------------------------------- + * 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); +} + diff --git a/tools/testfiles/tattrreg.ddl b/tools/testfiles/tattrreg.ddl new file mode 100644 index 0000000..5b64b18 --- /dev/null +++ b/tools/testfiles/tattrreg.ddl @@ -0,0 +1,38 @@ +############################# +Expected output for 'h5dump tattrreg.h5' +############################# +HDF5 "tattrreg.h5" { +GROUP "/" { + DATASET "Dataset1" { + DATATYPE H5T_STD_I32LE + DATASPACE NULL + DATA { + } + ATTRIBUTE "Attribute1" { + DATATYPE H5T_REFERENCE + DATASPACE SIMPLE { ( 4 ) / ( 4 ) } + DATA { + (0): DATASET /Dataset2 {(2,2)-(7,7)}, DATASET /Dataset2 {(6,9), + (1): (2,2), (8,4), (1,6), (2,8), (3,2), (0,4), (9,0), (7,1), + (1): (3,3)}, NULL, NULL + } + } + } + DATASET "Dataset2" { + DATATYPE H5T_STD_U8BE + DATASPACE SIMPLE { ( 10, 10 ) / ( 10, 10 ) } + DATA { + (0,0): 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, + (1,0): 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, + (2,0): 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, + (3,0): 90, 93, 96, 99, 102, 105, 108, 111, 114, 117, + (4,0): 120, 123, 126, 129, 132, 135, 138, 141, 144, 147, + (5,0): 150, 153, 156, 159, 162, 165, 168, 171, 174, 177, + (6,0): 180, 183, 186, 189, 192, 195, 198, 201, 204, 207, + (7,0): 210, 213, 216, 219, 222, 225, 228, 231, 234, 237, + (8,0): 240, 243, 246, 249, 252, 255, 2, 5, 8, 11, + (9,0): 14, 17, 20, 23, 26, 29, 32, 35, 38, 41 + } + } +} +} diff --git a/tools/testfiles/tattrreg.h5 b/tools/testfiles/tattrreg.h5 new file mode 100644 index 0000000..193b3e1 Binary files /dev/null and b/tools/testfiles/tattrreg.h5 differ diff --git a/tools/testfiles/tattrregR.ddl b/tools/testfiles/tattrregR.ddl new file mode 100644 index 0000000..6e399c0 --- /dev/null +++ b/tools/testfiles/tattrregR.ddl @@ -0,0 +1,66 @@ +############################# +Expected output for 'h5dump -R tattrreg.h5' +############################# +HDF5 "tattrreg.h5" { +GROUP "/" { + DATASET "Dataset1" { + DATATYPE H5T_STD_I32LE + DATASPACE NULL + DATA { + } + ATTRIBUTE "Attribute1" { + DATATYPE H5T_REFERENCE { H5T_STD_REF_DSETREG } + DATASPACE SIMPLE { ( 4 ) / ( 4 ) } + DATA { + (0): DATASET /Dataset2 { + (0): REGION_TYPE BLOCK (2,2)-(7,7) + (0): DATATYPE H5T_STD_U8BE + (0): DATASPACE SIMPLE { ( 10, 10 ) / ( 10, 10 ) } + (0): DATA { + (2,2): 66, 69, 72, 75, 78, 81, + (3,2): 96, 99, 102, 105, 108, 111, + (4,2): 126, 129, 132, 135, 138, 141, + (5,2): 156, 159, 162, 165, 168, 171, + (6,2): 186, 189, 192, 195, 198, 201, + (7,2): 216, 219, 222, 225, 228, 231 + (0): } + (0): } + (1): DATASET /Dataset2 { + (1): REGION_TYPE POINT (6,9), (2,2), (8,4), (1,6), (2,8), + (1): (3,2), (0,4), (9,0), (7,1), (3,3) + (1): DATATYPE H5T_STD_U8BE + (1): DATASPACE SIMPLE { ( 10, 10 ) / ( 10, 10 ) } + (1): DATA { + (6,9): 207, + (2,2): 66, + (8,4): 252, + (1,6): 48, + (2,8): 84, + (3,2): 96, + (0,4): 12, + (9,0): 14, + (7,1): 213, + (3,3): 99 + (1): } + (1): } + } + } + } + DATASET "Dataset2" { + DATATYPE H5T_STD_U8BE + DATASPACE SIMPLE { ( 10, 10 ) / ( 10, 10 ) } + DATA { + (0,0): 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, + (1,0): 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, + (2,0): 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, + (3,0): 90, 93, 96, 99, 102, 105, 108, 111, 114, 117, + (4,0): 120, 123, 126, 129, 132, 135, 138, 141, 144, 147, + (5,0): 150, 153, 156, 159, 162, 165, 168, 171, 174, 177, + (6,0): 180, 183, 186, 189, 192, 195, 198, 201, 204, 207, + (7,0): 210, 213, 216, 219, 222, 225, 228, 231, 234, 237, + (8,0): 240, 243, 246, 249, 252, 255, 2, 5, 8, 11, + (9,0): 14, 17, 20, 23, 26, 29, 32, 35, 38, 41 + } + } +} +} diff --git a/tools/testfiles/tdataregR.ddl b/tools/testfiles/tdataregR.ddl new file mode 100644 index 0000000..2d962ed --- /dev/null +++ b/tools/testfiles/tdataregR.ddl @@ -0,0 +1,60 @@ +############################# +Expected output for 'h5dump -R tdatareg.h5' +############################# +HDF5 "tdatareg.h5" { +GROUP "/" { + DATASET "Dataset1" { + DATATYPE H5T_REFERENCE { H5T_STD_REF_DSETREG } + DATASPACE SIMPLE { ( 4 ) / ( 4 ) } + DATA { + (0): DATASET /Dataset2 { + (0): REGION_TYPE BLOCK (2,2)-(7,7) + (0): DATATYPE H5T_STD_U8BE + (0): DATASPACE SIMPLE { ( 10, 10 ) / ( 10, 10 ) } + (0): DATA { + (2,2): 66, 69, 72, 75, 78, 81, + (3,2): 96, 99, 102, 105, 108, 111, + (4,2): 126, 129, 132, 135, 138, 141, + (5,2): 156, 159, 162, 165, 168, 171, + (6,2): 186, 189, 192, 195, 198, 201, + (7,2): 216, 219, 222, 225, 228, 231 + (0): } + (0): } + (1): DATASET /Dataset2 { + (1): REGION_TYPE POINT (6,9), (2,2), (8,4), (1,6), (2,8), (3,2), + (1): (0,4), (9,0), (7,1), (3,3) + (1): DATATYPE H5T_STD_U8BE + (1): DATASPACE SIMPLE { ( 10, 10 ) / ( 10, 10 ) } + (1): DATA { + (6,9): 207, + (2,2): 66, + (8,4): 252, + (1,6): 48, + (2,8): 84, + (3,2): 96, + (0,4): 12, + (9,0): 14, + (7,1): 213, + (3,3): 99 + (1): } + (1): } + } + } + DATASET "Dataset2" { + DATATYPE H5T_STD_U8BE + DATASPACE SIMPLE { ( 10, 10 ) / ( 10, 10 ) } + DATA { + (0,0): 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, + (1,0): 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, + (2,0): 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, + (3,0): 90, 93, 96, 99, 102, 105, 108, 111, 114, 117, + (4,0): 120, 123, 126, 129, 132, 135, 138, 141, 144, 147, + (5,0): 150, 153, 156, 159, 162, 165, 168, 171, 174, 177, + (6,0): 180, 183, 186, 189, 192, 195, 198, 201, 204, 207, + (7,0): 210, 213, 216, 219, 222, 225, 228, 231, 234, 237, + (8,0): 240, 243, 246, 249, 252, 255, 2, 5, 8, 11, + (9,0): 14, 17, 20, 23, 26, 29, 32, 35, 38, 41 + } + } +} +} diff --git a/tools/testfiles/tdset-3s.ddl b/tools/testfiles/tdset-3s.ddl index d8deced..5963e90 100644 --- a/tools/testfiles/tdset-3s.ddl +++ b/tools/testfiles/tdset-3s.ddl @@ -8,27 +8,10 @@ DATASET "/dset1" { SUBSET { START ( 1, 1 ); STRIDE ( 1, 1 ); - COUNT ( 9, 19 ); + COUNT ( 1, 1 ); BLOCK ( 1, 1 ); DATA { - (1,1): 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - (1,19): 20, - (2,1): 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - (2,18): 20, 21, - (3,1): 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - (3,18): 21, 22, - (4,1): 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, - (4,18): 22, 23, - (5,1): 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, - (5,18): 23, 24, - (6,1): 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, - (6,17): 23, 24, 25, - (7,1): 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - (7,17): 24, 25, 26, - (8,1): 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - (8,17): 25, 26, 27, - (9,1): 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, - (9,17): 26, 27, 28 + (1,1): 2 } } } diff --git a/tools/testfiles/tnofilename.ddl b/tools/testfiles/tnofilename.ddl index 594b0c0..5b9299b 100644 --- a/tools/testfiles/tnofilename.ddl +++ b/tools/testfiles/tnofilename.ddl @@ -28,6 +28,7 @@ usage: h5dump [OPTIONS] file -m T, --format=T Set the floating point output format -q Q, --sort_by=Q Sort groups and attributes by index Q -z Z, --sort_order=Z Sort groups and attributes by order Z + -R, --region Print dataset pointed by region references -x, --xml Output in XML using Schema -u, --use-dtd Output in XML using DTD -D U, --xml-dtd=U Use the DTD or schema at U @@ -38,14 +39,16 @@ usage: h5dump [OPTIONS] file Subsetting is available by using the following options with a dataset attribute. Subsetting is done by selecting a hyperslab from the data. Thus, the options mirror those for performing a hyperslab selection. - The START and COUNT parameters are mandatory if you do subsetting. - The STRIDE and BLOCK parameters are optional and will default to 1 in - each dimension. + One of the START, COUNT, STRIDE, or BLOCK parameters are mandatory if you do subsetting. + The STRIDE, COUNT, and BLOCK parameters are optional and will default to 1 in + each dimension. START is optional and will default to 0 in each dimension. - -s L, --start=L Offset of start of subsetting selection - -S L, --stride=L Hyperslab stride - -c L, --count=L Number of blocks to include in selection - -k L, --block=L Size of block in hyperslab + -s START, --start=START Offset of start of subsetting selection + -S STRIDE, --stride=STRIDE Hyperslab stride + -c COUNT, --count=COUNT Number of blocks to include in selection + -k BLOCK, --block=BLOCK Size of block in hyperslab + START, COUNT, STRIDE, and BLOCK - is a list of integers the number of which are equal to the + number of dimensions in the dataspace being queried D - is the file driver to use in opening the file. Acceptable values are "sec2", "family", "split", "multi", "direct", and "stream". Without @@ -56,8 +59,6 @@ usage: h5dump [OPTIONS] file P - is the full path from the root group to the object. N - is an integer greater than 1. T - is a string containing the floating point format, e.g '%.3f' - L - is a list of integers the number of which are equal to the - number of dimensions in the dataspace being queried U - is a URI reference (as defined in [IETF RFC 2396], updated by [IETF RFC 2732]) B - is the form of binary output: NATIVE for a memory type, FILE for the diff --git a/vms/src/h5pubconf.h b/vms/src/h5pubconf.h index 9a2d9b2..793856a 100644 --- a/vms/src/h5pubconf.h +++ b/vms/src/h5pubconf.h @@ -480,13 +480,13 @@ #define H5_PACKAGE_NAME "HDF5" /* Define to the full name and version of this package. */ -#define H5_PACKAGE_STRING "HDF5 1.9.45-FA_a3" +#define H5_PACKAGE_STRING "HDF5 1.9.46-FA_a3" /* Define to the one symbol short name of this package. */ #define H5_PACKAGE_TARNAME "hdf5" /* Define to the version of this package. */ -#define H5_PACKAGE_VERSION "1.9.45-FA_a3" +#define H5_PACKAGE_VERSION "1.9.46-FA_a3" /* Width for printf() for type `long long' or `__int64', use `ll' */ #define H5_PRINTF_LL_WIDTH "ll" @@ -639,7 +639,7 @@ /* #undef H5_USING_MEMCHECKER */ /* Version number of package */ -#define H5_VERSION "1.9.45-FA_a3" +#define H5_VERSION "1.9.46-FA_a3" /* Define if vsnprintf() returns the correct value for formatted strings that don't fit into size allowed */ diff --git a/vms/src/make.com b/vms/src/make.com index cbf15af..71362b5 100644 --- a/vms/src/make.com +++ b/vms/src/make.com @@ -32,14 +32,14 @@ $ cobj= "H5, H5checksum, H5dbg, H5system, H5timer, H5trace,"+- "H5Abtree2, H5A, H5AC, H5Adense, H5Adeprec, H5Aint, H5Atest, H5B2, H5B2cache,"+- "H5B2dbg, H5B2int, H5B2stat, H5B2test, H5B, H5Bcache, H5Bdbg, H5C, H5CS,"+- "H5Dbtree, H5D, H5Dchunk, H5Dcompact, H5Dcontig, H5Ddbg, H5Ddeprec,"+- - "H5Defl, H5Dfill, H5Dint, H5Dio, H5Dmpio, H5Doh, H5Dscatgath, H5Dselect, H5Dtest,"+- + "H5Defl, H5Dfill, H5Dint, H5Dio, H5Dlayout, H5Dmpio, H5Doh, H5Dscatgath, H5Dselect, H5Dtest,"+- "H5EA, H5EAcache, H5EAdbg, H5EAdblkpage, H5EAdblock, H5EAhdr, H5EAiblock, H5EAint,"+- "H5EAsblock, H5EAstat, H5EAtest, H5E, H5Edeprec, H5Eint,"+- "H5FA, H5FAcache, H5FAdbg, H5FAdblkpage, H5FAdblock, H5FAhdr, H5FAstat, H5FAtest,"+- "H5Faccum, H5F, H5Fdbg, H5FD, H5FDcore, H5FDdirect, H5FDfamily, H5FDint, H5FDlog, H5FDmpi,"+- "H5FDmpio, H5FDmpiposix, H5FDmulti, H5FDsec2, H5FDspace, H5FDstdio, H5FDwindows,"+- "H5Ffake, H5Fio, H5FL, H5Fmount, H5Fmpi, H5FO, H5Fquery, H5FS, H5FScache, H5FSdbg, H5Fsfile,"+- - "H5FSsection, H5FSstat, H5FStest, H5Fsuper, H5Ftest,"+- + "H5FSsection, H5FSstat, H5FStest, H5Fsuper, H5Fsuper_cache, H5Ftest,"+- "H5Gbtree2, H5G, H5Gcache, H5Gcompact, H5Gdense, H5Gdeprec, H5Gent, H5Gint, H5Glink, H5Gloc,"+- "H5Gname, H5Gnode, H5Gobj, H5Goh, H5Groot, H5Gstab, H5Gtest, H5Gtraverse,"+- "H5HFbtree2, H5HF, H5HFcache, H5HFdbg, H5HFdblock, H5HFdtable, H5HFhdr, H5HFhuge, H5HFiblock,"+- diff --git a/windows/examples/allexamples/allexamples.vcproj b/windows/examples/allexamples/allexamples.vcproj index a5795f9..4c87ec0 100644 --- a/windows/examples/allexamples/allexamples.vcproj +++ b/windows/examples/allexamples/allexamples.vcproj @@ -198,7 +198,7 @@ Name="Debug|Win32" OutputDirectory="..\..\..\examples\$(ProjectName)\$(ConfigurationName)" IntermediateDirectory="$(OutDir)" - ConfigurationType="10" + ConfigurationType="1" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="false" @@ -211,11 +211,74 @@ Name="VCCustomBuildTool" /> + + + + + + + + + + + + + + diff --git a/windows/proj/hdf5_f90cstubdll/hdf5_f90cstubdll.vcproj b/windows/proj/hdf5_f90cstubdll/hdf5_f90cstubdll.vcproj index 1682e4d..a6af615 100644 --- a/windows/proj/hdf5_f90cstubdll/hdf5_f90cstubdll.vcproj +++ b/windows/proj/hdf5_f90cstubdll/hdf5_f90cstubdll.vcproj @@ -52,7 +52,7 @@ Optimization="2" InlineFunctionExpansion="1" AdditionalIncludeDirectories="..\..\..\src" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_HDF5USEDLL_;HDF5FORT_CSTUB_DLL_EXPORTS" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_HDF5USEDLL_;HDF5FORT_CSTUB_DLL_EXPORTS" StringPooling="true" RuntimeLibrary="2" EnableFunctionLevelLinking="true" @@ -146,7 +146,7 @@ Optimization="2" InlineFunctionExpansion="1" AdditionalIncludeDirectories="..\..\..\src" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_HDF5USEDLL_;HDF5FORT_CSTUB_DLL_EXPORTS" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_HDF5USEDLL_;HDF5FORT_CSTUB_DLL_EXPORTS" StringPooling="true" RuntimeLibrary="2" EnableFunctionLevelLinking="true" diff --git a/windows/src/H5pubconf.h b/windows/src/H5pubconf.h index 574f10a..0043bdf 100755 --- a/windows/src/H5pubconf.h +++ b/windows/src/H5pubconf.h @@ -479,13 +479,13 @@ #define H5_PACKAGE_NAME "HDF5" /* Define to the full name and version of this package. */ -#define H5_PACKAGE_STRING "HDF5 1.9.45-FA_a3" +#define H5_PACKAGE_STRING "HDF5 1.9.46-FA_a3" /* Define to the one symbol short name of this package. */ #define H5_PACKAGE_TARNAME "hdf5" /* Define to the version of this package. */ -#define H5_PACKAGE_VERSION "1.9.45-FA_a3" +#define H5_PACKAGE_VERSION "1.9.46-FA_a3" /* Width for printf() for type `long long' or `__int64', use `ll' */ #define H5_PRINTF_LL_WIDTH "I64" @@ -642,7 +642,7 @@ /* #undef H5_USING_MEMCHECKER */ /* Version number of package */ -#define H5_VERSION "1.9.45-FA_a3" +#define H5_VERSION "1.9.46-FA_a3" /* Define if vsnprintf() returns the correct value for formatted strings that don't fit into size allowed */ diff --git a/windows/tools/h5diff/testh5diff.bat b/windows/tools/h5diff/testh5diff.bat index af1e7d4..4b5f265 100644 --- a/windows/tools/h5diff/testh5diff.bat +++ b/windows/tools/h5diff/testh5diff.bat @@ -381,8 +381,8 @@ rem ############################################################################ call :tooltest h5diff_607.txt -d "1" %file1% %file2% g1/dset3 g1/dset4 rem 6.8: repeated option - call :testing %h5diff% -d 1 -d 2 %srcfile1% %srcfile2% g1/dset3 g1/dset4 - call :tooltest h5diff_608.txt -d 1 -d 2 %file1% %file2% g1/dset3 g1/dset4 + call :testing %h5diff% --use-system-epsilon %srcfile1% %srcfile2% g1/dset3 g1/dset4 + call :tooltest h5diff_608.txt --use-system-epsilon %file1% %file2% g1/dset3 g1/dset4 rem 6.9: number larger than biggest difference call :testing %h5diff% -d 200 %srcfile1% %srcfile2% g1/dset3 g1/dset4 @@ -432,13 +432,10 @@ rem ############################################################################ call :tooltest h5diff_619.txt -p 0.005 %file1% %file2% g1/dset3 g1/dset4 - rem ############################################################################## rem # -n rem ############################################################################## - - rem 6.21: negative value call :testing %h5diff% -n -4 %srcfile1% %srcfile2% g1/dset3 g1/dset4 call :tooltest h5diff_621.txt -n -4 %file1% %file2% g1/dset3 g1/dset4 @@ -471,6 +468,7 @@ rem ############################################################################ call :testing %h5diff% -n 1 %srcfile1% %srcfile2% g1/dset3 g1/dset4 call :tooltest h5diff_628.txt -n 1 %file1% %file2% g1/dset3 g1/dset4 + rem This is disabled on *nix platforms rem 6.29 non valid files call :testing %h5diff% file1.h6 file2.h6 call :tooltest h5diff_629.txt file1.h6 file2.h6 @@ -493,7 +491,7 @@ rem ############################################################################ rem 10. read by hyperslab, print indexes rem ############################################################################## - rem Not tested on windows as this has not been a problem - ADB 1/22/2009 + rem Not skipped on windows as this has not been a problem - ADB 1/22/2009 rem if test -n "$pmode" -a "$mydomainname" = hdfgroup.uiuc.edu; then rem # skip this test which sometimes hangs in some THG machines rem SKIP -v $SRCFILE9 $SRCFILE10 diff --git a/windows/tools/h5dump/testh5dump.bat b/windows/tools/h5dump/testh5dump.bat index afad801..e776c07 100644 --- a/windows/tools/h5dump/testh5dump.bat +++ b/windows/tools/h5dump/testh5dump.bat @@ -377,6 +377,7 @@ rem ############################################################################ call :tooltest tarray5.ddl tarray5.h5 call :tooltest tarray6.ddl tarray6.h5 call :tooltest tarray7.ddl tarray7.h5 + call :tooltest tarray8.ddl tarray8.h5 rem test for files with empty data call :tooltest tempty.ddl tempty.h5 @@ -580,6 +581,9 @@ rem ############################################################################ rem test for dataset region references call :tooltest tdatareg.ddl tdatareg.h5 + call :tooltest tdataregR.ddl -R tdatareg.h5 + call :tooltest tattrreg.ddl tattrreg.h5 + call :tooltest tattrregR.ddl -R tattrreg.h5 rem tests for group creation order rem "1" tracked, "2" name, root tracked @@ -603,10 +607,6 @@ rem ############################################################################ rem tests for traversal of external links call :tooltest textlinksrc.ddl textlinksrc.h5 call :tooltest textlinkfar.ddl textlinkfar.h5 - - rem tests for traversal of external links - call :tooltest textlinksrc.ddl textlinksrc.h5 - call :tooltest textlinkfar.ddl textlinkfar.h5 diff --git a/windows/tools/talign/talign.vcproj b/windows/tools/talign/talign.vcproj index 6ee5c64..eb59c88 100644 --- a/windows/tools/talign/talign.vcproj +++ b/windows/tools/talign/talign.vcproj @@ -47,7 +47,7 @@ diff --git a/windows/tools/taligndll/taligndll.vcproj b/windows/tools/taligndll/taligndll.vcproj index 8c1ecce..61ec1a2 100644 --- a/windows/tools/taligndll/taligndll.vcproj +++ b/windows/tools/taligndll/taligndll.vcproj @@ -48,7 +48,7 @@ Name="VCCLCompilerTool" Optimization="2" InlineFunctionExpansion="1" - AdditionalIncludeDirectories="..\..\..\tools\lib,..\..\..\src" + AdditionalIncludeDirectories="..\..\..\tools\misc,..\..\..\src" PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_HDF5USEDLL_" StringPooling="true" RuntimeLibrary="2" @@ -140,7 +140,7 @@ Name="VCCLCompilerTool" Optimization="2" InlineFunctionExpansion="1" - AdditionalIncludeDirectories="..\..\..\tools\lib,..\..\..\src" + AdditionalIncludeDirectories="..\..\..\tools\misc,..\..\..\src" PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_HDF5USEDLL_" StringPooling="true" RuntimeLibrary="2" @@ -230,7 +230,7 @@ -- cgit v0.12