From 1ae6daaa807f2bfd63076215950d9c412bfa08d7 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Sat, 1 Aug 2020 09:18:18 -0700 Subject: Sync with develop --- .github/workflows/main.yml | 4 +- CMakeInstallation.cmake | 7 + CMakeLists.txt | 15 + MANIFEST | 32 +- Makefile.am | 6 +- bin/release | 248 +- bin/trace | 6 + c++/examples/Makefile.am | 4 +- config/cmake/CTestCustom.cmake | 2 +- config/cmake/ConfigureChecks.cmake | 17 + config/cmake/H5pubconf.h.in | 15 +- config/cmake/HDF5UseFortran.cmake | 2 +- config/cmake/libhdf5.settings.cmake.in | 1 + config/cmake_ext_mod/ConfigureChecks.cmake | 6 +- config/solaris | 21 +- configure.ac | 47 + examples/CMakeLists.txt | 1 + examples/Makefile.am | 32 +- examples/h5_crtgrp.c | 2 +- examples/h5_debug_trace.c | 144 + examples/run-c-ex.sh.in | 5 + fortran/examples/Makefile.am | 4 +- fortran/src/H5Aff.F90 | 12 +- fortran/src/H5Dff.F90 | 78 +- fortran/src/H5Eff.F90 | 4 +- fortran/src/H5Fff.F90 | 8 +- fortran/src/H5Gff.F90 | 22 +- fortran/src/H5Iff.F90 | 20 +- fortran/src/H5Lff.F90 | 38 +- fortran/src/H5Off.F90 | 158 +- fortran/src/H5Pff.F90 | 2584 ++++++------ fortran/src/H5Rff.F90 | 20 +- fortran/src/H5Sff.F90 | 94 +- fortran/src/H5Tff.F90 | 182 +- fortran/src/H5VLff.F90 | 14 +- fortran/src/H5Zff.F90 | 4 +- fortran/src/H5_buildiface.F90 | 52 +- fortran/src/H5_ff.F90 | 76 +- fortran/src/H5f90global.F90 | 36 +- fortran/src/H5fortkit.F90 | 4 +- fortran/test/H5_test_buildiface.F90 | 16 +- fortran/test/fflush1.F90 | 2 +- fortran/test/fortranlib_test.F90 | 20 +- fortran/test/fortranlib_test_F03.F90 | 16 +- fortran/test/tH5A.F90 | 2 +- fortran/test/tH5A_1_8.F90 | 636 +-- fortran/test/tH5D.F90 | 114 +- fortran/test/tH5E_F03.F90 | 6 +- fortran/test/tH5F.F90 | 12 +- fortran/test/tH5F_F03.F90 | 28 +- fortran/test/tH5G_1_8.F90 | 582 +-- fortran/test/tH5I.F90 | 20 +- fortran/test/tH5L_F03.F90 | 76 +- fortran/test/tH5MISC_1_8.F90 | 76 +- fortran/test/tH5O.F90 | 138 +- fortran/test/tH5O_F03.F90 | 30 +- fortran/test/tH5P.F90 | 138 +- fortran/test/tH5P_F03.F90 | 220 +- fortran/test/tH5R.F90 | 14 +- fortran/test/tH5S.F90 | 4 +- fortran/test/tH5Sselect.F90 | 438 +- fortran/test/tH5T.F90 | 34 +- fortran/test/tH5T_F03.F90 | 608 +-- fortran/test/tH5VL.F90 | 4 +- fortran/test/tHDF5_F03.F90 | 2 +- fortran/test/tf.F90 | 30 +- fortran/test/vol_connector.F90 | 8 +- hl/c++/examples/Makefile.am | 4 +- hl/examples/Makefile.am | 4 +- hl/fortran/examples/Makefile.am | 4 +- hl/fortran/src/H5DSff.F90 | 68 +- hl/fortran/src/H5HL_buildiface.F90 | 50 +- hl/fortran/src/H5IMff.F90 | 102 +- hl/fortran/src/H5LTff.F90 | 90 +- hl/fortran/src/H5TBff.F90 | 128 +- hl/fortran/test/tstds.F90 | 36 +- hl/fortran/test/tstlite.F90 | 16 +- hl/fortran/test/tsttable.F90 | 14 +- hl/src/H5IM.c | 3 +- hl/src/H5LT.c | 16 +- hl/src/H5LTanalyze.l | 1 - hl/test/test_file_image.c | 2 +- hl/tools/gif2h5/decompress.c | 23 +- hl/tools/gif2h5/hdf2gif.c | 74 +- hl/tools/gif2h5/hdfgifwr.c | 96 +- hl/tools/h5watch/h5watch.c | 70 +- java/test/TestH5S.java | 2 +- src/CMakeLists.txt | 4 + src/H5.c | 4 +- src/H5AC.c | 283 +- src/H5Adense.c | 80 +- src/H5Aint.c | 207 +- src/H5B2.c | 17 +- src/H5B2hdr.c | 11 +- src/H5B2leaf.c | 2 +- src/H5B2pkg.h | 2 +- src/H5B2private.h | 2 +- src/H5Bdbg.c | 204 +- src/H5Bmodule.h | 2 +- src/H5Bpkg.h | 2 +- src/H5Bprivate.h | 4 +- src/H5CX.c | 11 +- src/H5CXmodule.h | 2 +- src/H5Cmpio.c | 256 +- src/H5D.c | 21 +- src/H5Dbtree2.c | 2 +- src/H5Dchunk.c | 45 +- src/H5Dearray.c | 398 +- src/H5Dfarray.c | 386 +- src/H5Dint.c | 34 +- src/H5Dio.c | 21 +- src/H5Dlayout.c | 36 +- src/H5Dmodule.h | 2 +- src/H5Dmpio.c | 2 +- src/H5Dnone.c | 42 +- src/H5Dpkg.h | 2 +- src/H5Dselect.c | 2 +- src/H5Dvirtual.c | 2 +- src/H5EA.c | 9 +- src/H5EAdbg.c | 164 +- src/H5EAmodule.h | 2 +- src/H5EApkg.h | 2 +- src/H5EAprivate.h | 2 +- src/H5EAsblock.c | 8 +- src/H5Eint.c | 11 +- src/H5Eprivate.h | 2 +- src/H5F.c | 167 +- src/H5FA.c | 5 - src/H5FAhdr.c | 2 +- src/H5FD.c | 52 +- src/H5FDcore.c | 18 +- src/H5FDlog.c | 450 +- src/H5FDmirror.c | 2001 +++++++++ src/H5FDmirror.h | 371 ++ src/H5FDmpio.c | 2 +- src/H5FDprivate.h | 2 +- src/H5FDpublic.h | 2 + src/H5FDros3.c | 8 +- src/H5FDsec2.c | 22 +- src/H5FDsplitter.c | 1470 +++++++ src/H5FDsplitter.h | 99 + src/H5FS.c | 2 +- src/H5FSsection.c | 10 +- src/H5Fint.c | 24 +- src/H5Fprivate.h | 13 +- src/H5Fquery.c | 2 + src/H5Glink.c | 8 +- src/H5Gloc.c | 6 +- src/H5Gname.c | 23 +- src/H5Gnode.c | 19 +- src/H5HLcache.c | 2 +- src/H5HLmodule.h | 2 +- src/H5HLpkg.h | 2 +- src/H5HLprivate.h | 2 +- src/H5I.c | 135 +- src/H5L.c | 46 +- src/H5Lexternal.c | 2 +- src/H5Lprivate.h | 2 +- src/H5MF.c | 5 +- src/H5MM.c | 25 + src/H5MMprivate.h | 1 + src/H5Oattr.c | 5 + src/H5Ochunk.c | 13 +- src/H5Ocont.c | 6 +- src/H5Odbg.c | 4 +- src/H5Odeprec.c | 12 +- src/H5Olink.c | 19 +- src/H5PB.c | 166 +- src/H5Pacpl.c | 1 - src/H5Pdcpl.c | 20 +- src/H5Pfapl.c | 27 +- src/H5Pint.c | 2 +- src/H5Plapl.c | 4 +- src/H5Plcpl.c | 2 +- src/H5Ptest.c | 10 +- src/H5Rint.c | 8 + src/H5S.c | 652 +-- src/H5Sall.c | 8 +- src/H5Sdbg.c | 25 +- src/H5Shyper.c | 344 +- src/H5Smpio.c | 32 +- src/H5Snone.c | 69 +- src/H5Spkg.h | 6 +- src/H5Spoint.c | 150 +- src/H5Sprivate.h | 1 + src/H5Sselect.c | 49 +- src/H5T.c | 69 +- src/H5TS.c | 1 + src/H5Tconv.c | 20 +- src/H5Tdbg.c | 69 +- src/H5Tpkg.h | 2 +- src/H5Tref.c | 67 +- src/H5VL.c | 39 +- src/H5VLcallback.c | 11 +- src/H5VLconnector.h | 20 +- src/H5VLint.c | 12 +- src/H5VLnative_attr.c | 3 +- src/H5VLnative_group.c | 5 +- src/H5VLpassthru.c | 12 + src/H5VLprivate.h | 4 +- src/H5VLpublic.h | 19 + src/H5Z.c | 156 +- src/H5Zfletcher32.c | 2 +- src/H5Ztrans.c | 47 +- src/H5dbg.c | 3 +- src/H5make_libsettings.c | 28 +- src/H5mpi.c | 2 +- src/H5private.h | 187 +- src/H5public.h | 56 +- src/H5system.c | 149 +- src/H5timer.c | 625 ++- src/H5trace.c | 263 +- src/Makefile.am | 14 +- src/hdf5.h | 2 + src/libhdf5.settings.in | 1 + test/CMakeLists.txt | 42 +- test/H5srcdir.h | 53 +- test/Makefile.am | 18 +- test/cache.c | 14 +- test/cache_api.c | 8 +- test/del_many_dense_attrs.c | 22 +- test/direct_chunk.c | 2 +- test/dsets.c | 711 +++- test/dtransform.c | 12 +- test/earray.c | 18 +- test/efc.c | 45 +- test/err_compat.c | 35 +- test/error_test.c | 31 +- test/extend.c | 156 +- test/farray.c | 18 +- test/fheap.c | 234 +- test/fillval.c | 31 +- test/flush2.c | 16 +- test/freespace.c | 52 +- test/gen_bogus.c | 2 +- test/gen_new_super.c | 5 +- test/gen_nullspace.c | 7 +- test/gen_plist.c | 2 +- test/gen_specmetaread.c | 6 +- test/getname.c | 28 +- test/h5test.c | 202 + test/h5test.h | 63 +- test/hyperslab.c | 14 +- test/mf.c | 116 +- test/mirror_vfd.c | 2761 ++++++++++++ test/ohdr.c | 8 +- test/page_buffer.c | 12 +- test/set_extent.c | 3 +- test/tattr.c | 4 +- test/test_mirror.sh.in | 100 + test/th5s.c | 59 +- test/tid.c | 25 +- test/timer.c | 414 ++ test/tmisc.c | 88 +- test/trefer.c | 282 +- test/tselect.c | 158 +- test/ttsafe_cancel.c | 2 +- test/tvltypes.c | 14 +- test/unregister.c | 23 +- test/use.h | 28 +- test/use_append_chunk.c | 158 +- test/use_append_chunk_mirror.c | 403 ++ test/use_append_mchunks.c | 153 +- test/use_common.c | 647 ++- test/vds.c | 161 +- test/vfd.c | 1284 +++++- testpar/t_2Gio.c | 87 +- testpar/t_cache.c | 4 +- testpar/t_init_term.c | 2 +- testpar/t_pflush2.c | 4 +- testpar/t_prestart.c | 2 +- testpar/t_pshutdown.c | 2 +- testpar/t_span_tree.c | 6 + tools/lib/h5diff.c | 200 +- tools/lib/h5diff.h | 180 +- tools/lib/h5diff_array.c | 4461 +++++++------------- tools/lib/h5diff_attr.c | 162 +- tools/lib/h5diff_dset.c | 670 ++- tools/lib/h5tools.c | 769 +++- tools/lib/h5tools.h | 118 +- tools/lib/h5tools_dump.c | 642 +-- tools/lib/h5tools_dump.h | 80 +- tools/lib/h5tools_error.h | 52 +- tools/lib/h5tools_str.c | 98 +- tools/lib/h5tools_str.h | 5 +- tools/lib/h5tools_utils.c | 167 +- tools/lib/h5tools_utils.h | 7 +- tools/lib/io_timer.c | 1 - tools/libtest/h5tools_test_utils.c | 18 +- tools/src/h5copy/h5copy.c | 22 +- tools/src/h5diff/h5diff_common.c | 368 +- tools/src/h5diff/h5diff_main.c | 36 +- tools/src/h5dump/h5dump.c | 397 +- tools/src/h5dump/h5dump.h | 39 +- tools/src/h5dump/h5dump_ddl.c | 106 +- tools/src/h5dump/h5dump_extern.h | 43 +- tools/src/h5dump/h5dump_xml.c | 82 +- tools/src/h5format_convert/h5format_convert.c | 175 +- tools/src/h5import/h5import.c | 45 +- tools/src/h5jam/h5jam.c | 82 +- tools/src/h5jam/h5unjam.c | 20 +- tools/src/h5ls/h5ls.c | 609 +-- tools/src/h5repack/h5repack.c | 9 +- tools/src/h5repack/h5repack.h | 4 +- tools/src/h5repack/h5repack_copy.c | 82 +- tools/src/h5repack/h5repack_main.c | 230 +- tools/src/h5repack/h5repack_verify.c | 22 +- tools/src/h5stat/h5stat.c | 214 +- tools/src/misc/h5clear.c | 9 +- tools/src/misc/h5debug.c | 403 +- tools/src/misc/h5mkgrp.c | 240 +- tools/test/h5diff/CMakeTests.cmake | 34 +- tools/test/h5diff/h5diffgentest.c | 131 +- tools/test/h5diff/testfiles/diff_strings1.h5 | Bin 4640 -> 0 bytes tools/test/h5diff/testfiles/diff_strings2.h5 | Bin 4640 -> 0 bytes tools/test/h5diff/testfiles/h5diff_10.txt | 27 +- tools/test/h5diff/testfiles/h5diff_58_ref.txt | 12 +- tools/test/h5diff/testfiles/h5diff_600.txt | 27 +- tools/test/h5diff/testfiles/h5diff_603.txt | 27 +- tools/test/h5diff/testfiles/h5diff_606.txt | 27 +- tools/test/h5diff/testfiles/h5diff_612.txt | 27 +- tools/test/h5diff/testfiles/h5diff_615.txt | 27 +- tools/test/h5diff/testfiles/h5diff_621.txt | 27 +- tools/test/h5diff/testfiles/h5diff_622.txt | 27 +- tools/test/h5diff/testfiles/h5diff_623.txt | 27 +- tools/test/h5diff/testfiles/h5diff_624.txt | 27 +- tools/test/h5diff/testfiles/h5diff_70.txt | 32 + tools/test/h5diff/testfiles/h5diff_700.txt | 32 + tools/test/h5diff/testfiles/h5diff_701.txt | 32 + tools/test/h5diff/testfiles/h5diff_702.txt | 32 + tools/test/h5diff/testfiles/h5diff_703.txt | 32 + tools/test/h5diff/testfiles/h5diff_80.txt | 64 +- tools/test/h5diff/testfiles/h5diff_eps.txt | 17 + tools/test/h5diff/testfiles/h5diff_eps1.h5 | Bin 0 -> 2272 bytes tools/test/h5diff/testfiles/h5diff_eps2.h5 | Bin 0 -> 2272 bytes tools/test/h5diff/testfiles/h5diff_reg.txt | 9 +- tools/test/h5diff/testfiles/h5diff_strings1.h5 | Bin 0 -> 4640 bytes tools/test/h5diff/testfiles/h5diff_strings2.h5 | Bin 0 -> 4640 bytes tools/test/h5diff/testh5diff.sh.in | 27 +- tools/test/h5dump/CMakeLists.txt | 2 +- tools/test/h5dump/Makefile.am | 2 +- tools/test/h5dump/h5dumpgentest.c | 619 ++- tools/test/h5format_convert/h5fc_chk_idx.c | 2 +- .../h5format_convert/testfiles/h5fc_v_err.ddl.err | 7 - tools/test/h5import/h5importtest.c | 9 +- tools/test/h5jam/tellub.c | 46 +- tools/test/h5repack/CMakeLists.txt | 2 +- tools/test/h5repack/CMakeTests.cmake | 4 +- tools/test/h5repack/h5repack.sh.in | 2 +- tools/test/h5repack/h5repacktst.c | 553 +-- .../h5repack/testfiles/attrregion.tattrreg.h5.ddl | 2 +- tools/test/h5repack/testfiles/h5repack-help.txt | 15 +- tools/test/misc/CMakeLists.txt | 2 +- tools/test/misc/Makefile.am | 2 +- tools/test/misc/clear_open_chk.c | 2 +- tools/test/misc/h5clear_gentest.c | 25 +- tools/test/misc/testfiles/h5mkgrp_help.txt | 7 + tools/test/perform/CMakeLists.txt | 2 +- tools/test/perform/chunk_cache.c | 82 +- tools/test/perform/iopipe.c | 403 +- tools/test/perform/pio_perf.c | 2 +- tools/test/perform/pio_standalone.h | 2 +- tools/test/perform/sio_perf.c | 8 +- tools/test/perform/sio_standalone.h | 2 +- tools/test/perform/zip_perf.c | 4 +- tools/testfiles/h5dump-help.txt | 6 + tools/testfiles/help-1.ls | 6 + tools/testfiles/help-2.ls | 6 + tools/testfiles/help-3.ls | 6 + .../pbits/tnofilename-with-packed-bits.ddl | 6 + tools/testfiles/pbits/tpbitsIncomplete.ddl | 6 + tools/testfiles/pbits/tpbitsLengthExceeded.ddl | 6 + tools/testfiles/pbits/tpbitsLengthPositive.ddl | 6 + tools/testfiles/pbits/tpbitsMaxExceeded.ddl | 6 + tools/testfiles/pbits/tpbitsOffsetExceeded.ddl | 6 + tools/testfiles/pbits/tpbitsOffsetNegative.ddl | 6 + tools/testfiles/textlinksrc-nodangle-1.ls | 6 + tools/testfiles/tgroup-1.ls | 6 + tools/testfiles/tgrpnullspace.ddl | 2 +- tools/testfiles/tintsnodata.ddl | 18 +- tools/testfiles/trefer_attrR.ddl | 6 +- tools/testfiles/trefer_extR.ddl | 6 +- utils/CMakeLists.txt | 4 + utils/COPYING | 12 + utils/Makefile.am | 26 + utils/mirror_vfd/CMakeLists.txt | 64 + utils/mirror_vfd/Makefile.am | 30 + utils/mirror_vfd/mirror_remote.c | 225 + utils/mirror_vfd/mirror_remote.h | 51 + utils/mirror_vfd/mirror_server.c | 666 +++ utils/mirror_vfd/mirror_server_stop.c | 214 + utils/mirror_vfd/mirror_writer.c | 1103 +++++ 392 files changed, 28619 insertions(+), 15059 deletions(-) create mode 100644 examples/h5_debug_trace.c create mode 100644 src/H5FDmirror.c create mode 100644 src/H5FDmirror.h create mode 100644 src/H5FDsplitter.c create mode 100644 src/H5FDsplitter.h create mode 100644 test/mirror_vfd.c create mode 100644 test/test_mirror.sh.in create mode 100644 test/timer.c create mode 100644 test/use_append_chunk_mirror.c delete mode 100644 tools/test/h5diff/testfiles/diff_strings1.h5 delete mode 100644 tools/test/h5diff/testfiles/diff_strings2.h5 create mode 100644 tools/test/h5diff/testfiles/h5diff_eps.txt create mode 100644 tools/test/h5diff/testfiles/h5diff_eps1.h5 create mode 100644 tools/test/h5diff/testfiles/h5diff_eps2.h5 create mode 100644 tools/test/h5diff/testfiles/h5diff_strings1.h5 create mode 100644 tools/test/h5diff/testfiles/h5diff_strings2.h5 create mode 100644 utils/CMakeLists.txt create mode 100644 utils/COPYING create mode 100644 utils/Makefile.am create mode 100644 utils/mirror_vfd/CMakeLists.txt create mode 100644 utils/mirror_vfd/Makefile.am create mode 100644 utils/mirror_vfd/mirror_remote.c create mode 100644 utils/mirror_vfd/mirror_remote.h create mode 100644 utils/mirror_vfd/mirror_server.c create mode 100644 utils/mirror_vfd/mirror_server_stop.c create mode 100644 utils/mirror_vfd/mirror_writer.c diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a3fdadb..60e21c7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,8 +4,8 @@ name: hdf5 dev CI on: push: branches: [ develop, hdf5_1_12, hdf5_1_10, hdf5_1_8 ] -# pull_request: -# branches: [ develop ] + pull_request: + branches: [ develop, hdf5_1_12, hdf5_1_10, hdf5_1_8 ] # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: diff --git a/CMakeInstallation.cmake b/CMakeInstallation.cmake index 12d8273..94d3139 100644 --- a/CMakeInstallation.cmake +++ b/CMakeInstallation.cmake @@ -554,6 +554,13 @@ The HDF5 data model, file format, API, library, and tools are open and distribut ) endif () + cpack_add_component (utilsapplications + DISPLAY_NAME "HDF5 Utility Applications" + DEPENDS libraries + GROUP Applications + INSTALL_TYPES Full Developer User + ) + if (HDF5_BUILD_TOOLS) cpack_add_component (toolsapplications DISPLAY_NAME "HDF5 Tools Applications" diff --git a/CMakeLists.txt b/CMakeLists.txt index edf7a3c..fb20b1b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -137,6 +137,7 @@ set (HDF5_CPP_LIB_CORENAME "hdf5_cpp") set (HDF5_HL_LIB_CORENAME "hdf5_hl") set (HDF5_HL_CPP_LIB_CORENAME "hdf5_hl_cpp") set (HDF5_TOOLS_LIB_CORENAME "hdf5_tools") +set (HDF5_UTILS_LIB_CORENAME "hdf5_utils") set (HDF5_F90_LIB_CORENAME "hdf5_fortran") set (HDF5_F90_C_LIB_CORENAME "hdf5_f90cstub") set (HDF5_F90_TEST_LIB_CORENAME "hdf5_test_fortran") @@ -156,6 +157,7 @@ set (HDF5_CPP_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_CPP_LIB_COREN set (HDF5_HL_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_HL_LIB_CORENAME}") set (HDF5_HL_CPP_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_HL_CPP_LIB_CORENAME}") set (HDF5_TOOLS_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TOOLS_LIB_CORENAME}") +set (HDF5_UTILS_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_UTILS_LIB_CORENAME}") set (HDF5_F90_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_F90_LIB_CORENAME}") set (HDF5_F90_C_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_F90_C_LIB_CORENAME}") set (HDF5_F90_TEST_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_F90_TEST_LIB_CORENAME}") @@ -175,6 +177,7 @@ set (HDF5_CPP_LIB_TARGET "${HDF5_CPP_LIB_CORENAME}-static") set (HDF5_HL_LIB_TARGET "${HDF5_HL_LIB_CORENAME}-static") set (HDF5_HL_CPP_LIB_TARGET "${HDF5_HL_CPP_LIB_CORENAME}-static") set (HDF5_TOOLS_LIB_TARGET "${HDF5_TOOLS_LIB_CORENAME}-static") +set (HDF5_UTILS_LIB_TARGET "${HDF5_UTILS_LIB_CORENAME}-static") set (HDF5_F90_LIB_TARGET "${HDF5_F90_LIB_CORENAME}-static") set (HDF5_F90_C_LIB_TARGET "${HDF5_F90_C_LIB_CORENAME}-static") set (HDF5_F90_TEST_LIB_TARGET "${HDF5_F90_TEST_LIB_CORENAME}-static") @@ -190,6 +193,7 @@ set (HDF5_CPP_LIBSH_TARGET "${HDF5_CPP_LIB_CORENAME}-shared") set (HDF5_HL_LIBSH_TARGET "${HDF5_HL_LIB_CORENAME}-shared") set (HDF5_HL_CPP_LIBSH_TARGET "${HDF5_HL_CPP_LIB_CORENAME}-shared") set (HDF5_TOOLS_LIBSH_TARGET "${HDF5_TOOLS_LIB_CORENAME}-shared") +set (HDF5_UTILS_LIBSH_TARGET "${HDF5_UTILS_LIB_CORENAME}-shared") set (HDF5_F90_LIBSH_TARGET "${HDF5_F90_LIB_CORENAME}-shared") set (HDF5_F90_C_LIBSH_TARGET "${HDF5_F90_C_LIB_CORENAME}-shared") set (HDF5_F90_TEST_LIBSH_TARGET "${HDF5_F90_TEST_LIB_CORENAME}-shared") @@ -212,6 +216,7 @@ set (HDF5_HL_TOOLS_DIR ${HDF5_SOURCE_DIR}/hl/tools) set (HDF5_TOOLS_DIR ${HDF5_SOURCE_DIR}/tools) set (HDF5_TOOLS_SRC_DIR ${HDF5_SOURCE_DIR}/tools/src) set (HDF5_PERFORM_SRC_DIR ${HDF5_SOURCE_DIR}/tools/src/perform) +set (HDF5_UTILS_DIR ${HDF5_SOURCE_DIR}/utils) set (HDF5_F90_SRC_DIR ${HDF5_SOURCE_DIR}/fortran) set (HDF5_JAVA_JNI_SRC_DIR ${HDF5_SOURCE_DIR}/java/src/jni) set (HDF5_JAVA_HDF5_SRC_DIR ${HDF5_SOURCE_DIR}/java/src/hdf) @@ -909,6 +914,16 @@ if (BUILD_TESTING) endif () #----------------------------------------------------------------------------- +# Option to build HDF5 Utilities +#----------------------------------------------------------------------------- +if (EXISTS "${HDF5_SOURCE_DIR}/utils" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/utils") + option (HDF5_BUILD_UTILS "Build HDF5 Utils" ON) + if (HDF5_BUILD_UTILS) + add_subdirectory (utils) + endif () +endif () + +#----------------------------------------------------------------------------- # Option to build HDF5 Tools #----------------------------------------------------------------------------- if (EXISTS "${HDF5_SOURCE_DIR}/tools" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/tools") diff --git a/MANIFEST b/MANIFEST index e2ff1ba..89d89f6 100644 --- a/MANIFEST +++ b/MANIFEST @@ -190,6 +190,7 @@ ./examples/h5_chunk_read.c ./examples/h5_compound.c ./examples/h5_crtgrpd.c +./examples/h5_debug_trace.c ./examples/h5_subset.c ./examples/h5_cmprss.c ./examples/h5_rdwt.c @@ -688,6 +689,8 @@ ./src/H5FDint.c ./src/H5FDlog.c ./src/H5FDlog.h +./src/H5FDmirror.c +./src/H5FDmirror.h ./src/H5FDmodule.h ./src/H5FDmpi.c ./src/H5FDmpi.h @@ -705,6 +708,8 @@ ./src/H5FDsec2.c ./src/H5FDsec2.h ./src/H5FDspace.c +./src/H5FDsplitter.c +./src/H5FDsplitter.h ./src/H5FDstdio.c ./src/H5FDstdio.h ./src/H5FDtest.c @@ -1147,6 +1152,7 @@ ./test/memleak_H5O_dtype_decode_helper_H5Odtype.h5 ./test/mergemsg.h5 ./test/mf.c +./test/mirror_vfd.c ./test/mount.c ./test/mtime.c ./test/multi_file_v16-r.h5 @@ -1207,6 +1213,7 @@ ./test/testhdf5.c ./test/testhdf5.h ./test/testlibinfo.sh.in +./test/test_mirror.sh.in ./test/test_usecases.sh.in ./test/test_vol_plugin.sh.in ./test/testmeta.c @@ -1221,6 +1228,7 @@ ./test/theap.c ./test/thread_id.c ./test/tid.c +./test/timer.c ./test/titerate.c ./test/tlayouto.h5 ./test/tmeta.c @@ -1251,6 +1259,7 @@ ./test/unlink.c ./test/unregister.c ./test/use_append_chunk.c +./test/use_append_chunk_mirror.c ./test/use_append_mchunks.c ./test/use_common.c ./test/use_disable_mdc_flushes.c @@ -1369,7 +1378,6 @@ ./testpar/COPYING ./testpar/Makefile.am -./testpar/t_2Gio.c ./testpar/t_bigio.c ./testpar/t_cache.c ./testpar/t_cache_image.c @@ -1394,6 +1402,7 @@ ./testpar/t_prestart.c ./testpar/t_span_tree.c ./testpar/t_init_term.c +./testpar/t_2Gio.c ./testpar/testpar.h ./testpar/testpflush.sh.in ./testpar/testphdf5.c @@ -2597,6 +2606,8 @@ ./tools/test/h5diff/testfiles/h5diff_dset3.h5 ./tools/test/h5diff/testfiles/h5diff_dtypes.h5 ./tools/test/h5diff/testfiles/h5diff_empty.h5 +./tools/test/h5diff/testfiles/h5diff_eps1.h5 +./tools/test/h5diff/testfiles/h5diff_eps2.h5 ./tools/test/h5diff/testfiles/h5diff_hyper1.h5 ./tools/test/h5diff/testfiles/h5diff_hyper2.h5 ./tools/test/h5diff/testfiles/h5diff_types.h5 @@ -2625,6 +2636,7 @@ ./tools/test/h5diff/testfiles/h5diff_dset_zero_dim_size1.h5 ./tools/test/h5diff/testfiles/h5diff_dset_zero_dim_size2.h5 ./tools/test/h5diff/testfiles/h5diff_enum_invalid_values.h5 +./tools/test/h5diff/testfiles/h5diff_eps.txt ./tools/test/h5diff/testfiles/compounds_array_vlen1.h5 ./tools/test/h5diff/testfiles/compounds_array_vlen2.h5 ./tools/test/h5diff/testfiles/non_comparables1.h5 @@ -2636,8 +2648,8 @@ ./tools/test/h5diff/testfiles/h5diff_ud.txt ./tools/test/h5diff/testfiles/h5diff_udfail.err ./tools/test/h5diff/testfiles/h5diff_udfail.txt -./tools/test/h5diff/testfiles/diff_strings1.h5 -./tools/test/h5diff/testfiles/diff_strings2.h5 +./tools/test/h5diff/testfiles/h5diff_strings1.h5 +./tools/test/h5diff/testfiles/h5diff_strings2.h5 ./tools/test/h5diff/testfiles/h5diff_vlstr.txt #vds ./tools/test/h5diff/testfiles/h5diff_v1.txt @@ -2807,6 +2819,18 @@ ./tools/test/perform/sio_standalone.h ./tools/test/perform/zip_perf.c +# Utils directory +./utils/COPYING +./utils/Makefile.am + +# Mirror VFD utilities +./utils/mirror_vfd/Makefile.am +./utils/mirror_vfd/mirror_remote.c +./utils/mirror_vfd/mirror_remote.h +./utils/mirror_vfd/mirror_server.c +./utils/mirror_vfd/mirror_server_stop.c +./utils/mirror_vfd/mirror_writer.c + # high level libraries ./hl/COPYING ./hl/Makefile.am @@ -3544,6 +3568,8 @@ ./tools/test/misc/vds/CMakeLists.txt ./tools/test/perform/CMakeLists.txt ./tools/test/perform/CMakeTests.cmake +./utils/CMakeLists.txt +./utils/mirror_vfd/CMakeLists.txt # CMake-specific User Scripts ./config/cmake/CTestScript.cmake diff --git a/Makefile.am b/Makefile.am index 47da74d..8565788 100644 --- a/Makefile.am +++ b/Makefile.am @@ -85,9 +85,9 @@ else TOOLS_DIR= endif -SUBDIRS = src $(TESTSERIAL_DIR) $(TESTPARALLEL_DIR) bin $(TOOLS_DIR) . \ +SUBDIRS = src $(TESTSERIAL_DIR) $(TESTPARALLEL_DIR) bin utils $(TOOLS_DIR) . \ $(CXX_DIR) $(FORTRAN_DIR) $(JAVA_DIR) $(HDF5_HL_DIR) -DIST_SUBDIRS = src test testpar tools . c++ fortran hl examples java +DIST_SUBDIRS = src test testpar utils tools . c++ fortran hl examples java # Some files generated during configure that should be cleaned DISTCLEANFILES=config/stamp1 config/stamp2 @@ -190,7 +190,7 @@ trace: # Run tests with different Virtual File Drivers. # Currently, only invoke check-vfd in the test directory. check-vfd: - for d in src test; do \ + for d in src utils test; do \ if test $$d != .; then \ (cd $$d && $(MAKE) $(AM_MAKEFLAGS) $@) || exit 1; \ fi; \ diff --git a/bin/release b/bin/release index b4203f6..41422d0 100755 --- a/bin/release +++ b/bin/release @@ -39,36 +39,36 @@ USAGE() { cat << EOF Usage: $0 -d [--docver BRANCHNAME] [-h] [--nocheck] [--private] ... - -d DIR The name of the directory where the releas(es) should be + -d DIR The name of the directory where the releas(es) should be placed. --docver BRANCHNAME This is added for 1.8 and beyond to get the correct version of documentation files from the hdf5docs repository. BRANCHNAME for v1.8 should be hdf5_1_8. -h print the help page. - --nocheck Ignore errors in MANIFEST file. - --private Make a private release with today's date in version information. - + --nocheck Ignore errors in MANIFEST file. + --private Make a private release with today's date in version information. + This must be run at the top level of the source directory. The other command-line options are the names of the programs to use for compressing the resulting tar archive (if none are given then "tar" is assumed): - tar -- use tar and don't do any compressing. - gzip -- use gzip with "-9" and append ".gz" to the output name. + tar -- use tar and don't do any compressing. + gzip -- use gzip with "-9" and append ".gz" to the output name. bzip2 -- use bzip2 with "-9" and append ".bz2" to the output name. - zip -- convert all text files to DOS style and form a zip file for Windows use. - cmake-tgz -- create a tar file using the gzip default level with a build-unix.sh + zip -- convert all text files to DOS style and form a zip file for Windows use. + cmake-tgz -- create a tar file using the gzip default level with a build-unix.sh command file and all other CMake files needed to build HDF5 source using CMake on unix machines. cmake-zip -- convert all text files to DOS style and create a zip file inluding cmake - scripts and .bat files to build HDF5 source using CMake on Windows. - hpc-cmake-tgz - -- create a tar file using the gzip default level with a build-unix.sh + scripts and .bat files to build HDF5 source using CMake on Windows. + hpc-cmake-tgz + -- create a tar file using the gzip default level with a build-unix.sh command file and all other CMake files needed to build HDF5 source using CMake on unix machines, with HDF5options.cmake files for serial and parallel builds on machines requiring batch jobs to run tests. The default is for parallel build, with serial only build by changing - the HDF5options.cmake symlink to ser-HDF5options.cmake. More + the HDF5options.cmake symlink to ser-HDF5options.cmake. More information is available in the README_HPC file. doc -- produce the latest doc tree in addition to the archive. @@ -122,8 +122,8 @@ EOF tar2zip() { if [ $# -ne 3 ]; then - echo "usage: tar2zip " - return 1 + echo "usage: tar2zip " + return 1 fi ztmpdir=/tmp/ztmpdir$$ mkdir -p $ztmpdir @@ -135,23 +135,23 @@ tar2zip() (cd $ztmpdir; tar xf -) < $tarfile # sanity check if [ ! -d $ztmpdir/$version ]; then - echo "untar did not create $ztmpdir/$version source dir" - # cleanup - rm -rf $ztmpdir - return 1 + echo "untar did not create $ztmpdir/$version source dir" + # cleanup + rm -rf $ztmpdir + return 1 fi # step 2: convert text files # There maybe a simpler way to do this. # options used in unix2dos: - # -k Keep the date stamp + # -k Keep the date stamp # -q quiet mode # grep redirect output to /dev/null because -q or -s are not portable. find $ztmpdir/$version | \ - while read inf; do \ - if file $inf | grep "$inf\: .*text" > /dev/null 2>&1 ; then \ - unix2dos -q -k $inf; \ - fi\ - done + while read inf; do \ + if file $inf | grep "$inf\: .*text" > /dev/null 2>&1 ; then \ + unix2dos -q -k $inf; \ + fi\ + done # step 3: make zipball # -9 maximum compression # -y Store symbolic links as such in the zip archive @@ -202,8 +202,8 @@ tar2zip() tar2cmakezip() { if [ $# -ne 3 ]; then - echo "usage: tar2cmakezip " - return 1 + echo "usage: tar2cmakezip " + return 1 fi cmziptmpdir=/tmp/cmziptmpdir$$ cmziptmpsubdir=$cmziptmpdir/CMake-$HDF5_VERS @@ -216,10 +216,10 @@ tar2cmakezip() (cd $cmziptmpsubdir; tar xf -) < $tarfile # sanity check if [ ! -d $cmziptmpsubdir/$version ]; then - echo "untar did not create $cmziptmpsubdir/$version source dir" - # cleanup - rm -rf $cmziptmpdir - return 1 + echo "untar did not create $cmziptmpsubdir/$version source dir" + # cleanup + rm -rf $cmziptmpdir + return 1 fi # step 2: add batch file for building CMake on window @@ -241,15 +241,15 @@ tar2cmakezip() # step 4: convert text files # There maybe a simpler way to do this. # options used in unix2dos: - # -k Keep the date stamp + # -k Keep the date stamp # -q quiet mode # grep redirect output to /dev/null because -q or -s are not portable. find $cmziptmpsubdir/$version | \ - while read inf; do \ - if file $inf | grep "$inf\: .*text" > /dev/null 2>&1 ; then \ - unix2dos -q -k $inf; \ - fi\ - done + while read inf; do \ + if file $inf | grep "$inf\: .*text" > /dev/null 2>&1 ; then \ + unix2dos -q -k $inf; \ + fi\ + done # step 3: make zipball # -9 maximum compression @@ -301,8 +301,8 @@ tar2cmakezip() tar2cmaketgz() { if [ $# -ne 3 ]; then - echo "usage: tar2cmaketgz " - return 1 + echo "usage: tar2cmaketgz " + return 1 fi cmgztmpdir=/tmp/cmgztmpdir$$ cmgztmpsubdir=$cmgztmpdir/CMake-$HDF5_VERS @@ -315,10 +315,10 @@ tar2cmaketgz() (cd $cmgztmpsubdir; tar xf -) < $tarfile # sanity check if [ ! -d $cmgztmpsubdir/$version ]; then - echo "untar did not create $cmgztmpsubdir/$version source dir" - # cleanup - rm -rf $cmgztmpdir - return 1 + echo "untar did not create $cmgztmpsubdir/$version source dir" + # cleanup + rm -rf $cmgztmpdir + return 1 fi @@ -332,8 +332,8 @@ tar2cmaketgz() cp $cmgztmpsubdir/$version/config/cmake/scripts/CTestScript.cmake $cmgztmpsubdir cp $cmgztmpsubdir/$version/config/cmake/scripts/HDF5config.cmake $cmgztmpsubdir cp $cmgztmpsubdir/$version/config/cmake/scripts/HDF5options.cmake $cmgztmpsubdir - tar czf $DEST/CMake-$HDF5_VERS.tar.gz -C $cmgztmpdir . || exit 1 - + tar czf $DEST/CMake-$HDF5_VERS.tar.gz -C $cmgztmpdir . || exit 1 + # cleanup rm -rf $cmgztmpdir } @@ -384,8 +384,8 @@ tar2cmaketgz() tar2hpccmaketgz() { if [ $# -ne 3 ]; then - echo "usage: tar2hpccmaketgz " - return 1 + echo "usage: tar2hpccmaketgz " + return 1 fi cmgztmpdir=/tmp/cmgztmpdir$$ cmgztmpsubdir=$cmgztmpdir/HPC-CMake-$HDF5_VERS @@ -398,10 +398,10 @@ tar2hpccmaketgz() (cd $cmgztmpsubdir; tar xf -) < $tarfile # sanity check if [ ! -d $cmgztmpsubdir/$version ]; then - echo "untar did not create $cmgztmpsubdir/$version source dir" - # cleanup - rm -rf $cmgztmpdir - return 1 + echo "untar did not create $cmgztmpsubdir/$version source dir" + # cleanup + rm -rf $cmgztmpdir + return 1 fi @@ -419,8 +419,8 @@ tar2hpccmaketgz() cp $cmgztmpsubdir/$version/config/cmake/scripts/HPC/ser-HDF5options.cmake $cmgztmpsubdir cp $cmgztmpsubdir/$version/config/cmake/scripts/HPC/par-HDF5options.cmake $cmgztmpsubdir (cd $cmgztmpsubdir; ln -s par-HDF5options.cmake HDF5options.cmake) - tar czf $DEST/HPC-CMake-$HDF5_VERS.tar.gz -C $cmgztmpdir . || exit 1 - + tar czf $DEST/HPC-CMake-$HDF5_VERS.tar.gz -C $cmgztmpdir . || exit 1 + # cleanup rm -rf $cmgztmpdir } @@ -442,7 +442,7 @@ check=yes release_date=`date +%F` today=`date +%Y%m%d` pmode='no' -tmpdir="../#release_tmp.$$" # tmp work directory +tmpdir="../#release_tmp.$$" # tmp work directory DOC_URL=https://git@bitbucket.hdfgroup.org/scm/hdffv/hdf5doc.git CPPLUS_RM_NAME=cpplus_RM MAINT_MODE_ENABLED="" @@ -459,11 +459,11 @@ fi RESTORE_VERSION() { if [ X-${VERS_OLD} != X- ]; then - echo restoring version information back to $VERS_OLD - rm -f config/lt_vers.am - cp $tmpdir/lt_vers.am config/lt_vers.am - bin/h5vers -s $VERS_OLD - VERS_OLD= + echo restoring version information back to $VERS_OLD + rm -f config/lt_vers.am + cp $tmpdir/lt_vers.am config/lt_vers.am + bin/h5vers -s $VERS_OLD + VERS_OLD= fi } @@ -473,32 +473,32 @@ while [ -n "$1" ]; do arg=$1 shift case "$arg" in - -d) - DEST=$1 - shift - ;; - --nocheck) - check=no - ;; - -h) - USAGE - exit 0 - ;; - --private) - pmode=yes - ;; + -d) + DEST=$1 + shift + ;; + --nocheck) + check=no + ;; + -h) + USAGE + exit 0 + ;; + --private) + pmode=yes + ;; --docver) DOCVERSION=$1 shift ;; - -*) - echo "Unknown switch: $arg" 1>&2 - USAGE - exit 1 - ;; - *) - methods="$methods $arg" - ;; + -*) + echo "Unknown switch: $arg" 1>&2 + USAGE + exit 1 + ;; + *) + methods="$methods $arg" + ;; esac done @@ -548,12 +548,12 @@ if [ "X$fail" = "Xyes" ]; then echo "" echo "Note! If you are running bin/release in a development branch" echo "later than v 1.8 the MANIFEST check is expected to fail when" - echo "autogen.sh has not been run successfully. Either run autogen.sh " + echo "autogen.sh has not been run successfully. Either run autogen.sh " echo "with /usr/hdf/bin/AUTOTOOLS at the beginning of PATH or add the" echo "--nocheck argument to the bin/release command." exit 1 else - echo "Continuing anyway..." + echo "Continuing anyway..." fi fi @@ -587,7 +587,7 @@ test "$verbose" && echo " Running tar..." 1>&2 ( \ cd $tmpdir; \ tar cf $HDF5_VERS.tar $HDF5_VERS/Makefile \ - `sed 's/^\.\//hdf5-'$VERS'\//' $MANIFEST` || exit 1 \ + `sed 's/^\.\//hdf5-'$VERS'\//' $MANIFEST` || exit 1 \ ) # Compress @@ -595,61 +595,61 @@ MD5file=$HDF5_VERS.md5 cp /dev/null $DEST/$MD5file for comp in $methods; do case $comp in - tar) - cp -p $tmpdir/$HDF5_VERS.tar $DEST/$HDF5_VERS.tar - (cd $DEST; md5sum $HDF5_VERS.tar >> $MD5file) - ;; - gzip) - test "$verbose" && echo " Running gzip..." 1>&2 - gzip -9 <$tmpdir/$HDF5_VERS.tar >$DEST/$HDF5_VERS.tar.gz - (cd $DEST; md5sum $HDF5_VERS.tar.gz >> $MD5file) - ;; + tar) + cp -p $tmpdir/$HDF5_VERS.tar $DEST/$HDF5_VERS.tar + (cd $DEST; md5sum $HDF5_VERS.tar >> $MD5file) + ;; + gzip) + test "$verbose" && echo " Running gzip..." 1>&2 + gzip -9 <$tmpdir/$HDF5_VERS.tar >$DEST/$HDF5_VERS.tar.gz + (cd $DEST; md5sum $HDF5_VERS.tar.gz >> $MD5file) + ;; cmake-tgz) - test "$verbose" && echo " Creating CMake tar.gz file..." 1>&2 - tar2cmaketgz $HDF5_VERS $tmpdir/$HDF5_VERS.tar $DEST/CMake-$HDF5_VERS.tar.gz 1>&2 - (cd $DEST; md5sum CMake-$HDF5_VERS.tar.gz >> $MD5file) + test "$verbose" && echo " Creating CMake tar.gz file..." 1>&2 + tar2cmaketgz $HDF5_VERS $tmpdir/$HDF5_VERS.tar $DEST/CMake-$HDF5_VERS.tar.gz 1>&2 + (cd $DEST; md5sum CMake-$HDF5_VERS.tar.gz >> $MD5file) ;; hpc-cmake-tgz) - test "$verbose" && echo " Creating HPC-CMake tar.gz file..." 1>&2 - tar2hpccmaketgz $HDF5_VERS $tmpdir/$HDF5_VERS.tar $DEST/HPC-CMake-$HDF5_VERS.tar.gz 1>&2 - (cd $DEST; md5sum HPC-CMake-$HDF5_VERS.tar.gz >> $MD5file) + test "$verbose" && echo " Creating HPC-CMake tar.gz file..." 1>&2 + tar2hpccmaketgz $HDF5_VERS $tmpdir/$HDF5_VERS.tar $DEST/HPC-CMake-$HDF5_VERS.tar.gz 1>&2 + (cd $DEST; md5sum HPC-CMake-$HDF5_VERS.tar.gz >> $MD5file) + ;; + bzip2) + test "$verbose" && echo " Running bzip2..." 1>&2 + bzip2 -9 <$tmpdir/$HDF5_VERS.tar >$DEST/$HDF5_VERS.tar.bz2 + (cd $DEST; md5sum $HDF5_VERS.tar.bz2 >> $MD5file) + ;; + zip) + test "$verbose" && echo " Creating zip ball..." 1>&2 + tar2zip $HDF5_VERS $tmpdir/$HDF5_VERS.tar $DEST/$HDF5_VERS.zip 1>&2 + (cd $DEST; md5sum $HDF5_VERS.zip >> $MD5file) ;; - bzip2) - test "$verbose" && echo " Running bzip2..." 1>&2 - bzip2 -9 <$tmpdir/$HDF5_VERS.tar >$DEST/$HDF5_VERS.tar.bz2 - (cd $DEST; md5sum $HDF5_VERS.tar.bz2 >> $MD5file) - ;; - zip) - test "$verbose" && echo " Creating zip ball..." 1>&2 - tar2zip $HDF5_VERS $tmpdir/$HDF5_VERS.tar $DEST/$HDF5_VERS.zip 1>&2 - (cd $DEST; md5sum $HDF5_VERS.zip >> $MD5file) - ;; cmake-zip) test "$verbose" && echo " Creating CMake-zip ball..." 1>&2 tar2cmakezip $HDF5_VERS $tmpdir/$HDF5_VERS.tar $DEST/CMake-$HDF5_VERS.zip 1>&2 (cd $DEST; md5sum CMake-$HDF5_VERS.zip >> $MD5file) ;; - doc) + doc) if [ "${DOCVERSION}" = "" ]; then DOCVERSION=master fi - test "$verbose" && echo " Creating docs..." 1>&2 - # Check out docs from git repo - (cd $tmpdir; git clone -q $DOC_URL ${DOCVERSION} > /dev/null) || exit 1 + test "$verbose" && echo " Creating docs..." 1>&2 + # Check out docs from git repo + (cd $tmpdir; git clone -q $DOC_URL ${DOCVERSION} > /dev/null) || exit 1 # Create doxygen C++ RM - (cd c++/src && doxygen cpp_doc_config > /dev/null ) || exit 1 - # Replace version of C++ RM with just-created version - rm -rf $tmpdir/${DOCVERSION}/html/$CPPLUS_RM_NAME || exit 1 - mv c++/src/$CPPLUS_RM_NAME $tmpdir/${DOCVERSION}/html/$CPPLUS_RM_NAME || exit 1 + (cd c++/src && doxygen cpp_doc_config > /dev/null ) || exit 1 + # Replace version of C++ RM with just-created version + rm -rf $tmpdir/${DOCVERSION}/html/$CPPLUS_RM_NAME || exit 1 + mv c++/src/$CPPLUS_RM_NAME $tmpdir/${DOCVERSION}/html/$CPPLUS_RM_NAME || exit 1 # Compress the docs and move them to the release area - mv $tmpdir/${DOCVERSION} $tmpdir/${HDF5_VERS}_docs || exit 1 - (cd $tmpdir && tar cf ${HDF5_VERS}_docs.tar ${HDF5_VERS}_docs) || exit 1 - mv $tmpdir/${HDF5_VERS}_docs.tar $DEST || exit 1 - ;; - *) - echo "***Error*** Unknown method $comp" - exit 1 - ;; + mv $tmpdir/${DOCVERSION} $tmpdir/${HDF5_VERS}_docs || exit 1 + (cd $tmpdir && tar cf ${HDF5_VERS}_docs.tar ${HDF5_VERS}_docs) || exit 1 + mv $tmpdir/${HDF5_VERS}_docs.tar $DEST || exit 1 + ;; + *) + echo "***Error*** Unknown method $comp" + exit 1 + ;; esac done diff --git a/bin/trace b/bin/trace index 350e715..fd0248e 100755 --- a/bin/trace +++ b/bin/trace @@ -43,6 +43,7 @@ $Source = ""; "H5D_space_status_t" => "Ds", "H5D_vds_view_t" => "Dv", "H5FD_mpio_xfer_t" => "Dt", + "H5FD_splitter_vfd_config_t" => "Dr", "herr_t" => "e", "H5E_direction_t" => "Ed", "H5E_error_t" => "Ee", @@ -159,6 +160,7 @@ $Source = ""; "H5FD_ros3_fapl_t" => "x", "H5FD_hdfs_fapl_t" => "x", "H5FD_file_image_callbacks_t" => "x", + "H5FD_mirror_fapl_t" => "x", "H5G_iterate_t" => "x", "H5G_info_t" => "x", "H5I_free_t" => "x", @@ -240,7 +242,11 @@ sub argstring ($$$) { # certain type qualifiers, and indirection. $atype =~ s/^\bconst\b//; $atype =~ s/\bH5_ATTR_UNUSED\b//g; + $atype =~ s/\bH5_ATTR_DEPRECATED_USED\b//g; $atype =~ s/\bH5_ATTR_NDEBUG_UNUSED\b//g; + $atype =~ s/\bH5_ATTR_DEBUG_API_USED\b//g; + $atype =~ s/\bH5_ATTR_PARALLEL_UNUSED\b//g; + $atype =~ s/\bH5_ATTR_PARALLEL_USED\b//g; $atype =~ s/\s+/ /g; $ptr = length $1 if $atype =~ s/(\*+)//; $atype =~ s/^\s+//; diff --git a/c++/examples/Makefile.am b/c++/examples/Makefile.am index 0648504..cbec8f8 100644 --- a/c++/examples/Makefile.am +++ b/c++/examples/Makefile.am @@ -49,8 +49,8 @@ CXX_API=yes # Where to install examples # Note: no '/' after DESTDIR. Explanation in commence.am -EXAMPLEDIR=$(examplesdir)/c++ -EXAMPLETOPDIR=$(examplesdir) +EXAMPLEDIR=${DESTDIR}$(examplesdir)/c++ +EXAMPLETOPDIR=${DESTDIR}$(examplesdir) # How to build programs using h5c++ $(EXTRA_PROG): $(H5CPP) diff --git a/config/cmake/CTestCustom.cmake b/config/cmake/CTestCustom.cmake index b156bca..725e382 100644 --- a/config/cmake/CTestCustom.cmake +++ b/config/cmake/CTestCustom.cmake @@ -27,7 +27,7 @@ set (CTEST_CUSTOM_WARNING_EXCEPTION "config.cmake.xlatefile.c" "warning.*unknown pragma" "warning.*unrecognized .pragma" - "note: expanded from macro" +# "note: expanded from macro" # HDDFFV-11074 "This directive is not standard" ) diff --git a/config/cmake/ConfigureChecks.cmake b/config/cmake/ConfigureChecks.cmake index 11bf39c..2930969 100644 --- a/config/cmake/ConfigureChecks.cmake +++ b/config/cmake/ConfigureChecks.cmake @@ -171,6 +171,23 @@ option (HDF5_ENABLE_ROS3_VFD "Build the ROS3 Virtual File Driver" OFF) endif () endif () +# ---------------------------------------------------------------------- +# Check whether we can build the Mirror VFD +# Header-check flags set in config/cmake_ext_mod/ConfigureChecks.cmake +# ---------------------------------------------------------------------- +option (HDF5_ENABLE_MIRROR_VFD "Build the Mirror Virtual File Driver" OFF) +if (H5FD_ENABLE_MIRROR_VFD) + if ( ${HDF_PREFIX}_HAVE_NETINET_IN_H AND + ${HDF_PREFIX}_HAVE_NETDB_H AND + ${HDF_PREFIX}_HAVE_ARPA_INET_H AND + ${HDF_PREFIX}_HAVE_SYS_SOCKET_H AND + ${HDF_PREFIX}_HAVE_FORK) + set (${HDF_PREFIX}_HAVE_MIRROR_VFD 1) + else() + message(STATUS "The socket-based Mirror VFD was requested but cannot be built. System prerequisites are not met.") + endif() +endif() + #----------------------------------------------------------------------------- # Check if C has __float128 extension #----------------------------------------------------------------------------- diff --git a/config/cmake/H5pubconf.h.in b/config/cmake/H5pubconf.h.in index 120c023..934c9cb 100644 --- a/config/cmake/H5pubconf.h.in +++ b/config/cmake/H5pubconf.h.in @@ -104,6 +104,9 @@ /* Define if the compiler understands the __func__ keyword */ #cmakedefine H5_HAVE_C99_FUNC @H5_HAVE_C99_FUNC@ +/* Define to 1 if you have the header file. */ +#cmakedefine H5_HAVE_ARPA_INET_H @H5_HAVE_ARPA_INET_H@ + /* Define to 1 if you have the `clock_gettime' function. */ #cmakedefine H5_HAVE_CLOCK_GETTIME @H5_HAVE_CLOCK_GETTIME@ @@ -264,15 +267,15 @@ /* Define to 1 if you have the `lstat' function. */ #cmakedefine H5_HAVE_LSTAT @H5_HAVE_LSTAT@ -/* Define to 1 if you have the header file. */ -#cmakedefine H5_HAVE_MACH_MACH_TIME_H @H5_HAVE_MACH_MACH_TIME_H@ - /* Define if the map API (H5M) should be compiled */ #cmakedefine H5_HAVE_MAP_API @H5_HAVE_MAP_API@ /* Define to 1 if you have the header file. */ #cmakedefine H5_HAVE_MEMORY_H @H5_HAVE_MEMORY_H@ +/* Define if we can build the Mirror VFD */ +#cmakedefine H5_HAVE_MIRROR_VFD @H5_HAVE_MIRROR_VFD@ + /* Define if we have MPE support */ #cmakedefine H5_HAVE_MPE @H5_HAVE_MPE@ @@ -285,6 +288,12 @@ /* Define if MPI_Info_c2f and MPI_Info_f2c exists */ #cmakedefine H5_HAVE_MPI_MULTI_LANG_Info @H5_HAVE_MPI_MULTI_LANG_Info@ +/* Define to 1 if you have the header file. */ +#cmakedefine H5_HAVE_NETDB_H @H5_HAVE_NETDB_H@ + +/* Define to 1 if you have the header file. */ +#cmakedefine H5_HAVE_NETINET_IN_H @H5_HAVE_NETINET_IN_H@ + /* Define to 1 if you have the header file. */ #cmakedefine H5_HAVE_OPENSSL_EVP_H @H5_HAVE_OPENSSL_EVP_H@ diff --git a/config/cmake/HDF5UseFortran.cmake b/config/cmake/HDF5UseFortran.cmake index c5d8200..4350b7a 100644 --- a/config/cmake/HDF5UseFortran.cmake +++ b/config/cmake/HDF5UseFortran.cmake @@ -435,7 +435,7 @@ set (${HDF_PREFIX}_H5CONFIG_F_RKIND_SIZEOF "INTEGER, DIMENSION(1:num_rkinds) :: ENABLE_LANGUAGE (C) if (NOT CMAKE_VERSION VERSION_LESS "3.14.0") -include (CheckCSourceRuns) + include (CheckCSourceRuns) else () #----------------------------------------------------------------------------- # The provided CMake C macros don't provide a general compile/run function diff --git a/config/cmake/libhdf5.settings.cmake.in b/config/cmake/libhdf5.settings.cmake.in index e9a8395..b745765 100644 --- a/config/cmake/libhdf5.settings.cmake.in +++ b/config/cmake/libhdf5.settings.cmake.in @@ -76,6 +76,7 @@ Parallel Filtered Dataset Writes: @PARALLEL_FILTERED_WRITES@ I/O filters (external): @EXTERNAL_FILTERS@ MPE: @H5_HAVE_LIBLMPE@ Direct VFD: @H5_HAVE_DIRECT@ + Mirror VFD: @H5_HAVE_MIRROR_VFD@ (Read-Only) S3 VFD: @H5_HAVE_ROS3_VFD@ (Read-Only) HDFS VFD: @H5_HAVE_LIBHDFS@ dmalloc: @H5_HAVE_LIBDMALLOC@ diff --git a/config/cmake_ext_mod/ConfigureChecks.cmake b/config/cmake_ext_mod/ConfigureChecks.cmake index 93b977e..0ddb6d0 100644 --- a/config/cmake_ext_mod/ConfigureChecks.cmake +++ b/config/cmake_ext_mod/ConfigureChecks.cmake @@ -137,15 +137,11 @@ CHECK_INCLUDE_FILE_CONCAT ("stddef.h" ${HDF_PREFIX}_HAVE_STDDEF_H) CHECK_INCLUDE_FILE_CONCAT ("stdint.h" ${HDF_PREFIX}_HAVE_STDINT_H) CHECK_INCLUDE_FILE_CONCAT ("unistd.h" ${HDF_PREFIX}_HAVE_UNISTD_H) -# Darwin -CHECK_INCLUDE_FILE_CONCAT ("mach/mach_time.h" ${HDF_PREFIX}_HAVE_MACH_MACH_TIME_H) - # Windows CHECK_INCLUDE_FILE_CONCAT ("io.h" ${HDF_PREFIX}_HAVE_IO_H) if (NOT CYGWIN) CHECK_INCLUDE_FILE_CONCAT ("winsock2.h" ${HDF_PREFIX}_HAVE_WINSOCK2_H) endif () -CHECK_INCLUDE_FILE_CONCAT ("sys/timeb.h" ${HDF_PREFIX}_HAVE_SYS_TIMEB_H) if (CMAKE_SYSTEM_NAME MATCHES "OSF") CHECK_INCLUDE_FILE_CONCAT ("sys/sysinfo.h" ${HDF_PREFIX}_HAVE_SYS_SYSINFO_H) @@ -166,6 +162,8 @@ CHECK_INCLUDE_FILE_CONCAT ("memory.h" ${HDF_PREFIX}_HAVE_MEMORY_H) CHECK_INCLUDE_FILE_CONCAT ("dlfcn.h" ${HDF_PREFIX}_HAVE_DLFCN_H) CHECK_INCLUDE_FILE_CONCAT ("inttypes.h" ${HDF_PREFIX}_HAVE_INTTYPES_H) CHECK_INCLUDE_FILE_CONCAT ("netinet/in.h" ${HDF_PREFIX}_HAVE_NETINET_IN_H) +CHECK_INCLUDE_FILE_CONCAT ("netdb.h" ${HDF_PREFIX}_HAVE_NETDB_H) +CHECK_INCLUDE_FILE_CONCAT ("arpa/inet.h" ${HDF_PREFIX}_HAVE_ARPA_INET_H) # _Bool type support CHECK_INCLUDE_FILE_CONCAT (stdbool.h ${HDF_PREFIX}_HAVE_STDBOOL_H) diff --git a/config/solaris b/config/solaris index 656fee1..a424503 100644 --- a/config/solaris +++ b/config/solaris @@ -29,7 +29,9 @@ fi # Try solaris native compiler flags if test "X-" = "X-$cc_flags_set"; then - H5_CFLAGS="$H5_CFLAGS -erroff=%none -DBSD_COMP" + # HDF5 must be built with a C99 compiler on Solaris + # -erroff=%none turns on all warnings + H5_CFLAGS="$H5_CFLAGS -xc99=all -erroff=%none" # Production # NDEBUG is handled explicitly by the configure script @@ -41,17 +43,26 @@ if test "X-" = "X-$cc_flags_set"; then DEBUG_CFLAGS= # Symbols + # -g produces output for dbx, NOT gdb. You can use "gdb on" from + # inside gdb to use gdb commands if you need to debug. + # If you want a LOT of debugging information (at the expense of + # really slow code), try using -g3. That will even let you debug + # into macros. + # -s strips symbols, as in gcc NO_SYMBOLS_CFLAGS="-s" SYMBOLS_CFLAGS="-g" # Profile + # This produces profiling output for gprof. If you want to use + # the Solaris profiler, use -xprofile instead. PROFILE_CFLAGS="-xpg" # Optimization - # -g produces rather slow code. "-g -O" produces much faster code with some - # loss of debugger functions such as not able to print local variables. - HIGH_OPT_CFLAGS="-O" - DEBUG_OPT_CFLAGS="-O" + # -O has switched to -xO{1|2|3|4|5}. -xO3 is probably a good compromise + # for the daily tests, but you might want to switch to -xO2 or lower + # if you are actively debugging. + HIGH_OPT_CFLAGS="-xO5" + DEBUG_OPT_CFLAGS="-xO3" NO_OPT_CFLAGS= cc_flags_set=yes diff --git a/configure.ac b/configure.ac index d7089b8..d982e94 100644 --- a/configure.ac +++ b/configure.ac @@ -2903,6 +2903,50 @@ fi AM_CONDITIONAL([DIRECT_VFD_CONDITIONAL], [test "X$DIRECT_VFD" = "Xyes"]) ## ---------------------------------------------------------------------- +## Check whether the Mirror VFD can be built. +## Auto-enabled if the required libraries are present. +## +AC_SUBST([MIRROR_VFD]) + +## Default is no Mirror VFD +MIRROR_VFD=no + +AC_ARG_ENABLE([mirror-vfd], + [AS_HELP_STRING([--enable-mirror-vfd], + [Build the socket-based Mirror virtual file driver (VFD). + [default=no]])], + [MIRROR_VFD=$enableval], [MIRROR_VFD=no]) + +if test "X$MIRROR_VFD" = "Xyes"; then + + AC_CHECK_HEADERS([arpa/inet.h],, [unset MIRROR_VFD]) + AC_CHECK_HEADERS([netinet/in.h],, [unset MIRROR_VFD]) + AC_CHECK_HEADERS([netdb.h],, [unset MIRROR_VFD]) + AC_CHECK_HEADERS([sys/socket.h],, [unset MIRROR_VFD]) + AC_CHECK_FUNC([fork], [], [unset MIRROR_VFD]) + + AC_MSG_CHECKING([if the Mirror virtual file driver (VFD) can be built]) + if test "X$MIRROR_VFD" = "Xyes"; then + AC_DEFINE([HAVE_MIRROR_VFD], [1], + [Define whether the Mirror virtual file driver (VFD) will be compiled]) + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + MIRROR_VFD=no + AC_MSG_ERROR([The Mirror VFD cannot be built. + Missing one or more of: arpa/inet.h, netinet/in.h, + netdb.h, sys/socket.h, fork().]) + fi +else + AC_MSG_CHECKING([if the Mirror virtual file driver (VFD) is enabled]) + AC_MSG_RESULT([no]) + MIRROR_VFD=no +fi + +## Mirror VFD files built only if able. +AM_CONDITIONAL([MIRROR_VFD_CONDITIONAL], [test "X$MIRROR_VFD" = "Xyes"]) + +## ---------------------------------------------------------------------- ## Check if Read-Only S3 virtual file driver is enabled by --enable-ros3-vfd ## AC_SUBST([ROS3_VFD]) @@ -3776,10 +3820,13 @@ AC_CONFIG_FILES([src/libhdf5.settings test/testvds_env.sh test/testvdsswmr.sh test/test_filter_plugin.sh + test/test_mirror.sh test/test_usecases.sh test/test_vol_plugin.sh testpar/Makefile testpar/testpflush.sh + utils/Makefile + utils/mirror_vfd/Makefile tools/Makefile tools/lib/Makefile tools/libtest/Makefile diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 1bcbbf2..527b11f 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -31,6 +31,7 @@ set (examples h5_extlink h5_elink_unix2win h5_shared_mesg + h5_debug_trace h5_vds h5_vds-exc h5_vds-exclim diff --git a/examples/Makefile.am b/examples/Makefile.am index b7850a7..944a9d8 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -34,25 +34,25 @@ INSTALL_TOP_FILES = README EXAMPLE_PROG = h5_write h5_read h5_extend_write h5_chunk_read h5_compound \ h5_crtgrpd h5_subset h5_cmprss h5_rdwt h5_crtgrpar h5_extend \ h5_crtatt h5_crtgrp h5_crtdat \ - h5_group h5_select h5_attribute h5_mount h5_reference_deprec h5_drivers \ - h5_ref_extern h5_ref_compat \ - h5_ref2reg_deprec h5_extlink h5_elink_unix2win h5_shared_mesg h5_vds h5_vds-exc \ - h5_vds-exclim h5_vds-eiger h5_vds-simpleIO h5_vds-percival \ - h5_vds-percival-unlim h5_vds-percival-unlim-maxmin + h5_group h5_select h5_attribute h5_mount h5_drivers \ + h5_reference_deprec h5_ref_extern h5_ref_compat h5_ref2reg_deprec \ + h5_extlink h5_elink_unix2win h5_shared_mesg h5_debug_trace \ + h5_vds h5_vds-exc h5_vds-exclim h5_vds-eiger h5_vds-simpleIO \ + h5_vds-percival h5_vds-percival-unlim h5_vds-percival-unlim-maxmin TEST_SCRIPT=testh5cc.sh TEST_EXAMPLES_SCRIPT=$(INSTALL_SCRIPT_FILES) # Install files # List all file that should be installed in examples directory -INSTALL_FILES = h5_write.c h5_read.c h5_extend_write.c h5_chunk_read.c \ - h5_crtgrpd.c h5_subset.c h5_cmprss.c h5_rdwt.c h5_crtgrpar.c \ - h5_extend.c h5_crtatt.c h5_crtgrp.c h5_crtdat.c \ - h5_compound.c h5_group.c h5_select.c h5_attribute.c h5_mount.c \ - h5_reference_deprec.c h5_drivers.c h5_extlink.c h5_elink_unix2win.c \ - h5_ref_extern.c h5_ref_compat.c \ - h5_ref2reg_deprec.c h5_shared_mesg.c ph5example.c h5_vds.c h5_vds-exc.c \ - h5_vds-exclim.c h5_vds-eiger.c h5_vds-simpleIO.c h5_vds-percival.c \ - h5_vds-percival-unlim.c h5_vds-percival-unlim-maxmin.c +INSTALL_FILES = h5_write.c h5_read.c h5_extend_write.c h5_chunk_read.c h5_compound.c \ + h5_crtgrpd.c h5_subset.c h5_cmprss.c h5_rdwt.c h5_crtgrpar.c h5_extend.c \ + h5_crtatt.c h5_crtgrp.c h5_crtdat.c \ + h5_group.c h5_select.c h5_attribute.c h5_mount.c h5_drivers.c \ + h5_reference_deprec.c h5_ref_extern.c h5_ref_compat.c h5_ref2reg_deprec.c \ + h5_extlink.c h5_elink_unix2win.c h5_shared_mesg.c h5_debug_trace.c \ + ph5example.c \ + h5_vds.c h5_vds-exc.c h5_vds-exclim.c h5_vds-eiger.c h5_vds-simpleIO.c \ + h5_vds-percival.c h5_vds-percival-unlim.c h5_vds-percival-unlim-maxmin.c @@ -86,8 +86,8 @@ CHECK_CLEANFILES+=$(EXTLINK_DIRS) # Example directory # Note: no '/' after DESTDIR. Explanation in commence.am -EXAMPLEDIR=$(examplesdir)/c -EXAMPLETOPDIR=$(examplesdir) +EXAMPLEDIR=${DESTDIR}$(examplesdir)/c +EXAMPLETOPDIR=${DESTDIR}$(examplesdir) # List dependencies for each program. Normally, automake would take # care of this for us, but if we tell automake about the programs it diff --git a/examples/h5_crtgrp.c b/examples/h5_crtgrp.c index 89bddce..1b110c2 100644 --- a/examples/h5_crtgrp.c +++ b/examples/h5_crtgrp.c @@ -12,7 +12,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * This example illustrates how to create and close a group. + * This example illustrates how to create and close a group. * It is used in the HDF5 Tutorial. */ diff --git a/examples/h5_debug_trace.c b/examples/h5_debug_trace.c new file mode 100644 index 0000000..5da55ed --- /dev/null +++ b/examples/h5_debug_trace.c @@ -0,0 +1,144 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* This example demonstrates debug trace output. + * + * Debug/trace/performance output is not tested as a regular part of our + * testing so this program gives a quick check that it's all working. + * + * Preconditions: + * + * You need to set an environment variable named HDF5_DEBUG to have a value + * of "+all trace ttimes". In the bash shell, you'd use: + * + * export HDF5_DEBUG="+all trace ttimes" + * + * When you are done with this test program, you can set the variable back + * to "-all" to suppress trace output. + * + * Usage: + * + * Compile and run the test program, then inspect the output. You should see + * trace information for each HDF5 function call that increase over time. + * Each time stamp is in seconds and designated with an '@' sign. The + * elapsed time for the function call is given in seconds in the [dt= ] + * part. + * + * You will also get summary output for the shuffle filter performance and + * data type conversion performance. These will include the elapsed time + * (always) and the system and user times (if available on your system). On + * fast machines, these numbers may be 0.0. Adjust the loop variables in + * the program as needed to generate reasonable output. + */ + +#include +#include + +#include "hdf5.h" + +#define BUF_SIZE 1048576 +#define N_LOOPS 64 + +#define TESTFILE "h5_debug_trace_out.h5" + +int +main(int argc, char **argv) +{ + int i, j; + int *data; + + hid_t fid; + hid_t pid; + hid_t did; + hid_t sid; + + hsize_t dims[1] = { BUF_SIZE }; + hsize_t chunk_sizes[1] = { 1024 }; + + herr_t err; + + /*************************************************************************/ + + /* Warn the user about trace deluge to come */ + + printf("Testing debug/trace/performance data generation\n"); + printf("\n"); + printf("This test should generate a large amount of trace data\n"); + printf("\n"); + printf("*** BEGIN TRACE OUTPUT ***\n"); + printf("\n"); + fflush(stdout); + + /* This will emit H5Tconvert() performance information */ + + for(i = 0; i < N_LOOPS; i++) { + + /* The buffer has to be large enough to hold the conversion output */ + data = (int *)malloc(BUF_SIZE * sizeof(double)); + + for(j = 0; j < BUF_SIZE; j++) { + data[j] = j; + } + + err = H5Tconvert(H5T_NATIVE_INT, H5T_NATIVE_DOUBLE, BUF_SIZE, data, + NULL, H5P_DEFAULT); + + if(err < 0) { + fprintf(stderr, "ERROR: Conversion failed\n"); + free(data); + return err; + } + + free(data); + + } + + + /* This will emit H5Z performance information */ + + data = (int *)malloc(BUF_SIZE * sizeof(int)); + + for(i = 0; i < BUF_SIZE; i++) { + data[i] = i; + } + + fid = H5Fcreate(TESTFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + + pid = H5Pcreate(H5P_DATASET_CREATE); + err = H5Pset_chunk(pid, 1, chunk_sizes); + err = H5Pset_shuffle(pid); + + sid = H5Screate_simple(1, dims, dims); + did = H5Dcreate2(fid, "somedata", H5T_NATIVE_INT, sid, H5P_DEFAULT, pid, H5P_DEFAULT); + err = H5Dwrite(did, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data); + + H5Sclose(sid); + H5Dclose(did); + H5Pclose(pid); + H5Fclose(fid); + + free(data); + + /* Finished */ + fflush(stdout); + printf("\n"); + printf("*** END TRACE OUTPUT ***\n"); + printf("\n"); + + remove(TESTFILE); + + return 0; +} + diff --git a/examples/run-c-ex.sh.in b/examples/run-c-ex.sh.in index b649d98..a037f6c 100644 --- a/examples/run-c-ex.sh.in +++ b/examples/run-c-ex.sh.in @@ -149,6 +149,11 @@ then rm h5_extlink &&\ RunTest h5_elink_unix2win &&\ rm h5_elink_unix2win &&\ + OLD_DEBUG_STRING=$HDF5_DEBUG &&\ + export HDF5_DEBUG="+all +trace +ttimes" &&\ + RunTest h5_debug_trace &&\ + HDF5_DEBUG=$OLD_DEBUG_STRING &&\ + rm h5_debug_trace &&\ RunTest h5_shared_mesg &&\ rm h5_shared_mesg &&\ RunTest h5_vds-eiger &&\ diff --git a/fortran/examples/Makefile.am b/fortran/examples/Makefile.am index fb510bc..474126d 100644 --- a/fortran/examples/Makefile.am +++ b/fortran/examples/Makefile.am @@ -74,8 +74,8 @@ endif # Tell automake how to install examples # Note: no '/' after DESTDIR. Explanation in commence.am -EXAMPLEDIR=$(examplesdir)/fortran -EXAMPLETOPDIR=$(examplesdir) +EXAMPLEDIR=${DESTDIR}$(examplesdir)/fortran +EXAMPLETOPDIR=${DESTDIR}$(examplesdir) # List dependencies for each example. Normally, automake would take # care of this for us, but if we tell automake about the programs it diff --git a/fortran/src/H5Aff.F90 b/fortran/src/H5Aff.F90 index a728f2d..f514c37 100644 --- a/fortran/src/H5Aff.F90 +++ b/fortran/src/H5Aff.F90 @@ -72,7 +72,7 @@ MODULE H5A - USE, INTRINSIC :: ISO_C_BINDING + USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR, C_CHAR, C_NULL_CHAR, C_LOC, C_INT USE H5GLOBAL @@ -344,7 +344,7 @@ CONTAINS INTEGER(HID_T), INTENT(IN), VALUE :: attr_id END FUNCTION H5Aget_space END INTERFACE - + space_id = H5Aget_space(attr_id) hdferr = 0 @@ -389,7 +389,7 @@ CONTAINS INTEGER(HID_T), INTENT(IN), VALUE :: attr_id END FUNCTION H5Aget_type END INTERFACE - + type_id = H5Aget_type(attr_id) hdferr = 0 @@ -508,7 +508,7 @@ CONTAINS ! Returns attribute name size, ! -1 if fail INTEGER(HID_T), OPTIONAL, INTENT(IN) :: lapl_id ! Link access property list - INTEGER(SIZE_T), OPTIONAL, INTENT(OUT) :: size ! Indicates the size, in the number of characters, + INTEGER(SIZE_T), OPTIONAL, INTENT(OUT) :: size ! Indicates the size, in the number of characters, ! of the attribute !***** INTEGER(HID_T) :: lapl_id_default @@ -1766,7 +1766,7 @@ CONTAINS ! up to 7 dimensions. ! ! Fortran2003 Interface: -!! SUBROUTINE H5Awrite_f(attr_id, memtype_id, buf, hdferr) +!! SUBROUTINE H5Awrite_f(attr_id, memtype_id, buf, hdferr) !! INTEGER(HID_T) , INTENT(IN) :: attr_id !! INTEGER(HID_T) , INTENT(IN) :: memtype_id !! TYPE(C_PTR) , INTENT(IN) :: buf @@ -1851,7 +1851,7 @@ CONTAINS ! REAL, REAL(KIND=C_DOUBLE) and CHARACTER buffers ! up to 7 dimensions. ! Fortran2003 Interface: -!! SUBROUTINE H5Aread_f(attr_id, memtype_id, buf, hdferr) +!! SUBROUTINE H5Aread_f(attr_id, memtype_id, buf, hdferr) !! INTEGER(HID_T) , INTENT(IN) :: attr_id !! INTEGER(HID_T) , INTENT(IN) :: memtype_id !! TYPE(C_PTR) , INTENT(INOUT) :: buf diff --git a/fortran/src/H5Dff.F90 b/fortran/src/H5Dff.F90 index 77f0a15..7128698 100644 --- a/fortran/src/H5Dff.F90 +++ b/fortran/src/H5Dff.F90 @@ -86,8 +86,8 @@ #include MODULE H5D - - USE, INTRINSIC :: ISO_C_BINDING + + USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR, C_CHAR USE H5GLOBAL PRIVATE h5dread_vl_integer, h5dread_vl_real, h5dread_vl_string @@ -959,7 +959,7 @@ CONTAINS SUBROUTINE h5dwrite_vl_string(dset_id, mem_type_id, buf, dims, str_len, & hdferr, & mem_space_id, file_space_id, xfer_prp) - USE, INTRINSIC :: ISO_C_BINDING, ONLY : c_char + USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_CHAR IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: dset_id ! Dataset identifier INTEGER(HID_T), INTENT(IN) :: mem_type_id ! Memory datatype identifier @@ -1088,7 +1088,7 @@ CONTAINS SUBROUTINE h5dget_offset_f(dset_id, offset, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: dset_id - INTEGER(HADDR_T), INTENT(OUT) :: offset + INTEGER(HADDR_T), INTENT(OUT) :: offset INTEGER, INTENT(OUT) :: hdferr !***** INTERFACE @@ -1100,7 +1100,7 @@ CONTAINS END INTERFACE offset = h5dget_offset(dset_id) - + hdferr = 0 ! never returns a function error because C API never returns a function error. END SUBROUTINE h5dget_offset_f @@ -1164,7 +1164,7 @@ CONTAINS ! plist_id - Dataset access property list identifier ! hdferr - Returns 0 if successful and -1 if fails ! -! AUTHOR +! AUTHOR ! M. Scot Breitenfeld ! April 13, 2009 ! @@ -1172,8 +1172,8 @@ CONTAINS SUBROUTINE h5dget_access_plist_f(dset_id, plist_id, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: dset_id - INTEGER(HID_T), INTENT(OUT) :: plist_id - INTEGER , INTENT(OUT) :: hdferr + INTEGER(HID_T), INTENT(OUT) :: plist_id + INTEGER , INTENT(OUT) :: hdferr !***** INTERFACE INTEGER FUNCTION h5dget_access_plist_c(dset_id, plist_id) BIND(C,NAME='h5dget_access_plist_c') @@ -1183,15 +1183,15 @@ CONTAINS INTEGER(HID_T), INTENT(OUT) :: plist_id END FUNCTION h5dget_access_plist_c END INTERFACE - + hdferr = h5dget_access_plist_c(dset_id, plist_id) - + END SUBROUTINE h5dget_access_plist_f SUBROUTINE h5dwrite_reference_obj(dset_id, mem_type_id, buf, dims, hdferr, & mem_space_id, file_space_id, xfer_prp) - USE, INTRINSIC :: ISO_C_BINDING + USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: dset_id ! Dataset identifier INTEGER(HID_T), INTENT(IN) :: mem_type_id ! Memory datatype identifier @@ -1223,7 +1223,7 @@ CONTAINS SUBROUTINE h5dwrite_reference_dsetreg(dset_id, mem_type_id, buf, dims, hdferr, & mem_space_id, file_space_id, xfer_prp) - USE, INTRINSIC :: ISO_C_BINDING + USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: dset_id ! Dataset identifier INTEGER(HID_T), INTENT(IN) :: mem_type_id ! Memory datatype identifier @@ -1285,7 +1285,7 @@ CONTAINS SUBROUTINE h5dwrite_char_scalar(dset_id, mem_type_id, buf, dims, hdferr, & mem_space_id, file_space_id, xfer_prp) - USE, INTRINSIC :: ISO_C_BINDING + USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: dset_id ! Dataset identifier INTEGER(HID_T), INTENT(IN) :: mem_type_id ! Memory datatype identifier @@ -1295,7 +1295,7 @@ CONTAINS INTEGER(HID_T), OPTIONAL, INTENT(IN) :: mem_space_id ! Memory dataspace identfier INTEGER(HID_T), OPTIONAL, INTENT(IN) :: file_space_id ! File dataspace identfier INTEGER(HID_T), OPTIONAL, INTENT(IN) :: xfer_prp ! Transfer property list identifier - + CALL h5dwrite_char_scalar_fix(dset_id, mem_type_id, buf, LEN(buf), dims, hdferr, & mem_space_id, file_space_id, xfer_prp) @@ -1303,7 +1303,7 @@ CONTAINS SUBROUTINE h5dwrite_char_scalar_fix(dset_id, mem_type_id, buf, buf_len, dims, hdferr, & mem_space_id, file_space_id, xfer_prp) - USE, INTRINSIC :: ISO_C_BINDING + USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: dset_id ! Dataset identifier INTEGER(HID_T), INTENT(IN) :: mem_type_id ! Memory datatype identifier @@ -1336,7 +1336,7 @@ CONTAINS SUBROUTINE h5dread_reference_obj(dset_id, mem_type_id, buf, dims, hdferr, & mem_space_id, file_space_id, xfer_prp) - USE, INTRINSIC :: ISO_C_BINDING + USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: dset_id ! Dataset identifier INTEGER(HID_T), INTENT(IN) :: mem_type_id ! Memory datatype identifier @@ -1431,7 +1431,7 @@ CONTAINS SUBROUTINE h5dread_char_scalar(dset_id, mem_type_id, buf, dims, hdferr, & mem_space_id, file_space_id, xfer_prp) - USE, INTRINSIC :: ISO_C_BINDING + USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: dset_id ! Dataset identifier INTEGER(HID_T), INTENT(IN) :: mem_type_id ! Memory datatype identifier @@ -1461,7 +1461,7 @@ CONTAINS SUBROUTINE h5dread_char_scalar_fix(dset_id, mem_type_id, buf, buf_len, hdferr, & mem_space_id, file_space_id, xfer_prp) - USE, INTRINSIC :: ISO_C_BINDING + USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: dset_id ! Dataset identifier INTEGER(HID_T), INTENT(IN) :: mem_type_id ! Memory datatype identifier @@ -1483,17 +1483,17 @@ CONTAINS !****s* H5D (F03)/h5dwrite_f_F03 ! -! NAME +! NAME ! h5dwrite_f_F03 ! ! PURPOSE -! Writes raw data from a dataset into a buffer. +! Writes raw data from a dataset into a buffer. ! ! Inputs: ! dset_id - Identifier of the dataset to write to. ! mem_type_id - Identifier of the memory datatype. ! buf - Buffer with data to be written to the file. -! +! ! Outputs: ! hdferr - Returns 0 if successful and -1 if fails ! @@ -1519,7 +1519,7 @@ CONTAINS !***** SUBROUTINE h5dwrite_ptr(dset_id, mem_type_id, buf, hdferr, & mem_space_id, file_space_id, xfer_prp) - USE, INTRINSIC :: ISO_C_BINDING + USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: dset_id ! Dataset identifier INTEGER(HID_T), INTENT(IN) :: mem_type_id ! Memory datatype identifier @@ -1548,16 +1548,16 @@ CONTAINS !****s* H5D (F03)/h5dread_f_F03 ! -! NAME +! NAME ! h5dread_f_F03 ! ! PURPOSE -! Reads raw data from a dataset into a buffer. +! Reads raw data from a dataset into a buffer. ! ! Inputs: ! dset_id - Identifier of the dataset read from. ! mem_type_id - Identifier of the memory datatype. -! +! ! Outputs: ! buf - Buffer to receive data read from file. ! hdferr - Returns 0 if successful and -1 if fails @@ -1584,7 +1584,7 @@ CONTAINS !***** SUBROUTINE h5dread_ptr(dset_id, mem_type_id, buf, hdferr, & mem_space_id, file_space_id, xfer_prp) - USE, INTRINSIC :: ISO_C_BINDING + USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: dset_id ! Dataset identifier INTEGER(HID_T), INTENT(IN) :: mem_type_id ! Memory datatype identifier @@ -1612,10 +1612,10 @@ CONTAINS END SUBROUTINE h5dread_ptr ! -! NAME +! NAME ! h5dfill_integer ! -! PURPOSE +! PURPOSE ! Fills dataspace elements with a fill value in a memory buffer. ! Only INTEGER, CHARACTER, REAL and DOUBLE PRECISION datatypes ! of the fillvalues and buffers are supported. Buffer and fillvalue @@ -1638,7 +1638,7 @@ CONTAINS ! SUBROUTINE h5dfill_integer(fill_value, space_id, buf, hdferr) - USE, INTRINSIC :: ISO_C_BINDING + USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR IMPLICIT NONE INTEGER, INTENT(IN), TARGET :: fill_value ! Fill value INTEGER(HID_T), INTENT(IN) :: space_id ! Memory dataspace selection identifier @@ -1688,7 +1688,7 @@ CONTAINS ! March 12, 2003 ! SUBROUTINE h5dfill_c_float(fill_valuer, space_id, buf, hdferr) - USE, INTRINSIC :: ISO_C_BINDING + USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR IMPLICIT NONE REAL(KIND=C_FLOAT), INTENT(IN), TARGET :: fill_valuer ! Fill value INTEGER(HID_T), INTENT(IN) :: space_id ! Memory dataspace selection identifier @@ -1786,10 +1786,10 @@ CONTAINS END SUBROUTINE h5dfill_c_long_double #endif ! -! NAME +! NAME ! h5dfill_char ! -! PURPOSE +! PURPOSE ! Fills dataspace elements with a fill value in a memory buffer. ! Only INTEGER, CHARACTER, REAL and DOUBLE PRECISION datatypes ! of the fillvalues and buffers are supported. Buffer and fillvalue @@ -1810,7 +1810,7 @@ CONTAINS ! March 12, 2003 ! SUBROUTINE h5dfill_char(fill_value, space_id, buf, hdferr) - USE, INTRINSIC :: ISO_C_BINDING + USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR IMPLICIT NONE CHARACTER, INTENT(IN), TARGET :: fill_value ! Fill value INTEGER(HID_T), INTENT(IN) :: space_id ! Memory dataspace selection identifier @@ -1835,15 +1835,15 @@ CONTAINS ! NAME ! h5dvlen_reclaim_f ! -! PURPOSE -! Reclaims VL datatype memory buffers. +! PURPOSE +! Reclaims VL datatype memory buffers. ! ! Inputs: ! -! type_id - Identifier of the datatype. -! space_id - Identifier of the dataspace. -! plist_id - Identifier of the property list used to create the buffer. -! buf - Pointer to the buffer to be reclaimed. +! type_id - Identifier of the datatype. +! space_id - Identifier of the dataspace. +! plist_id - Identifier of the property list used to create the buffer. +! buf - Pointer to the buffer to be reclaimed. ! ! Outputs: ! hdferr - Returns 0 if successful and -1 if fails diff --git a/fortran/src/H5Eff.F90 b/fortran/src/H5Eff.F90 index fcd08ff..1e94c7a 100644 --- a/fortran/src/H5Eff.F90 +++ b/fortran/src/H5Eff.F90 @@ -254,7 +254,7 @@ CONTAINS ! estack_id - Error stack identifier. ! func - Function to be called upon an error condition. ! client_data - Data passed to the error function -! +! ! Outputs: ! hdferr - Returns 0 if successful and -1 if fails ! @@ -264,7 +264,7 @@ CONTAINS ! ! Fortran2003 Interface: SUBROUTINE h5eset_auto_f(printflag, hdferr, estack_id, func, client_data) - USE, INTRINSIC :: ISO_C_BINDING + USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR, C_FUNPTR INTEGER , INTENT(IN) :: printflag INTEGER , INTENT(OUT) :: hdferr INTEGER(HID_T), INTENT(IN) , OPTIONAL :: estack_id diff --git a/fortran/src/H5Fff.F90 b/fortran/src/H5Fff.F90 index 62e8de8..d74400c 100644 --- a/fortran/src/H5Fff.F90 +++ b/fortran/src/H5Fff.F90 @@ -690,7 +690,7 @@ CONTAINS INTEGER(SIZE_T), INTENT(OUT) :: obj_count END FUNCTION h5fget_obj_count_c END INTERFACE - + hdferr = h5fget_obj_count_c(file_id, obj_type, obj_count) ! Don't include objects created by H5open in the H5F_OBJ_ALL_F count @@ -929,7 +929,7 @@ CONTAINS ! h5fget_file_image_f ! ! PURPOSE -! Retrieves a copy of the image of an existing, open file. +! Retrieves a copy of the image of an existing, open file. ! ! INPUTS ! file_id - Target file identifier. @@ -939,7 +939,7 @@ CONTAINS ! OUTPUTS ! hdferr - error code: ! 0 on success and -1 on failure -! OPTIONAL PARAMETERS +! OPTIONAL PARAMETERS ! buf_size - Returns the size in bytes of the buffer required to store the file image, ! no data will be copied. ! @@ -1024,7 +1024,7 @@ CONTAINS hdferr = INT(h5fget_dset_no_attrs_hint_c(file_id, c_minimize)) - ! Transfer value of C C_BOOL type to Fortran LOGICAL + ! Transfer value of C C_BOOL type to Fortran LOGICAL minimize = c_minimize END SUBROUTINE h5fget_dset_no_attrs_hint_f diff --git a/fortran/src/H5Gff.F90 b/fortran/src/H5Gff.F90 index 0684508..942cc51 100644 --- a/fortran/src/H5Gff.F90 +++ b/fortran/src/H5Gff.F90 @@ -64,11 +64,11 @@ CONTAINS ! gcpl_id - Property list for group creation ! gapl_id - Property list for group access ! -! AUTHOR +! AUTHOR ! Elena Pourmal ! August 12, 1999 ! -! HISTORY +! HISTORY ! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows ! port). March 5, 2001 @@ -668,7 +668,7 @@ CONTAINS !***** INTEGER :: namelen ! Lenghth of the current_name string INTEGER :: new_namelen ! Lenghth of the new_name string - + INTERFACE INTEGER FUNCTION h5gmove_c(loc_id, name, namelen, new_name, new_namelen) BIND(C,NAME='h5gmove_c') IMPORT :: C_CHAR @@ -680,7 +680,7 @@ CONTAINS INTEGER :: new_namelen END FUNCTION h5gmove_c END INTERFACE - + namelen = LEN(name) new_namelen = LEN(new_name) hdferr = h5gmove_c(loc_id, name, namelen, new_name, new_namelen) @@ -716,7 +716,7 @@ CONTAINS !***** INTEGER :: src_namelen ! Length of the current_name string INTEGER :: dst_namelen ! Lenghth of the new_name string - + INTERFACE INTEGER FUNCTION h5gmove2_c(src_loc_id, src_name, src_namelen, & dst_loc_id, dst_name, dst_namelen) BIND(C,NAME='h5gmove2_c') @@ -730,7 +730,7 @@ CONTAINS INTEGER :: dst_namelen END FUNCTION h5gmove2_c END INTERFACE - + src_namelen = LEN(src_name) dst_namelen = LEN(dst_name) hdferr = h5gmove2_c(src_loc_id, src_name, src_namelen, dst_loc_id, dst_name, dst_namelen) @@ -777,7 +777,7 @@ CONTAINS INTEGER, INTENT(OUT) :: hdferr ! Error code !***** INTEGER :: namelen ! Lenghth of the current_name string - + INTERFACE INTEGER FUNCTION h5gget_linkval_c(loc_id, name, namelen, size, buffer) BIND(C,NAME='h5gget_linkval_c') IMPORT :: C_CHAR, SIZE_T @@ -789,7 +789,7 @@ CONTAINS CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(OUT) :: buffer END FUNCTION h5gget_linkval_c END INTERFACE - + namelen = LEN(name) hdferr = h5gget_linkval_c(loc_id, name, namelen, size, buffer) END SUBROUTINE h5gget_linkval_f @@ -829,7 +829,7 @@ CONTAINS !***** INTEGER :: namelen ! Lenghth of the current_name string INTEGER :: commentlen ! Lenghth of the comment string - + INTERFACE INTEGER FUNCTION h5gset_comment_c(loc_id, name, namelen, & comment, commentlen) BIND(C,NAME='h5gset_comment_c') @@ -842,7 +842,7 @@ CONTAINS INTEGER :: commentlen END FUNCTION h5gset_comment_c END INTERFACE - + namelen = LEN(name) commentlen = LEN(comment) hdferr = h5gset_comment_c(loc_id, name, namelen, comment, commentlen) @@ -1004,7 +1004,7 @@ CONTAINS ! INPUTS ! group_id - Group identifier ! -! OUTPUTS +! OUTPUTS ! storage_type - Type of storage for links in group ! H5G_STORAGE_TYPE_COMPACT: Compact storage ! H5G_STORAGE_TYPE_DENSE: Indexed storage diff --git a/fortran/src/H5Iff.F90 b/fortran/src/H5Iff.F90 index 351dd4b..d9c3d49 100644 --- a/fortran/src/H5Iff.F90 +++ b/fortran/src/H5Iff.F90 @@ -38,7 +38,7 @@ !***** MODULE H5I - + USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR, C_CHAR USE H5GLOBAL @@ -305,10 +305,10 @@ CONTAINS ! Check if an ID is valid without producing an error message ! ! INPUTS -! id - identifier -! OUTPUTS +! id - identifier +! OUTPUTS ! valid - status of id as a valid identifier -! hdferr: - error code +! hdferr: - error code ! Success: 0 ! Failure: -1 ! @@ -318,26 +318,26 @@ CONTAINS ! SOURCE SUBROUTINE h5iis_valid_f(id, valid, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: id ! Identifier + INTEGER(HID_T), INTENT(IN) :: id ! Identifier LOGICAL, INTENT(OUT) :: valid ! Status of id as a valid identifier INTEGER, INTENT(OUT) :: hdferr ! Error code !***** INTEGER :: c_valid ! 0 = .false, 1 = .true. - + INTERFACE INTEGER FUNCTION h5iis_valid_c(id, c_valid) BIND(C, NAME='h5iis_valid_c') IMPORT :: HID_T IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: id ! Identifier + INTEGER(HID_T), INTENT(IN) :: id ! Identifier INTEGER :: c_valid END FUNCTION h5iis_valid_c END INTERFACE - + hdferr = h5iis_valid_c(id, c_valid) - + valid = .FALSE. ! Default IF(c_valid.EQ.1) valid = .TRUE. - + END SUBROUTINE h5iis_valid_f END MODULE H5I diff --git a/fortran/src/H5Lff.F90 b/fortran/src/H5Lff.F90 index f672547..2901a16 100644 --- a/fortran/src/H5Lff.F90 +++ b/fortran/src/H5Lff.F90 @@ -64,10 +64,10 @@ MODULE H5L ! H5L_TYPE_HARD Hard link ! H5L_TYPE_SOFT Soft link ! H5L_TYPE_EXTERNAL External link -! H5L_TYPE_ERROR Error +! H5L_TYPE_ERROR Error !cset specifies the character set in which the link name is encoded. Valid values include the following: ! H5T_CSET_ASCII US ASCII -! H5T_CSET_UTF8 UTF-8 Unicode encoding +! H5T_CSET_UTF8 UTF-8 Unicode encoding CONTAINS @@ -593,7 +593,7 @@ CONTAINS ! link_loc_id - File or group identifier. ! link_name - Name of the link for which information is being sought ! -! OUTPUTS +! OUTPUTS ! NOTE: In C these are contained in the structure H5L_info_t ! ! cset - indicates the character set used for link’s name. @@ -605,8 +605,8 @@ CONTAINS ! H5L_TYPE_EXTERNAL_F - External link ! H5L_TYPE_ERROR_ F - Error ! token - If the link is a hard link, token specifies the object token 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. +! 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 - Returns 0 if successful and -1 if fails ! ! OPTIONAL PARAMETERS @@ -642,8 +642,8 @@ CONTAINS ! H5L_TYPE_EXTERNAL_F - External link ! H5L_TYPE_ERROR _F - Error TYPE(H5O_TOKEN_T_F), INTENT(OUT), TARGET :: token ! If the link is a hard link, token specifies the object token 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(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 @@ -701,13 +701,13 @@ CONTAINS ! order - Order within field or index ! n - Link for which to retrieve information ! -! OUTPUTS +! 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 +! cset - Indicates the character set used for the attribute’s name ! token - If the link is a hard link, token specifies the object token 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., +! 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 - Returns 0 if successful and -1 if fails ! @@ -723,13 +723,13 @@ CONTAINS ! H5L_LINK_HARD_F, H5L_LINK_SOFT_F,H5L_LINK_EXTERNAL_F,H5L_LINK_ERROR_F ! to ! H5L_TYPE_HARD_F, H5L_TYPE_SOFT_F,H5L_TYPE_EXTERNAL_F,H5L_TYPE_ERROR_F -! MSB January 8, 2010. +! MSB January 8, 2010. ! ! SOURCE SUBROUTINE h5lget_info_by_idx_f(loc_id, group_name, index_field, order, n, & link_type, f_corder_valid, corder, cset, token, val_size, hdferr, lapl_id) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: loc_id ! File or group identifier specifying location of subject group + 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 INTEGER, INTENT(IN) :: index_field ! Index or field which determines the order ! H5_INDEX_UNKNOWN_F - Unknown index type @@ -747,12 +747,12 @@ CONTAINS ! H5L_TYPE_SOFT_F - Soft link ! H5L_TYPE_EXTERNAL_F - External link ! H5L_TYPE_ERROR _F - Error - LOGICAL, INTENT(OUT) :: f_corder_valid ! Indicates whether the creation order data is valid for this attribute + 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 TYPE(H5O_TOKEN_T_F), INTENT(OUT), TARGET :: token ! If the link is a hard link, token specifies the object token 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(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 @@ -1343,7 +1343,7 @@ CONTAINS ! ! Fortran2003 Interface: SUBROUTINE h5literate_f(group_id, index_type, order, idx, op, op_data, return_value, hdferr) - USE, INTRINSIC :: ISO_C_BINDING + USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR, C_FUNPTR IMPLICIT NONE INTEGER(HID_T) , INTENT(IN) :: group_id INTEGER , INTENT(IN) :: index_type @@ -1423,14 +1423,14 @@ CONTAINS ! Fortran2003 Interface: SUBROUTINE h5literate_by_name_f(loc_id, group_name, index_type, order, & idx, op, op_data, return_value, hdferr, lapl_id) - USE, INTRINSIC :: ISO_C_BINDING + USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR, C_FUNPTR IMPLICIT NONE INTEGER(HID_T) , INTENT(IN) :: loc_id - CHARACTER(LEN=*), INTENT(IN) :: group_name + CHARACTER(LEN=*), INTENT(IN) :: group_name INTEGER , INTENT(IN) :: index_type INTEGER , INTENT(IN) :: order INTEGER(HSIZE_T), INTENT(INOUT) :: idx - TYPE(C_FUNPTR) , INTENT(IN) :: op + TYPE(C_FUNPTR) , INTENT(IN) :: op TYPE(C_PTR) , INTENT(IN) :: op_data INTEGER , INTENT(OUT) :: return_value INTEGER , INTENT(OUT) :: hdferr diff --git a/fortran/src/H5Off.F90 b/fortran/src/H5Off.F90 index 2b025a7..d3b02e5 100644 --- a/fortran/src/H5Off.F90 +++ b/fortran/src/H5Off.F90 @@ -92,7 +92,7 @@ MODULE H5O END TYPE space_t TYPE, BIND(C) :: mesg_t - INTEGER(c_int64_t) :: present ! Flags to indicate presence of message type in header + INTEGER(c_int64_t) :: present ! Flags to indicate presence of message type in header INTEGER(c_int64_t) :: shared ! Flags to indicate message type is shared in header END TYPE mesg_t @@ -341,13 +341,13 @@ CONTAINS END SUBROUTINE h5oopen_by_token_f ! !****s* H5O/h5ocopy_f -! NAME -! h5ocopy_f +! NAME +! h5ocopy_f ! ! PURPOSE ! Copies an object in an HDF5 file. ! -! Inputs: +! Inputs: ! src_loc_id - Object identifier indicating the location of the source object to be copied. ! src_name - Name of the source object to be copied. ! dst_loc_id - Location identifier specifying the destination. @@ -357,13 +357,13 @@ CONTAINS ! ocpypl_id - Object copy property list. ! lcpl_id - Link creation property list for the new hard link. ! -! Outputs: +! Outputs: ! hdferr - Returns 0 if successful and -1 if fails. ! -! AUTHOR +! AUTHOR ! M. Scot Breitenfeld ! March 14, 2012 -! +! ! Fortran90 Interface: SUBROUTINE h5ocopy_f(src_loc_id, src_name, dst_loc_id, dst_name, hdferr, ocpypl_id, lcpl_id) IMPLICIT NONE @@ -411,22 +411,22 @@ CONTAINS END SUBROUTINE h5ocopy_f !****s* H5O/h5odecr_refcount_f -! NAME +! NAME ! h5odecr_refcount_f ! ! PURPOSE -! Decrements an object reference count. +! Decrements an object reference count. ! -! Inputs: +! Inputs: ! object_id - Object identifier. ! -! Outputs: +! Outputs: ! hdferr - Returns 0 if successful and -1 if fails. ! -! AUTHOR +! AUTHOR ! M. Scot Breitenfeld ! May 11, 2012 -! +! ! Fortran90 Interface: SUBROUTINE h5odecr_refcount_f(object_id, hdferr) IMPLICIT NONE @@ -442,33 +442,33 @@ CONTAINS END FUNCTION h5odecr_refcount_c END INTERFACE - hdferr = h5odecr_refcount_c(object_id) + hdferr = h5odecr_refcount_c(object_id) END SUBROUTINE h5odecr_refcount_f !****s* H5O/h5oexists_by_name_f -! NAME +! NAME ! h5oexists_by_name_f ! ! PURPOSE ! Determines whether a link resolves to an actual object. ! ! Inputs: -! loc_id - Identifier of the file or group to query. -! name - The name of the link to check. -! +! loc_id - Identifier of the file or group to query. +! name - The name of the link to check. +! ! ! Optional parameters: ! lapl_id - Link access property list identifier. ! -! Outputs: +! Outputs: ! link_exists - Existing link resolves to an object. ! hdferr - Returns 0 if successful and -1 if fails. ! -! AUTHOR +! AUTHOR ! M. Scot Breitenfeld ! May 11, 2012 -! +! ! Fortran90 Interface: SUBROUTINE h5oexists_by_name_f(loc_id, name, link_exists, hdferr, lapl_id) IMPLICIT NONE @@ -498,7 +498,7 @@ CONTAINS END INTERFACE namelen = LEN(name) - + lapl_id_default = H5P_DEFAULT_F IF(PRESENT(lapl_id)) lapl_id_default = lapl_id @@ -517,11 +517,11 @@ CONTAINS END SUBROUTINE h5oexists_by_name_f !****s* H5O/h5oget_comment_f -! NAME +! NAME ! h5oget_comment_f ! ! PURPOSE -! Retrieves comment for specified object. +! Retrieves comment for specified object. ! ! Inputs: ! obj_id - Identifier for the target object. @@ -529,21 +529,21 @@ CONTAINS ! Optional parameters: ! bufsize - Size of the comment buffer. ! -! Outputs: +! Outputs: ! comment - The comment. ! hdferr - Returns 0 if successful and -1 if fails. ! -! AUTHOR +! AUTHOR ! M. Scot Breitenfeld ! May 11, 2012 -! +! ! Fortran90 Interface: SUBROUTINE h5oget_comment_f(obj_id, comment, hdferr, bufsize) IMPLICIT NONE INTEGER(HID_T) , INTENT(IN) :: obj_id CHARACTER(LEN=*) , INTENT(OUT) :: comment INTEGER , INTENT(OUT) :: hdferr - INTEGER(HSSIZE_T), INTENT(OUT), OPTIONAL :: bufsize + INTEGER(HSSIZE_T), INTENT(OUT), OPTIONAL :: bufsize !***** INTEGER(SIZE_T) :: commentsize_default @@ -565,13 +565,13 @@ CONTAINS commentsize_default = LEN(comment) hdferr = h5oget_comment_c(obj_id, comment, commentsize_default, bufsize_default) - + IF(PRESENT(bufsize)) bufsize = bufsize_default END SUBROUTINE h5oget_comment_f !****s* H5O/h5oget_comment_by_name_f -! NAME +! NAME ! h5oget_comment_by_name_f ! ! PURPOSE @@ -579,20 +579,20 @@ CONTAINS ! ! Inputs: ! loc_id - Identifier of a file, group, dataset, or named datatype. -! name - Name of the object whose comment is to be retrieved, -! specified as a path relative to loc_id. +! name - Name of the object whose comment is to be retrieved, +! specified as a path relative to loc_id. ! ! Optional parameters: ! bufsize - Size of the comment buffer. ! -! Outputs: +! Outputs: ! comment - The comment. ! hdferr - Returns 0 if successful and -1 if fails. ! -! AUTHOR +! AUTHOR ! M. Scot Breitenfeld ! July 6, 2012 -! +! ! Fortran90 Interface: SUBROUTINE h5oget_comment_by_name_f(loc_id, name, comment, hdferr, bufsize, lapl_id) IMPLICIT NONE @@ -600,8 +600,8 @@ CONTAINS CHARACTER(LEN=*), INTENT(IN) :: name CHARACTER(LEN=*), INTENT(OUT) :: comment INTEGER , INTENT(OUT) :: hdferr - INTEGER(SIZE_T) , INTENT(OUT), OPTIONAL :: bufsize - INTEGER(HID_T) , INTENT(IN) , OPTIONAL :: lapl_id + INTEGER(SIZE_T) , INTENT(OUT), OPTIONAL :: bufsize + INTEGER(HID_T) , INTENT(IN) , OPTIONAL :: lapl_id !***** INTEGER(SIZE_T) :: commentsize_default @@ -632,28 +632,28 @@ CONTAINS hdferr = h5oget_comment_by_name_c(loc_id, name, name_size, & comment, commentsize_default, bufsize_default, lapl_id_default) - + IF(PRESENT(bufsize)) bufsize = bufsize_default END SUBROUTINE h5oget_comment_by_name_f !****s* H5O/h5oincr_refcount_f -! NAME +! NAME ! h5oincr_refcount_f ! ! PURPOSE ! Increments an object reference count. ! -! Inputs: +! Inputs: ! obj_id - Object identifier. ! -! Outputs: +! Outputs: ! hdferr - Returns 0 if successful and -1 if fails. ! -! AUTHOR +! AUTHOR ! M. Scot Breitenfeld ! May 15, 2012 -! +! ! Fortran90 Interface: SUBROUTINE h5oincr_refcount_f(obj_id, hdferr) IMPLICIT NONE @@ -669,7 +669,7 @@ CONTAINS END FUNCTION h5oincr_refcount_c END INTERFACE - hdferr = h5oincr_refcount_c(obj_id) + hdferr = h5oincr_refcount_c(obj_id) END SUBROUTINE h5oincr_refcount_f @@ -679,7 +679,7 @@ CONTAINS ! h5oopen_by_idx_f ! ! PURPOSE -! Open the nth object in a group. +! Open the nth object in a group. ! ! Inputs: ! loc_id - A file or group identifier. @@ -714,7 +714,7 @@ CONTAINS !***** INTEGER(SIZE_T) :: group_namelen INTEGER(HID_T) :: lapl_id_default - + INTERFACE INTEGER FUNCTION h5oopen_by_idx_c(loc_id, group_name, group_namelen, index_type, order, n, obj_id, lapl_id_default) & BIND(C,NAME='h5oopen_by_idx_c') @@ -743,23 +743,23 @@ CONTAINS END SUBROUTINE H5Oopen_by_idx_f !****s* H5O/h5oset_comment_f -! NAME +! NAME ! h5oset_comment_f ! ! PURPOSE ! Sets comment for specified object. ! -! Inputs: +! Inputs: ! obj_id - Identifier of the target object. ! comment - The new comment. ! -! Outputs: +! Outputs: ! hdferr - Returns 0 if successful and -1 if fails. ! -! AUTHOR +! AUTHOR ! M. Scot Breitenfeld ! May 15, 2012 -! +! ! Fortran90 Interface: SUBROUTINE h5oset_comment_f(obj_id, comment, hdferr) IMPLICIT NONE @@ -782,34 +782,34 @@ CONTAINS END INTERFACE commentlen = LEN(comment) - + hdferr = h5oset_comment_c(obj_id, comment, commentlen) END SUBROUTINE h5oset_comment_f !****s* H5O/h5oset_comment_by_name_f -! NAME +! NAME ! h5oset_comment_by_name_f ! ! PURPOSE -! Sets comment for specified object. +! Sets comment for specified object. ! -! Inputs: +! Inputs: ! loc_id - Identifier of a file, group, dataset, or named datatype. -! name - Name of the object whose comment is to be set or reset, -! specified as a path relative to loc_id. +! name - Name of the object whose comment is to be set or reset, +! specified as a path relative to loc_id. ! comment - The new comment. ! -! Outputs: +! Outputs: ! hdferr - Returns 0 if successful and -1 if fails. ! ! Optional parameters: ! lapl_id - Link access property list identifier. ! -! AUTHOR +! AUTHOR ! M. Scot Breitenfeld ! May 15, 2012 -! +! ! Fortran90 Interface: SUBROUTINE h5oset_comment_by_name_f(loc_id, name, comment, hdferr, lapl_id) IMPLICIT NONE @@ -843,7 +843,7 @@ CONTAINS lapl_id_default = H5P_DEFAULT_F IF(PRESENT(lapl_id)) lapl_id_default = lapl_id - + hdferr = h5oset_comment_by_name_c(loc_id, name, namelen, comment, commentlen, lapl_id_default) END SUBROUTINE h5oset_comment_by_name_f @@ -869,7 +869,7 @@ CONTAINS ! op_data - User-defined pointer to data required by the application for its processing of the group ! ! Outputs: -! return_value - returns the return value of the first operator that returns a positive value, or +! return_value - returns the return value of the first operator that returns a positive value, or ! zero if all members were processed with no operator returning non-zero. ! hdferr - Returns 0 if successful and -1 if fails ! @@ -884,14 +884,14 @@ CONTAINS SUBROUTINE h5ovisit_f(object_id, index_type, order, op, op_data, return_value, hdferr, fields) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: object_id - INTEGER, INTENT(IN) :: index_type + INTEGER, INTENT(IN) :: index_type INTEGER, INTENT(IN) :: order TYPE(C_FUNPTR):: op TYPE(C_PTR) :: op_data INTEGER, INTENT(OUT) :: return_value INTEGER, INTENT(OUT) :: hdferr - INTEGER, INTENT(IN), OPTIONAL :: fields + INTEGER, INTENT(IN), OPTIONAL :: fields !***** INTEGER :: fields_c @@ -932,11 +932,11 @@ CONTAINS ! Retrieves the metadata for an object, identifying the object by location and relative name. ! ! Inputs: -! loc_id - File or group identifier specifying location of group +! loc_id - File or group identifier specifying location of group ! in which object is located. ! name - Name of group, relative to loc_id. ! -! Outputs: +! Outputs: ! object_info - Buffer in which to return object information. ! hdferr - Returns 0 if successful and -1 if fails. ! @@ -956,13 +956,13 @@ CONTAINS TYPE(h5o_info_t), INTENT(OUT), TARGET :: object_info INTEGER , INTENT(OUT) :: hdferr INTEGER(HID_T) , INTENT(IN) , OPTIONAL :: lapl_id - INTEGER , INTENT(IN) , OPTIONAL :: fields + INTEGER , INTENT(IN) , OPTIONAL :: fields !***** INTEGER(SIZE_T) :: namelen INTEGER(HID_T) :: lapl_id_default TYPE(C_PTR) :: ptr INTEGER :: fields_c - + INTERFACE INTEGER FUNCTION h5oget_info_by_name_c(loc_id, name, namelen, lapl_id_default, object_info, fields) & BIND(C, NAME='h5oget_info_by_name_c') @@ -1017,12 +1017,12 @@ CONTAINS ! Fortran2003 Interface: SUBROUTINE h5oget_info_f(object_id, object_info, hdferr, fields) - USE, INTRINSIC :: ISO_C_BINDING + USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR IMPLICIT NONE INTEGER(HID_T) , INTENT(IN) :: object_id TYPE(h5o_info_t), INTENT(OUT), TARGET :: object_info INTEGER , INTENT(OUT) :: hdferr - INTEGER , INTENT(IN), OPTIONAL :: fields + INTEGER , INTENT(IN), OPTIONAL :: fields !***** TYPE(C_PTR) :: ptr INTEGER :: fields_c @@ -1056,14 +1056,14 @@ CONTAINS ! Retrieves the metadata for an object, identifying the object by an index position. ! ! Inputs: -! loc_id - File or group identifier specifying location of group +! loc_id - File or group identifier specifying location of group ! in which object is located. ! group_name - Name of group in which object is located. ! index_field - Index or field that determines the order. ! order - Order within field or index. ! n - Object for which information is to be returned ! -! Outputs: +! Outputs: ! object_info - Buffer in which to return object information. ! hdferr - Returns 0 if successful and -1 if fails. ! @@ -1079,7 +1079,7 @@ CONTAINS SUBROUTINE h5oget_info_by_idx_f(loc_id, group_name, index_field, order, n, & object_info, hdferr, lapl_id, fields) - USE, INTRINSIC :: ISO_C_BINDING + USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR IMPLICIT NONE INTEGER(HID_T) , INTENT(IN) :: loc_id CHARACTER(LEN=*), INTENT(IN) :: group_name @@ -1089,13 +1089,13 @@ CONTAINS TYPE(h5o_info_t), INTENT(OUT), TARGET :: object_info INTEGER , INTENT(OUT) :: hdferr INTEGER(HID_T) , INTENT(IN) , OPTIONAL :: lapl_id - INTEGER , INTENT(IN) , OPTIONAL :: fields + INTEGER , INTENT(IN) , OPTIONAL :: fields !***** INTEGER(SIZE_T) :: namelen INTEGER(HID_T) :: lapl_id_default TYPE(C_PTR) :: ptr INTEGER :: fields_c - + INTERFACE INTEGER FUNCTION h5oget_info_by_idx_c(loc_id, group_name, namelen, & index_field, order, n, lapl_id_default, object_info, fields) BIND(C, NAME='h5oget_info_by_idx_c') @@ -1137,7 +1137,7 @@ CONTAINS ! ! Inputs: ! loc_id - Identifier of a file or group. -! object_name - Name of the object, generally relative to loc_id, that will serve as root of the iteration +! object_name - Name of the object, generally relative to loc_id, that will serve as root of the iteration ! index_type - Type of index; valid values include: ! H5_INDEX_NAME_F ! H5_INDEX_CRT_ORDER_F @@ -1149,7 +1149,7 @@ CONTAINS ! op_data - User-defined pointer to data required by the application for its processing of the group ! ! Outputs: -! return_value - Returns the return value of the first operator that returns a positive value, or +! return_value - Returns the return value of the first operator that returns a positive value, or ! zero if all members were processed with no operator returning non-zero. ! hdferr - Returns 0 if successful and -1 if fails ! @@ -1167,7 +1167,7 @@ CONTAINS IMPLICIT NONE INTEGER(HID_T) , INTENT(IN) :: loc_id CHARACTER(LEN=*), INTENT(IN) :: object_name - INTEGER , INTENT(IN) :: index_type + INTEGER , INTENT(IN) :: index_type INTEGER , INTENT(IN) :: order TYPE(C_FUNPTR) :: op @@ -1175,7 +1175,7 @@ CONTAINS INTEGER , INTENT(OUT) :: return_value INTEGER , INTENT(OUT) :: hdferr INTEGER(HID_T) , INTENT(IN) , OPTIONAL :: lapl_id - INTEGER , INTENT(IN) , OPTIONAL :: fields + INTEGER , INTENT(IN) , OPTIONAL :: fields !***** INTEGER(SIZE_T) :: namelen diff --git a/fortran/src/H5Pff.F90 b/fortran/src/H5Pff.F90 index 61d30b8..7e06cf3 100644 --- a/fortran/src/H5Pff.F90 +++ b/fortran/src/H5Pff.F90 @@ -38,7 +38,7 @@ MODULE H5P - USE, INTRINSIC :: ISO_C_BINDING + USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR, C_CHAR USE H5GLOBAL USE H5fortkit @@ -141,7 +141,7 @@ MODULE H5P BIND(C, NAME='h5pget_c') IMPORT :: c_char, c_ptr IMPORT :: HID_T - INTEGER(HID_T), INTENT(IN) :: prp_id + INTEGER(HID_T), INTENT(IN) :: prp_id CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(IN) :: name INTEGER :: name_len TYPE(C_PTR), VALUE :: value @@ -178,12 +178,12 @@ MODULE H5P CONTAINS -!****s* H5P/h5pcreate_f +!****s* H5P/h5pcreate_f ! NAME -! h5pcreate_f +! h5pcreate_f ! ! PURPOSE -! Creates a new property as an instance of a property +! Creates a new property as an instance of a property ! list class. ! ! INPUTS @@ -208,18 +208,18 @@ CONTAINS ! ! OUTPUTS ! prp_id - property list identifier -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 +! port). March 14, 2001 ! ! Fortran90 Interface: SUBROUTINE h5pcreate_f(class, prp_id, hdferr) @@ -238,15 +238,15 @@ CONTAINS END FUNCTION h5pcreate_c END INTERFACE - hdferr = h5pcreate_c(class, prp_id) + hdferr = h5pcreate_c(class, prp_id) END SUBROUTINE h5pcreate_f -!****s* H5P/h5pset_preserve_f +!****s* H5P/h5pset_preserve_f ! NAME -! h5pset_preserve_f +! h5pset_preserve_f ! ! PURPOSE -! Sets the dataset transfer property list status to +! Sets the dataset transfer property list status to ! TRUE or FALSE for initializing compound datatype ! members during write/read operations. ! @@ -262,20 +262,20 @@ CONTAINS ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 -! -! Datatype of the flag parameter is changed from +! port). March 14, 2001 +! +! Datatype of the flag parameter is changed from ! INTEGER to LOGICAL June 4, 2003 ! ! Fortran90 Interface: SUBROUTINE h5pset_preserve_f(prp_id, flag, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier LOGICAL, INTENT(IN) :: flag ! TRUE/FALSE flag to set the dataset ! transfer property for partila writing/reading ! compound datatype @@ -295,12 +295,12 @@ CONTAINS END INTERFACE flag_c = 0 IF(flag) flag_c = 1 - hdferr = h5pset_preserve_c(prp_id, flag_c) + hdferr = h5pset_preserve_c(prp_id, flag_c) END SUBROUTINE h5pset_preserve_f -!****s* H5P/h5pget_preserve_f +!****s* H5P/h5pget_preserve_f ! NAME -! h5pget_preserve_f +! h5pget_preserve_f ! ! PURPOSE ! Checks status of the dataset transfer property list. @@ -310,26 +310,26 @@ CONTAINS ! ! OUTPUTS ! flag - status flag -! hdferr - error code +! hdferr - error code ! Success: 0 ! Failure: -1 ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows ! port). March 14, 2001 -! -! Datatype of the flag parameter is changed from -! INTEGER to LOGICAL -! June 4, 2003 -! +! +! Datatype of the flag parameter is changed from +! INTEGER to LOGICAL +! June 4, 2003 +! ! Fortran90 Interface: SUBROUTINE h5pget_preserve_f(prp_id, flag, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier LOGICAL, INTENT(OUT) :: flag ! TRUE/FALSE flag. Shows status of the dataset's ! transfer property for partial writing/reading ! compound datatype @@ -347,15 +347,15 @@ CONTAINS INTEGER :: flag_c END FUNCTION h5pget_preserve_c END INTERFACE - - hdferr = h5pget_preserve_c(prp_id, flag_c) + + hdferr = h5pget_preserve_c(prp_id, flag_c) flag = .FALSE. IF(flag_c .EQ. 1) flag = .TRUE. END SUBROUTINE h5pget_preserve_f -!****s* H5P/h5pget_class_f +!****s* H5P/h5pget_class_f ! NAME -! h5pget_class_f +! h5pget_class_f ! ! PURPOSE ! Returns the property list class for a property list. @@ -365,24 +365,24 @@ CONTAINS ! ! OUTPUTS ! classtype - property list class -! hdferr: - error code +! hdferr: - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 +! port). March 14, 2001 ! ! Fortran90 Interface: SUBROUTINE h5pget_class_f(prp_id, classtype, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier - INTEGER(HID_T), INTENT(OUT) :: classtype ! The type of the property list + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(OUT) :: classtype ! The type of the property list ! to be created. INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure @@ -394,42 +394,42 @@ CONTAINS IMPORT :: HID_T IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: prp_id - INTEGER(HID_T), INTENT(OUT) :: classtype + INTEGER(HID_T), INTENT(OUT) :: classtype END FUNCTION h5pget_class_c END INTERFACE - hdferr = h5pget_class_c(prp_id, classtype) + hdferr = h5pget_class_c(prp_id, classtype) END SUBROUTINE h5pget_class_f -!****s* H5P/h5pcopy_f +!****s* H5P/h5pcopy_f ! NAME -! h5pcopy_f +! h5pcopy_f ! ! PURPOSE -! Copies an existing property list to create a new +! Copies an existing property list to create a new ! property list ! ! INPUTS ! prp_id - property list identifier ! OUTPUTS ! new_prp_id - new property list identifier -! hdferr: - error code +! hdferr: - error code ! Success: 0 ! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows ! port). March 14, 2001 ! ! Fortran90 Interface: SUBROUTINE h5pcopy_f(prp_id, new_prp_id, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier INTEGER(HID_T), INTENT(OUT) :: new_prp_id ! Identifier of property list INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure @@ -444,38 +444,38 @@ CONTAINS INTEGER(HID_T), INTENT(OUT) :: new_prp_id END FUNCTION h5pcopy_c END INTERFACE - + hdferr = h5pcopy_c(prp_id, new_prp_id) END SUBROUTINE h5pcopy_f -!****s* H5P/h5pclose_f +!****s* H5P/h5pclose_f ! NAME -! h5pclose_f +! h5pclose_f ! ! PURPOSE -! Terminates access to a property list. +! Terminates access to a property list. ! ! INPUTS -! prp_id - identifier of the property list to -! terminate access to. +! prp_id - identifier of the property list to +! terminate access to. ! OUTPUTS -! hdferr - error code +! hdferr - error code ! Success: 0 ! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 -! +! port). March 14, 2001 +! ! Fortran90 Interface: SUBROUTINE h5pclose_f(prp_id, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure !***** @@ -484,45 +484,45 @@ CONTAINS BIND(C,NAME='h5pclose_c') IMPORT :: HID_T IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id + INTEGER(HID_T), INTENT(IN) :: prp_id END FUNCTION h5pclose_c END INTERFACE - + hdferr = h5pclose_c(prp_id) END SUBROUTINE h5pclose_f -!****s* H5P/h5pset_chunk_f +!****s* H5P/h5pset_chunk_f ! NAME -! h5pset_chunk_f +! h5pset_chunk_f ! ! PURPOSE -! Sets the size of the chunks used to store -! a chunked layout dataset. +! Sets the size of the chunks used to store +! a chunked layout dataset. ! ! INPUTS ! prp_id - datatset creation property list identifier ! ndims - number of dimensions for each chunk ! dims - array with dimension sizes for each chunk ! OUTPUTS -! hdferr - error code +! hdferr - error code ! Success: 0 ! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 -! +! port). March 14, 2001 +! ! Fortran90 Interface: SUBROUTINE h5pset_chunk_f(prp_id, ndims, dims, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier INTEGER, INTENT(IN) :: ndims ! Number of chunk dimensions - INTEGER(HSIZE_T), DIMENSION(ndims), INTENT(IN) :: dims + INTEGER(HSIZE_T), DIMENSION(ndims), INTENT(IN) :: dims ! Array containing sizes of ! chunk dimensions INTEGER, INTENT(OUT) :: hdferr ! Error code @@ -538,16 +538,16 @@ CONTAINS INTEGER(HSIZE_T), DIMENSION(ndims), INTENT(IN) :: dims END FUNCTION h5pset_chunk_c END INTERFACE - + hdferr = h5pset_chunk_c(prp_id, ndims, dims) END SUBROUTINE h5pset_chunk_f -!****s* H5P/h5pget_chunk_f +!****s* H5P/h5pget_chunk_f ! NAME -! h5pget_chunk_f +! h5pget_chunk_f ! ! PURPOSE -! Retrieves the size of chunks for the raw data of a +! Retrieves the size of chunks for the raw data of a ! chunked layout dataset ! ! INPUTS @@ -555,26 +555,26 @@ CONTAINS ! ndims - size of dims array ! OUTPUTS ! dims - array with dimension sizes for each chunk -! hdferr - error code +! hdferr - error code ! Success: number of chunk dimensions ! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 -! +! port). March 14, 2001 +! ! Fortran90 Interface: SUBROUTINE h5pget_chunk_f(prp_id, ndims, dims, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier INTEGER, INTENT(IN) :: ndims ! Number of chunk dimensions to ! to return - INTEGER(HSIZE_T), DIMENSION(ndims), INTENT(OUT) :: dims + INTEGER(HSIZE_T), DIMENSION(ndims), INTENT(OUT) :: dims ! Array containing sizes of ! chunk dimensions INTEGER, INTENT(OUT) :: hdferr ! Error code: @@ -596,19 +596,19 @@ CONTAINS hdferr = h5pget_chunk_c(prp_id, ndims, dims) END SUBROUTINE h5pget_chunk_f -!****s* H5P/h5pset_deflate_f +!****s* H5P/h5pset_deflate_f ! NAME -! h5pset_deflate_f +! h5pset_deflate_f ! ! PURPOSE -! Sets compression method and compression level. +! Sets compression method and compression level. ! ! INPUTS ! prp_id - property list identifier ! level - compression level ! OUTPUTS -! -! hdferr - error code +! +! hdferr - error code ! Success: 0 ! Failure: -1 ! @@ -617,15 +617,15 @@ CONTAINS ! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows ! port). March 14, 2001 -! +! ! Fortran90 Interface: SUBROUTINE h5pset_deflate_f(prp_id, level, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier - INTEGER, INTENT(IN) :: level ! Compression level + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER, INTENT(IN) :: level ! Compression level INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure !***** @@ -643,15 +643,15 @@ CONTAINS END FUNCTION h5pset_deflate_c END INTERFACE hdferr = h5pset_deflate_c(prp_id, level) - + END SUBROUTINE h5pset_deflate_f -!****s* H5P/h5pget_version_f +!****s* H5P/h5pget_version_f ! NAME -! h5pget_version_f +! h5pget_version_f ! ! PURPOSE -! Retrieves the version information of various objects +! Retrieves the version information of various objects ! for a file creation property list ! ! INPUTS @@ -661,24 +661,24 @@ CONTAINS ! freelist - global freelist version number ! stab - symbol table version number ! shhdr - shared object header version number -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 -! -! Fortran90 Interface: +! port). March 14, 2001 +! +! Fortran90 Interface: SUBROUTINE h5pget_version_f(prp_id, boot, freelist, & stab, shhdr, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier INTEGER, DIMENSION(:), INTENT(OUT) :: boot ! Array to put boot ! block version number INTEGER, DIMENSION(:), INTENT(OUT) :: freelist ! Array to put global @@ -698,19 +698,19 @@ CONTAINS IMPORT :: HID_T IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: prp_id - INTEGER, DIMENSION(*), INTENT(OUT) :: boot - INTEGER, DIMENSION(*), INTENT(OUT) :: freelist + INTEGER, DIMENSION(*), INTENT(OUT) :: boot + INTEGER, DIMENSION(*), INTENT(OUT) :: freelist INTEGER, DIMENSION(*), INTENT(OUT) :: stab INTEGER, DIMENSION(*), INTENT(OUT) :: shhdr END FUNCTION h5pget_version_c END INTERFACE - + hdferr = h5pget_version_c(prp_id, boot, freelist, stab, shhdr) END SUBROUTINE h5pget_version_f -!****s* H5P/h5pset_userblock_f +!****s* H5P/h5pset_userblock_f ! NAME -! h5pset_userblock_f +! h5pset_userblock_f ! ! PURPOSE ! Sets user block size @@ -720,24 +720,24 @@ CONTAINS ! size - size of the user-block in bytes ! ! OUTPUTS -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 +! port). March 14, 2001 ! ! Fortran90 Interface: SUBROUTINE h5pset_userblock_f (prp_id, size, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier - INTEGER(HSIZE_T), INTENT(IN) :: size ! Size of the user-block in bytes + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HSIZE_T), INTENT(IN) :: size ! Size of the user-block in bytes INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure !***** @@ -754,38 +754,38 @@ CONTAINS hdferr = h5pset_userblock_c(prp_id, size) END SUBROUTINE h5pset_userblock_f -!****s* H5P/h5pget_userblock_f +!****s* H5P/h5pget_userblock_f ! NAME -! h5pget_userblock_f +! h5pget_userblock_f ! ! PURPOSE ! Gets user block size. ! ! INPUTS -! +! ! prp_id - file creation property list identifier ! OUTPUTS -! +! ! block_size - size of the user block in bytes -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 -! +! port). March 14, 2001 +! ! Fortran90 Interface: SUBROUTINE h5pget_userblock_f(prp_id, block_size, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier - INTEGER(HSIZE_T), INTENT(OUT) :: block_size ! Size of the - ! user-block in bytes + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HSIZE_T), INTENT(OUT) :: block_size ! Size of the + ! user-block in bytes INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure !***** @@ -801,41 +801,41 @@ CONTAINS hdferr = h5pget_userblock_c(prp_id, block_size) END SUBROUTINE h5pget_userblock_f -!****s* H5P/h5pset_sizes_f +!****s* H5P/h5pset_sizes_f ! NAME -! h5pset_sizes_f +! h5pset_sizes_f ! ! PURPOSE -! Sets the byte size of the offsets and lengths used +! Sets the byte size of the offsets and lengths used ! to address objects in an HDF5 file. ! ! INPUTS ! prp_id - file creation property list identifier -! sizeof_addr - size of an object offset in bytes +! sizeof_addr - size of an object offset in bytes ! sizeof_size - size of an object length in bytes ! OUTPUTS -! -! hdferr - error code +! +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 -! +! port). March 14, 2001 +! ! Fortran90 Interface: SUBROUTINE h5pset_sizes_f (prp_id, sizeof_addr, sizeof_size, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier - INTEGER(SIZE_T), INTENT(IN) :: sizeof_addr ! Size of an object - ! offset in bytes - INTEGER(SIZE_T), INTENT(IN) :: sizeof_size ! Size of an object - ! length in bytes + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(SIZE_T), INTENT(IN) :: sizeof_addr ! Size of an object + ! offset in bytes + INTEGER(SIZE_T), INTENT(IN) :: sizeof_size ! Size of an object + ! length in bytes INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure !***** @@ -844,50 +844,50 @@ CONTAINS BIND(C,NAME='h5pset_sizes_c') IMPORT :: HID_T, SIZE_T IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id + INTEGER(HID_T), INTENT(IN) :: prp_id INTEGER(SIZE_T), INTENT(IN) :: sizeof_addr INTEGER(SIZE_T), INTENT(IN) :: sizeof_size END FUNCTION h5pset_sizes_c END INTERFACE - + hdferr = h5pset_sizes_c(prp_id, sizeof_addr, sizeof_size) END SUBROUTINE h5pset_sizes_f -!****s* H5P/h5pget_sizes_f +!****s* H5P/h5pget_sizes_f ! NAME -! h5pget_sizes_f +! h5pget_sizes_f ! ! PURPOSE -! Retrieves the size of the offsets and lengths used +! Retrieves the size of the offsets and lengths used ! in an HDF5 file ! ! INPUTS ! prp_id - file creation property list identifier ! OUTPUTS -! -! sizeof_addr - size of an object offset in bytes +! +! sizeof_addr - size of an object offset in bytes ! sizeof_size - size of an object length in bytes -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 -! +! port). March 14, 2001 +! ! Fortran90 Interface: SUBROUTINE h5pget_sizes_f(prp_id, sizeof_addr, sizeof_size, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier INTEGER(SIZE_T), INTENT(OUT) :: sizeof_addr ! Size of an object - ! offset in bytes + ! offset in bytes INTEGER(SIZE_T), INTENT(OUT) :: sizeof_size ! Size of an object - ! length in bytes + ! length in bytes INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure !***** @@ -896,49 +896,49 @@ CONTAINS BIND(C,NAME='h5pget_sizes_c') IMPORT :: HID_T, SIZE_T IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id + INTEGER(HID_T), INTENT(IN) :: prp_id INTEGER(SIZE_T), INTENT(OUT) :: sizeof_addr INTEGER(SIZE_T), INTENT(OUT) :: sizeof_size END FUNCTION h5pget_sizes_c END INTERFACE - + hdferr = h5pget_sizes_c(prp_id, sizeof_addr, sizeof_size) END SUBROUTINE h5pget_sizes_f -!****s* H5P/h5pset_sym_k_f +!****s* H5P/h5pset_sym_k_f ! NAME -! h5pset_sym_k_f +! h5pset_sym_k_f ! ! PURPOSE -! Sets the size of parameters used to control the +! Sets the size of parameters used to control the !symbol table nodes ! ! INPUTS -! +! ! prp_id - file creation property list identifier ! ik - symbol table tree rank ! lk - symbol table node size ! OUTPUTS -! -! hdferr - error code +! +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 -! +! port). March 14, 2001 +! ! Fortran90 Interface: SUBROUTINE h5pset_sym_k_f (prp_id, ik, lk, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier - INTEGER, INTENT(IN) :: ik ! Symbol table tree rank - INTEGER, INTENT(IN) :: lk ! Symbol table node size + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER, INTENT(IN) :: ik ! Symbol table tree rank + INTEGER, INTENT(IN) :: lk ! Symbol table node size INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure !***** @@ -947,46 +947,46 @@ CONTAINS BIND(C,NAME='h5pset_sym_k_c') IMPORT :: HID_T IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id + INTEGER(HID_T), INTENT(IN) :: prp_id INTEGER, INTENT(IN) :: ik INTEGER, INTENT(IN) :: lk END FUNCTION h5pset_sym_k_c END INTERFACE - + hdferr = h5pset_sym_k_c(prp_id, ik, lk) END SUBROUTINE h5pset_sym_k_f -!****s* H5P/h5pget_sym_k_f +!****s* H5P/h5pget_sym_k_f ! NAME -! h5pget_sym_k_f +! h5pget_sym_k_f ! ! PURPOSE ! Retrieves the size of the symbol table B-tree 1/2 rank -! and the symbol table leaf node 1/2 size. +! and the symbol table leaf node 1/2 size. ! ! INPUTS -! +! ! prp_id - file creation property list identifier ! OUTPUTS -! +! ! ik - symbol table tree 1/2 rank ! lk - symbol table node 1/2 size -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 -! +! port). March 14, 2001 +! ! Fortran90 Interface: SUBROUTINE h5pget_sym_k_f(prp_id, ik, lk, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier INTEGER, INTENT(OUT) :: ik ! Symbol table tree rank INTEGER, INTENT(OUT) :: lk ! Symbol table node size INTEGER, INTENT(OUT) :: hdferr ! Error code @@ -997,45 +997,45 @@ CONTAINS BIND(C,NAME='h5pget_sym_k_c') IMPORT :: HID_T IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id + INTEGER(HID_T), INTENT(IN) :: prp_id INTEGER, INTENT(OUT) :: ik INTEGER, INTENT(OUT) :: lk END FUNCTION h5pget_sym_k_c END INTERFACE - + hdferr = h5pget_sym_k_c(prp_id, ik, lk) END SUBROUTINE h5pget_sym_k_f -!****s* H5P/h5pset_istore_k_f +!****s* H5P/h5pset_istore_k_f ! NAME -! h5pset_istore_k_f +! h5pset_istore_k_f ! ! PURPOSE -! Sets the size of the parameter used to control the +! Sets the size of the parameter used to control the ! B-trees for indexing chunked datasets ! ! INPUTS -! +! ! prp_id - file creation property list identifier ! ik - 1/2 rank of chunked storage B-tree ! OUTPUTS -! -! hdferr - error code +! +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 -! +! port). March 14, 2001 +! ! Fortran90 Interface: SUBROUTINE h5pset_istore_k_f (prp_id, ik, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier INTEGER, INTENT(IN) :: ik ! 1/2 rank of chunked storage B-tree INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure @@ -1049,40 +1049,40 @@ CONTAINS INTEGER, INTENT(IN) :: ik END FUNCTION h5pset_istore_k_c END INTERFACE - + hdferr = h5pset_istore_k_c(prp_id, ik) END SUBROUTINE h5pset_istore_k_f -!****s* H5P/h5pget_istore_k_f +!****s* H5P/h5pget_istore_k_f ! NAME -! h5pget_istore_k_f +! h5pget_istore_k_f ! ! PURPOSE -! Queries the 1/2 rank of an indexed storage B-tree. +! Queries the 1/2 rank of an indexed storage B-tree. ! ! INPUTS -! +! ! prp_id - file creation property list identifier ! OUTPUTS -! +! ! ik - 1/2 rank of chunked storage B-tree -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 -! +! port). March 14, 2001 +! ! Fortran90 Interface: SUBROUTINE h5pget_istore_k_f(prp_id, ik, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier INTEGER, INTENT(OUT) :: ik ! 1/2 rank of chunked storage B-tree INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure @@ -1096,41 +1096,41 @@ CONTAINS INTEGER, INTENT(OUT) :: ik END FUNCTION h5pget_istore_k_c END INTERFACE - + hdferr = h5pget_istore_k_c(prp_id, ik) END SUBROUTINE h5pget_istore_k_f -!****s* H5P/h5pget_driver_f +!****s* H5P/h5pget_driver_f ! NAME -! h5pget_driver_f +! h5pget_driver_f ! ! PURPOSE -! Returns low-lever driver identifier. +! Returns low-lever driver identifier. ! ! INPUTS -! -! prp_id - file access or data transfer property -! list identifier. +! +! prp_id - file access or data transfer property +! list identifier. ! OUTPUTS -! +! ! driver - low-level driver identifier -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 -! +! port). March 14, 2001 +! ! Fortran90 Interface: SUBROUTINE h5pget_driver_f(prp_id, driver, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier INTEGER(HID_T), INTENT(OUT) :: driver ! Low-level file driver identifier INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure @@ -1144,39 +1144,39 @@ CONTAINS INTEGER(HID_T), INTENT(OUT) :: driver END FUNCTION h5pget_driver_c END INTERFACE - + hdferr = h5pget_driver_c(prp_id, driver) END SUBROUTINE h5pget_driver_f -!****s* H5P/h5pset_fapl_stdio_f +!****s* H5P/h5pset_fapl_stdio_f ! NAME -! h5pset_fapl_stdio_f +! h5pset_fapl_stdio_f ! ! PURPOSE -! Sets the standard I/O driver. +! Sets the standard I/O driver. ! ! INPUTS -! +! ! prp_id - file access property list identifier ! OUTPUTS -! -! hdferr - error code +! +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 -! +! port). March 14, 2001 +! ! Fortran90 Interface: SUBROUTINE h5pset_fapl_stdio_f (prp_id, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure !***** @@ -1188,34 +1188,34 @@ CONTAINS INTEGER(HID_T), INTENT(IN) :: prp_id END FUNCTION h5pset_fapl_stdio_c END INTERFACE - + hdferr = h5pset_fapl_stdio_c(prp_id) END SUBROUTINE h5pset_fapl_stdio_f -!****s* H5P/h5pget_stdio_f +!****s* H5P/h5pget_stdio_f ! NAME -! h5pget_stdio_f +! h5pget_stdio_f ! ! PURPOSE ! NOT AVAILABLE ! ! INPUTS -! +! ! OUTPUTS -! -! hdferr - error code +! +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 -! +! port). March 14, 2001 +! ! SOURCE ! SUBROUTINE h5pget_stdio_f (prp_id, io, hdferr) ! @@ -1231,35 +1231,35 @@ CONTAINS ! hdferr = h5pget_stdio_c(prp_id, io) ! END SUBROUTINE h5pget_stdio_f -!****s* H5P/h5pset_fapl_sec2_f +!****s* H5P/h5pset_fapl_sec2_f ! NAME -! h5pset_fapl_sec2_f +! h5pset_fapl_sec2_f ! ! PURPOSE -! Sets the sec2 driver. +! Sets the sec2 driver. ! ! INPUTS -! +! ! prp_id - file access property list identifier ! OUTPUTS -! -! hdferr - error code +! +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 -! +! port). March 14, 2001 +! ! Fortran90 Interface: SUBROUTINE h5pset_fapl_sec2_f (prp_id, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure !***** @@ -1268,38 +1268,38 @@ CONTAINS BIND(C,NAME='h5pset_fapl_sec2_c') IMPORT :: HID_T IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier END FUNCTION h5pset_fapl_sec2_c END INTERFACE - + hdferr = h5pset_fapl_sec2_c(prp_id) END SUBROUTINE h5pset_fapl_sec2_f -!****s* H5P/h5pget_sec2_f +!****s* H5P/h5pget_sec2_f ! NAME -! h5pget_sec2_f +! h5pget_sec2_f ! ! PURPOSE ! NOT AVAILABLE ! ! INPUTS -! +! ! OUTPUTS -! -! hdferr - error code +! +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 -! -! SOURCE! SUBROUTINE h5pget_sec2_f (prp_id, sec2, hdferr) +! port). March 14, 2001 +! +! SOURCE! SUBROUTINE h5pget_sec2_f (prp_id, sec2, hdferr) ! IMPLICIT NONE ! INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier ! INTEGER, INTENT(OUT) :: sec2 ! value indicates whether the file @@ -1312,37 +1312,37 @@ CONTAINS ! hdferr = h5pget_sec2_c(prp_id, sec2) ! END SUBROUTINE h5pget_sec2_f -!****s* H5P/h5pset_alignment_f +!****s* H5P/h5pset_alignment_f ! NAME -! h5pset_alignment_f +! h5pset_alignment_f ! ! PURPOSE -! Sets alignment properties of a file access property list. +! Sets alignment properties of a file access property list. ! ! INPUTS -! +! ! prp_id - file access property list identifier -! threshold - threshold value +! threshold - threshold value ! alignment - alignment value ! OUTPUTS -! -! hdferr - error code +! +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 -! +! port). March 14, 2001 +! ! Fortran90 Interface: SUBROUTINE h5pset_alignment_f(prp_id, threshold, alignment, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier INTEGER(HSIZE_T), INTENT(IN) :: threshold ! Threshold value INTEGER(HSIZE_T), INTENT(IN) :: alignment ! alignment value INTEGER, INTENT(OUT) :: hdferr ! Error code @@ -1358,41 +1358,41 @@ CONTAINS INTEGER(HSIZE_T), INTENT(IN) :: alignment END FUNCTION h5pset_alignment_c END INTERFACE - + hdferr = h5pset_alignment_c(prp_id, threshold, alignment) END SUBROUTINE h5pset_alignment_f -!****s* H5P/h5pget_alignment_f +!****s* H5P/h5pget_alignment_f ! NAME -! h5pget_alignment_f +! h5pget_alignment_f ! ! PURPOSE -! Retrieves the current settings for alignment -! properties from a file access property list. +! Retrieves the current settings for alignment +! properties from a file access property list. ! ! INPUTS ! prp_id - file access property list identifier ! ! OUTPUTS -! threshold - threshold value +! threshold - threshold value ! alignment - alignment value -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 -! +! port). March 14, 2001 +! ! Fortran90 Interface: SUBROUTINE h5pget_alignment_f(prp_id, threshold, alignment, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier INTEGER(HSIZE_T), INTENT(OUT) :: threshold ! Threshold value INTEGER(HSIZE_T), INTENT(OUT) :: alignment ! alignment value INTEGER, INTENT(OUT) :: hdferr ! Error code @@ -1408,44 +1408,44 @@ CONTAINS INTEGER(HSIZE_T), INTENT(OUT) :: alignment END FUNCTION h5pget_alignment_c END INTERFACE - + hdferr = h5pget_alignment_c(prp_id, threshold, alignment) END SUBROUTINE h5pget_alignment_f -!****s* H5P/h5pset_fapl_core_f +!****s* H5P/h5pset_fapl_core_f ! NAME -! h5pset_fapl_core_f +! h5pset_fapl_core_f ! ! PURPOSE -! Modifies the file access property list to use the -! H5FD_CORE driver. +! Modifies the file access property list to use the +! H5FD_CORE driver. ! ! INPUTS ! prp_id - file access property list identifier -! increment - size, in bytes, of memory increments -! backing_store - boolean flag indicating whether to write -! the file contents to disk when the file is closed. +! increment - size, in bytes, of memory increments +! backing_store - boolean flag indicating whether to write +! the file contents to disk when the file is closed. ! OUTPUTS -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 -! +! port). March 14, 2001 +! ! Fortran90 Interface: SUBROUTINE h5pset_fapl_core_f(prp_id, increment, backing_store, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier INTEGER(SIZE_T), INTENT(IN) :: increment ! File block size in bytes. LOGICAL, INTENT(IN) :: backing_store ! Flag to indicate that - ! entire file contents are flushed to a file + ! entire file contents are flushed to a file ! with the same name as this core file. INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure @@ -1456,9 +1456,9 @@ CONTAINS BIND(C,NAME='h5pset_fapl_core_c') IMPORT :: HID_T, SIZE_T IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id - INTEGER(SIZE_T), INTENT(IN) :: increment - INTEGER :: backing_store_flag + INTEGER(HID_T), INTENT(IN) :: prp_id + INTEGER(SIZE_T), INTENT(IN) :: increment + INTEGER :: backing_store_flag END FUNCTION h5pset_fapl_core_c END INTERFACE backing_store_flag = 0 @@ -1466,96 +1466,96 @@ CONTAINS hdferr = h5pset_fapl_core_c(prp_id, increment, backing_store_flag) END SUBROUTINE h5pset_fapl_core_f -!****s* H5P/h5pget_fapl_core_f +!****s* H5P/h5pget_fapl_core_f ! NAME -! h5pget_fapl_core_f +! h5pget_fapl_core_f ! ! PURPOSE -! Queries core file driver properties. +! Queries core file driver properties. ! ! INPUTS ! prp_id - file access property list identifier ! OUTPUTS -! -! increment - size, in bytes, of memory increments -! backing_store - boolean flag indicating whether to write -! the file contents to disk when the file is closed. -! hdferr - error code +! +! increment - size, in bytes, of memory increments +! backing_store - boolean flag indicating whether to write +! the file contents to disk when the file is closed. +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 -! +! port). March 14, 2001 +! ! Fortran90 Interface: SUBROUTINE h5pget_fapl_core_f(prp_id, increment, backing_store, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier INTEGER(SIZE_T), INTENT(OUT) :: increment ! File block size in bytes. LOGICAL, INTENT(OUT) :: backing_store ! Flag to indicate that - ! entire file contents are flushed to a file + ! entire file contents are flushed to a file ! with the same name as this core file. INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure !***** - INTEGER :: backing_store_flag + INTEGER :: backing_store_flag INTERFACE INTEGER FUNCTION h5pget_fapl_core_c(prp_id, increment, backing_store_flag) & BIND(C,NAME='h5pget_fapl_core_c') IMPORT :: HID_T,SIZE_T IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id - INTEGER(SIZE_T), INTENT(OUT) :: increment - INTEGER :: backing_store_flag + INTEGER(HID_T), INTENT(IN) :: prp_id + INTEGER(SIZE_T), INTENT(OUT) :: increment + INTEGER :: backing_store_flag END FUNCTION h5pget_fapl_core_c END INTERFACE - + hdferr = h5pget_fapl_core_c(prp_id, increment, backing_store_flag) backing_store =.FALSE. IF (backing_store_flag .EQ. 1) backing_store =.TRUE. END SUBROUTINE h5pget_fapl_core_f -!****s* H5P/ h5pset_fapl_family_f +!****s* H5P/ h5pset_fapl_family_f ! NAME -! h5pset_fapl_family_f +! h5pset_fapl_family_f ! ! PURPOSE -! Sets the file access property list to use the family driver. +! Sets the file access property list to use the family driver. ! ! INPUTS ! prp_id - file access property list identifier -! memb_size - size in bytes of each file member -! memb_plist - identifier of the file access property +! memb_size - size in bytes of each file member +! memb_plist - identifier of the file access property ! list to be used for each family member ! OUTPUTS -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 -! +! port). March 14, 2001 +! ! Fortran90 Interface: SUBROUTINE h5pset_fapl_family_f(prp_id, memb_size, memb_plist , hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier INTEGER(HSIZE_T), INTENT(IN) :: memb_size ! Logical size, in bytes, ! of each family member - INTEGER(HID_T), INTENT(IN) :: memb_plist ! Identifier of the file - ! access property list for + INTEGER(HID_T), INTENT(IN) :: memb_plist ! Identifier of the file + ! access property list for ! each member of the family INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure @@ -1574,39 +1574,39 @@ CONTAINS hdferr = h5pset_fapl_family_c(prp_id, memb_size, memb_plist) END SUBROUTINE h5pset_fapl_family_f -!****s* H5P/h5pget_fapl_family_f +!****s* H5P/h5pget_fapl_family_f ! NAME -! h5pget_fapl_family_f +! h5pget_fapl_family_f ! ! PURPOSE -! Returns file access property list information. +! Returns file access property list information. ! ! INPUTS ! prp_id - file access property list identifier ! OUTPUTS -! memb_size - size in bytes of each file member -! memb_plist - identifier of the file access property +! memb_size - size in bytes of each file member +! memb_plist - identifier of the file access property ! list to be used for each family member -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 -! +! port). March 14, 2001 +! ! Fortran90 Interface: SUBROUTINE h5pget_fapl_family_f(prp_id, memb_size, memb_plist , hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier INTEGER(HSIZE_T), INTENT(OUT) :: memb_size ! Logical size, in bytes, ! of each family member - INTEGER(HID_T), INTENT(OUT) :: memb_plist ! Identifier of the file - ! access property list for + INTEGER(HID_T), INTENT(OUT) :: memb_plist ! Identifier of the file + ! access property list for ! each member of the family INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure @@ -1621,52 +1621,52 @@ CONTAINS INTEGER(HID_T), INTENT(OUT) :: memb_plist END FUNCTION h5pget_fapl_family_c END INTERFACE - + hdferr = h5pget_fapl_family_c(prp_id, memb_size, memb_plist) END SUBROUTINE h5pget_fapl_family_f -!****s* H5P/h5pset_cache_f +!****s* H5P/h5pset_cache_f ! NAME -! h5pset_cache_f +! h5pset_cache_f ! ! PURPOSE -! Sets the meta data cache and raw data chunk +! Sets the meta data cache and raw data chunk ! cache parameters ! ! INPUTS -! +! ! prp_id - file access property list identifier -! mdc_nelmts - number of elements (objects) in the meta -! data cache -! rdcc_nelmts - number of elements (objects) in the raw -! data chunk cache -! rdcc_nbytes - total size of the raw data chunk cache, in bytes +! mdc_nelmts - number of elements (objects) in the meta +! data cache +! rdcc_nelmts - number of elements (objects) in the raw +! data chunk cache +! rdcc_nbytes - total size of the raw data chunk cache, in bytes ! rdcc_w0 - preemption policy (0 or 1) ! OUTPUTS -! -! hdferr - error code +! +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 -! +! port). March 14, 2001 +! ! Fortran90 Interface: SUBROUTINE h5pset_cache_f(prp_id, mdc_nelmts,rdcc_nelmts, rdcc_nbytes, rdcc_w0, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier INTEGER, INTENT(IN) :: mdc_nelmts ! Number of elements (objects) ! in the meta data cache INTEGER(SIZE_T), INTENT(IN) :: rdcc_nelmts ! Number of elements (objects) ! in the meta data cache - INTEGER(SIZE_T), INTENT(IN) :: rdcc_nbytes ! Total size of the raw data - ! chunk cache, in bytes + INTEGER(SIZE_T), INTENT(IN) :: rdcc_nbytes ! Total size of the raw data + ! chunk cache, in bytes REAL, INTENT(IN) :: rdcc_w0 ! Preemption policy INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure @@ -1677,8 +1677,8 @@ CONTAINS IMPORT :: HID_T, SIZE_T IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: prp_id - INTEGER, INTENT(IN) :: mdc_nelmts - INTEGER(SIZE_T), INTENT(IN) :: rdcc_nelmts + INTEGER, INTENT(IN) :: mdc_nelmts + INTEGER(SIZE_T), INTENT(IN) :: rdcc_nelmts INTEGER(SIZE_T), INTENT(IN) :: rdcc_nbytes REAL, INTENT(IN) :: rdcc_w0 END FUNCTION h5pset_cache_c @@ -1687,50 +1687,50 @@ CONTAINS hdferr = h5pset_cache_c(prp_id, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0 ) END SUBROUTINE h5pset_cache_f -!****s* H5P/h5pget_cache_f +!****s* H5P/h5pget_cache_f ! NAME -! h5pget_cache_f +! h5pget_cache_f ! ! PURPOSE -! Queries the meta data cache and raw data chunk cache -! parameters. +! Queries the meta data cache and raw data chunk cache +! parameters. ! ! INPUTS ! prp_id - file access property list identifier ! ! OUTPUTS -! mdc_nelmts - number of elements (objects) in the meta -! data cache -! rdcc_nelmts - number of elements (objects) in the raw -! data chunk cache -! rdcc_nbytes - total size of the raw data chunk cache, in bytes +! mdc_nelmts - number of elements (objects) in the meta +! data cache +! rdcc_nelmts - number of elements (objects) in the raw +! data chunk cache +! rdcc_nbytes - total size of the raw data chunk cache, in bytes ! rdcc_w0 - preemption policy (0 or 1) -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 +! port). March 14, 2001 ! ! Bug fix: type of the rdcc_nelmts parameter should be INTEGER -! instead of INTEGER(SIZE_T) October 10, 2003 -! +! instead of INTEGER(SIZE_T) October 10, 2003 +! ! Fortran90 Interface: SUBROUTINE h5pget_cache_f(prp_id, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier INTEGER, INTENT(OUT) :: mdc_nelmts ! Number of elements (objects) ! in the meta data cache INTEGER(SIZE_T), INTENT(OUT) :: rdcc_nelmts ! Number of elements (objects) ! in the meta data cache - INTEGER(SIZE_T), INTENT(OUT) :: rdcc_nbytes ! Total size of the raw data - ! chunk cache, in bytes + INTEGER(SIZE_T), INTENT(OUT) :: rdcc_nbytes ! Total size of the raw data + ! chunk cache, in bytes REAL, INTENT(OUT) :: rdcc_w0 ! Preemption policy INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure @@ -1741,58 +1741,58 @@ CONTAINS IMPORT :: HID_T, SIZE_T IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: prp_id - INTEGER, INTENT(OUT) :: mdc_nelmts - INTEGER(SIZE_T), INTENT(OUT) :: rdcc_nelmts + INTEGER, INTENT(OUT) :: mdc_nelmts + INTEGER(SIZE_T), INTENT(OUT) :: rdcc_nelmts INTEGER(SIZE_T), INTENT(OUT) :: rdcc_nbytes REAL, INTENT(OUT) :: rdcc_w0 END FUNCTION h5pget_cache_c END INTERFACE - + hdferr = h5pget_cache_c(prp_id, mdc_nelmts,rdcc_nelmts, rdcc_nbytes, rdcc_w0 ) END SUBROUTINE h5pget_cache_f -!****s* H5P/h5pset_fapl_split_f +!****s* H5P/h5pset_fapl_split_f ! NAME -! h5pset_fapl_split_f +! h5pset_fapl_split_f ! ! PURPOSE -! Emulates the old split file driver. +! Emulates the old split file driver. ! ! INPUTS -! +! ! prp_id - file access property list identifier -! meta_ext - name of the extension for the metafile +! meta_ext - name of the extension for the metafile ! filename -! meta_plist - identifier of the meta file access property +! meta_plist - identifier of the meta file access property ! list ! raw_ext - name extension for the raw file filename ! raw_plist - identifier of the raw file access property list ! ! OUTPUTS -! -! hdferr - error code +! +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 -! +! port). March 14, 2001 +! ! Fortran90 Interface: SUBROUTINE h5pset_fapl_split_f(prp_id, meta_ext, meta_plist, raw_ext, raw_plist, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier CHARACTER(LEN=*), INTENT(IN) :: meta_ext ! Name of the extension for ! the metafile filename INTEGER(HID_T), INTENT(IN) :: meta_plist ! Identifier of the meta file ! access property list CHARACTER(LEN=*), INTENT(IN) :: raw_ext ! Name extension for the raw file filename - INTEGER(HID_T), INTENT(IN) :: raw_plist ! Identifier of the raw file + INTEGER(HID_T), INTENT(IN) :: raw_plist ! Identifier of the raw file ! access property list INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure @@ -1805,10 +1805,10 @@ CONTAINS IMPORT :: HID_T IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: prp_id - CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(IN) :: meta_ext + CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(IN) :: meta_ext INTEGER(HID_T), INTENT(IN) :: meta_plist CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(IN) :: raw_ext - INTEGER(HID_T), INTENT(IN) :: raw_plist + INTEGER(HID_T), INTENT(IN) :: raw_plist INTEGER :: meta_len, raw_len END FUNCTION h5pset_fapl_split_c END INTERFACE @@ -1818,30 +1818,30 @@ CONTAINS hdferr = h5pset_fapl_split_c(prp_id,meta_len,meta_ext,meta_plist,raw_len,raw_ext,raw_plist) END SUBROUTINE h5pset_fapl_split_f -!****s* H5P/h5pget_split_f +!****s* H5P/h5pget_split_f ! NAME -! h5pget_split_f +! h5pget_split_f ! ! PURPOSE ! NOT AVAILABLE ! ! INPUTS -! +! ! OUTPUTS -! -! hdferr - error code +! +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 -! +! port). March 14, 2001 +! ! SOURCE ! SUBROUTINE h5pget_split_f(prp_id, meta_ext_size, meta_ext, meta_plist,raw_ext_size,& ! raw_ext, raw_plist, hdferr) @@ -1870,37 +1870,37 @@ CONTAINS ! raw_ext_size, raw_ext, raw_plist ) ! END SUBROUTINE h5pget_split_f -!****s* H5P/h5pset_gc_references_f +!****s* H5P/h5pset_gc_references_f ! NAME -! h5pset_gc_references_f +! h5pset_gc_references_f ! ! PURPOSE -! Sets garbage collecting references flag. +! Sets garbage collecting references flag. ! ! INPUTS -! +! ! prp_id - file access property list identifier -! gc_reference - flag for stting garbage collection on +! gc_reference - flag for stting garbage collection on ! and off (1 or 0) ! OUTPUTS -! -! hdferr - error code +! +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 -! -! Fortran90 Interface: +! port). March 14, 2001 +! +! Fortran90 Interface: SUBROUTINE h5pset_gc_references_f (prp_id, gc_reference, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier INTEGER, INTENT(IN) :: gc_reference ! The flag for garbage collecting ! references for the file INTEGER, INTENT(OUT) :: hdferr ! Error code @@ -1919,37 +1919,37 @@ CONTAINS hdferr = h5pset_gc_references_c(prp_id, gc_reference) END SUBROUTINE h5pset_gc_references_f -!****s* H5P/h5pget_gc_references_f +!****s* H5P/h5pget_gc_references_f ! NAME -! h5pget_gc_references_f +! h5pget_gc_references_f ! ! PURPOSE -! Returns garbage collecting references setting. +! Returns garbage collecting references setting. ! ! INPUTS -! +! ! prp_id - file access property list identifier ! OUTPUTS -! -! gc_reference - flag for stting garbage collection on +! +! gc_reference - flag for stting garbage collection on ! and off (1 or 0) -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 -! +! port). March 14, 2001 +! ! Fortran90 Interface: SUBROUTINE h5pget_gc_references_f(prp_id, gc_reference, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier INTEGER, INTENT(OUT) :: gc_reference ! The flag for garbage collecting ! references for the file INTEGER, INTENT(OUT) :: hdferr ! Error code @@ -1964,20 +1964,20 @@ CONTAINS INTEGER, INTENT(OUT) :: gc_reference END FUNCTION h5pget_gc_references_c END INTERFACE - + hdferr = h5pget_gc_references_c(prp_id, gc_reference) END SUBROUTINE h5pget_gc_references_f -!****s* H5P/h5pset_layout_f +!****s* H5P/h5pset_layout_f ! NAME -! h5pset_layout_f +! h5pset_layout_f ! ! PURPOSE -! Sets the type of storage used store the raw data -! for a dataset. +! Sets the type of storage used store the raw data +! for a dataset. ! ! INPUTS -! +! ! prp_id - data creation property list identifier ! layout - type of storage layout for raw data ! possible values are: @@ -1985,24 +1985,24 @@ CONTAINS ! H5D_CONTIGUOUS_F ! H5D_CHUNKED_F ! OUTPUTS -! -! hdferr - error code +! +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 -! +! port). March 14, 2001 +! ! Fortran90 Interface: SUBROUTINE h5pset_layout_f (prp_id, layout, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier INTEGER, INTENT(IN) :: layout ! Type of storage layout for raw data ! possible values are: ! H5D_COMPACT_F @@ -2020,44 +2020,44 @@ CONTAINS INTEGER, INTENT(IN) :: layout END FUNCTION h5pset_layout_c END INTERFACE - + hdferr = h5pset_layout_c(prp_id, layout) END SUBROUTINE h5pset_layout_f -!****s* H5P/h5pget_layout_f +!****s* H5P/h5pget_layout_f ! NAME -! h5pget_layout_f +! h5pget_layout_f ! ! PURPOSE -! Returns the layout of the raw data for a dataset. +! Returns the layout of the raw data for a dataset. ! ! INPUTS -! +! ! prp_id - data creation property list identifier ! OUTPUTS -! +! ! layout - type of storage layout for raw data ! possible values are: ! H5D_COMPACT_F ! H5D_CONTIGUOUS_F ! H5D_CHUNKED_F -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 -! +! port). March 14, 2001 +! ! Fortran90 Interface: SUBROUTINE h5pget_layout_f (prp_id, layout, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier INTEGER, INTENT(OUT) :: layout ! Type of storage layout for raw data ! possible values are: ! H5D_COMPACT_F(0) @@ -2075,31 +2075,31 @@ CONTAINS INTEGER, INTENT(OUT) :: layout END FUNCTION h5pget_layout_c END INTERFACE - + hdferr = h5pget_layout_c(prp_id, layout) END SUBROUTINE h5pget_layout_f -!****s* H5P/h5pset_filter_f +!****s* H5P/h5pset_filter_f ! NAME -! h5pset_filter_f +! h5pset_filter_f ! ! PURPOSE -! Adds a filter to the filter pipeline. +! Adds a filter to the filter pipeline. ! ! INPUTS -! -! prp_id - data creation or transfer property list +! +! prp_id - data creation or transfer property list ! identifier -! filter - filter to be added to the pipeline +! filter - filter to be added to the pipeline ! flags - bit vector specifying certain general ! properties of the filter ! cd_nelmts - number of elements in cd_values ! cd_values - auxiliary data for the filter ! OUTPUTS -! -! hdferr - error code +! +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal @@ -2108,7 +2108,7 @@ CONTAINS ! Fortran90 Interface: SUBROUTINE h5pset_filter_f(prp_id, filter, flags, cd_nelmts, cd_values, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier INTEGER, INTENT(IN) :: filter ! Filter to be added to the pipeline. INTEGER, INTENT(IN) :: flags ! Bit vector specifying certain general ! properties of the filter. @@ -2122,48 +2122,48 @@ CONTAINS BIND(C,NAME='h5pset_filter_c') IMPORT :: HID_T, SIZE_T IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id - INTEGER, INTENT(IN) :: filter - INTEGER, INTENT(IN) :: flags - INTEGER(SIZE_T), INTENT(IN) :: cd_nelmts - INTEGER, DIMENSION(*), INTENT(IN) :: cd_values + INTEGER(HID_T), INTENT(IN) :: prp_id + INTEGER, INTENT(IN) :: filter + INTEGER, INTENT(IN) :: flags + INTEGER(SIZE_T), INTENT(IN) :: cd_nelmts + INTEGER, DIMENSION(*), INTENT(IN) :: cd_values END FUNCTION h5pset_filter_c END INTERFACE - + hdferr = h5pset_filter_c(prp_id, filter, flags, cd_nelmts, cd_values ) END SUBROUTINE h5pset_filter_f -!****s* H5P/h5pget_nfilters_f +!****s* H5P/h5pget_nfilters_f ! NAME -! h5pget_nfilters_f +! h5pget_nfilters_f ! ! PURPOSE -! Returns the number of filters in the pipeline. +! Returns the number of filters in the pipeline. ! ! INPUTS -! -! prp_id - data creation or transfer property list +! +! prp_id - data creation or transfer property list ! identifier ! OUTPUTS -! +! ! nfilters - number of filters in the pipeline -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 -! +! port). March 14, 2001 +! ! Fortran90 Interface: SUBROUTINE h5pget_nfilters_f (prp_id, nfilters, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier INTEGER, INTENT(OUT) :: nfilters ! The number of filters in the pipeline INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure @@ -2177,26 +2177,26 @@ CONTAINS INTEGER, INTENT(OUT) :: nfilters END FUNCTION h5pget_nfilters_c END INTERFACE - + hdferr = h5pget_nfilters_c(prp_id, nfilters) END SUBROUTINE h5pget_nfilters_f -!****s* H5P/h5pget_filter_f +!****s* H5P/h5pget_filter_f ! NAME -! h5pget_filter_f +! h5pget_filter_f ! ! PURPOSE ! Returns information about a filter in a pipeline ! ! INPUTS -! -! prp_id - data creation or transfer property list +! +! prp_id - data creation or transfer property list ! identifier ! filter_number - sequence number within the filter -! pipeline of the filter for which +! pipeline of the filter for which ! information is sought ! OUTPUTS -! +! ! filter_id - filter identification number ! flags - bit vector specifying certain general ! properties of the filter @@ -2204,25 +2204,25 @@ CONTAINS ! cd_values - auxiliary data for the filter ! namelen - number of characters in the name buffer ! name - buffer to retrieve filter name -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 -! +! port). March 14, 2001 +! ! Fortran90 Interface: SUBROUTINE h5pget_filter_f(prp_id, filter_number, flags, cd_nelmts, cd_values, namelen, name, filter_id, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier INTEGER, INTENT(IN) :: filter_number ! Sequence number within the filter - ! pipeline of the filter for which + ! pipeline of the filter for which ! information is sought INTEGER, DIMENSION(*), INTENT(OUT) :: cd_values ! Auxiliary data for the filter. INTEGER, INTENT(OUT) :: flags ! Bit vector specifying certain general @@ -2230,7 +2230,7 @@ CONTAINS INTEGER(SIZE_T), INTENT(INOUT) :: cd_nelmts ! Number of elements in cd_values. INTEGER(SIZE_T), INTENT(IN) :: namelen ! Anticipated number of characters in name. CHARACTER(LEN=*), INTENT(OUT) :: name ! Name of the filter - INTEGER, INTENT(OUT) :: filter_id ! Filter identification number + INTEGER, INTENT(OUT) :: filter_id ! Filter identification number INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure !***** @@ -2247,60 +2247,60 @@ CONTAINS IMPORT :: HID_T, SIZE_T IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: prp_id - INTEGER, INTENT(IN) :: filter_number + INTEGER, INTENT(IN) :: filter_number INTEGER, DIMENSION(*), INTENT(OUT) :: cd_values - INTEGER, INTENT(OUT) :: flags + INTEGER, INTENT(OUT) :: flags INTEGER(SIZE_T), INTENT(INOUT) :: cd_nelmts INTEGER(SIZE_T), INTENT(IN) :: namelen CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(OUT) :: name INTEGER, INTENT(OUT) :: filter_id END FUNCTION h5pget_filter_c END INTERFACE - - hdferr = h5pget_filter_c(prp_id, filter_number, flags, cd_nelmts, & + + hdferr = h5pget_filter_c(prp_id, filter_number, flags, cd_nelmts, & cd_values, namelen, name, filter_id ) END SUBROUTINE h5pget_filter_f -!****s* H5P/h5pset_external_f +!****s* H5P/h5pset_external_f ! NAME -! h5pset_external_f +! h5pset_external_f ! ! PURPOSE -! Adds an external file to the list of external files. +! Adds an external file to the list of external files. ! ! INPUTS -! +! ! prp_id - dataset creation property list identifier ! name - name of external file -! offset - offset in bytes from the beginning of the +! offset - offset in bytes from the beginning of the ! file to the location in the file ! where the data starts -! bytes - size of the external file data. +! bytes - size of the external file data. ! OUTPUTS -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows ! port). March 14, 2001 ! ! Changed type of 'offset' from integer to off_t -- MSB January 9, 2012 -! +! ! Fortran90 Interface: SUBROUTINE h5pset_external_f(prp_id, name, offset, bytes, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier CHARACTER(LEN=*), INTENT(IN) :: name ! Name of an external file - INTEGER(OFF_T), INTENT(IN) :: offset ! Offset, in bytes, from the beginning - ! of the file to the location in the file + INTEGER(OFF_T), INTENT(IN) :: offset ! Offset, in bytes, from the beginning + ! of the file to the location in the file ! where the data starts. - INTEGER(HSIZE_T), INTENT(IN) :: bytes ! Number of bytes reserved in the + INTEGER(HSIZE_T), INTENT(IN) :: bytes ! Number of bytes reserved in the ! file for the data INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure @@ -2320,43 +2320,43 @@ CONTAINS INTEGER(HSIZE_T), INTENT(IN) :: bytes END FUNCTION h5pset_external_c END INTERFACE - + namelen = LEN(name) hdferr = h5pset_external_c(prp_id, name, namelen, offset, bytes) END SUBROUTINE h5pset_external_f -!****s* H5P/h5pget_external_count_f +!****s* H5P/h5pget_external_count_f ! NAME -! h5pget_external_count_f +! h5pget_external_count_f ! ! PURPOSE -! Returns the number of external files for a dataset. +! Returns the number of external files for a dataset. ! ! INPUTS -! +! ! prp_id - dataset creation property list identifier ! OUTPUTS -! -! count - number of external files for the +! +! count - number of external files for the ! specified dataset -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 -! +! port). March 14, 2001 +! ! Fortran90 Interface: SUBROUTINE h5pget_external_count_f (prp_id, count, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier - INTEGER, INTENT(OUT) :: count ! Number of external files for the + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER, INTENT(OUT) :: count ! Number of external files for the ! Specified dataset INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure @@ -2366,60 +2366,60 @@ CONTAINS BIND(C,NAME='h5pget_external_count_c') IMPORT :: HID_T IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id + INTEGER(HID_T), INTENT(IN) :: prp_id INTEGER, INTENT(OUT) :: count END FUNCTION h5pget_external_count_c END INTERFACE - + hdferr = h5pget_external_count_c(prp_id, count) END SUBROUTINE h5pget_external_count_f -!****s* H5P/h5pget_external_f +!****s* H5P/h5pget_external_f ! NAME -! h5pget_external_f +! h5pget_external_f ! ! PURPOSE -! Returns information about an external file. +! Returns information about an external file. ! ! INPUTS -! +! ! prp_id - dataset creation property list identifier ! OUTPUTS -! -! idx - external file index +! +! idx - external file index ! name_size - maximum size of name array -! name - name of the external file +! name - name of the external file ! name - name of external file -! offset - offset in bytes from the beginning of the +! offset - offset in bytes from the beginning of the ! file to the location in the file ! where the data starts ! bytes - size of the external file data -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows ! port). March 14, 2001 ! ! Changed type of 'offset' from integer to off_t -- MSB January 9, 2012 -! +! ! Fortran90 Interface: SUBROUTINE h5pget_external_f(prp_id, idx, name_size, name, offset,bytes, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier INTEGER, INTENT(IN) :: idx ! External file index. - INTEGER(SIZE_T), INTENT(IN) :: name_size ! Maximum length of name array + INTEGER(SIZE_T), INTENT(IN) :: name_size ! Maximum length of name array CHARACTER(LEN=*), INTENT(OUT) :: name ! Name of an external file - INTEGER(OFF_T), INTENT(OUT) :: offset ! Offset, in bytes, from the beginning - ! of the file to the location in the file + INTEGER(OFF_T), INTENT(OUT) :: offset ! Offset, in bytes, from the beginning + ! of the file to the location in the file ! where the data starts. - INTEGER(HSIZE_T), INTENT(OUT) :: bytes ! Number of bytes reserved in the + INTEGER(HSIZE_T), INTENT(OUT) :: bytes ! Number of bytes reserved in the ! file for the data INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure @@ -2431,54 +2431,54 @@ CONTAINS IMPORT :: HID_T, SIZE_T, HSIZE_T, OFF_T IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: prp_id - INTEGER, INTENT(IN) :: idx + INTEGER, INTENT(IN) :: idx INTEGER(SIZE_T), INTENT(IN) :: name_size CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(OUT) :: name INTEGER(OFF_T), INTENT(OUT) :: offset INTEGER(HSIZE_T), INTENT(OUT) :: bytes END FUNCTION h5pget_external_c END INTERFACE - + hdferr = h5pget_external_c(prp_id, idx, name_size, name, offset, bytes) END SUBROUTINE h5pget_external_f -!****s* H5P/h5pset_btree_ratios_f +!****s* H5P/h5pset_btree_ratios_f ! NAME -! h5pset_btree_ratios_f +! h5pset_btree_ratios_f ! ! PURPOSE -! Sets B-tree split ratios for a dataset transfer -! property list. +! Sets B-tree split ratios for a dataset transfer +! property list. ! ! INPUTS -! -! prp_id - the dataset transfer property list -! identifier -! left - the B-tree split ratio for left-most nodes +! +! prp_id - the dataset transfer property list +! identifier +! left - the B-tree split ratio for left-most nodes ! middle - the B-tree split ratio for all other nodes ! right - the B-tree split ratio for right-most nodes ! OUTPUTS -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 -! +! port). March 14, 2001 +! ! Fortran90 Interface: SUBROUTINE h5pset_btree_ratios_f(prp_id, left, middle, right, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier REAL, INTENT(IN) :: left ! The B-tree split ratio for left-most nodes. - REAL, INTENT(IN) :: middle ! The B-tree split ratio for all other nodes - REAL, INTENT(IN) :: right ! The B-tree split ratio for right-most - ! nodes and lone nodes. + REAL, INTENT(IN) :: middle ! The B-tree split ratio for all other nodes + REAL, INTENT(IN) :: right ! The B-tree split ratio for right-most + ! nodes and lone nodes. INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure !***** @@ -2493,7 +2493,7 @@ CONTAINS REAL, INTENT(IN) :: right END FUNCTION h5pset_btree_ratios_c END INTERFACE - + hdferr = h5pset_btree_ratios_c(prp_id, left, middle, right) END SUBROUTINE h5pset_btree_ratios_f @@ -2505,34 +2505,34 @@ CONTAINS ! Gets B-tree split ratios for a dataset transfer property list ! ! INPUTS -! -! prp_id - the dataset transfer property list -! identifier +! +! prp_id - the dataset transfer property list +! identifier ! OUTPUTS -! -! left - the B-tree split ratio for left-most nodes +! +! left - the B-tree split ratio for left-most nodes ! middle - the B-tree split ratio for all other nodes ! right - the B-tree split ratio for right-most nodes -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! August 12, 1999 +! August 12, 1999 ! ! HISTORY -! Explicit Fortran interfaces were added for +! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows -! port). March 14, 2001 -! +! port). March 14, 2001 +! ! Fortran90 Interface: SUBROUTINE h5pget_btree_ratios_f(prp_id, left, middle, right, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier REAL, INTENT(OUT) :: left ! The B-tree split ratio for left-most nodes. - REAL, INTENT(OUT) :: middle ! The B-tree split ratio for all other nodes - REAL, INTENT(OUT) :: right ! The B-tree split ratio for right-most + REAL, INTENT(OUT) :: middle ! The B-tree split ratio for all other nodes + REAL, INTENT(OUT) :: right ! The B-tree split ratio for right-most ! nodes and lone nodes. INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure @@ -2548,43 +2548,43 @@ CONTAINS REAL, INTENT(OUT) :: right END FUNCTION h5pget_btree_ratios_c END INTERFACE - + hdferr = h5pget_btree_ratios_c(prp_id, left, middle, right) END SUBROUTINE h5pget_btree_ratios_f -!****s* H5P/h5pget_fclose_degree_f +!****s* H5P/h5pget_fclose_degree_f ! NAME -! h5pget_fclose_degree_f +! h5pget_fclose_degree_f ! ! PURPOSE ! Returns the degree for the file close behavior. ! ! INPUTS -! +! ! fapl_id - File access property list identifier ! OUTPUTS -! +! ! degree - Possible values are: ! H5F_CLOSE_DEFAULT_F ! H5F_CLOSE_WEAK_F ! H5F_CLOSE_SEMI_F ! H5F_CLOSE_STRONG_F -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! September 26, 2002 +! September 26, 2002 ! ! HISTORY -! -! +! +! ! Fortran90 Interface: SUBROUTINE h5pget_fclose_degree_f(fapl_id, degree, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: fapl_id ! File Access Property list identifier - INTEGER, INTENT(OUT) :: degree ! Possible values are: + INTEGER(HID_T), INTENT(IN) :: fapl_id ! File Access Property list identifier + INTEGER, INTENT(OUT) :: degree ! Possible values are: ! H5F_CLOSE_DEFAULT_F ! H5F_CLOSE_WEAK_F ! H5F_CLOSE_SEMI_F @@ -2601,19 +2601,19 @@ CONTAINS INTEGER, INTENT(OUT) :: degree END FUNCTION h5pget_fclose_degree_c END INTERFACE - - hdferr = h5pget_fclose_degree_c(fapl_id, degree) + + hdferr = h5pget_fclose_degree_c(fapl_id, degree) END SUBROUTINE h5pget_fclose_degree_f -!****s* H5P/h5pset_fclose_degree_f +!****s* H5P/h5pset_fclose_degree_f ! NAME -! h5pset_fclose_degree_f +! h5pset_fclose_degree_f ! ! PURPOSE ! Sets the degree for the file close behavior. ! ! INPUTS -! +! ! fapl_id - file access property list identifier ! degree - Possible values are: ! H5F_CLOSE_DEFAULT_F @@ -2621,19 +2621,19 @@ CONTAINS ! H5F_CLOSE_SEMI_F ! H5F_CLOSE_STRONG_F ! OUTPUTS -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! September 26, 2002 +! September 26, 2002 ! ! Fortran90 Interface: SUBROUTINE h5pset_fclose_degree_f(fapl_id, degree, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: fapl_id ! File Access Property list identifier - INTEGER, INTENT(IN) :: degree ! Possible values are: + INTEGER(HID_T), INTENT(IN) :: fapl_id ! File Access Property list identifier + INTEGER, INTENT(IN) :: degree ! Possible values are: ! H5F_CLOSE_DEFAULT_F ! H5F_CLOSE_WEAK_F ! H5F_CLOSE_SEMI_F @@ -2651,43 +2651,43 @@ CONTAINS END FUNCTION h5pset_fclose_degree_c END INTERFACE - hdferr = h5pset_fclose_degree_c(fapl_id, degree) + hdferr = h5pset_fclose_degree_c(fapl_id, degree) END SUBROUTINE h5pset_fclose_degree_f -!****s* H5P/h5pequal_f +!****s* H5P/h5pequal_f ! NAME -! h5pequal_f +! h5pequal_f ! ! PURPOSE ! Checks if two property lists are eqaul ! ! INPUTS -! +! ! plist1_id - property list identifier ! plist2_id - property list identifier ! OUTPUTS -! +! ! flag - flag, possible values ! .TRUE. or .FALSE. -! hdferr: - error code +! hdferr: - error code ! Success: 0 -! Failure: -1, flag is set to .FALSE. +! Failure: -1, flag is set to .FALSE. ! ! AUTHOR ! Elena Pourmal -! September 30, 2002 +! September 30, 2002 ! ! Fortran90 Interface: SUBROUTINE h5pequal_f(plist1_id, plist2_id, flag, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: plist1_id ! Property list identifier - INTEGER(HID_T), INTENT(IN) :: plist2_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: plist1_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: plist2_id ! Property list identifier LOGICAL, INTENT(OUT) :: flag ! Flag INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure !***** INTEGER :: c_flag - + INTERFACE INTEGER FUNCTION h5pequal_c(plist1_id, plist2_id, c_flag) & BIND(C,NAME='h5pequal_c') @@ -2700,36 +2700,36 @@ CONTAINS END INTERFACE flag = .FALSE. - hdferr = h5pequal_c(plist1_id, plist2_id, c_flag) + hdferr = h5pequal_c(plist1_id, plist2_id, c_flag) IF (c_flag .GT. 0) flag = .TRUE. END SUBROUTINE h5pequal_f !****s* H5P/h5pset_buffer_f ! NAME -! h5pset_buffer_f +! h5pset_buffer_f ! ! PURPOSE ! Sets sixe for conversion buffer ! ! INPUTS ! plist_id - data transfer property list identifier -! size - buffer size +! size - buffer size ! OUTPUTS -! -! hdferr: - error code +! +! hdferr: - error code ! Success: 0 ! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! October 2, 2002 +! October 2, 2002 ! ! Fortran90 Interface: SUBROUTINE h5pset_buffer_f(plist_id, size, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: plist_id ! Data transfer property list identifier - INTEGER(HSIZE_T), INTENT(IN) :: size ! Buffer size in bytes; - ! buffer is allocated and freed by + INTEGER(HID_T), INTENT(IN) :: plist_id ! Data transfer property list identifier + INTEGER(HSIZE_T), INTENT(IN) :: size ! Buffer size in bytes; + ! buffer is allocated and freed by ! the library. INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure @@ -2745,36 +2745,36 @@ CONTAINS END FUNCTION h5pset_buffer_c END INTERFACE - hdferr = h5pset_buffer_c(plist_id, size) + hdferr = h5pset_buffer_c(plist_id, size) END SUBROUTINE h5pset_buffer_f !****s* H5P/h5pget_buffer_f ! NAME -! h5pget_buffer_f +! h5pget_buffer_f ! ! PURPOSE ! Gets size for conversion buffer ! ! INPUTS -! +! ! plist_id - data transfer property list identifier ! OUTPUTS -! -! size - buffer size -! hdferr - error code +! +! size - buffer size +! hdferr - error code ! Success: 0 ! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! October 2, 2002 +! October 2, 2002 ! ! Fortran90 Interface: SUBROUTINE h5pget_buffer_f(plist_id, size, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: plist_id ! Data transfer property list identifier - INTEGER(HSIZE_T), INTENT(OUT) :: size ! Buffer size in bytes; - ! buffer is allocated and freed by + INTEGER(HID_T), INTENT(IN) :: plist_id ! Data transfer property list identifier + INTEGER(HSIZE_T), INTENT(OUT) :: size ! Buffer size in bytes; + ! buffer is allocated and freed by ! the library. INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure @@ -2790,7 +2790,7 @@ CONTAINS END FUNCTION h5pget_buffer_c END INTERFACE - hdferr = h5pget_buffer_c(plist_id, size) + hdferr = h5pget_buffer_c(plist_id, size) END SUBROUTINE h5pget_buffer_f !****s* H5P/h5pfill_value_defined_f @@ -2801,17 +2801,17 @@ CONTAINS ! Check if fill value is defined. ! ! INPUTS -! +! ! plist_id - dataset creation property list identifier ! OUTPUTS -! +! ! flag - fill value status flag ! Possible values are: ! H5D_FILL_VALUE_ERROR_F ! H5D_FILL_VALUE_UNDEFINED_F ! H5D_FILL_VALUE_DEFAULT_F ! H5D_FILL_VALUE_USER_DEFINED_F -! hdferr - error code +! hdferr - error code ! Success: 0 ! Failure: -1 ! @@ -2841,7 +2841,7 @@ CONTAINS END FUNCTION h5pfill_value_defined_c END INTERFACE - hdferr = h5pfill_value_defined_c(plist_id, flag) + hdferr = h5pfill_value_defined_c(plist_id, flag) END SUBROUTINE h5pfill_value_defined_f !****s* H5P/h5pset_alloc_time_f @@ -2852,7 +2852,7 @@ CONTAINS ! Set space allocation time for dataset during creation. ! ! INPUTS -! +! ! plist_id - dataset creation property list identifier ! flag - allocation time flag: ! H5D_ALLOC_TIME_ERROR_F @@ -2861,14 +2861,14 @@ CONTAINS ! H5D_ALLOC_TIME_LATE_F ! H5D_ALLOC_TIME_INCR_F ! OUTPUTS -! -! hdferr - error code +! +! hdferr - error code ! Success: 0 ! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! October 4, 2002 +! October 4, 2002 ! ! Fortran90 Interface: SUBROUTINE h5pset_alloc_time_f(plist_id, flag, hdferr) @@ -2882,8 +2882,8 @@ CONTAINS ! H5D_ALLOC_TIME_INCR_F INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure -!***** - +!***** + INTERFACE INTEGER FUNCTION h5pset_alloc_time_c(plist_id, flag) & BIND(C,NAME='h5pset_alloc_time_c') @@ -2893,8 +2893,8 @@ CONTAINS INTEGER, INTENT(IN) :: flag END FUNCTION h5pset_alloc_time_c END INTERFACE - - hdferr = h5pset_alloc_time_c(plist_id, flag) + + hdferr = h5pset_alloc_time_c(plist_id, flag) END SUBROUTINE h5pset_alloc_time_f !****s* H5P/h5pget_alloc_time_f @@ -2905,23 +2905,23 @@ CONTAINS ! Get space allocation time for dataset during creation. ! ! INPUTS -! +! ! plist_id - dataset creation property list identifier ! OUTPUTS -! +! ! flag - allocation time flag: ! H5D_ALLOC_TIME_ERROR_F ! H5D_ALLOC_TIME_DEFAULT_F ! H5D_ALLOC_TIME_EARLY_F ! H5D_ALLOC_TIME_LATE_F ! H5D_ALLOC_TIME_INCR_F -! hdferr: - error code +! hdferr: - error code ! Success: 0 ! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! October 4, 2002 +! October 4, 2002 ! ! Fortran90 Interface: SUBROUTINE h5pget_alloc_time_f(plist_id, flag, hdferr) @@ -2946,8 +2946,8 @@ CONTAINS INTEGER, INTENT(OUT) :: flag END FUNCTION h5pget_alloc_time_c END INTERFACE - - hdferr = h5pget_alloc_time_c(plist_id, flag) + + hdferr = h5pget_alloc_time_c(plist_id, flag) END SUBROUTINE h5pget_alloc_time_f !****s* H5P/h5pset_fill_time_f @@ -2958,21 +2958,21 @@ CONTAINS ! Set fill value writing time for dataset ! ! INPUTS -! +! ! plist_id - dataset creation property list identifier ! flag - fill time flag: ! H5D_FILL_TIME_ERROR_F ! H5D_FILL_TIME_ALLOC_F ! H5D_FILL_TIME_NEVER_F ! OUTPUTS -! -! hdferr - error code +! +! hdferr - error code ! Success: 0 ! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! October 4, 2002 +! October 4, 2002 ! ! Fortran90 Interface: SUBROUTINE h5pset_fill_time_f(plist_id, flag, hdferr) @@ -2984,7 +2984,7 @@ CONTAINS ! H5D_FILL_TIME_NEVER_F INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure -!***** +!***** INTERFACE INTEGER FUNCTION h5pset_fill_time_c(plist_id, flag) & @@ -2995,8 +2995,8 @@ CONTAINS INTEGER, INTENT(IN) :: flag END FUNCTION h5pset_fill_time_c END INTERFACE - - hdferr = h5pset_fill_time_c(plist_id, flag) + + hdferr = h5pset_fill_time_c(plist_id, flag) END SUBROUTINE h5pset_fill_time_f !****s* H5P/h5pget_fill_time_f @@ -3007,11 +3007,11 @@ CONTAINS ! Get fill value writing time for dataset ! ! INPUTS -! +! ! plist_id - dataset creation property list identifier ! OUTPUTS -! -! hdferr: - error code +! +! hdferr: - error code ! Success: 0 ! Failure: -1 ! OPTIONAL PARAMETERS @@ -3022,7 +3022,7 @@ CONTAINS ! H5D_FILL_TIME_NEVER_F ! AUTHOR ! Elena Pourmal -! October 4, 2002 +! October 4, 2002 ! ! Fortran90 Interface: SUBROUTINE h5pget_fill_time_f(plist_id, flag, hdferr) @@ -3034,8 +3034,8 @@ CONTAINS ! H5D_FILL_TIME_NEVER_F INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure -!***** - +!***** + INTERFACE INTEGER FUNCTION h5pget_fill_time_c(plist_id, flag) & BIND(C,NAME='h5pget_fill_time_c') @@ -3045,36 +3045,36 @@ CONTAINS INTEGER, INTENT(OUT) :: flag END FUNCTION h5pget_fill_time_c END INTERFACE - - hdferr = h5pget_fill_time_c(plist_id, flag) + + hdferr = h5pget_fill_time_c(plist_id, flag) END SUBROUTINE h5pget_fill_time_f -!****s* H5P/ h5pset_meta_block_size_f +!****s* H5P/ h5pset_meta_block_size_f ! NAME -! h5pset_meta_block_size_f +! h5pset_meta_block_size_f ! ! PURPOSE -! Sets the minimum size of metadata block allocations +! Sets the minimum size of metadata block allocations ! ! INPUTS -! +! ! plist_id - file access property list identifier ! size - metatdata block size ! OUTPUTS -! -! hdferr - error code +! +! hdferr - error code ! Success: 0 ! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! October 7, 2002 +! October 7, 2002 ! ! Fortran90 Interface: SUBROUTINE h5pset_meta_block_size_f(plist_id, size, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: plist_id ! File access property list identifier - INTEGER(HSIZE_T), INTENT(IN) :: size ! Block size in bytes; + INTEGER(HID_T), INTENT(IN) :: plist_id ! File access property list identifier + INTEGER(HSIZE_T), INTENT(IN) :: size ! Block size in bytes; INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure !***** @@ -3087,78 +3087,78 @@ CONTAINS INTEGER(HSIZE_T), INTENT(IN) :: size END FUNCTION h5pset_meta_block_size_c END INTERFACE - - hdferr = h5pset_meta_block_size_c(plist_id, size) + + hdferr = h5pset_meta_block_size_c(plist_id, size) END SUBROUTINE h5pset_meta_block_size_f -!****s* H5P/h5pget_meta_block_size_f +!****s* H5P/h5pget_meta_block_size_f ! NAME -! h5pget_meta_block_size_f +! h5pget_meta_block_size_f ! ! PURPOSE -! Gets the minimum size of metadata block allocations +! Gets the minimum size of metadata block allocations ! ! INPUTS -! +! ! plist_id - file access property list identifier ! OUTPUTS -! +! ! size - metatdata block size -! hdferr - error code +! hdferr - error code ! Success: 0 ! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! October 7, 2002 +! October 7, 2002 ! ! Fortran90 Interface: SUBROUTINE h5pget_meta_block_size_f(plist_id, size, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: plist_id ! File access property list identifier - INTEGER(HSIZE_T), INTENT(OUT) :: size ! Block size in bytes; + INTEGER(HID_T), INTENT(IN) :: plist_id ! File access property list identifier + INTEGER(HSIZE_T), INTENT(OUT) :: size ! Block size in bytes; INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure !***** INTERFACE INTEGER FUNCTION h5pget_meta_block_size_c(plist_id, size) & BIND(C,NAME='h5pget_meta_block_size_c') - IMPORT :: HID_T, HSIZE_T + IMPORT :: HID_T, HSIZE_T IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: plist_id INTEGER(HSIZE_T), INTENT(OUT) :: size END FUNCTION h5pget_meta_block_size_c END INTERFACE - - hdferr = h5pget_meta_block_size_c(plist_id, size) + + hdferr = h5pget_meta_block_size_c(plist_id, size) END SUBROUTINE h5pget_meta_block_size_f -!****s* H5P/h5pset_sieve_buf_size_f +!****s* H5P/h5pset_sieve_buf_size_f ! NAME -! h5pset_sieve_buf_size_f +! h5pset_sieve_buf_size_f ! ! PURPOSE ! Sets the maximum size of the data sieve buffer ! ! INPUTS -! +! ! plist_id - file access property list identifier ! size - sieve buffer size ! OUTPUTS -! -! hdferr - error code +! +! hdferr - error code ! Success: 0 ! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! October 7, 2002 +! October 7, 2002 ! ! Fortran90 Interface: SUBROUTINE h5pset_sieve_buf_size_f(plist_id, size, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: plist_id ! File access property list identifier - INTEGER(SIZE_T), INTENT(IN) :: size ! Buffer size in bytes; + INTEGER(HID_T), INTENT(IN) :: plist_id ! File access property list identifier + INTEGER(SIZE_T), INTENT(IN) :: size ! Buffer size in bytes; INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure !***** @@ -3171,36 +3171,36 @@ CONTAINS INTEGER(SIZE_T), INTENT(IN) :: size END FUNCTION h5pset_sieve_buf_size_c END INTERFACE - - hdferr = h5pset_sieve_buf_size_c(plist_id, size) + + hdferr = h5pset_sieve_buf_size_c(plist_id, size) END SUBROUTINE h5pset_sieve_buf_size_f !****s* H5P/h5pget_sieve_buf_size_f ! NAME -! h5pget_sieve_buf_size_f +! h5pget_sieve_buf_size_f ! ! PURPOSE ! Gets the maximum size of the data sieve buffer ! ! INPUTS -! +! ! plist_id - file access property list identifier ! OUTPUTS -! +! ! size - sieve buffer size -! hdferr - error code +! hdferr - error code ! Success: 0 ! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! October 7, 2002 +! October 7, 2002 ! ! Fortran90 Interface: SUBROUTINE h5pget_sieve_buf_size_f(plist_id, size, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: plist_id ! File access property list identifier - INTEGER(SIZE_T), INTENT(OUT) :: size ! Buffer size in bytes + INTEGER(HID_T), INTENT(IN) :: plist_id ! File access property list identifier + INTEGER(SIZE_T), INTENT(OUT) :: size ! Buffer size in bytes INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure !***** @@ -3213,35 +3213,35 @@ CONTAINS INTEGER(SIZE_T), INTENT(OUT) :: size END FUNCTION h5pget_sieve_buf_size_c END INTERFACE - - hdferr = h5pget_sieve_buf_size_c(plist_id, size) + + hdferr = h5pget_sieve_buf_size_c(plist_id, size) END SUBROUTINE h5pget_sieve_buf_size_f -!****s* H5P/h5pset_small_data_block_size_f +!****s* H5P/h5pset_small_data_block_size_f ! NAME -! h5pset_small_data_block_size_f +! h5pset_small_data_block_size_f ! ! PURPOSE ! Sets the minimum size of "small" raw data block ! ! INPUTS -! +! ! plist_id - file access property list identifier ! size - small raw data block size ! OUTPUTS -! -! hdferr - error code +! +! hdferr - error code ! Success: 0 ! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! October 7, 2002 +! October 7, 2002 ! ! Fortran90 Interface: SUBROUTINE h5pset_small_data_block_size_f(plist_id, size, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: plist_id ! File access property list identifier + INTEGER(HID_T), INTENT(IN) :: plist_id ! File access property list identifier INTEGER(HSIZE_T), INTENT(IN) :: size ! Small raw data block size INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure @@ -3256,34 +3256,34 @@ CONTAINS END FUNCTION h5pset_small_data_block_size_c END INTERFACE - hdferr = h5pset_small_data_block_size_c(plist_id, size) + hdferr = h5pset_small_data_block_size_c(plist_id, size) END SUBROUTINE h5pset_small_data_block_size_f -!****s* H5P/h5pget_small_data_block_size_f +!****s* H5P/h5pget_small_data_block_size_f ! NAME -! h5pget_small_data_block_size_f +! h5pget_small_data_block_size_f ! ! PURPOSE ! Gets the minimum size of "small" raw data block ! ! INPUTS -! +! ! plist_id - file access property list identifier ! OUTPUTS -! +! ! size - small raw data block size -! hdferr - error code +! hdferr - error code ! Success: 0 ! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! October 7, 2002 +! October 7, 2002 ! ! Fortran90 Interface: SUBROUTINE h5pget_small_data_block_size_f(plist_id, size, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: plist_id ! File access property list identifier + INTEGER(HID_T), INTENT(IN) :: plist_id ! File access property list identifier INTEGER(HSIZE_T), INTENT(OUT) :: size ! Small raw data block size INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure @@ -3297,35 +3297,35 @@ CONTAINS INTEGER(HSIZE_T), INTENT(OUT) :: size END FUNCTION h5pget_small_data_block_size_c END INTERFACE - - hdferr = h5pget_small_data_block_size_c(plist_id, size) + + hdferr = h5pget_small_data_block_size_c(plist_id, size) END SUBROUTINE h5pget_small_data_block_size_f -!****s* H5P/h5pset_hyper_vector_size_f +!****s* H5P/h5pset_hyper_vector_size_f ! NAME -! h5pset_hyper_vector_size_f +! h5pset_hyper_vector_size_f ! ! PURPOSE ! Set the number of "I/O" vectors (vector size) ! ! INPUTS -! +! ! plist_id - dataset transfer property list identifier ! size - vector size ! OUTPUTS -! -! hdferr - error code +! +! hdferr - error code ! Success: 0 ! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! October 7, 2002 +! October 7, 2002 ! ! Fortran90 Interface: SUBROUTINE h5pset_hyper_vector_size_f(plist_id, size, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: plist_id ! Dataset transfer property list identifier + INTEGER(HID_T), INTENT(IN) :: plist_id ! Dataset transfer property list identifier INTEGER(SIZE_T), INTENT(IN) :: size ! Vector size INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure @@ -3339,35 +3339,35 @@ CONTAINS INTEGER(SIZE_T), INTENT(IN) :: size END FUNCTION h5pset_hyper_vector_size_c END INTERFACE - - hdferr = h5pset_hyper_vector_size_c(plist_id, size) + + hdferr = h5pset_hyper_vector_size_c(plist_id, size) END SUBROUTINE h5pset_hyper_vector_size_f -!****s* H5P/ h5pget_hyper_vector_size_f +!****s* H5P/ h5pget_hyper_vector_size_f ! NAME -! h5pget_hyper_vector_size_f +! h5pget_hyper_vector_size_f ! ! PURPOSE ! Get the number of "I/O" vectors (vector size) ! ! INPUTS -! +! ! plist_id - dataset transfer property list identifier ! OUTPUTS -! +! ! size - vector size -! hdferr - error code +! hdferr - error code ! Success: 0 ! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! October 7, 2002 +! October 7, 2002 ! ! Fortran90 Interface: SUBROUTINE h5pget_hyper_vector_size_f(plist_id, size, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: plist_id ! Dataset transfer property list identifier + INTEGER(HID_T), INTENT(IN) :: plist_id ! Dataset transfer property list identifier INTEGER(SIZE_T), INTENT(OUT) :: size ! Vector size INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure @@ -3382,42 +3382,42 @@ CONTAINS END FUNCTION h5pget_hyper_vector_size_c END INTERFACE - hdferr = h5pget_hyper_vector_size_c(plist_id, size) + hdferr = h5pget_hyper_vector_size_c(plist_id, size) END SUBROUTINE h5pget_hyper_vector_size_f -!****s* H5P/h5pexist_f +!****s* H5P/h5pexist_f ! NAME -! h5pexist_f +! h5pexist_f ! ! PURPOSE -! Queries whether a property name exists in a property list or class. +! Queries whether a property name exists in a property list or class. ! ! INPUTS -! +! ! prp_id - property list identifier to query ! name - name of property to check for ! OUTPUTS -! +! ! flag - logical flag -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! October 9, 2002 +! October 9, 2002 ! ! Fortran90 Interface: SUBROUTINE h5pexist_f(prp_id, name, flag, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier CHARACTER(LEN=*), INTENT(IN) :: name ! Name of property to modify LOGICAL, INTENT(OUT) :: flag ! .TRUE. if exists, .FALSE. otherwise INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure !***** INTEGER :: name_len - + INTERFACE INTEGER FUNCTION h5pexist_c(prp_id, name, name_len) & BIND(C,NAME='h5pexist_c') @@ -3438,43 +3438,43 @@ CONTAINS ENDIF END SUBROUTINE h5pexist_f -!****s* H5P/h5pget_size_f +!****s* H5P/h5pget_size_f ! ! NAME -! h5pget_size_f +! h5pget_size_f ! ! PURPOSE ! Queries the size of a property value in bytes. ! ! INPUTS -! +! ! prp_id - property list identifier to query ! name - name of property to query ! OUTPUTS -! +! ! size - size of property in bytes -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! October 9, 2002 +! October 9, 2002 ! ! HISTORY -! -! +! +! ! Fortran90 Interface: SUBROUTINE h5pget_size_f(prp_id, name, size, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier CHARACTER(LEN=*), INTENT(IN) :: name ! Name of property to query INTEGER(SIZE_T), INTENT(OUT) :: size ! Size in bytes INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure !***** INTEGER :: name_len - + INTERFACE INTEGER FUNCTION h5pget_size_c(prp_id, name, name_len, size) & BIND(C,NAME='h5pget_size_c') @@ -3491,31 +3491,31 @@ CONTAINS hdferr = h5pget_size_c(prp_id, name , name_len, size) END SUBROUTINE h5pget_size_f -!****s* H5P/h5pget_npros_f +!****s* H5P/h5pget_npros_f ! NAME -! h5pget_npros_f +! h5pget_npros_f ! ! PURPOSE ! Queries number of properties in property list or class ! ! INPUTS -! +! ! prp_id - iproperty list identifier to query ! OUTPUTS -! +! ! nprops - number of properties in property object -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! October 9, 2002 +! October 9, 2002 ! ! Fortran90 Interface: SUBROUTINE h5pget_nprops_f(prp_id, nprops, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier INTEGER(SIZE_T), INTENT(OUT) :: nprops ! Number of properties INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure @@ -3532,18 +3532,18 @@ CONTAINS hdferr = h5pget_nprops_c(prp_id, nprops) END SUBROUTINE h5pget_nprops_f -!****s* H5P/h5pget_class_name_f +!****s* H5P/h5pget_class_name_f ! NAME -! h5pget_class_name_f +! h5pget_class_name_f ! ! PURPOSE ! Queries the name of a class. ! ! INPUTS -! +! ! prp_id - property list identifier to query ! OUTPUTS -! +! ! name - name of a class ! size - Actual length of the class name ! NOTE: If provided buffer "name" is smaller, @@ -3551,26 +3551,26 @@ CONTAINS ! provided user buffer. ! hdferr: - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! October 9, 2002 +! October 9, 2002 ! ! HISTORY -! Returned the size of name as an argument -! +! Returned the size of name as an argument +! ! Fortran90 Interface: SUBROUTINE h5pget_class_name_f(prp_id, name, size, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier CHARACTER(LEN=*), INTENT(OUT) :: name ! Buffer to retireve class name INTEGER, INTENT(OUT) :: size ! Actual length of the class name INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure !***** INTEGER :: name_len - + INTERFACE INTEGER FUNCTION h5pget_class_name_c(prp_id, name, name_len) & BIND(C,NAME='h5pget_class_name_c') @@ -3582,42 +3582,42 @@ CONTAINS INTEGER, INTENT(IN) :: name_len END FUNCTION h5pget_class_name_c END INTERFACE - + name_len = LEN(name) size = h5pget_class_name_c(prp_id, name, name_len) - + hdferr = 0 IF(size.LT.0) hdferr = -1 - + END SUBROUTINE h5pget_class_name_f -!****s* H5P/h5pget_class_parent_f +!****s* H5P/h5pget_class_parent_f ! NAME -! h5pget_class_parent_f +! h5pget_class_parent_f ! ! PURPOSE -! Retrieves the parent class of a genric property class. +! Retrieves the parent class of a genric property class. ! ! INPUTS -! +! ! prp_id - property list identifier to query ! OUTPUTS -! +! ! parent_id - identifier of the parent class -! hdferr: - error code +! hdferr: - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! October 9, 2002 +! October 9, 2002 ! ! Fortran90 Interface: SUBROUTINE h5pget_class_parent_f(prp_id, parent_id, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier - INTEGER(HID_T), INTENT(OUT) :: parent_id ! Parent class property list - ! identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(OUT) :: parent_id ! Parent class property list + ! identifier INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure !***** @@ -3633,32 +3633,32 @@ CONTAINS hdferr = h5pget_class_parent_c(prp_id, parent_id) END SUBROUTINE h5pget_class_parent_f -!****s* H5P/h5pisa_class_f +!****s* H5P/h5pisa_class_f ! NAME -! h5pisa_class_f +! h5pisa_class_f ! ! PURPOSE -! Determines whether a property list is a member of a class. +! Determines whether a property list is a member of a class. ! ! INPUTS -! -! plist - property list identifier +! +! plist - property list identifier ! pclass - identifier of the property class ! OUTPUTS -! +! ! flag - .TRUE. if a member, .FALSE. otherwise -! hdferr: - error code +! hdferr: - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! October 9, 2002 +! October 9, 2002 ! ! Fortran90 Interface: SUBROUTINE h5pisa_class_f(plist, pclass, flag, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: plist ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: plist ! Property list identifier INTEGER(HID_T), INTENT(IN) :: pclass ! Class identifier LOGICAL, INTENT(OUT) :: flag ! logical flag INTEGER, INTENT(OUT) :: hdferr ! Error code @@ -3681,40 +3681,40 @@ CONTAINS ENDIF END SUBROUTINE h5pisa_class_f -!****s* H5P/h5pcopy_prop_f +!****s* H5P/h5pcopy_prop_f ! NAME -! h5pcopy_prop_f +! h5pcopy_prop_f ! ! PURPOSE ! Copies a property from one list or class to another. ! ! INPUTS -! +! ! dst_id - Identifier of the destination property list -! src_id - Identifier of the source property list +! src_id - Identifier of the source property list ! name - name of the property to copy ! OUTPUTS -! +! ! hdferr: - error code -! Success: 0 -! Failure: -1 +! Success: 0 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! October 9, 2002 +! October 9, 2002 ! ! Fortran90 Interface: SUBROUTINE h5pcopy_prop_f(dst_id, src_id, name, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: dst_id ! Destination property list - ! identifier - INTEGER(HID_T), INTENT(IN) :: src_id ! Source property list identifier + INTEGER(HID_T), INTENT(IN) :: dst_id ! Destination property list + ! identifier + INTEGER(HID_T), INTENT(IN) :: src_id ! Source property list identifier CHARACTER(LEN=*), INTENT(IN) :: name ! Property name INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure !***** INTEGER :: name_len - + INTERFACE INTEGER FUNCTION h5pcopy_prop_c(dst_id, src_id, name, name_len) & BIND(C,NAME='h5pcopy_prop_c') @@ -3731,27 +3731,27 @@ CONTAINS hdferr = h5pcopy_prop_c(dst_id, src_id, name , name_len) END SUBROUTINE h5pcopy_prop_f -!****s* H5P/h5premove_f +!****s* H5P/h5premove_f ! NAME -! h5premove_f +! h5premove_f ! ! PURPOSE -! Removes a property from a property list. +! Removes a property from a property list. ! ! INPUTS -! +! ! plid - Property list identofoer ! name - name of the property to remove ! OUTPUTS -! +! ! hdferr: - error code -! Success: 0 -! Failure: -1 +! Success: 0 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! October 9, 2002 +! October 9, 2002 ! ! Fortran90 Interface: SUBROUTINE h5premove_f(plid, name, hdferr) @@ -3762,14 +3762,14 @@ CONTAINS ! 0 on success and -1 on failure !***** INTEGER :: name_len - + INTERFACE INTEGER FUNCTION h5premove_c(plid, name, name_len) & BIND(C,NAME='h5premove_c') IMPORT :: C_CHAR IMPORT :: HID_T IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: plid + INTEGER(HID_T), INTENT(IN) :: plid CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(IN) :: name INTEGER, INTENT(IN) :: name_len END FUNCTION h5premove_c @@ -3778,26 +3778,26 @@ CONTAINS hdferr = h5premove_c(plid, name , name_len) END SUBROUTINE h5premove_f -!****s* H5P/h5punregister_f +!****s* H5P/h5punregister_f ! NAME -! h5punregister_f +! h5punregister_f ! ! PURPOSE -! Removes a property from a property list class. +! Removes a property from a property list class. ! ! INPUTS -! +! ! class - Property list class identifier ! name - name of the property to remove ! OUTPUTS -! +! ! hdferr: - error code -! Success: 0 -! Failure: -1 +! Success: 0 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! October 9, 2002 +! October 9, 2002 ! ! Fortran90 Interface: SUBROUTINE h5punregister_f(class, name, hdferr) @@ -3824,25 +3824,25 @@ CONTAINS hdferr = h5punregister_c(class, name , name_len) END SUBROUTINE h5punregister_f -!****s* H5P/h5pclose_class_f +!****s* H5P/h5pclose_class_f ! NAME -! h5pclose_class_f +! h5pclose_class_f ! ! PURPOSE ! Closes an existing property list class. ! ! INPUTS -! +! ! class - Property list class identifier ! OUTPUTS -! -! hdferr - error code -! Success: 0 -! Failure: -1 +! +! hdferr - error code +! Success: 0 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal -! October 9, 2002 +! October 9, 2002 ! ! Fortran90 Interface: SUBROUTINE h5pclose_class_f(class, hdferr) @@ -3862,9 +3862,9 @@ CONTAINS hdferr = h5pclose_class_c(class) END SUBROUTINE h5pclose_class_f -!****s* H5P/h5pset_shuffle_f +!****s* H5P/h5pset_shuffle_f ! NAME -! h5pset_shuffle_f +! h5pset_shuffle_f ! ! PURPOSE ! Sets shuffling filter @@ -3872,9 +3872,9 @@ CONTAINS ! INPUTS ! prp_id - dataset creation property list identifier ! OUTPUTS -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal @@ -3883,7 +3883,7 @@ CONTAINS ! Fortran90 Interface: SUBROUTINE h5pset_shuffle_f(prp_id, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure !***** @@ -3896,26 +3896,26 @@ CONTAINS END FUNCTION h5pset_shuffle_c END INTERFACE hdferr = h5pset_shuffle_c(prp_id) - + END SUBROUTINE h5pset_shuffle_f -!****s* H5P/h5pset_edc_check_f +!****s* H5P/h5pset_edc_check_f ! NAME -! h5pset_edc_check_f +! h5pset_edc_check_f ! ! PURPOSE -! Enables/disables error detecting +! Enables/disables error detecting ! ! INPUTS -! +! ! prp_id - dataset creation property list identifier ! flag - EDC flag; possible values: ! H5Z_DISABLE_EDC_F ! H5Z_ENABLE_EDC_F ! OUTPUTS -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal @@ -3924,7 +3924,7 @@ CONTAINS ! Fortran90 Interface: SUBROUTINE h5pset_edc_check_f(prp_id, flag, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier INTEGER, INTENT(IN) :: flag ! Checksum filter flag INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure @@ -3935,27 +3935,27 @@ CONTAINS IMPORT :: HID_T IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: prp_id - INTEGER, INTENT(IN) :: flag + INTEGER, INTENT(IN) :: flag END FUNCTION h5pset_edc_check_c END INTERFACE hdferr = h5pset_edc_check_c(prp_id, flag) - + END SUBROUTINE h5pset_edc_check_f !****s* H5P/h5pget_edc_check_f ! NAME -! h5pget_edc_check_f +! h5pget_edc_check_f ! ! PURPOSE -! Queries error detecting +! Queries error detecting ! ! INPUTS -! +! ! prp_id - dataset creation property list identifier ! OUTPUTS -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal @@ -3964,7 +3964,7 @@ CONTAINS ! Fortran90 Interface: SUBROUTINE h5pget_edc_check_f(prp_id, flag, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Dataset transfer property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Dataset transfer property list identifier INTEGER, INTENT(OUT) :: flag ! Checksum filter flag ! May have one of the following values: ! H5Z_ERROR_EDC_F @@ -3984,24 +3984,24 @@ CONTAINS END FUNCTION h5pget_edc_check_c END INTERFACE hdferr = h5pget_edc_check_c(prp_id, flag) - + END SUBROUTINE h5pget_edc_check_f !****s* H5P/h5pset_fletcher32_f ! NAME -! h5pset_fletcher32_f +! h5pset_fletcher32_f ! ! PURPOSE -! Sets Fletcher32 checksum of EDC for a dataset creation +! Sets Fletcher32 checksum of EDC for a dataset creation ! property list. ! ! INPUTS -! +! ! prp_id - dataset creation property list identifier ! OUTPUTS -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal @@ -4010,7 +4010,7 @@ CONTAINS ! Fortran90 Interface: SUBROUTINE h5pset_fletcher32_f(prp_id, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure !***** @@ -4028,19 +4028,19 @@ CONTAINS !****s* H5P/ h5pset_family_offset_f ! NAME -! h5pset_family_offset_f +! h5pset_family_offset_f ! ! PURPOSE ! Sets offset for family file driver. ! ! INPUTS -! +! ! prp_id - file creation property list identifier ! offset - file offset ! OUTPUTS -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal @@ -4049,42 +4049,42 @@ CONTAINS ! Fortran90 Interface: SUBROUTINE h5pset_family_offset_f(prp_id, offset, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier INTEGER(HSIZE_T), INTENT(IN) :: offset ! Offset in bytes INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure -!***** +!***** INTERFACE INTEGER FUNCTION h5pset_family_offset_c(prp_id, offset) & BIND(C,NAME='h5pset_family_offset_c') IMPORT :: HID_T, HSIZE_T IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: prp_id - INTEGER(HSIZE_T), INTENT(IN) :: offset + INTEGER(HSIZE_T), INTENT(IN) :: offset END FUNCTION h5pset_family_offset_c END INTERFACE hdferr = h5pset_family_offset_c(prp_id, offset) - + END SUBROUTINE h5pset_family_offset_f !****s* H5P/h5pset_fapl_multi_l ! NAME -! h5pset_fapl_multi_l +! h5pset_fapl_multi_l ! ! PURPOSE -! Sets up use of the multi-file driver. +! Sets up use of the multi-file driver. ! ! INPUTS -! +! ! prp_id - file creation property list identifier ! mem_map - mapping array ! memb_fapl - property list for each memory usage type ! memb_name - names of member file -! relax - flag +! relax - flag ! OUTPUTS -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal @@ -4097,10 +4097,10 @@ CONTAINS INTEGER, DIMENSION(*), INTENT(IN) :: memb_map INTEGER(HID_T), DIMENSION(*), INTENT(IN) :: memb_fapl CHARACTER(LEN=*), DIMENSION(*), INTENT(IN) :: memb_name - REAL, DIMENSION(*), INTENT(IN) :: memb_addr + REAL, DIMENSION(*), INTENT(IN) :: memb_addr LOGICAL, INTENT(IN) :: relax INTEGER, INTENT(OUT) :: hdferr -!***** +!***** INTEGER, DIMENSION(1:H5FD_MEM_NTYPES_F) :: lenm INTEGER :: maxlen INTEGER :: flag = 0 @@ -4113,7 +4113,7 @@ CONTAINS IMPORT :: C_CHAR IMPORT :: HID_T IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! File creation property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! File creation property list identifier INTEGER, DIMENSION(*), INTENT(IN) :: memb_map INTEGER(HID_T), DIMENSION(*), INTENT(IN) :: memb_fapl CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(IN) :: memb_name @@ -4132,21 +4132,21 @@ CONTAINS hdferr = h5pset_fapl_multi_c(prp_id, memb_map, memb_fapl, memb_name, lenm, maxlen, memb_addr, flag) END SUBROUTINE h5pset_fapl_multi_l -!****s* H5P/h5pset_fapl_multi_s +!****s* H5P/h5pset_fapl_multi_s ! NAME -! h5pset_fapl_multi_s +! h5pset_fapl_multi_s ! ! PURPOSE -! Sets up use of the multi-file driver. +! Sets up use of the multi-file driver. ! ! INPUTS -! +! ! prp_id - file creation property list identifier -! relax - flag +! relax - flag ! OUTPUTS -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal @@ -4155,11 +4155,11 @@ CONTAINS ! Fortran90 Interface: SUBROUTINE h5pset_fapl_multi_s(prp_id, relax, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! File creation property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! File creation property list identifier LOGICAL, INTENT(IN) :: relax INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure -!***** +!***** INTEGER :: flag INTERFACE @@ -4167,37 +4167,37 @@ CONTAINS BIND(C,NAME='h5pset_fapl_multi_sc') IMPORT :: HID_T IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! File creation property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! File creation property list identifier INTEGER, INTENT(IN) :: flag END FUNCTION h5pset_fapl_multi_sc END INTERFACE flag = 0 IF (relax) flag = 1 - hdferr = h5pset_fapl_multi_sc(prp_id, flag) - + hdferr = h5pset_fapl_multi_sc(prp_id, flag) + END SUBROUTINE h5pset_fapl_multi_s -!****s* H5P/h5pget_fapl_multi_f +!****s* H5P/h5pget_fapl_multi_f ! NAME -! h5pget_fapl_multi_f +! h5pget_fapl_multi_f ! ! PURPOSE -! Sets up use of the multi-file driver. +! Sets up use of the multi-file driver. ! ! INPUTS -! +! ! prp_id - file creation property list identifier ! OUTPUTS -! +! ! mem_map - mapping array ! memb_fapl - property list for each memory usage type ! memb_name - names of member file -! relax - flag -! hdferr - error code +! relax - flag +! hdferr - error code ! Success: 0 ! Failure: -1 ! ! OPTIONAL PARAMETERS -! maxlen_out - maximum length for memb_name array element +! maxlen_out - maximum length for memb_name array element ! ! AUTHOR ! Elena Pourmal @@ -4206,19 +4206,19 @@ CONTAINS ! Fortran90 Interface: SUBROUTINE h5pget_fapl_multi_f(prp_id, memb_map, memb_fapl, memb_name, memb_addr, relax, hdferr, maxlen_out) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! File creation property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! File creation property list identifier INTEGER, DIMENSION(*), INTENT(OUT) :: memb_map INTEGER(HID_T), DIMENSION(*), INTENT(OUT) :: memb_fapl CHARACTER(LEN=*), DIMENSION(*), INTENT(OUT) :: memb_name REAL, DIMENSION(*), INTENT(OUT) :: memb_addr - INTEGER, OPTIONAL, INTENT(OUT) :: maxlen_out + INTEGER, OPTIONAL, INTENT(OUT) :: maxlen_out LOGICAL, INTENT(OUT) :: relax INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure -!***** +!***** INTEGER, DIMENSION(1:H5FD_MEM_NTYPES_F) :: lenm INTEGER :: maxlen - INTEGER :: c_maxlen_out + INTEGER :: c_maxlen_out INTEGER :: flag INTEGER :: i ! @@ -4229,14 +4229,14 @@ CONTAINS IMPORT :: C_CHAR IMPORT :: HID_T IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! File creation property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! File creation property list identifier INTEGER, DIMENSION(*), INTENT(OUT) :: memb_map INTEGER(HID_T), DIMENSION(*), INTENT(OUT) :: memb_fapl CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(OUT) :: memb_name REAL, DIMENSION(*), INTENT(OUT) :: memb_addr INTEGER, DIMENSION(*) :: lenm INTEGER :: maxlen - INTEGER :: c_maxlen_out + INTEGER :: c_maxlen_out INTEGER, INTENT(OUT) :: flag END FUNCTION h5pget_fapl_multi_c END INTERFACE @@ -4246,20 +4246,20 @@ CONTAINS lenm(i) = LEN_TRIM(memb_name(i)) ENDDO hdferr = h5pget_fapl_multi_c(prp_id, memb_map, memb_fapl, memb_name, lenm, maxlen, memb_addr, flag, c_maxlen_out) - + relax = .TRUE. IF(flag .EQ. 0) relax = .FALSE. IF(PRESENT(maxlen_out)) maxlen_out = c_maxlen_out END SUBROUTINE h5pget_fapl_multi_f -!****s* H5P/h5pset_szip_f +!****s* H5P/h5pset_szip_f ! NAME -! h5pset_szip_f +! h5pset_szip_f ! ! PURPOSE ! Sets up use of szip compression ! ! INPUTS -! +! ! prp_id - dataset creation property list identifier ! options_mask - A bit-mask conveying the desired SZIP options. ! Current valid values in Fortran are: @@ -4267,25 +4267,25 @@ CONTAINS ! H5_SZIP_NN_OM_F ! pixels_per_block - szip parameters ! OUTPUTS -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal ! April 10 2003 ! ! Fortran90 Interface: - SUBROUTINE h5pset_szip_f(prp_id, options_mask, pixels_per_block, hdferr) + SUBROUTINE h5pset_szip_f(prp_id, options_mask, pixels_per_block, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Dataset creation property - ! list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Dataset creation property + ! list identifier INTEGER, INTENT(IN) :: options_mask ! A bit-mask conveying the desired ! SZIP options ! Current valid values in Fortran are: ! H5_SZIP_EC_OM_F ! H5_SZIP_NN_OM_F - INTEGER, INTENT(IN) :: pixels_per_block ! The number of pixels or data elements + INTEGER, INTENT(IN) :: pixels_per_block ! The number of pixels or data elements ! in each data block INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure @@ -4295,33 +4295,33 @@ CONTAINS BIND(C,NAME='h5pset_szip_c') IMPORT :: HID_T IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! File creation property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! File creation property list identifier INTEGER, INTENT(IN) :: options_mask INTEGER, INTENT(IN) :: pixels_per_block END FUNCTION h5pset_szip_c END INTERFACE - hdferr = h5pset_szip_c(prp_id, options_mask, pixels_per_block) - + hdferr = h5pset_szip_c(prp_id, options_mask, pixels_per_block) + END SUBROUTINE h5pset_szip_f -!****s* H5P/h5pall_filters_avail_f +!****s* H5P/h5pall_filters_avail_f ! NAME -! h5pall_filters_avail_f +! h5pall_filters_avail_f ! ! PURPOSE ! Checks if all filters set in the dataset creation ! property list are available ! ! INPUTS -! +! ! prp_id - data creation property list identifier ! OUTPUTS -! +! ! flag - .TRUE. if all filters are available ! .FALSE. otherwise -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal @@ -4330,13 +4330,13 @@ CONTAINS ! Fortran90 Interface: SUBROUTINE h5pall_filters_avail_f(prp_id, flag, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Dataset creation property - ! list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Dataset creation property + ! list identifier LOGICAL, INTENT(OUT) :: flag ! .TRUE. if all filters are available ! .FALSE. otherwise INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure -!***** +!***** INTEGER :: status INTERFACE @@ -4349,24 +4349,24 @@ CONTAINS END FUNCTION h5pall_filters_avail_c END INTERFACE flag = .TRUE. - hdferr = h5pall_filters_avail_c(prp_id, status) + hdferr = h5pall_filters_avail_c(prp_id, status) IF (status .EQ. 0 ) flag = .FALSE. - + END SUBROUTINE h5pall_filters_avail_f !****s* H5P/h5pget_filter_by_id_f ! NAME -! h5pget_filter_by_id_f +! h5pget_filter_by_id_f ! ! PURPOSE ! Returns information about a filter in a pipeline ! ! INPUTS -! -! prp_id - data creation or transfer property list +! +! prp_id - data creation or transfer property list ! identifier ! OUTPUTS -! +! ! filter_id - filter identifier ! flags - bit vector specifying certain general ! properties of the filter @@ -4374,9 +4374,9 @@ CONTAINS ! cd_values - auxiliary data for the filter ! namelen - number of characters in the name buffer ! name - buffer to retrieve filter name -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal @@ -4385,7 +4385,7 @@ CONTAINS ! Fortran90 Interface: SUBROUTINE h5pget_filter_by_id_f(prp_id, filter_id, flags, cd_nelmts, cd_values, namelen, name, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier INTEGER, INTENT(IN) :: filter_id ! Filter identifier INTEGER(SIZE_T), INTENT(INOUT) :: cd_nelmts ! Number of elements in cd_values. INTEGER, DIMENSION(*), INTENT(OUT) :: cd_values ! Auxiliary data for the filter. @@ -4404,29 +4404,29 @@ CONTAINS IMPORT :: HID_T, SIZE_T IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: prp_id - INTEGER, INTENT(IN) :: filter_id + INTEGER, INTENT(IN) :: filter_id INTEGER, DIMENSION(*), INTENT(OUT) :: cd_values - INTEGER, INTENT(OUT) :: flags + INTEGER, INTENT(OUT) :: flags INTEGER(SIZE_T), INTENT(INOUT) :: cd_nelmts INTEGER(SIZE_T), INTENT(IN) :: namelen CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(OUT) :: name END FUNCTION h5pget_filter_by_id_c END INTERFACE - - hdferr = h5pget_filter_by_id_c(prp_id, filter_id, flags, cd_nelmts, & + + hdferr = h5pget_filter_by_id_c(prp_id, filter_id, flags, cd_nelmts, & cd_values, namelen, name) END SUBROUTINE h5pget_filter_by_id_f !****s* H5P/h5pmodify_filter_f ! NAME -! h5pmodify_filter_f +! h5pmodify_filter_f ! ! PURPOSE -! Adds a filter to the filter pipeline. +! Adds a filter to the filter pipeline. ! ! INPUTS -! -! prp_id - data creation or transfer property list +! +! prp_id - data creation or transfer property list ! identifier ! filter - filter to be modified ! flags - bit vector specifying certain general @@ -4434,9 +4434,9 @@ CONTAINS ! cd_nelmts - number of elements in cd_values ! cd_values - auxiliary data for the filter ! OUTPUTS -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Elena Pourmal @@ -4445,7 +4445,7 @@ CONTAINS ! Fortran90 Interface: SUBROUTINE h5pmodify_filter_f(prp_id, filter, flags, cd_nelmts, cd_values, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier + INTEGER(HID_T), INTENT(IN) :: prp_id ! Property list identifier INTEGER, INTENT(IN) :: filter ! Filter to be modified INTEGER, INTENT(IN) :: flags ! Bit vector specifying certain general ! properties of the filter @@ -4459,33 +4459,33 @@ CONTAINS BIND(C,NAME='h5pmodify_filter_c') IMPORT :: HID_T, SIZE_T IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id - INTEGER, INTENT(IN) :: filter - INTEGER, INTENT(IN) :: flags - INTEGER(SIZE_T), INTENT(IN) :: cd_nelmts - INTEGER, DIMENSION(*), INTENT(IN) :: cd_values + INTEGER(HID_T), INTENT(IN) :: prp_id + INTEGER, INTENT(IN) :: filter + INTEGER, INTENT(IN) :: flags + INTEGER(SIZE_T), INTENT(IN) :: cd_nelmts + INTEGER, DIMENSION(*), INTENT(IN) :: cd_values END FUNCTION h5pmodify_filter_c END INTERFACE - + hdferr = h5pmodify_filter_c(prp_id, filter, flags, cd_nelmts, cd_values ) END SUBROUTINE h5pmodify_filter_f -!****s* H5P/h5premove_filter_f +!****s* H5P/h5premove_filter_f ! NAME -! h5premove_filter_f +! h5premove_filter_f ! ! PURPOSE -! Delete one or more filters from the filter pipeline. +! Delete one or more filters from the filter pipeline. ! ! INPUTS -! -! prp_id - data creation or transfer property list +! +! prp_id - data creation or transfer property list ! identifier ! filter - filter to be removed ! OUTPUTS -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! Quincey Koziol @@ -4505,39 +4505,39 @@ CONTAINS BIND(C,NAME='h5premove_filter_c') IMPORT :: HID_T IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id - INTEGER, INTENT(IN) :: filter + INTEGER(HID_T), INTENT(IN) :: prp_id + INTEGER, INTENT(IN) :: filter END FUNCTION h5premove_filter_c END INTERFACE - + hdferr = h5premove_filter_c(prp_id, filter) END SUBROUTINE h5premove_filter_f !****s* H5P/H5Pget_attr_phase_change_f ! NAME -! H5Pget_attr_phase_change_f +! H5Pget_attr_phase_change_f ! ! PURPOSE -! Retrieves attribute storage phase change thresholds +! Retrieves attribute storage phase change thresholds ! ! INPUTS -! +! ! ocpl_id - Object (dataset or group) creation property list identifier ! OUTPUTS -! +! ! max_compact - Maximum number of attributes to be stored in compact storage ! (Default: 8) ! min_dense - Minimum number of attributes to be stored in dense storage ! (Default: 6) -! hdferr - Error code +! hdferr - Error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! M. Scot Breitenfeld ! January, 2008 ! -! Fortran90 Interface: +! Fortran90 Interface: SUBROUTINE h5pget_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: ocpl_id ! Object (dataset or group) creation property list identifier @@ -4563,28 +4563,28 @@ CONTAINS hdferr = h5pget_attr_phase_change_c(ocpl_id, max_compact, min_dense) END SUBROUTINE h5pget_attr_phase_change_f -!****s* H5P/H5Pset_attr_creation_order_f +!****s* H5P/H5Pset_attr_creation_order_f ! NAME -! H5Pset_attr_creation_order_f +! H5Pset_attr_creation_order_f ! ! PURPOSE ! Sets tracking and indexing of attribute creation order ! ! INPUTS -! +! ! ocpl_id - Object creation property list identifier ! crt_order_flags - Flags specifying whether to track and index attribute creation order ! OUTPUTS ! -! hdferr - Error code +! hdferr - Error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! M. Scot Breitenfeld ! January, 2008 ! -! Fortran90 Interface: +! Fortran90 Interface: SUBROUTINE h5pset_attr_creation_order_f(ocpl_id, crt_order_flags , hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: ocpl_id ! Object (dataset or group) creation property list identifier @@ -4606,36 +4606,36 @@ CONTAINS hdferr = H5Pset_attr_creation_order_c(ocpl_id, crt_order_flags) END SUBROUTINE h5pset_attr_creation_order_f -!****s* H5P/H5Pset_shared_mesg_nindexes_f +!****s* H5P/H5Pset_shared_mesg_nindexes_f ! NAME -! H5Pset_shared_mesg_nindexes_f +! H5Pset_shared_mesg_nindexes_f ! ! PURPOSE -! Sets number of shared object header message indexes +! Sets number of shared object header message indexes ! ! INPUTS -! +! ! plist_id - file creation property list ! nindexes - Number of shared object header message indexes to be available in files created with this property list ! OUTPUTS ! -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! M. Scot Breitenfeld ! January, 2008 ! -! Fortran90 Interface: +! Fortran90 Interface: SUBROUTINE h5pset_shared_mesg_nindexes_f( plist_id, nindexes, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: plist_id ! File creation property list - INTEGER, INTENT(IN) :: nindexes ! Number of shared object header message indexes + INTEGER, INTENT(IN) :: nindexes ! Number of shared object header message indexes ! available in files created WITH this property list INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure -!***** +!***** ! ! MS FORTRAN needs explicit interface for C functions called here. ! @@ -4662,7 +4662,7 @@ CONTAINS ! Configures the specified shared object header message index ! ! INPUTS -! +! ! fcpl_id - File creation property list identifier. ! index_num - Index being configured. ! mesg_type_flags - Types of messages that should be stored in this index. @@ -4670,15 +4670,15 @@ CONTAINS ! ! OUTPUTS ! -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! M. Scot Breitenfeld ! January, 2008 ! -! Fortran90 Interface: +! Fortran90 Interface: SUBROUTINE h5pset_shared_mesg_index_f(fcpl_id, index_num, mesg_type_flags, min_mesg_size, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: fcpl_id ! file creation property list @@ -4687,7 +4687,7 @@ CONTAINS INTEGER, INTENT(IN) :: min_mesg_size ! Minimum message size. INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure -!***** +!***** ! ! MS FORTRAN needs explicit interface for C functions called here. ! @@ -4696,7 +4696,7 @@ CONTAINS BIND(C,NAME='h5pset_shared_mesg_index_c') IMPORT :: HID_T IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: fcpl_id + INTEGER(HID_T), INTENT(IN) :: fcpl_id INTEGER, INTENT(IN) :: index_num INTEGER, INTENT(IN) :: mesg_type_flags INTEGER, INTENT(IN) :: min_mesg_size @@ -4721,22 +4721,22 @@ CONTAINS ! OUTPUTS ! ! crt_order_flags - Flags specifying whether to track and index attribute creation order -! hdferr - Error code +! hdferr - Error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! M. Scot Breitenfeld ! February, 2008 ! -! Fortran90 Interface: +! Fortran90 Interface: SUBROUTINE h5pget_attr_creation_order_f(ocpl_id, crt_order_flags, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: ocpl_id ! Object (group or dataset) creation property list identifier - INTEGER, INTENT(OUT) :: crt_order_flags ! Flags specifying whether to track and index attribute creation order + INTEGER(HID_T), INTENT(IN) :: ocpl_id ! Object (group or dataset) creation property list identifier + INTEGER, INTENT(OUT) :: crt_order_flags ! Flags specifying whether to track and index attribute creation order INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure -!***** +!***** ! ! MS FORTRAN needs explicit interface for C functions called here. ! @@ -4759,7 +4759,7 @@ CONTAINS ! H5Pget_libver_bounds_f ! ! PURPOSE -! Retrieves the lower and upper bounds on the HDF5 library release versions that indirectly +! Retrieves the lower and upper bounds on the HDF5 library release versions that indirectly ! determine the object format versions used when creating objects in the file. ! ! INPUTS @@ -4828,15 +4828,15 @@ CONTAINS ! ! OUTPUTS ! -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! M. Scot Breitenfeld ! February 18, 2008 ! -! Fortran90 Interface: +! Fortran90 Interface: SUBROUTINE h5pset_libver_bounds_f(fapl_id, low, high, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: fapl_id ! File access property list identifier @@ -4867,9 +4867,9 @@ CONTAINS END SUBROUTINE h5pset_libver_bounds_f -!****s* H5P/H5Pset_link_creation_order_f +!****s* H5P/H5Pset_link_creation_order_f ! NAME -! H5Pset_link_creation_order_f +! H5Pset_link_creation_order_f ! ! PURPOSE ! Sets creation order tracking and indexing for links in a group. @@ -4881,15 +4881,15 @@ CONTAINS ! ! OUTPUTS ! -! hdferr - Error code +! hdferr - Error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! M. Scot Breitenfeld ! February 18, 2008 ! -! Fortran90 Interface: +! Fortran90 Interface: SUBROUTINE h5pset_link_creation_order_f(gcpl_id, crt_order_flags, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: gcpl_id ! File access property list identifier @@ -4920,21 +4920,21 @@ CONTAINS ! Queries the settings for conversion between compact and dense groups. ! ! INPUTS -! +! ! gcpl_id - Group creation property list identifier ! OUTPUTS -! +! ! max_compact - Maximum number of attributes to be stored in compact storage ! min_dense - Minimum number of attributes to be stored in dense storage -! hdferr - Error code +! hdferr - Error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! M. Scot Breitenfeld ! February 20, 2008 ! -! Fortran90 Interface: +! Fortran90 Interface: SUBROUTINE h5pget_link_phase_change_f(gcpl_id, max_compact, min_dense, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: gcpl_id ! Group creation property list identifier @@ -4958,37 +4958,37 @@ CONTAINS hdferr = h5pget_link_phase_change_c(gcpl_id, max_compact, min_dense) END SUBROUTINE h5pget_link_phase_change_f -!****s* H5P/H5Pget_obj_track_times_f +!****s* H5P/H5Pget_obj_track_times_f ! NAME -! H5Pget_obj_track_times_f +! H5Pget_obj_track_times_f ! ! PURPOSE ! Returns whether times are tracked for an object. ! ! INPUTS -! +! ! plist_id - property list id ! flag - object timestamp setting ! .TRUE.,.FALSE. ! OUTPUTS ! -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! M. Scot Breitenfeld ! February 22, 2008 ! -! Fortran90 Interface: +! Fortran90 Interface: SUBROUTINE h5pget_obj_track_times_f(plist_id, flag, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: plist_id ! Dataset creation property - ! list identifier + INTEGER(HID_T), INTENT(IN) :: plist_id ! Dataset creation property + ! list identifier LOGICAL, INTENT(OUT) :: flag ! Object timestamp setting INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure -!***** +!***** INTEGER :: status ! ! MS FORTRAN needs explicit interface for C functions called here. @@ -4997,7 +4997,7 @@ CONTAINS INTEGER FUNCTION h5pget_obj_track_times_c(plist_id, status) & BIND(C,NAME='h5pget_obj_track_times_c') IMPORT :: HID_T - INTEGER(HID_T), INTENT(IN) :: plist_id ! File creation property list identifier + INTEGER(HID_T), INTENT(IN) :: plist_id ! File creation property list identifier INTEGER, INTENT(OUT) :: status END FUNCTION h5pget_obj_track_times_c END INTERFACE @@ -5007,9 +5007,9 @@ CONTAINS END SUBROUTINE h5pget_obj_track_times_f -!****s* H5P/H5Pset_obj_track_times_f +!****s* H5P/H5Pset_obj_track_times_f ! NAME -! H5Pset_obj_track_times_f +! H5Pset_obj_track_times_f ! ! PURPOSE ! Set whether the birth, access, modification & change times for @@ -5029,22 +5029,22 @@ CONTAINS ! epoch) when queried. ! ! INPUTS -! +! ! plist_id - property list id ! flag - object timestamp setting ! .TRUE.,.FALSE. ! OUTPUTS ! -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! M. Scot Breitenfeld ! February 22, 2008 -! -! -! Fortran90 Interface: +! +! +! Fortran90 Interface: SUBROUTINE h5pset_obj_track_times_f(plist_id, flag, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: plist_id ! Dataset creation property @@ -5052,7 +5052,7 @@ CONTAINS LOGICAL, INTENT(IN) :: flag ! Object timestamp setting INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure -!***** +!***** INTEGER :: status ! ! MS FORTRAN needs explicit interface for C functions called here. @@ -5062,7 +5062,7 @@ CONTAINS BIND(C,NAME='h5pset_obj_track_times_c') IMPORT :: HID_T IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: plist_id ! File creation property list identifier + INTEGER(HID_T), INTENT(IN) :: plist_id ! File creation property list identifier INTEGER, INTENT(IN) :: status END FUNCTION h5pset_obj_track_times_c END INTERFACE @@ -5082,22 +5082,22 @@ CONTAINS ! Specifies in property list whether to create missing intermediate groups. ! ! INPUTS -! +! ! lcpl_id - Link creation property list identifier -! crt_intermed_group - crt_intermed_group specifying whether -! to create intermediate groups upon the creation +! crt_intermed_group - crt_intermed_group specifying whether +! to create intermediate groups upon the creation ! of an object ! OUTPUTS ! -! hdferr - Error code +! hdferr - Error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! M. Scot Breitenfeld ! February 22, 2008 ! -! HISTORY +! HISTORY ! The long subroutine name (>31) on older f90 compilers causes problems ! so had to shorten the name ! Fortran90 Interface: @@ -5137,15 +5137,15 @@ CONTAINS ! OUTPUTS ! ! crt_order_flags - Creation order flag(s) -! hdferr - Error code +! hdferr - Error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! M. Scot Breitenfeld ! March 3, 2008 ! -! Fortran90 Interface: +! Fortran90 Interface: SUBROUTINE h5pget_link_creation_order_f(gcpl_id, crt_order_flags, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: gcpl_id ! Group creation property list identifier @@ -5183,15 +5183,15 @@ CONTAINS ! H5T_CSET_UTF8_F -> UTF-8 Unicode encoding ! ! OUTPUTS -! hdferr - Error code +! hdferr - Error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! M. Scot Breitenfeld ! March 3, 2008 ! -! Fortran90 Interface: +! Fortran90 Interface: SUBROUTINE h5pset_char_encoding_f(plist_id, encoding, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: plist_id ! Property list identifier @@ -5232,15 +5232,15 @@ CONTAINS ! encoding - Valid values for encoding are: ! H5T_CSET_ASCII_F -> US ASCII ! H5T_CSET_UTF8_F -> UTF-8 Unicode encoding -! hdferr - Error code +! hdferr - Error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! M. Scot Breitenfeld ! March 3, 2008 ! -! Fortran90 Interface: +! Fortran90 Interface: SUBROUTINE h5pget_char_encoding_f(plist_id, encoding, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: plist_id ! Property list identifier @@ -5268,20 +5268,20 @@ CONTAINS !****s* H5P/h5pset_copy_object_f ! NAME -! h5pset_copy_object_f +! h5pset_copy_object_f ! ! PURPOSE ! Sets properties to be used when an object is copied. ! ! INPUTS -! +! ! ocp_plist_id - Object copy property list identifier ! copy_options - Copy option(s) to be set ! OUTPUTS -! -! hdferr - error code +! +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! M. Scot Breitenfeld @@ -5289,8 +5289,8 @@ CONTAINS ! ! HISTORY ! -! -! Fortran90 Interface: +! +! Fortran90 Interface: SUBROUTINE h5pset_copy_object_f(ocp_plist_id, copy_options, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: ocp_plist_id ! Object copy property list identifier @@ -5317,20 +5317,20 @@ CONTAINS !****s* H5P/h5pget_copy_object_f ! NAME -! h5pget_copy_object_f +! h5pget_copy_object_f ! ! PURPOSE ! Retrieves the properties to be used when an object is copied. ! ! INPUTS -! +! ! ocp_plist_id - Object copy property list identifier ! OUTPUTS -! +! ! copy_options - Copy option(s) to be get -! hdferr - Error code +! hdferr - Error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! M. Scot Breitenfeld @@ -5338,14 +5338,14 @@ CONTAINS ! ! HISTORY ! -! +! ! Fortran90 Interface: SUBROUTINE h5pget_copy_object_f(ocp_plist_id, copy_options, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: ocp_plist_id ! Object copy property list identifier INTEGER, INTENT(OUT) :: copy_options ! Valid copy options returned are: ! H5O_COPY_SHALLOW_HIERARCHY_F - ! H5O_COPY_EXPAND_SOFT_LINK_F + ! H5O_COPY_EXPAND_SOFT_LINK_F ! H5O_COPY_EXPAND_EXT_LINK_F ! H5O_COPY_EXPAND_REFERENCE_F ! H5O_COPY_WITHOUT_ATTR_FLAG_F @@ -5364,23 +5364,23 @@ CONTAINS hdferr = h5pget_copy_object_c(ocp_plist_id, copy_options) END SUBROUTINE h5pget_copy_object_f -!****s* H5P/h5pget_data_transform_f +!****s* H5P/h5pget_data_transform_f ! NAME -! h5pget_data_transform_f +! h5pget_data_transform_f ! ! PURPOSE ! Retrieves a data transform expression. ! ! INPUTS -! +! ! plist_id - Identifier of the property list or class ! OUTPUTS -! +! ! expression - buffer to hold transform expression ! hdferr - Error code ! Success: Actual length of the expression -! If provided buffer "expression" is -! smaller, than expression will be +! If provided buffer "expression" is +! smaller, than expression will be ! truncated to fit into ! provided user buffer ! Failure: -1 @@ -5400,7 +5400,7 @@ SUBROUTINE h5pget_data_transform_f(plist_id, expression, hdferr, size) INTEGER(SIZE_T), INTENT(OUT), OPTIONAL :: size ! Registered size of the transform expression INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure -!***** +!***** INTEGER :: expression_len INTEGER(SIZE_T) :: size_default @@ -5410,8 +5410,8 @@ SUBROUTINE h5pget_data_transform_f(plist_id, expression, hdferr, size) IMPORT :: C_CHAR IMPORT :: HID_T, SIZE_T IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: plist_id - CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(OUT) :: expression + INTEGER(HID_T), INTENT(IN) :: plist_id + CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(OUT) :: expression INTEGER(SIZE_T) :: size_default INTEGER :: expression_len END FUNCTION h5pget_data_transform_c @@ -5426,19 +5426,19 @@ SUBROUTINE h5pget_data_transform_f(plist_id, expression, hdferr, size) END SUBROUTINE h5pget_data_transform_f -!****s* H5P/h5pset_data_transform_f +!****s* H5P/h5pset_data_transform_f ! NAME -! h5pset_data_transform_f +! h5pset_data_transform_f ! ! PURPOSE ! Sets a data transform expression. ! ! INPUTS -! -! plist_id - Identifier of the property list or class +! +! plist_id - Identifier of the property list or class ! expression - Buffer to hold transform expression ! OUTPUTS -! +! ! hdferr - error code ! Success: 0 ! Failure: -1 @@ -5454,7 +5454,7 @@ SUBROUTINE h5pget_data_transform_f(plist_id, expression, hdferr, size) CHARACTER(LEN=*), INTENT(IN) :: expression ! Buffer to hold transform expression INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure -!***** +!***** INTEGER :: expression_len INTERFACE @@ -5463,7 +5463,7 @@ SUBROUTINE h5pget_data_transform_f(plist_id, expression, hdferr, size) IMPORT :: C_CHAR IMPORT :: HID_T IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: plist_id + INTEGER(HID_T), INTENT(IN) :: plist_id CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(IN) :: expression INTEGER :: expression_len END FUNCTION h5pset_data_transform_c @@ -5474,15 +5474,15 @@ SUBROUTINE h5pget_data_transform_f(plist_id, expression, hdferr, size) END SUBROUTINE h5pset_data_transform_f -!****s* H5P/H5Pget_local_heap_size_hint_f +!****s* H5P/H5Pget_local_heap_size_hint_f ! NAME -! H5Pget_local_heap_size_hint_f +! H5Pget_local_heap_size_hint_f ! ! PURPOSE ! Queries the local heap size hint for original-style groups. ! ! INPUTS -! +! ! gcpl_id - Group creation property list identifier ! OUTPUTS ! @@ -5517,18 +5517,18 @@ SUBROUTINE h5pget_data_transform_f(plist_id, expression, hdferr, size) END SUBROUTINE h5pget_local_heap_size_hint_f -!****s* H5P/H5Pget_est_link_info_f +!****s* H5P/H5Pget_est_link_info_f ! NAME -! H5Pget_est_link_info_f +! H5Pget_est_link_info_f ! ! PURPOSE ! Queries data required to estimate required local heap or object header size. ! ! INPUTS -! +! ! gcpl_id - Group creation property list identifier ! OUTPUTS -! +! ! est_num_entries - Estimated number of links to be inserted into group ! est_name_len - Estimated average length of link names ! hdferr - Error code @@ -5541,11 +5541,11 @@ SUBROUTINE h5pget_data_transform_f(plist_id, expression, hdferr, size) ! ! HISTORY ! -! +! ! Fortran90 Interface: SUBROUTINE h5pget_est_link_info_f(gcpl_id, est_num_entries, est_name_len, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: gcpl_id ! Group creation property list identifier + INTEGER(HID_T), INTENT(IN) :: gcpl_id ! Group creation property list identifier INTEGER, INTENT(OUT) :: est_num_entries ! Estimated number of links to be inserted into group INTEGER, INTENT(OUT) :: est_name_len ! Estimated average length of link names INTEGER, INTENT(OUT) :: hdferr ! Error code @@ -5556,7 +5556,7 @@ SUBROUTINE h5pget_data_transform_f(plist_id, expression, hdferr, size) BIND(C,NAME='h5pget_est_link_info_c') IMPORT :: HID_T IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: gcpl_id + INTEGER(HID_T), INTENT(IN) :: gcpl_id INTEGER, INTENT(OUT) :: est_num_entries INTEGER, INTENT(OUT) :: est_name_len END FUNCTION h5pget_est_link_info_c @@ -5566,15 +5566,15 @@ SUBROUTINE h5pget_data_transform_f(plist_id, expression, hdferr, size) END SUBROUTINE h5pget_est_link_info_f -!****s* H5P/H5Pset_local_heap_size_hint_f +!****s* H5P/H5Pset_local_heap_size_hint_f ! NAME -! H5Pset_local_heap_size_hint_f +! H5Pset_local_heap_size_hint_f ! ! PURPOSE ! Sets the local heap size hint for original-style groups. ! ! INPUTS -! +! ! gcpl_id - Group creation property list identifier ! size_hint - Hint for size of local heap ! OUTPUTS @@ -5598,7 +5598,7 @@ SUBROUTINE h5pget_data_transform_f(plist_id, expression, hdferr, size) INTERFACE INTEGER FUNCTION h5pset_local_heap_size_hint_c(gcpl_id, size_hint) & BIND(C,NAME='h5pset_local_heap_size_hint_c') - IMPORT :: HID_T, SIZE_T + IMPORT :: HID_T, SIZE_T IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: gcpl_id INTEGER(SIZE_T), INTENT(IN) :: size_hint @@ -5609,16 +5609,16 @@ SUBROUTINE h5pget_data_transform_f(plist_id, expression, hdferr, size) END SUBROUTINE h5pset_local_heap_size_hint_f -!****s* H5P/h5pset_est_link_info_f +!****s* H5P/h5pset_est_link_info_f ! NAME -! h5pset_est_link_info_f +! h5pset_est_link_info_f ! ! PURPOSE ! Sets estimated number of links and length of link names in a group. ! ! INPUTS -! -! gcpl_id - Group creation property list identifier +! +! gcpl_id - Group creation property list identifier ! est_num_entries - Estimated number of links to be inserted into group ! est_name_len - Estimated average length of link names ! OUTPUTS @@ -5634,7 +5634,7 @@ SUBROUTINE h5pget_data_transform_f(plist_id, expression, hdferr, size) ! Fortran90 Interface: SUBROUTINE h5pset_est_link_info_f(gcpl_id, est_num_entries, est_name_len, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: gcpl_id ! Group creation property list identifier + INTEGER(HID_T), INTENT(IN) :: gcpl_id ! Group creation property list identifier INTEGER, INTENT(IN) :: est_num_entries ! Estimated number of links to be inserted into group INTEGER, INTENT(IN) :: est_name_len ! Estimated average length of link names INTEGER, INTENT(OUT) :: hdferr ! Error code @@ -5645,7 +5645,7 @@ SUBROUTINE h5pget_data_transform_f(plist_id, expression, hdferr, size) BIND(C,NAME='h5pset_est_link_info_c') IMPORT :: HID_T IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: gcpl_id + INTEGER(HID_T), INTENT(IN) :: gcpl_id INTEGER, INTENT(IN) :: est_num_entries INTEGER, INTENT(IN) :: est_name_len END FUNCTION h5pset_est_link_info_c @@ -5663,15 +5663,15 @@ SUBROUTINE h5pget_data_transform_f(plist_id, expression, hdferr, size) ! Sets the parameters for conversion between compact and dense groups. ! ! INPUTS -! -! gcpl_id - Group creation property list identifier +! +! gcpl_id - Group creation property list identifier ! max_compact - Maximum number of attributes to be stored in compact storage ! min_dense - Minimum number of attributes to be stored in dense storage ! OUTPUTS ! -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! M. Scot Breitenfeld @@ -5708,16 +5708,16 @@ SUBROUTINE h5pset_link_phase_change_f(gcpl_id, max_compact, min_dense, hdferr) ! Sets up use of the direct I/O driver. ! ! INPUTS -! +! ! fapl_id - File access property list identifier ! alignment - Required memory alignment boundary ! block_size - File system block size ! cbuf_size - Copy buffer size ! OUTPUTS ! -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! M. Scot Breitenfeld @@ -5725,7 +5725,7 @@ SUBROUTINE h5pset_link_phase_change_f(gcpl_id, max_compact, min_dense, hdferr) ! ! Fortran90 Interface: SUBROUTINE h5pset_fapl_direct_f(fapl_id, alignment, block_size, cbuf_size, hdferr) - IMPLICIT NONE + IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: fapl_id ! File access property list identifier INTEGER(SIZE_T), INTENT(IN) :: alignment ! Required memory alignment boundary! INTEGER(SIZE_T), INTENT(IN) :: block_size ! File system block size @@ -5738,7 +5738,7 @@ SUBROUTINE h5pset_fapl_direct_f(fapl_id, alignment, block_size, cbuf_size, hdfer BIND(C,NAME='h5pset_fapl_direct_c') IMPORT :: HID_T, SIZE_T IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: fapl_id + INTEGER(HID_T), INTENT(IN) :: fapl_id INTEGER(SIZE_T), INTENT(IN) :: alignment INTEGER(SIZE_T), INTENT(IN) :: block_size INTEGER(SIZE_T), INTENT(IN) :: cbuf_size @@ -5756,16 +5756,16 @@ SUBROUTINE h5pset_fapl_direct_f(fapl_id, alignment, block_size, cbuf_size, hdfer ! Gets up use of the direct I/O driver. ! ! INPUTS -! +! ! fapl_id - File access property list identifier ! OUTPUTS ! ! alignment - Required memory alignment boundary ! block_size - File system block size ! cbuf_size - Copy buffer size -! hdferr - error code +! hdferr - error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! M. Scot Breitenfeld @@ -5773,7 +5773,7 @@ SUBROUTINE h5pset_fapl_direct_f(fapl_id, alignment, block_size, cbuf_size, hdfer ! ! Fortran90 Interface: SUBROUTINE h5pget_fapl_direct_f(fapl_id, alignment, block_size, cbuf_size, hdferr) - IMPLICIT NONE + IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: fapl_id ! File access property list identifier INTEGER(SIZE_T), INTENT(OUT) :: alignment ! Required memory alignment boundary! INTEGER(SIZE_T), INTENT(OUT) :: block_size ! File system block size @@ -5786,7 +5786,7 @@ SUBROUTINE h5pset_fapl_direct_f(fapl_id, alignment, block_size, cbuf_size, hdfer BIND(C,NAME='h5pget_fapl_direct_c') IMPORT :: HID_T, SIZE_T IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: fapl_id + INTEGER(HID_T), INTENT(IN) :: fapl_id INTEGER(SIZE_T), INTENT(OUT) :: alignment INTEGER(SIZE_T), INTENT(OUT) :: block_size INTEGER(SIZE_T), INTENT(OUT) :: cbuf_size @@ -5798,23 +5798,23 @@ SUBROUTINE h5pset_fapl_direct_f(fapl_id, alignment, block_size, cbuf_size, hdfer !****s* H5P/H5Pset_attr_phase_change_f ! NAME -! H5Pset_attr_phase_change_f +! H5Pset_attr_phase_change_f ! ! PURPOSE ! Sets attribute storage phase change thresholds. ! ! INPUTS -! +! ! ocpl_id - Object (dataset or group) creation property list identifier ! OUTPUTS -! +! ! max_compact - Maximum number of attributes to be stored in compact storage ! (Default: 8) ! min_dense - Minimum number of attributes to be stored in dense storage ! (Default: 6) -! hdferr - Error code +! hdferr - Error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! M. Scot Breitenfeld @@ -5850,7 +5850,7 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) !****s* H5P/H5Pset_nbit_f ! NAME -! H5Pset_nbit_f +! H5Pset_nbit_f ! ! PURPOSE ! Sets up the use of the N-Bit filter. @@ -5886,7 +5886,7 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) !****s* H5P/h5pset_scaleoffset_f ! NAME -! h5pset_scaleoffset_f +! h5pset_scaleoffset_f ! ! PURPOSE ! Sets up the use of the scale-offset filter. @@ -5914,7 +5914,7 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) INTEGER , INTENT(IN) :: scale_type INTEGER , INTENT(IN) :: scale_factor INTEGER , INTENT(OUT) :: hdferr -!***** +!***** INTERFACE INTEGER FUNCTION h5pset_scaleoffset_c(plist_id, scale_type, scale_factor) & @@ -5931,15 +5931,15 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) END SUBROUTINE h5pset_scaleoffset_f -!****s* H5P/h5pset_nlinks_f +!****s* H5P/h5pset_nlinks_f ! NAME -! h5pset_nlinks_f +! h5pset_nlinks_f ! ! PURPOSE ! Sets maximum number of soft or user-defined link traversals. ! ! INPUTS -! +! ! lapl_id - File access property list identifier ! nlinks - Maximum number of links to traverse ! @@ -5955,15 +5955,15 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) ! ! HISTORY ! -! +! ! Fortran90 Interface: SUBROUTINE h5pset_nlinks_f(lapl_id, nlinks, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: lapl_id ! File access property list identifier INTEGER(SIZE_T), INTENT(IN) :: nlinks ! Maximum number of links to traverse - INTEGER, INTENT(OUT) :: hdferr ! Error code + INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure -!***** +!***** INTERFACE INTEGER FUNCTION h5pset_nlinks_c(lapl_id, nlinks) & BIND(C,NAME='h5pset_nlinks_c') @@ -5978,15 +5978,15 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) END SUBROUTINE h5pset_nlinks_f -!****s* H5P/h5pget_nlinks_f +!****s* H5P/h5pget_nlinks_f ! NAME -! h5pget_nlinks_f +! h5pget_nlinks_f ! ! PURPOSE ! Gets maximum number of soft or user-defined link traversals. ! ! INPUTS -! +! ! lapl_id - File access property list identifier ! nlinks - Maximum number of links to traverse ! @@ -6011,7 +6011,7 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) INTERFACE INTEGER FUNCTION h5pget_nlinks_c(lapl_id, nlinks) & BIND(C,NAME='h5pget_nlinks_c') - IMPORT :: HID_T, SIZE_T + IMPORT :: HID_T, SIZE_T IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: lapl_id INTEGER(SIZE_T), INTENT(OUT) :: nlinks @@ -6030,22 +6030,22 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) ! Determines whether property is set to enable creating missing intermediate groups. ! ! INPUTS -! +! ! lcpl_id - Link creation property list identifier -! crt_intermed_group - Specifying whether to create intermediate groups upon +! crt_intermed_group - Specifying whether to create intermediate groups upon ! the creation of an object ! OUTPUTS ! -! hdferr - Error code +! hdferr - Error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! M. Scot Breitenfeld ! April 4, 2008 ! ! HISTORY -! +! ! The long subroutine name (>31) on older f90 compilers causes problems ! so the name was shortened ! Fortran90 Interface: @@ -6056,7 +6056,7 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) ! upon creation of an object INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure -!***** +!***** INTERFACE INTEGER FUNCTION h5pget_create_inter_group_c(lcpl_id, crt_intermed_group) & BIND(C,NAME='h5pget_create_inter_group_c') @@ -6095,16 +6095,16 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) ! other chunks. ! ! INPUTS -! +! ! dapl_id - Dataset access property list identifier. ! rdcc_nslots - The number of chunk slots in the raw data chunk cache for this dataset. ! rdcc_nbytes - The total size of the raw data chunk cache for this dataset. ! rdcc_w0 - The chunk preemption policy for this dataset. ! OUTPUTS ! -! hdferr - Error code +! hdferr - Error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! M. Scot Breitenfeld @@ -6116,19 +6116,19 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) SUBROUTINE h5pset_chunk_cache_f(dapl_id, rdcc_nslots, rdcc_nbytes, rdcc_w0, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: dapl_id ! Dataset access property list identifier. - INTEGER(SIZE_T), INTENT(IN) :: rdcc_nslots ! The number of chunk slots in the raw data + INTEGER(SIZE_T), INTENT(IN) :: rdcc_nslots ! The number of chunk slots in the raw data ! chunk cache for this dataset. - INTEGER(SIZE_T), INTENT(IN) :: rdcc_nbytes ! The total size of the raw data chunk cache + INTEGER(SIZE_T), INTENT(IN) :: rdcc_nbytes ! The total size of the raw data chunk cache ! for this dataset. REAL, INTENT(IN) :: rdcc_w0 ! The chunk preemption policy for this dataset. INTEGER, INTENT(OUT) :: hdferr ! Error code ! 0 on success and -1 on failure -!***** +!***** INTERFACE INTEGER FUNCTION h5pset_chunk_cache_c(dapl_id, rdcc_nslots, rdcc_nbytes, rdcc_w0) & BIND(C,NAME='h5pset_chunk_cache_c') - IMPORT :: HID_T, SIZE_T + IMPORT :: HID_T, SIZE_T IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: dapl_id INTEGER(SIZE_T), INTENT(IN) :: rdcc_nslots @@ -6155,16 +6155,16 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) ! file access property list are returned. ! ! INPUTS -! +! ! dapl_id - Dataset access property list identifier. ! OUTPUTS -! -! rdcc_nslots - Number of chunk slots in the raw data chunk cache hash table. -! rdcc_nbytes - Total size of the raw data chunk cache, in bytes. -! rdcc_w0 - Preemption policy. -! hdferr - Error code +! +! rdcc_nslots - Number of chunk slots in the raw data chunk cache hash table. +! rdcc_nbytes - Total size of the raw data chunk cache, in bytes. +! rdcc_w0 - Preemption policy. +! hdferr - Error code ! Success: 0 -! Failure: -1 +! Failure: -1 ! ! AUTHOR ! M. Scot Breitenfeld @@ -6177,11 +6177,11 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: dapl_id ! Dataset access property list identifier. INTEGER(SIZE_T), INTENT(OUT) :: rdcc_nslots ! Number of chunk slots in the raw data chunk cache hash table. - INTEGER(SIZE_T), INTENT(OUT) :: rdcc_nbytes ! Total size of the raw data chunk cache, in bytes. + INTEGER(SIZE_T), INTENT(OUT) :: rdcc_nbytes ! Total size of the raw data chunk cache, in bytes. REAL, INTENT(OUT) :: rdcc_w0 ! Preemption policy. INTEGER, INTENT(OUT) :: hdferr ! Error code: ! 0 on success and -1 on failure -!***** +!***** INTERFACE INTEGER FUNCTION h5pget_chunk_cache_c(dapl_id, rdcc_nslots, rdcc_nbytes, rdcc_w0) & BIND(C,NAME='h5pget_chunk_cache_c') @@ -6234,7 +6234,7 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) ! INTEGER, REAL, DOUBLE PRECISION and CHARACTER dtatypes. ! ! Fortran90 Interface: -!! SUBROUTINE h5pset_fill_value_f(prp_id, type_id, fillvalue, hdferr) +!! SUBROUTINE h5pset_fill_value_f(prp_id, type_id, fillvalue, hdferr) !! IMPLICIT NONE !! INTEGER(HID_T), INTENT(IN) :: prp_id !! INTEGER(HID_T), INTENT(IN) :: type_id @@ -6295,7 +6295,7 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) ! ! Fortran90 Interface: !! SUBROUTINE h5pget_fill_value_f(prp_id, type_id, fillvalue, hdferr) -!! INTEGER(HID_T), INTENT(IN) :: prp_id +!! INTEGER(HID_T), INTENT(IN) :: prp_id !! INTEGER(HID_T), INTENT(IN) :: type_id !! TYPE(VOID) , INTENT(OUT) :: fillvalue !! INTEGER , INTENT(OUT) :: hdferr @@ -6402,7 +6402,7 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) ! ! Fortran2003 Interface: !! SUBROUTINE h5pset_fill_value_f(prp_id, type_id, fillvalue, hdferr) -!! INTEGER(HID_T), INTENT(IN) :: prp_id +!! INTEGER(HID_T), INTENT(IN) :: prp_id !! INTEGER(HID_T), INTENT(IN) :: type_id !! TYPE(C_PTR) , INTENT(IN) :: fillvalue !! INTEGER , INTENT(OUT) :: hdferr @@ -6458,7 +6458,7 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) ! ! Fortran2003 Interface: !! SUBROUTINE h5pget_fill_value_f(prp_id, type_id, fillvalue, hdferr) -!! INTEGER(HID_T), INTENT(IN) :: prp_id +!! INTEGER(HID_T), INTENT(IN) :: prp_id !! INTEGER(HID_T), INTENT(IN) :: type_id !! TYPE(C_PTR) :: fillvalue !! INTEGER , INTENT(OUT) :: hdferr @@ -6750,7 +6750,7 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) !! CHARACTER(LEN=*), INTENT(IN) :: name !! INTEGER(SIZE_T) , INTENT(IN) :: size !! TYPE , INTENT(IN) :: value -!! INTEGER , INTENT(OUT) :: hdferr +!! INTEGER , INTENT(OUT) :: hdferr !***** SUBROUTINE h5pregister_integer(class, name, size, value, hdferr) IMPLICIT NONE @@ -6832,7 +6832,7 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) !! CHARACTER(LEN=*), INTENT(IN) :: name !! INTEGER(SIZE_T) , INTENT(IN) :: size !! TYPE(C_PTR) , INTENT(IN) :: value -!! INTEGER , INTENT(OUT) :: hdferr +!! INTEGER , INTENT(OUT) :: hdferr !***** SUBROUTINE h5pregister_ptr(class, name, size, value, hdferr) @@ -6951,7 +6951,7 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) ! Outputs: ! hdferr - Returns 0 if successful and -1 if fails ! -! AUTHOR +! AUTHOR ! M. Scot Breitenfeld ! June 24, 2008 ! @@ -7077,7 +7077,7 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) ! ! Inputs: ! fapl_id - File access property list identifier -! buf_ptr - Pointer to the initial file image, +! buf_ptr - Pointer to the initial file image, ! or C_NULL_PTR if no initial file image is desired ! buf_len - Size of the supplied buffer, or 0 (zero) if no initial image is desired ! @@ -7117,7 +7117,7 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) ! h5pget_file_image_f ! ! PURPOSE -! Retrieves a copy of the file image designated as the initial content and structure of a file. +! Retrieves a copy of the file image designated as the initial content and structure of a file. ! ! Inputs: ! fapl_id - File access property list identifier. @@ -7149,7 +7149,7 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) TYPE(C_PTR) , INTENT(OUT), DIMENSION(*) :: buf_ptr INTEGER(SIZE_T), INTENT(OUT) :: buf_len_ptr INTEGER , INTENT(OUT) :: hdferr - + !***** INTERFACE INTEGER FUNCTION h5pget_file_image_c(fapl_id, buf_ptr, buf_len_ptr) & @@ -7205,7 +7205,7 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) BIND(C,NAME='h5pset_fapl_mpio_c') IMPORT :: HID_T IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id + INTEGER(HID_T), INTENT(IN) :: prp_id INTEGER , INTENT(IN) :: comm INTEGER , INTENT(IN) :: info END FUNCTION h5pset_fapl_mpio_c @@ -7248,7 +7248,7 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) BIND(C,NAME='h5pget_fapl_mpio_c') IMPORT :: HID_T IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id + INTEGER(HID_T), INTENT(IN) :: prp_id INTEGER , INTENT(OUT) :: comm INTEGER , INTENT(OUT) :: info END FUNCTION h5pget_fapl_mpio_c @@ -7291,7 +7291,7 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) BIND(C,NAME='h5pset_dxpl_mpio_c') IMPORT :: HID_T IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id + INTEGER(HID_T), INTENT(IN) :: prp_id INTEGER , INTENT(IN) :: data_xfer_mode END FUNCTION h5pset_dxpl_mpio_c END INTERFACE @@ -7333,7 +7333,7 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) BIND(C,NAME='h5pget_dxpl_mpio_c') IMPORT :: HID_T IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: prp_id + INTEGER(HID_T), INTENT(IN) :: prp_id INTEGER , INTENT(OUT) :: data_xfer_mode END FUNCTION h5pget_dxpl_mpio_c END INTERFACE @@ -7346,8 +7346,8 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) ! h5pget_mpio_actual_io_mode_f ! ! PURPOSE -! Retrieves the type of I/O that HDF5 actually performed on the last -! parallel I/O call. This is not necessarily the type of I/O requested. +! Retrieves the type of I/O that HDF5 actually performed on the last +! parallel I/O call. This is not necessarily the type of I/O requested. ! ! INPUTS ! dxpl_id - Dataset transfer property list identifier. @@ -7367,7 +7367,7 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) INTEGER(HID_T), INTENT(IN) :: dxpl_id INTEGER , INTENT(OUT) :: actual_io_mode INTEGER , INTENT(OUT) :: hdferr -!***** +!***** INTERFACE INTEGER FUNCTION h5pget_mpio_actual_io_mode_c(dxpl_id, actual_io_mode) & BIND(C,NAME='h5pget_mpio_actual_io_mode_c') @@ -7389,9 +7389,9 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) ! h5pset_all_coll_metadata_ops_f ! ! PURPOSE -! Sets requirement whether HDF5 metadata read operations using the access property -! list are required to be collective or independent. If collective requirement is -! selected, the HDF5 library will optimize the metadata reads improving performance. +! Sets requirement whether HDF5 metadata read operations using the access property +! list are required to be collective or independent. If collective requirement is +! selected, the HDF5 library will optimize the metadata reads improving performance. ! The default setting is independent (false). ! ! INPUTS @@ -7414,7 +7414,7 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) INTEGER, INTENT(OUT) :: hdferr !***** LOGICAL(C_BOOL) :: c_is_collective - + INTERFACE INTEGER FUNCTION h5pset_all_coll_metadata_ops(plist_id, is_collective) BIND(C, NAME='H5Pset_all_coll_metadata_ops') IMPORT :: HID_T, C_BOOL @@ -7426,12 +7426,12 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) ! Transfer value of Fortran LOGICAL to C c_bool type c_is_collective = is_collective - + hdferr = INT(H5Pset_all_coll_metadata_ops(plist_id, c_is_collective)) - + END SUBROUTINE h5pset_all_coll_metadata_ops_f -!****s* H5P/h5pget_all_coll_metadata_ops_f +!****s* H5P/h5pget_all_coll_metadata_ops_f ! NAME ! h5pget_all_coll_metadata_ops_f ! @@ -7452,14 +7452,14 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) ! ! SOURCE SUBROUTINE h5pget_all_coll_metadata_ops_f(plist_id, is_collective, hdferr) - + IMPLICIT NONE INTEGER(HID_T) , INTENT(IN) :: plist_id LOGICAL, INTENT(OUT) :: is_collective INTEGER, INTENT(OUT) :: hdferr !***** LOGICAL(C_BOOL) :: c_is_collective - + INTERFACE INTEGER FUNCTION h5pget_all_coll_metadata_ops(plist_id, is_collective) BIND(C, NAME='H5Pget_all_coll_metadata_ops') IMPORT :: HID_T, C_BOOL @@ -7468,12 +7468,12 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) LOGICAL(C_BOOL), INTENT(OUT) :: is_collective END FUNCTION h5pget_all_coll_metadata_ops END INTERFACE - + hdferr = INT(H5Pget_all_coll_metadata_ops(plist_id, c_is_collective)) - - ! Transfer value of C c_bool type to Fortran LOGICAL + + ! Transfer value of C c_bool type to Fortran LOGICAL is_collective = c_is_collective - + END SUBROUTINE h5pget_all_coll_metadata_ops_f !****s* H5P/h5pset_coll_metadata_write_f @@ -7503,7 +7503,7 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) INTEGER, INTENT(OUT) :: hdferr !***** LOGICAL(C_BOOL) :: c_is_collective - + INTERFACE INTEGER FUNCTION h5pset_coll_metadata_write(plist_id, is_collective) BIND(C, NAME='H5Pset_coll_metadata_write') IMPORT :: HID_T, C_BOOL @@ -7512,12 +7512,12 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) LOGICAL(C_BOOL), INTENT(IN), VALUE :: is_collective END FUNCTION h5pset_coll_metadata_write END INTERFACE - + ! Transfer value of Fortran LOGICAL to C c_bool type c_is_collective = is_collective - + hdferr = INT(H5Pset_coll_metadata_write(plist_id, c_is_collective)) - + END SUBROUTINE h5pset_coll_metadata_write_f !****s* H5P/h5pget_coll_metadata_write_f @@ -7541,14 +7541,14 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) ! ! SOURCE SUBROUTINE h5pget_coll_metadata_write_f(plist_id, is_collective, hdferr) - + IMPLICIT NONE INTEGER(HID_T) , INTENT(IN) :: plist_id LOGICAL, INTENT(OUT) :: is_collective INTEGER, INTENT(OUT) :: hdferr !***** LOGICAL(C_BOOL) :: c_is_collective - + INTERFACE INTEGER FUNCTION h5pget_coll_metadata_write(plist_id, is_collective) BIND(C, NAME='H5Pget_coll_metadata_write') IMPORT :: HID_T, C_BOOL @@ -7557,14 +7557,14 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) LOGICAL(C_BOOL), INTENT(OUT) :: is_collective END FUNCTION h5pget_coll_metadata_write END INTERFACE - + hdferr = INT(H5Pget_coll_metadata_write(plist_id, c_is_collective)) - - ! Transfer value of C c_bool type to Fortran LOGICAL + + ! Transfer value of C c_bool type to Fortran LOGICAL is_collective = c_is_collective - + END SUBROUTINE h5pget_coll_metadata_write_f - + #endif ! @@ -7584,9 +7584,9 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) ! Valid values are: ! H5D_VDS_FIRST_MISSING_F ! H5D_VDS_LAST_AVAILABLE_F -! +! ! OUTPUTS -! +! ! hdferr - Returns 0 if successful and -1 if fails. ! ! AUTHOR @@ -7601,7 +7601,7 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) INTEGER(HID_T), INTENT(IN) :: dapl_id INTEGER , INTENT(IN) :: view INTEGER , INTENT(OUT) :: hdferr - + !***** INTERFACE INTEGER FUNCTION h5pset_virtual_view(dapl_id, view) BIND(C,NAME='H5Pset_virtual_view') @@ -7613,7 +7613,7 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) END INTERFACE hdferr = INT( h5pset_virtual_view(dapl_id, INT(view,ENUM_T)) ) - + END SUBROUTINE h5pset_virtual_view_f !****s* H5P/h5pget_virtual_view_f @@ -7621,7 +7621,7 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) ! h5pget_virtual_view_f ! ! PURPOSE -! Retrieves the view of a virtual dataset accessed with dapl_id. +! Retrieves the view of a virtual dataset accessed with dapl_id. ! ! INPUTS ! dapl_id - Dataset access property list identifier for the virtual dataset @@ -7657,7 +7657,7 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) hdferr = INT( h5pget_virtual_view(dapl_id, view_enum) ) view = INT(view_enum) - + END SUBROUTINE h5pget_virtual_view_f !****s* H5P/h5pset_virtual_printf_gap_f @@ -7665,15 +7665,15 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) ! h5pset_virtual_printf_gap_f ! ! PURPOSE -! Sets the maximum number of missing source files and/or datasets with the printf-style names -! when getting the extent of an unlimited virtual dataset. +! Sets the maximum number of missing source files and/or datasets with the printf-style names +! when getting the extent of an unlimited virtual dataset. ! ! INPUTS ! dapl_id - Dataset access property list identifier for the virtual dataset. -! gap_size - Maximum number of files and/or datasets allowed to be missing for determining +! gap_size - Maximum number of files and/or datasets allowed to be missing for determining ! the extent of an unlimited virtual dataset with printf-style mappings. ! -! OUTPUTS +! OUTPUTS ! hdferr - Returns 0 if successful and -1 if fails. ! ! AUTHOR @@ -7682,7 +7682,7 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) ! ! HISTORY ! -! SOURCE +! SOURCE SUBROUTINE h5pset_virtual_printf_gap_f(dapl_id, gap_size, hdferr) IMPLICIT NONE INTEGER(HID_T) , INTENT(IN) :: dapl_id @@ -7699,7 +7699,7 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) END INTERFACE hdferr = INT( h5pset_virtual_printf_gap(dapl_id, gap_size) ) - + END SUBROUTINE h5pset_virtual_printf_gap_f !****s* H5P/h5pget_virtual_printf_gap_f @@ -7707,15 +7707,15 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) ! h5pget_virtual_printf_gap_f ! ! PURPOSE -! Returns the maximum number of missing source files and/or datasets with the +! Returns the maximum number of missing source files and/or datasets with the ! printf-style names when getting the extent for an unlimited virtual dataset. ! ! INPUTS ! dapl_id - Dataset access property list identifier for the virtual dataset ! ! OUTPUTS -! gap_size - Maximum number of the files and/or datasets allowed to be missing for -! determining the extent of an unlimited virtual dataset with printf-style mappings. +! gap_size - Maximum number of the files and/or datasets allowed to be missing for +! determining the extent of an unlimited virtual dataset with printf-style mappings. ! hdferr - Returns 0 if successful and -1 if fails ! ! AUTHOR @@ -7727,7 +7727,7 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) ! SOURCE SUBROUTINE h5pget_virtual_printf_gap_f(dapl_id, gap_size, hdferr) IMPLICIT NONE - + INTEGER(HID_T) , INTENT(IN) :: dapl_id INTEGER(HSIZE_T), INTENT(OUT) :: gap_size INTEGER , INTENT(OUT) :: hdferr @@ -7742,7 +7742,7 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) END INTERFACE hdferr = INT( h5pget_virtual_printf_gap(dapl_id, gap_size) ) - + END SUBROUTINE h5pget_virtual_printf_gap_f !****s* H5P/h5pset_virtual_f @@ -7753,9 +7753,9 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) ! Sets the mapping between virtual and source datasets. ! ! INPUTS -! dcpl_id - The identifier of the dataset creation property list that will be +! dcpl_id - The identifier of the dataset creation property list that will be ! used when creating the virtual dataset. -! vspace_id - The dataspace identifier with the selection within the virtual +! vspace_id - The dataspace identifier with the selection within the virtual ! dataset applied, possibly an unlimited selection. ! src_file_name - The name of the HDF5 file where the source dataset is located. ! src_dset_name - The path to the HDF5 dataset in the file specified by src_file_name. @@ -7773,7 +7773,7 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) ! SOURCE SUBROUTINE h5pset_virtual_f(dcpl_id, vspace_id, src_file_name, src_dset_name, src_space_id, hdferr) IMPLICIT NONE - + INTEGER(HID_T), INTENT(IN) :: dcpl_id INTEGER(HID_T), INTENT(IN) :: vspace_id CHARACTER(LEN=*), INTENT(IN) :: src_file_name @@ -7813,7 +7813,7 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) ! Gets the number of mappings for the virtual dataset. ! ! INPUTS -! dcpl_id - The identifier of the virtual dataset creation property list. +! dcpl_id - The identifier of the virtual dataset creation property list. ! ! OUTPUTS ! count - The number of mappings. @@ -7828,7 +7828,7 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) SUBROUTINE h5pget_virtual_count_f(dcpl_id, count, hdferr) IMPLICIT NONE - + INTEGER(HID_T), INTENT(IN) :: dcpl_id INTEGER(SIZE_T), INTENT(OUT) :: count INTEGER, INTENT(OUT) :: hdferr @@ -7841,7 +7841,7 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) INTEGER(SIZE_T), INTENT(OUT) :: count END FUNCTION h5pget_virtual_count END INTERFACE - + hdferr = INT( h5pget_virtual_count(dcpl_id, count)) END SUBROUTINE h5pget_virtual_count_f @@ -7856,10 +7856,10 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) ! INPUTS ! dcpl_id - The identifier of the virtual dataset creation property list. ! index - Mapping index. -! The value of index is 0 (zero) or greater and less than count (0 ≤ index < count), +! The value of index is 0 (zero) or greater and less than count (0 ≤ index < count), ! where count is the number of mappings returned by h5pget_virtual_count. ! -! OUTPUTS +! OUTPUTS ! hdferr - Returns 0 if successful and -1 if fails. ! ! AUTHOR @@ -7886,9 +7886,9 @@ SUBROUTINE h5pset_attr_phase_change_f(ocpl_id, max_compact, min_dense, hdferr) INTEGER(SIZE_T), INTENT(IN), VALUE :: index END FUNCTION h5pget_virtual_vspace END INTERFACE - + ds_id = h5pget_virtual_vspace(dcpl_id, index) - + hdferr = 0 IF(ds_id.LT.0) hdferr = -1 @@ -7904,7 +7904,7 @@ END SUBROUTINE h5pget_virtual_vspace_f ! INPUTS ! dcpl_id - The identifier of the virtual dataset creation property list. ! index - Mapping index. -! The value of index is 0 (zero) or greater and less than count (0 ≤ index < count), +! The value of index is 0 (zero) or greater and less than count (0 ≤ index < count), ! where count is the number of mappings returned by h5pget_virtual_count. ! ! @@ -7936,7 +7936,7 @@ SUBROUTINE h5pget_virtual_srcspace_f(dcpl_id, index, ds_id, hdferr) INTEGER(SIZE_T), INTENT(IN), VALUE :: index END FUNCTION h5pget_virtual_srcspace END INTERFACE - + ds_id = h5pget_virtual_srcspace(dcpl_id, index) hdferr = 0 @@ -7954,9 +7954,9 @@ END SUBROUTINE h5pget_virtual_srcspace_f ! INPUTS ! dcpl_id - The identifier of the virtual dataset creation property list. ! index - Mapping index. -! The value of index is 0 (zero) or greater and less than count (0 ≤ index < count), +! The value of index is 0 (zero) or greater and less than count (0 ≤ index < count), ! where count is the number of mappings returned by h5pget_virtual_count. -! +! ! OUTPUTS ! name - A buffer containing the name of the file containing the source dataset. ! hdferr - Returns 0 if successful and -1 if fails. @@ -7983,7 +7983,7 @@ SUBROUTINE h5pget_virtual_filename_f(dcpl_id, index, name, hdferr, name_len) CHARACTER(LEN=1,KIND=C_CHAR), DIMENSION(1:LEN(name)+1), TARGET :: c_name TYPE(C_PTR) :: f_ptr - + INTERFACE INTEGER(SIZE_T) FUNCTION h5pget_virtual_filename(dcpl_id, index, name, size) BIND(C, NAME='H5Pget_virtual_filename') IMPORT :: HID_T, SIZE_T, C_PTR @@ -8022,9 +8022,9 @@ END SUBROUTINE h5pget_virtual_filename_f ! INPUTS ! dcpl_id - The identifier of the virtual dataset creation property list. ! index - Mapping index. -! The value of index is 0 (zero) or greater and less than count (0 ≤ index < count), +! The value of index is 0 (zero) or greater and less than count (0 ≤ index < count), ! where count is the number of mappings returned by h5pget_virtual_count. -! +! ! OUTPUTS ! name - A buffer containing the name of the source dataset. ! hdferr - Returns 0 if successful and -1 if fails. @@ -8051,7 +8051,7 @@ SUBROUTINE h5pget_virtual_dsetname_f(dcpl_id, index, name, hdferr, name_len) CHARACTER(LEN=1,KIND=C_CHAR), DIMENSION(1:LEN(name)+1), TARGET :: c_name TYPE(C_PTR) :: f_ptr - + INTERFACE INTEGER(SIZE_T) FUNCTION h5pget_virtual_dsetname(dcpl_id, index, name, size) BIND(C, NAME='H5Pget_virtual_dsetname') IMPORT :: HID_T, SIZE_T, C_PTR @@ -8120,7 +8120,7 @@ END SUBROUTINE h5pget_virtual_dsetname_f hdferr = INT(h5pget_dset_no_attrs_hint_c(dcpl_id, c_minimize)) - ! Transfer value of C C_BOOL type to Fortran LOGICAL + ! Transfer value of C C_BOOL type to Fortran LOGICAL minimize = c_minimize END SUBROUTINE h5pget_dset_no_attrs_hint_f diff --git a/fortran/src/H5Rff.F90 b/fortran/src/H5Rff.F90 index 6c2ba28..e5cfb1d 100644 --- a/fortran/src/H5Rff.F90 +++ b/fortran/src/H5Rff.F90 @@ -61,7 +61,7 @@ MODULE H5R PRIVATE h5rcreate_object_f, h5rcreate_region_f, h5rcreate_ptr_f PRIVATE h5rdereference_object_f, h5rdereference_region_f, h5rdereference_ptr_f PRIVATE h5rget_name_object_f, h5rget_name_region_f, h5rget_name_ptr_f - + INTERFACE h5rget_object_type_f MODULE PROCEDURE h5rget_object_type_obj_f @@ -341,7 +341,7 @@ CONTAINS ! ! Signature: SUBROUTINE h5rcreate_object_f(loc_id, name, ref, hdferr) - USE, INTRINSIC :: ISO_C_BINDING + USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: loc_id ! Location identifier CHARACTER(LEN=*), INTENT(IN) :: name ! Name of the object at location specified @@ -450,7 +450,7 @@ CONTAINS ! ! Signature: SUBROUTINE h5rcreate_ptr_f(loc_id, name, ref_type, ref, hdferr, space_id) - USE, INTRINSIC :: ISO_C_BINDING + USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: loc_id ! Location identifier CHARACTER(LEN=*), INTENT(IN) :: name ! Name of the dataset at location specified @@ -498,7 +498,7 @@ CONTAINS ! ! Signature: SUBROUTINE h5rdereference_object_f(obj_id, ref, ref_obj_id, hdferr) - USE, INTRINSIC :: ISO_C_BINDING + USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: obj_id ! Dataset identifier TYPE(hobj_ref_t_f), INTENT(IN), TARGET :: ref ! Object reference @@ -541,7 +541,7 @@ CONTAINS ! ! Signature: SUBROUTINE h5rdereference_region_f(obj_id, ref, ref_obj_id, hdferr) - USE, INTRINSIC :: ISO_C_BINDING + USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: obj_id ! Dataset identifier TYPE(hdset_reg_ref_t_f), INTENT(IN), TARGET :: ref ! Object reference @@ -582,7 +582,7 @@ CONTAINS ! ! Signature: SUBROUTINE h5rdereference_ptr_f(obj_id, ref_type, ref, ref_obj_id, hdferr) - USE, INTRINSIC :: ISO_C_BINDING + USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: obj_id ! Valid identifier for the file containing the ! referenced object or any object in that file. @@ -622,7 +622,7 @@ CONTAINS ! ! Signature: SUBROUTINE h5rget_name_object_f(loc_id, ref, name, hdferr, size) - USE, INTRINSIC :: ISO_C_BINDING + USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: loc_id TYPE(hobj_ref_t_f), INTENT(IN), TARGET :: ref @@ -669,7 +669,7 @@ CONTAINS ! ! Signature: SUBROUTINE h5rget_name_region_f(loc_id, ref, name, hdferr, size) - USE, INTRINSIC :: ISO_C_BINDING + USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: loc_id TYPE(hdset_reg_ref_t_f), INTENT(IN), TARGET :: ref @@ -718,7 +718,7 @@ CONTAINS ! ! Signature: SUBROUTINE h5rget_name_ptr_f(loc_id, ref_type, ref, name, hdferr, size) - USE, INTRINSIC :: ISO_C_BINDING + USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: loc_id INTEGER, INTENT(IN) :: ref_type @@ -767,7 +767,7 @@ CONTAINS ! ! Signature: SUBROUTINE h5rget_obj_type_f(loc_id, ref_type, ref, obj_type, hdferr) - USE, INTRINSIC :: ISO_C_BINDING + USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: loc_id INTEGER, INTENT(IN) :: ref_type diff --git a/fortran/src/H5Sff.F90 b/fortran/src/H5Sff.F90 index e6f8e4c..5199ed6 100644 --- a/fortran/src/H5Sff.F90 +++ b/fortran/src/H5Sff.F90 @@ -49,7 +49,7 @@ CONTAINS ! NAME ! h5screate_simple_f ! -! PURPOSE +! PURPOSE ! Creates a new simple data space and opens it for access . ! ! INPUTS @@ -104,7 +104,7 @@ CONTAINS ENDIF hdferr = h5screate_simple_c(rank, dims, f_maxdims, space_id) DEALLOCATE(f_maxdims) - + END SUBROUTINE h5screate_simple_f ! @@ -142,9 +142,9 @@ CONTAINS INTEGER(HID_T), INTENT(IN) :: space_id END FUNCTION h5sclose_c END INTERFACE - + hdferr = h5sclose_c(space_id) - + END SUBROUTINE h5sclose_f ! @@ -193,9 +193,9 @@ CONTAINS INTEGER(HID_T), INTENT(OUT) :: space_id END FUNCTION h5screate_c END INTERFACE - + hdferr = h5screate_c(classtype, space_id) - + END SUBROUTINE h5screate_f ! @@ -287,7 +287,7 @@ CONTAINS END INTERFACE hdferr = h5sget_select_hyper_nblocks_c (space_id, num_blocks) - + END SUBROUTINE h5sget_select_hyper_nblocks_f ! @@ -319,7 +319,7 @@ CONTAINS SUBROUTINE h5sget_select_hyper_blocklist_f(space_id, startblock, & num_blocks, buf, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: space_id + INTEGER(HID_T), INTENT(IN) :: space_id INTEGER(HSIZE_T), INTENT(IN) :: startblock INTEGER(HSIZE_T), INTENT(IN) :: num_blocks INTEGER(HSIZE_T), DIMENSION(*), INTENT(OUT) :: buf @@ -432,7 +432,7 @@ CONTAINS END INTERFACE hdferr = h5sget_select_elem_npoints_c (space_id, num_points) - + END SUBROUTINE h5sget_select_elem_npoints_f ! @@ -481,10 +481,10 @@ CONTAINS INTEGER(HSIZE_T), DIMENSION(*), INTENT(OUT) :: buf END FUNCTION h5sget_select_elem_pointlist_c END INTERFACE - + hdferr = h5sget_select_elem_pointlist_c(space_id, startpoint, & num_points, buf ) - + END SUBROUTINE h5sget_select_elem_pointlist_f ! @@ -500,8 +500,8 @@ CONTAINS ! INPUTS ! space_id - dataspace identifier ! operator - flag, valid values are: -! H5S_SELECT_SET_F -! H5S_SELECT_APPEND_F +! H5S_SELECT_SET_F +! H5S_SELECT_APPEND_F ! H5S_SELECT_PREPEND_F ! rank - number of dataspace dimensions ! num_elements - number of elements to be selected @@ -527,7 +527,7 @@ CONTAINS INTEGER, INTENT(IN) :: rank INTEGER(SIZE_T), INTENT(IN) :: num_elements INTEGER(HSIZE_T), INTENT(IN) , DIMENSION(rank,num_elements) :: coord - INTEGER, INTENT(OUT) :: hdferr + INTEGER, INTENT(OUT) :: hdferr !***** INTEGER(HSIZE_T), ALLOCATABLE, DIMENSION(:,:) :: c_coord INTEGER :: error, i @@ -595,7 +595,7 @@ CONTAINS SUBROUTINE h5sselect_all_f(space_id, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: space_id - INTEGER, INTENT(OUT) :: hdferr + INTEGER, INTENT(OUT) :: hdferr !***** INTERFACE INTEGER FUNCTION h5sselect_all_c(space_id) BIND(C,NAME='h5sselect_all_c') @@ -604,9 +604,9 @@ CONTAINS INTEGER(HID_T), INTENT(IN) :: space_id END FUNCTION h5sselect_all_c END INTERFACE - + hdferr = h5sselect_all_c(space_id) - + END SUBROUTINE h5sselect_all_f ! @@ -646,9 +646,9 @@ CONTAINS INTEGER(HID_T), INTENT(IN) :: space_id END FUNCTION h5sselect_none_c END INTERFACE - + hdferr = h5sselect_none_c(space_id) - + END SUBROUTINE h5sselect_none_f ! @@ -665,8 +665,8 @@ CONTAINS ! space_id - identifier for the dataspace for which ! selection is verified ! OUTPUTS -! status - TRUE if the selection is contained within -! the extent, FALSE otherwise. +! status - TRUE if the selection is contained within +! the extent, FALSE otherwise. ! hdferr - Returns 0 if successful and -1 if fails ! ! AUTHOR @@ -695,11 +695,11 @@ CONTAINS INTEGER :: flag END FUNCTION h5sselect_valid_c END INTERFACE - + hdferr = h5sselect_valid_c(space_id, flag) status = .TRUE. IF (flag .EQ. 0) status = .FALSE. - + END SUBROUTINE h5sselect_valid_f ! @@ -729,7 +729,7 @@ CONTAINS ! SOURCE SUBROUTINE h5sget_simple_extent_npoints_f(space_id, npoints, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: space_id + INTEGER(HID_T), INTENT(IN) :: space_id INTEGER(HSIZE_T), INTENT(OUT) :: npoints INTEGER, INTENT(OUT) :: hdferr !***** @@ -783,7 +783,7 @@ CONTAINS INTEGER(HSSIZE_T), INTENT(OUT) :: npoints END FUNCTION h5sget_select_npoints_c END INTERFACE - + hdferr = h5sget_select_npoints_c(space_id, npoints) END SUBROUTINE h5sget_select_npoints_f @@ -826,9 +826,9 @@ CONTAINS INTEGER, INTENT(OUT) :: rank END FUNCTION h5sget_simple_extent_ndims_c END INTERFACE - + hdferr = h5sget_simple_extent_ndims_c(space_id, rank) - + END SUBROUTINE h5sget_simple_extent_ndims_f ! !****s* H5S/h5sget_simple_extent_dims_f @@ -873,9 +873,9 @@ CONTAINS INTEGER(HSIZE_T), DIMENSION(*), INTENT(OUT) :: maxdims END FUNCTION h5sget_simple_extent_dims_c END INTERFACE - + hdferr = h5sget_simple_extent_dims_c(space_id, dims, maxdims) - + END SUBROUTINE h5sget_simple_extent_dims_f ! @@ -920,9 +920,9 @@ CONTAINS INTEGER, INTENT(OUT) :: classtype END FUNCTION h5sget_simple_extent_type_c END INTERFACE - + hdferr = h5sget_simple_extent_type_c(space_id, classtype) - + END SUBROUTINE h5sget_simple_extent_type_f ! !****s* H5S/h5sset_extent_simple_f @@ -970,7 +970,7 @@ CONTAINS INTEGER(HSIZE_T), DIMENSION(rank), INTENT(IN) :: maximum_size END FUNCTION h5sset_extent_simple_c END INTERFACE - + hdferr = h5sset_extent_simple_c(space_id, rank, current_size, & maximum_size) @@ -1016,11 +1016,11 @@ CONTAINS INTEGER :: flag END FUNCTION h5sis_simple_c END INTERFACE - + hdferr = h5sis_simple_c(space_id, flag) status = .TRUE. IF (flag .EQ. 0) status = .FALSE. - + END SUBROUTINE h5sis_simple_f ! @@ -1156,9 +1156,9 @@ CONTAINS INTEGER(HID_T), INTENT(IN) :: space_id END FUNCTION h5sset_extent_none_c END INTERFACE - + hdferr = h5sset_extent_none_c(space_id) - + END SUBROUTINE h5sset_extent_none_f ! !****s* H5S/h5sselect_hyperslab_f @@ -1196,7 +1196,7 @@ CONTAINS SUBROUTINE h5sselect_hyperslab_f(space_id, OPERATOR, start, count, & hdferr, stride, BLOCK) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: space_id + INTEGER(HID_T), INTENT(IN) :: space_id INTEGER, INTENT(IN) :: OPERATOR INTEGER(HSIZE_T), DIMENSION(*), INTENT(IN) :: start INTEGER(HSIZE_T), DIMENSION(*), INTENT(IN) :: count @@ -1208,7 +1208,7 @@ CONTAINS INTEGER(HSIZE_T), DIMENSION(:), ALLOCATABLE :: def_stride INTEGER :: rank INTEGER :: error1, error2 - + INTERFACE INTEGER FUNCTION h5sselect_hyperslab_c(space_id, OPERATOR, & start, count, stride, BLOCK) BIND(C,NAME='h5sselect_hyperslab_c') @@ -1248,7 +1248,7 @@ CONTAINS DEALLOCATE(def_block) RETURN ENDIF - + IF (.NOT.PRESENT(stride).AND. PRESENT(BLOCK)) THEN ALLOCATE(def_stride(rank), stat=error2) IF (error2.NE.0) THEN @@ -1273,7 +1273,7 @@ CONTAINS def_stride, def_block) DEALLOCATE(def_block) DEALLOCATE(def_stride) - + END SUBROUTINE h5sselect_hyperslab_f ! !$! ! !$!****s* H5S/h5scombine_hyperslab_f @@ -1618,10 +1618,10 @@ CONTAINS INTEGER, INTENT(OUT) :: TYPE END FUNCTION h5sget_select_type_c END INTERFACE - + hdferr = h5sget_select_type_c(space_id, TYPE) RETURN - + END SUBROUTINE h5sget_select_type_f ! @@ -1779,7 +1779,7 @@ CONTAINS ! January, 28 2016 ! SOURCE SUBROUTINE h5sget_regular_hyperslab_f(space_id, start, stride, count, block, hdferr) - + IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: space_id INTEGER(HSIZE_T), INTENT(OUT), DIMENSION(*), TARGET :: start @@ -1790,7 +1790,7 @@ CONTAINS !***** TYPE(C_PTR) :: start_c, stride_c, count_c, block_c INTEGER :: n - + INTERFACE INTEGER FUNCTION h5sget_regular_hyperslab(space_id, start, stride, count, block) BIND(C,NAME='H5Sget_regular_hyperslab') IMPORT :: HID_T, C_PTR @@ -1809,7 +1809,7 @@ CONTAINS IF(INT(h5sget_regular_hyperslab(space_id, start_c, stride_c, count_c, block_c)).LT.0) hdferr = -1 - ! Reverse the C arrays description values of the hyperslab because + ! Reverse the C arrays description values of the hyperslab because ! the hyperslab was for a C stored hyperslab CALL H5Sget_simple_extent_ndims_f(space_id,n,hdferr) @@ -1848,8 +1848,8 @@ CONTAINS LOGICAL :: IsRegular INTEGER, INTENT(OUT) :: hdferr !***** - INTEGER(C_INT) :: status - + INTEGER(C_INT) :: status + INTERFACE INTEGER(C_INT) FUNCTION H5Sis_regular_hyperslab(space_id) BIND(C,NAME='H5Sis_regular_hyperslab') IMPORT :: HID_T, C_INT diff --git a/fortran/src/H5Tff.F90 b/fortran/src/H5Tff.F90 index 46c8f39..25eb613 100644 --- a/fortran/src/H5Tff.F90 +++ b/fortran/src/H5Tff.F90 @@ -28,7 +28,7 @@ ! **** | | | |\/| | ___/| | | | _ / | | / /\ \ | . ` | | | **** ! **** _| |_| | | | | | |__| | | \ \ | |/ ____ \| |\ | | | **** ! |_____|_| |_|_| \____/|_| \_\ |_/_/ \_\_| \_| |_| -! +! ! If you add a new function here then you MUST add the function name to the ! Windows dll file 'hdf5_fortrandll.def.in' in the fortran/src directory. ! This is needed for Windows based operating systems. @@ -41,7 +41,7 @@ MODULE H5T USE H5GLOBAL IMPLICIT NONE - PRIVATE h5tenum_insert_f03, h5tenum_insert_f90 + PRIVATE h5tenum_insert_f03, h5tenum_insert_f90 !****t* H5T/hvl_t ! Fortran2003 Derived Type: @@ -92,7 +92,7 @@ CONTAINS ! SOURCE SUBROUTINE h5topen_f(loc_id, name, type_id, hdferr, tapl_id) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: loc_id + INTEGER(HID_T), INTENT(IN) :: loc_id CHARACTER(LEN=*), INTENT(IN) :: name INTEGER(HID_T), INTENT(OUT) :: type_id INTEGER, INTENT(OUT) :: hdferr @@ -231,7 +231,7 @@ CONTAINS ! SOURCE SUBROUTINE h5tcopy_f(type_id, new_type_id, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: type_id + INTEGER(HID_T), INTENT(IN) :: type_id INTEGER(HID_T), INTENT(OUT) :: new_type_id INTEGER, INTENT(OUT) :: hdferr !***** @@ -242,7 +242,7 @@ CONTAINS INTEGER(HID_T), INTENT(OUT) :: new_type_id END FUNCTION h5tcopy_c END INTERFACE - + hdferr = h5tcopy_c(type_id, new_type_id) END SUBROUTINE h5tcopy_f ! @@ -288,7 +288,7 @@ CONTAINS INTEGER :: c_flag END FUNCTION h5tequal_c END INTERFACE - + flag = .FALSE. hdferr = h5tequal_c(type1_id, type2_id, c_flag) IF(c_flag .GT. 0) flag = .TRUE. @@ -329,7 +329,7 @@ CONTAINS INTEGER(HID_T), INTENT(IN) :: type_id END FUNCTION h5tclose_c END INTERFACE - + hdferr = h5tclose_c(type_id) END SUBROUTINE h5tclose_f ! @@ -356,7 +356,7 @@ CONTAINS ! H5T_REFERENCE_F (7) ! H5T_ENUM_F (8) ! H5T_VLEN_F (9) -! H5T_ARRAY_F (10) +! H5T_ARRAY_F (10) ! hdferr - Returns 0 if successful and -1 if fails ! ! AUTHOR @@ -372,7 +372,7 @@ CONTAINS SUBROUTINE h5tget_class_f(type_id, class, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: type_id - INTEGER, INTENT(OUT) :: class + INTEGER, INTENT(OUT) :: class INTEGER, INTENT(OUT) :: hdferr !***** INTERFACE @@ -425,7 +425,7 @@ CONTAINS INTEGER(SIZE_T), INTENT(OUT) :: size END FUNCTION h5tget_size_c END INTERFACE - + hdferr = h5tget_size_c(type_id, size) END SUBROUTINE h5tget_size_f @@ -469,7 +469,7 @@ CONTAINS INTEGER(SIZE_T), INTENT(IN) :: size END FUNCTION h5tset_size_c END INTERFACE - + hdferr = h5tset_size_c(type_id, size) END SUBROUTINE h5tset_size_f @@ -519,7 +519,7 @@ CONTAINS INTEGER, INTENT(OUT) :: order END FUNCTION h5tget_order_c END INTERFACE - + hdferr = h5tget_order_c(type_id, order) END SUBROUTINE h5tget_order_f ! @@ -567,7 +567,7 @@ CONTAINS INTEGER, INTENT(IN) :: order END FUNCTION h5tset_order_c END INTERFACE - + hdferr = h5tset_order_c(type_id, order) END SUBROUTINE h5tset_order_f @@ -600,7 +600,7 @@ CONTAINS IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: type_id INTEGER(SIZE_T), INTENT(OUT) :: precision - INTEGER, INTENT(OUT) :: hdferr + INTEGER, INTENT(OUT) :: hdferr !***** INTERFACE INTEGER FUNCTION h5tget_precision_c(type_id, PRECISION) BIND(C,NAME='h5tget_precision_c') @@ -642,7 +642,7 @@ CONTAINS SUBROUTINE h5tset_precision_f(type_id, PRECISION, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: type_id - INTEGER(SIZE_T), INTENT(IN) :: PRECISION + INTEGER(SIZE_T), INTENT(IN) :: PRECISION INTEGER, INTENT(OUT) :: hdferr !***** INTERFACE @@ -653,7 +653,7 @@ CONTAINS INTEGER(SIZE_T), INTENT(IN) :: PRECISION END FUNCTION h5tset_precision_c END INTERFACE - + hdferr = h5tset_precision_c(type_id, PRECISION) END SUBROUTINE h5tset_precision_f @@ -695,10 +695,10 @@ CONTAINS INTEGER(SIZE_T), INTENT(OUT) :: offset END FUNCTION h5tget_offset_c END INTERFACE - + hdferr = h5tget_offset_c(type_id, offset) END SUBROUTINE h5tget_offset_f - + ! !****s* H5T/h5tset_offset_f ! @@ -737,10 +737,10 @@ CONTAINS INTEGER(SIZE_T), INTENT(IN) :: offset END FUNCTION h5tset_offset_c END INTERFACE - + hdferr = h5tset_offset_c(type_id, offset) END SUBROUTINE h5tset_offset_f - + ! !****s* H5T/h5tget_pad_f ! @@ -757,7 +757,7 @@ CONTAINS ! lsbpad - least-significant bit padding type ! msbpad - most-significant bit padding type ! Possible values of padding type are: -! H5T_PAD_ERROR_F +! H5T_PAD_ERROR_F ! H5T_PAD_ZERO_F ! H5T_PAD_ONE_F ! H5T_PAD_BACKGROUND_F @@ -790,7 +790,7 @@ CONTAINS INTEGER, INTENT(OUT) :: msbpad END FUNCTION h5tget_pad_c END INTERFACE - + hdferr = h5tget_pad_c(type_id, lsbpad, msbpad) END SUBROUTINE h5tget_pad_f @@ -841,10 +841,10 @@ CONTAINS INTEGER, INTENT(IN) :: msbpad END FUNCTION h5tset_pad_c END INTERFACE - + hdferr = h5tset_pad_c(type_id, lsbpad, msbpad) END SUBROUTINE h5tset_pad_f - + ! !****s* H5T/h5tget_sign_f ! @@ -859,7 +859,7 @@ CONTAINS ! OUTPUTS ! sign - sign type ! Possible values are: -! - Unsigned integer type +! - Unsigned integer type ! H5T_SGN_NONE_F = 0 ! - Two's complement signed integer type ! H5T_SGN_2_F = 1 @@ -877,7 +877,7 @@ CONTAINS ! SOURCE SUBROUTINE h5tget_sign_f(type_id, sign, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: type_id + INTEGER(HID_T), INTENT(IN) :: type_id INTEGER, INTENT(OUT) :: sign INTEGER, INTENT(OUT) :: hdferr !***** @@ -890,10 +890,10 @@ CONTAINS INTEGER, INTENT(OUT) :: sign END FUNCTION h5tget_sign_c END INTERFACE - + hdferr = h5tget_sign_c(type_id, sign) END SUBROUTINE h5tget_sign_f - + ! !****s* H5T/h5tset_sign_f ! @@ -907,7 +907,7 @@ CONTAINS ! type_id - datatype identifier ! sign - sign type ! Possible values are: -! - Unsigned integer type +! - Unsigned integer type ! H5T_SGN_NONE_F = 0 ! - Two's complement signed integer type ! H5T_SGN_2_F = 1 @@ -938,7 +938,7 @@ CONTAINS INTEGER, INTENT(IN) :: sign END FUNCTION h5tset_sign_c END INTERFACE - + hdferr = h5tset_sign_c(type_id, sign) END SUBROUTINE h5tset_sign_f @@ -994,7 +994,7 @@ CONTAINS INTEGER(SIZE_T), INTENT(OUT) :: msize END FUNCTION h5tget_fields_c END INTERFACE - + hdferr = h5tget_fields_c(type_id, spos, epos, esize, mpos, msize) END SUBROUTINE h5tget_fields_f @@ -1028,7 +1028,7 @@ CONTAINS ! SOURCE SUBROUTINE h5tset_fields_f(type_id, spos, epos, esize, mpos, msize, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: type_id + INTEGER(HID_T), INTENT(IN) :: type_id INTEGER(SIZE_T), INTENT(IN) :: spos INTEGER(SIZE_T), INTENT(IN) :: epos INTEGER(SIZE_T), INTENT(IN) :: esize @@ -1050,10 +1050,10 @@ CONTAINS INTEGER(SIZE_T), INTENT(IN) :: msize END FUNCTION h5tset_fields_c END INTERFACE - + hdferr = h5tset_fields_c(type_id, spos, epos, esize, mpos, msize) END SUBROUTINE h5tset_fields_f - + ! !****s* H5T/h5tget_ebias_f ! @@ -1084,7 +1084,7 @@ CONTAINS INTEGER(SIZE_T), INTENT(OUT) :: ebias INTEGER, INTENT(OUT) :: hdferr !***** - + INTERFACE INTEGER FUNCTION h5tget_ebias_c(type_id, ebias) BIND(C,NAME='h5tget_ebias_c') IMPORT :: HID_T, SIZE_T @@ -1093,7 +1093,7 @@ CONTAINS INTEGER(SIZE_T), INTENT(OUT) :: ebias END FUNCTION h5tget_ebias_c END INTERFACE - + hdferr = h5tget_ebias_c(type_id, ebias) END SUBROUTINE h5tget_ebias_f @@ -1135,7 +1135,7 @@ CONTAINS INTEGER(SIZE_T), INTENT(IN) :: ebias END FUNCTION h5tset_ebias_c END INTERFACE - + hdferr = h5tset_ebias_c(type_id, ebias) END SUBROUTINE h5tset_ebias_f @@ -1182,7 +1182,7 @@ CONTAINS INTEGER, INTENT(OUT) :: norm END FUNCTION h5tget_norm_c END INTERFACE - + hdferr = h5tget_norm_c(type_id, norm) END SUBROUTINE h5tget_norm_f @@ -1228,7 +1228,7 @@ CONTAINS INTEGER, INTENT(IN) :: norm END FUNCTION h5tset_norm_c END INTERFACE - + hdferr = h5tset_norm_c(type_id, norm) END SUBROUTINE h5tset_norm_f @@ -1275,7 +1275,7 @@ CONTAINS INTEGER, INTENT(OUT) :: padtype END FUNCTION h5tget_inpad_c END INTERFACE - + hdferr = h5tget_inpad_c(type_id, padtype) END SUBROUTINE h5tget_inpad_f @@ -1321,7 +1321,7 @@ CONTAINS INTEGER, INTENT(IN) :: padtype END FUNCTION h5tset_inpad_c END INTERFACE - + hdferr = h5tset_inpad_c(type_id, padtype) END SUBROUTINE h5tset_inpad_f @@ -1366,7 +1366,7 @@ CONTAINS INTEGER, INTENT(OUT) :: cset END FUNCTION h5tget_cset_c END INTERFACE - + hdferr = h5tget_cset_c(type_id, cset) END SUBROUTINE h5tget_cset_f @@ -1411,7 +1411,7 @@ CONTAINS INTEGER, INTENT(IN) :: cset END FUNCTION h5tset_cset_c END INTERFACE - + hdferr = h5tset_cset_c(type_id, cset) END SUBROUTINE h5tset_cset_f ! @@ -1457,7 +1457,7 @@ CONTAINS INTEGER, INTENT(OUT) :: strpad END FUNCTION h5tget_strpad_c END INTERFACE - + hdferr = h5tget_strpad_c(type_id, strpad) END SUBROUTINE h5tget_strpad_f @@ -1547,7 +1547,7 @@ CONTAINS INTEGER, INTENT(OUT) :: num_members END FUNCTION h5tget_nmembers_c END INTERFACE - + hdferr = h5tget_nmembers_c(type_id, num_members) END SUBROUTINE h5tget_nmembers_f @@ -1596,7 +1596,7 @@ CONTAINS INTEGER, INTENT(OUT) :: namelen END FUNCTION h5tget_member_name_c END INTERFACE - + hdferr = h5tget_member_name_c(type_id, index, member_name, namelen) END SUBROUTINE h5tget_member_name_f @@ -1641,7 +1641,7 @@ CONTAINS INTEGER(SIZE_T), INTENT(OUT) :: offset END FUNCTION h5tget_member_offset_c END INTERFACE - + hdferr = h5tget_member_offset_c(type_id, member_no, offset ) END SUBROUTINE h5tget_member_offset_f ! @@ -1686,11 +1686,11 @@ CONTAINS INTEGER, INTENT(OUT) :: index END FUNCTION h5tget_member_index_c END INTERFACE - + namelen = LEN(name) hdferr = h5tget_member_index_c(type_id, name, namelen, index) END SUBROUTINE h5tget_member_index_f - + ! !$! ! !$!****s* H5T/h5tget_member_dim_f @@ -1774,9 +1774,9 @@ CONTAINS INTEGER(HSIZE_T),DIMENSION(*), INTENT(OUT) :: dims END FUNCTION h5tget_array_dims_c END INTERFACE - + hdferr = h5tget_array_dims_c(type_id, dims) - + END SUBROUTINE h5tget_array_dims_f ! @@ -1817,9 +1817,9 @@ CONTAINS INTEGER, INTENT(OUT) :: ndims END FUNCTION h5tget_array_ndims_c END INTERFACE - + hdferr = h5tget_array_ndims_c(type_id, ndims) - + END SUBROUTINE h5tget_array_ndims_f ! @@ -1860,9 +1860,9 @@ CONTAINS INTEGER(HID_T), INTENT(OUT) :: base_type_id END FUNCTION h5tget_super_c END INTERFACE - + hdferr = h5tget_super_c(type_id, base_type_id) - + END SUBROUTINE h5tget_super_f ! @@ -1908,7 +1908,7 @@ CONTAINS INTEGER(HID_T), INTENT(OUT) :: datatype END FUNCTION h5tget_member_type_c END INTERFACE - + hdferr = h5tget_member_type_c(type_id, field_idx , datatype) END SUBROUTINE h5tget_member_type_f @@ -1992,7 +1992,7 @@ CONTAINS SUBROUTINE h5tinsert_f(type_id, name, offset, field_id, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: type_id - CHARACTER(LEN=*), INTENT(IN) :: name + CHARACTER(LEN=*), INTENT(IN) :: name INTEGER(SIZE_T), INTENT(IN) :: offset INTEGER(HID_T), INTENT(IN) :: field_id INTEGER, INTENT(OUT) :: hdferr @@ -2011,11 +2011,11 @@ CONTAINS INTEGER :: namelen END FUNCTION h5tinsert_c END INTERFACE - + namelen = LEN(name) hdferr = h5tinsert_c(type_id, name, namelen, offset, field_id ) END SUBROUTINE h5tinsert_f - + ! !****s* H5T/h5tpack_f ! @@ -2051,10 +2051,10 @@ CONTAINS INTEGER(HID_T), INTENT(IN) :: type_id END FUNCTION h5tpack_c END INTERFACE - + hdferr = h5tpack_c(type_id) END SUBROUTINE h5tpack_f - + ! !$! ! !$!****s* H5T/h5tinsert_array_f ! !$! @@ -2150,9 +2150,9 @@ CONTAINS INTEGER(HID_T), INTENT(OUT) :: type_id END FUNCTION h5tarray_create_c END INTERFACE - + hdferr = h5tarray_create_c(base_id, rank, dims, type_id) - + END SUBROUTINE h5tarray_create_f ! @@ -2194,7 +2194,7 @@ CONTAINS INTEGER(HID_T), INTENT(OUT) :: new_type_id END FUNCTION h5tenum_create_c END INTERFACE - + hdferr = h5tenum_create_c(parent_id, new_type_id) END SUBROUTINE h5tenum_create_f ! @@ -2225,9 +2225,9 @@ CONTAINS ! port). March 7, 2001 ! ! NOTE -! According to the standard: Because an INTENT(OUT) variable is considered undefined -! on entry to the procedure, any default initialization specified for its type will -! be applied. So we need to blank out the "name" to be portable and eliminate any +! According to the standard: Because an INTENT(OUT) variable is considered undefined +! on entry to the procedure, any default initialization specified for its type will +! be applied. So we need to blank out the "name" to be portable and eliminate any ! characters the "name' may contain upon entry, depending on compiler implementation. ! SOURCE SUBROUTINE h5tenum_nameof_f(type_id, value, namelen, name, hdferr) @@ -2249,7 +2249,7 @@ CONTAINS INTEGER, INTENT(IN) :: value END FUNCTION h5tenum_nameof_c END INTERFACE - + name(1:LEN(name)) = ' ' hdferr = h5tenum_nameof_c(type_id, value, name, namelen) @@ -2302,7 +2302,7 @@ CONTAINS INTEGER, INTENT(OUT) :: value END FUNCTION h5tenum_valueof_c END INTERFACE - + namelen = LEN(name) hdferr = h5tenum_valueof_c(type_id, name, namelen, value) END SUBROUTINE h5tenum_valueof_f @@ -2349,10 +2349,10 @@ CONTAINS INTEGER, INTENT(OUT) :: value END FUNCTION h5tget_member_value_c END INTERFACE - + hdferr = h5tget_member_value_c(type_id, member_no, value) END SUBROUTINE h5tget_member_value_f - + ! !****s* H5T/h5tset_tag_f ! @@ -2385,7 +2385,7 @@ CONTAINS INTEGER, INTENT(OUT) :: hdferr !***** INTEGER :: taglen - + INTERFACE INTEGER FUNCTION h5tset_tag_c(type_id, tag, taglen) BIND(C,NAME='h5tset_tag_c') IMPORT :: C_CHAR @@ -2396,11 +2396,11 @@ CONTAINS INTEGER :: taglen END FUNCTION h5tset_tag_c END INTERFACE - + taglen = LEN(tag) hdferr = h5tset_tag_c(type_id, tag, taglen) END SUBROUTINE h5tset_tag_f - + ! !****s* H5T/h5tget_tag_f ! @@ -2434,7 +2434,7 @@ CONTAINS INTEGER, INTENT(OUT) :: taglen INTEGER, INTENT(OUT) :: hdferr !***** - INTEGER(SIZE_T):: tag_size ! Declared character length of tab + INTEGER(SIZE_T):: tag_size ! Declared character length of tab INTERFACE INTEGER FUNCTION h5tget_tag_c(type_id, tag, tag_size, taglen) & BIND(C,NAME='h5tget_tag_c') @@ -2447,11 +2447,11 @@ CONTAINS INTEGER, INTENT(OUT) :: taglen END FUNCTION h5tget_tag_c END INTERFACE - + tag_size = LEN(tag) hdferr = h5tget_tag_c(type_id, tag, tag_size, taglen ) END SUBROUTINE h5tget_tag_f - + ! !****s* H5T/h5tvlen_create_f ! @@ -2489,7 +2489,7 @@ CONTAINS INTEGER(HID_T), INTENT(OUT) :: vltype_id END FUNCTION h5tvlen_create_c END INTERFACE - + hdferr = h5tvlen_create_c(type_id, vltype_id) END SUBROUTINE h5tvlen_create_f @@ -2517,11 +2517,11 @@ CONTAINS SUBROUTINE h5tis_variable_str_f(type_id, status, hdferr) IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: type_id - LOGICAL, INTENT(OUT) :: status + LOGICAL, INTENT(OUT) :: status INTEGER, INTENT(OUT) :: hdferr !***** INTEGER :: flag ! "TRUE/FALSE/ERROR from C" - + INTERFACE INTEGER FUNCTION h5tis_variable_str_c(type_id, flag) & BIND(C,NAME='h5tis_variable_str_c') @@ -2531,13 +2531,13 @@ CONTAINS INTEGER :: flag END FUNCTION h5tis_variable_str_c END INTERFACE - + hdferr = h5tis_variable_str_c(type_id, flag) status = .TRUE. IF (flag .EQ. 0) status = .FALSE. - + END SUBROUTINE h5tis_variable_str_f - + ! !****s* H5T/h5tget_member_class_f ! @@ -2728,7 +2728,7 @@ CONTAINS SUBROUTINE h5tdecode_f(buf, obj_id, hdferr) IMPLICIT NONE CHARACTER(LEN=*), INTENT(IN) :: buf - INTEGER(HID_T), INTENT(OUT) :: obj_id + INTEGER(HID_T), INTENT(OUT) :: obj_id INTEGER, INTENT(OUT) :: hdferr !***** INTERFACE @@ -2811,7 +2811,7 @@ CONTAINS ! SOURCE SUBROUTINE h5tget_create_plist_f(dtype_id, dtpl_id, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: dtype_id + INTEGER(HID_T), INTENT(IN) :: dtype_id INTEGER(HID_T), INTENT(OUT) :: dtpl_id INTEGER, INTENT(OUT) :: hdferr !***** @@ -2884,7 +2884,7 @@ CONTAINS ! ! INPUTS ! dtype_id - Datatype identifier for the dataset datatype. -! +! ! direction - Direction of search: ! H5T_DIR_DEFAULT, default direction is inscendent, ! H5T_DIR_ASCEND , in inscendent order, @@ -2901,8 +2901,8 @@ CONTAINS ! SOURCE SUBROUTINE h5tget_native_type_f(dtype_id, direction, native_dtype_id, hdferr) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: dtype_id - INTEGER, INTENT(IN) :: direction + INTEGER(HID_T), INTENT(IN) :: dtype_id + INTEGER, INTENT(IN) :: direction INTEGER(HID_T), INTENT(OUT) :: native_dtype_id INTEGER, INTENT(OUT) :: hdferr !***** @@ -3025,7 +3025,7 @@ CONTAINS INTEGER :: namelen END FUNCTION h5tenum_insert_c END INTERFACE - + namelen = LEN(name) hdferr = h5tenum_insert_c(type_id, name, namelen, value) END SUBROUTINE h5tenum_insert_f90 @@ -3061,7 +3061,7 @@ CONTAINS INTEGER, INTENT(OUT) :: hdferr !***** INTEGER :: namelen - + INTERFACE INTEGER FUNCTION h5tenum_insert_ptr_c(type_id, name, namelen, value) & BIND(C, NAME='h5tenum_insert_ptr_c') @@ -3074,7 +3074,7 @@ CONTAINS TYPE(C_PTR), VALUE :: value END FUNCTION h5tenum_insert_ptr_c END INTERFACE - + namelen = LEN(name) hdferr = h5tenum_insert_ptr_c(type_id, name, namelen, value) END SUBROUTINE h5tenum_insert_f03 diff --git a/fortran/src/H5VLff.F90 b/fortran/src/H5VLff.F90 index 32dd7d7..ae03cee 100644 --- a/fortran/src/H5VLff.F90 +++ b/fortran/src/H5VLff.F90 @@ -82,7 +82,7 @@ CONTAINS INTEGER(HID_T), INTENT(IN), VALUE :: vipl_id END FUNCTION H5VLregister_connector_by_name END INTERFACE - + vipl_id_default = H5P_DEFAULT_F IF(PRESENT(vipl_id)) vipl_id_default = vipl_id @@ -136,7 +136,7 @@ CONTAINS ! INPUTS ! name - Connector name ! OUTPUTS -! registered - state of VOL class registration +! registered - state of VOL class registration ! hdferr - Returns 0 if successful and -1 if fails ! SOURCE @@ -156,7 +156,7 @@ CONTAINS CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(IN) :: name END FUNCTION H5VLis_connector_registered_by_name END INTERFACE - + c_name = TRIM(name)//C_NULL_CHAR registered_c = H5VLis_connector_registered_by_name(c_name) @@ -180,7 +180,7 @@ CONTAINS ! INPUTS ! value - Connector value ! OUTPUTS -! registered - state of VOL class registration +! registered - state of VOL class registration ! hdferr - Returns 0 if successful and -1 if fails ! SOURCE @@ -278,10 +278,10 @@ CONTAINS CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(IN) :: name END FUNCTION H5VLget_connector_id_by_name END INTERFACE - + c_name = TRIM(name)//C_NULL_CHAR vol_id = H5VLget_connector_id_by_name(c_name) - + hdferr = 0 IF(vol_id.LT.0)THEN hdferr = -1 @@ -367,7 +367,7 @@ CONTAINS END SUBROUTINE H5VLget_connector_name_f -! +! ! !****s* H5VL/H5VLclose_f ! diff --git a/fortran/src/H5Zff.F90 b/fortran/src/H5Zff.F90 index 848f047..6bd7b45 100644 --- a/fortran/src/H5Zff.F90 +++ b/fortran/src/H5Zff.F90 @@ -56,7 +56,7 @@ CONTAINS ! H5Z_FILTER_SCALEOFFSET_F ! H5Z_FILTER_SHUFFLE_F ! H5Z_FILTER_FLETCHER32_F -! +! ! OUTPUTS ! hdferr - Error code ! Success: 0 @@ -147,7 +147,7 @@ CONTAINS ! H5Z_FILTER_SHUFFLE_F ! H5Z_FILTER_FLETCHER32_Ffilter ! OUTPUTS -! config_flags - Flag, indicates if filter has its encoder +! config_flags - Flag, indicates if filter has its encoder ! and/or decoder available, possibly containing the ! following values: ! H5Z_FILTER_ENCODE_ENABLED_F diff --git a/fortran/src/H5_buildiface.F90 b/fortran/src/H5_buildiface.F90 index f793b7f..e81e1c0 100644 --- a/fortran/src/H5_buildiface.F90 +++ b/fortran/src/H5_buildiface.F90 @@ -13,8 +13,8 @@ ! depending on which of the KIND values are found. ! ! NOTES -! This program uses the Fortran 2008 intrinsic function STORAGE_SIZE or SIZEOF -! depending on availablity.It generates code that makes use of +! This program uses the Fortran 2008 intrinsic function STORAGE_SIZE or SIZEOF +! depending on availablity.It generates code that makes use of ! STORAGE_SIZE/SIZEOF in H5_gen.F90. STORAGE_SIZE is standard ! compliant and should always be chosen over SIZEOF. ! @@ -47,7 +47,7 @@ #include PROGRAM H5_buildiface - USE, INTRINSIC :: ISO_C_BINDING + USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR, C_CHAR, C_LOC IMPLICIT NONE ! These values are valid REAL KINDs (with corresponding C float) found during configure @@ -98,7 +98,7 @@ PROGRAM H5_buildiface ! ! DEVELOPER'S NOTES: ! -! Only interfaces with arrays of rank 7 and less are provided. Even-though, the F2008 +! Only interfaces with arrays of rank 7 and less are provided. Even-though, the F2008 ! standard extended the maximum rank to 15, it was decided that user's should use the ! new APIs to handle those use cases. Handling rank 7 and less is for backward compatibility ! with the Fortran 90/95 APIs codes which could never handle ranks greater than 7. @@ -135,7 +135,7 @@ PROGRAM H5_buildiface WRITE(11,'(A)') "MODULE H5_GEN" - WRITE(11,'(2X,A)') 'USE, INTRINSIC :: ISO_C_BINDING' + WRITE(11,'(2X,A)') 'USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR, C_LOC' WRITE(11,'(2X,A)') 'USE H5GLOBAL' WRITE(11,'(2X,A)') 'USE H5A' @@ -195,7 +195,7 @@ PROGRAM H5_buildiface DO k = 1, 8 WRITE(11,'(2X,A)') "PRIVATE h5dwrite_ikind_"//TRIM(ADJUSTL(chr2))//'_rank'//chr_rank(k) ENDDO - END DO + END DO DO k = 2, 8 WRITE(11,'(2X,A)') "PRIVATE h5dwrite_ckind_rank"//chr_rank(k) END DO @@ -211,7 +211,7 @@ PROGRAM H5_buildiface WRITE(chr2,'(I2)') j DO k = 1, 8 WRITE(11,'(2X,A)') "PRIVATE h5dread_ikind_"//TRIM(ADJUSTL(chr2))//'_rank'//chr_rank(k) - ENDDO + ENDDO END DO DO k = 2, 8 WRITE(11,'(2X,A)') "PRIVATE h5dread_ckind_rank"//chr_rank(k) @@ -313,7 +313,7 @@ PROGRAM H5_buildiface DO k = 1, 8 WRITE(11,'(5X,A)') "MODULE PROCEDURE h5dwrite_ikind_"//TRIM(ADJUSTL(chr2))//'_rank'//chr_rank(k) ENDDO - END DO + END DO DO k = 2, 8 WRITE(11,'(5X,A)') "MODULE PROCEDURE h5dwrite_ckind_rank"//chr_rank(k) END DO @@ -333,7 +333,7 @@ PROGRAM H5_buildiface WRITE(chr2,'(I2)') j DO k = 1, 8 WRITE(11,'(5X,A)') "MODULE PROCEDURE h5dread_ikind_"//TRIM(ADJUSTL(chr2))//'_rank'//chr_rank(k) - ENDDO + ENDDO END DO DO k = 2, 8 WRITE(11,'(5X,A)') "MODULE PROCEDURE h5dread_ckind_rank"//chr_rank(k) @@ -448,7 +448,7 @@ PROGRAM H5_buildiface ! up to 7 dimensions. ! ! Fortran90 Interface: -!! SUBROUTINE H5Awrite_f(attr_id, memtype_id, buf, dims, hdferr) +!! SUBROUTINE H5Awrite_f(attr_id, memtype_id, buf, dims, hdferr) !! INTEGER(HID_T) , INTENT(IN) :: attr_id !! INTEGER(HID_T) , INTENT(IN) :: memtype_id !! TYPE , INTENT(IN) :: buf @@ -476,7 +476,7 @@ PROGRAM H5_buildiface WRITE(11,'(A)') ' REAL(KIND='//TRIM(ADJUSTL(chr2))//'),INTENT(IN)'//TRIM(rank_dim_line(j))//', TARGET :: buf' WRITE(11,'(A)') ' INTEGER , INTENT(OUT) :: hdferr' WRITE(11,'(A)') ' TYPE(C_PTR) :: f_ptr' - + WRITE(11,'(A)') f_ptr_line(j) WRITE(11,'(A)') ' hdferr = H5Awrite_f_c(attr_id, memtype_id, f_ptr)' WRITE(11,'(A)') ' END SUBROUTINE h5awrite_rkind_'//TRIM(ADJUSTL(chr2))//'_rank'//chr_rank(j) @@ -502,7 +502,7 @@ PROGRAM H5_buildiface WRITE(11,'(A)') ' INTEGER(KIND='//TRIM(ADJUSTL(chr2))//'),INTENT(IN)'//TRIM(rank_dim_line(j))//', TARGET :: buf' WRITE(11,'(A)') ' INTEGER , INTENT(OUT) :: hdferr' WRITE(11,'(A)') ' TYPE(C_PTR) :: f_ptr' - + WRITE(11,'(A)') f_ptr_line(j) WRITE(11,'(A)') ' hdferr = H5Awrite_f_c(attr_id, memtype_id, f_ptr)' WRITE(11,'(A)') ' END SUBROUTINE h5awrite_ikind_'//TRIM(ADJUSTL(chr2))//'_rank'//chr_rank(j) @@ -524,7 +524,7 @@ PROGRAM H5_buildiface WRITE(11,'(A)') ' CHARACTER(LEN=*) , INTENT(IN)'//TRIM(rank_dim_line(j))//', TARGET :: buf' WRITE(11,'(A)') ' INTEGER , INTENT(OUT) :: hdferr' WRITE(11,'(A)') ' TYPE(C_PTR) :: f_ptr' - + WRITE(11,'(A)') fchr_ptr_line(j) WRITE(11,'(A)') ' hdferr = H5Awrite_f_c(attr_id, memtype_id, f_ptr)' WRITE(11,'(A)') ' END SUBROUTINE h5awrite_ckind_rank'//chr_rank(j) @@ -574,7 +574,7 @@ PROGRAM H5_buildiface ! REAL, REAL(KIND=C_DOUBLE) and CHARACTER buffers ! up to 7 dimensions. ! Fortran90 Interface: -!! SUBROUTINE H5Aread_f(attr_id, memtype_id, buf, dims, hdferr) +!! SUBROUTINE H5Aread_f(attr_id, memtype_id, buf, dims, hdferr) !! INTEGER(HID_T) , INTENT(IN) :: attr_id !! INTEGER(HID_T) , INTENT(IN) :: memtype_id !! TYPE , INTENT(INOUT) :: buf @@ -599,7 +599,7 @@ PROGRAM H5_buildiface WRITE(11,'(A)') ' REAL(KIND='//TRIM(ADJUSTL(chr2))//'),INTENT(INOUT)'//TRIM(rank_dim_line(j))//', TARGET :: buf' WRITE(11,'(A)') ' INTEGER , INTENT(OUT) :: hdferr' WRITE(11,'(A)') ' TYPE(C_PTR) :: f_ptr' - + WRITE(11,'(A)') f_ptr_line(j) WRITE(11,'(A)') ' hdferr = H5Aread_f_c(attr_id, memtype_id, f_ptr)' WRITE(11,'(A)') ' END SUBROUTINE h5aread_rkind_'//TRIM(ADJUSTL(chr2))//'_rank'//chr_rank(j) @@ -623,7 +623,7 @@ PROGRAM H5_buildiface WRITE(11,'(A)') ' INTEGER(KIND='//TRIM(ADJUSTL(chr2))//'),INTENT(INOUT)'//TRIM(rank_dim_line(j))//', TARGET :: buf' WRITE(11,'(A)') ' INTEGER , INTENT(OUT) :: hdferr' WRITE(11,'(A)') ' TYPE(C_PTR) :: f_ptr' - + WRITE(11,'(A)') f_ptr_line(j) WRITE(11,'(A)') ' hdferr = H5Aread_f_c(attr_id, memtype_id, f_ptr)' WRITE(11,'(A)') ' END SUBROUTINE h5aread_ikind_'//TRIM(ADJUSTL(chr2))//'_rank'//chr_rank(j) @@ -643,7 +643,7 @@ PROGRAM H5_buildiface WRITE(11,'(A)') ' CHARACTER(LEN=*), INTENT(IN)'//TRIM(rank_dim_line(j))//', TARGET :: buf' WRITE(11,'(A)') ' INTEGER , INTENT(OUT) :: hdferr' WRITE(11,'(A)') ' TYPE(C_PTR) :: f_ptr' - + WRITE(11,'(A)') fchr_ptr_line(j) WRITE(11,'(A)') ' hdferr = H5Aread_f_c(attr_id, memtype_id, f_ptr)' WRITE(11,'(A)') ' END SUBROUTINE h5aread_ckind_rank'//chr_rank(j) @@ -656,7 +656,7 @@ PROGRAM H5_buildiface ! h5dread_f ! -! NAME +! NAME ! h5dread_f ! ! PURPOSE @@ -683,7 +683,7 @@ PROGRAM H5_buildiface ! Elena Pourmal ! August 12, 1999 ! -! HISTORY +! HISTORY ! Explicit Fortran interfaces were added for ! called C functions (it is needed for Windows ! port). February 28, 2001 @@ -693,7 +693,7 @@ PROGRAM H5_buildiface ! the h5dwrite_reference_obj and h5dwrite_reference_dsetreg ! functions. April 2, 2001 ! -! NOTES +! NOTES ! This function is overloaded to read INTEGER, ! REAL, DOUBLE PRECISION and CHARACTER buffers ! up to 7 dimensions, and one dimensional buffers @@ -712,7 +712,6 @@ PROGRAM H5_buildiface WRITE(11,'(A)') ' SUBROUTINE h5dread_rkind_'//TRIM(ADJUSTL(chr2))& &//'_rank'//chr_rank(j)//'(dset_id, mem_type_id, buf, dims, hdferr, &' WRITE(11,'(A)') ' mem_space_id, file_space_id, xfer_prp)' - WRITE(11,'(A)') ' USE, INTRINSIC :: ISO_C_BINDING' WRITE(11,'(A)') ' IMPLICIT NONE' WRITE(11,'(A)') ' INTEGER(HID_T), INTENT(IN) :: dset_id' WRITE(11,'(A)') ' INTEGER(HID_T), INTENT(IN) :: mem_type_id' @@ -752,7 +751,6 @@ PROGRAM H5_buildiface WRITE(11,'(A)') ' SUBROUTINE h5dread_ikind_'//TRIM(ADJUSTL(chr2))& &//'_rank'//chr_rank(j)//'(dset_id, mem_type_id, buf, dims, hdferr, &' WRITE(11,'(A)') ' mem_space_id, file_space_id, xfer_prp)' - WRITE(11,'(A)') ' USE, INTRINSIC :: ISO_C_BINDING' WRITE(11,'(A)') ' IMPLICIT NONE' WRITE(11,'(A)') ' INTEGER(HID_T), INTENT(IN) :: dset_id' WRITE(11,'(A)') ' INTEGER(HID_T), INTENT(IN) :: mem_type_id' @@ -787,7 +785,6 @@ PROGRAM H5_buildiface ! Subroutine API WRITE(11,'(A)') ' SUBROUTINE h5dread_ckind_rank'//chr_rank(j)//'(dset_id, mem_type_id, buf, dims, hdferr, &' WRITE(11,'(A)') ' mem_space_id, file_space_id, xfer_prp)' - WRITE(11,'(A)') ' USE, INTRINSIC :: ISO_C_BINDING' WRITE(11,'(A)') ' IMPLICIT NONE' WRITE(11,'(A)') ' INTEGER(HID_T), INTENT(IN) :: dset_id' WRITE(11,'(A)') ' INTEGER(HID_T), INTENT(IN) :: mem_type_id' @@ -827,7 +824,6 @@ PROGRAM H5_buildiface WRITE(11,'(A)') ' SUBROUTINE h5dwrite_rkind_'//TRIM(ADJUSTL(chr2))& &//'_rank'//chr_rank(j)//'(dset_id, mem_type_id, buf, dims, hdferr, &' WRITE(11,'(A)') ' mem_space_id, file_space_id, xfer_prp)' - WRITE(11,'(A)') ' USE, INTRINSIC :: ISO_C_BINDING' WRITE(11,'(A)') ' IMPLICIT NONE' WRITE(11,'(A)') ' INTEGER(HID_T), INTENT(IN) :: dset_id' WRITE(11,'(A)') ' INTEGER(HID_T), INTENT(IN) :: mem_type_id' @@ -866,7 +862,6 @@ PROGRAM H5_buildiface WRITE(11,'(A)') ' SUBROUTINE h5dwrite_ikind_'//TRIM(ADJUSTL(chr2))& &//'_rank'//chr_rank(j)//'(dset_id, mem_type_id, buf, dims, hdferr, &' WRITE(11,'(A)') ' mem_space_id, file_space_id, xfer_prp)' - WRITE(11,'(A)') ' USE, INTRINSIC :: ISO_C_BINDING' WRITE(11,'(A)') ' IMPLICIT NONE' WRITE(11,'(A)') ' INTEGER(HID_T), INTENT(IN) :: dset_id' WRITE(11,'(A)') ' INTEGER(HID_T), INTENT(IN) :: mem_type_id' @@ -891,7 +886,7 @@ PROGRAM H5_buildiface WRITE(11,'(A)') ' file_space_id_default, xfer_prp_default, f_ptr)' WRITE(11,'(A)') ' END SUBROUTINE h5dwrite_ikind_'//TRIM(ADJUSTL(chr2))//'_rank'//chr_rank(j) ENDDO - ENDDO + ENDDO DO j = 2, 8 ! DLL definitions for windows WRITE(11,'(A)') '!DEC$if defined(BUILD_HDF5_DLL)' @@ -900,7 +895,6 @@ PROGRAM H5_buildiface ! Subroutine API WRITE(11,'(A)') ' SUBROUTINE h5dwrite_ckind_rank'//chr_rank(j)//'(dset_id, mem_type_id, buf, dims, hdferr, &' WRITE(11,'(A)') ' mem_space_id, file_space_id, xfer_prp)' - WRITE(11,'(A)') ' USE, INTRINSIC :: ISO_C_BINDING' WRITE(11,'(A)') ' IMPLICIT NONE' WRITE(11,'(A)') ' INTEGER(HID_T), INTENT(IN) :: dset_id' WRITE(11,'(A)') ' INTEGER(HID_T), INTENT(IN) :: mem_type_id' @@ -944,7 +938,7 @@ PROGRAM H5_buildiface WRITE(11,'(A)') ' IMPLICIT NONE' WRITE(11,'(A)') ' INTEGER(HID_T), INTENT(IN) :: prp_id' WRITE(11,'(A)') ' INTEGER(HID_T), INTENT(IN) :: type_id' - WRITE(11,'(A)') ' REAL(KIND='//TRIM(ADJUSTL(chr2))//'), INTENT(IN), TARGET :: fillvalue' + WRITE(11,'(A)') ' REAL(KIND='//TRIM(ADJUSTL(chr2))//'), INTENT(IN), TARGET :: fillvalue' WRITE(11,'(A)') ' INTEGER, INTENT(OUT) :: hdferr ' WRITE(11,'(A)') ' TYPE(C_PTR) :: f_ptr ' WRITE(11,'(A)') ' f_ptr = C_LOC(fillvalue)' @@ -995,7 +989,7 @@ PROGRAM H5_buildiface WRITE(11,'(A)') ' f_ptr = C_LOC(value)' WRITE(11,'(A)') ' name_len = LEN(name)' WRITE(11,'(A)') ' hdferr = h5pget_c(prp_id, name, name_len, f_ptr)' - + WRITE(11,'(A)') ' END SUBROUTINE h5pset_kind_'//TRIM(ADJUSTL(chr2)) ENDDO diff --git a/fortran/src/H5_ff.F90 b/fortran/src/H5_ff.F90 index d77c25f..412074b 100644 --- a/fortran/src/H5_ff.F90 +++ b/fortran/src/H5_ff.F90 @@ -53,7 +53,7 @@ MODULE H5LIB ! INTEGER, PARAMETER :: H5generic_FLAGS_LEN = 9 INTEGER, DIMENSION(1:H5generic_FLAGS_LEN) :: H5generic_flags - + INTEGER, PARAMETER :: H5generic_haddr_FLAGS_LEN = 1 INTEGER(HADDR_T), DIMENSION(1:H5generic_haddr_FLAGS_LEN) :: H5generic_haddr_flags ! @@ -81,7 +81,7 @@ MODULE H5LIB INTEGER, PARAMETER :: H5FD_FLAGS_LEN = 11 INTEGER, DIMENSION(1:H5FD_FLAGS_LEN) :: H5FD_flags ! - ! H5FD file drivers flags declaration + ! H5FD file drivers flags declaration ! INTEGER, PARAMETER :: H5FD_HID_FLAGS_LEN = 7 INTEGER(HID_T), DIMENSION(1:H5FD_HID_FLAGS_LEN) :: H5FD_hid_flags @@ -170,7 +170,7 @@ CONTAINS ! October 13, 2011 ! Fortran90 Interface: SUBROUTINE h5open_f(error) - USE H5F, ONLY : h5fget_obj_count_f, H5OPEN_NUM_OBJ + USE H5F, ONLY : h5fget_obj_count_f, H5OPEN_NUM_OBJ IMPLICIT NONE INTEGER, INTENT(OUT) :: error INTEGER(SIZE_T) :: H5OPEN_NUM_OBJ_LOC = 0 @@ -249,13 +249,13 @@ CONTAINS END FUNCTION h5init1_flags_c END INTERFACE - + error = h5init_types_c(predef_types, floating_types, integer_types) - H5T_NATIVE_INTEGER_KIND(1:5) = predef_types(1:5) + H5T_NATIVE_INTEGER_KIND(1:5) = predef_types(1:5) H5T_NATIVE_INTEGER = predef_types(6) H5T_NATIVE_REAL = predef_types(7) - H5T_NATIVE_DOUBLE = predef_types(8) + H5T_NATIVE_DOUBLE = predef_types(8) H5T_NATIVE_CHARACTER = predef_types(9) H5T_STD_REF_OBJ = predef_types(10) H5T_STD_REF_DSETREG = predef_types(11) @@ -267,12 +267,12 @@ CONTAINS H5T_NATIVE_B32 = predef_types(17) H5T_NATIVE_B64 = predef_types(18) H5T_NATIVE_FLOAT_128 = predef_types(19) - + H5T_IEEE_F32BE = floating_types(1) H5T_IEEE_F32LE = floating_types(2) H5T_IEEE_F64BE = floating_types(3) - H5T_IEEE_F64LE = floating_types(4) - + H5T_IEEE_F64LE = floating_types(4) + H5T_STD_I8BE = integer_types(1) H5T_STD_I8LE = integer_types(2) H5T_STD_I16BE = integer_types(3) @@ -361,12 +361,12 @@ CONTAINS H5_ITER_DEC_F = H5generic_flags(7) H5_ITER_NATIVE_F = H5generic_flags(8) H5_ITER_N_F = H5generic_flags(9) - + HADDR_UNDEF_F = H5generic_haddr_flags(1) ! ! H5G flags ! - H5G_UNKNOWN_F = H5G_flags(1) + H5G_UNKNOWN_F = H5G_flags(1) H5G_GROUP_F = H5G_flags(2) H5G_DATASET_F = H5G_flags(3) H5G_TYPE_F = H5G_flags(4) @@ -410,7 +410,7 @@ CONTAINS H5D_VDS_FIRST_MISSING_F = H5D_flags(27) H5D_VDS_LAST_AVAILABLE_F = H5D_flags(28) H5D_VIRTUAL_F = H5D_flags(29) - + H5D_CHUNK_CACHE_NSLOTS_DFLT_F = H5D_size_flags(1) H5D_CHUNK_CACHE_NBYTES_DFLT_F = H5D_size_flags(2) ! @@ -419,7 +419,7 @@ CONTAINS H5E_DEFAULT_F = H5E_hid_flags(1) H5E_MAJOR_F = H5E_flags(1) - H5E_MINOR_F = H5E_flags(2) + H5E_MINOR_F = H5E_flags(2) H5E_WALK_UPWARD_F = H5E_flags(3) H5E_WALK_DOWNWARD_F = H5E_flags(4) ! @@ -438,7 +438,7 @@ CONTAINS H5FD_MEM_NTYPES_F = H5FD_flags(11) ! ! H5FD file driver flags - ! + ! H5FD_CORE_F = H5FD_hid_flags(1) H5FD_FAMILY_F = H5FD_hid_flags(2) H5FD_LOG_F = H5FD_hid_flags(3) @@ -468,7 +468,7 @@ CONTAINS H5I_INVALID_HID_F = H5I_flags(17) ! ! H5L flags - ! + ! H5L_TYPE_ERROR_F = H5L_flags(1) H5L_TYPE_HARD_F = H5L_flags(2) H5L_TYPE_SOFT_F = H5L_flags(3) @@ -485,25 +485,25 @@ CONTAINS H5O_COPY_WITHOUT_ATTR_FLAG_F = h5o_flags(5) H5O_COPY_PRESERVE_NULL_FLAG_F = h5o_flags(6) H5O_COPY_ALL_F = h5o_flags(7) - H5O_SHMESG_NONE_FLAG_F = h5o_flags(8) + H5O_SHMESG_NONE_FLAG_F = h5o_flags(8) H5O_SHMESG_SDSPACE_FLAG_F = h5o_flags(9) H5O_SHMESG_DTYPE_FLAG_F = h5o_flags(10) - H5O_SHMESG_FILL_FLAG_F = h5o_flags(11) - H5O_SHMESG_PLINE_FLAG_F = h5o_flags(12) - H5O_SHMESG_ATTR_FLAG_F = h5o_flags(13) - H5O_SHMESG_ALL_FLAG_F = h5o_flags(14) - H5O_HDR_CHUNK0_SIZE_F = h5o_flags(15) - H5O_HDR_ATTR_CRT_ORDER_TRACK_F = h5o_flags(16) - H5O_HDR_ATTR_CRT_ORDER_INDEX_F = h5o_flags(17) - H5O_HDR_ATTR_STORE_PHASE_CHA_F = h5o_flags(18) - H5O_HDR_STORE_TIMES_F = h5o_flags(19) + H5O_SHMESG_FILL_FLAG_F = h5o_flags(11) + H5O_SHMESG_PLINE_FLAG_F = h5o_flags(12) + H5O_SHMESG_ATTR_FLAG_F = h5o_flags(13) + H5O_SHMESG_ALL_FLAG_F = h5o_flags(14) + H5O_HDR_CHUNK0_SIZE_F = h5o_flags(15) + H5O_HDR_ATTR_CRT_ORDER_TRACK_F = h5o_flags(16) + H5O_HDR_ATTR_CRT_ORDER_INDEX_F = h5o_flags(17) + H5O_HDR_ATTR_STORE_PHASE_CHA_F = h5o_flags(18) + H5O_HDR_STORE_TIMES_F = h5o_flags(19) H5O_HDR_ALL_FLAGS_F = h5o_flags(20) - H5O_SHMESG_MAX_NINDEXES_F = h5o_flags(21) - H5O_SHMESG_MAX_LIST_SIZE_F = h5o_flags(22) - H5O_TYPE_UNKNOWN_F = h5o_flags(23) - H5O_TYPE_GROUP_F = h5o_flags(24) - H5O_TYPE_DATASET_F = h5o_flags(25) - H5O_TYPE_NAMED_DATATYPE_F = h5o_flags(26) + H5O_SHMESG_MAX_NINDEXES_F = h5o_flags(21) + H5O_SHMESG_MAX_LIST_SIZE_F = h5o_flags(22) + H5O_TYPE_UNKNOWN_F = h5o_flags(23) + H5O_TYPE_GROUP_F = h5o_flags(24) + H5O_TYPE_DATASET_F = h5o_flags(25) + H5O_TYPE_NAMED_DATATYPE_F = h5o_flags(26) H5O_TYPE_NTYPES_F = h5o_flags(27) H5O_INFO_ALL_F = h5o_flags(28) H5O_INFO_BASIC_F = h5o_flags(29) @@ -513,7 +513,7 @@ CONTAINS H5O_INFO_META_SIZE_F = h5o_flags(33) ! ! H5P flags - ! + ! H5P_FILE_CREATE_F = H5P_flags(1) H5P_FILE_ACCESS_F = H5P_flags(2) H5P_DATASET_CREATE_F = H5P_flags(3) @@ -534,21 +534,21 @@ CONTAINS H5P_LINK_ACCESS_F = H5P_flags(18) ! ! H5P integers flags - ! + ! H5P_CRT_ORDER_INDEXED_F = H5P_flags_int(1) H5P_CRT_ORDER_TRACKED_F = H5P_flags_int(2) ! ! H5R flags - ! + ! H5R_OBJECT_F = H5R_flags(1) H5R_DATASET_REGION_F = H5R_flags(2) ! ! H5S flags - ! + ! H5S_ALL_F = H5S_hid_flags(1) - + H5S_UNLIMITED_F = H5S_hsize_flags(1) - + H5S_SCALAR_F = H5S_flags(1) H5S_SIMPLE_F = H5S_flags(2) H5S_NULL_F = H5S_flags(3) @@ -569,7 +569,7 @@ CONTAINS H5S_SEL_ALL_F = H5S_flags(18) ! ! H5T flags declaration - ! + ! H5T_NO_CLASS_F = H5T_flags(1) H5T_INTEGER_F = H5T_flags(2) H5T_FLOAT_F = H5T_flags(3) diff --git a/fortran/src/H5f90global.F90 b/fortran/src/H5f90global.F90 index 90475ee..c4007ec 100644 --- a/fortran/src/H5f90global.F90 +++ b/fortran/src/H5f90global.F90 @@ -49,7 +49,7 @@ MODULE H5GLOBAL ENUMERATOR :: enum_dtype END ENUM INTEGER, PARAMETER :: ENUM_T = KIND(enum_dtype) - + ! Definitions for reference datatypes. ! If you change the value of these parameters, do not forget to change corresponding ! values in the H5f90.h file. @@ -87,7 +87,7 @@ MODULE H5GLOBAL INTEGER(HID_T), DIMENSION(1:PREDEF_TYPES_LEN) :: predef_types = -1 INTEGER(HID_T), DIMENSION(1:FLOATING_TYPES_LEN) :: floating_types = -1 INTEGER(HID_T), DIMENSION(1:INTEGER_TYPES_LEN) :: integer_types = -1 - + !DEC$if defined(BUILD_HDF5_DLL) !DEC$ATTRIBUTES DLLEXPORT :: H5T_NATIVE_REAL_C_FLOAT !DEC$ATTRIBUTES DLLEXPORT :: H5T_NATIVE_REAL_C_DOUBLE @@ -95,7 +95,7 @@ MODULE H5GLOBAL !DEC$ATTRIBUTES DLLEXPORT :: H5T_NATIVE_INTEGER !DEC$ATTRIBUTES DLLEXPORT :: H5T_NATIVE_REAL !DEC$ATTRIBUTES DLLEXPORT :: H5T_NATIVE_DOUBLE - !DEC$ATTRIBUTES DLLEXPORT :: H5T_NATIVE_CHARACTER + !DEC$ATTRIBUTES DLLEXPORT :: H5T_NATIVE_CHARACTER !DEC$ATTRIBUTES DLLEXPORT :: H5T_STD_REF_OBJ !DEC$ATTRIBUTES DLLEXPORT :: H5T_STD_REF_DSETREG !DEC$ATTRIBUTES DLLEXPORT :: H5T_IEEE_F32BE @@ -136,14 +136,14 @@ MODULE H5GLOBAL !DEC$ATTRIBUTES DLLEXPORT :: H5T_NATIVE_INTEGER_KIND !DEC$ATTRIBUTES DLLEXPORT :: H5T_NATIVE_FLOAT_128 !DEC$endif - + INTEGER(HID_T) :: H5T_NATIVE_REAL_C_FLOAT INTEGER(HID_T) :: H5T_NATIVE_REAL_C_DOUBLE INTEGER(HID_T) :: H5T_NATIVE_REAL_C_LONG_DOUBLE INTEGER(HID_T) :: H5T_NATIVE_INTEGER INTEGER(HID_T) :: H5T_NATIVE_REAL INTEGER(HID_T) :: H5T_NATIVE_DOUBLE - INTEGER(HID_T) :: H5T_NATIVE_CHARACTER + INTEGER(HID_T) :: H5T_NATIVE_CHARACTER INTEGER(HID_T) :: H5T_STD_REF_OBJ INTEGER(HID_T) :: H5T_STD_REF_DSETREG INTEGER(HID_T) :: H5T_IEEE_F32BE @@ -202,7 +202,7 @@ MODULE H5GLOBAL !DEC$ATTRIBUTES DLLEXPORT :: H5_ITER_N_F !DEC$ATTRIBUTES DLLEXPORT :: HADDR_UNDEF_F !DEC$endif - + INTEGER :: H5_INDEX_UNKNOWN_F INTEGER :: H5_INDEX_NAME_F INTEGER :: H5_INDEX_CRT_ORDER_F @@ -243,7 +243,7 @@ MODULE H5GLOBAL !DEC$ATTRIBUTES DLLEXPORT :: H5F_LIBVER_V110_F !DEC$ATTRIBUTES DLLEXPORT :: H5F_LIBVER_V112_F !DEC$endif - + INTEGER :: H5F_ACC_RDWR_F INTEGER :: H5F_ACC_RDONLY_F INTEGER :: H5F_ACC_TRUNC_F @@ -287,7 +287,7 @@ MODULE H5GLOBAL !DEC$ATTRIBUTES DLLEXPORT :: H5G_STORAGE_TYPE_COMPACT_F !DEC$ATTRIBUTES DLLEXPORT :: H5G_STORAGE_TYPE_DENSE_F !DEC$endif - + INTEGER :: H5G_UNKNOWN_F INTEGER :: H5G_GROUP_F INTEGER :: H5G_DATASET_F @@ -338,7 +338,7 @@ MODULE H5GLOBAL !DEC$ATTRIBUTES DLLEXPORT :: H5D_VDS_LAST_AVAILABLE_F !DEC$ATTRIBUTES DLLEXPORT :: H5D_VIRTUAL_F !DEC$endif - + INTEGER :: H5D_COMPACT_F INTEGER :: H5D_CONTIGUOUS_F INTEGER :: H5D_CHUNKED_F @@ -367,7 +367,7 @@ MODULE H5GLOBAL ! characters for variable names in Fortran. ! shortened "_CONTIGUOUS" to "_CONTIG" to satisfy the limit of 31 ! characters for variable names in Fortran. - + INTEGER(SIZE_T) :: H5D_CHUNK_CACHE_NSLOTS_DFLT_F INTEGER(SIZE_T) :: H5D_CHUNK_CACHE_NBYTES_DFLT_F @@ -491,7 +491,7 @@ MODULE H5GLOBAL !DEC$ATTRIBUTES DLLEXPORT :: H5L_SAME_LOC_F !DEC$ATTRIBUTES DLLEXPORT :: H5L_LINK_CLASS_T_VERS_F !DEC$endif - + INTEGER :: H5L_TYPE_ERROR_F INTEGER :: H5L_TYPE_HARD_F INTEGER :: H5L_TYPE_SOFT_F @@ -537,7 +537,7 @@ MODULE H5GLOBAL !DEC$ATTRIBUTES DLLEXPORT :: H5O_INFO_META_SIZE_F ! !DEC$endif - + INTEGER :: H5O_COPY_SHALLOW_HIERARCHY_F ! *** THESE VARIABLES DO INTEGER :: H5O_COPY_EXPAND_SOFT_LINK_F ! NOT MATCH THE C VARIABLE INTEGER :: H5O_COPY_EXPAND_EXT_LINK_F ! IN ORDER @@ -653,7 +653,7 @@ MODULE H5GLOBAL !DEC$ATTRIBUTES DLLEXPORT :: H5S_SEL_HYPERSLABS_F !DEC$ATTRIBUTES DLLEXPORT :: H5S_SEL_ALL_F !DEC$endif - + INTEGER(HSIZE_T) :: H5S_UNLIMITED_F INTEGER(HID_T) :: H5S_ALL_F @@ -817,7 +817,7 @@ CONTAINS SUBROUTINE H5_Fortran_string_c2f(c_string, f_string) - USE, INTRINSIC :: ISO_C_BINDING + USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_CHAR, C_NULL_CHAR IMPLICIT NONE CHARACTER(KIND=C_CHAR, LEN=*), INTENT(IN) :: c_string CHARACTER(LEN=*), INTENT(OUT) :: f_string @@ -829,11 +829,11 @@ CONTAINS f_len = LEN(f_string) ! CASE (1): C string is equal to or larger than Fortran character buffer, - ! so fill the entire Fortran buffer. + ! so fill the entire Fortran buffer. IF(c_len.GE.f_len)THEN ! f_string(1:f_len) = c_string(1:f_len) - ! CASE (2): C string is smaller than Fortran character buffer, + ! CASE (2): C string is smaller than Fortran character buffer, ! so copy C string and blank pad remaining characters. ELSE f_string(1:c_len) = c_string(1:c_len) @@ -843,7 +843,7 @@ CONTAINS SUBROUTINE H5_Fortran_string_f2c(f_string, c_string) - USE, INTRINSIC :: ISO_C_BINDING + USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_CHAR, C_NULL_CHAR IMPLICIT NONE CHARACTER(LEN=*), INTENT(IN) :: f_string CHARACTER(KIND=C_CHAR, LEN=*), INTENT(OUT) :: c_string @@ -900,6 +900,6 @@ CONTAINS !!$ fstring(j:j) = ' ' !!$ end do !!$end subroutine MPIR_Fortran_string_c2f - + END MODULE H5GLOBAL diff --git a/fortran/src/H5fortkit.F90 b/fortran/src/H5fortkit.F90 index f5eba8a..7710a4d 100644 --- a/fortran/src/H5fortkit.F90 +++ b/fortran/src/H5fortkit.F90 @@ -51,8 +51,8 @@ CONTAINS INTEGER :: i INTEGER :: len CHARACTER(LEN=len) :: fstring - CHARACTER(LEN=1), DIMENSION(1:len) :: cstring - + CHARACTER(LEN=1), DIMENSION(1:len) :: cstring + fstring = '' DO i = 1, len IF (cstring(i)(1:1)==CHAR(0)) EXIT diff --git a/fortran/test/H5_test_buildiface.F90 b/fortran/test/H5_test_buildiface.F90 index 636ded4..6cbeb68 100644 --- a/fortran/test/H5_test_buildiface.F90 +++ b/fortran/test/H5_test_buildiface.F90 @@ -13,8 +13,8 @@ ! depending on which of the KIND values are found. ! ! NOTES -! This program uses the Fortran 2008 intrinsic function STORAGE_SIZE or SIZEOF -! depending on availablity.It generates code that makes use of +! This program uses the Fortran 2008 intrinsic function STORAGE_SIZE or SIZEOF +! depending on availablity.It generates code that makes use of ! STORAGE_SIZE/SIZEOF in H5fortran_detect.f90. STORAGE_SIZE is standard ! compliant and should always be chosen over SIZEOF. ! @@ -94,7 +94,7 @@ PROGRAM H5_test_buildiface WRITE(11,'(a)') "MODULE TH5_MISC_gen" WRITE(11,'(A)') ' USE, INTRINSIC :: ISO_C_BINDING' - + ! Interfaces for validating REALs, INTEGERs, CHARACTERs, LOGICALs WRITE(11,'(A)') ' INTERFACE verify' @@ -156,8 +156,8 @@ PROGRAM H5_test_buildiface WRITE(11,'(A)') '!DEC$if defined(BUILD_HDF5_TEST_DLL)' WRITE(11,'(A)') '!DEC$attributes dllexport :: verify_real_kind_'//TRIM(ADJUSTL(chr2)) WRITE(11,'(A)') '!DEC$endif' - -! Subroutine API + +! Subroutine API WRITE(11,'(A)') ' SUBROUTINE verify_real_kind_'//TRIM(ADJUSTL(chr2))//'(string,value,correct_value,total_error)' WRITE(11,'(A)') ' IMPLICIT NONE' WRITE(11,'(A)') ' CHARACTER(LEN=*) :: string' @@ -186,7 +186,7 @@ PROGRAM H5_test_buildiface ! { EXPONENT(x)-DIGITS(x) ! { 2.0 for x /= 0 ! SPACING(x) = { -! { +! { ! { TINY(x) for x == 0 ! ! The ULP optional argument scales the comparison: @@ -228,7 +228,7 @@ PROGRAM H5_test_buildiface WRITE(11,'(A)') '!DEC$attributes dllexport :: verify_character' WRITE(11,'(A)') '!DEC$endif' -! Subroutine API +! Subroutine API WRITE(11,'(A)') ' SUBROUTINE verify_character(string,value,correct_value,total_error)' WRITE(11,'(A)') ' IMPLICIT NONE' WRITE(11,'(A)') ' CHARACTER*(*) :: string' @@ -258,7 +258,7 @@ PROGRAM H5_test_buildiface WRITE(11,'(A)') ' total_error = total_error + 1' WRITE(11,'(A)') ' WRITE(*,*) "ERROR: INCORRECT VALIDATION ", string' WRITE(11,'(A)') ' ENDIF' - + WRITE(11,'(A)') ' END SUBROUTINE verify_logical' WRITE(11,'(A)') "END MODULE TH5_MISC_gen" diff --git a/fortran/test/fflush1.F90 b/fortran/test/fflush1.F90 index bd1f551..0916813 100644 --- a/fortran/test/fflush1.F90 +++ b/fortran/test/fflush1.F90 @@ -6,7 +6,7 @@ ! FUNCTION ! This is the first half of a two-part test that makes sure ! that a file can be read after an application crashes as long -! as the file was flushed first. We simulate by exit the +! as the file was flushed first. We simulate by exit the ! the program using stop statement ! ! COPYRIGHT diff --git a/fortran/test/fortranlib_test.F90 b/fortran/test/fortranlib_test.F90 index 8d5b32b..92f9279 100644 --- a/fortran/test/fortranlib_test.F90 +++ b/fortran/test/fortranlib_test.F90 @@ -81,7 +81,7 @@ PROGRAM fortranlibtest CALL file_space("file_space",cleanup, ret_total_error) CALL write_test_status(ret_total_error, ' File free space test', total_error) -! +! ! '=========================================' ! 'Testing DATASET Interface ' ! '=========================================' @@ -97,7 +97,7 @@ PROGRAM fortranlibtest CALL test_userblock_offset(cleanup, ret_total_error) CALL write_test_status(ret_total_error, ' Dataset offset with user block', total_error) -! +! ! '=========================================' ! 'Testing DATASPACE Interface ' ! '=========================================' @@ -106,7 +106,7 @@ PROGRAM fortranlibtest CALL dataspace_basic_test(cleanup, ret_total_error) CALL write_test_status(ret_total_error, ' Basic dataspace test', total_error) -! +! ! '=========================================' ! 'Testing REFERENCE Interface ' ! '=========================================' @@ -119,7 +119,7 @@ PROGRAM fortranlibtest CALL refregtest(cleanup, ret_total_error) CALL write_test_status(ret_total_error, ' Reference to dataset region test', total_error) -! +! ! '=========================================' ! 'Testing selection functionalities ' ! '=========================================' @@ -148,8 +148,8 @@ PROGRAM fortranlibtest ret_total_error = 0 CALL test_select_bounds(ret_total_error) CALL write_test_status(ret_total_error, ' Selection bounds test ', total_error) - -! + +! ! '=========================================' ! 'Testing DATATYPE interface ' ! '=========================================' @@ -169,7 +169,7 @@ PROGRAM fortranlibtest CALL test_derived_flt(cleanup, ret_total_error) CALL write_test_status(ret_total_error, ' Derived float datatype test', total_error) -! +! ! '=========================================' ! 'Testing PROPERTY interface ' ! '=========================================' @@ -186,7 +186,7 @@ PROGRAM fortranlibtest CALL test_chunk_cache (cleanup, ret_total_error) CALL write_test_status(ret_total_error, ' Dataset chunk cache configuration', total_error) -! +! ! '=========================================' ! 'Testing ATTRIBUTE interface ' ! '=========================================' @@ -195,7 +195,7 @@ PROGRAM fortranlibtest CALL attribute_test(cleanup, ret_total_error) CALL write_test_status(ret_total_error, ' Attribute test', total_error) -! +! ! '=========================================' ! 'Testing IDENTIFIER interface ' ! '=========================================' @@ -217,7 +217,7 @@ PROGRAM fortranlibtest CALL write_test_status(ret_total_error, ' SZIP filter test', total_error) ENDIF -! +! ! '=========================================' ! 'Testing GROUP interface ' ! '=========================================' diff --git a/fortran/test/fortranlib_test_F03.F90 b/fortran/test/fortranlib_test_F03.F90 index 808cb4d..377645d 100644 --- a/fortran/test/fortranlib_test_F03.F90 +++ b/fortran/test/fortranlib_test_F03.F90 @@ -24,7 +24,7 @@ !***** PROGRAM fortranlibtest_F03 - + USE HDF5 USE THDF5_F03 @@ -48,7 +48,7 @@ PROGRAM fortranlibtest_F03 IF(total_error .EQ. 0) THEN WRITE(*, '(" FORTRANLIB_TEST is linked with HDF5 Library version ")', advance="NO") WRITE(*, '(I0)', advance="NO") majnum - WRITE(*, '(".")', advance="NO") + WRITE(*, '(".")', advance="NO") WRITE(*, '(I0)', advance="NO") minnum WRITE(*, '(" release ")', advance="NO") WRITE(*, '(I0)') relnum @@ -77,11 +77,11 @@ PROGRAM fortranlibtest_F03 ret_total_error = 0 CALL t_enum(ret_total_error) - CALL write_test_status(ret_total_error, ' Testing writing/reading enum dataset, using C_LOC', total_error) + CALL write_test_status(ret_total_error, ' Testing writing/reading enum dataset, using C_LOC', total_error) ret_total_error = 0 CALL t_enum_conv(ret_total_error) - CALL write_test_status(ret_total_error, ' Testing enumeration conversions', total_error) + CALL write_test_status(ret_total_error, ' Testing enumeration conversions', total_error) ret_total_error = 0 CALL t_bit(ret_total_error) @@ -89,7 +89,7 @@ PROGRAM fortranlibtest_F03 ret_total_error = 0 CALL t_opaque(ret_total_error) - CALL write_test_status(ret_total_error, ' Testing writing/reading opaque datatypes, using C_LOC', total_error) + CALL write_test_status(ret_total_error, ' Testing writing/reading opaque datatypes, using C_LOC', total_error) ret_total_error = 0 CALL t_objref(ret_total_error) @@ -97,7 +97,7 @@ PROGRAM fortranlibtest_F03 ret_total_error = 0 CALL t_regref(ret_total_error) - CALL write_test_status(ret_total_error, ' Testing writing/reading region references, using C_LOC', total_error) + CALL write_test_status(ret_total_error, ' Testing writing/reading region references, using C_LOC', total_error) ret_total_error = 0 CALL t_vlen(ret_total_error) @@ -150,7 +150,7 @@ PROGRAM fortranlibtest_F03 ret_total_error = 0 CALL test_h5p_file_image(ret_total_error) CALL write_test_status(ret_total_error, ' Testing h5pset/get file image', total_error) - + ! write(*,*) ! write(*,*) '=========================================' ! write(*,*) 'Testing OBJECT interface ' @@ -188,7 +188,7 @@ PROGRAM fortranlibtest_F03 WRITE(*, fmt = '(i4)', advance='NO') total_error WRITE(*, fmt = '(12a)' ) ' error(s) ! ' WRITE(*,*) ' ============================================ ' - + CALL h5close_f(error) ! if errors detected, exit with non-zero code. diff --git a/fortran/test/tH5A.F90 b/fortran/test/tH5A.F90 index 1e6fdeb..8968f59 100644 --- a/fortran/test/tH5A.F90 +++ b/fortran/test/tH5A.F90 @@ -21,7 +21,7 @@ ! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ! ! CONTAINS SUBROUTINES -! attribute_test +! attribute_test ! ! !***** diff --git a/fortran/test/tH5A_1_8.F90 b/fortran/test/tH5A_1_8.F90 index f2f11aa..8e59483 100644 --- a/fortran/test/tH5A_1_8.F90 +++ b/fortran/test/tH5A_1_8.F90 @@ -25,7 +25,7 @@ ! test_attr_create_by_name, test_attr_info_by_idx, attr_info_by_idx_check, ! test_attr_shared_rename, test_attr_delete_by_idx, test_attr_shared_delete, ! test_attr_dense_open, test_attr_dense_verify, test_attr_corder_create_basic, -! test_attr_basic_write, test_attr_many, attr_open_check, +! test_attr_basic_write, test_attr_many, attr_open_check, ! !***** MODULE TH5A_1_8 @@ -157,7 +157,7 @@ SUBROUTINE attribute_test_1_8(cleanup, total_error) ' - Testing creating attributes by name', & total_error) - ! More complex tests with both "new format" and "shared" attributes + ! More complex tests with both "new format" and "shared" attributes IF( use_shared(j) ) THEN ret_total_error = 0 CALL test_attr_shared_rename(my_fcpl, my_fapl, ret_total_error) @@ -243,17 +243,17 @@ SUBROUTINE test_attr_corder_create_compact(fcpl,fapl, total_error) data_dims = 0 ! WRITE(*,*) " - Testing Compact Storage of Attributes with Creation Order Info" - ! Create file + ! Create file CALL h5fcreate_f(FileName, H5F_ACC_TRUNC_F, fid, error, fcpl, fapl) CALL check("h5fcreate_f",error,total_error) - ! Create dataset creation property list + ! Create dataset creation property list CALL H5Pcreate_f(H5P_DATASET_CREATE_F,dcpl,error) CALL check("h5Pcreate_f",error,total_error) CALL H5Pset_attr_creation_order_f(dcpl, IOR(H5P_CRT_ORDER_TRACKED_F, H5P_CRT_ORDER_INDEXED_F), error) CALL check("H5Pset_attr_creation_order",error,total_error) - ! Query the attribute creation properties + ! Query the attribute creation properties CALL H5Pget_attr_phase_change_f(dcpl, max_compact, min_dense, error) CALL check("H5Pget_attr_phase_change_f",error,total_error) @@ -279,7 +279,7 @@ SUBROUTINE test_attr_corder_create_compact(fcpl,fapl, total_error) my_dataset = dset3 END SELECT DO u = 0, max_compact - 1 - ! Create attribute + ! Create attribute WRITE(chr2,'(I2.2)') u attrname = 'attr '//chr2 @@ -296,7 +296,7 @@ SUBROUTINE test_attr_corder_create_compact(fcpl,fapl, total_error) END DO END DO - ! Close Datasets + ! Close Datasets CALL h5dclose_f(dset1, error) CALL check("h5dclose_f",error,total_error) CALL h5dclose_f(dset2, error) @@ -304,15 +304,15 @@ SUBROUTINE test_attr_corder_create_compact(fcpl,fapl, total_error) CALL h5dclose_f(dset3, error) CALL check("h5dclose_f",error,total_error) - ! Close file + ! Close file CALL h5fclose_f(fid, error) CALL check("h5fclose_f",error,total_error) - ! Close dataspace + ! Close dataspace CALL h5sclose_f(sid, error) CALL check("h5sclose_f",error,total_error) - ! Close property list + ! Close property list CALL h5pclose_f(dcpl, error) CALL check("h5pclose_f",error,total_error) @@ -339,34 +339,34 @@ SUBROUTINE test_attr_corder_create_compact(fcpl,fapl, total_error) DO u = 0,max_compact-1 WRITE(chr2,'(I2.2)') u attrname = 'attr '//chr2 - ! Retrieve information for attribute + ! Retrieve information for attribute CALL H5Aget_info_by_name_f(my_dataset, ".", attrname, & f_corder_valid, corder, cset, data_size, error, lapl_id = H5P_DEFAULT_F ) !with optional CALL check("H5Aget_info_by_name_f", error, total_error) - ! Verify creation order of attribute + ! Verify creation order of attribute CALL verify("H5Aget_info_by_name_f", f_corder_valid, .TRUE., total_error) CALL verify("H5Aget_info_by_name_f", corder, u, total_error) - ! Retrieve information for attribute + ! Retrieve information for attribute CALL H5Aget_info_by_name_f(my_dataset, ".", attrname, & f_corder_valid, corder, cset, data_size, error) ! without optional CALL check("H5Aget_info_by_name_f", error, total_error) - ! Verify creation order of attribute + ! Verify creation order of attribute CALL verify("H5Aget_info_by_name_f", f_corder_valid, .TRUE., total_error) CALL verify("H5Aget_info_by_name_f", corder, u, total_error) END DO END DO - ! Close Datasets + ! Close Datasets CALL h5dclose_f(dset1, error) CALL check("h5dclose_f",error,total_error) CALL h5dclose_f(dset2, error) @@ -374,7 +374,7 @@ SUBROUTINE test_attr_corder_create_compact(fcpl,fapl, total_error) CALL h5dclose_f(dset3, error) CALL check("h5dclose_f",error,total_error) - ! Close file + ! Close file CALL h5fclose_f(fid, error) CALL check("h5fclose_f",error,total_error) @@ -423,33 +423,33 @@ SUBROUTINE test_attr_null_space(fcpl, fapl, total_error) data_dims = 0 - ! Create file + ! Create file CALL h5fcreate_f(FileName, H5F_ACC_TRUNC_F, fid, error, fcpl, fapl) CALL check("h5fcreate_f",error,total_error) - ! Close file + ! Close file CALL h5fclose_f(fid, error) CALL check("h5fclose_f",error,total_error) - ! Re-open file + ! Re-open file CALL h5fopen_f(FileName, H5F_ACC_RDWR_F, fid, error) CALL check("h5open_f",error,total_error) - ! Create dataspace for dataset attributes + ! Create dataspace for dataset attributes CALL h5screate_f(H5S_SCALAR_F, sid, error) CALL check("h5screate_f",error,total_error) - ! Create "null" dataspace for attribute + ! Create "null" dataspace for attribute CALL h5screate_f(H5S_NULL_F, null_sid, error) CALL check("h5screate_f",error,total_error) - ! Create a dataset + ! Create a dataset CALL h5dcreate_f(fid, DSET1_NAME, H5T_NATIVE_CHARACTER, sid, dataset, error) CALL check("h5dcreate_f",error,total_error) - ! Add attribute with 'null' dataspace + ! Add attribute with 'null' dataspace - ! Create attribute + ! Create attribute CALL h5acreate_f(dataset, "null attr", H5T_NATIVE_INTEGER, null_sid, attr, error) CALL check("h5acreate_f",error,total_error) - ! Try to read data from the attribute - ! (shouldn't fail, but should leave buffer alone) + ! Try to read data from the attribute + ! (shouldn't fail, but should leave buffer alone) value(1) = 103 data_dims(1) = 1 CALL h5aread_f(attr, H5T_NATIVE_INTEGER, value, data_dims, error) @@ -457,7 +457,7 @@ SUBROUTINE test_attr_null_space(fcpl, fapl, total_error) CALL verify("h5aread_f",value(1),103,total_error) ! Try to read data from the attribute again but -! for a scalar +! for a scalar value_scalar = 104 data_dims(1) = 1 @@ -479,7 +479,7 @@ SUBROUTINE test_attr_null_space(fcpl, fapl, total_error) CALL h5aget_info_f(attr, f_corder_valid, corder, cset, data_size, error) CALL check("h5aget_info_f", error, total_error) - ! Check the attribute's information + ! Check the attribute's information CALL verify("h5aget_info_f.corder",corder,0,total_error) CALL verify("h5aget_info_f.cset", cset, H5T_CSET_ASCII_F, total_error) @@ -557,32 +557,32 @@ SUBROUTINE test_attr_create_by_name(new_format,fcpl,fapl, total_error) data_dims = 0 - ! Create dataspace for dataset & attributes + ! Create dataspace for dataset & attributes CALL h5screate_f(H5S_SCALAR_F, sid, error) CALL check("h5screate_f",error,total_error) - ! Create dataset creation property list + ! Create dataset creation property list CALL H5Pcreate_f(H5P_DATASET_CREATE_F,dcpl,error) CALL check("h5Pcreate_f",error,total_error) - ! Query the attribute creation properties + ! Query the attribute creation properties CALL H5Pget_attr_phase_change_f(dcpl, max_compact, min_dense, error) CALL check("H5Pget_attr_phase_change_f",error,total_error) - ! Loop over using index for creation order value + ! Loop over using index for creation order value DO i = 1, 2 - ! Print appropriate test message + ! Print appropriate test message IF(use_index(i))THEN WRITE(*,*) " - Testing Creating Attributes By Name w/Creation Order Index" ELSE WRITE(*,*) " - Testing Creating Attributes By Name w/o Creation Order Index" ENDIF - ! Create file + ! Create file CALL h5fcreate_f(FileName, H5F_ACC_TRUNC_F, fid, error, fcpl, fapl) CALL check("h5fcreate_f",error,total_error) - ! Set attribute creation order tracking & indexing for object + ! Set attribute creation order tracking & indexing for object IF(new_format)THEN IF(use_index(i))THEN @@ -596,7 +596,7 @@ SUBROUTINE test_attr_create_by_name(new_format,fcpl,fapl, total_error) ENDIF - ! Create datasets + ! Create datasets CALL h5dcreate_f(fid, DSET1_NAME, H5T_NATIVE_CHARACTER, sid, dset1, error, dcpl_id=dcpl ) CALL check("h5dcreate_f2",error,total_error) @@ -608,7 +608,7 @@ SUBROUTINE test_attr_create_by_name(new_format,fcpl,fapl, total_error) CALL check("h5dcreate_f4",error,total_error) - ! Work on all the datasets + ! Work on all the datasets DO curr_dset = 0,NUM_DSETS-1 SELECT CASE (curr_dset) @@ -626,39 +626,39 @@ SUBROUTINE test_attr_create_by_name(new_format,fcpl,fapl, total_error) END SELECT - ! Create attributes, up to limit of compact form + ! Create attributes, up to limit of compact form DO u = 0, max_compact - 1 - ! Create attribute + ! Create attribute WRITE(chr2,'(I2.2)') u attrname = 'attr '//chr2 CALL H5Acreate_by_name_f(fid, dsetname, attrname, H5T_NATIVE_INTEGER, sid, & attr, error, lapl_id=H5P_DEFAULT_F, acpl_id=H5P_DEFAULT_F, aapl_id=H5P_DEFAULT_F) CALL check("H5Acreate_by_name_f",error,total_error) - ! Write data into the attribute + ! Write data into the attribute data_dims(1) = 1 CALL h5awrite_f(attr, H5T_NATIVE_INTEGER, u, data_dims, error) CALL check("h5awrite_f",error,total_error) - ! Close attribute + ! Close attribute CALL h5aclose_f(attr, error) CALL check("h5aclose_f",error,total_error) - ! Verify information for NEW attribute + ! Verify information for NEW attribute CALL attr_info_by_idx_check(my_dataset, attrname, INT(u,HSIZE_T), use_index(i), total_error) ! CALL check("FAILED IN attr_info_by_idx_check",total_error) ENDDO - ! Test opening attributes stored compactly + ! Test opening attributes stored compactly CALL attr_open_check(fid, dsetname, my_dataset, u, total_error) ENDDO - ! Work on all the datasets + ! Work on all the datasets DO curr_dset = 0,NUM_DSETS-1 SELECT CASE (curr_dset) CASE (0) @@ -672,7 +672,7 @@ SUBROUTINE test_attr_create_by_name(new_format,fcpl,fapl, total_error) dsetname = DSET3_NAME END SELECT - ! Create more attributes, to push into dense form + ! Create more attributes, to push into dense form DO u = max_compact, max_compact* 2 - 1 WRITE(chr2,'(I2.2)') u @@ -682,12 +682,12 @@ SUBROUTINE test_attr_create_by_name(new_format,fcpl,fapl, total_error) attr, error, lapl_id=H5P_DEFAULT_F) CALL check("H5Acreate_by_name",error,total_error) - ! Write data into the attribute + ! Write data into the attribute data_dims(1) = 1 CALL h5awrite_f(attr, H5T_NATIVE_INTEGER, u, data_dims, error) CALL check("h5awrite_f",error,total_error) - ! Close attribute + ! Close attribute CALL h5aclose_f(attr, error) CALL check("h5aclose_f",error,total_error) @@ -695,7 +695,7 @@ SUBROUTINE test_attr_create_by_name(new_format,fcpl,fapl, total_error) ENDDO - ! Close Datasets + ! Close Datasets CALL h5dclose_f(dset1, error) CALL check("h5dclose_f",error,total_error) CALL h5dclose_f(dset2, error) @@ -704,16 +704,16 @@ SUBROUTINE test_attr_create_by_name(new_format,fcpl,fapl, total_error) CALL check("h5dclose_f",error,total_error) - ! Close file + ! Close file CALL h5fclose_f(fid, error) CALL check("h5fclose_f",error,total_error) ENDDO - ! Close property list + ! Close property list CALL h5pclose_f(dcpl, error) CALL check("h5pclose_f",error,total_error) - ! Close dataspace + ! Close dataspace CALL h5sclose_f(sid, error) CALL check("h5sclose_f",error,total_error) @@ -781,31 +781,31 @@ SUBROUTINE test_attr_info_by_idx(new_format, fcpl, fapl, total_error) data_dims = 0 - ! Create dataspace for dataset & attributes + ! Create dataspace for dataset & attributes CALL h5screate_f(H5S_SCALAR_F, sid, error) CALL check("h5screate_f",error,total_error) - ! Create dataset creation property list + ! Create dataset creation property list CALL H5Pcreate_f(H5P_DATASET_CREATE_F,dcpl,error) CALL check("h5Pcreate_f",error,total_error) - ! Query the attribute creation properties + ! Query the attribute creation properties CALL H5Pget_attr_phase_change_f(dcpl, max_compact, min_dense, error) CALL check("H5Pget_attr_phase_change_f",error,total_error) - ! Loop over using index for creation order value + ! Loop over using index for creation order value DO i = 1, 2 - ! Create file + ! Create file CALL h5fcreate_f(FileName, H5F_ACC_TRUNC_F, fid, error, fcpl, fapl) CALL check("h5fcreate_f",error,total_error) - ! Set attribute creation order tracking & indexing for object + ! Set attribute creation order tracking & indexing for object IF(new_format)THEN IF(use_index(i))THEN Input1 = H5P_CRT_ORDER_INDEXED_F @@ -816,7 +816,7 @@ SUBROUTINE test_attr_info_by_idx(new_format, fcpl, fapl, total_error) CALL check("H5Pset_attr_creation_order",error,total_error) ENDIF - ! Create datasets + ! Create datasets CALL h5dcreate_f(fid, DSET1_NAME, H5T_NATIVE_CHARACTER, sid, dset1, error ) CALL check("h5dcreate_f",error,total_error) @@ -827,7 +827,7 @@ SUBROUTINE test_attr_info_by_idx(new_format, fcpl, fapl, total_error) CALL h5dcreate_f(fid, DSET3_NAME, H5T_NATIVE_CHARACTER, sid, dset3, error ) CALL check("h5dcreate_f",error,total_error) - ! Work on all the datasets + ! Work on all the datasets DO curr_dset = 0,NUM_DSETS-1 @@ -840,7 +840,7 @@ SUBROUTINE test_attr_info_by_idx(new_format, fcpl, fapl, total_error) my_dataset = dset3 END SELECT - ! Check for query on non-existant attribute + ! Check for query on non-existant attribute n = 0 @@ -870,10 +870,10 @@ SUBROUTINE test_attr_info_by_idx(new_format, fcpl, fapl, total_error) CALL verify("h5aget_name_by_idx_f",error,minusone,total_error) - ! Create attributes, up to limit of compact form + ! Create attributes, up to limit of compact form DO j = 0, max_compact-1 - ! Create attribute + ! Create attribute WRITE(chr2,'(I2.2)') j attrname = 'attr '//chr2 @@ -881,19 +881,19 @@ SUBROUTINE test_attr_info_by_idx(new_format, fcpl, fapl, total_error) CALL h5acreate_f(my_dataset, attrname, H5T_NATIVE_INTEGER, sid, attr, error, H5P_DEFAULT_F, H5P_DEFAULT_F) CALL check("h5acreate_f",error,total_error) - ! Write data into the attribute + ! Write data into the attribute attr_integer_data(1) = j data_dims(1) = 1 CALL h5awrite_f(attr, H5T_NATIVE_INTEGER, attr_integer_data, data_dims, error) CALL check("h5awrite_f",error,total_error) - ! Close attribute + ! Close attribute CALL h5aclose_f(attr, error) CALL check("h5aclose_f",error,total_error) - ! Verify information for new attribute + ! Verify information for new attribute !EP CALL attr_info_by_idx_check(my_dataset, attrname, INT(j,HSIZE_T), use_index(i), total_error ) htmp = j @@ -905,7 +905,7 @@ SUBROUTINE test_attr_info_by_idx(new_format, fcpl, fapl, total_error) ENDDO - ! Close Datasets + ! Close Datasets CALL h5dclose_f(dset1, error) CALL check("h5dclose_f",error,total_error) CALL h5dclose_f(dset2, error) @@ -913,17 +913,17 @@ SUBROUTINE test_attr_info_by_idx(new_format, fcpl, fapl, total_error) CALL h5dclose_f(dset3, error) CALL check("h5dclose_f",error,total_error) - ! Close file + ! Close file CALL h5fclose_f(fid, error) CALL check("h5fclose_f",error,total_error) END DO - ! Close property list + ! Close property list CALL h5pclose_f(dcpl,error) CALL check("h5pclose_f", error, total_error) - ! Close dataspace + ! Close dataspace CALL h5sclose_f(sid, error) CALL check("h5sclose_f",error,total_error) @@ -950,13 +950,13 @@ SUBROUTINE attr_info_by_idx_check(obj_id, attrname, n, use_index, total_error ) INTEGER(HSIZE_T) :: hzero = 0_HSIZE_T - ! Verify the information for first attribute, in increasing creation order + ! Verify the information for first attribute, in increasing creation order CALL h5aget_info_by_idx_f(obj_id, ".", H5_INDEX_CRT_ORDER_F, H5_ITER_INC_F, hzero, & f_corder_valid, corder, cset, data_size, error) CALL check("h5aget_info_by_idx_f",error,total_error) CALL verify("h5aget_info_by_idx_f",corder,0,total_error) - ! Verify the information for new attribute, in increasing creation order + ! Verify the information for new attribute, in increasing creation order CALL h5aget_info_by_idx_f(obj_id, ".", H5_INDEX_CRT_ORDER_F, H5_ITER_INC_F, n, & f_corder_valid, corder, cset, data_size, error) @@ -964,7 +964,7 @@ SUBROUTINE attr_info_by_idx_check(obj_id, attrname, n, use_index, total_error ) CALL check("h5aget_info_by_idx_f",error,total_error) CALL verify("h5aget_info_by_idx_f",corder,INT(n),total_error) - ! Verify the name for new link, in increasing creation order + ! Verify the name for new link, in increasing creation order ! Try with the correct buffer size @@ -981,21 +981,21 @@ SUBROUTINE attr_info_by_idx_check(obj_id, attrname, n, use_index, total_error ) ! Don't test "native" order if there is no creation order index, since ! * there's not a good way to easily predict the attribute's order in the name ! * index. - ! + ! IF (use_index) THEN - ! Verify the information for first attribute, in native creation order + ! Verify the information for first attribute, in native creation order CALL h5aget_info_by_idx_f(obj_id, ".", H5_INDEX_CRT_ORDER_F, H5_ITER_NATIVE_F, hzero, & f_corder_valid, corder, cset, data_size, error) CALL check("h5aget_info_by_idx_f",error,total_error) CALL verify("h5aget_info_by_idx_f",corder,0,total_error) - ! Verify the information for new attribute, in native creation order + ! Verify the information for new attribute, in native creation order CALL h5aget_info_by_idx_f(obj_id, ".", H5_INDEX_CRT_ORDER_F, H5_ITER_NATIVE_F, n, & f_corder_valid, corder, cset, data_size, error) CALL check("h5aget_info_by_idx_f",error,total_error) CALL verify("h5aget_info_by_idx_f",corder,INT(n),total_error) - ! Verify the name for new link, in increasing native order + ! Verify the name for new link, in increasing native order CALL h5aget_name_by_idx_f(obj_id, ".", H5_INDEX_CRT_ORDER_F, H5_ITER_NATIVE_F, & n, tmpname, error) ! check with no optional parameters CALL check("h5aget_name_by_idx_f",error,total_error) @@ -1113,114 +1113,114 @@ SUBROUTINE test_attr_shared_rename( fcpl, fapl, total_error) INTEGER(HSIZE_T), DIMENSION(1) :: adims2 = (/1/) ! Attribute dimension INTEGER :: arank = 1 ! Attribure rank - ! Initialize "big" attribute data + ! Initialize "big" attribute data - ! Create dataspace for dataset + ! Create dataspace for dataset CALL h5screate_f(H5S_SCALAR_F, sid, error) CALL check("h5screate_f",error,total_error) - ! Create "big" dataspace for "large" attributes + ! Create "big" dataspace for "large" attributes CALL h5screate_simple_f(arank, adims2, big_sid, error) CALL check("h5screate_simple_f",error,total_error) - ! Loop over type of shared components + ! Loop over type of shared components DO test_shared = 0, 2 - ! Make copy of file creation property list + ! Make copy of file creation property list CALL H5Pcopy_f(fcpl, my_fcpl, error) CALL check("H5Pcopy",error,total_error) - ! Set up datatype for attributes + ! Set up datatype for attributes CALL H5Tcopy_f(H5T_NATIVE_INTEGER, attr_tid, error) CALL check("H5Tcopy",error,total_error) - ! Special setup for each type of shared components + ! Special setup for each type of shared components IF( test_shared .EQ. 0) THEN - ! Make attributes > 500 bytes shared + ! Make attributes > 500 bytes shared CALL H5Pset_shared_mesg_nindexes_f(my_fcpl,1,error) CALL check("H5Pset_shared_mesg_nindexes_f",error, total_error) CALL H5Pset_shared_mesg_index_f(my_fcpl, 0, H5O_SHMESG_ATTR_FLAG_F, 500,error) CALL check(" H5Pset_shared_mesg_index_f",error, total_error) ELSE - ! Set up copy of file creation property list + ! Set up copy of file creation property list CALL H5Pset_shared_mesg_nindexes_f(my_fcpl,3,error) - ! Make attributes > 500 bytes shared + ! Make attributes > 500 bytes shared CALL H5Pset_shared_mesg_index_f(my_fcpl, 0, H5O_SHMESG_ATTR_FLAG_F, 500,error) - ! Make datatypes & dataspaces > 1 byte shared (i.e. all of them :-) + ! Make datatypes & dataspaces > 1 byte shared (i.e. all of them :-) CALL H5Pset_shared_mesg_index_f(my_fcpl, 1, H5O_SHMESG_DTYPE_FLAG_F, 1,error) CALL H5Pset_shared_mesg_index_f(my_fcpl, 2, H5O_SHMESG_SDSPACE_FLAG_F, 1,error) ENDIF - ! Create file + ! Create file CALL h5fcreate_f(FileName, H5F_ACC_TRUNC_F, fid, error, my_fcpl, fapl) CALL check("h5fcreate_f",error,total_error) - ! Close FCPL copy + ! Close FCPL copy CALL h5pclose_f(my_fcpl, error) CALL check("h5pclose_f", error, total_error) - ! Close file + ! Close file CALL h5fclose_f(fid, error) CALL check("h5fclose_f",error,total_error) - ! Re-open file + ! Re-open file CALL h5fopen_f(FileName, H5F_ACC_RDWR_F, fid, error,fapl) CALL check("h5open_f",error,total_error) - ! Commit datatype to file + ! Commit datatype to file IF(test_shared.EQ.2) THEN CALL H5Tcommit_f(fid, TYPE1_NAME, attr_tid, error, H5P_DEFAULT_F, H5P_DEFAULT_F, H5P_DEFAULT_F) CALL check("H5Tcommit",error,total_error) ENDIF - ! Set up to query the object creation properties + ! Set up to query the object creation properties CALL H5Pcreate_f(H5P_DATASET_CREATE_F,dcpl,error) CALL check("h5Pcreate_f",error,total_error) - ! Create datasets + ! Create datasets CALL h5dcreate_f(fid, DSET1_NAME, H5T_NATIVE_CHARACTER, sid, dataset, error, dcpl_id=dcpl ) CALL check("h5dcreate_f",error,total_error) CALL h5dcreate_f(fid, DSET2_NAME, H5T_NATIVE_CHARACTER, sid, dataset2, error, dcpl_id=dcpl ) CALL check("h5dcreate_f",error,total_error) - ! Retrieve limits for compact/dense attribute storage + ! Retrieve limits for compact/dense attribute storage CALL H5Pget_attr_phase_change_f(dcpl, max_compact, min_dense, error) CALL check("H5Pget_attr_phase_change_f",error,total_error) - ! Close property list + ! Close property list CALL h5pclose_f(dcpl,error) CALL check("h5pclose_f", error, total_error) - ! Add attributes to each dataset, until after converting to dense storage + ! Add attributes to each dataset, until after converting to dense storage DO u = 0, (max_compact * 2) - 1 - ! Create attribute name + ! Create attribute name WRITE(chr2,'(I2.2)') u attrname = 'attr '//chr2 - ! Alternate between creating "small" & "big" attributes + ! Alternate between creating "small" & "big" attributes IF(MOD(u+1,2).EQ.0)THEN - ! Create "small" attribute on first dataset + ! Create "small" attribute on first dataset CALL h5acreate_f(dataset, attrname, attr_tid, sid, attr, error, H5P_DEFAULT_F, H5P_DEFAULT_F) CALL check("h5acreate_f",error,total_error) - ! Write data into the attribute + ! Write data into the attribute attr_integer_data(1) = u + 1 data_dims(1) = 1 CALL h5awrite_f(attr, attr_tid, attr_integer_data, data_dims, error) CALL check("h5awrite_f",error,total_error) ELSE - ! Create "big" attribute on first dataset + ! Create "big" attribute on first dataset CALL h5acreate_f(dataset, attrname, attr_tid, big_sid, attr, error, H5P_DEFAULT_F, H5P_DEFAULT_F) CALL check("h5acreate_f",error,total_error) - ! Write data into the attribute + ! Write data into the attribute data_dims(1) = 1 attr_integer_data(1) = u + 1 @@ -1229,19 +1229,19 @@ SUBROUTINE test_attr_shared_rename( fcpl, fapl, total_error) ENDIF - ! Close attribute + ! Close attribute CALL h5aclose_f(attr, error) CALL check("h5aclose_f",error,total_error) - ! Alternate between creating "small" & "big" attributes + ! Alternate between creating "small" & "big" attributes IF(MOD(u+1,2).EQ.0)THEN - ! Create "small" attribute on second dataset + ! Create "small" attribute on second dataset CALL h5acreate_f(dataset2, attrname, attr_tid, sid, attr, error, H5P_DEFAULT_F, H5P_DEFAULT_F) CALL check("h5acreate_f",error,total_error) - ! Write data into the attribute + ! Write data into the attribute attr_integer_data(1) = u + 1 data_dims(1) = 1 @@ -1249,12 +1249,12 @@ SUBROUTINE test_attr_shared_rename( fcpl, fapl, total_error) CALL check("h5awrite_f",error,total_error) ELSE - ! Create "big" attribute on second dataset + ! Create "big" attribute on second dataset CALL h5acreate_f(dataset2, attrname, attr_tid, big_sid, attr, error, H5P_DEFAULT_F, H5P_DEFAULT_F) CALL check("h5acreate_f",error,total_error) -! Write data into the attribute +! Write data into the attribute attr_integer_data(1) = u + 1 @@ -1263,103 +1263,103 @@ SUBROUTINE test_attr_shared_rename( fcpl, fapl, total_error) ! CALL check("h5awrite_f",error,total_error) -! Check refcount for attribute +! Check refcount for attribute ENDIF - ! Close attribute + ! Close attribute CALL h5aclose_f(attr, error) CALL check("h5aclose_f",error,total_error) - ! Create new attribute name + ! Create new attribute name WRITE(chr2,'(I2.2)') u attrname2 = 'new attr '//chr2 - ! Change second dataset's attribute's name + ! Change second dataset's attribute's name CALL H5Arename_by_name_f(fid, DSET2_NAME, attrname, attrname2, error, lapl_id=H5P_DEFAULT_F) CALL check("H5Arename_by_name_f",error,total_error) - ! Check refcount on attributes now + ! Check refcount on attributes now - ! Check refcount on renamed attribute + ! Check refcount on renamed attribute CALL H5Aopen_f(dataset2, attrname2, attr, error, aapl_id=H5P_DEFAULT_F) CALL check("H5Aopen_f",error,total_error) - ! Close attribute + ! Close attribute CALL h5aclose_f(attr, error) CALL check("h5aclose_f",error,total_error) - ! Check refcount on original attribute + ! Check refcount on original attribute CALL H5Aopen_f(dataset, attrname, attr, error) CALL check("H5Aopen",error,total_error) - ! Close attribute + ! Close attribute CALL h5aclose_f(attr, error) CALL check("h5aclose_f",error,total_error) - ! Change second dataset's attribute's name back to original + ! Change second dataset's attribute's name back to original CALL H5Arename_by_name_f(fid, DSET2_NAME, attrname2, attrname, error) CALL check("H5Arename_by_name_f",error,total_error) - ! Check refcount on attributes now + ! Check refcount on attributes now - ! Check refcount on renamed attribute + ! Check refcount on renamed attribute CALL H5Aopen_f(dataset2, attrname, attr, error) CALL check("H5Aopen",error,total_error) - ! Close attribute + ! Close attribute CALL h5aclose_f(attr, error) CALL check("h5aclose_f",error,total_error) - ! Check refcount on original attribute + ! Check refcount on original attribute - ! Check refcount on renamed attribute + ! Check refcount on renamed attribute CALL H5Aopen_f(dataset, attrname, attr, error) CALL check("H5Aopen",error,total_error) - ! Close attribute + ! Close attribute CALL h5aclose_f(attr, error) CALL check("h5aclose_f",error,total_error) ENDDO - ! Close attribute's datatype + ! Close attribute's datatype CALL h5tclose_f(attr_tid, error) CALL check("h5tclose_f",error,total_error) - ! Close attribute's datatype + ! Close attribute's datatype CALL h5dclose_f(dataset, error) CALL check("h5dclose_f",error,total_error) CALL h5dclose_f(dataset2, error) CALL check("h5dclose_f",error,total_error) - ! Unlink datasets with attributes + ! Unlink datasets with attributes CALL H5Ldelete_f(fid, DSET1_NAME, error, H5P_DEFAULT_F) CALL check("HLdelete",error,total_error) CALL H5Ldelete_f(fid, DSET2_NAME, error) CALL check("HLdelete",error,total_error) - ! Unlink committed datatype + ! Unlink committed datatype IF(test_shared == 2)THEN CALL H5Ldelete_f(fid, TYPE1_NAME, error) CALL check("HLdelete_f",error,total_error) ENDIF - ! Close file + ! Close file CALL h5fclose_f(fid, error) CALL check("h5fclose_f",error,total_error) - ! Check size of file + ! Check size of file !filesize = h5_get_file_size(FILENAME); !verify(filesize, empty_filesize, "h5_get_file_size"); ENDDO - ! Close dataspaces + ! Close dataspaces CALL h5sclose_f(sid, error) CALL check("h5sclose_f",error,total_error) CALL h5sclose_f(big_sid, error) @@ -1384,9 +1384,9 @@ SUBROUTINE test_attr_delete_by_idx(new_format, fcpl, fapl, total_error) INTEGER(HID_T), INTENT(IN) :: fapl INTEGER, INTENT(INOUT) :: total_error CHARACTER(LEN=8) :: FileName = "tattr.h5" - INTEGER(HID_T) :: fid ! HDF5 File ID - INTEGER(HID_T) :: dcpl ! Dataset creation property list ID - INTEGER(HID_T) :: sid ! Dataspace ID + INTEGER(HID_T) :: fid ! HDF5 File ID + INTEGER(HID_T) :: dcpl ! Dataset creation property list ID + INTEGER(HID_T) :: sid ! Dataspace ID CHARACTER(LEN=8) :: DSET1_NAME = "Dataset1" CHARACTER(LEN=8) :: DSET2_NAME = "Dataset2" @@ -1424,40 +1424,40 @@ SUBROUTINE test_attr_delete_by_idx(new_format, fcpl, fapl, total_error) INTEGER :: idx_type INTEGER :: order - INTEGER :: u ! Local index variable + INTEGER :: u ! Local index variable INTEGER :: Input1 INTEGER(HSIZE_T) :: hzero = 0_HSIZE_T INTEGER :: minusone = -1 data_dims = 0 - ! Create dataspace for dataset & attributes + ! Create dataspace for dataset & attributes CALL h5screate_f(H5S_SCALAR_F, sid, error) CALL check("h5screate_f",error,total_error) - ! Create dataset creation property list + ! Create dataset creation property list CALL H5Pcreate_f(H5P_DATASET_CREATE_F,dcpl,error) CALL check("h5Pcreate_f",error,total_error) - ! Query the attribute creation properties + ! Query the attribute creation properties CALL H5Pget_attr_phase_change_f(dcpl, max_compact, min_dense, error) CALL check("H5Pget_attr_phase_change_f",error,total_error) - ! Loop over operating on different indices on link fields + ! Loop over operating on different indices on link fields DO idx_type = H5_INDEX_NAME_F, H5_INDEX_CRT_ORDER_F - ! Loop over operating in different orders + ! Loop over operating in different orders DO order = H5_ITER_INC_F, H5_ITER_DEC_F - ! Loop over using index for creation order value + ! Loop over using index for creation order value DO i = 1, 2 - ! Create file + ! Create file CALL h5fcreate_f(FileName, H5F_ACC_TRUNC_F, fid, error, fcpl, fapl) CALL check("h5fcreate_f",error,total_error) - ! Set attribute creation order tracking & indexing for object + ! Set attribute creation order tracking & indexing for object IF(new_format)THEN IF(use_index(i))THEN @@ -1471,7 +1471,7 @@ SUBROUTINE test_attr_delete_by_idx(new_format, fcpl, fapl, total_error) ENDIF - ! Create datasets + ! Create datasets CALL h5dcreate_f(fid, DSET1_NAME, H5T_NATIVE_CHARACTER, sid, dset1, error, dcpl ) CALL check("h5dcreate_f2",error,total_error) @@ -1482,7 +1482,7 @@ SUBROUTINE test_attr_delete_by_idx(new_format, fcpl, fapl, total_error) CALL h5dcreate_f(fid, DSET3_NAME, H5T_NATIVE_CHARACTER, sid, dset3, error, dcpl ) CALL check("h5dcreate_f4",error,total_error) - ! Work on all the datasets + ! Work on all the datasets DO curr_dset = 0,NUM_DSETS-1 SELECT CASE (curr_dset) @@ -1497,36 +1497,36 @@ SUBROUTINE test_attr_delete_by_idx(new_format, fcpl, fapl, total_error) END SELECT - ! Check for deleting non-existant attribute + ! Check for deleting non-existant attribute !EP CALL H5Adelete_by_idx_f(my_dataset, '.', idx_type, order, 0_HSIZE_T,error, lapl_id=H5P_DEFAULT_F) CALL H5Adelete_by_idx_f(my_dataset, '.', idx_type, order, hzero,error, lapl_id=H5P_DEFAULT_F) CALL verify("H5Adelete_by_idx_f",error,minusone,total_error) - ! Create attributes, up to limit of compact form + ! Create attributes, up to limit of compact form DO u = 0, max_compact - 1 - ! Create attribute + ! Create attribute WRITE(chr2,'(I2.2)') u attrname = 'attr '//chr2 CALL h5acreate_f(my_dataset, attrname, H5T_NATIVE_INTEGER, sid, attr, error, H5P_DEFAULT_F, H5P_DEFAULT_F) CALL check("h5acreate_f",error,total_error) - ! Write data into the attribute + ! Write data into the attribute attr_integer_data(1) = u data_dims(1) = 1 CALL h5awrite_f(attr, H5T_NATIVE_INTEGER, attr_integer_data, data_dims, error) CALL check("h5awrite_f",error,total_error) - ! Close attribute + ! Close attribute CALL h5aclose_f(attr, error) CALL check("h5aclose_f",error,total_error) - ! Verify information for new attribute + ! Verify information for new attribute CALL attr_info_by_idx_check(my_dataset, attrname, INT(u,HSIZE_T), use_index(i), total_error ) ENDDO - ! Check for out of bound deletions + ! Check for out of bound deletions CALL H5Adelete_by_idx_f(my_dataset, ".", idx_type, order, INT(u,HSIZE_T), error, lapl_id=H5P_DEFAULT_F) CALL verify("H5Adelete_by_idx_f",error,minusone,total_error) @@ -1545,11 +1545,11 @@ SUBROUTINE test_attr_delete_by_idx(new_format, fcpl, fapl, total_error) ! CALL HDassert(0.AND."Toomanydatasets!") END SELECT - ! Delete attributes from compact storage + ! Delete attributes from compact storage DO u = 0, max_compact - 2 - ! Delete first attribute in appropriate order + ! Delete first attribute in appropriate order !EP CALL H5Adelete_by_idx_f(my_dataset, ".", idx_type, order, 0_HSIZE_T, error) @@ -1557,7 +1557,7 @@ SUBROUTINE test_attr_delete_by_idx(new_format, fcpl, fapl, total_error) CALL check("H5Adelete_by_idx_f",error,total_error) - ! Verify the attribute information for first attribute in appropriate order + ! Verify the attribute information for first attribute in appropriate order ! HDmemset(&ainfo, 0, sizeof(ainfo)); !EP CALL h5aget_info_by_idx_f(my_dataset, ".", idx_type, order, 0_HSIZE_T, & @@ -1572,7 +1572,7 @@ SUBROUTINE test_attr_delete_by_idx(new_format, fcpl, fapl, total_error) CALL verify("H5Aget_info_by_idx_f",corder, max_compact-(u + 2),total_error) ENDIF - ! Verify the name for first attribute in appropriate order + ! Verify the name for first attribute in appropriate order size = 7 ! *CHECK* IF NOT THE SAME SIZE CALL h5aget_name_by_idx_f(my_dataset, ".", idx_type, order,INT(0,hsize_t), & @@ -1589,7 +1589,7 @@ SUBROUTINE test_attr_delete_by_idx(new_format, fcpl, fapl, total_error) CALL verify("h5aget_name_by_idx_f",error,0,total_error) ENDDO - ! Delete last attribute + ! Delete last attribute !EP CALL H5Adelete_by_idx_f(my_dataset, ".", idx_type, order, 0_HSIZE_T, error) CALL H5Adelete_by_idx_f(my_dataset, ".", idx_type, order, hzero, error) @@ -1597,7 +1597,7 @@ SUBROUTINE test_attr_delete_by_idx(new_format, fcpl, fapl, total_error) ENDDO -! Work on all the datasets +! Work on all the datasets DO curr_dset = 0,NUM_DSETS-1 SELECT CASE (curr_dset) @@ -1611,11 +1611,11 @@ SUBROUTINE test_attr_delete_by_idx(new_format, fcpl, fapl, total_error) ! CALL HDassert(0.AND."Toomanydatasets!") END SELECT - ! Create more attributes, to push into dense form + ! Create more attributes, to push into dense form DO u = 0, (max_compact * 2) - 1 - ! Create attribute + ! Create attribute WRITE(chr2,'(I2.2)') u attrname = 'attr '//chr2 @@ -1623,24 +1623,24 @@ SUBROUTINE test_attr_delete_by_idx(new_format, fcpl, fapl, total_error) CALL check("h5acreate_f",error,total_error) - ! Write data into the attribute + ! Write data into the attribute attr_integer_data(1) = u data_dims(1) = 1 CALL h5awrite_f(attr, H5T_NATIVE_INTEGER, attr_integer_data, data_dims, error) CALL check("h5awrite_f",error,total_error) - ! Close attribute + ! Close attribute CALL h5aclose_f(attr, error) CALL check("h5aclose_f",error,total_error) ENDDO - ! Check for out of bound deletion + ! Check for out of bound deletion CALL H5Adelete_by_idx_f(my_dataset, ".", idx_type, order, INT(u,HSIZE_T), error) CALL verify("H5Adelete_by_idx_f",error,minusone,total_error) ENDDO - ! Work on all the datasets + ! Work on all the datasets DO curr_dset = 0,NUM_DSETS-1 SELECT CASE (curr_dset) @@ -1652,15 +1652,15 @@ SUBROUTINE test_attr_delete_by_idx(new_format, fcpl, fapl, total_error) my_dataset = dset3 END SELECT - ! Delete attributes from dense storage + ! Delete attributes from dense storage DO u = 0, (max_compact * 2) - 1 - 1 - ! Delete first attribute in appropriate order + ! Delete first attribute in appropriate order CALL H5Adelete_by_idx_f(my_dataset, ".", idx_type, order, INT(0,HSIZE_T), error) CALL check("H5Adelete_by_idx_f",error,total_error) - ! Verify the attribute information for first attribute in appropriate order + ! Verify the attribute information for first attribute in appropriate order CALL h5aget_info_by_idx_f(my_dataset, ".", idx_type, order, INT(0,HSIZE_T), & f_corder_valid, corder, cset, data_size, error) @@ -1672,7 +1672,7 @@ SUBROUTINE test_attr_delete_by_idx(new_format, fcpl, fapl, total_error) CALL verify("H5Aget_info_by_idx_f",corder, ((max_compact * 2) - (u + 2)), total_error) ENDIF - ! Verify the name for first attribute in appropriate order + ! Verify the name for first attribute in appropriate order ! HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); size = 7 ! *CHECK* if not the correct size @@ -1691,17 +1691,17 @@ SUBROUTINE test_attr_delete_by_idx(new_format, fcpl, fapl, total_error) ENDDO - ! Delete last attribute + ! Delete last attribute CALL H5Adelete_by_idx_f(my_dataset, ".", idx_type, order, INT(0,HSIZE_T), error, lapl_id=H5P_DEFAULT_F) CALL check("H5Adelete_by_idx_f",error,total_error) - ! Check for deletion on empty attribute storage again + ! Check for deletion on empty attribute storage again CALL H5Adelete_by_idx_f(my_dataset, ".", idx_type, order, INT(0,HSIZE_T), error) CALL verify("H5Adelete_by_idx_f",error,minusone,total_error) ENDDO - ! Close Datasets + ! Close Datasets CALL h5dclose_f(dset1, error) CALL check("h5dclose_f",error,total_error) CALL h5dclose_f(dset2, error) @@ -1709,18 +1709,18 @@ SUBROUTINE test_attr_delete_by_idx(new_format, fcpl, fapl, total_error) CALL h5dclose_f(dset3, error) CALL check("h5dclose_f",error,total_error) - ! Close file + ! Close file CALL h5fclose_f(fid, error) CALL check("h5fclose_f",error,total_error) ENDDO ENDDO ENDDO - ! Close property list + ! Close property list CALL h5pclose_f(dcpl,error) CALL check("h5pclose_f", error, total_error) - ! Close dataspace + ! Close dataspace CALL h5sclose_f(sid, error) CALL check("h5sclose_f",error,total_error) @@ -1775,77 +1775,77 @@ SUBROUTINE test_attr_shared_delete(fcpl, fapl, total_error) INTEGER(HSIZE_T), DIMENSION(1) :: adims2 = (/1/) ! Attribute dimension INTEGER :: arank = 1 ! Attribure rank - ! Output message about test being performed + ! Output message about test being performed - ! Initialize "big" attribute DATA - ! Create dataspace for dataset + ! Initialize "big" attribute DATA + ! Create dataspace for dataset CALL h5screate_f(H5S_SCALAR_F, sid, error) CALL check("h5screate_f",error,total_error) - ! Create "big" dataspace for "large" attributes + ! Create "big" dataspace for "large" attributes CALL h5screate_simple_f(arank, adims2, big_sid, error) CALL check("h5screate_simple_f",error,total_error) - ! Loop over type of shared components + ! Loop over type of shared components DO test_shared = 0, 2 - ! Make copy of file creation property list + ! Make copy of file creation property list CALL H5Pcopy_f(fcpl, my_fcpl, error) CALL check("H5Pcopy",error,total_error) - ! Set up datatype for attributes + ! Set up datatype for attributes CALL H5Tcopy_f(H5T_NATIVE_INTEGER, attr_tid, error) CALL check("H5Tcopy",error,total_error) - ! Special setup for each type of shared components + ! Special setup for each type of shared components IF( test_shared .EQ. 0) THEN - ! Make attributes > 500 bytes shared + ! Make attributes > 500 bytes shared CALL H5Pset_shared_mesg_nindexes_f(my_fcpl,1,error) CALL check("H5Pset_shared_mesg_nindexes_f",error, total_error) CALL H5Pset_shared_mesg_index_f(my_fcpl, 0, H5O_SHMESG_ATTR_FLAG_F, 500,error) CALL check(" H5Pset_shared_mesg_index_f",error, total_error) ELSE - ! Set up copy of file creation property list + ! Set up copy of file creation property list CALL H5Pset_shared_mesg_nindexes_f(my_fcpl,3,error) - ! Make attributes > 500 bytes shared + ! Make attributes > 500 bytes shared CALL H5Pset_shared_mesg_index_f(my_fcpl, 0, H5O_SHMESG_ATTR_FLAG_F, 500,error) - ! Make datatypes & dataspaces > 1 byte shared (i.e. all of them :-) + ! Make datatypes & dataspaces > 1 byte shared (i.e. all of them :-) CALL H5Pset_shared_mesg_index_f(my_fcpl, 1, H5O_SHMESG_DTYPE_FLAG_F, 1,error) CALL H5Pset_shared_mesg_index_f(my_fcpl, 2, H5O_SHMESG_SDSPACE_FLAG_F, 1,error) ENDIF - ! Create file + ! Create file CALL h5fcreate_f(FileName, H5F_ACC_TRUNC_F, fid, error, my_fcpl, fapl) CALL check("h5fcreate_f",error,total_error) - ! Close FCPL copy + ! Close FCPL copy CALL h5pclose_f(my_fcpl, error) CALL check("h5pclose_f", error, total_error) - ! Close file + ! Close file CALL h5fclose_f(fid, error) CALL check("h5fclose_f",error,total_error) - ! Re-open file + ! Re-open file CALL h5fopen_f(FileName, H5F_ACC_RDWR_F, fid, error,fapl) CALL check("h5open_f",error,total_error) - ! Commit datatype to file + ! Commit datatype to file IF(test_shared.EQ.2) THEN CALL H5Tcommit_f(fid, TYPE1_NAME, attr_tid, error, H5P_DEFAULT_F, H5P_DEFAULT_F, H5P_DEFAULT_F) CALL check("H5Tcommit",error,total_error) ENDIF - ! Set up to query the object creation properties + ! Set up to query the object creation properties CALL H5Pcreate_f(H5P_DATASET_CREATE_F,dcpl,error) CALL check("h5Pcreate_f",error,total_error) - ! Create datasets + ! Create datasets CALL h5dcreate_f(fid, DSET1_NAME, H5T_NATIVE_CHARACTER, sid, dataset, error, dcpl_id=dcpl ) CALL check("h5dcreate_f",error,total_error) @@ -1853,42 +1853,42 @@ SUBROUTINE test_attr_shared_delete(fcpl, fapl, total_error) CALL h5dcreate_f(fid, DSET2_NAME, H5T_NATIVE_CHARACTER, sid, dataset2, error, dcpl_id=dcpl ) CALL check("h5dcreate_f",error,total_error) - ! Retrieve limits for compact/dense attribute storage + ! Retrieve limits for compact/dense attribute storage CALL H5Pget_attr_phase_change_f(dcpl, max_compact, min_dense, error) CALL check("H5Pget_attr_phase_change_f",error,total_error) - ! Close property list + ! Close property list CALL h5pclose_f(dcpl,error) CALL check("h5pclose_f", error, total_error) - ! Add attributes to each dataset, until after converting to dense storage + ! Add attributes to each dataset, until after converting to dense storage DO u = 0, (max_compact * 2) - 1 - ! Create attribute name + ! Create attribute name WRITE(chr2,'(I2.2)') u attrname = 'attr '//chr2 - ! Alternate between creating "small" & "big" attributes + ! Alternate between creating "small" & "big" attributes IF(MOD(u+1,2).EQ.0)THEN - ! Create "small" attribute on first dataset + ! Create "small" attribute on first dataset CALL h5acreate_f(dataset, attrname, attr_tid, sid, attr, error, H5P_DEFAULT_F, H5P_DEFAULT_F) CALL check("h5acreate_f",error,total_error) - ! Write data into the attribute + ! Write data into the attribute attr_integer_data(1) = u + 1 data_dims(1) = 1 CALL h5awrite_f(attr, attr_tid, attr_integer_data, data_dims, error) CALL check("h5awrite_f",error,total_error) ELSE - ! Create "big" attribute on first dataset + ! Create "big" attribute on first dataset CALL h5acreate_f(dataset, attrname, attr_tid, big_sid, attr, error) CALL check("h5acreate_f",error,total_error) - ! Write data into the attribute + ! Write data into the attribute attr_integer_data(1) = u + 1 data_dims(1) = 1 @@ -1897,31 +1897,31 @@ SUBROUTINE test_attr_shared_delete(fcpl, fapl, total_error) ENDIF - ! Close attribute + ! Close attribute CALL h5aclose_f(attr, error) CALL check("h5aclose_f",error,total_error) - ! Alternate between creating "small" & "big" attributes + ! Alternate between creating "small" & "big" attributes IF(MOD(u+1,2).EQ.0)THEN - ! Create "small" attribute on second dataset + ! Create "small" attribute on second dataset CALL h5acreate_f(dataset2, attrname, attr_tid, sid, attr, error) CALL check("h5acreate_f",error,total_error) - ! Write data into the attribute + ! Write data into the attribute attr_integer_data(1) = u + 1 data_dims(1) = 1 CALL h5awrite_f(attr, attr_tid, attr_integer_data, data_dims, error) CALL check("h5awrite_f",error,total_error) ELSE - ! Create "big" attribute on second dataset + ! Create "big" attribute on second dataset CALL h5acreate_f(dataset2, attrname, attr_tid, big_sid, attr, error, acpl_id=H5P_DEFAULT_F, aapl_id=H5P_DEFAULT_F) CALL check("h5acreate_f",error,total_error) -! Write data into the attribute +! Write data into the attribute attr_integer_data(1) = u + 1 @@ -1930,21 +1930,21 @@ SUBROUTINE test_attr_shared_delete(fcpl, fapl, total_error) CALL check("h5awrite_f",error,total_error) ENDIF - ! Close attribute + ! Close attribute CALL h5aclose_f(attr, error) CALL check("h5aclose_f",error,total_error) ENDDO - ! Delete attributes from second dataset + ! Delete attributes from second dataset DO u = 0, max_compact*2-1 - ! Create attribute name + ! Create attribute name WRITE(chr2,'(I2.2)') u attrname = 'attr '//chr2 - ! Delete second dataset's attribute + ! Delete second dataset's attribute CALL H5Adelete_by_name_f(fid, DSET2_NAME, attrname,error,lapl_id=H5P_DEFAULT_F) CALL check("H5Adelete_by_name", error, total_error) @@ -1952,31 +1952,31 @@ SUBROUTINE test_attr_shared_delete(fcpl, fapl, total_error) CALL check("h5aopen_f",error,total_error) - ! Close attribute + ! Close attribute CALL h5aclose_f(attr, error) CALL check("h5aclose_f",error,total_error) ENDDO - ! Close attribute's datatype + ! Close attribute's datatype CALL h5tclose_f(attr_tid, error) CALL check("h5tclose_f",error,total_error) - ! Close Datasets + ! Close Datasets CALL h5dclose_f(dataset, error) CALL check("h5dclose_f",error,total_error) CALL h5dclose_f(dataset2, error) CALL check("h5dclose_f",error,total_error) - ! Unlink datasets WITH attributes + ! Unlink datasets WITH attributes CALL h5ldelete_f(fid, DSET1_NAME, error, H5P_DEFAULT_F) CALL check("H5Ldelete_f", error, total_error) CALL h5ldelete_f(fid, DSET2_NAME, error) CALL check("H5Ldelete_f", error, total_error) - ! Unlink committed datatype + ! Unlink committed datatype IF( test_shared == 2) THEN CALL h5ldelete_f(fid, TYPE1_NAME, error) @@ -1984,13 +1984,13 @@ SUBROUTINE test_attr_shared_delete(fcpl, fapl, total_error) ENDIF - ! Close file + ! Close file CALL h5fclose_f(fid, error) CALL check("h5fclose_f",error,total_error) ENDDO - ! Close dataspaces + ! Close dataspaces CALL h5sclose_f(sid, error) CALL check("h5sclose_f",error,total_error) CALL h5sclose_f(big_sid, error) @@ -2040,73 +2040,73 @@ SUBROUTINE test_attr_dense_open( fcpl, fapl, total_error) data_dims = 0 - ! Create file + ! Create file CALL h5fcreate_f(FileName, H5F_ACC_TRUNC_F, fid, error, fcpl, fapl) CALL check("h5fcreate_f",error,total_error) - ! Close file + ! Close file CALL h5fclose_f(fid, error) CALL check("h5fclose_f",error,total_error) - ! Re-open file + ! Re-open file CALL h5fopen_f(FileName, H5F_ACC_RDWR_F, fid, error, fapl) CALL check("h5open_f",error,total_error) - ! Create dataspace for dataset + ! Create dataspace for dataset CALL h5screate_f(H5S_SCALAR_F, sid, error) CALL check("h5screate_f",error,total_error) - ! Query the group creation properties + ! Query the group creation properties CALL H5Pcreate_f(H5P_DATASET_CREATE_F,dcpl,error) CALL check("h5Pcreate_f",error,total_error) - ! Enable creation order tracking on attributes, so creation order tests work + ! Enable creation order tracking on attributes, so creation order tests work CALL H5Pset_attr_creation_order_f(dcpl, H5P_CRT_ORDER_TRACKED_F, error) CALL check("H5Pset_attr_creation_order",error,total_error) - ! Create a dataset + ! Create a dataset CALL h5dcreate_f(fid, DSET1_NAME, H5T_NATIVE_CHARACTER, sid, dataset, error, & lcpl_id=H5P_DEFAULT_F, dcpl_id=dcpl, dapl_id=H5P_DEFAULT_F) CALL check("h5dcreate_f",error,total_error) - ! Retrieve limits for compact/dense attribute storage + ! Retrieve limits for compact/dense attribute storage CALL H5Pget_attr_phase_change_f(dcpl, max_compact, min_dense, error) CALL check("H5Pget_attr_phase_change_f",error,total_error) - ! Close property list + ! Close property list CALL h5pclose_f(dcpl, error) CALL check("h5pclose_f",error,total_error) - ! Add attributes, until just before converting to dense storage + ! Add attributes, until just before converting to dense storage DO u = 0, max_compact - 1 - ! Create attribute + ! Create attribute WRITE(chr2,'(I2.2)') u attrname = 'attr '//chr2 CALL h5acreate_f(dataset, attrname, H5T_NATIVE_INTEGER, sid, attr, error, aapl_id=H5P_DEFAULT_F) CALL check("h5acreate_f",error,total_error) - ! Write data into the attribute + ! Write data into the attribute data_dims(1) = 1 CALL h5awrite_f(attr, H5T_NATIVE_INTEGER, u, data_dims, error) CALL check("h5awrite_f",error,total_error) - ! Close attribute + ! Close attribute CALL h5aclose_f(attr, error) CALL check("h5aclose_f",error,total_error) - ! Verify attributes written so far + ! Verify attributes written so far CALL test_attr_dense_verify(dataset, u, total_error) ENDDO ! -! Add one more attribute, to push into "dense" storage -! Create attribute +! Add one more attribute, to push into "dense" storage +! Create attribute WRITE(chr2,'(I2.2)') u attrname = 'attr '//chr2 @@ -2114,36 +2114,36 @@ SUBROUTINE test_attr_dense_open( fcpl, fapl, total_error) CALL h5acreate_f(dataset, attrname, H5T_NATIVE_INTEGER, sid, attr, error, aapl_id=H5P_DEFAULT_F) CALL check("h5acreate_f",error,total_error) - ! Write data into the attribute + ! Write data into the attribute data_dims(1) = 1 CALL h5awrite_f(attr, H5T_NATIVE_INTEGER, u, data_dims, error) CALL check("h5awrite_f",error,total_error) - ! Close attribute + ! Close attribute CALL h5aclose_f(attr, error) CALL check("h5aclose_f",error,total_error) - ! Close dataspace + ! Close dataspace CALL h5sclose_f(sid, error) CALL check("h5sclose_f",error,total_error) - ! Verify all the attributes written + ! Verify all the attributes written ! ret = test_attr_dense_verify(dataset, (u + 1)); ! CHECK(ret, FAIL, "test_attr_dense_verify"); - ! CLOSE Dataset + ! CLOSE Dataset CALL h5dclose_f(dataset, error) CALL check("h5dclose_f",error,total_error) - ! Unlink dataset with attributes + ! Unlink dataset with attributes CALL h5ldelete_f(fid, DSET1_NAME, error, H5P_DEFAULT_F) CALL check("H5Ldelete_f", error, total_error) - ! Close file + ! Close file CALL h5fclose_f(fid, error) CALL check("h5fclose_f",error,total_error) - ! Check size of file + ! Check size of file ! filesize = h5_get_file_size(FILENAME); ! verify(filesize, empty_filesize, "h5_get_file_size") @@ -2179,21 +2179,21 @@ SUBROUTINE test_attr_dense_verify(loc_id, max_attr, total_error) data_dims = 0 - ! Retrieve the current # of reported errors + ! Retrieve the current # of reported errors ! old_nerrs = GetTestNumErrs(); - ! Re-open all the attributes by name and verify the data + ! Re-open all the attributes by name and verify the data DO u = 0, max_attr -1 - ! Open attribute + ! Open attribute WRITE(chr2,'(I2.2)') u attrname = 'attr '//chr2 CALL h5aopen_f(loc_id, attrname, attr, error) CALL check("h5aopen_f",error,total_error) - ! Read data from the attribute + ! Read data from the attribute ! value = 103 data_dims(1) = 1 @@ -2202,22 +2202,22 @@ SUBROUTINE test_attr_dense_verify(loc_id, max_attr, total_error) CALL CHECK("H5Aread_F", error, total_error) CALL verify("H5Aread_F", value, u, total_error) - ! Close attribute + ! Close attribute CALL h5aclose_f(attr, error) CALL check("h5aclose_f",error,total_error) ENDDO - ! Re-open all the attributes by index and verify the data + ! Re-open all the attributes by index and verify the data DO u=0, max_attr-1 - ! Open attribute + ! Open attribute CALL H5Aopen_by_idx_f(loc_id, ".", H5_INDEX_CRT_ORDER_F, H5_ITER_INC_F, INT(u,HSIZE_T), & attr, error, aapl_id=H5P_DEFAULT_F) - ! Verify Name + ! Verify Name WRITE(chr2,'(I2.2)') u attrname = 'attr '//chr2 @@ -2228,14 +2228,14 @@ SUBROUTINE test_attr_dense_verify(loc_id, max_attr, total_error) WRITE(*,*) 'ERROR: attribute name different: attr_name = ',check_name, ', should be ', attrname total_error = total_error + 1 ENDIF - ! Read data from the attribute + ! Read data from the attribute data_dims(1) = 1 CALL h5aread_f(attr, H5T_NATIVE_INTEGER, value, data_dims, error) CALL CHECK("H5Aread_f", error, total_error) CALL verify("H5Aread_f", value, u, total_error) - ! Close attribute + ! Close attribute CALL h5aclose_f(attr, error) CALL check("h5aclose_f",error,total_error) ENDDO @@ -2270,30 +2270,30 @@ SUBROUTINE test_attr_corder_create_basic( fcpl, fapl, total_error ) INTEGER :: crt_order_flags INTEGER :: minusone = -1 - ! Output message about test being performed + ! Output message about test being performed ! WRITE(*,*) " - Testing Basic Code for Attributes with Creation Order Info" - ! Create file + ! Create file CALL h5fcreate_f(FileName, H5F_ACC_TRUNC_F, fid, error, fcpl, fapl) CALL check("h5fcreate_f",error,total_error) - ! Create dataset creation property list + ! Create dataset creation property list CALL H5Pcreate_f(H5P_DATASET_CREATE_F,dcpl,error) CALL check("h5Pcreate_f",error,total_error) - ! Get creation order indexing on object + ! Get creation order indexing on object CALL H5Pget_attr_creation_order_f(dcpl, crt_order_flags, error) CALL check("H5Pget_attr_creation_order_f",error,total_error) CALL verify("H5Pget_attr_creation_order_f",crt_order_flags , 0, total_error) - ! Setting invalid combination of a attribute order creation order indexing on should fail + ! Setting invalid combination of a attribute order creation order indexing on should fail CALL H5Pset_attr_creation_order_f(dcpl, H5P_CRT_ORDER_INDEXED_F, error) CALL verify("H5Pset_attr_creation_order_f",error , minusone, total_error) CALL H5Pget_attr_creation_order_f(dcpl, crt_order_flags, error) CALL check("H5Pget_attr_creation_order_f",error,total_error) CALL verify("H5Pget_attr_creation_order_f",crt_order_flags , 0, total_error) - ! Set attribute creation order tracking & indexing for object + ! Set attribute creation order tracking & indexing for object CALL h5pset_attr_creation_order_f(dcpl, IOR(H5P_CRT_ORDER_TRACKED_F, H5P_CRT_ORDER_INDEXED_F), error) CALL check("H5Pset_attr_creation_order_f",error,total_error) @@ -2302,60 +2302,60 @@ SUBROUTINE test_attr_corder_create_basic( fcpl, fapl, total_error ) CALL verify("H5Pget_attr_creation_order_f",crt_order_flags , & IOR(H5P_CRT_ORDER_TRACKED_F, H5P_CRT_ORDER_INDEXED_F), total_error) - ! Create dataspace for dataset + ! Create dataspace for dataset CALL h5screate_f(H5S_SCALAR_F, sid, error) CALL check("h5screate_f",error,total_error) - ! Create a dataset + ! Create a dataset CALL h5dcreate_f(fid, DSET1_NAME, H5T_NATIVE_CHARACTER, sid, dataset, error, & lcpl_id=H5P_DEFAULT_F, dapl_id=H5P_DEFAULT_F, dcpl_id=dcpl) CALL check("h5dcreate_f",error,total_error) - ! Close dataspace + ! Close dataspace CALL h5sclose_f(sid, error) CALL check("h5sclose_f",error,total_error) - ! Close Dataset + ! Close Dataset CALL h5dclose_f(dataset, error) CALL check("h5dclose_f",error,total_error) - ! Close property list + ! Close property list CALL h5pclose_f(dcpl, error) CALL check("h5pclose_f",error,total_error) - ! Close file + ! Close file CALL h5fclose_f(fid, error) CALL check("h5fclose_f",error,total_error) - ! Re-open file + ! Re-open file CALL h5fopen_f(FileName, H5F_ACC_RDWR_F, fid, error, fapl) CALL check("h5open_f",error,total_error) - ! Open dataset created + ! Open dataset created CALL h5dopen_f(fid, DSET1_NAME, dataset, error, H5P_DEFAULT_F ) CALL check("h5dopen_f",error,total_error) - ! Retrieve dataset creation property list for group + ! Retrieve dataset creation property list for group CALL H5Dget_create_plist_f(dataset, dcpl, error) CALL check("H5Dget_create_plist_f",error,total_error) - ! Query the attribute creation properties + ! Query the attribute creation properties CALL H5Pget_attr_creation_order_f(dcpl, crt_order_flags, error) CALL check("H5Pget_attr_creation_order_f",error,total_error) CALL verify("H5Pget_attr_creation_order_f",crt_order_flags , & IOR(H5P_CRT_ORDER_TRACKED_F, H5P_CRT_ORDER_INDEXED_F), total_error ) - ! Close property list + ! Close property list CALL h5pclose_f(dcpl, error) CALL check("h5pclose_f",error,total_error) - ! Close Dataset + ! Close Dataset CALL h5dclose_f(dataset, error) CALL check("h5dclose_f",error,total_error) - ! Close file + ! Close file CALL h5fclose_f(fid, error) CALL check("h5fclose_f",error,total_error) @@ -2418,97 +2418,97 @@ SUBROUTINE test_attr_basic_write(fapl, total_error) attr_data1a(3) = -99890 - ! Create file + ! Create file CALL h5fcreate_f(FileName, H5F_ACC_TRUNC_F, fid1, error, H5P_DEFAULT_F, fapl) CALL check("h5fcreate_f",error,total_error) - ! Create dataspace for dataset + ! Create dataspace for dataset CALL h5screate_simple_f(rank1, dims1, sid1, error, maxdims1) CALL check("h5screate_simple_f",error,total_error) - ! Create a dataset + ! Create a dataset CALL h5dcreate_f(fid1, DSET1_NAME, H5T_NATIVE_CHARACTER, sid1, dataset, error, H5P_DEFAULT_F, H5P_DEFAULT_F, H5P_DEFAULT_F ) CALL check("h5dcreate_f",error,total_error) - ! Create dataspace for attribute + ! Create dataspace for attribute CALL h5screate_simple_f(ATTR1_RANK, dimsa, sid2, error) CALL check("h5screate_simple_f",error,total_error) - ! Try to create an attribute on the file (should create an attribute on root group) + ! Try to create an attribute on the file (should create an attribute on root group) CALL h5acreate_f(fid1, ATTR1_NAME, H5T_NATIVE_INTEGER, sid2, attr, error, aapl_id=H5P_DEFAULT_F, acpl_id=H5P_DEFAULT_F) CALL check("h5acreate_f",error,total_error) - ! Close attribute + ! Close attribute CALL h5aclose_f(attr, error) CALL check("h5aclose_f",error,total_error) - ! Open the root group + ! Open the root group CALL H5Gopen_f(fid1, "/", group, error, H5P_DEFAULT_F) CALL check("H5Gopen_f",error,total_error) - ! Open attribute again + ! Open attribute again CALL h5aopen_f(group, ATTR1_NAME, attr, error) CALL check("h5aopen_f",error,total_error) - ! Close attribute + ! Close attribute CALL h5aclose_f(attr, error) CALL check("h5aclose_f",error,total_error) - ! Close root group + ! Close root group CALL H5Gclose_f(group, error) CALL check("h5gclose_f",error,total_error) - ! Create an attribute for the dataset + ! Create an attribute for the dataset CALL h5acreate_f(dataset, ATTR1_NAME, H5T_NATIVE_INTEGER, sid2, attr, error, H5P_DEFAULT_F, H5P_DEFAULT_F) CALL check("h5acreate_f",error,total_error) - ! Write attribute information + ! Write attribute information CALL h5awrite_f(attr, H5T_NATIVE_INTEGER, attr_data1, dimsa, error) CALL check("h5awrite_f",error,total_error) - ! Create an another attribute for the dataset + ! Create an another attribute for the dataset CALL h5acreate_f(dataset, ATTR1A_NAME, H5T_NATIVE_INTEGER, sid2, attr2, error, H5P_DEFAULT_F, H5P_DEFAULT_F) CALL check("h5acreate_f",error,total_error) - ! Write attribute information + ! Write attribute information CALL h5awrite_f(attr2, H5T_NATIVE_INTEGER, attr_data1a, dimsa, error) CALL check("h5awrite_f",error,total_error) - ! Check storage size for attribute + ! Check storage size for attribute CALL h5aget_storage_size_f(attr, attr_size, error) CALL check("h5aget_storage_size_f",error,total_error) !EP CALL verify("h5aget_storage_size_f", INT(attr_size), 2*HSIZE_T, total_error) - ! Read attribute information immediately, without closing attribute + ! Read attribute information immediately, without closing attribute CALL h5aread_f(attr, H5T_NATIVE_INTEGER, read_data1, dimsa, error) CALL check("h5aread_f",error,total_error) - ! Verify values read in + ! Verify values read in DO i = 1, ATTR1_DIM1 CALL verify('h5aread_f',attr_data1(i),read_data1(i), total_error) ENDDO - ! CLOSE attribute + ! CLOSE attribute CALL h5aclose_f(attr, error) CALL check("h5aclose_f",error,total_error) - ! Close attribute + ! Close attribute CALL h5aclose_f(attr2, error) CALL check("h5aclose_f",error,total_error) - ! change attribute name + ! change attribute name CALL H5Arename_f(dataset, ATTR1_NAME, ATTR_TMP_NAME, error) CALL check("H5Arename_f", error, total_error) - ! Open attribute again + ! Open attribute again CALL h5aopen_f(dataset, ATTR_TMP_NAME, attr, error) CALL check("h5aopen_f",error,total_error) - ! Verify new attribute name + ! Verify new attribute name ! Set a deliberately small size check_name = ' ' ! need to initialize or does not pass test @@ -2539,7 +2539,7 @@ SUBROUTINE test_attr_basic_write(fapl, total_error) CALL check('H5Aget_name_f',error,total_error) CALL verify('H5Aget_name_f',chr_exact_size,ATTR_TMP_NAME, total_error) - ! Close attribute + ! Close attribute CALL h5aclose_f(attr, error) CALL check("h5aclose_f",error,total_error) @@ -2547,11 +2547,11 @@ SUBROUTINE test_attr_basic_write(fapl, total_error) CALL check("h5sclose_f",error,total_error) CALL h5sclose_f(sid2, error) CALL check("h5sclose_f",error,total_error) - ! Close Dataset + ! Close Dataset CALL h5dclose_f(dataset, error) CALL check("h5dclose_f",error,total_error) - ! Close file + ! Close file CALL h5fclose_f(fid1, error) CALL check("h5fclose_f",error,total_error) @@ -2594,20 +2594,20 @@ SUBROUTINE test_attr_many(new_format, fcpl, fapl, total_error) data_dims = 0 - ! Create file + ! Create file CALL h5fcreate_f(FileName, H5F_ACC_TRUNC_F, fid, error, fcpl, fapl) CALL check("h5fcreate_f",error,total_error) - ! Create dataspace for attribute + ! Create dataspace for attribute CALL h5screate_f(H5S_SCALAR_F, sid, error) CALL check("h5screate_f",error,total_error) - ! Create group for attributes + ! Create group for attributes CALL H5Gcreate_f(fid, GROUP1_NAME, gid, error) CALL check("H5Gcreate_f", error, total_error) - ! Create many attributes + ! Create many attributes IF(new_format)THEN nattr = 250 @@ -2651,15 +2651,15 @@ SUBROUTINE test_attr_many(new_format, fcpl, fapl, total_error) ENDDO - ! Close group + ! Close group CALL H5Gclose_f(gid, error) CALL check("h5gclose_f",error,total_error) - ! Close file + ! Close file CALL h5fclose_f(fid, error) CALL check("h5fclose_f",error,total_error) - ! Close dataspaces + ! Close dataspaces CALL h5sclose_f(sid, error) CALL check("h5sclose_f",error,total_error) @@ -2677,7 +2677,7 @@ END SUBROUTINE test_attr_many ! * March 21, 2008 ! * ! *------------------------------------------------------------------------- -! +! SUBROUTINE attr_open_check(fid, dsetname, obj_id, max_attrs, total_error ) @@ -2699,10 +2699,10 @@ SUBROUTINE attr_open_check(fid, dsetname, obj_id, max_attrs, total_error ) INTEGER(HSIZE_T) :: storage_size ! attributes storage requirements CHARACTER(LEN=2) :: chr2 INTEGER(HID_T) attr_id - ! Open each attribute on object by index and check that it's the correct one + ! Open each attribute on object by index and check that it's the correct one DO u = 0, max_attrs-1 - ! Open the attribute + ! Open the attribute WRITE(chr2,'(I2.2)') u attrname = 'attr '//chr2 @@ -2712,12 +2712,12 @@ SUBROUTINE attr_open_check(fid, dsetname, obj_id, max_attrs, total_error ) CALL check("h5aopen_f",error,total_error) - ! Get the attribute's information + ! Get the attribute's information CALL h5aget_info_f(attr_id, f_corder_valid, corder, cset, data_size, error) CALL check("h5aget_info_f",error,total_error) - ! Check that the object's attributes are correct + ! Check that the object's attributes are correct CALL verify("h5aget_info_f.corder",corder,u,total_error) CALL verify("h5aget_info_f.corder_valid",f_corder_valid,.TRUE.,total_error) CALL verify("h5aget_info_f.cset", cset, H5T_CSET_ASCII_F, total_error) @@ -2727,18 +2727,18 @@ SUBROUTINE attr_open_check(fid, dsetname, obj_id, max_attrs, total_error ) CALL verify("h5aget_info_f.data_size", INT(data_size), INT(storage_size), total_error) - ! Close attribute + ! Close attribute CALL h5aclose_f(attr_id, error) CALL check("h5aclose_f",error,total_error) - ! Open the attribute + ! Open the attribute CALL H5Aopen_by_name_f(obj_id, ".", attrname, attr_id, error, lapl_id=H5P_DEFAULT_F, aapl_id=H5P_DEFAULT_F) CALL check("H5Aopen_by_name_f", error, total_error) CALL h5aget_info_f(attr_id, f_corder_valid, corder, cset, data_size, error) CALL check("h5aget_info_f",error,total_error) - ! Check the attribute's information + ! Check the attribute's information CALL verify("h5aget_info_f",corder,u,total_error) CALL verify("h5aget_info_f",f_corder_valid,.TRUE.,total_error) CALL verify("h5aget_info_f", cset, H5T_CSET_ASCII_F, total_error) @@ -2746,21 +2746,21 @@ SUBROUTINE attr_open_check(fid, dsetname, obj_id, max_attrs, total_error ) CALL check("h5aget_storage_size_f",error,total_error) CALL verify("h5aget_info_f", INT(data_size), INT(storage_size), total_error) - ! Close attribute + ! Close attribute CALL h5aclose_f(attr_id, error) CALL check("h5aclose_f",error,total_error) - ! Open the attribute + ! Open the attribute CALL H5Aopen_by_name_f(fid, dsetname, attrname, attr_id, error) CALL check("H5Aopen_by_name_f", error, total_error) - ! Get the attribute's information + ! Get the attribute's information CALL h5aget_info_f(attr_id, f_corder_valid, corder, cset, data_size, error) CALL check("h5aget_info_f",error,total_error) - ! Check the attribute's information + ! Check the attribute's information CALL verify("h5aget_info_f",corder,u,total_error) CALL verify("h5aget_info_f",f_corder_valid,.TRUE.,total_error) CALL verify("h5aget_info_f", cset, H5T_CSET_ASCII_F, total_error) @@ -2768,7 +2768,7 @@ SUBROUTINE attr_open_check(fid, dsetname, obj_id, max_attrs, total_error ) CALL check("h5aget_storage_size_f",error,total_error) CALL verify("h5aget_info_f", INT(data_size), INT(storage_size), total_error) - ! Close attribute + ! Close attribute CALL h5aclose_f(attr_id, error) CALL check("h5aclose_f",error,total_error) ENDDO diff --git a/fortran/test/tH5D.F90 b/fortran/test/tH5D.F90 index 7001b98..7f8a988 100644 --- a/fortran/test/tH5D.F90 +++ b/fortran/test/tH5D.F90 @@ -44,31 +44,31 @@ CONTAINS IMPLICIT NONE LOGICAL, INTENT(IN) :: cleanup INTEGER, INTENT(OUT) :: total_error - + CHARACTER(LEN=5), PARAMETER :: filename = "dsetf" ! File name CHARACTER(LEN=80) :: fix_filename CHARACTER(LEN=4), PARAMETER :: dsetname = "dset" ! Dataset name CHARACTER(LEN=9), PARAMETER :: null_dsetname = "null_dset" ! Dataset name - + INTEGER(HID_T) :: file_id ! File identifier INTEGER(HID_T) :: dset_id ! Dataset identifier INTEGER(HID_T) :: null_dset ! Null dataset identifier INTEGER(HID_T) :: dspace_id ! Dataspace identifier INTEGER(HID_T) :: null_dspace ! Null dataspace identifier INTEGER(HID_T) :: dtype_id ! Datatype identifier - + INTEGER(HSIZE_T), DIMENSION(2) :: dims = (/4,6/) ! Dataset dimensions INTEGER :: rank = 2 ! Dataset rank - + INTEGER, DIMENSION(4,6) :: dset_data, data_out ! Data buffers INTEGER :: error ! Error flag - + INTEGER :: i, j !general purpose integers INTEGER(HSIZE_T), DIMENSION(2) :: data_dims INTEGER(HSIZE_T), DIMENSION(1) :: null_data_dim INTEGER :: null_dset_data = 1 ! null data INTEGER :: flag ! Space allocation status - + ! ! Initialize the dset_data array. ! @@ -157,10 +157,10 @@ CONTAINS CALL h5dget_space_status_f(dset_id, flag, error) CALL check("h5dget_space_status_f",error, total_error) CALL VERIFY("h5dget_space_status_f", flag, H5D_SPACE_STS_ALLOCATED_F, total_error) - + CALL h5dget_space_status_f(null_dset, flag, error) CALL check("h5dget_space_status_f",error, total_error) - CALL VERIFY("h5dget_space_status_f", flag, H5D_SPACE_STS_NOT_ALLOCATED_F, total_error) + CALL VERIFY("h5dget_space_status_f", flag, H5D_SPACE_STS_NOT_ALLOCATED_F, total_error) ! ! Get the dataset type. ! @@ -210,7 +210,7 @@ CONTAINS ! CALL h5sclose_f(dspace_id, error) CALL check("h5sclose_f", error, total_error) - + ! ! Terminate access to the data type. ! @@ -223,86 +223,86 @@ CONTAINS CALL check("h5fclose_f", error, total_error) IF(cleanup) CALL h5_cleanup_f(filename, H5P_DEFAULT_F, error) CALL check("h5_cleanup_f", error, total_error) - + RETURN END SUBROUTINE datasettest - + ! !the following subroutine tests h5dextend_f functionality ! SUBROUTINE extenddsettest(cleanup, total_error) - + IMPLICIT NONE - + LOGICAL, INTENT(IN) :: cleanup INTEGER, INTENT(OUT) :: total_error - + ! !the dataset is stored in file "extf.h5" ! CHARACTER(LEN=4), PARAMETER :: filename = "extf" CHARACTER(LEN=80) :: fix_filename - + ! !dataset name is "ExtendibleArray" ! CHARACTER(LEN=15), PARAMETER :: dsetname = "ExtendibleArray" - + ! !dataset rank is 2 ! INTEGER :: RANK = 2 - + INTEGER(HID_T) :: file_id ! File identifier INTEGER(HID_T) :: dset_id ! Dataset identifier INTEGER(HID_T) :: dataspace ! Dataspace identifier INTEGER(HID_T) :: memspace ! memory Dataspace identifier INTEGER(HID_T) :: crp_list ! dataset creatation property identifier - + ! !dataset dimensions at creation time ! INTEGER(HSIZE_T), DIMENSION(2) :: dims = (/3,3/) - + ! !data dimensions ! INTEGER(HSIZE_T), DIMENSION(2) :: dims1 = (/10,3/) - + ! !Maximum dimensions ! INTEGER(HSIZE_T), DIMENSION(2) :: maxdims - + ! !data arrays for reading and writing ! INTEGER, DIMENSION(10,3) :: data_in, data_out - + ! !Size of data in the file ! INTEGER(HSIZE_T), DIMENSION(2) :: size - + ! !general purpose integer ! INTEGER :: i, j INTEGER(HSIZE_T) :: ih, jh - + ! !flag to check operation success ! INTEGER :: error - + ! !Variables used in reading data back ! INTEGER(HSIZE_T), DIMENSION(2) :: dimsr, maxdimsr INTEGER :: rankr INTEGER(HSIZE_T), DIMENSION(2) :: data_dims - + ! !data initialization ! @@ -311,7 +311,7 @@ CONTAINS data_in(i,j) = 2 END DO END DO - + ! !Initialize FORTRAN predifined datatypes ! @@ -328,24 +328,24 @@ CONTAINS ENDIF CALL h5fcreate_f(fix_filename, H5F_ACC_TRUNC_F, file_id, error) CALL check("h5fcreate_f",error,total_error) - + ! !Create the data space with unlimited dimensions. ! maxdims = (/H5S_UNLIMITED_F, H5S_UNLIMITED_F/) - + CALL h5screate_simple_f(RANK, dims, dataspace, error, maxdims) CALL check("h5screate_simple_f",error,total_error) - + ! !Modify dataset creation properties, i.e. enable chunking ! CALL h5pcreate_f(H5P_DATASET_CREATE_F, crp_list, error) CALL check("h5pcreate_f",error,total_error) - + CALL h5pset_chunk_f(crp_list, RANK, dims1, error) CALL check("h5pset_chunk_f",error,total_error) - + ! !Create a dataset with 3X3 dimensions using cparms creation propertie . ! @@ -359,8 +359,8 @@ CONTAINS SIZE(2) = 3 CALL h5dextend_f(dset_id, size, error) CALL check("h5dextend_f",error,total_error) - - + + ! !Extend the dataset. Dataset becomes 10 x 3. ! @@ -368,7 +368,7 @@ CONTAINS SIZE(2) = 3; CALL h5dextend_f(dset_id, size, error) CALL check("h5dextend_f",error,total_error) - + ! !Write the data of size 10X3 to the extended dataset. ! @@ -376,13 +376,13 @@ CONTAINS data_dims(2) = 3 CALL H5dwrite_f(dset_id, H5T_NATIVE_INTEGER, data_in, data_dims, error) CALL check("h5dwrite_f",error,total_error) - + ! !Close the dataspace for the dataset. ! CALL h5sclose_f(dataspace, error) CALL check("h5sclose_f",error,total_error) - + ! !Close the property list. ! @@ -393,13 +393,13 @@ CONTAINS ! CALL h5dclose_f(dset_id, error) CALL check("h5dclose_f",error,total_error) - + ! !Close the file. ! CALL h5fclose_f(file_id, error) CALL check("h5fclose_f",error,total_error) - + ! !read the data back ! @@ -407,19 +407,19 @@ CONTAINS ! CALL h5fopen_f (fix_filename, H5F_ACC_RDONLY_F, file_id, error) CALL check("hfopen_f",error,total_error) - + ! !Open the dataset. ! CALL h5dopen_f(file_id, dsetname, dset_id, error) CALL check("h5dopen_f",error,total_error) - + ! !Get dataset's dataspace handle. ! CALL h5dget_space_f(dset_id, dataspace, error) CALL check("h5dget_space_f",error,total_error) - + ! !Get dataspace's rank. ! @@ -429,7 +429,7 @@ CONTAINS WRITE(*,*) "dataset rank error occured" STOP END IF - + ! !Get dataspace's dimensinons. ! @@ -439,27 +439,27 @@ CONTAINS WRITE(*,*) "dataset dimensions error occured" STOP END IF - + ! !Get creation property list. ! CALL h5dget_create_plist_f(dset_id, crp_list, error) CALL check("h5dget_create_plist_f",error,total_error) - + ! !create memory dataspace. ! CALL h5screate_simple_f(rankr, dimsr, memspace, error) CALL check("h5screate_simple_f",error,total_error) - + ! !Read data ! CALL H5dread_f(dset_id, H5T_NATIVE_INTEGER, data_out, data_dims, error, memspace, dataspace) CALL check("h5dread_f",error,total_error) - + ! !Compare the data. ! @@ -471,31 +471,31 @@ CONTAINS END IF END DO END DO - + ! !Close the dataspace for the dataset. ! CALL h5sclose_f(dataspace, error) CALL check("h5sclose_f",error,total_error) - + ! !Close the memspace for the dataset. ! CALL h5sclose_f(memspace, error) CALL check("h5sclose_f",error,total_error) - + ! !Close the property list. ! CALL h5pclose_f(crp_list, error) CALL check("h5pclose_f",error,total_error) - + ! !Close the dataset. ! CALL h5dclose_f(dset_id, error) CALL check("h5dclose_f",error,total_error) - + ! !Close the file. ! @@ -503,7 +503,7 @@ CONTAINS CALL check("h5fclose_f",error,total_error) IF(cleanup) CALL h5_cleanup_f(filename, H5P_DEFAULT_F, error) CALL check("h5_cleanup_f", error, total_error) - + RETURN END SUBROUTINE extenddsettest @@ -549,7 +549,7 @@ CONTAINS DO i = 1, dset_dim1 DO j = 1, dset_dim2 n = n + 1 - data_in(i,j) = n + data_in(i,j) = n END DO END DO CALL h5fcreate_f(fix_filename, H5F_ACC_TRUNC_F, file, error, fcpl) @@ -557,7 +557,7 @@ CONTAINS ! Create the data space dims(1:2) = (/dset_dim1,dset_dim2/) - + CALL h5screate_simple_f(2, dims, space, error) CALL check("h5screate_simple_f",error,total_error) @@ -596,7 +596,7 @@ CONTAINS total_error = total_error + 1 RETURN ENDIF - ! The pos= specifier illustrates that positions are in bytes, + ! The pos= specifier illustrates that positions are in bytes, ! starting from byte 1 (as opposed to C, where they start from byte 0) READ(10, POS=offset+1, IOSTAT=ios) rdata IF(ios.NE.0)THEN @@ -625,7 +625,7 @@ CONTAINS CALL check("h5_cleanup_f", error, total_error) IF(cleanup) CALL h5_cleanup_f(filename, H5P_DEFAULT_F, error) CALL check("h5_cleanup_f", error, total_error) - + END SUBROUTINE test_userblock_offset END MODULE TH5D diff --git a/fortran/test/tH5E_F03.F90 b/fortran/test/tH5E_F03.F90 index 1878966..a8ca103 100644 --- a/fortran/test/tH5E_F03.F90 +++ b/fortran/test/tH5E_F03.F90 @@ -5,7 +5,7 @@ ! ! FUNCTION ! Test FORTRAN HDF5 H5E APIs which are dependent on FORTRAN 2003 -! features. +! features. ! ! COPYRIGHT ! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @@ -168,10 +168,10 @@ SUBROUTINE test_error(total_error) !!$#ifdef H5_USE_16_API !!$ if (old_func != (H5E_auto_t)H5Eprint) !!$ TEST_ERROR; -!!$#else H5_USE_16_API +!!$#else H5_USE_16_API !!$ if (old_func != (H5E_auto2_t)H5Eprint2) !!$ TEST_ERROR; -!!$#endif H5_USE_16_API +!!$#endif H5_USE_16_API ! set the customized error handling routine diff --git a/fortran/test/tH5F.F90 b/fortran/test/tH5F.F90 index b898c21..16464dd 100644 --- a/fortran/test/tH5F.F90 +++ b/fortran/test/tH5F.F90 @@ -25,10 +25,10 @@ ! !***** ! -! In the mountingtest subroutine we create one file with a group in it, +! In the mountingtest subroutine we create one file with a group in it, ! and another file with a dataset. Mounting is used to -! access the dataset from the second file as a member of a group -! in the first file. +! access the dataset from the second file as a member of a group +! in the first file. MODULE TH5F @@ -148,7 +148,7 @@ CONTAINS CALL check(" h5tcopy_f",error,total_error) CALL h5tcopy_f(H5T_NATIVE_CHARACTER, t4, error) CALL check(" h5tcopy_f",error,total_error) - + CALL h5fget_obj_count_f(INT(H5F_OBJ_ALL_F,HID_T), H5F_OBJ_ALL_F, obj_count, error) CALL check(" h5fget_obj_count_f",error,total_error) @@ -280,7 +280,7 @@ CONTAINS IF(obj_count.NE.1)THEN total_error = total_error + 1 - ENDIF + ENDIF CALL h5fopen_f (fix_filename2, H5F_ACC_RDWR_F, file2_id, error) CALL check("h5fopen_f",error,total_error) @@ -290,7 +290,7 @@ CONTAINS IF(obj_count.NE.2)THEN total_error = total_error + 1 - ENDIF + ENDIF ! !Check file numbers diff --git a/fortran/test/tH5F_F03.F90 b/fortran/test/tH5F_F03.F90 index 8cc6b83..f938565 100644 --- a/fortran/test/tH5F_F03.F90 +++ b/fortran/test/tH5F_F03.F90 @@ -5,7 +5,7 @@ ! ! FUNCTION ! Test FORTRAN HDF5 H5F APIs which are dependent on FORTRAN 2003 -! features. +! features. ! ! COPYRIGHT ! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @@ -37,8 +37,8 @@ MODULE TH5F_F03 USE HDF5 - USE TH5_MISC - USE TH5_MISC_GEN + USE TH5_MISC + USE TH5_MISC_GEN USE ISO_C_BINDING CONTAINS @@ -79,21 +79,21 @@ SUBROUTINE test_get_file_image(total_error) CALL h5fcreate_f("tget_file_image.h5", H5F_ACC_TRUNC_F, file_id, error, H5P_DEFAULT_F, fapl) CALL check("h5fcreate_f", error, total_error) - ! Set up data space for new data set + ! Set up data space for new data set dims(1:2) = (/10,10/) - + CALL h5screate_simple_f(2, dims, space_id, error) CALL check("h5screate_simple_f", error, total_error) - ! Create a dataset + ! Create a dataset CALL h5dcreate_f(file_id, "dset 0", H5T_NATIVE_INTEGER, space_id, dset_id, error) CALL check("h5dcreate_f", error, total_error) - ! Write some data to the data set + ! Write some data to the data set DO i = 1, 100 data(i) = INT(i) ENDDO - + f_ptr = C_LOC(data(1)) CALL h5dwrite_f(dset_id, H5T_NATIVE_INTEGER, f_ptr, error) CALL check("h5dwrite_f",error, total_error) @@ -102,7 +102,7 @@ SUBROUTINE test_get_file_image(total_error) CALL h5fflush_f(file_id, H5F_SCOPE_GLOBAL_F, error) CALL check("h5fflush_f",error, total_error) - ! Open the test file using standard I/O calls + ! Open the test file using standard I/O calls OPEN(UNIT=10,FILE='tget_file_image.h5', ACCESS='STREAM') ! Get the size of the test file ! @@ -110,8 +110,8 @@ SUBROUTINE test_get_file_image(total_error) ! may be larger. This is OK, as long as (in this specialized instance) ! the remainder of the file is all '\0's. ! - ! With latest mods to truncate call in core file drive, - ! file size should match image size; get the file size + ! With latest mods to truncate call in core file drive, + ! file size should match image size; get the file size INQUIRE(UNIT=10, SIZE=file_sz) CLOSE(UNIT=10) @@ -131,7 +131,7 @@ SUBROUTINE test_get_file_image(total_error) CALL verify("h5fget_file_image_f", INT(itmp_a), 1, total_error) ! Routine should not change the value CALL verify("h5fget_file_image_f", file_sz, INT(image_size), total_error) - ! Allocate a buffer of the appropriate size + ! Allocate a buffer of the appropriate size ALLOCATE(image_ptr(1:image_size)) ! Load the image of the file into the buffer @@ -139,7 +139,7 @@ SUBROUTINE test_get_file_image(total_error) CALL h5fget_file_image_f(file_id, f_ptr, image_size, error) CALL check("h5fget_file_image_f",error, total_error) - ! Close dset and space + ! Close dset and space CALL h5dclose_f(dset_id, error) CALL check("h5dclose_f", error, total_error) CALL h5sclose_f(space_id, error) @@ -151,7 +151,7 @@ SUBROUTINE test_get_file_image(total_error) ! Allocate a buffer for the test file image ALLOCATE(file_image_ptr(1:image_size)) - ! Open the test file using standard I/O calls + ! Open the test file using standard I/O calls OPEN(UNIT=10,FILE='tget_file_image.h5', FORM='UNFORMATTED', ACCESS='STREAM') ! Read the test file from disk into the buffer diff --git a/fortran/test/tH5G_1_8.F90 b/fortran/test/tH5G_1_8.F90 index 58431a1..c35edad 100644 --- a/fortran/test/tH5G_1_8.F90 +++ b/fortran/test/tH5G_1_8.F90 @@ -22,7 +22,7 @@ ! ! CONTAINS SUBROUTINES ! group_test, group_info, timestamps, mklinks, test_move_preserves, lifecycle -! cklinks, delete_by_idx, link_info_by_idx_check, test_lcpl, objcopy, +! cklinks, delete_by_idx, link_info_by_idx_check, test_lcpl, objcopy, ! lapl_nlinks ! !***** @@ -41,7 +41,7 @@ SUBROUTINE group_test(cleanup, total_error) LOGICAL, INTENT(IN) :: cleanup INTEGER, INTENT(INOUT) :: total_error - INTEGER(HID_T) :: fapl, fapl2, my_fapl ! File access property lists + INTEGER(HID_T) :: fapl, fapl2, my_fapl ! File access property lists INTEGER :: error, ret_total_error @@ -49,15 +49,15 @@ SUBROUTINE group_test(cleanup, total_error) CALL H5Pcreate_f(H5P_FILE_ACCESS_F, fapl, error) CALL check("H5Pcreate_f",error, total_error) - ! Copy the file access property list + ! Copy the file access property list CALL H5Pcopy_f(fapl, fapl2, error) CALL check("H5Pcopy_f",error, total_error) - ! Set the "use the latest version of the format" bounds for creating objects in the file + ! Set the "use the latest version of the format" bounds for creating objects in the file CALL H5Pset_libver_bounds_f(fapl2, H5F_LIBVER_LATEST_F, H5F_LIBVER_LATEST_F, error) CALL check("H5Pset_libver_bounds_f",error, total_error) - ! Check for FAPL to USE + ! Check for FAPL to USE my_fapl = fapl2 ret_total_error = 0 @@ -135,7 +135,7 @@ END SUBROUTINE group_test ! * February 18, 2008 ! * ! *------------------------------------------------------------------------- -! +! SUBROUTINE group_info(cleanup, fapl, total_error) @@ -143,21 +143,21 @@ SUBROUTINE group_info(cleanup, fapl, total_error) INTEGER, INTENT(INOUT) :: total_error INTEGER(HID_T), INTENT(IN) :: fapl - INTEGER(HID_T) :: gcpl_id ! Group creation property list ID + INTEGER(HID_T) :: gcpl_id ! Group creation property list ID - INTEGER :: max_compact ! Maximum # of links to store in group compactly - INTEGER :: min_dense ! Minimum # of links to store in group "densely" + INTEGER :: max_compact ! Maximum # of links to store in group compactly + INTEGER :: min_dense ! Minimum # of links to store in group "densely" - INTEGER :: idx_type ! Type of index to operate on - INTEGER :: order, iorder ! Order within in the index - LOGICAL, DIMENSION(1:2) :: use_index = (/.FALSE.,.TRUE./) ! Use index on creation order values + INTEGER :: idx_type ! Type of index to operate on + INTEGER :: order, iorder ! Order within in the index + LOGICAL, DIMENSION(1:2) :: use_index = (/.FALSE.,.TRUE./) ! Use index on creation order values CHARACTER(LEN=6), PARAMETER :: prefix = 'links0' - CHARACTER(LEN=9), PARAMETER :: filename = prefix//'.h5' ! File name + CHARACTER(LEN=9), PARAMETER :: filename = prefix//'.h5' ! File name INTEGER :: Input1 - INTEGER(HID_T) :: group_id ! Group ID - INTEGER(HID_T) :: soft_group_id ! Group ID for soft links + INTEGER(HID_T) :: group_id ! Group ID + INTEGER(HID_T) :: soft_group_id ! Group ID for soft links - INTEGER :: i ! Local index variables + INTEGER :: i ! Local index variables INTEGER :: storage_type ! Type of storage for links in group: ! H5G_STORAGE_TYPE_COMPACT: Compact storage ! H5G_STORAGE_TYPE_DENSE: Indexed storage @@ -165,34 +165,34 @@ SUBROUTINE group_info(cleanup, fapl, total_error) INTEGER :: nlinks ! Number of links in group INTEGER :: max_corder ! Current maximum creation order value for group - INTEGER :: u,v ! Local index variables + INTEGER :: u,v ! Local index variables CHARACTER(LEN=2) :: chr2 - INTEGER(HID_T) :: group_id2, group_id3 ! Group IDs - CHARACTER(LEN=7) :: objname ! Object name - CHARACTER(LEN=7) :: objname2 ! Object name - CHARACTER(LEN=19) :: valname ! Link value + INTEGER(HID_T) :: group_id2, group_id3 ! Group IDs + CHARACTER(LEN=7) :: objname ! Object name + CHARACTER(LEN=7) :: objname2 ! Object name + CHARACTER(LEN=19) :: valname ! Link value CHARACTER(LEN=12), PARAMETER :: CORDER_GROUP_NAME = "corder_group" CHARACTER(LEN=17), PARAMETER :: CORDER_SOFT_GROUP_NAME = "corder_soft_group" - INTEGER(HID_T) :: file_id ! File ID - INTEGER :: error ! Generic return value + INTEGER(HID_T) :: file_id ! File ID + INTEGER :: error ! Generic return value LOGICAL :: mounted LOGICAL :: cleanup - ! Create group creation property list + ! Create group creation property list CALL H5Pcreate_f(H5P_GROUP_CREATE_F, gcpl_id, error ) CALL check("H5Pcreate_f", error, total_error) - ! Query the group creation properties + ! Query the group creation properties CALL H5Pget_link_phase_change_f(gcpl_id, max_compact, min_dense, error) CALL check("H5Pget_link_phase_change_f", error, total_error) - ! Loop over operating on different indices on link fields + ! Loop over operating on different indices on link fields DO idx_type = H5_INDEX_NAME_F, H5_INDEX_CRT_ORDER_F - ! Loop over operating in different orders + ! Loop over operating in different orders DO iorder = H5_ITER_INC_F, H5_ITER_NATIVE_F - ! Loop over using index for creation order value + ! Loop over using index for creation order value DO i = 1, 2 - ! Print appropriate test message + ! Print appropriate test message IF(idx_type == H5_INDEX_CRT_ORDER_F)THEN IF(iorder == H5_ITER_INC_F)THEN order = H5_ITER_INC_F @@ -241,11 +241,11 @@ SUBROUTINE group_info(cleanup, fapl, total_error) ENDIF END IF - ! Create file + ! Create file CALL H5Fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, error, H5P_DEFAULT_F, fapl) CALL check("H5Fcreate_f", error, total_error) - ! Set creation order tracking & indexing on group + ! Set creation order tracking & indexing on group IF(use_index(i))THEN Input1 = H5P_CRT_ORDER_INDEXED_F ELSE @@ -254,103 +254,103 @@ SUBROUTINE group_info(cleanup, fapl, total_error) CALL H5Pset_link_creation_order_f(gcpl_id, IOR(H5P_CRT_ORDER_TRACKED_F, Input1), error) CALL check("H5Pset_link_creation_order_f", error, total_error) - ! Create group with creation order tracking on + ! Create group with creation order tracking on CALL H5Gcreate_f(file_id, CORDER_GROUP_NAME, group_id, error, gcpl_id=gcpl_id) CALL check("H5Gcreate_f", error, total_error) - ! Create group with creation order tracking on for soft links + ! Create group with creation order tracking on for soft links CALL H5Gcreate_f(file_id, CORDER_SOFT_GROUP_NAME, soft_group_id, error, & OBJECT_NAMELEN_DEFAULT_F, H5P_DEFAULT_F, gcpl_id) CALL check("H5Gcreate_f", error, total_error) - ! Check for out of bound query by index on empty group, should fail + ! Check for out of bound query by index on empty group, should fail CALL H5Gget_info_by_idx_f(group_id, ".", H5_INDEX_NAME_F, order, INT(0,HSIZE_T), & storage_type, nlinks, max_corder, error) CALL verify("H5Gget_info_by_idx_f", error, -1, total_error) - ! Create several links, up to limit of compact form + ! Create several links, up to limit of compact form DO u = 0, max_compact-1 - ! Make name for link + ! Make name for link WRITE(chr2,'(I2.2)') u objname = 'fill '//chr2 - ! Create hard link, with group object + ! Create hard link, with group object CALL H5Gcreate_f(group_id, objname, group_id2, error, OBJECT_NAMELEN_DEFAULT_F, H5P_DEFAULT_F, gcpl_id) CALL check("H5Gcreate_f", error, total_error) - ! Retrieve group's information + ! Retrieve group's information CALL H5Gget_info_f(group_id2, storage_type, nlinks, max_corder, error, mounted) CALL check("H5Gget_info_f", error, total_error) - ! Check (new/empty) group's information + ! Check (new/empty) group's information CALL verify("H5Gget_info_f", storage_type, H5G_STORAGE_TYPE_COMPACT_F, total_error) CALL verify("H5Gget_info_f", max_corder, 0, total_error) CALL verify("H5Gget_info_f", nlinks, 0, total_error) CALL verify("H5Gget_info_f.mounted", mounted,.FALSE.,total_error) - ! Retrieve group's information + ! Retrieve group's information CALL H5Gget_info_by_name_f(group_id, objname, storage_type, nlinks, max_corder, error, mounted=mounted) CALL check("H5Gget_info_by_name_f", error, total_error) - ! Check (new/empty) group's information + ! Check (new/empty) group's information CALL verify("H5Gget_info_by_name_f", storage_type, H5G_STORAGE_TYPE_COMPACT_F, total_error) CALL verify("H5Gget_info_by_name_f", max_corder, 0, total_error) CALL verify("H5Gget_info_by_name_f", nlinks, 0, total_error) CALL verify("H5Gget_info_by_name_f.mounted", mounted,.FALSE.,total_error) - ! Retrieve group's information + ! Retrieve group's information CALL H5Gget_info_by_name_f(group_id2, ".", storage_type, nlinks, max_corder, error) CALL check("H5Gget_info_by_name", error, total_error) - ! Check (new/empty) group's information + ! Check (new/empty) group's information CALL verify("H5Gget_info_by_name_f", storage_type, H5G_STORAGE_TYPE_COMPACT_F, total_error) CALL verify("H5Gget_info_by_name_f", max_corder, 0, total_error) CALL verify("H5Gget_info_by_name_f", nlinks, 0, total_error) - ! Create objects in new group created + ! Create objects in new group created DO v = 0, u - ! Make name for link + ! Make name for link WRITE(chr2,'(I2.2)') v objname2 = 'fill '//chr2 - ! Create hard link, with group object + ! Create hard link, with group object CALL H5Gcreate_f(group_id2, objname2, group_id3, error ) CALL check("H5Gcreate_f", error, total_error) - ! Close group created + ! Close group created CALL H5Gclose_f(group_id3, error) CALL check("H5Gclose_f", error, total_error) ENDDO - ! Retrieve group's information + ! Retrieve group's information CALL H5Gget_info_f(group_id2, storage_type, nlinks, max_corder, error) CALL check("H5Gget_info_f", error, total_error) - ! Check (new) group's information + ! Check (new) group's information CALL verify("H5Gget_info_f", storage_type, H5G_STORAGE_TYPE_COMPACT_F, total_error) CALL verify("H5Gget_info_f", max_corder, u+1, total_error) CALL verify("H5Gget_info_f", nlinks, u+1, total_error) - ! Retrieve group's information + ! Retrieve group's information CALL H5Gget_info_by_name_f(group_id, objname, storage_type, nlinks, max_corder, error) CALL check("H5Gget_info_by_name_f", error, total_error) - ! Check (new) group's information + ! Check (new) group's information CALL verify("H5Gget_info_by_name_f", storage_type, H5G_STORAGE_TYPE_COMPACT_F, total_error) CALL verify("H5Gget_info_by_name_f",max_corder, u+1, total_error) CALL verify("H5Gget_info_by_name_f", nlinks, u+1, total_error) - ! Retrieve group's information + ! Retrieve group's information CALL H5Gget_info_by_name_f(group_id2, ".", storage_type, nlinks, max_corder, error) CALL check("H5Gget_info_by_name_f", error, total_error) - ! Check (new) group's information + ! Check (new) group's information CALL verify("H5Gget_info_by_name_f", storage_type, H5G_STORAGE_TYPE_COMPACT_F, total_error) CALL verify("H5Gget_info_by_name_f", max_corder, u+1, total_error) CALL verify("H5Gget_info_by_name_f", nlinks, u+1, total_error) - ! Retrieve group's information + ! Retrieve group's information IF(order.NE.H5_ITER_NATIVE_F)THEN IF(order.EQ.H5_ITER_INC_F) THEN CALL H5Gget_info_by_idx_f(group_id, ".", idx_type, order, INT(u,HSIZE_T), & @@ -363,72 +363,72 @@ SUBROUTINE group_info(cleanup, fapl, total_error) CALL verify("H5Gget_info_by_idx_f", mounted,.FALSE.,total_error) CALL check("H5Gget_info_by_idx_f", error, total_error) ENDIF - ! Check (new) group's information + ! Check (new) group's information CALL verify("H5Gget_info_by_idx_f", storage_type, H5G_STORAGE_TYPE_COMPACT_F, total_error) CALL verify("H5Gget_info_by_idx_f", max_corder, u+1, total_error) CALL verify("H5Gget_info_by_idx_f", nlinks, u+1, total_error) ENDIF - ! Close group created + ! Close group created CALL H5Gclose_f(group_id2, error) CALL check("H5Gclose_f", error, total_error) - ! Retrieve main group's information + ! Retrieve main group's information CALL H5Gget_info_f(group_id, storage_type, nlinks, max_corder, error) CALL check("H5Gget_info_f", error, total_error) - ! Check main group's information + ! Check main group's information CALL verify("H5Gget_info_f", storage_type, H5G_STORAGE_TYPE_COMPACT_F, total_error) CALL verify("H5Gget_info_f", max_corder, u+1, total_error) CALL verify("H5Gget_info_f", nlinks, u+1, total_error) - ! Retrieve main group's information, by name + ! Retrieve main group's information, by name CALL H5Gget_info_by_name_f(file_id, CORDER_GROUP_NAME, storage_type, nlinks, max_corder, error) CALL check("H5Gget_info_by_name_f", error, total_error) - ! Check main group's information + ! Check main group's information CALL verify("H5Gget_info_by_name_f", storage_type, H5G_STORAGE_TYPE_COMPACT_F, total_error) CALL verify("H5Gget_info_by_name_f", max_corder, u+1, total_error) CALL verify("H5Gget_info_by_name_f", nlinks, u+1, total_error) - ! Retrieve main group's information, by name + ! Retrieve main group's information, by name CALL H5Gget_info_by_name_f(group_id, ".", storage_type, nlinks, max_corder, error, H5P_DEFAULT_F) CALL check("H5Gget_info_by_name_f", error, total_error) - ! Check main group's information + ! Check main group's information CALL verify("H5Gget_info_by_name_f", storage_type, H5G_STORAGE_TYPE_COMPACT_F, total_error) CALL verify("H5Gget_info_by_name_f", max_corder, u+1, total_error) CALL verify("H5Gget_info_by_name_f", nlinks, u+1, total_error) - ! Create soft link in another group, to objects in main group + ! Create soft link in another group, to objects in main group valname = CORDER_GROUP_NAME//objname CALL H5Lcreate_soft_f(valname, soft_group_id, objname, error, H5P_DEFAULT_F, H5P_DEFAULT_F) - ! Retrieve soft link group's information, by name + ! Retrieve soft link group's information, by name CALL H5Gget_info_f(soft_group_id, storage_type, nlinks, max_corder, error) CALL check("H5Gget_info_f", error, total_error) - ! Check soft link group's information + ! Check soft link group's information CALL verify("H5Gget_info_f", storage_type, H5G_STORAGE_TYPE_COMPACT_F, total_error) CALL verify("H5Gget_info_f", max_corder, u+1, total_error) CALL verify("H5Gget_info_f", nlinks, u+1, total_error) ENDDO - ! Close the groups + ! Close the groups CALL H5Gclose_f(group_id, error) CALL check("H5Gclose_f", error, total_error) CALL H5Gclose_f(soft_group_id, error) CALL check("H5Gclose_f", error, total_error) - ! Close the file + ! Close the file CALL H5Fclose_f(file_id, error) CALL check("H5Fclose_f", error, total_error) ENDDO ENDDO ENDDO - ! Free resources + ! Free resources CALL H5Pclose_f(gcpl_id, error) CALL check("H5Pclose_f", error, total_error) @@ -449,7 +449,7 @@ SUBROUTINE group_info(cleanup, fapl, total_error) ! * February 20, 2008 ! * ! *------------------------------------------------------------------------- -! +! SUBROUTINE timestamps(cleanup, fapl, total_error) @@ -457,15 +457,15 @@ SUBROUTINE group_info(cleanup, fapl, total_error) INTEGER, INTENT(INOUT) :: total_error INTEGER(HID_T), INTENT(IN) :: fapl - INTEGER(HID_T) :: file_id ! File ID - INTEGER(HID_T) :: group_id ! Group ID - INTEGER(HID_T) :: group_id2 ! Group ID - INTEGER(HID_T) :: gcpl_id ! Group creation property list ID - INTEGER(HID_T) :: gcpl_id2 ! Group creation property list ID + INTEGER(HID_T) :: file_id ! File ID + INTEGER(HID_T) :: group_id ! Group ID + INTEGER(HID_T) :: group_id2 ! Group ID + INTEGER(HID_T) :: gcpl_id ! Group creation property list ID + INTEGER(HID_T) :: gcpl_id2 ! Group creation property list ID CHARACTER(LEN=6), PARAMETER :: prefix = 'links9' - CHARACTER(LEN=9), PARAMETER :: filename = prefix//'.h5' ! File name - ! Timestamp macros + CHARACTER(LEN=9), PARAMETER :: filename = prefix//'.h5' ! File name + ! Timestamp macros CHARACTER(LEN=10), PARAMETER :: TIMESTAMP_GROUP_1="timestamp1" CHARACTER(LEN=10), PARAMETER :: TIMESTAMP_GROUP_2="timestamp2" LOGICAL :: track_times @@ -473,58 +473,58 @@ SUBROUTINE group_info(cleanup, fapl, total_error) INTEGER :: error - ! Print test message + ! Print test message ! WRITE(*,*) "timestamps on objects" - ! Create group creation property list + ! Create group creation property list CALL H5Pcreate_f(H5P_GROUP_CREATE_F, gcpl_id, error ) CALL check("H5Pcreate_f", error, total_error) - ! Query the object timestamp setting + ! Query the object timestamp setting CALL H5Pget_obj_track_times_f(gcpl_id, track_times, error) CALL check("H5Pget_obj_track_times_f", error, total_error) - ! Check default timestamp information + ! Check default timestamp information CALL verify("H5Pget_obj_track_times",track_times,.TRUE.,total_error) - ! Set a non-default object timestamp setting + ! Set a non-default object timestamp setting CALL H5Pset_obj_track_times_f(gcpl_id, .FALSE., error) CALL check("H5Pset_obj_track_times_f", error, total_error) - ! Query the object timestamp setting + ! Query the object timestamp setting CALL H5Pget_obj_track_times_f(gcpl_id, track_times, error) CALL check("H5Pget_obj_track_times_f", error, total_error) - ! Check default timestamp information + ! Check default timestamp information CALL verify("H5Pget_obj_track_times",track_times,.FALSE.,total_error) - ! Create file + ! Create file !h5_fixname(FILENAME[0], fapl, filename, sizeof filename); CALL H5Fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, error, H5P_DEFAULT_F, fapl) CALL check("h5fcreate_f",error,total_error) - ! Create group with non-default object timestamp setting + ! Create group with non-default object timestamp setting CALL h5gcreate_f(file_id, TIMESTAMP_GROUP_1, group_id, error, & OBJECT_NAMELEN_DEFAULT_F, H5P_DEFAULT_F, gcpl_id, H5P_DEFAULT_F) CALL check("h5fcreate_f",error,total_error) - ! Close the group creation property list + ! Close the group creation property list CALL H5Pclose_f(gcpl_id, error) CALL check("H5Pclose_f", error, total_error) - ! Create group with default object timestamp setting + ! Create group with default object timestamp setting CALL h5gcreate_f(file_id, TIMESTAMP_GROUP_2, group_id2, error, & OBJECT_NAMELEN_DEFAULT_F, H5P_DEFAULT_F, H5P_DEFAULT_F, H5P_DEFAULT_F) CALL check("h5fcreate_f",error,total_error) - ! Retrieve the new groups' creation properties + ! Retrieve the new groups' creation properties CALL H5Gget_create_plist_f(group_id, gcpl_id, error) CALL check("H5Gget_create_plist", error, total_error) CALL H5Gget_create_plist_f(group_id2, gcpl_id2, error) CALL check("H5Gget_create_plist", error, total_error) - ! Query & verify the object timestamp settings + ! Query & verify the object timestamp settings CALL H5Pget_obj_track_times_f(gcpl_id, track_times, error) CALL check("H5Pget_obj_track_times_f", error, total_error) CALL verify("H5Pget_obj_track_times1",track_times,.FALSE.,total_error) @@ -532,11 +532,11 @@ SUBROUTINE group_info(cleanup, fapl, total_error) CALL check("H5Pget_obj_track_times_f", error, total_error) CALL verify("H5Pget_obj_track_times2",track_times,.TRUE.,total_error) -! Query the object information for each group +! Query the object information for each group ! if(H5Oget_info(group_id, &oinfo) < 0) TEST_ERROR ! if(H5Oget_info(group_id2, &oinfo2) < 0) TEST_ERROR -!!$ Sanity check object information for each group +!!$ Sanity check object information for each group !!$ if(oinfo.atime != 0) TEST_ERROR !!$ if(oinfo.mtime != 0) TEST_ERROR !!$ if(oinfo.ctime != 0) TEST_ERROR @@ -550,40 +550,40 @@ SUBROUTINE group_info(cleanup, fapl, total_error) !!$ if(oinfo.hdr.space.total >= oinfo2.hdr.space.total) TEST_ERROR !!$ if(oinfo.hdr.space.meta >= oinfo2.hdr.space.meta) TEST_ERROR - ! Close the property lists + ! Close the property lists CALL H5Pclose_f(gcpl_id, error) CALL check("H5Pclose_f", error, total_error) CALL H5Pclose_f(gcpl_id2, error) CALL check("H5Pclose_f", error, total_error) - ! Close the groups + ! Close the groups CALL H5Gclose_f(group_id, error) CALL check("H5Gclose_f", error, total_error) CALL H5Gclose_f(group_id2, error) CALL check("H5Gclose_f", error, total_error) - ! Close the file + ! Close the file CALL H5Fclose_f(file_id, error) CALL check("H5Fclose_f", error, total_error) - ! Re-open the file + ! Re-open the file CALL h5fopen_f(FileName, H5F_ACC_RDONLY_F, file_id, error, H5P_DEFAULT_F) CALL check("h5fopen_f",error,total_error) - ! Open groups + ! Open groups CALL H5Gopen_f(file_id, TIMESTAMP_GROUP_1, group_id, error) ! with no optional param. CALL check("H5Gopen_f", error, total_error) CALL H5Gopen_f(file_id, TIMESTAMP_GROUP_2, group_id2, error, H5P_DEFAULT_F) ! with optional param. CALL check("H5Gopen_f", error, total_error) - ! Retrieve the new groups' creation properties + ! Retrieve the new groups' creation properties CALL H5Gget_create_plist_f(group_id, gcpl_id, error) CALL check("H5Gget_create_plist", error, total_error) CALL H5Gget_create_plist_f(group_id2, gcpl_id2, error) CALL check("H5Gget_create_plist", error, total_error) - ! Query & verify the object timestamp settings + ! Query & verify the object timestamp settings CALL H5Pget_obj_track_times_f(gcpl_id, track_times, error) CALL check("H5Pget_obj_track_times_f", error, total_error) @@ -592,11 +592,11 @@ SUBROUTINE group_info(cleanup, fapl, total_error) CALL check("H5Pget_obj_track_times_f", error, total_error) CALL verify("H5Pget_obj_track_times2",track_times,.TRUE.,total_error) !!$ -!!$ Query the object information for each group +!!$ Query the object information for each group !!$ if(H5Oget_info(group_id, &oinfo) < 0) TEST_ERROR !!$ if(H5Oget_info(group_id2, &oinfo2) < 0) TEST_ERROR !!$ -!!$ Sanity check object information for each group +!!$ Sanity check object information for each group !!$ if(oinfo.atime != 0) TEST_ERROR !!$ if(oinfo.mtime != 0) TEST_ERROR !!$ if(oinfo.ctime != 0) TEST_ERROR @@ -610,19 +610,19 @@ SUBROUTINE group_info(cleanup, fapl, total_error) !!$ if(oinfo.hdr.space.total >= oinfo2.hdr.space.total) TEST_ERROR !!$ if(oinfo.hdr.space.meta >= oinfo2.hdr.space.meta) TEST_ERROR - ! Close the property lists + ! Close the property lists CALL H5Pclose_f(gcpl_id, error) CALL check("H5Pclose_f", error, total_error) CALL H5Pclose_f(gcpl_id2, error) CALL check("H5Pclose_f", error, total_error) - ! Close the groups + ! Close the groups CALL H5Gclose_f(group_id, error) CALL check("H5Gclose_f", error, total_error) CALL H5Gclose_f(group_id2, error) CALL check("H5Gclose_f", error, total_error) - ! Close the file + ! Close the file CALL H5Fclose_f(file_id, error) CALL check("H5Fclose_f", error, total_error) @@ -643,7 +643,7 @@ SUBROUTINE group_info(cleanup, fapl, total_error) ! * Modifications: ! * ! *------------------------------------------------------------------------- -! +! SUBROUTINE mklinks(fapl, total_error) @@ -671,29 +671,29 @@ SUBROUTINE group_info(cleanup, fapl, total_error) WRITE(*,*) "link creation (w/new group format)" - ! Create a file + ! Create a file CALL h5fcreate_f(FileName, H5F_ACC_TRUNC_F, file, error, H5P_DEFAULT_F, fapl) CALL check("mklinks.h5fcreate_f",error,total_error) CALL h5screate_simple_f(arank, adims2, scalar, error) CALL check("mklinks.h5screate_simple_f",error,total_error) - ! Create a group + ! Create a group CALL H5Gcreate_f(file, "grp1", grp, error) CALL check("H5Gcreate_f", error, total_error) CALL H5Gclose_f(grp, error) CALL check("h5gclose_f",error,total_error) - ! Create a dataset + ! Create a dataset CALL h5dcreate_f(file, "d1", H5T_NATIVE_INTEGER, scalar, d1, error) CALL check("h5dcreate_f",error,total_error) CALL h5dclose_f(d1, error) CALL check("h5dclose_f",error,total_error) - ! Create a hard link + ! Create a hard link CALL H5Lcreate_hard_f(file, "d1", INT(H5L_SAME_LOC_F,HID_T), "grp1/hard", error) CALL check("H5Lcreate_hard_f", error, total_error) - ! Create a symbolic link + ! Create a symbolic link CALL H5Lcreate_soft_f("/d1", file, "grp1/soft",error) CALL check("H5Lcreate_soft_f", error, total_error) @@ -709,14 +709,14 @@ SUBROUTINE group_info(cleanup, fapl, 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 + ! Create a symbolic link to something that doesn't exist CALL H5Lcreate_soft_f("foobar", file, "grp1/dangle",error) - ! Create a recursive symbolic link + ! Create a recursive symbolic link CALL H5Lcreate_soft_f("/grp1/recursive", file, "/grp1/recursive",error) - ! Close + ! Close CALL h5sclose_f(scalar, error) CALL check("h5sclose_f",error,total_error) CALL h5fclose_f(file, error) @@ -736,7 +736,7 @@ SUBROUTINE group_info(cleanup, fapl, total_error) ! * Modifications: ! * ! *------------------------------------------------------------------------- -! +! SUBROUTINE test_move_preserves(fapl_id, total_error) @@ -746,20 +746,20 @@ SUBROUTINE group_info(cleanup, fapl, total_error) INTEGER(HID_T):: file_id INTEGER(HID_T):: group_id - INTEGER(HID_T):: fcpl_id ! Group creation property list ID + INTEGER(HID_T):: fcpl_id ! Group creation property list ID INTEGER(HID_T):: lcpl_id !H5O_info_t oinfo; !H5L_info_t linfo; INTEGER :: old_cset INTEGER :: old_corder !H5T_cset_t old_cset; - !int64_t old_corder; Creation order value of link + !int64_t old_corder; Creation order value of link !time_t old_modification_time; !time_t curr_time; - !unsigned crt_order_flags; Status of creation order info for GCPL + !unsigned crt_order_flags; Status of creation order info for GCPL !char filename[1024]; - INTEGER :: crt_order_flags ! Status of creation order info for GCPL + INTEGER :: crt_order_flags ! Status of creation order info for GCPL CHARACTER(LEN=12), PARAMETER :: filename = 'TestLinks.h5' INTEGER :: cset ! Indicates the character set used for the link’s name. @@ -779,7 +779,7 @@ SUBROUTINE group_info(cleanup, fapl, total_error) ! Create a file creation property list with creation order stored for links ! * in the root group - ! + ! CALL H5Pcreate_f(H5P_FILE_CREATE_F, fcpl_id, error) CALL check("H5Pcreate_f",error, total_error) @@ -795,26 +795,26 @@ SUBROUTINE group_info(cleanup, fapl, total_error) CALL check("H5Pget_link_creation_order_f",error, total_error) CALL verify("H5Pget_link_creation_order_f",crt_order_flags, H5P_CRT_ORDER_TRACKED_F, total_error) - ! Create file - ! (with creation order tracking for the root group) + ! Create file + ! (with creation order tracking for the root group) CALL h5fcreate_f(FileName, H5F_ACC_TRUNC_F, file_id, error, fcpl_id, fapl_id) CALL check("h5fcreate_f",error,total_error) - ! Create a link creation property list with the UTF-8 character encoding + ! Create a link creation property list with the UTF-8 character encoding CALL H5Pcreate_f(H5P_LINK_CREATE_F, lcpl_id, error) CALL check("H5Pcreate_f",error, total_error) CALL H5Pset_char_encoding_f(lcpl_id, H5T_CSET_UTF8_F, error) CALL check("H5Pset_char_encoding_f",error, total_error) - ! Create a group with that lcpl + ! Create a group with that lcpl CALL H5Gcreate_f(file_id, "group", group_id, error,lcpl_id=lcpl_id, gcpl_id=H5P_DEFAULT_F, gapl_id=H5P_DEFAULT_F) CALL check("H5Gcreate_f", error, total_error) CALL H5Gclose_f(group_id, error) CALL check("H5Gclose_f", error, total_error) - ! Get the group's link's information + ! Get the group's link's information CALL H5Lget_info_f(file_id, "group", & cset, corder, f_corder_valid, link_type, token, val_size, & error, H5P_DEFAULT_F) @@ -830,18 +830,18 @@ SUBROUTINE group_info(cleanup, fapl, total_error) ! old_modification_time = oinfo.mtime; -! If this test happens too quickly, the times will all be the same. Make sure the time changes. +! If this test happens too quickly, the times will all be the same. Make sure the time changes. ! curr_time = HDtime(NULL); ! while(HDtime(NULL) <= curr_time) ! ; -! Close the file and reopen it +! Close the file and reopen it CALL H5Fclose_f(file_id, error) CALL check("H5Fclose_f", error, total_error) !!$ if((file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) TEST_ERROR !!$ -!!$ Get the link's character set & modification time . They should be unchanged +!!$ Get the link's character set & modification time . They should be unchanged !!$ if(H5Lget_info(file_id, "group", &linfo, H5P_DEFAULT) < 0) TEST_ERROR !!$ if(H5Oget_info_by_name(file_id, "group", &oinfo, H5P_DEFAULT) < 0) TEST_ERROR !!$ if(old_modification_time != oinfo.mtime) TEST_ERROR @@ -849,7 +849,7 @@ SUBROUTINE group_info(cleanup, fapl, total_error) !!$ if(linfo.corder_valid != TRUE) TEST_ERROR !!$ if(old_corder != linfo.corder) TEST_ERROR !!$ -!!$ Create a new link to the group. It should have a different creation order value but the same modification time +!!$ Create a new link to the group. It should have a different creation order value but the same modification time !!$ if(H5Lcreate_hard(file_id, "group", file_id, "group2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR !!$ if(H5Oget_info_by_name(file_id, "group2", &oinfo, H5P_DEFAULT) < 0) TEST_ERROR !!$ if(old_modification_time != oinfo.mtime) TEST_ERROR @@ -862,7 +862,7 @@ SUBROUTINE group_info(cleanup, fapl, total_error) !!$ Copy the first link to a UTF-8 name. !!$ * Its creation order value should be different, but modification time !!$ * should not change. -!!$ +!!$ !!$ if(H5Lcopy(file_id, "group", file_id, "group_copied", lcpl_id, H5P_DEFAULT) < 0) TEST_ERROR !!$ if(H5Oget_info_by_name(file_id, "group_copied", &oinfo, H5P_DEFAULT) < 0) TEST_ERROR !!$ if(old_modification_time != oinfo.mtime) TEST_ERROR @@ -870,10 +870,10 @@ SUBROUTINE group_info(cleanup, fapl, total_error) !!$ if(linfo.corder_valid != TRUE) TEST_ERROR !!$ if(linfo.corder != 2) TEST_ERROR !!$ -!!$ Check that its character encoding is UTF-8 +!!$ Check that its character encoding is UTF-8 !!$ if(linfo.cset != H5T_CSET_UTF8) TEST_ERROR !!$ -!!$ Move the link with the default property list. +!!$ Move the link with the default property list. !!$ if(H5Lmove(file_id, "group_copied", file_id, "group_copied2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR !!$ if(H5Oget_info_by_name(file_id, "group_copied2", &oinfo, H5P_DEFAULT) < 0) TEST_ERROR !!$ if(old_modification_time != oinfo.mtime) TEST_ERROR @@ -881,10 +881,10 @@ SUBROUTINE group_info(cleanup, fapl, total_error) !!$ if(linfo.corder_valid != TRUE) TEST_ERROR !!$ if(linfo.corder != 3) TEST_ERROR !!$ -!!$ Check that its character encoding is not UTF-8 +!!$ Check that its character encoding is not UTF-8 !!$ if(linfo.cset == H5T_CSET_UTF8) TEST_ERROR !!$ -!!$ Check that the original link is unchanged +!!$ Check that the original link is unchanged !!$ if(H5Oget_info_by_name(file_id, "group", &oinfo, H5P_DEFAULT) < 0) TEST_ERROR !!$ if(old_modification_time != oinfo.mtime) TEST_ERROR !!$ if(H5Lget_info(file_id, "group", &linfo, H5P_DEFAULT) < 0) TEST_ERROR @@ -894,7 +894,7 @@ SUBROUTINE group_info(cleanup, fapl, total_error) !!$ !!$ Move the first link to a UTF-8 name. !!$ * Its creation order value will change, but modification time should not -!!$ * change. +!!$ * change. !!$ if(H5Lmove(file_id, "group", file_id, "group_moved", lcpl_id, H5P_DEFAULT) < 0) TEST_ERROR !!$ if(H5Oget_info_by_name(file_id, "group_moved", &oinfo, H5P_DEFAULT) < 0) TEST_ERROR !!$ if(old_modification_time != oinfo.mtime) TEST_ERROR @@ -902,10 +902,10 @@ SUBROUTINE group_info(cleanup, fapl, total_error) !!$ if(linfo.corder_valid != TRUE) TEST_ERROR !!$ if(linfo.corder != 4) TEST_ERROR !!$ -!!$ Check that its character encoding is UTF-8 +!!$ Check that its character encoding is UTF-8 !!$ if(linfo.cset != H5T_CSET_UTF8) TEST_ERROR !!$ -!!$ Move the link again using the default property list. +!!$ Move the link again using the default property list. !!$ if(H5Lmove(file_id, "group_moved", file_id, "group_moved_again", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR !!$ if(H5Oget_info_by_name(file_id, "group_moved_again", &oinfo, H5P_DEFAULT) < 0) TEST_ERROR !!$ if(old_modification_time != oinfo.mtime) TEST_ERROR @@ -913,10 +913,10 @@ SUBROUTINE group_info(cleanup, fapl, total_error) !!$ if(linfo.corder_valid != TRUE) TEST_ERROR !!$ if(linfo.corder != 5) TEST_ERROR !!$ -!!$ Check that its character encoding is not UTF-8 +!!$ Check that its character encoding is not UTF-8 !!$ if(linfo.cset == H5T_CSET_UTF8) TEST_ERROR - ! Close open IDs + ! Close open IDs CALL H5Pclose_f(fcpl_id, error) CALL check("H5Pclose_f", error, total_error) CALL H5Pclose_f(lcpl_id, error) @@ -941,7 +941,7 @@ SUBROUTINE group_info(cleanup, fapl, total_error) ! * Monday, October 17, 2005 ! * ! *------------------------------------------------------------------------- -! +! SUBROUTINE lifecycle(cleanup, fapl2, total_error) IMPLICIT NONE @@ -951,14 +951,14 @@ SUBROUTINE lifecycle(cleanup, fapl2, total_error) INTEGER, PARAMETER :: NAME_BUF_SIZE =7 - INTEGER(HID_T) :: fid ! File ID - INTEGER(HID_T) :: gid ! Group ID - INTEGER(HID_T) :: gcpl ! Group creation property list ID - INTEGER(size_t) :: lheap_size_hint ! Local heap size hint - INTEGER :: max_compact ! Maximum # of links to store in group compactly - INTEGER :: min_dense ! Minimum # of links to store in group "densely" - INTEGER :: est_num_entries ! Estimated # of entries in group - INTEGER :: est_name_len ! Estimated length of entry name + INTEGER(HID_T) :: fid ! File ID + INTEGER(HID_T) :: gid ! Group ID + INTEGER(HID_T) :: gcpl ! Group creation property list ID + INTEGER(size_t) :: lheap_size_hint ! Local heap size hint + INTEGER :: max_compact ! Maximum # of links to store in group compactly + INTEGER :: min_dense ! Minimum # of links to store in group "densely" + INTEGER :: est_num_entries ! Estimated # of entries in group + INTEGER :: est_name_len ! Estimated length of entry name CHARACTER(LEN=NAME_BUF_SIZE) :: filename = 'fixx.h5' INTEGER(SIZE_T) :: LIFECYCLE_LOCAL_HEAP_SIZE_HINT = 256 INTEGER :: LIFECYCLE_MAX_COMPACT = 4 @@ -975,29 +975,29 @@ SUBROUTINE lifecycle(cleanup, fapl2, total_error) ! WRITE(*,*) 'group lifecycle' - ! Create file + ! Create file CALL H5Fcreate_f(filename, H5F_ACC_TRUNC_F, fid, error, access_prp=fapl2) CALL check("H5Fcreate_f",error,total_error) - ! Close file + ! Close file CALL H5Fclose_f(fid,error) CALL check("H5Fclose_f",error,total_error) - ! Get size of file as empty + ! Get size of file as empty ! if((empty_size = h5_get_file_size(filename)) < 0) TEST_ERROR - ! Re-open file + ! Re-open file CALL H5Fopen_f(filename, H5F_ACC_RDWR_F, fid, error,access_prp=fapl2) CALL check("H5Fopen_f",error,total_error) - ! Set up group creation property list + ! Set up group creation property list CALL H5Pcreate_f(H5P_GROUP_CREATE_F,gcpl,error) CALL check("H5Pcreate_f",error,total_error) - ! Query default group creation property settings + ! Query default group creation property settings CALL H5Pget_local_heap_size_hint_f(gcpl, lheap_size_hint, error) CALL check("H5Pget_local_heap_size_hint_f",error,total_error) CALL verify("H5Pget_local_heap_size_hint_f", INT(lheap_size_hint),0,total_error) @@ -1014,7 +1014,7 @@ SUBROUTINE lifecycle(cleanup, fapl2, total_error) CALL verify("H5Pget_est_link_info_f", est_name_len, H5G_CRT_GINFO_EST_NAME_LEN,total_error) - ! Set GCPL parameters + ! Set GCPL parameters CALL H5Pset_local_heap_size_hint_f(gcpl, LIFECYCLE_LOCAL_HEAP_SIZE_HINT, error) CALL check("H5Pset_local_heap_size_hint_f", error, total_error) @@ -1023,12 +1023,12 @@ SUBROUTINE lifecycle(cleanup, fapl2, total_error) CALL H5Pset_est_link_info_f(gcpl, LIFECYCLE_EST_NUM_ENTRIES, LIFECYCLE_EST_NAME_LEN, error) CALL check("H5Pset_est_link_info_f", error, total_error) - ! Create group for testing lifecycle + ! Create group for testing lifecycle CALL H5Gcreate_f(fid, LIFECYCLE_TOP_GROUP, gid, error, gcpl_id=gcpl) CALL check("H5Gcreate_f", error, total_error) - ! Query group creation property settings + ! Query group creation property settings CALL H5Pget_local_heap_size_hint_f(gcpl, lheap_size_hint, error) CALL check("H5Pget_local_heap_size_hint_f",error,total_error) @@ -1046,20 +1046,20 @@ SUBROUTINE lifecycle(cleanup, fapl2, total_error) - ! Close top group + ! Close top group CALL H5Gclose_f(gid, error) CALL check("H5Gclose_f", error, total_error) - ! Unlink top group + ! Unlink top group CALL H5Ldelete_f(fid, LIFECYCLE_TOP_GROUP, error) CALL check("H5Ldelete_f", error, total_error) - ! Close GCPL + ! Close GCPL CALL H5Pclose_f(gcpl, error) CALL check("H5Pclose_f", error, total_error) - ! Close file + ! Close file CALL H5Fclose_f(fid,error) CALL check("H5Fclose_f",error,total_error) @@ -1084,7 +1084,7 @@ SUBROUTINE lifecycle(cleanup, fapl2, total_error) ! * Modifications: Modified original C code ! * ! *------------------------------------------------------------------------- -! +! SUBROUTINE cklinks(fapl, total_error) @@ -1104,25 +1104,25 @@ SUBROUTINE lifecycle(cleanup, fapl2, total_error) LOGICAL :: Lexists - ! Open the file + ! Open the file CALL H5Fopen_f(filename, H5F_ACC_RDONLY_F, file, error,access_prp=fapl) CALL check("H5Fopen_f",error,total_error) - ! Hard link + ! Hard link !!$ IF(H5Oget_info_by_name(file, "d1", &oinfo1, H5P_DEFAULT) < 0) FAIL_STACK_ERROR !!$ IF(H5Oget_info_by_name(file, "grp1/hard", &oinfo2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR !!$ IF(H5O_TYPE_DATASET != oinfo2.type) { !!$ H5_FAILED(); !!$ printf(" %d: Unexpected object type should have been a dataset\n", __LINE__); !!$ TEST_ERROR -!!$ } end if +!!$ } end if !!$ if(H5F_addr_ne(oinfo1.addr, oinfo2.addr)) { !!$ H5_FAILED(); !!$ puts(" Hard link test failed. Link seems not to point to the "); !!$ puts(" expected file location."); !!$ TEST_ERROR -!!$ } end if +!!$ } end if CALL H5Lexists_f(file,"d1",Lexists, error) @@ -1131,7 +1131,7 @@ SUBROUTINE lifecycle(cleanup, fapl2, total_error) CALL H5Lexists_f(file,"grp1/hard",Lexists, error) CALL verify("H5Lexists", Lexists,.TRUE.,total_error) - ! Cleanup + ! Cleanup CALL H5Fclose_f(file,error) CALL check("H5Fclose_f",error,total_error) @@ -1153,25 +1153,25 @@ END SUBROUTINE cklinks ! * March 3, 2008 ! * ! *------------------------------------------------------------------------- -! +! SUBROUTINE delete_by_idx(cleanup, fapl, total_error) IMPLICIT NONE INTEGER, INTENT(INOUT) :: total_error INTEGER(HID_T), INTENT(IN) :: fapl - INTEGER(HID_T) :: file_id ! File ID - INTEGER(HID_T) :: group_id ! Group ID - INTEGER(HID_T) :: gcpl_id ! Group creation property list ID + INTEGER(HID_T) :: file_id ! File ID + INTEGER(HID_T) :: group_id ! Group ID + INTEGER(HID_T) :: gcpl_id ! Group creation property list ID - INTEGER :: idx_type ! Type of index to operate on + INTEGER :: idx_type ! Type of index to operate on LOGICAL, DIMENSION(1:2) :: use_index = (/.FALSE.,.TRUE./) - ! Use index on creation order values - INTEGER :: max_compact ! Maximum # of links to store in group compactly - INTEGER :: min_dense ! Minimum # of links to store in group "densely" + ! Use index on creation order values + INTEGER :: max_compact ! Maximum # of links to store in group compactly + INTEGER :: min_dense ! Minimum # of links to store in group "densely" - CHARACTER(LEN=7) :: objname ! Object name - CHARACTER(LEN=8) :: filename = 'file0.h5' ! File name + CHARACTER(LEN=7) :: objname ! Object name + CHARACTER(LEN=8) :: filename = 'file0.h5' ! File name CHARACTER(LEN=12), PARAMETER :: CORDER_GROUP_NAME = "corder_group" LOGICAL :: f_corder_valid ! Indicates whether the creation order data is valid for this attribute @@ -1181,11 +1181,11 @@ SUBROUTINE delete_by_idx(cleanup, fapl, total_error) INTEGER :: link_type TYPE(H5O_TOKEN_T_F) :: token - INTEGER :: u ! Local index variable + INTEGER :: u ! Local index variable INTEGER :: Input1, i INTEGER(HID_T) :: group_id2 INTEGER(HID_T) :: grp - INTEGER :: iorder ! Order within in the index + INTEGER :: iorder ! Order within in the index CHARACTER(LEN=2) :: chr2 INTEGER :: error INTEGER :: id_type @@ -1203,13 +1203,13 @@ SUBROUTINE delete_by_idx(cleanup, fapl, total_error) fix_filename2(i:i) = " " ENDDO - ! Loop over operating on different indices on link fields + ! Loop over operating on different indices on link fields DO idx_type = H5_INDEX_NAME_F, H5_INDEX_CRT_ORDER_F - ! Loop over operating in different orders + ! Loop over operating in different orders DO iorder = H5_ITER_INC_F, H5_ITER_DEC_F - ! Loop over using index for creation order value + ! Loop over using index for creation order value DO i = 1, 2 - ! Print appropriate test message + ! Print appropriate test message !!$ IF(idx_type == H5_INDEX_CRT_ORDER_F)THEN !!$ IF(iorder == H5_ITER_INC_F)THEN !!$ IF(use_index(i))THEN @@ -1240,15 +1240,15 @@ SUBROUTINE delete_by_idx(cleanup, fapl, total_error) !!$ ENDIF !!$ ENDIF - ! Create file + ! Create file CALL H5Fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, error, access_prp=fapl) CALL check("delete_by_idx.H5Fcreate_f", error, total_error) - ! Create group creation property list + ! Create group creation property list CALL H5Pcreate_f(H5P_GROUP_CREATE_F, gcpl_id, error ) CALL check("delete_by_idx.H5Pcreate_f", error, total_error) - ! Set creation order tracking & indexing on group + ! Set creation order tracking & indexing on group IF(use_index(i))THEN Input1 = H5P_CRT_ORDER_INDEXED_F ELSE @@ -1258,54 +1258,54 @@ SUBROUTINE delete_by_idx(cleanup, fapl, total_error) CALL H5Pset_link_creation_order_f(gcpl_id, IOR(H5P_CRT_ORDER_TRACKED_F, Input1), error) CALL check("delete_by_idx.H5Pset_link_creation_order_f", error, total_error) - ! Create group with creation order tracking on + ! Create group with creation order tracking on CALL H5Gcreate_f(file_id, CORDER_GROUP_NAME, group_id, error, gcpl_id=gcpl_id) CALL check("delete_by_idx.H5Gcreate_f", error, total_error) - ! Query the group creation properties + ! Query the group creation properties CALL H5Pget_link_phase_change_f(gcpl_id, max_compact, min_dense, error) CALL check("delete_by_idx.H5Pget_link_phase_change_f", error, total_error) - ! Delete links from one end + ! Delete links from one end - ! Check for deletion on empty group + ! Check for deletion on empty group CALL H5Ldelete_by_idx_f(group_id, ".", idx_type, iorder, INT(0,HSIZE_T), error) CALL verify("delete_by_idx.H5Ldelete_by_idx_f", error, -1, total_error) ! test should fail (error = -1) - ! Create several links, up to limit of compact form + ! Create several links, up to limit of compact form DO u = 0, max_compact-1 - ! Make name for link + ! Make name for link WRITE(chr2,'(I2.2)') u objname = 'fill '//chr2 - ! Create hard link, with group object + ! Create hard link, with group object CALL H5Gcreate_f(group_id, objname, group_id2, error) CALL check("delete_by_idx.H5Gcreate_f", error, total_error) CALL H5Gclose_f(group_id2, error) CALL check("delete_by_idx.H5Gclose_f", error, total_error) - ! Verify link information for new link + ! Verify link information for new link CALL link_info_by_idx_check(group_id, objname, u, & .TRUE., use_index(i), total_error) ENDDO - ! Verify state of group (compact) + ! Verify state of group (compact) ! IF(H5G_has_links_test(group_id, NULL) != TRUE) TEST_ERROR - ! Check for out of bound deletion + ! Check for out of bound deletion 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("H5Ldelete_by_idx_f", error, -1, total_error) ! test should fail (error = -1) - ! Delete links from compact group + ! Delete links from compact group DO u = 0, (max_compact - 1) -1 - ! Delete first link in appropriate order + ! Delete first link in appropriate order CALL H5Ldelete_by_idx_f(group_id, ".", idx_type, iorder, INT(0,HSIZE_T), error) CALL check("H5Ldelete_by_idx_f", error, total_error) - ! Verify the link information for first link in appropriate order + ! 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), & @@ -1335,7 +1335,7 @@ SUBROUTINE delete_by_idx(cleanup, fapl, total_error) - ! Verify the name for first link in appropriate order + ! Verify the name for first link in appropriate order ! HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); !!$ size_tmp = 20 !!$ CALL H5Lget_name_by_idx_f(group_id, ".", idx_type, order, INT(0,HSIZE_T), size_tmp, tmpname, error) @@ -1351,15 +1351,15 @@ SUBROUTINE delete_by_idx(cleanup, fapl, total_error) !!$ CALL verify("delete_by_idx.H5Lget_name_by_idx_f", objname, tmpname, total_error) ENDDO - ! Close the group + ! Close the group CALL H5Gclose_f(group_id, error) CALL check("delete_by_idx.H5Gclose_f", error, total_error) - ! Close the group creation property list + ! Close the group creation property list CALL H5Pclose_f(gcpl_id, error) CALL check("delete_by_idx.H5Pclose_f", error, total_error) - ! Close the file + ! Close the file CALL H5Fclose_f(file_id, error) CALL check("delete_by_idx.H5Fclose_f", error, total_error) @@ -1391,7 +1391,7 @@ END SUBROUTINE delete_by_idx ! * Tuesday, November 7, 2006 ! * ! *------------------------------------------------------------------------- -! +! SUBROUTINE link_info_by_idx_check(group_id, linkname, n, & hard_link, use_index, total_error) @@ -1410,35 +1410,35 @@ SUBROUTINE link_info_by_idx_check(group_id, linkname, n, & TYPE(H5O_TOKEN_T_F) :: token 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 - CHARACTER(LEN=10) :: tmpname_big ! to big temporary link name + CHARACTER(LEN=7) :: tmpname ! Temporary link name + CHARACTER(LEN=3) :: tmpname_small ! to small temporary link name + CHARACTER(LEN=10) :: tmpname_big ! to big temporary link name - CHARACTER(LEN=7) :: valname ! Link value name + CHARACTER(LEN=7) :: valname ! Link value name CHARACTER(LEN=2) :: chr2 INTEGER(SIZE_T) :: size_tmp INTEGER :: error - ! Make link value for increasing/native order queries + ! Make link value for increasing/native order queries WRITE(chr2,'(I2.2)') n valname = 'valn.'//chr2 - ! Verify the link information for first link, in increasing creation order + ! 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), & link_type, f_corder_valid, corder, cset, token, 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 + ! 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), & link_type, f_corder_valid, corder, cset, token, val_size, error) CALL check("H5Lget_info_by_idx_f", error, total_error) CALL verify("H5Lget_info_by_idx_f", corder, n, total_error) - ! Verify value for new soft link, in increasing creation order + ! Verify value for new soft link, in increasing creation order !!$ IF(hard_link)THEN !!$ ! HDmemset(tmpval, 0, (size_t)NAME_BUF_SIZE); !!$ @@ -1448,7 +1448,7 @@ SUBROUTINE link_info_by_idx_check(group_id, linkname, n, & !!$! IF(HDstrcmp(valname, tmpval)) TEST_ERROR !!$ ENDIF - ! Verify the name for new link, in increasing creation order + ! Verify the name for new link, in increasing creation order ! HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); ! The actual size of tmpname should be 7 @@ -1492,7 +1492,7 @@ SUBROUTINE link_info_by_idx_check(group_id, linkname, n, & ! * Modifications: ! * ! *------------------------------------------------------------------------- -! +! SUBROUTINE test_lcpl(cleanup, fapl, total_error) @@ -1537,34 +1537,34 @@ SUBROUTINE link_info_by_idx_check(group_id, linkname, n, & ! Actually, intermediate group creation is tested elsewhere (tmisc). - ! * Here we only need to test the character encoding property + ! * Here we only need to test the character encoding property - ! Create file + ! Create file ! h5_fixname(FILENAME[0], fapl, filename, sizeof filename); CALL H5Fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, error, H5P_DEFAULT_F, fapl) CALL check("H5Fcreate_f", error, total_error) - ! Create and link a group with the default LCPL + ! Create and link a group with the default LCPL CALL H5Gcreate_f(file_id, "/group", group_id, error) CALL check("H5Gcreate_f", error, total_error) - ! Check that its character encoding is the default + ! Check that its character encoding is the default CALL H5Lget_info_f(file_id, "group", & cset, corder, f_corder_valid, link_type, token, val_size, & error, H5P_DEFAULT_F) ! File-wide default character encoding can not yet be set via the file -! * creation property list and is always ASCII. +! * creation property list and is always ASCII. !#define H5F_DEFAULT_CSET H5T_CSET_ASCII -- FROM H5Fprivate.h -- CALL verify("H5Lget_info_f",cset, H5T_CSET_ASCII_F,total_error) - ! Create and commit a datatype with the default LCPL + ! Create and commit a datatype with the default LCPL CALL h5tcopy_f(H5T_NATIVE_INTEGER, type_id, error) CALL check("h5tcopy_f",error,total_error) CALL h5tcommit_f(file_id, "/type", type_id, error) @@ -1573,19 +1573,19 @@ SUBROUTINE link_info_by_idx_check(group_id, linkname, n, & CALL check("h5tclose_f", error, total_error) - ! Check that its character encoding is the default + ! Check that its character encoding is the default CALL H5Lget_info_f(file_id, "type", & cset, corder, f_corder_valid, link_type, token, val_size, & error) CALL check("h5tclose_f", error, total_error) ! File-wide default character encoding can not yet be set via the file -! * creation property list and is always ASCII. +! * creation property list and is always ASCII. !#define H5F_DEFAULT_CSET H5T_CSET_ASCII -- FROM H5Fprivate.h -- CALL verify("H5Lget_info_f",cset, H5T_CSET_ASCII_F,total_error) - ! Create a dataspace + ! Create a dataspace CALL h5screate_simple_f(2, dims, space_id, error) CALL check("h5screate_simple_f",error,total_error) CALL h5pcreate_f(H5P_DATASET_CREATE_F, crp_list, error) @@ -1595,7 +1595,7 @@ SUBROUTINE link_info_by_idx_check(group_id, linkname, n, & CALL h5pcreate_f(H5P_DATASET_CREATE_F, crp_list, error) CALL h5pset_chunk_f(crp_list, 2, dims, error) - ! Create a dataset using the default LCPL + ! Create a dataset using the default LCPL CALL h5dcreate_f(file_id, "/dataset", H5T_NATIVE_INTEGER, space_id, dset_id, error, crp_list) CALL check("h5dcreate_f", error, total_error) @@ -1607,10 +1607,10 @@ SUBROUTINE link_info_by_idx_check(group_id, linkname, n, & CALL H5Dopen_f(file_id, "/dataset", dset_id, error) CALL check("h5dopen_f", error, total_error) - ! Extend the dataset + ! Extend the dataset CALL H5Dset_extent_f(dset_id, extend_dim, error) CALL check("H5Dset_extent_f", error, total_error) - ! Verify the dataspaces + ! Verify the dataspaces ! !Get dataset's dataspace handle. ! @@ -1629,37 +1629,37 @@ SUBROUTINE link_info_by_idx_check(group_id, linkname, n, & CALL verify("H5Sget_simple_extent_dims", tmp1, tmp2, total_error) ENDDO - ! close data set + ! close data set CALL h5dclose_f(dset_id, error) CALL check("h5dclose_f", error, total_error) - ! Check that its character encoding is the default + ! Check that its character encoding is the default CALL H5Lget_info_f(file_id, "dataset", & cset, corder, f_corder_valid, link_type, token, val_size, & error) CALL check("H5Lget_info_f", error, total_error) ! File-wide default character encoding can not yet be set via the file -! * creation property list and is always ASCII. +! * creation property list and is always ASCII. !#define H5F_DEFAULT_CSET H5T_CSET_ASCII -- FROM H5Fprivate.h -- CALL verify("h5tclose_f",cset, H5T_CSET_ASCII_F,total_error) - ! Create a link creation property list with the UTF-8 character encoding + ! Create a link creation property list with the UTF-8 character encoding CALL H5Pcreate_f(H5P_LINK_CREATE_F,lcpl_id,error) CALL check("h5Pcreate_f",error,total_error) CALL H5Pset_char_encoding_f(lcpl_id, H5T_CSET_UTF8_F, error) CALL check("H5Pset_char_encoding_f",error, total_error) - ! Create and link a group with the new LCPL + ! Create and link a group with the new LCPL CALL H5Gcreate_f(file_id, "/group2", group_id, error,lcpl_id=lcpl_id) CALL check("H5Gcreate_f", error, total_error) CALL H5Gclose_f(group_id, error) CALL check("H5Gclose_f", error, total_error) - ! Check that its character encoding is UTF-8 + ! Check that its character encoding is UTF-8 CALL H5Lget_info_f(file_id, "group2", & cset, corder, f_corder_valid, link_type, token, val_size, & error) @@ -1667,7 +1667,7 @@ SUBROUTINE link_info_by_idx_check(group_id, linkname, n, & CALL verify("H5Lget_info_f",cset, H5T_CSET_UTF8_F,total_error) - ! Create and commit a datatype with the new LCPL + ! Create and commit a datatype with the new LCPL CALL h5tcopy_f(H5T_NATIVE_INTEGER, type_id, error) CALL check("h5tcopy_f",error,total_error) @@ -1677,14 +1677,14 @@ SUBROUTINE link_info_by_idx_check(group_id, linkname, n, & CALL check("h5tclose_f", error, total_error) - ! Check that its character encoding is UTF-8 + ! Check that its character encoding is UTF-8 CALL H5Lget_info_f(file_id, "type2", & cset, corder, f_corder_valid, link_type, token, val_size, & error) CALL check("H5Lget_info_f", error, total_error) CALL verify("H5Lget_info_f",cset, H5T_CSET_UTF8_F,total_error) - ! Create a dataset using the new LCPL + ! Create a dataset using the new LCPL CALL h5dcreate_f(file_id, "/dataset2", H5T_NATIVE_INTEGER, space_id, dset_id, error,lcpl_id=lcpl_id) CALL check("h5dcreate_f", error, total_error) @@ -1695,14 +1695,14 @@ SUBROUTINE link_info_by_idx_check(group_id, linkname, n, & CALL check("H5Pget_char_encoding_f", error, total_error) CALL verify("H5Pget_char_encoding_f", encoding, H5T_CSET_UTF8_F, total_error) - ! Check that its character encoding is UTF-8 + ! Check that its character encoding is UTF-8 CALL H5Lget_info_f(file_id, "dataset2", & cset, corder, f_corder_valid, link_type, token, val_size, & error) CALL check("H5Lget_info_f", error, total_error) CALL verify("H5Lget_info_f2",cset, H5T_CSET_UTF8_F,total_error) - ! Create a new link to the dataset with a different character encoding. + ! Create a new link to the dataset with a different character encoding. CALL H5Pclose_f(lcpl_id, error) CALL check("H5Pclose_f", error, total_error) @@ -1717,14 +1717,14 @@ SUBROUTINE link_info_by_idx_check(group_id, linkname, n, & CALL check("H5Lexists",error, total_error) CALL verify("H5Lexists", Lexists,.TRUE.,total_error) - ! Check that its character encoding is ASCII + ! Check that its character encoding is ASCII CALL H5Lget_info_f(file_id, "/dataset2_link", & cset, corder, f_corder_valid, link_type, token, val_size, & error) CALL check("H5Lget_info_f", error, total_error) CALL verify("H5Lget_info_f",cset, H5T_CSET_ASCII_F,total_error) - ! Check that the first link's encoding hasn't changed + ! Check that the first link's encoding hasn't changed CALL H5Lget_info_f(file_id, "/dataset2", & cset, corder, f_corder_valid, link_type, token, val_size, & @@ -1733,8 +1733,8 @@ SUBROUTINE link_info_by_idx_check(group_id, linkname, n, & CALL verify("H5Lget_info_f3",cset, H5T_CSET_UTF8_F,total_error) - ! Make sure that LCPLs work properly for other API calls: - ! H5Lcreate_soft + ! Make sure that LCPLs work properly for other API calls: + ! H5Lcreate_soft CALL H5Pset_char_encoding_f(lcpl_id, H5T_CSET_UTF8_F, error) CALL check("H5Pset_char_encoding_f",error, total_error) @@ -1748,7 +1748,7 @@ SUBROUTINE link_info_by_idx_check(group_id, linkname, n, & CALL verify("H5Lget_info_f",cset, H5T_CSET_UTF8_F,total_error) - ! H5Lmove + ! H5Lmove CALL H5Pset_char_encoding_f(lcpl_id, H5T_CSET_ASCII_F, error) CALL check("H5Pset_char_encoding_f",error, total_error) @@ -1762,7 +1762,7 @@ SUBROUTINE link_info_by_idx_check(group_id, linkname, n, & CALL verify("H5Lget_info_f",cset, H5T_CSET_ASCII_F,total_error) - ! H5Lcopy + ! H5Lcopy CALL H5Pset_char_encoding_f(lcpl_id, H5T_CSET_UTF8_F, error) CALL check("H5Pset_char_encoding_f",error, total_error) @@ -1776,7 +1776,7 @@ SUBROUTINE link_info_by_idx_check(group_id, linkname, n, & CALL verify("H5Lget_info_f",cset, H5T_CSET_UTF8_F,total_error) - ! H5Lcreate_external + ! H5Lcreate_external CALL H5Lcreate_external_f("filename", "path", file_id, "extlink", error, lcpl_id) CALL check("H5Lcreate_external_f", error, total_error) @@ -1788,7 +1788,7 @@ SUBROUTINE link_info_by_idx_check(group_id, linkname, n, & CALL verify("H5Lget_info_f",cset, H5T_CSET_UTF8_F,total_error) - ! Close open IDs + ! Close open IDs CALL H5Pclose_f(lcpl_id, error) CALL check("H5Pclose_f", error, total_error) @@ -1817,22 +1817,22 @@ SUBROUTINE objcopy(fapl, total_error) flag = H5O_COPY_SHALLOW_HIERARCHY_F -! Copy the file access property list +! Copy the file access property list CALL H5Pcopy_f(fapl, fapl2, error) CALL check("H5Pcopy_f", error, total_error) -! Set the "use the latest version of the format" bounds for creating objects in the file +! Set the "use the latest version of the format" bounds for creating objects in the file CALL H5Pset_libver_bounds_f(fapl2, H5F_LIBVER_LATEST_F, H5F_LIBVER_LATEST_F, error) - ! create property to pass copy options + ! create property to pass copy options CALL h5pcreate_f(H5P_OBJECT_COPY_F, pid, error) CALL check("h5pcreate_f",error, total_error) - ! set options for object copy + ! set options for object copy CALL H5Pset_copy_object_f(pid, flag, error) CALL check("H5Pset_copy_object_f",error, total_error) - ! Verify object copy flags + ! Verify object copy flags CALL H5Pget_copy_object_f(pid, cpy_flags, error) CALL check("H5Pget_copy_object_f",error, total_error) CALL verify("H5Pget_copy_object_f", cpy_flags, flag, total_error) @@ -1862,7 +1862,7 @@ END SUBROUTINE objcopy ! * Modifications: ! * ! *------------------------------------------------------------------------- -! +! SUBROUTINE lapl_nlinks( fapl, total_error) @@ -1872,30 +1872,30 @@ SUBROUTINE lapl_nlinks( fapl, total_error) INTEGER :: error - INTEGER(HID_T) :: fid = (-1) ! File ID - INTEGER(HID_T) :: gid = (-1), gid2 = (-1) ! Group IDs - INTEGER(HID_T) :: plist = (-1) ! lapl ID - INTEGER(HID_T) :: tid = (-1) ! Other IDs - INTEGER(HID_T) :: gapl = (-1), dapl = (-1), tapl = (-1) ! Other property lists + INTEGER(HID_T) :: fid = (-1) ! File ID + INTEGER(HID_T) :: gid = (-1), gid2 = (-1) ! Group IDs + INTEGER(HID_T) :: plist = (-1) ! lapl ID + INTEGER(HID_T) :: tid = (-1) ! Other IDs + INTEGER(HID_T) :: gapl = (-1), dapl = (-1), tapl = (-1) ! Other property lists - CHARACTER(LEN=7) :: objname ! Object name - INTEGER(size_t) :: name_len ! Length of object name + CHARACTER(LEN=7) :: objname ! Object name + INTEGER(size_t) :: name_len ! Length of object name CHARACTER(LEN=12) :: filename = 'TestLinks.h5' - INTEGER(size_t) :: nlinks ! nlinks for H5Pset_nlinks + INTEGER(size_t) :: nlinks ! nlinks for H5Pset_nlinks INTEGER(size_t) :: buf_size = 7 ! WRITE(*,*) "adjusting nlinks with LAPL (w/new group format)" - ! Create file + ! Create file CALL h5fcreate_f(FileName, H5F_ACC_TRUNC_F, fid, error, access_prp=fapl) CALL check(" lapl_nlinks.h5fcreate_f",error,total_error) - ! Create group with short name in file (used as target for links) + ! Create group with short name in file (used as target for links) CALL H5Gcreate_f(fid, "final", gid, error) CALL check(" lapl_nlinks.H5Gcreate_f", error, total_error) - ! Create chain of soft links to existing object (limited) + ! Create chain of soft links to existing object (limited) CALL H5Lcreate_soft_f("final", fid, "soft1", error) CALL H5Lcreate_soft_f("soft1", fid, "soft2", error) CALL H5Lcreate_soft_f("soft2", fid, "soft3", error) @@ -1914,26 +1914,26 @@ SUBROUTINE lapl_nlinks( fapl, total_error) CALL H5Lcreate_soft_f("soft15", fid, "soft16", error) CALL H5Lcreate_soft_f("soft16", fid, "soft17", error) - ! Close objects + ! Close objects CALL H5Gclose_f(gid, error) CALL check("h5gclose_f",error,total_error) CALL h5fclose_f(fid, error) CALL check("h5fclose_f",error,total_error) - ! Open file + ! Open file CALL h5fopen_f(FileName, H5F_ACC_RDWR_F, fid, error, fapl) CALL check("h5open_f",error,total_error) - ! Create LAPL with higher-than-usual nlinks value - ! Create a non-default lapl with udata set to point to the first group + ! Create LAPL with higher-than-usual nlinks value + ! Create a non-default lapl with udata set to point to the first group CALL H5Pcreate_f(H5P_LINK_ACCESS_F,plist,error) CALL check("h5Pcreate_f",error,total_error) nlinks = 20 CALL H5Pset_nlinks_f(plist, nlinks, error) CALL check("H5Pset_nlinks_f",error,total_error) - ! Ensure that nlinks was set successfully + ! Ensure that nlinks was set successfully nlinks = 0 CALL H5Pget_nlinks_f(plist, nlinks, error) CALL check("H5Pset_nlinks_f",error,total_error) @@ -1941,71 +1941,71 @@ SUBROUTINE lapl_nlinks( fapl, total_error) ! Open object through what is normally too many soft links using - ! * new property list + ! * new property list CALL H5Oopen_f(fid,"soft17",gid,error,plist) CALL check("H5Oopen_f",error,total_error) - ! Check name + ! Check name CALL h5iget_name_f(gid, objname, buf_size, name_len, error) CALL check("h5iget_name_f",error,total_error) CALL verify("h5iget_name_f", TRIM(objname),"/soft17", total_error) - ! Create group using soft link + ! Create group using soft link CALL H5Gcreate_f(gid, "new_soft", gid2, error) CALL check("H5Gcreate_f", error, total_error) - ! Close groups + ! Close groups CALL H5Gclose_f(gid2, error) CALL check("H5Gclose_f", error, total_error) CALL H5Gclose_f(gid, error) CALL check("H5Gclose_f", error, total_error) - ! Set nlinks to a smaller number + ! Set nlinks to a smaller number nlinks = 4 CALL H5Pset_nlinks_f(plist, nlinks, error) CALL check("H5Pset_nlinks_f", error, total_error) - ! Ensure that nlinks was set successfully + ! Ensure that nlinks was set successfully nlinks = 0 CALL H5Pget_nlinks_f(plist, nlinks, error) CALL check("H5Pget_nlinks_f",error,total_error) CALL verify("H5Pget_nlinks_f", INT(nlinks), 4, total_error) - ! Try opening through what is now too many soft links + ! Try opening through what is now too many soft links CALL H5Oopen_f(fid,"soft5",gid,error,plist) CALL verify("H5Oopen_f", error, -1, total_error) ! should fail - ! Open object through lesser soft link + ! Open object through lesser soft link CALL H5Oopen_f(fid,"soft4",gid,error,plist) CALL check("H5Oopen_",error,total_error) - ! Check name + ! Check name CALL h5iget_name_f(gid, objname, buf_size, name_len, error) CALL check("h5iget_name_f",error,total_error) CALL verify("h5iget_name_f", TRIM(objname),"/soft4", total_error) - ! Test other functions that should use a LAPL + ! Test other functions that should use a LAPL nlinks = 20 CALL H5Pset_nlinks_f(plist, nlinks, error) CALL check("H5Pset_nlinks_f", error, total_error) ! Try copying and moving when both src and dst contain many soft links ! * using a non-default LAPL - ! + ! CALL H5Lcopy_f(fid, "soft17", fid, "soft17/newer_soft", error, H5P_DEFAULT_F, plist) CALL check("H5Lcopy_f",error,total_error) CALL H5Lmove_f(fid, "soft17/newer_soft", fid, "soft17/newest_soft", error, lapl_id=plist) CALL check("H5Lmove_f",error, total_error) - ! H5Olink + ! H5Olink CALL H5Olink_f(gid, fid, "soft17/link_to_group", error, H5P_DEFAULT_F, plist) CALL check("H5Olink_f", error, total_error) - ! H5Lcreate_hard and H5Lcreate_soft + ! H5Lcreate_hard and H5Lcreate_soft CALL H5Lcreate_hard_f(fid, "soft17", fid, "soft17/link2_to_group", error, H5P_DEFAULT_F, plist) CALL check("H5Lcreate_hard_f", error, total_error) @@ -2013,27 +2013,27 @@ SUBROUTINE lapl_nlinks( fapl, total_error) CALL H5Lcreate_soft_f("/soft4", fid, "soft17/soft_link",error, H5P_DEFAULT_F, plist) CALL check("H5Lcreate_soft_f", error, total_error) - ! H5Ldelete + ! H5Ldelete CALL h5ldelete_f(fid, "soft17/soft_link", error, plist) CALL check("H5Ldelete_f", error, total_error) -!!$ H5Lget_val and H5Lget_info +!!$ H5Lget_val and H5Lget_info !!$ if(H5Lget_val(fid, "soft17", NULL, (size_t)0, plist) < 0) TEST_ERROR !!$ if(H5Lget_info(fid, "soft17", NULL, plist) < 0) TEST_ERROR !!$ - ! H5Lcreate_external and H5Lcreate_ud + ! H5Lcreate_external and H5Lcreate_ud CALL H5Lcreate_external_f("filename", "path", fid, "soft17/extlink", error, H5P_DEFAULT_F, plist) CALL check("H5Lcreate_external_f", error, total_error) !!$ if(H5Lregister(UD_rereg_class) < 0) TEST_ERROR !!$ if(H5Lcreate_ud(fid, "soft17/udlink", UD_HARD_TYPE, NULL, (size_t)0, H5P_DEFAULT, plist) < 0) TEST_ERROR !!$ - ! Close plist + ! Close plist CALL h5pclose_f(plist, error) CALL check("h5pclose_f", error, total_error) - ! Create a datatype and dataset as targets inside the group + ! Create a datatype and dataset as targets inside the group CALL h5tcopy_f(H5T_NATIVE_INTEGER, tid, error) CALL check("h5tcopy_f",error,total_error) CALL h5tcommit_f(gid, "datatype", tid, error) @@ -2048,12 +2048,12 @@ SUBROUTINE lapl_nlinks( fapl, total_error) !!$ if((did = H5Dcreate2(gid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR !!$ if(H5Dclose(did) < 0) TEST_ERROR !!$ - ! Close group + ! Close group CALL h5gclose_f(gid, error) CALL check("h5gclose_f",error,total_error) !!$ -!!$ Try to open the objects using too many symlinks with default *APLs +!!$ Try to open the objects using too many symlinks with default *APLs !!$ H5E_BEGIN_TRY { !!$ if((gid = H5Gopen2(fid, "soft17", H5P_DEFAULT)) >= 0) !!$ FAIL_PUTS_ERROR(" Should have failed for too many nested links.") @@ -2063,7 +2063,7 @@ SUBROUTINE lapl_nlinks( fapl, total_error) !!$ FAIL_PUTS_ERROR(" Should have failed for too many nested links.") !!$ } H5E_END_TRY !!$ - ! Create property lists with nlinks set + ! Create property lists with nlinks set CALL H5Pcreate_f(H5P_GROUP_ACCESS_F,gapl,error) CALL check("h5Pcreate_f",error,total_error) @@ -2083,7 +2083,7 @@ SUBROUTINE lapl_nlinks( fapl, total_error) ! We should now be able to use these property lists to open each kind ! * of object. - ! + ! CALL H5Gopen_f(fid, "soft17", gid, error, gapl) CALL check("H5Gopen_f",error,total_error) @@ -2093,7 +2093,7 @@ SUBROUTINE lapl_nlinks( fapl, total_error) !!$ if((did = H5Dopen2(fid, "soft17/dataset", dapl)) < 0) TEST_ERROR - ! Close objects + ! Close objects CALL h5gclose_f(gid, error) CALL check("h5gclose_f",error,total_error) @@ -2102,7 +2102,7 @@ SUBROUTINE lapl_nlinks( fapl, total_error) !!$ if(H5Dclose(did) < 0) TEST_ERROR !!$ - ! Close plists + ! Close plists CALL h5pclose_f(gapl, error) CALL check("h5pclose_f", error, total_error) @@ -2111,11 +2111,11 @@ SUBROUTINE lapl_nlinks( fapl, total_error) !!$ if(H5Pclose(dapl) < 0) TEST_ERROR !!$ -!!$ Unregister UD hard link class +!!$ Unregister UD hard link class !!$ if(H5Lunregister(UD_HARD_TYPE) < 0) TEST_ERROR !!$ - ! Close file + ! Close file CALL H5Fclose_f(fid, error) CALL check("H5Fclose_f", error, total_error) diff --git a/fortran/test/tH5I.F90 b/fortran/test/tH5I.F90 index 5ce37fd..1934acf 100644 --- a/fortran/test/tH5I.F90 +++ b/fortran/test/tH5I.F90 @@ -25,8 +25,8 @@ ! !***** MODULE TH5I - - USE HDF5 ! This module contains all necessary modules + + USE HDF5 ! This module contains all necessary modules USE TH5_MISC USE TH5_MISC_GEN @@ -87,21 +87,21 @@ CONTAINS ! check that the ID is not valid dtype = -1 CALL H5Iis_valid_f(dtype, tri_ret, error) - CALL check("H5Iis_valid_f", error, total_error) + CALL check("H5Iis_valid_f", error, total_error) CALL verify("H5Iis_valid_f", tri_ret, .FALSE., total_error) - + ! Create a datatype id CALL H5Tcopy_f(H5T_NATIVE_INTEGER,dtype,error) - CALL check("H5Tcopy_f", error, total_error) - + CALL check("H5Tcopy_f", error, total_error) + ! Check that the ID is valid CALL H5Iis_valid_f(dtype, tri_ret, error) - CALL check("H5Iis_valid_f", error, total_error) + CALL check("H5Iis_valid_f", error, total_error) CALL verify("H5Tequal_f", tri_ret, .TRUE., total_error) - + CALL H5Tclose_f(dtype, error) - CALL check("H5Tclose_f", error, total_error) - + CALL check("H5Tclose_f", error, total_error) + ! ! Create a new file using default properties. ! diff --git a/fortran/test/tH5L_F03.F90 b/fortran/test/tH5L_F03.F90 index bdb5c55..a8a8c65 100644 --- a/fortran/test/tH5L_F03.F90 +++ b/fortran/test/tH5L_F03.F90 @@ -5,7 +5,7 @@ ! ! FUNCTION ! Test FORTRAN HDF5 H5L APIs which are dependent on FORTRAN 2003 -! features. +! features. ! ! COPYRIGHT ! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @@ -30,8 +30,8 @@ !***** MODULE liter_cb_mod - USE HDF5 - USE TH5_MISC + USE HDF5 + USE TH5_MISC USE TH5_MISC_GEN USE, INTRINSIC :: ISO_C_BINDING IMPLICIT NONE @@ -43,11 +43,11 @@ MODULE liter_cb_mod INTEGER RET_CHANGE2 END TYPE iter_enum - ! Custom group iteration callback data + ! Custom group iteration callback data TYPE, bind(c) :: iter_info - CHARACTER(KIND=C_CHAR), DIMENSION(1:10) :: name ! The name of the object - INTEGER(c_int) :: TYPE ! The TYPE of the object - INTEGER(c_int) :: command ! The TYPE of RETURN value + CHARACTER(KIND=C_CHAR), DIMENSION(1:10) :: name ! The name of the object + INTEGER(c_int) :: TYPE ! The TYPE of the object + INTEGER(c_int) :: command ! The TYPE of RETURN value END TYPE iter_info CONTAINS @@ -73,7 +73,7 @@ CONTAINS INTEGER, SAVE :: count INTEGER, SAVE :: count2 -!!$ +!!$ !!$ iter_info *info = (iter_info *)op_data; !!$ static int count = 0; !!$ static int count2 = 0; @@ -126,17 +126,17 @@ SUBROUTINE test_iter_group(total_error) INTEGER, INTENT(INOUT) :: total_error INTEGER(HID_T) :: fapl - INTEGER(HID_T) :: file ! File ID - INTEGER(hid_t) :: dataset ! Dataset ID - INTEGER(hid_t) :: datatype ! Common datatype ID - INTEGER(hid_t) :: filespace ! Common dataspace ID - INTEGER(hid_t) :: grp ! Group ID - INTEGER i,j ! counting variable - INTEGER(hsize_t) idx ! Index in the group + INTEGER(HID_T) :: file ! File ID + INTEGER(hid_t) :: dataset ! Dataset ID + INTEGER(hid_t) :: datatype ! Common datatype ID + INTEGER(hid_t) :: filespace ! Common dataspace ID + INTEGER(hid_t) :: grp ! Group ID + INTEGER i,j ! counting variable + INTEGER(hsize_t) idx ! Index in the group CHARACTER(LEN=11) :: DATAFILE = "titerate.h5" INTEGER, PARAMETER :: ndatasets = 50 - CHARACTER(LEN=10) :: name ! temporary name buffer - CHARACTER(LEN=10), DIMENSION(1:ndatasets+2) :: lnames ! Names of the links created + CHARACTER(LEN=10) :: name ! temporary name buffer + CHARACTER(LEN=10), DIMENSION(1:ndatasets+2) :: lnames ! Names of the links created TYPE(iter_info), TARGET :: info @@ -147,15 +147,15 @@ SUBROUTINE test_iter_group(total_error) CHARACTER(LEN=2) :: ichr2 CHARACTER(LEN=10) :: ichr10 - ! Get the default FAPL + ! Get the default FAPL CALL H5Pcreate_f(H5P_FILE_ACCESS_F, fapl, error) CALL check("h5pcreate_f", error, total_error) - ! Set the "use the latest version of the format" bounds for creating objects in the file + ! Set the "use the latest version of the format" bounds for creating objects in the file CALL H5Pset_libver_bounds_f(fapl, H5F_LIBVER_LATEST_F, H5F_LIBVER_LATEST_F, error) CALL check("H5Pset_libver_bounds_f",error, total_error) - ! Create the test file with the datasets + ! Create the test file with the datasets CALL h5fcreate_f(DATAFILE, H5F_ACC_TRUNC_F, file, error, H5P_DEFAULT_F, fapl) CALL check("h5fcreate_f", error, total_error) @@ -190,12 +190,12 @@ SUBROUTINE test_iter_group(total_error) ENDDO - ! Create a group and named datatype under root group for testing + ! Create a group and named datatype under root group for testing CALL H5Gcreate_f(file, "grp0000000", grp, error) CALL check("H5Gcreate_f", error, total_error) - lnames(ndatasets+2) = "grp0000000" + lnames(ndatasets+2) = "grp0000000" !!$ !!$ lnames[NDATASETS] = HDstrdup("grp"); @@ -205,9 +205,9 @@ SUBROUTINE test_iter_group(total_error) CALL H5Tcommit_f(file, "dtype00000", datatype, error) CALL check("H5Tcommit_f", error, total_error) - lnames(ndatasets+1) = "dtype00000" + lnames(ndatasets+1) = "dtype00000" - ! Close everything up + ! Close everything up CALL H5Tclose_f(datatype, error) CALL check("H5Tclose_f", error, total_error) @@ -221,11 +221,11 @@ SUBROUTINE test_iter_group(total_error) CALL H5Fclose_f(file, error) CALL check("H5Fclose_f", error, total_error) - ! Iterate through the datasets in the root group in various ways + ! Iterate through the datasets in the root group in various ways CALL H5Fopen_f(DATAFILE, H5F_ACC_RDONLY_F, file, error, access_prp=fapl) CALL check("h5fopen_f", error, total_error) - ! Test all objects in group, when callback always returns 0 + ! Test all objects in group, when callback always returns 0 info%command = 0 idx = 0 CALL H5Literate_f(file, H5_INDEX_NAME_F, H5_ITER_INC_F, idx, f1, f2, ret_value, error) @@ -234,28 +234,28 @@ SUBROUTINE test_iter_group(total_error) CALL verify("H5Literate_f", error, -1, total_error) ENDIF - ! Test all objects in group, when callback always returns 1 - ! This also tests the "restarting" ability, because the index changes + ! Test all objects in group, when callback always returns 1 + ! This also tests the "restarting" ability, because the index changes info%command = 2 idx = 0 i = 0 f1 = C_FUNLOC(liter_cb) f2 = C_LOC(info) - DO + DO CALL H5Literate_f(file, H5_INDEX_NAME_F, H5_ITER_INC_F, idx, f1, f2, ret_value, error) IF(error.LT.0) EXIT - ! Verify return value from iterator gets propagated correctly + ! Verify return value from iterator gets propagated correctly CALL verify("H5Literate", ret_value, 2, total_error) - ! Increment the number of times "2" is returned + ! Increment the number of times "2" is returned i = i + 1 - ! Verify that the index is the correct value + ! Verify that the index is the correct value CALL verify("H5Literate", INT(idx), INT(i), total_error) IF(idx .GT.ndatasets+2)THEN PRINT*,"ERROR: Group iteration function walked too far!" ENDIF - ! Verify the correct name is retrieved + ! Verify the correct name is retrieved DO j = 1, 10 ichr10(j:j) = info%name(j)(1:1) ENDDO @@ -270,8 +270,8 @@ SUBROUTINE test_iter_group(total_error) PRINT*,"ERROR: Group iteration function didn't perform multiple iterations correctly" ENDIF - ! Test all objects in group, when callback changes return value - ! This also tests the "restarting" ability, because the index changes + ! Test all objects in group, when callback changes return value + ! This also tests the "restarting" ability, because the index changes info%command = 3 idx = 0 @@ -285,10 +285,10 @@ SUBROUTINE test_iter_group(total_error) IF(error.LT.0) EXIT CALL verify("H5Literate_f", ret_value, 1, total_error) - ! Increment the number of times "1" is returned + ! Increment the number of times "1" is returned i = i + 1 - ! Verify that the index is the correct value + ! Verify that the index is the correct value CALL verify("H5Literate_f", INT(idx), INT(i+10), total_error) IF(idx .GT.ndatasets+2)THEN @@ -298,7 +298,7 @@ SUBROUTINE test_iter_group(total_error) DO j = 1, 10 ichr10(j:j) = info%name(j)(1:1) ENDDO - ! Verify that the correct name is retrieved + ! Verify that the correct name is retrieved CALL verify("H5Literate_f", ichr10, lnames(INT(idx)), total_error) IF(i.EQ.42)EXIT ! prints out error message otherwise (for gcc/gfortran/g95) not intel (why) -FIX- scot ENDDO diff --git a/fortran/test/tH5MISC_1_8.F90 b/fortran/test/tH5MISC_1_8.F90 index b8c777c..bad77d0 100644 --- a/fortran/test/tH5MISC_1_8.F90 +++ b/fortran/test/tH5MISC_1_8.F90 @@ -95,18 +95,18 @@ SUBROUTINE test_genprop_basic_class(total_error) IMPLICIT NONE INTEGER, INTENT(INOUT) :: total_error - INTEGER(HID_T) :: cid1 ! Generic Property class ID - INTEGER(HID_T) :: cid2 ! Generic Property class ID + INTEGER(HID_T) :: cid1 ! Generic Property class ID + INTEGER(HID_T) :: cid2 ! Generic Property class ID CHARACTER(LEN=7) :: CLASS1_NAME = "Class 1" - CHARACTER(LEN=7) :: name ! Name of class - CHARACTER(LEN=10) :: name_big ! Name of class bigger buffer + CHARACTER(LEN=7) :: name ! Name of class + CHARACTER(LEN=10) :: name_big ! Name of class bigger buffer CHARACTER(LEN=4) :: name_small ! Name of class smaller buffer INTEGER :: error INTEGER :: size LOGICAL :: flag - ! Output message about test being performed + ! Output message about test being performed !WRITE(*,*) "Testing Basic Generic Property List Class Creation Functionality" @@ -116,11 +116,11 @@ SUBROUTINE test_genprop_basic_class(total_error) CALL H5Pget_class_name_f(cid1, name, size, error) CALL verify("H5Pget_class_name", error, -1, error) - ! Create a new generic class, derived from the root of the class hierarchy + ! Create a new generic class, derived from the root of the class hierarchy CALL H5Pcreate_class_f(H5P_ROOT_F, CLASS1_NAME, cid1, error) CALL check("H5Pcreate_class", error, total_error) - ! Check class name + ! Check class name CALL H5Pget_class_name_f(cid1, name, size, error) CALL check("H5Pget_class_name", error, total_error) CALL verify("H5Pget_class_name", size,7,error) @@ -150,27 +150,27 @@ SUBROUTINE test_genprop_basic_class(total_error) total_error = total_error + 1 ENDIF - ! Check class parent + ! Check class parent CALL H5Pget_class_parent_f(cid1, cid2, error) CALL check("H5Pget_class_parent_f", error, total_error) - ! Verify class parent correct + ! Verify class parent correct CALL H5Pequal_f(cid2, H5P_ROOT_F, flag, error) CALL check("H5Pequal_f", error, total_error) CALL verify("H5Pequal_f", flag, .TRUE., total_error) - ! Make certain false postives aren't being returned + ! Make certain false postives aren't being returned CALL H5Pequal_f(cid2, H5P_FILE_CREATE_F, flag, error) CALL check("H5Pequal_f", error, total_error) CALL verify("H5Pequal_f", flag, .FALSE., total_error) - ! Close parent class + ! Close parent class CALL H5Pclose_class_f(cid2, error) CALL check("H5Pclose_class_f", error, total_error) - ! Close class + ! Close class CALL H5Pclose_class_f(cid1, error) CALL check("H5Pclose_class_f", error, total_error) @@ -187,17 +187,17 @@ SUBROUTINE test_h5s_encode(total_error) IMPLICIT NONE INTEGER, INTENT(INOUT) :: total_error - INTEGER(hid_t) :: sid1, sid3! Dataspace ID + INTEGER(hid_t) :: sid1, sid3! Dataspace ID INTEGER(hid_t) :: decoded_sid1, decoded_sid3 INTEGER(hid_t) :: fapl ! File access property - INTEGER :: rank ! LOGICAL rank of dataspace + INTEGER :: rank ! LOGICAL rank of dataspace INTEGER(size_t) :: new_size = 0, old_size = 0, orig_size=0, scalar_size=0 ! Make sure the size is large CHARACTER(LEN=288) :: sbuf CHARACTER(LEN=288) :: scalar_buf - INTEGER(hsize_t) :: n ! Number of dataspace elements + INTEGER(hsize_t) :: n ! Number of dataspace elements INTEGER(hsize_t), DIMENSION(1:3) :: start = (/0, 0, 0/) INTEGER(hsize_t), DIMENSION(1:3) :: stride = (/2, 5, 3/) @@ -217,7 +217,7 @@ SUBROUTINE test_h5s_encode(total_error) !------------------------------------------------------------------------- ! * Test encoding and decoding of simple dataspace and hyperslab selection. ! *------------------------------------------------------------------------- - ! + ! CALL H5Screate_simple_f(SPACE1_RANK, dims1, sid1, error) CALL check("H5Screate_simple", error, total_error) @@ -227,13 +227,13 @@ SUBROUTINE test_h5s_encode(total_error) CALL check("h5sselect_hyperslab_f", error, total_error) - ! Encode simple data space in a buffer + ! Encode simple data space in a buffer ! Find the buffer size without fapl CALL H5Sencode_f(sid1, sbuf, orig_size, error) CALL check("H5Sencode_f", error, total_error) CALL verify("H5Sencode_f", INT(orig_size), 279, total_error) - + ! Create file access property list CALL h5pcreate_f(H5P_FILE_ACCESS_F, fapl, error) CALL check("h5pcreate_f", error, total_error) @@ -252,7 +252,7 @@ SUBROUTINE test_h5s_encode(total_error) CALL check("H5Sencode_f", error, total_error) CALL verify("H5Sencode_f", INT(new_size), 101, total_error) - ! Try decoding bogus buffer + ! Try decoding bogus buffer CALL H5Sdecode_f(sbuf, decoded_sid1, error) CALL verify("H5Sdecode", error, -1, total_error) @@ -260,12 +260,12 @@ SUBROUTINE test_h5s_encode(total_error) CALL H5Sencode_f(sid1, sbuf, new_size, error, fapl) CALL check("H5Sencode_f", error, total_error) - ! Decode from the dataspace buffer and return an object handle + ! Decode from the dataspace buffer and return an object handle CALL H5Sdecode_f(sbuf, decoded_sid1, error) CALL check("H5Sdecode", error, total_error) - ! Verify the decoded dataspace + ! Verify the decoded dataspace CALL h5sget_simple_extent_npoints_f(decoded_sid1, n, error) CALL check("h5sget_simple_extent_npoints_f", error, total_error) CALL verify("h5sget_simple_extent_npoints_f", INT(n), INT(SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3), & @@ -283,13 +283,13 @@ SUBROUTINE test_h5s_encode(total_error) ! ------------------------------------------------------------------------- ! * Test encoding and decoding of scalar dataspace. ! *------------------------------------------------------------------------- - ! - ! Create scalar dataspace + ! + ! Create scalar dataspace CALL H5Screate_f(H5S_SCALAR_F, sid3, error) CALL check("H5Screate_f",error, total_error) - ! Encode scalar data space in a buffer + ! Encode scalar data space in a buffer ! First find the buffer size CALL H5Sencode_f(sid3, scalar_buf, scalar_size, error) @@ -301,19 +301,19 @@ SUBROUTINE test_h5s_encode(total_error) CALL check("H5Sencode_f", error, total_error) - ! Decode from the dataspace buffer and return an object handle + ! Decode from the dataspace buffer and return an object handle CALL H5Sdecode_f(scalar_buf, decoded_sid3, error) CALL check("H5Sdecode_f", error, total_error) - ! Verify extent type + ! Verify extent type CALL H5Sget_simple_extent_type_f(decoded_sid3, space_type, error) CALL check("H5Sget_simple_extent_type_f", error, total_error) CALL verify("H5Sget_simple_extent_type_f", space_type, H5S_SCALAR_F, total_error) - ! Verify decoded dataspace + ! Verify decoded dataspace CALL h5sget_simple_extent_npoints_f(decoded_sid3, n, error) CALL check("h5sget_simple_extent_npoints_f", error, total_error) CALL verify("h5sget_simple_extent_npoints_f", INT(n), 1, total_error) @@ -359,7 +359,7 @@ SUBROUTINE test_scaleoffset(cleanup, total_error ) INTEGER(hsize_t), DIMENSION(1:2) :: chunk_dim = (/2, 5/) INTEGER, DIMENSION(1:2,1:5) :: orig_data INTEGER, DIMENSION(1:2,1:5) :: new_data - INTEGER(hsize_t), DIMENSION(1:2) :: start ! Start of hyperslab + INTEGER(hsize_t), DIMENSION(1:2) :: start ! Start of hyperslab INTEGER(hsize_t), DIMENSION(1:2) :: stride ! Stride of hyperslab INTEGER(hsize_t), DIMENSION(1:2) :: count ! BLOCK count INTEGER(hsize_t), DIMENSION(1:2) :: BLOCK ! BLOCK sizes @@ -390,11 +390,11 @@ SUBROUTINE test_scaleoffset(cleanup, total_error ) CALL H5Screate_simple_f(2, dims, space, error) CALL CHECK(" H5Screate_simple_f", error, total_error) - ! Create the dataset property list + ! Create the dataset property list CALL H5Pcreate_f(H5P_DATASET_CREATE_F, dc, error) CALL CHECK(" H5Pcreate_f", error, total_error) - ! Set fill value + ! Set fill value fillval = 10000 CALL H5Pset_fill_value_f(dc, H5T_NATIVE_INTEGER, fillval, error) CALL CHECK(" H5Pset_fill_value_f", error, total_error) @@ -402,10 +402,10 @@ SUBROUTINE test_scaleoffset(cleanup, total_error ) ! Set up to use scaleoffset filter, let library calculate minbits CALL H5Pset_chunk_f(dc, 2, chunk_dim, error) CALL CHECK(" H5Pset_chunk_f", error, total_error) - + CALL H5Pset_scaleoffset_f(dc, H5Z_SO_INT_F, H5Z_SO_INT_MINBITS_DEFAULT_F, error) CALL CHECK(" H5Pset_scaleoffset_f", error, total_error) - + ! Create the dataset CALL H5Dcreate_f(file, "scaleoffset_int", datatype, & space, dataset, error, dc) @@ -417,7 +417,7 @@ SUBROUTINE test_scaleoffset(cleanup, total_error ) ! Select hyperslab for data to write, using 1x5 blocks, ! (1,1) stride and (1,1) count starting at the position (0,0) - + start(1:2) = (/0,0/) stride(1:2) = (/1,1/) COUNT(1:2) = (/1,1/) @@ -441,21 +441,21 @@ SUBROUTINE test_scaleoffset(cleanup, total_error ) ! STEP 1: Test scaleoffset by setting up a chunked dataset and writing ! to it. !---------------------------------------------------------------------- - - ! Only data in the hyperslab will be written, other value should be fill value + + ! Only data in the hyperslab will be written, other value should be fill value CALL H5Dwrite_f(dataset, H5T_NATIVE_INTEGER, orig_data, dims, error, mspace, mspace, H5P_DEFAULT_F) CALL CHECK(" H5Dwrite_f", error, total_error) !---------------------------------------------------------------------- ! STEP 2: Try to read the data we just wrote. !---------------------------------------------------------------------- - + ! Read the dataset back - + CALL H5Dread_f(dataset, H5T_NATIVE_INTEGER, new_data, dims, error, mspace, mspace, H5P_DEFAULT_F) CALL CHECK(" H5Dread_f", error, total_error) - ! Check that the values read are the same as the values written + ! Check that the values read are the same as the values written DO j = 1, INT(dims(2)) IF(new_data(1,j) .NE. orig_data(1,j))THEN total_error = total_error + 1 diff --git a/fortran/test/tH5O.F90 b/fortran/test/tH5O.F90 index fa3787e..e8a226e 100644 --- a/fortran/test/tH5O.F90 +++ b/fortran/test/tH5O.F90 @@ -77,22 +77,22 @@ SUBROUTINE test_h5o_link(total_error) INTEGER, PARAMETER :: TRUE = 1 - LOGICAL :: committed ! Whether the named datatype is committed + LOGICAL :: committed ! Whether the named datatype is committed INTEGER :: i, j - INTEGER :: error ! Value returned from API calls + INTEGER :: error ! Value returned from API calls CHARACTER(LEN=14) :: NAME_DATATYPE_SIMPLE="H5T_NATIVE_INT" CHARACTER(LEN=16) :: NAME_DATATYPE_SIMPLE2="H5T_NATIVE_INT-2" INTEGER(HID_T) :: tid, tid2 LOGICAL :: flag - + ! Data for tested h5ocopy_f CHARACTER(LEN=3) , PARAMETER :: dataset = "DS1" INTEGER , PARAMETER :: dim0 = 4 INTEGER(HSIZE_T), DIMENSION(1:1) :: dims2 = (/dim0/) ! size read/write buffer - INTEGER , DIMENSION(1:dim0) :: wdata2 ! Write buffer + INTEGER , DIMENSION(1:dim0) :: wdata2 ! Write buffer LOGICAL :: link_exists CHARACTER(LEN=8) :: chr_exact CHARACTER(LEN=10) :: chr_lg @@ -107,45 +107,45 @@ SUBROUTINE test_h5o_link(total_error) INTEGER(HSSIZE_T) :: comment_size INTEGER(SIZE_T) :: comment_size2 - ! Initialize the raw data + ! Initialize the raw data DO i = 1, TEST6_DIM1 DO j = 1, TEST6_DIM2 wdata(i,j) = i*j ENDDO ENDDO - ! Create the dataspace + ! Create the dataspace CALL h5screate_simple_f(2, dims, space_id, error) CALL check("h5screate_simple_f",error,total_error) - ! Create LCPL with intermediate group creation flag set + ! Create LCPL with intermediate group creation flag set CALL H5Pcreate_f(H5P_LINK_CREATE_F, lcpl_id, error) CALL check("h5Pcreate_f",error,total_error) CALL H5Pset_create_inter_group_f(lcpl_id, TRUE, error) CALL check("H5Pset_create_inter_group_f",error,total_error) - ! Loop over using new group format + ! Loop over using new group format ! for(new_format = FALSE; new_format <= TRUE; new_format++) { - ! Make a FAPL that uses the "use the latest version of the format" bounds + ! Make a FAPL that uses the "use the latest version of the format" bounds CALL H5Pcreate_f(H5P_FILE_ACCESS_F,fapl_id,error) CALL check("h5Pcreate_f",error,total_error) - ! Set the "use the latest version of the format" bounds for creating objects in the file + ! Set the "use the latest version of the format" bounds for creating objects in the file CALL H5Pset_libver_bounds_f(fapl_id, H5F_LIBVER_LATEST_F, H5F_LIBVER_LATEST_F, error) CALL check("H5Pset_libver_bounds_f",error, total_error) - ! Create a new HDF5 file + ! Create a new HDF5 file CALL H5Fcreate_f(TEST_FILENAME, H5F_ACC_TRUNC_F, file_id, error, H5P_DEFAULT_F, fapl_id) CALL check("H5Fcreate_f", error, total_error) - ! Close the FAPL + ! Close the FAPL CALL h5pclose_f(fapl_id, error) CALL check("h5pclose_f",error,total_error) - ! Create and commit a datatype with no name + ! Create and commit a datatype with no name CALL H5Tcopy_f( H5T_NATIVE_INTEGER, type_id, error) CALL check("H5Tcopy_F",error,total_error) @@ -160,22 +160,22 @@ SUBROUTINE test_h5o_link(total_error) CALL H5Dcreate_anon_f(file_id, type_id, space_id, dset_id, error ) ! using no optional parameters CALL check("H5Dcreate_anon_f",error,total_error) ! - ! Verify that we can write to and read from the dataset + ! Verify that we can write to and read from the dataset ! - ! Write the data to the dataset + ! Write the data to the dataset !EP CALL h5dwrite_f(dset_id, H5T_NATIVE_INTEGER, wdata, dims, error, & !EP mem_space_id=H5S_ALL_F, file_space_id=H5S_ALL_F, xfer_prp = H5P_DEFAULT_F) CALL h5dwrite_f(dset_id, H5T_NATIVE_INTEGER, wdata, dims, error) CALL check("h5dwrite_f", error, total_error) - ! Read the data back + ! Read the data back !EP CALL h5dread_f(dset_id, H5T_NATIVE_INTEGER, rdata, dims, error, & !EP mem_space_id=H5S_ALL_F, file_space_id=H5S_ALL_F, xfer_prp = H5P_DEFAULT_F) CALL h5dread_f(dset_id, H5T_NATIVE_INTEGER, rdata, dims, error) CALL check("h5dread_f", error, total_error) - ! Verify the data + ! Verify the data DO i = 1, TEST6_DIM1 DO j = 1, TEST6_DIM2 CALL verify("H5Dread_f",wdata(i,j),rdata(i,j),total_error) @@ -188,21 +188,21 @@ SUBROUTINE test_h5o_link(total_error) CALL H5Gcreate_anon_f(file_id, group_id, error) CALL check("H5Gcreate_anon", error, total_error) - ! Link nameless datatype into nameless group + ! Link nameless datatype into nameless group CALL H5Olink_f(type_id, group_id, "datatype", error, H5P_DEFAULT_F) CALL check("H5Olink_f", error, total_error) - ! Link nameless dataset into nameless group with intermediate group + ! Link nameless dataset into nameless group with intermediate group CALL H5Olink_f(dset_id, group_id, "inter_group/dataset", error, lcpl_id, H5P_DEFAULT_F) CALL check("H5Olink_f", error, total_error) - ! Close IDs for dataset and datatype + ! Close IDs for dataset and datatype CALL h5dclose_f(dset_id, error) CALL check("h5dclose_f", error, total_error) CALL h5tclose_f(type_id, error) CALL check("h5tclose_f", error, total_error) - ! Re-open datatype using new link + ! Re-open datatype using new link CALL H5Topen_f(group_id, "datatype", type_id, error) CALL check("h5topen_f", error, total_error) @@ -213,30 +213,30 @@ SUBROUTINE test_h5o_link(total_error) CALL h5gclose_f(group_id, error) CALL check("h5gclose_f",error,total_error) - ! Open dataset through root group and verify its data + ! Open dataset through root group and verify its data CALL H5Dopen_f(file_id, "/group/inter_group/dataset", dset_id, error) CALL check("test_lcpl.h5dopen_f", error, total_error) - ! Read data from dataset + ! Read data from dataset !EP CALL h5dread_f(dset_id, H5T_NATIVE_INTEGER, rdata, dims, error, & !EP H5S_ALL_F, H5S_ALL_F, xfer_prp = H5P_DEFAULT_F) CALL h5dread_f(dset_id, H5T_NATIVE_INTEGER, rdata, dims, error) CALL check("h5dread_f", error, total_error) - ! Verify the data + ! Verify the data DO i = 1, TEST6_DIM1 DO j = 1, TEST6_DIM2 CALL verify("H5Dread",wdata(i,j),rdata(i,j),total_error) ENDDO ENDDO - ! Close open IDs + ! Close open IDs CALL h5dclose_f(dset_id, error) CALL check("h5dclose_f",error,total_error) CALL h5tclose_f(type_id, error) CALL check("h5tclose_f",error,total_error) - ! Close remaining IDs + ! Close remaining IDs CALL h5sclose_f(space_id, error) CALL check("h5sclose_f",error,total_error) CALL h5pclose_f(lcpl_id,error) @@ -270,7 +270,7 @@ SUBROUTINE test_h5o_link(total_error) comment_lg = ' ' - CALL h5oget_comment_by_name_f(file_id, "/G1/G2/G3", comment_lg, error) + CALL h5oget_comment_by_name_f(file_id, "/G1/G2/G3", comment_lg, error) CALL check("h5oget_comment_by_name_f", error, total_error) IF(comment_lg(1:13).NE.grp_comment)THEN @@ -287,7 +287,7 @@ SUBROUTINE test_h5o_link(total_error) comment_lg = ' ' - CALL h5oget_comment_by_name_f(file_id, "/G1/G2/G3"//' ', comment_lg, error) + CALL h5oget_comment_by_name_f(file_id, "/G1/G2/G3"//' ', comment_lg, error) CALL check("h5oget_comment_by_name_f", error, total_error) IF(comment_lg(1:13).NE.grp_comment)THEN @@ -309,7 +309,7 @@ SUBROUTINE test_h5o_link(total_error) ! Try reading into a buffer that is the correct size - CALL h5oget_comment_f(dset_id, comment, error) + CALL h5oget_comment_f(dset_id, comment, error) CALL check("h5oget_comment_f", error, total_error) IF(comment(1:15).NE.dset_comment(1:15))THEN @@ -318,18 +318,18 @@ SUBROUTINE test_h5o_link(total_error) ! Try reading into a buffer that is to small - CALL h5oget_comment_f(dset_id, comment_sm, error) + CALL h5oget_comment_f(dset_id, comment_sm, error) CALL check("h5oget_comment_f", error, total_error) IF(comment_sm(1:10).NE.dset_comment(1:10))THEN CALL check("h5oget_comment_f", -1, total_error) - ENDIF + ENDIF ! Try reading into a buffer that is larger then needed comment_lg = ' ' - CALL h5oget_comment_f(dset_id, comment_lg, error) + CALL h5oget_comment_f(dset_id, comment_lg, error) CALL check("h5oget_comment_f", error, total_error) IF(comment_lg(1:15).NE.dset_comment)THEN @@ -341,7 +341,7 @@ SUBROUTINE test_h5o_link(total_error) ! ! Check optional parameter ! - CALL h5oget_comment_f(dset_id, comment_lg, error, comment_size) + CALL h5oget_comment_f(dset_id, comment_lg, error, comment_size) CALL check("h5oget_comment_f", error, total_error) IF( comment_size.NE.15)THEN @@ -352,7 +352,7 @@ SUBROUTINE test_h5o_link(total_error) ! Try reading into a buffer that is the correct size - CALL h5oget_comment_by_name_f(dset_id, ".", comment, error) + CALL h5oget_comment_by_name_f(dset_id, ".", comment, error) CALL check("h5oget_comment_by_name_f", error, total_error) IF(comment(1:15).NE.dset_comment(1:15))THEN @@ -361,7 +361,7 @@ SUBROUTINE test_h5o_link(total_error) ! Try with trailing blanks in the name - CALL h5oget_comment_by_name_f(dset_id, ". ", comment, error) + CALL h5oget_comment_by_name_f(dset_id, ". ", comment, error) CALL check("h5oget_comment_by_name_f", error, total_error) IF(comment(1:15).NE.dset_comment(1:15))THEN @@ -371,7 +371,7 @@ SUBROUTINE test_h5o_link(total_error) ! ! Check optional parameter ! - CALL h5oget_comment_by_name_f(dset_id, ". ", comment_lg, error, comment_size2) + CALL h5oget_comment_by_name_f(dset_id, ". ", comment_lg, error, comment_size2) CALL check("h5oget_comment_by_name_f", error, total_error) IF( comment_size2.NE.15)THEN @@ -481,7 +481,7 @@ SUBROUTINE test_h5o_link(total_error) CALL h5gclose_f(group_id, error) CALL check("h5gclose_f", error, total_error) - ! Test opening an object by index, note + ! Test opening an object by index, note CALL h5oopen_by_idx_f(file_id, "/G1/G2/G3", H5_INDEX_NAME_F, H5_ITER_INC_F, 0_hsize_t, group_id, error) CALL check("h5oopen_by_idx_f", error, total_error) @@ -508,13 +508,13 @@ SUBROUTINE test_h5o_link(total_error) CALL h5pcreate_f(H5P_OBJECT_COPY_F, ocpypl_id, error) CALL check("h5Pcreate_f",error,total_error) - CALL h5pset_copy_object_f(ocpypl_id, H5O_COPY_SHALLOW_HIERARCHY_F, error) + CALL h5pset_copy_object_f(ocpypl_id, H5O_COPY_SHALLOW_HIERARCHY_F, error) CALL check("H5Pset_copy_object_f",error,total_error) - CALL h5ocopy_f(file_id, "/G1/G2", file_id, "/G1/G_cp2", error, ocpypl_id=ocpypl_id) + CALL h5ocopy_f(file_id, "/G1/G2", file_id, "/G1/G_cp2", error, ocpypl_id=ocpypl_id) CALL check("h5ocopy_f",error,total_error) - ! Makes sure the "DS1" dataset was not copied since we set a + ! Makes sure the "DS1" dataset was not copied since we set a ! flag to copy only immediate members of a group. ! Therefore, this should fail. CALL h5dopen_f(file_id, "/G1/G_cp2/DS1", dset_id, error) @@ -578,31 +578,31 @@ SUBROUTINE test_h5o_plist(total_error) IMPLICIT NONE INTEGER, INTENT(INOUT) :: total_error - INTEGER(hid_t) :: fid ! HDF5 File ID - INTEGER(hid_t) :: grp, dset, dtype, dspace ! Object identifiers - INTEGER(hid_t) :: fapl ! File access property list - INTEGER(hid_t) :: gcpl, dcpl, tcpl ! Object creation properties - INTEGER :: def_max_compact, def_min_dense ! Default phase change parameters - INTEGER :: max_compact, min_dense ! Actual phase change parameters - INTEGER :: error ! Value returned from API calls + INTEGER(hid_t) :: fid ! HDF5 File ID + INTEGER(hid_t) :: grp, dset, dtype, dspace ! Object identifiers + INTEGER(hid_t) :: fapl ! File access property list + INTEGER(hid_t) :: gcpl, dcpl, tcpl ! Object creation properties + INTEGER :: def_max_compact, def_min_dense ! Default phase change parameters + INTEGER :: max_compact, min_dense ! Actual phase change parameters + INTEGER :: error ! Value returned from API calls CHARACTER(LEN=7), PARAMETER :: TEST_FILENAME = 'test.h5' ! PRINT*,'Testing object creation properties' - ! Make a FAPL that uses the "use the latest version of the format" flag + ! Make a FAPL that uses the "use the latest version of the format" flag CALL H5Pcreate_f(H5P_FILE_ACCESS_F, fapl, error) CALL check("H5Pcreate_f", error, total_error) - ! Set the "use the latest version of the format" bounds for creating objects in the file + ! Set the "use the latest version of the format" bounds for creating objects in the file CALL H5Pset_libver_bounds_f(fapl, H5F_LIBVER_LATEST_F, H5F_LIBVER_LATEST_F, error) CALL check("H5Pcreate_f", error, total_error) - ! Create a new HDF5 file + ! Create a new HDF5 file CALL H5Fcreate_f(TEST_FILENAME, H5F_ACC_TRUNC_F, fid, error, access_prp=fapl) CALL check("H5Fcreate_f", error, total_error) - ! Create group, dataset & named datatype creation property lists + ! Create group, dataset & named datatype creation property lists CALL H5Pcreate_f(H5P_GROUP_CREATE_F, gcpl, error) CALL check("H5Pcreate_f", error, total_error) CALL H5Pcreate_f(H5P_DATASET_CREATE_F, dcpl, error) @@ -610,11 +610,11 @@ SUBROUTINE test_h5o_plist(total_error) CALL H5Pcreate_f(H5P_DATATYPE_CREATE_F, tcpl, error) CALL check("H5Pcreate_f", error, total_error) - ! Retrieve default attribute phase change values + ! Retrieve default attribute phase change values CALL H5Pget_attr_phase_change_f(gcpl, def_max_compact, def_min_dense, error) CALL check("H5Pget_attr_phase_change_f", error, total_error) - ! Set non-default attribute phase change values on each creation property list + ! Set non-default attribute phase change values on each creation property list CALL H5Pset_attr_phase_change_f(gcpl, def_max_compact+1, def_min_dense-1, error) CALL check("H5Pget_attr_phase_change_f", error, total_error) CALL H5Pset_attr_phase_change_f(dcpl, def_max_compact+1, def_min_dense-1, error) @@ -622,7 +622,7 @@ SUBROUTINE test_h5o_plist(total_error) CALL H5Pset_attr_phase_change_f(tcpl, def_max_compact+1, def_min_dense-1, error) CALL check("H5Pget_attr_phase_change_f", error, total_error) - ! Retrieve attribute phase change values on each creation property list and verify + ! Retrieve attribute phase change values on each creation property list and verify CALL H5Pget_attr_phase_change_f(gcpl, max_compact, min_dense, error) CALL check("H5Pget_attr_phase_change_f", error, total_error) CALL verify("H5Pget_attr_phase_change_f", max_compact, (def_max_compact + 1), total_error) @@ -640,16 +640,16 @@ SUBROUTINE test_h5o_plist(total_error) ! Create a group, dataset, and committed datatype within the file, ! using the respective type of creation property lists. - ! + ! - ! Create the group anonymously and link it in + ! Create the group anonymously and link it in CALL H5Gcreate_anon_f(fid, grp, error, gcpl_id=gcpl) CALL check("H5Gcreate_anon_f", error, total_error) CALL H5Olink_f(grp, fid, "group", error) CALL check("H5Olink_f", error, total_error) - ! Commit the type inside the group anonymously and link it in + ! Commit the type inside the group anonymously and link it in CALL h5tcopy_f(H5T_NATIVE_INTEGER, dtype, error) CALL check("h5tcopy_f", error, total_error) @@ -659,11 +659,11 @@ SUBROUTINE test_h5o_plist(total_error) CALL H5Olink_f(dtype, fid, "datatype", error) CALL check("H5Olink_f", error, total_error) - ! Create the dataspace for the dataset. + ! Create the dataspace for the dataset. CALL h5screate_f(H5S_SCALAR_F, dspace, error) CALL check("h5screate_f",error,total_error) - ! Create the dataset anonymously and link it in + ! Create the dataset anonymously and link it in CALL H5Dcreate_anon_f(fid, H5T_NATIVE_INTEGER, dspace, dset, error, dcpl ) CALL check("H5Dcreate_anon_f",error,total_error) @@ -673,7 +673,7 @@ SUBROUTINE test_h5o_plist(total_error) CALL h5sclose_f(dspace, error) CALL check("h5sclose_f",error,total_error) - ! Close current creation property lists + ! Close current creation property lists CALL h5pclose_f(gcpl,error) CALL check("h5pclose_f", error, total_error) CALL h5pclose_f(dcpl,error) @@ -681,7 +681,7 @@ SUBROUTINE test_h5o_plist(total_error) CALL h5pclose_f(tcpl,error) CALL check("h5pclose_f", error, total_error) - ! Retrieve each object's creation property list + ! Retrieve each object's creation property list CALL H5Gget_create_plist_f(grp, gcpl, error) CALL check("H5Gget_create_plist", error, total_error) @@ -691,7 +691,7 @@ SUBROUTINE test_h5o_plist(total_error) CALL H5Dget_create_plist_f(dset, dcpl, error) CALL check("H5Dget_create_plist_f", error, total_error) - ! Retrieve attribute phase change values on each creation property list and verify + ! Retrieve attribute phase change values on each creation property list and verify CALL H5Pget_attr_phase_change_f(gcpl, max_compact, min_dense, error) CALL check("H5Pget_attr_phase_change_f", error, total_error) CALL verify("H5Pget_attr_phase_change_f", max_compact, (def_max_compact + 1), total_error) @@ -707,7 +707,7 @@ SUBROUTINE test_h5o_plist(total_error) CALL verify("H5Pget_attr_phase_change_f", max_compact, (def_max_compact + 1), total_error) CALL verify("H5Pget_attr_phase_change_f", min_dense, (def_min_dense - 1), total_error) - ! Close current objects + ! Close current objects CALL h5pclose_f(gcpl,error) CALL check("h5pclose_f", error, total_error) CALL h5pclose_f(dcpl,error) @@ -724,11 +724,11 @@ SUBROUTINE test_h5o_plist(total_error) CALL check("h5dclose_f",error,total_error) CALL h5fclose_f(fid, error) CALL check("h5fclose_f",error,total_error) - ! Re-open the file and check that the object creation properties persist + ! Re-open the file and check that the object creation properties persist CALL h5fopen_f(TEST_FILENAME, H5F_ACC_RDONLY_F, fid, error, access_prp=fapl) CALL check("H5fopen_f",error,total_error) - ! Re-open objects + ! Re-open objects CALL H5Gopen_f(fid, "group", grp, error) CALL check("h5gopen_f", error, total_error) @@ -738,7 +738,7 @@ SUBROUTINE test_h5o_plist(total_error) CALL H5Dopen_f(fid, "dataset", dset, error) CALL check("h5dopen_f", error, total_error) - ! Retrieve each object's creation property list + ! Retrieve each object's creation property list CALL H5Gget_create_plist_f(grp, gcpl, error) CALL check("H5Gget_create_plist", error, total_error) @@ -748,7 +748,7 @@ SUBROUTINE test_h5o_plist(total_error) CALL H5Dget_create_plist_f(dset, dcpl, error) CALL check("H5Dget_create_plist_f", error, total_error) - ! Retrieve attribute phase change values on each creation property list and verify + ! Retrieve attribute phase change values on each creation property list and verify CALL H5Pget_attr_phase_change_f(gcpl, max_compact, min_dense, error) CALL check("H5Pget_attr_phase_change_f", error, total_error) CALL verify("H5Pget_attr_phase_change_f", max_compact, (def_max_compact + 1), total_error) @@ -764,7 +764,7 @@ SUBROUTINE test_h5o_plist(total_error) CALL verify("H5Pget_attr_phase_change_f", max_compact, (def_max_compact + 1), total_error) CALL verify("H5Pget_attr_phase_change_f", min_dense, (def_min_dense - 1), total_error) - ! Close current objects + ! Close current objects CALL h5pclose_f(gcpl,error) CALL check("h5pclose_f", error, total_error) CALL h5pclose_f(dcpl,error) @@ -782,7 +782,7 @@ SUBROUTINE test_h5o_plist(total_error) CALL h5fclose_f(fid, error) CALL check("h5fclose_f",error,total_error) - ! Close the FAPL + ! Close the FAPL CALL H5Pclose_f(fapl, error) CALL check("H5Pclose_f", error, total_error) diff --git a/fortran/test/tH5O_F03.F90 b/fortran/test/tH5O_F03.F90 index c9ecccc..cb6273e 100644 --- a/fortran/test/tH5O_F03.F90 +++ b/fortran/test/tH5O_F03.F90 @@ -5,7 +5,7 @@ ! ! FUNCTION ! Test FORTRAN HDF5 H5O APIs which are dependent on FORTRAN 2003 -! features. +! features. ! ! COPYRIGHT ! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @@ -28,9 +28,9 @@ ! ***************************************** MODULE visit_cb - USE HDF5 + USE HDF5 USE, INTRINSIC :: ISO_C_BINDING - + IMPLICIT NONE INTEGER, PARAMETER :: info_size = 9 @@ -283,7 +283,7 @@ CONTAINS SUBROUTINE test_h5o_refcount(total_error) - USE HDF5 + USE HDF5 USE TH5_MISC USE ISO_C_BINDING IMPLICIT NONE @@ -301,7 +301,7 @@ SUBROUTINE test_h5o_refcount(total_error) ! Create a new HDF5 file CALL h5fcreate_f(FILENAME,H5F_ACC_TRUNC_F,fid,error) - CALL check("h5fcreate_f", error, total_error) + CALL check("h5fcreate_f", error, total_error) ! Create a group, dataset, and committed datatype within the file ! Create the group @@ -567,13 +567,13 @@ SUBROUTINE test_obj_info(total_error) INTEGER, INTENT(INOUT) :: total_error - INTEGER(hid_t) :: fid = -1 ! File ID - INTEGER(hid_t) :: gid = -1, gid2 = -1 ! Group IDs - INTEGER(hid_t) :: did ! Dataset ID - INTEGER(hid_t) :: sid ! Dataspace ID - TYPE(hobj_ref_t_f), TARGET :: wref ! Reference to write + INTEGER(hid_t) :: fid = -1 ! File ID + INTEGER(hid_t) :: gid = -1, gid2 = -1 ! Group IDs + INTEGER(hid_t) :: did ! Dataset ID + INTEGER(hid_t) :: sid ! Dataspace ID + TYPE(hobj_ref_t_f), TARGET :: wref ! Reference to write TYPE(hobj_ref_t_f), TARGET :: rref ! Reference to read - TYPE(H5O_info_t) :: oinfo ! Object info struct + TYPE(H5O_info_t) :: oinfo ! Object info struct INTEGER :: error TYPE(C_PTR) :: f_ptr @@ -595,7 +595,7 @@ SUBROUTINE test_obj_info(total_error) CALL h5gcreate_f(fid, GROUPNAME, gid, error) CALL check("h5gcreate_f",error,total_error) - ! Create nested groups + ! Create nested groups CALL h5gcreate_f(gid, GROUPNAME2, gid2, error) CALL check("h5gcreate_f",error,total_error) CALL h5gclose_f(gid2, error) @@ -630,7 +630,7 @@ SUBROUTINE test_obj_info(total_error) CALL h5dwrite_f(did, H5T_STD_REF_OBJ, f_ptr, error) CALL check("h5dwrite_f",error, total_error) - ! Close objects + ! Close objects CALL h5dclose_f(did, error) CALL check("h5dclose_f", error, total_error) CALL h5sclose_f(sid, error) @@ -718,7 +718,7 @@ SUBROUTINE build_visit_file(fid) USE TH5_MISC IMPLICIT NONE - INTEGER(hid_t) :: fid ! File ID + INTEGER(hid_t) :: fid ! File ID INTEGER(hid_t) :: gid = -1, gid2 = -1 ! Group IDs INTEGER(hid_t) :: sid = -1 ! Dataspace ID INTEGER(hid_t) :: did = -1 ! Dataset ID @@ -726,7 +726,7 @@ SUBROUTINE build_visit_file(fid) INTEGER(hid_t) :: aid = -1, aid2 = -1, aid3 = -1 ! Attribute ID CHARACTER(LEN=20) :: filename = 'visit.h5' INTEGER :: error - + ! Create file for visiting CALL H5Fcreate_f(filename, H5F_ACC_TRUNC_F, fid, error) diff --git a/fortran/test/tH5P.F90 b/fortran/test/tH5P.F90 index c42dd7e..7fe3971 100644 --- a/fortran/test/tH5P.F90 +++ b/fortran/test/tH5P.F90 @@ -25,7 +25,7 @@ ! !***** MODULE TH5P - USE HDF5 ! This module contains all necessary modules + USE HDF5 ! This module contains all necessary modules USE TH5_MISC USE TH5_MISC_GEN @@ -37,11 +37,11 @@ SUBROUTINE external_test(cleanup, total_error) ! h5pset_external_f, h5pget_external_count_f, ! h5pget_external_f - + IMPLICIT NONE LOGICAL, INTENT(IN) :: cleanup INTEGER, INTENT(INOUT) :: total_error - + CHARACTER(LEN=8), PARAMETER :: filename = "external" CHARACTER(LEN=80) :: fix_filename INTEGER(HID_T) :: file_id @@ -75,7 +75,7 @@ SUBROUTINE external_test(cleanup, total_error) ENDIF CALL h5fcreate_f(fix_filename, H5F_ACC_TRUNC_F, file_id, error) CALL check("h5fcreate_f",error,total_error) - + CALL h5pcreate_f(H5P_DATASET_XFER_F, plist_id, error) CALL check("h5pcreate_f", error, total_error) CALL h5pset_buffer_f(plist_id, buf_size, error) @@ -88,7 +88,7 @@ SUBROUTINE external_test(cleanup, total_error) ENDIF CALL h5pclose_f(plist_id, error) CALL check("h5pclose_f", error, total_error) - + CALL h5pcreate_f(H5P_DATASET_CREATE_F, plist_id, error) CALL check("h5pcreate_f",error,total_error) cur_size(1) =100 @@ -103,7 +103,7 @@ SUBROUTINE external_test(cleanup, total_error) CALL h5dcreate_f(file_id, "dset1", H5T_NATIVE_INTEGER, space_id, & dataset_id, error, plist_id) CALL check("h5dcreate_f", error, total_error) - + CALL h5dclose_f(dataset_id, error) CALL check("h5dclose_f", error, total_error) CALL h5pclose_f(plist_id, error) @@ -111,11 +111,11 @@ SUBROUTINE external_test(cleanup, total_error) CALL h5sclose_f(space_id, error) CALL check("h5sclose_f", error, total_error) CALL h5fclose_f(file_id, error) - + CALL h5fopen_f(fix_filename, H5F_ACC_RDWR_F, file_id, error) CALL h5dopen_f(file_id, "dset1", dataset_id, error) CALL check("h5dopen_f",error,total_error) - + ! Read dataset creation information CALL h5dget_create_plist_f(dataset_id, plist_id, error) CALL check("h5dget_create_plist_f",error,total_error) @@ -138,7 +138,7 @@ SUBROUTINE external_test(cleanup, total_error) WRITE (*,*) "got external file size is not correct" total_error = total_error + 1 END IF - + CALL h5dclose_f(dataset_id, error) CALL check("h5dclose_f", error, total_error) CALL h5pclose_f(plist_id, error) @@ -152,15 +152,15 @@ SUBROUTINE external_test(cleanup, total_error) END SUBROUTINE external_test SUBROUTINE multi_file_test(cleanup, total_error) - + IMPLICIT NONE LOGICAL, INTENT(IN) :: cleanup INTEGER, INTENT(INOUT) :: total_error - + CHARACTER(LEN=9), PARAMETER :: filename = "multidset" ! File name CHARACTER(LEN=80) :: fix_filename CHARACTER(LEN=4), PARAMETER :: dsetname = "dset" ! Dataset name - + INTEGER(HID_T) :: file_id ! File identifier INTEGER(HID_T) :: dset_id ! Dataset identifier INTEGER(HID_T) :: dspace_id ! Dataspace identifier @@ -173,10 +173,10 @@ SUBROUTINE multi_file_test(cleanup, total_error) !INTEGER(HADDR_T), DIMENSION(0:H5FD_MEM_NTYPES_F) :: memb_addr LOGICAL :: relax = .TRUE. LOGICAL :: relax_out = .TRUE. - + INTEGER(HSIZE_T), DIMENSION(2) :: dims = (/4,6/) ! Dataset dimensions INTEGER :: rank = 2 ! Dataset rank - + INTEGER, DIMENSION(4,6) :: dset_data, data_out ! Data buffers INTEGER :: error ! Error flag INTEGER(HID_T) :: driver @@ -201,7 +201,7 @@ SUBROUTINE multi_file_test(cleanup, total_error) memb_addr(H5FD_MEM_LHEAP_F) = 0.3 memb_map(H5FD_MEM_OHDR_F) = H5FD_MEM_OHDR_F memb_addr(H5FD_MEM_OHDR_F) = 0.4 - + memb_name = ' ' memb_name(H5FD_MEM_SUPER_F) = '%s-s.h5' memb_name(H5FD_MEM_BTREE_F) = '%s-b.h5' @@ -218,7 +218,7 @@ SUBROUTINE multi_file_test(cleanup, total_error) dset_data(i,j) = (i-1)*6 + j END DO END DO - + ! ! Create a new file using default properties. ! @@ -244,8 +244,8 @@ SUBROUTINE multi_file_test(cleanup, total_error) ! CALL h5pget_cache_f(fapl, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, & rdcc_w0, error) - CALL check("h5pget_cache_f", error, total_error) - + CALL check("h5pget_cache_f", error, total_error) + ! ! Set cache to some number ! @@ -284,13 +284,13 @@ SUBROUTINE multi_file_test(cleanup, total_error) ! CALL h5dclose_f(dset_id, error) CALL check("h5dclose_f", error, total_error) - + ! ! Terminate access to the data space. ! CALL h5sclose_f(dspace_id, error) CALL check("h5sclose_f", error, total_error) - + ! ! Close the file. ! @@ -318,31 +318,31 @@ SUBROUTINE multi_file_test(cleanup, total_error) ! write(*,*) memb_name_out ! write(*,*) memb_addr_out ! CALL check("h5pget_fapl_multi_f", error, total_error) - + ! ! Open the existing dataset. ! CALL h5dopen_f(file_id, dsetname, dset_id, error) CALL check("h5dopen_f", error, total_error) - + ! ! Get the dataset type. ! CALL h5dget_type_f(dset_id, dtype_id, error) CALL check("h5dget_type_f", error, total_error) - + ! ! Get the data space. ! CALL h5dget_space_f(dset_id, dspace_id, error) CALL check("h5dget_space_f", error, total_error) - + ! ! Read the dataset. ! CALL h5dread_f(dset_id, H5T_NATIVE_INTEGER, data_out, data_dims, error) CALL check("h5dread_f", error, total_error) - + ! !Compare the data. ! @@ -354,19 +354,19 @@ SUBROUTINE multi_file_test(cleanup, total_error) END IF END DO END DO - + ! ! End access to the dataset and release resources used by it. ! CALL h5dclose_f(dset_id, error) CALL check("h5dclose_f", error, total_error) - + ! ! Terminate access to the data space. ! CALL h5sclose_f(dspace_id, error) CALL check("h5sclose_f", error, total_error) - + ! ! Terminate access to the data type. ! @@ -383,7 +383,7 @@ SUBROUTINE multi_file_test(cleanup, total_error) CALL check("h5pclose_f", error, total_error) IF(cleanup) CALL h5_cleanup_f(filename, H5P_DEFAULT_F, error) CALL check("h5_cleanup_f", error, total_error) - + IF(cleanup) CALL h5_cleanup_f(filename//'.h5-b', H5P_DEFAULT_F, error) CALL check("h5_cleanup_f", error, total_error) IF(cleanup) CALL h5_cleanup_f(filename//'.h5-g', H5P_DEFAULT_F, error) @@ -396,7 +396,7 @@ SUBROUTINE multi_file_test(cleanup, total_error) CALL check("h5_cleanup_f", error, total_error) IF(cleanup) CALL h5_cleanup_f(filename//'.h5-s', H5P_DEFAULT_F, error) CALL check("h5_cleanup_f", error, total_error) - + RETURN END SUBROUTINE multi_file_test @@ -419,27 +419,27 @@ END SUBROUTINE multi_file_test !------------------------------------------------------------------------- ! SUBROUTINE test_chunk_cache(cleanup, total_error) - + IMPLICIT NONE LOGICAL, INTENT(IN) :: cleanup INTEGER, INTENT(INOUT) :: total_error - + CHARACTER(LEN=14), PARAMETER :: filename="chunk_cache" CHARACTER(LEN=80) :: fix_filename - INTEGER(hid_t) :: fid = -1 ! File ID - INTEGER(hid_t) :: fapl_local = -1 ! Local fapl - INTEGER(hid_t) :: fapl_def = -1 ! Default fapl - INTEGER(hid_t) :: dcpl = -1 ! Dataset creation property list ID - INTEGER(hid_t) :: dapl1 = -1 ! Dataset access property list ID - INTEGER(hid_t) :: dapl2 = -1 ! Dataset access property list ID - INTEGER(hid_t) :: sid = -1 ! Dataspace ID - INTEGER(hid_t) :: dsid = -1 ! Dataset ID - INTEGER(hsize_t), DIMENSION(1:1) :: chunk_dim, NDIM = (/100/) ! Dataset and chunk dimensions - INTEGER(size_t) :: nslots_1, nslots_2, nslots_3, nslots_4 ! rdcc number of elements - INTEGER(size_t) :: nbytes_1, nbytes_2, nbytes_3, nbytes_4 ! rdcc number of bytes + INTEGER(hid_t) :: fid = -1 ! File ID + INTEGER(hid_t) :: fapl_local = -1 ! Local fapl + INTEGER(hid_t) :: fapl_def = -1 ! Default fapl + INTEGER(hid_t) :: dcpl = -1 ! Dataset creation property list ID + INTEGER(hid_t) :: dapl1 = -1 ! Dataset access property list ID + INTEGER(hid_t) :: dapl2 = -1 ! Dataset access property list ID + INTEGER(hid_t) :: sid = -1 ! Dataspace ID + INTEGER(hid_t) :: dsid = -1 ! Dataset ID + INTEGER(hsize_t), DIMENSION(1:1) :: chunk_dim, NDIM = (/100/) ! Dataset and chunk dimensions + INTEGER(size_t) :: nslots_1, nslots_2, nslots_3, nslots_4 ! rdcc number of elements + INTEGER(size_t) :: nbytes_1, nbytes_2, nbytes_3, nbytes_4 ! rdcc number of bytes INTEGER :: mdc_nelmts - INTEGER(size_t) ::nlinks ! Number of link traversals - REAL :: w0_1, w0_2, w0_3, w0_4 ! rdcc preemption policy + INTEGER(size_t) ::nlinks ! Number of link traversals + REAL :: w0_1, w0_2, w0_3, w0_4 ! rdcc preemption policy INTEGER :: error INTEGER(size_t) rdcc_nelmts INTEGER(size_t) rdcc_nbytes @@ -452,7 +452,7 @@ SUBROUTINE test_chunk_cache(cleanup, total_error) STOP ENDIF - ! Create a default fapl and dapl + ! Create a default fapl and dapl CALL H5Pcreate_f(H5P_FILE_ACCESS_F, fapl_def, error) CALL check("H5Pcreate_f", error, total_error) CALL H5Pcreate_f(H5P_DATASET_ACCESS_F, dapl1, error) @@ -460,7 +460,7 @@ SUBROUTINE test_chunk_cache(cleanup, total_error) ! Verify that H5Pget_chunk_cache(dapl) returns the same values as are in ! the default fapl. - ! + ! CALL H5Pget_cache_f(fapl_def, mdc_nelmts, nslots_1, nbytes_1, w0_1, error) CALL check("H5Pget_cache_f", error, total_error) CALL H5Pget_chunk_cache_f(dapl1, nslots_4, nbytes_4, w0_4, error) @@ -469,7 +469,7 @@ SUBROUTINE test_chunk_cache(cleanup, total_error) CALL verify("H5Pget_chunk_cache_f", nbytes_1, nbytes_4, total_error) CALL verify("H5Pget_chunk_cache_f", w0_1, w0_4, total_error) - ! Set a lapl property on dapl1 (to verify inheritance) + ! Set a lapl property on dapl1 (to verify inheritance) CALL H5Pset_nlinks_f(dapl1, 134_size_t , error) CALL check("H5Pset_nlinks_f", error, total_error) CALL H5Pget_nlinks_f(dapl1, nlinks, error) @@ -494,29 +494,29 @@ SUBROUTINE test_chunk_cache(cleanup, total_error) CALL H5Pset_cache_f(fapl_local, 0, nslots_2, nbytes_2, w0_2, error) CALL check("H5Pset_cache_f", error, total_error) - ! Create file + ! Create file CALL H5Fcreate_f(fix_filename, H5F_ACC_TRUNC_F, fid, error, H5P_DEFAULT_F, fapl_local) CALL check("H5Fcreate_f", error, total_error) - ! Create dataset creation property list + ! Create dataset creation property list CALL H5Pcreate_f(H5P_DATASET_CREATE_F, dcpl, error) CALL check("H5Pcreate_f", error, total_error) - ! Set chunking + ! Set chunking chunk_dim(1) = 10 CALL H5Pset_chunk_f(dcpl, 1, chunk_dim, error) CALL check("H5Pset_chunk_f", error, total_error) - ! Create 1-D dataspace + ! Create 1-D dataspace ndim(1) = 100 CALL H5Screate_simple_f(1, ndim, sid, error) CALL check("H5Pcreate_f", error, total_error) - ! Create dataset with default dapl + ! Create dataset with default dapl CALL H5Dcreate_f(fid, "dset", H5T_NATIVE_INTEGER, sid, dsid, error, dcpl, H5P_DEFAULT_F, dapl1) CALL check("H5Pcreate_f", error, total_error) - - ! Retrieve dapl from dataset, verify cache values are the same as on fapl_local + + ! Retrieve dapl from dataset, verify cache values are the same as on fapl_local CALL H5Dget_access_plist_f(dsid, dapl2, error) CALL check("H5Dget_access_plist_f", error, total_error) CALL H5Pget_chunk_cache_f(dapl2, nslots_4, nbytes_4, w0_4, error) @@ -524,9 +524,9 @@ SUBROUTINE test_chunk_cache(cleanup, total_error) CALL verify("H5Pget_chunk_cache_f", INT(nslots_2), INT(nslots_4), total_error) CALL verify("H5Pget_chunk_cache_f", INT(nbytes_2), INT(nbytes_4), total_error) CALL verify("H5Pget_chunk_cache_f", w0_2, w0_4, total_error) - CALL H5Pclose_f(dapl2,error) + CALL H5Pclose_f(dapl2,error) CALL check("H5Pclose_f", error, total_error) - + ! Set new values on dapl1. nbytes will be set to default, so the file ! property will override this setting @@ -537,7 +537,7 @@ SUBROUTINE test_chunk_cache(cleanup, total_error) CALL H5Pset_chunk_cache_f(dapl1, nslots_3, nbytes_3, w0_3, error) CALL check("H5Pset_chunk_cache_f", error, total_error) - ! Close dataset, reopen with dapl1. Note the use of a dapl with H5Oopen + ! Close dataset, reopen with dapl1. Note the use of a dapl with H5Oopen CALL H5Dclose_f(dsid, error) CALL H5Oopen_f(fid, "dset", dsid, error, dapl1) @@ -572,11 +572,11 @@ SUBROUTINE test_chunk_cache(cleanup, total_error) CALL verify("H5Pget_chunk_cache_f", INT(nslots_2), INT(nslots_4), total_error) CALL verify("H5Pget_chunk_cache_f", INT(nbytes_2), INT(nbytes_4), total_error) CALL verify("H5Pget_chunk_cache_f", w0_2, w0_4, total_error) - CALL H5Pclose_f(dapl2,error) + CALL H5Pclose_f(dapl2,error) CALL check("H5Pclose_f", error, total_error) ! Similary, test use of H5Dcreate2 with H5P_DEFAULT - CALL H5Dclose_f(dsid, error) + CALL H5Dclose_f(dsid, error) CALL check("H5Dclose_f", error, total_error) CALL H5Dcreate_f(fid, "dset2", H5T_NATIVE_INTEGER, sid, dsid, error, dcpl, H5P_DEFAULT_F, H5P_DEFAULT_F) @@ -599,7 +599,7 @@ SUBROUTINE test_chunk_cache(cleanup, total_error) CALL check("H5Pset_cache_f", error, total_error) ! Close and reopen file with new fapl_local - + CALL H5Dclose_f(dsid, error) CALL check("H5Dclose_f", error, total_error) CALL H5Fclose_f(fid,error) @@ -611,13 +611,13 @@ SUBROUTINE test_chunk_cache(cleanup, total_error) ! Verify that dapl2 retrieved earlier (using values from the old fapl) ! sets its values in the new file (test use of H5Dopen2 with a dapl) ! - + CALL h5dopen_f (fid, "dset", dsid, error, dapl2) CALL check("h5dopen_f", error, total_error) - + CALL H5Pclose_f(dapl2,error) CALL check("H5Pclose_f", error, total_error) ! Close dapl2, to avoid id leak - + CALL H5Dget_access_plist_f(dsid, dapl2, error) CALL check("H5Dget_access_plist_f", error, total_error) CALL H5Pget_chunk_cache_f(dapl2, nslots_4, nbytes_4, w0_4, error) @@ -707,15 +707,15 @@ SUBROUTINE test_chunk_cache(cleanup, total_error) CALL H5Sclose_f(sid,error) CALL check("H5Sclose_f", error, total_error) CALL H5Pclose_f(fapl_local,error) - CALL check("H5Pclose_f", error, total_error) + CALL check("H5Pclose_f", error, total_error) CALL H5Pclose_f(fapl_def,error) - CALL check("H5Pclose_f", error, total_error) + CALL check("H5Pclose_f", error, total_error) CALL H5Pclose_f(dapl1,error) - CALL check("H5Pclose_f", error, total_error) + CALL check("H5Pclose_f", error, total_error) CALL H5Pclose_f(dapl2,error) - CALL check("H5Pclose_f", error, total_error) + CALL check("H5Pclose_f", error, total_error) CALL H5Pclose_f(dcpl,error) - CALL check("H5Pclose_f", error, total_error) + CALL check("H5Pclose_f", error, total_error) CALL H5Fclose_f(fid,error) CALL check("H5Fclose_f", error, total_error) diff --git a/fortran/test/tH5P_F03.F90 b/fortran/test/tH5P_F03.F90 index 88c581c..54980a7 100644 --- a/fortran/test/tH5P_F03.F90 +++ b/fortran/test/tH5P_F03.F90 @@ -5,7 +5,7 @@ ! ! FUNCTION ! Test FORTRAN HDF5 H5P APIs which are dependent on FORTRAN 2003 -! features. +! features. ! ! COPYRIGHT ! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @@ -40,35 +40,35 @@ MODULE test_genprop_cls_cb1_mod USE HDF5 USE ISO_C_BINDING IMPLICIT NONE - - TYPE, BIND(C) :: cop_cb_struct_ ! Struct for iterations + + TYPE, BIND(C) :: cop_cb_struct_ ! Struct for iterations INTEGER :: count INTEGER(HID_T) :: id END TYPE cop_cb_struct_ CONTAINS - + INTEGER FUNCTION test_genprop_cls_cb1_f(list_id, create_data ) bind(C) - + IMPLICIT NONE INTEGER(HID_T), INTENT(IN), VALUE :: list_id - + TYPE(cop_cb_struct_) :: create_data create_data%count = create_data%count + 1 create_data%id = list_id test_genprop_cls_cb1_f = 0 - + END FUNCTION test_genprop_cls_cb1_f END MODULE test_genprop_cls_cb1_mod MODULE TH5P_F03 - USE HDF5 - USE TH5_MISC + USE HDF5 + USE TH5_MISC USE TH5_MISC_GEN USE ISO_C_BINDING @@ -89,7 +89,7 @@ CONTAINS ! * Modifications: ! * ! *------------------------------------------------------------------------- -! +! SUBROUTINE test_create(total_error) @@ -116,9 +116,9 @@ SUBROUTINE test_create(total_error) ! ! * Create a file. - ! + ! CALL h5fcreate_f(filename,H5F_ACC_TRUNC_F,file,error) - CALL check("h5fcreate_f", error, total_error) + CALL check("h5fcreate_f", error, total_error) CALL h5screate_simple_f(5, cur_size, space, error, cur_size) CALL check("h5screate_simple_f", error, total_error) @@ -129,7 +129,7 @@ SUBROUTINE test_create(total_error) CALL h5pset_chunk_f(dcpl, 5, ch_size, error) CALL check("h5pset_chunk_f",error, total_error) - ! Create a compound datatype + ! Create a compound datatype CALL h5tcreate_f(H5T_COMPOUND_F, H5_SIZEOF(fill_ctype), comp_type_id, error) CALL check("h5tcreate_f", error, total_error) h5off = H5OFFSETOF(C_LOC(fill_ctype), C_LOC(fill_ctype%a)) @@ -150,7 +150,7 @@ SUBROUTINE test_create(total_error) CALL H5Pset_fill_time_f(dcpl, H5D_FILL_TIME_ALLOC_F, error) CALL check("H5Pset_fill_time_f",error, total_error) - ! Compound datatype test + ! Compound datatype test f_ptr = C_LOC(fill_ctype) @@ -205,7 +205,7 @@ SUBROUTINE test_create(total_error) CALL h5fclose_f(file,error) CALL check("h5fclose_f", error, total_error) - ! Open the file and get the dataset fill value from each dataset + ! Open the file and get the dataset fill value from each dataset CALL h5pcreate_f(H5P_FILE_ACCESS_F, fapl, error) CALL check("h5pcreate_f",error, total_error) @@ -245,7 +245,7 @@ SUBROUTINE test_create(total_error) CALL h5fopen_f (FILENAME, H5F_ACC_RDONLY_F, file, error, fapl) CALL check("h5fopen_f", error, total_error) - ! Compound datatype test + ! Compound datatype test CALL h5dopen_f(file, "dset9", dset9, error) CALL check("h5dopen_f", error, total_error) @@ -299,9 +299,9 @@ SUBROUTINE test_genprop_class_callback(total_error) INTEGER, INTENT(INOUT) :: total_error - INTEGER(hid_t) :: cid1, cid2 ! Generic Property class ID - INTEGER(hid_t) :: lid1, lid2 ! Generic Property list ID - INTEGER(size_t) :: nprops ! Number of properties in class + INTEGER(hid_t) :: cid1, cid2 ! Generic Property class ID + INTEGER(hid_t) :: lid1, lid2 ! Generic Property list ID + INTEGER(size_t) :: nprops ! Number of properties in class TYPE(cop_cb_struct_), TARGET :: crt_cb_struct, cls_cb_struct INTEGER :: CLASS1_NAME_SIZE = 7 ! length of class string @@ -322,7 +322,7 @@ SUBROUTINE test_genprop_class_callback(total_error) INTEGER :: PROP3_DEF_VALUE = 10 INTEGER :: PROP4_DEF_VALUE = 10 - INTEGER :: error ! Generic RETURN value + INTEGER :: error ! Generic RETURN value LOGICAL :: flag ! for tests f1 = C_FUNLOC(test_genprop_cls_cb1_f) @@ -331,45 +331,45 @@ SUBROUTINE test_genprop_class_callback(total_error) f2 = C_LOC(crt_cb_struct) f6 = C_LOC(cls_cb_struct) - ! Create a new generic class, derived from the root of the class hierarchy + ! Create a new generic class, derived from the root of the class hierarchy CALL h5pcreate_class_f(h5p_ROOT_F, CLASS1_NAME, cid1, error, f1, f2, c_null_funptr, c_null_ptr, f5, f6) CALL check("h5pcreate_class_f", error, total_error) - ! Insert first property into class (with no callbacks) + ! Insert first property into class (with no callbacks) CALL h5pregister_f(cid1, PROP1_NAME, PROP1_SIZE, PROP1_DEF_VALUE, error) CALL check("h5pregister_f", error, total_error) - ! Insert second property into class (with no callbacks) + ! Insert second property into class (with no callbacks) CALL h5pregister_f(cid1, PROP2_NAME, PROP2_SIZE, PROP2_DEF_VALUE, error) CALL check("h5pregister_f", error, total_error) - ! Insert third property into class (with no callbacks) + ! Insert third property into class (with no callbacks) CALL h5pregister_f(cid1, PROP3_NAME, PROP3_SIZE, PROP3_DEF_VALUE, error) CALL check("h5pregister_f", error, total_error) - ! Insert fourth property into class (with no callbacks) + ! Insert fourth property into class (with no callbacks) CALL h5pregister_f(cid1, PROP4_NAME, PROP4_SIZE, PROP4_DEF_VALUE, error) CALL check("h5pregister_f", error, total_error) - ! Check the number of properties in class + ! Check the number of properties in class CALL h5pget_nprops_f(cid1, nprops, error) CALL check("h5pget_nprops_f", error, total_error) CALL verify("h5pget_nprops_f", INT(nprops), 4, total_error) - ! Initialize class callback structs + ! Initialize class callback structs crt_cb_struct%count = 0 crt_cb_struct%id = -1 cls_cb_struct%count = 0 cls_cb_struct%id = -1 - ! Create a property list from the class + ! Create a property list from the class CALL h5pcreate_f(cid1, lid1, error) CALL check("h5pcreate_f", error, total_error) - ! Get the list's class + ! Get the list's class CALL H5Pget_class_f(lid1, cid2, error) CALL check("H5Pget_class_f", error, total_error) - ! Check that the list's class is correct + ! Check that the list's class is correct CALL H5Pequal_f(cid2, cid1, flag, error) CALL check("H5Pequal_f", error, total_error) CALL verify("H5Pequal_f", flag, .TRUE., total_error) @@ -382,41 +382,41 @@ SUBROUTINE test_genprop_class_callback(total_error) WRITE(*,*) 'Class names do not match! name=',CLASS1_NAME_BUF, 'CLASS1_NAME=',CLASS1_NAME total_error = total_error + 1 ENDIF - ! Close class + ! Close class CALL h5pclose_class_f(cid2, error) CALL check("h5pclose_class_f", error, total_error) - ! Verify that the creation callback occurred + ! Verify that the creation callback occurred CALL verify("h5pcreate_f", crt_cb_struct%count, 1, total_error) CALL verify("h5pcreate_f", crt_cb_struct%id, lid1, total_error) - ! Check the number of properties in list + ! Check the number of properties in list CALL h5pget_nprops_f(lid1,nprops, error) CALL check("h5pget_nprops_f", error, total_error) CALL verify("h5pget_nprops_f", INT(nprops), 4, total_error) - ! Create another property list from the class + ! Create another property list from the class CALL h5pcreate_f(cid1, lid2, error) CALL check("h5pcreate_f", error, total_error) - ! Verify that the creation callback occurred + ! Verify that the creation callback occurred CALL verify("h5pcreate_f", crt_cb_struct%count, 2, total_error) CALL verify("h5pcreate_f", crt_cb_struct%id, lid2, total_error) - ! Check the number of properties in list + ! Check the number of properties in list CALL h5pget_nprops_f(lid2,nprops, error) CALL check("h5pget_nprops_f", error, total_error) CALL verify("h5pget_nprops_f", INT(nprops), 4, total_error) - ! Close first list + ! Close first list CALL h5pclose_f(lid1, error); CALL check("h5pclose_f", error, total_error) - ! Verify that the close callback occurred + ! Verify that the close callback occurred CALL verify("h5pcreate_f", cls_cb_struct%count, 1, total_error) CALL verify("h5pcreate_f", cls_cb_struct%id, lid1, total_error) - ! Close second list + ! Close second list CALL h5pclose_f(lid2, error); CALL check("h5pclose_f", error, total_error) @@ -424,7 +424,7 @@ SUBROUTINE test_genprop_class_callback(total_error) CALL verify("h5pcreate_f", cls_cb_struct%count, 2, total_error) CALL verify("h5pcreate_f", cls_cb_struct%id, lid2, total_error) - ! Close class + ! Close class CALL h5pclose_class_f(cid1, error) CALL check("h5pclose_class_f", error, total_error) @@ -452,7 +452,7 @@ SUBROUTINE test_h5p_file_image(total_error) INTEGER, PARAMETER :: count = 10 INTEGER, DIMENSION(1:count), TARGET :: buffer INTEGER, DIMENSION(1:count), TARGET :: temp - INTEGER :: i + INTEGER :: i INTEGER(size_t) :: size INTEGER(size_t) :: temp_size INTEGER :: error ! error return value @@ -482,7 +482,7 @@ SUBROUTINE test_h5p_file_image(total_error) CALL h5pset_file_image_f(fapl_1, f_ptr, size, error) CALL check("h5pset_file_image_f", error, total_error) - + ! Get the same data back DO i = 1, count f_ptr1(i) = C_LOC(temp(i)) @@ -494,7 +494,7 @@ SUBROUTINE test_h5p_file_image(total_error) ! Check that sizes are the same, and that the buffers are identical but separate CALL verify("h5pget_file_image_f", INT(temp_size), INT(size), total_error) - + ! Verify the image data is correct DO i = 1, count CALL verify("h5pget_file_image_f", temp(i), buffer(i), total_error) @@ -522,18 +522,18 @@ SUBROUTINE external_test_offset(cleanup,total_error) LOGICAL, INTENT(IN) :: cleanup INTEGER(hid_t) :: fapl=-1 ! file access property list - INTEGER(hid_t) :: file=-1 ! file to write to - INTEGER(hid_t) :: dcpl=-1 ! dataset creation properties - INTEGER(hid_t) :: space=-1 ! data space - INTEGER(hid_t) :: dset=-1 ! dataset + INTEGER(hid_t) :: file=-1 ! file to write to + INTEGER(hid_t) :: dcpl=-1 ! dataset creation properties + INTEGER(hid_t) :: space=-1 ! data space + INTEGER(hid_t) :: dset=-1 ! dataset INTEGER(hid_t) :: grp=-1 ! group to emit diagnostics - INTEGER(size_t) :: i, j ! miscellaneous counters + INTEGER(size_t) :: i, j ! miscellaneous counters CHARACTER(LEN=180) :: filename ! file names INTEGER, DIMENSION(1:25) :: part - INTEGER, DIMENSION(1:100), TARGET :: whole ! raw data buffers - INTEGER(hsize_t), DIMENSION(1:1) :: cur_size ! current data space size - INTEGER(hid_t) :: hs_space ! hyperslab data space - INTEGER(hsize_t), DIMENSION(1:1) :: hs_start = (/30/) ! hyperslab starting offset + INTEGER, DIMENSION(1:100), TARGET :: whole ! raw data buffers + INTEGER(hsize_t), DIMENSION(1:1) :: cur_size ! current data space size + INTEGER(hid_t) :: hs_space ! hyperslab data space + INTEGER(hsize_t), DIMENSION(1:1) :: hs_start = (/30/) ! hyperslab starting offset INTEGER(hsize_t), DIMENSION(1:1) :: hs_count = (/25/) ! hyperslab size CHARACTER(LEN=1) :: ichr1 ! character conversion holder INTEGER :: error ! error status @@ -552,23 +552,23 @@ SUBROUTINE external_test_offset(cleanup,total_error) WRITE(ichr1,'(I1.1)') i filename = "extern_"//ichr1//"a.raw" OPEN(10, FILE=filename, ACCESS='STREAM', form='UNFORMATTED') - + WRITE(10) temparray(1:(i-1)*10) WRITE(10) part CLOSE(10) ENDDO ! - ! Create the file and an initial group. + ! Create the file and an initial group. CALL h5pcreate_f(H5P_FILE_ACCESS_F, fapl, error) CALL h5fcreate_f('extren_raw.h5', H5F_ACC_TRUNC_F, file, error, access_prp=fapl) CALL check("h5fcreate_f",error,total_error) - + CALL h5gcreate_f(file, "emit-diagnostics", grp, error) CALL check("h5gcreate_f",error, total_error) - + ! Create the dataset - sizeof_part = INT(H5_SIZEOF(part(1))*25, hsize_t) + sizeof_part = INT(H5_SIZEOF(part(1))*25, hsize_t) CALL h5pcreate_f(H5P_DATASET_CREATE_F, dcpl, error) CALL check("h5pcreate_f", error, total_error) @@ -580,7 +580,7 @@ SUBROUTINE external_test_offset(cleanup,total_error) CALL check("h5pset_external_f",error,total_error) CALL h5pset_external_f(dcpl, "extern_4a.raw", INT(30,off_t), sizeof_part, error) CALL check("h5pset_external_f",error,total_error) - + cur_size(1) = 100 CALL h5screate_simple_f(1, cur_size, space, error) CALL check("h5screate_simple_f", error, total_error) @@ -622,7 +622,7 @@ SUBROUTINE external_test_offset(cleanup,total_error) EXIT ENDIF ENDDO - + CALL h5dclose_f(dset, error) CALL check("h5dclose_f", error, total_error) CALL h5pclose_f(dcpl, error) @@ -671,12 +671,12 @@ SUBROUTINE test_vds(total_error) CHARACTER(LEN=3), PARAMETER :: DATASET="VDS" INTEGER(hsize_t) :: VDSDIM0 INTEGER(hsize_t), PARAMETER :: VDSDIM1 = 10 - INTEGER(hsize_t), PARAMETER :: VDSDIM2 = 15 + INTEGER(hsize_t), PARAMETER :: VDSDIM2 = 15 INTEGER(hsize_t) :: DIM0 INTEGER, PARAMETER :: DIM0_1= 4 ! Initial size of the source datasets - INTEGER, PARAMETER :: DIM1 = 10 - INTEGER, PARAMETER :: DIM2 = 15 + INTEGER, PARAMETER :: DIM1 = 10 + INTEGER, PARAMETER :: DIM2 = 15 INTEGER, PARAMETER :: RANK = 3 INTEGER(hsize_t), PARAMETER :: PLANE_STRIDE = 4 @@ -702,15 +702,15 @@ SUBROUTINE test_vds(total_error) src_count, block INTEGER(hsize_t), DIMENSION(1:2,1:3) :: vdsdims_out_correct - INTEGER(hsize_t), DIMENSION(1:3) :: start_out, & !Hyperslab PARAMETER out + INTEGER(hsize_t), DIMENSION(1:3) :: start_out, & !Hyperslab PARAMETER out stride_out, count_out, block_out INTEGER(hsize_t), DIMENSION(1:3,1:PLANE_STRIDE) :: start_correct INTEGER :: i, j - INTEGER(size_t) :: i_sz + INTEGER(size_t) :: i_sz INTEGER :: layout ! Storage layout - INTEGER(size_t) :: num_map ! Number of mappings - INTEGER(size_t) :: len ! Length of the string also a RETURN value + INTEGER(size_t) :: num_map ! Number of mappings + INTEGER(size_t) :: len ! Length of the string also a RETURN value ! Different sized character buffers CHARACTER(len=LEN(SRC_FILE(1))-3) :: SRC_FILE_LEN_TINY CHARACTER(len=LEN(SRC_FILE(1))-1) :: SRC_FILE_LEN_SMALL @@ -719,7 +719,7 @@ SUBROUTINE test_vds(total_error) CHARACTER(len=LEN(SRC_FILE(1))+10) :: SRC_FILE_LEN_HUGE CHARACTER(len=LEN(SRC_DATASET(1))) :: SRC_DATASET_LEN_EXACT - INTEGER(HID_T) :: space_out + INTEGER(HID_T) :: space_out INTEGER :: s_type, virtual_view INTEGER :: type1, type2 @@ -728,13 +728,13 @@ SUBROUTINE test_vds(total_error) TYPE(C_PTR) :: f_ptr INTEGER(SIZE_T) :: nsize LOGICAL :: IsRegular - INTEGER(HSIZE_T) :: gap_size + INTEGER(HSIZE_T) :: gap_size ! For testing against vdsdims_out_correct(1,1) = DIM0_1*5 vdsdims_out_correct(2,1) = DIM0_1*8 - vdsdims_out_correct(1:2,2) = VDSDIM1 - vdsdims_out_correct(1:2,3) = VDSDIM2 + vdsdims_out_correct(1:2,2) = VDSDIM1 + vdsdims_out_correct(1:2,3) = VDSDIM2 VDSDIM0 = H5S_UNLIMITED_F DIM0 = H5S_UNLIMITED_F @@ -742,7 +742,7 @@ SUBROUTINE test_vds(total_error) dims_max = (/INT(DIM0,hsize_t), INT(DIM1,hsize_t), INT(DIM2,hsize_t)/) ! - ! Create source files and datasets. + ! Create source files and datasets. ! DO i = 1, PLANE_STRIDE ! @@ -751,7 +751,7 @@ SUBROUTINE test_vds(total_error) wdata(j) = i ENDDO ! - ! Create the source files and datasets. Write data to each dataset and + ! Create the source files and datasets. Write data to each dataset and ! close all resources. CALL h5fcreate_f(SRC_FILE(i), H5F_ACC_TRUNC_F, file, error) CALL check("h5fcreate_f", error, total_error) @@ -762,7 +762,7 @@ SUBROUTINE test_vds(total_error) CALL check("h5pcreate_f", error, total_error) CALL h5pset_chunk_f(dcpl, RANK, chunk_dims, error) CALL check("h5pset_chunk_f",error, total_error) - + CALL h5dcreate_f(file, SRC_DATASET(i), H5T_NATIVE_INTEGER, src_space, dset, error, dcpl, H5P_DEFAULT_F, H5P_DEFAULT_F) CALL check("h5dcreate_f",error, total_error) f_ptr = C_LOC(wdata(1)) @@ -788,20 +788,20 @@ SUBROUTINE test_vds(total_error) ! Create dataspaces for the source dataset. CALL H5Screate_simple_f(RANK, dims, src_space, error, dims_max) CALL check("H5Screate_simple_f", error, total_error) - + ! Create VDS creation property CALL H5Pcreate_f (H5P_DATASET_CREATE_F, dcpl, error) CALL check("H5Pcreate_f", error, total_error) - - ! Initialize hyperslab values + + ! Initialize hyperslab values start(1:3) = 0 - stride(1:3) = (/PLANE_STRIDE,1_hsize_t,1_hsize_t/) ! we will select every fifth plane in VDS + stride(1:3) = (/PLANE_STRIDE,1_hsize_t,1_hsize_t/) ! we will select every fifth plane in VDS count(1:3) = (/H5S_UNLIMITED_F,1_hsize_t,1_hsize_t/) src_count(1:3) = (/H5S_UNLIMITED_F,1_hsize_t,1_hsize_t/) block(1:3) = (/1, DIM1, DIM2/) - - ! - ! Build the mappings + + ! + ! Build the mappings ! start_correct = 0 CALL H5Sselect_hyperslab_f(src_space, H5S_SELECT_SET_F, start, src_count, error, block=block) @@ -820,10 +820,10 @@ SUBROUTINE test_vds(total_error) start(1) = start(1) + 1 ENDDO - CALL H5Sselect_none_f(vspace, error) + CALL H5Sselect_none_f(vspace, error) CALL check("H5Sselect_none_f", error, total_error) - ! Create a virtual dataset + ! Create a virtual dataset CALL H5Dcreate_f(vfile, DATASET, H5T_NATIVE_INTEGER, vspace, vdset, error, dcpl, H5P_DEFAULT_F, H5P_DEFAULT_F) CALL check("H5Dcreate_f", error, total_error) CALL H5Sclose_f(vspace, error) @@ -833,9 +833,9 @@ SUBROUTINE test_vds(total_error) CALL H5Pclose_f(dcpl, error) CALL check("H5Pclose_f", error, total_error) - ! Let's add data to the source datasets and check new dimensions for VDS + ! Let's add data to the source datasets and check new dimensions for VDS ! We will add only one plane to the first source dataset, two planes to the - ! second one, three to the third, and four to the forth. + ! second one, three to the third, and four to the forth. DO i = 1, PLANE_STRIDE ! @@ -845,15 +845,15 @@ SUBROUTINE test_vds(total_error) ENDDO ! - ! Open the source files and datasets. Append data to each dataset and + ! Open the source files and datasets. Append data to each dataset and ! close all resources. CALL H5Fopen_f (SRC_FILE(i), H5F_ACC_RDWR_F, file, error) CALL check("H5Fopen_f", error, total_error) CALL H5Dopen_f (file, SRC_DATASET(i), dset, error) CALL check("H5Dopen_f", error, total_error) extdims(1) = DIM0_1+i - CALL H5Dset_extent_f(dset, extdims, error) - CALL check("H5Dset_extent_f", error, total_error) + CALL H5Dset_extent_f(dset, extdims, error) + CALL check("H5Dset_extent_f", error, total_error) CALL H5Dget_space_f(dset, src_space, error) CALL check("H5Dget_space_f", error, total_error) @@ -863,13 +863,13 @@ SUBROUTINE test_vds(total_error) memdims(1) = i - CALL H5Screate_simple_f(RANK, memdims, mem_space, error) + CALL H5Screate_simple_f(RANK, memdims, mem_space, error) CALL check("H5Screate_simple_f", error, total_error) - CALL H5Sselect_hyperslab_f(src_space, H5S_SELECT_SET_F, start,count, error,block=block) + CALL H5Sselect_hyperslab_f(src_space, H5S_SELECT_SET_F, start,count, error,block=block) CALL check("H5Sselect_hyperslab_f", error, total_error) f_ptr = C_LOC(wdata(1)) - CALL H5Dwrite_f(dset, H5T_NATIVE_INTEGER, f_ptr, error, mem_space, src_space, H5P_DEFAULT_F) + CALL H5Dwrite_f(dset, H5T_NATIVE_INTEGER, f_ptr, error, mem_space, src_space, H5P_DEFAULT_F) CALL check("H5Dwrite_f", error, total_error) CALL H5Sclose_f(src_space, error) CALL check("H5Sclose_f", error, total_error) @@ -881,38 +881,38 @@ SUBROUTINE test_vds(total_error) call H5Dclose_f(vdset, error) CALL check("H5Dclose_f", error, total_error) - call H5Fclose_f(vfile, error) + call H5Fclose_f(vfile, error) CALL check("H5Fclose_f", error, total_error) - + ! ! begin the read section ! ! Open file and dataset using the default properties. CALL H5Fopen_f(VFILENAME, H5F_ACC_RDONLY_F, vfile, error) - CALL check("H5Fopen_f", error, total_error) - - ! + CALL check("H5Fopen_f", error, total_error) + + ! ! Open VDS using different access properties to use max or ! min extents depending on the sizes of the underlying datasets CALL H5Pcreate_f(H5P_DATASET_ACCESS_F, dapl, error) - CALL check("H5Pcreate_f", error, total_error) + CALL check("H5Pcreate_f", error, total_error) DO i = 1, 2 IF(i.NE.1)THEN CALL H5Pset_virtual_view_f(dapl, H5D_VDS_LAST_AVAILABLE_F, error) - CALL check("H5Pset_virtual_view_f", error, total_error) + CALL check("H5Pset_virtual_view_f", error, total_error) ELSE CALL H5Pset_virtual_view_f(dapl, H5D_VDS_FIRST_MISSING_F, error) - CALL check("H5Pset_virtual_view_f", error, total_error) + CALL check("H5Pset_virtual_view_f", error, total_error) ENDIF - + CALL H5Dopen_f(vfile, DATASET, vdset, error, dapl) - CALL check("H5Dopen_f", error, total_error) + CALL check("H5Dopen_f", error, total_error) ! Let's get space of the VDS and its dimension we should get 32(or 20)x10x10 CALL H5Dget_space_f(vdset, vspace, error) - CALL check("H5Dget_space_f", error, total_error) + CALL check("H5Dget_space_f", error, total_error) CALL H5Sget_simple_extent_dims_f(vspace, vdsdims_out, vdsdims_max_out, error) CALL check("H5Sget_simple_extent_dims_f", error, total_error) @@ -920,12 +920,12 @@ SUBROUTINE test_vds(total_error) DO j = 1, RANK IF(vdsdims_out(j).NE.vdsdims_out_correct(i,j))THEN total_error = total_error + 1 - EXIT + EXIT ENDIF ENDDO CALL H5Pget_virtual_view_f(dapl, virtual_view, error) - CALL check("h5pget_virtual_view_f", error, total_error) + CALL check("h5pget_virtual_view_f", error, total_error) IF(i.EQ.1)THEN IF(virtual_view .NE. H5D_VDS_FIRST_MISSING_F)THEN @@ -935,10 +935,10 @@ SUBROUTINE test_vds(total_error) IF(virtual_view .NE. H5D_VDS_LAST_AVAILABLE_F)THEN total_error = total_error + 1 ENDIF - + ENDIF - ! Close + ! Close CALL H5Dclose_f(vdset, error) CALL check("H5Dclose_f", error, total_error) CALL H5Sclose_f(vspace, error) @@ -950,7 +950,7 @@ SUBROUTINE test_vds(total_error) ! ! Get creation property list and mapping properties. - ! + ! CALL H5Dget_create_plist_f (vdset, dcpl, error) CALL check("H5Dget_create_plist_f", error, total_error) @@ -966,7 +966,7 @@ SUBROUTINE test_vds(total_error) ! ! Find number of mappings. - + CALL H5Pget_virtual_count_f(dcpl, num_map, error) CALL check("H5Pget_virtual_count_f", error, total_error) @@ -974,7 +974,7 @@ SUBROUTINE test_vds(total_error) PRINT*,"Number of mappings is incorrect" total_error = total_error + 1 ENDIF - ! + ! ! Get mapping parameters for each mapping. ! DO i_sz = 1, num_map @@ -1098,7 +1098,7 @@ SUBROUTINE test_vds(total_error) PRINT*,"gapsize is incorrect" total_error = total_error + 1 ENDIF - + CALL H5Dclose_f(vdset, error) CALL check("H5Dclose_f", error, total_error) CALL H5Sclose_f(vspace, error) @@ -1107,7 +1107,7 @@ SUBROUTINE test_vds(total_error) CALL check("H5Pclose_f", error, total_error) CALL H5Fclose_f(vfile, error) CALL check("H5Fclose_f", error, total_error) - + END SUBROUTINE test_vds diff --git a/fortran/test/tH5R.F90 b/fortran/test/tH5R.F90 index f7cccfa..708d290 100644 --- a/fortran/test/tH5R.F90 +++ b/fortran/test/tH5R.F90 @@ -21,7 +21,7 @@ ! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ! ! NOTES -! Tests h5rcreate_f, h5rdereference_f, h5rget_name_f +! Tests h5rcreate_f, h5rdereference_f, h5rget_name_f ! and H5Rget_object_type functions ! ! CONTAINS SUBROUTINES @@ -262,20 +262,20 @@ SUBROUTINE refregtest(cleanup, total_error) INTEGER(HID_T) :: dsetv_id ! Dataset identifier INTEGER(HID_T) :: dsetr_id ! Dataset identifier INTEGER :: error -! TYPE(hdset_reg_ref_t_f) , DIMENSION(1:2), TARGET :: ref - TYPE(hdset_reg_ref_t_f) , DIMENSION(1:2) :: ref +! TYPE(hdset_reg_ref_t_f) , DIMENSION(1:2), TARGET :: ref + TYPE(hdset_reg_ref_t_f) , DIMENSION(1:2) :: ref TYPE(hdset_reg_ref_t_f) , DIMENSION(1:2) :: ref_out INTEGER(HSIZE_T), DIMENSION(2) :: ref_dim = (/0,0/) INTEGER(HSIZE_T), DIMENSION(2) :: data_dims ! = (/0,0/) INTEGER(HSIZE_T), DIMENSION(2) :: dims = (/2,9/) ! Datasets dimensions - INTEGER(HSIZE_T), DIMENSION(1) :: dimsr = (/2/) ! + INTEGER(HSIZE_T), DIMENSION(1) :: dimsr = (/2/) ! INTEGER(HSIZE_T), DIMENSION(2) :: start ! = (/0,0/) INTEGER(HSIZE_T), DIMENSION(2) :: count ! = (/0,0/) INTEGER :: rankr = 1 INTEGER :: rank = 2 -! INTEGER , DIMENSION(2,9), TARGET :: DATA - INTEGER , DIMENSION(2,9) :: DATA +! INTEGER , DIMENSION(2,9), TARGET :: DATA + INTEGER , DIMENSION(2,9) :: DATA INTEGER , DIMENSION(2,9) :: data_out = 0 INTEGER(HSIZE_T) , DIMENSION(2,3) :: coord INTEGER(SIZE_T) ::num_points = 3 ! Number of selected points @@ -353,7 +353,7 @@ SUBROUTINE refregtest(cleanup, total_error) CALL check("h5sselect_hyperslab_f", error, total_error) ref(1)%ref(:) = 0 ! f_ptr = C_LOC(ref(1)) -! CALL h5rcreate_f(file_id, dsetnamev, 1, space_id, f_ptr, error) +! CALL h5rcreate_f(file_id, dsetnamev, 1, space_id, f_ptr, error) CALL h5rcreate_f(file_id, dsetnamev, space_id, ref(1), error) CALL check("h5rcreate_f", error, total_error) diff --git a/fortran/test/tH5S.F90 b/fortran/test/tH5S.F90 index a4f5f4a..a839d8b 100644 --- a/fortran/test/tH5S.F90 +++ b/fortran/test/tH5S.F90 @@ -176,14 +176,14 @@ CONTAINS CALL check("h5sget_simple_extent_type_f", error, total_error) IF (classtype .NE. 1) write(*,*)"class type not H5S_SIMPLE_f" - ! + ! !set the copied space to none before extend the dimensions. ! CALL h5sset_extent_none_f(space2_id, error) CALL check("h5sset_extent_none_f", error, total_error) ! - !set the copied space to dim2 size. + !set the copied space to dim2 size. ! CALL h5sset_extent_simple_f(space2_id, rank2, dims2, maxdims2, error) CALL check("h5sset_extent_simple_f", error, total_error) diff --git a/fortran/test/tH5Sselect.F90 b/fortran/test/tH5Sselect.F90 index 8415bce..5f7ece7 100644 --- a/fortran/test/tH5Sselect.F90 +++ b/fortran/test/tH5Sselect.F90 @@ -26,12 +26,12 @@ ! h5sselect_none_f, h5sselect_valid_f, h5sselect_hyperslab_f, ! h5sget_select_bounds_f, h5sget_select_elem_pointlist_f, ! h5sget_select_elem_npoints_f, h5sget_select_hyper_blocklist_f, -! h5sget_select_hyper_nblocks_f, h5sget_select_npoints_f +! h5sget_select_hyper_nblocks_f, h5sget_select_npoints_f ! ! CONTAINS SUBROUTINES ! test_select_hyperslab, test_select_element, test_basic_select, ! test_select_point, test_select_combine, test_select_bounds -! +! ! !***** MODULE TH5SSELECT @@ -1033,12 +1033,12 @@ CONTAINS !*************************************************************** SUBROUTINE test_select_point(cleanup, total_error) - + IMPLICIT NONE LOGICAL, INTENT(IN) :: cleanup INTEGER, INTENT(INOUT) :: total_error INTEGER(HID_T) :: xfer_plist - + INTEGER, PARAMETER :: SPACE1_DIM1=3 INTEGER, PARAMETER :: SPACE1_DIM2=15 INTEGER, PARAMETER :: SPACE1_DIM3=13 @@ -1046,36 +1046,36 @@ SUBROUTINE test_select_point(cleanup, total_error) INTEGER, PARAMETER :: SPACE2_DIM2=26 INTEGER, PARAMETER :: SPACE3_DIM1=15 INTEGER, PARAMETER :: SPACE3_DIM2=26 - + INTEGER, PARAMETER :: SPACE1_RANK=3 INTEGER, PARAMETER :: SPACE2_RANK=2 INTEGER, PARAMETER :: SPACE3_RANK=2 - - ! Element selection information + + ! Element selection information INTEGER, PARAMETER :: POINT1_NPOINTS=10 - INTEGER(hid_t) ::fid1 ! HDF5 File IDs - INTEGER(hid_t) ::dataset ! Dataset ID - INTEGER(hid_t) ::sid1,sid2 ! Dataspace ID + INTEGER(hid_t) ::fid1 ! HDF5 File IDs + INTEGER(hid_t) ::dataset ! Dataset ID + INTEGER(hid_t) ::sid1,sid2 ! Dataspace ID INTEGER(hsize_t), DIMENSION(1:3) :: dims1 = (/SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3/) INTEGER(hsize_t), DIMENSION(1:2) :: dims2 = (/SPACE2_DIM1, SPACE2_DIM2/) INTEGER(hsize_t), DIMENSION(1:2) :: dims3 = (/SPACE3_DIM1, SPACE3_DIM2/) - - INTEGER(hsize_t), DIMENSION(1:SPACE1_RANK,1:POINT1_NPOINTS) :: coord1 ! Coordinates for point selection - INTEGER(hsize_t), DIMENSION(1:SPACE1_RANK,1:POINT1_NPOINTS) :: temp_coord1 ! Coordinates for point selection - INTEGER(hsize_t), DIMENSION(1:SPACE2_RANK,1:POINT1_NPOINTS) :: coord2 ! Coordinates for point selection - INTEGER(hsize_t), DIMENSION(1:SPACE2_RANK,1:POINT1_NPOINTS) :: temp_coord2 ! Coordinates for point selection - INTEGER(hsize_t), DIMENSION(1:SPACE3_RANK,1:POINT1_NPOINTS) :: coord3 ! Coordinates for point selection - INTEGER(hsize_t), DIMENSION(1:SPACE3_RANK,1:POINT1_NPOINTS) :: temp_coord3 ! Coordinates for point selection + + INTEGER(hsize_t), DIMENSION(1:SPACE1_RANK,1:POINT1_NPOINTS) :: coord1 ! Coordinates for point selection + INTEGER(hsize_t), DIMENSION(1:SPACE1_RANK,1:POINT1_NPOINTS) :: temp_coord1 ! Coordinates for point selection + INTEGER(hsize_t), DIMENSION(1:SPACE2_RANK,1:POINT1_NPOINTS) :: coord2 ! Coordinates for point selection + INTEGER(hsize_t), DIMENSION(1:SPACE2_RANK,1:POINT1_NPOINTS) :: temp_coord2 ! Coordinates for point selection + INTEGER(hsize_t), DIMENSION(1:SPACE3_RANK,1:POINT1_NPOINTS) :: coord3 ! Coordinates for point selection + INTEGER(hsize_t), DIMENSION(1:SPACE3_RANK,1:POINT1_NPOINTS) :: temp_coord3 ! Coordinates for point selection INTEGER(hssize_t) :: npoints -!!$ uint8_t *wbuf, buffer to write to disk -!!$ *rbuf, buffer read from disk -!!$ *tbuf; temporary buffer pointer - INTEGER :: i,j; ! Counters -! struct pnt_iter pi; Custom Pointer iterator struct - INTEGER :: error ! Generic return value +!!$ uint8_t *wbuf, buffer to write to disk +!!$ *rbuf, buffer read from disk +!!$ *tbuf; temporary buffer pointer + INTEGER :: i,j; ! Counters +! struct pnt_iter pi; Custom Pointer iterator struct + INTEGER :: error ! Generic return value CHARACTER(LEN=9) :: filename = 'h5s_hyper' - CHARACTER(LEN=80) :: fix_filename + CHARACTER(LEN=80) :: fix_filename CHARACTER(LEN=1), DIMENSION(1:SPACE2_DIM1,1:SPACE2_DIM2) :: wbuf CALL h5_fixname_f(filename, fix_filename, H5P_DEFAULT_F, error) @@ -1086,11 +1086,11 @@ SUBROUTINE test_select_point(cleanup, total_error) xfer_plist = H5P_DEFAULT_F ! MESSAGE(5, ("Testing Element Selection Functions\n")); - ! Allocate write & read buffers + ! Allocate write & read buffers !!$ wbuf = HDmalloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2); !!$ rbuf = HDcalloc(sizeof(uint8_t), (size_t)(SPACE3_DIM1 * SPACE3_DIM2)); !!$ - ! Initialize WRITE buffer + ! Initialize WRITE buffer DO i = 1, SPACE2_DIM1 DO j = 1, SPACE2_DIM2 @@ -1101,20 +1101,20 @@ SUBROUTINE test_select_point(cleanup, total_error) !!$ for(i=0, tbuf=wbuf; i>image<< dataset */ - has_attr = H5LT_find_attribute(did, "INTERLACE_MODE"); + if ((has_attr = H5LT_find_attribute(did, "INTERLACE_MODE")) < 0) + goto out; /* It exists, get it */ if(has_attr == 1) diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c index d63776d..a631533 100644 --- a/hl/src/H5LT.c +++ b/hl/src/H5LT.c @@ -1407,12 +1407,18 @@ find_dataset(hid_t loc_id, const char *name, const H5L_info2_t *linfo, void *op_ * *------------------------------------------------------------------------- */ - +/* H5Literate wants a non-const pointer but we have a const pointer in the API + * call. It's safe to ignore this because we control the callback, don't + * modify the op_data buffer (i.e.: dset_name) during the traversal, and the + * library never modifies that buffer. + */ +H5_GCC_DIAG_OFF(cast-qual) herr_t H5LTfind_dataset( hid_t loc_id, const char *dset_name ) { return H5Literate2(loc_id, H5_INDEX_NAME, H5_ITER_INC, 0, find_dataset, (void *)dset_name); } +H5_GCC_DIAG_ON(cast-qual) /*------------------------------------------------------------------------- * @@ -2032,12 +2038,18 @@ herr_t H5LTfind_attribute( hid_t loc_id, const char* attr_name ) * *------------------------------------------------------------------------- */ - +/* H5Aiterate wants a non-const pointer but we have a const pointer in the API + * call. It's safe to ignore this because we control the callback, don't + * modify the op_data buffer (i.e.: attr_name) during the traversal, and the + * library never modifies that buffer. + */ +H5_GCC_DIAG_OFF(cast-qual) herr_t H5LT_find_attribute( hid_t loc_id, const char* attr_name ) { return H5Aiterate2(loc_id, H5_INDEX_NAME, H5_ITER_INC, NULL, find_attr, (void *)attr_name); } +H5_GCC_DIAG_ON(cast-qual) /*------------------------------------------------------------------------- diff --git a/hl/src/H5LTanalyze.l b/hl/src/H5LTanalyze.l index f16455b..5015053 100644 --- a/hl/src/H5LTanalyze.l +++ b/hl/src/H5LTanalyze.l @@ -26,7 +26,6 @@ /* Turn off suggest const & malloc attribute warnings in gcc */ #if defined __GNUC__ && 402 <= __GNUC__ * 100 + __GNUC_MINOR__ #pragma GCC diagnostic ignored "-Wsuggest-attribute=const" -#pragma GCC diagnostic ignored "-Wsuggest-attribute=malloc" #endif int my_yyinput(char *, int); diff --git a/hl/test/test_file_image.c b/hl/test/test_file_image.c index fd2d0d2..504a3f5 100644 --- a/hl/test/test_file_image.c +++ b/hl/test/test_file_image.c @@ -467,7 +467,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) FAIL_PUTS_ERROR("H5Dclose() failed"); } /* end for */ - PASSED() + PASSED(); HL_TESTING2("close file images"); diff --git a/hl/tools/gif2h5/decompress.c b/hl/tools/gif2h5/decompress.c index 8cd8a8e..129fa60 100644 --- a/hl/tools/gif2h5/decompress.c +++ b/hl/tools/gif2h5/decompress.c @@ -57,12 +57,12 @@ GIFBYTE *Raster; /* The raster data stream, unblocked * /* The hash table used by the decompressor */ -int Prefix[4096]; -int Suffix[4096]; +int *Prefix; +int *Suffix; /* An output array used by the decompressor */ -int OutCode[1025]; +int *OutCode; /* The color map, read from the GIF header */ @@ -159,6 +159,19 @@ Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead) { int i; + if (!(Prefix = calloc(4096, sizeof(int)))) { + printf("Out of memory"); + exit(EXIT_FAILURE); + } + if (!(Suffix = calloc(4096, sizeof(int)))) { + printf("Out of memory"); + exit(EXIT_FAILURE); + } + if (!(OutCode = calloc(1024, sizeof(int)))) { + printf("Out of memory"); + exit(EXIT_FAILURE); + } + XC = 0; YC = 0; Pass = 0; @@ -309,5 +322,9 @@ Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead) Code = ReadCode(); } + free(Prefix); + free(Suffix); + free(OutCode); + return Image; } diff --git a/hl/tools/gif2h5/hdf2gif.c b/hl/tools/gif2h5/hdf2gif.c index e32facb..1833c92 100644 --- a/hl/tools/gif2h5/hdf2gif.c +++ b/hl/tools/gif2h5/hdf2gif.c @@ -18,8 +18,11 @@ #include "h5tools.h" #include "h5tools_utils.h" -#define IMAGE_WIDTH_MAX 65535 /* unsigned 16bits integer */ -#define IMAGE_HEIGHT_MAX 65535 /* unsigned 16bits integer */ +/* Name of tool */ +#define PROGRAMNAME "hdf2gif" + +#define IMAGE_WIDTH_MAX 65535 /* unsigned 16bits integer */ +#define IMAGE_HEIGHT_MAX 65535 /* unsigned 16bits integer */ int EndianOrder; @@ -42,12 +45,17 @@ usage(void) } +static void +leave(int ret) +{ + h5tools_close(); + HDexit(ret); +} + FILE *fpGif = NULL; int main(int argc , char **argv) { GIFBYTE *Image; - void *edata; - H5E_auto2_t func; /* compression structs */ GIFCHAR *HDFName = NULL; @@ -73,9 +81,8 @@ int main(int argc , char **argv) char *image_name = NULL; int idx; - /* Disable error reporting */ - H5Eget_auto2(H5E_DEFAULT, &func, &edata); - H5Eset_auto2(H5E_DEFAULT, NULL, NULL); + h5tools_setprogname(PROGRAMNAME); + h5tools_setstatus(EXIT_SUCCESS); /* Initialize h5tools lib */ h5tools_init(); @@ -83,8 +90,7 @@ int main(int argc , char **argv) if ( argv[1] && (strcmp("-V",argv[1])==0) ) { print_version("gif2h5"); - exit(EXIT_SUCCESS); - + h5tools_setstatus(EXIT_SUCCESS); } @@ -92,7 +98,7 @@ int main(int argc , char **argv) { /* they didn't supply at least one image -- bail */ usage(); - return EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); } HDFName = argv[1]; @@ -149,30 +155,41 @@ int main(int argc , char **argv) goto out; } - /* read image */ + /* get image's information */ if ( H5IMget_image_info( fid, image_name, &width, &height, &planes, interlace, &npals ) < 0 ) + { + fprintf(stderr , "Unable to get information of the image. Aborting.\n"); goto out; + } - if (width > IMAGE_WIDTH_MAX || height > IMAGE_HEIGHT_MAX){ - fprintf(stderr, "HDF5 image is too large. Limit is %d by %d.\n", IMAGE_WIDTH_MAX, IMAGE_HEIGHT_MAX); - goto out; - } + if (width > IMAGE_WIDTH_MAX || height > IMAGE_HEIGHT_MAX) + { + fprintf(stderr, "HDF5 image is too large. Limit is %d by %d.\n", IMAGE_WIDTH_MAX, IMAGE_HEIGHT_MAX); + goto out; + } - /* tool can handle single plane images only. */ - if (planes > 1){ - fprintf(stderr, "Cannot handle multiple planes image\n"); - goto out; - } + /* tool can handle single plane images only. */ + if (planes > 1) + { + fprintf(stderr, "Cannot handle multiple planes image\n"); + goto out; + } Image = (GIFBYTE*) malloc( (size_t) width * (size_t) height ); if ( H5IMread_image( fid, image_name, Image ) < 0 ) + { + fprintf(stderr , "Unable to read the image. Aborting.\n"); goto out; + } if (npals) { if ( H5IMget_palette_info( fid, image_name, 0, pal_dims ) < 0 ) + { + fprintf(stderr , "Unable to get information of the palette. Aborting.\n"); goto out; + } pal = (GIFBYTE*) malloc( (size_t) pal_dims[0] * (size_t) pal_dims[1] ); @@ -211,9 +228,9 @@ int main(int argc , char **argv) numcols = 256; for (i = 0 ; i < numcols ; i++) { - Red[i] = (GIFBYTE)(255 - i); - Green[i] = (GIFBYTE)(255 - i); - Blue[i] = (GIFBYTE)(255 - i); + Red[i] = (GIFBYTE)(255 - i); + Green[i] = (GIFBYTE)(255 - i); + Blue[i] = (GIFBYTE)(255 - i); } } else @@ -246,7 +263,7 @@ int main(int argc , char **argv) if (j==i) { /* wasn't found */ - pc2nc[i] = (GIFBYTE)nc; + pc2nc[i] = (GIFBYTE)nc; r1[nc] = Red[i]; g1[nc] = Green[i]; b1[nc] = Blue[i]; @@ -334,9 +351,7 @@ int main(int argc , char **argv) if (image_name != NULL) free(image_name); - H5Eset_auto2(H5E_DEFAULT, func, edata); - - return EXIT_SUCCESS; + leave(h5tools_getstatus()); out: @@ -346,7 +361,6 @@ out: if (image_name != NULL) free(image_name); - H5Eset_auto2(H5E_DEFAULT, func, edata); - - return EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); + leave(h5tools_getstatus()); } diff --git a/hl/tools/gif2h5/hdfgifwr.c b/hl/tools/gif2h5/hdfgifwr.c index ed3e9e9..d44ff7a 100644 --- a/hl/tools/gif2h5/hdfgifwr.c +++ b/hl/tools/gif2h5/hdfgifwr.c @@ -69,45 +69,6 @@ static void char_init(), char_out(), flush_char(); static byte pc2nc[256]; -/*************************************************************/ -int hdfWriteGIF(FILE *fp, byte *pic, int ptype, int w, int h, byte *rmap, - byte *gmap, byte *bmap, byte *pc2ncmap, int numcols, - int colorstyle, int BitsPerPixel) -{ - int InitCodeSize; - int i; - byte *pic8 = pic; - - /* Shut compiler up... */ - ptype=ptype; - rmap=rmap; - gmap=gmap; - bmap=bmap; - numcols=numcols; - colorstyle=colorstyle; - - for (i = 0; i < 256; i++) { - pc2nc[i] = pc2ncmap[i]; - } - - if (BitsPerPixel <= 1) - InitCodeSize = 2; - else - InitCodeSize = BitsPerPixel; - - if (!fp) { - fprintf(stderr, "WriteGIF: file not open for writing\n" ); - return (1); - } - - compress(InitCodeSize+1, fp, pic8, w*h); - - if (ferror(fp)) - return -1; - - return 0 ; -} - /***********************************************************************/ static unsigned long cur_accum = 0; static int cur_bits = 0; @@ -123,8 +84,8 @@ static int maxbits = XV_BITS; /* user settable max # bits/code */ static int maxcode; /* maximum code, given n_bits */ static int maxmaxcode = 1 << XV_BITS; /* NEVER generate this */ -static count_int htab [HSIZE]; -static unsigned short codetab [HSIZE]; +static count_int *htab; +static unsigned short *codetab; #define HashTabOf(i) htab[i] #define CodeTabOf(i) codetab[i] @@ -173,6 +134,57 @@ static FILE *g_outfile; static int ClearCode; static int EOFCode; +/*************************************************************/ +int hdfWriteGIF(FILE *fp, byte *pic, int ptype, int w, int h, byte *rmap, + byte *gmap, byte *bmap, byte *pc2ncmap, int numcols, + int colorstyle, int BitsPerPixel) +{ + int InitCodeSize; + int i; + byte *pic8 = pic; + + if (!(htab = calloc(HSIZE, sizeof(count_int)))) { + fprintf(stderr, "Out of memory"); + return 1; + } + if (!(codetab = calloc(HSIZE, sizeof(unsigned short)))) { + fprintf(stderr, "Out of memory"); + return 1; + } + + /* Shut compiler up... */ + ptype=ptype; + rmap=rmap; + gmap=gmap; + bmap=bmap; + numcols=numcols; + colorstyle=colorstyle; + + for (i = 0; i < 256; i++) { + pc2nc[i] = pc2ncmap[i]; + } + + if (BitsPerPixel <= 1) + InitCodeSize = 2; + else + InitCodeSize = BitsPerPixel; + + if (!fp) { + fprintf(stderr, "WriteGIF: file not open for writing\n"); + return 1; + } + + compress(InitCodeSize+1, fp, pic8, w*h); + + free(htab); + free(codetab); + + if (ferror(fp)) + return -1; + + return 0 ; +} + /********************************************************/ static void compress(int init_bits, FILE *outfile, byte *data, int len) { @@ -194,8 +206,6 @@ static void compress(int init_bits, FILE *outfile, byte *data, int len) /* initialize 'compress' globals */ maxbits = XV_BITS; maxmaxcode = 1<= 0) { HDfprintf(stdout, "Opened \"%s\" with %s driver.\n", fname, drivername); @@ -911,30 +912,37 @@ main(int argc, const char *argv[]) if(fid < 0) { error_msg("unable to open file \"%s\"\n", fname); - if(fname) HDfree(fname); - if(fapl >= 0) H5Pclose(fapl); - leave(EXIT_FAILURE); + h5tools_setstatus(EXIT_FAILURE); + goto done; } if(!dname) { error_msg("no dataset specified\n"); h5tools_setstatus(EXIT_FAILURE); - } else { + goto done; + } + else { *dname = '/'; x = dname; if((dname = HDstrdup(dname)) == NULL) { - error_msg("memory allocation failed (file %s:line %d)\n", - __FILE__, __LINE__); + error_msg("memory allocation failed (file %s:line %d)\n", __FILE__, __LINE__); h5tools_setstatus(EXIT_FAILURE); - } else { + goto done; + } + else { *x = '\0'; /* Validate dataset */ - if(check_dataset(fid, dname) < 0) + if(check_dataset(fid, dname) < 0) { h5tools_setstatus(EXIT_FAILURE); + goto done; + } /* Validate input "fields" */ - else if(g_list_of_fields && *g_list_of_fields) - if(process_cmpd_fields(fid, dname) < 0) + else if(g_list_of_fields && *g_list_of_fields) { + if(process_cmpd_fields(fid, dname) < 0) { h5tools_setstatus(EXIT_FAILURE); + goto done; + } + } } } @@ -943,15 +951,20 @@ main(int argc, const char *argv[]) if(monitor_dataset(fid, dname) < 0) h5tools_setstatus(EXIT_FAILURE); +done: /* Free spaces */ - if(fname) HDfree(fname); - if(dname) HDfree(dname); - if(g_list_of_fields) HDfree(g_list_of_fields); + if(fname) + HDfree(fname); + if(dname) + HDfree(dname); + if(g_list_of_fields) + HDfree(g_list_of_fields); if(g_listv) { H5LD_clean_vector(g_listv); HDfree(g_listv); } - if(g_dup_fields) HDfree(g_dup_fields); + if(g_dup_fields) + HDfree(g_dup_fields); /* Close the file access property list */ if(fapl >= 0 && H5Pclose(fapl) < 0) { @@ -960,12 +973,11 @@ main(int argc, const char *argv[]) } /* Close the file */ - if(H5Fclose(fid) < 0) { + if(fid >= 0 && H5Fclose(fid) < 0) { error_msg("unable to close file\n"); h5tools_setstatus(EXIT_FAILURE); } - H5Eset_auto2(H5E_DEFAULT, func, edata); /* exit */ leave(h5tools_getstatus()); } /* main() */ diff --git a/java/test/TestH5S.java b/java/test/TestH5S.java index 985342b..97c0b68 100644 --- a/java/test/TestH5S.java +++ b/java/test/TestH5S.java @@ -171,7 +171,7 @@ public class TestH5S { try { H5.H5Sset_extent_none(H5sid); read_type = H5.H5Sget_simple_extent_type(H5sid); - assertTrue("H5.H5Sget_simple_extent_type: "+read_type, HDF5Constants.H5S_NO_CLASS == read_type); + assertTrue("H5.H5Sget_simple_extent_type: "+read_type, HDF5Constants.H5S_NULL == read_type); } catch (Throwable err) { err.printStackTrace(); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1342376..39a9e3e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -231,6 +231,7 @@ set (H5FD_SOURCES ${HDF5_SRC_DIR}/H5FDhdfs.c ${HDF5_SRC_DIR}/H5FDint.c ${HDF5_SRC_DIR}/H5FDlog.c + ${HDF5_SRC_DIR}/H5FDmirror.c ${HDF5_SRC_DIR}/H5FDmpi.c ${HDF5_SRC_DIR}/H5FDmpio.c ${HDF5_SRC_DIR}/H5FDmulti.c @@ -238,6 +239,7 @@ set (H5FD_SOURCES ${HDF5_SRC_DIR}/H5FDs3comms.c ${HDF5_SRC_DIR}/H5FDsec2.c ${HDF5_SRC_DIR}/H5FDspace.c + ${HDF5_SRC_DIR}/H5FDsplitter.c ${HDF5_SRC_DIR}/H5FDstdio.c ${HDF5_SRC_DIR}/H5FDtest.c ${HDF5_SRC_DIR}/H5FDwindows.c @@ -249,6 +251,7 @@ set (H5FD_HDRS ${HDF5_SRC_DIR}/H5FDfamily.h ${HDF5_SRC_DIR}/H5FDhdfs.h ${HDF5_SRC_DIR}/H5FDlog.h + ${HDF5_SRC_DIR}/H5FDmirror.h ${HDF5_SRC_DIR}/H5FDmpi.h ${HDF5_SRC_DIR}/H5FDmpio.h ${HDF5_SRC_DIR}/H5FDmulti.h @@ -256,6 +259,7 @@ set (H5FD_HDRS ${HDF5_SRC_DIR}/H5FDros3.h ${HDF5_SRC_DIR}/H5FDs3comms.h ${HDF5_SRC_DIR}/H5FDsec2.h + ${HDF5_SRC_DIR}/H5FDsplitter.h ${HDF5_SRC_DIR}/H5FDstdio.h ${HDF5_SRC_DIR}/H5FDwindows.h ) diff --git a/src/H5.c b/src/H5.c index 2e8b992..31b8546 100644 --- a/src/H5.c +++ b/src/H5.c @@ -355,7 +355,9 @@ H5_term_library(void) pending += DOWN(Z); pending += DOWN(FD); pending += DOWN(VL); - pending += DOWN(PL); + /* Don't shut down the plugin code until all "pluggable" interfaces (Z, FD, PL) are shut down */ + if(pending == 0) + pending += DOWN(PL); /* Don't shut down the error code until other APIs which use it are shut down */ if(pending == 0) pending += DOWN(E); diff --git a/src/H5AC.c b/src/H5AC.c index 1756107..6972a31 100644 --- a/src/H5AC.c +++ b/src/H5AC.c @@ -136,14 +136,14 @@ static const H5AC_class_t *const H5AC_class_s[] = { /*------------------------------------------------------------------------- - * Function: H5AC_init + * Function: H5AC_init * - * Purpose: Initialize the interface from some other layer. + * Purpose: Initialize the interface from some other layer. * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Saturday, January 18, 2003 * *------------------------------------------------------------------------- @@ -162,13 +162,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5AC__init_package + * Function H5AC__init_package * - * Purpose: Initialize interface-specific information + * Purpose: Initialize interface-specific information * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, July 18, 2002 * *------------------------------------------------------------------------- @@ -198,15 +198,15 @@ H5AC__init_package(void) /*------------------------------------------------------------------------- - * Function: H5AC_term_package + * Function: H5AC_term_package * - * Purpose: Terminate this interface. + * Purpose: Terminate this interface. * - * Return: Success: Positive if anything was done that might - * affect other interfaces; zero otherwise. - * Failure: Negative. + * Return: Success: Positive if anything was done that might + * affect other interfaces; zero otherwise. + * Failure: Negative. * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, July 18, 2002 * *------------------------------------------------------------------------- @@ -284,7 +284,7 @@ herr_t H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr, H5AC_cache_image_config_t * image_config_ptr) { #ifdef H5_HAVE_PARALLEL - char prefix[H5C__PREFIX_LEN] = ""; + char prefix[H5C__PREFIX_LEN] = ""; H5AC_aux_t * aux_ptr = NULL; #endif /* H5_HAVE_PARALLEL */ struct H5C_cache_image_ctl_t int_ci_config = H5C__DEFAULT_CACHE_IMAGE_CTL; @@ -309,9 +309,9 @@ H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr, H5AC_cache_image_co #ifdef H5_HAVE_PARALLEL if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) { - MPI_Comm mpi_comm; - int mpi_rank; - int mpi_size; + MPI_Comm mpi_comm; + int mpi_rank; + int mpi_size; if(MPI_COMM_NULL == (mpi_comm = H5F_mpi_get_comm(f))) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't get MPI communicator") @@ -400,7 +400,7 @@ H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr, H5AC_cache_image_co #endif /* H5_HAVE_PARALLEL */ if(NULL == f->shared->cache) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed") + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed") #ifdef H5_HAVE_PARALLEL if(aux_ptr != NULL) @@ -561,12 +561,12 @@ done: * Function: H5AC_evict * * Purpose: Evict all entries except the pinned entries - * in the cache. + * in the cache. * * Return: Non-negative on success/Negative on failure * * Programmer: Vailin Choi - * Dec 2013 + * Dec 2013 * *------------------------------------------------------------------------- */ @@ -600,9 +600,9 @@ done: /*------------------------------------------------------------------------- * Function: H5AC_expunge_entry * - * Purpose: Expunge the target entry from the cache without writing it - * to disk even if it is dirty. The entry must not be either - * pinned or protected. + * Purpose: Expunge the target entry from the cache without writing it + * to disk even if it is dirty. The entry must not be either + * pinned or protected. * * Return: Non-negative on success/Negative on failure * @@ -643,13 +643,13 @@ done: /*------------------------------------------------------------------------- * Function: H5AC_flush * - * Purpose: Flush (and possibly destroy) the metadata cache associated - * with the specified file. + * Purpose: Flush (and possibly destroy) the metadata cache associated + * with the specified file. * - * If the cache contains protected entries, the function will - * fail, as protected entries cannot be flushed. However - * all unprotected entries should be flushed before the - * function returns failure. + * If the cache contains protected entries, the function will + * fail, as protected entries cannot be flushed. However + * all unprotected entries should be flushed before the + * function returns failure. * * Return: Non-negative on success/Negative on failure if there was a * request to flush all items and something was protected. @@ -701,15 +701,15 @@ done: * Function: H5AC_get_entry_status * * Purpose: Given a file address, determine whether the metadata - * cache contains an entry at that location. If it does, - * also determine whether the entry is dirty, protected, - * pinned, etc. and return that information to the caller - * in *status. + * cache contains an entry at that location. If it does, + * also determine whether the entry is dirty, protected, + * pinned, etc. and return that information to the caller + * in *status. * - * If the specified entry doesn't exist, set *status_ptr - * to zero. + * If the specified entry doesn't exist, set *status_ptr + * to zero. * - * On error, the value of *status is undefined. + * On error, the value of *status is undefined. * * Return: Non-negative on success/Negative on failure * @@ -721,14 +721,14 @@ done: herr_t H5AC_get_entry_status(const H5F_t *f, haddr_t addr, unsigned *status) { - hbool_t in_cache; /* Entry @ addr is in the cache */ - hbool_t is_dirty; /* Entry @ addr is in the cache and dirty */ - hbool_t is_protected; /* Entry @ addr is in the cache and protected */ - hbool_t is_pinned; /* Entry @ addr is in the cache and pinned */ - hbool_t is_corked; - hbool_t is_flush_dep_child; /* Entry @ addr is in the cache and is a flush dependency child */ - hbool_t is_flush_dep_parent; /* Entry @ addr is in the cache and is a flush dependency parent */ - hbool_t image_is_up_to_date; /* Entry @ addr is in the cache and has an up to date image */ + hbool_t in_cache; /* Entry @ addr is in the cache */ + hbool_t is_dirty; /* Entry @ addr is in the cache and dirty */ + hbool_t is_protected; /* Entry @ addr is in the cache and protected */ + hbool_t is_pinned; /* Entry @ addr is in the cache and pinned */ + hbool_t is_corked; + hbool_t is_flush_dep_child; /* Entry @ addr is in the cache and is a flush dependency child */ + hbool_t is_flush_dep_parent; /* Entry @ addr is in the cache and is a flush dependency parent */ + hbool_t image_is_up_to_date; /* Entry @ addr is in the cache and has an up to date image */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -741,21 +741,21 @@ H5AC_get_entry_status(const H5F_t *f, haddr_t addr, unsigned *status) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_get_entry_status() failed") if(in_cache) { - *status |= H5AC_ES__IN_CACHE; - if(is_dirty) - *status |= H5AC_ES__IS_DIRTY; - if(is_protected) - *status |= H5AC_ES__IS_PROTECTED; - if(is_pinned) - *status |= H5AC_ES__IS_PINNED; - if(is_corked) - *status |= H5AC_ES__IS_CORKED; - if(is_flush_dep_parent) - *status |= H5AC_ES__IS_FLUSH_DEP_PARENT; - if(is_flush_dep_child) - *status |= H5AC_ES__IS_FLUSH_DEP_CHILD; - if(image_is_up_to_date) - *status |= H5AC_ES__IMAGE_IS_UP_TO_DATE; + *status |= H5AC_ES__IN_CACHE; + if(is_dirty) + *status |= H5AC_ES__IS_DIRTY; + if(is_protected) + *status |= H5AC_ES__IS_PROTECTED; + if(is_pinned) + *status |= H5AC_ES__IS_PINNED; + if(is_corked) + *status |= H5AC_ES__IS_CORKED; + if(is_flush_dep_parent) + *status |= H5AC_ES__IS_FLUSH_DEP_PARENT; + if(is_flush_dep_child) + *status |= H5AC_ES__IS_FLUSH_DEP_CHILD; + if(image_is_up_to_date) + *status |= H5AC_ES__IMAGE_IS_UP_TO_DATE; } /* end if */ else *status = 0; @@ -875,8 +875,8 @@ done: /*------------------------------------------------------------------------- * Function: H5AC_mark_entry_dirty * - * Purpose: Mark a pinned or protected entry as dirty. The target - * entry MUST be either pinned, protected, or both. + * Purpose: Mark a pinned or protected entry as dirty. The target + * entry MUST be either pinned, protected, or both. * * Return: Non-negative on success/Negative on failure * @@ -929,8 +929,8 @@ done: /*------------------------------------------------------------------------- * Function: H5AC_mark_entry_clean * - * Purpose: Mark a pinned entry as clean. The target - * entry MUST be pinned. + * Purpose: Mark a pinned entry as clean. The target + * entry MUST be pinned. * * Return: Non-negative on success/Negative on failure * @@ -982,8 +982,8 @@ done: /*------------------------------------------------------------------------- * Function: H5AC_mark_entry_unserialized * - * Purpose: Mark a pinned or protected entry as unserialized. The target - * entry MUST be either pinned, protected, or both. + * Purpose: Mark a pinned or protected entry as unserialized. The target + * entry MUST be either pinned, protected, or both. * * Return: Non-negative on success/Negative on failure * @@ -1024,8 +1024,8 @@ done: /*------------------------------------------------------------------------- * Function: H5AC_mark_entry_serialized * - * Purpose: Mark a pinned entry as serialized. The target - * entry MUST be pinned. + * Purpose: Mark a pinned entry as serialized. The target + * entry MUST be pinned. * * Return: Non-negative on success/Negative on failure * @@ -1124,7 +1124,7 @@ done: /*------------------------------------------------------------------------- * Function: H5AC_pin_protected_entry() * - * Purpose: Pin a protected cache entry. The entry must be protected + * Purpose: Pin a protected cache entry. The entry must be protected * at the time of call, and must be unpinned. * * Return: Non-negative on success/Negative on failure @@ -1205,7 +1205,7 @@ done: /*------------------------------------------------------------------------- * Function: H5AC_create_flush_dependency() * - * Purpose: Create a flush dependency between two entries in the metadata + * Purpose: Create a flush dependency between two entries in the metadata * cache. * * Return: Non-negative on success/Negative on failure @@ -1250,16 +1250,16 @@ done: * Function: H5AC_protect * * Purpose: If the target entry is not in the cache, load it. If - * necessary, attempt to evict one or more entries to keep - * the cache within its maximum size. + * necessary, attempt to evict one or more entries to keep + * the cache within its maximum size. * - * Mark the target entry as protected, and return its address - * to the caller. The caller must call H5AC_unprotect() when - * finished with the entry. + * Mark the target entry as protected, and return its address + * to the caller. The caller must call H5AC_unprotect() when + * finished with the entry. * - * While it is protected, the entry may not be either evicted - * or flushed -- nor may it be accessed by another call to - * H5AC_protect. Any attempt to do so will result in a failure. + * While it is protected, the entry may not be either evicted + * or flushed -- nor may it be accessed by another call to + * H5AC_protect. Any attempt to do so will result in a failure. * * Return: Success: Ptr to the object. * Failure: NULL @@ -1301,7 +1301,7 @@ H5AC_protect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *udata, /* Check for invalid access request */ if((0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) && (0 == (flags & H5C__READ_ONLY_FLAG))) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "no write intent on file") + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "no write intent on file") #if H5AC_DO_TAGGING_SANITY_CHECKS if(!H5C_get_ignore_tags(f->shared->cache) && H5AC__verify_tag(type) < 0) @@ -1331,7 +1331,7 @@ done: /*------------------------------------------------------------------------- * Function: H5AC_resize_entry * - * Purpose: Resize a pinned or protected entry. + * Purpose: Resize a pinned or protected entry. * * Return: Non-negative on success/Negative on failure * @@ -1384,8 +1384,8 @@ done: /*------------------------------------------------------------------------- * Function: H5AC_unpin_entry() * - * Purpose: Unpin a cache entry. The entry must be unprotected at - * the time of call, and must be pinned. + * Purpose: Unpin a cache entry. The entry must be unprotected at + * the time of call, and must be pinned. * * Return: Non-negative on success/Negative on failure * @@ -1427,7 +1427,7 @@ done: /*------------------------------------------------------------------------- * Function: H5AC_destroy_flush_dependency() * - * Purpose: Destroy a flush dependency between two entries. + * Purpose: Destroy a flush dependency between two entries. * * Return: Non-negative on success/Negative on failure * @@ -1470,27 +1470,27 @@ done: /*------------------------------------------------------------------------- * Function: H5AC_unprotect * - * Purpose: Undo an H5AC_protect() call -- specifically, mark the - * entry as unprotected, remove it from the protected list, - * and give it back to the replacement policy. + * Purpose: Undo an H5AC_protect() call -- specifically, mark the + * entry as unprotected, remove it from the protected list, + * and give it back to the replacement policy. * - * The TYPE and ADDR arguments must be the same as those in - * the corresponding call to H5AC_protect() and the THING - * argument must be the value returned by that call to - * H5AC_protect(). + * The TYPE and ADDR arguments must be the same as those in + * the corresponding call to H5AC_protect() and the THING + * argument must be the value returned by that call to + * H5AC_protect(). * - * If the deleted flag is TRUE, simply remove the target entry - * from the cache, clear it, and free it without writing it to - * disk. + * If the deleted flag is TRUE, simply remove the target entry + * from the cache, clear it, and free it without writing it to + * disk. * - * This version of the function is a complete re-write to - * use the new metadata cache. While there isn't all that - * much difference between the old and new Purpose sections, - * the original version is given below. + * This version of the function is a complete re-write to + * use the new metadata cache. While there isn't all that + * much difference between the old and new Purpose sections, + * the original version is given below. * - * Original purpose section: + * Original purpose section: * - * This function should be called to undo the effect of + * This function should be called to undo the effect of * H5AC_protect(). The TYPE and ADDR arguments should be the * same as the corresponding call to H5AC_protect() and the * THING argument should be the value returned by H5AC_protect(). @@ -1509,8 +1509,8 @@ herr_t H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, unsigned flags) { - hbool_t dirtied; - hbool_t deleted; + hbool_t dirtied; + hbool_t deleted; #ifdef H5_HAVE_PARALLEL H5AC_aux_t * aux_ptr = NULL; #endif /* H5_HAVE_PARALLEL */ @@ -1531,14 +1531,14 @@ H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, HDassert( ((H5AC_info_t *)thing)->type == type ); dirtied = (hbool_t)(((flags & H5AC__DIRTIED_FLAG) == H5AC__DIRTIED_FLAG) || - (((H5AC_info_t *)thing)->dirtied)); + (((H5AC_info_t *)thing)->dirtied)); deleted = (hbool_t)((flags & H5C__DELETED_FLAG) == H5C__DELETED_FLAG); /* Check if the size changed out from underneath us, if we're not deleting * the entry. */ if(dirtied && !deleted) { - size_t curr_size = 0; + size_t curr_size = 0; if((type->image_len)(thing, &curr_size) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGETSIZE, FAIL, "Can't get size of thing") @@ -1625,7 +1625,7 @@ H5AC_get_cache_auto_resize_config(const H5AC_t *cache_ptr, if(internal_config.rpt_fcn == NULL) config_ptr->rpt_fcn_enabled = FALSE; else - config_ptr->rpt_fcn_enabled = TRUE; + config_ptr->rpt_fcn_enabled = TRUE; config_ptr->open_trace_file = FALSE; config_ptr->close_trace_file = FALSE; config_ptr->trace_file_name[0] = '\0'; @@ -1658,12 +1658,12 @@ H5AC_get_cache_auto_resize_config(const H5AC_t *cache_ptr, if(NULL != (aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr))) { config_ptr->dirty_bytes_threshold = aux_ptr->dirty_bytes_threshold; - config_ptr->metadata_write_strategy = aux_ptr->metadata_write_strategy; + config_ptr->metadata_write_strategy = aux_ptr->metadata_write_strategy; } /* end if */ else { #endif /* H5_HAVE_PARALLEL */ config_ptr->dirty_bytes_threshold = H5AC__DEFAULT_DIRTY_BYTES_THRESHOLD; - config_ptr->metadata_write_strategy = H5AC__DEFAULT_METADATA_WRITE_STRATEGY; + config_ptr->metadata_write_strategy = H5AC__DEFAULT_METADATA_WRITE_STRATEGY; #ifdef H5_HAVE_PARALLEL } /* end else */ } @@ -1800,7 +1800,7 @@ herr_t H5AC_set_cache_auto_resize_config(H5AC_t *cache_ptr, H5AC_cache_config_t *config_ptr) { H5C_auto_size_ctl_t internal_config; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1880,16 +1880,16 @@ done: * Function: H5AC_validate_config() * * Purpose: Run a sanity check on the contents of the supplied - * instance of H5AC_cache_config_t. + * instance of H5AC_cache_config_t. * * Do nothing and return SUCCEED if no errors are detected, * and flag an error and return FAIL otherwise. * - * At present, this function operates by packing the data - * from the instance of H5AC_cache_config_t into an instance - * of H5C_auto_size_ctl_t, and then calling - * H5C_validate_resize_config(). As H5AC_cache_config_t and - * H5C_auto_size_ctl_t diverge, we may have to change this. + * At present, this function operates by packing the data + * from the instance of H5AC_cache_config_t into an instance + * of H5C_auto_size_ctl_t, and then calling + * H5C_validate_resize_config(). As H5AC_cache_config_t and + * H5C_auto_size_ctl_t diverge, we may have to change this. * * Return: Non-negative on success/Negative on failure * @@ -1914,7 +1914,7 @@ H5AC_validate_config(H5AC_cache_config_t *config_ptr) /* don't bother to test trace_file_name unless open_trace_file is TRUE */ if(config_ptr->open_trace_file) { - size_t name_len; + size_t name_len; /* Can't really test the trace_file_name field without trying to * open the file, so we will content ourselves with a couple of @@ -1957,17 +1957,17 @@ done: * Function: H5AC_validate_cache_image_config() * * Purpose: Run a sanity check on the contents of the supplied - * instance of H5AC_cache_image_config_t. + * instance of H5AC_cache_image_config_t. * * Do nothing and return SUCCEED if no errors are detected, * and flag an error and return FAIL otherwise. * - * At present, this function operates by packing the data - * from the instance of H5AC_cache_image_config_t into an - * instance of H5C_cache_image_ctl_t, and then calling - * H5C_validate_cache_image_config(). If and when + * At present, this function operates by packing the data + * from the instance of H5AC_cache_image_config_t into an + * instance of H5C_cache_image_ctl_t, and then calling + * H5C_validate_cache_image_config(). If and when * H5AC_cache_image_config_t and H5C_cache_image_ctl_t - * diverge, we may have to change this. + * diverge, we may have to change this. * * Return: Non-negative on success/Negative on failure * @@ -2013,13 +2013,13 @@ done: * Function: H5AC__check_if_write_permitted * * Purpose: Determine if a write is permitted under the current - * circumstances, and set *write_permitted_ptr accordingly. - * As a general rule it is, but when we are running in parallel - * mode with collective I/O, we must ensure that a read cannot - * cause a write. + * circumstances, and set *write_permitted_ptr accordingly. + * As a general rule it is, but when we are running in parallel + * mode with collective I/O, we must ensure that a read cannot + * cause a write. * - * In the event of failure, the value of *write_permitted_ptr - * is undefined. + * In the event of failure, the value of *write_permitted_ptr + * is undefined. * * Return: Non-negative on success/Negative on failure. * @@ -2035,9 +2035,9 @@ H5_ATTR_UNUSED *f, hbool_t *write_permitted_ptr) { #ifdef H5_HAVE_PARALLEL - H5AC_aux_t * aux_ptr = NULL; + H5AC_aux_t * aux_ptr = NULL; #endif /* H5_HAVE_PARALLEL */ - hbool_t write_permitted = TRUE; + hbool_t write_permitted = TRUE; FUNC_ENTER_STATIC_NOERR @@ -2051,9 +2051,9 @@ H5_ATTR_UNUSED HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); if((aux_ptr->mpi_rank == 0) || (aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED)) - write_permitted = aux_ptr->write_permitted; + write_permitted = aux_ptr->write_permitted; else - write_permitted = FALSE; + write_permitted = FALSE; } /* end if */ #endif /* H5_HAVE_PARALLEL */ @@ -2067,12 +2067,12 @@ H5_ATTR_UNUSED * Function: H5AC__ext_config_2_int_config() * * Purpose: Utility function to translate an instance of - * H5AC_cache_config_t to an instance of H5C_auto_size_ctl_t. + * H5AC_cache_config_t to an instance of H5C_auto_size_ctl_t. * - * Places translation in *int_conf_ptr and returns SUCCEED - * if successful. Returns FAIL on failure. + * Places translation in *int_conf_ptr and returns SUCCEED + * if successful. Returns FAIL on failure. * - * Does only minimal sanity checking. + * Does only minimal sanity checking. * * Return: Non-negative on success/Negative on failure * @@ -2453,7 +2453,7 @@ done: * Purpose: Given a file address, retrieve the ring for an entry at that * address. * - * On error, the value of *ring is not modified. + * On error, the value of *ring is not modified. * * Return: Non-negative on success/Negative on failure * @@ -2531,11 +2531,11 @@ H5AC_set_ring(H5AC_ring_t ring, H5AC_ring_t *orig_ring) * are in the process of a file shutdown, post an error * message, and return FAIL. * - * Note that this function simply passes the call on to - * the metadata cache proper, and returns the result. + * Note that this function simply passes the call on to + * the metadata cache proper, and returns the result. * - * Return: Success: Non-negative - * Failure: Negative + * Return: Success: Non-negative + * Failure: Negative * * Programmer: Quincey Koziol * September 17, 2016 @@ -2608,7 +2608,7 @@ done: * Function: H5AC_remove_entry() * * Purpose: Remove an entry from the cache. Must be not protected, pinned, - * dirty, involved in flush dependencies, etc. + * dirty, involved in flush dependencies, etc. * * Return: Non-negative on success/Negative on failure * @@ -2669,3 +2669,4 @@ H5AC_get_mdc_image_info(H5AC_t *cache_ptr, haddr_t *image_addr, hsize_t *image_l done: FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_get_mdc_image_info() */ + diff --git a/src/H5Adense.c b/src/H5Adense.c index a73fcc6..fd92e8f 100644 --- a/src/H5Adense.c +++ b/src/H5Adense.c @@ -171,7 +171,6 @@ typedef struct H5A_bt2_ud_rmbi_t { * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Dec 4 2006 * *------------------------------------------------------------------------- @@ -290,9 +289,8 @@ done: * * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Dec 11 2006 + * Programmer: Quincey Koziol + * Dec 11 2006 * *------------------------------------------------------------------------- */ @@ -351,9 +349,8 @@ done: * * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Dec 11 2006 + * Programmer: Quincey Koziol + * Dec 11 2006 * *------------------------------------------------------------------------- */ @@ -440,9 +437,8 @@ done: * * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Dec 4 2006 + * Programmer: Quincey Koziol + * Dec 4 2006 * *------------------------------------------------------------------------- */ @@ -598,7 +594,7 @@ done: * * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Tuesday, February 20, 2007 * *------------------------------------------------------------------------- @@ -632,7 +628,7 @@ H5A__dense_write_bt2_cb2(void *_record, void *_op_data, hbool_t *changed) * * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Tuesday, December 5, 2006 * *------------------------------------------------------------------------- @@ -743,9 +739,8 @@ done: * * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Dec 4 2006 + * Programmer: Quincey Koziol + * Dec 4 2006 * *------------------------------------------------------------------------- */ @@ -840,9 +835,8 @@ done: * * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Dec 5 2006 + * Programmer: Quincey Koziol + * Dec 5 2006 * *------------------------------------------------------------------------- */ @@ -883,9 +877,8 @@ done: * * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Jan 3 2007 + * Programmer: Quincey Koziol + * Jan 3 2007 * *------------------------------------------------------------------------- */ @@ -1065,9 +1058,8 @@ done: * * Return: H5_ITER_ERROR/H5_ITER_CONT/H5_ITER_STOP * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Dec 5 2006 + * Programmer: Quincey Koziol + * Dec 5 2006 * *------------------------------------------------------------------------- */ @@ -1161,9 +1153,8 @@ done: * * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Dec 5 2006 + * Programmer: Quincey Koziol + * Dec 5 2006 * *------------------------------------------------------------------------- */ @@ -1296,9 +1287,8 @@ done: * * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Dec 11 2006 + * Programmer: Quincey Koziol + * Dec 11 2006 * *------------------------------------------------------------------------- */ @@ -1360,9 +1350,8 @@ done: * * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Dec 11 2006 + * Programmer: Quincey Koziol + * Dec 11 2006 * *------------------------------------------------------------------------- */ @@ -1448,9 +1437,8 @@ done: * * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Feb 14 2007 + * Programmer: Quincey Koziol + * Feb 14 2007 * *------------------------------------------------------------------------- */ @@ -1574,9 +1562,8 @@ done: * * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Feb 14 2007 + * Programmer: Quincey Koziol + * Feb 14 2007 * *------------------------------------------------------------------------- */ @@ -1702,9 +1689,8 @@ done: * * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Dec 11 2006 + * Programmer: Quincey Koziol + * Dec 11 2006 * *------------------------------------------------------------------------- */ @@ -1788,9 +1774,8 @@ done: * * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Jan 3 2007 + * Programmer: Quincey Koziol + * Jan 3 2007 * *------------------------------------------------------------------------- */ @@ -1852,9 +1837,8 @@ done: * * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Dec 6 2006 + * Programmer: Quincey Koziol + * Dec 6 2006 * *------------------------------------------------------------------------- */ diff --git a/src/H5Aint.c b/src/H5Aint.c index 2f772a0..1e9989d 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -121,10 +121,10 @@ const unsigned H5O_attr_ver_bounds[] = { /* Local Variables */ /*******************/ -typedef H5A_t* H5A_t_ptr; +typedef H5A_t* H5A_t_ptr; H5FL_SEQ_DEFINE(H5A_t_ptr); - + /*------------------------------------------------------------------------- * Function: H5A__create * @@ -287,16 +287,16 @@ done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* H5A__create() */ - + /*------------------------------------------------------------------------- * Function: H5A__create_by_name * - * Purpose: Create an attribute on object, according to it's name + * Purpose: Create an attribute on object, according to it's name * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol - * December 6, 2017 + * Programmer: Quincey Koziol + * December 6, 2017 * *------------------------------------------------------------------------- */ @@ -305,8 +305,8 @@ H5A__create_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr const H5T_t *type, const H5S_t *space, hid_t acpl_id) { H5G_loc_t obj_loc; /* Location used to open group */ - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ H5A_t *attr = NULL; /* Attribute from object header */ H5A_t *ret_value = NULL; /* Return value */ @@ -348,22 +348,21 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5A__create_by_name() */ - + /*------------------------------------------------------------------------- * Function: H5A__open_common * - * Purpose: - * Finishes initializing an attributes the open + * Purpose: Finishes initializing an attributes the open * * Usage: * herr_t H5A__open_common(loc, name) * const H5G_loc_t *loc; IN: Pointer to group location for object * H5A_t *attr; IN/OUT: Pointer to attribute to initialize * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol - * December 18, 2006 + * Programmer: Quincey Koziol + * December 18, 2006 * *------------------------------------------------------------------------- */ @@ -405,7 +404,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5A__open_common() */ - + /*------------------------------------------------------------------------- * Function: H5A__open * @@ -450,13 +449,13 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5A__open() */ - + /*------------------------------------------------------------------------- * Function: H5A__open_by_idx * * Purpose: Open an attribute according to its index order * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * April 2, 1998 @@ -514,7 +513,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5A__open_by_idx() */ - + /*------------------------------------------------------------------------- * Function: H5A__open_by_name * @@ -578,7 +577,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5A__open_by_name() */ - + /*-------------------------------------------------------------------------- NAME H5A__read @@ -680,12 +679,12 @@ done: if(tconv_buf) tconv_buf = H5FL_BLK_FREE(attr_buf, tconv_buf); if(bkg_buf) - bkg_buf = H5FL_BLK_FREE(attr_buf, bkg_buf); + bkg_buf = H5FL_BLK_FREE(attr_buf, bkg_buf); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* H5A__read() */ - + /*-------------------------------------------------------------------------- NAME H5A__write @@ -799,7 +798,7 @@ done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* H5A__write() */ - + /*-------------------------------------------------------------------------- NAME H5A__get_name @@ -820,7 +819,7 @@ ssize_t H5A__get_name(H5A_t *attr, size_t buf_size, char *buf) { size_t copy_len, nbytes; - ssize_t ret_value = -1; /* Return value */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -845,7 +844,7 @@ H5A__get_name(H5A_t *attr, size_t buf_size, char *buf) FUNC_LEAVE_NOAPI(ret_value) } /* H5A__get_name() */ - + /*------------------------------------------------------------------------- * Function: H5A_get_space * @@ -882,14 +881,13 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A_get_space() */ - + /*------------------------------------------------------------------------- * Function: H5A__get_type * * Purpose: Returns an ID for the datatype of an attribute * * Return: Success: A valid ID for the datatype of an attribute - * * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- @@ -945,7 +943,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__get_type() */ - + /*-------------------------------------------------------------------------- NAME H5A__get_create_plist @@ -977,7 +975,7 @@ H5A__get_create_plist(H5A_t* attr) /* Create the property list object to return */ if((new_plist_id = H5P_copy_plist(plist, TRUE)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to copy attribute creation properties") + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to copy attribute creation properties") if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_plist_id))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "can't get property list") @@ -991,7 +989,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__get_create_plist() */ - + /*------------------------------------------------------------------------- * Function: H5A__get_info * @@ -1032,14 +1030,13 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__get_info() */ - + /*------------------------------------------------------------------------- * Function: H5A__copy * * Purpose: Copies attribute OLD_ATTR. * * Return: Success: Pointer to a new copy of the OLD_ATTR argument. - * * Failure: NULL * * Programmer: Robb Matzke @@ -1095,7 +1092,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__copy() */ - + /*------------------------------------------------------------------------- * Function: H5A__shared_free * @@ -1147,7 +1144,7 @@ H5A__shared_free(H5A_t *attr) FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__shared_free() */ - + /*------------------------------------------------------------------------- * Function: H5A__close_cb * @@ -1179,7 +1176,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__close_cb() */ - + /*------------------------------------------------------------------------- * Function: H5A__close * @@ -1230,7 +1227,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__close() */ - + /*------------------------------------------------------------------------- * Function: H5A_oloc * @@ -1262,7 +1259,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A_oloc() */ - + /*------------------------------------------------------------------------- * Function: H5A_nameof * @@ -1294,7 +1291,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A_nameof() */ - + /*------------------------------------------------------------------------- * Function: H5A_type * @@ -1324,7 +1321,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A_type() */ - + /*------------------------------------------------------------------------- * Function: H5A__exists_by_name * @@ -1370,7 +1367,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5A__exists_by_name() */ - + /*------------------------------------------------------------------------- * Function: H5A__compact_build_table_cb * @@ -1380,7 +1377,6 @@ done: * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Dec 18 2006 * * Modification:Raymond Lu @@ -1431,7 +1427,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__compact_build_table_cb() */ - + /*------------------------------------------------------------------------- * Function: H5A__compact_build_table * @@ -1443,8 +1439,8 @@ done: * * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol - * Dec 18, 2006 + * Programmer: Quincey Koziol + * Dec 18, 2006 * *------------------------------------------------------------------------- */ @@ -1494,18 +1490,16 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__compact_build_table() */ - + /*------------------------------------------------------------------------- * Function: H5A__dense_build_table_cb * * Purpose: Callback routine for building table of attributes from dense * attribute storage. * - * Return: Success: Non-negative - * Failure: Negative + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Dec 11 2006 * *------------------------------------------------------------------------- @@ -1538,7 +1532,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_build_table_cb() */ - + /*------------------------------------------------------------------------- * Function: H5A__dense_build_table * @@ -1623,21 +1617,20 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_build_table() */ - + /*------------------------------------------------------------------------- * Function: H5A__attr_cmp_name_inc * - * Purpose: Callback routine for comparing two attribute names, in + * Purpose: Callback routine for comparing two attribute names, in * increasing alphabetic order * - * Return: An integer less than, equal to, or greater than zero if the + * Return: An integer less than, equal to, or greater than zero if the * first argument is considered to be respectively less than, * equal to, or greater than the second. If two members compare * as equal, their order in the sorted array is undefined. * (i.e. same as strcmp()) * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Dec 11 2006 * *------------------------------------------------------------------------- @@ -1651,7 +1644,7 @@ H5A__attr_cmp_name_inc(const void *attr1, const void *attr2) (*(const H5A_t * const *)attr2)->shared->name)) } /* end H5A__attr_cmp_name_inc() */ - + /*------------------------------------------------------------------------- * Function: H5A__attr_cmp_name_dec * @@ -1665,7 +1658,6 @@ H5A__attr_cmp_name_inc(const void *attr1, const void *attr2) * (i.e. opposite of strcmp()) * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Feb 8 2007 * *------------------------------------------------------------------------- @@ -1679,7 +1671,7 @@ H5A__attr_cmp_name_dec(const void *attr1, const void *attr2) (*(const H5A_t * const *)attr1)->shared->name)) } /* end H5A__attr_cmp_name_dec() */ - + /*------------------------------------------------------------------------- * Function: H5A__attr_cmp_corder_inc * @@ -1692,7 +1684,6 @@ H5A__attr_cmp_name_dec(const void *attr1, const void *attr2) * as equal, their order in the sorted array is undefined. * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Feb 8 2007 * *------------------------------------------------------------------------- @@ -1714,21 +1705,20 @@ H5A__attr_cmp_corder_inc(const void *attr1, const void *attr2) FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__attr_cmp_corder_inc() */ - + /*------------------------------------------------------------------------- * Function: H5A__attr_cmp_corder_dec * - * Purpose: Callback routine for comparing two attributes, in + * Purpose: Callback routine for comparing two attributes, in * decreasing creation order * - * Return: An integer less than, equal to, or greater than zero if the + * Return: An integer less than, equal to, or greater than zero if the * second argument is considered to be respectively less than, * equal to, or greater than the first. If two members compare * as equal, their order in the sorted array is undefined. * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Feb 8 2007 + * Programmer: Quincey Koziol + * Feb 8 2007 * *------------------------------------------------------------------------- */ @@ -1749,17 +1739,16 @@ H5A__attr_cmp_corder_dec(const void *attr1, const void *attr2) FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__attr_cmp_corder_dec() */ - + /*------------------------------------------------------------------------- * Function: H5A__attr_sort_table * * Purpose: Sort table containing a list of attributes for an object * - * Return: Success: Non-negative - * Failure: Negative + * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol - * Dec 11, 2006 + * Programmer: Quincey Koziol + * Dec 11, 2006 * *------------------------------------------------------------------------- */ @@ -1794,7 +1783,7 @@ H5A__attr_sort_table(H5A_attr_table_t *atable, H5_index_t idx_type, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5A__attr_sort_table() */ - + /*------------------------------------------------------------------------- * Function: H5A__attr_iterate_table * @@ -1803,8 +1792,8 @@ H5A__attr_sort_table(H5A_attr_table_t *atable, H5_index_t idx_type, * * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol - * Dec 18, 2006 + * Programmer: Quincey Koziol + * Dec 18, 2006 * *------------------------------------------------------------------------- */ @@ -1876,7 +1865,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__attr_iterate_table() */ - + /*------------------------------------------------------------------------- * Function: H5A__attr_release_table * @@ -1884,7 +1873,7 @@ done: * * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Dec 11, 2006 * *------------------------------------------------------------------------- @@ -1892,7 +1881,7 @@ done: herr_t H5A__attr_release_table(H5A_attr_table_t *atable) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1917,18 +1906,16 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__attr_release_table() */ - + /*------------------------------------------------------------------------- * Function: H5A__get_ainfo * * Purpose: Retrieves the "attribute info" message for an object. Also * sets the number of attributes correctly, if it isn't set up yet. * - * Return: Success: TRUE/FALSE whether message was found & retrieved - * Failure: FAIL if error occurred + * Return: TRUE/FALSE/FAIL * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Mar 11 2007 * *------------------------------------------------------------------------- @@ -1948,11 +1935,11 @@ H5A__get_ainfo(H5F_t *f, H5O_t *oh, H5O_ainfo_t *ainfo) /* Check if the "attribute info" message exists */ if((ret_value = H5O_msg_exists_oh(oh, H5O_AINFO_ID)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "unable to check object header") + HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "unable to check object header") if(ret_value > 0) { /* Retrieve the "attribute info" structure */ if(NULL == H5O_msg_read_oh(f, oh, H5O_AINFO_ID, ainfo)) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't read AINFO message") + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't read AINFO message") /* Check if we don't know how many attributes there are */ if(ainfo->nattrs == HSIZET_MAX) { @@ -1981,7 +1968,7 @@ done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5A__get_ainfo() */ - + /*------------------------------------------------------------------------- * Function: H5A__set_version * @@ -1992,7 +1979,6 @@ done: * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Jul 17 2007 * *------------------------------------------------------------------------- @@ -2043,7 +2029,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__set_version() */ - + /*------------------------------------------------------------------------- * Function: H5A__attr_copy_file * @@ -2253,10 +2239,10 @@ H5A__attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_s H5MM_memcpy(buf, attr_src->shared->data, attr_src->shared->data_size); - /* Allocate background memory */ - if(H5T_path_bkg(tpath_src_mem) || H5T_path_bkg(tpath_mem_dst)) - if(NULL == (bkg_buf = H5FL_BLK_CALLOC(attr_buf, buf_size))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTALLOC, NULL, "memory allocation failed") + /* Allocate background memory */ + if(H5T_path_bkg(tpath_src_mem) || H5T_path_bkg(tpath_mem_dst)) + if(NULL == (bkg_buf = H5FL_BLK_CALLOC(attr_buf, buf_size))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTALLOC, NULL, "memory allocation failed") /* Convert from source file to memory */ if(H5T_convert(tpath_src_mem, tid_src, tid_mem, nelmts, (size_t)0, (size_t)0, buf, bkg_buf) < 0) @@ -2264,9 +2250,9 @@ H5A__attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_s H5MM_memcpy(reclaim_buf, buf, buf_size); - /* Set background buffer to all zeros */ - if(bkg_buf) - HDmemset(bkg_buf, 0, buf_size); + /* Set background buffer to all zeros */ + if(bkg_buf) + HDmemset(bkg_buf, 0, buf_size); /* Convert from memory to destination file */ if(H5T_convert(tpath_mem_dst, tid_mem, tid_dst, nelmts, (size_t)0, (size_t)0, buf, bkg_buf) < 0) @@ -2326,7 +2312,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5A__attr_copy_file() */ - + /*------------------------------------------------------------------------- * Function: H5A__attr_post_copy_file * @@ -2419,7 +2405,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5A__attr_post_copy_file() */ - + /*------------------------------------------------------------------------- * Function: H5A__dense_post_copy_file_cb * @@ -2477,7 +2463,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_post_copy_file_cb() */ - + /*------------------------------------------------------------------------- * Function: H5A__dense_post_copy_file_all * @@ -2486,7 +2472,6 @@ done: * Return: SUCCEED/FAIL * * Programmer: Peter Cao - * xcao@hdfgroup.org * July 20, 2007 * *------------------------------------------------------------------------- @@ -2524,7 +2509,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_post_copy_file_all */ - + /*------------------------------------------------------------------------- * Function: H5A__rename_by_name * @@ -2532,7 +2517,7 @@ done: * * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * February 20, 2007 * *------------------------------------------------------------------------- @@ -2542,10 +2527,10 @@ H5A__rename_by_name(H5G_loc_t loc, const char *obj_name, const char *old_attr_na const char *new_attr_name) { H5G_loc_t obj_loc; /* Location used to open group */ - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2574,7 +2559,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5A__rename_by_name() */ - + /*------------------------------------------------------------------------- * Function: H5A__iterate_common * @@ -2582,7 +2567,7 @@ done: * * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * December 6, 2017 * *------------------------------------------------------------------------- @@ -2609,7 +2594,7 @@ H5A__iterate_common(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, FUNC_LEAVE_NOAPI(ret_value) } /* H5A__iterate_common() */ - + /*------------------------------------------------------------------------- * Function: H5A__iterate * @@ -2674,7 +2659,7 @@ done: } /* end H5A__iterate() */ #ifndef H5_NO_DEPRECATED_SYMBOLS - + /*------------------------------------------------------------------------- * Function: H5A__iterate_old * @@ -2682,7 +2667,7 @@ done: * * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * December 6, 2017 * *------------------------------------------------------------------------- @@ -2724,7 +2709,7 @@ H5A__iterate_old(hid_t loc_id, unsigned *attr_num, H5A_operator1_t op, * * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * December 6, 2017 * *------------------------------------------------------------------------- @@ -2733,8 +2718,8 @@ herr_t H5A__delete_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr_name) { H5G_loc_t obj_loc; /* Location used to open group */ - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2762,7 +2747,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5A__delete_by_name() */ - + /*------------------------------------------------------------------------- * Function: H5A__delete_by_idx * @@ -2770,7 +2755,7 @@ done: * * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * December 6, 2017 * *------------------------------------------------------------------------- @@ -2780,8 +2765,8 @@ H5A__delete_by_idx(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_ty H5_iter_order_t order, hsize_t n) { H5G_loc_t obj_loc; /* Location used to open group */ - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5B2.c b/src/H5B2.c index c9ed303..5c83de2 100644 --- a/src/H5B2.c +++ b/src/H5B2.c @@ -15,7 +15,7 @@ * * Created: H5B2.c * Jan 31 2005 - * Quincey Koziol + * Quincey Koziol * * Purpose: Implements a B-tree, with several modifications from * the "standard" methods. @@ -129,7 +129,6 @@ H5FL_DEFINE_STATIC(H5B2_t); * filled in), negative on failure * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu * Jan 31 2005 * *------------------------------------------------------------------------- @@ -200,7 +199,6 @@ done: * NULL on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Oct 15 2009 * *------------------------------------------------------------------------- @@ -264,7 +262,6 @@ done: * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu * Feb 2 2005 * *------------------------------------------------------------------------- @@ -307,7 +304,6 @@ done: * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Dec 23 2015 * *------------------------------------------------------------------------- @@ -379,7 +375,6 @@ done: * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Nov 5 2009 * *------------------------------------------------------------------------- @@ -414,7 +409,6 @@ H5B2_get_addr(const H5B2_t *bt2, haddr_t *addr_p) * Return: Value from callback: non-negative on success, negative on error * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu * Feb 11 2005 * *------------------------------------------------------------------------- @@ -465,7 +459,6 @@ H5B2_iterate(H5B2_t *bt2, H5B2_operator_t op, void *op_data) * Return: Non-negative (TRUE/FALSE) on success, negative on failure. * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu * Feb 23 2005 * *------------------------------------------------------------------------- @@ -705,7 +698,6 @@ done: * Return: Non-negative on success, negative on failure. * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu * Feb 23 2005 * *------------------------------------------------------------------------- @@ -894,7 +886,6 @@ done: * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu * Feb 25 2005 * *------------------------------------------------------------------------- @@ -968,7 +959,6 @@ done: * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Nov 14 2006 * *------------------------------------------------------------------------- @@ -1051,7 +1041,6 @@ done: * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu * Feb 25 2005 * *------------------------------------------------------------------------- @@ -1092,7 +1081,6 @@ H5B2_get_nrec(const H5B2_t *bt2, hsize_t *nrec) * Return: Non-negative on success, negative on failure. * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu * Mar 8 2005 * *------------------------------------------------------------------------- @@ -1150,7 +1138,6 @@ done: * Return: Non-negative on success, negative on failure. * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu * Mar 10 2005 * *------------------------------------------------------------------------- @@ -1384,7 +1371,6 @@ done: * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Oct 15 2009 * *------------------------------------------------------------------------- @@ -1493,7 +1479,6 @@ done: * Return: Non-negative on success, negative on failure. * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu * Mar 9 2005 * *------------------------------------------------------------------------- diff --git a/src/H5B2hdr.c b/src/H5B2hdr.c index 68669e8..9ba8235 100644 --- a/src/H5B2hdr.c +++ b/src/H5B2hdr.c @@ -15,7 +15,7 @@ * * Created: H5B2int.c * Feb 27 2006 - * Quincey Koziol + * Quincey Koziol * * Purpose: Internal routines for managing v2 B-trees. * @@ -101,7 +101,6 @@ H5FL_SEQ_DEFINE(H5B2_node_info_t); * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu * Feb 2 2005 * *------------------------------------------------------------------------- @@ -230,7 +229,6 @@ done: * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Oct 27 2009 * *------------------------------------------------------------------------- @@ -276,7 +274,6 @@ done: * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu * Mar 21 2006 * *------------------------------------------------------------------------- @@ -355,7 +352,6 @@ done: * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Oct 13 2009 * *------------------------------------------------------------------------- @@ -391,7 +387,6 @@ done: * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Oct 13 2009 * *------------------------------------------------------------------------- @@ -428,7 +423,6 @@ done: * Return: SUCCEED (Can't fail) * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Oct 27 2009 * *------------------------------------------------------------------------- @@ -456,7 +450,6 @@ H5B2__hdr_fuse_incr(H5B2_hdr_t *hdr) * Return: The file's reference count after the decrement. (Can't fail) * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Oct 27 2009 * *------------------------------------------------------------------------- @@ -485,7 +478,6 @@ H5B2__hdr_fuse_decr(H5B2_hdr_t *hdr) * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Oct 13 2009 * *------------------------------------------------------------------------- @@ -517,7 +509,6 @@ done: * Return: Non-NULL pointer to header on success/NULL on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Dec 18 2015 * *------------------------------------------------------------------------- diff --git a/src/H5B2leaf.c b/src/H5B2leaf.c index b542061..1fde36d 100644 --- a/src/H5B2leaf.c +++ b/src/H5B2leaf.c @@ -1051,7 +1051,7 @@ H5B2__assert_leaf(const H5B2_hdr_t H5_ATTR_NDEBUG_UNUSED *hdr, *------------------------------------------------------------------------- */ H5_ATTR_PURE herr_t -H5B2__assert_leaf2(const H5B2_hdr_t *hdr, const H5B2_leaf_t *leaf, const H5B2_leaf_t H5_ATTR_UNUSED *leaf2) +H5B2__assert_leaf2(const H5B2_hdr_t H5_ATTR_NDEBUG_UNUSED *hdr, const H5B2_leaf_t H5_ATTR_NDEBUG_UNUSED *leaf, const H5B2_leaf_t H5_ATTR_UNUSED *leaf2) { /* General sanity checking on node */ HDassert(leaf->nrec <= hdr->node_info->split_nrec); diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h index 338db5a..7d73752 100644 --- a/src/H5B2pkg.h +++ b/src/H5B2pkg.h @@ -12,7 +12,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Monday, January 31, 2005 * * Purpose: This file contains declarations which are visible only within diff --git a/src/H5B2private.h b/src/H5B2private.h index 0b64381..9303d4f 100644 --- a/src/H5B2private.h +++ b/src/H5B2private.h @@ -15,7 +15,7 @@ * * Created: H5B2private.h * Jan 31 2005 - * Quincey Koziol + * Quincey Koziol * * Purpose: Private header for library accessible B-tree routines. * diff --git a/src/H5Bdbg.c b/src/H5Bdbg.c index 665e826..d900852 100644 --- a/src/H5Bdbg.c +++ b/src/H5Bdbg.c @@ -13,11 +13,11 @@ /*------------------------------------------------------------------------- * - * Created: H5Bdbg.c - * Dec 11 2008 - * Quincey Koziol + * Created: H5Bdbg.c + * Dec 11 2008 + * Quincey Koziol * - * Purpose: Debugging routines for B-link tree package. + * Purpose: Debugging routines for B-link tree package. * *------------------------------------------------------------------------- */ @@ -32,35 +32,33 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Bpkg.h" /* B-link trees */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5Bpkg.h" /* B-link trees */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ /*------------------------------------------------------------------------- - * Function: H5B_debug + * Function: H5B_debug * - * Purpose: Prints debugging info about a B-tree. + * Purpose: Prints debugging info about a B-tree. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke - * matzke@llnl.gov - * Aug 4 1997 + * Programmer: Robb Matzke + * Aug 4 1997 * *------------------------------------------------------------------------- */ herr_t -H5B_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, - const H5B_class_t *type, void *udata) +H5B_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, const H5B_class_t *type, void *udata) { - H5B_t *bt = NULL; - H5UC_t *rc_shared; /* Ref-counted shared info */ + H5B_t *bt = NULL; + H5UC_t *rc_shared; /* Ref-counted shared info */ H5B_shared_t *shared; /* Pointer to shared B-tree info */ H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ - unsigned u; /* Local index variable */ + unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -97,55 +95,53 @@ H5B_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, * Print the values. */ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Tree type ID:", - ((shared->type->id) == H5B_SNODE_ID ? "H5B_SNODE_ID" : + "Tree type ID:", + ((shared->type->id) == H5B_SNODE_ID ? "H5B_SNODE_ID" : ((shared->type->id) == H5B_CHUNK_ID ? "H5B_CHUNK_ID" : "Unknown!"))); HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Size of node:", - shared->sizeof_rnode); + "Size of node:", + shared->sizeof_rnode); HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Size of raw (disk) key:", - shared->sizeof_rkey); + "Size of raw (disk) key:", + shared->sizeof_rkey); HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Dirty flag:", - bt->cache_info.is_dirty ? "True" : "False"); + "Dirty flag:", + bt->cache_info.is_dirty ? "True" : "False"); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Level:", - bt->level); + "Level:", + bt->level); HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Address of left sibling:", - bt->left); + "Address of left sibling:", + bt->left); HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Address of right sibling:", - bt->right); + "Address of right sibling:", + bt->right); HDfprintf(stream, "%*s%-*s %u (%u)\n", indent, "", fwidth, - "Number of children (max):", - bt->nchildren, shared->two_k); + "Number of children (max):", + bt->nchildren, shared->two_k); /* * Print the child addresses */ for(u = 0; u < bt->nchildren; u++) { - HDfprintf(stream, "%*sChild %d...\n", indent, "", u); - HDfprintf(stream, "%*s%-*s %a\n", indent + 3, "", MAX(0, fwidth - 3), - "Address:", bt->child[u]); + HDfprintf(stream, "%*sChild %d...\n", indent, "", u); + HDfprintf(stream, "%*s%-*s %a\n", indent + 3, "", MAX(0, fwidth - 3), + "Address:", bt->child[u]); /* If there is a key debugging routine, use it to display the left & right keys */ - if(type->debug_key) { + if(type->debug_key) { /* Decode the 'left' key & print it */ HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), "Left Key:"); HDassert(H5B_NKEY(bt,shared,u)); - (void)(type->debug_key)(stream, indent + 6, MAX(0, fwidth - 6), - H5B_NKEY(bt, shared, u), udata); + (void)(type->debug_key)(stream, indent + 6, MAX(0, fwidth - 6), H5B_NKEY(bt, shared, u), udata); /* Decode the 'right' key & print it */ HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), "Right Key:"); HDassert(H5B_NKEY(bt, shared, u + 1)); - (void)(type->debug_key)(stream, indent + 6, MAX (0, fwidth - 6), - H5B_NKEY(bt, shared, u + 1), udata); - } /* end if */ + (void)(type->debug_key)(stream, indent + 6, MAX (0, fwidth - 6), H5B_NKEY(bt, shared, u + 1), udata); + } /* end if */ } /* end for */ done: @@ -157,16 +153,16 @@ done: /*------------------------------------------------------------------------- - * Function: H5B__assert + * Function: H5B__assert * - * Purpose: Verifies that the tree is structured correctly. + * Purpose: Verifies that the tree is structured correctly. * - * Return: Success: SUCCEED + * Return: Success: SUCCEED * - * Failure: aborts if something is wrong. + * Failure: aborts if something is wrong. * - * Programmer: Robb Matzke - * Tuesday, November 4, 1997 + * Programmer: Robb Matzke + * Tuesday, November 4, 1997 * *------------------------------------------------------------------------- */ @@ -174,20 +170,20 @@ done: herr_t H5B__assert(H5F_t *f, haddr_t addr, const H5B_class_t *type, void *udata) { - H5B_t *bt = NULL; - H5UC_t *rc_shared; /* Ref-counted shared info */ + H5B_t *bt = NULL; + H5UC_t *rc_shared; /* Ref-counted shared info */ H5B_shared_t *shared; /* Pointer to shared B-tree info */ H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ - int ncell, cmp; - static int ncalls = 0; - herr_t status; + int ncell, cmp; + static int ncalls = 0; + herr_t status; herr_t ret_value = SUCCEED; /* Return value */ /* A queue of child data */ struct child_t { - haddr_t addr; - unsigned level; - struct child_t *next; + haddr_t addr; + unsigned level; + struct child_t *next; } *head = NULL, *tail = NULL, *prev = NULL, *cur = NULL, *tmp = NULL; FUNC_ENTER_PACKAGE @@ -228,60 +224,60 @@ H5B__assert(H5F_t *f, haddr_t addr, const H5B_class_t *type, void *udata) * test. */ for(ncell = 0; cur; ncell++) { - bt = (H5B_t *)H5AC_protect(f, H5AC_BT, cur->addr, &cache_udata, H5AC__READ_ONLY_FLAG); - HDassert(bt); - - /* Check node header */ - HDassert(bt->level == cur->level); - if(cur->next && cur->next->level == bt->level) - HDassert(H5F_addr_eq(bt->right, cur->next->addr)); - else - HDassert(!H5F_addr_defined(bt->right)); - if(prev && prev->level == bt->level) - HDassert(H5F_addr_eq(bt->left, prev->addr)); - else - HDassert(!H5F_addr_defined(bt->left)); - - if(cur->level > 0) { + bt = (H5B_t *)H5AC_protect(f, H5AC_BT, cur->addr, &cache_udata, H5AC__READ_ONLY_FLAG); + HDassert(bt); + + /* Check node header */ + HDassert(bt->level == cur->level); + if(cur->next && cur->next->level == bt->level) + HDassert(H5F_addr_eq(bt->right, cur->next->addr)); + else + HDassert(!H5F_addr_defined(bt->right)); + if(prev && prev->level == bt->level) + HDassert(H5F_addr_eq(bt->left, prev->addr)); + else + HDassert(!H5F_addr_defined(bt->left)); + + if(cur->level > 0) { unsigned u; - for(u = 0; u < bt->nchildren; u++) { - /* - * Check that child nodes haven't already been seen. If they - * have then the tree has a cycle. - */ - for(tmp = head; tmp; tmp = tmp->next) - HDassert(H5F_addr_ne(tmp->addr, bt->child[u])); - - /* Add the child node to the end of the queue */ - tmp = (struct child_t *)H5MM_calloc(sizeof(struct child_t)); - HDassert(tmp); - tmp->addr = bt->child[u]; - tmp->level = bt->level - 1; - tail->next = tmp; - tail = tmp; - - /* Check that the keys are monotonically increasing */ - cmp = (type->cmp2)(H5B_NKEY(bt, shared, u), udata, H5B_NKEY(bt, shared, u + 1)); - HDassert(cmp < 0); - } /* end for */ - } /* end if */ - - /* Release node */ - status = H5AC_unprotect(f, H5AC_BT, cur->addr, bt, H5AC__NO_FLAGS_SET); - HDassert(status >= 0); + for(u = 0; u < bt->nchildren; u++) { + /* + * Check that child nodes haven't already been seen. If they + * have then the tree has a cycle. + */ + for(tmp = head; tmp; tmp = tmp->next) + HDassert(H5F_addr_ne(tmp->addr, bt->child[u])); + + /* Add the child node to the end of the queue */ + tmp = (struct child_t *)H5MM_calloc(sizeof(struct child_t)); + HDassert(tmp); + tmp->addr = bt->child[u]; + tmp->level = bt->level - 1; + tail->next = tmp; + tail = tmp; + + /* Check that the keys are monotonically increasing */ + cmp = (type->cmp2)(H5B_NKEY(bt, shared, u), udata, H5B_NKEY(bt, shared, u + 1)); + HDassert(cmp < 0); + } /* end for */ + } /* end if */ + + /* Release node */ + status = H5AC_unprotect(f, H5AC_BT, cur->addr, bt, H5AC__NO_FLAGS_SET); + HDassert(status >= 0); bt = NULL; /* Make certain future references will be caught */ - /* Advance current location in queue */ - prev = cur; - cur = cur->next; + /* Advance current location in queue */ + prev = cur; + cur = cur->next; } /* end for */ /* Free all entries from queue */ while(head) { - tmp = head->next; - H5MM_xfree(head); - head = tmp; + tmp = head->next; + H5MM_xfree(head); + head = tmp; } /* end while */ done: diff --git a/src/H5Bmodule.h b/src/H5Bmodule.h index bc46752..c8e1546 100644 --- a/src/H5Bmodule.h +++ b/src/H5Bmodule.h @@ -11,7 +11,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Saturday, September 12, 2015 * * Purpose: This file contains declarations which define macros for the diff --git a/src/H5Bpkg.h b/src/H5Bpkg.h index a451cab..a57584e 100644 --- a/src/H5Bpkg.h +++ b/src/H5Bpkg.h @@ -12,7 +12,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, May 15, 2003 * * Purpose: This file contains declarations which are visible only within diff --git a/src/H5Bprivate.h b/src/H5Bprivate.h index 5aa3628..55bf5b3 100644 --- a/src/H5Bprivate.h +++ b/src/H5Bprivate.h @@ -15,12 +15,10 @@ * * Created: H5Bprivate.h * Jul 10 1997 - * Robb Matzke + * Robb Matzke * * Purpose: Private non-prototype header. * - * Modifications: - * *------------------------------------------------------------------------- */ diff --git a/src/H5CX.c b/src/H5CX.c index df335ea..b78d9ec 100644 --- a/src/H5CX.c +++ b/src/H5CX.c @@ -33,11 +33,11 @@ /***********/ #include "H5private.h" /* Generic Functions */ #include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ +#include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ +#include "H5Lprivate.h" /* Links */ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ @@ -295,8 +295,8 @@ typedef struct H5CX_t { hbool_t nlinks_valid; /* Whether number of soft / UD links to traverse is valid */ /* Cached DCPL properties */ - hbool_t do_min_dset_ohdr; /* Whether to minimize dataset object header */ - hbool_t do_min_dset_ohdr_valid; /* Whether minimize dataset object header flag is valid */ + hbool_t do_min_dset_ohdr; /* Whether to minimize dataset object header */ + hbool_t do_min_dset_ohdr_valid; /* Whether minimize dataset object header flag is valid */ uint8_t ohdr_flags; /* Object header flags */ hbool_t ohdr_flags_valid; /* Whether the object headers flags are valid */ @@ -581,7 +581,6 @@ H5CX__init_package(void) if(H5P_get(la_plist, H5L_ACS_NLINKS_NAME, &H5CX_def_lapl_cache.nlinks) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve number of soft / UD links to traverse") - /* Reset the "default DCPL cache" information */ HDmemset(&H5CX_def_dcpl_cache, 0, sizeof(H5CX_dcpl_cache_t)); @@ -1171,6 +1170,7 @@ H5CX_set_dcpl(hid_t dcpl_id) FUNC_LEAVE_NOAPI_VOID } /* end H5CX_set_dcpl() */ + /*------------------------------------------------------------------------- * Function: H5CX_set_libver_bounds * @@ -2593,6 +2593,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_nlinks() */ + /*------------------------------------------------------------------------- * Function: H5CX_get_libver_bounds * diff --git a/src/H5CXmodule.h b/src/H5CXmodule.h index f6a8f29..186f8aa 100644 --- a/src/H5CXmodule.h +++ b/src/H5CXmodule.h @@ -11,7 +11,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Sunday, February 25, 2018 * * Purpose: This file contains declarations which define macros for the diff --git a/src/H5Cmpio.c b/src/H5Cmpio.c index 0ac4c4f..199c494 100644 --- a/src/H5Cmpio.c +++ b/src/H5Cmpio.c @@ -18,7 +18,7 @@ * Quincey Koziol * * Purpose: Functions in this file implement support for parallel I/O for - * generic cache code. + * generic cache code. * *------------------------------------------------------------------------- */ @@ -28,20 +28,20 @@ /****************/ #include "H5Cmodule.h" /* This source code file is part of the H5C module */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ +#include "H5private.h" /* Generic Functions */ #include "H5ACprivate.h" /* Metadata cache */ -#include "H5Cpkg.h" /* Cache */ +#include "H5Cpkg.h" /* Cache */ #include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* Files */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5MMprivate.h" /* Memory management */ #ifdef H5_HAVE_PARALLEL @@ -87,74 +87,74 @@ static herr_t H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, * * Purpose: Apply the supplied candidate list. * - * We used to do this by simply having each process write - * every mpi_size-th entry in the candidate list, starting - * at index mpi_rank, and mark all the others clean. + * We used to do this by simply having each process write + * every mpi_size-th entry in the candidate list, starting + * at index mpi_rank, and mark all the others clean. * - * However, this can cause unnecessary contention in a file - * system by increasing the number of processes writing to - * adjacent locations in the HDF5 file. + * However, this can cause unnecessary contention in a file + * system by increasing the number of processes writing to + * adjacent locations in the HDF5 file. * - * To attempt to minimize this, we now arange matters such - * that each process writes n adjacent entries in the - * candidate list, and marks all others clean. We must do - * this in such a fashion as to guarantee that each entry - * on the candidate list is written by exactly one process, - * and marked clean by all others. + * To attempt to minimize this, we now arange matters such + * that each process writes n adjacent entries in the + * candidate list, and marks all others clean. We must do + * this in such a fashion as to guarantee that each entry + * on the candidate list is written by exactly one process, + * and marked clean by all others. * - * To do this, first construct a table mapping mpi_rank - * to the index of the first entry in the candidate list to - * be written by the process of that mpi_rank, and then use - * the table to control which entries are written and which - * are marked as clean as a function of the mpi_rank. + * To do this, first construct a table mapping mpi_rank + * to the index of the first entry in the candidate list to + * be written by the process of that mpi_rank, and then use + * the table to control which entries are written and which + * are marked as clean as a function of the mpi_rank. * - * Note that the table must be identical on all processes, as - * all see the same candidate list, mpi_size, and mpi_rank -- - * the inputs used to construct the table. + * Note that the table must be identical on all processes, as + * all see the same candidate list, mpi_size, and mpi_rank -- + * the inputs used to construct the table. * - * We construct the table as follows. Let: + * We construct the table as follows. Let: * - * n = num_candidates / mpi_size; + * n = num_candidates / mpi_size; * - * m = num_candidates % mpi_size; + * m = num_candidates % mpi_size; * - * Now allocate an array of integers of length mpi_size + 1, - * and call this array candidate_assignment_table. + * Now allocate an array of integers of length mpi_size + 1, + * and call this array candidate_assignment_table. * - * Conceptually, if the number of candidates is a multiple - * of the mpi_size, we simply pass through the candidate list - * and assign n entries to each process to flush, with the - * index of the first entry to flush in the location in - * the candidate_assignment_table indicated by the mpi_rank - * of the process. + * Conceptually, if the number of candidates is a multiple + * of the mpi_size, we simply pass through the candidate list + * and assign n entries to each process to flush, with the + * index of the first entry to flush in the location in + * the candidate_assignment_table indicated by the mpi_rank + * of the process. * - * In the more common case in which the candidate list isn't - * isn't a multiple of the mpi_size, we pretend it is, and - * give num_candidates % mpi_size processes one extra entry - * each to make things work out. + * In the more common case in which the candidate list isn't + * isn't a multiple of the mpi_size, we pretend it is, and + * give num_candidates % mpi_size processes one extra entry + * each to make things work out. * - * Once the table is constructed, we determine the first and - * last entry this process is to flush as follows: + * Once the table is constructed, we determine the first and + * last entry this process is to flush as follows: * - * first_entry_to_flush = candidate_assignment_table[mpi_rank] + * first_entry_to_flush = candidate_assignment_table[mpi_rank] * - * last_entry_to_flush = - * candidate_assignment_table[mpi_rank + 1] - 1; + * last_entry_to_flush = + * candidate_assignment_table[mpi_rank + 1] - 1; * - * With these values determined, we simply scan through the - * candidate list, marking all entries in the range - * [first_entry_to_flush, last_entry_to_flush] for flush, - * and all others to be cleaned. + * With these values determined, we simply scan through the + * candidate list, marking all entries in the range + * [first_entry_to_flush, last_entry_to_flush] for flush, + * and all others to be cleaned. * - * Finally, we scan the LRU from tail to head, flushing - * or marking clean the candidate entries as indicated. - * If necessary, we scan the pinned list as well. + * Finally, we scan the LRU from tail to head, flushing + * or marking clean the candidate entries as indicated. + * If necessary, we scan the pinned list as well. * - * Note that this function will fail if any protected or - * clean entries appear on the candidate list. + * Note that this function will fail if any protected or + * clean entries appear on the candidate list. * - * This function is used in managing sync points, and - * shouldn't be used elsewhere. + * This function is used in managing sync points, and + * shouldn't be used elsewhere. * * Return: Success: SUCCEED * @@ -176,20 +176,20 @@ H5C_apply_candidate_list(H5F_t * f, int i; int m; unsigned n; - unsigned first_entry_to_flush; - unsigned last_entry_to_flush; - unsigned total_entries_to_clear = 0; - unsigned total_entries_to_flush = 0; + unsigned first_entry_to_flush; + unsigned last_entry_to_flush; + unsigned total_entries_to_clear = 0; + unsigned total_entries_to_flush = 0; unsigned * candidate_assignment_table = NULL; unsigned entries_to_flush[H5C_RING_NTYPES]; unsigned entries_to_clear[H5C_RING_NTYPES]; - haddr_t addr; - H5C_cache_entry_t * entry_ptr = NULL; + haddr_t addr; + H5C_cache_entry_t * entry_ptr = NULL; #if H5C_DO_SANITY_CHECKS - haddr_t last_addr; + haddr_t last_addr; #endif /* H5C_DO_SANITY_CHECKS */ #if H5C_APPLY_CANDIDATE_LIST__DEBUG - char tbl_buf[1024]; + char tbl_buf[1024]; #endif /* H5C_APPLY_CANDIDATE_LIST__DEBUG */ unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -413,10 +413,10 @@ done: * Function: H5C_construct_candidate_list__clean_cache * * Purpose: Construct the list of entries that should be flushed to - * clean all entries in the cache. + * clean all entries in the cache. * - * This function is used in managing sync points, and - * shouldn't be used elsewhere. + * This function is used in managing sync points, and + * shouldn't be used elsewhere. * * Return: Success: SUCCEED * @@ -457,7 +457,7 @@ H5C_construct_candidate_list__clean_cache(H5C_t * cache_ptr) H5C_cache_entry_t *entry_ptr; unsigned nominated_entries_count = 0; size_t nominated_entries_size = 0; - haddr_t nominated_addr; + haddr_t nominated_addr; HDassert( cache_ptr->slist_len > 0 ); @@ -522,10 +522,10 @@ done: * Function: H5C_construct_candidate_list__min_clean * * Purpose: Construct the list of entries that should be flushed to - * get the cache back within its min clean constraints. + * get the cache back within its min clean constraints. * - * This function is used in managing sync points, and - * shouldn't be used elsewhere. + * This function is used in managing sync points, and + * shouldn't be used elsewhere. * * Return: Success: SUCCEED * @@ -582,7 +582,7 @@ H5C_construct_candidate_list__min_clean(H5C_t * cache_ptr) (nominated_entries_count < cache_ptr->slist_len) && (entry_ptr != NULL) && (!entry_ptr->flush_me_last)) { - haddr_t nominated_addr; + haddr_t nominated_addr; HDassert( ! (entry_ptr->is_protected) ); HDassert( ! (entry_ptr->is_read_only) ); @@ -612,24 +612,24 @@ done: * Function: H5C_mark_entries_as_clean * * Purpose: When the H5C code is used to implement the metadata caches - * in PHDF5, only the cache with MPI_rank 0 is allowed to - * actually write entries to disk -- all other caches must - * retain dirty entries until they are advised that the - * entries are clean. + * in PHDF5, only the cache with MPI_rank 0 is allowed to + * actually write entries to disk -- all other caches must + * retain dirty entries until they are advised that the + * entries are clean. * - * This function exists to allow the H5C code to receive these - * notifications. + * This function exists to allow the H5C code to receive these + * notifications. * - * The function receives a list of entry base addresses - * which must refer to dirty entries in the cache. If any - * of the entries are either clean or don't exist, the - * function flags an error. + * The function receives a list of entry base addresses + * which must refer to dirty entries in the cache. If any + * of the entries are either clean or don't exist, the + * function flags an error. * - * The function scans the list of entries and flushes all - * those that are currently unprotected with the - * H5C__FLUSH_CLEAR_ONLY_FLAG. Those that are currently - * protected are flagged for clearing when they are - * unprotected. + * The function scans the list of entries and flushes all + * those that are currently unprotected with the + * H5C__FLUSH_CLEAR_ONLY_FLAG. Those that are currently + * protected are flagged for clearing when they are + * unprotected. * * Return: Non-negative on success/Negative on failure * @@ -644,22 +644,22 @@ H5C_mark_entries_as_clean(H5F_t * f, haddr_t * ce_array_ptr) { H5C_t * cache_ptr; - unsigned entries_cleared; + unsigned entries_cleared; unsigned pinned_entries_cleared; hbool_t progress; - unsigned entries_examined; - unsigned initial_list_len; - haddr_t addr; - unsigned pinned_entries_marked = 0; + unsigned entries_examined; + unsigned initial_list_len; + haddr_t addr; + unsigned pinned_entries_marked = 0; #if H5C_DO_SANITY_CHECKS - unsigned protected_entries_marked = 0; - unsigned other_entries_marked = 0; - haddr_t last_addr; + unsigned protected_entries_marked = 0; + unsigned other_entries_marked = 0; + haddr_t last_addr; #endif /* H5C_DO_SANITY_CHECKS */ - H5C_cache_entry_t * clear_ptr = NULL; - H5C_cache_entry_t * entry_ptr = NULL; + H5C_cache_entry_t * clear_ptr = NULL; + H5C_cache_entry_t * entry_ptr = NULL; unsigned u; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -706,7 +706,7 @@ H5C_mark_entries_as_clean(H5F_t * f, if(entry_ptr == NULL) { #if H5C_DO_SANITY_CHECKS - HDfprintf(stdout, + HDfprintf(stdout, "H5C_mark_entries_as_clean: entry[%u] = %a not in cache.\n", u, addr); @@ -715,7 +715,7 @@ H5C_mark_entries_as_clean(H5F_t * f, } /* end if */ else if(!entry_ptr->is_dirty) { #if H5C_DO_SANITY_CHECKS - HDfprintf(stdout, + HDfprintf(stdout, "H5C_mark_entries_as_clean: entry %a is not dirty!?!\n", addr); #endif /* H5C_DO_SANITY_CHECKS */ @@ -735,13 +735,13 @@ H5C_mark_entries_as_clean(H5F_t * f, } /* end if */ entry_ptr->clear_on_unprotect = TRUE; - if(entry_ptr->is_pinned) - pinned_entries_marked++; + if(entry_ptr->is_pinned) + pinned_entries_marked++; #if H5C_DO_SANITY_CHECKS - else if(entry_ptr->is_protected) - protected_entries_marked++; - else - other_entries_marked++; + else if(entry_ptr->is_protected) + protected_entries_marked++; + else + other_entries_marked++; #endif /* H5C_DO_SANITY_CHECKS */ } } @@ -769,7 +769,7 @@ H5C_mark_entries_as_clean(H5F_t * f, * of the pre_serialize / serialize routines, this may * cease to be the case -- requiring a review of this * point. - * JRM -- 4/7/15 + * JRM -- 4/7/15 */ entries_cleared = 0; entries_examined = 0; @@ -873,9 +873,9 @@ done: herr_t H5C_clear_coll_entries(H5C_t *cache_ptr, hbool_t partial) { - uint32_t clear_cnt; - H5C_cache_entry_t * entry_ptr = NULL; - herr_t ret_value = SUCCEED; + uint32_t clear_cnt; + H5C_cache_entry_t * entry_ptr = NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -1084,7 +1084,7 @@ done: /*------------------------------------------------------------------------- * Function: H5C__flush_candidate_entries * - * Purpose: Flush or clear (as indicated) the candidate entries that + * Purpose: Flush or clear (as indicated) the candidate entries that * have been marked in the metadata cache. In so doing, * observe rings and flush dependencies. * @@ -1113,9 +1113,9 @@ done: * Return: Non-negative on success/Negative on failure. * * Programmer: John Mainzer - * 2/10/17 + * 2/10/17 * - * Changes: None. + * Changes: None. * *------------------------------------------------------------------------- */ @@ -1124,17 +1124,17 @@ H5C__flush_candidate_entries(H5F_t *f, unsigned entries_to_flush[H5C_RING_NTYPES unsigned entries_to_clear[H5C_RING_NTYPES]) { #if H5C_DO_SANITY_CHECKS - int i; - uint32_t index_len = 0; - size_t index_size = (size_t)0; - size_t clean_index_size = (size_t)0; - size_t dirty_index_size = (size_t)0; - size_t slist_size = (size_t)0; - uint32_t slist_len = 0; + int i; + uint32_t index_len = 0; + size_t index_size = (size_t)0; + size_t clean_index_size = (size_t)0; + size_t dirty_index_size = (size_t)0; + size_t slist_size = (size_t)0; + uint32_t slist_len = 0; #endif /* H5C_DO_SANITY_CHECKS */ - H5C_ring_t ring; + H5C_ring_t ring; H5C_t * cache_ptr; - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1164,7 +1164,7 @@ H5C__flush_candidate_entries(H5F_t *f, unsigned entries_to_flush[H5C_RING_NTYPES clean_index_size += cache_ptr->clean_index_ring_size[i]; dirty_index_size += cache_ptr->dirty_index_ring_size[i]; - slist_len += cache_ptr->slist_ring_len[i]; + slist_len += cache_ptr->slist_ring_len[i]; slist_size += cache_ptr->slist_ring_size[i]; } /* end for */ @@ -1206,7 +1206,7 @@ done: /*------------------------------------------------------------------------- * Function: H5C__flush_candidates_in_ring * - * Purpose: Flush or clear (as indicated) the candidate entries + * Purpose: Flush or clear (as indicated) the candidate entries * contained in the specified cache and ring. All candidate * entries in rings outside the specified ring must have been * flushed (or cleared) on entry. @@ -1235,7 +1235,7 @@ done: * Return: Non-negative on success/Negative on failure. * * Programmer: John Mainzer - * 2/10/17 + * 2/10/17 * *------------------------------------------------------------------------- */ diff --git a/src/H5D.c b/src/H5D.c index 37b3b39..3428d77 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -150,9 +150,9 @@ H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, if(NULL == (dset = H5VL_dataset_create(vol_obj, &loc_params, name, lcpl_id, type_id, space_id, dcpl_id, dapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, H5I_INVALID_HID, "unable to create dataset") - /* Get an atom for the dataset */ + /* Get an ID for the dataset */ if((ret_value = H5VL_register(H5I_DATASET, dset, vol_obj->connector, TRUE)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize dataset handle") + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataset") done: if(H5I_INVALID_HID == ret_value) @@ -315,7 +315,7 @@ done: * it. It is illegal to subsequently use that same dataset * ID in calls to other dataset functions. * - * Return: SUCCEED/FAIL + * Return: Non-negative on success/Negative on failure * *------------------------------------------------------------------------- */ @@ -382,7 +382,7 @@ done: * * Purpose: Returns the status of dataspace allocation. * - * Return: SUCCEED/FAIL + * Return: Non-negative on success/Negative on failure * *------------------------------------------------------------------------- */ @@ -719,8 +719,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, - hsize_t *size) +H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, hsize_t *size) { H5VL_object_t *vol_obj; /* Dataset for this operation */ hbool_t supported; /* Whether 'get vlen buf size' operation is supported by VOL connector */ @@ -765,7 +764,7 @@ done: * Purpose: Modifies the dimensions of a dataset. * Can change to a smaller dimension. * - * Return: SUCCEED/FAIL + * Return: Non-negative on success, negative on failure * *------------------------------------------------------------------------- */ @@ -802,7 +801,7 @@ done: * * Purpose: Flushes all buffers associated with a dataset. * - * Return: SUCCEED/FAIL + * Return: Non-negative on success, negative on failure * *------------------------------------------------------------------------- */ @@ -840,7 +839,7 @@ done: * * Purpose: Refreshes all buffers associated with a dataset. * - * Return: SUCCEED/FAIL + * Return: Non-negative on success, negative on failure * *------------------------------------------------------------------------- */ @@ -880,7 +879,7 @@ done: * For virtual: * No conversion * - * Return: SUCCEED/FAIL + * Return: Non-negative on success, negative on failure * * Programmer: Vailin Choi * Feb 2015 @@ -957,7 +956,7 @@ done: * Intended for use with the H5D(O)read_chunk API call so * the caller can construct an appropriate buffer. * - * Return: SUCCEED/FAIL + * Return: Non-negative on success, negative on failure * * Programmer: Matthew Strong (GE Healthcare) * 20 October 2016 diff --git a/src/H5Dbtree2.c b/src/H5Dbtree2.c index ae98654..ccb786b 100644 --- a/src/H5Dbtree2.c +++ b/src/H5Dbtree2.c @@ -292,7 +292,7 @@ H5D__bt2_dst_context(void *_ctx) /* Free array for chunk dimension sizes */ if(ctx->dim) - (void)H5FL_ARR_FREE(uint32_t, ctx->dim); + H5FL_ARR_FREE(uint32_t, ctx->dim); /* Release callback context */ ctx = H5FL_FREE(H5D_bt2_ctx_t, ctx); diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index f6fa91a..ee83564 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -216,6 +216,7 @@ typedef struct H5D_chunk_readvv_ud_t { const H5D_t *dset; /* Dataset to operate on */ } H5D_chunk_readvv_ud_t; +/* Typedef for chunk info iterator callback */ typedef struct H5D_chunk_info_iter_ud_t { hsize_t scaled[H5O_LAYOUT_NDIMS]; /* Logical offset of the chunk */ hsize_t ndims; /* Number of dimensions in the dataset */ @@ -433,7 +434,7 @@ H5D__chunk_direct_write(const H5D_t *dset, uint32_t filters, hsize_t *offset, /* Allocate storage */ if(H5D__alloc_storage(&io_info, H5D_ALLOC_WRITE, FALSE, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize storage") - } /* end if */ + } /* Calculate the index of this chunk */ H5VM_chunk_scaled(dset->shared->ndims, offset, layout->u.chunk.dim, scaled); @@ -1913,7 +1914,7 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t new_chunk_info->mspace_shared = FALSE; /* Copy the chunk's scaled coordinates */ - H5MM_memcpy(new_chunk_info->scaled, scaled, sizeof(hsize_t) * fm->f_ndims); + H5MM_memcpy(new_chunk_info->scaled, scaled, sizeof(hsize_t) * fm->f_ndims); new_chunk_info->scaled[fm->f_ndims] = 0; /* Insert the new chunk into the skip list */ @@ -2094,7 +2095,7 @@ H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm) for(u = 0; u < fm->f_ndims; u++) { /* Compensate for the chunk offset */ H5_CHECK_OVERFLOW(coords[u], hsize_t, hssize_t); - chunk_adjust[u] = adjust[u] - (hssize_t)coords[u]; /*lint !e771 The adjust array will always be initialized */ + chunk_adjust[u] = adjust[u] - (hssize_t)coords[u]; } /* end for */ /* Adjust the selection */ @@ -2328,7 +2329,7 @@ H5D__chunk_mem_cb(void H5_ATTR_UNUSED *elem, const H5T_t H5_ATTR_UNUSED *type, u { H5D_chunk_map_t *fm = (H5D_chunk_map_t *)_fm; /* File<->memory chunk mapping info */ H5D_chunk_info_t *chunk_info; /* Chunk information for current chunk */ - hsize_t coords_in_mem[H5S_MAX_RANK]; /* Coordinates of element in memory */ + hsize_t coords_in_mem[H5S_MAX_RANK]; /* Coordinates of element in memory */ hsize_t chunk_index; /* Chunk index */ herr_t ret_value = SUCCEED; /* Return value */ @@ -3146,8 +3147,8 @@ done: /*------------------------------------------------------------------------- * Function: H5D__chunk_hash_val * - * Purpose: To calculate an index based on the dataset's scaled - * coordinates and sizes of the faster dimensions. + * Purpose: To calculate an index based on the dataset's scaled + * coordinates and sizes of the faster dimensions. * * Return: Hash value index * @@ -4852,7 +4853,7 @@ H5D__chunk_update_old_edge_chunks(H5D_t *dset, hsize_t old_dim[]) /* Check if the dataspace expanded enough to cause the old edge chunks * in this dimension to become full */ - if((space_dim[op_dim]/chunk_dim[op_dim]) >= (old_edge_chunk_sc[op_dim] + 1)) + if((space_dim[op_dim]/chunk_dim[op_dim]) >= (old_edge_chunk_sc[op_dim] + 1)) new_full_dim[op_dim] = TRUE; } /* end for */ @@ -5990,7 +5991,7 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) if((udata->common.layout->flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) && H5D__chunk_is_partial_edge_chunk(udata->dset_ndims, udata->common.layout->dim, chunk_rec->scaled, udata->dset_dims)) must_filter = FALSE; - } /* end if */ + } /* Check parameter for type conversion */ if(udata->do_convert) { @@ -6028,7 +6029,7 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) HDassert(!H5F_addr_defined(chunk_rec->chunk_addr)); H5MM_memcpy(buf, udata->chunk, nbytes); udata->chunk = NULL; - } /* end if */ + } else { H5D_rdcc_ent_t *ent = NULL; /* Cache entry */ unsigned idx; /* Index of chunk in cache, if present */ @@ -6061,13 +6062,13 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) H5_CHECKED_ASSIGN(nbytes, size_t, shared_fo->layout.u.chunk.size, uint32_t); H5MM_memcpy(buf, ent->chunk, nbytes); - } /* end if */ + } else { /* read chunk data from the source file */ if(H5F_block_read(udata->file_src, H5FD_MEM_DRAW, chunk_rec->chunk_addr, nbytes, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, H5_ITER_ERROR, "unable to read raw data chunk") - } /* end else */ - } /* end else */ + } + } /* Need to uncompress filtered variable-length & reference data elements that are not found in chunk cache */ if(must_filter && (is_vlen || fix_ref) && !udata->chunk_in_cache) { @@ -7200,10 +7201,10 @@ H5D__get_num_chunks(const H5D_t *dset, const H5S_t H5_ATTR_UNUSED *space, hsize_ if((dset->shared->layout.storage.u.chunk.ops->iterate)(&idx_info, H5D__get_num_chunks_cb, &num_chunks) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve allocated chunk information from index") *nchunks = num_chunks; - } /* end else */ + } done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__get_num_chunks() */ @@ -7247,7 +7248,7 @@ H5D__get_chunk_info_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) /* Stop iterating */ ret_value = H5_ITER_STOP; - } /* end if */ + } /* Go to the next chunk */ else chunk_info->curr_idx++; @@ -7306,9 +7307,9 @@ H5D__get_chunk_info(const H5D_t *dset, const H5S_t H5_ATTR_UNUSED *space, hsize_ idx_info.storage = &dset->shared->layout.storage.u.chunk; /* Set addr & size for when dset is not written or queried chunk is not found */ - if(addr) + if (addr) *addr = HADDR_UNDEF; - if(size) + if (size) *size = 0; /* If the chunk is written, get its info, otherwise, return without error */ @@ -7341,7 +7342,7 @@ H5D__get_chunk_info(const H5D_t *dset, const H5S_t H5_ATTR_UNUSED *space, hsize_ } /* end if H5F_addr_defined */ done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__get_chunk_info() */ @@ -7374,12 +7375,12 @@ H5D__get_chunk_info_by_coord_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) HDassert(chunk_info); /* Going through the scaled, stop when a mismatch is found */ - for(ii = 0; ii < chunk_info->ndims && !different; ii++) - if(chunk_info->scaled[ii] != chunk_rec->scaled[ii]) + for (ii = 0; ii < chunk_info->ndims && !different; ii++) + if (chunk_info->scaled[ii] != chunk_rec->scaled[ii]) different = TRUE; /* Same scaled coords means the chunk is found, copy the chunk info */ - if(!different) { + if (!different) { chunk_info->nbytes = chunk_rec->nbytes; chunk_info->filter_mask = chunk_rec->filter_mask; chunk_info->chunk_addr = chunk_rec->chunk_addr; @@ -7387,7 +7388,7 @@ H5D__get_chunk_info_by_coord_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) /* Stop iterating */ ret_value = H5_ITER_STOP; - } /* end if */ + } FUNC_LEAVE_NOAPI(ret_value) } /* H5D__get_chunk_info_by_coord_cb() */ diff --git a/src/H5Dearray.c b/src/H5Dearray.c index eaa8c46..a53489e 100644 --- a/src/H5Dearray.c +++ b/src/H5Dearray.c @@ -11,10 +11,10 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* Programmer: Quincey Koziol - * Tuesday, January 27, 2009 +/* Programmer: Quincey Koziol + * Tuesday, January 27, 2009 * - * Purpose: Extensible array indexed (chunked) I/O functions. The chunks + * Purpose: Extensible array indexed (chunked) I/O functions. The chunks * are given a single-dimensional index which is used as the * offset in an extensible array that maps a chunk coordinate to * a disk address. @@ -183,7 +183,7 @@ const H5EA_class_t H5EA_CLS_CHUNK[1]={{ H5D__earray_fill, /* Fill block of missing elements callback */ H5D__earray_encode, /* Element encoding callback */ H5D__earray_decode, /* Element decoding callback */ - H5D__earray_debug, /* Element debugging callback */ + H5D__earray_debug, /* Element debugging callback */ H5D__earray_crt_dbg_context, /* Create debugging context */ H5D__earray_dst_dbg_context /* Destroy debugging context */ }}; @@ -216,14 +216,14 @@ H5FL_DEFINE_STATIC(H5D_earray_ctx_ud_t); /*------------------------------------------------------------------------- - * Function: H5D__earray_crt_context + * Function: H5D__earray_crt_context * - * Purpose: Create context for callbacks + * Purpose: Create context for callbacks * - * Return: Success: non-NULL - * Failure: NULL + * Return: Success: non-NULL + * Failure: NULL * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, January 29, 2009 * *------------------------------------------------------------------------- @@ -265,14 +265,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__earray_dst_context + * Function: H5D__earray_dst_context * - * Purpose: Destroy context for callbacks + * Purpose: Destroy context for callbacks * - * Return: Success: non-NULL - * Failure: NULL + * Return: Success: non-NULL + * Failure: NULL * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, January 29, 2009 * *------------------------------------------------------------------------- @@ -295,14 +295,14 @@ H5D__earray_dst_context(void *_ctx) /*------------------------------------------------------------------------- - * Function: H5D__earray_fill + * Function: H5D__earray_fill * - * Purpose: Fill "missing elements" in block of elements + * Purpose: Fill "missing elements" in block of elements * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Tuesday, January 27, 2009 * *------------------------------------------------------------------------- @@ -325,14 +325,14 @@ H5D__earray_fill(void *nat_blk, size_t nelmts) /*------------------------------------------------------------------------- - * Function: H5D__earray_encode + * Function: H5D__earray_encode * - * Purpose: Encode an element from "native" to "raw" form + * Purpose: Encode an element from "native" to "raw" form * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Tuesday, January 27, 2009 * *------------------------------------------------------------------------- @@ -369,14 +369,14 @@ H5D__earray_encode(void *raw, const void *_elmt, size_t nelmts, void *_ctx) /*------------------------------------------------------------------------- - * Function: H5D__earray_decode + * Function: H5D__earray_decode * - * Purpose: Decode an element from "raw" to "native" form + * Purpose: Decode an element from "raw" to "native" form * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, January 29, 2009 * *------------------------------------------------------------------------- @@ -413,14 +413,14 @@ H5D__earray_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx) /*------------------------------------------------------------------------- - * Function: H5D__earray_debug + * Function: H5D__earray_debug * - * Purpose: Display an element for debugging + * Purpose: Display an element for debugging * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, January 29, 2009 * *------------------------------------------------------------------------- @@ -447,14 +447,14 @@ H5D__earray_debug(FILE *stream, int indent, int fwidth, hsize_t idx, /*------------------------------------------------------------------------- - * Function: H5D__earray_filt_fill + * Function: H5D__earray_filt_fill * - * Purpose: Fill "missing elements" in block of elements + * Purpose: Fill "missing elements" in block of elements * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Saturday, January 31, 2009 * *------------------------------------------------------------------------- @@ -478,14 +478,14 @@ H5D__earray_filt_fill(void *nat_blk, size_t nelmts) /*------------------------------------------------------------------------- - * Function: H5D__earray_filt_encode + * Function: H5D__earray_filt_encode * - * Purpose: Encode an element from "native" to "raw" form + * Purpose: Encode an element from "native" to "raw" form * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Saturday, January 31, 2009 * *------------------------------------------------------------------------- @@ -525,14 +525,14 @@ H5D__earray_filt_encode(void *_raw, const void *_elmt, size_t nelmts, void *_ctx /*------------------------------------------------------------------------- - * Function: H5D__earray_filt_decode + * Function: H5D__earray_filt_decode * - * Purpose: Decode an element from "raw" to "native" form + * Purpose: Decode an element from "raw" to "native" form * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Saturday, January 31, 2009 * *------------------------------------------------------------------------- @@ -571,14 +571,14 @@ H5D__earray_filt_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx /*------------------------------------------------------------------------- - * Function: H5D__earray_filt_debug + * Function: H5D__earray_filt_debug * - * Purpose: Display an element for debugging + * Purpose: Display an element for debugging * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Saturday, January 31, 2009 * *------------------------------------------------------------------------- @@ -606,15 +606,15 @@ H5D__earray_filt_debug(FILE *stream, int indent, int fwidth, hsize_t idx, /*------------------------------------------------------------------------- - * Function: H5D__earray_crt_dbg_context + * Function: H5D__earray_crt_dbg_context * - * Purpose: Create context for debugging callback - * (get the layout message in the specified object header) + * Purpose: Create context for debugging callback + * (get the layout message in the specified object header) * - * Return: Success: non-NULL - * Failure: NULL + * Return: Success: non-NULL + * Failure: NULL * - * Programmer: Vailin Choi; July 2010 + * Programmer: Vailin Choi; July 2010 * *------------------------------------------------------------------------- */ @@ -680,15 +680,15 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__earray_dst_dbg_context + * Function: H5D__earray_dst_dbg_context * - * Purpose: Destroy context for debugging callback - * (free the layout message from the specified object header) + * Purpose: Destroy context for debugging callback + * (free the layout message from the specified object header) * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Vailin Choi; July 2010 + * Programmer: Vailin Choi; July 2010 * *------------------------------------------------------------------------- */ @@ -710,16 +710,16 @@ H5D__earray_dst_dbg_context(void *_dbg_ctx) /*------------------------------------------------------------------------- - * Function: H5D__earray_idx_depend + * Function: H5D__earray_idx_depend * - * Purpose: Create flush dependency between extensible array and dataset's + * Purpose: Create flush dependency between extensible array and dataset's * object header. * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Quincey Koziol - * Tuesday, June 2, 2009 + * Programmer: Quincey Koziol + * Tuesday, June 2, 2009 * *------------------------------------------------------------------------- */ @@ -772,20 +772,20 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__earray_idx_open + * Function: H5D__earray_idx_open * - * Purpose: Opens an existing extensible array. + * Purpose: Opens an existing extensible array. * - * Note: This information is passively initialized from each index + * Note: This information is passively initialized from each index * operation callback because those abstract chunk index operations * are designed to work with the v1 B-tree chunk indices also, * which don't require an 'open' for the data structure. * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Quincey Koziol - * Thursday, January 29, 2009 + * Programmer: Quincey Koziol + * Thursday, January 29, 2009 * *------------------------------------------------------------------------- */ @@ -814,7 +814,7 @@ H5D__earray_idx_open(const H5D_chk_idx_info_t *idx_info) /* Open the extensible array for the chunk index */ if(NULL == (idx_info->storage->u.earray.ea = H5EA_open(idx_info->f, idx_info->storage->idx_addr, &udata))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't open extensible array") + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't open extensible array") /* Check for SWMR writes to the file */ if(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) @@ -827,13 +827,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__earray_idx_init + * Function: H5D__earray_idx_init * - * Purpose: Initialize the indexing information for a dataset. + * Purpose: Initialize the indexing information for a dataset. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Wednesday, May 27, 2009 * *------------------------------------------------------------------------- @@ -862,7 +862,7 @@ H5D__earray_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t *space, /* Get the dim info for dataset */ if((sndims = H5S_get_simple_extent_dims(space, NULL, max_dims)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataspace dimensions") + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataspace dimensions") H5_CHECKED_ASSIGN(ndims, unsigned, sndims, int); /* Find the rank of the unlimited dimension */ @@ -895,20 +895,20 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__earray_idx_create + * Function: H5D__earray_idx_create * - * Purpose: Creates a new indexed-storage extensible array and initializes + * Purpose: Creates a new indexed-storage extensible array and initializes * the layout struct with information about the storage. The - * struct should be immediately written to the object header. + * struct should be immediately written to the object header. * - * This function must be called before passing LAYOUT to any of - * the other indexed storage functions! + * This function must be called before passing LAYOUT to any of + * the other indexed storage functions! * - * Return: Non-negative on success (with the LAYOUT argument initialized - * and ready to write to an object header). Negative on failure. + * Return: Non-negative on success (with the LAYOUT argument initialized + * and ready to write to an object header). Negative on failure. * - * Programmer: Quincey Koziol - * Tuesday, January 27, 2009 + * Programmer: Quincey Koziol + * Tuesday, January 27, 2009 * *------------------------------------------------------------------------- */ @@ -965,11 +965,11 @@ H5D__earray_idx_create(const H5D_chk_idx_info_t *idx_info) /* Create the extensible array for the chunk index */ if(NULL == (idx_info->storage->u.earray.ea = H5EA_create(idx_info->f, &cparam, &udata))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't create extensible array") + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't create extensible array") /* Get the address of the extensible array in file */ if(H5EA_get_addr(idx_info->storage->u.earray.ea, &(idx_info->storage->idx_addr)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't query extensible array address") + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't query extensible array address") /* Check for SWMR writes to the file */ if(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) @@ -982,14 +982,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__earray_idx_is_space_alloc + * Function: H5D__earray_idx_is_space_alloc * - * Purpose: Query if space is allocated for index method + * Purpose: Query if space is allocated for index method * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol - * Thursday, January 29, 2009 + * Programmer: Quincey Koziol + * Thursday, January 29, 2009 * *------------------------------------------------------------------------- */ @@ -1006,13 +1006,13 @@ H5D__earray_idx_is_space_alloc(const H5O_storage_chunk_t *storage) /*------------------------------------------------------------------------- - * Function: H5D__earray_idx_insert + * Function: H5D__earray_idx_insert * - * Purpose: Insert chunk address into the indexing structure. + * Purpose: Insert chunk address into the indexing structure. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Vailin Choi; May 2014 + * Programmer: Vailin Choi; May 2014 * *------------------------------------------------------------------------- */ @@ -1021,7 +1021,7 @@ H5D__earray_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata const H5D_t H5_ATTR_UNUSED *dset) { H5EA_t *ea; /* Pointer to extensible array structure */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1046,26 +1046,26 @@ H5D__earray_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata ea = idx_info->storage->u.earray.ea; if(!H5F_addr_defined(udata->chunk_block.offset)) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "The chunk should have allocated already") + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "The chunk should have allocated already") if(udata->chunk_idx != (udata->chunk_idx & 0xffffffff)) /* negative value */ - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "chunk index must be less than 2^32") + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "chunk index must be less than 2^32") /* Check for filters on chunks */ if(idx_info->pline->nused > 0) { - H5D_earray_filt_elmt_t elmt; /* Extensible array element */ + H5D_earray_filt_elmt_t elmt; /* Extensible array element */ - elmt.addr = udata->chunk_block.offset; + elmt.addr = udata->chunk_block.offset; H5_CHECKED_ASSIGN(elmt.nbytes, uint32_t, udata->chunk_block.length, hsize_t); - elmt.filter_mask = udata->filter_mask; + elmt.filter_mask = udata->filter_mask; - /* Set the info for the chunk */ - if(H5EA_set(ea, udata->chunk_idx, &elmt) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set chunk info") + /* Set the info for the chunk */ + if(H5EA_set(ea, udata->chunk_idx, &elmt) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set chunk info") } /* end if */ else { - /* Set the address for the chunk */ - if(H5EA_set(ea, udata->chunk_idx, &udata->chunk_block.offset) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set chunk address") + /* Set the address for the chunk */ + if(H5EA_set(ea, udata->chunk_idx, &udata->chunk_block.offset) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set chunk address") } /* end else */ done: @@ -1074,15 +1074,15 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__earray_idx_get_addr + * Function: H5D__earray_idx_get_addr * - * Purpose: Get the file address of a chunk if file space has been - * assigned. Save the retrieved information in the udata - * supplied. + * Purpose: Get the file address of a chunk if file space has been + * assigned. Save the retrieved information in the udata + * supplied. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, January 29, 2009 * *------------------------------------------------------------------------- @@ -1092,7 +1092,7 @@ H5D__earray_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *uda { H5EA_t *ea; /* Pointer to extensible array structure */ hsize_t idx; /* Array index of chunk */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1118,13 +1118,13 @@ H5D__earray_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *uda /* Check for unlimited dim. not being the slowest-changing dim. */ if(idx_info->layout->u.earray.unlim_dim > 0) { - hsize_t swizzled_coords[H5O_LAYOUT_NDIMS]; /* swizzled chunk coordinates */ + hsize_t swizzled_coords[H5O_LAYOUT_NDIMS]; /* swizzled chunk coordinates */ unsigned ndims = (idx_info->layout->ndims - 1); /* Number of dimensions */ - unsigned u; + unsigned u; - /* Compute coordinate offset from scaled offset */ - for(u = 0; u < ndims; u++) - swizzled_coords[u] = udata->common.scaled[u] * idx_info->layout->dim[u]; + /* Compute coordinate offset from scaled offset */ + for(u = 0; u < ndims; u++) + swizzled_coords[u] = udata->common.scaled[u] * idx_info->layout->dim[u]; H5VM_swizzle_coords(hsize_t, swizzled_coords, idx_info->layout->u.earray.unlim_dim); @@ -1157,12 +1157,12 @@ H5D__earray_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *uda HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk address") /* Update the other (constant) information for the chunk */ - udata->chunk_block.length = idx_info->layout->size; + udata->chunk_block.length = idx_info->layout->size; udata->filter_mask = 0; } /* end else */ if(!H5F_addr_defined(udata->chunk_block.offset)) - udata->chunk_block.length = 0; + udata->chunk_block.length = 0; done: FUNC_LEAVE_NOAPI(ret_value) @@ -1170,14 +1170,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__earray_idx_resize + * Function: H5D__earray_idx_resize * - * Purpose: Calculate/setup the swizzled down chunk array, used for chunk + * Purpose: Calculate/setup the swizzled down chunk array, used for chunk * index calculations. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, July 23, 2009 * *------------------------------------------------------------------------- @@ -1224,13 +1224,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__earray_idx_iterate_cb + * Function: H5D__earray_idx_iterate_cb * - * Purpose: Callback routine for extensible array element iteration. + * Purpose: Callback routine for extensible array element iteration. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Vailin Choi; Feb 2015 + * Programmer: Vailin Choi; Feb 2015 * *------------------------------------------------------------------------- */ @@ -1257,8 +1257,8 @@ H5D__earray_idx_iterate_cb(hsize_t H5_ATTR_UNUSED idx, const void *_elmt, void * /* Make "generic chunk" callback */ if(H5F_addr_defined(udata->chunk_rec.chunk_addr)) - if((ret_value = (udata->cb)(&udata->chunk_rec, udata->udata)) < 0) - HERROR(H5E_DATASET, H5E_CALLBACK, "failure in generic chunk iterator callback"); + if((ret_value = (udata->cb)(&udata->chunk_rec, udata->udata)) < 0) + HERROR(H5E_DATASET, H5E_CALLBACK, "failure in generic chunk iterator callback"); /* Update coordinates of chunk in dataset */ ndims = udata->common.layout->ndims - 1; @@ -1283,18 +1283,18 @@ H5D__earray_idx_iterate_cb(hsize_t H5_ATTR_UNUSED idx, const void *_elmt, void * /*------------------------------------------------------------------------- - * Function: H5D__earray_idx_iterate + * Function: H5D__earray_idx_iterate * - * Purpose: Iterate over the chunks in an index, making a callback + * Purpose: Iterate over the chunks in an index, making a callback * for each one. * - * Note: This implementation is slow, particularly for sparse + * Note: This implementation is slow, particularly for sparse * extensible arrays, replace it with call to H5EA_iterate() * when that's available. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, January 29, 2009 * *------------------------------------------------------------------------- @@ -1332,27 +1332,27 @@ H5D__earray_idx_iterate(const H5D_chk_idx_info_t *idx_info, /* Get the extensible array statistics */ if(H5EA_get_stats(ea, &ea_stat) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't query extensible array statistics") + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't query extensible array statistics") if(ea_stat.stored.max_idx_set > 0) { H5D_earray_it_ud_t udata; /* User data for iteration callback */ - /* Initialize userdata */ - HDmemset(&udata, 0, sizeof udata); - udata.common.layout = idx_info->layout; - udata.common.storage = idx_info->storage; + /* Initialize userdata */ + HDmemset(&udata, 0, sizeof udata); + udata.common.layout = idx_info->layout; + udata.common.storage = idx_info->storage; HDmemset(&udata.chunk_rec, 0, sizeof(udata.chunk_rec)); udata.filtered = (idx_info->pline->nused > 0); if(!udata.filtered) { udata.chunk_rec.nbytes = idx_info->layout->size; udata.chunk_rec.filter_mask = 0; } /* end if */ - udata.cb = chunk_cb; - udata.udata = chunk_udata; + udata.cb = chunk_cb; + udata.udata = chunk_udata; /* Iterate over the extensible array elements */ - if((ret_value = H5EA_iterate(ea, H5D__earray_idx_iterate_cb, &udata)) < 0) - HERROR(H5E_DATASET, H5E_BADITER, "unable to iterate over fixed array chunk index"); + if((ret_value = H5EA_iterate(ea, H5D__earray_idx_iterate_cb, &udata)) < 0) + HERROR(H5E_DATASET, H5E_BADITER, "unable to iterate over fixed array chunk index"); } /* end if */ done: @@ -1361,13 +1361,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__earray_idx_remove + * Function: H5D__earray_idx_remove * - * Purpose: Remove chunk from index. + * Purpose: Remove chunk from index. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, January 29, 2009 * *------------------------------------------------------------------------- @@ -1377,7 +1377,7 @@ H5D__earray_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t { H5EA_t *ea; /* Pointer to extensible array structure */ hsize_t idx; /* Array index of chunk */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1404,13 +1404,13 @@ H5D__earray_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t /* Check for unlimited dim. not being the slowest-changing dim. */ if(idx_info->layout->u.earray.unlim_dim > 0) { - hsize_t swizzled_coords[H5O_LAYOUT_NDIMS]; /* swizzled chunk coordinates */ + hsize_t swizzled_coords[H5O_LAYOUT_NDIMS]; /* swizzled chunk coordinates */ unsigned ndims = (idx_info->layout->ndims - 1); /* Number of dimensions */ - unsigned u; + unsigned u; - /* Compute coordinate offset from scaled offset */ - for(u = 0; u < ndims; u++) - swizzled_coords[u] = udata->scaled[u] * idx_info->layout->dim[u]; + /* Compute coordinate offset from scaled offset */ + for(u = 0; u < ndims; u++) + swizzled_coords[u] = udata->scaled[u] * idx_info->layout->dim[u]; H5VM_swizzle_coords(hsize_t, swizzled_coords, idx_info->layout->u.earray.unlim_dim); @@ -1472,14 +1472,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__earray_idx_delete_cb + * Function: H5D__earray_idx_delete_cb * - * Purpose: Delete space for chunk in file + * Purpose: Delete space for chunk in file * - * Return: Success: Non-negative - * Failure: negative + * Return: Success: Non-negative + * Failure: negative * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Saturday, January 31, 2009 * *------------------------------------------------------------------------- @@ -1509,19 +1509,19 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__earray_idx_delete + * Function: H5D__earray_idx_delete * - * Purpose: Delete index and raw data storage for entire dataset + * Purpose: Delete index and raw data storage for entire dataset * (i.e. all chunks) * - * Note: This implementation is slow, particularly for sparse + * Note: This implementation is slow, particularly for sparse * extensible arrays, replace it with call to H5EA_iterate() * when that's available. * - * Return: Success: Non-negative - * Failure: negative + * Return: Success: Non-negative + * Failure: negative * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, January 29, 2009 * *------------------------------------------------------------------------- @@ -1571,13 +1571,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__earray_idx_copy_setup + * Function: H5D__earray_idx_copy_setup * - * Purpose: Set up any necessary information for copying chunks + * Purpose: Set up any necessary information for copying chunks * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Saturday, January 31, 2009 * *------------------------------------------------------------------------- @@ -1626,13 +1626,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__earray_idx_copy_shutdown + * Function: H5D__earray_idx_copy_shutdown * - * Purpose: Shutdown any information from copying chunks + * Purpose: Shutdown any information from copying chunks * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Saturday, January 31, 2009 * *------------------------------------------------------------------------- @@ -1704,7 +1704,7 @@ H5D__earray_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *index_size) /* Get the extensible array statistics */ if(H5EA_get_stats(ea, &ea_stat) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't query extensible array statistics") + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't query extensible array statistics") /* Set the size of the extensible array */ *index_size = ea_stat.computed.hdr_size + ea_stat.computed.index_blk_size @@ -1722,13 +1722,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__earray_idx_reset + * Function: H5D__earray_idx_reset * - * Purpose: Reset indexing information. + * Purpose: Reset indexing information. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Saturday, January 31, 2009 * *------------------------------------------------------------------------- @@ -1743,7 +1743,7 @@ H5D__earray_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr) /* Reset index info */ if(reset_addr) { - storage->idx_addr = HADDR_UNDEF; + storage->idx_addr = HADDR_UNDEF; storage->u.earray.dset_ohdr_addr = HADDR_UNDEF; } /* end if */ storage->u.earray.ea = NULL; @@ -1753,13 +1753,13 @@ H5D__earray_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr) /*------------------------------------------------------------------------- - * Function: H5D__earray_idx_dump + * Function: H5D__earray_idx_dump * - * Purpose: Dump indexing information to a stream. + * Purpose: Dump indexing information to a stream. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Saturday, January 31, 2009 * *------------------------------------------------------------------------- @@ -1780,13 +1780,13 @@ H5D__earray_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream) /*------------------------------------------------------------------------- - * Function: H5D__earray_idx_dest + * Function: H5D__earray_idx_dest * - * Purpose: Release indexing information in memory. + * Purpose: Release indexing information in memory. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Saturday, January 31, 2009 * *------------------------------------------------------------------------- @@ -1806,7 +1806,7 @@ H5D__earray_idx_dest(const H5D_chk_idx_info_t *idx_info) /* Check if the extensible array is open */ if(idx_info->storage->u.earray.ea) { - /* Patch the top level file pointer contained in ea if needed */ + /* Patch the top level file pointer contained in ea if needed */ if(H5EA_patch_file(idx_info->storage->u.earray.ea, idx_info->f) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch earray file pointer") diff --git a/src/H5Dfarray.c b/src/H5Dfarray.c index cbaa52d..a9202c2 100644 --- a/src/H5Dfarray.c +++ b/src/H5Dfarray.c @@ -11,12 +11,12 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* Programmer: Vailin Choi - * Thursday, April 30, 2009 +/* Programmer: Vailin Choi + * Thursday, April 30, 2009 * - * Purpose: Fixed array indexed (chunked) I/O functions. - * The chunk coordinate is mapped as an index into an array of - * disk addresses for the chunks. + * Purpose: Fixed array indexed (chunked) I/O functions. + * The chunk coordinate is mapped as an index into an array of + * disk addresses for the chunks. * */ @@ -30,13 +30,13 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FAprivate.h" /* Fixed arrays */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MFprivate.h" /* File space management */ -#include "H5VMprivate.h" /* Vector functions */ +#include "H5private.h" /* Generic Functions */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FAprivate.h" /* Fixed arrays */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MFprivate.h" /* File space management */ +#include "H5VMprivate.h" /* Vector functions */ /****************/ @@ -212,14 +212,14 @@ H5FL_DEFINE_STATIC(H5D_farray_ctx_ud_t); /*------------------------------------------------------------------------- - * Function: H5D__farray_crt_context + * Function: H5D__farray_crt_context * - * Purpose: Create context for callbacks + * Purpose: Create context for callbacks * - * Return: Success: non-NULL - * Failure: NULL + * Return: Success: non-NULL + * Failure: NULL * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- @@ -261,14 +261,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__farray_dst_context + * Function: H5D__farray_dst_context * - * Purpose: Destroy context for callbacks + * Purpose: Destroy context for callbacks * - * Return: Success: non-NULL - * Failure: NULL + * Return: Success: non-NULL + * Failure: NULL * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- @@ -291,14 +291,14 @@ H5D__farray_dst_context(void *_ctx) /*------------------------------------------------------------------------- - * Function: H5D__farray_fill + * Function: H5D__farray_fill * - * Purpose: Fill "missing elements" in block of elements + * Purpose: Fill "missing elements" in block of elements * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- @@ -321,14 +321,14 @@ H5D__farray_fill(void *nat_blk, size_t nelmts) /*------------------------------------------------------------------------- - * Function: H5D__farray_encode + * Function: H5D__farray_encode * - * Purpose: Encode an element from "native" to "raw" form + * Purpose: Encode an element from "native" to "raw" form * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- @@ -365,14 +365,14 @@ H5D__farray_encode(void *raw, const void *_elmt, size_t nelmts, void *_ctx) /*------------------------------------------------------------------------- - * Function: H5D__farray_decode + * Function: H5D__farray_decode * - * Purpose: Decode an element from "raw" to "native" form + * Purpose: Decode an element from "raw" to "native" form * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- @@ -409,14 +409,14 @@ H5D__farray_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx) /*------------------------------------------------------------------------- - * Function: H5D__farray_debug + * Function: H5D__farray_debug * - * Purpose: Display an element for debugging + * Purpose: Display an element for debugging * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- @@ -443,23 +443,23 @@ H5D__farray_debug(FILE *stream, int indent, int fwidth, hsize_t idx, /*------------------------------------------------------------------------- - * Function: H5D__farray_crt_dbg_context + * Function: H5D__farray_crt_dbg_context * - * Purpose: Create context for debugging callback - * (get the layout message in the specified object header) + * Purpose: Create context for debugging callback + * (get the layout message in the specified object header) * - * Return: Success: non-NULL - * Failure: NULL + * Return: Success: non-NULL + * Failure: NULL * - * Programmer: Vailin Choi - * 5th August, 2009 + * Programmer: Vailin Choi + * 5th August, 2009 * *------------------------------------------------------------------------- */ static void * H5D__farray_crt_dbg_context(H5F_t *f, haddr_t obj_addr) { - H5D_farray_ctx_ud_t *dbg_ctx = NULL; /* Context for fixed array callback */ + H5D_farray_ctx_ud_t *dbg_ctx = NULL; /* Context for fixed array callback */ H5O_loc_t obj_loc; /* Pointer to an object's location */ hbool_t obj_opened = FALSE; /* Flag to indicate that the object header was opened */ H5O_layout_t layout; /* Layout message */ @@ -518,23 +518,23 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__farray_dst_dbg_context + * Function: H5D__farray_dst_dbg_context * - * Purpose: Destroy context for debugging callback - * (free the layout message from the specified object header) + * Purpose: Destroy context for debugging callback + * (free the layout message from the specified object header) * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Quincey Koziol - * 24th September, 2009 + * Programmer: Quincey Koziol + * 24th September, 2009 * *------------------------------------------------------------------------- */ static herr_t H5D__farray_dst_dbg_context(void *_dbg_ctx) { - H5D_farray_ctx_ud_t *dbg_ctx = (H5D_farray_ctx_ud_t *)_dbg_ctx; /* Context for fixed array callback */ + H5D_farray_ctx_ud_t *dbg_ctx = (H5D_farray_ctx_ud_t *)_dbg_ctx; /* Context for fixed array callback */ FUNC_ENTER_STATIC_NOERR @@ -549,14 +549,14 @@ H5D__farray_dst_dbg_context(void *_dbg_ctx) /*------------------------------------------------------------------------- - * Function: H5D__farray_filt_fill + * Function: H5D__farray_filt_fill * - * Purpose: Fill "missing elements" in block of elements + * Purpose: Fill "missing elements" in block of elements * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- @@ -580,14 +580,14 @@ H5D__farray_filt_fill(void *nat_blk, size_t nelmts) /*------------------------------------------------------------------------- - * Function: H5D__farray_filt_encode + * Function: H5D__farray_filt_encode * - * Purpose: Encode an element from "native" to "raw" form + * Purpose: Encode an element from "native" to "raw" form * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- @@ -612,7 +612,7 @@ H5D__farray_filt_encode(void *_raw, const void *_elmt, size_t nelmts, void *_ctx /* Encode element */ /* (advances 'raw' pointer) */ H5F_addr_encode_len(ctx->file_addr_len, &raw, elmt->addr); - UINT64ENCODE_VAR(raw, elmt->nbytes, ctx->chunk_size_len); + UINT64ENCODE_VAR(raw, elmt->nbytes, ctx->chunk_size_len); UINT32ENCODE(raw, elmt->filter_mask); /* Advance native element pointer */ @@ -627,14 +627,14 @@ H5D__farray_filt_encode(void *_raw, const void *_elmt, size_t nelmts, void *_ctx /*------------------------------------------------------------------------- - * Function: H5D__farray_filt_decode + * Function: H5D__farray_filt_decode * - * Purpose: Decode an element from "raw" to "native" form + * Purpose: Decode an element from "raw" to "native" form * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- @@ -658,7 +658,7 @@ H5D__farray_filt_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx /* Decode element */ /* (advances 'raw' pointer) */ H5F_addr_decode_len(ctx->file_addr_len, &raw, &elmt->addr); - UINT64DECODE_VAR(raw, elmt->nbytes, ctx->chunk_size_len); + UINT64DECODE_VAR(raw, elmt->nbytes, ctx->chunk_size_len); UINT32DECODE(raw, elmt->filter_mask); /* Advance native element pointer */ @@ -673,14 +673,14 @@ H5D__farray_filt_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx /*------------------------------------------------------------------------- - * Function: H5D__farray_filt_debug + * Function: H5D__farray_filt_debug * - * Purpose: Display an element for debugging + * Purpose: Display an element for debugging * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- @@ -708,15 +708,15 @@ H5D__farray_filt_debug(FILE *stream, int indent, int fwidth, hsize_t idx, /*------------------------------------------------------------------------- - * Function: H5D__farray_idx_depend + * Function: H5D__farray_idx_depend * - * Purpose: Create flush dependency between fixed array and dataset's + * Purpose: Create flush dependency between fixed array and dataset's * object header. * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- @@ -798,15 +798,15 @@ H5D__farray_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t H5_ATTR_UNU /*------------------------------------------------------------------------- - * Function: H5D__farray_idx_open + * Function: H5D__farray_idx_open * - * Purpose: Opens an existing fixed array and initializes + * Purpose: Opens an existing fixed array and initializes * the layout struct with information about the storage. * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- @@ -836,7 +836,7 @@ H5D__farray_idx_open(const H5D_chk_idx_info_t *idx_info) /* Open the fixed array for the chunk index */ if(NULL == (idx_info->storage->u.farray.fa = H5FA_open(idx_info->f, idx_info->storage->idx_addr, &udata))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't open fixed array") + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't open fixed array") /* Check for SWMR writes to the file */ if(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) @@ -849,19 +849,19 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__farray_idx_create + * Function: H5D__farray_idx_create * - * Purpose: Creates a new indexed-storage fixed array and initializes + * Purpose: Creates a new indexed-storage fixed array and initializes * the layout struct with information about the storage. The - * struct should be immediately written to the object header. + * struct should be immediately written to the object header. * - * This function must be called before passing LAYOUT to any of - * the other indexed storage functions! + * This function must be called before passing LAYOUT to any of + * the other indexed storage functions! * - * Return: Non-negative on success (with the LAYOUT argument initialized - * and ready to write to an object header). Negative on failure. + * Return: Non-negative on success (with the LAYOUT argument initialized + * and ready to write to an object header). Negative on failure. * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- @@ -869,9 +869,9 @@ done: static herr_t H5D__farray_idx_create(const H5D_chk_idx_info_t *idx_info) { - H5FA_create_t cparam; /* Fixed array creation parameters */ + H5FA_create_t cparam; /* Fixed array creation parameters */ H5D_farray_ctx_ud_t udata; /* User data for fixed array create call */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -887,7 +887,7 @@ H5D__farray_idx_create(const H5D_chk_idx_info_t *idx_info) /* General parameters */ if(idx_info->pline->nused > 0) { - unsigned chunk_size_len; /* Size of encoded chunk size */ + unsigned chunk_size_len; /* Size of encoded chunk size */ /* Compute the size required for encoding the size of a chunk, allowing * for an extra byte, in case the filter makes the chunk larger. @@ -913,11 +913,11 @@ H5D__farray_idx_create(const H5D_chk_idx_info_t *idx_info) /* Create the fixed array for the chunk index */ if(NULL == (idx_info->storage->u.farray.fa = H5FA_create(idx_info->f, &cparam, &udata))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't create fixed array") + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't create fixed array") /* Get the address of the fixed array in file */ if(H5FA_get_addr(idx_info->storage->u.farray.fa, &(idx_info->storage->idx_addr)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't query fixed array address") + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't query fixed array address") /* Check for SWMR writes to the file */ if(H5F_INTENT(idx_info->f) & H5F_ACC_SWMR_WRITE) @@ -930,13 +930,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__farray_idx_is_space_alloc + * Function: H5D__farray_idx_is_space_alloc * - * Purpose: Query if space is allocated for index method + * Purpose: Query if space is allocated for index method * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- @@ -954,13 +954,13 @@ H5D__farray_idx_is_space_alloc(const H5O_storage_chunk_t *storage) /*------------------------------------------------------------------------- - * Function: H5D__farray_idx_insert + * Function: H5D__farray_idx_insert * - * Purpose: Insert chunk address into the indexing structure. + * Purpose: Insert chunk address into the indexing structure. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Vailin Choi; 5 May 2014 + * Programmer: Vailin Choi; 5 May 2014 * *------------------------------------------------------------------------- */ @@ -968,8 +968,8 @@ static herr_t H5D__farray_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, const H5D_t H5_ATTR_UNUSED *dset) { - H5FA_t *fa; /* Pointer to fixed array structure */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FA_t *fa; /* Pointer to fixed array structure */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -988,7 +988,7 @@ H5D__farray_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata if(H5D__farray_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open fixed array") } else /* Patch the top level file pointer contained in fa if needed */ - H5FA_patch_file(idx_info->storage->u.farray.fa, idx_info->f); + H5FA_patch_file(idx_info->storage->u.farray.fa, idx_info->f); /* Set convenience pointer to fixed array structure */ fa = idx_info->storage->u.farray.fa; @@ -1002,13 +1002,13 @@ H5D__farray_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata if(idx_info->pline->nused > 0) { H5D_farray_filt_elmt_t elmt; /* Fixed array element */ - elmt.addr = udata->chunk_block.offset; + elmt.addr = udata->chunk_block.offset; H5_CHECKED_ASSIGN(elmt.nbytes, uint32_t, udata->chunk_block.length, hsize_t); elmt.filter_mask = udata->filter_mask; /* Set the info for the chunk */ if(H5FA_set(fa, udata->chunk_idx, &elmt) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set chunk info") + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set chunk info") } /* end if */ else { /* Set the address for the chunk */ @@ -1022,15 +1022,15 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__farray_idx_get_addr + * Function: H5D__farray_idx_get_addr * - * Purpose: Get the file address of a chunk if file space has been - * assigned. Save the retrieved information in the udata - * supplied. + * Purpose: Get the file address of a chunk if file space has been + * assigned. Save the retrieved information in the udata + * supplied. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- @@ -1038,9 +1038,9 @@ done: static herr_t H5D__farray_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata) { - H5FA_t *fa; /* Pointer to fixed array structure */ - hsize_t idx; /* Array index of chunk */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FA_t *fa; /* Pointer to fixed array structure */ + hsize_t idx; /* Array index of chunk */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1059,7 +1059,7 @@ H5D__farray_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *uda if(H5D__farray_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open fixed array") } else /* Patch the top level file pointer contained in fa if needed */ - H5FA_patch_file(idx_info->storage->u.farray.fa, idx_info->f); + H5FA_patch_file(idx_info->storage->u.farray.fa, idx_info->f); /* Set convenience pointer to fixed array structure */ fa = idx_info->storage->u.farray.fa; @@ -1088,12 +1088,12 @@ H5D__farray_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *uda HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk address") /* Update the other (constant) information for the chunk */ - udata->chunk_block.length = idx_info->layout->size; + udata->chunk_block.length = idx_info->layout->size; udata->filter_mask = 0; } /* end else */ if(!H5F_addr_defined(udata->chunk_block.offset)) - udata->chunk_block.length = 0; + udata->chunk_block.length = 0; done: FUNC_LEAVE_NOAPI(ret_value) @@ -1101,13 +1101,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__farray_idx_iterate_cb + * Function: H5D__farray_idx_iterate_cb * - * Purpose: Callback routine for fixed array element iteration. + * Purpose: Callback routine for fixed array element iteration. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- @@ -1135,8 +1135,8 @@ H5D__farray_idx_iterate_cb(hsize_t H5_ATTR_UNUSED idx, const void *_elmt, void * /* Make "generic chunk" callback */ if(H5F_addr_defined(udata->chunk_rec.chunk_addr)) - if((ret_value = (udata->cb)(&udata->chunk_rec, udata->udata)) < 0) - HERROR(H5E_DATASET, H5E_CALLBACK, "failure in generic chunk iterator callback"); + if((ret_value = (udata->cb)(&udata->chunk_rec, udata->udata)) < 0) + HERROR(H5E_DATASET, H5E_CALLBACK, "failure in generic chunk iterator callback"); /* Update coordinates of chunk in dataset */ ndims = udata->common.layout->ndims - 1; @@ -1161,14 +1161,14 @@ H5D__farray_idx_iterate_cb(hsize_t H5_ATTR_UNUSED idx, const void *_elmt, void * /*------------------------------------------------------------------------- - * Function: H5D__farray_idx_iterate + * Function: H5D__farray_idx_iterate * - * Purpose: Iterate over the chunks in an index, making a callback + * Purpose: Iterate over the chunks in an index, making a callback * for each one. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- @@ -1199,35 +1199,35 @@ H5D__farray_idx_iterate(const H5D_chk_idx_info_t *idx_info, if(H5D__farray_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open fixed array") } else /* Patch the top level file pointer contained in fa if needed */ - H5FA_patch_file(idx_info->storage->u.farray.fa, idx_info->f); + H5FA_patch_file(idx_info->storage->u.farray.fa, idx_info->f); /* Set convenience pointer to fixed array structure */ fa = idx_info->storage->u.farray.fa; /* Get the fixed array statistics */ if(H5FA_get_stats(fa, &fa_stat) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't query fixed array statistics") + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't query fixed array statistics") /* Check if there are any array elements */ if(fa_stat.nelmts > 0) { H5D_farray_it_ud_t udata; /* User data for iteration callback */ - /* Initialize userdata */ - HDmemset(&udata, 0, sizeof udata); - udata.common.layout = idx_info->layout; - udata.common.storage = idx_info->storage; + /* Initialize userdata */ + HDmemset(&udata, 0, sizeof udata); + udata.common.layout = idx_info->layout; + udata.common.storage = idx_info->storage; HDmemset(&udata.chunk_rec, 0, sizeof(udata.chunk_rec)); udata.filtered = (idx_info->pline->nused > 0); if(!udata.filtered) { udata.chunk_rec.nbytes = idx_info->layout->size; udata.chunk_rec.filter_mask = 0; } /* end if */ - udata.cb = chunk_cb; - udata.udata = chunk_udata; + udata.cb = chunk_cb; + udata.udata = chunk_udata; /* Iterate over the fixed array elements */ - if((ret_value = H5FA_iterate(fa, H5D__farray_idx_iterate_cb, &udata)) < 0) - HERROR(H5E_DATASET, H5E_BADITER, "unable to iterate over fixed array chunk index"); + if((ret_value = H5FA_iterate(fa, H5D__farray_idx_iterate_cb, &udata)) < 0) + HERROR(H5E_DATASET, H5E_BADITER, "unable to iterate over fixed array chunk index"); } /* end if */ done: @@ -1236,13 +1236,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__farray_idx_remove + * Function: H5D__farray_idx_remove * - * Purpose: Remove chunk from index. + * Purpose: Remove chunk from index. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- @@ -1250,9 +1250,9 @@ done: static herr_t H5D__farray_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *udata) { - H5FA_t *fa; /* Pointer to fixed array structure */ - hsize_t idx; /* Array index of chunk */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FA_t *fa; /* Pointer to fixed array structure */ + hsize_t idx; /* Array index of chunk */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1271,7 +1271,7 @@ H5D__farray_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t if(H5D__farray_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open fixed array") } else /* Patch the top level file pointer contained in fa if needed */ - if(H5FA_patch_file(idx_info->storage->u.farray.fa, idx_info->f) < 0) + if(H5FA_patch_file(idx_info->storage->u.farray.fa, idx_info->f) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch fixed array file pointer") /* Set convenience pointer to fixed array structure */ @@ -1330,14 +1330,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__farray_idx_delete_cb + * Function: H5D__farray_idx_delete_cb * - * Purpose: Delete space for chunk in file + * Purpose: Delete space for chunk in file * - * Return: Success: Non-negative - * Failure: negative + * Return: Success: Non-negative + * Failure: negative * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- @@ -1367,15 +1367,15 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__farray_idx_delete + * Function: H5D__farray_idx_delete * - * Purpose: Delete index and raw data storage for entire dataset + * Purpose: Delete index and raw data storage for entire dataset * (i.e. all chunks) * - * Return: Success: Non-negative - * Failure: negative + * Return: Success: Non-negative + * Failure: negative * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- @@ -1398,7 +1398,7 @@ H5D__farray_idx_delete(const H5D_chk_idx_info_t *idx_info) if(H5F_addr_defined(idx_info->storage->idx_addr)) { H5D_farray_ctx_ud_t ctx_udata; /* User data for fixed array open call */ - /* Iterate over the chunk addresses in the fixed array, deleting each chunk */ + /* Iterate over the chunk addresses in the fixed array, deleting each chunk */ if(H5D__farray_idx_iterate(idx_info, H5D__farray_idx_delete_cb, idx_info->f) < 0) HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to iterate over chunk addresses") @@ -1425,13 +1425,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__farray_idx_copy_setup + * Function: H5D__farray_idx_copy_setup * - * Purpose: Set up any necessary information for copying chunks + * Purpose: Set up any necessary information for copying chunks * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- @@ -1480,13 +1480,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__farray_idx_copy_shutdown + * Function: H5D__farray_idx_copy_shutdown * - * Purpose: Shutdown any information from copying chunks + * Purpose: Shutdown any information from copying chunks * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- @@ -1526,7 +1526,7 @@ done: * Return: Success: Non-negative * Failure: negative * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- @@ -1558,7 +1558,7 @@ H5D__farray_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *index_size) /* Get the fixed array statistics */ if(H5FA_get_stats(fa, &fa_stat) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't query fixed array statistics") + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't query fixed array statistics") *index_size = fa_stat.hdr_size; *index_size += fa_stat.dblk_size; @@ -1575,13 +1575,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__farray_idx_reset + * Function: H5D__farray_idx_reset * - * Purpose: Reset indexing information. + * Purpose: Reset indexing information. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- @@ -1596,7 +1596,7 @@ H5D__farray_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr) /* Reset index info */ if(reset_addr) - storage->idx_addr = HADDR_UNDEF; + storage->idx_addr = HADDR_UNDEF; storage->u.farray.fa = NULL; FUNC_LEAVE_NOAPI(SUCCEED) @@ -1604,13 +1604,13 @@ H5D__farray_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr) /*------------------------------------------------------------------------- - * Function: H5D__farray_idx_dump + * Function: H5D__farray_idx_dump * - * Purpose: Dump indexing information to a stream. + * Purpose: Dump indexing information to a stream. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- @@ -1631,13 +1631,13 @@ H5D__farray_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream) /*------------------------------------------------------------------------- - * Function: H5D__farray_idx_dest + * Function: H5D__farray_idx_dest * - * Purpose: Release indexing information in memory. + * Purpose: Release indexing information in memory. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Vailin Choi + * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- @@ -1657,8 +1657,8 @@ H5D__farray_idx_dest(const H5D_chk_idx_info_t *idx_info) /* Check if the fixed array is open */ if(idx_info->storage->u.farray.fa) { - /* Patch the top level file pointer contained in fa if needed */ - if(H5FA_patch_file(idx_info->storage->u.farray.fa, idx_info->f) < 0) + /* Patch the top level file pointer contained in fa if needed */ + if(H5FA_patch_file(idx_info->storage->u.farray.fa, idx_info->f) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch fixed array file pointer") /* Close fixed array */ diff --git a/src/H5Dint.c b/src/H5Dint.c index 9f7e004..c063bb9 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -78,7 +78,7 @@ typedef struct { /********************/ /* General stuff */ -static H5D_shared_t *H5D__new(hid_t dcpl_id, hid_t dapl, hbool_t creating, hbool_t vl_type); +static H5D_shared_t *H5D__new(hid_t dcpl_id, hid_t dapl_id, hbool_t creating, hbool_t vl_type); static herr_t H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, const H5T_t *type); static herr_t H5D__cache_dataspace_info(const H5D_t *dset); static herr_t H5D__init_space(H5F_t *file, const H5D_t *dset, const H5S_t *space); @@ -207,6 +207,9 @@ H5D__init_package(void) /* Reset the "default dataset" information */ HDmemset(&H5D_def_dset, 0, sizeof(H5D_shared_t)); + H5D_def_dset.type_id = H5I_INVALID_HID; + H5D_def_dset.dapl_id = H5I_INVALID_HID; + H5D_def_dset.dcpl_id = H5I_INVALID_HID; /* Get the default dataset creation property list values and initialize the * default dataset with them. @@ -740,7 +743,7 @@ H5D__use_minimized_dset_headers(H5F_t *file, hbool_t *minimize) { herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT; + FUNC_ENTER_STATIC HDassert(file); HDassert(minimize); @@ -781,7 +784,7 @@ H5D__calculate_minimum_header_size(H5F_t *file, H5D_t *dset, H5O_t *ohdr) size_t get_value = 0; size_t ret_value = 0; - FUNC_ENTER_NOAPI_NOINIT; + FUNC_ENTER_STATIC HDassert(file); HDassert(dset); @@ -899,7 +902,7 @@ H5D__prepare_minimized_oh(H5F_t *file, H5D_t *dset, H5O_loc_t *oloc) size_t ohdr_size = 0; herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT; + FUNC_ENTER_STATIC HDassert(file); HDassert(dset); @@ -944,7 +947,7 @@ H5D__update_oh_info(H5F_t *file, H5D_t *dset, hid_t dapl_id) hbool_t fill_changed = FALSE; /* Flag indicating the fill value was changed */ hbool_t layout_init = FALSE; /* Flag to indicate that chunk information was initialized */ hbool_t use_at_least_v18; /* Flag indicating to use at least v18 format versions */ - hbool_t minimize_header = FALSE; + hbool_t use_minimized_header = FALSE; /* Flag to use minimized dataset object headers */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1013,10 +1016,10 @@ H5D__update_oh_info(H5F_t *file, H5D_t *dset, hid_t dapl_id) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set fill value info") } /* end if */ - if(H5D__use_minimized_dset_headers(file, &minimize_header) == FAIL) + if(H5D__use_minimized_dset_headers(file, &use_minimized_header) == FAIL) HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get minimize settings") - if(TRUE == minimize_header) { + if(TRUE == use_minimized_header) { if(H5D__prepare_minimized_oh(file, dset, oloc) == FAIL) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't create minimized dataset object header") } else { @@ -1029,7 +1032,7 @@ H5D__update_oh_info(H5F_t *file, H5D_t *dset, hid_t dapl_id) /* Create an object header for the dataset */ if(H5O_create(file, ohdr_size, (size_t)1, dset->shared->dcpl_id, oloc/*out*/) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset object header") - } /* If use minimum/standard object header space */ + } /* if using default/minimized object headers */ HDassert(file == dset->oloc.file); @@ -1162,17 +1165,19 @@ H5D__build_file_prefix(const H5D_t *dset, H5F_prefix_open_t prefix_type, char ** if(H5F_PREFIX_VDS == prefix_type) { prefix = H5D_prefix_vds_env; - if(prefix == NULL || *prefix == '\0') + if(prefix == NULL || *prefix == '\0') { if(H5CX_get_vds_prefix(&prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get the prefix for vds file") - } /* end if */ + } + } else if(H5F_PREFIX_EFILE == prefix_type) { prefix = H5D_prefix_ext_env; - if(prefix == NULL || *prefix == '\0') + if(prefix == NULL || *prefix == '\0') { if(H5CX_get_ext_file_prefix(&prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get the prefix for the external file") - } /* end else-if */ + } + } else HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "prefix name is not sensible") @@ -1278,6 +1283,7 @@ H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, /* Initialize the shared dataset space */ if(NULL == (new_dset->shared = H5D__new(dcpl_id, dapl_id, TRUE, has_vl_type))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + /* Copy & initialize datatype for dataset */ if(H5D__init_type(file, new_dset, type_id, type) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "can't copy datatype") @@ -2030,7 +2036,7 @@ H5D_close(H5D_t *dataset) if(H5AC_cork(dataset->oloc.file, dataset->oloc.addr, H5AC__UNCORK, NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTUNCORK, FAIL, "unable to uncork an object") - /* Release datatype, dataspace and creation and access property lists -- there isn't + /* Release datatype, dataspace, and creation and access property lists -- there isn't * much we can do if one of these fails, so we just continue. */ free_failed |= (H5I_dec_ref(dataset->shared->type_id) < 0) || @@ -2560,7 +2566,7 @@ done: /*------------------------------------------------------------------------- * Function: H5D__get_offset * - * Purpose: Private function for H5D__get_offset. Returns the address + * Purpose: Private function for H5Dget_offset(). Returns the address * of dataset in file. * * Return: Success: The address of dataset diff --git a/src/H5Dio.c b/src/H5Dio.c index 84b7e7a..a972e00 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -149,7 +149,7 @@ done: * The PLIST_ID can be the constant H5P_DEFAULT in which * case the default data transfer properties are used. * - * Return: SUCCEED/FAIL + * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, December 4, 1997 @@ -271,7 +271,7 @@ done: * The PLIST_ID can be the constant H5P_DEFAULT in which * case the default data transfer properties are used. * - * Return: SUCCEED/FAIL + * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Thursday, December 4, 1997 @@ -280,7 +280,7 @@ done: */ herr_t H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, - hid_t file_space_id, hid_t dxpl_id, const void *buf) + hid_t file_space_id, hid_t dxpl_id, const void *buf) { H5VL_object_t *vol_obj = NULL; herr_t ret_value = SUCCEED; /* Return value */ @@ -410,7 +410,7 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, /* projected mem space must be discarded at the */ /* end of the function to avoid a memory leak. */ H5D_storage_t store; /* union of EFL and chunk pointer in file space */ - hsize_t nelmts; /* total number of elmts */ + hsize_t nelmts; /* total number of elmts */ hbool_t io_op_init = FALSE; /* Whether the I/O op has been initialized */ char fake_char; /* Temporary variable for NULL buffer pointers */ herr_t ret_value = SUCCEED; /* Return value */ @@ -621,7 +621,7 @@ H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, /* projected mem space must be discarded at the */ /* end of the function to avoid a memory leak. */ H5D_storage_t store; /* union of EFL and chunk pointer in file space */ - hsize_t nelmts; /* total number of elmts */ + hsize_t nelmts; /* total number of elmts */ hbool_t io_op_init = FALSE; /* Whether the I/O op has been initialized */ char fake_char; /* Temporary variable for NULL buffer pointers */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1153,10 +1153,7 @@ H5D__ioinfo_adjust(H5D_io_info_t *io_info, const H5D_t *dset, /* Append each of the "reason for breaking collective I/O" error messages to the * local and global no collective cause strings */ - for (cause = 1, idx = 0; - (cause < H5D_MPIO_NO_COLLECTIVE_MAX_CAUSE) && - (idx < cause_strings_len); - cause <<= 1, idx++) { + for (cause = 1, idx = 0; (cause < H5D_MPIO_NO_COLLECTIVE_MAX_CAUSE) && (idx < cause_strings_len); cause <<= 1, idx++) { size_t cause_strlen = HDstrlen(cause_strings[idx]); if (cause & local_no_collective_cause) { @@ -1166,8 +1163,7 @@ H5D__ioinfo_adjust(H5D_io_info_t *io_info, const H5D_t *dset, if(local_error_message_previously_written) HDstrncat(local_no_collective_cause_string, "; ", 2); - HDstrncat(local_no_collective_cause_string, - cause_strings[idx], cause_strlen); + HDstrncat(local_no_collective_cause_string, cause_strings[idx], cause_strlen); local_error_message_previously_written = TRUE; } /* end if */ @@ -1179,8 +1175,7 @@ H5D__ioinfo_adjust(H5D_io_info_t *io_info, const H5D_t *dset, if(global_error_message_previously_written) HDstrncat(global_no_collective_cause_string, "; ", 2); - HDstrncat(global_no_collective_cause_string, - cause_strings[idx], cause_strlen); + HDstrncat(global_no_collective_cause_string, cause_strings[idx], cause_strlen); global_error_message_previously_written = TRUE; } /* end if */ diff --git a/src/H5Dlayout.c b/src/H5Dlayout.c index 7ac274c..69238a1 100644 --- a/src/H5Dlayout.c +++ b/src/H5Dlayout.c @@ -65,7 +65,7 @@ const unsigned H5O_layout_ver_bounds[] = { - + /*------------------------------------------------------------------------- * Function: H5D__layout_set_io_ops * @@ -152,7 +152,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__layout_set_io_ops() */ - + /*------------------------------------------------------------------------- * Function: H5D__layout_meta_size * @@ -283,7 +283,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__layout_meta_size() */ - + /*------------------------------------------------------------------------- * Function: H5D__layout_set_version * @@ -321,7 +321,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__layout_set_version() */ - + /*------------------------------------------------------------------------- * Function: H5D__layout_set_latest_indexing * @@ -361,7 +361,7 @@ H5D__layout_set_latest_indexing(H5O_layout_t *layout, const H5S_t *space, if(ndims > 0) { hsize_t max_dims[H5O_LAYOUT_NDIMS]; /* Maximum dimension sizes */ hsize_t cur_dims[H5O_LAYOUT_NDIMS]; /* Current dimension sizes */ - unsigned unlim_count = 0; /* Count of unlimited max. dimensions */ + unsigned unlim_count = 0; /* Count of unlimited max. dimensions */ hbool_t single = TRUE; /* Fulfill single chunk indexing */ unsigned u; /* Local index variable */ @@ -445,7 +445,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__layout_set_latest_indexing() */ - + /*------------------------------------------------------------------------- * Function: H5D__layout_oh_create * @@ -588,17 +588,17 @@ done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__layout_oh_create() */ - + /*------------------------------------------------------------------------- * Function: H5D__layout_oh_read * - * Purpose: Read layout/pline/efl information for dataset + * Purpose: Read layout/pline/efl information for dataset * - * Return: Success: SUCCEED - * Failure: FAIL + * Return: Success: SUCCEED + * Failure: FAIL * - * Programmer: Quincey Koziol - * Monday, July 27, 2009 + * Programmer: Quincey Koziol + * Monday, July 27, 2009 * *------------------------------------------------------------------------- */ @@ -682,17 +682,17 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__layout_oh_read() */ - + /*------------------------------------------------------------------------- * Function: H5D__layout_oh_write * - * Purpose: Write layout information for dataset + * Purpose: Write layout information for dataset * - * Return: Success: SUCCEED - * Failure: FAIL + * Return: Success: SUCCEED + * Failure: FAIL * - * Programmer: Quincey Koziol - * Monday, July 27, 2009 + * Programmer: Quincey Koziol + * Monday, July 27, 2009 * *------------------------------------------------------------------------- */ diff --git a/src/H5Dmodule.h b/src/H5Dmodule.h index b259b69..27ccf54 100644 --- a/src/H5Dmodule.h +++ b/src/H5Dmodule.h @@ -11,7 +11,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Saturday, September 12, 2015 * * Purpose: This file contains declarations which define macros for the diff --git a/src/H5Dmpio.c b/src/H5Dmpio.c index 492902b..cfed02e 100644 --- a/src/H5Dmpio.c +++ b/src/H5Dmpio.c @@ -3272,7 +3272,7 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk if(H5S_close(dataspace) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace") dataspace = NULL; - } /* end if */ + } H5MM_free(chunk_entry->async_info.receive_buffer_array[i]); } /* end for */ diff --git a/src/H5Dnone.c b/src/H5Dnone.c index 5ba3f5b..40ddcb8 100644 --- a/src/H5Dnone.c +++ b/src/H5Dnone.c @@ -267,31 +267,31 @@ H5D__none_idx_iterate(const H5D_chk_idx_info_t *idx_info, /* Iterate over all the chunks in the dataset's dataspace */ for(u = 0; u < idx_info->layout->nchunks && ret_value == H5_ITER_CONT; u++) { - /* Calculate the index of this chunk */ - idx = H5VM_array_offset_pre(ndims, idx_info->layout->max_down_chunks, chunk_rec.scaled); + /* Calculate the index of this chunk */ + idx = H5VM_array_offset_pre(ndims, idx_info->layout->max_down_chunks, chunk_rec.scaled); - /* Calculate the address of the chunk */ - chunk_rec.chunk_addr = idx_info->storage->idx_addr + idx * idx_info->layout->size; + /* Calculate the address of the chunk */ + chunk_rec.chunk_addr = idx_info->storage->idx_addr + idx * idx_info->layout->size; - /* Make "generic chunk" callback */ - if((ret_value = (*chunk_cb)(&chunk_rec, chunk_udata)) < 0) + /* Make "generic chunk" callback */ + if((ret_value = (*chunk_cb)(&chunk_rec, chunk_udata)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CALLBACK, H5_ITER_ERROR, "failure in generic chunk iterator callback") - /* Update coordinates of chunk in dataset */ - curr_dim = (int)(ndims - 1); - while(curr_dim >= 0) { - /* Increment coordinate in current dimension */ - chunk_rec.scaled[curr_dim]++; - - /* Check if we went off the end of the current dimension */ - if(chunk_rec.scaled[curr_dim] >= idx_info->layout->chunks[curr_dim]) { - /* Reset coordinate & move to next faster dimension */ - chunk_rec.scaled[curr_dim] = 0; - curr_dim--; - } /* end if */ - else - break; - } /* end while */ + /* Update coordinates of chunk in dataset */ + curr_dim = (int)(ndims - 1); + while(curr_dim >= 0) { + /* Increment coordinate in current dimension */ + chunk_rec.scaled[curr_dim]++; + + /* Check if we went off the end of the current dimension */ + if(chunk_rec.scaled[curr_dim] >= idx_info->layout->chunks[curr_dim]) { + /* Reset coordinate & move to next faster dimension */ + chunk_rec.scaled[curr_dim] = 0; + curr_dim--; + } /* end if */ + else + break; + } /* end while */ } /* end for */ done: diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index c46e38b6..37a27d3 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -12,7 +12,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Monday, April 14, 2003 * * Purpose: This file contains declarations which are visible only within diff --git a/src/H5Dselect.c b/src/H5Dselect.c index c5469c2..5a5c491 100644 --- a/src/H5Dselect.c +++ b/src/H5Dselect.c @@ -11,7 +11,7 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* Programmer: Quincey Koziol +/* Programmer: Quincey Koziol * Thursday, September 30, 2004 * * Purpose: Dataspace I/O functions. diff --git a/src/H5Dvirtual.c b/src/H5Dvirtual.c index 877aadb..e07f538 100644 --- a/src/H5Dvirtual.c +++ b/src/H5Dvirtual.c @@ -1120,7 +1120,7 @@ H5D__virtual_str_append(const char *src, size_t src_len, char **p, char **buf, /* Copy string to *p. Note that since src in not NULL terminated, we must * use memcpy */ - (void)H5MM_memcpy(*p, src, src_len); + H5MM_memcpy(*p, src, src_len); /* Advance *p */ *p += src_len; diff --git a/src/H5EA.c b/src/H5EA.c index 96eee12..56663dc 100644 --- a/src/H5EA.c +++ b/src/H5EA.c @@ -991,11 +991,6 @@ END_FUNC(PRIV) /* end H5EA_delete() */ * * Programmer: Vailin Choi; Feb 2015 * - * Modification: - * Prototype changed (HDFFV-10661) - * - herr_t to int - * - SUCCEED/FAIL to H5_ITER_CONT/H5_ITER_ERROR - * June 6, 2019 -BMR *------------------------------------------------------------------------- */ BEGIN_FUNC(PRIV, ERR, @@ -1007,9 +1002,7 @@ H5EA_iterate(H5EA_t *ea, H5EA_operator_t op, void *udata)) hsize_t u; int cb_ret = H5_ITER_CONT; /* Return value from callback */ - /* - * Check arguments. - */ + /* Check arguments */ HDassert(ea); HDassert(op); HDassert(udata); diff --git a/src/H5EAdbg.c b/src/H5EAdbg.c index 3d6c2ed..e5b68be 100644 --- a/src/H5EAdbg.c +++ b/src/H5EAdbg.c @@ -13,11 +13,11 @@ /*------------------------------------------------------------------------- * - * Created: H5EAdbg.c - * Sep 11 2008 - * Quincey Koziol + * Created: H5EAdbg.c + * Sep 11 2008 + * Quincey Koziol * - * Purpose: Dump debugging information about an extensible array. + * Purpose: Dump debugging information about an extensible array. * *------------------------------------------------------------------------- */ @@ -37,9 +37,9 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5EApkg.h" /* Extensible Arrays */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5EApkg.h" /* Extensible Arrays */ /****************/ @@ -79,15 +79,14 @@ /*------------------------------------------------------------------------- - * Function: H5EA__hdr_debug + * Function: H5EA__hdr_debug * - * Purpose: Prints debugging info about a extensible array header. + * Purpose: Prints debugging info about a extensible array header. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Sep 11 2008 + * Programmer: Quincey Koziol + * Sep 11 2008 * *------------------------------------------------------------------------- */ @@ -97,7 +96,7 @@ H5EA__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, const H5EA_class_t *cls, haddr_t obj_addr)) /* Local variables */ - H5EA_hdr_t *hdr = NULL; /* Shared extensible array header */ + H5EA_hdr_t *hdr = NULL; /* Shared extensible array header */ void *dbg_ctx = NULL; /* Extensible array debugging context */ /* Check arguments */ @@ -117,73 +116,72 @@ H5EA__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, /* Load the extensible array header */ if(NULL == (hdr = H5EA__hdr_protect(f, addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header") + H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header") /* Print opening message */ HDfprintf(stream, "%*sExtensible Array Header...\n", indent, ""); /* Print the values */ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Array class ID:", hdr->cparam.cls->name); + "Array class ID:", hdr->cparam.cls->name); HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Header size:", - hdr->size); + "Header size:", + hdr->size); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Raw Element Size:", - (unsigned)hdr->cparam.raw_elmt_size); + "Raw Element Size:", + (unsigned)hdr->cparam.raw_elmt_size); HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Native Element Size (on this platform):", - hdr->cparam.cls->nat_elmt_size); + "Native Element Size (on this platform):", + hdr->cparam.cls->nat_elmt_size); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Log2(Max. # of elements in array):", - (unsigned)hdr->cparam.max_nelmts_bits); + "Log2(Max. # of elements in array):", + (unsigned)hdr->cparam.max_nelmts_bits); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "# of elements in index block:", - (unsigned)hdr->cparam.idx_blk_elmts); + "# of elements in index block:", + (unsigned)hdr->cparam.idx_blk_elmts); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Min. # of elements per data block:", - (unsigned)hdr->cparam.data_blk_min_elmts); + "Min. # of elements per data block:", + (unsigned)hdr->cparam.data_blk_min_elmts); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Min. # of data block pointers for a super block:", - (unsigned)hdr->cparam.sup_blk_min_data_ptrs); + "Min. # of data block pointers for a super block:", + (unsigned)hdr->cparam.sup_blk_min_data_ptrs); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Log2(Max. # of elements in data block page):", - (unsigned)hdr->cparam.max_dblk_page_nelmts_bits); + "Log2(Max. # of elements in data block page):", + (unsigned)hdr->cparam.max_dblk_page_nelmts_bits); HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Highest element index stored (+1):", - hdr->stats.stored.max_idx_set); + "Highest element index stored (+1):", + hdr->stats.stored.max_idx_set); HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Number of super blocks created:", - hdr->stats.stored.nsuper_blks); + "Number of super blocks created:", + hdr->stats.stored.nsuper_blks); HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Number of data blocks created:", - hdr->stats.stored.ndata_blks); + "Number of data blocks created:", + hdr->stats.stored.ndata_blks); HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Number of elements 'realized':", - hdr->stats.stored.nelmts); + "Number of elements 'realized':", + hdr->stats.stored.nelmts); HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Index Block Address:", - hdr->idx_blk_addr); + "Index Block Address:", + hdr->idx_blk_addr); CATCH if(dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) H5E_THROW(H5E_CANTRELEASE, "unable to release extensible array debugging context") if(hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") + H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") END_FUNC(PKG) /* end H5EA__hdr_debug() */ /*------------------------------------------------------------------------- - * Function: H5EA__iblock_debug + * Function: H5EA__iblock_debug * - * Purpose: Prints debugging info about a extensible array index block. + * Purpose: Prints debugging info about a extensible array index block. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Sep 11 2008 + * Programmer: Quincey Koziol + * Sep 11 2008 * *------------------------------------------------------------------------- */ @@ -215,7 +213,7 @@ H5EA__iblock_debug(H5F_t *f, haddr_t H5_ATTR_UNUSED addr, FILE *stream, int inde /* Load the extensible array header */ if(NULL == (hdr = H5EA__hdr_protect(f, hdr_addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header") + H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header") /* Sanity check */ HDassert(H5F_addr_eq(hdr->idx_blk_addr, addr)); @@ -229,16 +227,16 @@ H5EA__iblock_debug(H5F_t *f, haddr_t H5_ATTR_UNUSED addr, FILE *stream, int inde /* Print the values */ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Array class ID:", hdr->cparam.cls->name); + "Array class ID:", hdr->cparam.cls->name); HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Index Block size:", - iblock->size); + "Index Block size:", + iblock->size); HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "# of data block addresses in index block:", - iblock->ndblk_addrs); + "# of data block addresses in index block:", + iblock->ndblk_addrs); HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "# of super block addresses in index block:", - iblock->nsblk_addrs); + "# of super block addresses in index block:", + iblock->nsblk_addrs); /* Check if there are any elements in index block */ if(hdr->cparam.idx_blk_elmts > 0) { @@ -293,21 +291,20 @@ CATCH if(iblock && H5EA__iblock_unprotect(iblock, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array index block") if(hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") + H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") END_FUNC(PKG) /* end H5EA__iblock_debug() */ /*------------------------------------------------------------------------- - * Function: H5EA__sblock_debug + * Function: H5EA__sblock_debug * - * Purpose: Prints debugging info about a extensible array super block. + * Purpose: Prints debugging info about a extensible array super block. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Sep 30 2008 + * Programmer: Quincey Koziol + * Sep 30 2008 * *------------------------------------------------------------------------- */ @@ -339,7 +336,7 @@ H5EA__sblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, /* Load the extensible array header */ if(NULL == (hdr = H5EA__hdr_protect(f, hdr_addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header") + H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header") /* Protect super block */ /* (Note: setting parent of super block to 'hdr' for this operation should be OK -QAK) */ @@ -351,16 +348,16 @@ H5EA__sblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, /* Print the values */ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Array class ID:", hdr->cparam.cls->name); + "Array class ID:", hdr->cparam.cls->name); HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Super Block size:", - sblock->size); + "Super Block size:", + sblock->size); HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "# of data block addresses in super block:", - sblock->ndblks); + "# of data block addresses in super block:", + sblock->ndblks); HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "# of elements in data blocks from this super block:", - sblock->dblk_nelmts); + "# of elements in data blocks from this super block:", + sblock->dblk_nelmts); /* Check if there are any data block addresses in super block */ if(sblock->ndblks > 0) { @@ -384,21 +381,20 @@ CATCH if(sblock && H5EA__sblock_unprotect(sblock, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array super block") if(hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") + H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") END_FUNC(PKG) /* end H5EA__sblock_debug() */ /*------------------------------------------------------------------------- - * Function: H5EA__dblock_debug + * Function: H5EA__dblock_debug * - * Purpose: Prints debugging info about a extensible array data block. + * Purpose: Prints debugging info about a extensible array data block. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Sep 22 2008 + * Programmer: Quincey Koziol + * Sep 22 2008 * *------------------------------------------------------------------------- */ @@ -432,7 +428,7 @@ H5EA__dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, /* Load the extensible array header */ if(NULL == (hdr = H5EA__hdr_protect(f, hdr_addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header") + H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header") /* Protect data block */ /* (Note: setting parent of data block to 'hdr' for this operation should be OK -QAK) */ @@ -444,10 +440,10 @@ H5EA__dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, /* Print the values */ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Array class ID:", hdr->cparam.cls->name); + "Array class ID:", hdr->cparam.cls->name); HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Data Block size:", - dblock->size); + "Data Block size:", + dblock->size); /* Print the elements in the index block */ @@ -466,7 +462,7 @@ CATCH if(dblock && H5EA__dblock_unprotect(dblock, H5AC__NO_FLAGS_SET) < 0) H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array data block") if(hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") + H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") END_FUNC(PKG) /* end H5EA__dblock_debug() */ diff --git a/src/H5EAmodule.h b/src/H5EAmodule.h index d3e06b7..c3a4c7c 100644 --- a/src/H5EAmodule.h +++ b/src/H5EAmodule.h @@ -11,7 +11,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Saturday, September 12, 2015 * * Purpose: This file contains declarations which define macros for the diff --git a/src/H5EApkg.h b/src/H5EApkg.h index bb3f39c..b70231d 100644 --- a/src/H5EApkg.h +++ b/src/H5EApkg.h @@ -12,7 +12,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Tuesday, June 17, 2008 * * Purpose: This file contains declarations which are visible only diff --git a/src/H5EAprivate.h b/src/H5EAprivate.h index 1195256..af0ef3a 100644 --- a/src/H5EAprivate.h +++ b/src/H5EAprivate.h @@ -15,7 +15,7 @@ * * Created: H5EAprivate.h * Jun 17 2008 - * Quincey Koziol + * Quincey Koziol * * Purpose: Private header for library accessible extensible * array routines. diff --git a/src/H5EAsblock.c b/src/H5EAsblock.c index b4671f8..fb7c458 100644 --- a/src/H5EAsblock.c +++ b/src/H5EAsblock.c @@ -15,7 +15,7 @@ * * Created: H5EAsblock.c * Sep 30 2008 - * Quincey Koziol + * Quincey Koziol * * Purpose: Super block routines for extensible arrays. * @@ -98,7 +98,6 @@ H5FL_BLK_DEFINE(page_init); * Return: Non-NULL pointer to super block on success/NULL on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Sep 30 2008 * *------------------------------------------------------------------------- @@ -179,7 +178,6 @@ END_FUNC(PKG) /* end H5EA__sblock_alloc() */ * Return: Valid file address on success/HADDR_UNDEF on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Sep 30 2008 * *------------------------------------------------------------------------- @@ -267,7 +265,6 @@ END_FUNC(PKG) /* end H5EA__sblock_create() */ * Return: Non-NULL pointer to data block on success/NULL on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Sep 30 2008 * *------------------------------------------------------------------------- @@ -328,7 +325,6 @@ END_FUNC(PKG) /* end H5EA__sblock_protect() */ * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Sep 30 2008 * *------------------------------------------------------------------------- @@ -359,7 +355,6 @@ END_FUNC(PKG) /* end H5EA__sblock_unprotect() */ * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Sep 30 2008 * *------------------------------------------------------------------------- @@ -408,7 +403,6 @@ END_FUNC(PKG) /* end H5EA__sblock_delete() */ * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Sep 30 2008 * *------------------------------------------------------------------------- diff --git a/src/H5Eint.c b/src/H5Eint.c index ca7031b..2371a5f 100644 --- a/src/H5Eint.c +++ b/src/H5Eint.c @@ -33,7 +33,6 @@ /* Headers */ /***********/ #include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ #include "H5Epkg.h" /* Error handling */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ @@ -576,7 +575,7 @@ H5E__walk(const H5E_t *estack, H5E_direction_t direction, const H5E_walk_op_t *o ret_value = (op->u.func2)((unsigned)(estack->nused - (size_t)(i + 1)), estack->slot + i, client_data); } /* end else */ - if(ret_value < 0) + if(ret_value < 0) HERROR(H5E_ERROR, H5E_CANTLIST, "can't walk error stack"); } /* end if */ } /* end else */ @@ -880,12 +879,12 @@ H5E__clear_entries(H5E_t *estack, size_t nentries) /* Release strings */ if(error->func_name) - error->func_name = (const char *) H5MM_xfree((void *)error->func_name); /* Casting away const OK - QAK */ + error->func_name = (const char *) H5MM_xfree_const(error->func_name); if(error->file_name) - error->file_name = (const char *) H5MM_xfree((void *)error->file_name); /* Casting away const OK - QAK */ + error->file_name = (const char *) H5MM_xfree_const(error->file_name); if(error->desc) - error->desc = (const char *) H5MM_xfree((void *)error->desc); /* Casting away const OK - QAK */ - } /* end for */ + error->desc = (const char *) H5MM_xfree_const(error->desc); + } /* Decrement number of errors on stack */ estack->nused -= u; diff --git a/src/H5Eprivate.h b/src/H5Eprivate.h index 19ab729..130a8fd 100644 --- a/src/H5Eprivate.h +++ b/src/H5Eprivate.h @@ -180,7 +180,7 @@ extern int H5E_mpi_error_str_len; /* Library-private functions defined in H5E package */ H5_DLL herr_t H5E_init(void); H5_DLL herr_t H5E_printf_stack(H5E_t *estack, const char *file, const char *func, - unsigned line, hid_t cls_id, hid_t maj_id, hid_t min_id, const char *fmt, ...)H5_ATTR_FORMAT(printf, 8, 9); + unsigned line, hid_t cls_id, hid_t maj_id, hid_t min_id, const char *fmt, ...) H5_ATTR_FORMAT(printf, 8, 9); H5_DLL herr_t H5E_clear_stack(H5E_t *estack); H5_DLL herr_t H5E_dump_api_stack(hbool_t is_api); diff --git a/src/H5F.c b/src/H5F.c index e80b1bd..9d426ac 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -280,7 +280,7 @@ H5Fget_create_plist(hid_t file_id) /* Retrieve the file creation property list */ if(H5VL_file_get(vol_obj, H5VL_FILE_GET_FCPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, H5I_INVALID_HID, "unable to retrieve file creation properties") + HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, H5I_INVALID_HID, "unable to retrieve file creation properties") done: FUNC_LEAVE_API(ret_value) @@ -320,7 +320,7 @@ H5Fget_access_plist(hid_t file_id) /* Retrieve the file's access property list */ if(H5VL_file_get(vol_obj, H5VL_FILE_GET_FAPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't get file access property list") + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't get file access property list") done: FUNC_LEAVE_API(ret_value) @@ -549,8 +549,8 @@ done: * Purpose: Returns a pointer to the file handle of the low-level file * driver. * - * Return: SUCCEED/FAIL - * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -584,8 +584,8 @@ done: * * Purpose: Check if the file can be opened with the given fapl. * - * Return: Succeed: TRUE/FALSE - * Failure: FAIL (includes file does not exist) + * Return: Success: TRUE/FALSE + * Failure: -1 (includes file does not exist) * *------------------------------------------------------------------------- */ @@ -637,9 +637,7 @@ done: * the list of file creation and file access properties. * * Return: Success: A file ID - * * Failure: H5I_INVALID_HID - * *------------------------------------------------------------------------- */ hid_t @@ -739,9 +737,7 @@ done: * See Also: H5Fpublic.h for a list of possible values for FLAGS. * * Return: Success: A file ID - * * Failure: H5I_INVALID_HID - * *------------------------------------------------------------------------- */ hid_t @@ -798,7 +794,7 @@ H5Fopen(const char *filename, unsigned flags, hid_t fapl_id) /* Get the file object */ if(NULL == (vol_obj = H5VL_vol_object(ret_value))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid object identifier") + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "invalid object identifier") /* Make the 'post open' callback */ supported = FALSE; @@ -820,8 +816,8 @@ done: * not remove them from the cache. The OBJECT_ID can be a file, * dataset, group, attribute, or named data type. * - * Return: SUCCEED/FAIL - * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -863,8 +859,8 @@ done: * closed until those objects are closed; however, all data for * the file and the open objects is flushed. * - * Return: SUCCEED/FAIL - * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -879,11 +875,9 @@ H5Fclose(hid_t file_id) if(H5I_FILE != H5I_get_type(file_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file ID") - /* Decrement reference count on atom. When it reaches zero the file will - * be closed. - */ + /* Close the file */ if(H5I_dec_app_ref(file_id) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTCLOSEFILE, FAIL, "decrementing file ID failed") + HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "closing file ID failed") done: FUNC_LEAVE_API(ret_value) @@ -1011,8 +1005,8 @@ done: * Purpose: Public API to retrieve the file's 'intent' flags passed * during H5Fopen() * - * Return: SUCCEED/FAIL - * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -1083,9 +1077,7 @@ done: * Purpose: Retrieves the amount of free space in the file. * * Return: Success: Amount of free space for type - * * Failure: -1 - * *------------------------------------------------------------------------- */ hssize_t @@ -1117,8 +1109,8 @@ done: * is called after an existing file is opened in order * to learn the true size of the underlying file. * - * Return: SUCCEED/FAIL - * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -1179,9 +1171,7 @@ done: * this now. * * Return: Success: Bytes copied / number of bytes needed - * * Failure: -1 - * *------------------------------------------------------------------------- */ ssize_t @@ -1216,8 +1206,8 @@ done: * filled in by the caller. This allows us to adapt for * obsolete versions of the structure. * - * Return: SUCCEED/FAIL - * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -1253,8 +1243,8 @@ done: * configuration, using the contents of the instance of * H5AC_cache_config_t pointed to by config_ptr. * - * Return: SUCCEED/FAIL - * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -1287,8 +1277,8 @@ done: * the hit rate statistics were reset either manually or * automatically. * - * Return: SUCCEED/FAIL - * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -1324,8 +1314,8 @@ done: * the ptr parameters are NULL, the associated datum is * not returned. * - * Return: SUCCEED/FAIL - * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -1364,8 +1354,8 @@ done: * you are controlling cache size from your program instead * of using our cache size control code. * - * Return: SUCCEED/FAIL - * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -1406,9 +1396,7 @@ done: * not the actual name after resolving symlinks, etc. * * Return: Success: The length of the file name - * * Failure: -1 - * *------------------------------------------------------------------------- */ ssize_t @@ -1448,8 +1436,8 @@ done: * in the SOHM table if there is one. * 3. The amount of free space tracked in the file. * - * Return: SUCCEED/FAIL - * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -1490,8 +1478,8 @@ done: * Purpose: To retrieve the collection of read retries for metadata * items with checksum. * - * Return: SUCCEED/FAIL - * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -1529,9 +1517,7 @@ done: * sections. * * Return: Success: The total # of free space sections - * * Failure: -1 - * *------------------------------------------------------------------------- */ ssize_t @@ -1566,8 +1552,8 @@ done: * provided file, potentially closing any cached files * unless they are held open from somewhere\ else. * - * Return: SUCCEED/FAIL - * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -1622,14 +1608,14 @@ done: * set up flush dependency/proxy even for file opened without * SWMR to resolve issues with opened objects. * - * Return: SUCCEED/FAIL - * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t H5Fstart_swmr_write(hid_t file_id) { - H5VL_object_t *vol_obj = NULL; /* File info */ + H5VL_object_t *vol_obj = NULL; /* File info */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1658,8 +1644,8 @@ done: * Purpose: Start metadata cache logging operations for a file. * - Logging must have been set up via the fapl. * - * Return: SUCCEED/FAIL - * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -1691,8 +1677,8 @@ done: * - Does not close the log file. * - Logging must have been set up via the fapl. * - * Return: SUCCEED/FAIL - * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -1724,8 +1710,8 @@ done: * set up via the fapl. is_currently_logging determines if * log messages are being recorded at this time. * - * Return: SUCCEED/FAIL - * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -1759,8 +1745,8 @@ done: * H5Fset_latest_format() starting release 1.10.2. * See explanation for H5Fset_latest_format() in H5Fdeprec.c. * - * Return: SUCCEED/FAIL - * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -1796,8 +1782,8 @@ done: * downgrade persistent file space to non-persistent * for 1.8 library. * - * Return: SUCCEED/FAIL - * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -1831,8 +1817,8 @@ done: * * Purpose: Resets statistics for the page buffer layer. * - * Return: SUCCEED/FAIL - * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -1862,8 +1848,8 @@ done: * * Purpose: Retrieves statistics for the page buffer layer. * - * Return: SUCCEED/FAIL - * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -1901,8 +1887,8 @@ done: * image_len: --size of the on disk metadata cache image * --zero if no cache image * - * Return: SUCCEED/FAIL - * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -1930,11 +1916,12 @@ done: /*------------------------------------------------------------------------- * Function: H5Fget_eoa * - * Purpose: Returns the address of the first byte after the last + * Purpose: Gets the address of the first byte after the last * allocated memory in the file. * (See H5FDget_eoa() in H5FD.c) * - * Return: SUCCEED/FAIL + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -1967,7 +1954,8 @@ done: * * Purpose: Set the EOA for the file to the maximum of (EOA, EOF) + increment * - * Return: SUCCEED/FAIL + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -1993,24 +1981,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5Fget_dset_no_attrs_hint - * - * Purpose: - * - * Get the file-level setting to create minimized dataset object headers. - * Result is stored at pointer `minimize`. + * Function: H5Fget_dset_no_attrs_hint * - * Return: + * Purpose: Get the file-level setting to create minimized dataset object headers. + * Result is stored at pointer `minimize`. * - * Success: SUCCEED (0) (non-negative value) - * Failure: FAIL (-1) (negative value) - * - * Programmer: - * - * Jacob Smith - * 15 August 2018 - * - * Changes: None. + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -2038,23 +2015,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5Fset_dset_no_attrs_hint - * - * Purpose: - * - * Set the file-level setting to create minimized dataset object headers. - * - * Return: - * - * Success: SUCCEED (0) (non-negative value) - * Failure: FAIL (-1) (negative value) - * - * Programmer: + * Function: H5Fset_dset_no_attrs_hint * - * Jacob Smith - * 15 August 2018 + * Purpose: Set the file-level setting to create minimized dataset object + * headers. * - * Changes: None. + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t diff --git a/src/H5FA.c b/src/H5FA.c index df53f27..f8bb094 100644 --- a/src/H5FA.c +++ b/src/H5FA.c @@ -691,11 +691,6 @@ END_FUNC(PRIV) /* end H5FA_delete() */ * Programmer: Vailin Choi * Thursday, April 30, 2009 * - * Modification: - * Prototype changed (HDFFV-10661) - * - herr_t to int - * - SUCCEED/FAIL to H5_ITER_CONT/H5_ITER_ERROR - * June 6, 2019 -BMR *------------------------------------------------------------------------- */ BEGIN_FUNC(PRIV, ERR, diff --git a/src/H5FAhdr.c b/src/H5FAhdr.c index 8f29b83..506c767 100644 --- a/src/H5FAhdr.c +++ b/src/H5FAhdr.c @@ -39,7 +39,7 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5FApkg.h" /* Fixed Arrays */ #include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5MMprivate.h" /* Memory management */ /****************/ diff --git a/src/H5FD.c b/src/H5FD.c index 1a4ab4d..2cd69df 100644 --- a/src/H5FD.c +++ b/src/H5FD.c @@ -202,7 +202,7 @@ H5FD__free_cls(H5FD_class_t *cls) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_free_cls() */ +} /* end H5FD__free_cls() */ /*------------------------------------------------------------------------- @@ -566,22 +566,22 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_fapl_close + * Function: H5FD_free_driver_info * - * Purpose: Closes a driver for a dataset transfer property list + * Purpose: Frees a driver's info * * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ herr_t -H5FD_fapl_close(hid_t driver_id, const void *driver_info) +H5FD_free_driver_info(hid_t driver_id, const void *driver_info) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if(driver_id > 0) { + if(driver_id > 0 && driver_info) { H5FD_class_t *driver; /* Retrieve the driver for the ID */ @@ -589,19 +589,19 @@ H5FD_fapl_close(hid_t driver_id, const void *driver_info) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a driver ID") /* Allow driver to free info or do it ourselves */ - if(driver_info) { - if(driver->fapl_free) { - if((driver->fapl_free)((void *)driver_info) < 0) /* Casting away const OK -QAK */ - HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "driver free request failed") - } /* end if */ - else - driver_info = H5MM_xfree((void *)driver_info); /* Casting away const OK -QAK */ - } /* end if */ - } /* end if */ + if(driver->fapl_free) { + /* Free the const pointer */ + /* Cast through uintptr_t to de-const memory */ + if((driver->fapl_free)((void *)(uintptr_t)driver_info) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "driver free request failed") + } + else + driver_info = H5MM_xfree_const(driver_info); + } done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_fapl_close() */ +} /* end H5FD_free_driver_info() */ /*------------------------------------------------------------------------- @@ -789,7 +789,7 @@ done: * will be all zero during the driver close callback like during * the 'open' callback. * - * Return: SUCCEED/FAIL + * Return: Non-negative on success/Negative on failure * *------------------------------------------------------------------------- */ @@ -1088,7 +1088,7 @@ done: * doesn't map to a free list then either the application 'free' * callback is invoked (if defined) or the memory is leaked. * - * Return: SUCCEED/FAIL + * Return: Non-negative on success/Negative on failure * *------------------------------------------------------------------------- */ @@ -1382,11 +1382,11 @@ done: * be the constant H5P_DEFAULT). The result is written into the * buffer BUF. * - * Return: Success: SUCCEED + * Return: Success: Non-negative * The read result is written into the BUF buffer * which should be allocated by the caller. * - * Failure: FAIL + * Failure: Negative * The contents of BUF are undefined. * *------------------------------------------------------------------------- @@ -1436,7 +1436,7 @@ done: * constant H5P_DEFAULT). The bytes to be written come from the * buffer BUF. * - * Return: SUCCEED/FAIL + * Return: Non-negative on success/Negative on failure * *------------------------------------------------------------------------- */ @@ -1483,7 +1483,7 @@ done: * Purpose: Notify driver to flush all cached data. If the driver has no * flush method then nothing happens. * - * Return: SUCCEED/FAIL + * Return: Non-negative on success/Negative on failureL * *------------------------------------------------------------------------- */ @@ -1553,7 +1553,7 @@ done: * * Purpose: Notify driver to truncate the file back to the allocated size. * - * Return: SUCCEED/FAIL + * Return: Non-negative on success/Negative on failure * *------------------------------------------------------------------------- */ @@ -1622,7 +1622,7 @@ done: * * Purpose: Set a file lock * - * Return: SUCCEED/FAIL + * Return: Non-negative on success/Negative on failure * *------------------------------------------------------------------------- */ @@ -1684,7 +1684,7 @@ done: * * Purpose: Remove a file lock * - * Return: SUCCEED/FAIL + * Return: Non-negative on success/Negative on failure * *------------------------------------------------------------------------- */ @@ -1773,7 +1773,7 @@ H5FD_get_fileno(const H5FD_t *file, unsigned long *filenum) * Purpose: Returns a pointer to the file handle of low-level virtual * file driver. * - * Return: SUCCEED/FAIL + * Return: Non-negative on success/Negative on failure * *-------------------------------------------------------------------------- */ @@ -1919,7 +1919,7 @@ H5FD_set_paged_aggr(H5FD_t *file, hbool_t paged) * can't use the file to get the driver, the driver ID is passed * in as a parameter. * -* Return: SUCCEED/FAIL +* Return: Non-negative on success/Negative on failure * *------------------------------------------------------------------------- */ diff --git a/src/H5FDcore.c b/src/H5FDcore.c index d551f2f..0551dd0 100644 --- a/src/H5FDcore.c +++ b/src/H5FDcore.c @@ -342,6 +342,7 @@ H5FD__core_write_to_bstore(H5FD_core_t *file, haddr_t addr, size_t size) unsigned char *ptr = file->mem + addr; /* mutable pointer into the * buffer (can't change mem) */ + HDoff_t offset = (HDoff_t)addr; /* Offset to write at */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -358,7 +359,6 @@ H5FD__core_write_to_bstore(H5FD_core_t *file, haddr_t addr, size_t size) h5_posix_io_t bytes_in = 0; /* # of bytes to write */ h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes written */ - HDoff_t offset = (HDoff_t)addr; /* Trying to write more bytes than the return type can handle is * undefined behavior in POSIX. @@ -371,7 +371,8 @@ H5FD__core_write_to_bstore(H5FD_core_t *file, haddr_t addr, size_t size) do { #ifdef H5_HAVE_PREADWRITE bytes_wrote = HDpwrite(file->fd, ptr, bytes_in, offset); - offset += bytes_wrote; + if(bytes_wrote > 0) + offset += bytes_wrote; #else bytes_wrote = HDwrite(file->fd, ptr, bytes_in); #endif /* H5_HAVE_PREADWRITE */ @@ -855,14 +856,14 @@ H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr /* Read in existing data, being careful of interrupted system calls, * partial results, and the end of the file. */ - - uint8_t *mem = file->mem; /* memory pointer for writes */ - + + uint8_t *mem = file->mem; /* memory pointer for writes */ + HDoff_t offset = (HDoff_t)0; /* offset for reading */ + while(size > 0) { h5_posix_io_t bytes_in = 0; /* # of bytes to read */ h5_posix_io_ret_t bytes_read = -1; /* # of bytes actually read */ - HDoff_t offset = (HDoff_t)0; - + /* Trying to read more bytes than the return type can handle is * undefined behavior in POSIX. */ @@ -874,7 +875,8 @@ H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr do { #ifdef H5_HAVE_PREADWRITE bytes_read = HDpread(file->fd, mem, bytes_in, offset); - offset += bytes_read; + if(bytes_read > 0) + offset += bytes_read; #else bytes_read = HDread(file->fd, mem, bytes_in); #endif /* H5_HAVE_PREADWRITE */ diff --git a/src/H5FDlog.c b/src/H5FDlog.c index b1da5f0..78b7742 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -487,11 +487,8 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) #ifdef H5_HAVE_WIN32_API struct _BY_HANDLE_FILE_INFORMATION fileinfo; #endif -#ifdef H5_HAVE_GETTIMEOFDAY - struct timeval timeval_start; - struct timeval open_timeval_diff; - struct timeval stat_timeval_diff; -#endif /* H5_HAVE_GETTIMEOFDAY */ + H5_timer_t open_timer; /* Timer for open() call */ + H5_timer_t stat_timer; /* Timer for stat() call */ h5_stat_t sb; H5FD_t *ret_value = NULL; /* Return value */ @@ -523,54 +520,36 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) if(NULL == (fa = (const H5FD_log_fapl_t *)H5P_peek_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, NULL, "bad VFL driver info") -#ifdef H5_HAVE_GETTIMEOFDAY - if(fa->flags & H5FD_LOG_TIME_OPEN) - HDgettimeofday(&timeval_start, NULL); -#endif /* H5_HAVE_GETTIMEOFDAY */ + /* Start timer for open() call */ + if(fa->flags & H5FD_LOG_TIME_OPEN) { + H5_timer_init(&open_timer); + H5_timer_start(&open_timer); + } /* end if */ + /* Open the file */ if((fd = HDopen(name, o_flags, H5_POSIX_CREATE_MODE_RW)) < 0) { int myerrno = errno; HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: name = '%s', errno = %d, error message = '%s', flags = %x, o_flags = %x", name, myerrno, HDstrerror(myerrno), flags, (unsigned)o_flags); } /* end if */ -#ifdef H5_HAVE_GETTIMEOFDAY - if(fa->flags & H5FD_LOG_TIME_OPEN) { - struct timeval timeval_stop; - HDgettimeofday(&timeval_stop, NULL); + /* Stop timer for open() call */ + if(fa->flags & H5FD_LOG_TIME_OPEN) + H5_timer_stop(&open_timer); - /* Calculate the elapsed gettimeofday time */ - open_timeval_diff.tv_usec = timeval_stop.tv_usec - timeval_start.tv_usec; - open_timeval_diff.tv_sec = timeval_stop.tv_sec - timeval_start.tv_sec; - if(open_timeval_diff.tv_usec < 0) { - open_timeval_diff.tv_usec += 1000000; - open_timeval_diff.tv_sec--; - } /* end if */ + /* Start timer for stat() call */ + if(fa->flags & H5FD_LOG_TIME_STAT) { + H5_timer_init(&stat_timer); + H5_timer_start(&stat_timer); } /* end if */ -#endif /* H5_HAVE_GETTIMEOFDAY */ -#ifdef H5_HAVE_GETTIMEOFDAY - if(fa->flags & H5FD_LOG_TIME_STAT) - HDgettimeofday(&timeval_start, NULL); -#endif /* H5_HAVE_GETTIMEOFDAY */ /* Get the file stats */ if(HDfstat(fd, &sb) < 0) HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, NULL, "unable to fstat file") -#ifdef H5_HAVE_GETTIMEOFDAY - if(fa->flags & H5FD_LOG_TIME_STAT) { - struct timeval timeval_stop; - HDgettimeofday(&timeval_stop, NULL); - - /* Calculate the elapsed gettimeofday time */ - stat_timeval_diff.tv_usec = timeval_stop.tv_usec - timeval_start.tv_usec; - stat_timeval_diff.tv_sec = timeval_stop.tv_sec - timeval_start.tv_sec; - if(stat_timeval_diff.tv_usec < 0) { - stat_timeval_diff.tv_usec += 1000000; - stat_timeval_diff.tv_sec--; - } /* end if */ - } /* end if */ -#endif /* H5_HAVE_GETTIMEOFDAY */ + /* Stop timer for stat() call */ + if(fa->flags & H5FD_LOG_TIME_STAT) + H5_timer_stop(&stat_timer); /* Create the new file struct */ if(NULL == (file = H5FL_CALLOC(H5FD_log_t))) @@ -631,13 +610,19 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) else file->logfp = stderr; -#ifdef H5_HAVE_GETTIMEOFDAY - if(file->fa.flags & H5FD_LOG_TIME_OPEN) - HDfprintf(file->logfp, "Open took: (%f s)\n", (double)open_timeval_diff.tv_sec + ((double)open_timeval_diff.tv_usec / (double)1000000.0f)); - if(file->fa.flags & H5FD_LOG_TIME_STAT) - HDfprintf(file->logfp, "Stat took: (%f s)\n", (double)stat_timeval_diff.tv_sec + ((double)stat_timeval_diff.tv_usec / (double)1000000.0f)); -#endif /* H5_HAVE_GETTIMEOFDAY */ + /* Log the timer values */ + if(file->fa.flags & H5FD_LOG_TIME_OPEN) { + H5_timevals_t open_times; /* Elapsed time for open() call */ + H5_timer_get_times(open_timer, &open_times); + HDfprintf(file->logfp, "Open took: (%f s)\n", open_times.elapsed); + } /* end if */ + if(file->fa.flags & H5FD_LOG_TIME_STAT) { + H5_timevals_t stat_times; /* Elapsed time for stat() call */ + + H5_timer_get_times(stat_timer, &stat_times); + HDfprintf(file->logfp, "Stat took: (%f s)\n", stat_times.elapsed); + } /* end if */ } /* end if */ /* Check for non-default FAPL */ @@ -684,27 +669,27 @@ static herr_t H5FD_log_close(H5FD_t *_file) { H5FD_log_t *file = (H5FD_log_t *)_file; -#ifdef H5_HAVE_GETTIMEOFDAY - struct timeval timeval_start, timeval_stop; -#endif /* H5_HAVE_GETTIMEOFDAY */ - herr_t ret_value = SUCCEED; /* Return value */ + H5_timer_t close_timer; /* Timer for close() call */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Sanity check */ HDassert(file); -#ifdef H5_HAVE_GETTIMEOFDAY - if(file->fa.flags&H5FD_LOG_TIME_CLOSE) - HDgettimeofday(&timeval_start, NULL); -#endif /* H5_HAVE_GETTIMEOFDAY */ + /* Start timer for close() call */ + if(file->fa.flags & H5FD_LOG_TIME_CLOSE) { + H5_timer_init(&close_timer); + H5_timer_start(&close_timer); + } /* end if */ + /* Close the underlying file */ if(HDclose(file->fd) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "unable to close file") -#ifdef H5_HAVE_GETTIMEOFDAY + + /* Stop timer for close() call */ if(file->fa.flags&H5FD_LOG_TIME_CLOSE) - HDgettimeofday(&timeval_stop, NULL); -#endif /* H5_HAVE_GETTIMEOFDAY */ + H5_timer_stop(&close_timer); /* Dump I/O information */ if(file->fa.flags != 0) { @@ -712,20 +697,12 @@ H5FD_log_close(H5FD_t *_file) haddr_t last_addr; unsigned char last_val; -#ifdef H5_HAVE_GETTIMEOFDAY if(file->fa.flags & H5FD_LOG_TIME_CLOSE) { - struct timeval timeval_diff; - - /* Calculate the elapsed gettimeofday time */ - timeval_diff.tv_usec = timeval_stop.tv_usec - timeval_start.tv_usec; - timeval_diff.tv_sec = timeval_stop.tv_sec - timeval_start.tv_sec; - if(timeval_diff.tv_usec < 0) { - timeval_diff.tv_usec += 1000000; - timeval_diff.tv_sec--; - } /* end if */ - HDfprintf(file->logfp, "Close took: (%f s)\n", (double)timeval_diff.tv_sec + ((double)timeval_diff.tv_usec / (double)1000000.0f)); + H5_timevals_t close_times; /* Elapsed time for close() call */ + + H5_timer_get_times(close_timer, &close_times); + HDfprintf(file->logfp, "Close took: (%f s)\n", close_times.elapsed); } /* end if */ -#endif /* H5_HAVE_GETTIMEOFDAY */ /* Dump the total number of seek/read/write operations */ if(file->fa.flags & H5FD_LOG_NUM_READ) @@ -1168,10 +1145,14 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hadd H5FD_log_t *file = (H5FD_log_t *)_file; size_t orig_size = size; /* Save the original size for later */ haddr_t orig_addr = addr; -#ifdef H5_HAVE_GETTIMEOFDAY - struct timeval timeval_start, timeval_stop; -#endif /* H5_HAVE_GETTIMEOFDAY */ - herr_t ret_value = SUCCEED; /* Return value */ + H5_timer_t read_timer; /* Timer for read operation */ + H5_timevals_t read_times; /* Elapsed time for read operation */ +#ifndef H5_HAVE_PREADWRITE + H5_timer_t seek_timer; /* Timer for seek operation */ + H5_timevals_t seek_times; /* Elapsed time for seek operation */ +#endif /* H5_HAVE_PREADWRITE */ + HDoff_t offset = (HDoff_t)addr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1200,62 +1181,58 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hadd #ifndef H5_HAVE_PREADWRITE /* Seek to the correct location (if we don't have pread) */ if(addr != file->pos || OP_READ != file->op) { -#ifdef H5_HAVE_GETTIMEOFDAY - if(file->fa.flags & H5FD_LOG_TIME_SEEK) - HDgettimeofday(&timeval_start, NULL); -#endif /* H5_HAVE_GETTIMEOFDAY */ + /* Start timer for seek() call */ + if(file->fa.flags & H5FD_LOG_TIME_SEEK) { + H5_timer_init(&seek_timer); + H5_timer_start(&seek_timer); + } /* end if */ + if(HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") -#ifdef H5_HAVE_GETTIMEOFDAY + + /* Stop timer for seek() call */ if(file->fa.flags & H5FD_LOG_TIME_SEEK) - HDgettimeofday(&timeval_stop, NULL); -#endif /* H5_HAVE_GETTIMEOFDAY */ + H5_timer_stop(&seek_timer); - /* Log information about the seek */ + /* Add to the number of seeks, when tracking that */ if(file->fa.flags & H5FD_LOG_NUM_SEEK) file->total_seek_ops++; + + /* Add to the total seek time, when tracking that */ + if(file->fa.flags & H5FD_LOG_TIME_SEEK) { + H5_timer_get_times(seek_timer, &seek_times); + file->total_seek_time += seek_times.elapsed; + } /* end if */ + + /* Emit log string if we're tracking individual seek events. */ if(file->fa.flags & H5FD_LOG_LOC_SEEK) { HDfprintf(file->logfp, "Seek: From %10a To %10a", file->pos, addr); -#ifdef H5_HAVE_GETTIMEOFDAY - if(file->fa.flags & H5FD_LOG_TIME_SEEK) { - struct timeval timeval_diff; - double time_diff; - - /* Calculate the elapsed gettimeofday time */ - timeval_diff.tv_usec = timeval_stop.tv_usec - timeval_start.tv_usec; - timeval_diff.tv_sec = timeval_stop.tv_sec - timeval_start.tv_sec; - if(timeval_diff.tv_usec < 0) { - timeval_diff.tv_usec += 1000000; - timeval_diff.tv_sec--; - } /* end if */ - time_diff = (double)timeval_diff.tv_sec + ((double)timeval_diff.tv_usec / (double)1000000.0f); - HDfprintf(file->logfp, " (%fs @ %.6lu.%.6llu)\n", time_diff, (unsigned long long)timeval_start.tv_sec, (unsigned long long)timeval_start.tv_usec); - /* Add to total seek time */ - file->total_seek_time += time_diff; - } /* end if */ - else - HDfprintf(file->logfp, "\n"); -#else /* H5_HAVE_GETTIMEOFDAY */ - HDfprintf(file->logfp, "\n"); -#endif /* H5_HAVE_GETTIMEOFDAY */ + /* Add the seek time, if we're tracking that. + * Note that the seek time is NOT emitted for when just H5FD_LOG_TIME_SEEK + * is set. + */ + if(file->fa.flags & H5FD_LOG_TIME_SEEK) + HDfprintf(file->logfp, " (%fs @ %f)\n", seek_times.elapsed, seek_timer.initial.elapsed); + else + HDfprintf(file->logfp, "\n"); } /* end if */ } /* end if */ #endif /* H5_HAVE_PREADWRITE */ + /* Start timer for read operation */ + if(file->fa.flags & H5FD_LOG_TIME_READ) { + H5_timer_init(&read_timer); + H5_timer_start(&read_timer); + } /* end if */ + /* * Read data, being careful of interrupted system calls, partial results, * and the end of the file. */ -#ifdef H5_HAVE_GETTIMEOFDAY - if(file->fa.flags & H5FD_LOG_TIME_READ) - HDgettimeofday(&timeval_start, NULL); -#endif /* H5_HAVE_GETTIMEOFDAY */ while(size > 0) { - h5_posix_io_t bytes_in = 0; /* # of bytes to read */ - h5_posix_io_ret_t bytes_read = -1; /* # of bytes actually read */ - HDoff_t offset = (HDoff_t)addr; + h5_posix_io_ret_t bytes_read = -1; /* # of bytes actually read */ /* Trying to read more bytes than the return type can handle is * undefined behavior in POSIX. @@ -1268,7 +1245,8 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hadd do { #ifdef H5_HAVE_PREADWRITE bytes_read = HDpread(file->fd, buf, bytes_in, offset); - offset += bytes_read; + if(bytes_read > 0) + offset += bytes_read; #else bytes_read = HDread(file->fd, buf, bytes_in); #endif /* H5_HAVE_PREADWRITE */ @@ -1300,14 +1278,22 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hadd buf = (char *)buf + bytes_read; } /* end while */ -#ifdef H5_HAVE_GETTIMEOFDAY + + /* Stop timer for read operation */ if(file->fa.flags & H5FD_LOG_TIME_READ) - HDgettimeofday(&timeval_stop, NULL); -#endif /* H5_HAVE_GETTIMEOFDAY */ + H5_timer_stop(&read_timer); - /* Log information about the read */ + /* Add to the number of reads, when tracking that */ if(file->fa.flags & H5FD_LOG_NUM_READ) file->total_read_ops++; + + /* Add to the total read time, when tracking that */ + if(file->fa.flags & H5FD_LOG_TIME_READ) { + H5_timer_get_times(read_timer, &read_times); + file->total_read_time += read_times.elapsed; + } /* end if */ + + /* Log information about the read */ if(file->fa.flags & H5FD_LOG_LOC_READ) { HDfprintf(file->logfp, "%10a-%10a (%10Zu bytes) (%s) Read", orig_addr, (orig_addr + orig_size) - 1, orig_size, flavors[type]); @@ -1317,30 +1303,14 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hadd HDassert(type == H5FD_MEM_DEFAULT || type == (H5FD_mem_t)file->flavor[(orig_addr + orig_size) - 1] || (H5FD_mem_t)file->flavor[(orig_addr + orig_size) - 1] == H5FD_MEM_DEFAULT); } /* end if */ - -#ifdef H5_HAVE_GETTIMEOFDAY - if(file->fa.flags & H5FD_LOG_TIME_READ) { - struct timeval timeval_diff; - double time_diff; - - /* Calculate the elapsed gettimeofday time */ - timeval_diff.tv_usec = timeval_stop.tv_usec - timeval_start.tv_usec; - timeval_diff.tv_sec = timeval_stop.tv_sec - timeval_start.tv_sec; - if(timeval_diff.tv_usec < 0) { - timeval_diff.tv_usec += 1000000; - timeval_diff.tv_sec--; - } /* end if */ - time_diff = (double)timeval_diff.tv_sec + ((double)timeval_diff.tv_usec / (double)1000000.0f); - HDfprintf(file->logfp, " (%fs @ %.6lu.%.6llu)\n", time_diff, (unsigned long long)timeval_start.tv_sec, (unsigned long long)timeval_start.tv_usec); - - /* Add to total read time */ - file->total_read_time += time_diff; - } /* end if */ + /* Add the read time, if we're tracking that. + * Note that the read time is NOT emitted for when just H5FD_LOG_TIME_READ + * is set. + */ + if(file->fa.flags & H5FD_LOG_TIME_READ) + HDfprintf(file->logfp, " (%fs @ %f)\n", read_times.elapsed, read_timer.initial.elapsed); else HDfprintf(file->logfp, "\n"); -#else /* H5_HAVE_GETTIMEOFDAY */ - HDfprintf(file->logfp, "\n"); -#endif /* H5_HAVE_GETTIMEOFDAY */ } /* end if */ /* Update current position */ @@ -1379,10 +1349,14 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had H5FD_log_t *file = (H5FD_log_t *)_file; size_t orig_size = size; /* Save the original size for later */ haddr_t orig_addr = addr; -#ifdef H5_HAVE_GETTIMEOFDAY - struct timeval timeval_start, timeval_stop; -#endif /* H5_HAVE_GETTIMEOFDAY */ - herr_t ret_value = SUCCEED; /* Return value */ + H5_timer_t write_timer; /* Timer for write operation */ + H5_timevals_t write_times; /* Elapsed time for write operation */ +#ifndef H5_HAVE_PREADWRITE + H5_timer_t seek_timer; /* Timer for seek operation */ + H5_timevals_t seek_times; /* Elapsed time for seek operation */ +#endif /* H5_HAVE_PREADWRITE */ + HDoff_t offset = (HDoff_t)addr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1416,62 +1390,58 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had #ifndef H5_HAVE_PREADWRITE /* Seek to the correct location (if we don't have pwrite) */ if(addr != file->pos || OP_WRITE != file->op) { -#ifdef H5_HAVE_GETTIMEOFDAY - if(file->fa.flags & H5FD_LOG_TIME_SEEK) - HDgettimeofday(&timeval_start, NULL); -#endif /* H5_HAVE_GETTIMEOFDAY */ + /* Start timer for seek() call */ + if(file->fa.flags & H5FD_LOG_TIME_SEEK) { + H5_timer_init(&seek_timer); + H5_timer_start(&seek_timer); + } /* end if */ + if(HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") -#ifdef H5_HAVE_GETTIMEOFDAY + + /* Stop timer for seek() call */ if(file->fa.flags & H5FD_LOG_TIME_SEEK) - HDgettimeofday(&timeval_stop, NULL); -#endif /* H5_HAVE_GETTIMEOFDAY */ + H5_timer_stop(&seek_timer); - /* Log information about the seek */ + /* Add to the number of seeks, when tracking that */ if(file->fa.flags & H5FD_LOG_NUM_SEEK) file->total_seek_ops++; + + /* Add to the total seek time, when tracking that */ + if(file->fa.flags & H5FD_LOG_TIME_SEEK) { + H5_timer_get_times(seek_timer, &seek_times); + file->total_seek_time += seek_times.elapsed; + } /* end if */ + + /* Emit log string if we're tracking individual seek events. */ if(file->fa.flags & H5FD_LOG_LOC_SEEK) { HDfprintf(file->logfp, "Seek: From %10a To %10a", file->pos, addr); -#ifdef H5_HAVE_GETTIMEOFDAY - if(file->fa.flags & H5FD_LOG_TIME_SEEK) { - struct timeval timeval_diff; - double time_diff; - - /* Calculate the elapsed gettimeofday time */ - timeval_diff.tv_usec = timeval_stop.tv_usec - timeval_start.tv_usec; - timeval_diff.tv_sec = timeval_stop.tv_sec - timeval_start.tv_sec; - if(timeval_diff.tv_usec < 0) { - timeval_diff.tv_usec += 1000000; - timeval_diff.tv_sec--; - } /* end if */ - time_diff = (double)timeval_diff.tv_sec + ((double)timeval_diff.tv_usec / (double)1000000.0f); - HDfprintf(file->logfp, " (%fs @ %.6lu.%.6llu)\n", time_diff, (unsigned long long)timeval_start.tv_sec, (unsigned long long)timeval_start.tv_usec); - /* Add to total seek time */ - file->total_seek_time += time_diff; - } /* end if */ - else - HDfprintf(file->logfp, "\n"); -#else /* H5_HAVE_GETTIMEOFDAY */ - HDfprintf(file->logfp, "\n"); -#endif /* H5_HAVE_GETTIMEOFDAY */ + /* Add the seek time, if we're tracking that. + * Note that the seek time is NOT emitted for when just H5FD_LOG_TIME_SEEK + * is set. + */ + if(file->fa.flags & H5FD_LOG_TIME_SEEK) + HDfprintf(file->logfp, " (%fs @ %f)\n", seek_times.elapsed, seek_timer.initial.elapsed); + else + HDfprintf(file->logfp, "\n"); } /* end if */ } /* end if */ #endif /* H5_HAVE_PREADWRITE */ + /* Start timer for write operation */ + if(file->fa.flags&H5FD_LOG_TIME_WRITE) { + H5_timer_init(&write_timer); + H5_timer_start(&write_timer); + } /* end if */ + /* * Write the data, being careful of interrupted system calls and partial * results */ -#ifdef H5_HAVE_GETTIMEOFDAY - if(file->fa.flags&H5FD_LOG_TIME_WRITE) - HDgettimeofday(&timeval_start, NULL); -#endif /* H5_HAVE_GETTIMEOFDAY */ while(size > 0) { - h5_posix_io_t bytes_in = 0; /* # of bytes to write */ - h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes written */ - HDoff_t offset = (HDoff_t)addr; + h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes written */ /* Trying to write more bytes than the return type can handle is * undefined behavior in POSIX. @@ -1484,7 +1454,8 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had do { #ifdef H5_HAVE_PREADWRITE bytes_wrote = HDpwrite(file->fd, buf, bytes_in, offset); - offset += bytes_wrote; + if(bytes_wrote > 0) + offset += bytes_wrote; #else bytes_wrote = HDwrite(file->fd, buf, bytes_in); #endif /* H5_HAVE_PREADWRITE */ @@ -1509,14 +1480,22 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had addr += (haddr_t)bytes_wrote; buf = (const char *)buf + bytes_wrote; } /* end while */ -#ifdef H5_HAVE_GETTIMEOFDAY + + /* Stop timer for write operation */ if(file->fa.flags & H5FD_LOG_TIME_WRITE) - HDgettimeofday(&timeval_stop, NULL); -#endif /* H5_HAVE_GETTIMEOFDAY */ + H5_timer_stop(&write_timer); - /* Log information about the write */ + /* Add to the number of writes, when tracking that */ if(file->fa.flags & H5FD_LOG_NUM_WRITE) file->total_write_ops++; + + /* Add to the total write time, when tracking that */ + if(file->fa.flags & H5FD_LOG_TIME_WRITE) { + H5_timer_get_times(write_timer, &write_times); + file->total_write_time += write_times.elapsed; + } /* end if */ + + /* Log information about the write */ if(file->fa.flags & H5FD_LOG_LOC_WRITE) { HDfprintf(file->logfp, "%10a-%10a (%10Zu bytes) (%s) Written", orig_addr, (orig_addr + orig_size) - 1, orig_size, flavors[type]); @@ -1528,29 +1507,14 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had } /* end if */ } /* end if */ -#ifdef H5_HAVE_GETTIMEOFDAY - if(file->fa.flags & H5FD_LOG_TIME_WRITE) { - struct timeval timeval_diff; - double time_diff; - - /* Calculate the elapsed gettimeofday time */ - timeval_diff.tv_usec = timeval_stop.tv_usec - timeval_start.tv_usec; - timeval_diff.tv_sec = timeval_stop.tv_sec - timeval_start.tv_sec; - if(timeval_diff.tv_usec < 0) { - timeval_diff.tv_usec += 1000000; - timeval_diff.tv_sec--; - } /* end if */ - time_diff = (double)timeval_diff.tv_sec + ((double)timeval_diff.tv_usec / (double)1000000.0f); - HDfprintf(file->logfp, " (%fs @ %.6lu.%.6llu)\n", time_diff, (unsigned long long)timeval_start.tv_sec, (unsigned long long)timeval_start.tv_usec); - - /* Add to total write time */ - file->total_write_time += time_diff; - } /* end if */ - else - HDfprintf(file->logfp, "\n"); -#else /* H5_HAVE_GETTIMEOFDAY */ - HDfprintf(file->logfp, "\n"); -#endif /* H5_HAVE_GETTIMEOFDAY */ + /* Add the write time, if we're tracking that. + * Note that the write time is NOT emitted for when just H5FD_LOG_TIME_WRITE + * is set. + */ + if(file->fa.flags & H5FD_LOG_TIME_WRITE) + HDfprintf(file->logfp, " (%fs @ %f)\n", write_times.elapsed, write_timer.initial.elapsed); + else + HDfprintf(file->logfp, "\n"); } /* end if */ /* Update current position and eof */ @@ -1595,23 +1559,22 @@ H5FD_log_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_U /* Extend the file to make sure it's large enough */ if(!H5F_addr_eq(file->eoa, file->eof)) { -#ifdef H5_HAVE_GETTIMEOFDAY - struct timeval timeval_start, timeval_stop; -#endif /* H5_HAVE_GETTIMEOFDAY */ + H5_timer_t trunc_timer; /* Timer for truncate operation */ + H5_timevals_t trunc_times; /* Elapsed time for truncate operation */ + + /* Start timer for truncate operation */ + if(file->fa.flags & H5FD_LOG_TIME_TRUNCATE) { + H5_timer_init(&trunc_timer); + H5_timer_start(&trunc_timer); + } /* end if */ + #ifdef H5_HAVE_WIN32_API +{ LARGE_INTEGER li; /* 64-bit (union) integer for SetFilePointer() call */ DWORD dwPtrLow; /* Low-order pointer bits from SetFilePointer() * Only used as an error code here. */ - DWORD dwError; /* DWORD error code from GetLastError() */ - BOOL bError; /* Boolean error flag */ -#endif /* H5_HAVE_WIN32_API */ -#ifdef H5_HAVE_GETTIMEOFDAY - if(file->fa.flags & H5FD_LOG_TIME_TRUNCATE) - HDgettimeofday(&timeval_start, NULL); -#endif /* H5_HAVE_GETTIMEOFDAY */ -#ifdef H5_HAVE_WIN32_API /* Windows uses this odd QuadPart union for 32/64-bit portability */ li.QuadPart = (__int64)file->eoa; @@ -1622,51 +1585,48 @@ H5FD_log_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_U */ dwPtrLow = SetFilePointer(file->hFile, li.LowPart, &li.HighPart, FILE_BEGIN); if(INVALID_SET_FILE_POINTER == dwPtrLow) { + DWORD dwError; /* DWORD error code from GetLastError() */ + dwError = GetLastError(); if(dwError != NO_ERROR ) HGOTO_ERROR(H5E_FILE, H5E_FILEOPEN, FAIL, "unable to set file pointer") - } + } /* end if */ - bError = SetEndOfFile(file->hFile); - if(0 == bError) + if(0 == SetEndOfFile(file->hFile)) HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") +} #else /* H5_HAVE_WIN32_API */ + /* Truncate/extend the file */ if(-1 == HDftruncate(file->fd, (HDoff_t)file->eoa)) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") #endif /* H5_HAVE_WIN32_API */ -#ifdef H5_HAVE_GETTIMEOFDAY + + /* Stop timer for truncate operation */ if(file->fa.flags & H5FD_LOG_TIME_TRUNCATE) - HDgettimeofday(&timeval_stop, NULL); -#endif /* H5_HAVE_GETTIMEOFDAY */ + H5_timer_stop(&trunc_timer); - /* Log information about the truncate */ + /* Add to the number of truncates, when tracking that */ if(file->fa.flags & H5FD_LOG_NUM_TRUNCATE) file->total_truncate_ops++; + + /* Add to the total truncate time, when tracking that */ + if(file->fa.flags & H5FD_LOG_TIME_TRUNCATE) { + H5_timer_get_times(trunc_timer, &trunc_times); + file->total_truncate_time += trunc_times.elapsed; + } /* end if */ + + /* Emit log string if we're tracking individual truncate events. */ if(file->fa.flags & H5FD_LOG_TRUNCATE) { HDfprintf(file->logfp, "Truncate: To %10a", file->eoa); -#ifdef H5_HAVE_GETTIMEOFDAY - if(file->fa.flags & H5FD_LOG_TIME_TRUNCATE) { - struct timeval timeval_diff; - double time_diff; - - /* Calculate the elapsed gettimeofday time */ - timeval_diff.tv_usec = timeval_stop.tv_usec - timeval_start.tv_usec; - timeval_diff.tv_sec = timeval_stop.tv_sec - timeval_start.tv_sec; - if(timeval_diff.tv_usec < 0) { - timeval_diff.tv_usec += 1000000; - timeval_diff.tv_sec--; - } /* end if */ - time_diff = (double)timeval_diff.tv_sec + ((double)timeval_diff.tv_usec / (double)1000000.0f); - HDfprintf(file->logfp, " (%fs @ %.6lu.%.6llu)\n", time_diff, (unsigned long long)timeval_start.tv_sec, (unsigned long long)timeval_start.tv_usec); - /* Add to total truncate time */ - file->total_truncate_time += time_diff; - } /* end if */ - else - HDfprintf(file->logfp, "\n"); -#else /* H5_HAVE_GETTIMEOFDAY */ - HDfprintf(file->logfp, "\n"); -#endif /* H5_HAVE_GETTIMEOFDAY */ + /* Add the truncate time, if we're tracking that. + * Note that the truncate time is NOT emitted for when just H5FD_LOG_TIME_TRUNCATE + * is set. + */ + if(file->fa.flags & H5FD_LOG_TIME_TRUNCATE) + HDfprintf(file->logfp, " (%fs @ %f)\n", trunc_times.elapsed, trunc_timer.initial.elapsed); + else + HDfprintf(file->logfp, "\n"); } /* end if */ /* Update the eof value */ diff --git a/src/H5FDmirror.c b/src/H5FDmirror.c new file mode 100644 index 0000000..ef035c1 --- /dev/null +++ b/src/H5FDmirror.c @@ -0,0 +1,2001 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Transmit write-only operations to a receiver/writer process on + * a remote host. + */ + +#include "H5FDdrvr_module.h" /* This source code file is part of the H5FD driver module */ + +#include "H5private.h" /* Generic Functions */ + +#ifdef H5_HAVE_MIRROR_VFD + +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDmirror.h" /* "Mirror" definitions */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ + +/* The driver identification number, initialized at runtime */ +static hid_t H5FD_MIRROR_g = 0; + +/* Virtual file structure for a Mirror Driver */ +typedef struct H5FD_mirror_t { + H5FD_t pub; /* Public stuff, must be first */ + H5FD_mirror_fapl_t fa; /* Configuration structure */ + haddr_t eoa; /* End of allocated region */ + haddr_t eof; /* End of file; current file size */ + int sock_fd; /* Handle of socket to remote operator */ + H5FD_mirror_xmit_t xmit; /* Primary communication header */ + uint32_t xmit_i; /* Counter of transmission sent and rec'd */ +} H5FD_mirror_t; + +/* + * These macros check for overflow of various quantities. These macros + * assume that HDoff_t is signed and haddr_t and size_t are unsigned. + * + * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t' + * is too large to be represented by the second argument + * of the file seek function. + * + * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too + * large to be represented by the `size_t' type. + * + * REGION_OVERFLOW: Checks whether an address and size pair describe data + * which can be addressed entirely by the second + * argument of the file seek function. + */ +#define MAXADDR (((haddr_t)1<<(8*sizeof(HDoff_t)-1))-1) +#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || ((A) & ~(haddr_t)MAXADDR)) + +#ifndef BSWAP_64 +#define BSWAP_64(X) \ + (uint64_t)( (((X) & 0x00000000000000FF) << 56) \ + | (((X) & 0x000000000000FF00) << 40) \ + | (((X) & 0x0000000000FF0000) << 24) \ + | (((X) & 0x00000000FF000000) << 8) \ + | (((X) & 0x000000FF00000000) >> 8) \ + | (((X) & 0x0000FF0000000000) >> 24) \ + | (((X) & 0x00FF000000000000) >> 40) \ + | (((X) & 0xFF00000000000000) >> 56)) +#endif /* BSWAP_64 */ + +/* Debugging flabs for verbose tracing -- nonzero to enable */ +#define MIRROR_DEBUG_OP_CALLS 0 +#define MIRROR_DEBUG_XMIT_BYTES 0 + +#if MIRROR_DEBUG_XMIT_BYTES +#define LOG_XMIT_BYTES(label, buf, len) do { \ + ssize_t bytes_written = 0; \ + const unsigned char *b = NULL; \ + \ + HDfprintf(stdout, "%s bytes:\n```\n", (label)); \ + \ + /* print whole lines */ \ + while ((len - bytes_written) >= 32) { \ + b = (const unsigned char *)(buf) + bytes_written; \ + HDfprintf(stdout, \ + "%04zX %02X%02X%02X%02X %02X%02X%02X%02X" \ + " %02X%02X%02X%02X %02X%02X%02X%02X" \ + " %02X%02X%02X%02X %02X%02X%02X%02X" \ + " %02X%02X%02X%02X %02X%02X%02X%02X\n", \ + bytes_written, \ + b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7], \ + b[8], b[9], b[10],b[11], b[12],b[13],b[14],b[15], \ + b[16],b[17],b[18],b[19], b[20],b[21],b[22],b[23], \ + b[24],b[25],b[26],b[27], b[28],b[29],b[30],b[31]); \ + bytes_written += 32; \ + } \ + \ + /* start partial line */ \ + if (len > bytes_written) { \ + HDfprintf(stdout, "%04zX ", bytes_written); \ + } \ + \ + /* partial line blocks */ \ + while ((len - bytes_written) >= 4) { \ + HDfprintf(stdout, " %02X%02X%02X%02X", \ + (buf)[bytes_written], (buf)[bytes_written+1], \ + (buf)[bytes_written+2], (buf)[bytes_written+3]); \ + bytes_written += 4; \ + } \ + \ + /* block separator before partial block */ \ + if (len > bytes_written) { \ + HDfprintf(stdout, " "); \ + } \ + \ + /* partial block individual bytes */ \ + while (len > bytes_written) { \ + HDfprintf(stdout, "%02X", (buf)[bytes_written++]); \ + } \ + \ + /* end partial line */ \ + HDfprintf(stdout, "\n"); \ + HDfprintf(stdout, "```\n"); \ + HDfflush(stdout); \ +} while (0) +#else +#define LOG_XMIT_BYTES(label, buf, len) /* no-op */ +#endif /* MIRROR_DEBUG_XMIT_BYTE */ + +#if MIRROR_DEBUG_OP_CALLS +#define LOG_OP_CALL(name) do { \ + HDprintf("called %s()\n", (name)); \ + fflush(stdout); \ +} while (0) +#else +#define LOG_OP_CALL(name) /* no-op */ +#endif /* MIRROR_DEBUG_OP_CALLS */ + +/* Prototypes */ +static herr_t H5FD_mirror_term(void); +static void *H5FD_mirror_fapl_get(H5FD_t *_file); +static void *H5FD_mirror_fapl_copy(const void *_old_fa); +static herr_t H5FD_mirror_fapl_free(void *_fa); +static haddr_t H5FD_mirror_get_eoa(const H5FD_t *_file, H5FD_mem_t type); +static herr_t H5FD_mirror_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); +static haddr_t H5FD_mirror_get_eof(const H5FD_t *_file, H5FD_mem_t type); +static H5FD_t *H5FD_mirror_open(const char *name, unsigned flags, \ + hid_t fapl_id, haddr_t maxaddr); +static herr_t H5FD_mirror_close(H5FD_t *_file); +static herr_t H5FD_mirror_query(const H5FD_t *_file, unsigned long *flags); +static herr_t H5FD_mirror_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, \ + haddr_t addr, size_t size, const void *buf); +static herr_t H5FD_mirror_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, + haddr_t addr, size_t size, void *buf); +static herr_t H5FD_mirror_truncate(H5FD_t *_file, hid_t dxpl_id, \ + hbool_t closing); +static herr_t H5FD_mirror_lock(H5FD_t *_file, hbool_t rw); +static herr_t H5FD_mirror_unlock(H5FD_t *_file); + +static herr_t H5FD__mirror_verify_reply(H5FD_mirror_t *file); + +static const H5FD_class_t H5FD_mirror_g = { + "mirror", /* name */ + MAXADDR, /* maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + H5FD_mirror_term, /* terminate */ + NULL, /* sb_size */ + NULL, /* sb_encode */ + NULL, /* sb_decode */ + 0, /* fapl_size */ + H5FD_mirror_fapl_get, /* fapl_get */ + H5FD_mirror_fapl_copy, /* fapl_copy */ + H5FD_mirror_fapl_free, /* fapl_free */ + 0, /* dxpl_size */ + NULL, /* dxpl_copy */ + NULL, /* dxpl_free */ + H5FD_mirror_open, /* open */ + H5FD_mirror_close, /* close */ + NULL, /* cmp */ + H5FD_mirror_query, /* query */ + NULL, /* get_type_map */ + NULL, /* alloc */ + NULL, /* free */ + H5FD_mirror_get_eoa, /* get_eoa */ + H5FD_mirror_set_eoa, /* set_eoa */ + H5FD_mirror_get_eof, /* get_eof */ + NULL, /* get_handle */ + H5FD_mirror_read, /* read */ + H5FD_mirror_write, /* write */ + NULL, /* flush */ + H5FD_mirror_truncate, /* truncate */ + H5FD_mirror_lock, /* lock */ + H5FD_mirror_unlock, /* unlock */ + H5FD_FLMAP_DICHOTOMY /* fl_map */ +}; + +/* Declare a free list to manage the H5FD_mirror_t struct */ +H5FL_DEFINE_STATIC(H5FD_mirror_t); + + +/*------------------------------------------------------------------------- + * Function: H5FD__init_package + * + * Purpose: Initializes any interface-specific data or routines. + * + * Return: Non-negative on success/Negative on failure + *------------------------------------------------------------------------- + */ +static herr_t +H5FD__init_package(void) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + LOG_OP_CALL("H5FD__init_package"); + + if (H5FD_mirror_init() < 0) { + HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, + "unable to initialize mirror VFD"); + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5FD__init_package() */ + + +/* ------------------------------------------------------------------------- + * Function: H5FD_mirror_init + * + * Purpose: Initialize this driver by registering the driver with the + * library. + * + * Return: Success: The driver ID for the mirror driver. + * Failure: Negative + * ------------------------------------------------------------------------- + */ +hid_t +H5FD_mirror_init(void) +{ + hid_t ret_value = H5I_INVALID_HID; + + FUNC_ENTER_NOAPI(FAIL) + + LOG_OP_CALL("H5FD_mirror_init"); + + if (H5I_VFL != H5I_get_type(H5FD_MIRROR_g)) { + H5FD_MIRROR_g = H5FD_register(&H5FD_mirror_g, sizeof(H5FD_class_t), + FALSE); + } + + ret_value = H5FD_MIRROR_g; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_mirror_init() */ + + +/* --------------------------------------------------------------------------- + * Function: H5FD_mirror_term + * + * Purpose: Shut down the VFD + * + * Returns: SUCCEED (Can't fail) + * --------------------------------------------------------------------------- + */ +static herr_t +H5FD_mirror_term(void) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + /* Reset VFL ID */ + H5FD_MIRROR_g = 0; + + LOG_OP_CALL("H5FD_mirror_term"); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FD_mirror_term() */ + + +/* --------------------------------------------------------------------------- + * Function: H5FD__mirror_xmit_decode_uint16 + * + * Purpose: Extract a 16-bit integer in "network" (Big-Endian) word order + * from the byte-buffer and return it with the local word order at + * the destination pointer. + * + * The programmer must ensure that the received buffer holds + * at least the expected size of data. + * + * Return: The number of bytes read from the buffer (2). + * --------------------------------------------------------------------------- + */ +size_t +H5FD__mirror_xmit_decode_uint16(uint16_t *out, const unsigned char *_buf) +{ + uint16_t n = 0; + LOG_OP_CALL("H5FD__mirror_xmit_decode_uint16"); + HDassert(_buf && out); + HDmemcpy(&n, _buf, sizeof(n)); + *out = (uint16_t)HDntohs(n); + return 2; /* number of bytes eaten */ +} /* end H5FD__mirror_xmit_decode_uint16() */ + + +/* --------------------------------------------------------------------------- + * Function: H5FD__mirror_xmit_decode_uint32 + * + * Purpose: Extract a 32-bit integer in "network" (Big-Endian) word order + * from the byte-buffer and return it with the local word order at + * the destination pointer. + * + * The programmer must ensure that the received buffer holds + * at least the expected size of data. + * + * Return: The number of bytes read from the buffer (4). + * --------------------------------------------------------------------------- + */ +size_t +H5FD__mirror_xmit_decode_uint32(uint32_t *out, const unsigned char *_buf) +{ + uint32_t n = 0; + LOG_OP_CALL("H5FD__mirror_xmit_decode_uint32"); + HDassert(_buf && out); + HDmemcpy(&n, _buf, sizeof(n)); + *out = (uint32_t)HDntohl(n); + return 4; /* number of bytes eaten */ +} /* end H5FD__mirror_xmit_decode_uint32() */ + + + +/* --------------------------------------------------------------------------- + * Function: is_host_little_endian + * + * Purpose: Determine whether the host machine is is little-endian. + * + * Store an intger with a known value, re-map the memory to a + * character array, and inspect the array's contents. + * + * Return: The number of bytes written to the buffer (8). + * + * Programmer: Jacob Smith + * 2020-03-05 + * --------------------------------------------------------------------------- + */ +static hbool_t +is_host_little_endian(void) +{ + union { + uint32_t u32; + uint8_t u8[4]; + } echeck; + echeck.u32 = 0xA1B2C3D4; + if (echeck.u8[0] == 0xD4) { + return TRUE; + } + else { + return FALSE; + } +} /* end is_host_little_endian() */ + + +/* --------------------------------------------------------------------------- + * Function: H5FD__mirror_xmit_decode_uint64 + * + * Purpose: Extract a 64-bit integer in "network" (Big-Endian) word order + * from the byte-buffer and return it with the local word order. + * + * The programmer must ensure that the received buffer holds + * at least the expected size of data. + * + * WARNING: Does not accommodate other forms of endianness, + * e.g. "middle-endian". + * + * Return: The number of bytes written to the buffer (8). + * --------------------------------------------------------------------------- + */ +size_t +H5FD__mirror_xmit_decode_uint64(uint64_t *out, const unsigned char *_buf) +{ + uint64_t n = 0; + LOG_OP_CALL("H5FD__mirror_xmit_decode_uint64"); + HDassert(_buf && out); + HDmemcpy(&n, _buf, sizeof(n)); + if (TRUE == is_host_little_endian()) { + *out = BSWAP_64(n); + } + else { + *out = n; + } + return 8; +} /* end H5FD__mirror_xmit_decode_uint64() */ + + +/* --------------------------------------------------------------------------- + * Function: H5FD__mirror_xmit_decode_uint8 + * + * Purpose: Extract a 8-bit integer in "network" (Big-Endian) word order + * from the byte-buffer and return it with the local word order at + * the destination pointer. + * (yes, it's one byte). + * + * Return: The number of bytes read from the buffer (1). + * --------------------------------------------------------------------------- + */ +size_t +H5FD__mirror_xmit_decode_uint8(uint8_t *out, const unsigned char *_buf) +{ + LOG_OP_CALL("H5FD__mirror_xmit_decode_uint8"); + HDassert(_buf && out); + HDmemcpy(out, _buf, sizeof(uint8_t)); + return 1; /* number of bytes eaten */ +} /* end H5FD__mirror_xmit_decode_uint8() */ + + +/* --------------------------------------------------------------------------- + * Function: H5FD__mirror_xmit_encode_uint16 + * + * Purpose: Encode a 16-bit integer in "network" (Big-Endian) word order + * in place in the destination bytes-buffer. + * + * The programmer must ensure that the destination buffer is + * large enough to hold the expected data. + * + * Return: The number of bytes written to the buffer (2). + * --------------------------------------------------------------------------- + */ +size_t +H5FD__mirror_xmit_encode_uint16(unsigned char *_dest, uint16_t v) +{ + uint16_t n = 0; + LOG_OP_CALL("H5FD__mirror_xmit_encode_uint16"); + HDassert(_dest); + n = (uint16_t)HDhtons(v); + HDmemcpy(_dest, &n, sizeof(n)); + return 2; +} /* end H5FD__mirror_xmit_encode_uint16() */ + + +/* --------------------------------------------------------------------------- + * Function: H5FD__mirror_xmit_encode_uint32 + * + * Purpose: Encode a 32-bit integer in "network" (Big-Endian) word order + * in place in the destination bytes-buffer. + * + * The programmer must ensure that the destination buffer is + * large enough to hold the expected data. + * + * Return: The number of bytes written to the buffer (4). + * --------------------------------------------------------------------------- + */ +size_t +H5FD__mirror_xmit_encode_uint32(unsigned char *_dest, uint32_t v) +{ + uint32_t n = 0; + LOG_OP_CALL("H5FD__mirror_xmit_encode_uint32"); + HDassert(_dest); + n = (uint32_t)HDhtonl(v); + HDmemcpy(_dest, &n, sizeof(n)); + return 4; +} /* end H5FD__mirror_xmit_encode_uint32() */ + + +/* --------------------------------------------------------------------------- + * Function: H5FD__mirror_xmit_encode_uint64 + * + * Purpose: Encode a 64-bit integer in "network" (Big-Endian) word order + * in place in the destination bytes-buffer. + * + * The programmer must ensure that the destination buffer is + * large enough to hold the expected data. + * + * Return: The number of bytes written to the buffer (8). + * --------------------------------------------------------------------------- + */ +size_t +H5FD__mirror_xmit_encode_uint64(unsigned char *_dest, uint64_t v) +{ + uint64_t n = v; + LOG_OP_CALL("H5FD__mirror_xmit_decode_uint64"); + HDassert(_dest); + if (TRUE == is_host_little_endian()) { + n = BSWAP_64(v); + } + HDmemcpy(_dest, &n, sizeof(n)); + return 8; +} /* H5FD__mirror_xmit_encode_uint64() */ + + +/* --------------------------------------------------------------------------- + * Function: H5FD__mirror_xmit_encode_uint8 + * + * Purpose: Encode a 8-bit integer in "network" (Big-Endian) word order + * in place in the destination bytes-buffer. + * (yes, it's one byte). + * + * The programmer must ensure that the destination buffer is + * large enough to hold the expected data. + * + * Return: The number of bytes read from the buffer (1). + * --------------------------------------------------------------------------- + */ +size_t +H5FD__mirror_xmit_encode_uint8(unsigned char *dest, uint8_t v) +{ + LOG_OP_CALL("H5FD__mirror_xmit_encode_uint8"); + HDassert(dest); + HDmemcpy(dest, &v, sizeof(v)); + return 1; +} /* end H5FD__mirror_xmit_encode_uint8() */ + + +/* --------------------------------------------------------------------------- + * Function: H5FD_mirror_xmit_decode_header + * + * Purpose: Extract a mirror_xmit_t "header" from the bytes-buffer. + * + * Fields will be lifted from the buffer and stored in the + * target structure, using in the correct location (different + * systems may insert different padding between components) and + * word order (Big- vs Little-Endian). + * + * The resulting structure should be sanity-checked with + * H5FD_mirror_xmit_is_xmit() before use. + * + * The programmer must ensure that the received buffer holds + * at least the expected size of data. + * + * Return: The number of bytes consumed from the buffer. + * --------------------------------------------------------------------------- + */ +size_t +H5FD_mirror_xmit_decode_header(H5FD_mirror_xmit_t *out, + const unsigned char *buf) +{ + size_t n_eaten = 0; + LOG_OP_CALL("H5FD_mirror_xmit_decode_header"); + HDassert(out && buf); + n_eaten += H5FD__mirror_xmit_decode_uint32(&(out->magic), &buf[n_eaten]); + n_eaten += H5FD__mirror_xmit_decode_uint8(&(out->version), &buf[n_eaten]); + n_eaten += H5FD__mirror_xmit_decode_uint32(&(out->session_token), + &buf[n_eaten]); + n_eaten += H5FD__mirror_xmit_decode_uint32(&(out->xmit_count), + &buf[n_eaten]); + n_eaten += H5FD__mirror_xmit_decode_uint8(&(out->op), &buf[n_eaten]); + HDassert(n_eaten == H5FD_MIRROR_XMIT_HEADER_SIZE); + return n_eaten; +} /* end H5FD_mirror_xmit_decode_header() */ + + +/* --------------------------------------------------------------------------- + * Function: H5FD_mirror_xmit_decode_lock + * + * Purpose: Extract a mirror_xmit_lock_t from the bytes-buffer. + * + * Fields will be lifted from the buffer and stored in the + * target structure, using in the correct location (different + * systems may insert different padding between components) and + * word order (Big- vs Little-Endian). + * + * The programmer must ensure that the received buffer holds + * at least the expected size of data. + * + * The resulting structure should be sanity-checked with + * H5FD_mirror_xmit_is_lock() before use. + * + * Return: The number of bytes consumed from the buffer. + * --------------------------------------------------------------------------- + */ +size_t +H5FD_mirror_xmit_decode_lock(H5FD_mirror_xmit_lock_t *out, + const unsigned char *buf) +{ + size_t n_eaten = 0; + LOG_OP_CALL("H5FD_mirror_xmit_decode_lock"); + HDassert(out && buf); + n_eaten += H5FD_mirror_xmit_decode_header(&(out->pub), buf); + n_eaten += H5FD__mirror_xmit_decode_uint64(&(out->rw), &buf[n_eaten]); + HDassert(n_eaten == H5FD_MIRROR_XMIT_LOCK_SIZE); + return n_eaten; +} /* end H5FD_mirror_xmit_decode_lock() */ + + +/* --------------------------------------------------------------------------- + * Function: H5FD_mirror_xmit_decode_open + * + * Purpose: Extract a mirror_xmit_open_t from the bytes-buffer. + * + * Fields will be lifted from the buffer and stored in the + * target structure, using in the correct location (different + * systems may insert different padding between components) and + * word order (Big- vs Little-Endian). + * + * The programmer must ensure that the received buffer holds + * at least the expected size of data. + * + * The resulting structure should be sanity-checked with + * H5FD_mirror_xmit_is_open() before use. + * + * Return: The maximum number of bytes that this decoding operation might + * have consumed from the buffer. + * --------------------------------------------------------------------------- + */ +size_t +H5FD_mirror_xmit_decode_open(H5FD_mirror_xmit_open_t *out, + const unsigned char *buf) +{ + size_t n_eaten = 0; + LOG_OP_CALL("H5FD_mirror_xmit_decode_open"); + HDassert(out && buf); + n_eaten += H5FD_mirror_xmit_decode_header(&(out->pub), buf); + n_eaten += H5FD__mirror_xmit_decode_uint32(&(out->flags), &buf[n_eaten]); + n_eaten += H5FD__mirror_xmit_decode_uint64(&(out->maxaddr), &buf[n_eaten]); + n_eaten += H5FD__mirror_xmit_decode_uint64(&(out->size_t_blob), + &buf[n_eaten]); + HDassert((H5FD_MIRROR_XMIT_OPEN_SIZE - H5FD_MIRROR_XMIT_FILEPATH_MAX) + == n_eaten); + HDstrncpy(out->filename, (const char *)&buf[n_eaten], + H5FD_MIRROR_XMIT_FILEPATH_MAX-1); + out->filename[H5FD_MIRROR_XMIT_FILEPATH_MAX-1] = 0; /* force final NULL */ + return H5FD_MIRROR_XMIT_OPEN_SIZE; +} /* end H5FD_mirror_xmit_decode_open() */ + + +/* --------------------------------------------------------------------------- + * Function: H5FD_mirror_xmit_decode_reply + * + * Purpose: Extract a mirror_xmit_reply_t from the bytes-buffer. + * + * Fields will be lifted from the buffer and stored in the + * target structure, using in the correct location (different + * systems may insert different padding between components) and + * word order (Big- vs Little-Endian). + * + * The programmer must ensure that the received buffer holds + * at least the expected size of data. + * + * The resulting structure should be sanity-checked with + * H5FD_mirror_xmit_is_reply() before use. + * + * Return: The maximum number of bytes that this decoding operation might + * have consumed from the buffer. + * --------------------------------------------------------------------------- + */ +size_t +H5FD_mirror_xmit_decode_reply(H5FD_mirror_xmit_reply_t *out, + const unsigned char *buf) +{ + size_t n_eaten = 0; + LOG_OP_CALL("H5FD_mirror_xmit_decode_reply"); + HDassert(out && buf); + n_eaten += H5FD_mirror_xmit_decode_header(&(out->pub), buf); + n_eaten += H5FD__mirror_xmit_decode_uint32(&(out->status), &buf[n_eaten]); + HDassert((H5FD_MIRROR_XMIT_REPLY_SIZE - H5FD_MIRROR_STATUS_MESSAGE_MAX) + == n_eaten); + HDstrncpy(out->message, (const char *)&buf[n_eaten], + H5FD_MIRROR_STATUS_MESSAGE_MAX-1); + out->message[H5FD_MIRROR_STATUS_MESSAGE_MAX-1] = 0; /* force NULL term */ + return H5FD_MIRROR_XMIT_REPLY_SIZE; +} /* end H5FD_mirror_xmit_decode_reply() */ + + +/* --------------------------------------------------------------------------- + * Function: H5FD_mirror_xmit_decode_set_eoa + * + * Purpose: Extract a mirror_xmit_eoa_t from the bytes-buffer. + * + * Fields will be lifted from the buffer and stored in the + * target structure, using in the correct location (different + * systems may insert different padding between components) and + * word order (Big- vs Little-Endian). + * + * The programmer must ensure that the received buffer holds + * at least the expected size of data. + * + * The resulting structure should be sanity-checked with + * H5FD_mirror_xmit_is_set_eoa() before use. + * + * Return: The number of bytes consumed from the buffer. + * --------------------------------------------------------------------------- + */ +size_t +H5FD_mirror_xmit_decode_set_eoa(H5FD_mirror_xmit_eoa_t *out, + const unsigned char *buf) +{ + size_t n_eaten = 0; + LOG_OP_CALL("H5FD_mirror_xmit_decode_set_eoa"); + HDassert(out && buf); + n_eaten += H5FD_mirror_xmit_decode_header(&(out->pub), buf); + n_eaten += H5FD__mirror_xmit_decode_uint8(&(out->type), &buf[n_eaten]); + n_eaten += H5FD__mirror_xmit_decode_uint64(&(out->eoa_addr), &buf[n_eaten]); + HDassert(n_eaten == H5FD_MIRROR_XMIT_EOA_SIZE); + return n_eaten; +} /* end H5FD_mirror_xmit_decode_set_eoa() */ + + +/* --------------------------------------------------------------------------- + * Function: H5FD_mirror_xmit_decode_write + * + * Purpose: Extract a mirror_xmit_write_t from the bytes-buffer. + * + * Fields will be lifted from the buffer and stored in the + * target structure, using in the correct location (different + * systems may insert different padding between components) and + * word order (Big- vs Little-Endian). + * + * The programmer must ensure that the received buffer holds + * at least the expected size of data. + * + * The resulting structure should be sanity-checked with + * H5FD_mirror_xmit_is_write() before use. + * + * Return: The number of bytes consumed from the buffer. + * --------------------------------------------------------------------------- + */ +size_t +H5FD_mirror_xmit_decode_write(H5FD_mirror_xmit_write_t *out, + const unsigned char *buf) +{ + size_t n_eaten = 0; + LOG_OP_CALL("H5FD_mirror_xmit_decode_write"); + HDassert(out && buf); + n_eaten += H5FD_mirror_xmit_decode_header(&(out->pub), buf); + n_eaten += H5FD__mirror_xmit_decode_uint8(&(out->type), &buf[n_eaten]); + n_eaten += H5FD__mirror_xmit_decode_uint64(&(out->offset), &buf[n_eaten]); + n_eaten += H5FD__mirror_xmit_decode_uint64(&(out->size), &buf[n_eaten]); + HDassert(n_eaten == H5FD_MIRROR_XMIT_WRITE_SIZE); + return n_eaten; +} /* end H5FD_mirror_xmit_decode_write() */ + + +/* --------------------------------------------------------------------------- + * Function: H5FD_mirror_xmit_encode_header + * + * Purpose: Encode a mirror_xmit_t "header" to the bytes-buffer. + * + * Fields will be packed into the buffer in a predictable manner, + * any numbers stored in "network" (Big-Endian) word order. + * + * The programmer must ensure that the destination buffer is + * large enough to hold the expected data. + * + * Return: The number of bytes written to the buffer. + * --------------------------------------------------------------------------- + */ +size_t +H5FD_mirror_xmit_encode_header(unsigned char *dest, + const H5FD_mirror_xmit_t *x) +{ + size_t n_writ = 0; + LOG_OP_CALL("H5FD_mirror_xmit_encode_header"); + HDassert(dest && x); + n_writ += H5FD__mirror_xmit_encode_uint32((dest+n_writ), x->magic); + n_writ += H5FD__mirror_xmit_encode_uint8((dest+n_writ), x->version); + n_writ += H5FD__mirror_xmit_encode_uint32((dest+n_writ), x->session_token); + n_writ += H5FD__mirror_xmit_encode_uint32((dest+n_writ), x->xmit_count); + n_writ += H5FD__mirror_xmit_encode_uint8((dest+n_writ), x->op); + HDassert(n_writ == H5FD_MIRROR_XMIT_HEADER_SIZE); + return n_writ; +} /* end H5FD_mirror_xmit_encode_header() */ + + +/* --------------------------------------------------------------------------- + * Function: H5FD_mirror_xmit_encode_lock + * + * Purpose: Encode a mirror_xmit_lock_t to the bytes-buffer. + * Fields will be packed into the buffer in a predictable manner, + * any numbers stored in "network" (Big-Endian) word order. + * + * The programmer must ensure that the destination buffer is + * large enough to hold the expected data. + * + * Return: The number of bytes written to the buffer. + * --------------------------------------------------------------------------- + */ +size_t +H5FD_mirror_xmit_encode_lock(unsigned char *dest, + const H5FD_mirror_xmit_lock_t *x) +{ + size_t n_writ = 0; + LOG_OP_CALL("H5FD_mirror_xmit_encode_lock"); + HDassert(dest && x); + n_writ += H5FD_mirror_xmit_encode_header(dest, + (const H5FD_mirror_xmit_t *)&(x->pub)); + n_writ += H5FD__mirror_xmit_encode_uint64(&dest[n_writ], x->rw); + HDassert(n_writ == H5FD_MIRROR_XMIT_LOCK_SIZE); + return n_writ; +} /* end H5FD_mirror_xmit_encode_lock() */ + + +/* --------------------------------------------------------------------------- + * Function: H5FD_mirror_xmit_encode_open + * + * Purpose: Encode a mirror_xmit_open_t to the bytes-buffer. + * Fields will be packed into the buffer in a predictable manner, + * any numbers stored in "network" (Big-Endian) word order. + * + * The programmer must ensure that the destination buffer is + * large enough to hold the expected data. + * + * Return: The maximum number of bytes that this decoding operation might + * have written into the buffer. + * --------------------------------------------------------------------------- + */ +size_t +H5FD_mirror_xmit_encode_open(unsigned char *dest, + const H5FD_mirror_xmit_open_t *x) +{ + size_t n_writ = 0; + LOG_OP_CALL("H5FD_mirror_xmit_encode_open"); + HDassert(dest && x); + /* clear entire structure, but especially its filepath string area */ + for (n_writ = 0; n_writ < H5FD_MIRROR_XMIT_OPEN_SIZE; n_writ++) { + *(dest+n_writ) = 0; + } + n_writ = 0; + n_writ += H5FD_mirror_xmit_encode_header(dest, + (const H5FD_mirror_xmit_t *)&(x->pub)); + n_writ += H5FD__mirror_xmit_encode_uint32(&dest[n_writ], x->flags); + n_writ += H5FD__mirror_xmit_encode_uint64(&dest[n_writ], x->maxaddr); + n_writ += H5FD__mirror_xmit_encode_uint64(&dest[n_writ], x->size_t_blob); + HDassert((H5FD_MIRROR_XMIT_OPEN_SIZE - H5FD_MIRROR_XMIT_FILEPATH_MAX) + == n_writ); + HDstrncpy((char *)&dest[n_writ], x->filename, + H5FD_MIRROR_XMIT_FILEPATH_MAX); + return H5FD_MIRROR_XMIT_OPEN_SIZE; +} /* end H5FD_mirror_xmit_encode_open() */ + + +/* --------------------------------------------------------------------------- + * Function: H5FD_mirror_xmit_encode_reply + * + * Purpose: Encode a mirror_xmit_reply_t to the bytes-buffer. + * + * Fields will be packed into the buffer in a predictable manner, + * any numbers stored in "network" (Big-Endian) word order. + * + * The programmer must ensure that the destination buffer is + * large enough to hold the expected data. + * + * Return: The maximum number of bytes that this decoding operation might + * have written into the buffer. + * --------------------------------------------------------------------------- + */ +size_t +H5FD_mirror_xmit_encode_reply(unsigned char *dest, + const H5FD_mirror_xmit_reply_t *x) +{ + size_t n_writ = 0; + LOG_OP_CALL("H5FD_mirror_xmit_encode_reply"); + HDassert(dest && x); + /* clear entire structure, but especially its message string area */ + for (n_writ = 0; n_writ < H5FD_MIRROR_XMIT_REPLY_SIZE; n_writ++) { + *(dest+n_writ) = 0; + } + n_writ = 0; + n_writ += H5FD_mirror_xmit_encode_header(dest, + (const H5FD_mirror_xmit_t *)&(x->pub)); + n_writ += H5FD__mirror_xmit_encode_uint32(&dest[n_writ], x->status); + HDassert((H5FD_MIRROR_XMIT_REPLY_SIZE - H5FD_MIRROR_STATUS_MESSAGE_MAX) + == n_writ); + HDstrncpy((char *)&dest[n_writ], x->message, + H5FD_MIRROR_STATUS_MESSAGE_MAX); + return H5FD_MIRROR_XMIT_REPLY_SIZE; +} /* end H5FD_mirror_xmit_encode_reply() */ + + +/* --------------------------------------------------------------------------- + * Function: H5FD_mirror_xmit_encode_set_eoa + * + * Purpose: Encode a mirror_xmit_eoa_t to the bytes-buffer. + * + * Fields will be packed into the buffer in a predictable manner, + * any numbers stored in "network" (Big-Endian) word order. + * + * The programmer must ensure that the destination buffer is + * large enough to hold the expected data. + * + * Return: The number of bytes written to the buffer. + * --------------------------------------------------------------------------- + */ +size_t +H5FD_mirror_xmit_encode_set_eoa(unsigned char *dest, + const H5FD_mirror_xmit_eoa_t *x) +{ + size_t n_writ = 0; + LOG_OP_CALL("H5FD_mirror_xmit_encode_set_eoa"); + HDassert(dest && x); + n_writ += H5FD_mirror_xmit_encode_header(dest, + (const H5FD_mirror_xmit_t *)&(x->pub)); + n_writ += H5FD__mirror_xmit_encode_uint8(&dest[n_writ], x->type); + n_writ += H5FD__mirror_xmit_encode_uint64(&dest[n_writ], x->eoa_addr); + HDassert(n_writ == H5FD_MIRROR_XMIT_EOA_SIZE); + return n_writ; +} /* end H5FD_mirror_xmit_encode_set_eoa() */ + + +/* --------------------------------------------------------------------------- + * Function: H5FD_mirror_xmit_encode_write + * + * Purpose: Encode a mirror_xmit_write_t to the bytes-buffer. + * + * Fields will be packed into the buffer in a predictable manner, + * any numbers stored in "network" (Big-Endian) word order. + * + * The programmer must ensure that the destination buffer is + * large enough to hold the expected data. + * + * Return: The number of bytes written to the buffer. + * --------------------------------------------------------------------------- + */ +size_t +H5FD_mirror_xmit_encode_write(unsigned char *dest, + const H5FD_mirror_xmit_write_t *x) +{ + size_t n_writ = 0; + LOG_OP_CALL("H5FD_mirror_xmit_encode_write"); + HDassert(dest && x); + n_writ += H5FD_mirror_xmit_encode_header(dest, + (const H5FD_mirror_xmit_t *)&(x->pub)); + n_writ += H5FD__mirror_xmit_encode_uint8(&dest[n_writ], x->type); + n_writ += H5FD__mirror_xmit_encode_uint64(&dest[n_writ], x->offset); + n_writ += H5FD__mirror_xmit_encode_uint64(&dest[n_writ], x->size); + HDassert(n_writ == H5FD_MIRROR_XMIT_WRITE_SIZE); + return n_writ; +} /* end H5FD_mirror_xmit_encode_write() */ + + +/* --------------------------------------------------------------------------- + * Function: H5FD_mirror_xmit_is_close + * + * Purpose: Verify that a mirror_xmit_t is a valid CLOSE xmit. + * + * Checks header validity and op code. + * + * Return: TRUE if valid; else FALSE. + * --------------------------------------------------------------------------- + */ +hbool_t +H5FD_mirror_xmit_is_close(const H5FD_mirror_xmit_t *xmit) +{ + LOG_OP_CALL("H5FD_mirror_xmit_is_close"); + HDassert(xmit); + if ( (TRUE == H5FD_mirror_xmit_is_xmit(xmit)) && + (H5FD_MIRROR_OP_CLOSE == xmit->op) ) + { + return TRUE; + } + return FALSE; +} /* end H5FD_mirror_xmit_is_close() */ + + +/* --------------------------------------------------------------------------- + * Function: H5FD_mirror_xmit_is_lock + * + * Purpose: Verify that a mirror_xmit_lock_t is a valid LOCK xmit. + * + * Checks header validity and op code. + * + * Return: TRUE if valid; else FALSE. + * --------------------------------------------------------------------------- + */ +hbool_t +H5FD_mirror_xmit_is_lock(const H5FD_mirror_xmit_lock_t *xmit) +{ + LOG_OP_CALL("H5FD_mirror_xmit_is_lock"); + HDassert(xmit); + if ( (TRUE == H5FD_mirror_xmit_is_xmit(&(xmit->pub))) && + (H5FD_MIRROR_OP_LOCK == xmit->pub.op) ) + { + return TRUE; + } + return FALSE; +} /* end H5FD_mirror_xmit_is_lock() */ + + +/* --------------------------------------------------------------------------- + * Function: H5FD_mirror_xmit_is_open + * + * Purpose: Verify that a mirror_xmit_open_t is a valid OPEN xmit. + * + * Checks header validity and op code. + * + * Return: TRUE if valid; else FALSE. + * --------------------------------------------------------------------------- + */ +hbool_t +H5FD_mirror_xmit_is_open(const H5FD_mirror_xmit_open_t *xmit) +{ + LOG_OP_CALL("H5FD_mirror_xmit_is_open"); + HDassert(xmit); + if ( (TRUE == H5FD_mirror_xmit_is_xmit(&(xmit->pub))) && + (H5FD_MIRROR_OP_OPEN == xmit->pub.op) ) + { + return TRUE; + } + return FALSE; +} /* end H5FD_mirror_xmit_is_open() */ + + +/* --------------------------------------------------------------------------- + * Function: H5FD_mirror_xmit_is_eoa + * + * Purpose: Verify that a mirror_xmit_eoa_t is a valid SET-EOA xmit. + * + * Checks header validity and op code. + * + * Return: TRUE if valid; else FALSE. + * --------------------------------------------------------------------------- + */ +hbool_t +H5FD_mirror_xmit_is_set_eoa(const H5FD_mirror_xmit_eoa_t *xmit) +{ + LOG_OP_CALL("H5FD_mirror_xmit_is_set_eoa"); + HDassert(xmit); + if ( (TRUE == H5FD_mirror_xmit_is_xmit(&(xmit->pub))) && + (H5FD_MIRROR_OP_SET_EOA == xmit->pub.op) ) + { + return TRUE; + } + return FALSE; +} /* end H5FD_mirror_xmit_is_eoa() */ + + +/* --------------------------------------------------------------------------- + * Function: H5FD_mirror_xmit_is_reply + * + * Purpose: Verify that a mirror_xmit_reply_t is a valid REPLY xmit. + * + * Checks header validity and op code. + * + * Return: TRUE if valid; else FALSE. + * --------------------------------------------------------------------------- + */ +hbool_t +H5FD_mirror_xmit_is_reply(const H5FD_mirror_xmit_reply_t *xmit) +{ + LOG_OP_CALL("H5FD_mirror_xmit_is_reply"); + HDassert(xmit); + if ( (TRUE == H5FD_mirror_xmit_is_xmit(&(xmit->pub))) && + (H5FD_MIRROR_OP_REPLY == xmit->pub.op) ) + { + return TRUE; + } + return FALSE; +} /* end H5FD_mirror_xmit_is_reply() */ + + +/* --------------------------------------------------------------------------- + * Function: H5FD_mirror_xmit_is_write + * + * Purpose: Verify that a mirror_xmit_write_t is a valid WRITE xmit. + * + * Checks header validity and op code. + * + * Return: TRUE if valid; else FALSE. + * --------------------------------------------------------------------------- + */ +hbool_t +H5FD_mirror_xmit_is_write(const H5FD_mirror_xmit_write_t *xmit) +{ + LOG_OP_CALL("H5FD_mirror_xmit_is_write"); + HDassert(xmit); + if ( (TRUE == H5FD_mirror_xmit_is_xmit(&(xmit->pub))) && + (H5FD_MIRROR_OP_WRITE == xmit->pub.op) ) + { + return TRUE; + } + return FALSE; +} /* end H5FD_mirror_xmit_is_write() */ + + +/* --------------------------------------------------------------------------- + * Function: H5FD_mirror_xmit_is_xmit + * + * Purpose: Verify that a mirror_xmit_t is well-formed. + * + * Checks magic number and structure version. + * + * Return: TRUE if valid; else FALSE. + * --------------------------------------------------------------------------- + */ +hbool_t +H5FD_mirror_xmit_is_xmit(const H5FD_mirror_xmit_t *xmit) +{ + LOG_OP_CALL("H5FD_mirror_xmit_is_xmit"); + HDassert(xmit); + if ( (H5FD_MIRROR_XMIT_MAGIC != xmit->magic) || + (H5FD_MIRROR_XMIT_CURR_VERSION != xmit->version) ) + { + return FALSE; + } + return TRUE; +} /* end H5FD_mirror_xmit_is_xmit() */ + + +/* ---------------------------------------------------------------------------- + * Function: H5FD__mirror_verify_reply + * + * Purpose: Wait for and read reply data from remote processes. + * Sanity-check that a reply is well-formed and valid. + * If all checks pass, inspect the reply contents and handle + * reported error, if not an OK reply. + * + * Return: SUCCEED if ok, else FAIL. + * ---------------------------------------------------------------------------- + */ +herr_t +H5FD__mirror_verify_reply(H5FD_mirror_t *file) +{ + char xmit_buf[H5FD_MIRROR_XMIT_REPLY_SIZE]; + struct H5FD_mirror_xmit_reply_t reply; + ssize_t read_ret = 0; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT; + + LOG_OP_CALL("H5FD__mirror_verify_reply"); + + HDassert(file && file->sock_fd); + + read_ret = HDread(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_REPLY_SIZE); + if (read_ret < 0) { + HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "unable to read reply"); + } + if (read_ret != H5FD_MIRROR_XMIT_REPLY_SIZE) { + HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "unexpected read size"); + } + + LOG_XMIT_BYTES("reply", xmit_buf, read_ret); + + if (H5FD_mirror_xmit_decode_reply(&reply, (const unsigned char *)xmit_buf) + != H5FD_MIRROR_XMIT_REPLY_SIZE) + { + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "unable to decode reply xmit"); + } + + if (H5FD_mirror_xmit_is_reply(&reply) != TRUE) { + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "xmit op code was not REPLY"); + } + + if (reply.pub.session_token != file->xmit.session_token) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "wrong session"); + } + + if (reply.pub.xmit_count != (file->xmit_i)++) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "xmit out of sync"); + } + + if (reply.status != H5FD_MIRROR_STATUS_OK) { + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, + "%s", (const char *)(reply.message)); + } + +done: + FUNC_LEAVE_NOAPI(ret_value); +} /* end H5FD__mirror_verify_reply() */ + + +/* ------------------------------------------------------------------------- + * Function: H5FD_mirror_fapl_get + * + * Purpose: Get the file access propety list which could be used to create + * an identical file. + * + * Return: Success: pointer to the new file access property list value. + * Failure: NULL + * ------------------------------------------------------------------------- + */ +static void * +H5FD_mirror_fapl_get(H5FD_t *_file) +{ + H5FD_mirror_t *file = (H5FD_mirror_t *)_file; + H5FD_mirror_fapl_t *fa = NULL; + void *ret_value = NULL; + + FUNC_ENTER_NOAPI_NOINIT + + LOG_OP_CALL("H5FD_mirror_fapl_get"); + + fa = (H5FD_mirror_fapl_t *)H5MM_calloc(sizeof(H5FD_mirror_fapl_t)); + if (NULL == fa) { + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "calloc failed"); + } + + HDmemcpy(fa, &(file->fa), sizeof(H5FD_mirror_fapl_t)); + + ret_value = fa; + +done: + if (ret_value == NULL) { + if (fa != NULL) { + H5MM_xfree(fa); + } + } + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_mirror_fapl_get() */ + + +/* ------------------------------------------------------------------------- + * Function: H5FD_mirror_fapl_copy + * + * Purpose: Copies the mirror vfd-specific file access properties. + * + * Return: Success: Pointer to a new property list + * Failure: NULL + * ------------------------------------------------------------------------- + */ +static void * +H5FD_mirror_fapl_copy(const void *_old_fa) +{ + const H5FD_mirror_fapl_t *old_fa = (const H5FD_mirror_fapl_t *)_old_fa; + H5FD_mirror_fapl_t *new_fa = NULL; + void *ret_value = NULL; + + FUNC_ENTER_NOAPI_NOINIT + + LOG_OP_CALL("H5FD_mirror_fapl_copy"); + + new_fa = (H5FD_mirror_fapl_t *)H5MM_malloc(sizeof(H5FD_mirror_fapl_t)); + if (new_fa == NULL) { + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed"); + } + + HDmemcpy(new_fa, old_fa, sizeof(H5FD_mirror_fapl_t)); + ret_value = new_fa; + +done: + if (ret_value == NULL) { + if (new_fa != NULL) { + H5MM_xfree(new_fa); + } + } + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_mirror_fapl_copy() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_mirror_fapl_free + * + * Purpose: Frees the mirror VFD-specific file access properties. + * + * Return: SUCCEED (cannot fail) + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_mirror_fapl_free(void *_fa) +{ + H5FD_mirror_fapl_t *fa = (H5FD_mirror_fapl_t*)_fa; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + LOG_OP_CALL("H5FD_mirror_fapl_free"); + + /* sanity check */ + HDassert(fa != NULL); + HDassert(fa->magic == H5FD_MIRROR_FAPL_MAGIC); + + fa->magic += 1; /* invalidate */ + H5MM_xfree(fa); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FD_mirror_fapl_free() */ + + +/* ------------------------------------------------------------------------- + * Function: H5Pget_fapl_mirror + * + * Purpose: Get the configuration information for this fapl. + * Data is memcopied into the fa_out pointer. + * + * Return: SUCCEED/FAIL + * ------------------------------------------------------------------------- + */ +herr_t +H5Pget_fapl_mirror(hid_t fapl_id, H5FD_mirror_fapl_t *fa_out) +{ + const H5FD_mirror_fapl_t *fa = NULL; + H5P_genplist_t *plist = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "i*x", fapl_id, fa_out); + + LOG_OP_CALL("H5Pget_fapl_mirror"); + + if (NULL == fa_out) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "fa_out is NULL"); + } + + plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS); + if (NULL == plist) { + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file access property list"); + } + + if (H5P_peek_driver(plist) != H5FD_MIRROR) { + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver"); + } + + fa = (const H5FD_mirror_fapl_t *)H5P_peek_driver_info(plist); + if (NULL == fa) { + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info"); + } + + HDassert(fa->magic == H5FD_MIRROR_FAPL_MAGIC); /* sanity check */ + + HDmemcpy(fa_out, fa, sizeof(H5FD_mirror_fapl_t)); + +done: + FUNC_LEAVE_API(ret_value); +} /* end H5Pget_fapl_mirror() */ + + +/*------------------------------------------------------------------------- + * Function: H5Pset_fapl_mirror + * + * Purpose: Modify the file access property list to use the mirror + * driver (H5FD_MIRROR) defined in this source file. + * + * Return: SUCCEED/FAIL + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_fapl_mirror(hid_t fapl_id, H5FD_mirror_fapl_t *fa) +{ + H5P_genplist_t *plist = NULL; + herr_t ret_value = FAIL; + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "i*x", fapl_id, fa); + + LOG_OP_CALL("H5Pset_fapl_mirror"); + + plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS); + if (NULL == plist) { + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file access property list"); + } + if (NULL == fa) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null fapl_t pointer"); + } + if (H5FD_MIRROR_FAPL_MAGIC != fa->magic) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fapl_t magic"); + } + if (H5FD_MIRROR_CURR_FAPL_T_VERSION != fa->version) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unknown fapl_t version"); + } + + ret_value = H5P_set_driver(plist, H5FD_MIRROR, (const void *)fa); + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pset_fapl_mirror() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_mirror_open + * + * Purpose: Create and/or opens a file as an HDF5 file. + * + * Initiate connection with remote Server/Writer. + * If successful, the remote file is open. + * + * Return: Success: A pointer to a new file data structure. The + * public fields will be initialized by the + * caller, which is always H5FD_open(). + * Failure: NULL + *------------------------------------------------------------------------- + */ +static H5FD_t * +H5FD_mirror_open(const char *name, + unsigned flags, + hid_t fapl_id, + haddr_t maxaddr) +{ +#define MIRR_OPEN_MAXBUF 16 /* local symbol to give meaning to magic number */ + /* #defined because it is needed at compile time */ + /* Large enough to hold a port number string */ + int live_socket = -1; + struct sockaddr_in target_addr; + socklen_t addr_size; + char xmit_buf[H5FD_MIRROR_XMIT_OPEN_SIZE]; + H5FD_mirror_fapl_t fa; + H5FD_mirror_t *file = NULL; + H5FD_mirror_xmit_open_t open_xmit; + H5FD_t *ret_value = NULL; + + FUNC_ENTER_NOAPI_NOINIT + + LOG_OP_CALL("H5FD_mirror_open"); + + /* --------------- */ + /* Check arguments */ + /* --------------- */ + + if (!name || !*name) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name"); + } + if (HDstrlen(name) >= H5FD_MIRROR_XMIT_FILEPATH_MAX) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "filename is too long"); + } + if (0 == maxaddr || HADDR_UNDEF == maxaddr) { + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr"); + } + if (ADDR_OVERFLOW(maxaddr)) { + HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr"); + } + + if (H5Pget_fapl_mirror(fapl_id, &fa) == FAIL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "can't get config info"); + } + + if (H5FD_MIRROR_FAPL_MAGIC != fa.magic) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid fapl magic"); + } + + if (H5FD_MIRROR_CURR_FAPL_T_VERSION != fa.version) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid fapl version"); + } + + /* --------------------- */ + /* Handshake with remote */ + /* --------------------- */ + + live_socket = HDsocket(AF_INET, SOCK_STREAM, 0); + if (live_socket < 0) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "can't create socket"); + } + + target_addr.sin_family = AF_INET; + target_addr.sin_port = HDhtons((uint16_t)fa.handshake_port); + target_addr.sin_addr.s_addr = HDinet_addr(fa.remote_ip); + HDmemset(target_addr.sin_zero, '\0', sizeof target_addr.sin_zero); + + addr_size = sizeof(target_addr); + if (HDconnect(live_socket, (struct sockaddr *)&target_addr, addr_size) < 0) + { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, + "can't connect to remote server"); + } + + /* ------------- */ + /* Open the file */ + /* ------------- */ + + file = (H5FD_mirror_t *)H5FL_CALLOC(H5FD_mirror_t); + if (NULL == file) { + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + "unable to allocate file struct"); + } + + file->sock_fd = live_socket; + file->xmit_i = 0; + + file->xmit.magic = H5FD_MIRROR_XMIT_MAGIC; + file->xmit.version = H5FD_MIRROR_XMIT_CURR_VERSION; + file->xmit.xmit_count = file->xmit_i++; + file->xmit.session_token = (uint32_t)(0x01020304 ^ file->sock_fd); /* TODO: hashing? */ + /* int --> uint32_t may truncate on some systems... shouldn't matter? */ + + file->xmit.op = H5FD_MIRROR_OP_OPEN; + open_xmit.pub = file->xmit; + open_xmit.flags = (uint32_t)flags; + open_xmit.maxaddr = (uint64_t)maxaddr; + open_xmit.size_t_blob = (uint64_t)((size_t)(-1)); + HDsnprintf(open_xmit.filename, H5FD_MIRROR_XMIT_FILEPATH_MAX-1, "%s", name); + + if (H5FD_mirror_xmit_encode_open((unsigned char *)xmit_buf, + (const H5FD_mirror_xmit_open_t *)&open_xmit) + != H5FD_MIRROR_XMIT_OPEN_SIZE) + { + HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, NULL, "unable to encode open"); + } + + LOG_XMIT_BYTES("open", xmit_buf, H5FD_MIRROR_XMIT_OPEN_SIZE); + + if (HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_OPEN_SIZE) < 0) { + HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, NULL, "unable to transmit open"); + } + + if (H5FD__mirror_verify_reply(file) == FAIL) { + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, NULL, "invalid reply"); + } + + ret_value = (H5FD_t *)file; + +done: + if (NULL == ret_value) { + if (file) { + file = H5FL_FREE(H5FD_mirror_t, file); + } + if (live_socket >= 0 && HDclose(live_socket) < 0) { + HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, NULL, + "can't close socket"); + } + } + FUNC_LEAVE_NOAPI(ret_value) +#undef MIRR_OPEN_MAXBUF +} /* end H5FD_mirror_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_mirror_close + * + * Purpose: Closes the HDF5 file. + * + * Tries to send a CLOSE op to the remote Writer and expects + * a valid reply, then closes the socket. + * In error, attempts to send a deliberately invalid xmit to the + * Writer to get it to close/abort, then attempts to close the + * socket. + * + * Return: Success: SUCCEED + * Failure: FAIL, file possibly not closed but resources freed. + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_mirror_close(H5FD_t *_file) +{ + H5FD_mirror_t *file = (H5FD_mirror_t *)_file; + unsigned char xmit_buf[H5FD_MIRROR_XMIT_HEADER_SIZE]; + int xmit_encoded = 0; /* monitor point of failure */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + + LOG_OP_CALL("H5FD_mirror_close"); + + /* Sanity check */ + HDassert(file); + HDassert(file->sock_fd >= 0); + + file->xmit.xmit_count = (file->xmit_i)++; + file->xmit.op = H5FD_MIRROR_OP_CLOSE; + + if (H5FD_mirror_xmit_encode_header(xmit_buf, + (const H5FD_mirror_xmit_t *)&(file->xmit)) + != H5FD_MIRROR_XMIT_HEADER_SIZE) + { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to encode close"); + } + xmit_encoded = 1; + + LOG_XMIT_BYTES("close", xmit_buf, H5FD_MIRROR_XMIT_HEADER_SIZE); + + if (HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_HEADER_SIZE) < 0) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to transmit close"); + } + + if (H5FD__mirror_verify_reply(file) == FAIL) { + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid reply"); + } + + if (HDclose(file->sock_fd) < 0) { + HGOTO_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "can't close socket"); + } + +done: + if (ret_value == FAIL) { + if (xmit_encoded == 0) { + /* Encode failed; send GOODBYE to force writer halt. + * We can ignore any response from the writer, if we receive + * any reply at all. + */ + if (HDwrite(file->sock_fd, "GOODBYE", HDstrlen("GOODBYE")) < 0) { + HDONE_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "unable to transmit close"); + if (HDclose(file->sock_fd) < 0) { + HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, + "can't close socket"); + } + file->sock_fd = -1; /* invalidate for later */ + } /* end if problem writing goodbye; go down hard */ + else + if (HDshutdown(file->sock_fd, SHUT_WR) < 0) { + HDONE_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, + "can't shutdown socket write: %s", + HDstrerror(errno)); + } /* end else-if problem shutting down socket */ + } /* end if xmit encode failed */ + + if (file->sock_fd >= 0) { + if (HDclose(file->sock_fd) < 0) { + HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, + "can't close socket"); + } + } /* end if socket not closed by going down hard */ + } /* end if error */ + + file = H5FL_FREE(H5FD_mirror_t, file); /* always release resources */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_mirror_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_mirror_query + * + * Purpose: Get the driver feature flags implemented by the driver. + * + * Return: SUCCEED (non-negative) (can't fail) + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_mirror_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR; + + LOG_OP_CALL("H5FD_mirror_query"); + + /* Notice: the Mirror VFD Writer currently uses only the Sec2 driver as + * the underying driver -- as such, the Mirror VFD implementation copies + * the Sec2 feature flags as its own. + * + * File pointer is always NULL/unused -- the H5FD_FEAT_IGNORE_DRVRINFO flag + * is never included. + * -- JOS 2020-01-13 + */ + if (flags) { + *flags = 0 \ + | H5FD_FEAT_AGGREGATE_METADATA \ + | H5FD_FEAT_ACCUMULATE_METADATA \ + | H5FD_FEAT_DATA_SIEVE \ + | H5FD_FEAT_AGGREGATE_SMALLDATA \ + | H5FD_FEAT_POSIX_COMPAT_HANDLE \ + | H5FD_FEAT_SUPPORTS_SWMR_IO \ + | H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; + } + + FUNC_LEAVE_NOAPI(SUCCEED); +} /* end H5FD_mirror_query() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_mirror_get_eoa + * + * Purpose: Gets the end-of-address marker for the file. The EOA marker + * is the first address past the last byte allocated in the + * format address space. + * + * Required to register the driver. + * + * Return: The end-of-address marker. + *------------------------------------------------------------------------- + */ +static haddr_t +H5FD_mirror_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) +{ + const H5FD_mirror_t *file = (const H5FD_mirror_t *)_file; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + LOG_OP_CALL("H5FD_mirror_get_eoa"); + + HDassert(file); + + FUNC_LEAVE_NOAPI(file->eoa) +} /* end H5FD_mirror_get_eoa() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_mirror_set_eoa + * + * Purpose: Set the end-of-address marker for the file. This function is + * called shortly after an existing HDF5 file is opened in order + * to tell the driver where the end of the HDF5 data is located. + * + * Return: SUCCEED / FAIL + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_mirror_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr) +{ + H5FD_mirror_xmit_eoa_t xmit_eoa; + unsigned char xmit_buf[H5FD_MIRROR_XMIT_EOA_SIZE]; + H5FD_mirror_t *file = (H5FD_mirror_t *)_file; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + + LOG_OP_CALL("H5FD_mirror_set_eoa"); + + HDassert(file); + + file->eoa = addr; /* local copy */ + + file->xmit.xmit_count = (file->xmit_i)++; + file->xmit.op = H5FD_MIRROR_OP_SET_EOA; + + xmit_eoa.pub = file->xmit; + xmit_eoa.type = (uint8_t)type; + xmit_eoa.eoa_addr = (uint64_t)addr; + + if (H5FD_mirror_xmit_encode_set_eoa(xmit_buf, + (const H5FD_mirror_xmit_eoa_t *)&xmit_eoa) + != H5FD_MIRROR_XMIT_EOA_SIZE) + { + HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to encode set-eoa"); + } + + LOG_XMIT_BYTES("set-eoa", xmit_buf, H5FD_MIRROR_XMIT_EOA_SIZE); + + if (HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_EOA_SIZE) < 0) { + HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, + "unable to transmit set-eoa"); + } + + if (H5FD__mirror_verify_reply(file) == FAIL) { + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid reply"); + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_mirror_set_eoa() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_mirror_get_eof + * + * Purpose: Returns the end-of-file marker, which is the greater of + * either the filesystem end-of-file or the HDF5 end-of-address + * markers. + * + * Required to register the driver. + * + * Return: End of file address, the first address past the end of the + * "file", either the filesystem file or the HDF5 file. + *------------------------------------------------------------------------- + */ +static haddr_t +H5FD_mirror_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) +{ + const H5FD_mirror_t *file = (const H5FD_mirror_t *)_file; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + LOG_OP_CALL("H5FD_mirror_get_eof"); + + HDassert(file); + + FUNC_LEAVE_NOAPI(file->eof) +} /* end H5FD_mirror_get_eof() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_mirror_read + * + * Purpose: Required to register the driver. + * If called, MUST fail. + * + * Return: FAIL + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_mirror_read(H5FD_t H5_ATTR_UNUSED *_file, + H5FD_mem_t H5_ATTR_UNUSED type, + hid_t H5_ATTR_UNUSED fapl_id, + haddr_t H5_ATTR_UNUSED addr, + size_t H5_ATTR_UNUSED size, + void H5_ATTR_UNUSED *buf) +{ + herr_t ret_value = FAIL; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + LOG_OP_CALL("H5FD_mirror_read"); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_mirror_read() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_mirror_write + * + * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR + * from buffer BUF according to data transfer properties in + * DXPL_ID. + * + * Send metadata regarding the write (location, size) to the + * remote Writer, then separately transmits the data. + * Both transmission expect an OK reply from the Writer. + * This two-exchange approach incurs significant overhead, + * but is a simple and modular approach. + * Start optimizations here. + * + * Return: SUCCEED/FAIL + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_mirror_write(H5FD_t *_file, + H5FD_mem_t type, + hid_t H5_ATTR_UNUSED dxpl_id, + haddr_t addr, + size_t size, + const void *buf) +{ + H5FD_mirror_xmit_write_t xmit_write; + unsigned char xmit_buf[H5FD_MIRROR_XMIT_WRITE_SIZE]; + H5FD_mirror_t *file = (H5FD_mirror_t *)_file; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + + LOG_OP_CALL("H5FD_mirror_write"); + + HDassert(file); + HDassert(buf); + + file->xmit.xmit_count = (file->xmit_i)++; + file->xmit.op = H5FD_MIRROR_OP_WRITE; + + xmit_write.pub = file->xmit; + xmit_write.size = (uint64_t)size; + xmit_write.offset = (uint64_t)addr; + xmit_write.type = (uint8_t)type; + + + /* Notify Writer of incoming data to write. */ + if (H5FD_mirror_xmit_encode_write(xmit_buf, + (const H5FD_mirror_xmit_write_t *)&xmit_write) + != H5FD_MIRROR_XMIT_WRITE_SIZE) + { + HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to encode write"); + } + + LOG_XMIT_BYTES("write", xmit_buf, H5FD_MIRROR_XMIT_WRITE_SIZE); + + if (HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_WRITE_SIZE) < 0) { + HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to transmit write"); + } + + /* Check that our write xmission was received */ + if (H5FD__mirror_verify_reply(file) == FAIL) { + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid reply"); + } + + /* Send the data to be written */ + if (HDwrite(file->sock_fd, buf, size) < 0) { + HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to transmit data"); + } + + /* Writer should reply that it got the data and is still okay/ready */ + if (H5FD__mirror_verify_reply(file) == FAIL) { + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid reply"); + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_mirror_write() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_mirror_truncate + * + * Purpose: Makes sure that the true file size is the same (or larger) + * than the end-of-address. + * + * Return: SUCCEED/FAIL + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_mirror_truncate(H5FD_t *_file, + hid_t H5_ATTR_UNUSED dxpl_id, + hbool_t H5_ATTR_UNUSED closing) +{ + unsigned char xmit_buf[H5FD_MIRROR_XMIT_HEADER_SIZE]; + H5FD_mirror_t *file = (H5FD_mirror_t *)_file; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + + LOG_OP_CALL("H5FD_mirror_truncate"); + + file->xmit.xmit_count = (file->xmit_i)++; + file->xmit.op = H5FD_MIRROR_OP_TRUNCATE; + + if (H5FD_mirror_xmit_encode_header(xmit_buf, &(file->xmit)) + != H5FD_MIRROR_XMIT_HEADER_SIZE) + { + HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to encode truncate"); + } + + LOG_XMIT_BYTES("truncate", xmit_buf, H5FD_MIRROR_XMIT_HEADER_SIZE); + + if (HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_HEADER_SIZE) < 0) { + HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, + "unable to transmit truncate"); + } + + if (H5FD__mirror_verify_reply(file) == FAIL) { + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid reply"); + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_mirror_truncate() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_mirror_lock + * + * Purpose: To place an advisory lock on a file. + * The lock type to apply depends on the parameter "rw": + * TRUE--opens for write: an exclusive lock + * FALSE--opens for read: a shared lock + * + * Return: SUCCEED/FAIL + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_mirror_lock(H5FD_t *_file, hbool_t rw) +{ + H5FD_mirror_xmit_lock_t xmit_lock; + unsigned char xmit_buf[H5FD_MIRROR_XMIT_LOCK_SIZE]; + H5FD_mirror_t *file = (H5FD_mirror_t *)_file; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT; + + LOG_OP_CALL("H5FD_mirror_lock"); + + file->xmit.xmit_count = (file->xmit_i)++; + file->xmit.op = H5FD_MIRROR_OP_LOCK; + + xmit_lock.pub = file->xmit; + xmit_lock.rw = (uint64_t)rw; + + if (H5FD_mirror_xmit_encode_lock(xmit_buf, + (const H5FD_mirror_xmit_lock_t *)&xmit_lock) + != H5FD_MIRROR_XMIT_LOCK_SIZE) + { + HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to encode lock"); + } + + LOG_XMIT_BYTES("lock", xmit_buf, H5FD_MIRROR_XMIT_LOCK_SIZE); + + if (HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_LOCK_SIZE) < 0) { + HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to transmit lock"); + } + + if (H5FD__mirror_verify_reply(file) == FAIL) { + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid reply"); + } + +done: + FUNC_LEAVE_NOAPI(ret_value); +} /* end H5FD_mirror_lock */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_mirror_unlock + * + * Purpose: Remove the existing lock on the file. + * + * Return: SUCCEED/FAIL + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_mirror_unlock(H5FD_t *_file) +{ + unsigned char xmit_buf[H5FD_MIRROR_XMIT_HEADER_SIZE]; + H5FD_mirror_t *file = (H5FD_mirror_t *)_file; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT; + + LOG_OP_CALL("H5FD_mirror_unlock"); + + file->xmit.xmit_count = (file->xmit_i)++; + file->xmit.op = H5FD_MIRROR_OP_UNLOCK; + + if (H5FD_mirror_xmit_encode_header(xmit_buf, &(file->xmit)) + != H5FD_MIRROR_XMIT_HEADER_SIZE) + { + HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to encode unlock"); + } + + LOG_XMIT_BYTES("unlock", xmit_buf, H5FD_MIRROR_XMIT_HEADER_SIZE); + + if (HDwrite(file->sock_fd, xmit_buf, H5FD_MIRROR_XMIT_HEADER_SIZE) < 0) { + HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to transmit unlock"); + } + + if (H5FD__mirror_verify_reply(file) == FAIL) { + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid reply"); + } + +done: + FUNC_LEAVE_NOAPI(ret_value); +} /* end H5FD_mirror_unlock */ + +#endif /* H5_HAVE_MIRROR_VFD */ + diff --git a/src/H5FDmirror.h b/src/H5FDmirror.h new file mode 100644 index 0000000..fb66b7b --- /dev/null +++ b/src/H5FDmirror.h @@ -0,0 +1,371 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Public, shared definitions for Mirror VFD & remote Writer. + */ + +#ifndef H5FDmirror_H +#define H5FDmirror_H + +#ifdef H5_HAVE_MIRROR_VFD + +#define H5FD_MIRROR (H5FD_mirror_init()) + +#ifdef __cplusplus +extern "C" { +#endif + +/* ============================================================================ + * Mirror VFD use and operation. + * ============================================================================ + */ + +/* --------------------------------------------------------------------------- + * Structure: H5FD_mirror_fapl_t + * + * Used to pass configuraiton information to the Mirror VFD. + * Populate components as appropriate and pass structure pointer to + * `H5Pset_fapl_mirror()`. + * + * `magic` (uint32_t) + * Semi-unique number to sanity-check pointers to this structure type. + * MUST equal H5FD_MIRROR_FAPL_MAGIC to be considered valid. + * + * `version` (uint32_t) + * Indicates expected components of the structure. + * + * `handshake_port (int) + * Port number to expect to reach the "Mirror Server" on the remote host. + * + * `remote_ip` (char[]) + * IP address string of "Mirror Server" remote host. + * --------------------------------------------------------------------------- + */ +#define H5FD_MIRROR_FAPL_MAGIC 0xF8DD514C +#define H5FD_MIRROR_CURR_FAPL_T_VERSION 1 +#define H5FD_MIRROR_MAX_IP_LEN 32 +typedef struct H5FD_mirror_fapl_t { + uint32_t magic; + uint32_t version; + int handshake_port; + char remote_ip[H5FD_MIRROR_MAX_IP_LEN + 1]; +} H5FD_mirror_fapl_t; + +H5_DLL hid_t H5FD_mirror_init(void); +H5_DLL herr_t H5Pget_fapl_mirror(hid_t fapl_id, H5FD_mirror_fapl_t *fa_out); +H5_DLL herr_t H5Pset_fapl_mirror(hid_t fapl_id, H5FD_mirror_fapl_t *fa); + +/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + * IPC - Mirror VFD and Remote Worker application. + * = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + */ + + +/* The maximum allowed size for a receiving buffer when accepting bytes to + * write. Writes larger than this size are performed by multiple accept-write + * steps by the Writer. */ +#define H5FD_MIRROR_DATA_BUFFER_MAX H5_GB /* 1 Gigabyte */ + +#define H5FD_MIRROR_XMIT_CURR_VERSION 1 +#define H5FD_MIRROR_XMIT_MAGIC 0x87F8005B + +#define H5FD_MIRROR_OP_OPEN 1 +#define H5FD_MIRROR_OP_CLOSE 2 +#define H5FD_MIRROR_OP_WRITE 3 +#define H5FD_MIRROR_OP_TRUNCATE 4 +#define H5FD_MIRROR_OP_REPLY 5 +#define H5FD_MIRROR_OP_SET_EOA 6 +#define H5FD_MIRROR_OP_LOCK 7 +#define H5FD_MIRROR_OP_UNLOCK 8 + +#define H5FD_MIRROR_STATUS_OK 0 +#define H5FD_MIRROR_STATUS_ERROR 1 +#define H5FD_MIRROR_STATUS_MESSAGE_MAX 256 /* Dedicated error message size */ + +/* Maximum length of a path/filename string, including the NULL-terminator. + * Must not be smaller than H5FD_SPLITTER_PATH_MAX. */ +#define H5FD_MIRROR_XMIT_FILEPATH_MAX 4097 + +/* Define the exact sizes of the various xmit blobs as sent over the wire. + * This is used to minimize the number of bytes transmitted as well as to + * sanity-check received bytes. + * Any modifications to the xmit structures and/or the encode/decode functions + * must be reflected here. + * */ +#define H5FD_MIRROR_XMIT_HEADER_SIZE 14 +#define H5FD_MIRROR_XMIT_EOA_SIZE (H5FD_MIRROR_XMIT_HEADER_SIZE + 9) +#define H5FD_MIRROR_XMIT_LOCK_SIZE (H5FD_MIRROR_XMIT_HEADER_SIZE + 8) +#define H5FD_MIRROR_XMIT_OPEN_SIZE (H5FD_MIRROR_XMIT_HEADER_SIZE + 20 + H5FD_MIRROR_XMIT_FILEPATH_MAX) +#define H5FD_MIRROR_XMIT_REPLY_SIZE (H5FD_MIRROR_XMIT_HEADER_SIZE + 4 + H5FD_MIRROR_STATUS_MESSAGE_MAX) +#define H5FD_MIRROR_XMIT_WRITE_SIZE (H5FD_MIRROR_XMIT_HEADER_SIZE + 17) + +/* Maximum length of any xmit. */ +#define H5FD_MIRROR_XMIT_BUFFER_MAX MAX2( MAX3(H5FD_MIRROR_XMIT_HEADER_SIZE, \ + H5FD_MIRROR_XMIT_EOA_SIZE, \ + H5FD_MIRROR_XMIT_LOCK_SIZE), \ + MAX3(H5FD_MIRROR_XMIT_OPEN_SIZE, \ + H5FD_MIRROR_XMIT_REPLY_SIZE, \ + H5FD_MIRROR_XMIT_WRITE_SIZE) ) \ + +/* --------------------------------------------------------------------------- + * Structure: H5FD_mirror_xmit_t + * + * Common structure 'header' for all mirror VFD/worker IPC. + * Must be the first component of a derived operation xmit structure, + * such as file-open or write command. + * + * `magic` (uint32_t) + * A "unique" number identifying the structure and endianness of + * transmitting maching. + * Must be set to H5FD_MIRROR_XMIT_MAGIC native to the VFD "sender". + * + * `version` (uint8_t) + * Number used to identify the structure membership. + * Allows sane modifications to this structure in the future. + * Must be set to H5FD_MIRROR_XMIT_CURR_VERSION. + * + * `session_token` (uint32_t) + * A "unique" number identifying the session between VFD sender and + * remote receiver/worker/writer. Exists to help sanity-check. + * + * `xmit_count` (uint32_t) + * Which transmission this is since the session began. + * Used to sanity-check transmission errors. + * First xmit (file-open) must be 0. + * + * `op` (uint8_t) + * Number identifying which operation to perform. + * Corresponds with the extended structure outside of this xmit header. + * Possible values are all defined H5FD_MIRROR_OP_* constants. + * + * --------------------------------------------------------------------------- + */ +typedef struct H5FD_mirror_xmit_t { + uint32_t magic; + uint8_t version; + uint32_t session_token; + uint32_t xmit_count; + uint8_t op; +} H5FD_mirror_xmit_t; + +/* --------------------------------------------------------------------------- + * Structure: H5FD_mirror_xmit_eoa_t + * + * Structure containing eoa-set information from VFD sender. + * + * `pub` (H5FD_mirror_xmit_t) + * Common transmission header, containing session information. + * Must be first. + * + * `type` (uint8_t) + * System-independent alias for H5F[D]_mem_t. + * Specifies datatype to be written. + * + * `eoa_addr` (uint64_t) + * New address for eoa. + * (Natively 'haddr_t', always a 64-bit field) + * + * --------------------------------------------------------------------------- + */ +typedef struct H5FD_mirror_xmit_eoa_t { + H5FD_mirror_xmit_t pub; + uint8_t type; + uint64_t eoa_addr; +} H5FD_mirror_xmit_eoa_t; + +/* --------------------------------------------------------------------------- + * Structure: H5FD_mirror_xmit_lock_t + * + * Structure containing eoa-set information from VFD sender. + * + * `pub` (H5FD_mirror_xmit_t) + * Common transmission header, containing session information. + * Must be first. + * + * `rw` (uint64_t) + * The Read/Write mode flag passed into H5FDlock(). + * (Natively `hbool_t`, an 'int') TODO: native int may be 64-bit? + * + * --------------------------------------------------------------------------- + */ +typedef struct H5FD_mirror_xmit_lock_t { + H5FD_mirror_xmit_t pub; + uint64_t rw; +} H5FD_mirror_xmit_lock_t; + +/* --------------------------------------------------------------------------- + * Structure: H5FD_mirror_xmit_open_t + * + * Structure containing file-open information from the VFD sender. + * + * `pub` (H5FD_mirror_xmit_t) + * Common transmission header, containing session information. + * Must be first. + * + * `flags` (uint32_t) + * VFL-layer file-open flags passed directly to H5FDopen(). + * (Natively 'unsigned [int]') TODO: native int may be 64-bit? + * + * `maxaddr` (uint64_t) + * VFL-layer maximum allowed address space for the file to open passed + * directly to H5FDopen(). + * (Natively 'haddr_t', always a 64-bit field) + * + * `size_t_blob` (uint64_t) + * A number indicating how large a size_t is on the sending system. + * Must be set to (uint64_t)((size_t)(-1)) + * (maximum possible value of size_t, cast to uint64_t). + * The receiving system inspects this value -- if the local (remote) + * size_t is smaller than that of the Sender, issues a warning. + * Not an error, as: + * 1. It is assumed that underlying file systems/drivers have become + * smart enough to handle file sizes that otherwise might be + * constrained. + * 2. The Mirror Writer ingests bytes to write multiple 'slices' if the + * size is greater than H5FD_MIRROR_DATA_BUFFER_MAX, regardless of + * any size_t storage size disparity. + * + * `filename` (char[]) + * String giving the filename and path of file to open. + * + * --------------------------------------------------------------------------- + */ +typedef struct H5FD_mirror_xmit_open_t { + H5FD_mirror_xmit_t pub; + uint32_t flags; + uint64_t maxaddr; + uint64_t size_t_blob; + char filename[H5FD_MIRROR_XMIT_FILEPATH_MAX]; +} H5FD_mirror_xmit_open_t; + +/* --------------------------------------------------------------------------- + * Structure: H5FD_mirror_xmit_reply_t + * + * Structure used by the remote receiver/worker/writer to respond to + * a command from the VFD sender. + * + * `pub` (H5FD_mirror_xmit_t) + * Common transmission header, containing session information. + * Must be first. + * + * `status` (uint32_t) + * Number indicating whether the command was successful or if an + * occured. + * Allowed values are H5FD_MIRROR_STATUS_OK and + * H5FD_MIRROR_STATUS_ERROR. + * + * `message` (char[]) + * Error message. Populated if and only if there was a problem. + * It is possible that a message may reach the end of the alloted + * space without a NULL terminator -- the onus is on the programmer to + * handle this situation. + * + * --------------------------------------------------------------------------- + */ +typedef struct H5FD_mirror_xmit_reply_t { + H5FD_mirror_xmit_t pub; + uint32_t status; + char message[H5FD_MIRROR_STATUS_MESSAGE_MAX]; +} H5FD_mirror_xmit_reply_t; + +/* --------------------------------------------------------------------------- + * Structure: H5FD_mirror_xmit_write_t + * + * Structure containing data-write information from VFD sender. + * + * The data to be written is transmitted in subsequent, packets + * and may be broken up into more than one transmission buffer. + * The VFD sender and remote receiver/worker/writer must coordinate + * the receipt of data. + * + * `pub` (H5FD_mirror_xmit_t) + * Common transmission header, containing session information. + * Must be first. + * + * `type` (uint8_t) + * Specifies datatype to be written. + * (Natively 'H5FD_mem_t', an enumerated type in H5Fpublic.h) + * + * `offset` (uint64_t) + * Start location of write in file. + * (Natively 'haddr_t', always a 64-bit field) + * + * `size` (uint64_t) + * Size of the data to be written, in bytes. + * (Natively 'size_t', accommodate the largest possible as 64-bits) + * + * --------------------------------------------------------------------------- + */ +typedef struct H5FD_mirror_xmit_write_t { + H5FD_mirror_xmit_t pub; + uint8_t type; + uint64_t offset; + uint64_t size; +} H5FD_mirror_xmit_write_t; + + + +/* Encode/decode routines are required to "pack" the xmit data into a known + * byte format for transmission over the wire. + * + * All component numbers must be stored in "network" word order (Big-Endian). + * + * All components must be packed in the order given in the structure definition. + * + * All components must be packed with zero padding between. + */ + +H5_DLL size_t H5FD__mirror_xmit_decode_uint16(uint16_t *out, const unsigned char *buf); +H5_DLL size_t H5FD__mirror_xmit_decode_uint32(uint32_t *out, const unsigned char *buf); +H5_DLL size_t H5FD__mirror_xmit_decode_uint64(uint64_t *out, const unsigned char *buf); +H5_DLL size_t H5FD__mirror_xmit_decode_uint8(uint8_t *out, const unsigned char *buf); +H5_DLL size_t H5FD__mirror_xmit_encode_uint16(unsigned char *dest, uint16_t v); +H5_DLL size_t H5FD__mirror_xmit_encode_uint32(unsigned char *dest, uint32_t v); +H5_DLL size_t H5FD__mirror_xmit_encode_uint64(unsigned char *dest, uint64_t v); +H5_DLL size_t H5FD__mirror_xmit_encode_uint8(unsigned char *dest, uint8_t v); + +H5_DLL size_t H5FD_mirror_xmit_decode_header(H5FD_mirror_xmit_t *out, const unsigned char *buf); +H5_DLL size_t H5FD_mirror_xmit_decode_lock(H5FD_mirror_xmit_lock_t *out, const unsigned char *buf); +H5_DLL size_t H5FD_mirror_xmit_decode_open(H5FD_mirror_xmit_open_t *out, const unsigned char *buf); +H5_DLL size_t H5FD_mirror_xmit_decode_reply(H5FD_mirror_xmit_reply_t *out, const unsigned char *buf); +H5_DLL size_t H5FD_mirror_xmit_decode_set_eoa(H5FD_mirror_xmit_eoa_t *out, const unsigned char *buf); +H5_DLL size_t H5FD_mirror_xmit_decode_write(H5FD_mirror_xmit_write_t *out, const unsigned char *buf); + +H5_DLL size_t H5FD_mirror_xmit_encode_header(unsigned char *dest, const H5FD_mirror_xmit_t *x); +H5_DLL size_t H5FD_mirror_xmit_encode_lock(unsigned char *dest, const H5FD_mirror_xmit_lock_t *x); +H5_DLL size_t H5FD_mirror_xmit_encode_open(unsigned char *dest, const H5FD_mirror_xmit_open_t *x); +H5_DLL size_t H5FD_mirror_xmit_encode_reply(unsigned char *dest, const H5FD_mirror_xmit_reply_t *x); +H5_DLL size_t H5FD_mirror_xmit_encode_set_eoa(unsigned char *dest, const H5FD_mirror_xmit_eoa_t *x); +H5_DLL size_t H5FD_mirror_xmit_encode_write(unsigned char *dest, const H5FD_mirror_xmit_write_t *x); + +H5_DLL hbool_t H5FD_mirror_xmit_is_close(const H5FD_mirror_xmit_t *xmit); +H5_DLL hbool_t H5FD_mirror_xmit_is_lock(const H5FD_mirror_xmit_lock_t *xmit); +H5_DLL hbool_t H5FD_mirror_xmit_is_open(const H5FD_mirror_xmit_open_t *xmit); +H5_DLL hbool_t H5FD_mirror_xmit_is_reply(const H5FD_mirror_xmit_reply_t *xmit); +H5_DLL hbool_t H5FD_mirror_xmit_is_set_eoa(const H5FD_mirror_xmit_eoa_t *xmit); +H5_DLL hbool_t H5FD_mirror_xmit_is_write(const H5FD_mirror_xmit_write_t *xmit); +H5_DLL hbool_t H5FD_mirror_xmit_is_xmit(const H5FD_mirror_xmit_t *xmit); + +#ifdef __cplusplus +} +#endif + +#else /* H5_HAVE_MIRROR_VFD */ + +#define H5FD_MIRROR (H5I_INAVLID_HID) + +#endif /* H5_HAVE_MIRROR_VFD */ + +#endif /* H5FDmirror_H */ + + diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c index 8c7e91a..3d2e0cf 100644 --- a/src/H5FDmpio.c +++ b/src/H5FDmpio.c @@ -15,7 +15,7 @@ * Programmer: Robb Matzke * Thursday, July 29, 1999 * - * Purpose: This is the MPI-2 I/O driver. + * Purpose: This is the MPI-2 I/O driver. * */ diff --git a/src/H5FDprivate.h b/src/H5FDprivate.h index ac08f7f..2e3d3ce 100644 --- a/src/H5FDprivate.h +++ b/src/H5FDprivate.h @@ -115,7 +115,7 @@ H5_DLL hsize_t H5FD_sb_size(H5FD_t *file); H5_DLL herr_t H5FD_sb_encode(H5FD_t *file, char *name/*out*/, uint8_t *buf); H5_DLL herr_t H5FD_sb_load(H5FD_t *file, const char *name, const uint8_t *buf); H5_DLL void *H5FD_fapl_get(H5FD_t *file); -H5_DLL herr_t H5FD_fapl_close(hid_t driver_id, const void *fapl); +H5_DLL herr_t H5FD_free_driver_info(hid_t driver_id, const void *driver_info); H5_DLL hid_t H5FD_register(const void *cls, size_t size, hbool_t app_ref); H5_DLL H5FD_t *H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); diff --git a/src/H5FDpublic.h b/src/H5FDpublic.h index 54ca8f7..61bf212 100644 --- a/src/H5FDpublic.h +++ b/src/H5FDpublic.h @@ -255,6 +255,8 @@ typedef enum H5F_mem_t H5FD_mem_t; * that creates a file which is compatible with the default VFD. * Generally, this means that the VFD creates a single file that follows * the canonical HDF5 file format. + * Regarding the Splitter VFD specifically, only drivers with this flag + * enabled may be used as the Write-Only (W/O) channel driver. */ #define H5FD_FEAT_DEFAULT_VFD_COMPATIBLE 0x00008000 diff --git a/src/H5FDros3.c b/src/H5FDros3.c index 75fcfd7..d99272c 100644 --- a/src/H5FDros3.c +++ b/src/H5FDros3.c @@ -325,7 +325,9 @@ hid_t H5FD_ros3_init(void) { hid_t ret_value = H5I_INVALID_HID; +#if ROS3_STATS unsigned int bin_i; +#endif FUNC_ENTER_NOAPI(FAIL) @@ -1347,7 +1349,7 @@ H5FD_ros3_cmp( } /* FAPL: AWS_REGION */ - if (f1->fa.aws_region[0] != '\0' && f1->fa.aws_region[0] != '\0') { + if (f1->fa.aws_region[0] != '\0' && f2->fa.aws_region[0] != '\0') { if (HDstrcmp(f1->fa.aws_region, f2->fa.aws_region)) { HGOTO_DONE(-1); } @@ -1362,7 +1364,7 @@ H5FD_ros3_cmp( } /* FAPL: SECRET_ID */ - if (f1->fa.secret_id[0] != '\0' && f1->fa.secret_id[0] != '\0') { + if (f1->fa.secret_id[0] != '\0' && f2->fa.secret_id[0] != '\0') { if (HDstrcmp(f1->fa.secret_id, f2->fa.secret_id)) { HGOTO_DONE(-1); } @@ -1377,7 +1379,7 @@ H5FD_ros3_cmp( } /* FAPL: SECRET_KEY */ - if (f1->fa.secret_key[0] != '\0' && f1->fa.secret_key[0] != '\0') { + if (f1->fa.secret_key[0] != '\0' && f2->fa.secret_key[0] != '\0') { if (HDstrcmp(f1->fa.secret_key, f2->fa.secret_key)) { HGOTO_DONE(-1); } diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index 6504ef9..3551905 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -521,6 +521,12 @@ H5FD_sec2_query(const H5FD_t *_file, unsigned long *flags /* out */) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Set the VFL feature flags that this driver supports */ + /* Notice: the Mirror VFD Writer currently uses only the Sec2 driver as + * the underying driver -- as such, the Mirror VFD implementation copies + * these feature flags as its own. Any modifications made here must be + * reflected in H5FDmirror.c + * -- JOS 2020-01-13 + */ if(flags) { *flags = 0; *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ @@ -669,6 +675,7 @@ H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUS haddr_t addr, size_t size, void *buf /*out*/) { H5FD_sec2_t *file = (H5FD_sec2_t *)_file; + HDoff_t offset = (HDoff_t)addr; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -687,7 +694,7 @@ H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUS if(addr != file->pos || OP_READ != file->op) { if(HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") - } /* end if */ + } #endif /* H5_HAVE_PREADWRITE */ /* Read data, being careful of interrupted system calls, partial results, @@ -697,7 +704,6 @@ H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUS h5_posix_io_t bytes_in = 0; /* # of bytes to read */ h5_posix_io_ret_t bytes_read = -1; /* # of bytes actually read */ - HDoff_t offset = (HDoff_t)addr; /* Trying to read more bytes than the return type can handle is * undefined behavior in POSIX. @@ -710,7 +716,8 @@ H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUS do { #ifdef H5_HAVE_PREADWRITE bytes_read = HDpread(file->fd, buf, bytes_in, offset); - offset += bytes_read; + if(bytes_read > 0) + offset += bytes_read; #else bytes_read = HDread(file->fd, buf, bytes_in); #endif /* H5_HAVE_PREADWRITE */ @@ -773,6 +780,7 @@ H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU haddr_t addr, size_t size, const void *buf) { H5FD_sec2_t *file = (H5FD_sec2_t *)_file; + HDoff_t offset = (HDoff_t)addr; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -791,7 +799,7 @@ H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU if(addr != file->pos || OP_WRITE != file->op) { if(HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") - } /* end if */ + } #endif /* H5_HAVE_PREADWRITE */ /* Write the data, being careful of interrupted system calls and partial @@ -800,8 +808,7 @@ H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU while(size > 0) { h5_posix_io_t bytes_in = 0; /* # of bytes to write */ - h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes written */ - HDoff_t offset = (HDoff_t)addr; + h5_posix_io_ret_t bytes_wrote = -1; /* # of bytes written */ /* Trying to write more bytes than the return type can handle is * undefined behavior in POSIX. @@ -814,7 +821,8 @@ H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU do { #ifdef H5_HAVE_PREADWRITE bytes_wrote = HDpwrite(file->fd, buf, bytes_in, offset); - offset += bytes_wrote; + if(bytes_wrote > 0) + offset += bytes_wrote; #else bytes_wrote = HDwrite(file->fd, buf, bytes_in); #endif /* H5_HAVE_PREADWRITE */ diff --git a/src/H5FDsplitter.c b/src/H5FDsplitter.c new file mode 100644 index 0000000..4ed3c4a --- /dev/null +++ b/src/H5FDsplitter.c @@ -0,0 +1,1470 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: The Splitter VFD implements a file driver which relays all the + * VFD calls to an underlying VFD, and send all the write calls to + * another underlying VFD. Maintains two files simultaneously. + */ + +/* This source code file is part of the H5FD driver module */ +#include "H5FDdrvr_module.h" + +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDsplitter.h" /* Splitter file driver */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5FDsec2.h" /* Generic Functions */ +#include "H5FDstdio.h" /* Generic Functions */ +#include "H5Pprivate.h" /* Property lists */ + +/* The driver identification number, initialized at runtime */ +static hid_t H5FD_SPLITTER_g = 0; + +/* Driver-specific file access properties */ +typedef struct H5FD_splitter_fapl_t { + hid_t rw_fapl_id; /* fapl for the R/W channel */ + hid_t wo_fapl_id; /* fapl for the W/O channel */ + char wo_path[H5FD_SPLITTER_PATH_MAX + 1]; /* file name for the W/O channel */ + char log_file_path[H5FD_SPLITTER_PATH_MAX + 1]; /* file to record errors reported by the W/O channel */ + hbool_t ignore_wo_errs; /* TRUE to ignore errors on the W/O channel */ +} H5FD_splitter_fapl_t; + +/* The information of this splitter */ +typedef struct H5FD_splitter_t { + H5FD_t pub; /* public stuff, must be first */ + unsigned version; /* version of the H5FD_splitter_vfd_config_t structure used */ + H5FD_splitter_fapl_t fa; /* driver-specific file access properties */ + H5FD_t *rw_file; /* pointer of R/W channel */ + H5FD_t *wo_file; /* pointer of W/O channel */ + FILE *logfp; /* Log file pointer */ +} H5FD_splitter_t; + +/* + * These macros check for overflow of various quantities. These macros + * assume that HDoff_t is signed and haddr_t and size_t are unsigned. + * + * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t' + * is too large to be represented by the second argument + * of the file seek function. + * + * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too + * large to be represented by the `size_t' type. + * + * REGION_OVERFLOW: Checks whether an address and size pair describe data + * which can be addressed entirely by the second + * argument of the file seek function. + */ +#define MAXADDR (((haddr_t)1<<(8*sizeof(HDoff_t)-1))-1) +#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || ((A) & ~(haddr_t)MAXADDR)) +#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) +#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ + HADDR_UNDEF==(A)+(Z) || \ + (HDoff_t)((A)+(Z))<(HDoff_t)(A)) + +/* This macro provides a wrapper for shared fail-log-ignore behavior + * for errors arising in the splitter's W/O channel. + * Logs an error entry in a log file, if the file exists. + * If not set to ignore errors, registers an error with the library. + */ +#define H5FD_SPLITTER_WO_ERROR(file, funcname, errmajor, errminor, ret, mesg) \ +{ \ + H5FD__splitter_log_error((file), (funcname), (mesg)); \ + if (FALSE == (file)->fa.ignore_wo_errs) { \ + HGOTO_ERROR((errmajor), (errminor), (ret), (mesg)) \ + } \ +} + +#define H5FD_SPLITTER_DEBUG_OP_CALLS 0 /* debugging print toggle; 0 disables */ + +#if H5FD_SPLITTER_DEBUG_OP_CALLS +#define H5FD_SPLITTER_LOG_CALL(name) do { \ + HDprintf("called %s()\n", (name)); \ + fflush(stdout); \ +} while (0) +#else +#define H5FD_SPLITTER_LOG_CALL(name) /* no-op */ +#endif /* H5FD_SPLITTER_DEBUG_OP_CALLS */ + +/* Private functions */ + +/* Print error messages from W/O channel to log file */ +static herr_t H5FD__splitter_log_error(const H5FD_splitter_t *file, const char *atfunc, const char *msg); + +static int H5FD__copy_plist(hid_t fapl_id, hid_t *id_out_ptr); + +/* Prototypes */ +static herr_t H5FD_splitter_term(void); +static hsize_t H5FD_splitter_sb_size(H5FD_t *_file); +static herr_t H5FD_splitter_sb_encode(H5FD_t *_file, char *name/*out*/, unsigned char *buf/*out*/); +static herr_t H5FD_splitter_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf); +static void *H5FD_splitter_fapl_get(H5FD_t *_file); +static void *H5FD_splitter_fapl_copy(const void *_old_fa); +static herr_t H5FD_splitter_fapl_free(void *_fapl); +static H5FD_t *H5FD_splitter_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); +static herr_t H5FD_splitter_close(H5FD_t *_file); +static int H5FD_splitter_cmp(const H5FD_t *_f1, const H5FD_t *_f2); +static herr_t H5FD_splitter_query(const H5FD_t *_file, unsigned long *flags /* out */); +static herr_t H5FD_splitter_get_type_map(const H5FD_t *_file, H5FD_mem_t *type_map); +static haddr_t H5FD_splitter_alloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size); +static herr_t H5FD_splitter_free(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size); +static haddr_t H5FD_splitter_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type); +static herr_t H5FD_splitter_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr); +static haddr_t H5FD_splitter_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type); +static herr_t H5FD_splitter_get_handle(H5FD_t *_file, hid_t H5_ATTR_UNUSED fapl, void** file_handle); +static herr_t H5FD_splitter_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, void *buf); +static herr_t H5FD_splitter_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *buf); +static herr_t H5FD_splitter_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD_splitter_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); +static herr_t H5FD_splitter_lock(H5FD_t *_file, hbool_t rw); +static herr_t H5FD_splitter_unlock(H5FD_t *_file); + +static const H5FD_class_t H5FD_splitter_g = { + "splitter", /* name */ + MAXADDR, /* maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + H5FD_splitter_term, /* terminate */ + H5FD_splitter_sb_size, /* sb_size */ + H5FD_splitter_sb_encode, /* sb_encode */ + H5FD_splitter_sb_decode, /* sb_decode */ + sizeof(H5FD_splitter_fapl_t), /* fapl_size */ + H5FD_splitter_fapl_get, /* fapl_get */ + H5FD_splitter_fapl_copy, /* fapl_copy */ + H5FD_splitter_fapl_free, /* fapl_free */ + 0, /* dxpl_size */ + NULL, /* dxpl_copy */ + NULL, /* dxpl_free */ + H5FD_splitter_open, /* open */ + H5FD_splitter_close, /* close */ + H5FD_splitter_cmp, /* cmp */ + H5FD_splitter_query, /* query */ + H5FD_splitter_get_type_map, /* get_type_map */ + H5FD_splitter_alloc, /* alloc */ + H5FD_splitter_free, /* free */ + H5FD_splitter_get_eoa, /* get_eoa */ + H5FD_splitter_set_eoa, /* set_eoa */ + H5FD_splitter_get_eof, /* get_eof */ + H5FD_splitter_get_handle, /* get_handle */ + H5FD_splitter_read, /* read */ + H5FD_splitter_write, /* write */ + H5FD_splitter_flush, /* flush */ + H5FD_splitter_truncate, /* truncate */ + H5FD_splitter_lock, /* lock */ + H5FD_splitter_unlock, /* unlock */ + H5FD_FLMAP_DICHOTOMY /* fl_map */ +}; + +/* Declare a free list to manage the H5FD_splitter_t struct */ +H5FL_DEFINE_STATIC(H5FD_splitter_t); + + +/*------------------------------------------------------------------------- + * Function: H5FD__init_package + * + * Purpose: Initializes any interface-specific data or routines. + * + * Return: SUCCEED/FAIL + *------------------------------------------------------------------------- + */ +static herr_t +H5FD__init_package(void) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + H5FD_SPLITTER_LOG_CALL("H5FD__init_package"); + + if (H5FD_splitter_init() < 0) { + HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize splitter VFD") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5FD__init_package() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_splitter_init + * + * Purpose: Initialize the splitter driver by registering it with the + * library. + * + * Return: Success: The driver ID for the splitter driver. + * Failure: Negative + *------------------------------------------------------------------------- + */ +hid_t +H5FD_splitter_init(void) +{ + hid_t ret_value = H5I_INVALID_HID; + + FUNC_ENTER_NOAPI(FAIL) + + H5FD_SPLITTER_LOG_CALL("H5FD_splitter_init"); + + if (H5I_VFL != H5I_get_type(H5FD_SPLITTER_g)) { + H5FD_SPLITTER_g = H5FDregister(&H5FD_splitter_g); + } + + ret_value = H5FD_SPLITTER_g; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_splitter_init() */ + + +/*--------------------------------------------------------------------------- + * Function: H5FD_splitter_term + * + * Purpose: Shut down the splitter VFD. + * + * Returns: SUCCEED (Can't fail) + *--------------------------------------------------------------------------- + */ +static herr_t +H5FD_splitter_term(void) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + H5FD_SPLITTER_LOG_CALL("H5FD_splitter_term"); + + /* Reset VFL ID */ + H5FD_SPLITTER_g = 0; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FD_splitter_term() */ + + + /*------------------------------------------------------------------------- + * Function: H5FD__copy_plist + * + * Purpose: Sanity-wrapped H5P_copy_plist() for each channel. + * Utility function for operation in multiple locations. + * + * Return: 0 on success, -1 on error. + *------------------------------------------------------------------------- + */ +static int +H5FD__copy_plist(hid_t fapl_id, + hid_t *id_out_ptr) +{ + int ret_value = 0; + H5P_genplist_t *plist_ptr = NULL; + + FUNC_ENTER_NOAPI_NOINIT + + H5FD_SPLITTER_LOG_CALL("H5FD__copy_plist"); + + HDassert(id_out_ptr != NULL); + + if (FALSE == H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) { + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, -1, "not a file access property list"); + } + + plist_ptr = (H5P_genplist_t *)H5I_object(fapl_id); + if (NULL == plist_ptr) { + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, -1, "unable to get property list"); + } + + *id_out_ptr = H5P_copy_plist(plist_ptr, FALSE); + if (H5I_INVALID_HID == *id_out_ptr) { + HGOTO_ERROR(H5E_VFL, H5E_BADTYPE, -1, "unable to copy file access property list"); + } + +done: + FUNC_LEAVE_NOAPI(ret_value); +} /* end H5FD__copy_plist() */ + + +/*------------------------------------------------------------------------- + * Function: H5Pset_fapl_splitter + * + * Purpose: Sets the file access property list to use the + * splitter driver. + * + * Return: SUCCEED/FAIL + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *vfd_config) +{ + H5FD_splitter_fapl_t info; + H5P_genplist_t *plist_ptr = NULL; + herr_t ret_value = SUCCEED; + + H5Eclear2(H5E_DEFAULT); + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "i*Dr", fapl_id, vfd_config); + + H5FD_SPLITTER_LOG_CALL("H5Pset_fapl_splitter"); + + if (H5FD_SPLITTER_MAGIC != vfd_config->magic) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid configuration (magic number mismatch)") + } + if (H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION != vfd_config->version) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invlaid config (version number mismatch)") + } + + if (NULL == (plist_ptr = (H5P_genplist_t *)H5I_object(fapl_id))) { + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a valid property list") + } + + + /* Make sure that the W/O channel supports write-only capability. + * Some drivers (e.g. family or multi) do revision of the superblock + * in-memory, causing problems in that channel. + * Uses the feature flag H5FD_FEAT_DEFAULT_VFD_COMPATIBLE as the + * determining attribute. + */ + if (H5P_DEFAULT != vfd_config->wo_fapl_id) { + H5FD_class_t *wo_driver = NULL; + H5FD_driver_prop_t wo_driver_prop; + H5P_genplist_t *wo_plist_ptr = NULL; + unsigned long wo_driver_flags = 0; + + wo_plist_ptr = (H5P_genplist_t *)H5I_object(vfd_config->wo_fapl_id); + if (NULL == wo_plist_ptr) { + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") + } + if (H5P_peek(wo_plist_ptr, H5F_ACS_FILE_DRV_NAME, &wo_driver_prop) < 0) { + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver ID & info") + } + wo_driver = (H5FD_class_t *)H5I_object(wo_driver_prop.driver_id); + if (NULL == wo_driver) { + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid driver ID in file access property list") + } + if (H5FD_driver_query(wo_driver, &wo_driver_flags) < 0) { + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "can't query VFD flags") + } + if (0 == (H5FD_FEAT_DEFAULT_VFD_COMPATIBLE & wo_driver_flags)) { + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "unsuitable W/O driver") + } + } /* end if W/O VFD is non-default */ + + + info.ignore_wo_errs = vfd_config->ignore_wo_errs; + HDstrncpy(info.wo_path, vfd_config->wo_path, H5FD_SPLITTER_PATH_MAX); + HDstrncpy(info.log_file_path, vfd_config->log_file_path, H5FD_SPLITTER_PATH_MAX); + info.rw_fapl_id = H5P_FILE_ACCESS_DEFAULT; /* pre-set value */ + info.wo_fapl_id = H5P_FILE_ACCESS_DEFAULT; /* pre-set value */ + + /* Set non-default channel FAPL IDs in splitter configuration info */ + if (H5P_DEFAULT != vfd_config->rw_fapl_id) { + if (FALSE == H5P_isa_class(vfd_config->rw_fapl_id, H5P_FILE_ACCESS)) { + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") + } + info.rw_fapl_id = vfd_config->rw_fapl_id; + } + if (H5P_DEFAULT != vfd_config->wo_fapl_id) { + if (FALSE == H5P_isa_class(vfd_config->wo_fapl_id, H5P_FILE_ACCESS)) { + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") + } + info.wo_fapl_id = vfd_config->wo_fapl_id; + } + + ret_value = H5P_set_driver(plist_ptr, H5FD_SPLITTER, &info); + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pset_fapl_splitter() */ + + +/*------------------------------------------------------------------------- + * Function: H5Pget_fapl_splitter + * + * Purpose: Returns information about the splitter file access property + * list through the structure config_out. + * + * Will fail if config_out is received without pre-set valid + * magic and version information. + * + * Return: SUCCEED/FAIL + *------------------------------------------------------------------------- + */ +herr_t +H5Pget_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *config_out) +{ + const H5FD_splitter_fapl_t *fapl_ptr = NULL; + H5P_genplist_t *plist_ptr = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "i*Dr", fapl_id, config_out); + + H5FD_SPLITTER_LOG_CALL("H5Pget_fapl_splitter"); + + /* Check arguments */ + if (TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) { + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") + } + if (config_out == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "config_out pointer is null") + } + if (H5FD_SPLITTER_MAGIC != config_out->magic) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "info-out pointer invalid (magic number mismatch)") + } + if (H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION != config_out->version) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "info-out pointer invalid (version unsafe)") + } + + /* Pre-set out FAPL IDs with intent to replace these values */ + config_out->rw_fapl_id = H5I_INVALID_HID; + config_out->wo_fapl_id = H5I_INVALID_HID; + + /* Check and get the splitter fapl */ + if (NULL == (plist_ptr = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) { + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") + } + if (H5FD_SPLITTER != H5P_peek_driver(plist_ptr)) { + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") + } + if (NULL == (fapl_ptr = (const H5FD_splitter_fapl_t *)H5P_peek_driver_info(plist_ptr))) { + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unable to get specific-driver info") + } + + HDstrncpy(config_out->wo_path, fapl_ptr->wo_path, H5FD_SPLITTER_PATH_MAX); + HDstrncpy(config_out->log_file_path, fapl_ptr->log_file_path, H5FD_SPLITTER_PATH_MAX); + config_out->ignore_wo_errs = fapl_ptr->ignore_wo_errs; + + /* Copy R/W and W/O FAPLs */ + if (H5FD__copy_plist(fapl_ptr->rw_fapl_id, &(config_out->rw_fapl_id)) < 0) { + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "can't copy R/W FAPL"); + } + if (H5FD__copy_plist(fapl_ptr->wo_fapl_id, &(config_out->wo_fapl_id)) < 0) { + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "can't copy W/O FAPL"); + } + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pget_fapl_splitter() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_splitter_flush + * + * Purpose: Flushes all data to disk for both channels. + * + * Return: SUCCEED/FAIL + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_splitter_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t closing) +{ + H5FD_splitter_t *file = (H5FD_splitter_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + H5FD_SPLITTER_LOG_CALL("H5FD_splitter_flush"); + + /* Public API for dxpl "context" */ + if (H5FDflush(file->rw_file, dxpl_id, closing) < 0) { + HGOTO_ERROR(H5E_VFL, H5E_CANTFLUSH, FAIL, "unable to flush R/W file") + } + if (H5FDflush(file->wo_file, dxpl_id, closing) < 0) { + H5FD_SPLITTER_WO_ERROR(file, "H5FD_splitter_flush", + H5E_VFL, H5E_CANTFLUSH, FAIL, + "unable to flush W/O file") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_splitter_flush() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_splitter_read + * + * Purpose: Reads SIZE bytes of data from the R/W channel, beginning at + * address ADDR into buffer BUF according to data transfer + * properties in DXPL_ID. + * + * Return: Success: SUCCEED + * The read result is written into the BUF buffer + * which should be allocated by the caller. + * Failure: FAIL + * The contents of BUF are undefined. + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_splitter_read( + H5FD_t *_file, + H5FD_mem_t H5_ATTR_UNUSED type, + hid_t H5_ATTR_UNUSED dxpl_id, + haddr_t addr, + size_t size, + void *buf /*out*/) +{ + H5FD_splitter_t *file = (H5FD_splitter_t *)_file; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + + H5FD_SPLITTER_LOG_CALL("H5FD_splitter_read"); + + HDassert(file && file->pub.cls); + HDassert(buf); + + /* Check for overflow conditions */ + if (!H5F_addr_defined(addr)) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined, addr = %llu", (unsigned long long)addr) + } + if (REGION_OVERFLOW(addr, size)) { + HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu", (unsigned long long)addr) + } + + /* Only read from R/W channel */ + /* Public API for dxpl "context" */ + if (H5FDread(file->rw_file, type, dxpl_id, addr, size, buf) < 0) { + HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "Reading from R/W channel failed") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_splitter_read() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_splitter_write + * + * Purpose: Writes SIZE bytes of data to R/W and W/O channels, beginning + * at address ADDR from buffer BUF according to data transfer + * properties in DXPL_ID. + * + * Return: SUCCEED/FAIL + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_splitter_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *buf) +{ + H5FD_splitter_t *file = (H5FD_splitter_t *)_file; + H5P_genplist_t *plist_ptr = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + + H5FD_SPLITTER_LOG_CALL("H5FD_splitter_write"); + + if (NULL == (plist_ptr = (H5P_genplist_t *)H5I_object(dxpl_id))) { + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + } + + /* Write to each file */ + /* Public API for dxpl "context" */ + if (H5FDwrite(file->rw_file, type, dxpl_id, addr, size, buf) < 0) { + HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "R/W file write failed") + } + if (H5FDwrite(file->wo_file, type, dxpl_id, addr, size, buf) < 0) { + H5FD_SPLITTER_WO_ERROR(file, "H5FD_splitter_write", + H5E_VFL, H5E_WRITEERROR, FAIL, + "unable to write W/O file") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_splitter_write() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_splitter_fapl_get + * + * Purpose: Returns a file access property list which indicates how the + * specified file is being accessed. The return list could be + * used to access another file the same way. + * + * Return: Success: Ptr to new file access property list with all + * members copied from the file struct. + * Failure: NULL + *------------------------------------------------------------------------- + */ +static void * +H5FD_splitter_fapl_get(H5FD_t *_file) +{ + H5FD_splitter_t *file = (H5FD_splitter_t *)_file; + void *ret_value = NULL; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + H5FD_SPLITTER_LOG_CALL("H5FD_splitter_fapl_get"); + + ret_value = H5FD_splitter_fapl_copy(&(file->fa)); + + FUNC_LEAVE_NOAPI(ret_value) +} + + +/*------------------------------------------------------------------------- + * Function: H5FD_splitter_fapl_copy + * + * Purpose: Copies the file access properties. + * + * Return: Success: Pointer to a new property list info structure. + * Failure: NULL + *------------------------------------------------------------------------- + */ +static void * +H5FD_splitter_fapl_copy(const void *_old_fa) +{ + const H5FD_splitter_fapl_t *old_fa_ptr = (const H5FD_splitter_fapl_t *)_old_fa; + H5FD_splitter_fapl_t *new_fa_ptr = NULL; + void *ret_value = NULL; + + FUNC_ENTER_NOAPI_NOINIT + + H5FD_SPLITTER_LOG_CALL("H5FD_splitter_fapl_copy"); + + HDassert(old_fa_ptr); + + new_fa_ptr = (H5FD_splitter_fapl_t *)H5MM_calloc(sizeof(H5FD_splitter_fapl_t)); + if (NULL == new_fa_ptr) { + HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, NULL, "unable to allocate log file FAPL") + } + + if (HDmemcpy(new_fa_ptr, old_fa_ptr, sizeof(H5FD_splitter_fapl_t)) == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_CANTCOPY, NULL, "unable to shallow-copy info") + } + if (HDstrncpy(new_fa_ptr->wo_path, old_fa_ptr->wo_path, H5FD_SPLITTER_PATH_MAX) == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_CANTCOPY, NULL, "unable to copy write-only channel file path") + } + if (HDstrncpy(new_fa_ptr->log_file_path, old_fa_ptr->log_file_path, H5FD_SPLITTER_PATH_MAX) == NULL) { + HGOTO_ERROR(H5E_ARGS, H5E_CANTCOPY, NULL, "unable to copy log file path") + } + + /* Copy R/W and W/O FAPLs */ + if (H5FD__copy_plist(old_fa_ptr->rw_fapl_id, &(new_fa_ptr->rw_fapl_id)) < 0) { + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, NULL, "can't copy R/W FAPL"); + } + if (H5FD__copy_plist(old_fa_ptr->wo_fapl_id, &(new_fa_ptr->wo_fapl_id)) < 0) { + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, NULL, "can't copy W/O FAPL"); + } + + ret_value = (void *)new_fa_ptr; + +done: + if (NULL == ret_value) { + if (new_fa_ptr) { + H5MM_free(new_fa_ptr); + } + } + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_splitter_fapl_copy() */ + + +/*-------------------------------------------------------------------------- + * Function: H5FD_splitter_fapl_free + * + * Purpose: Releases the file access lists + * + * Return: SUCCEED/FAIL + *-------------------------------------------------------------------------- + */ +static herr_t +H5FD_splitter_fapl_free(void *_fapl) +{ + H5FD_splitter_fapl_t *fapl = (H5FD_splitter_fapl_t*)_fapl; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + + H5FD_SPLITTER_LOG_CALL("H5FD_splitter_fapl_free"); + + /* Check arguments */ + HDassert(fapl); + + if (H5I_dec_ref(fapl->rw_fapl_id) < 0) { + HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close R/W FAPL ID") + } + if (H5I_dec_ref(fapl->wo_fapl_id) < 0) { + HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close W/O FAPL ID") + } + + /* Free the property list */ + H5MM_free(fapl); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_splitter_fapl_free() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_splitter_open + * + * Purpose: Create and/or opens a file as an HDF5 file. + * + * Return: Success: A pointer to a new file data structure. The + * public fields will be initialized by the + * caller, which is always H5FD_open(). + * Failure: NULL + *------------------------------------------------------------------------- + */ +static H5FD_t * +H5FD_splitter_open(const char *name, unsigned flags, hid_t splitter_fapl_id, haddr_t maxaddr) +{ + H5FD_splitter_t *file_ptr = NULL; /* Splitter VFD info */ + const H5FD_splitter_fapl_t *fapl_ptr = NULL; /* Driver-specific property list */ + H5P_genplist_t *plist_ptr = NULL; + H5FD_t *ret_value = NULL; + + FUNC_ENTER_NOAPI_NOINIT + + H5FD_SPLITTER_LOG_CALL("H5FD_splitter_open"); + + /* Check arguments */ + if (!name || !*name) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name") + } + if (0 == maxaddr || HADDR_UNDEF == maxaddr) { + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr") + } + if (ADDR_OVERFLOW(maxaddr)) { + HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr") + } + if ( (H5P_FILE_ACCESS_DEFAULT == splitter_fapl_id) || + (H5FD_SPLITTER != H5Pget_driver(splitter_fapl_id)) ) + { + /* presupposes that H5P_FILE_ACCESS_DEFAULT is not a splitter */ + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "driver is not splitter") + } + + file_ptr = (H5FD_splitter_t *)H5FL_CALLOC(H5FD_splitter_t); + if (NULL == file_ptr) { + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct") + } + file_ptr->fa.rw_fapl_id = H5I_INVALID_HID; + file_ptr->fa.wo_fapl_id = H5I_INVALID_HID; + + /* Get the driver-specific file access properties */ + plist_ptr = (H5P_genplist_t *)H5I_object(splitter_fapl_id); + if (NULL == plist_ptr) { + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") + } + fapl_ptr = (const H5FD_splitter_fapl_t *)H5P_peek_driver_info(plist_ptr); + if (NULL == fapl_ptr) { + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "unable to get VFL driver info") + } + + /* Copy simpler info */ + if (HDstrncpy(file_ptr->fa.wo_path, fapl_ptr->wo_path, H5FD_SPLITTER_PATH_MAX) == NULL) { + HGOTO_ERROR(H5E_VFL, H5E_CANTCOPY, NULL, "unable to copy write-only path") + } + if (HDstrncpy(file_ptr->fa.log_file_path, fapl_ptr->log_file_path, H5FD_SPLITTER_PATH_MAX) == NULL) { + HGOTO_ERROR(H5E_VFL, H5E_CANTCOPY, NULL, "unable to copy logfile path") + } + file_ptr->fa.ignore_wo_errs = fapl_ptr->ignore_wo_errs; + + /* Copy R/W and W/O channel FAPLs. */ + if (H5FD__copy_plist(fapl_ptr->rw_fapl_id, &(file_ptr->fa.rw_fapl_id)) < 0) { + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, NULL, "can't copy R/W FAPL"); + } + if (H5FD__copy_plist(fapl_ptr->wo_fapl_id, &(file_ptr->fa.wo_fapl_id)) < 0) { + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, NULL, "can't copy W/O FAPL"); + } + + /* Prepare log file if necessary. + * If application wants to ignore the errors from W/O channel and + * provided a name for the log file, then open it + */ + if (!file_ptr->logfp) { + if (file_ptr->fa.log_file_path[0] != '\0') { + file_ptr->logfp = HDfopen(file_ptr->fa.log_file_path, "w"); + if (file_ptr->logfp == NULL) { + HGOTO_ERROR(H5E_VFL, H5E_CANTOPENFILE, NULL, "unable to open log file") + } + } /* end if logfile path given */ + } /* end if logfile pointer/handle does not exist */ + + file_ptr->rw_file = H5FD_open(name, flags, fapl_ptr->rw_fapl_id, HADDR_UNDEF); + if (!file_ptr->rw_file) { + HGOTO_ERROR(H5E_VFL, H5E_CANTOPENFILE, NULL, "unable to open R/W file") + } + + file_ptr->wo_file = H5FD_open(fapl_ptr->wo_path, flags, fapl_ptr->wo_fapl_id, HADDR_UNDEF); + if (!file_ptr->wo_file) { + H5FD_SPLITTER_WO_ERROR(file_ptr, "H5FD_splitter_open", + H5E_VFL, H5E_CANTOPENFILE, NULL, + "unable to open W/O file") + } + + ret_value = (H5FD_t*)file_ptr; + +done: + if (NULL == ret_value) { + if (file_ptr) { + if (H5I_INVALID_HID != file_ptr->fa.rw_fapl_id) { + H5I_dec_ref(file_ptr->fa.rw_fapl_id); + } + if (H5I_INVALID_HID != file_ptr->fa.wo_fapl_id) { + H5I_dec_ref(file_ptr->fa.wo_fapl_id); + } + if (file_ptr->rw_file) { + H5FD_close(file_ptr->rw_file); + } + if (file_ptr->wo_file) { + H5FD_close(file_ptr->wo_file); + } + if (file_ptr->logfp) { + HDfclose(file_ptr->logfp); + } + H5FL_FREE(H5FD_splitter_t, file_ptr); + } + } /* end if error */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_splitter_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_splitter_close + * + * Purpose: Closes files on both read-write and write-only channels. + * + * Return: Success: SUCCEED + * Failure: FAIL, file not closed. + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_splitter_close(H5FD_t *_file) +{ + H5FD_splitter_t *file = (H5FD_splitter_t *)_file; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + + H5FD_SPLITTER_LOG_CALL("H5FD_splitter_close"); + + /* Sanity check */ + HDassert(file); + + if (H5I_dec_ref(file->fa.rw_fapl_id) < 0) { + HGOTO_ERROR(H5E_VFL, H5E_ARGS, FAIL, "can't close R/W FAPL") + } + if (H5I_dec_ref(file->fa.wo_fapl_id) < 0) { + HGOTO_ERROR(H5E_VFL, H5E_ARGS, FAIL, "can't close W/O FAPL") + } + + if (file->rw_file) { + if (H5FD_close(file->rw_file) == FAIL) { + HGOTO_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "unable to close R/W file") + } + } + if (file->wo_file) { + if (H5FD_close(file->wo_file) == FAIL) { + H5FD_SPLITTER_WO_ERROR(file, "H5FD_splitter_close", + H5E_VFL, H5E_CANTCLOSEFILE, FAIL, + "unable to close W/O file") + } + } + + if (file->logfp) { + HDfclose(file->logfp); + file->logfp = NULL; + } + + /* Release the file info */ + file = H5FL_FREE(H5FD_splitter_t, file); + file = NULL; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_splitter_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_splitter_get_eoa + * + * Purpose: Returns the end-of-address marker for the file. The EOA + * marker is the first address past the last byte allocated in + * the format address space. + * + * Return: Success: The end-of-address-marker + * + * Failure: HADDR_UNDEF + *------------------------------------------------------------------------- + */ +static haddr_t +H5FD_splitter_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) +{ + const H5FD_splitter_t *file = (const H5FD_splitter_t *)_file; + haddr_t ret_value = HADDR_UNDEF; + + FUNC_ENTER_NOAPI_NOINIT + + H5FD_SPLITTER_LOG_CALL("H5FD_splitter_get_eoa"); + + /* Sanity check */ + HDassert(file); + HDassert(file->rw_file); + + if ((ret_value = H5FD_get_eoa(file->rw_file, type)) == HADDR_UNDEF) { + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, HADDR_UNDEF, "unable to get eoa") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_splitter_get_eoa */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_splitter_set_eoa + * + * Purpose: Set the end-of-address marker for the file. This function is + * called shortly after an existing HDF5 file is opened in order + * to tell the driver where the end of the HDF5 data is located. + * + * Return: SUCCEED/FAIL + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_splitter_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) +{ + H5FD_splitter_t *file = (H5FD_splitter_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + H5FD_SPLITTER_LOG_CALL("H5FD_splitter_set_eoa";) + + /* Sanity check */ + HDassert(file); + HDassert(file->rw_file); + HDassert(file->wo_file); + + if (H5FD_set_eoa(file->rw_file, type, addr) < 0) { + HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "H5FDset_eoa failed for R/W file") + } + + if (H5FD_set_eoa(file->wo_file, type, addr) < 0) { + H5FD_SPLITTER_WO_ERROR(file, "H5FD_splitter_set_eoa", + H5E_VFL, H5E_CANTSET, FAIL, + "unable to set EOA for W/O file") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_splitter_set_eoa() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_splitter_get_eof + * + * Purpose: Returns the end-of-address marker for the file. The EOA + * marker is the first address past the last byte allocated in + * the format address space. + * + * Return: Success: The end-of-address-marker + * + * Failure: HADDR_UNDEF + *------------------------------------------------------------------------- + */ +static haddr_t +H5FD_splitter_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) +{ + const H5FD_splitter_t *file = (const H5FD_splitter_t *)_file; + haddr_t ret_value = HADDR_UNDEF; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + H5FD_SPLITTER_LOG_CALL("H5FD_splitter_get_eof"); + + /* Sanity check */ + HDassert(file); + HDassert(file->rw_file); + + if (HADDR_UNDEF == (ret_value = H5FD_get_eof(file->rw_file, type))) { + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, HADDR_UNDEF, "unable to get eof") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_splitter_get_eof */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_splitter_truncate + * + * Purpose: Notify driver to truncate the file back to the allocated size. + * + * Return: SUCCEED/FAIL + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_splitter_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing) +{ + H5FD_splitter_t *file = (H5FD_splitter_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + H5FD_SPLITTER_LOG_CALL("H5FD_splitter_truncate"); + + HDassert(file); + HDassert(file->rw_file); + HDassert(file->wo_file); + + if (H5FDtruncate(file->rw_file, dxpl_id, closing) < 0) { + HGOTO_ERROR(H5E_VFL, H5E_CANTUPDATE, FAIL, "unable to truncate R/W file") + } + + if (H5FDtruncate(file->wo_file, dxpl_id, closing) < 0) { + H5FD_SPLITTER_WO_ERROR(file, "H5FD_splitter_truncate", + H5E_VFL, H5E_CANTUPDATE, FAIL, + "unable to truncate W/O file") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_splitter_truncate */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_splitter_sb_size + * + * Purpose: Obtains the number of bytes required to store the driver file + * access data in the HDF5 superblock. + * + * Return: Success: Number of bytes required. + * + * Failure: 0 if an error occurs or if the driver has no + * data to store in the superblock. + * + * NOTE: no public API for H5FD_sb_size, it needs to be added + *------------------------------------------------------------------------- + */ +static hsize_t +H5FD_splitter_sb_size(H5FD_t *_file) +{ + H5FD_splitter_t *file = (H5FD_splitter_t *)_file; + hsize_t ret_value = 0; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + H5FD_SPLITTER_LOG_CALL("H5FD_splitter_sb_size"); + + /* Sanity check */ + HDassert(file); + HDassert(file->rw_file); + + if (file->rw_file) { + ret_value = H5FD_sb_size(file->rw_file); + } + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_splitter_sb_size */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_splitter_sb_encode + * + * Purpose: Encode driver-specific data into the output arguments. + * + * Return: SUCCEED/FAIL + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_splitter_sb_encode(H5FD_t *_file, char *name/*out*/, unsigned char *buf/*out*/) +{ + H5FD_splitter_t *file = (H5FD_splitter_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + H5FD_SPLITTER_LOG_CALL("H5FD_splitter_sb_encode"); + + /* Sanity check */ + HDassert(file); + HDassert(file->rw_file); + + if (file->rw_file && H5FD_sb_encode(file->rw_file, name, buf) < 0) { + HGOTO_ERROR(H5E_VFL, H5E_CANTENCODE, FAIL, "unable to encode the superblock in R/W file") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_splitter_sb_encode */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_splitter_sb_decode + * + * Purpose: Decodes the driver information block. + * + * Return: SUCCEED/FAIL + * + * NOTE: no public API for H5FD_sb_size, need to add + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_splitter_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf) +{ + H5FD_splitter_t *file = (H5FD_splitter_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + H5FD_SPLITTER_LOG_CALL("H5FD_splitter_sb_decode"); + + /* Sanity check */ + HDassert(file); + HDassert(file->rw_file); + + if (H5FD_sb_load(file->rw_file, name, buf) < 0) { + HGOTO_ERROR(H5E_VFL, H5E_CANTDECODE, FAIL, "unable to decode the superblock in R/W file") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_splitter_sb_decode */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_splitter_cmp + * + * Purpose: Compare the keys of two files. + * + * Return: Success: A value like strcmp() + * Failure: Must never fail + *------------------------------------------------------------------------- + */ +static int +H5FD_splitter_cmp(const H5FD_t *_f1, const H5FD_t *_f2) +{ + const H5FD_splitter_t *f1 = (const H5FD_splitter_t *)_f1; + const H5FD_splitter_t *f2 = (const H5FD_splitter_t *)_f2; + herr_t ret_value = 0; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + H5FD_SPLITTER_LOG_CALL("H5FD_splitter_cmp"); + + HDassert(f1); + HDassert(f2); + + ret_value = H5FD_cmp(f1->rw_file, f2->rw_file); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_splitter_cmp */ + + +/*-------------------------------------------------------------------------- + * Function: H5FD_splitter_get_handle + * + * Purpose: Returns a pointer to the file handle of low-level virtual + * file driver. + * + * Return: SUCCEED/FAIL + *-------------------------------------------------------------------------- + */ +static herr_t +H5FD_splitter_get_handle( + H5FD_t *_file, + hid_t H5_ATTR_UNUSED fapl, + void **file_handle) +{ + H5FD_splitter_t *file = (H5FD_splitter_t*)_file; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + H5FD_SPLITTER_LOG_CALL("H5FD_splitter_get_handle"); + + /* Check arguments */ + HDassert(file); + HDassert(file->rw_file); + HDassert(file_handle); + + /* Only do for R/W channel */ + if (H5FD_get_vfd_handle(file->rw_file, file->fa.rw_fapl_id, file_handle) < 0) + { + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "unable to get handle of R/W file") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_splitter_get_handle */ + + +/*-------------------------------------------------------------------------- + * Function: H5FD_splitter_lock + * + * Purpose: Sets a file lock. + * + * Return: SUCCEED/FAIL + *-------------------------------------------------------------------------- + */ +static herr_t +H5FD_splitter_lock(H5FD_t *_file, hbool_t rw) +{ + H5FD_splitter_t *file = (H5FD_splitter_t *)_file; /* VFD file struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + H5FD_SPLITTER_LOG_CALL("H5FD_splitter_lock"); + + HDassert(file); + HDassert(file->rw_file); + + /* Place the lock on each file */ + if (H5FD_lock(file->rw_file, rw) < 0) { + HGOTO_ERROR(H5E_VFL, H5E_CANTLOCK, FAIL, "unable to lock R/W file") + } + if (file->wo_file != NULL) { + if (H5FD_lock(file->wo_file, rw) < 0) { + H5FD_SPLITTER_WO_ERROR(file, "H5FD_splitter_lock", + H5E_VFL, H5E_CANTLOCK, FAIL, + "unable to lock W/O file") + } + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_splitter_lock */ + + +/*-------------------------------------------------------------------------- + * Function: H5FD_splitter_unlock + * + * Purpose: Removes a file lock. + * + * Return: SUCCEED/FAIL + *-------------------------------------------------------------------------- + */ +static herr_t +H5FD_splitter_unlock(H5FD_t *_file) +{ + H5FD_splitter_t *file = (H5FD_splitter_t *)_file; /* VFD file struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + H5FD_SPLITTER_LOG_CALL("H5FD_splitter_unlock"); + + /* Check arguments */ + HDassert(file); + HDassert(file->rw_file); + + /* Remove the lock on each file */ + if (H5FD_unlock(file->rw_file) < 0) { + HGOTO_ERROR(H5E_VFL, H5E_CANTUNLOCK, FAIL, "unable to unlock R/W file") + } + if (file->wo_file != NULL) { + if (H5FD_unlock(file->wo_file) < 0) { + HGOTO_ERROR(H5E_VFL, H5E_CANTUNLOCK, FAIL, + "unable to unlock W/O file") + } + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_splitter_unlock */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_splitter_query + * + * Purpose: Set the flags that this VFL driver is capable of supporting. + * (listed in H5FDpublic.h) + * + * Return: SUCCEED/FAIL + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_splitter_query(const H5FD_t *_file, unsigned long *flags /* out */) +{ + const H5FD_splitter_t *file = (const H5FD_splitter_t *)_file; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + + H5FD_SPLITTER_LOG_CALL("H5FD_splitter_query"); + + if (file) { + HDassert(file); + HDassert(file->rw_file); + + if (H5FDquery(file->rw_file, flags) < 0) { + HGOTO_ERROR(H5E_VFL, H5E_CANTLOCK, FAIL, + "unable to query R/W file"); + } + } + else { + /* There is no file. Because this is a pure passthrough VFD, + * it has no features of its own. + */ + if (flags) { + *flags = 0; + } + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_splitter_query() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_splitter_alloc + * + * Purpose: Allocate file memory. + * + * Return: Address of allocated space (HADDR_UNDEF if error). + *------------------------------------------------------------------------- + */ +static haddr_t +H5FD_splitter_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) +{ + H5FD_splitter_t *file = (H5FD_splitter_t *)_file; /* VFD file struct */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + H5FD_SPLITTER_LOG_CALL("H5FD_splitter_alloc"); + + /* Check arguments */ + HDassert(file); + HDassert(file->rw_file); + + /* Allocate memory for each file, only return the return value for R/W file. */ + if ((ret_value = H5FDalloc(file->rw_file, type, dxpl_id, size)) == HADDR_UNDEF) { + HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "unable to allocate for R/W file") + } + + if (H5FDalloc(file->wo_file, type, dxpl_id, size) == HADDR_UNDEF) { + H5FD_SPLITTER_WO_ERROR(file, "H5FD_splitter_alloc", + H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, + "unable to alloc for W/O file") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_splitter_alloc() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_splitter_get_type_map + * + * Purpose: Retrieve the memory type mapping for this file + * + * Return: SUCCEED/FAIL + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_splitter_get_type_map(const H5FD_t *_file, H5FD_mem_t *type_map) +{ + const H5FD_splitter_t *file = (const H5FD_splitter_t *)_file; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + + H5FD_SPLITTER_LOG_CALL("H5FD_splitter_get_type_map"); + + /* Check arguments */ + HDassert(file); + HDassert(file->rw_file); + + /* Retrieve memory type mapping for R/W channel only */ + if (H5FD_get_fs_type_map(file->rw_file, type_map) < 0) { + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "unable to allocate for R/W file") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_splitter_get_type_map() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_splitter_free + * + * Purpose: Free the resources for the splitter VFD. + * + * Return: SUCCEED/FAIL + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_splitter_free(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size) +{ + H5FD_splitter_t *file = (H5FD_splitter_t *)_file; /* VFD file struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + H5FD_SPLITTER_LOG_CALL("H5FD_splitter_free"); + + /* Check arguments */ + HDassert(file); + HDassert(file->rw_file); + + if (H5FDfree(file->rw_file, type, dxpl_id, addr, size) < 0) { + HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "unable to free for R/W file") + } + + if (H5FDfree(file->wo_file, type, dxpl_id, addr, size) < 0) { + H5FD_SPLITTER_WO_ERROR(file, "H5FD_splitter_free", + H5E_VFL, H5E_CANTINIT, FAIL, + "unable to free for W/O file") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_splitter_free() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD__splitter_log_error + * + * Purpose: Log an error from the W/O channel appropriately. + * + * Return: SUCCEED/FAIL + *------------------------------------------------------------------------- + */ +static herr_t +H5FD__splitter_log_error(const H5FD_splitter_t *file, const char *atfunc, const char *msg) +{ + size_t size = 0; + char *s = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC_NOERR + + H5FD_SPLITTER_LOG_CALL("H5FD__splitter_log_error"); + + /* Check arguments */ + HDassert(file); + HDassert(atfunc && *atfunc); + HDassert(msg && *msg); + + if (file->logfp != NULL) { + size = strlen(atfunc) + strlen(msg) + 3; /* ':', ' ', '\n' */ + s = (char *)malloc(sizeof(char) * (size+1)); + if (NULL == s) { + ret_value = FAIL; + } + else + if (size < (size_t)HDsnprintf(s, size+1, "%s: %s\n", atfunc, msg)) { + ret_value = FAIL; + } + else + if (size != HDfwrite(s, 1, size, file->logfp)) { + ret_value = FAIL; + } + HDfree(s); + } + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD__splitter_log_error() */ + diff --git a/src/H5FDsplitter.h b/src/H5FDsplitter.h new file mode 100644 index 0000000..5a5ef29 --- /dev/null +++ b/src/H5FDsplitter.h @@ -0,0 +1,99 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: The public header file for the "splitter" driver. + */ + +#ifndef H5FDsplitter_H +#define H5FDsplitter_H + +#define H5FD_SPLITTER (H5FD_splitter_init()) + +/* The version of the H5FD_splitter_vfd_config_t structure used */ +#define H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION 1 + +/* Maximum length of a filename/path string in the Write-Only channel, + * including the NULL-terminator. + */ +#define H5FD_SPLITTER_PATH_MAX 4096 + +/* Semi-unique constant used to help identify structure pointers */ +#define H5FD_SPLITTER_MAGIC 0x2B916880 + +/* ---------------------------------------------------------------------------- + * Structure: H5FD_spliiter_vfd_config_t + * + * One-stop shopping for configuring a Splitter VFD (rather than many + * paramaters passed into H5Pset/get functions). + * + * magic (int32_t) + * Semi-unique number, used to sanity-check that a given pointer is + * likely (or not) to be this structure type. MUST be first. + * If magic is not H5FD_SPLITTER_MAGIC, the structure (and/or pointer to) + * must be considered invalid. + * + * version (unsigned int) + * Version number of this structure -- informs component membership. + * If not H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION, the structure (and/or + * pointer to) must be considered invalid. + * + * rw_fapl_id (hid_t) + * Library-given identification number of the Read/Write channel driver + * File Access Property List. + * The driver must support read/write access. + * Must be set to H5P_DEFAULT or a valid FAPL ID. + * + * wo_fapl_id (hid_t) + * Library-given identification number of the Read/Write channel driver + * File Access Property List. + * The driver feature flags must include H5FD_FEAT_DEFAULT_VFD_COMPAITBLE. + * Must be set to H5P_DEFAULT or a valid FAPL ID. + * + * wo_file_path (char[H5FD_SPLITTER_PATH_MAX + 1]) + * String buffer for the Write-Only channel target file. + * Must be null-terminated, cannot be empty. + * + * log_file_path (char[H5FD_SPLITTER_PATH_MAX + 1]) + * String buffer for the Splitter VFD logging output. + * Must be null-terminated. + * If null, no logfile is created. + * + * ignore_wo_errors (hbool_t) + * Toggle flag for how judiciously to respond to errors on the Write-Only + * channel. + * + * ---------------------------------------------------------------------------- + */ +typedef struct H5FD_splitter_vfd_config_t { + int32_t magic; + unsigned int version; + hid_t rw_fapl_id; + hid_t wo_fapl_id; + char wo_path[H5FD_SPLITTER_PATH_MAX + 1]; + char log_file_path[H5FD_SPLITTER_PATH_MAX + 1]; + hbool_t ignore_wo_errs; +} H5FD_splitter_vfd_config_t; + +#ifdef __cplusplus +extern "C" { +#endif +H5_DLL hid_t H5FD_splitter_init(void); +H5_DLL herr_t H5Pset_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *config_ptr); +H5_DLL herr_t H5Pget_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *config_ptr); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/src/H5FS.c b/src/H5FS.c index 4fe0927..6d574c0 100644 --- a/src/H5FS.c +++ b/src/H5FS.c @@ -36,7 +36,7 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5FSpkg.h" /* File free space */ #include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5MMprivate.h" /* Memory management */ /****************/ diff --git a/src/H5FSsection.c b/src/H5FSsection.c index 047657e..d783901 100644 --- a/src/H5FSsection.c +++ b/src/H5FSsection.c @@ -371,10 +371,10 @@ HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n" /* Check if section info lock count dropped to zero */ if(fspace->sinfo_lock_count == 0) { hbool_t release_sinfo_space = FALSE; /* Flag to indicate section info space in file should be released */ - hbool_t flush_in_progress = FALSE; /* Is flushing in progress */ + hbool_t closing_or_flushing = f->shared->closing; /* Is closing or flushing in progress */ - /* Check whether cache is flush_in_progress */ - if(H5AC_get_cache_flush_in_progress(f->shared->cache, &flush_in_progress) < 0) + /* Check whether cache-flush is in progress if closing is not. */ + if(!closing_or_flushing && H5AC_get_cache_flush_in_progress(f->shared->cache, &closing_or_flushing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't get flush_in_progress") /* Check if we actually protected the section info */ @@ -390,7 +390,7 @@ HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n" cache_flags |= H5AC__DIRTIED_FLAG; /* On file close or flushing, does not allow section info to shrink in size */ - if(f->shared->closing || flush_in_progress) { + if(closing_or_flushing) { if(fspace->sect_size > fspace->alloc_sect_size) cache_flags |= H5AC__DELETED_FLAG | H5AC__TAKE_OWNERSHIP_FLAG; else @@ -441,7 +441,7 @@ HDfprintf(stderr, "%s: Relinquishing section info ownership\n", FUNC); /* Set flag to release section info space in file */ /* On file close or flushing, only need to release section info with size bigger than previous section */ - if(f->shared->closing || flush_in_progress) { + if(closing_or_flushing) { if(fspace->sect_size > fspace->alloc_sect_size) release_sinfo_space = TRUE; else diff --git a/src/H5Fint.c b/src/H5Fint.c index 74189c1..0bda894 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -273,7 +273,7 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref) done: /* Release the copy of the driver info, if it was set up */ - if(driver_prop_copied && H5FD_fapl_close(driver_prop.driver_id, driver_prop.driver_info) < 0) + if(driver_prop_copied && H5FD_free_driver_info(driver_prop.driver_id, driver_prop.driver_info) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, H5I_INVALID_HID, "can't close copy of driver info") FUNC_LEAVE_NOAPI(ret_value) @@ -391,7 +391,7 @@ H5F__get_objects(const H5F_t *f, unsigned types, size_t max_nobjs, hid_t *obj_id if(H5I_iterate(H5I_DATASET, H5F__get_objects_cb, &olist, app_ref) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(2)") } /* end if */ - } /* end if */ + } /* If the caller just wants to count the number of objects (OLIST.MAX_NOBJS is zero), * or the caller wants to get the list of IDs and the list isn't full, @@ -402,8 +402,8 @@ H5F__get_objects(const H5F_t *f, unsigned types, size_t max_nobjs, hid_t *obj_id olist.obj_type = H5I_GROUP; if(H5I_iterate(H5I_GROUP, H5F__get_objects_cb, &olist, app_ref) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(3)") - } /* end if */ - } /* end if */ + } + } /* If the caller just wants to count the number of objects (OLIST.MAX_NOBJS is zero), * or the caller wants to get the list of IDs and the list isn't full, @@ -415,7 +415,7 @@ H5F__get_objects(const H5F_t *f, unsigned types, size_t max_nobjs, hid_t *obj_id if(H5I_iterate(H5I_DATATYPE, H5F__get_objects_cb, &olist, app_ref) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(4)") } /* end if */ - } /* end if */ + } /* If the caller just wants to count the number of objects (OLIST.MAX_NOBJS is zero), * or the caller wants to get the list of IDs and the list isn't full, @@ -427,7 +427,7 @@ H5F__get_objects(const H5F_t *f, unsigned types, size_t max_nobjs, hid_t *obj_id if(H5I_iterate(H5I_ATTR, H5F__get_objects_cb, &olist, app_ref) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(5)") } /* end if */ - } /* end if */ + } /* Set the number of objects currently open */ *obj_id_count_ptr = obj_id_count; @@ -1066,12 +1066,12 @@ H5F__new(H5F_shared_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5F f->shared->feature_flags &= ~(unsigned)H5FD_FEAT_ACCUMULATE_METADATA; if(H5FD_set_feature_flags(f->shared->lf, f->shared->feature_flags) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, NULL, "can't set feature_flags in VFD") - } /* end if */ + } else { /* If no value for read attempts has been set, use the default */ if(!f->shared->read_attempts) f->shared->read_attempts = H5F_METADATA_READ_ATTEMPTS; - } /* end else */ + } /* Determine the # of bins for metdata read retries */ if(H5F_set_retries(f) < 0) @@ -1138,7 +1138,7 @@ done: HDONE_ERROR(H5E_FILE, H5E_CANTDEC, NULL, "can't close property list") f->shared = H5FL_FREE(H5F_shared_t, f->shared); - } /* end if */ + } /* Free VOL object */ if(f->vol_obj) @@ -1146,7 +1146,7 @@ done: HDONE_ERROR(H5E_FILE, H5E_CANTDEC, NULL, "unable to free VOL object") f = H5FL_FREE(H5F_t, f); - } /* end if */ + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__new() */ @@ -2298,7 +2298,7 @@ H5F_get_id(H5F_t *file) if((ret_value = H5VL_wrap_register(H5I_FILE, file, FALSE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register group") file->id_exists = TRUE; - } /* end if */ + } else { /* Increment reference count on existing ID */ if(H5I_inc_ref(ret_value, FALSE) < 0) @@ -3033,7 +3033,7 @@ H5F_set_retries(H5F_t *f) /* Initialize the # of bins for retries */ f->shared->retries_nbins = 0; if(f->shared->read_attempts > 1) { - /* Use HDceil to ensure that the log10 value is rounded up to the + /* Use HDceil to ensure that the log10 value is rounded up to the nearest integer before casting to unsigned */ tmp = HDceil(HDlog10((double)f->shared->read_attempts)); f->shared->retries_nbins = (unsigned)tmp; diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index f0c28ca..c5d4c89 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -25,15 +25,15 @@ typedef struct H5F_t H5F_t; #include "H5Fpublic.h" /* Public headers needed by this file */ -#include "H5FDpublic.h" /* File drivers */ +#include "H5FDpublic.h" /* File drivers */ /* Private headers needed by this file */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5MMprivate.h" /* Memory management */ #ifdef H5_HAVE_PARALLEL -#include "H5Pprivate.h" /* Property lists */ +#include "H5Pprivate.h" /* Property lists */ #endif /* H5_HAVE_PARALLEL */ -#include "H5VMprivate.h" /* Vectors and arrays */ -#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /**************************/ @@ -432,7 +432,7 @@ typedef struct H5F_t H5F_t; default: HDassert("bad sizeof size" && 0); \ } -#define H5F_DECODE_LENGTH(f,p,l) H5F_DECODE_LENGTH_LEN(p,l,H5F_SIZEOF_SIZE(f)) +#define H5F_DECODE_LENGTH(f,p,l) DECODE_VAR(p,l,H5F_SIZEOF_SIZE(f)) /* * Macros that check for overflows. These are somewhat dangerous to fiddle @@ -795,7 +795,6 @@ H5_DLL hsize_t H5F_get_alignment(const H5F_t *f); H5_DLL hsize_t H5F_get_threshold(const H5F_t *f); #ifdef H5_HAVE_PARALLEL H5_DLL H5P_coll_md_read_flag_t H5F_coll_md_read(const H5F_t *f); -H5_DLL void H5F_set_coll_md_read(H5F_t *f, H5P_coll_md_read_flag_t flag); #endif /* H5_HAVE_PARALLEL */ H5_DLL hbool_t H5F_use_mdc_logging(const H5F_t *f); H5_DLL hbool_t H5F_start_mdc_log_on_access(const H5F_t *f); diff --git a/src/H5Fquery.c b/src/H5Fquery.c index 68ad8e5..e1b11c8 100644 --- a/src/H5Fquery.c +++ b/src/H5Fquery.c @@ -229,6 +229,7 @@ H5F_get_extpath(const H5F_t *f) FUNC_ENTER_NOAPI_NOINIT_NOERR HDassert(f); + HDassert(f->shared); HDassert(f->shared->extpath); FUNC_LEAVE_NOAPI(f->shared->extpath) @@ -1259,6 +1260,7 @@ H5F_get_point_of_no_return(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->point_of_no_return) } /* end H5F_get_point_of_no_return() */ + /*------------------------------------------------------------------------- * Function: H5F_get_null_fsm_addr * diff --git a/src/H5Glink.c b/src/H5Glink.c index 6c42f1d..cbe5307 100644 --- a/src/H5Glink.c +++ b/src/H5Glink.c @@ -15,7 +15,7 @@ * * Created: H5Glink.c * Nov 13 2006 - * Quincey Koziol + * Quincey Koziol * * Purpose: Functions for handling links in groups. * @@ -98,7 +98,6 @@ static int H5G_link_cmp_corder_dec(const void *lnk1, const void *lnk2); * (i.e. same as strcmp()) * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu * Sep 5 2005 * *------------------------------------------------------------------------- @@ -125,7 +124,6 @@ H5G_link_cmp_name_inc(const void *lnk1, const void *lnk2) * (i.e. opposite strcmp()) * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu * Sep 25 2006 * *------------------------------------------------------------------------- @@ -151,7 +149,6 @@ H5G_link_cmp_name_dec(const void *lnk1, const void *lnk2) * as equal, their order in the sorted array is undefined. * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Nov 6 2006 * *------------------------------------------------------------------------- @@ -186,7 +183,6 @@ H5G_link_cmp_corder_inc(const void *lnk1, const void *lnk2) * as equal, their order in the sorted array is undefined. * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Nov 6 2006 * *------------------------------------------------------------------------- @@ -217,7 +213,6 @@ H5G_link_cmp_corder_dec(const void *lnk1, const void *lnk2) * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Sep 16 2006 * *------------------------------------------------------------------------- @@ -561,7 +556,6 @@ done: * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Nov 13 2006 * *------------------------------------------------------------------------- diff --git a/src/H5Gloc.c b/src/H5Gloc.c index 4d89abb..2461c51 100644 --- a/src/H5Gloc.c +++ b/src/H5Gloc.c @@ -15,7 +15,7 @@ * * Created: H5Gloc.c * Sep 13 2005 - * Quincey Koziol + * Quincey Koziol * * Purpose: Functions for working with group "locations" * @@ -809,9 +809,9 @@ done: /*------------------------------------------------------------------------- - * Function: H5G_loc_info + * Function: H5G_loc_info * - * Purpose: Retrieve the data model information for an object from a group location + * Purpose: Retrieve the data model information for an object from a group location * and path to that object * * Return: Non-negative on success/Negative on failure diff --git a/src/H5Gname.c b/src/H5Gname.c index 4b0f04c..e1004de 100644 --- a/src/H5Gname.c +++ b/src/H5Gname.c @@ -15,7 +15,7 @@ * * Created: H5Gname.c * Sep 12 2005 - * Quincey Koziol + * Quincey Koziol * * Purpose: Functions for handling group hierarchy paths. * @@ -123,7 +123,6 @@ H5FL_BLK_EXTERN(str_buf); * Failure: Ptr to the null terminator of NAME. * * Programmer: Robb Matzke - * matzke@llnl.gov * Aug 11 1997 * *------------------------------------------------------------------------- @@ -216,7 +215,7 @@ done: * Return: TRUE for valid prefix, FALSE for not a valid prefix, FAIL * on error * - * Programmer: Quincey Koziol, koziol@ncsa.uiuc.edu + * Programmer: Quincey Koziol * * Date: September 24, 2002 * @@ -281,7 +280,7 @@ done: * * Return: Pointer to reference counted string on success, NULL on error * - * Programmer: Quincey Koziol, koziol@ncsa.uiuc.edu + * Programmer: Quincey Koziol * * Date: August 19, 2005 * @@ -343,7 +342,7 @@ done: * Return: Success: Non-NULL, combined path * Failure: NULL * - * Programmer: Quincey Koziol, koziol@ncsa.uiuc.edu + * Programmer: Quincey Koziol * Tuesday, October 11, 2005 * *------------------------------------------------------------------------- @@ -379,7 +378,7 @@ H5G_build_fullpath_refstr_str(H5RS_str_t *prefix_r, const char *name) * * Return: Pointer to reference counted string on success, NULL on error * - * Programmer: Quincey Koziol, koziol@ncsa.uiuc.edu + * Programmer: Quincey Koziol * * Date: August 19, 2005 * @@ -448,7 +447,7 @@ H5G__name_init(H5G_name_t *name, const char *path) * Return: Success: Non-negative * Failure: Negative * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * Programmer: Pedro Vicente * Thursday, August 22, 2002 * *------------------------------------------------------------------------- @@ -552,10 +551,6 @@ H5G_name_copy(H5G_name_t *dst, const H5G_name_t *src, H5_copy_depth_t depth) * Programmer: Quincey Koziol * Tuesday, December 13, 2005 * - * Modifications: Leon Arber - * Oct. 18, 2006 - * Added functionality to get the name for a reference. - * *------------------------------------------------------------------------- */ ssize_t @@ -639,7 +634,7 @@ H5G_name_reset(H5G_name_t *name) * * Return: Success * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * Programmer: Pedro Vicente * * Date: August 22, 2002 * @@ -777,7 +772,7 @@ done: * * Return: Success: 0, Failure: -1 * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * Programmer: Pedro Vicente * * Date: June 5, 2002 * @@ -1060,7 +1055,7 @@ done: * * Return: Success: 0, Failure: -1 * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * Programmer: Pedro Vicente * * Date: June 11, 2002 * diff --git a/src/H5Gnode.c b/src/H5Gnode.c index 9faa0b5..2e7b367 100644 --- a/src/H5Gnode.c +++ b/src/H5Gnode.c @@ -15,7 +15,7 @@ * * Created: H5Gnode.c * Jun 26 1997 - * Robb Matzke + * Robb Matzke * * Purpose: Functions for handling symbol table nodes. A * symbol table node is a small collection of symbol @@ -145,8 +145,6 @@ H5FL_SEQ_DEFINE(H5G_entry_t); * Programmer: Robb Matzke * Wednesday, October 8, 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ static H5UC_t * @@ -169,7 +167,6 @@ H5G_node_get_shared(const H5F_t *f, const void H5_ATTR_UNUSED *_udata) * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke - * matzke@llnl.gov * Jul 8 1997 * *------------------------------------------------------------------------- @@ -199,7 +196,6 @@ H5G_node_decode_key(const H5B_shared_t *shared, const uint8_t *raw, void *_key) * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke - * matzke@llnl.gov * Jul 8 1997 * *------------------------------------------------------------------------- @@ -270,7 +266,6 @@ H5G_node_debug_key(FILE *stream, int indent, int fwidth, const void *_key, * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu * Jan 15 2003 * *------------------------------------------------------------------------- @@ -310,7 +305,6 @@ H5G__node_free(H5G_node_t *sym) * Failure: Negative * * Programmer: Robb Matzke - * matzke@llnl.gov * Jun 23 1997 * *------------------------------------------------------------------------- @@ -382,11 +376,8 @@ done: * Failure: FAIL (same as LT_KEY + * Programmer: Quincey Koziol * Saturday, September 12, 2015 * * Purpose: This file contains declarations which define macros for the diff --git a/src/H5HLpkg.h b/src/H5HLpkg.h index 44a2cfb..9891e10 100644 --- a/src/H5HLpkg.h +++ b/src/H5HLpkg.h @@ -12,7 +12,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Wednesday, July 9, 2003 * * Purpose: This file contains declarations which are visible diff --git a/src/H5HLprivate.h b/src/H5HLprivate.h index 7a53b25..60505ee 100644 --- a/src/H5HLprivate.h +++ b/src/H5HLprivate.h @@ -15,7 +15,7 @@ * * Created: H5HLprivate.h * Jul 16 1997 - * Robb Matzke + * Robb Matzke * * Purpose: Private declarations for the H5HL (local heap) package. * diff --git a/src/H5I.c b/src/H5I.c index 8ae808d..a739c4e 100644 --- a/src/H5I.c +++ b/src/H5I.c @@ -33,9 +33,9 @@ #include "H5ACprivate.h" /* Metadata cache */ #include "H5CXprivate.h" /* API Contexts */ #include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FLprivate.h" /* Free Lists */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FLprivate.h" /* Free Lists */ #include "H5Gprivate.h" /* Groups */ #include "H5Ipkg.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ @@ -48,25 +48,25 @@ /* Local Macros */ /* Combine a Type number and an atom index into an atom */ -#define H5I_MAKE(g,i) ((((hid_t)(g) & TYPE_MASK) << ID_BITS) | \ - ((hid_t)(i) & ID_MASK)) +#define H5I_MAKE(g,i) ((((hid_t)(g) & TYPE_MASK) << ID_BITS) | \ + ((hid_t)(i) & ID_MASK)) /* Local typedefs */ /* Atom information structure used */ typedef struct H5I_id_info_t { - hid_t id; /* ID for this info */ - unsigned count; /* ref. count for this atom */ + hid_t id; /* ID for this info */ + unsigned count; /* ref. count for this atom */ unsigned app_count; /* ref. count of application visible atoms */ - const void *obj_ptr; /* pointer associated with the atom */ + const void *obj_ptr; /* pointer associated with the atom */ } H5I_id_info_t; /* ID type structure used */ typedef struct { const H5I_class_t *cls; /* Pointer to ID class */ - unsigned init_count; /* # of times this type has been initialized*/ - uint64_t id_count; /* Current number of IDs held */ - uint64_t nextid; /* ID to use for the next atom */ + unsigned init_count; /* # of times this type has been initialized*/ + uint64_t id_count; /* Current number of IDs held */ + uint64_t nextid; /* ID to use for the next atom */ H5I_id_info_t *last_info; /* Info for most recent ID looked up */ H5SL_t *ids; /* Pointer to skip list that stores IDs */ } H5I_id_type_t; @@ -156,14 +156,14 @@ static int H5I__id_dump_cb(void *_item, void *_key, void *_udata); * Return: Success: Positive if any action was taken that might * affect some other interface; zero otherwise. * - * Failure: Negative + * Failure: Negative * *------------------------------------------------------------------------- */ int H5I_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -216,7 +216,8 @@ H5I_term_package(void) *------------------------------------------------------------------------- */ H5I_type_t -H5Iregister_type(size_t hash_size, unsigned reserved, H5I_free_t free_func) +H5Iregister_type(size_t H5_ATTR_DEBUG_API_USED hash_size, unsigned reserved, + H5I_free_t free_func) { H5I_class_t *cls = NULL; /* New ID class */ H5I_type_t new_type; /* New ID type value */ @@ -292,7 +293,7 @@ done: herr_t H5I_register_type(const H5I_class_t *cls) { - H5I_id_type_t *type_ptr = NULL; /* Ptr to the atomic type*/ + H5I_id_type_t *type_ptr = NULL; /* Ptr to the atomic type*/ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -327,7 +328,7 @@ H5I_register_type(const H5I_class_t *cls) type_ptr->init_count++; done: - if(ret_value < 0) { /* Clean up on error */ + if(ret_value < 0) { /* Clean up on error */ if(type_ptr) { if(type_ptr->ids) H5SL_close(type_ptr->ids); @@ -381,8 +382,8 @@ done: * * Return: SUCCEED/FAIL * - * Programmer: James Laird - * Nathaniel Furrer + * Programmer: James Laird + * Nathaniel Furrer * Friday, April 23, 2004 * *------------------------------------------------------------------------- @@ -431,7 +432,7 @@ done: * * Failure: Negative * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, March 24, 1999 * *------------------------------------------------------------------------- @@ -511,8 +512,8 @@ H5I__unwrap(void *obj_ptr, H5I_type_t type) * * Return: SUCCEED/FAIL * - * Programmer: James Laird - * Nathaniel Furrer + * Programmer: James Laird + * Nathaniel Furrer * Friday, April 23, 2004 * *------------------------------------------------------------------------- @@ -543,7 +544,7 @@ done: * * Return: SUCCEED/FAIL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, March 24, 1999 * *------------------------------------------------------------------------- @@ -654,8 +655,8 @@ H5I__clear_type_cb(void *_id, void H5_ATTR_UNUSED *key, void *_udata) * * Return: SUCCEED/FAIL * - * Programmer: Nathaniel Furrer - * James Laird + * Programmer: Nathaniel Furrer + * James Laird * *------------------------------------------------------------------------- */ @@ -687,15 +688,15 @@ done: * * Return: SUCCEED/FAIL * - * Programmer: Nathaniel Furrer - * James Laird + * Programmer: Nathaniel Furrer + * James Laird * *------------------------------------------------------------------------- */ static herr_t H5I__destroy_type(H5I_type_t type) { - H5I_id_type_t *type_ptr; /* ptr to the atomic type */ + H5I_id_type_t *type_ptr; /* ptr to the atomic type */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -899,8 +900,8 @@ done: * with the specified ID. * Failure: NULL * - * Programmer: Quincey Koziol - * Saturday, February 27, 2010 + * Programmer: Quincey Koziol + * Saturday, February 27, 2010 * *------------------------------------------------------------------------- */ @@ -908,7 +909,7 @@ void * H5I_subst(hid_t id, const void *new_object) { H5I_id_info_t *id_ptr; /* Pointer to the atom */ - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -942,8 +943,8 @@ done: void * H5I_object(hid_t id) { - H5I_id_info_t *id_ptr; /* Pointer to the new atom */ - void *ret_value = NULL; /* Return value */ + H5I_id_info_t *id_ptr; /* Pointer to the new atom */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOERR @@ -1001,8 +1002,8 @@ done: * specified ID. * Failure: NULL * - * Programmer: Quincey Koziol - * Wednesday, July 31, 2002 + * Programmer: Quincey Koziol + * Wednesday, July 31, 2002 * *------------------------------------------------------------------------- */ @@ -1039,8 +1040,8 @@ H5I_object_verify(hid_t id, H5I_type_t id_type) * ID types). * Failure: H5I_BADID * - * Programmer: Robb Matzke - * Friday, February 19, 1999 + * Programmer: Robb Matzke + * Friday, February 19, 1999 * *------------------------------------------------------------------------- */ @@ -1086,7 +1087,7 @@ H5Iget_type(hid_t id) ret_value = H5I_get_type(id); if(ret_value <= H5I_BADID || (int)ret_value >= H5I_next_type || NULL == H5I_object(id)) - HGOTO_DONE(H5I_BADID); + HGOTO_DONE(H5I_BADID); done: FUNC_LEAVE_API(ret_value) @@ -1156,8 +1157,8 @@ done: * calling H5I_object(). * Failure: NULL * - * Programmer: James Laird - * Nathaniel Furrer + * Programmer: James Laird + * Nathaniel Furrer * *------------------------------------------------------------------------- */ @@ -1191,15 +1192,15 @@ done: * calling H5I_object(). * Failure: NULL * - * Programmer: James Laird - * Nat Furrer + * Programmer: James Laird + * Nat Furrer * *------------------------------------------------------------------------- */ static void * H5I__remove_verify(hid_t id, H5I_type_t id_type) { - void * ret_value = NULL; /*return value */ + void * ret_value = NULL; /*return value */ FUNC_ENTER_STATIC_NOERR @@ -1231,8 +1232,8 @@ H5I__remove_verify(hid_t id, H5I_type_t id_type) static void * H5I__remove_common(H5I_id_type_t *type_ptr, hid_t id) { - H5I_id_info_t *curr_id; /* Pointer to the current atom */ - void *ret_value = NULL; /* Return value */ + H5I_id_info_t *curr_id; /* Pointer to the current atom */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1268,16 +1269,16 @@ done: * calling H5I_object(). * Failure: NULL * - * Programmer: Unknown + * Programmer: Unknown * *------------------------------------------------------------------------- */ void * H5I_remove(hid_t id) { - H5I_id_type_t *type_ptr; /* Pointer to the atomic type */ - H5I_type_t type; /* Atom's atomic type */ - void * ret_value = NULL; /* Return value */ + H5I_id_type_t *type_ptr; /* Pointer to the atomic type */ + H5I_type_t type; /* Atom's atomic type */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1379,7 +1380,7 @@ H5I_dec_ref(hid_t id) * file. We have to close the dataset anyway. (SLU - 2010/9/7) */ if(1 == id_ptr->count) { - H5I_id_type_t *type_ptr; /*ptr to the type */ + H5I_id_type_t *type_ptr; /*ptr to the type */ /* Get the ID's type */ type_ptr = H5I_id_type_list_g[H5I_TYPE(id)]; @@ -1700,7 +1701,7 @@ done: * Purpose: Decrements the reference count on an entire type of IDs. * If the type reference count becomes zero then the type is * destroyed along with all atoms in that type regardless of - * their reference counts. Destroying IDs involves calling + * their reference counts. Destroying IDs involves calling * the free-func for each ID's object and then adding the ID * struct to the ID free list. Public interface to * H5I_dec_type_ref. @@ -1742,7 +1743,7 @@ done: * Purpose: Decrements the reference count on an entire type of IDs. * If the type reference count becomes zero then the type is * destroyed along with all atoms in that type regardless of - * their reference counts. Destroying IDs involves calling + * their reference counts. Destroying IDs involves calling * the free-func for each ID's object and then adding the ID * struct to the ID free list. * Returns the number of references to the type on success; a @@ -1912,7 +1913,7 @@ H5I__search_cb(void *obj, hid_t id, void *_udata) /* Set the return value based on the callback's return value */ if(cb_ret_val > 0) { - ret_value = H5_ITER_STOP; /* terminate iteration early */ + ret_value = H5_ITER_STOP; /* terminate iteration early */ udata->ret_obj = obj; /* also set out parameter */ } else if(cb_ret_val < 0) @@ -2003,7 +2004,7 @@ H5I__iterate_pub_cb(void H5_ATTR_UNUSED *obj, hid_t id, void *_udata) /* Set the return value based on the callback's return value */ if(cb_ret_val > 0) - ret_value = H5_ITER_STOP; /* terminate iteration early */ + ret_value = H5_ITER_STOP; /* terminate iteration early */ else if(cb_ret_val < 0) ret_value = H5_ITER_ERROR; /* indicate failure (which terminates iteration) */ else @@ -2099,7 +2100,7 @@ H5I__iterate_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) /* Set the return value based on the callback's return value */ if(cb_ret_val > 0) - ret_value = H5_ITER_STOP; /* terminate iteration early */ + ret_value = H5_ITER_STOP; /* terminate iteration early */ else if(cb_ret_val < 0) ret_value = H5_ITER_ERROR; /* indicate failure (which terminates iteration) */ } /* end if */ @@ -2109,7 +2110,7 @@ H5I__iterate_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) /*------------------------------------------------------------------------- - * Function: H5I_iterate + * Function: H5I_iterate * * Purpose: Apply function FUNC to each member of type TYPE (with * non-zero application reference count if app_ref is TRUE). @@ -2137,7 +2138,7 @@ herr_t H5I_iterate(H5I_type_t type, H5I_search_func_t func, void *udata, hbool_t app_ref) { H5I_id_type_t *type_ptr; /* Pointer to the type */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2182,9 +2183,9 @@ done: static H5I_id_info_t * H5I__find_id(hid_t id) { - H5I_type_t type; /*ID's type */ - H5I_id_type_t *type_ptr; /*ptr to the type */ - H5I_id_info_t *ret_value = NULL; /* Return value */ + H5I_type_t type; /*ID's type */ + H5I_id_type_t *type_ptr; /*ptr to the type */ + H5I_id_info_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -2413,9 +2414,9 @@ H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) FUNC_ENTER_STATIC_NOERR - HDfprintf(stderr, " id = %lu\n", (unsigned long)(item->id)); - HDfprintf(stderr, " count = %u\n", item->count); - HDfprintf(stderr, " obj = 0x%08lx\n", (unsigned long)(item->obj_ptr)); + HDfprintf(stderr, " id = %lu\n", (unsigned long)(item->id)); + HDfprintf(stderr, " count = %u\n", item->count); + HDfprintf(stderr, " obj = 0x%08p\n", item->obj_ptr); /* Get the group location, so we get get the name */ switch (type) { @@ -2504,14 +2505,14 @@ H5I_dump_ids_for_type(H5I_type_t type) if(type_ptr) { /* Header */ - HDfprintf(stderr, " init_count = %u\n", type_ptr->init_count); - HDfprintf(stderr, " reserved = %u\n", type_ptr->cls->reserved); - HDfprintf(stderr, " id_count = %llu\n", (unsigned long long)type_ptr->id_count); - HDfprintf(stderr, " nextid = %llu\n", (unsigned long long)type_ptr->nextid); + HDfprintf(stderr, " init_count = %u\n", type_ptr->init_count); + HDfprintf(stderr, " reserved = %u\n", type_ptr->cls->reserved); + HDfprintf(stderr, " id_count = %llu\n", (unsigned long long)type_ptr->id_count); + HDfprintf(stderr, " nextid = %llu\n", (unsigned long long)type_ptr->nextid); /* List */ if(type_ptr->id_count > 0) { - HDfprintf(stderr, " List:\n"); + HDfprintf(stderr, " List:\n"); H5SL_iterate(type_ptr->ids, H5I__id_dump_cb, &type); } } diff --git a/src/H5L.c b/src/H5L.c index 6136266..4ef045d 100644 --- a/src/H5L.c +++ b/src/H5L.c @@ -264,7 +264,7 @@ H5L_term_package(void) * are interpreted relative to SRC_LOC_ID and DST_LOC_ID, * which are either file IDs or group ID. * - * Return: SUCCEED/FAIL + * Return: Non-negative on success/Negative on failure * * Programmer: James Laird * Wednesday, March 29, 2006 @@ -308,13 +308,13 @@ H5Lmove(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, ((src_loc_id != H5L_SAME_LOC) ? src_loc_id : dst_loc_id), TRUE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") - /* Set location paramter for source object */ + /* Set location parameter for source object */ loc_params1.type = H5VL_OBJECT_BY_NAME; loc_params1.loc_data.loc_by_name.name = src_name; loc_params1.loc_data.loc_by_name.lapl_id = lapl_id; loc_params1.obj_type = H5I_get_type(src_loc_id); - /* Set location paramter for destination object */ + /* Set location parameter for destination object */ loc_params2.type = H5VL_OBJECT_BY_NAME; loc_params2.loc_data.loc_by_name.name = dst_name; loc_params2.loc_data.loc_by_name.lapl_id = lapl_id; @@ -354,7 +354,7 @@ done: * time and target. The new link can have a different name * and be in a different location than the original. * - * Return: SUCCEED/FAIL + * Return: Non-negative on success/Negative on failure * * Programmer: James Laird * Wednesday, March 29, 2006 @@ -398,13 +398,13 @@ H5Lcopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, ((src_loc_id != H5L_SAME_LOC) ? src_loc_id : dst_loc_id), TRUE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") - /* Set location paramter for source object */ + /* Set location parameter for source object */ loc_params1.type = H5VL_OBJECT_BY_NAME; loc_params1.loc_data.loc_by_name.name = src_name; loc_params1.loc_data.loc_by_name.lapl_id = lapl_id; loc_params1.obj_type = H5I_get_type(src_loc_id); - /* Set location paramter for destination object */ + /* Set location parameter for destination object */ loc_params2.type = H5VL_OBJECT_BY_NAME; loc_params2.loc_data.loc_by_name.name = dst_name; loc_params2.loc_data.loc_by_name.lapl_id = lapl_id; @@ -448,7 +448,7 @@ done: * LINK_NAME is `./x/y/bar' and a request is made for `./x/y/bar' * then the actual object looked up is `./x/y/./foo'. * - * Return: SUCCEED/FAIL + * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Monday, April 6, 1998 @@ -519,7 +519,7 @@ done: * NEW_NAME are interpreted relative to CUR_LOC_ID and * NEW_LOC_ID, which are either file IDs or group IDs. * - * Return: SUCCEED/FAIL + * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Monday, April 6, 1998 @@ -621,7 +621,7 @@ done: * The link class of the new link must already be registered * with the library. * - * Return: SUCCEED/FAIL + * Return: Non-negative on success/Negative on failure * * Programmer: James Laird * Tuesday, December 13, 2005 @@ -687,7 +687,7 @@ done: * object is open, then the reclamation of the file space is * delayed until all handles to the object are closed). * - * Return: SUCCEED/FAIL + * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Monday, April 6, 1998 @@ -966,11 +966,11 @@ done: /*------------------------------------------------------------------------- - * Function: H5Lget_info2 + * Function: H5Lget_info2 * - * Purpose: Gets metadata for a link. + * Purpose: Gets metadata for a link. * - * Return: Success: Non-negative with information in LINFO + * Return: Success: Non-negative with information in LINFO * Failure: Negative * * Programmer: James Laird @@ -1016,13 +1016,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5Lget_info_by_idx2 + * Function: H5Lget_info_by_idx2 * - * Purpose: Gets metadata for a link, according to the order within an + * Purpose: Gets metadata for a link, according to the order within an * index. * - * Return: Success: Non-negative with information in LINFO - * Failure: Negative + * Return: Success: Non-negative with information in LINFO + * Failure: Negative * * Programmer: Quincey Koziol * Monday, November 6, 2006 @@ -1221,7 +1221,7 @@ done: * Return: Success: Non-negative length of name, with information * in NAME buffer * - * Failure: -1 + * Failure: -1 * * Programmer: Quincey Koziol * Saturday, November 11, 2006 @@ -2007,7 +2007,7 @@ H5L__create_real(const H5G_loc_t *link_loc, const char *link_name, HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "can't normalize name") /* Check for flags present in creation property list */ - if(lcpl_id != H5P_DEFAULT && lcpl_id != H5P_LINK_CREATE_DEFAULT) { + if(lcpl_id != H5P_DEFAULT) { unsigned crt_intmd_group; /* Get link creation property list */ @@ -2897,7 +2897,7 @@ H5L_move(const H5G_loc_t *src_loc, const char *src_name, const H5G_loc_t *dst_lo HDassert(dst_name && *dst_name); /* Check for flags present in creation property list */ - if(lcpl_id != H5P_DEFAULT && lcpl_id != H5P_LINK_CREATE_DEFAULT) { + if(lcpl_id != H5P_DEFAULT) { unsigned crt_intmd_group; if(NULL == (lc_plist = (H5P_genplist_t *)H5I_object(lcpl_id))) @@ -3178,11 +3178,11 @@ done: /*------------------------------------------------------------------------- - * Function: H5L_get_info + * Function: H5L_get_info * - * Purpose: Returns metadata about a link. + * Purpose: Returns metadata about a link. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: James Laird * Monday, April 17 2006 diff --git a/src/H5Lexternal.c b/src/H5Lexternal.c index 1b007b6..8a3e3e1 100644 --- a/src/H5Lexternal.c +++ b/src/H5Lexternal.c @@ -125,7 +125,7 @@ H5L__extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, size_t fname_len; /* Length of external link file name */ unsigned intent; /* File access permissions */ H5L_elink_cb_t cb_info; /* Callback info struct */ - hid_t fapl_id = -1; /* File access property list for external link's file */ + hid_t fapl_id = H5I_INVALID_HID; /* File access property list for external link's file */ void *ext_obj = NULL; /* External link's object */ hid_t ext_obj_id = H5I_INVALID_HID; /* ID for external link's object */ H5I_type_t opened_type; /* ID type of external link's object */ diff --git a/src/H5Lprivate.h b/src/H5Lprivate.h index ab68b84..0487557 100644 --- a/src/H5Lprivate.h +++ b/src/H5Lprivate.h @@ -68,7 +68,7 @@ typedef struct { hsize_t n; /* Offset of link within index */ /* Out */ - H5L_info2_t *linfo; /* Buffer to return to user */ + H5L_info2_t *linfo; /* Buffer to return to user */ } H5L_trav_gibi_t; /* User data for path traversal routine for getting name by index */ diff --git a/src/H5MF.c b/src/H5MF.c index 79a6c07..fac6620 100644 --- a/src/H5MF.c +++ b/src/H5MF.c @@ -100,7 +100,7 @@ static herr_t H5MF__close_shrink_eoa(H5F_t *f); static herr_t H5MF__get_free_sects(H5F_t *f, H5FS_t *fspace, H5MF_sect_iter_ud_t *sect_udata, size_t *nums); static hbool_t H5MF__fsm_type_is_self_referential(H5F_shared_t *f_sh, H5F_mem_page_t fsm_type); static hbool_t H5MF__fsm_is_self_referential(H5F_shared_t *f_sh, H5FS_t *fspace); -static herr_t H5MF__continue_alloc_fsm(H5F_shared_t *f_sh, H5FS_t *sm_hdr_fspace, H5FS_t *sm_sinfo_fspace, +static herr_t H5MF__continue_alloc_fsm(H5F_shared_t *f_sh, H5FS_t *sm_hdr_fspace, H5FS_t *sm_sinfo_fspace, H5FS_t *lg_hdr_fspace, H5FS_t *lg_sinfo_fspace, hbool_t *continue_alloc_fsm); /* Free-space type manager routines */ @@ -1137,10 +1137,11 @@ HDfprintf(stderr, "%s: Entering - alloc_type = %u, addr = %a, size = %Hu\n", FUN /* If it's metadata, check if the space to free intersects with the file's * metadata accumulator */ - if(H5FD_MEM_DRAW != alloc_type) + if(H5FD_MEM_DRAW != alloc_type) { /* Check if the space to free intersects with the file's metadata accumulator */ if(H5F__accum_free(f->shared, alloc_type, addr, size) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't check free space intersection w/metadata accumulator") + } /* end if */ /* Check if the free space manager for the file has been initialized */ if(!f->shared->fs_man[fs_type]) { diff --git a/src/H5MM.c b/src/H5MM.c index 33247ba..cceac4f 100644 --- a/src/H5MM.c +++ b/src/H5MM.c @@ -566,6 +566,31 @@ H5MM_xfree(void *mem) /*------------------------------------------------------------------------- + * Function: H5MM_xfree_const + * + * Purpose: H5MM_xfree() wrapper that handles const pointers without + * warnings. Used for freeing buffers that should be regarded + * as const in use but need to be freed when no longer needed. + * + * Return: Success: NULL + * Failure: never fails + * + *------------------------------------------------------------------------- + */ +void * +H5MM_xfree_const(const void *mem) +{ + /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + /* Cast through uintptr_t to de-const memory */ + H5MM_xfree((void *)(uintptr_t)mem); + + FUNC_LEAVE_NOAPI(NULL) +} /* end H5MM_xfree_const() */ + + +/*------------------------------------------------------------------------- * Function: H5MM_memcpy * * Purpose: Like memcpy(3) but with sanity checks on the parameters, diff --git a/src/H5MMprivate.h b/src/H5MMprivate.h index ea87db6..0787eb2 100644 --- a/src/H5MMprivate.h +++ b/src/H5MMprivate.h @@ -45,6 +45,7 @@ H5_DLL void *H5MM_realloc(void *mem, size_t size); H5_DLL char *H5MM_xstrdup(const char *s); H5_DLL char *H5MM_strdup(const char *s); H5_DLL void *H5MM_xfree(void *mem); +H5_DLL void *H5MM_xfree_const(const void *mem); H5_DLL void *H5MM_memcpy(void *dest, const void *src, size_t n); H5_DLL herr_t H5MM_get_alloc_stats(H5_alloc_stats_t *stats); #if defined H5_MEMORY_ALLOC_SANITY_CHECK diff --git a/src/H5Oattr.c b/src/H5Oattr.c index aeaebea..e38ef5c 100644 --- a/src/H5Oattr.c +++ b/src/H5Oattr.c @@ -238,6 +238,11 @@ H5O_attr_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, /* Go get the data */ if(attr->shared->data_size) { + /* Ensure that data size doesn't exceed buffer size, in case of + it's being corrupted in the file */ + if(attr->shared->data_size > p_size) + HGOTO_ERROR(H5E_RESOURCE, H5E_OVERFLOW, NULL, "data size exceeds buffer size") + if(NULL == (attr->shared->data = H5FL_BLK_MALLOC(attr_buf, attr->shared->data_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") H5MM_memcpy(attr->shared->data, p, attr->shared->data_size); diff --git a/src/H5Ochunk.c b/src/H5Ochunk.c index 9ce5a46..cb31cec 100644 --- a/src/H5Ochunk.c +++ b/src/H5Ochunk.c @@ -15,7 +15,7 @@ * * Created: H5Ochunk.c * Jul 13 2008 - * Quincey Koziol + * Quincey Koziol * * Purpose: Object header chunk routines. * @@ -84,7 +84,6 @@ H5FL_DEFINE(H5O_chunk_proxy_t); * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Jul 13 2008 * *------------------------------------------------------------------------- @@ -146,14 +145,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5O_chunk_protect + * Function: H5O__chunk_protect * * Purpose: Protect an object header chunk for modifications * * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Jul 17 2008 * *------------------------------------------------------------------------- @@ -227,7 +225,6 @@ done: * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Jul 17 2008 * *------------------------------------------------------------------------- @@ -278,7 +275,6 @@ done: * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * May 6 2010 * *------------------------------------------------------------------------- @@ -319,7 +315,6 @@ done: * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Jul 13 2008 * *------------------------------------------------------------------------- @@ -358,7 +353,7 @@ H5O__chunk_update_idx(H5F_t *f, H5O_t *oh, unsigned idx) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header chunk") done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O__chunk_update_idx() */ @@ -370,7 +365,6 @@ done: * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Jul 13 2008 * *------------------------------------------------------------------------- @@ -415,7 +409,6 @@ done: * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * July 13, 2008 * *------------------------------------------------------------------------- diff --git a/src/H5Ocont.c b/src/H5Ocont.c index ad54272..68a88e2 100644 --- a/src/H5Ocont.c +++ b/src/H5Ocont.c @@ -15,7 +15,7 @@ * * Created: H5Ocont.c * Aug 6 1997 - * Robb Matzke + * Robb Matzke * * Purpose: The object header continuation message. This * message is only generated and read from within @@ -83,7 +83,6 @@ H5FL_DEFINE(H5O_cont_t); * Failure: NULL * * Programmer: Robb Matzke - * matzke@llnl.gov * Aug 6 1997 * *------------------------------------------------------------------------- @@ -127,7 +126,6 @@ done: * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke - * matzke@llnl.gov * Aug 7 1997 * *------------------------------------------------------------------------- @@ -166,7 +164,6 @@ H5O__cont_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, co * Failure: zero * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu * Sep 6 2005 * *------------------------------------------------------------------------- @@ -253,7 +250,6 @@ done: * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke - * matzke@llnl.gov * Aug 6 1997 * *------------------------------------------------------------------------- diff --git a/src/H5Odbg.c b/src/H5Odbg.c index b8190ae..3c91cae 100644 --- a/src/H5Odbg.c +++ b/src/H5Odbg.c @@ -153,7 +153,7 @@ H5O__assert(const H5O_t *oh) /* Loop over all messages in object header */ for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { - uint8_t *curr_hdr; /* Start of current message header */ + uint8_t H5_ATTR_NDEBUG_UNUSED *curr_hdr; /* Start of current message header */ size_t curr_tot_size; /* Total size of current message (including header) */ curr_hdr = curr_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh); @@ -164,7 +164,7 @@ H5O__assert(const H5O_t *oh) free_space += curr_tot_size; else if(H5O_CONT_ID == curr_msg->type->id) { H5O_cont_t *cont = (H5O_cont_t *)curr_msg->native; - hbool_t found_chunk = FALSE; /* Found a chunk that matches */ + hbool_t H5_ATTR_NDEBUG_UNUSED found_chunk = FALSE; /* Found a chunk that matches */ HDassert(cont); diff --git a/src/H5Odeprec.c b/src/H5Odeprec.c index e43213d..aca0d59 100644 --- a/src/H5Odeprec.c +++ b/src/H5Odeprec.c @@ -189,10 +189,10 @@ H5O__iterate1_adapter(hid_t obj_id, const char *name, const H5O_info2_t *oinfo2, /* Set the native fields */ if(shim_data->fields & H5O_INFO_HDR) - HDmemcpy(&(oinfo.hdr), &(nat_info.hdr), sizeof(H5O_hdr_info_t)); + H5MM_memcpy(&(oinfo.hdr), &(nat_info.hdr), sizeof(H5O_hdr_info_t)); if(shim_data->fields & H5O_INFO_META_SIZE) { - HDmemcpy(&(oinfo.meta_size.obj), &(nat_info.meta_size.obj), sizeof(H5_ih_info_t)); - HDmemcpy(&(oinfo.meta_size.attr), &(nat_info.meta_size.attr), sizeof(H5_ih_info_t)); + H5MM_memcpy(&(oinfo.meta_size.obj), &(nat_info.meta_size.obj), sizeof(H5_ih_info_t)); + H5MM_memcpy(&(oinfo.meta_size.attr), &(nat_info.meta_size.attr), sizeof(H5_ih_info_t)); } } @@ -279,10 +279,10 @@ H5O__get_info_old(H5VL_object_t *vol_obj, H5VL_loc_params_t *loc_params, /* Set the native fields */ if(fields & H5O_INFO_HDR) - HDmemcpy(&(oinfo->hdr), &(nat_info.hdr), sizeof(H5O_hdr_info_t)); + H5MM_memcpy(&(oinfo->hdr), &(nat_info.hdr), sizeof(H5O_hdr_info_t)); if(fields & H5O_INFO_META_SIZE) { - HDmemcpy(&(oinfo->meta_size.obj), &(nat_info.meta_size.obj), sizeof(H5_ih_info_t)); - HDmemcpy(&(oinfo->meta_size.attr), &(nat_info.meta_size.attr), sizeof(H5_ih_info_t)); + H5MM_memcpy(&(oinfo->meta_size.obj), &(nat_info.meta_size.obj), sizeof(H5_ih_info_t)); + H5MM_memcpy(&(oinfo->meta_size.attr), &(nat_info.meta_size.attr), sizeof(H5_ih_info_t)); } /* end if */ } /* end if */ diff --git a/src/H5Olink.c b/src/H5Olink.c index 1f0c6c7..c27b51f 100644 --- a/src/H5Olink.c +++ b/src/H5Olink.c @@ -119,11 +119,12 @@ H5FL_DEFINE_STATIC(H5O_link_t); static void * H5O__link_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, - size_t H5_ATTR_UNUSED p_size, const uint8_t *p) + size_t p_size, const uint8_t *p) { H5O_link_t *lnk = NULL; /* Pointer to link message */ size_t len = 0; /* Length of a string in the message */ unsigned char link_flags; /* Flags for encoding link info */ + const uint8_t *p_end = p + p_size; /* End of the p buffer */ void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -199,6 +200,11 @@ H5O__link_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, if(len == 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "invalid name length") + /* Make sure that length doesn't exceed buffer size, which could occur + when the file is corrupted */ + if(p + len > p_end) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "name length causes read past end of buffer") + /* Get the link's name */ if(NULL == (lnk->name = (char *)H5MM_malloc(len + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") @@ -218,6 +224,12 @@ H5O__link_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, UINT16DECODE(p, len) if(len == 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "invalid link length") + + /* Make sure that length doesn't exceed buffer size, which could occur + when the file is corrupted */ + if(p + len > p_end) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "name length causes read past end of buffer") + if(NULL == (lnk->u.soft.name = (char *)H5MM_malloc((size_t)len + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") H5MM_memcpy(lnk->u.soft.name, p, len); @@ -238,6 +250,11 @@ H5O__link_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, lnk->u.ud.size = len; if(len > 0) { + /* Make sure that length doesn't exceed buffer size, which could + occur when the file is corrupted */ + if(p + len > p_end) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "name length causes read past end of buffer") + if(NULL == (lnk->u.ud.udata = H5MM_malloc((size_t)len))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") H5MM_memcpy(lnk->u.ud.udata, p, len); diff --git a/src/H5PB.c b/src/H5PB.c index 45f24e3..907fe82 100644 --- a/src/H5PB.c +++ b/src/H5PB.c @@ -24,21 +24,21 @@ /* Module Setup */ /****************/ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5F_FRIEND /* Suppress error about including H5Fpkg */ #include "H5PBmodule.h" /* This source code file is part of the H5PB module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* Files */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5PBpkg.h" /* File access */ -#include "H5SLprivate.h" /* Skip List */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5PBpkg.h" /* File access */ +#include "H5SLprivate.h" /* Skip List */ /****************/ @@ -153,7 +153,7 @@ H5FL_DEFINE_STATIC(H5PB_entry_t); /*------------------------------------------------------------------------- - * Function: H5PB_reset_stats + * Function: H5PB_reset_stats * * Purpose: This function was created without documentation. * What follows is my best understanding of Mohamad's intent. @@ -162,7 +162,7 @@ H5FL_DEFINE_STATIC(H5PB_entry_t); * * Return: Non-negative on success/Negative on failure * - * Programmer: Mohamad Chaarawi + * Programmer: Mohamad Chaarawi * *------------------------------------------------------------------------- */ @@ -190,7 +190,7 @@ H5PB_reset_stats(H5PB_t *page_buf) /*------------------------------------------------------------------------- - * Function: H5PB_get_stats + * Function: H5PB_get_stats * * Purpose: This function was created without documentation. * What follows is my best understanding of Mohamad's intent. @@ -202,9 +202,9 @@ H5PB_reset_stats(H5PB_t *page_buf) * --evictions: the number of metadata and raw data evictions from the page buffer layer * --bypasses: the number of metadata and raw data accesses that bypass the page buffer layer * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Mohamad Chaarawi + * Programmer: Mohamad Chaarawi * *------------------------------------------------------------------------- */ @@ -233,16 +233,16 @@ H5PB_get_stats(const H5PB_t *page_buf, unsigned accesses[2], unsigned hits[2], /*------------------------------------------------------------------------- - * Function: H5PB_print_stats() + * Function: H5PB_print_stats() * * Purpose: This function was created without documentation. * What follows is my best understanding of Mohamad's intent. * * Print out statistics collected for the page buffer layer. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Mohamad Chaarawi + * Programmer: Mohamad Chaarawi * *------------------------------------------------------------------------- */ @@ -278,13 +278,13 @@ H5PB_print_stats(const H5PB_t *page_buf) /*------------------------------------------------------------------------- - * Function: H5PB_create + * Function: H5PB_create * - * Purpose: Create and setup the PB on the file. + * Purpose: Create and setup the PB on the file. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Mohamad Chaarawi + * Programmer: Mohamad Chaarawi * *------------------------------------------------------------------------- */ @@ -314,7 +314,7 @@ H5PB_create(H5F_shared_t *f_sh, size_t size, unsigned page_buf_min_meta_perc, un /* Allocate the new page buffering structure */ if(NULL == (page_buf = H5FL_CALLOC(H5PB_t))) - HGOTO_ERROR(H5E_PAGEBUF, H5E_NOSPACE, FAIL, "memory allocation failed") + HGOTO_ERROR(H5E_PAGEBUF, H5E_NOSPACE, FAIL, "memory allocation failed") page_buf->max_size = size; H5_CHECKED_ASSIGN(page_buf->page_size, size_t, f_sh->fs_page_size, hsize_t); @@ -355,13 +355,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5PB__flush_cb + * Function: H5PB__flush_cb * - * Purpose: Callback to flush PB skiplist entries. + * Purpose: Callback to flush PB skiplist entries. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Mohamad Chaarawi + * Programmer: Mohamad Chaarawi * *------------------------------------------------------------------------- */ @@ -389,13 +389,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5PB_flush + * Function: H5PB_flush * - * Purpose: Flush/Free all the PB entries to the file. + * Purpose: Flush/Free all the PB entries to the file. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Mohamad Chaarawi + * Programmer: Mohamad Chaarawi * *------------------------------------------------------------------------- */ @@ -424,13 +424,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5PB__dest_cb + * Function: H5PB__dest_cb * - * Purpose: Callback to free PB skiplist entries. + * Purpose: Callback to free PB skiplist entries. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Mohamad Chaarawi + * Programmer: Mohamad Chaarawi * *------------------------------------------------------------------------- */ @@ -461,13 +461,13 @@ H5PB__dest_cb(void *item, void H5_ATTR_UNUSED *key, void *_op_data) /*------------------------------------------------------------------------- - * Function: H5PB_dest + * Function: H5PB_dest * - * Purpose: Flush and destroy the PB on the file if it exists. + * Purpose: Flush and destroy the PB on the file if it exists. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Mohamad Chaarawi + * Programmer: Mohamad Chaarawi * *------------------------------------------------------------------------- */ @@ -515,16 +515,16 @@ done: /*------------------------------------------------------------------------- - * Function: H5PB_add_new_page + * Function: H5PB_add_new_page * - * Purpose: Add a new page to the new page skip list. This is called + * Purpose: Add a new page to the new page skip list. This is called * from the MF layer when a new page is allocated to * indicate to the page buffer layer that a read of the page * from the file is not necessary since it's an empty page. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Mohamad Chaarawi + * Programmer: Mohamad Chaarawi * *------------------------------------------------------------------------- */ @@ -575,16 +575,16 @@ done: /*------------------------------------------------------------------------- - * Function: H5PB_update_entry + * Function: H5PB_update_entry * - * Purpose: In PHDF5, entries that are written by other processes and just + * Purpose: In PHDF5, entries that are written by other processes and just * marked clean by this process have to have their corresponding * pages updated if they exist in the page buffer. * This routine checks and update the pages. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Mohamad Chaarawi + * Programmer: Mohamad Chaarawi * *------------------------------------------------------------------------- */ @@ -675,14 +675,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5PB_read + * Function: H5PB_read * - * Purpose: Reads in the data from the page containing it if it exists + * Purpose: Reads in the data from the page containing it if it exists * in the PB cache; otherwise reads in the page through the VFD. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Mohamad Chaarawi + * Programmer: Mohamad Chaarawi * *------------------------------------------------------------------------- */ @@ -971,15 +971,15 @@ done: /*------------------------------------------------------------------------- - * Function: H5PB_write + * Function: H5PB_write * - * Purpose: Write data into the Page Buffer. If the page exists in the - * cache, update it; otherwise read it from disk, update it, and - * insert into cache. + * Purpose: Write data into the Page Buffer. If the page exists in the + * cache, update it; otherwise read it from disk, update it, and + * insert into cache. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Mohamad Chaarawi + * Programmer: Mohamad Chaarawi * *------------------------------------------------------------------------- */ @@ -1311,26 +1311,24 @@ done: /*------------------------------------------------------------------------- - * Function: H5PB__insert_entry() - * - * Purpose: ??? + * Function: H5PB__insert_entry() * - * This function was created without documentation. - * What follows is my best understanding of Mohamad's intent. + * Purpose: This function was created without documentation. + * What follows is my best understanding of Mohamad's intent. * - * Insert the supplied page into the page buffer, both the - * skip list and the LRU. + * Insert the supplied page into the page buffer, both the + * skip list and the LRU. * - * As best I can tell, this function imposes no limit on the - * number of entries in the page buffer beyond an assertion - * failure it the page count exceeds the limit. + * As best I can tell, this function imposes no limit on the + * number of entries in the page buffer beyond an assertion + * failure it the page count exceeds the limit. * * JRM -- 12/22/16 * * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Mohamad Chaarawi + * Programmer: Mohamad Chaarawi * *------------------------------------------------------------------------- */ @@ -1361,16 +1359,21 @@ done: /*------------------------------------------------------------------------- - * Function: H5PB__make_space() + * Function: H5PB__make_space() * - * Purpose: If necessary and if possible, evict a page from the page - * buffer to make space for the supplied page. Depending on - * the page buffer configuration and contents, and the page - * supplied this may or may not be possible. + * Purpose: This function was created without documentation. + * What follows is my best understanding of Mohamad's intent. * - * Return: Non-negative on success/Negative on failure + * If necessary and if possible, evict a page from the page + * buffer to make space for the supplied page. Depending on + * the page buffer configuration and contents, and the page + * supplied this may or may not be possible. * - * Programmer: Mohamad Chaarawi + * JRM -- 12/22/16 + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi * *------------------------------------------------------------------------- */ @@ -1459,17 +1462,16 @@ done: /*------------------------------------------------------------------------- - * Function: H5PB__write_entry() - * - * Purpose: ??? + * Function: H5PB__write_entry() * - * This function was created without documentation. - * What follows is my best understanding of Mohamad's intent. + * Purpose: ??? * + * This function was created without documentation. + * What follows is my best understanding of Mohamad's intent. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Mohamad Chaarawi + * Programmer: Mohamad Chaarawi * *------------------------------------------------------------------------- */ diff --git a/src/H5Pacpl.c b/src/H5Pacpl.c index 53e68fa..166a35f 100644 --- a/src/H5Pacpl.c +++ b/src/H5Pacpl.c @@ -33,7 +33,6 @@ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Ppkg.h" /* Property lists */ -#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index 7e49c4b..064a9b8 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -246,7 +246,7 @@ static hbool_t H5P_dcrt_def_layout_init_g = FALSE; static herr_t H5P__dcrt_reg_prop(H5P_genclass_t *pclass) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -421,13 +421,13 @@ H5P__dcrt_layout_enc(const void *value, void **_pp, size_t *size) for(u = 0; u < layout->storage.u.virt.list_nused; u++) { /* Source file name */ tmp_size = HDstrlen(layout->storage.u.virt.list[u].source_file_name) + (size_t)1; - (void)H5MM_memcpy(*pp, layout->storage.u.virt.list[u].source_file_name, tmp_size); + H5MM_memcpy(*pp, layout->storage.u.virt.list[u].source_file_name, tmp_size); *pp += tmp_size; *size += tmp_size; /* Source dataset name */ tmp_size = HDstrlen(layout->storage.u.virt.list[u].source_dset_name) + (size_t)1; - (void)H5MM_memcpy(*pp, layout->storage.u.virt.list[u].source_dset_name, tmp_size); + H5MM_memcpy(*pp, layout->storage.u.virt.list[u].source_dset_name, tmp_size); *pp += tmp_size; *size += tmp_size; @@ -597,14 +597,14 @@ H5P__dcrt_layout_dec(const void **_pp, void *value) tmp_size = HDstrlen((const char *)*pp) + 1; if(NULL == (tmp_layout.storage.u.virt.list[u].source_file_name = (char *)H5MM_malloc(tmp_size))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "unable to allocate memory for source file name") - (void)H5MM_memcpy(tmp_layout.storage.u.virt.list[u].source_file_name, *pp, tmp_size); + H5MM_memcpy(tmp_layout.storage.u.virt.list[u].source_file_name, *pp, tmp_size); *pp += tmp_size; /* Source dataset name */ tmp_size = HDstrlen((const char *)*pp) + 1; if(NULL == (tmp_layout.storage.u.virt.list[u].source_dset_name = (char *)H5MM_malloc(tmp_size))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "unable to allocate memory for source dataset name") - (void)H5MM_memcpy(tmp_layout.storage.u.virt.list[u].source_dset_name, *pp, tmp_size); + H5MM_memcpy(tmp_layout.storage.u.virt.list[u].source_dset_name, *pp, tmp_size); *pp += tmp_size; /* Source selection */ @@ -2375,7 +2375,7 @@ H5Pget_virtual_vspace(hid_t dcpl_id, size_t idx) /* Get the virtual space */ if(idx >= layout.storage.u.virt.list_nused) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid idx (out of range)") + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid index (out of range)") HDassert(layout.storage.u.virt.list_nused <= layout.storage.u.virt.list_nalloc); if(NULL == (space = H5S_copy(layout.storage.u.virt.list[idx].source_dset.virtual_select, FALSE, TRUE))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to copy virtual selection") @@ -2431,9 +2431,9 @@ H5Pget_virtual_srcspace(hid_t dcpl_id, size_t idx) if(H5D_VIRTUAL != layout.type) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a virtual storage layout") - /* Check idx */ + /* Check index */ if(idx >= layout.storage.u.virt.list_nused) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid idx (out of range)") + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid index (out of range)") HDassert(layout.storage.u.virt.list_nused <= layout.storage.u.virt.list_nalloc); /* Attempt to open source dataset and patch extent if extent status is not @@ -2537,7 +2537,7 @@ H5Pget_virtual_filename(hid_t dcpl_id, size_t idx, char *name/*out*/, /* Get the virtual filename */ if(idx >= layout.storage.u.virt.list_nused) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid idx (out of range)") + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid index (out of range)") HDassert(layout.storage.u.virt.list_nused <= layout.storage.u.virt.list_nalloc); HDassert(layout.storage.u.virt.list[idx].source_file_name); if(name && (size > 0)) @@ -2600,7 +2600,7 @@ H5Pget_virtual_dsetname(hid_t dcpl_id, size_t idx, char *name/*out*/, /* Get the virtual filename */ if(idx >= layout.storage.u.virt.list_nused) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid idx (out of range)") + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid index (out of range)") HDassert(layout.storage.u.virt.list_nused <= layout.storage.u.virt.list_nalloc); HDassert(layout.storage.u.virt.list[idx].source_dset_name); if(name && (size > 0)) diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index b157e5e..30b590f 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -1158,27 +1158,17 @@ H5P__file_driver_free(void *value) /* Copy the driver & info, if there is one */ if(info->driver_id > 0) { - if(info->driver_info) { - H5FD_class_t *driver; /* Pointer to driver */ - - /* Retrieve the driver for the ID */ - if(NULL == (driver = (H5FD_class_t *)H5I_object(info->driver_id))) - HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a driver ID") - /* Allow driver to free info or do it ourselves */ - if(driver->fapl_free) { - if((driver->fapl_free)((void *)info->driver_info) < 0) /* Casting away const OK -QAK */ - HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "driver info free request failed") - } /* end if */ - else - H5MM_xfree((void *)info->driver_info); /* Casting away const OK -QAK */ - } /* end if */ + /* Free the driver info, if it exists */ + if(info->driver_info) + if(H5FD_free_driver_info(info->driver_id, info->driver_info) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "driver info free request failed") /* Decrement reference count for driver */ if(H5I_dec_ref(info->driver_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTDEC, FAIL, "can't decrement reference count for driver ID") - } /* end if */ - } /* end if */ + } + } done: FUNC_LEAVE_NOAPI(ret_value) @@ -4489,7 +4479,8 @@ H5P_facc_mdc_log_location_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_ *------------------------------------------------------------------------- */ herr_t -H5Pset_evict_on_close(hid_t fapl_id, hbool_t evict_on_close) +H5Pset_evict_on_close(hid_t fapl_id, + hbool_t H5_ATTR_PARALLEL_UNUSED evict_on_close) { H5P_genplist_t *plist; /* property list pointer */ herr_t ret_value = SUCCEED; /* return value */ @@ -5407,7 +5398,7 @@ H5P_set_vol(H5P_genplist_t *plist, hid_t vol_id, const void *vol_info) /* Prepare the VOL connector property */ vol_prop.connector_id = vol_id; - vol_prop.connector_info = (void *)vol_info; + vol_prop.connector_info = vol_info; /* Set the connector ID & info property */ if(H5P_set(plist, H5F_ACS_VOL_CONN_NAME, &vol_prop) < 0) diff --git a/src/H5Pint.c b/src/H5Pint.c index 3cefb64..2e463b2 100644 --- a/src/H5Pint.c +++ b/src/H5Pint.c @@ -1481,7 +1481,7 @@ H5P__free_del_name_cb(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED NAME H5P__access_class PURPOSE - Internal routine to increment or decrement list & class dependancies on a + Internal routine to increment or decrement list & class dependencies on a property list class USAGE herr_t H5P__access_class(pclass,mod) diff --git a/src/H5Plapl.c b/src/H5Plapl.c index 3d00c12..8fdcc8b 100644 --- a/src/H5Plapl.c +++ b/src/H5Plapl.c @@ -344,7 +344,7 @@ H5P__lacc_elink_fapl_enc(const void *value, void **_pp, size_t *size) uint8_t **pp = (uint8_t **)_pp; H5P_genplist_t *fapl_plist; /* Pointer to property list */ hbool_t non_default_fapl = FALSE; /* Whether the FAPL is non-default */ - size_t fapl_size = 0; /* FAPL's encoded size */ + size_t fapl_size = 0; /* FAPL's encoded size */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -595,7 +595,7 @@ static herr_t H5P__lacc_elink_fapl_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { hid_t l_fapl_id; - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC diff --git a/src/H5Plcpl.c b/src/H5Plcpl.c index fc1a3b9..9c32552 100644 --- a/src/H5Plcpl.c +++ b/src/H5Plcpl.c @@ -119,7 +119,7 @@ static const unsigned H5L_def_intmd_group_g = H5L_CRT_INTERMEDIATE_GROUP_DEF; herr_t H5P_lcrt_reg_prop(H5P_genclass_t *pclass) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) diff --git a/src/H5Ptest.c b/src/H5Ptest.c index 114b37b..303fbf7 100644 --- a/src/H5Ptest.c +++ b/src/H5Ptest.c @@ -82,7 +82,7 @@ done: PURPOSE Routine to open a [copy of] a class with its full path name USAGE - hid_t H5P__open_class_name_test(path) + hid_t H5P__open_class_path_test(path) const char *path; IN: Full path name of class to open [copy of] RETURNS Success: ID of generic property class @@ -105,19 +105,19 @@ H5P__open_class_path_test(const char *path) FUNC_ENTER_PACKAGE /* Check arguments. */ - if(NULL == path || *path=='\0') + if (NULL == path || *path=='\0') HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid class path"); /* Open the property list class */ - if(NULL == (pclass = H5P__open_class_path(path))) + if (NULL == (pclass = H5P__open_class_path(path))) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, H5I_INVALID_HID, "unable to find class with full path"); /* Get an atom for the class */ - if((ret_value = H5I_register(H5I_GENPROP_CLS, pclass, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_GENPROP_CLS, pclass, TRUE)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize property list class"); done: - if(H5I_INVALID_HID == ret_value && pclass) + if (H5I_INVALID_HID == ret_value && pclass) H5P__close_class(pclass); FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Rint.c b/src/H5Rint.c index 30f3dbb..6dfbf2b 100644 --- a/src/H5Rint.c +++ b/src/H5Rint.c @@ -423,6 +423,10 @@ H5R__destroy(H5R_ref_priv_t *ref) HDassert(ref != NULL); + H5R_LOG_DEBUG("Destroying reference, filename=%s, obj_addr=%s, encode size=%u", + ref->info.obj.filename, H5R__print_token(ref->info.obj.token), + ref->encode_size); + H5MM_xfree(ref->info.obj.filename); ref->info.obj.filename = NULL; @@ -1028,6 +1032,10 @@ H5R__encode(const char *filename, const H5R_ref_priv_t *ref, unsigned char *buf, HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (unknown reference type)") } /* end switch */ + H5R_LOG_DEBUG("Encoded reference, filename=%s, obj_addr=%s, encode size=%u", + ref->info.obj.filename, H5R__print_token(ref->info.obj.token), + encode_size); + *nalloc = encode_size; done: diff --git a/src/H5S.c b/src/H5S.c index 9eda3ae..1390bdf 100644 --- a/src/H5S.c +++ b/src/H5S.c @@ -87,18 +87,18 @@ H5FL_ARR_DEFINE(hsize_t, H5S_MAX_RANK); /* Dataspace ID class */ static const H5I_class_t H5I_DATASPACE_CLS[1] = {{ - H5I_DATASPACE, /* ID class value */ - 0, /* Class flags */ - 2, /* # of reserved IDs for class */ - (H5I_free_t)H5S_close /* Callback routine for closing objects of this class */ + H5I_DATASPACE, /* ID class value */ + 0, /* Class flags */ + 2, /* # of reserved IDs for class */ + (H5I_free_t)H5S_close /* Callback routine for closing objects of this class */ }}; /* Dataspace selection iterator ID class */ static const H5I_class_t H5I_SPACE_SEL_ITER_CLS[1] = {{ - H5I_SPACE_SEL_ITER, /* ID class value */ - 0, /* Class flags */ - 0, /* # of reserved IDs for class */ - (H5I_free_t)H5S_sel_iter_close /* Callback routine for closing objects of this class */ + H5I_SPACE_SEL_ITER, /* ID class value */ + 0, /* Class flags */ + 0, /* # of reserved IDs for class */ + (H5I_free_t)H5S_sel_iter_close /* Callback routine for closing objects of this class */ }}; @@ -106,7 +106,7 @@ static const H5I_class_t H5I_SPACE_SEL_ITER_CLS[1] = {{ static hbool_t H5S_top_package_initialize_s = FALSE; - + /*-------------------------------------------------------------------------- NAME H5S__init_package -- Initialize interface-specific information @@ -126,11 +126,11 @@ H5S__init_package(void) /* Initialize the atom group for the dataspace IDs */ if(H5I_register_type(H5I_DATASPACE_CLS) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize dataspace ID class") + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize dataspace ID class") /* Initialize the atom group for the dataspace selction iterator IDs */ if(H5I_register_type(H5I_SPACE_SEL_ITER_CLS) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize dataspace selection iterator ID class") + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize dataspace selection iterator ID class") /* Mark "top" of interface as initialized, too */ H5S_top_package_initialize_s = TRUE; @@ -139,7 +139,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__init_package() */ - + /*-------------------------------------------------------------------------- NAME H5S_top_term_package @@ -161,22 +161,22 @@ done: int H5S_top_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR if(H5S_top_package_initialize_s) { - if(H5I_nmembers(H5I_DATASPACE) > 0) { - (void)H5I_clear_type(H5I_DATASPACE, FALSE, FALSE); + if(H5I_nmembers(H5I_DATASPACE) > 0) { + (void)H5I_clear_type(H5I_DATASPACE, FALSE, FALSE); n++; /*H5I*/ - } /* end if */ + } /* end if */ - if(H5I_nmembers(H5I_SPACE_SEL_ITER) > 0) { - (void)H5I_clear_type(H5I_SPACE_SEL_ITER, FALSE, FALSE); + if(H5I_nmembers(H5I_SPACE_SEL_ITER) > 0) { + (void)H5I_clear_type(H5I_SPACE_SEL_ITER, FALSE, FALSE); n++; /*H5I*/ - } /* end if */ + } /* end if */ - /* Mark "top" of interface as closed */ + /* Mark "top" of interface as closed */ if(0 == n) H5S_top_package_initialize_s = FALSE; } /* end if */ @@ -184,7 +184,7 @@ H5S_top_term_package(void) FUNC_LEAVE_NOAPI(n) } /* end H5S_top_term_package() */ - + /*-------------------------------------------------------------------------- NAME H5S_term_package @@ -208,7 +208,7 @@ H5S_top_term_package(void) int H5S_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -224,7 +224,7 @@ H5S_term_package(void) /* Destroy the dataspace selection iterator object id group */ n += (H5I_dec_type_ref(H5I_SPACE_SEL_ITER) > 0); - /* Mark interface as closed */ + /* Mark interface as closed */ if(0 == n) H5_PKG_INIT_VAR = FALSE; } /* end if */ @@ -233,7 +233,7 @@ H5S_term_package(void) } /* end H5S_term_package() */ - + /*-------------------------------------------------------------------------- NAME H5S_get_validiated_dataspace @@ -277,13 +277,13 @@ H5S_get_validated_dataspace(hid_t space_id, const H5S_t **space) /* Check for valid selection */ if(H5S_SELECT_VALID(*space) != TRUE) HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection + offset not within extent") - } /* end else */ + } done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_get_validated_dataspace() */ - + /*-------------------------------------------------------------------------- NAME H5S_create @@ -361,7 +361,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_create() */ - + /*-------------------------------------------------------------------------- NAME H5Screate @@ -408,16 +408,16 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Screate() */ - + /*------------------------------------------------------------------------- * Function: H5S__extent_release * - * Purpose: Releases all memory associated with a dataspace extent. + * Purpose: Releases all memory associated with a dataspace extent. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol - * Thursday, July 23, 1998 + * Programmer: Quincey Koziol + * Thursday, July 23, 1998 * *------------------------------------------------------------------------- */ @@ -436,19 +436,22 @@ H5S__extent_release(H5S_extent_t *extent) extent->max = H5FL_ARR_FREE(hsize_t, extent->max); } /* end if */ + extent->rank = 0; + extent->nelem = 0; + FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__extent_release() */ - + /*------------------------------------------------------------------------- * Function: H5S_close * - * Purpose: Releases all memory associated with a dataspace. + * Purpose: Releases all memory associated with a dataspace. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke - * Tuesday, December 9, 1997 + * Programmer: Robb Matzke + * Tuesday, December 9, 1997 * *------------------------------------------------------------------------- */ @@ -480,16 +483,16 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_close() */ - + /*------------------------------------------------------------------------- * Function: H5Sclose * - * Purpose: Release access to a dataspace object. + * Purpose: Release access to a dataspace object. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke - * Tuesday, December 9, 1997 + * Programmer: Robb Matzke + * Tuesday, December 9, 1997 * *------------------------------------------------------------------------- */ @@ -513,69 +516,70 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Sclose() */ - + /*------------------------------------------------------------------------- * Function: H5Scopy * - * Purpose: Copies a dataspace. + * Purpose: Copies a dataspace. + * + * Return: Success: ID of the new dataspace * - * Return: Success: ID of the new dataspace - * Failure: Negative + * Failure: H5I_INVALID_HID * - * Programmer: Robb Matzke - * Friday, January 30, 1998 + * Programmer: Robb Matzke + * Friday, January 30, 1998 * *------------------------------------------------------------------------- */ hid_t H5Scopy(hid_t space_id) { - H5S_t *src; - H5S_t *dst = NULL; - hid_t ret_value; + H5S_t *src = NULL; + H5S_t *dst = NULL; + hid_t ret_value = H5I_INVALID_HID; - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", space_id); /* Check args */ if(NULL == (src = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace") /* Copy */ if(NULL == (dst = H5S_copy(src, FALSE, TRUE))) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to copy dataspace") + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, H5I_INVALID_HID, "unable to copy dataspace") /* Atomize */ if((ret_value = H5I_register (H5I_DATASPACE, dst, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom") + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataspace atom") done: if(ret_value < 0) if(dst && H5S_close(dst) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, H5I_INVALID_HID, "unable to release dataspace") FUNC_LEAVE_API(ret_value) } /* end H5Scopy() */ - + /*------------------------------------------------------------------------- * Function: H5Sextent_copy * - * Purpose: Copies a dataspace extent. + * Purpose: Copies a dataspace extent. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol - * Thursday, July 23, 1998 + * Programmer: Quincey Koziol + * Thursday, July 23, 1998 * *------------------------------------------------------------------------- */ herr_t H5Sextent_copy(hid_t dst_id,hid_t src_id) { - H5S_t *src; - H5S_t *dst; - herr_t ret_value = SUCCEED; + H5S_t *src; + H5S_t *dst; + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE2("e", "ii", dst_id, src_id); @@ -594,7 +598,7 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Sextent_copy() */ - + /*------------------------------------------------------------------------- * Function: H5S_extent_copy * @@ -631,16 +635,16 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_extent_copy() */ - + /*------------------------------------------------------------------------- * Function: H5S__extent_copy_real * - * Purpose: Copies a dataspace extent + * Purpose: Copies a dataspace extent * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol - * Wednesday, June 3, 1998 + * Programmer: Quincey Koziol + * Wednesday, June 3, 1998 * *------------------------------------------------------------------------- */ @@ -700,29 +704,30 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__extent_copy_real() */ - + /*------------------------------------------------------------------------- * Function: H5S_copy * - * Purpose: Copies a dataspace, by copying the extent and selection through - * H5S_extent_copy and H5S_select_copy. If the SHARE_SELECTION flag - * is set, then the selection can be shared between the source and - * destination dataspaces. (This should only occur in situations - * where the destination dataspace will immediately change to a new - * selection) + * Purpose: Copies a dataspace, by copying the extent and selection through + * H5S_extent_copy and H5S_select_copy. If the SHARE_SELECTION flag + * is set, then the selection can be shared between the source and + * destination dataspaces. (This should only occur in situations + * where the destination dataspace will immediately change to a new + * selection) + * + * Return: Success: A pointer to a new copy of SRC * - * Return: Success: A pointer to a new copy of SRC - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke - * Thursday, December 4, 1997 + * Programmer: Robb Matzke + * Thursday, December 4, 1997 * *------------------------------------------------------------------------- */ H5S_t * H5S_copy(const H5S_t *src, hbool_t share_selection, hbool_t copy_max) { - H5S_t *dst = NULL; + H5S_t *dst = NULL; H5S_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -749,17 +754,18 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_copy() */ - + /*------------------------------------------------------------------------- * Function: H5S_get_simple_extent_npoints * - * Purpose: Determines how many data points a dataset extent has. + * Purpose: Determines how many data points a dataset extent has. * - * Return: Success: Number of data points in the dataset extent. - * Failure: negative + * Return: Success: Number of data points in the dataset extent. * - * Programmer: Robb Matzke - * Tuesday, December 9, 1997 + * Failure: Negative + * + * Programmer: Robb Matzke + * Tuesday, December 9, 1997 * * Note: This routine participates in the "Inlining C function pointers" * pattern, don't call it directly, use the appropriate macro @@ -784,17 +790,17 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_get_simple_extent_npoints() */ - + /*------------------------------------------------------------------------- * Function: H5Sget_simple_extent_npoints * - * Purpose: Determines how many data points a dataset extent has. + * Purpose: Determines how many data points a dataset extent has. * - * Return: Success: Number of data points in the dataset. - * Failure: negative + * Return: Success: Number of data points in the dataset. + * Failure: Negative * - * Programmer: Robb Matzke - * Tuesday, December 9, 1997 + * Programmer: Robb Matzke + * Tuesday, December 9, 1997 * *------------------------------------------------------------------------- */ @@ -802,7 +808,7 @@ hssize_t H5Sget_simple_extent_npoints(hid_t space_id) { H5S_t *ds; - hssize_t ret_value; + hssize_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE1("Hs", "i", space_id); @@ -817,22 +823,22 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Sget_simple_extent_npoints() */ - + /*------------------------------------------------------------------------- * Function: H5S_get_npoints_max * - * Purpose: Determines the maximum number of data points a dataspace may - * have. If the `max' array is null then the maximum number of - * data points is the same as the current number of data points - * without regard to the hyperslab. If any element of the `max' - * array is zero then the maximum possible size is returned. + * Purpose: Determines the maximum number of data points a dataspace may + * have. If the `max' array is null then the maximum number of + * data points is the same as the current number of data points + * without regard to the hyperslab. If any element of the `max' + * array is zero then the maximum possible size is returned. * - * Return: Success: Maximum number of data points the dataspace - * may have. - * Failure: 0 + * Return: Success: Maximum number of data points the dataspace + * may have. + * Failure: 0 * - * Programmer: Robb Matzke - * Tuesday, December 9, 1997 + * Programmer: Robb Matzke + * Tuesday, December 9, 1997 * *------------------------------------------------------------------------- */ @@ -840,7 +846,7 @@ hsize_t H5S_get_npoints_max(const H5S_t *ds) { unsigned u; - hsize_t ret_value = 0; /* Return value */ + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(0) @@ -862,11 +868,11 @@ H5S_get_npoints_max(const H5S_t *ds) if(H5S_UNLIMITED == ds->extent.max[u]) { ret_value = HSIZET_MAX; break; - } /* end if */ + } else ret_value *= ds->extent.max[u]; - } /* end for */ - } /* end if */ + } + } else for(ret_value = 1, u = 0; u < ds->extent.rank; u++) ret_value *= ds->extent.size[u]; @@ -876,38 +882,38 @@ H5S_get_npoints_max(const H5S_t *ds) default: HDassert("unknown dataspace class" && 0); HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, 0, "internal error (unknown dataspace class)") - } /* end switch */ + } done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_get_npoints_max() */ - + /*------------------------------------------------------------------------- * Function: H5Sget_simple_extent_ndims * - * Purpose: Determines the dimensionality of a dataspace. + * Purpose: Determines the dimensionality of a dataspace. * - * Return: Success: The number of dimensions in a dataspace. - * Failure: Negative + * Return: Success: The number of dimensions in a dataspace. + * Failure: Negative * - * Programmer: Robb Matzke - * Thursday, December 11, 1997 + * Programmer: Robb Matzke + * Thursday, December 11, 1997 * *------------------------------------------------------------------------- */ int H5Sget_simple_extent_ndims(hid_t space_id) { - H5S_t *ds; - int ret_value; /* Return value */ + H5S_t *ds; + int ret_value = -1; - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API((-1)) H5TRACE1("Is", "i", space_id); /* Check args */ if(NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not a dataspace") ret_value = (int)H5S_GET_EXTENT_NDIMS(ds); @@ -915,18 +921,19 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Sget_simple_extent_ndims() */ - + /*------------------------------------------------------------------------- * Function: H5S_get_simple_extent_ndims * - * Purpose: Returns the number of dimensions in a dataspace. + * Purpose: Returns the number of dimensions in a dataspace. + * + * Return: Success: Non-negative number of dimensions. + * Zero implies a scalar. * - * Return: Success: Non-negative number of dimensions. Zero - * implies a scalar. - * Failure: Negative + * Failure: Negative * - * Programmer: Robb Matzke - * Thursday, December 11, 1997 + * Programmer: Robb Matzke + * hursday, December 11, 1997 * * Note: This routine participates in the "Inlining C function pointers" * pattern, don't call it directly, use the appropriate macro @@ -937,7 +944,7 @@ done: int H5S_get_simple_extent_ndims(const H5S_t *ds) { - int ret_value = -1; /* Return value */ + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -961,35 +968,35 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_get_simple_extent_ndims() */ - + /*------------------------------------------------------------------------- * Function: H5Sget_simple_extent_dims * - * Purpose: Returns the size and maximum sizes in each dimension of - * a dataspace DS through the DIMS and MAXDIMS arguments. + * Purpose: Returns the size and maximum sizes in each dimension of + * a dataspace DS through the DIMS and MAXDIMS arguments. * - * Return: Success: Number of dimensions, the same value as - * returned by H5Sget_simple_extent_ndims(). - * Failure: Negative + * Return: Success: Number of dimensions, the same value as + * returned by H5Sget_simple_extent_ndims(). * - * Programmer: Robb Matzke - * Thursday, December 11, 1997 + * Failure: Negative + * + * Programmer: Robb Matzke + * Thursday, December 11, 1997 * *------------------------------------------------------------------------- */ int -H5Sget_simple_extent_dims(hid_t space_id, hsize_t dims[]/*out*/, - hsize_t maxdims[]/*out*/) +H5Sget_simple_extent_dims(hid_t space_id, hsize_t dims[]/*out*/, hsize_t maxdims[]/*out*/) { - H5S_t *ds; - int ret_value; /* Return value */ + H5S_t *ds; + int ret_value = -1; - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API((-1)) H5TRACE3("Is", "ixx", space_id, dims, maxdims); /* Check args */ if(NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not a dataspace") ret_value = H5S_get_simple_extent_dims(ds, dims, maxdims); @@ -997,26 +1004,26 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Sget_simple_extent_dims() */ - + /*------------------------------------------------------------------------- * Function: H5S_extent_get_dims * - * Purpose: Returns the size in each dimension of a dataspace. This - * function may not be meaningful for all types of dataspaces. + * Purpose: Returns the size in each dimension of a dataspace. This + * function may not be meaningful for all types of dataspaces. * - * Return: Success: Number of dimensions. Zero implies scalar. - * Failure: Negative + * Return: Success: Number of dimensions. Zero implies scalar. + * Failure: Negative * - * Programmer: Quincey Koziol - * Tuesday, June 30, 2009 + * Programmer: Quincey Koziol + * Tuesday, June 30, 2009 * *------------------------------------------------------------------------- */ int H5S_extent_get_dims(const H5S_extent_t *ext, hsize_t dims[], hsize_t max_dims[]) { - int i; /* Local index variable */ - int ret_value = -1; /* Return value */ + int i; /* Local index variable */ + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1053,25 +1060,25 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_extent_get_dims() */ - + /*------------------------------------------------------------------------- * Function: H5S_get_simple_extent_dims * - * Purpose: Returns the size in each dimension of a dataspace. This - * function may not be meaningful for all types of dataspaces. + * Purpose: Returns the size in each dimension of a dataspace. This + * function may not be meaningful for all types of dataspaces. * - * Return: Success: Number of dimensions. Zero implies scalar. - * Failure: Negative + * Return: Success: Number of dimensions. Zero implies scalar. + * Failure: Negative * - * Programmer: Robb Matzke - * Thursday, December 11, 1997 + * Programmer: Robb Matzke + * Thursday, December 11, 1997 * *------------------------------------------------------------------------- */ int H5S_get_simple_extent_dims(const H5S_t *ds, hsize_t dims[], hsize_t max_dims[]) { - int ret_value = -1; /* Return value */ + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1086,17 +1093,17 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_get_simple_extent_dims() */ - + /*------------------------------------------------------------------------- * Function: H5S_write * - * Purpose: Updates a dataspace by writing a message to an object - * header. + * Purpose: Updates a dataspace by writing a message to an object + * header. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke - * Tuesday, December 9, 1997 + * Programmer: Robb Matzke + * Tuesday, December 9, 1997 * *------------------------------------------------------------------------- */ @@ -1120,17 +1127,16 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_write() */ - + /*------------------------------------------------------------------------- * Function: H5S_append * - * Purpose: Updates a dataspace by adding a message to an object - * header. + * Purpose: Updates a dataspace by adding a message to an object header. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol - * Tuesday, December 31, 2002 + * Programmer: Quincey Koziol + * Tuesday, December 31, 2002 * *------------------------------------------------------------------------- */ @@ -1154,24 +1160,25 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_append() */ - + /*------------------------------------------------------------------------- * Function: H5S_read * - * Purpose: Reads the dataspace from an object header. + * Purpose: Reads the dataspace from an object header. + * + * Return: Success: Pointer to a new dataspace. * - * Return: Success: Pointer to a new dataspace. - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke - * Tuesday, December 9, 1997 + * Programmer: Robb Matzke + * Tuesday, December 9, 1997 * *------------------------------------------------------------------------- */ H5S_t * H5S_read(const H5O_loc_t *loc) { - H5S_t *ds = NULL; /* Dataspace to return */ + H5S_t *ds = NULL; /* Dataspace to return */ H5S_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1200,7 +1207,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_read() */ - + /*-------------------------------------------------------------------------- NAME H5S__is_simple @@ -1232,7 +1239,7 @@ H5S__is_simple(const H5S_t *sdim) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__is_simple() */ - + /*-------------------------------------------------------------------------- NAME H5Sis_simple @@ -1240,7 +1247,7 @@ H5S__is_simple(const H5S_t *sdim) Check if a dataspace is simple USAGE htri_t H5Sis_simple(space_id) - hid_t space_id; IN: ID of dataspace object to query + hid_t space_id; IN: ID of dataspace object to query RETURNS TRUE/FALSE/FAIL DESCRIPTION @@ -1250,15 +1257,15 @@ H5S__is_simple(const H5S_t *sdim) htri_t H5Sis_simple(hid_t space_id) { - H5S_t *space; /* Dataspace to check */ - htri_t ret_value; /* Return value */ + H5S_t *space; /* Dataspace to check */ + htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("t", "i", space_id); /* Check args and all the boring stuff. */ if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a dataspace") + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a dataspace") ret_value = H5S__is_simple(space); @@ -1266,7 +1273,7 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Sis_simple() */ - + /*-------------------------------------------------------------------------- NAME H5Sset_extent_simple @@ -1274,11 +1281,11 @@ done: Sets the size of a simple dataspace USAGE herr_t H5Sset_extent_simple(space_id, rank, dims, max) - hid_t space_id; IN: Dataspace object to query - int rank; IN: # of dimensions for the dataspace - const size_t *dims; IN: Size of each dimension for the dataspace - const size_t *max; IN: Maximum size of each dimension for the - dataspace + hid_t space_id; IN: Dataspace object to query + int rank; IN: # of dimensions for the dataspace + const size_t *dims; IN: Size of each dimension for the dataspace + const size_t *max; IN: Maximum size of each dimension for the + dataspace RETURNS Non-negative on success/Negative on failure DESCRIPTION @@ -1297,8 +1304,8 @@ herr_t H5Sset_extent_simple(hid_t space_id, int rank, const hsize_t dims[/*rank*/], const hsize_t max[/*rank*/]) { - H5S_t *space; /* Dataspace to modify */ - int u; /* Local counting variable */ + H5S_t *space; /* Dataspace to modify */ + int u; /* Local counting variable */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1321,26 +1328,25 @@ H5Sset_extent_simple(hid_t space_id, int rank, const hsize_t dims[/*rank*/], for(u = 0; u < rank; u++) if(max[u] != H5S_UNLIMITED && max[u] < dims[u]) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid maximum dimension size") - } /* end if */ + } /* Do it */ if(H5S_set_extent_simple(space, (unsigned)rank, dims, max) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to set simple extent") + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to set simple extent") done: FUNC_LEAVE_API(ret_value) } /* end H5Sset_extent_simple() */ - + /*------------------------------------------------------------------------- * Function: H5S_set_extent_simple * - * Purpose: This is where the real work happens for - * H5Sset_extent_simple(). + * Purpose: This is where the real work happens for H5Sset_extent_simple(). * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, July 8, 1998 * *------------------------------------------------------------------------- @@ -1361,10 +1367,10 @@ H5S_set_extent_simple(H5S_t *space, unsigned rank, const hsize_t *dims, if(H5S__extent_release(&space->extent) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "failed to release previous dataspace extent") - if(rank == 0) { /* scalar variable */ + if(rank == 0) { /* scalar variable */ space->extent.type = H5S_SCALAR; space->extent.nelem = 1; - space->extent.rank = 0; /* set to scalar rank */ + space->extent.rank = 0; /* set to scalar rank */ } /* end if */ else { hsize_t nelem; /* Number of elements in extent */ @@ -1407,91 +1413,90 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_set_extent_simple() */ - + /*------------------------------------------------------------------------- * Function: H5Screate_simple * - * Purpose: Creates a new simple dataspace object and opens it for - * access. The DIMS argument is the size of the simple dataset - * and the MAXDIMS argument is the upper limit on the size of - * the dataset. MAXDIMS may be the null pointer in which case - * the upper limit is the same as DIMS. If an element of - * MAXDIMS is H5S_UNLIMITED then the corresponding dimension is - * unlimited, otherwise no element of MAXDIMS should be smaller - * than the corresponding element of DIMS. + * Purpose: Creates a new simple dataspace object and opens it for + * access. The DIMS argument is the size of the simple dataset + * and the MAXDIMS argument is the upper limit on the size of + * the dataset. MAXDIMS may be the null pointer in which case + * the upper limit is the same as DIMS. If an element of + * MAXDIMS is H5S_UNLIMITED then the corresponding dimension is + * unlimited, otherwise no element of MAXDIMS should be smaller + * than the corresponding element of DIMS. + * + * Return: Success: The ID for the new simple dataspace object. * - * Return: Success: The ID for the new simple dataspace object. - * Failure: Negative + * Failure: H5I_INVALID_HID * - * Programmer: Quincey Koziol - * Tuesday, January 27, 1998 + * Programmer: Quincey Koziol + * Tuesday, January 27, 1998 * *------------------------------------------------------------------------- */ hid_t -H5Screate_simple(int rank, const hsize_t dims[/*rank*/], - const hsize_t maxdims[/*rank*/]) +H5Screate_simple(int rank, const hsize_t dims[/*rank*/], const hsize_t maxdims[/*rank*/]) { - H5S_t *space = NULL; - int i; - hid_t ret_value; /* Return value */ + H5S_t *space = NULL; + int i; + hid_t ret_value = H5I_INVALID_HID; - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "Is*[a0]h*[a0]h", rank, dims, maxdims); /* Check arguments */ if(rank < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dimensionality cannot be negative") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "dimensionality cannot be negative") if(rank > H5S_MAX_RANK) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dimensionality is too large") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "dimensionality is too large") /* We allow users to use this function to create scalar or null dataspace. * Check DIMS isn't set when the RANK is 0. */ if(!dims && rank != 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid dataspace information") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid dataspace information") /* Check whether the current dimensions are valid */ for(i = 0; i < rank; i++) { if(H5S_UNLIMITED == dims[i]) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "current dimension must have a specific size, not H5S_UNLIMITED") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "current dimension must have a specific size, not H5S_UNLIMITED") if(maxdims && H5S_UNLIMITED != maxdims[i] && maxdims[i]extent))) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy object") + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy object") if(H5S__extent_release(extent) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTDELETE, NULL, "can't release previous dataspace") extent = H5FL_FREE(H5S_extent_t, extent); @@ -1753,17 +1754,18 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_decode() */ - + /*------------------------------------------------------------------------- * Function: H5S_get_simple_extent_type * - * Purpose: Internal function for retrieving the type of extent for a dataspace object + * Purpose: Internal function for retrieving the type of extent for a dataspace object + * + * Return: Success: The class of the dataspace object * - * Return: Success: The class of the dataspace object - * Failure: N5S_NO_CLASS + * Failure: N5S_NO_CLASS * - * Programmer: Quincey Koziol - * Thursday, September 28, 2000 + * Programmer: Quincey Koziol + * Thursday, September 28, 2000 * * Note: This routine participates in the "Inlining C function pointers" * pattern, don't call it directly, use the appropriate macro @@ -1774,7 +1776,7 @@ done: H5S_class_t H5S_get_simple_extent_type(const H5S_t *space) { - H5S_class_t ret_value = H5S_NO_CLASS; /* Return value */ + H5S_class_t ret_value = H5S_NO_CLASS; /* Return value */ FUNC_ENTER_NOAPI(H5S_NO_CLASS) @@ -1786,25 +1788,26 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_get_simple_extent_type() */ - + /*------------------------------------------------------------------------- * Function: H5Sget_simple_extent_type * - * Purpose: Retrieves the type of extent for a dataspace object + * Purpose: Retrieves the type of extent for a dataspace object * - * Return: Success: The class of the dataspace object - * Failure: N5S_NO_CLASS + * Return: Success: The class of the dataspace object * - * Programmer: Quincey Koziol - * Thursday, July 23, 1998 + * Failure: N5S_NO_CLASS + * + * Programmer: Quincey Koziol + * Thursday, July 23, 1998 * *------------------------------------------------------------------------- */ H5S_class_t H5Sget_simple_extent_type(hid_t sid) { - H5S_t *space; - H5S_class_t ret_value; /* Return value */ + H5S_t *space; + H5S_class_t ret_value; /* Return value */ FUNC_ENTER_API(H5S_NO_CLASS) H5TRACE1("Sc", "i", sid); @@ -1819,7 +1822,7 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Sget_simple_extent_type() */ - + /*-------------------------------------------------------------------------- NAME H5Sset_extent_none @@ -1827,18 +1830,18 @@ done: Resets the extent of a dataspace back to "none" USAGE herr_t H5Sset_extent_none(space_id) - hid_t space_id; IN: Dataspace object to reset + hid_t space_id; IN: Dataspace object to reset RETURNS Non-negative on success/Negative on failure DESCRIPTION - This function resets the type of a dataspace back to "none" with no + This function resets the type of a dataspace to H5S_NULL with no extent information stored for the dataspace. --------------------------------------------------------------------------*/ herr_t H5Sset_extent_none(hid_t space_id) { - H5S_t *space; /* Dataspace to modify */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_t *space; /* Dataspace to modify */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", space_id); @@ -1851,22 +1854,21 @@ H5Sset_extent_none(hid_t space_id) if(H5S__extent_release(&space->extent) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTDELETE, FAIL, "can't release previous dataspace") - space->extent.type = H5S_NO_CLASS; + space->extent.type = H5S_NULL; done: FUNC_LEAVE_API(ret_value) } /* end H5Sset_extent_none() */ - + /*------------------------------------------------------------------------- * Function: H5S_set_extent * * Purpose: Modify the dimensions of a dataspace. * - * Return: Success: Non-negative - * Failure: Negative + * Return: TRUE/FALSE/FAIL * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * Programmer: Pedro Vicente * March 13, 2002 * *------------------------------------------------------------------------- @@ -1904,7 +1906,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_set_extent() */ - + /*------------------------------------------------------------------------- * Function: H5S_has_extent * @@ -1937,7 +1939,7 @@ H5S_has_extent(const H5S_t *ds) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_has_extent() */ - + /*------------------------------------------------------------------------- * Function: H5S_set_extent_real * @@ -1946,7 +1948,7 @@ H5S_has_extent(const H5S_t *ds) * Return: Success: Non-negative * Failure: Negative * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * Programmer: Pedro Vicente * March 13, 2002 * *------------------------------------------------------------------------- @@ -1984,25 +1986,27 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_set_extent_real() */ - + /*------------------------------------------------------------------------- * Function: H5Sextent_equal * - * Purpose: Determines if two dataspace extents are equal. + * Purpose: Determines if two dataspace extents are equal. + * + * Return: Success: TRUE if equal, FALSE if unequal * - * Return: Success: TRUE if equal, FALSE if unequal - * Failure: Negative + * Failure: FAIL * - * Programmer: Quincey Koziol - * Monday, October 24, 2005 + * Programmer: Quincey Koziol + * Monday, October 24, 2005 * *------------------------------------------------------------------------- */ htri_t H5Sextent_equal(hid_t space1_id, hid_t space2_id) { - const H5S_t *ds1, *ds2; /* Dataspaces to compare */ - htri_t ret_value; /* Return value */ + const H5S_t *ds1; /* Dataspaces to compare */ + const H5S_t *ds2; + htri_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE2("t", "ii", space1_id, space2_id); @@ -2010,17 +2014,17 @@ H5Sextent_equal(hid_t space1_id, hid_t space2_id) /* check args */ if(NULL == (ds1 = (const H5S_t *)H5I_object_verify(space1_id, H5I_DATASPACE)) || NULL == (ds2 = (const H5S_t *)H5I_object_verify(space2_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") /* Check dataspaces for extent's equality */ if((ret_value = H5S_extent_equal(ds1, ds2)) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOMPARE, FAIL, "dataspace comparison failed") + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOMPARE, FAIL, "dataspace comparison failed") done: FUNC_LEAVE_API(ret_value) } /* end H5Sextent_equal() */ - + /*-------------------------------------------------------------------------- NAME H5S_extent_equal @@ -2081,17 +2085,17 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_extent_equal() */ - + /*------------------------------------------------------------------------- * Function: H5S_extent_nelem * - * Purpose: Determines how many elements a dataset extent describes. + * Purpose: Determines how many elements a dataset extent describes. * - * Return: Success: Number of data points in the dataset extent. - * Failure: negative + * Return: Success: Number of data points in the dataset extent. + * Failure: Negative * - * Programmer: Quincey Koziol - * Thursday, November 30, 2006 + * Programmer: Quincey Koziol + * Thursday, November 30, 2006 * *------------------------------------------------------------------------- */ @@ -2107,7 +2111,7 @@ H5S_extent_nelem(const H5S_extent_t *ext) FUNC_LEAVE_NOAPI(ext->nelem) } /* end H5S_extent_nelem() */ - + /*------------------------------------------------------------------------- * Function: H5S_set_version * diff --git a/src/H5Sall.c b/src/H5Sall.c index 8290ae2..9026e7c 100644 --- a/src/H5Sall.c +++ b/src/H5Sall.c @@ -29,7 +29,7 @@ /* Headers */ /***********/ #include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ +#include "H5Eprivate.h" /* Error handling */ #include "H5Iprivate.h" /* ID Functions */ #include "H5Spkg.h" /* Dataspace functions */ #include "H5VMprivate.h" /* Vector functions */ @@ -599,7 +599,7 @@ H5S__all_serial_size(const H5S_t H5_ATTR_UNUSED *space) PURPOSE Serialize the current selection into a user-provided buffer. USAGE - herr_t H5S_all_serialize(space, p) + herr_t H5S__all_serialize(space, p) const H5S_t *space; IN: Dataspace with selection to serialize uint8_t **p; OUT: Pointer to buffer to put serialized selection. Will be advanced to end of @@ -627,8 +627,8 @@ H5S__all_serialize(const H5S_t *space, uint8_t **p) HDassert(pp); /* Store the preamble information */ - UINT32ENCODE(pp, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ - UINT32ENCODE(pp, (uint32_t)H5S_ALL_VERSION_1); /* Store the version number */ + UINT32ENCODE(pp, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ + UINT32ENCODE(pp, (uint32_t)H5S_ALL_VERSION_1); /* Store the version number */ UINT32ENCODE(pp, (uint32_t)0); /* Store the un-used padding */ UINT32ENCODE(pp, (uint32_t)0); /* Store the additional information length */ diff --git a/src/H5Sdbg.c b/src/H5Sdbg.c index 8171191..32f5295 100644 --- a/src/H5Sdbg.c +++ b/src/H5Sdbg.c @@ -13,11 +13,12 @@ /*------------------------------------------------------------------------- * - * Created: H5Sdbg.c - * Jul 24 2007 - * Quincey Koziol + * Created: H5Sdbg.c + * Quincey Koziol + * Jul 24 2007 + * * - * Purpose: Dump debugging information about a dataspace + * Purpose: Dump debugging information about a dataspace * *------------------------------------------------------------------------- */ @@ -32,9 +33,9 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Spkg.h" /* Dataspaces */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Spkg.h" /* Dataspaces */ /****************/ @@ -74,13 +75,13 @@ /*------------------------------------------------------------------------- - * Function: H5S_debug + * Function: H5S_debug * - * Purpose: Prints debugging information about a dataspace. + * Purpose: Prints debugging information about a dataspace. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Tuesday, July 21, 1998 * *------------------------------------------------------------------------- @@ -88,7 +89,7 @@ herr_t H5S_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth) { - const H5S_t *mesg = (const H5S_t*)_mesg; + const H5S_t *mesg = (const H5S_t*)_mesg; FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5Shyper.c b/src/H5Shyper.c index 4a84c41..68e1fb0 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -12,10 +12,10 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, June 18, 1998 * - * Purpose: Hyperslab selection dataspace I/O functions. + * Purpose: Hyperslab selection dataspace I/O functions. */ /****************/ @@ -30,8 +30,8 @@ /***********/ #include "H5private.h" /* Generic Functions */ #include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ #include "H5Iprivate.h" /* ID Functions */ #include "H5MMprivate.h" /* Memory management */ #include "H5Spkg.h" /* Dataspace functions */ @@ -303,7 +303,7 @@ H5FL_EXTERN(H5S_sel_iter_t); static uint64_t H5S_hyper_op_gen_g = 1; -/* Uncomment this, to provide the debugging routines for printing selection info */ +/* Uncomment this to provide the debugging routines for printing selection info */ /* #define H5S_HYPER_DEBUG */ #ifdef H5S_HYPER_DEBUG static herr_t @@ -384,7 +384,7 @@ H5S__hyper_print_diminfo(FILE *f, const H5S_t *space) FUNC_LEAVE_NOAPI(SUCCEED) } - + /*-------------------------------------------------------------------------- NAME H5S__hyper_print_spans_dfs @@ -530,7 +530,7 @@ H5S__hyper_print_space_dfs(FILE *f, const H5S_t *space) } /* end H5S__hyper_print_space_dfs() */ #endif /* H5S_HYPER_DEBUG */ - + /*------------------------------------------------------------------------- * Function: H5S__hyper_get_op_gen * @@ -554,15 +554,15 @@ H5S__hyper_get_op_gen(void) FUNC_LEAVE_NOAPI(H5S_hyper_op_gen_g++); } /* end H5S__hyper_op_gen() */ - + /*------------------------------------------------------------------------- * Function: H5S__hyper_iter_init * - * Purpose: Initializes iteration information for hyperslab selection. + * Purpose: Initializes iteration information for hyperslab selection. * - * Return: Non-negative on success, negative on failure. + * Return: Non-negative on success, negative on failure. * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Saturday, February 24, 2001 * * Notes: If the 'iter->elmt_size' field is set to zero, the regular @@ -793,16 +793,16 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_iter_init() */ - + /*------------------------------------------------------------------------- * Function: H5S__hyper_iter_coords * - * Purpose: Retrieve the current coordinates of iterator for current + * Purpose: Retrieve the current coordinates of iterator for current * selection * - * Return: Non-negative on success, negative on failure + * Return: Non-negative on success, negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Tuesday, April 22, 2003 * *------------------------------------------------------------------------- @@ -878,16 +878,16 @@ H5S__hyper_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_iter_coords() */ - + /*------------------------------------------------------------------------- * Function: H5S__hyper_iter_block * - * Purpose: Retrieve the current block of iterator for current + * Purpose: Retrieve the current block of iterator for current * selection * - * Return: Non-negative on success, negative on failure + * Return: Non-negative on success, negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Monday, June 2, 2003 * * Notes: This routine assumes that the iterator is always located at @@ -915,28 +915,28 @@ H5S__hyper_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) for(u = 0; u < iter->rank; u++) { start[u] = iter->u.hyp.off[u]; end[u] = (start[u] + iter->u.hyp.diminfo[u].block) - 1; - } /* end for */ + } } /* end if */ else { /* Copy the start & end of the block */ for(u = 0; u < iter->rank; u++) { start[u] = iter->u.hyp.span[u]->low; end[u] = iter->u.hyp.span[u]->high; - } /* end for */ + } } /* end else */ FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_iter_block() */ - + /*------------------------------------------------------------------------- * Function: H5S__hyper_iter_nelmts * - * Purpose: Return number of elements left to process in iterator + * Purpose: Return number of elements left to process in iterator * - * Return: Non-negative number of elements on success, zero on failure + * Return: Non-negative number of elements on success, zero on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Tuesday, June 16, 1998 * *------------------------------------------------------------------------- @@ -952,7 +952,7 @@ H5S__hyper_iter_nelmts(const H5S_sel_iter_t *iter) FUNC_LEAVE_NOAPI(iter->elmt_left) } /* end H5S__hyper_iter_nelmts() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_iter_has_next_block @@ -1008,17 +1008,17 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_iter_has_next_block() */ - + /*------------------------------------------------------------------------- * Function: H5S__hyper_iter_next * - * Purpose: Moves a hyperslab iterator to the beginning of the next sequence - * of elements to read. Handles walking off the end in all dimensions. + * Purpose: Moves a hyperslab iterator to the beginning of the next sequence + * of elements to read. Handles walking off the end in all dimensions. * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Friday, September 8, 2000 * *------------------------------------------------------------------------- @@ -1215,17 +1215,17 @@ H5S__hyper_iter_next(H5S_sel_iter_t *iter, size_t nelem) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_iter_next() */ - + /*------------------------------------------------------------------------- * Function: H5S__hyper_iter_next_block * - * Purpose: Moves a hyperslab iterator to the beginning of the next sequence - * of elements to read. Handles walking off the end in all dimensions. + * Purpose: Moves a hyperslab iterator to the beginning of the next sequence + * of elements to read. Handles walking off the end in all dimensions. * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Tuesday, June 3, 2003 * *------------------------------------------------------------------------- @@ -1390,7 +1390,7 @@ H5S__hyper_iter_next_block(H5S_sel_iter_t *iter) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_iter_next_block() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_iter_get_seq_list_gen @@ -1408,7 +1408,7 @@ H5S__hyper_iter_next_block(H5S_sel_iter_t *iter) hsize_t *off; OUT: Array of offsets size_t *len; OUT: Array of lengths RETURNS - Non-negative on success/Negative on failure. + Non-negative on success/Negative on failure DESCRIPTION Use the selection in the dataspace to generate a list of byte offsets and lengths for the region(s) selected. Start/Restart from the position in the @@ -1755,7 +1755,7 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max /* Work back up through the dimensions */ while(curr_dim >= 0) { /* Reset the current span */ - curr_span = ispan[curr_dim]; + curr_span = ispan[curr_dim]; /* Increment absolute position */ abs_arr[curr_dim]++; @@ -1842,7 +1842,7 @@ H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t max FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_iter_get_seq_list_gen() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_iter_get_seq_list_opt @@ -2109,15 +2109,15 @@ H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t maxseq, size_t max /* Read in data until an entire sequence can't be written out any longer */ while(curr_rows > 0) { -#define DUFF_GUTS \ -/* Store the sequence information */ \ -off[curr_seq] = loc; \ -len[curr_seq] = actual_bytes; \ - \ -/* Increment sequence count */ \ -curr_seq++; \ - \ -/* Increment information to reflect block just processed */ \ +#define DUFF_GUTS \ +/* Store the sequence information */ \ +off[curr_seq] = loc; \ +len[curr_seq] = actual_bytes; \ + \ +/* Increment sequence count */ \ +curr_seq++; \ + \ +/* Increment information to reflect block just processed */ \ loc += fast_dim_buf_off; #ifdef NO_DUFFS_DEVICE @@ -2286,7 +2286,7 @@ loc += fast_dim_buf_off; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_iter_get_seq_list_opt() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_iter_get_seq_list_single @@ -2564,7 +2564,7 @@ H5S__hyper_iter_get_seq_list_single(H5S_sel_iter_t *iter, size_t maxseq, size_t FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_iter_get_seq_list_single() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_iter_get_seq_list @@ -2573,7 +2573,6 @@ H5S__hyper_iter_get_seq_list_single(H5S_sel_iter_t *iter, size_t maxseq, size_t USAGE herr_t H5S__hyper_iter_get_seq_list(iter,maxseq,maxelem,nseq,nelem,off,len) H5S_t *space; IN: Dataspace containing selection to use. - unsigned flags; IN: Flags for extra information about operation H5S_sel_iter_t *iter; IN/OUT: Selection iterator describing last position of interest in selection. size_t maxseq; IN: Maximum number of sequences to generate @@ -2726,7 +2725,7 @@ H5S__hyper_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_iter_get_seq_list() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_iter_release @@ -2759,7 +2758,7 @@ H5S__hyper_iter_release(H5S_sel_iter_t *iter) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_iter_release() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_new_span @@ -2807,7 +2806,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_new_span() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_new_span_info @@ -2850,7 +2849,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_new_span_info() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_copy_span_helper @@ -2946,7 +2945,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_copy_span_helper() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_copy_span @@ -2991,7 +2990,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_copy_span() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_cmp_spans @@ -3012,8 +3011,7 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static H5_ATTR_PURE hbool_t -H5S__hyper_cmp_spans(const H5S_hyper_span_info_t *span_info1, - const H5S_hyper_span_info_t *span_info2) +H5S__hyper_cmp_spans(const H5S_hyper_span_info_t *span_info1, const H5S_hyper_span_info_t *span_info2) { hbool_t ret_value = TRUE; /* Return value */ @@ -3087,7 +3085,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_cmp_spans() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_free_span_info @@ -3144,7 +3142,7 @@ H5S__hyper_free_span_info(H5S_hyper_span_info_t *span_info) FUNC_LEAVE_NOAPI_VOID } /* end H5S__hyper_free_span_info() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_free_span @@ -3182,7 +3180,7 @@ H5S__hyper_free_span(H5S_hyper_span_t *span) FUNC_LEAVE_NOAPI_VOID } /* end H5S__hyper_free_span() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_copy @@ -3257,7 +3255,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_copy() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_is_valid @@ -3316,7 +3314,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_is_valid() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_span_nblocks_helper @@ -3384,7 +3382,7 @@ H5S__hyper_span_nblocks_helper(H5S_hyper_span_info_t *spans, unsigned op_info_i, FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_span_nblocks_helper() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_span_nblocks @@ -3425,7 +3423,7 @@ H5S__hyper_span_nblocks(H5S_hyper_span_info_t *spans) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_span_nblocks() */ - + /*-------------------------------------------------------------------------- NAME H5S__get_select_hyper_nblocks @@ -3462,7 +3460,7 @@ H5S__get_select_hyper_nblocks(const H5S_t *space, hbool_t app_ref) /* Check each dimension */ for(ret_value = 1, u = 0; u < space->extent.rank; u++) ret_value *= (app_ref ? space->select.sel_info.hslab->diminfo.app[u].count : - space->select.sel_info.hslab->diminfo.opt[u].count); + space->select.sel_info.hslab->diminfo.opt[u].count); } /* end if */ else ret_value = H5S__hyper_span_nblocks(space->select.sel_info.hslab->span_lst); @@ -3470,7 +3468,7 @@ H5S__get_select_hyper_nblocks(const H5S_t *space, hbool_t app_ref) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__get_select_hyper_nblocks() */ - + /*-------------------------------------------------------------------------- NAME H5Sget_select_hyper_nblocks @@ -3511,7 +3509,7 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Sget_select_hyper_nblocks() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_get_enc_size_real @@ -3706,13 +3704,13 @@ H5S__hyper_get_version_enc_size(const H5S_t *space, hsize_t block_count, uint32_ default: HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown hyperslab selection version") break; - } /* end switch */ + } done: FUNC_LEAVE_NOAPI(ret_value) } /* H5S__hyper_get_version_enc_size() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_serial_size @@ -3737,14 +3735,15 @@ H5S__hyper_serial_size(const H5S_t *space) { hsize_t block_count = 0; /* block counter for regular hyperslabs */ uint32_t version; /* Version number */ - uint8_t enc_size; /* Encoded size of hyerslab selection info */ + uint8_t enc_size; /* Encoded size of hyperslab selection info */ hssize_t ret_value = -1; /* return value */ FUNC_ENTER_STATIC HDassert(space); - if(space->select.sel_info.hslab->unlim_dim < 0) /* ! H5S_UNLIMITED */ + /* Determine the number of blocks */ + if(space->select.sel_info.hslab->unlim_dim < 0) /* ! H5S_UNLIMITED */ block_count = H5S__get_select_hyper_nblocks(space, FALSE); /* Determine the version and the encoded size */ @@ -3786,7 +3785,7 @@ H5S__hyper_serial_size(const H5S_t *space) */ HDassert(enc_size == 8); ret_value = (hssize_t)17 + ((hssize_t)4 * (hssize_t)8 * (hssize_t)space->extent.rank); - } /* end else-if */ + } else { HDassert(version == H5S_HYPER_VERSION_1); HDassert(enc_size == 4); @@ -3806,7 +3805,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_serial_size() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_serialize_helper @@ -3927,14 +3926,14 @@ H5S__hyper_serialize_helper(const H5S_hyper_span_info_t *spans, FUNC_LEAVE_NOAPI_VOID } /* end H5S__hyper_serialize_helper() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_serialize PURPOSE Serialize the current selection into a user-provided buffer. USAGE - herr_t H5S_hyper_serialize(space, p) + herr_t H5S__hyper_serialize(space, p) const H5S_t *space; IN: Dataspace with selection to serialize uint8_t **p; OUT: Pointer to buffer to put serialized selection. Will be advanced to end of @@ -3957,7 +3956,7 @@ H5S__hyper_serialize(const H5S_t *space, uint8_t **p) hsize_t offset[H5S_MAX_RANK]; /* Offset of element in dataspace */ hsize_t start[H5S_MAX_RANK]; /* Location of start of hyperslab */ hsize_t end[H5S_MAX_RANK]; /* Location of end of hyperslab */ - uint8_t *pp; /* Local pointer for decoding */ + uint8_t *pp; /* Local pointer for encoding */ uint8_t *lenp = NULL; /* pointer to length location for later storage */ uint32_t len = 0; /* number of bytes used */ uint32_t version; /* Version number */ @@ -3968,7 +3967,7 @@ H5S__hyper_serialize(const H5S_t *space, uint8_t **p) unsigned u; /* Local counting variable */ hbool_t complete = FALSE; /* Whether we are done with the iteration */ hbool_t is_regular; /* Whether selection is regular */ - uint8_t enc_size; + uint8_t enc_size; /* Encoded size */ herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_STATIC @@ -3983,7 +3982,8 @@ H5S__hyper_serialize(const H5S_t *space, uint8_t **p) ndims = space->extent.rank; diminfo = space->select.sel_info.hslab->diminfo.opt; - if(space->select.sel_info.hslab->unlim_dim < 0) /* ! H5S_UNLIMITED */ + /* Calculate the # of blocks */ + if(space->select.sel_info.hslab->unlim_dim < 0) /* ! H5S_UNLIMITED */ block_count = H5S__get_select_hyper_nblocks(space, FALSE); /* Determine the version and the encoded size */ @@ -4119,7 +4119,7 @@ H5S__hyper_serialize(const H5S_t *space, uint8_t **p) tmp_count[fast_dim]--; } /* end while */ - /* Work on other dimensions if necessary */ + /* Work on other dimensions if necessary */ if(fast_dim > 0) { int temp_dim; /* Temporary rank holder */ @@ -4140,7 +4140,7 @@ H5S__hyper_serialize(const H5S_t *space, uint8_t **p) if(temp_dim == 0) complete = TRUE; - /* Reset the block count in this dimension */ + /* Reset the block count in this dimension */ tmp_count[temp_dim] = diminfo[temp_dim].count; /* Wrapped a dimension, go up to next dimension */ @@ -4203,7 +4203,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_serialize() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_deserialize @@ -4283,7 +4283,7 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p) /* Check for unknown flags */ if(flags & ~H5S_SELECT_FLAG_BITS) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTLOAD, FAIL, "unknown flag for selection") - } /* end if */ + } else { /* Skip over the remainder of the header */ pp += 8; @@ -4299,7 +4299,7 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p) if(!*space) { /* Patch the rank of the allocated dataspace */ - (void)HDmemset(dims, 0, (size_t)rank * sizeof(dims[0])); + HDmemset(dims, 0, (size_t)rank * sizeof(dims[0])); if(H5S_set_extent_simple(tmp_space, rank, dims, NULL) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't set dimensions") } /* end if */ @@ -4314,7 +4314,7 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p) /* Sanity checks */ HDassert(H5S_UNLIMITED == HSIZE_UNDEF); - HDassert(version >= 2); + HDassert(version >= H5S_HYPER_VERSION_2); /* Decode start/stride/block/count */ switch(enc_size) { @@ -4382,7 +4382,7 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p) size_t num_elem; /* Number of elements in selection */ unsigned v; /* Local counting variable */ - /* decode the number of blocks */ + /* Decode the number of blocks */ switch(enc_size) { case H5S_SELECT_INFO_ENC_SIZE_2: UINT16DECODE(pp, num_elem); @@ -4460,7 +4460,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_deserialize() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_span_blocklist @@ -4565,7 +4565,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_span_blocklist() */ - + /*-------------------------------------------------------------------------- NAME H5S__get_select_hyper_blocklist @@ -4747,7 +4747,7 @@ H5S__get_select_hyper_blocklist(H5S_t *space, hsize_t startblock, FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__get_select_hyper_blocklist() */ - + /*-------------------------------------------------------------------------- NAME H5Sget_select_hyper_blocklist @@ -4760,7 +4760,7 @@ H5S__get_select_hyper_blocklist(H5S_t *space, hsize_t startblock, hsize_t numblocks; IN: Number of hyperslab blocks to get hsize_t buf[]; OUT: List of hyperslab blocks selected RETURNS - Non-negative on success/Negative on failure + Non-negative on success, negative on failure DESCRIPTION Puts a list of the hyperslab blocks into the user's buffer. The blocks start with the 'startblock'th block in the list of blocks and put @@ -4808,7 +4808,7 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Sget_select_hyper_blocklist() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_bounds @@ -4889,7 +4889,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_bounds() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_offset @@ -4998,7 +4998,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_offset() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_unlim_dim @@ -5025,7 +5025,7 @@ H5S__hyper_unlim_dim(const H5S_t *space) FUNC_LEAVE_NOAPI(space->select.sel_info.hslab->unlim_dim); } /* end H5S__hyper_unlim_dim() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_num_elem_non_unlim @@ -5067,7 +5067,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_num_elem_non_unlim() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_is_contiguous @@ -5253,7 +5253,7 @@ H5S__hyper_is_contiguous(const H5S_t *space) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_is_contiguous() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_is_single @@ -5326,7 +5326,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_is_single() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_is_regular @@ -5371,7 +5371,7 @@ H5S__hyper_is_regular(const H5S_t *space) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_is_regular() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_spans_shape_same_helper @@ -5723,7 +5723,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_shape_same() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_release @@ -5764,7 +5764,7 @@ H5S__hyper_release(H5S_t *space) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_release() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_coord_to_span @@ -5827,7 +5827,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_coord_to_span() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_add_span_element_helper @@ -6058,7 +6058,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_add_span_element_helper() */ - + /*-------------------------------------------------------------------------- NAME H5S_hyper_add_span_element @@ -6168,7 +6168,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_hyper_add_span_element() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_intersect_block_helper @@ -6258,7 +6258,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_intersect_block_helper() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_intersect_block @@ -6390,7 +6390,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_intersect_block() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_adjust_u_helper @@ -6457,7 +6457,7 @@ H5S__hyper_adjust_u_helper(H5S_hyper_span_info_t *spans, unsigned rank, FUNC_LEAVE_NOAPI_VOID } /* end H5S__hyper_adjust_u_helper() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_adjust_u @@ -6493,7 +6493,7 @@ H5S__hyper_adjust_u(H5S_t *space, const hsize_t *offset) if(0 != offset[u]) { non_zero_offset = TRUE; break; - } /* end if */ + } /* Only perform operation if the offset is non-zero */ if(non_zero_offset) { @@ -6528,7 +6528,7 @@ H5S__hyper_adjust_u(H5S_t *space, const hsize_t *offset) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_adjust_u() */ - + /*------------------------------------------------------------------------- * Function: H5S__hyper_project_scalar * @@ -6604,7 +6604,7 @@ H5S__hyper_project_scalar(const H5S_t *space, hsize_t *offset) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_project_scalar() */ - + /*------------------------------------------------------------------------- * Function: H5S__hyper_project_simple_lower * @@ -6651,7 +6651,7 @@ H5S__hyper_project_simple_lower(const H5S_t *base_space, H5S_t *new_space) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__hyper_project_simple_lower() */ - + /*------------------------------------------------------------------------- * Function: H5S__hyper_project_simple_higher * @@ -6751,7 +6751,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_project_simple_higher() */ - + /*------------------------------------------------------------------------- * Function: H5S__hyper_project_simple * @@ -6925,7 +6925,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_project_simple() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_adjust_s_helper @@ -6992,7 +6992,7 @@ H5S__hyper_adjust_s_helper(H5S_hyper_span_info_t *spans, unsigned rank, FUNC_LEAVE_NOAPI_VOID } /* end H5S__hyper_adjust_s_helper() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_adjust_s @@ -7059,13 +7059,13 @@ H5S__hyper_adjust_s(H5S_t *space, const hssize_t *offset) * simultaneous operations */ H5S__hyper_adjust_s_helper(space->select.sel_info.hslab->span_lst, space->extent.rank, offset, 0, op_gen); } /* end if */ - } /* end if */ + } done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_adjust_s() */ - + /*-------------------------------------------------------------------------- NAME H5S_hyper_normalize_offset @@ -7123,7 +7123,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_hyper_normalize_offset() */ - + /*-------------------------------------------------------------------------- NAME H5S_hyper_denormalize_offset @@ -7167,7 +7167,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_hyper_denormalize_offset() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_append_span @@ -7198,7 +7198,7 @@ H5S__hyper_append_span(H5S_hyper_span_info_t **span_tree, unsigned ndims, FUNC_ENTER_STATIC - /* Sanity check */ + /* Sanity checks */ HDassert(span_tree); /* Check for adding first node to merged spans */ @@ -7305,7 +7305,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_append_span() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_clip_spans @@ -7901,7 +7901,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_clip_spans() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_merge_spans_helper @@ -8217,7 +8217,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_merge_spans_helper() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_merge_spans @@ -8272,7 +8272,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_merge_spans() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_spans_nelem_helper @@ -8345,7 +8345,7 @@ H5S__hyper_spans_nelem_helper(H5S_hyper_span_info_t *spans, unsigned op_info_i, FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_spans_nelem_helper() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_spans_nelem @@ -8434,7 +8434,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_add_disjoint_spans */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_make_spans @@ -8801,7 +8801,7 @@ H5S__hyper_update_diminfo(H5S_t *space, H5S_seloper_t op, FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_update_diminfo() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_rebuild_helper @@ -8910,7 +8910,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_rebuild_helper() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_rebuild @@ -8960,7 +8960,7 @@ H5S__hyper_rebuild(H5S_t *space) FUNC_LEAVE_NOAPI_VOID } /* end H5S__hyper_rebuild() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_generate_spans @@ -9019,7 +9019,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_generate_spans() */ - + /*-------------------------------------------------------------------------- NAME H5S__check_spans_overlap @@ -9100,7 +9100,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__check_spans_overlap() */ - + /*-------------------------------------------------------------------------- NAME H5S__fill_in_new_space @@ -9399,15 +9399,15 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__fill_in_new_space() */ - + /*------------------------------------------------------------------------- * Function: H5S__generate_hyperlab * - * Purpose: Generate hyperslab information from H5S_select_hyperslab() + * Purpose: Generate hyperslab information from H5S_select_hyperslab() * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Tuesday, September 12, 2000 * *------------------------------------------------------------------------- @@ -9489,7 +9489,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__generate_hyperslab() */ - + /*------------------------------------------------------------------------- * Function: H5S__set_regular_hyperslab * @@ -9819,15 +9819,15 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_regular_and_single_block() */ - + /*------------------------------------------------------------------------- * Function: H5S_select_hyperslab * - * Purpose: Internal version of H5Sselect_hyperslab(). + * Purpose: Internal version of H5Sselect_hyperslab(). * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Wednesday, January 10, 2001 * *------------------------------------------------------------------------- @@ -10137,7 +10137,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_hyperslab() */ - + /*-------------------------------------------------------------------------- NAME H5Sselect_hyperslab @@ -10201,7 +10201,7 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Sselect_hyperslab() */ - + /*-------------------------------------------------------------------------- NAME H5S_combine_hyperslab @@ -10407,7 +10407,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_combine_hyperslab() */ - + /*------------------------------------------------------------------------- * Function: H5S__fill_in_select * @@ -10460,7 +10460,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__fill_in_select() */ - + /*-------------------------------------------------------------------------- NAME H5Scombine_hyperslab @@ -10494,9 +10494,9 @@ hid_t H5Scombine_hyperslab(hid_t space_id, H5S_seloper_t op, const hsize_t start[], const hsize_t stride[], const hsize_t count[], const hsize_t block[]) { - H5S_t *space; /* Dataspace to modify selection of */ - H5S_t *new_space = NULL; /* New dataspace created */ - hid_t ret_value; /* Return value */ + H5S_t *space; /* Dataspace to modify selection of */ + H5S_t *new_space = NULL; /* New dataspace created */ + hid_t ret_value; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE6("i", "iSs*h*h*h*h", space_id, op, start, stride, count, block); @@ -10524,15 +10524,15 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Scombine_hyperslab() */ - + /*------------------------------------------------------------------------- * Function: H5S__combine_select * - * Purpose: Internal version of H5Scombine_select(). + * Purpose: Internal version of H5Scombine_select(). * - * Return: New dataspace on success/NULL on failure + * Return: New dataspace on success/NULL on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Tuesday, October 30, 2001 * *------------------------------------------------------------------------- @@ -10592,7 +10592,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__combine_select() */ - + /*-------------------------------------------------------------------------- NAME H5Scombine_select @@ -10667,15 +10667,15 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Scombine_select() */ - + /*------------------------------------------------------------------------- * Function: H5S__modify_select * - * Purpose: Internal version of H5Smodify_select(). + * Purpose: Internal version of H5Smodify_select(). * - * Return: New dataspace on success/NULL on failure + * Return: New dataspace on success/NULL on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Tuesday, October 30, 2001 * *------------------------------------------------------------------------- @@ -10727,7 +10727,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__modify_select() */ - + /*-------------------------------------------------------------------------- NAME H5Smodify_select @@ -10809,7 +10809,7 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Smodify_select() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_proj_int_build_proj @@ -11203,7 +11203,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_proj_int_build_proj() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_proj_int_iterate @@ -11454,7 +11454,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_proj_int_iterate() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_project_intersection @@ -11644,7 +11644,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_project_intersection() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_get_clip_diminfo @@ -11699,7 +11699,7 @@ H5S__hyper_get_clip_diminfo(hsize_t start, hsize_t stride, hsize_t *count, FUNC_LEAVE_NOAPI_VOID } /* end H5S__hyper_get_clip_diminfo() */ - + /*-------------------------------------------------------------------------- NAME H5S_hyper_clip_unlim @@ -11825,7 +11825,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_hyper_clip_unlim() */ - + /*-------------------------------------------------------------------------- NAME H5S__hyper_get_clip_extent_real @@ -11907,7 +11907,7 @@ H5S__hyper_get_clip_extent_real(const H5S_t *clip_space, hsize_t num_slices, FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_get_clip_extent_real() */ - + /*-------------------------------------------------------------------------- NAME H5S_hyper_get_clip_extent @@ -11970,7 +11970,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_hyper_get_clip_extent() */ - + /*-------------------------------------------------------------------------- NAME H5S_hyper_get_clip_extent_match @@ -12060,7 +12060,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_hyper_get_clip_extent_match() */ - + /*-------------------------------------------------------------------------- NAME H5S_hyper_get_unlim_block @@ -12143,7 +12143,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_hyper_get_unlim_block */ - + /*-------------------------------------------------------------------------- NAME H5S_hyper_get_first_inc_block @@ -12173,7 +12173,7 @@ H5S_hyper_get_first_inc_block(const H5S_t *space, hsize_t clip_size, hbool_t *partial) { H5S_hyper_sel_t *hslab; /* Convenience pointer to hyperslab info */ - H5S_hyper_dim_t *diminfo; /* Convenience pointer to diminfo.opt in unlimited dimension */ + H5S_hyper_dim_t *diminfo; /* Convenience pointer to diminfo in unlimited dimension */ hsize_t ret_value = 0; FUNC_ENTER_NOAPI(0) @@ -12211,7 +12211,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_hyper_get_first_inc_block */ - + /*-------------------------------------------------------------------------- NAME H5Sis_regular_hyperslab @@ -12253,7 +12253,7 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Sis_regular_hyperslab() */ - + /*-------------------------------------------------------------------------- NAME H5Sget_regular_hyperslab diff --git a/src/H5Smpio.c b/src/H5Smpio.c index 33dd492..147fd25 100644 --- a/src/H5Smpio.c +++ b/src/H5Smpio.c @@ -14,7 +14,7 @@ /* * Programmer: rky 980813 * - * Purpose: Create MPI data types for HDF5 selections. + * Purpose: Create MPI data types for HDF5 selections. * */ @@ -148,14 +148,14 @@ H5S__mpio_all_type(const H5S_t *space, size_t elmt_size, *new_type = MPI_BYTE; H5_CHECKED_ASSIGN(*count, int, total_bytes, hsize_t); *is_derived_type = FALSE; - } /* end if */ + } else { /* Create a LARGE derived datatype for this transfer */ if(H5_mpio_create_large_type(total_bytes, 0, MPI_BYTE, new_type) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create a large datatype from the all selection") *count = 1; *is_derived_type = TRUE; - } /* end else */ + } done: FUNC_LEAVE_NOAPI(ret_value) @@ -253,7 +253,7 @@ H5S__mpio_create_point_datatype(size_t elmt_size, hsize_t num_points, /* Commit MPI datatype for later use */ if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) - } /* end if */ + } else { /* use LARGE_DATATYPE:: * We'll create an hindexed_block type for every 2G point count and then combine @@ -295,7 +295,7 @@ H5S__mpio_create_point_datatype(size_t elmt_size, hsize_t num_points, #if MPI_VERSION >= 3 if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed_block((int)bigio_count, 1, &disp[(hsize_t)i*bigio_count], elmt_type, &inner_types[i]))) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed_block failed", mpi_code) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed_block failed", mpi_code); #else if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed((int)bigio_count, blocks, &disp[i*bigio_count], elmt_type, &inner_types[i]))) @@ -309,7 +309,7 @@ H5S__mpio_create_point_datatype(size_t elmt_size, hsize_t num_points, #if MPI_VERSION >= 3 if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed_block(remaining_points, 1, &disp[(hsize_t)num_big_types*bigio_count], elmt_type, &inner_types[num_big_types]))) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed_block failed", mpi_code) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed_block failed", mpi_code); #else if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed((int)remaining_points, blocks, &disp[num_big_types*bigio_count], elmt_type, &inner_types[num_big_types]))) @@ -317,11 +317,12 @@ H5S__mpio_create_point_datatype(size_t elmt_size, hsize_t num_points, #endif inner_blocks[num_big_types] = 1; inner_disps[num_big_types] = 0; - } /* end if */ + } if(MPI_SUCCESS != (mpi_code = MPI_Type_create_struct(total_types, inner_blocks, inner_disps, inner_types, new_type))) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_struct", mpi_code) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_struct", mpi_code); + for(i = 0; i < total_types; i++) MPI_Type_free(&inner_types[i]); @@ -492,7 +493,7 @@ done: * selection and so the memory datatype has to be permuted using the * permutation map created by the file selection. * - * Note: This routine is called from H5_mpio_space_type(), which is + * Note: This routine is called from H5S_mpio_space_type(), which is * called first for the file dataspace and creates * * Return: Non-negative on success, negative on failure. @@ -799,7 +800,7 @@ if(H5DEBUG(S)) { /* Use a single MPI datatype that has a 32 bit size */ if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)elmt_size, MPI_BYTE, &inner_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code) - } /* end if */ + } else /* Create the compound datatype for this operation (> 2GB) */ if(H5_mpio_create_large_type(elmt_size, 0, MPI_BYTE, &inner_type) < 0) @@ -836,7 +837,7 @@ if(H5DEBUG(S)) MPI_Type_free(&inner_type); if(mpi_code != MPI_SUCCESS) HMPI_GOTO_ERROR(FAIL, "couldn't create MPI vector type", mpi_code) - } /* end if */ + } else { /* Things get a bit more complicated and require LARGE_DATATYPE processing * There are two MPI datatypes that need to be created: @@ -858,7 +859,7 @@ if(H5DEBUG(S)) if(bigio_count < d[i].block) { if(H5_mpio_create_large_type(d[i].block, 0, inner_type, &block_type) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create a large block datatype in hyper selection") - } /* end if */ + } else if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)d[i].block, inner_type, &block_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code) @@ -879,7 +880,7 @@ if(H5DEBUG(S)) if(bigio_count < d[i].count) { if(H5_mpio_create_large_type(d[i].count, stride_in_bytes, block_type, &outer_type) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create a large outer datatype in hyper selection") - } /* end if */ + } /* otherwise a regular create_hvector will do */ else if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector((int)d[i].count, /* count */ @@ -891,7 +892,7 @@ if(H5DEBUG(S)) MPI_Type_free(&block_type); MPI_Type_free(&inner_type); - } /* end else */ + } /* end else */ /**************************************** * Then build the dimension type as (start, vector type, xtent). @@ -1004,7 +1005,7 @@ H5S__mpio_span_hyper_type(const H5S_t *space, size_t elmt_size, if(bigio_count >= elmt_size) { if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)elmt_size, MPI_BYTE, &elmt_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code) - } /* end if */ + } else if(H5_mpio_create_large_type(elmt_size, 0, MPI_BYTE, &elmt_type) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create a large element datatype in span_hyper selection") @@ -1113,7 +1114,6 @@ H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down, { H5S_hyper_span_t *span; /* Hyperslab span to iterate with */ hsize_t bigio_count; /* Transition point to create derived type */ - size_t alloc_count = 0; /* Number of span tree nodes allocated at this level */ size_t outercount = 0; /* Number of span tree nodes at this level */ MPI_Datatype *inner_type = NULL; diff --git a/src/H5Snone.c b/src/H5Snone.c index 630d1d5..672302d 100644 --- a/src/H5Snone.c +++ b/src/H5Snone.c @@ -29,7 +29,7 @@ /* Headers */ /***********/ #include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ +#include "H5Eprivate.h" /* Error handling */ #include "H5Iprivate.h" /* ID Functions */ #include "H5Spkg.h" /* Dataspace functions */ #include "H5VMprivate.h" /* Vector functions */ @@ -68,8 +68,7 @@ static htri_t H5S__none_intersect_block(const H5S_t *space, const hsize_t *start static herr_t H5S__none_adjust_u(H5S_t *space, const hsize_t *offset); static herr_t H5S__none_adjust_s(H5S_t *space, const hssize_t *offset); static herr_t H5S__none_project_scalar(const H5S_t *space, hsize_t *offset); -static herr_t H5S__none_project_simple(const H5S_t *space, H5S_t *new_space, - hsize_t *offset); +static herr_t H5S__none_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset); static herr_t H5S__none_iter_init(const H5S_t *space, H5S_sel_iter_t *iter); /* Selection iteration callbacks */ @@ -143,13 +142,13 @@ static const H5S_sel_iter_class_t H5S_sel_iter_none[1] = {{ /*------------------------------------------------------------------------- - * Function: H5S__none_iter_init + * Function: H5S__none_iter_init * - * Purpose: Initializes iteration information for "none" selection. + * Purpose: Initializes iteration information for "none" selection. * - * Return: Non-negative on success, negative on failure. + * Return: Non-negative on success, negative on failure. * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Tuesday, June 16, 1998 * *------------------------------------------------------------------------- @@ -171,21 +170,20 @@ H5S__none_iter_init(const H5S_t H5_ATTR_UNUSED *space, H5S_sel_iter_t *iter) /*------------------------------------------------------------------------- - * Function: H5S__none_iter_coords + * Function: H5S__none_iter_coords * - * Purpose: Retrieve the current coordinates of iterator for current + * Purpose: Retrieve the current coordinates of iterator for current * selection * - * Return: Non-negative on success, negative on failure + * Return: Non-negative on success, negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Tuesday, April 22, 2003 * *------------------------------------------------------------------------- */ static herr_t -H5S__none_iter_coords(const H5S_sel_iter_t H5_ATTR_UNUSED *iter, - hsize_t H5_ATTR_UNUSED *coords) +H5S__none_iter_coords(const H5S_sel_iter_t H5_ATTR_UNUSED *iter, hsize_t H5_ATTR_UNUSED *coords) { FUNC_ENTER_STATIC_NOERR @@ -198,21 +196,20 @@ H5S__none_iter_coords(const H5S_sel_iter_t H5_ATTR_UNUSED *iter, /*------------------------------------------------------------------------- - * Function: H5S__none_iter_block + * Function: H5S__none_iter_block * - * Purpose: Retrieve the current block of iterator for current + * Purpose: Retrieve the current block of iterator for current * selection * - * Return: Non-negative on success, negative on failure + * Return: Non-negative on success, negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Monday, June 2, 2003 * *------------------------------------------------------------------------- */ static herr_t -H5S__none_iter_block(const H5S_sel_iter_t H5_ATTR_UNUSED *iter, - hsize_t H5_ATTR_UNUSED *start, hsize_t H5_ATTR_UNUSED *end) +H5S__none_iter_block(const H5S_sel_iter_t H5_ATTR_UNUSED *iter, hsize_t H5_ATTR_UNUSED *start, hsize_t H5_ATTR_UNUSED *end) { FUNC_ENTER_STATIC_NOERR @@ -226,13 +223,13 @@ H5S__none_iter_block(const H5S_sel_iter_t H5_ATTR_UNUSED *iter, /*------------------------------------------------------------------------- - * Function: H5S__none_iter_nelmts + * Function: H5S__none_iter_nelmts * - * Purpose: Return number of elements left to process in iterator + * Purpose: Return number of elements left to process in iterator * - * Return: Non-negative number of elements on success, zero on failure + * Return: Non-negative number of elements on success, zero on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Tuesday, June 16, 1998 * *------------------------------------------------------------------------- @@ -472,8 +469,7 @@ H5S__none_release(H5S_t H5_ATTR_UNUSED *space) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__none_copy(H5S_t *dst, const H5S_t H5_ATTR_UNUSED *src, - hbool_t H5_ATTR_UNUSED share_selection) +H5S__none_copy(H5S_t *dst, const H5S_t H5_ATTR_UNUSED *src, hbool_t H5_ATTR_UNUSED share_selection) { FUNC_ENTER_STATIC_NOERR @@ -586,8 +582,8 @@ H5S__none_serialize(const H5S_t *space, uint8_t **p) HDassert(pp); /* Store the preamble information */ - UINT32ENCODE(pp, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ - UINT32ENCODE(pp, (uint32_t)H5S_NONE_VERSION_1); /* Store the version number */ + UINT32ENCODE(pp, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ + UINT32ENCODE(pp, (uint32_t)H5S_NONE_VERSION_1); /* Store the version number */ UINT32ENCODE(pp, (uint32_t)0); /* Store the un-used padding */ UINT32ENCODE(pp, (uint32_t)0); /* Store the additional information length */ @@ -698,8 +694,7 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__none_bounds(const H5S_t H5_ATTR_UNUSED *space, hsize_t H5_ATTR_UNUSED *start, - hsize_t H5_ATTR_UNUSED *end) +H5S__none_bounds(const H5S_t H5_ATTR_UNUSED *space, hsize_t H5_ATTR_UNUSED *start, hsize_t H5_ATTR_UNUSED *end) { FUNC_ENTER_STATIC_NOERR @@ -708,7 +703,7 @@ H5S__none_bounds(const H5S_t H5_ATTR_UNUSED *space, hsize_t H5_ATTR_UNUSED *star HDassert(end); FUNC_LEAVE_NOAPI(FAIL) -} /* end H5Sget_none_bounds() */ +} /* end H5S_none_bounds() */ /*-------------------------------------------------------------------------- @@ -991,11 +986,11 @@ H5S__none_adjust_s(H5S_t H5_ATTR_UNUSED *space, const hssize_t H5_ATTR_UNUSED *o /*------------------------------------------------------------------------- - * Function: H5S__none_project_scalar + * Function: H5S__none_project_scalar * - * Purpose: Projects a 'none' selection into a scalar dataspace + * Purpose: Projects a 'none' selection into a scalar dataspace * - * Return: Non-negative on success, negative on failure. + * Return: Non-negative on success, negative on failure. * * Programmer: Quincey Koziol * Sunday, July 18, 2010 @@ -1016,14 +1011,14 @@ H5S__none_project_scalar(const H5S_t H5_ATTR_UNUSED *space, hsize_t H5_ATTR_UNUS /*------------------------------------------------------------------------- - * Function: H5S__none_project_simple + * Function: H5S__none_project_simple * - * Purpose: Projects an 'none' selection onto/into a simple dataspace + * Purpose: Projects an 'none' selection onto/into a simple dataspace * of a different rank * - * Return: Non-negative on success, negative on failure. + * Return: Non-negative on success, negative on failure. * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Sunday, July 18, 2010 * *------------------------------------------------------------------------- diff --git a/src/H5Spkg.h b/src/H5Spkg.h index da2dd4a..e08fedf 100644 --- a/src/H5Spkg.h +++ b/src/H5Spkg.h @@ -324,11 +324,9 @@ struct H5S_t { /* Selection iteration methods */ /* Method to retrieve the current coordinates of iterator for current selection */ -typedef herr_t (*H5S_sel_iter_coords_func_t)(const H5S_sel_iter_t *iter, - hsize_t *coords); +typedef herr_t (*H5S_sel_iter_coords_func_t)(const H5S_sel_iter_t *iter, hsize_t *coords); /* Method to retrieve the current block of iterator for current selection */ -typedef herr_t (*H5S_sel_iter_block_func_t)(const H5S_sel_iter_t *iter, - hsize_t *start, hsize_t *end); +typedef herr_t (*H5S_sel_iter_block_func_t)(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end); /* Method to determine number of elements left in iterator for current selection */ typedef hsize_t (*H5S_sel_iter_nelmts_func_t)(const H5S_sel_iter_t *iter); /* Method to determine if there are more blocks left in the current selection */ diff --git a/src/H5Spoint.c b/src/H5Spoint.c index 8259275..7353c83 100644 --- a/src/H5Spoint.c +++ b/src/H5Spoint.c @@ -12,10 +12,10 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Tuesday, June 16, 1998 * - * Purpose: Point selection dataspace I/O functions. + * Purpose: Point selection dataspace I/O functions. */ /****************/ @@ -30,8 +30,8 @@ /***********/ #include "H5private.h" /* Generic Functions */ #include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ #include "H5Iprivate.h" /* ID Functions */ #include "H5MMprivate.h" /* Memory management */ #include "H5Spkg.h" /* Dataspace functions */ @@ -75,21 +75,17 @@ static htri_t H5S__point_is_contiguous(const H5S_t *space); static htri_t H5S__point_is_single(const H5S_t *space); static htri_t H5S__point_is_regular(const H5S_t *space); static htri_t H5S__point_shape_same(const H5S_t *space1, const H5S_t *space2); -static htri_t H5S__point_intersect_block(const H5S_t *space, const hsize_t *start, - const hsize_t *end); +static htri_t H5S__point_intersect_block(const H5S_t *space, const hsize_t *start, const hsize_t *end); static herr_t H5S__point_adjust_u(H5S_t *space, const hsize_t *offset); static herr_t H5S__point_adjust_s(H5S_t *space, const hssize_t *offset); -static herr_t H5S__point_project_scalar(const H5S_t *spasce, hsize_t *offset); -static herr_t H5S__point_project_simple(const H5S_t *space, H5S_t *new_space, - hsize_t *offset); +static herr_t H5S__point_project_scalar(const H5S_t *space, hsize_t *offset); +static herr_t H5S__point_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset); static herr_t H5S__point_iter_init(const H5S_t *space, H5S_sel_iter_t *iter); -static herr_t H5S__point_get_version_enc_size(const H5S_t *space, - uint32_t *version, uint8_t *enc_size); +static herr_t H5S__point_get_version_enc_size(const H5S_t *space, uint32_t *version, uint8_t *enc_size); /* Selection iteration callbacks */ static herr_t H5S__point_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords); -static herr_t H5S__point_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, - hsize_t *end); +static herr_t H5S__point_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end); static hsize_t H5S__point_iter_nelmts(const H5S_sel_iter_t *iter); static htri_t H5S__point_iter_has_next_block(const H5S_sel_iter_t *iter); static herr_t H5S__point_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); @@ -168,16 +164,15 @@ H5FL_BARR_DEFINE_STATIC(H5S_pnt_node_t, hcoords_t, H5S_MAX_RANK); /* Declare a free list to manage the H5S_pnt_list_t struct */ H5FL_DEFINE_STATIC(H5S_pnt_list_t); - - + /*------------------------------------------------------------------------- * Function: H5S__point_iter_init * - * Purpose: Initializes iteration information for point selection. + * Purpose: Initializes iteration information for point selection. * - * Return: Non-negative on success, negative on failure. + * Return: Non-negative on success, negative on failure. * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Tuesday, June 16, 1998 * *------------------------------------------------------------------------- @@ -222,16 +217,16 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_iter_init() */ - + /*------------------------------------------------------------------------- * Function: H5S__point_iter_coords * - * Purpose: Retrieve the current coordinates of iterator for current + * Purpose: Retrieve the current coordinates of iterator for current * selection * - * Return: Non-negative on success, negative on failure + * Return: Non-negative on success, negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Tuesday, April 22, 2003 * *------------------------------------------------------------------------- @@ -251,16 +246,16 @@ H5S__point_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__point_iter_coords() */ - + /*------------------------------------------------------------------------- - * Function: H5S__point_iter_block + * Function: H5S_point_iter_block * - * Purpose: Retrieve the current block of iterator for current + * Purpose: Retrieve the current block of iterator for current * selection * - * Return: Non-negative on success, negative on failure + * Return: Non-negative on success, negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Monday, June 2, 2003 * *------------------------------------------------------------------------- @@ -282,15 +277,15 @@ H5S__point_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__point_iter_block() */ - + /*------------------------------------------------------------------------- * Function: H5S__point_iter_nelmts * - * Purpose: Return number of elements left to process in iterator + * Purpose: Return number of elements left to process in iterator * - * Return: Non-negative number of elements on success, zero on failure + * Return: Non-negative number of elements on success, zero on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Tuesday, June 16, 1998 * *------------------------------------------------------------------------- @@ -306,7 +301,7 @@ H5S__point_iter_nelmts(const H5S_sel_iter_t *iter) FUNC_LEAVE_NOAPI(iter->elmt_left) } /* end H5S__point_iter_nelmts() */ - + /*-------------------------------------------------------------------------- NAME H5S__point_iter_has_next_block @@ -342,7 +337,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_iter_has_next_block() */ - + /*-------------------------------------------------------------------------- NAME H5S__point_iter_next @@ -379,7 +374,7 @@ H5S__point_iter_next(H5S_sel_iter_t *iter, size_t nelem) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__point_iter_next() */ - + /*-------------------------------------------------------------------------- NAME H5S__point_iter_next_block @@ -411,7 +406,7 @@ H5S__point_iter_next_block(H5S_sel_iter_t *iter) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__point_iter_next_block() */ - + /*-------------------------------------------------------------------------- NAME H5S__point_iter_get_seq_list @@ -542,7 +537,7 @@ H5S__point_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_iter_get_seq_list() */ - + /*-------------------------------------------------------------------------- NAME H5S__point_iter_release @@ -576,7 +571,7 @@ H5S__point_iter_release(H5S_sel_iter_t * iter) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__point_iter_release() */ - + /*-------------------------------------------------------------------------- NAME H5S__point_add @@ -693,7 +688,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_add() */ - + /*-------------------------------------------------------------------------- NAME H5S__point_release @@ -731,7 +726,7 @@ H5S__point_release(H5S_t *space) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__point_release() */ - + /*-------------------------------------------------------------------------- NAME H5S_select_elements @@ -788,7 +783,7 @@ H5S_select_elements(H5S_t *space, H5S_seloper_t op, size_t num_elem, /* Set the bound box to the default value */ H5VM_array_fill(space->select.sel_info.pnt_lst->low_bounds, &tmp, sizeof(hsize_t), space->extent.rank); HDmemset(space->select.sel_info.pnt_lst->high_bounds, 0, sizeof(hsize_t) * space->extent.rank); - } /* end if */ + } /* Add points to selection */ if(H5S__point_add(space, op, num_elem, coord) < 0) @@ -801,7 +796,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_elements() */ - + /*-------------------------------------------------------------------------- NAME H5S__copy_pnt_list @@ -877,7 +872,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__copy_pnt_list() */ - + /*-------------------------------------------------------------------------- NAME H5S__free_pnt_list @@ -919,7 +914,7 @@ H5S__free_pnt_list(H5S_pnt_list_t *pnt_lst) FUNC_LEAVE_NOAPI_VOID } /* end H5S__free_pnt_list() */ - + /*-------------------------------------------------------------------------- NAME H5S__point_copy @@ -947,7 +942,7 @@ H5S__point_copy(H5S_t *dst, const H5S_t *src, hbool_t H5_ATTR_UNUSED share_selec FUNC_ENTER_STATIC - /* Sanity check */ + /* Sanity checks */ HDassert(src); HDassert(dst); @@ -959,7 +954,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_copy() */ - + /*-------------------------------------------------------------------------- NAME H5S__point_is_valid @@ -1003,7 +998,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_is_valid() */ - + /*-------------------------------------------------------------------------- NAME H5Sget_select_elem_npoints @@ -1049,7 +1044,7 @@ done: PURPOSE Determine the version and the size (2, 4 or 8 bytes) to encode point selection info USAGE - hssize_t H5S__point_set_enc_size(space, version, enc_size) + hssize_t H5S__point_get_version_enc_size(space, version, enc_size) const H5S_t *space: IN: Dataspace ID of selection to query uint32_t *version: OUT: The version to use for encoding uint8_t *enc_size: OUT: The size to use for encoding @@ -1160,7 +1155,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5S__point_get_version_enc_size() */ - + /*-------------------------------------------------------------------------- NAME H5S__point_serial_size @@ -1193,7 +1188,7 @@ H5S__point_serial_size(const H5S_t *space) /* Determine the version and encoded size for point selection */ if(H5S__point_get_version_enc_size(space, &version, &enc_size) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't determine hyper version") + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't determine version and enc_size") /* Basic number of bytes required to serialize point selection: */ if(version >= H5S_POINT_VERSION_2) @@ -1219,7 +1214,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_serial_size() */ - + /*-------------------------------------------------------------------------- NAME H5S__point_serialize @@ -1245,7 +1240,7 @@ static herr_t H5S__point_serialize(const H5S_t *space, uint8_t **p) { H5S_pnt_node_t *curr; /* Point information nodes */ - uint8_t *pp; /* Local pointer for decoding */ + uint8_t *pp; /* Local pointer for encoding */ uint8_t *lenp = NULL; /* pointer to length location for later storage */ uint32_t len=0; /* number of bytes used */ unsigned u; /* local counting variable */ @@ -1263,7 +1258,7 @@ H5S__point_serialize(const H5S_t *space, uint8_t **p) /* Determine the version and encoded size for point selection info */ if(H5S__point_get_version_enc_size(space, &version, &enc_size) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't determine hyper version") + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't determine version and enc_size") /* Store the preamble information */ UINT32ENCODE(pp, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */ @@ -1351,8 +1346,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5S__point_serialize() */ - - + /*-------------------------------------------------------------------------- NAME H5S__point_deserialize @@ -1507,7 +1501,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_deserialize() */ - + /*-------------------------------------------------------------------------- NAME H5S__get_select_elem_pointlist @@ -1538,8 +1532,7 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__get_select_elem_pointlist(const H5S_t *space, hsize_t startpoint, - hsize_t numpoints, hsize_t *buf) +H5S__get_select_elem_pointlist(const H5S_t *space, hsize_t startpoint, hsize_t numpoints, hsize_t *buf) { H5S_pnt_node_t *node; /* Point node */ unsigned rank; /* Dataspace rank */ @@ -1572,7 +1565,7 @@ H5S__get_select_elem_pointlist(const H5S_t *space, hsize_t startpoint, FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__get_select_elem_pointlist() */ - + /*-------------------------------------------------------------------------- NAME H5Sget_select_elem_pointlist @@ -1626,7 +1619,7 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Sget_select_elem_pointlist() */ - + /*-------------------------------------------------------------------------- NAME H5S__point_bounds @@ -1684,7 +1677,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_bounds() */ - + /*-------------------------------------------------------------------------- NAME H5S__point_offset @@ -1748,7 +1741,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_offset() */ - + /*-------------------------------------------------------------------------- NAME H5S__point_unlim_dim @@ -1777,7 +1770,7 @@ H5S__point_unlim_dim(const H5S_t H5_ATTR_UNUSED *space) FUNC_LEAVE_NOAPI(-1) } /* end H5S__point_unlim_dim() */ - + /*-------------------------------------------------------------------------- NAME H5S__point_is_contiguous @@ -1817,7 +1810,7 @@ H5S__point_is_contiguous(const H5S_t *space) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_is_contiguous() */ - + /*-------------------------------------------------------------------------- NAME H5S__point_is_single @@ -1854,7 +1847,7 @@ H5S__point_is_single(const H5S_t *space) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_is_single() */ - + /*-------------------------------------------------------------------------- NAME H5S__point_is_regular @@ -1895,7 +1888,7 @@ H5S__point_is_regular(const H5S_t *space) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_is_regular() */ - + /*-------------------------------------------------------------------------- NAME H5S__point_shape_same @@ -2003,7 +1996,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_shape_same() */ - + /*-------------------------------------------------------------------------- NAME H5S__point_intersect_block @@ -2060,7 +2053,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_intersect_block() */ - + /*-------------------------------------------------------------------------- NAME H5S__point_adjust_u @@ -2097,7 +2090,7 @@ H5S__point_adjust_u(H5S_t *space, const hsize_t *offset) if(0 != offset[u]) { non_zero_offset = TRUE; break; - } /* end if */ + } /* Only perform operation if the offset is non-zero */ if(non_zero_offset) { @@ -2128,7 +2121,7 @@ H5S__point_adjust_u(H5S_t *space, const hsize_t *offset) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5S__point_adjust_u() */ - + /*-------------------------------------------------------------------------- NAME H5S__point_adjust_s @@ -2198,15 +2191,16 @@ H5S__point_adjust_s(H5S_t *space, const hssize_t *offset) } /* end H5S__point_adjust_s() */ + /*------------------------------------------------------------------------- * Function: H5S__point_project_scalar * - * Purpose: Projects a single element point selection into a scalar + * Purpose: Projects a single element point selection into a scalar * dataspace * - * Return: Non-negative on success, negative on failure. + * Return: Non-negative on success, negative on failure. * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Sunday, July 18, 2010 * *------------------------------------------------------------------------- @@ -2237,16 +2231,16 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_project_scalar() */ - + /*------------------------------------------------------------------------- - * Function: H5S__point_project_simple + * Function: H5S_point_project_simple * - * Purpose: Projects a point selection onto/into a simple dataspace + * Purpose: Projects a point selection onto/into a simple dataspace * of a different rank * - * Return: Non-negative on success, negative on failure. + * Return: Non-negative on success, negative on failure. * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Sunday, July 18, 2010 * *------------------------------------------------------------------------- @@ -2373,7 +2367,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__point_project_simple() */ - + /*-------------------------------------------------------------------------- NAME H5Sselect_elements diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h index a61c505..5100f1c 100644 --- a/src/H5Sprivate.h +++ b/src/H5Sprivate.h @@ -183,6 +183,7 @@ typedef struct H5S_sel_iter_op_t { #define H5S_SELECT_ITER_GET_SEQ_LIST(ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN) (H5S_select_iter_get_seq_list(ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN)) #define H5S_SELECT_ITER_RELEASE(ITER) (H5S_select_iter_release(ITER)) #endif /* H5S_MODULE */ + /* Handle these callbacks in a special way, since they have prologs that need to be executed */ #define H5S_SELECT_COPY(DST,SRC,SHARE) (H5S_select_copy(DST,SRC,SHARE)) #define H5S_SELECT_SHAPE_SAME(S1,S2) (H5S_select_shape_same(S1,S2)) diff --git a/src/H5Sselect.c b/src/H5Sselect.c index 47909f5..c9d7fc0 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -32,6 +32,7 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ #include "H5Spkg.h" /* Dataspaces */ #include "H5VMprivate.h" /* Vector and array functions */ @@ -144,8 +145,8 @@ H5S_select_offset(H5S_t *space, const hssize_t *offset) herr_t H5Soffset_simple(hid_t space_id, const hssize_t *offset) { - H5S_t *space; /* Dataspace to query */ - herr_t ret_value = SUCCEED; /* Return value */ + H5S_t *space; /* Dataspace to modify */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*Hs", space_id, offset); @@ -582,7 +583,7 @@ H5S_select_deserialize(H5S_t **space, const uint8_t **p) default: break; - } /* end switch */ + } if(ret_value < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTLOAD, FAIL, "can't deserialize selection") @@ -1170,7 +1171,7 @@ H5S_select_iter_init(H5S_sel_iter_t *sel_iter, const H5S_t *space, if(sel_iter->rank > 0) { H5MM_memcpy(sel_iter->dims, space->extent.size, sizeof(hsize_t) * space->extent.rank); H5MM_memcpy(sel_iter->sel_off, space->select.offset, sizeof(hsize_t) * space->extent.rank); - } /* end if */ + } /* Save the element size */ sel_iter->elmt_size = elmt_size; @@ -2610,9 +2611,9 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, { H5S_t *new_space = NULL; /* New dataspace constructed */ H5S_t *tmp_src_intersect_space = NULL; /* Temporary SIS converted from points->hyperslabs */ - H5S_sel_iter_t ss_iter; /* Selection iterator for src_space */ + H5S_sel_iter_t *ss_iter = NULL; /* Selection iterator for src_space */ hbool_t ss_iter_init = FALSE; /* Whether ss_iter has been initialized */ - H5S_sel_iter_t ds_iter; /* Selection iterator for dst_space */ + H5S_sel_iter_t *ds_iter = NULL; /* Selection iterator for dst_space */ hbool_t ds_iter_init = FALSE; /* Whether ds_iter has been initialized */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2626,6 +2627,11 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, HDassert(H5S_GET_SELECT_NPOINTS(src_space) == H5S_GET_SELECT_NPOINTS(dst_space)); HDassert(H5S_GET_EXTENT_NDIMS(src_space) == H5S_GET_EXTENT_NDIMS(src_intersect_space)); + if(NULL == (ss_iter = H5FL_CALLOC(H5S_sel_iter_t))) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate selection iterator") + if(NULL == (ds_iter = H5FL_CALLOC(H5S_sel_iter_t))) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate selection iterator") + /* Create new space, using dst extent. Start with "all" selection. */ if(NULL == (new_space = H5S_create(H5S_SIMPLE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "unable to create output dataspace") @@ -2726,20 +2732,20 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") /* Initialize iterators */ - if(H5S_select_iter_init(&ss_iter, src_space, 1, H5S_SEL_ITER_SHARE_WITH_DATASPACE) < 0) + if(H5S_select_iter_init(ss_iter, src_space, 1, H5S_SEL_ITER_SHARE_WITH_DATASPACE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't initialize source space selection iterator") ss_iter_init = TRUE; - if(H5S_select_iter_init(&ds_iter, dst_space, 1, H5S_SEL_ITER_SHARE_WITH_DATASPACE) < 0) + if(H5S_select_iter_init(ds_iter, dst_space, 1, H5S_SEL_ITER_SHARE_WITH_DATASPACE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't initialize destination space selection iterator") ds_iter_init = TRUE; /* Iterate over points */ do { - HDassert(ss_iter.elmt_left > 0); - HDassert(ss_iter.elmt_left > 0); + HDassert(ss_iter->elmt_left > 0); + HDassert(ss_iter->elmt_left > 0); /* Get SS coords */ - if(H5S_SELECT_ITER_COORDS(&ss_iter, coords) < 0) + if(H5S_SELECT_ITER_COORDS(ss_iter, coords) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get source selection coordinates") /* Check for intersection */ @@ -2749,7 +2755,7 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, /* Add point if it intersects */ if(intersect) { /* Get DS coords */ - if(H5S_SELECT_ITER_COORDS(&ds_iter, coords) < 0) + if(H5S_SELECT_ITER_COORDS(ds_iter, coords) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get destination selection coordinates") /* Add point to new_space */ @@ -2758,14 +2764,14 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, } /* end if */ /* Advance iterators */ - if(H5S_SELECT_ITER_NEXT(&ss_iter, 1) < 0) + if(H5S_SELECT_ITER_NEXT(ss_iter, 1) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTNEXT, FAIL, "can't advacne source selection iterator") - ss_iter.elmt_left--; - if(H5S_SELECT_ITER_NEXT(&ds_iter, 1) < 0) + ss_iter->elmt_left--; + if(H5S_SELECT_ITER_NEXT(ds_iter, 1) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTNEXT, FAIL, "can't advacne destination selection iterator") - ds_iter.elmt_left--; - } while(ss_iter.elmt_left > 0); - HDassert(H5S_SELECT_ITER_NELMTS(&ds_iter) == 0); + ds_iter->elmt_left--; + } while(ss_iter->elmt_left > 0); + HDassert(H5S_SELECT_ITER_NELMTS(ds_iter) == 0); } /* end if */ else { HDassert(H5S_GET_SELECT_TYPE(src_space) != H5S_SEL_NONE); @@ -2792,11 +2798,14 @@ done: /* General cleanup */ if(tmp_src_intersect_space && H5S_close(tmp_src_intersect_space) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release temporary dataspace") - if(ss_iter_init && H5S_SELECT_ITER_RELEASE(&ss_iter) < 0) + if(ss_iter_init && H5S_SELECT_ITER_RELEASE(ss_iter) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release source selection iterator") - if(ds_iter_init && H5S_SELECT_ITER_RELEASE(&ds_iter) < 0) + if(ds_iter_init && H5S_SELECT_ITER_RELEASE(ds_iter) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release destination selection iterator") + ss_iter = H5FL_FREE(H5S_sel_iter_t, ss_iter); + ds_iter = H5FL_FREE(H5S_sel_iter_t, ds_iter); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_project_intersection() */ diff --git a/src/H5T.c b/src/H5T.c index a097b25..898c82a 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -1754,15 +1754,16 @@ H5Tcopy(hid_t obj_id) switch(H5I_get_type(obj_id)) { case H5I_DATATYPE: + /* The argument is a datatype handle */ if(NULL == (dt = (H5T_t *)H5I_object(obj_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "type_id is not a datatype ID") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "obj_id is not a datatype ID") break; case H5I_DATASET: { H5VL_object_t *vol_obj = NULL; /* Dataset structure */ - /* Check args */ + /* The argument is a dataset handle */ if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(obj_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "type_id is not a dataset ID") @@ -1775,9 +1776,8 @@ H5Tcopy(hid_t obj_id) /* Unwrap the type ID */ if(NULL == (dt = (H5T_t *)H5I_object(dset_tid))) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, H5I_INVALID_HID, "received invalid datatype from the dataset") - - break; } + break; case H5I_UNINIT: case H5I_BADID: @@ -1801,7 +1801,7 @@ H5Tcopy(hid_t obj_id) /* Copy datatype */ if(NULL == (new_dt = H5T_copy(dt, H5T_COPY_TRANSIENT))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5I_INVALID_HID, "unable to copy") + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5I_INVALID_HID, "unable to copy"); /* Get an ID for the copied datatype */ if((ret_value = H5I_register(H5I_DATATYPE, new_dt, TRUE)) < 0) @@ -2344,9 +2344,9 @@ H5T_get_super(const H5T_t *dt) HDassert(dt); if(!dt->shared->parent) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "not a derived data type") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "not a derived data type"); if(NULL == (ret_value = H5T_copy(dt->shared->parent, H5T_COPY_ALL))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy parent data type") + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy parent data type"); done: FUNC_LEAVE_NOAPI(ret_value) @@ -3221,7 +3221,7 @@ H5T__create(H5T_class_t type, size_t size) /* Copy the default string datatype */ if(NULL == (dt = H5T_copy(origin_dt, H5T_COPY_TRANSIENT))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy") + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy"); /* Modify the datatype */ if(H5T__set_size(dt, size) < 0) @@ -3999,7 +3999,7 @@ H5T_close_real(H5T_t *dt) /* Clean up resources, depending on shared state */ if(dt->shared->state != H5T_STATE_OPEN) { if(H5T__free(dt) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "unable to free datatype") + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "unable to free datatype"); dt->shared = H5FL_FREE(H5T_shared_t, dt->shared); } /* end if */ @@ -4093,7 +4093,7 @@ H5T_close(H5T_t *dt) /* Clean up resources */ if(H5T_close_real(dt) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "unable to free datatype") + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "unable to free datatype"); done: FUNC_LEAVE_NOAPI(ret_value) @@ -4142,7 +4142,7 @@ H5T__set_size(H5T_t *dt, size_t size) if(dt->shared->parent) { if(H5T__set_size(dt->shared->parent, size) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set size for parent data type") + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set size for parent data type"); /* Adjust size of datatype appropriately */ if(dt->shared->type==H5T_ARRAY) @@ -4184,7 +4184,7 @@ H5T__set_size(H5T_t *dt, size_t size) size_t max_size; if((num_membs = H5T_get_nmembers(dt)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to get number of members") + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to get number of members"); if(num_membs) { for(i = 0; i < (unsigned)num_membs; i++) { @@ -4198,7 +4198,7 @@ H5T__set_size(H5T_t *dt, size_t size) max_size = H5T__get_member_size(dt, max_index); if(size < (max_offset + max_size)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "size shrinking will cut off last member ") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "size shrinking will cut off last member "); } /* end if */ /* Compound must not have been packed previously */ @@ -4218,7 +4218,7 @@ H5T__set_size(H5T_t *dt, size_t size) /* Get a copy of unsigned char type as the base/parent type */ if(NULL == (base = (H5T_t *)H5I_object(H5T_NATIVE_UCHAR))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid base datatype") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid base datatype"); dt->shared->parent=H5T_copy(base,H5T_COPY_ALL); /* change this datatype into a VL string */ @@ -4244,7 +4244,7 @@ H5T__set_size(H5T_t *dt, size_t size) /* Set up VL information */ if (H5T_set_loc(dt, NULL, H5T_LOC_MEMORY)<0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location") + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location"); } /* end if */ else { prec = 8 * size; @@ -4260,7 +4260,7 @@ H5T__set_size(H5T_t *dt, size_t size) if(dt->shared->u.atomic.u.f.sign >= prec+offset || dt->shared->u.atomic.u.f.epos + dt->shared->u.atomic.u.f.esize > prec+offset || dt->shared->u.atomic.u.f.mpos + dt->shared->u.atomic.u.f.msize > prec+offset) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "adjust sign, mantissa, and exponent fields first") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "adjust sign, mantissa, and exponent fields first"); } break; @@ -4400,7 +4400,7 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset) /* Build an index for each type so the names are sorted */ if(NULL == (idx1 = (unsigned *)H5MM_malloc(dt1->shared->u.compnd.nmembs * sizeof(unsigned))) || NULL == (idx2 = (unsigned *)H5MM_malloc(dt2->shared->u.compnd.nmembs * sizeof(unsigned)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed"); for(u = 0; u < dt1->shared->u.compnd.nmembs; u++) idx1[u] = idx2[u] = u; if(dt1->shared->u.enumer.nmembs > 1) { @@ -4486,7 +4486,7 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset) /* Build an index for each type so the names are sorted */ if(NULL == (idx1 = (unsigned *)H5MM_malloc(dt1->shared->u.enumer.nmembs * sizeof(unsigned))) || NULL == (idx2 = (unsigned *)H5MM_malloc(dt2->shared->u.enumer.nmembs * sizeof(unsigned)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed"); for(u=0; ushared->u.enumer.nmembs; u++) idx1[u] = u; if(dt1->shared->u.enumer.nmembs > 1) { @@ -5271,16 +5271,21 @@ H5T_convert(H5T_path_t *tpath, hid_t src_id, hid_t dst_id, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg) { #ifdef H5T_DEBUG - H5_timer_t timer; + H5_timer_t timer; /* Timer for conversion */ #endif herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) #ifdef H5T_DEBUG - if(H5DEBUG(T)) - H5_timer_begin(&timer); + if(H5DEBUG(T)) { + /* Initialize and start timer */ + H5_timer_init(&timer); + H5_timer_start(&timer); + } /* end if */ #endif + + /* Call the appropriate conversion callback */ tpath->cdata.command = H5T_CONV_CONV; if(tpath->conv.is_app) { if((tpath->conv.u.app_func)(src_id, dst_id, &(tpath->cdata), nelmts, buf_stride, bkg_stride, buf, bkg, H5CX_get_dxpl()) < 0) @@ -5291,10 +5296,16 @@ H5T_convert(H5T_path_t *tpath, hid_t src_id, hid_t dst_id, size_t nelmts, HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "datatype conversion failed") #ifdef H5T_DEBUG if(H5DEBUG(T)) { - H5_timer_end(&(tpath->stats.timer), &timer); + /* Stop timer */ + H5_timer_stop(&timer); + + /* Record elapsed timer info */ + H5_timer_get_times(timer, &tpath->stats.times); + + /* Increment # of calls and # of elements converted */ tpath->stats.ncalls++; tpath->stats.nelmts += nelmts; - } + } /* end if */ #endif done: @@ -5660,7 +5671,7 @@ H5T_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) /* Range check against compound member's offset */ if ((accum_change < 0) && ((ssize_t) dt->shared->u.compnd.memb[i].offset < accum_change)) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid field size in datatype") + HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid field size in datatype"); /* Apply the accumulated size change to the offset of the field */ dt->shared->u.compnd.memb[i].offset += (size_t) accum_change; @@ -5676,7 +5687,7 @@ H5T_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) /* Mark the VL, compound, enum or array type */ if((changed = H5T_set_loc(memb_type, file, loc)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location") + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location"); if(changed > 0) ret_value = changed; @@ -5685,7 +5696,7 @@ H5T_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) /* Fail if the old_size is zero */ if (0 == old_size) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "old_size of zero would cause division by zero") + HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "old_size of zero would cause division by zero"); /* Adjust the size of the member */ dt->shared->u.compnd.memb[i].size = (dt->shared->u.compnd.memb[i].size*memb_type->shared->size)/old_size; @@ -5698,7 +5709,7 @@ H5T_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) /* Range check against datatype size */ if ((accum_change < 0) && ((ssize_t) dt->shared->size < accum_change)) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid field size in datatype") + HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid field size in datatype"); /* Apply the accumulated size change to the datatype */ dt->shared->size += (size_t) accum_change; @@ -5710,14 +5721,14 @@ H5T_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) /* (If the force_conv flag is _not_ set, the type cannot change in size, so don't recurse) */ if(dt->shared->parent->shared->force_conv && H5T_IS_COMPLEX(dt->shared->parent->shared->type)) { if((changed = H5T_set_loc(dt->shared->parent, file, loc)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location") + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location"); if(changed > 0) ret_value = changed; } /* end if */ /* Mark this VL sequence */ if((changed = H5T__vlen_set_loc(dt, file, loc)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location") + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location"); if(changed > 0) ret_value = changed; break; diff --git a/src/H5TS.c b/src/H5TS.c index 3643ed5..ee3b219 100644 --- a/src/H5TS.c +++ b/src/H5TS.c @@ -678,3 +678,4 @@ H5TS_create_thread(void *(*func)(void *), H5TS_attr_t *attr, void *udata) } /* H5TS_create_thread */ #endif /* H5_HAVE_THREADSAFE */ + diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 06eb44e..15658cc 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -3110,8 +3110,24 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, if(NULL == (tpath = H5T_path_find(src->shared->parent, dst->shared->parent))) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest datatypes") else if(!H5T_path_noop(tpath)) { - if((tsrc_id = H5I_register(H5I_DATATYPE, H5T_copy(src->shared->parent, H5T_COPY_ALL), FALSE)) < 0 || - (tdst_id = H5I_register(H5I_DATATYPE, H5T_copy(dst->shared->parent, H5T_COPY_ALL), FALSE)) < 0) + H5T_t *tsrc_cpy = NULL, *tdst_cpy = NULL; + + if(NULL == (tsrc_cpy = H5T_copy(src->shared->parent, H5T_COPY_ALL))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "unable to copy src type for conversion") + /* References need to know about the src file */ + if(tsrc_cpy->shared->type == H5T_REFERENCE) + if(H5T_set_loc(tsrc_cpy, src->shared->u.vlen.file, H5T_LOC_MEMORY) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set datatype location"); + + if(NULL == (tdst_cpy = H5T_copy(dst->shared->parent, H5T_COPY_ALL))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "unable to copy dst type for conversion") + /* References need to know about the dst file */ + if(tdst_cpy->shared->type == H5T_REFERENCE) + if(H5T_set_loc(tdst_cpy, dst->shared->u.vlen.file, H5T_LOC_MEMORY) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set datatype location"); + + if(((tsrc_id = H5I_register(H5I_DATATYPE, tsrc_cpy, FALSE)) < 0) + || ((tdst_id = H5I_register(H5I_DATATYPE, tdst_cpy, FALSE)) < 0)) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion") } /* end else-if */ else diff --git a/src/H5Tdbg.c b/src/H5Tdbg.c index 605310a..6188138 100644 --- a/src/H5Tdbg.c +++ b/src/H5Tdbg.c @@ -13,11 +13,11 @@ /*------------------------------------------------------------------------- * - * Created: H5Tdbg.c - * Jul 19 2007 - * Quincey Koziol + * Created: H5Tdbg.c + * Jul 19 2007 + * Quincey Koziol * - * Purpose: Dump debugging information about a datatype + * Purpose: Dump debugging information about a datatype * *------------------------------------------------------------------------- */ @@ -95,25 +95,24 @@ herr_t H5T__print_stats(H5T_path_t H5_ATTR_UNUSED * path, int H5_ATTR_UNUSED * nprint/*in,out*/) { -#ifdef H5T_DEBUG - hsize_t nbytes; - char bandwidth[32]; -#endif - FUNC_ENTER_PACKAGE_NOERR #ifdef H5T_DEBUG - if (H5DEBUG(T) && path->stats.ncalls > 0) { - if (nprint && 0 == (*nprint)++) { - HDfprintf(H5DEBUG(T), "H5T: type conversion statistics:\n"); - HDfprintf(H5DEBUG(T), " %-16s %10s %10s %8s %8s %8s %10s\n", - "Conversion", "Elmts", "Calls", "User", - "System", "Elapsed", "Bandwidth"); - HDfprintf(H5DEBUG(T), " %-16s %10s %10s %8s %8s %8s %10s\n", - "----------", "-----", "-----", "----", - "------", "-------", "---------"); - } - if (path->src && path->dst) + if(H5DEBUG(T) && path->stats.ncalls > 0) { + hsize_t nbytes; + char bandwidth[32]; + + if(nprint && 0 == (*nprint)++) { + HDfprintf(H5DEBUG(T), "H5T: type conversion statistics:\n"); + HDfprintf(H5DEBUG(T), " %-16s %10s %10s %8s %8s %8s %10s\n", + "Conversion", "Elmts", "Calls", "User", + "System", "Elapsed", "Bandwidth"); + HDfprintf(H5DEBUG(T), " %-16s %10s %10s %8s %8s %8s %10s\n", + "----------", "-----", "-----", "----", + "------", "-------", "---------"); + } /* end if */ + + if(path->src && path->dst) nbytes = MAX(H5T_get_size(path->src), H5T_get_size(path->dst)); else if (path->src) nbytes = H5T_get_size(path->src); @@ -121,18 +120,20 @@ H5T__print_stats(H5T_path_t H5_ATTR_UNUSED * path, int H5_ATTR_UNUSED * nprint/* nbytes = H5T_get_size(path->dst); else nbytes = 0; - nbytes *= path->stats.nelmts; - H5_bandwidth(bandwidth, (double)nbytes, path->stats.timer.etime); - HDfprintf(H5DEBUG(T), " %-16s %10Hd %10d %8.2f %8.2f %8.2f %10s\n", - path->name, - path->stats.nelmts, - path->stats.ncalls, - path->stats.timer.utime, - path->stats.timer.stime, - path->stats.timer.etime, - bandwidth); - } + + nbytes *= path->stats.nelmts; + H5_bandwidth(bandwidth, (double)nbytes, path->stats.times.elapsed); + HDfprintf(H5DEBUG(T), " %-16s %10Hd %10d %8T %8T %8T %10s\n", + path->name, + path->stats.nelmts, + path->stats.ncalls, + path->stats.times.user, + path->stats.times.system, + path->stats.times.elapsed, + bandwidth); + } /* end if */ #endif + FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5T__print_stats() */ @@ -405,18 +406,18 @@ H5T_debug(const H5T_t *dt, FILE *stream) } /* end else */ } else if (H5T_ENUM == dt->shared->type) { - size_t base_size; + size_t base_size; /* Enumeration data type */ HDfprintf(stream, " "); H5T_debug(dt->shared->parent, stream); base_size = dt->shared->parent->shared->size; for (i = 0; i < dt->shared->u.enumer.nmembs; i++) { - size_t k; + size_t k; HDfprintf(stream, "\n\"%s\" = 0x", dt->shared->u.enumer.name[i]); for (k = 0; k < base_size; k++) - HDfprintf(stream, "%02lx", (unsigned long)((uint8_t *)dt->shared->u.enumer.value + (i * base_size) + k)); + HDfprintf(stream, "%02p", ((uint8_t *)dt->shared->u.enumer.value + (i * base_size) + k)); } /* end for */ HDfprintf(stream, "\n"); } diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h index 39bff15..600d7aa 100644 --- a/src/H5Tpkg.h +++ b/src/H5Tpkg.h @@ -152,7 +152,7 @@ struct H5T_stats_t { unsigned ncalls; /*num calls to conversion function */ hsize_t nelmts; /*total data points converted */ - H5_timer_t timer; /*total time for conversion */ + H5_timevals_t times; /*total time for conversion */ }; /* Library internal datatype conversion functions are... */ diff --git a/src/H5Tref.c b/src/H5Tref.c index f97b78a..7c59e75 100644 --- a/src/H5Tref.c +++ b/src/H5Tref.c @@ -144,7 +144,9 @@ H5T__ref_set_loc(const H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) switch(loc) { case H5T_LOC_MEMORY: /* Memory based reference datatype */ - HDassert(NULL == file); + + /* NB. We allow for the file to be non-NULL when doing + * memory-to-memory conversion */ /* Mark this type as being stored in memory */ dt->shared->u.atomic.u.r.loc = H5T_LOC_MEMORY; @@ -364,9 +366,8 @@ static size_t H5T__ref_mem_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, size_t H5_ATTR_UNUSED src_size, H5VL_object_t *dst_file, hbool_t *dst_copy) { - H5VL_object_t *vol_obj; /* VOL object for src ref's location */ + H5VL_object_t *vol_obj = NULL; /* VOL object for src ref's location */ const H5R_ref_priv_t *src_ref = (const H5R_ref_priv_t *)src_buf; - hbool_t files_equal = FALSE; /* Whether src & dst references are in same file */ char *file_name_buf_dyn = NULL; /* Pointer to dynamically allocated buffer for file name, if static buffer is too small */ unsigned flags = 0; /* References flags */ size_t ret_value = 0; /* Return value */ @@ -377,14 +378,18 @@ H5T__ref_mem_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf HDassert(src_buf); HDassert(src_size == H5T_REF_MEM_SIZE); - /* Retrieve VOL object */ - if(NULL == (vol_obj = H5VL_vol_object(src_ref->loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "invalid location identifier") + if(NULL != dst_file) { + hbool_t files_equal = TRUE; /* Whether src & dst references are in same file */ - /* Set external flag if referenced file is not destination file */ - if(H5VL_file_is_same(vol_obj, dst_file, &files_equal) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOMPARE, 0, "can't check if files are equal") - flags |= !files_equal ? H5R_IS_EXTERNAL : 0; + /* Retrieve VOL object */ + if(NULL == (vol_obj = H5VL_vol_object(src_ref->loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "invalid location identifier") + + /* Set external flag if referenced file is not destination file */ + if(H5VL_file_is_same(vol_obj, dst_file, &files_equal) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOMPARE, 0, "can't check if files are equal") + flags |= !files_equal ? H5R_IS_EXTERNAL : 0; + } /* Force re-calculating encoding size if any flags are set */ if(flags || !src_ref->encode_size) { @@ -458,8 +463,8 @@ H5T__ref_mem_read(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, { H5VL_object_t *vol_obj; /* VOL object for src ref's location */ const H5R_ref_priv_t *src_ref = (const H5R_ref_priv_t *)src_buf; - hbool_t files_equal = FALSE; /* Whether src & dst references are in same file */ - char file_name_buf_static[256]; /* File name */ + hbool_t files_equal = TRUE; /* Whether src & dst references are in same file */ + char file_name_buf_static[256] = {'\0'}; /* File name */ char *file_name_buf_dyn = NULL; /* Pointer to dynamically allocated buffer for file name, if static buffer is too small */ ssize_t file_name_len; /* Size of file name buffer */ unsigned flags = 0; /* References flags */ @@ -470,10 +475,15 @@ H5T__ref_mem_read(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, /* Sanity check */ HDassert(src_buf); HDassert(src_size == H5T_REF_MEM_SIZE); - HDassert(dst_file); HDassert(dst_buf); HDassert(dst_size); + /* Memory-to-memory conversion to support vlen conversion */ + if(NULL == dst_file) { + HDmemcpy(dst_buf, src_buf, dst_size); + HGOTO_DONE(ret_value); + } + /* Retrieve VOL object */ if(NULL == (vol_obj = H5VL_vol_object(src_ref->loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "invalid location identifier") @@ -504,14 +514,16 @@ H5T__ref_mem_read(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, H5CX_set_libver_bounds(NULL); } /* end if */ - /* Get file name */ - if(H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, NULL, H5I_FILE, sizeof(file_name_buf_static), file_name_buf_static, &file_name_len) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, 0, "can't get file name") - if(file_name_len >= (ssize_t)sizeof(file_name_buf_static)) { - if(NULL == (file_name_buf_dyn = (char *)H5MM_malloc((size_t)file_name_len + 1))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, 0, "can't allocate space for file name") - if(H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, NULL, H5I_FILE, (size_t)file_name_len + 1, file_name_buf_dyn, &file_name_len) < 0) + /* Get file name (if external reference) */ + if(flags) { + if(H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, NULL, H5I_FILE, sizeof(file_name_buf_static), file_name_buf_static, &file_name_len) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, 0, "can't get file name") + if(file_name_len >= (ssize_t)sizeof(file_name_buf_static)) { + if(NULL == (file_name_buf_dyn = (char *)H5MM_malloc((size_t)file_name_len + 1))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, 0, "can't allocate space for file name") + if(H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, NULL, H5I_FILE, (size_t)file_name_len + 1, file_name_buf_dyn, &file_name_len) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, 0, "can't get file name") + } /* end if */ } /* end if */ /* Encode reference */ @@ -539,7 +551,7 @@ H5T__ref_mem_write(H5VL_object_t *src_file, const void *src_buf, size_t src_size H5R_type_t src_type, H5VL_object_t H5_ATTR_UNUSED *dst_file, void *dst_buf, size_t dst_size, void H5_ATTR_UNUSED *bg_buf) { - H5F_t *src_f; + H5F_t *src_f = NULL; hid_t file_id = H5I_INVALID_HID; H5R_ref_priv_t *dst_ref = (H5R_ref_priv_t *)dst_buf; herr_t ret_value = SUCCEED; @@ -547,14 +559,19 @@ H5T__ref_mem_write(H5VL_object_t *src_file, const void *src_buf, size_t src_size FUNC_ENTER_STATIC /* Sanity check */ - HDassert(src_file); HDassert(src_buf); HDassert(src_size); HDassert(dst_buf); HDassert(dst_size == H5T_REF_MEM_SIZE); + /* Memory-to-memory conversion to support vlen conversion */ + if(NULL == src_file) { + HDmemcpy(dst_buf, src_buf, src_size); + HGOTO_DONE(ret_value); + } + #ifndef NDEBUG - { + if((src_type == H5R_OBJECT1) || (src_type == H5R_DATASET_REGION1)) { hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ /* Check if using native VOL connector */ @@ -800,7 +817,7 @@ H5T__ref_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t H5_ATTR_ HDassert(dst_size); /* Copy header manually */ - HDmemcpy(q, p, H5R_ENCODE_HEADER_SIZE); + H5MM_memcpy(q, p, H5R_ENCODE_HEADER_SIZE); p += H5R_ENCODE_HEADER_SIZE; q += H5R_ENCODE_HEADER_SIZE; blob_size -= H5R_ENCODE_HEADER_SIZE; @@ -860,7 +877,7 @@ H5T__ref_disk_write(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, } /* end if */ /* Copy header manually so that it does not get encoded into the blob */ - HDmemcpy(q, p, H5R_ENCODE_HEADER_SIZE); + H5MM_memcpy(q, p, H5R_ENCODE_HEADER_SIZE); p += H5R_ENCODE_HEADER_SIZE; q += H5R_ENCODE_HEADER_SIZE; src_size -= H5R_ENCODE_HEADER_SIZE; diff --git a/src/H5VL.c b/src/H5VL.c index 18fd3d6..c4f38dd 100644 --- a/src/H5VL.c +++ b/src/H5VL.c @@ -663,7 +663,7 @@ done: /*--------------------------------------------------------------------------- * Function: H5VLobject * - * Purpose: Retrieve the object pointer associated with an hid_t for a. + * Purpose: Retrieve the object pointer associated with an hid_t for a * VOL object. * * Note: This routine is mainly targeted toward unwrapping objects for @@ -903,7 +903,7 @@ H5VLfree_lib_state(void *state) /* Check args */ if(NULL == state) - HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "invalid state pointer") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid state pointer") /* Free the library state */ if(H5VL_free_lib_state(state) < 0) @@ -913,3 +913,38 @@ done: FUNC_LEAVE_API(ret_value) } /* H5VLfree_lib_state() */ + +/*--------------------------------------------------------------------------- + * Function: H5VLquery_optional + * + * Purpose: Determine if a VOL connector supports a particular optional + * callback operation. + * + * Return: Success: Non-negative + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLquery_optional(hid_t obj_id, H5VL_subclass_t subcls, int opt_type, hbool_t *supported) +{ + H5VL_object_t *vol_obj = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE4("e", "iVSIs*b", obj_id, subcls, opt_type, supported); + + /* Check args */ + if(NULL == supported) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid supported pointer") + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + + /* Query the connector */ + if(H5VL_introspect_opt_query(vol_obj, subcls, opt_type, supported) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to query VOL connector support") + +done: + FUNC_LEAVE_API(ret_value) +} /* H5VLquery_optional() */ + diff --git a/src/H5VLcallback.c b/src/H5VLcallback.c index e4ebb95..5c54b5b 100644 --- a/src/H5VLcallback.c +++ b/src/H5VLcallback.c @@ -525,7 +525,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_free_connector_info(hid_t connector_id, void *info) +H5VL_free_connector_info(hid_t connector_id, const void *info) { H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ @@ -543,12 +543,13 @@ H5VL_free_connector_info(hid_t connector_id, void *info) if(info) { /* Allow the connector to free info or do it ourselves */ if(cls->info_cls.free) { - if((cls->info_cls.free)(info) < 0) + /* Cast through uintptr_t to de-const memory */ + if((cls->info_cls.free)((void *)(uintptr_t)info) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "connector info free request failed") - } /* end if */ + } else - H5MM_xfree(info); - } /* end if */ + H5MM_xfree_const(info); + } done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5VLconnector.h b/src/H5VLconnector.h index 39d9b14..4a35f22 100644 --- a/src/H5VLconnector.h +++ b/src/H5VLconnector.h @@ -48,24 +48,6 @@ /* Public Typedefs */ /*******************/ -/* Enum type for each VOL subclass */ -/* (Used for various queries, etc) */ -typedef enum H5VL_subclass_t { - H5VL_SUBCLS_NONE, /* Operations outside of a subclass */ - H5VL_SUBCLS_INFO, /* 'Info' subclass */ - H5VL_SUBCLS_WRAP, /* 'Wrap' subclass */ - H5VL_SUBCLS_ATTR, /* 'Attribute' subclass */ - H5VL_SUBCLS_DATASET, /* 'Dataset' subclass */ - H5VL_SUBCLS_DATATYPE, /* 'Named datatype' subclass */ - H5VL_SUBCLS_FILE, /* 'File' subclass */ - H5VL_SUBCLS_GROUP, /* 'Group' subclass */ - H5VL_SUBCLS_LINK, /* 'Link' subclass */ - H5VL_SUBCLS_OBJECT, /* 'Object' subclass */ - H5VL_SUBCLS_REQUEST, /* 'Request' subclass */ - H5VL_SUBCLS_BLOB, /* 'Blob' subclass */ - H5VL_SUBCLS_TOKEN /* 'Token' subclass */ -} H5VL_subclass_t; - /* types for attribute GET callback */ typedef enum H5VL_attr_get_t { H5VL_ATTR_GET_ACPL, /* creation property list */ @@ -194,7 +176,7 @@ typedef enum H5VL_object_get_t { H5VL_OBJECT_GET_FILE, /* object file */ H5VL_OBJECT_GET_NAME, /* object name */ H5VL_OBJECT_GET_TYPE, /* object type */ - H5VL_OBJECT_GET_INFO /* H5Oget_info(_by_idx|name)3 */ + H5VL_OBJECT_GET_INFO /* H5Oget_info(_by_idx|name) */ } H5VL_object_get_t; /* types for object SPECIFIC callback */ diff --git a/src/H5VLint.c b/src/H5VLint.c index 39b0f53..861629f 100644 --- a/src/H5VLint.c +++ b/src/H5VLint.c @@ -273,7 +273,7 @@ H5VL_term_package(void) else { if(H5I_nmembers(H5I_VOL) > 0) { /* Unregister all VOL connectors */ - (void)H5I_clear_type(H5I_VOL, FALSE, FALSE); + (void)H5I_clear_type(H5I_VOL, TRUE, FALSE); n++; } /* end if */ else { @@ -318,7 +318,7 @@ H5VL__free_cls(H5VL_class_t *cls) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "VOL connector did not terminate cleanly") /* Release the class */ - H5MM_xfree((void *)cls->name); /* Casting away const OK -QAK */ + H5MM_xfree_const(cls->name); H5FL_FREE(H5VL_class_t, cls); done: @@ -682,14 +682,14 @@ H5VL_conn_free(const H5VL_connector_prop_t *connector_prop) if(connector_prop->connector_id > 0) { if(connector_prop->connector_info) /* Free the connector info */ - if(H5VL_free_connector_info(connector_prop->connector_id, (void *)connector_prop->connector_info) < 0) /* Casting away const OK - QAK */ + if(H5VL_free_connector_info(connector_prop->connector_id, connector_prop->connector_info) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to release VOL connector info object") /* Decrement reference count for connector ID */ if(H5I_dec_ref(connector_prop->connector_id) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "can't decrement reference count for connector ID") - } /* end if */ - } /* end if */ + } + } done: FUNC_LEAVE_NOAPI(ret_value) @@ -1144,7 +1144,7 @@ H5VL_register_connector(const void *_cls, hbool_t app_ref, hid_t vipl_id) done: if(ret_value < 0 && saved) { if(saved->name) - H5MM_xfree((void *)(saved->name)); /* Casting away const OK -QAK */ + H5MM_xfree_const(saved->name); H5FL_FREE(H5VL_class_t, saved); } /* end if */ diff --git a/src/H5VLnative_attr.c b/src/H5VLnative_attr.c index 16d3527..1798a0e 100644 --- a/src/H5VLnative_attr.c +++ b/src/H5VLnative_attr.c @@ -525,7 +525,8 @@ done: */ herr_t H5VL__native_attr_optional(void H5_ATTR_UNUSED *obj, H5VL_attr_optional_t opt_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, + va_list H5_ATTR_DEPRECATED_USED arguments) { herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5VLnative_group.c b/src/H5VLnative_group.c index 13864ab..cca5c55 100644 --- a/src/H5VLnative_group.c +++ b/src/H5VLnative_group.c @@ -266,8 +266,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL__native_group_optional(void *obj, H5VL_group_optional_t optional_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +H5VL__native_group_optional(void H5_ATTR_UNUSED *obj, + H5VL_group_optional_t optional_type, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list H5_ATTR_DEPRECATED_USED arguments) { herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5VLpassthru.c b/src/H5VLpassthru.c index 8b3dc62..2cf470e 100644 --- a/src/H5VLpassthru.c +++ b/src/H5VLpassthru.c @@ -1591,6 +1591,10 @@ H5VL_pass_through_file_create(const char *name, unsigned flags, hid_t fcpl_id, /* Get copy of our VOL info from FAPL */ H5Pget_vol_info(fapl_id, (void **)&info); + /* Make sure we have info about the underlying VOL to be used */ + if (!info) + return NULL; + /* Copy the FAPL */ under_fapl_id = H5Pcopy(fapl_id); @@ -1645,6 +1649,10 @@ H5VL_pass_through_file_open(const char *name, unsigned flags, hid_t fapl_id, /* Get copy of our VOL info from FAPL */ H5Pget_vol_info(fapl_id, (void **)&info); + /* Make sure we have info about the underlying VOL to be used */ + if (!info) + return NULL; + /* Copy the FAPL */ under_fapl_id = H5Pcopy(fapl_id); @@ -1785,6 +1793,10 @@ H5VL_pass_through_file_specific(void *file, H5VL_file_specific_t specific_type, /* Get copy of our VOL info from FAPL */ H5Pget_vol_info(fapl_id, (void **)&info); + /* Make sure we have info about the underlying VOL to be used */ + if (!info) + return (-1); + /* Copy the FAPL */ under_fapl_id = H5Pcopy(fapl_id); diff --git a/src/H5VLprivate.h b/src/H5VLprivate.h index 24ae1f3..3235357 100644 --- a/src/H5VLprivate.h +++ b/src/H5VLprivate.h @@ -44,7 +44,7 @@ typedef struct H5VL_object_t { /* Internal structure to hold the connector ID & info for FAPLs */ typedef struct H5VL_connector_prop_t { hid_t connector_id; /* VOL connector's ID */ - void *connector_info; /* VOL connector info, for open callbacks */ + const void *connector_info; /* VOL connector info, for open callbacks */ } H5VL_connector_prop_t; /* Which kind of VOL connector field to use for searching */ @@ -128,7 +128,7 @@ H5_DLL int H5VL_copy_connector_info(const H5VL_class_t *connector, void **dst_in const void *src_info); H5_DLL herr_t H5VL_cmp_connector_info(const H5VL_class_t *connector, int *cmp_value, const void *info1, const void *info2); -H5_DLL herr_t H5VL_free_connector_info(hid_t connector_id, void *info); +H5_DLL herr_t H5VL_free_connector_info(hid_t connector_id, const void *info); /* Attribute functions */ H5_DLL void *H5VL_attr_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *attr_name, hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req); diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h index c8df035..8f79adc 100644 --- a/src/H5VLpublic.h +++ b/src/H5VLpublic.h @@ -48,6 +48,24 @@ typedef int H5VL_class_value_t; +/* Enum type for each VOL subclass */ +/* (Used for various queries, etc) */ +typedef enum H5VL_subclass_t { + H5VL_SUBCLS_NONE, /* Operations outside of a subclass */ + H5VL_SUBCLS_INFO, /* 'Info' subclass */ + H5VL_SUBCLS_WRAP, /* 'Wrap' subclass */ + H5VL_SUBCLS_ATTR, /* 'Attribute' subclass */ + H5VL_SUBCLS_DATASET, /* 'Dataset' subclass */ + H5VL_SUBCLS_DATATYPE, /* 'Named datatype' subclass */ + H5VL_SUBCLS_FILE, /* 'File' subclass */ + H5VL_SUBCLS_GROUP, /* 'Group' subclass */ + H5VL_SUBCLS_LINK, /* 'Link' subclass */ + H5VL_SUBCLS_OBJECT, /* 'Object' subclass */ + H5VL_SUBCLS_REQUEST, /* 'Request' subclass */ + H5VL_SUBCLS_BLOB, /* 'Blob' subclass */ + H5VL_SUBCLS_TOKEN /* 'Token' subclass */ +} H5VL_subclass_t; + /********************/ /* Public Variables */ /********************/ @@ -70,6 +88,7 @@ H5_DLL hid_t H5VLget_connector_id_by_value(H5VL_class_value_t connector_value); H5_DLL ssize_t H5VLget_connector_name(hid_t id, char *name/*out*/, size_t size); H5_DLL herr_t H5VLclose(hid_t connector_id); H5_DLL herr_t H5VLunregister_connector(hid_t connector_id); +H5_DLL herr_t H5VLquery_optional(hid_t obj_id, H5VL_subclass_t subcls, int opt_type, hbool_t *supported); #ifdef __cplusplus } diff --git a/src/H5Z.c b/src/H5Z.c index 53186f1..3bd4bcb 100644 --- a/src/H5Z.c +++ b/src/H5Z.c @@ -35,10 +35,10 @@ #ifdef H5Z_DEBUG typedef struct H5Z_stats_t { struct { - hsize_t total; /* total number of bytes processed */ - hsize_t errors; /* bytes of total attributable to errors */ - H5_timer_t timer; /* execution time including errors */ - } stats[2]; /* 0=output, 1=input */ + hsize_t total; /* total number of bytes processed */ + hsize_t errors; /* bytes of total attributable to errors */ + H5_timevals_t times; /* execution time including errors */ + } stats[2]; /* 0 = output, 1 = input */ } H5Z_stats_t; #endif /* H5Z_DEBUG */ @@ -132,9 +132,9 @@ H5Z_term_package(void) if(H5_PKG_INIT_VAR) { #ifdef H5Z_DEBUG - char comment[16], bandwidth[32]; - int dir, nprint = 0; - size_t i; + char comment[16], bandwidth[32]; + int dir, nprint = 0; + size_t i; if(H5DEBUG(Z)) { for(i = 0; i < H5Z_table_used_g; i++) { @@ -167,25 +167,26 @@ H5Z_term_package(void) */ H5_bandwidth(bandwidth, (double)(H5Z_stat_table_g[i].stats[dir].total), - H5Z_stat_table_g[i].stats[dir].timer.etime); + H5Z_stat_table_g[i].stats[dir].times.elapsed); /* Print the statistics */ - HDfprintf(H5DEBUG(Z), - " %s%-15s %10Hd %10Hd %8.2f %8.2f %8.2f " - "%10s\n", dir?"<":">", comment, + HDfprintf(H5DEBUG(Z), " %s%-15s %10Hd %10Hd %8T %8T %8T %10s\n", + (dir ? "<" : ">"), comment, H5Z_stat_table_g[i].stats[dir].total, H5Z_stat_table_g[i].stats[dir].errors, - H5Z_stat_table_g[i].stats[dir].timer.utime, - H5Z_stat_table_g[i].stats[dir].timer.stime, - H5Z_stat_table_g[i].stats[dir].timer.etime, + H5Z_stat_table_g[i].stats[dir].times.user, + H5Z_stat_table_g[i].stats[dir].times.system, + H5Z_stat_table_g[i].stats[dir].times.elapsed, bandwidth); } /* end for */ } /* end for */ } /* end if */ #endif /* H5Z_DEBUG */ + /* Free the table of filters */ - if (H5Z_table_g) { + if(H5Z_table_g) { H5Z_table_g = (H5Z_class2_t *)H5MM_xfree(H5Z_table_g); + #ifdef H5Z_DEBUG H5Z_stat_table_g = (H5Z_stats_t *)H5MM_xfree(H5Z_stat_table_g); #endif /* H5Z_DEBUG */ @@ -585,7 +586,8 @@ done: *------------------------------------------------------------------------- */ static int -H5Z__flush_file_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void *key) +H5Z__flush_file_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, + void *key H5_ATTR_PARALLEL_USED) { H5F_t *f = (H5F_t *)obj_ptr; /* File object for operations */ #ifdef H5_HAVE_PARALLEL @@ -1247,20 +1249,22 @@ done: */ herr_t H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, - unsigned *filter_mask/*in,out*/, H5Z_EDC_t edc_read, - H5Z_cb_t cb_struct, size_t *nbytes/*in,out*/, - size_t *buf_size/*in,out*/, void **buf/*in,out*/) + unsigned *filter_mask/*in,out*/, H5Z_EDC_t edc_read, H5Z_cb_t cb_struct, + size_t *nbytes/*in,out*/, size_t *buf_size/*in,out*/, void **buf/*in,out*/) { - size_t i, idx, new_nbytes; - int fclass_idx; /* Index of filter class in global table */ - H5Z_class2_t *fclass=NULL; /* Filter class pointer */ + size_t idx; + size_t new_nbytes; + int fclass_idx; /* Index of filter class in global table */ + H5Z_class2_t *fclass = NULL; /* Filter class pointer */ #ifdef H5Z_DEBUG - H5Z_stats_t *fstats=NULL; /* Filter stats pointer */ - H5_timer_t timer; + H5Z_stats_t *fstats = NULL; /* Filter stats pointer */ + H5_timer_t timer; /* Timer for filter operations */ + H5_timevals_t times; /* Elapsed time for each operation */ #endif - unsigned failed = 0; - unsigned tmp_flags; - herr_t ret_value = SUCCEED; /* Return value */ + unsigned failed = 0; + unsigned tmp_flags; + size_t i; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1271,11 +1275,13 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, HDassert(buf && *buf); HDassert(!pline || pline->nused < H5Z_MAX_NFILTERS); - if (pline && (flags & H5Z_FLAG_REVERSE)) { /* Read */ - for (i = pline->nused; i > 0; --i) { - idx = i-1; - - if (*filter_mask & ((unsigned)1 << idx)) { +#ifdef H5Z_DEBUG + H5_timer_init(&timer); +#endif + if(pline && (flags & H5Z_FLAG_REVERSE)) { /* Read */ + for(i = pline->nused; i > 0; --i) { + idx = i - 1; + if(*filter_mask & ((unsigned)1 << idx)) { failed |= (unsigned)1 << idx; continue; /* filter excluded */ } @@ -1285,9 +1291,9 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, * try to load it dynamically and register it. Otherwise, return failure */ if ((fclass_idx = H5Z_find_idx(pline->filter[idx].id)) < 0) { - hbool_t issue_error = FALSE; H5PL_key_t key; const H5Z_class2_t *filter_info; + hbool_t issue_error = FALSE; /* Try loading the filter */ key.id = (int)(pline->filter[idx].id); @@ -1297,7 +1303,7 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register filter") /* Search in the table of registered filters again to find the dynamic filter just loaded and registered */ - if ((fclass_idx = H5Z_find_idx(pline->filter[idx].id)) < 0) + if((fclass_idx = H5Z_find_idx(pline->filter[idx].id)) < 0) issue_error = TRUE; } else @@ -1315,76 +1321,96 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, } /* end if */ fclass = &H5Z_table_g[fclass_idx]; + #ifdef H5Z_DEBUG fstats = &H5Z_stat_table_g[fclass_idx]; - H5_timer_begin (&timer); + H5_timer_start(&timer); #endif + tmp_flags = flags | (pline->filter[idx].flags); - tmp_flags |= (edc_read== H5Z_DISABLE_EDC) ? H5Z_FLAG_SKIP_EDC : 0; - new_nbytes = (fclass->filter)(tmp_flags, pline->filter[idx].cd_nelmts, - pline->filter[idx].cd_values, *nbytes, buf_size, buf); + tmp_flags |= (edc_read == H5Z_DISABLE_EDC) ? H5Z_FLAG_SKIP_EDC : 0; + new_nbytes = (fclass->filter)(tmp_flags, + pline->filter[idx].cd_nelmts, pline->filter[idx].cd_values, + *nbytes, buf_size, buf); #ifdef H5Z_DEBUG - H5_timer_end (&(fstats->stats[1].timer), &timer); - fstats->stats[1].total += MAX(*nbytes, new_nbytes); - if (0 == new_nbytes) + H5_timer_stop(&timer); + H5_timer_get_times(timer, ×); + fstats->stats[1].times.elapsed += times.elapsed; + fstats->stats[1].times.system += times.system; + fstats->stats[1].times.user += times.user; + + fstats->stats[1].total += MAX(*nbytes, new_nbytes); + if(0 == new_nbytes) fstats->stats[1].errors += *nbytes; #endif - if (0 == new_nbytes) { - if ((cb_struct.func && (H5Z_CB_FAIL == cb_struct.func(pline->filter[idx].id, *buf, *buf_size, cb_struct.op_data))) || !cb_struct.func) + if(0 == new_nbytes) { + if((cb_struct.func + && (H5Z_CB_FAIL == cb_struct.func(pline->filter[idx].id, *buf, *buf_size, cb_struct.op_data))) + || !cb_struct.func) HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "filter returned failure during read") *nbytes = *buf_size; failed |= (unsigned)1 << idx; - H5E_clear_stack (NULL); + H5E_clear_stack(NULL); } else *nbytes = new_nbytes; } } - else if (pline) { /* Write */ - for (idx = 0; idx < pline->nused; idx++) { - if (*filter_mask & ((unsigned)1 << idx)) { + else if(pline) { /* Write */ + for(idx = 0; idx < pline->nused; idx++) { + if(*filter_mask & ((unsigned)1 << idx)) { failed |= (unsigned)1 << idx; - continue; /*filter excluded*/ + continue; /* filter excluded */ } - if ((fclass_idx = H5Z_find_idx(pline->filter[idx].id)) < 0) { + if((fclass_idx = H5Z_find_idx(pline->filter[idx].id)) < 0) { /* Check if filter is optional -- If it isn't, then error */ - if ((pline->filter[idx].flags & H5Z_FLAG_OPTIONAL) == 0) + if((pline->filter[idx].flags & H5Z_FLAG_OPTIONAL) == 0) HGOTO_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL, "required filter is not registered") - failed |= (unsigned)1 << idx; - H5E_clear_stack (NULL); - continue; /*filter excluded*/ - } + H5E_clear_stack(NULL); + continue; /* filter excluded */ + } /* end if */ + fclass = &H5Z_table_g[fclass_idx]; + #ifdef H5Z_DEBUG fstats = &H5Z_stat_table_g[fclass_idx]; - H5_timer_begin (&timer); + H5_timer_start(&timer); #endif - new_nbytes = (fclass->filter)(flags | (pline->filter[idx].flags), pline->filter[idx].cd_nelmts, - pline->filter[idx].cd_values, *nbytes, buf_size, buf); + + new_nbytes = (fclass->filter)(flags | (pline->filter[idx].flags), + pline->filter[idx].cd_nelmts, pline->filter[idx].cd_values, + *nbytes, buf_size, buf); + #ifdef H5Z_DEBUG - H5_timer_end (&(fstats->stats[0].timer), &timer); + H5_timer_stop(&timer); + H5_timer_get_times(timer, ×); + fstats->stats[0].times.elapsed += times.elapsed; + fstats->stats[0].times.system += times.system; + fstats->stats[0].times.user += times.user; + fstats->stats[0].total += MAX(*nbytes, new_nbytes); - if (0 == new_nbytes) + if(0 == new_nbytes) fstats->stats[0].errors += *nbytes; #endif - if (0 == new_nbytes) { - if (0 == (pline->filter[idx].flags & H5Z_FLAG_OPTIONAL)) { - if ((cb_struct.func && (H5Z_CB_FAIL == cb_struct.func (pline->filter[idx].id, *buf, *nbytes, cb_struct.op_data))) || !cb_struct.func) + + if(0 == new_nbytes) { + if(0 == (pline->filter[idx].flags & H5Z_FLAG_OPTIONAL)) { + if((cb_struct.func && (H5Z_CB_FAIL == cb_struct.func(pline->filter[idx].id, *buf, *nbytes, cb_struct.op_data))) + || !cb_struct.func) HGOTO_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL, "filter returned failure") *nbytes = *buf_size; } - failed |= (unsigned)1 << idx; - H5E_clear_stack (NULL); + H5E_clear_stack(NULL); } else *nbytes = new_nbytes; - } + } /* end for */ } *filter_mask = failed; diff --git a/src/H5Zfletcher32.c b/src/H5Zfletcher32.c index 4d75d14..c40e9b4 100644 --- a/src/H5Zfletcher32.c +++ b/src/H5Zfletcher32.c @@ -12,7 +12,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Raymond Lu + * Programmer: Raymond Lu * Jan 3, 2003 */ diff --git a/src/H5Ztrans.c b/src/H5Ztrans.c index dfc984a..1c8d415 100644 --- a/src/H5Ztrans.c +++ b/src/H5Ztrans.c @@ -400,8 +400,6 @@ static void H5Z_print(H5Z_node *tree, FILE *stream); * Return: Always succeeds. * Programmer: Bill Wendling * 26. August 2003 - * Modifications: - * Leon Arber: Added FUNC_ENTER / FUNC_LEAVE pairs * *------------------------------------------------------------------------- */ @@ -565,8 +563,6 @@ done: * Return: Nothing * Programmer: Bill Wendling * 25. August 2003 - * Modifications: - * Leon Arber: Added FUNC_ENTER / FUNC_LEAVE pairs * *------------------------------------------------------------------------- */ @@ -634,8 +630,6 @@ done: * NULLure: NULL * Programmer: Bill Wendling * 26. August 2003 - * Modifications: - * Leon Arber: Added FUNC_ENTER / FUNC_LEAVE pairs * *------------------------------------------------------------------------- */ @@ -728,8 +722,6 @@ done: * NULLure: NULL * Programmer: Bill Wendling * 26. August 2003 - * Modifications: - * Leon Arber: Added FUNC_ENTER / FUNC_LEAVE pairs * *------------------------------------------------------------------------- */ @@ -828,8 +820,6 @@ done: * NULLure: NULL * Programmer: Bill Wendling * 26. August 2003 - * Modifications: - * Leon Arber: Added FUNC_ENTER / FUNC_LEAVE pairs * *------------------------------------------------------------------------- */ @@ -972,8 +962,6 @@ done: * NULLure: NULL * Programmer: Bill Wendling * 26. August 2003 - * Modifications: - * Leon Arber: Added FUNC_ENTER / FUNC_LEAVE pairs * *------------------------------------------------------------------------- */ @@ -1002,7 +990,6 @@ done: * Return: SUCCEED if transform applied successfully, FAIL otherwise * Programmer: Leon Arber * 5/1/04 - * Modifications: * *------------------------------------------------------------------------- */ @@ -1115,8 +1102,6 @@ done: * Return: Nothing * Programmer: Leon Arber * 5/1/04 - * Modifications: - * * * Notes: In the case of a polynomial data transform (ie, the left and right subtree * are both of type H5Z_XFORM_SYMBOL), the convention is that the left hand side @@ -1213,8 +1198,6 @@ done: * Function: H5Z_find_type * Return: Native type of datatype that is passed in * Programmer: Leon Arber, 4/20/04 - * Modifications: - * * *------------------------------------------------------------------------- */ @@ -1301,7 +1284,6 @@ done: * of the one passed in. * Programmer: Leon Arber * April 1, 2004. - * Modifications: * *------------------------------------------------------------------------- */ @@ -1375,7 +1357,6 @@ done: * Return: TRUE or FALSE * Programmer: Raymond Lu * 15 March 2012 - * Modifications: * *------------------------------------------------------------------------- */ @@ -1404,7 +1385,6 @@ H5Z_op_is_numbs(H5Z_node* _tree) * Return: TRUE or FALSE * Programmer: Raymond Lu * 15 March 2012 - * Modifications: * *------------------------------------------------------------------------- */ @@ -1490,11 +1470,6 @@ H5Z_xform_reduce_tree(H5Z_node* tree) * Return: None. * Programmer: Leon Arber * April 1, 2004. - * Modifications: - * Raymond Lu - * 15 March 2012 - * I added a new macro H5Z_XFORM_DO_OP6 to handle the special - * operations like -x or +x when the left operand is empty. * *------------------------------------------------------------------------- */ @@ -1525,14 +1500,10 @@ H5Z_do_op(H5Z_node* tree) * Success: SUCCEED * Failure: FAIL * - * Programmer: Quincey Koziol, koziol@ncsa.uiuc.edu + * Programmer: Quincey Koziol * * Date: May 4, 2004 * - * Comments: - * - * Modifications: - * *------------------------------------------------------------------------- */ H5Z_data_xform_t * @@ -1616,14 +1587,10 @@ done: * Success: SUCCEED * Failure: FAIL * - * Programmer: Quincey Koziol, koziol@ncsa.uiuc.edu + * Programmer: Quincey Koziol * * Date: May 4, 2004 * - * Comments: - * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -1662,7 +1629,7 @@ H5Z_xform_destroy(H5Z_data_xform_t *data_xform_prop) * Success: SUCCEED * Failure: FAIL * - * Programmer: Quincey Koziol, koziol@ncsa.uiuc.edu + * Programmer: Quincey Koziol * * Date: May 4, 2004 * @@ -1742,14 +1709,12 @@ done: * * Return: TRUE for no data transform, FALSE for a data transform * - * Programmer: Quincey Koziol, koziol@ncsa.uiuc.edu + * Programmer: Quincey Koziol * * Date: May 4, 2004 * * Comments: Can't fail * - * Modifications: - * *------------------------------------------------------------------------- */ hbool_t @@ -1773,12 +1738,10 @@ H5Z_xform_noop(const H5Z_data_xform_t *data_xform_prop) * Return: * Pointer to a copy of the string in the data_xform property. * - * Programmer: Leon Arber, larber@ncsa.uiuc.edu + * Programmer: Leon Arber * * Date: Sept. 4, 2004 * - * Modifications: - * *------------------------------------------------------------------------- */ const char * diff --git a/src/H5dbg.c b/src/H5dbg.c index 4939bca..c01ad88 100644 --- a/src/H5dbg.c +++ b/src/H5dbg.c @@ -15,7 +15,7 @@ * * Created: H5dbg.c * Mar 4 2006 - * Quincey Koziol + * Quincey Koziol * * Purpose: Generic debugging routines * @@ -70,7 +70,6 @@ * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu * Mar 4 2006 * *------------------------------------------------------------------------- diff --git a/src/H5make_libsettings.c b/src/H5make_libsettings.c index 5f8de34..72041ed 100644 --- a/src/H5make_libsettings.c +++ b/src/H5make_libsettings.c @@ -32,8 +32,6 @@ static const char *FileHeader = "\n\ *------------------------------------------------------------------------- */ -#include -#include #include "H5private.h" /* Do NOT use HDfprintf in this file as it is not linked with the library, @@ -67,7 +65,7 @@ insert_libhdf5_settings(FILE *flibinfo) if(NULL == (fsettings = HDfopen(LIBSETTINGSFNAME, "r"))) { HDperror(LIBSETTINGSFNAME); HDexit(EXIT_FAILURE); - } /* end if */ + } /* print variable definition and the string */ /* Do not use const else AIX strings does not show it. */ @@ -78,30 +76,31 @@ insert_libhdf5_settings(FILE *flibinfo) /* Start a new line */ fprintf(flibinfo, "\t\""); bol = 0; - } /* end if */ + } if(inchar == '\n') { /* end of a line */ fprintf(flibinfo, "\\n\"\n"); bol++; - } /* end if */ + } else HDputc(inchar, flibinfo); - } /* end while */ + } + if(HDfeof(fsettings)) { /* wrap up */ if(!bol) /* EOF found without a new line */ fprintf(flibinfo, "\\n\"\n"); fprintf(flibinfo, ";\n\n"); - } /* end if */ + } else { fprintf(stderr, "Read errors encountered with %s\n", LIBSETTINGSFNAME); HDexit(EXIT_FAILURE); - } /* end else */ + } if(0 != HDfclose(fsettings)) { HDperror(LIBSETTINGSFNAME); HDexit(EXIT_FAILURE); - } /* end if */ + } #else /* print variable definition and an empty string */ /* Do not use const else AIX strings does not show it. */ @@ -171,12 +170,12 @@ information about the library build configuration\n"; n = MIN(sizeof(real_name) - 1, (unsigned)(comma - pwd->pw_gecos)); HDstrncpy(real_name, pwd->pw_gecos, n); real_name[n] = '\0'; - } /* end if */ + } else { HDstrncpy(real_name, pwd->pw_gecos, sizeof(real_name)); real_name[sizeof(real_name) - 1] = '\0'; - } /* end else */ - } /* end if */ + } + } else real_name[0] = '\0'; } @@ -215,14 +214,15 @@ information about the library build configuration\n"; if(real_name[0]) fprintf(rawoutstream, ">"); HDfputc('\n', rawoutstream); - } /* end if */ + } + fprintf(rawoutstream, " *\n * Purpose:\t\t"); for(s = purpose; *s; s++) { HDfputc(*s, rawoutstream); if('\n' == *s && s[1]) fprintf(rawoutstream, " *\t\t\t"); - } /* end for */ + } fprintf(rawoutstream, " *\n * Modifications:\n *\n"); fprintf(rawoutstream, " *\tDO NOT MAKE MODIFICATIONS TO THIS FILE!\n"); diff --git a/src/H5mpi.c b/src/H5mpi.c index 0f8b554..9c72fb0 100644 --- a/src/H5mpi.c +++ b/src/H5mpi.c @@ -59,7 +59,7 @@ H5_mpi_set_bigio_count(hsize_t new_count) bigio_count = new_count; } return orig_count; -} /* end H5_mpio_set_bigio_count() */ +} /* end H5_mpi_set_bigio_count() */ /*------------------------------------------------------------------------- diff --git a/src/H5private.h b/src/H5private.h index d185212..836d7d5 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -304,17 +304,38 @@ * file). Be sure to update that file if the #ifdefs change here. */ #ifdef __cplusplus -# define H5_ATTR_FORMAT(X,Y,Z) /*void*/ -# define H5_ATTR_UNUSED /*void*/ -# define H5_ATTR_NDEBUG_UNUSED /*void*/ -# define H5_ATTR_NORETURN /*void*/ -# define H5_ATTR_CONST /*void*/ -# define H5_ATTR_PURE /*void*/ -# define H5_ATTR_FALLTHROUGH /*void*/ +# define H5_ATTR_FORMAT(X,Y,Z) /*void*/ +# define H5_ATTR_UNUSED /*void*/ +# define H5_ATTR_DEPRECATED_USED /*void*/ +# define H5_ATTR_NDEBUG_UNUSED /*void*/ +# define H5_ATTR_DEBUG_API_USED /*void*/ +# define H5_ATTR_PARALLEL_UNUSED /*void*/ +# define H5_ATTR_PARALLEL_USED /*void*/ +# define H5_ATTR_NORETURN /*void*/ +# define H5_ATTR_CONST /*void*/ +# define H5_ATTR_PURE /*void*/ +# define H5_ATTR_FALLTHROUGH /*void*/ #else /* __cplusplus */ #if defined(H5_HAVE_ATTRIBUTE) && !defined(__SUNPRO_C) # define H5_ATTR_FORMAT(X,Y,Z) __attribute__((format(X, Y, Z))) # define H5_ATTR_UNUSED __attribute__((unused)) +#ifdef H5_HAVE_PARALLEL +# define H5_ATTR_PARALLEL_UNUSED __attribute__((unused)) +# define H5_ATTR_PARALLEL_USED /*void*/ +#else +# define H5_ATTR_PARALLEL_UNUSED /*void*/ +# define H5_ATTR_PARALLEL_USED __attribute__((unused)) +#endif +#ifdef H5_NO_DEPRECATED_SYMBOLS +#define H5_ATTR_DEPRECATED_USED H5_ATTR_UNUSED +#else /* H5_NO_DEPRECATED_SYMBOLS */ +#define H5_ATTR_DEPRECATED_USED /*void*/ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ +#ifdef H5_DEBUG_API +#define H5_ATTR_DEBUG_API_USED /*void*/ +#else /* H5_DEBUG_API */ +#define H5_ATTR_DEBUG_API_USED H5_ATTR_UNUSED +#endif /* H5_DEBUG_API */ #ifndef NDEBUG #define H5_ATTR_NDEBUG_UNUSED /*void*/ #else /* NDEBUG */ @@ -329,17 +350,37 @@ # define H5_ATTR_FALLTHROUGH /*void*/ #endif #else -# define H5_ATTR_FORMAT(X,Y,Z) /*void*/ -# define H5_ATTR_UNUSED /*void*/ -# define H5_ATTR_NDEBUG_UNUSED /*void*/ -# define H5_ATTR_NORETURN /*void*/ -# define H5_ATTR_CONST /*void*/ -# define H5_ATTR_PURE /*void*/ -# define H5_ATTR_FALLTHROUGH /*void*/ +# define H5_ATTR_FORMAT(X,Y,Z) /*void*/ +# define H5_ATTR_UNUSED /*void*/ +# define H5_ATTR_NDEBUG_UNUSED /*void*/ +# define H5_ATTR_DEBUG_API_USED /*void*/ +# define H5_ATTR_DEPRECATED_USED /*void*/ +# define H5_ATTR_PARALLEL_UNUSED /*void*/ +# define H5_ATTR_PARALLEL_USED /*void*/ +# define H5_ATTR_NORETURN /*void*/ +# define H5_ATTR_CONST /*void*/ +# define H5_ATTR_PURE /*void*/ +# define H5_ATTR_FALLTHROUGH /*void*/ #endif #endif /* __cplusplus */ /* + * Networking headers used by the mirror VFD and related tests and utilities. + */ +#ifdef H5_HAVE_ARPA_INET_H +# include +#endif +#ifdef H5_HAVE_NETDB_H +# include +#endif +#ifdef H5_HAVE_NETINET_IN_H +# include +#endif +#ifdef H5_HAVE_SYS_SOCKET_H +# include +#endif + +/* * Status return values for the `herr_t' type. * Since some unix/c routines use 0 and -1 (or more precisely, non-negative * vs. negative) as their return code, and some assumption had been made in @@ -534,28 +575,6 @@ #define H5_REQUEST_NULL NULL /* - * A macro to portably decrement enumerated types. - */ -#ifndef H5_DEC_ENUM -# define H5_DEC_ENUM(TYPE,VAR) (VAR)=((TYPE)((VAR)-1)) -#endif - -/* Double constant wrapper - * - * Quiets gcc warnings from -Wunsuffixed-float-constants. - * - * This is a really annoying warning since the standard specifies that - * constants of type double do NOT get a suffix so there's no way - * to specify a constant of type double. To quiet gcc, we specify floating - * point constants as type long double and cast to double. - * - * Note that this macro only needs to be used where using a double - * is important. For most code, suffixing constants with F will quiet the - * compiler and not produce erroneous code. - */ -#define H5_DOUBLE(S) ((double) S ## L) - -/* * Methods to compare the equality of floating-point values: * * 1. H5_XXX_ABS_EQUAL - check if the difference is smaller than the @@ -595,21 +614,37 @@ #define LOCK_UN 0x08 #endif /* H5_HAVE_FLOCK */ -/* - * Data types and functions for timing certain parts of the library. +/* Typedefs and functions for timing certain parts of the library. */ + +/* A set of elapsed/user/system times emitted as a time point by the + * platform-independent timers. */ typedef struct { - double utime; /*user time */ - double stime; /*system time */ - double etime; /*elapsed wall-clock time */ + double user; /* User time in seconds */ + double system; /* System time in seconds */ + double elapsed; /* Elapsed (wall clock) time in seconds */ +} H5_timevals_t; + +/* Timer structure for platform-independent timers */ +typedef struct { + H5_timevals_t initial; /* Current interval start time */ + H5_timevals_t final_interval; /* Last interval elapsed time */ + H5_timevals_t total; /* Total elapsed time for all intervals */ + hbool_t is_running; /* Whether timer is running */ } H5_timer_t; -H5_DLL void H5_timer_reset (H5_timer_t *timer); -H5_DLL void H5_timer_begin (H5_timer_t *timer); -H5_DLL void H5_timer_end (H5_timer_t *sum/*in,out*/, - H5_timer_t *timer/*in,out*/); +/* Returns library bandwidth as a pretty string */ H5_DLL void H5_bandwidth(char *buf/*out*/, double nbytes, double nseconds); + +/* Timer functionality */ H5_DLL time_t H5_now(void); +H5_DLL uint64_t H5_now_usec(void); +H5_DLL herr_t H5_timer_init(H5_timer_t *timer /*in,out*/); +H5_DLL herr_t H5_timer_start(H5_timer_t *timer /*in,out*/); +H5_DLL herr_t H5_timer_stop(H5_timer_t *timer /*in,out*/); +H5_DLL herr_t H5_timer_get_times(H5_timer_t timer, H5_timevals_t *times /*in,out*/); +H5_DLL herr_t H5_timer_get_total_times(H5_timer_t timer, H5_timevals_t *times /*in,out*/); +H5_DLL char *H5_timer_get_time_string(double seconds); /* Depth of object copy */ typedef enum { @@ -643,6 +678,9 @@ typedef struct { #ifndef HDabs #define HDabs(X) abs(X) #endif /* HDabs */ +#ifndef HDaccept + #define HDaccept(A,B,C) accept((A),(B),(C)) /* mirror VFD */ +#endif /* HDaccept */ #ifndef HDaccess #define HDaccess(F,M) access(F, M) #endif /* HDaccess */ @@ -689,6 +727,9 @@ typedef struct { #ifndef HDatoll #define HDatoll(S) atoll(S) #endif /* HDatol */ +#ifndef HDbind + #define HDbind(A,B,C) bind((A),(B),(C)) /* mirror VFD */ +#endif /* HDbind */ #ifndef HDbsearch #define HDbsearch(K,B,N,Z,F) bsearch(K,B,N,Z,F) #endif /* HDbsearch */ @@ -725,12 +766,18 @@ typedef struct { #ifndef HDclock #define HDclock() clock() #endif /* HDclock */ +#ifndef HDclock_gettime + #define HDclock_gettime(CID, TS) clock_gettime(CID, TS) +#endif /* HDclock_gettime */ #ifndef HDclose #define HDclose(F) close(F) #endif /* HDclose */ #ifndef HDclosedir #define HDclosedir(D) closedir(D) #endif /* HDclosedir */ +#ifndef HDconnect + #define HDconnect(A,B,C) connect((A),(B),(C)) /* mirror VFD */ +#endif /* HDconnect */ #ifndef HDcos #define HDcos(X) cos(X) #endif /* HDcos */ @@ -931,7 +978,7 @@ typedef off_t h5_stat_size_t; #define H5_SIZEOF_H5_STAT_SIZE_T H5_SIZEOF_OFF_T #ifndef HDftell - #define HDftell(F) ftello(F) + #define HDftell(F) ftell(F) #endif /* HDftell */ #ifndef HDftruncate #define HDftruncate(F,L) ftruncate(F,L) @@ -975,9 +1022,12 @@ typedef off_t h5_stat_size_t; #ifndef HDgetgroups #define HDgetgroups(Z,G) getgroups(Z,G) #endif /* HDgetgroups */ +#ifndef HDgethostbyaddr + #define HDgethostbyaddr(A,B,C) gethostbyaddr((A),(B),(C)) /* mirror VFD */ +#endif /* HDgethostbyaddr */ #ifndef HDgethostname #define HDgethostname(N,L) gethostname(N,L) -#endif /* HDgetlogin */ +#endif /* HDgethostname */ #ifndef HDgetlogin #define HDgetlogin() getlogin() #endif /* HDgetlogin */ @@ -999,9 +1049,12 @@ typedef off_t h5_stat_size_t; #ifndef HDgetrusage #define HDgetrusage(X,S) getrusage(X,S) #endif /* HDgetrusage */ -#ifndef HDgets - #define HDgets(S) gets(S) + +/* Don't define HDgets - gets() was deprecated in C99 and removed in C11 */ +#ifdef HDgets + #undef HDgets #endif /* HDgets */ + #ifndef HDgettimeofday #define HDgettimeofday(S,P) gettimeofday(S,P) #endif /* HDgettimeofday */ @@ -1011,6 +1064,18 @@ typedef off_t h5_stat_size_t; #ifndef HDgmtime #define HDgmtime(T) gmtime(T) #endif /* HDgmtime */ +#ifndef HDhtonl + #define HDhtonl(X) htonl((X)) /* mirror VFD */ +#endif /* HDhtonl */ +#ifndef HDhtons + #define HDhtons(X) htons((X)) /* mirror VFD */ +#endif /* HDhtons */ +#ifndef HDinet_addr + #define HDinet_addr(C) inet_addr((C)) /* mirror VFD */ +#endif /* HDinet_addr */ +#ifndef HDinet_ntoa + #define HDinet_ntoa(C) inet_ntoa((C)) /* mirror VFD */ +#endif /* HDinet_ntoa */ #ifndef HDisalnum #define HDisalnum(C) isalnum((int)(C)) /*cast for solaris warning*/ #endif /* HDisalnum */ @@ -1065,6 +1130,9 @@ typedef off_t h5_stat_size_t; #ifndef HDlink #define HDlink(OLD,NEW) link(OLD,NEW) #endif /* HDlink */ +#ifndef HDlisten + #define HDlisten(A,B) listen((A),(B)) /* mirror VFD */ +#endif /* HDlisten */ #ifndef HDllround #define HDllround(V) llround(V) #endif /* HDround */ @@ -1146,6 +1214,12 @@ typedef off_t h5_stat_size_t; #ifndef HDnanosleep #define HDnanosleep(N, O) nanosleep(N, O) #endif /* HDnanosleep */ +#ifndef HDntohl + #define HDntohl(A) ntohl((A)) /* mirror VFD */ +#endif /* HDntohl */ +#ifndef HDntohs + #define HDntohs(A) ntohs((A)) /* mirror VFD */ +#endif /* HDntohs */ #ifndef HDopen #define HDopen(F,...) open(F,__VA_ARGS__) #endif /* HDopen */ @@ -1293,12 +1367,21 @@ typedef off_t h5_stat_size_t; #ifndef HDsetsid #define HDsetsid() setsid() #endif /* HDsetsid */ +#ifndef HDsetsockopt + #define HDsetsockopt(A,B,C,D,E) setsockopt((A),(B),(C),(D),(E)) /* mirror VFD */ +#endif /* HDsetsockopt */ #ifndef HDsetuid #define HDsetuid(U) setuid(U) #endif /* HDsetuid */ #ifndef HDsetvbuf #define HDsetvbuf(F,S,M,Z) setvbuf(F,S,M,Z) #endif /* HDsetvbuf */ +#ifndef HDshutdown + #define HDshutdown(A, B) shutdown((A),(B)) /* mirror VFD */ +#endif /* HDshutdown */ +#ifndef HDsigaction + #define HDsigaction(S,A,O) sigaction((S),(A),(O)) +#endif /* HDsigaction */ #ifndef HDsigaddset #define HDsigaddset(S,N) sigaddset(S,N) #endif /* HDsigaddset */ @@ -1344,6 +1427,9 @@ typedef off_t h5_stat_size_t; #ifndef HDsnprintf #define HDsnprintf snprintf /*varargs*/ #endif /* HDsnprintf */ +#ifndef HDsocket + #define HDsocket(A,B,C) socket((A),(B),(C)) /* mirror VFD */ +#endif /* HDsocket */ #ifndef HDsprintf #define HDsprintf sprintf /*varargs*/ #endif /* HDsprintf */ @@ -1915,9 +2001,6 @@ H5_DLL double H5_trace(const double *calltime, const char *func, const char *typ /* global library version information string */ extern char H5_lib_vers_info_g[]; -/* Include required thread-safety header, always, for the H5TS_thread_id() - * definition. - */ #include "H5TSprivate.h" /* Lock headers */ diff --git a/src/H5public.h b/src/H5public.h index 8cb7b5b..ca17f37 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -26,7 +26,7 @@ * it via H5public.h. The #ifndef _H5public_H guard above would * prevent repeated include. */ -#include "H5pubconf.h" /*from configure */ +#include "H5pubconf.h" /*from configure */ /* API Version macro wrapper definitions */ #include "H5version.h" @@ -38,20 +38,20 @@ #include #endif #ifdef H5_STDC_HEADERS -# include /*for H5T_NATIVE_CHAR defn in H5Tpublic.h */ +# include /*for H5T_NATIVE_CHAR defn in H5Tpublic.h */ # include /*for variadic functions in H5VLpublic.h */ #endif #ifndef __cplusplus # ifdef H5_HAVE_STDINT_H -# include /*for C9x types */ +# include /*for C9x types */ # endif #else # ifdef H5_HAVE_STDINT_H_CXX -# include /*for C9x types when include from C++ */ +# include /*for C9x types when include from C++ */ # endif #endif #ifdef H5_HAVE_INTTYPES_H -# include /* For uint64_t on some platforms */ +# include /* C99/POSIX.1 header for uint64_t, PRIu64 */ #endif #ifdef H5_HAVE_STDDEF_H # include @@ -61,7 +61,7 @@ # define MPICH_SKIP_MPICXX 1 # define OMPI_SKIP_MPICXX 1 # include -#ifndef MPI_FILE_NULL /*MPIO may be defined in mpi.h already */ +#ifndef MPI_FILE_NULL /*MPIO may be defined in mpi.h already */ # include #endif #endif @@ -101,8 +101,8 @@ extern "C" { /* Empty string for real releases. */ #define H5_VERS_INFO "HDF5 library version: 1.12.1-2" /* Full version string */ -#define H5check() H5check_version(H5_VERS_MAJOR,H5_VERS_MINOR, \ - H5_VERS_RELEASE) +#define H5check() H5check_version(H5_VERS_MAJOR,H5_VERS_MINOR, \ + H5_VERS_RELEASE) /* macros for comparing the version */ #define H5_VERSION_GE(Maj,Min,Rel) \ @@ -122,8 +122,8 @@ extern "C" { * The negative failure value is most commonly -1, but don't bet on it. The * proper way to detect failure is something like: * - * if((dset = H5Dopen2(file, name)) < 0) - * fprintf(stderr, "unable to open the requested dataset\n"); + * if((dset = H5Dopen2(file, name)) < 0) + * fprintf(stderr, "unable to open the requested dataset\n"); */ typedef int herr_t; @@ -135,13 +135,13 @@ typedef int herr_t; * (false), positive (true), or negative (failure). The proper way to test * for truth from a htri_t function is: * - * if ((retval = H5Tcommitted(type))>0) { - * printf("data type is committed\n"); - * } else if (!retval) { - * printf("data type is not committed\n"); - * } else { - * printf("error determining whether data type is committed\n"); - * } + * if ((retval = H5Tcommitted(type))>0) { + * printf("data type is committed\n"); + * } else if (!retval) { + * printf("data type is not committed\n"); + * } else { + * printf("error determining whether data type is committed\n"); + * } */ #ifdef H5_HAVE_STDBOOL_H #include @@ -183,8 +183,8 @@ typedef long long ssize_t; */ #if H5_SIZEOF_LONG_LONG >= 8 H5_GCC_DIAG_OFF(long-long) -typedef unsigned long long hsize_t; -typedef signed long long hssize_t; +typedef unsigned long long hsize_t; +typedef signed long long hssize_t; H5_GCC_DIAG_ON(long-long) # define H5_SIZEOF_HSIZE_T H5_SIZEOF_LONG_LONG # define H5_SIZEOF_HSSIZE_T H5_SIZEOF_LONG_LONG @@ -229,7 +229,7 @@ H5_GCC_DIAG_ON(long-long) #else # error "nothing appropriate for H5_PRINTF_HADDR_FMT" #endif -#define HADDR_MAX (HADDR_UNDEF-1) +#define HADDR_MAX (HADDR_UNDEF-1) /* uint32_t type is used for creation order field for messages. It may be * defined in Posix.1g, otherwise it is defined here. @@ -297,7 +297,7 @@ typedef enum { H5_ITER_INC, /* Increasing order */ H5_ITER_DEC, /* Decreasing order */ H5_ITER_NATIVE, /* No particular order, whatever is fastest */ - H5_ITER_N /* Number of iteration orders */ + H5_ITER_N /* Number of iteration orders */ } H5_iter_order_t; /* Iteration callback values */ @@ -314,10 +314,10 @@ typedef enum { * links in groups/attributes on objects. */ typedef enum H5_index_t { - H5_INDEX_UNKNOWN = -1, /* Unknown index type */ - H5_INDEX_NAME, /* Index on names */ - H5_INDEX_CRT_ORDER, /* Index on creation order */ - H5_INDEX_N /* Number of indices defined */ + H5_INDEX_UNKNOWN = -1, /* Unknown index type */ + H5_INDEX_NAME, /* Index on names */ + H5_INDEX_CRT_ORDER, /* Index on creation order */ + H5_INDEX_N /* Number of indices defined */ } H5_index_t; /* @@ -365,9 +365,9 @@ H5_DLL herr_t H5get_free_list_sizes(size_t *reg_size, size_t *arr_size, size_t *blk_size, size_t *fac_size); H5_DLL herr_t H5get_alloc_stats(H5_alloc_stats_t *stats); H5_DLL herr_t H5get_libversion(unsigned *majnum, unsigned *minnum, - unsigned *relnum); + unsigned *relnum); H5_DLL herr_t H5check_version(unsigned majnum, unsigned minnum, - unsigned relnum); + unsigned relnum); H5_DLL herr_t H5is_library_threadsafe(hbool_t *is_ts); H5_DLL herr_t H5free_memory(void *mem); H5_DLL void *H5allocate_memory(size_t size, hbool_t clear); @@ -377,5 +377,5 @@ H5_DLL void *H5resize_memory(void *mem, size_t size); } #endif #endif /* _H5public_H */ - + diff --git a/src/H5system.c b/src/H5system.c index ca0c6bf..24935fd 100644 --- a/src/H5system.c +++ b/src/H5system.c @@ -13,11 +13,11 @@ /*------------------------------------------------------------------------- * - * Created: H5system.c - * Aug 21 2006 - * Quincey Koziol + * Created: H5system.c + * Aug 21 2006 + * Quincey Koziol * - * Purpose: System call wrapper implementations. + * Purpose: System call wrapper implementations. * *------------------------------------------------------------------------- */ @@ -30,10 +30,10 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5MMprivate.h" /* Memory management */ /****************/ @@ -379,7 +379,7 @@ HDfprintf(FILE *stream, const char *fmt, ...) if(fwidth) len += HDsnprintf(format_templ + len, (sizeof(format_templ) - (size_t)(len + 1)), "%d", fwidth); HDstrncat(format_templ, "s", (sizeof(format_templ) - (size_t)(len + 1))); - fprintf(stream, format_templ, "UNDEF"); + n = fprintf(stream, format_templ, "UNDEF"); } } break; @@ -409,11 +409,25 @@ HDfprintf(FILE *stream, const char *fmt, ...) htri_t tri_var = HDva_arg(ap, htri_t); if(tri_var > 0) - fprintf(stream, "TRUE"); + n = fprintf(stream, "TRUE"); else if(!tri_var) - fprintf(stream, "FALSE"); + n = fprintf(stream, "FALSE"); else - fprintf(stream, "FAIL(%d)", (int)tri_var); + n = fprintf(stream, "FAIL(%d)", (int)tri_var); + } + break; + + case 'T': /* Elapsed time, in seconds */ + { + double seconds = HDva_arg(ap, double); + char *time_string = H5_timer_get_time_string(seconds); + + if(time_string) { + n = fprintf(stream, format_templ, time_string); + HDfree(time_string); + } /* end if */ + else + n = fprintf(stream, format_templ, "(error)"); } break; @@ -861,11 +875,88 @@ Wsetenv(const char *name, const char *value, int overwrite) #pragma comment(lib, "advapi32.lib") #endif + +/*------------------------------------------------------------------------- + * Function: H5_get_win32_times + * + * Purpose: Gets the elapsed, system and user times on Windows platforms. + * All time values are in seconds. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Dana Robinson + * May 2011 + * + *------------------------------------------------------------------------- + */ +#ifdef H5_HAVE_WIN32_API +int +H5_get_win32_times(H5_timevals_t *tvs /*in,out*/) +{ + static HANDLE process_handle; + ULARGE_INTEGER kernel_start; + ULARGE_INTEGER user_start; + FILETIME KernelTime; + FILETIME UserTime; + FILETIME CreationTime; + FILETIME ExitTime; + LARGE_INTEGER counts_start; + static LARGE_INTEGER counts_freq; + static hbool_t is_initialized = FALSE; + BOOL err; + + HDassert(tvs); + + if(!is_initialized) { + /* NOTE: This is just a pseudo handle and does not need to be closed. */ + process_handle = GetCurrentProcess(); + err = QueryPerformanceFrequency(&counts_freq); + if(0 == err) + return -1; + is_initialized = TRUE; + } /* end if */ + + /************************* + * System and user times * + *************************/ + + err = GetProcessTimes(process_handle, &CreationTime, &ExitTime, &KernelTime, + &UserTime); + if(0 == err) + return -1; + + /* The 1.0E7 factor seems strange but it's due to the clock + * ticking in 100 ns increments. + */ + kernel_start.HighPart = KernelTime.dwHighDateTime; + kernel_start.LowPart = KernelTime.dwLowDateTime; + tvs->system = (double)(kernel_start.QuadPart / 1.0E7F); + + user_start.HighPart = UserTime.dwHighDateTime; + user_start.LowPart = UserTime.dwLowDateTime; + tvs->user = (double)(user_start.QuadPart / 1.0E7F); + + /**************** + * Elapsed time * + ****************/ + + err = QueryPerformanceCounter(&counts_start); + if(0 == err) + return -1; + + tvs->elapsed = (double)(counts_start.QuadPart) / (double)counts_freq.QuadPart; + + return 0; +} /* end H5_get_win32_times() */ +#endif + #define WloginBuffer_count 256 static char Wlogin_buffer[WloginBuffer_count]; + char* -Wgetlogin() +Wgetlogin(void) { #ifdef H5_HAVE_WINSOCK2_H @@ -1370,38 +1461,6 @@ H5_nanosleep(uint64_t nanosec) FUNC_LEAVE_NOAPI_VOID } /* end H5_nanosleep() */ - -/*-------------------------------------------------------------------------- - * Function: H5_get_time - * - * Purpose: Get the current time, as the time of seconds after the UNIX epoch - * - * Return: SUCCEED/FAIL - * - * Programmer: Quincey Koziol - * October 05, 2016 - *-------------------------------------------------------------------------- - */ -double -H5_get_time(void) -{ -#ifdef H5_HAVE_GETTIMEOFDAY - struct timeval curr_time; -#endif /* H5_HAVE_GETTIMEOFDAY */ - double ret_value = (double)0.0f; - - FUNC_ENTER_NOAPI_NOINIT_NOERR - -#ifdef H5_HAVE_GETTIMEOFDAY - HDgettimeofday(&curr_time, NULL); - - ret_value = (double)curr_time.tv_sec + ((double)curr_time.tv_usec / (double)1000000.0f); -#endif /* H5_HAVE_GETTIMEOFDAY */ - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5_get_time() */ - - #ifdef H5_HAVE_WIN32_API #define H5_WIN32_ENV_VAR_BUFFER_SIZE 32767 diff --git a/src/H5timer.c b/src/H5timer.c index 4b1ec06..cef7bf9 100644 --- a/src/H5timer.c +++ b/src/H5timer.c @@ -12,12 +12,11 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*------------------------------------------------------------------------- - * * Created: H5timer.c * Aug 21 2006 * Quincey Koziol * - * Purpose: Internal 'timer' routines & support routines. + * Purpose: Internal, platform-independent 'timer' support routines. * *------------------------------------------------------------------------- */ @@ -32,20 +31,22 @@ /***********/ #include "H5private.h" /* Generic Functions */ -/* We need this for the struct rusage declaration */ -#if defined(H5_HAVE_GETRUSAGE) && defined(H5_HAVE_SYS_RESOURCE_H) -# include -#endif - -#if defined(H5_HAVE_GETTIMEOFDAY) && defined(H5_HAVE_SYS_TIME_H) -#include -#endif - /****************/ /* Local Macros */ /****************/ +/* Size of a generated time string. + * Most time strings should be < 20 or so characters (max!) so this should be a + * safe size. Dynamically allocating the correct size would be painful. + */ +#define H5TIMER_TIME_STRING_LEN 1536 + +/* Conversion factors */ +#define H5_SEC_PER_DAY (double)(24.0F * 60.0F * 60.0F) +#define H5_SEC_PER_HOUR (double)(60.0F * 60.0F) +#define H5_SEC_PER_MIN (double)(60.0F) + /******************/ /* Local Typedefs */ @@ -76,104 +77,6 @@ /* Local Variables */ /*******************/ - -/*------------------------------------------------------------------------- - * Function: H5_timer_reset - * - * Purpose: Resets the timer struct to zero. Use this to reset a timer - * that's being used as an accumulator for summing times. - * - * Return: void - * - * Programmer: Robb Matzke - * Thursday, April 16, 1998 - * - *------------------------------------------------------------------------- - */ -void -H5_timer_reset (H5_timer_t *timer) -{ - HDassert(timer); - HDmemset(timer, 0, sizeof *timer); -} /* end H5_timer_reset() */ - - -/*------------------------------------------------------------------------- - * Function: H5_timer_begin - * - * Purpose: Initialize a timer to time something. - * - * Return: void - * - * Programmer: Robb Matzke - * Thursday, April 16, 1998 - * - *------------------------------------------------------------------------- - */ -void -H5_timer_begin (H5_timer_t *timer) -{ -#ifdef H5_HAVE_GETRUSAGE - struct rusage rusage; -#endif -#ifdef H5_HAVE_GETTIMEOFDAY - struct timeval etime; -#endif - - HDassert(timer); - -#ifdef H5_HAVE_GETRUSAGE - HDgetrusage (RUSAGE_SELF, &rusage); - timer->utime = (double)rusage.ru_utime.tv_sec + - ((double)rusage.ru_utime.tv_usec / (double)1e6F); - timer->stime = (double)rusage.ru_stime.tv_sec + - ((double)rusage.ru_stime.tv_usec / (double)1e6F); -#else - timer->utime = 0.0F; - timer->stime = 0.0F; -#endif -#ifdef H5_HAVE_GETTIMEOFDAY - HDgettimeofday (&etime, NULL); - timer->etime = (double)etime.tv_sec + ((double)etime.tv_usec / (double)1e6F); -#else - timer->etime = 0.0F; -#endif -} /* end H5_timer_begin() */ - - -/*------------------------------------------------------------------------- - * Function: H5_timer_end - * - * Purpose: This function should be called at the end of a timed region. - * The SUM is an optional pointer which will accumulate times. - * TMS is the same struct that was passed to H5_timer_start(). - * On return, TMS will contain total times for the timed region. - * - * Return: void - * - * Programmer: Robb Matzke - * Thursday, April 16, 1998 - * - *------------------------------------------------------------------------- - */ -void -H5_timer_end (H5_timer_t *sum/*in,out*/, H5_timer_t *timer/*in,out*/) -{ - H5_timer_t now; - - HDassert(timer); - H5_timer_begin(&now); - - timer->utime = MAX((double)0.0F, now.utime - timer->utime); - timer->stime = MAX((double)0.0F, now.stime - timer->stime); - timer->etime = MAX((double)0.0F, now.etime - timer->etime); - - if (sum) { - sum->utime += timer->utime; - sum->stime += timer->stime; - sum->etime += timer->etime; - } -} /* end H5_timer_end() */ /*------------------------------------------------------------------------- @@ -209,32 +112,35 @@ H5_bandwidth(char *buf/*out*/, double nbytes, double nseconds) if(nseconds <= (double)0.0F) HDstrcpy(buf, " NaN"); else { - bw = nbytes/nseconds; + bw = nbytes / nseconds; if(H5_DBL_ABS_EQUAL(bw, (double)0.0F)) HDstrcpy(buf, "0.000 B/s"); else if(bw < (double)1.0F) HDsprintf(buf, "%10.4e", bw); else if(bw < (double)H5_KB) { HDsprintf(buf, "%05.4f", bw); - HDstrcpy(buf+5, " B/s"); + HDstrcpy(buf + 5, " B/s"); } else if(bw < (double)H5_MB) { HDsprintf(buf, "%05.4f", bw / (double)H5_KB); - HDstrcpy(buf+5, " kB/s"); + HDstrcpy(buf + 5, " kB/s"); } else if(bw < (double)H5_GB) { HDsprintf(buf, "%05.4f", bw / (double)H5_MB); - HDstrcpy(buf+5, " MB/s"); + HDstrcpy(buf + 5, " MB/s"); } else if(bw < (double)H5_TB) { HDsprintf(buf, "%05.4f", bw / (double)H5_GB); - HDstrcpy(buf+5, " GB/s"); + HDstrcpy(buf + 5, " GB/s"); } else if(bw < (double)H5_PB) { HDsprintf(buf, "%05.4f", bw / (double)H5_TB); - HDstrcpy(buf+5, " TB/s"); + HDstrcpy(buf + 5, " TB/s"); + } else if(bw < (double)H5_EB) { + HDsprintf(buf, "%05.4f", bw / (double)H5_PB); + HDstrcpy(buf + 5, " PB/s"); } else { HDsprintf(buf, "%10.4e", bw); if(HDstrlen(buf) > 10) HDsprintf(buf, "%10.3e", bw); - } - } + } /* end else-if */ + } /* end else */ } /* end H5_bandwidth() */ @@ -269,3 +175,488 @@ H5_now(void) return(now); } /* end H5_now() */ + +/*------------------------------------------------------------------------- + * Function: H5_now_usec + * + * Purpose: Retrieves the current time, as microseconds after the UNIX epoch. + * + * Return: # of microseconds from the epoch (can't fail) + * + * Programmer: Quincey Koziol + * Tuesday, November 28, 2006 + * + *------------------------------------------------------------------------- + */ +uint64_t +H5_now_usec(void) +{ + uint64_t now; /* Current time, in microseconds */ + +#if defined(H5_HAVE_CLOCK_GETTIME) + { + struct timespec ts; + + HDclock_gettime(CLOCK_MONOTONIC, &ts); + now = (uint64_t)(ts.tv_sec * (1000 * 1000)) + (uint64_t)(ts.tv_nsec / 1000); + } +#elif defined(H5_HAVE_GETTIMEOFDAY) + { + struct timeval now_tv; + + HDgettimeofday(&now_tv, NULL); + now = (uint64_t)(now_tv.tv_sec * (1000 * 1000)) + (uint64_t)now_tv.tv_usec; + } +#else /* H5_HAVE_GETTIMEOFDAY */ + now = (uint64_t)(HDtime(NULL) * (1000 * 1000)); +#endif /* H5_HAVE_GETTIMEOFDAY */ + + return(now); +} /* end H5_now_usec() */ + + +/*-------------------------------------------------------------------------- + * Function: H5_get_time + * + * Purpose: Get the current time, as the time of seconds after the UNIX epoch + * + * Return: Success: A non-negative time value + * Failure: -1.0 (in theory, can't currently fail) + * + * Programmer: Quincey Koziol + * October 05, 2016 + *-------------------------------------------------------------------------- + */ +double +H5_get_time(void) +{ + double ret_value = (double)0.0f; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + +#if defined(H5_HAVE_CLOCK_GETTIME) + { + struct timespec ts; + + HDclock_gettime(CLOCK_MONOTONIC, &ts); + ret_value = (double)ts.tv_sec + ((double)ts.tv_nsec / (double)1000000000.0f); + } +#elif defined(H5_HAVE_GETTIMEOFDAY) + { + struct timeval now_tv; + + HDgettimeofday(&now_tv, NULL); + ret_value = (double)now_tv.tv_sec + ((double)now_tv.tv_usec / (double)1000000.0f); + } +#else + ret_value = (double)HDtime(NULL); +#endif + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5_get_time() */ + + + +/*------------------------------------------------------------------------- + * Function: H5__timer_get_timevals + * + * Purpose: Internal platform-specific function to get time system, + * user and elapsed time values. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Dana Robinson + * May 2011 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5__timer_get_timevals(H5_timevals_t *times /*in,out*/) +{ + /* Sanity check */ + HDassert(times); + + /* Windows call handles both system/user and elapsed times */ +#ifdef H5_HAVE_WIN32_API + if(H5_get_win32_times(times) < 0) { + times->elapsed = -1.0; + times->system = -1.0; + times->user = -1.0; + + return -1; + } /* end if */ +#else /* H5_HAVE_WIN32_API */ + + /************************* + * System and user times * + *************************/ +#if defined(H5_HAVE_GETRUSAGE) +{ + struct rusage res; + + if(HDgetrusage(RUSAGE_SELF, &res) < 0) + return -1; + times->system = (double)res.ru_stime.tv_sec + ((double)res.ru_stime.tv_usec / (double)1.0E6F); + times->user = (double)res.ru_utime.tv_sec + ((double)res.ru_utime.tv_usec / (double)1.0E6F); +} +#else + /* No suitable way to get system/user times */ + /* This is not an error condition, they just won't be available */ + times->system = -1.0; + times->user = -1.0; +#endif + + /**************** + * Elapsed time * + ****************/ + + times->elapsed = H5_get_time(); + +#endif /* H5_HAVE_WIN32_API */ + + return 0; +} /* end H5__timer_get_timevals() */ + + +/*------------------------------------------------------------------------- + * Function: H5_timer_init + * + * Purpose: Initialize a platform-independent timer. + * + * Timer usage is as follows: + * + * 1) Call H5_timer_init(), passing in a timer struct, to set + * up the timer. + * + * 2) Wrap any code you'd like to time with calls to + * H5_timer_start/stop(). For accurate timing, place these + * calls as close to the code of interest as possible. You + * can call start/stop multiple times on the same timer - + * when you do this, H5_timer_get_times() will return time + * values for the current/last session and + * H5_timer_get_total_times() will return the summed times + * of all sessions (see #3 and #4, below). + * + * 3) Use H5_timer_get_times() to get the current system, user + * and elapsed times from a running timer. If called on a + * stopped timer, this will return the time recorded at the + * stop point. + * + * 4) Call H5_timer_get_total_times() to get the total system, + * user and elapsed times recorded across multiple start/stop + * sessions. If called on a running timer, it will return the + * time recorded up to that point. On a stopped timer, it + * will return the time recorded at the stop point. + * + * NOTE: Obtaining a time point is not free! Keep in mind that + * the time functions make system calls and can have + * non-trivial overhead. If you call one of the get_time + * functions on a running timer, that overhead will be + * added to the reported times. + * + * 5) All times recorded will be in seconds. These can be + * converted into human-readable strings with the + * H5_timer_get_time_string() function. + * + * 6) A timer can be reset using by calling H5_timer_init() on + * it. This will set its state to 'stopped' and reset all + * accumulated times to zero. + * + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Dana Robinson + * May 2011 + * + *------------------------------------------------------------------------- + */ +herr_t +H5_timer_init(H5_timer_t *timer /*in,out*/) +{ + /* Sanity check */ + HDassert(timer); + + /* Initialize everything */ + HDmemset(timer, 0, sizeof(H5_timer_t)); + + return 0; +} /* end H5_timer_init() */ + + +/*------------------------------------------------------------------------- + * Function: H5_timer_start + * + * Purpose: Start tracking time in a platform-independent timer. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Dana Robinson + * May 2011 + * + *------------------------------------------------------------------------- + */ +herr_t +H5_timer_start(H5_timer_t *timer /*in,out*/) +{ + /* Sanity check */ + HDassert(timer); + + /* Start the timer + * This sets the "initial" times to the system-defined start times. + */ + if(H5__timer_get_timevals(&(timer->initial)) < 0) + return -1; + + timer->is_running = TRUE; + + return 0; +} /* end H5_timer_start() */ + + +/*------------------------------------------------------------------------- + * Function: H5_timer_stop + * + * Purpose: Stop tracking time in a platform-independent timer. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Dana Robinson + * May 2011 + * + *------------------------------------------------------------------------- + */ +herr_t +H5_timer_stop(H5_timer_t *timer /*in,out*/) +{ + /* Sanity check */ + HDassert(timer); + + /* Stop the timer */ + if(H5__timer_get_timevals(&(timer->final_interval)) < 0) + return -1; + + /* The "final" times are stored as intervals (final - initial) + * for more useful reporting to the user. + */ + timer->final_interval.elapsed = timer->final_interval.elapsed - timer->initial.elapsed; + timer->final_interval.system = timer->final_interval.system - timer->initial.system; + timer->final_interval.user = timer->final_interval.user - timer->initial.user; + + /* Add the intervals to the elapsed time */ + timer->total.elapsed += timer->final_interval.elapsed; + timer->total.system += timer->final_interval.system; + timer->total.user += timer->final_interval.user; + + timer->is_running = FALSE; + + return 0; +} /* end H5_timer_stop() */ + + +/*------------------------------------------------------------------------- + * Function: H5_timer_get_times + * + * Purpose: Get the system, user and elapsed times from a timer. These + * are the times since the timer was last started and will be + * 0.0 in a timer that has not been started since it was + * initialized. + * + * This function can be called either before or after + * H5_timer_stop() has been called. If it is called before the + * stop function, the timer will continue to run. + * + * The system and user times will be -1.0 if those times cannot + * be computed on a particular platform. The elapsed time will + * always be present. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Dana Robinson + * May 2011 + * + *------------------------------------------------------------------------- + */ +herr_t +H5_timer_get_times(H5_timer_t timer, H5_timevals_t *times /*in,out*/) +{ + /* Sanity check */ + HDassert(times); + + if(timer.is_running) { + H5_timevals_t now; + + /* Get the current times and report the current intervals without + * stopping the timer. + */ + if(H5__timer_get_timevals(&now) < 0) + return -1; + + times->elapsed = now.elapsed - timer.initial.elapsed; + times->system = now.system - timer.initial.system; + times->user = now.user - timer.initial.user; + } /* end if */ + else { + times->elapsed = timer.final_interval.elapsed; + times->system = timer.final_interval.system; + times->user = timer.final_interval.user; + } /* end else */ + + return 0; +} /* end H5_timer_get_times() */ + + +/*------------------------------------------------------------------------- + * Function: H5_timer_get_total_times + * + * Purpose: Get the TOTAL system, user and elapsed times recorded by + * the timer since its initialization. This is the sum of all + * times recorded while the timer was running. + * + * These will be 0.0 in a timer that has not been started + * since it was initialized. Calling H5_timer_init() on a + * timer will reset these values to 0.0. + * + * This function can be called either before or after + * H5_timer_stop() has been called. If it is called before the + * stop function, the timer will continue to run. + * + * The system and user times will be -1.0 if those times cannot + * be computed on a particular platform. The elapsed time will + * always be present. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Dana Robinson + * May 2011 + * + *------------------------------------------------------------------------- + */ +herr_t +H5_timer_get_total_times(H5_timer_t timer, H5_timevals_t *times /*in,out*/) +{ + /* Sanity check */ + HDassert(times); + + if(timer.is_running) { + H5_timevals_t now; + + /* Get the current times and report the current totals without + * stopping the timer. + */ + if(H5__timer_get_timevals(&now) < 0) + return -1; + + times->elapsed = timer.total.elapsed + (now.elapsed - timer.initial.elapsed); + times->system = timer.total.system + (now.system - timer.initial.system); + times->user = timer.total.user + (now.user - timer.initial.user); + } /* end if */ + else { + times->elapsed = timer.total.elapsed; + times->system = timer.total.system; + times->user = timer.total.user; + } /* end else */ + + return 0; +} /* end H5_timer_get_total_times() */ + + +/*------------------------------------------------------------------------- + * Function: H5_timer_get_time_string + * + * Purpose: Converts a time (in seconds) into a human-readable string + * suitable for log messages. + * + * Return: Success: The time string. + * + * The general format of the time string is: + * + * "N/A" time < 0 (invalid time) + * "%.f ns" time < 1 microsecond + * "%.1f us" time < 1 millisecond + * "%.1f ms" time < 1 second + * "%.2f s" time < 1 minute + * "%.f m %.f s" time < 1 hour + * "%.f h %.f m %.f s" longer times + * + * Failure: NULL + * + * Programmer: Dana Robinson + * May 2011 + * + *------------------------------------------------------------------------- + */ +char * +H5_timer_get_time_string(double seconds) +{ + char *s; /* output string */ + + /* Used when the time is greater than 59 seconds */ + double days; + double hours; + double minutes; + double remainder_sec; + + /* Extract larger time units from count of seconds */ + if(seconds > (double)60.0F) { + /* Set initial # of seconds */ + remainder_sec = seconds; + + /* Extract days */ + days = HDfloor(remainder_sec / H5_SEC_PER_DAY); + remainder_sec -= (days * H5_SEC_PER_DAY); + + /* Extract hours */ + hours = HDfloor(remainder_sec / H5_SEC_PER_HOUR); + remainder_sec -= (hours * H5_SEC_PER_HOUR); + + /* Extract minutes */ + minutes = HDfloor(remainder_sec / H5_SEC_PER_MIN); + remainder_sec -= (minutes * H5_SEC_PER_MIN); + + /* The # of seconds left is in remainder_sec */ + } /* end if */ + + /* Allocate */ + if(NULL == (s = (char *)HDcalloc(H5TIMER_TIME_STRING_LEN, sizeof(char)))) + return NULL; + + /* Do we need a format string? Some people might like a certain + * number of milliseconds or s before spilling to the next highest + * time unit. Perhaps this could be passed as an integer. + * (name? round_up_size? ?) + */ + if(seconds < (double)0.0F) + HDsprintf(s, "N/A"); + else if(H5_DBL_ABS_EQUAL((double)0.0F, seconds)) + HDsprintf(s, "0.0 s"); + else if(seconds < (double)1.0E-6F) + /* t < 1 us, Print time in ns */ + HDsprintf(s, "%.f ns", seconds * (double)1.0E9F); + else if(seconds < (double)1.0E-3F) + /* t < 1 ms, Print time in us */ + HDsprintf(s, "%.1f us", seconds * (double)1.0E6F); + else if(seconds < (double)1.0F) + /* t < 1 s, Print time in ms */ + HDsprintf(s, "%.1f ms", seconds * (double)1.0E3F); + else if(seconds < H5_SEC_PER_MIN) + /* t < 1 m, Print time in s */ + HDsprintf(s, "%.2f s", seconds); + else if(seconds < H5_SEC_PER_HOUR) + /* t < 1 h, Print time in m and s */ + HDsprintf(s, "%.f m %.f s", minutes, remainder_sec); + else if(seconds < H5_SEC_PER_DAY) + /* t < 1 d, Print time in h, m and s */ + HDsprintf(s, "%.f h %.f m %.f s", hours, minutes, remainder_sec); + else + /* Print time in d, h, m and s */ + HDsprintf(s, "%.f d %.f h %.f m %.f s", days, hours, minutes, remainder_sec); + + return s; +} /* end H5_timer_get_time_string() */ + diff --git a/src/H5trace.c b/src/H5trace.c index 26a59c7..6ba9fd0 100644 --- a/src/H5trace.c +++ b/src/H5trace.c @@ -127,8 +127,11 @@ H5_trace(const double *returning, const char *func, const char *type, ...) hssize_t i; void *vp = NULL; FILE *out = H5_debug_g.trace; - H5_timer_t event_time; - static H5_timer_t first_time = {0.0F, 0.0F, 0.0F}; + static hbool_t is_first_invocation = TRUE; + H5_timer_t function_timer; + H5_timevals_t function_times; + static H5_timer_t running_timer; + H5_timevals_t running_times; static int current_depth = 0; static int last_call_depth = 0; @@ -154,13 +157,18 @@ H5_trace(const double *returning, const char *func, const char *type, ...) } /* end else */ } /* end if */ - /* Get time for event */ - if(H5_DBL_ABS_EQUAL(first_time.etime, H5_DOUBLE(0.0))) - H5_timer_begin(&first_time); - if(H5_debug_g.ttimes) - H5_timer_begin(&event_time); - else - HDmemset(&event_time, 0, sizeof event_time); + /* Get time for event if the trace times flag is set */ + if(is_first_invocation && H5_debug_g.ttimes) { + /* start the library-wide timer */ + is_first_invocation = FALSE; + H5_timer_init(&running_timer); + H5_timer_start(&running_timer); + } /* end if */ + if(H5_debug_g.ttimes) { + /* start the timer for this function */ + H5_timer_init(&function_timer); + H5_timer_start(&function_timer); + } /* end if */ /* Print the first part of the line. This is the indication of the * nesting depth followed by the function name and either start of @@ -176,7 +184,9 @@ H5_trace(const double *returning, const char *func, const char *type, ...) if(H5_debug_g.ttimes) { char tmp[320]; - HDsprintf(tmp, "%.6f", event_time.etime-first_time.etime); + H5_timer_get_times(function_timer, &function_times); + H5_timer_get_times(running_timer, &running_times); + HDsprintf(tmp, "%.6f", (function_times.elapsed - running_times.elapsed)); HDfprintf(out, " %*s ", (int)HDstrlen(tmp), ""); } /* end if */ for(i = 0; i < current_depth; i++) @@ -191,8 +201,11 @@ H5_trace(const double *returning, const char *func, const char *type, ...) else { if(current_depth>last_call_depth) HDfputs(" = \n", out); - if(H5_debug_g.ttimes) - HDfprintf(out, "@%.6f ", event_time.etime - first_time.etime); + if(H5_debug_g.ttimes) { + H5_timer_get_times(function_timer, &function_times); + H5_timer_get_times(running_timer, &running_times); + HDfprintf(out, "@%.6f ", (function_times.elapsed - running_times.elapsed)); + } /* end if */ for(i = 0; i < current_depth; i++) HDfputc('+', out); HDfprintf(out, "%*s%s(", 2*current_depth, "", func); @@ -249,7 +262,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'a': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -263,7 +276,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'b': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -282,7 +295,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'd': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -298,7 +311,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'a': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -336,7 +349,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'c': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -362,7 +375,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'f': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -396,7 +409,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'F': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -430,7 +443,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'h': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -460,7 +473,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'i': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -498,7 +511,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'k': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -544,7 +557,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'l': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -586,7 +599,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'n': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -633,7 +646,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'o': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -663,7 +676,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -697,7 +710,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -723,7 +736,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'v': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -759,7 +772,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'e': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -778,7 +791,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'd': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -804,21 +817,21 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'e': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ else { H5E_error2_t *error = HDva_arg(ap, H5E_error2_t *); - HDfprintf(out, "0x%lx", (unsigned long)error); + HDfprintf(out, "0x%p", error); } /* end else */ break; case 's': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -849,7 +862,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -883,7 +896,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'd': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -917,7 +930,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'f': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -952,7 +965,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'm': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1003,7 +1016,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1029,7 +1042,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1038,7 +1051,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'v': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1084,7 +1097,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'o': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1132,14 +1145,14 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ else { H5G_stat_t *statbuf = HDva_arg(ap, H5G_stat_t*); - HDfprintf(out, "0x%lx", (unsigned long)statbuf); + HDfprintf(out, "0x%p", statbuf); } break; #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -1153,7 +1166,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'h': if(ptr) { if(vp) { - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); if(asize_idx >= 0 && asize[asize_idx] >= 0) { hsize_t *p = (hsize_t *)vp; @@ -1187,7 +1200,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) { - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); if(asize_idx >= 0 && asize[asize_idx] >= 0) { hssize_t *p = (hssize_t *)vp; @@ -1217,7 +1230,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'i': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1413,7 +1426,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'i': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1447,7 +1460,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'o': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1485,7 +1498,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) { - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); if(asize_idx >= 0 && asize[asize_idx] >= 0) { int *p = (int*)vp; @@ -1509,7 +1522,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1599,7 +1612,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'u': if(ptr) { if(vp) { - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); if(asize_idx >= 0 && asize[asize_idx] >= 0) { unsigned *p = (unsigned*)vp; @@ -1629,7 +1642,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'k': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1647,7 +1660,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'l': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1693,7 +1706,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'c': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1709,7 +1722,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'i': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1725,7 +1738,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1784,7 +1797,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'o': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1800,7 +1813,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1848,7 +1861,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'p': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1875,7 +1888,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'o': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1889,7 +1902,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'd': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1903,7 +1916,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'r': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1917,7 +1930,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1971,7 +1984,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'c': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2005,7 +2018,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2063,7 +2076,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2111,7 +2124,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2127,7 +2140,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'c': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2174,7 +2187,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'd': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2204,7 +2217,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'e': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2234,7 +2247,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'n': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2268,7 +2281,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'o': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2310,7 +2323,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'p': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2348,7 +2361,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2382,7 +2395,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2452,7 +2465,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'z': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2508,7 +2521,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2529,7 +2542,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'l': if(ptr) { if(vp) { - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); if(asize_idx >= 0 && asize[asize_idx] >= 0) { unsigned long *p = (unsigned long *)vp; @@ -2553,7 +2566,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'L': if(ptr) { if(vp) { - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); if(asize_idx >= 0 && asize[asize_idx] >= 0) { unsigned long long *p = (unsigned long long *)vp; @@ -2585,7 +2598,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'a': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2621,7 +2634,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'A': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2639,7 +2652,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'b': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2669,7 +2682,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'B': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2699,7 +2712,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'C': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2716,7 +2729,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'c': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2752,7 +2765,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'd': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2779,7 +2792,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'e': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2803,7 +2816,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'f': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2827,7 +2840,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'g': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2869,7 +2882,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'h': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2908,7 +2921,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'i': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2932,7 +2945,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'j': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2956,7 +2969,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'k': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2983,7 +2996,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'l': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3010,7 +3023,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'L': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3034,7 +3047,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'm': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3061,7 +3074,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'n': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3091,7 +3104,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'o': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3127,7 +3140,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'r': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3154,7 +3167,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3177,7 +3190,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'S': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3234,7 +3247,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3282,7 +3295,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'u': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3300,7 +3313,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'v': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3405,7 +3418,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'w': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3431,7 +3444,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'x': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3449,7 +3462,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'y': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3485,7 +3498,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'z': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3509,14 +3522,14 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'x': if(ptr) { if(vp) { - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); if(asize_idx >= 0 && asize[asize_idx] >= 0) { void **p = (void**)vp; HDfprintf(out, " {"); for(i = 0; i < asize[asize_idx]; i++) { if(p[i]) - HDfprintf(out, "%s0x%lx", (i ? ", " : ""), (unsigned long)(p[i])); + HDfprintf(out, "%s0x%p", (i ? ", " : ""), p[i]); else HDfprintf(out, "%sNULL", (i ? ", " : "")); } /* end for */ @@ -3530,7 +3543,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) vp = HDva_arg (ap, void *); if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end else */ @@ -3539,7 +3552,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'z': if(ptr) { if(vp) { - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); if(asize_idx >= 0 && asize[asize_idx] >= 0) { size_t *p = (size_t *)vp; @@ -3565,7 +3578,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'a': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3595,21 +3608,21 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'c': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ else { H5Z_class2_t *filter = HDva_arg(ap, H5Z_class2_t*); - HDfprintf(out, "0x%lx", (unsigned long)filter); + HDfprintf(out, "0x%p", filter); } /* end else */ break; case 'e': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3628,7 +3641,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'f': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3645,7 +3658,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) { - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); if(asize_idx >= 0 && asize[asize_idx] >= 0) { ssize_t *p = (ssize_t *)vp; @@ -3682,9 +3695,12 @@ H5_trace(const double *returning, const char *func, const char *type, ...) } /* end for */ /* Display event time for return */ - if(returning && H5_debug_g.ttimes) - HDfprintf(out, " @%.6f [dt=%.6f]", (event_time.etime - first_time.etime), - (event_time.etime - *returning)); + if(returning && H5_debug_g.ttimes) { + H5_timer_get_times(function_timer, &function_times); + H5_timer_get_times(running_timer, &running_times); + HDfprintf(out, " @%.6f [dt=%.6f]", (function_times.elapsed - running_times.elapsed), + (function_times.elapsed - *returning)); + } /* end if */ error: HDva_end(ap); @@ -3696,6 +3712,9 @@ error: } /* end else */ HDfflush(out); - return event_time.etime; + if(H5_debug_g.ttimes) + return function_times.elapsed; + else + return 0.0F; } /* end H5_trace() */ diff --git a/src/Makefile.am b/src/Makefile.am index 0c07c1b..787b502 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -62,7 +62,8 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5lib_settings.c H5system.c \ H5FA.c H5FAcache.c H5FAdbg.c H5FAdblock.c H5FAdblkpage.c H5FAhdr.c \ H5FAint.c H5FAstat.c H5FAtest.c \ H5FD.c H5FDcore.c H5FDfamily.c H5FDhdfs.c H5FDint.c H5FDlog.c \ - H5FDmulti.c H5FDsec2.c H5FDspace.c H5FDstdio.c H5FDtest.c \ + H5FDmulti.c H5FDsec2.c H5FDspace.c \ + H5FDsplitter.c H5FDstdio.c H5FDtest.c \ H5FL.c H5FO.c H5FS.c H5FScache.c H5FSdbg.c H5FSint.c H5FSsection.c \ H5FSstat.c H5FStest.c \ H5G.c H5Gbtree2.c H5Gcache.c H5Gcompact.c H5Gdense.c H5Gdeprec.c \ @@ -125,6 +126,11 @@ if DIRECT_VFD_CONDITIONAL libhdf5_la_SOURCES += H5FDdirect.c endif +# Only compile the mirror VFD if necessary +if MIRROR_VFD_CONDITIONAL + libhdf5_la_SOURCES += H5FDmirror.c +endif + # Only compile the read-only S3 VFD if necessary if ROS3_VFD_CONDITIONAL libhdf5_la_SOURCES += H5FDros3.c H5FDs3comms.c @@ -135,9 +141,9 @@ include_HEADERS = hdf5.h H5api_adpt.h H5overflow.h H5pubconf.h H5public.h H5vers H5Apublic.h H5ACpublic.h \ H5Cpublic.h H5Dpublic.h \ H5Epubgen.h H5Epublic.h H5ESpublic.h H5Fpublic.h \ - H5FDpublic.h H5FDcore.h H5FDdirect.h \ - H5FDfamily.h H5FDhdfs.h H5FDlog.h H5FDmpi.h H5FDmpio.h \ - H5FDmulti.h H5FDros3.h H5FDsec2.h H5FDstdio.h H5FDwindows.h \ + H5FDpublic.h H5FDcore.h H5FDdirect.h H5FDfamily.h H5FDhdfs.h \ + H5FDlog.h H5FDmirror.h H5FDmpi.h H5FDmpio.h H5FDmulti.h H5FDros3.h \ + H5FDsec2.h H5FDsplitter.h H5FDstdio.h H5FDwindows.h \ H5Gpublic.h H5Ipublic.h H5Lpublic.h \ H5Mpublic.h H5MMpublic.h H5Opublic.h H5Ppublic.h \ H5PLextern.h H5PLpublic.h \ diff --git a/src/hdf5.h b/src/hdf5.h index 8367122..eaaf8ae 100644 --- a/src/hdf5.h +++ b/src/hdf5.h @@ -46,10 +46,12 @@ #include "H5FDfamily.h" /* File families */ #include "H5FDhdfs.h" /* Hadoop HDFS */ #include "H5FDlog.h" /* sec2 driver with I/O logging (for debugging) */ +#include "H5FDmirror.h" /* Mirror VFD and IPC definitions */ #include "H5FDmpi.h" /* MPI-based file drivers */ #include "H5FDmulti.h" /* Usage-partitioned file family */ #include "H5FDros3.h" /* R/O S3 "file" I/O */ #include "H5FDsec2.h" /* POSIX unbuffered file I/O */ +#include "H5FDsplitter.h" /* Twin-channel (R/W & R/O) I/O passthrough */ #include "H5FDstdio.h" /* Standard C buffered I/O */ #ifdef H5_HAVE_WINDOWS #include "H5FDwindows.h" /* Win32 I/O */ diff --git a/src/libhdf5.settings.in b/src/libhdf5.settings.in index 8e108c9..fb9deec 100644 --- a/src/libhdf5.settings.in +++ b/src/libhdf5.settings.in @@ -80,6 +80,7 @@ Parallel Filtered Dataset Writes: @PARALLEL_FILTERED_WRITES@ MPE: @MPE@ Map (H5M) API: @MAP_API@ Direct VFD: @DIRECT_VFD@ + Mirror VFD: @MIRROR_VFD@ (Read-Only) S3 VFD: @ROS3_VFD@ (Read-Only) HDFS VFD: @HAVE_LIBHDFS@ dmalloc: @HAVE_DMALLOC@ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 5f3ec5f..311d753 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -211,6 +211,11 @@ set (cache_image_SOURCES ${HDF5_TEST_SOURCE_DIR}/genall5.c ) +set(mirror_vfd_SOURCES + ${HDF5_TEST_SOURCE_DIR}/mirror_vfd.c + ${HDF5_TEST_SOURCE_DIR}/genall5.c +) + set (ttsafe_SOURCES ${HDF5_TEST_SOURCE_DIR}/ttsafe.c ${HDF5_TEST_SOURCE_DIR}/ttsafe_dcreate.c @@ -274,6 +279,7 @@ set (H5_TESTS ros3 s3comms hdfs + mirror_vfd ntypes dangle dtransform @@ -288,8 +294,9 @@ set (H5_TESTS cache_logging cork swmr - thread_id + thread_id # special link vol + timer ) macro (ADD_H5_EXE file) @@ -312,6 +319,8 @@ set (H5_TESTS_MULTIPLE testhdf5 cache_image ttsafe + thread_id # special link + mirror_vfd ) # Only build single source tests here foreach (h5_test ${H5_TESTS}) @@ -396,6 +405,37 @@ else () endif () set_target_properties (ttsafe PROPERTIES FOLDER test) +######### Special handling for extra link lib of threads ############# +#-- Adding test for thread_id +add_executable (thread_id ${HDF5_TEST_SOURCE_DIR}/thread_id.c) +target_compile_options(thread_id PRIVATE "${HDF5_CMAKE_C_FLAGS}") +target_include_directories (thread_id PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") +if (NOT BUILD_SHARED_LIBS) + TARGET_C_PROPERTIES (thread_id STATIC) + target_link_libraries (thread_id PRIVATE ${HDF5_TEST_LIB_TARGET}) + if (NOT WIN32) + target_link_libraries (thread_id + PRIVATE $<$:Threads::Threads> + ) + endif () +else () + TARGET_C_PROPERTIES (thread_id SHARED) + target_link_libraries (thread_id PRIVATE ${HDF5_TEST_LIBSH_TARGET} $<$:Threads::Threads>) +endif () +set_target_properties (thread_id PROPERTIES FOLDER test) + +#-- Adding test for mirror_vfd +add_executable (mirror_vfd ${mirror_vfd_SOURCES}) +target_include_directories (mirror_vfd PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") +if (NOT BUILD_SHARED_LIBS) + TARGET_C_PROPERTIES (mirror_vfd STATIC) + target_link_libraries (mirror_vfd PRIVATE ${HDF5_TEST_LIB_TARGET}) +else () + TARGET_C_PROPERTIES (mirror_vfd SHARED) + target_link_libraries (mirror_vfd PRIVATE ${HDF5_TEST_LIBSH_TARGET}) +endif () +set_target_properties (mirror_vfd PROPERTIES FOLDER test) + ############################################################################## ### A D D I T I O N A L T E S T S ### ############################################################################## diff --git a/test/H5srcdir.h b/test/H5srcdir.h index 32fe8c9..019cfda 100644 --- a/test/H5srcdir.h +++ b/test/H5srcdir.h @@ -12,7 +12,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Wednesday, March 17, 2010 * * Purpose: srcdir querying support. @@ -20,51 +20,18 @@ #ifndef _H5SRCDIR_H #define _H5SRCDIR_H -/* Include the header file with the correct relative path for the srcdir string */ -#include "H5srcdir_str.h" - -/* Buffer to construct path in and return pointer to */ -static char srcdir_path[1024] = ""; - -/* Buffer to construct file in and return pointer to */ -static char srcdir_testpath[1024] = ""; - +#ifdef __cplusplus +extern "C" { +#endif /* Just return the srcdir path */ -static const char * -H5_get_srcdir(void) -{ - const char *srcdir = HDgetenv("srcdir"); - - /* Check for using the srcdir from configure time */ - if(NULL == srcdir) - srcdir = config_srcdir; - - /* Build path to all test files */ - if((HDstrlen(srcdir) + 2) < sizeof(srcdir_path)) { - HDsnprintf(srcdir_path, sizeof(srcdir_path), "%s/", srcdir); - return(srcdir_path); - } /* end if */ - else - return(NULL); -} /* end H5_get_srcdir() */ +H5TEST_DLL const char *H5_get_srcdir(void); /* Append the test file name to the srcdir path and return the whole string */ -static const char *H5_get_srcdir_filename(const char *filename) -{ - const char *srcdir = H5_get_srcdir(); +H5TEST_DLL const char *H5_get_srcdir_filename(const char *filename); + +#ifdef __cplusplus +} +#endif - /* Check for error */ - if(NULL == srcdir) - return(NULL); - else { - /* Build path to test file */ - if((HDstrlen(srcdir) + HDstrlen(filename) + 1) < sizeof(srcdir_testpath)) { - HDsnprintf(srcdir_testpath, sizeof(srcdir_testpath), "%s%s", srcdir, filename); - return(srcdir_testpath); - } /* end if */ - else - return(NULL); - } /* end else */ -} /* end H5_get_srcdir_filename() */ #endif /* _H5SRCDIR_H */ diff --git a/test/Makefile.am b/test/Makefile.am index 34159c7..7ebeae7 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -33,9 +33,11 @@ AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_builddir)/src # testvdsswmr.sh: vds_swmr* # testabort_fail.sh: filenotclosed.c and del_many_dense_attrs.c # test_filter_plugin.sh: filter_plugin.c +# test_mirror.sh: mirror_vfd ../utils/mirror_vfd/* # test_usecases.sh: use_append_chunk, use_append_mchunks, use_disable_mdc_flushes TEST_SCRIPT = testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh testexternal_env.sh \ - testswmr.sh testvds_env.sh testvdsswmr.sh testflushrefresh.sh test_usecases.sh testabort_fail.sh + testswmr.sh testvds_env.sh testvdsswmr.sh testflushrefresh.sh test_usecases.sh testabort_fail.sh \ + test_mirror.sh SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT) links_env$(EXEEXT) \ external_env$(EXEEXT) filenotclosed$(EXEEXT) del_many_dense_attrs$(EXEEXT) \ flushrefresh$(EXEEXT) use_append_chunk$(EXEEXT) use_append_mchunks$(EXEEXT) use_disable_mdc_flushes$(EXEEXT) \ @@ -63,7 +65,7 @@ TEST_PROG= testhdf5 \ flush1 flush2 app_ref enum set_extent ttsafe enc_dec_plist \ enc_dec_plist_cross_platform getname vfd ros3 s3comms hdfs ntypes \ dangle dtransform reserved cross_read freespace mf vds file_image \ - unregister cache_logging cork swmr thread_id vol + unregister cache_logging cork swmr thread_id vol timer # List programs to be built when testing here. # error_test and err_compat are built at the same time as the other tests, but executed by testerror.sh. @@ -78,16 +80,18 @@ TEST_PROG= testhdf5 \ # swmr_* files (besides swmr.c) are used by testswmr.sh. # vds_swmr_* files are used by testvdsswmr.sh # vds_env is used by testvds_env.sh +# mirror_vfd is used by test_mirror.sh # 'make check' doesn't run them directly, so they are not included in TEST_PROG. # Also build testmeta, which is used for timings test. It builds quickly, # and this lets automake keep all its test programs in one place. check_PROGRAMS=$(TEST_PROG) error_test err_compat tcheck_version \ testmeta accum_swmr_reader atomic_writer atomic_reader external_env \ links_env filenotclosed del_many_dense_attrs flushrefresh \ - use_append_chunk use_append_mchunks use_disable_mdc_flushes \ + use_append_chunk use_append_chunk_mirror use_append_mchunks use_disable_mdc_flushes \ swmr_generator swmr_start_write swmr_reader swmr_writer swmr_remove_reader \ swmr_remove_writer swmr_addrem_writer swmr_sparse_reader swmr_sparse_writer \ - swmr_check_compat_vfd vds_env vds_swmr_gen vds_swmr_reader vds_swmr_writer + swmr_check_compat_vfd vds_env vds_swmr_gen vds_swmr_reader vds_swmr_writer \ + mirror_vfd if HAVE_SHARED_CONDITIONAL check_PROGRAMS+= filter_plugin vol_plugin endif @@ -144,6 +148,7 @@ LDADD=libh5test.la $(LIBHDF5) ttsafe_SOURCES=ttsafe.c ttsafe_dcreate.c ttsafe_error.c ttsafe_cancel.c \ ttsafe_acreate.c ttsafe_attr_vlen.c cache_image_SOURCES=cache_image.c genall5.c +mirror_vfd_SOURCES=mirror_vfd.c genall5.c VFD_LIST = sec2 stdio core core_paged split multi family if DIRECT_VFD_CONDITIONAL @@ -226,12 +231,13 @@ testhdf5_SOURCES=testhdf5.c tarray.c tattr.c tchecksum.c tconfig.c tfile.c \ # Sources for Use Cases use_append_chunk_SOURCES=use_append_chunk.c use_common.c +use_append_chunk_mirror_SOURCES=use_append_chunk_mirror.c use_common.c use_append_mchunks_SOURCES=use_append_mchunks.c use_common.c use_disable_mdc_flushes_SOURCES=use_disable_mdc_flushes.c # Temporary files. DISTCLEANFILES=testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh test_filter_plugin.sh \ - testexternal_env.sh testswmr.sh testvds_env.sh testvdsswmr.sh test_usecases.sh testflushrefresh.sh testabort_fail.sh \ - test_vol_plugin.sh + testexternal_env.sh testswmr.sh testvds_env.sh testvdsswmr.sh test_usecases.sh testflushrefresh.sh \ + testabort_fail.sh test_vol_plugin.sh test_mirror.sh include $(top_srcdir)/config/conclude.am diff --git a/test/cache.c b/test/cache.c index a90f12b..bb18728 100644 --- a/test/cache.c +++ b/test/cache.c @@ -13932,7 +13932,7 @@ check_move_entry(unsigned paged) takedown_cache(file_ptr, FALSE, FALSE); if(pass) - PASSED() + PASSED(); else H5_FAILED() @@ -17061,7 +17061,7 @@ check_move_entry_errs(unsigned paged) takedown_cache(file_ptr, FALSE, FALSE); if(pass) - PASSED() + PASSED(); else { H5_FAILED() @@ -19914,7 +19914,7 @@ check_auto_cache_resize(hbool_t cork_ageout, unsigned paged) /* NOTE: upper_hr_threshold MUST be type double (not float) * or the cache test will fail on 64-bit systems. */ - auto_size_ctl.upper_hr_threshold = H5_DOUBLE(0.999); /* for ease of testing */ + auto_size_ctl.upper_hr_threshold = 0.999; /* for ease of testing */ auto_size_ctl.decrement = 0.5f; @@ -30716,7 +30716,7 @@ done: takedown_cache(file_ptr, FALSE, FALSE); if(pass) - PASSED() + PASSED(); else { H5_FAILED(); HDfprintf(stdout, "%s.\n", failure_mssg); @@ -30939,7 +30939,7 @@ done: takedown_cache(file_ptr, FALSE, FALSE); if(pass) - PASSED() + PASSED(); else { H5_FAILED(); HDfprintf(stdout, "%s.\n", failure_mssg); @@ -33511,7 +33511,7 @@ done: takedown_cache(file_ptr, FALSE, FALSE); if(pass) - PASSED() + PASSED(); else { H5_FAILED(); HDfprintf(stdout, "%s.\n", failure_mssg); @@ -33714,7 +33714,7 @@ done: takedown_cache(file_ptr, FALSE, FALSE); if(pass) - PASSED() + PASSED(); else { H5_FAILED(); HDfprintf(stdout, "%s.\n", failure_mssg); diff --git a/test/cache_api.c b/test/cache_api.c index 87d0025..ca2e0ca 100644 --- a/test/cache_api.c +++ b/test/cache_api.c @@ -1664,7 +1664,7 @@ init_invalid_configs(void) { configs[13].lower_hr_threshold = 1.00000001f; /* 14 -- increment too small */ - configs[14].increment = H5_DOUBLE(0.999999999999); + configs[14].increment = 0.999999999999; /* 15 -- invalid flash_incr_mode */ configs[15].flash_incr_mode = (enum H5C_cache_flash_incr_mode)-1; @@ -1697,7 +1697,7 @@ init_invalid_configs(void) { /* 23 -- decrement too big */ configs[23].decr_mode = H5C_decr__threshold; - configs[23].decrement = H5_DOUBLE(1.0000000001); + configs[23].decrement = 1.0000000001; /* 24 -- epochs_before_eviction too small */ configs[24].epochs_before_eviction = 0; @@ -1709,13 +1709,13 @@ init_invalid_configs(void) { configs[26].empty_reserve = -0.0000000001f; /* 27 -- empty_reserve too big */ - configs[27].empty_reserve = H5_DOUBLE(1.00000000001); + configs[27].empty_reserve = 1.00000000001; /* 28 -- upper_hr_threshold too small */ configs[28].upper_hr_threshold = -0.000000001f; /* 29 -- upper_hr_threshold too big */ - configs[29].upper_hr_threshold = H5_DOUBLE(1.00000001); + configs[29].upper_hr_threshold = 1.00000001; /* 30 -- upper_hr_threshold <= lower_hr_threshold */ configs[30].lower_hr_threshold = 0.9f; diff --git a/test/del_many_dense_attrs.c b/test/del_many_dense_attrs.c index 4c1efae..6f48901 100644 --- a/test/del_many_dense_attrs.c +++ b/test/del_many_dense_attrs.c @@ -62,17 +62,17 @@ static void catch_signal(int H5_ATTR_UNUSED signo) int main(void) { - hid_t fid = -1; /* HDF5 File ID */ - hid_t gid = -1; /* Group ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t aid = -1; /* Attribute ID */ - hid_t tid = -1; /* Datatype ID */ - hid_t fapl = -1; /* File access property lists */ - hid_t gcpl = -1; /* Group creation property list */ - char aname[50]; /* Name of attribute */ - char *basename="attr"; /* Name prefix for attribute */ - char filename[100]; /* File name */ - int i; /* Local index variable */ + hid_t fid = -1; /* HDF5 File ID */ + hid_t gid = -1; /* Group ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t aid = -1; /* Attribute ID */ + hid_t tid = -1; /* Datatype ID */ + hid_t fapl = -1; /* File access property lists */ + hid_t gcpl = -1; /* Group creation property list */ + char aname[50]; /* Name of attribute */ + const char *basename="attr"; /* Name prefix for attribute */ + char filename[100]; /* File name */ + int i; /* Local index variable */ /* Testing setup */ h5_reset(); diff --git a/test/direct_chunk.c b/test/direct_chunk.c index 6cf27c8..2e6cc68 100644 --- a/test/direct_chunk.c +++ b/test/direct_chunk.c @@ -43,7 +43,7 @@ #define CHUNK_NX 4 #define CHUNK_NY 4 -#define DEFLATE_SIZE_ADJUST(s) (HDceil(((double)(s))*H5_DOUBLE(1.001))+H5_DOUBLE(12.0)) +#define DEFLATE_SIZE_ADJUST(s) (HDceil(((double)(s))*1.001)+12.0) /* Temporary filter IDs used for testing */ #define H5Z_FILTER_BOGUS1 305 diff --git a/test/dsets.c b/test/dsets.c index 7f2eda5..4ab3efa 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -277,10 +277,16 @@ const char *FILENAME[] = { /* Shared global arrays */ #define DSET_DIM1 100 #define DSET_DIM2 200 -int points[DSET_DIM1][DSET_DIM2], check[DSET_DIM1][DSET_DIM2]; -double points_dbl[DSET_DIM1][DSET_DIM2], check_dbl[DSET_DIM1][DSET_DIM2]; -size_t count_nbytes_read = 0; -size_t count_nbytes_written = 0; +int **points = NULL; +int *points_data = NULL; +double **points_dbl = NULL; +double *points_dbl_data = NULL; +int **check = NULL; +int *check_data = NULL; +double **check_dbl = NULL; +double *check_dbl_data = NULL; +size_t count_nbytes_read = 0; +size_t count_nbytes_written = 0; /* Temporary buffer dimensions */ #define DSET_TMP_DIM1 50 @@ -516,7 +522,8 @@ test_simple_io(const char *env_h5_drvr, hid_t fapl) void *tconv_buf = NULL; int f = -1; haddr_t offset; - int rdata[DSET_DIM1][DSET_DIM2]; + int **rdata = NULL; + int *rdata_bytes = NULL; TESTING("simple I/O"); @@ -524,6 +531,14 @@ test_simple_io(const char *env_h5_drvr, hid_t fapl) if(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family")) { h5_fixname(FILENAME[4], fapl, filename, sizeof filename); + /* Set up data array */ + if(NULL == (rdata_bytes = (int *)HDcalloc(DSET_DIM1 * DSET_DIM2, sizeof(int)))) + TEST_ERROR; + if(NULL == (rdata = (int **)HDcalloc(DSET_DIM1, sizeof(rdata_bytes)))) + TEST_ERROR; + for (i = 0; i < DSET_DIM1; i++) + rdata[i] = rdata_bytes + (i * DSET_DIM2); + /* Initialize the dataset */ for(i = n = 0; i < DSET_DIM1; i++) for(j = 0; j < DSET_DIM2; j++) @@ -553,7 +568,7 @@ test_simple_io(const char *env_h5_drvr, hid_t fapl) if(H5Dget_offset(dataset) != HADDR_UNDEF) goto error; /* Write the data to the dataset */ - if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, points) < 0) + if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, points_data) < 0) goto error; /* Test dataset address in file. Open the same file as a C file, seek @@ -562,7 +577,7 @@ test_simple_io(const char *env_h5_drvr, hid_t fapl) if((offset=H5Dget_offset(dataset))==HADDR_UNDEF) goto error; /* Read the dataset back */ - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, check) < 0) + if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, check_data) < 0) goto error; /* Check that the values read are the same as the values written */ @@ -586,7 +601,7 @@ test_simple_io(const char *env_h5_drvr, hid_t fapl) f = HDopen(filename, O_RDONLY); HDlseek(f, (off_t)offset, SEEK_SET); - if(HDread(f, rdata, sizeof(int)*DSET_DIM1*DSET_DIM2) < 0) + if(HDread(f, rdata_bytes, sizeof(int)*DSET_DIM1*DSET_DIM2) < 0) goto error; /* Check that the values read are the same as the values written */ @@ -605,6 +620,9 @@ test_simple_io(const char *env_h5_drvr, hid_t fapl) f = -1; HDfree(tconv_buf); + HDfree(rdata_bytes); + HDfree(rdata); + PASSED(); } /* end if */ else { @@ -625,8 +643,11 @@ error: if(H5Fclose(file) < 0) TEST_ERROR if(f > 0) HDclose(f); - if(tconv_buf) - HDfree(tconv_buf); + + HDfree(tconv_buf); + HDfree(rdata_bytes); + HDfree(rdata); + return FAIL; } /* end test_simple_io() */ @@ -649,7 +670,8 @@ test_userblock_offset(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) hsize_t dims[2]; int f = -1; haddr_t offset; - int rdata[DSET_DIM1][DSET_DIM2]; + int **rdata = NULL; + int *rdata_bytes = NULL; TESTING("dataset offset with user block"); @@ -657,6 +679,14 @@ test_userblock_offset(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) if(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family")) { h5_fixname(FILENAME[2], fapl, filename, sizeof filename); + /* Set up data array */ + if(NULL == (rdata_bytes = (int *)HDcalloc(DSET_DIM1 * DSET_DIM2, sizeof(int)))) + TEST_ERROR; + if(NULL == (rdata = (int **)HDcalloc(DSET_DIM1, sizeof(rdata_bytes)))) + TEST_ERROR; + for (i = 0; i < DSET_DIM1; i++) + rdata[i] = rdata_bytes + (i * DSET_DIM2); + if((fcpl=H5Pcreate(H5P_FILE_CREATE)) < 0) goto error; if(H5Pset_userblock(fcpl, (hsize_t)USER_BLOCK) < 0) goto error; if(new_format) @@ -680,7 +710,7 @@ test_userblock_offset(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) space = -1; /* Write the data to the dataset */ - if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0) + if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points_data) < 0) goto error; /* Test dataset address in file. Open the same file as a C file, seek @@ -695,7 +725,7 @@ test_userblock_offset(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) f = HDopen(filename, O_RDONLY); HDlseek(f, (off_t)offset, SEEK_SET); - if(HDread(f, rdata, sizeof(int)*DSET_DIM1*DSET_DIM2) < 0) + if(HDread(f, rdata_bytes, sizeof(int)*DSET_DIM1*DSET_DIM2) < 0) goto error; /* Check that the values read are the same as the values written */ @@ -713,6 +743,9 @@ test_userblock_offset(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) HDclose(f); f = -1; + HDfree(rdata_bytes); + HDfree(rdata); + PASSED(); } /* end if */ else { @@ -733,6 +766,10 @@ error: if(H5Fclose(file) < 0) TEST_ERROR if(f > 0) HDclose(f); + + HDfree(rdata_bytes); + HDfree(rdata); + return FAIL; } /* end test_userblock_offset() */ @@ -1791,7 +1828,7 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, */ TESTING(" filters (uninitialized read)"); - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0) + if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check_data) < 0) TEST_ERROR; for(i=0; i<(size_t)size[0]; i++) { @@ -1820,7 +1857,7 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, } } - if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, points) < 0) + if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, points_data) < 0) TEST_ERROR; if((*dset_size=H5Dget_storage_size(dataset))==0) TEST_ERROR; @@ -1838,25 +1875,25 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, /* Default behavior is failure when data is corrupted. */ /* (Use the "write" DXPL in order to make certain corruption is seen) */ H5E_BEGIN_TRY { - status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check); + status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data); } H5E_END_TRY; if(status>=0) TEST_ERROR; /* Callback decides to continue inspite data is corrupted. */ if(H5Pset_filter_callback(dxpl, filter_cb_cont, NULL) < 0) TEST_ERROR; - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0) + if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check_data) < 0) TEST_ERROR; /* Callback decides to fail when data is corrupted. */ if(H5Pset_filter_callback(write_dxpl, filter_cb_fail, NULL) < 0) TEST_ERROR; /* (Use the "write" DXPL in order to make certain corruption is seen) */ H5E_BEGIN_TRY { - status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check); + status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data); } H5E_END_TRY; if(status>=0) TEST_ERROR; } else { - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0) + if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check_data) < 0) TEST_ERROR; /* Check that the values read are the same as the values written */ @@ -1890,33 +1927,33 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, points[i][j] = (int)HDrandom (); } } - if(H5Dwrite (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, points) < 0) + if(H5Dwrite (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, points_data) < 0) TEST_ERROR; if(corrupted) { /* Default behavior is failure when data is corrupted. */ /* (Use the "write" DXPL in order to make certain corruption is seen) */ H5E_BEGIN_TRY { - status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check); + status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data); } H5E_END_TRY; if(status>=0) TEST_ERROR; /* Callback decides to continue inspite data is corrupted. */ if(H5Pset_filter_callback(dxpl, filter_cb_cont, NULL) < 0) TEST_ERROR; - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0) + if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check_data) < 0) TEST_ERROR; /* Callback decides to fail when data is corrupted. */ if(H5Pset_filter_callback(write_dxpl, filter_cb_fail, NULL) < 0) TEST_ERROR; /* (Use the "write" DXPL in order to make certain corruption is seen) */ H5E_BEGIN_TRY { - status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check); + status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data); } H5E_END_TRY; if(status>=0) TEST_ERROR; } else { /* Read the dataset back and check it */ - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0) + if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check_data) < 0) TEST_ERROR; /* Check that the values read are the same as the values written */ @@ -1951,13 +1988,13 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, /* Default behavior is failure when data is corrupted. */ /* (Use the "write" DXPL in order to make certain corruption is seen) */ H5E_BEGIN_TRY { - status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check); + status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data); } H5E_END_TRY; if(status >= 0) TEST_ERROR; /* Callback decides to continue inspite data is corrupted. */ if(H5Pset_filter_callback(dxpl, filter_cb_cont, NULL) < 0) TEST_ERROR; - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0) + if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check_data) < 0) TEST_ERROR; /* Callback decides to fail when data is corrupted. */ @@ -1965,12 +2002,12 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, /* (Use the "write" DXPL in order to make certain corruption is seen) */ H5E_BEGIN_TRY { - status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check); + status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data); } H5E_END_TRY; if(status >= 0) TEST_ERROR; } /* end if */ else { - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0) + if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check_data) < 0) TEST_ERROR; /* Check that the values read are the same as the values written */ @@ -2004,32 +2041,32 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0) TEST_ERROR; /* (Use the "read" DXPL because partial I/O on corrupted data test needs to ignore errors during writing) */ - if(H5Dwrite (dataset, H5T_NATIVE_INT, sid, sid, dxpl, points) < 0) + if(H5Dwrite (dataset, H5T_NATIVE_INT, sid, sid, dxpl, points_data) < 0) TEST_ERROR; if(corrupted) { /* Default behavior is failure when data is corrupted. */ /* (Use the "write" DXPL in order to make certain corruption is seen) */ H5E_BEGIN_TRY { - status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check); + status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data); } H5E_END_TRY; if(status>=0) TEST_ERROR; /* Callback decides to continue inspite data is corrupted. */ if(H5Pset_filter_callback(dxpl, filter_cb_cont, NULL) < 0) TEST_ERROR; - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0) + if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check_data) < 0) TEST_ERROR; /* Callback decides to fail when data is corrupted. */ if(H5Pset_filter_callback(write_dxpl, filter_cb_fail, NULL) < 0) TEST_ERROR; /* (Use the "write" DXPL in order to make certain corruption is seen) */ H5E_BEGIN_TRY { - status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check); + status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data); } H5E_END_TRY; if(status>=0) TEST_ERROR; } else { - if(H5Dread (dataset, H5T_NATIVE_INT, sid, sid, dxpl, check) < 0) + if(H5Dread (dataset, H5T_NATIVE_INT, sid, sid, dxpl, check_data) < 0) TEST_ERROR; /* Check that the values read are the same as the values written */ @@ -2634,7 +2671,7 @@ test_missing_filter(hid_t file) } /* end if */ /* Write data */ - if(H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0) { + if(H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points_data) < 0) { H5_FAILED(); HDprintf(" Line %d: Error writing dataset data\n",__LINE__); goto error; @@ -2663,7 +2700,7 @@ test_missing_filter(hid_t file) } /* end if */ /* Read data */ - if(H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check) < 0) { + if(H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check_data) < 0) { H5_FAILED(); HDprintf(" Line %d: Error reading dataset data\n",__LINE__); goto error; @@ -2724,7 +2761,7 @@ test_missing_filter(hid_t file) /* Read data (should fail, since deflate filter is missing) */ H5E_BEGIN_TRY { - ret = H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check); + ret = H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check_data); } H5E_END_TRY; if(ret>=0) { H5_FAILED(); @@ -3132,18 +3169,18 @@ test_nbit_double(hid_t file) */ double orig_data[2][5] = { { - H5_DOUBLE(1.6081706885101836e+60), - H5_DOUBLE(-255.32099170994480), - H5_DOUBLE(1.2677579992621376e-61), - H5_DOUBLE(64568.289448797700), - H5_DOUBLE(-1.0619721778839084e-75) + (double)1.6081706885101836e+60L, + -255.32099170994480f, + (double)1.2677579992621376e-61L, + 64568.289448797700f, + (double)-1.0619721778839084e-75L }, { - H5_DOUBLE(2.1499497833454840e+56), - H5_DOUBLE(6.6562295504670740e-3), - H5_DOUBLE(-1.5747263393432150), - H5_DOUBLE(1.0711093225222612), - H5_DOUBLE(-9.8971679387636870e-1) + (double)2.1499497833454840e+56L, + 6.6562295504670740e-3f, + -1.5747263393432150f, + 1.0711093225222612f, + -9.8971679387636870e-1f }}; double new_data[2][5]; size_t precision, offset; @@ -4132,149 +4169,164 @@ test_nbit_int_size(hid_t file) hid_t dataspace, dataset, datatype, mem_datatype, dset_create_props; hsize_t dims[2], chunk_size[2]; hsize_t dset_size = 0; - int orig_data[DSET_DIM1][DSET_DIM2]; + int **orig = NULL; + int *orig_data = NULL; double power; int i, j; size_t precision, offset; TESTING(" nbit integer dataset size"); - /* Define dataset datatype (integer), and set precision, offset */ - if((datatype = H5Tcopy(H5T_NATIVE_INT)) < 0) { - H5_FAILED(); - HDprintf(" line %d: H5Tcopy failed\n",__LINE__); - goto error; - } /* end if */ + /* Set up data array */ + if(NULL == (orig_data = (int *)HDcalloc(DSET_DIM1 * DSET_DIM2, sizeof(int)))) + TEST_ERROR; + if(NULL == (orig = (int **)HDcalloc(DSET_DIM1, sizeof(orig_data)))) + TEST_ERROR; + for (i = 0; i < DSET_DIM1; i++) + orig[i] = orig_data + (i * DSET_DIM2); - precision = 16; /* precision includes sign bit */ - if(H5Tset_precision(datatype,precision)<0) { - H5_FAILED(); - HDprintf(" line %d: H5Pset_precision failed\n",__LINE__); - goto error; - } /* end if */ + /* Define dataset datatype (integer), and set precision, offset */ + if((datatype = H5Tcopy(H5T_NATIVE_INT)) < 0) { + H5_FAILED(); + HDprintf(" line %d: H5Tcopy failed\n",__LINE__); + goto error; + } - offset = 8; - if(H5Tset_offset(datatype,offset)<0) { - H5_FAILED(); - HDprintf(" line %d: H5Tset_offset failed\n",__LINE__); - goto error; - } /* end if */ + precision = 16; /* precision includes sign bit */ + if(H5Tset_precision(datatype,precision)<0) { + H5_FAILED(); + HDprintf(" line %d: H5Pset_precision failed\n",__LINE__); + goto error; + } - /* Copy to memory datatype */ - if((mem_datatype = H5Tcopy(datatype)) < 0) { - H5_FAILED(); - HDprintf(" line %d: H5Tcopy failed\n",__LINE__); - goto error; - } /* end if */ + offset = 8; + if(H5Tset_offset(datatype,offset)<0) { + H5_FAILED(); + HDprintf(" line %d: H5Tset_offset failed\n",__LINE__); + goto error; + } - /* Set order of dataset datatype */ - if(H5Tset_order(datatype, H5T_ORDER_BE)<0) { + /* Copy to memory datatype */ + if((mem_datatype = H5Tcopy(datatype)) < 0) { H5_FAILED(); - HDprintf(" line %d: H5Pset_order failed\n",__LINE__); - goto error; - } /* end if */ + HDprintf(" line %d: H5Tcopy failed\n",__LINE__); + goto error; + } - if(H5Tset_size(datatype, 4)<0) { - H5_FAILED(); - HDprintf(" line %d: H5Pset_size failed\n",__LINE__); - goto error; - } /* end if */ + /* Set order of dataset datatype */ + if(H5Tset_order(datatype, H5T_ORDER_BE)<0) { + H5_FAILED(); + HDprintf(" line %d: H5Pset_order failed\n",__LINE__); + goto error; + } - /* Initiliaze data buffer with random data within correct range - * corresponding to the memory datatype's precision and offset. - */ - for (i=0; i < DSET_DIM1; i++) - for (j=0; j < DSET_DIM2; j++) { - power = HDpow(2.0F, (double)(precision-1)); - orig_data[i][j] = HDrandom() % (int)power << offset; - } /* end for */ + if(H5Tset_size(datatype, 4)<0) { + H5_FAILED(); + HDprintf(" line %d: H5Pset_size failed\n",__LINE__); + goto error; + } + /* Initiliaze data buffer with random data within correct range + * corresponding to the memory datatype's precision and offset. + */ + for (i=0; i < DSET_DIM1; i++) + for (j=0; j < DSET_DIM2; j++) { + power = HDpow(2.0F, (double)(precision-1)); + orig[i][j] = HDrandom() % (int)power << offset; + } - /* Describe the dataspace. */ - dims[0] = DSET_DIM1; - dims[1] = DSET_DIM2; - if((dataspace = H5Screate_simple (2, dims, NULL))<0) { - H5_FAILED(); - HDprintf(" line %d: H5Pcreate failed\n",__LINE__); - goto error; - } /* end if */ - /* - * Set the dataset creation property list to specify the chunks - */ - chunk_size[0] = DSET_DIM1/10; - chunk_size[1] = DSET_DIM2/10; - if((dset_create_props = H5Pcreate (H5P_DATASET_CREATE))<0) { - H5_FAILED(); - HDprintf(" line %d: H5Pcreate failed\n",__LINE__); - goto error; - } /* end if */ + /* Describe the dataspace. */ + dims[0] = DSET_DIM1; + dims[1] = DSET_DIM2; + if((dataspace = H5Screate_simple(2, dims, NULL))<0) { + H5_FAILED(); + HDprintf(" line %d: H5Pcreate failed\n",__LINE__); + goto error; + } - if(H5Pset_chunk (dset_create_props, 2, chunk_size)<0) { - H5_FAILED(); - HDprintf(" line %d: H5Pset_chunk failed\n",__LINE__); - goto error; - } /* end if */ + /* + * Set the dataset creation property list to specify the chunks + */ + chunk_size[0] = DSET_DIM1/10; + chunk_size[1] = DSET_DIM2/10; + if((dset_create_props = H5Pcreate(H5P_DATASET_CREATE))<0) { + H5_FAILED(); + HDprintf(" line %d: H5Pcreate failed\n",__LINE__); + goto error; + } - /* - * Set for n-bit compression - */ - if(H5Pset_nbit (dset_create_props)<0) { - H5_FAILED(); - HDprintf(" line %d: H5Pset_nbit failed\n",__LINE__); - goto error; - } /* end if */ + if(H5Pset_chunk(dset_create_props, 2, chunk_size)<0) { + H5_FAILED(); + HDprintf(" line %d: H5Pset_chunk failed\n",__LINE__); + goto error; + } - /* - * Create a new dataset within the file. - */ - if((dataset = H5Dcreate2 (file, DSET_NBIT_INT_SIZE_NAME, datatype, + /* + * Set for n-bit compression + */ + if(H5Pset_nbit(dset_create_props)<0) { + H5_FAILED(); + HDprintf(" line %d: H5Pset_nbit failed\n",__LINE__); + goto error; + } + + /* + * Create a new dataset within the file. + */ + if((dataset = H5Dcreate2(file, DSET_NBIT_INT_SIZE_NAME, datatype, dataspace, H5P_DEFAULT, dset_create_props, H5P_DEFAULT))<0) { - H5_FAILED(); - HDprintf(" line %d: H5dwrite failed\n",__LINE__); - goto error; - } /* end if */ + H5_FAILED(); + HDprintf(" line %d: H5dwrite failed\n",__LINE__); + goto error; + } - /* - * Write the array to the file. - */ - if(H5Dwrite (dataset, mem_datatype, H5S_ALL, H5S_ALL, - H5P_DEFAULT, orig_data)<0) { - H5_FAILED(); - HDprintf(" Line %d: H5Dwrite failed\n",__LINE__); - goto error; - } /* end if */ + /* + * Write the array to the file. + */ + if(H5Dwrite(dataset, mem_datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig_data)<0) { + H5_FAILED(); + HDprintf(" Line %d: H5Dwrite failed\n",__LINE__); + goto error; + } - /* - * Get the precision of the data type - */ - if((precision = H5Tget_precision(datatype)) == 0) { - H5_FAILED(); - HDprintf(" Line %d: wrong precision size: %zu\n",__LINE__, precision); - goto error; - } /* end if */ + /* + * Get the precision of the data type + */ + if((precision = H5Tget_precision(datatype)) == 0) { + H5_FAILED(); + HDprintf(" Line %d: wrong precision size: %zu\n",__LINE__, precision); + goto error; + } - /* - * The size of the dataset after compression should around 2 * DSET_DIM1 * DSET_DIM2 - */ - if((dset_size = H5Dget_storage_size(dataset)) < DSET_DIM1*DSET_DIM2*(precision/8) || - dset_size > DSET_DIM1*DSET_DIM2*(precision/8) + 1*KB) { - H5_FAILED(); - HDfprintf(stdout, " Line %d: wrong dataset size: %Hu\n",__LINE__, dset_size); - goto error; - } /* end if */ + /* + * The size of the dataset after compression should around 2 * DSET_DIM1 * DSET_DIM2 + */ + if((dset_size = H5Dget_storage_size(dataset)) < DSET_DIM1*DSET_DIM2*(precision/8) || + dset_size > DSET_DIM1*DSET_DIM2*(precision/8) + 1*KB) { + H5_FAILED(); + HDfprintf(stdout, " Line %d: wrong dataset size: %Hu\n",__LINE__, dset_size); + goto error; + } - H5Tclose (datatype); - H5Tclose (mem_datatype); - H5Dclose (dataset); - H5Sclose (dataspace); - H5Pclose (dset_create_props); + H5Tclose(datatype); + H5Tclose(mem_datatype); + H5Dclose(dataset); + H5Sclose(dataspace); + H5Pclose(dset_create_props); + + HDfree(orig); + HDfree(orig_data); PASSED(); - return SUCCEED; + return SUCCEED; + error: + HDfree(orig); + HDfree(orig_data); + return FAIL; } /* end test_nbit_int_size() */ @@ -4300,13 +4352,22 @@ test_nbit_flt_size(hid_t file) hid_t dataspace, dataset, datatype, dset_create_props; hsize_t dims[2], chunk_size[2]; hsize_t dset_size = 0; - float orig_data[DSET_DIM1][DSET_DIM2]; + float **orig = NULL; + float *orig_data = NULL; int i, j; size_t precision, offset; size_t spos, epos, esize, mpos, msize; TESTING(" nbit floating-number dataset size"); + /* Set up data array */ + if(NULL == (orig_data = (float *)HDcalloc(DSET_DIM1 * DSET_DIM2, sizeof(float)))) + TEST_ERROR; + if(NULL == (orig = (float **)HDcalloc(DSET_DIM1, sizeof(orig_data)))) + TEST_ERROR; + for (i = 0; i < DSET_DIM1; i++) + orig[i] = orig_data + (i * DSET_DIM2); + /* Define floating-point type for dataset *------------------------------------------------------------------- * size=4 byte, precision=16 bits, offset=8 bits, @@ -4385,7 +4446,7 @@ test_nbit_flt_size(hid_t file) */ for (i=0; i < DSET_DIM1; i++) for (j=0; j < DSET_DIM2; j++) - orig_data[i][j] = (float)(HDrandom() % 1234567) / 2; + orig[i][j] = (float)(HDrandom() % 1234567) / 2; /* Describe the dataspace. */ @@ -4470,8 +4531,14 @@ test_nbit_flt_size(hid_t file) PASSED(); + HDfree(orig); + HDfree(orig_data); + return SUCCEED; error: + HDfree(orig); + HDfree(orig_data); + return FAIL; } /* end test_nbit_flt_size() */ @@ -5298,7 +5365,7 @@ test_types(hid_t file) (space=H5Screate_simple(1, &nelmts, NULL)) < 0 || (dset=H5Dcreate2(grp, "bitfield_1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - for(i=0; i max_size[0] || size[1] > max_size[1]) { if(size[0] > max_size[0]) max_size[0] = size[0]; @@ -82,8 +87,8 @@ write_data(const char *msg, hid_t file, const char *name, hid_t cparms, hid_t me if((file_space = H5Dget_space(dataset)) < 0) TEST_ERROR; if(H5Sselect_hyperslab(file_space, H5S_SELECT_SET, offset, NULL, dims, NULL) < 0) TEST_ERROR; - /* Write to the hyperslab */ - if(H5Dwrite(dataset, H5T_NATIVE_INT, mem_space, file_space, H5P_DEFAULT, buf1) < 0) TEST_ERROR; + /* Write to the hyperslab */ + if(H5Dwrite(dataset, H5T_NATIVE_INT, mem_space, file_space, H5P_DEFAULT, buf1_data) < 0) TEST_ERROR; if(H5Sclose(file_space) < 0) TEST_ERROR; } /* end for */ @@ -93,24 +98,24 @@ write_data(const char *msg, hid_t file, const char *name, hid_t cparms, hid_t me for(i = 0; i < 10; i++) { for(j = 0; j < 10; j++) { - /* Select a hyperslab */ - offset[0] = (hsize_t)(i * (NX / 2)); - offset[1] = (hsize_t)(j * (NY / 2)); - if(H5Sselect_hyperslab(file_space, H5S_SELECT_SET, offset, NULL, half_dims, NULL) < 0) TEST_ERROR; - - /* Read */ - if(H5Dread(dataset, H5T_NATIVE_INT, half_space, file_space, H5P_DEFAULT, buf2) < 0) TEST_ERROR; - - /* Compare */ - for(k = 0; k < (NX / 2); k++) - for(m = 0; m < (NY / 2); m++) - if(buf2[k][m] != buf1[(i % 2) * (NX / 2) + k][(j % 2) * (NY / 2) + m]) { - HDprintf(" i=%d, j=%d, k=%d, m=%d\n", i, j, k, m); - HDprintf(" buf2[%d][%d]=%d\n", k, m, buf2[k][m]); - HDprintf(" buf1[%d][%d]=%d\n", (i % 2) * (NX / 2) + k, (j % 2) * (NY / 2) + m, buf1[(i % 2) * (NX / 2) + k][(j % 2) * (NY / 2) + m]); - TEST_ERROR; - } /* end if */ - } /* end for */ + /* Select a hyperslab */ + offset[0] = (hsize_t)(i * N2X); + offset[1] = (hsize_t)(j * N2Y); + if(H5Sselect_hyperslab(file_space, H5S_SELECT_SET, offset, NULL, half_dims, NULL) < 0) TEST_ERROR; + + /* Read */ + if(H5Dread(dataset, H5T_NATIVE_INT, half_space, file_space, H5P_DEFAULT, buf2_data) < 0) TEST_ERROR; + + /* Compare */ + for(k = 0; k < N2X; k++) + for(m = 0; m < N2Y; m++) + if(buf2[k][m] != buf1[(i % 2) * N2X + k][(j % 2) * N2Y + m]) { + HDprintf(" i=%d, j=%d, k=%d, m=%d\n", i, j, k, m); + HDprintf(" buf2[%d][%d]=%d\n", k, m, buf2[k][m]); + HDprintf(" buf1[%d][%d]=%d\n", (i % 2) * N2X + k, (j % 2) * N2Y + m, buf1[(i % 2) * N2X + k][(j % 2) * N2Y + m]); + TEST_ERROR; + } /* end if */ + } /* end for */ } /* end for */ /* Cleanup */ @@ -145,8 +150,8 @@ static int write_data_deprec(const char *msg, hid_t file, const char *name, hid_t cparms, hid_t mem_space) { hid_t dataset, file_space, half_space; - static const hsize_t dims[2] = {NX, NY}; - static const hsize_t half_dims[2] = {NX / 2, NY / 2}; + static const hsize_t dims[2] = {N1X, N1Y}; + static const hsize_t half_dims[2] = {N2X, N2Y}; static hsize_t size[2]; hsize_t offset[2]; int i, j, k, m; @@ -160,19 +165,19 @@ write_data_deprec(const char *msg, hid_t file, const char *name, hid_t cparms, h for(i = 0; i < 5; i++) for(j = 0; j < 5; j++) { - /* Extend the dataset */ - offset[0] = (hsize_t)(i * NX); - offset[1] = (hsize_t)(j * NY); - size[0] = offset[0] + NX; - size[1] = offset[1] + NY; - if(H5Dextend(dataset, size) < 0) TEST_ERROR; + /* Extend the dataset */ + offset[0] = (hsize_t)(i * N1X); + offset[1] = (hsize_t)(j * N1Y); + size[0] = offset[0] + N1X; + size[1] = offset[1] + N1Y; + if(H5Dextend(dataset, size) < 0) TEST_ERROR; /* Select a hyperslab */ if((file_space = H5Dget_space(dataset)) < 0) TEST_ERROR; if(H5Sselect_hyperslab(file_space, H5S_SELECT_SET, offset, NULL, dims, NULL) < 0) TEST_ERROR; - /* Write to the hyperslab */ - if(H5Dwrite(dataset, H5T_NATIVE_INT, mem_space, file_space, H5P_DEFAULT, buf1) < 0) TEST_ERROR; + /* Write to the hyperslab */ + if(H5Dwrite(dataset, H5T_NATIVE_INT, mem_space, file_space, H5P_DEFAULT, buf1_data) < 0) TEST_ERROR; if(H5Sclose(file_space) < 0) TEST_ERROR; } /* end for */ @@ -182,24 +187,24 @@ write_data_deprec(const char *msg, hid_t file, const char *name, hid_t cparms, h for(i = 0; i < 10; i++) { for(j = 0; j < 10; j++) { - /* Select a hyperslab */ - offset[0] = (hsize_t)(i * (NX / 2)); - offset[1] = (hsize_t)(j * (NY / 2)); - if(H5Sselect_hyperslab(file_space, H5S_SELECT_SET, offset, NULL, half_dims, NULL) < 0) TEST_ERROR; - - /* Read */ - if(H5Dread(dataset, H5T_NATIVE_INT, half_space, file_space, H5P_DEFAULT, buf2) < 0) TEST_ERROR; - - /* Compare */ - for(k = 0; k < (NX / 2); k++) - for(m = 0; m < (NY / 2); m++) - if(buf2[k][m] != buf1[(i % 2) * (NX / 2) + k][(j % 2) * (NY / 2) + m]) { - HDprintf(" i=%d, j=%d, k=%d, m=%d\n", i, j, k, m); - HDprintf(" buf2[%d][%d]=%d\n", k, m, buf2[k][m]); - HDprintf(" buf1[%d][%d]=%d\n", (i % 2) * (NX / 2) + k, (j % 2) * (NY / 2) + m, buf1[(i % 2) * (NX / 2) + k][(j % 2) * (NY / 2) + m]); - TEST_ERROR; - } /* end if */ - } /* end for */ + /* Select a hyperslab */ + offset[0] = (hsize_t)(i * N2X); + offset[1] = (hsize_t)(j * N2Y); + if(H5Sselect_hyperslab(file_space, H5S_SELECT_SET, offset, NULL, half_dims, NULL) < 0) TEST_ERROR; + + /* Read */ + if(H5Dread(dataset, H5T_NATIVE_INT, half_space, file_space, H5P_DEFAULT, buf2_data) < 0) TEST_ERROR; + + /* Compare */ + for(k = 0; k < N2X; k++) + for(m = 0; m < N2Y; m++) + if(buf2[k][m] != buf1[(i % 2) * N2X + k][(j % 2) * N2Y + m]) { + HDprintf(" i=%d, j=%d, k=%d, m=%d\n", i, j, k, m); + HDprintf(" buf2[%d][%d]=%d\n", k, m, buf2[k][m]); + HDprintf(" buf1[%d][%d]=%d\n", (i % 2) * N2X + k, (j % 2) * N2Y + m, buf1[(i % 2) * N2X + k][(j % 2) * N2Y + m]); + TEST_ERROR; + } /* end if */ + } /* end for */ } /* end for */ @@ -235,8 +240,8 @@ main (void) hid_t file, mem_space, cparms; hid_t fapl; int nerrors = 0; - static const hsize_t dims[2] = {NX, NY}; - static const hsize_t chunk_dims[2] = {NX/2, NY/2}; + static const hsize_t dims[2] = {N1X, N1Y}; + static const hsize_t chunk_dims[2] = {N2X, N2Y}; static hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; char filename[1024]; int i, j; @@ -245,9 +250,23 @@ main (void) fapl = h5_fileaccess(); /* Initialize buffer and space */ - for(i = 0; i < NX; i++) - for(j = 0; j < NY; j++) - buf1[i][j] = i * NY + j; + if(NULL == (buf1_data = (int *)HDcalloc(N1X * N1Y, sizeof(int)))) + TEST_ERROR; + if(NULL == (buf1 = (int **)HDcalloc(N1X, sizeof(buf1_data)))) + TEST_ERROR; + for (i = 0; i < N1X; i++) + buf1[i] = buf1_data + (i * N1Y); + + if(NULL == (buf2_data = (int *)HDcalloc(N2X * N2Y, sizeof(int)))) + TEST_ERROR; + if(NULL == (buf2 = (int **)HDcalloc(N2X, sizeof(buf2_data)))) + TEST_ERROR; + for (i = 0; i < N2X; i++) + buf2[i] = buf2_data + (i * N2Y); + + for(i = 0; i < N1X; i++) + for(j = 0; j < N1Y; j++) + buf1[i][j] = i * N1Y + j; if((mem_space = H5Screate_simple(2, dims, maxdims)) < 0) TEST_ERROR; @@ -287,9 +306,20 @@ main (void) HDprintf("All extend tests passed.\n"); h5_cleanup(FILENAME, fapl); + HDfree(buf1); + HDfree(buf1_data); + HDfree(buf2); + HDfree(buf2_data); + HDexit(EXIT_SUCCESS); error: + + HDfree(buf1); + HDfree(buf1_data); + HDfree(buf2); + HDfree(buf2_data); + HDprintf("*** One or more extend tests failed ***\n"); HDexit(EXIT_FAILURE); } /* end main() */ diff --git a/test/farray.c b/test/farray.c index e73a4b4..b647b51 100644 --- a/test/farray.c +++ b/test/farray.c @@ -500,7 +500,7 @@ test_create(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t H5_ATTR_UNUSE TEST_ERROR } /* end if */ - PASSED() + PASSED(); } #else /* NDEBUG */ SKIPPED(); @@ -516,7 +516,7 @@ test_create(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t H5_ATTR_UNUSE if(create_array(f, cparam, &fa, &fa_addr) < 0) TEST_ERROR - PASSED() + PASSED(); /* Verify the creation parameters */ TESTING("verify array creation parameters"); @@ -530,7 +530,7 @@ test_create(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t H5_ATTR_UNUSE TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return 0; @@ -597,7 +597,7 @@ test_reopen(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam) TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return 0; @@ -696,7 +696,7 @@ test_open_twice(hid_t fapl_id, H5FA_create_t *cparam, farray_test_param_t *tpara TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return 0; @@ -829,7 +829,7 @@ test_open_twice_diff(hid_t fapl_id, H5FA_create_t *cparam, farray_test_param_t * TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return 0; @@ -947,7 +947,7 @@ test_delete_open(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam) TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return 0; @@ -1487,7 +1487,7 @@ test_set_elmts(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam, TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return 0; @@ -1614,7 +1614,7 @@ test_skip_elmts(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam, TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return 0; diff --git a/test/fheap.c b/test/fheap.c index d4164a2..b1a0db0 100644 --- a/test/fheap.c +++ b/test/fheap.c @@ -1903,7 +1903,7 @@ test_create(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) HDmemset(&state, 0, sizeof(fheap_heap_state_t)); if(check_stats(fh, &state)) TEST_ERROR - PASSED() + PASSED(); /* Query the type of address mapping */ TESTING("query heap creation parameters"); @@ -1935,7 +1935,7 @@ test_create(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return 0; @@ -2087,7 +2087,7 @@ test_reopen(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -2260,7 +2260,7 @@ test_open_twice(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return 0; @@ -2435,7 +2435,7 @@ test_delete_open(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return 0; @@ -2781,7 +2781,7 @@ test_id_limits(hid_t fapl, H5HF_create_t *cparam, hid_t fcpl) FAIL_STACK_ERROR /* All tests passed */ - PASSED() + PASSED(); return 0; @@ -2904,7 +2904,7 @@ test_filtered_create(hid_t fapl, H5HF_create_t *cparam, hid_t fcpl) H5O_msg_reset(H5O_PLINE_ID, &test_cparam.pline); /* All tests passed */ - PASSED() + PASSED(); return 0; @@ -3044,7 +3044,7 @@ test_size(hid_t fapl, H5HF_create_t *cparam, hid_t fcpl) FAIL_STACK_ERROR /* All tests passed */ - PASSED() + PASSED(); return 0; @@ -3181,7 +3181,7 @@ test_reopen_hdr(hid_t fapl, H5HF_create_t *cparam, hid_t fcpl) FAIL_STACK_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -3292,7 +3292,7 @@ test_man_insert_weird(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpa FAIL_STACK_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -3393,7 +3393,7 @@ test_man_insert_first(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpa TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -3487,7 +3487,7 @@ test_man_insert_second(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tp TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -3584,7 +3584,7 @@ test_man_insert_root_mult(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -3689,7 +3689,7 @@ test_man_insert_force_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_par TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -3794,7 +3794,7 @@ test_man_insert_fill_second(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_ TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -3905,7 +3905,7 @@ test_man_insert_third_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -4000,7 +4000,7 @@ test_man_fill_first_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *t TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -4102,7 +4102,7 @@ test_man_start_second_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -4201,7 +4201,7 @@ test_man_fill_second_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t * TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -4311,7 +4311,7 @@ test_man_start_third_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t * TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -4408,7 +4408,7 @@ test_man_fill_fourth_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t * TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -4503,7 +4503,7 @@ test_man_fill_all_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_para TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -4603,7 +4603,7 @@ test_man_first_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_ TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -4712,7 +4712,7 @@ test_man_second_direct_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhe TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -4813,7 +4813,7 @@ test_man_fill_first_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_ TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -4922,7 +4922,7 @@ test_man_second_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -5029,7 +5029,7 @@ test_man_fill_second_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -5128,7 +5128,7 @@ test_man_fill_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fheap_te TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -5236,7 +5236,7 @@ test_man_start_2nd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -5337,7 +5337,7 @@ test_man_recursive_indirect_two_deep(hid_t fapl, H5HF_create_t *cparam, fheap_te TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -5446,7 +5446,7 @@ test_man_start_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -5556,7 +5556,7 @@ test_man_fill_first_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fh TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -5662,7 +5662,7 @@ test_man_fill_3rd_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fhea TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -5768,7 +5768,7 @@ test_man_fill_all_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhea TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -5882,7 +5882,7 @@ test_man_start_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -6001,7 +6001,7 @@ test_man_fill_first_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fh TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -6112,7 +6112,7 @@ test_man_fill_4th_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fhea TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -6223,7 +6223,7 @@ test_man_fill_all_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhea TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -6357,7 +6357,7 @@ test_man_start_5th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -6511,7 +6511,7 @@ HDfprintf(stderr, "Random # seed was: %lu\n", seed); TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -6675,7 +6675,7 @@ test_man_remove_one(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -6867,7 +6867,7 @@ test_man_remove_two(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -7035,7 +7035,7 @@ test_man_remove_one_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -7278,7 +7278,7 @@ HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -7581,7 +7581,7 @@ HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -7616,7 +7616,8 @@ test_man_incr_insert_remove(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ - unsigned char heap_id[100][MAX_HEAP_ID_LEN]; /* Heap ID for object inserted */ + unsigned char **heap_id = NULL; + unsigned char *heap_id_data = NULL; struct a_type_t1 { char a[10]; char b[40]; @@ -7628,6 +7629,14 @@ test_man_incr_insert_remove(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); + /* Set up data array */ + if(NULL == (heap_id_data = (unsigned char *)HDcalloc(100 * MAX_HEAP_ID_LEN, sizeof(unsigned char)))) + TEST_ERROR; + if(NULL == (heap_id = (unsigned char **)HDcalloc(100, sizeof(heap_id_data)))) + TEST_ERROR; + for (i = 0; i < 100; i++) + heap_id[i] = heap_id_data + (i * MAX_HEAP_ID_LEN); + /* Create the file to work on */ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) FAIL_STACK_ERROR @@ -7656,7 +7665,7 @@ test_man_incr_insert_remove(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_ FAIL_STACK_ERROR /* - * Test incremental insert and removal + * Test incremental insert and removal */ TESTING("incremental object insertion and removal") @@ -7682,7 +7691,7 @@ test_man_incr_insert_remove(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_ if(H5HF_insert(fh, (sizeof(obj1)), &obj1, heap_id[i]) < 0) FAIL_STACK_ERROR } /* end for */ - + /* Close the fractal heap */ if(H5HF_close(fh) < 0) TEST_ERROR @@ -7692,9 +7701,12 @@ test_man_incr_insert_remove(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_ TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); - return(0); + HDfree(heap_id); + HDfree(heap_id_data); + + return 0; error: H5E_BEGIN_TRY { @@ -7702,7 +7714,11 @@ error: H5HF_close(fh); H5Fclose(file); } H5E_END_TRY; - return(1); + + HDfree(heap_id); + HDfree(heap_id_data); + + return 1; } /* test_man_incr_insert_remove() */ #endif /* QAK */ @@ -7764,7 +7780,7 @@ test_man_remove_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_ H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -7852,7 +7868,7 @@ test_man_remove_two_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -7922,7 +7938,7 @@ test_man_remove_first_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -7994,7 +8010,7 @@ test_man_remove_first_two_rows(hid_t fapl, H5HF_create_t *cparam, fheap_test_par H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -8070,7 +8086,7 @@ test_man_remove_first_four_rows(hid_t fapl, H5HF_create_t *cparam, fheap_test_pa H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -8140,7 +8156,7 @@ test_man_remove_all_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_pa H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -8214,7 +8230,7 @@ test_man_remove_2nd_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -8292,7 +8308,7 @@ test_man_remove_3rd_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -8373,7 +8389,7 @@ test_man_skip_start_block(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -8470,7 +8486,7 @@ test_man_skip_start_block_add_back(hid_t fapl, H5HF_create_t *cparam, fheap_test H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -8579,7 +8595,7 @@ test_man_skip_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_t H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -8672,7 +8688,7 @@ test_man_skip_2nd_block(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *t H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -8814,7 +8830,7 @@ test_man_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_tes H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -8980,7 +8996,7 @@ test_man_fill_one_partial_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t * H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -9109,7 +9125,7 @@ test_man_fill_row_skip_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -9236,7 +9252,7 @@ test_man_skip_direct_skip_indirect_two_rows_add_skipped(hid_t fapl, H5HF_create_ H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -9358,7 +9374,7 @@ test_man_fill_direct_skip_indirect_start_block_add_skipped(hid_t fapl, H5HF_crea H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -9485,7 +9501,7 @@ test_man_fill_direct_skip_2nd_indirect_start_block_add_skipped(hid_t fapl, H5HF_ H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -9627,7 +9643,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -9801,7 +9817,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -9952,7 +9968,7 @@ test_man_fill_direct_skip_indirect_two_rows_add_skipped(hid_t fapl, H5HF_create_ H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -10132,7 +10148,7 @@ test_man_fill_direct_skip_indirect_two_rows_skip_indirect_row_add_skipped(hid_t H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -10258,7 +10274,7 @@ test_man_fill_2nd_direct_skip_start_block_add_skipped(hid_t fapl, H5HF_create_t H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -10396,7 +10412,7 @@ test_man_fill_2nd_direct_skip_2nd_indirect_start_block_add_skipped(hid_t fapl, H H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -10546,7 +10562,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -10707,7 +10723,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -10868,7 +10884,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -11036,7 +11052,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -11195,7 +11211,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -11372,7 +11388,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -11584,7 +11600,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -11780,7 +11796,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -12012,7 +12028,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -12146,7 +12162,7 @@ test_man_frag_simple(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -12315,7 +12331,7 @@ test_man_frag_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -12427,7 +12443,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -12545,7 +12561,7 @@ test_man_frag_3rd_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t * H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -12698,7 +12714,7 @@ HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -12929,7 +12945,7 @@ HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -13235,7 +13251,7 @@ HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -13660,7 +13676,7 @@ HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -13880,7 +13896,7 @@ HDfprintf(stderr, "empty_size = %lu, file_size = %lu\n", (unsigned long)empty_si H5MM_xfree(heap_id); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -14033,7 +14049,7 @@ HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -14264,7 +14280,7 @@ HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -14869,7 +14885,7 @@ HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -15057,7 +15073,7 @@ HDfprintf(stderr, "empty_size = %lu, file_size = %lu\n", (unsigned long)empty_si H5O_msg_reset(H5O_PLINE_ID, &tmp_cparam.pline); /* Release the I/O pipeline filter information */ /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -15385,7 +15401,7 @@ HDfprintf(stderr, "empty_size = %lu, file_size = %lu\n", (unsigned long)empty_si H5O_msg_reset(H5O_PLINE_ID, &tmp_cparam.pline); /* Release the I/O pipeline filter information */ /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -15585,7 +15601,7 @@ HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -15804,7 +15820,7 @@ HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -16092,7 +16108,7 @@ test_write(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) H5MM_xfree(rewrite_obj); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -16270,7 +16286,7 @@ test_bug1(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -16334,7 +16350,7 @@ main(void) def_fapl = h5_fileaccess(); ExpressMode = GetTestExpress(); - /* + /* * Caution when turning on ExpressMode 0: * It will activate testing with different combinations of * page buffering and file space strategy and the @@ -16384,12 +16400,12 @@ main(void) for(v = 0; v < num_pb_fs; v++) { /* Skip test when: a) multi/split drivers and - b) persisting free-space or using paged aggregation strategy + b) persisting free-space or using paged aggregation strategy because the library will fail file creation (temporary) for the above conditions */ if(!contig_addr_vfd && v) break; - if((fcpl = H5Pcopy(def_fcpl)) < 0) + if((fcpl = H5Pcopy(def_fcpl)) < 0) TEST_ERROR switch(v) { @@ -16403,14 +16419,14 @@ main(void) TEST_ERROR fapl = def_fapl; /* This is a fix for the daily test failure from the checkin for libver bounds. */ - /* + /* * Many tests failed the file size check when comparing (a) and (b) as below: * --Create a file and close the file. Got the initial file size (a). * --Reopen the file, perform fractal heap operations, and close the file. * Got the file size (b). * The cause for the file size differences: - * When the file is initially created with persisting free-space and with - * (earliest, latest) libver bounds, the file will have version 2 superblock + * When the file is initially created with persisting free-space and with + * (earliest, latest) libver bounds, the file will have version 2 superblock * due to non-default free-space handling. As the low bound is earliest, * the library uses version 1 object header when creating the superblock * extension message. @@ -16424,7 +16440,7 @@ main(void) * The fix: * Set libver bounds in fapl to (v18, latest) so that the file created in the * test routines will have low bound set to v18. This will cause the - * library to use version 2 object header for the superblock extension + * library to use version 2 object header for the superblock extension * message. */ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_V18, H5F_LIBVER_LATEST) < 0) diff --git a/test/fillval.c b/test/fillval.c index 019744a..72b8dcb 100644 --- a/test/fillval.c +++ b/test/fillval.c @@ -1453,12 +1453,16 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name, void *val_rd, *odd_val; const void *init_val, *should_be, *even_val; int val_rd_i, init_val_i = 9999; - comp_vl_datatype init_val_c = {87, "baz", "mumble", 129}; + comp_vl_datatype init_val_c = {87, NULL, NULL, 129}; comp_vl_datatype val_rd_c; void *buf = NULL; unsigned odd; /* Whether an odd or even coord. was read */ unsigned i, j; /* Local index variables */ + /* Set vl datatype init value strings */ + init_val_c.a = HDstrdup("baz"); + init_val_c.b = HDstrdup("mumble"); + /* Make copy of dataset creation property list */ if((dcpl = H5Pcopy(_dcpl)) < 0) TEST_ERROR @@ -1802,8 +1806,10 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name, /* Release elements & memory buffer */ for(i = 0; i < nelmts; i++) release_rtn((void *)((char *)buf + (val_size * i))); + + HDfree(init_val_c.a); + HDfree(init_val_c.b); HDfree(buf); - buf = NULL; /* Cleanup IDs */ if(H5Pclose(dcpl) < 0) TEST_ERROR @@ -1813,8 +1819,10 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name, return 0; error: - if(buf) - HDfree(buf); + HDfree(init_val_c.a); + HDfree(init_val_c.b); + HDfree(buf); + H5E_BEGIN_TRY { H5Pclose(dcpl); H5Dclose(dset); @@ -1856,7 +1864,7 @@ test_extend(hid_t fapl, const char *base_name, H5D_layout_t layout) #else int fillval_i = 0x4c70f1cd; #endif - comp_vl_datatype fillval_c = {32, "foo", "bar", 64}; /* Fill value for compound+vl datatype tests */ + comp_vl_datatype fillval_c = {32, NULL, NULL, 64}; /* Fill value for compound+vl datatype tests */ char filename[1024]; /* Print testing message */ @@ -1865,6 +1873,10 @@ test_extend(hid_t fapl, const char *base_name, H5D_layout_t layout) else TESTING("contiguous dataset extend") + /* Set vl datatype fill value strings */ + fillval_c.a = HDstrdup("foo"); + fillval_c.b = HDstrdup("bar"); + /* Create dataset creation property list */ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR if(H5D_CHUNKED == layout) @@ -1945,11 +1957,17 @@ test_extend(hid_t fapl, const char *base_name, H5D_layout_t layout) if(H5Pclose(dcpl) < 0) TEST_ERROR if(H5Fclose(file) < 0) TEST_ERROR + HDfree(fillval_c.a); + HDfree(fillval_c.b); + PASSED(); return 0; error: + HDfree(fillval_c.a); + HDfree(fillval_c.b); + H5E_BEGIN_TRY { H5Tclose(cmpd_vl_tid); H5Pclose(dcpl); @@ -1958,6 +1976,9 @@ error: return 1; skip: + HDfree(fillval_c.a); + HDfree(fillval_c.b); + H5E_BEGIN_TRY { H5Pclose(dcpl); H5Fclose(file); diff --git a/test/flush2.c b/test/flush2.c index 0f15903..5fc716b 100644 --- a/test/flush2.c +++ b/test/flush2.c @@ -266,7 +266,7 @@ main(void) h5_fixname(FILENAME[0], fapl_id, filename, sizeof(filename)); check_second_dset = FALSE; if(file_ok(filename, fapl_id, check_second_dset)) - PASSED() + PASSED(); else TEST_ERROR @@ -279,7 +279,7 @@ main(void) if(clear_status_flags(filename, fapl_id) < 0) TEST_ERROR if(file_ok(filename, fapl_id, check_second_dset)) - PASSED() + PASSED(); else TEST_ERROR } /* end if */ @@ -305,7 +305,7 @@ main(void) #endif } /* end if */ else - PASSED() + PASSED(); /* Turn the error stack back on */ if(H5Eset_auto2(H5E_DEFAULT, func, NULL) < 0) FAIL_STACK_ERROR @@ -332,7 +332,7 @@ main(void) #endif } /* end if */ else - PASSED() + PASSED(); /* Turn the error stack back on */ if(H5Eset_auto2(H5E_DEFAULT, func, NULL) < 0) FAIL_STACK_ERROR @@ -348,13 +348,13 @@ main(void) check_second_dset = TRUE; h5_fixname(FILENAME[4], fapl_id, filename, sizeof(filename)); if(file_ok(filename, fapl_id, check_second_dset)) - PASSED() + PASSED(); else TEST_ERROR /* TEST 6 */ /* Check the case where the file was flushed, but more data was - * added afterward and then flushed (w/SWMR) + * added afterward and then flushed (w/SWMR) */ TESTING("H5Fflush (part2 with flush and later addition and another flush + SWMR)"); if(vfd_supports_swmr) { @@ -363,7 +363,7 @@ main(void) if(clear_status_flags(filename, fapl_id) < 0) TEST_ERROR if(file_ok(filename, fapl_id, check_second_dset)) - PASSED() + PASSED(); else TEST_ERROR } /* end if */ @@ -391,7 +391,7 @@ main(void) #endif } /* end if */ else - PASSED() + PASSED(); /* Turn the error stack back on */ if(H5Eset_auto2(H5E_DEFAULT, func, NULL) < 0) FAIL_STACK_ERROR diff --git a/test/freespace.c b/test/freespace.c index 947b2ce..124ae3e 100644 --- a/test/freespace.c +++ b/test/freespace.c @@ -547,7 +547,7 @@ test_fs_create(hid_t fapl) if(file_size != empty_size) TEST_ERROR - PASSED() + PASSED(); return 0; @@ -674,7 +674,7 @@ test_fs_sect_add(hid_t fapl) if (tmp_file_size <= (file_size+fr_meta_size)) TEST_ERROR - PASSED() + PASSED(); TESTING("adding a section via H5FS_sect_add() to free-space with H5FS_CLS_GHOST_OBJ: test 2"); @@ -736,7 +736,7 @@ test_fs_sect_add(hid_t fapl) if (tmp_file_size != (file_size+fr_meta_size)) TEST_ERROR - PASSED() + PASSED(); TESTING("adding a section via H5FS_sect_add() to free-space: test 3"); @@ -805,7 +805,7 @@ test_fs_sect_add(hid_t fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); TESTING("adding a section via H5FS_sect_add() to free-space: test 4"); @@ -880,11 +880,11 @@ test_fs_sect_add(hid_t fapl) FAIL_STACK_ERROR fs_addr = HADDR_UNDEF; - /* Close the file and dxpl */ + /* Close the file */ if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); return 0; @@ -982,7 +982,7 @@ test_fs_sect_find(hid_t fapl) FAIL_STACK_ERROR frsp = NULL; - PASSED() + PASSED(); TESTING("H5FS_sect_find() a section equal to requested-size from free-space"); @@ -1110,7 +1110,7 @@ test_fs_sect_find(hid_t fapl) FAIL_STACK_ERROR frsp = NULL; - PASSED() + PASSED(); TESTING("H5FS_sect_find() a section greater than requested-size from free-space"); @@ -1190,7 +1190,7 @@ test_fs_sect_find(hid_t fapl) FAIL_STACK_ERROR frsp = NULL; - PASSED() + PASSED(); TESTING("H5FS_sect_find(): cannot find a section with requested-size from free-space"); @@ -1249,11 +1249,11 @@ test_fs_sect_find(hid_t fapl) FAIL_STACK_ERROR fs_addr = HADDR_UNDEF; - /* Close the file and dxpl */ + /* Close the file */ if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); return 0; @@ -1453,7 +1453,7 @@ test_fs_sect_merge(hid_t fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); /* * TEST 2 @@ -1555,7 +1555,7 @@ test_fs_sect_merge(hid_t fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); /* * TEST 3 @@ -1723,7 +1723,7 @@ test_fs_sect_merge(hid_t fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); return 0; @@ -1894,7 +1894,7 @@ test_fs_sect_shrink(hid_t fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); TESTING("shrinking of sections when H5FS_sect_add() to free-space: test 2"); @@ -1996,7 +1996,7 @@ test_fs_sect_shrink(hid_t fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); TESTING("shrinking of sections when H5FS_sect_add() to free-space: test 3"); @@ -2087,7 +2087,7 @@ test_fs_sect_shrink(hid_t fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); return 0; @@ -2240,7 +2240,7 @@ test_fs_sect_change_class(hid_t fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); /* * TEST 2 @@ -2362,7 +2362,7 @@ test_fs_sect_change_class(hid_t fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); return 0; @@ -2515,7 +2515,7 @@ test_fs_sect_extend(hid_t fapl) FAIL_STACK_ERROR fs_addr = HADDR_UNDEF; - PASSED() + PASSED(); /* * TEST 2 @@ -2588,7 +2588,7 @@ test_fs_sect_extend(hid_t fapl) FAIL_STACK_ERROR fs_addr = HADDR_UNDEF; - PASSED() + PASSED(); /* * Test 3 @@ -2662,7 +2662,7 @@ test_fs_sect_extend(hid_t fapl) FAIL_STACK_ERROR fs_addr = HADDR_UNDEF; - PASSED() + PASSED(); /* * TEST 4 @@ -2735,9 +2735,9 @@ test_fs_sect_extend(hid_t fapl) FAIL_STACK_ERROR fs_addr = HADDR_UNDEF; - PASSED() + PASSED(); - /* Close the file and dxpl */ + /* Close the file */ if(H5Fclose(file) < 0) FAIL_STACK_ERROR @@ -2839,11 +2839,11 @@ test_fs_sect_iterate(hid_t fapl) FAIL_STACK_ERROR fs_addr = HADDR_UNDEF; - /* Close the file and dxpl */ + /* Close the file */ if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); return 0; diff --git a/test/gen_bogus.c b/test/gen_bogus.c index 1ab18a4..ab2620f 100644 --- a/test/gen_bogus.c +++ b/test/gen_bogus.c @@ -12,7 +12,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Apr 17, 2007 * * Purpose: This program is run to generate an HDF5 data file with several diff --git a/test/gen_new_super.c b/test/gen_new_super.c index f6ce589..329f724 100644 --- a/test/gen_new_super.c +++ b/test/gen_new_super.c @@ -23,8 +23,7 @@ * put into the 'test' directory in the 1.4+ branch of the library. */ -#include -#include "hdf5.h" +#include "h5test.h" #define TESTFILE "tsupern.h5" #define ISTORE_IK 64 @@ -50,7 +49,7 @@ main(void) { hid_t file; /* File IDs for old & new files */ hid_t fcpl; /* File creation property list */ - herr_t ret; /* Generic return value */ + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Create a file creation property list */ fcpl = H5Pcreate(H5P_FILE_CREATE); diff --git a/test/gen_nullspace.c b/test/gen_nullspace.c index 9d76deb..c0f1d23 100644 --- a/test/gen_nullspace.c +++ b/test/gen_nullspace.c @@ -12,7 +12,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Saturday, April 17, 2004 * * Purpose: Create a dataset with a null dataspace and an attribute @@ -24,8 +24,7 @@ * put into the 'test' directory in the 1.6.x branch of the library. */ -#include "hdf5.h" -#include +#include "h5test.h" #define NULLFILE "tnullspace.h5" #define NULLDATASET "null_dataset" @@ -39,7 +38,7 @@ main(void) hid_t sid; /* Dataspace ID */ hid_t did; /* Dataset ID */ hid_t attr; /* Attribute ID */ - herr_t ret; /* Generic return value */ + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ /* Create the file */ fid = H5Fcreate(NULLFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); diff --git a/test/gen_plist.c b/test/gen_plist.c index 458ee97..b6f5597 100644 --- a/test/gen_plist.c +++ b/test/gen_plist.c @@ -458,7 +458,7 @@ encode_plist(hid_t plist_id, int little_endian, int word_length, const char *fil herr_t ret = 0; void *temp_buf = NULL; size_t temp_size = 0; - ssize_t write_size; + ssize_t H5_ATTR_NDEBUG_UNUSED write_size; char filename[1024]; /* Generate filename */ diff --git a/test/gen_specmetaread.c b/test/gen_specmetaread.c index d06bd59..f2625a7 100644 --- a/test/gen_specmetaread.c +++ b/test/gen_specmetaread.c @@ -23,8 +23,8 @@ * the library on the trunk as of when this file is checked in. */ -#include "hdf5.h" -#include + +#include "h5test.h" #define FILENAME "specmetaread.h5" #define DIM 10 @@ -39,7 +39,7 @@ main(void) hsize_t dim[1] = {DIM}; unsigned data[DIM]; unsigned u; - herr_t ret; /* Generic return value */ + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Initialize the data */ for(u = 0; u < DIM; u++) diff --git a/test/getname.c b/test/getname.c index c301e04..a6f2f5a 100644 --- a/test/getname.c +++ b/test/getname.c @@ -2588,7 +2588,7 @@ test_obj_ref(hid_t fapl) namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[0], (char*)buf, sizeof(buf)); if(!((HDstrcmp(buf, "/Dataset3") == 0) &&(namelen == 9))) TEST_ERROR - PASSED() + PASSED(); HDmemset(buf, 0, sizeof(buf)); TESTING("getting path to dataset in /Group1"); @@ -2600,7 +2600,7 @@ test_obj_ref(hid_t fapl) *buf = '\0'; namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[1], (char*)buf, sizeof(buf)); if(!((HDstrcmp(buf, "/Group1/Dataset2") == 0) &&(namelen == 16))) TEST_ERROR - PASSED() + PASSED(); HDmemset(buf, 0, sizeof(buf)); TESTING("getting path to /Group1"); @@ -2612,7 +2612,7 @@ test_obj_ref(hid_t fapl) *buf = '\0'; namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[2], (char*)buf, sizeof(buf)); if(!((HDstrcmp(buf, "/Group1") == 0) &&(namelen == 7))) TEST_ERROR - PASSED() + PASSED(); HDmemset(buf, 0, sizeof(buf)); TESTING("getting path to datatype in /Group1"); @@ -2624,7 +2624,7 @@ test_obj_ref(hid_t fapl) *buf = '\0'; namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[3], (char*)buf, sizeof(buf)); if(!((HDstrcmp(buf, "/Group1/Datatype1") == 0) &&(namelen == 17))) TEST_ERROR - PASSED() + PASSED(); HDmemset(buf, 0, sizeof(buf)); TESTING("getting path to dataset in nested group"); @@ -2636,7 +2636,7 @@ test_obj_ref(hid_t fapl) *buf = '\0'; namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[4], (char*)buf, sizeof(buf)); if(!((HDstrcmp(buf, "/Group1/Group2/Dataset4") == 0) &&(namelen == 23))) TEST_ERROR - PASSED() + PASSED(); HDmemset(buf, 0, sizeof(buf)); TESTING("getting path to nested group"); @@ -2648,7 +2648,7 @@ test_obj_ref(hid_t fapl) *buf = '\0'; namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[5], (char*)buf, sizeof(buf)); if(!((HDstrcmp(buf, "/Group1/Group2") == 0) &&(namelen == 14))) TEST_ERROR - PASSED() + PASSED(); HDmemset(buf, 0, sizeof(buf)); TESTING("getting path to dataset created via hard link"); @@ -2660,7 +2660,7 @@ test_obj_ref(hid_t fapl) *buf = '\0'; namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[6], (char*)buf, sizeof(buf)); if(!((HDstrcmp(buf, "/Group1/Dataset5") == 0) &&(namelen == 16))) TEST_ERROR - PASSED() + PASSED(); HDmemset(buf, 0, sizeof(buf)); TESTING("getting path to root group"); @@ -2672,7 +2672,7 @@ test_obj_ref(hid_t fapl) *buf = '\0'; namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[7], (char*)buf, sizeof(buf)); if(!((HDstrcmp(buf, "/") == 0) &&(namelen == 1))) TEST_ERROR - PASSED() + PASSED(); /* Now we mount fid2 at /Group2 and look for dataset4. It shouldn't be found */ if(H5Fmount(fid1, "/Group1/Group2", fid2, H5P_DEFAULT) < 0) @@ -2687,7 +2687,7 @@ test_obj_ref(hid_t fapl) *buf = '\0'; namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[4], (char*)buf, sizeof(buf)); if(namelen != 0) TEST_ERROR - PASSED() + PASSED(); /* Now we try unlinking dataset2 from the file and searching for it. It shouldn't be found */ if((dataset2 = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &wbuf[1])) < 0) @@ -2703,7 +2703,7 @@ test_obj_ref(hid_t fapl) *buf = '\0'; namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[1], (char*)buf, sizeof(buf)); if(namelen != 0) TEST_ERROR - PASSED() + PASSED(); /* Close disk dataspace */ if(H5Sclose(sid1) < 0) @@ -2830,7 +2830,7 @@ test_reg_ref(hid_t fapl) name_size1 = H5Rget_name(dsetr_id, H5R_DATASET_REGION, &ref_out[0], (char*)buf1, NAME_BUF_SIZE ); if(!((HDstrcmp(buf1, "/MATRIX") == 0) &&(name_size1 == 7))) TEST_ERROR - PASSED() + PASSED(); TESTING("H5Iget_name to get name from region reference(hyperslab)"); @@ -2844,14 +2844,14 @@ test_reg_ref(hid_t fapl) if(H5Dclose(dsetv_id) < 0) TEST_ERROR - PASSED() + PASSED(); /* Get name of the dataset the second region reference points to using H5Rget_name */ TESTING("H5Rget_name to get name from region reference(pnt selec)"); *buf1 = '\0'; name_size1 = H5Rget_name(dsetr_id, H5R_DATASET_REGION, &ref_out[1], (char*)buf1, NAME_BUF_SIZE); if(!((HDstrcmp(buf1, "/MATRIX") == 0) &&(name_size1 == 7))) TEST_ERROR - PASSED() + PASSED(); TESTING("H5Iget_name to get name from region reference(pnt selec)"); @@ -2865,7 +2865,7 @@ test_reg_ref(hid_t fapl) if(H5Dclose(dsetv_id) < 0) TEST_ERROR - PASSED() + PASSED(); if(H5Dclose(dsetr_id) < 0) TEST_ERROR diff --git a/test/h5test.c b/test/h5test.c index ce573de..d5a5261 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -23,6 +23,7 @@ #include "h5test.h" #include "H5srcdir.h" +#include "H5srcdir_str.h" /* Necessary for h5_verify_cached_stabs() */ #define H5G_FRIEND /*suppress error about including H5Gpkg */ @@ -100,6 +101,12 @@ static const char *multi_letters = "msbrglo"; /* The # of seconds to wait for the message file--used by h5_wait_message() */ #define MESSAGE_TIMEOUT 300 /* Timeout in seconds */ +/* Buffer to construct path in and return pointer to */ +static char srcdir_path[1024] = ""; + +/* Buffer to construct file in and return pointer to */ +static char srcdir_testpath[1024] = ""; + /* The strings that correspond to library version bounds H5F_libver_t in H5Fpublic.h */ /* This is used by h5_get_version_string() */ const char *LIBVER_NAMES[] = { @@ -2033,3 +2040,198 @@ h5_get_version_string(H5F_libver_t libver) { return(LIBVER_NAMES[libver]); } /* end of h5_get_version_string */ + +/*------------------------------------------------------------------------- + * Function: h5_compare_file_bytes() + * + * Purpose: Helper function to compare two files byte-for-byte. + * + * Return: Success: 0, if files are identical + * Failure: -1, if files differ + * + * Programmer: Binh-Minh Ribler + * October, 2018 + *------------------------------------------------------------------------- + */ +int +h5_compare_file_bytes(char *f1name, char *f2name) +{ + FILE *f1ptr = NULL; /* two file pointers */ + FILE *f2ptr = NULL; + off_t f1size = 0; /* size of the files */ + off_t f2size = 0; + char f1char = 0; /* one char from each file */ + char f2char = 0; + off_t ii = 0; + int ret_value = 0; /* for error handling */ + + /* Open files for reading */ + f1ptr = HDfopen(f1name, "r"); + if (f1ptr == NULL) { + HDfprintf(stderr, "Unable to fopen() %s\n", f1name); + ret_value = -1; + goto done; + } + f2ptr = HDfopen(f2name, "r"); + if (f2ptr == NULL) { + HDfprintf(stderr, "Unable to fopen() %s\n", f2name); + ret_value = -1; + goto done; + } + + /* Get the file sizes and verify that they equal */ + HDfseek(f1ptr , 0 , SEEK_END); + f1size = HDftell(f1ptr); + + HDfseek(f2ptr , 0 , SEEK_END); + f2size = HDftell(f2ptr); + + if (f1size != f2size) { + HDfprintf(stderr, "Files differ in size, %llu vs. %llu\n", f1size, f2size); + ret_value = -1; + goto done; + } + + /* Compare each byte and fail if a difference is found */ + HDrewind(f1ptr); + HDrewind(f2ptr); + for (ii = 0; ii < f1size; ii++) { + HDfread(&f1char, 1, 1, f1ptr); + HDfread(&f2char, 1, 1, f2ptr); + if (f1char != f2char) { + HDfprintf(stderr, "Mismatch @ 0x%llX: 0x%X != 0x%X\n", ii, f1char, f2char); + ret_value = -1; + goto done; + } + } + +done: + if (f1ptr) { + HDfclose(f1ptr); + } + if (f2ptr) { + HDfclose(f2ptr); + } + return(ret_value); +} /* end h5_compare_file_bytes() */ + +/*------------------------------------------------------------------------- + * Function: H5_get_srcdir_filename + * + * Purpose: Append the test file name to the srcdir path and return the whole string + * + * Return: The string + * + *------------------------------------------------------------------------- + */ +const char *H5_get_srcdir_filename(const char *filename) +{ + const char *srcdir = H5_get_srcdir(); + + /* Check for error */ + if(NULL == srcdir) + return(NULL); + else { + /* Build path to test file */ + if((HDstrlen(srcdir) + HDstrlen(filename) + 1) < sizeof(srcdir_testpath)) { + HDsnprintf(srcdir_testpath, sizeof(srcdir_testpath), "%s%s", srcdir, filename); + return(srcdir_testpath); + } /* end if */ + else + return(NULL); + } /* end else */ +} /* end H5_get_srcdir_filename() */ + +/*------------------------------------------------------------------------- + * Function: H5_get_srcdir + * + * Purpose: Just return the srcdir path + * + * Return: The string + * + *------------------------------------------------------------------------- + */ +const char *H5_get_srcdir(void) +{ + const char *srcdir = HDgetenv("srcdir"); + + /* Check for using the srcdir from configure time */ + if(NULL == srcdir) + srcdir = config_srcdir; + + /* Build path to all test files */ + if((HDstrlen(srcdir) + 2) < sizeof(srcdir_path)) { + HDsnprintf(srcdir_path, sizeof(srcdir_path), "%s/", srcdir); + return(srcdir_path); + } /* end if */ + else + return(NULL); +} /* end H5_get_srcdir() */ + +/*------------------------------------------------------------------------- + * Function: h5_duplicate_file_by_bytes + * + * Purpose: Duplicate a file byte-for-byte at filename/path 'orig' + * to a new (or replaced) file at 'dest'. + * + * Return: Success: 0, completed successfully + * Failure: -1 + * + * Programmer: Jake Smith + * 24 June 2020 + * + *------------------------------------------------------------------------- + */ +int +h5_duplicate_file_by_bytes(const char *orig, const char *dest) +{ + FILE *orig_ptr = NULL; + FILE *dest_ptr = NULL; + hsize_t fsize = 0; + hsize_t read_size = 0; + hsize_t max_buf = 0; + void *dup_buf = NULL; + int ret_value = 0; + + max_buf = 4096 * sizeof(char); + + orig_ptr = HDfopen(orig, "r"); + if (NULL == orig_ptr) { + ret_value = -1; + goto done; + } + + HDfseek(orig_ptr , 0 , SEEK_END); + fsize = (hsize_t)HDftell(orig_ptr); + HDrewind(orig_ptr); + + dest_ptr = HDfopen(dest, "w"); + if (NULL == dest_ptr) { + ret_value = -1; + goto done; + } + + read_size = MIN(fsize, max_buf); + dup_buf = HDmalloc(read_size); + if (NULL == dup_buf) { + ret_value = -1; + goto done; + } + + while (read_size > 0) { + HDfread(dup_buf, read_size, 1, orig_ptr); /* warning: no error-check */ + HDfwrite(dup_buf, read_size, 1, dest_ptr); + fsize -= read_size; + read_size = MIN(fsize, max_buf); + } + +done: + if (orig_ptr != NULL) + HDfclose(orig_ptr); + if (dest_ptr != NULL) + HDfclose(dest_ptr); + if (dup_buf != NULL) + HDfree(dup_buf); + return ret_value; +} /* end h5_duplicate_file_by_bytes() */ + diff --git a/test/h5test.h b/test/h5test.h index 15bb15c..3eeb1f8 100644 --- a/test/h5test.h +++ b/test/h5test.h @@ -103,7 +103,7 @@ H5TEST_DLLVAR MPI_Info h5_io_info_g; /* MPI INFO object for IO */ */ #define TESTING(WHAT) {HDprintf("Testing %-62s",WHAT); HDfflush(stdout);} #define TESTING_2(WHAT) {HDprintf(" Testing %-60s",WHAT); HDfflush(stdout);} -#define PASSED() {HDputs(" PASSED");HDfflush(stdout);} +#define PASSED() do {HDputs(" PASSED");HDfflush(stdout);} while (0) #define H5_FAILED() {HDputs("*FAILED*");HDfflush(stdout);} #define H5_WARNING() {HDputs("*WARNING*");HDfflush(stdout);} #define SKIPPED() {HDputs(" -SKIP-");HDfflush(stdout);} @@ -125,6 +125,65 @@ H5TEST_DLLVAR MPI_Info h5_io_info_g; /* MPI INFO object for IO */ #define H5_FILEACCESS_VFD 0x01 #define H5_FILEACCESS_LIBVER 0x02 +/* Macros to create and fill 2D arrays with a single heap allocation. + * These can be used to replace large stack and global arrays which raise + * warnings. + * + * The macros make a single heap allocation large enough to hold all the + * pointers and the data elements. The first part of the allocation holds + * the pointers, and the second part holds the data as a contiguous block + * in row-major order. + * + * To pass the data block to calls like H5Dread(), pass a pointer to the + * first array element as the data pointer (e.g., array[0] in a 2D array). + * + * The fill macro just fills the array with an increasing count value. + * + * Usage: + * + * int **array; + * + * H5TEST_ALLOCATE_2D_ARRAY(array, int, 5, 10); + * + * H5TEST_FILL_2D_ARRAY(array, int, 5, 10); + * + * (do stuff) + * + * HDfree(array); + */ +#define H5TEST_ALLOCATE_2D_ARRAY(ARR, TYPE, DIMS_I, DIMS_J) \ +do { \ + /* Prefix with h5taa to avoid shadow warnings */ \ + size_t h5taa_pointers_size = 0; \ + size_t h5taa_data_size = 0; \ + int h5taa_i; \ + \ + h5taa_pointers_size = (DIMS_I) * sizeof(TYPE *); \ + h5taa_data_size = (DIMS_I) * (DIMS_J) * sizeof(TYPE); \ + \ + ARR = (TYPE **)HDmalloc(h5taa_pointers_size + h5taa_data_size); \ + \ + ARR[0] = (TYPE *)(ARR + (DIMS_I)); \ + \ + for (h5taa_i = 1; h5taa_i < (DIMS_I); h5taa_i++) \ + ARR[h5taa_i] = ARR[h5taa_i-1] + (DIMS_J); \ +} while(0) + +#define H5TEST_FILL_2D_ARRAY(ARR, TYPE, DIMS_I, DIMS_J) \ +do { \ + /* Prefix with h5tfa to avoid shadow warnings */ \ + int h5tfa_i = 0; \ + int h5tfa_j = 0; \ + TYPE h5tfa_count = 0; \ + \ + for (h5tfa_i = 0; h5tfa_i < (DIMS_I); h5tfa_i++) \ + for (h5tfa_j = 0; h5tfa_j < (DIMS_J); h5tfa_j++) { \ + ARR[h5tfa_i][h5tfa_j] = h5tfa_count; \ + h5tfa_count++; \ + } \ +} while(0) + + #ifdef __cplusplus extern "C" { #endif @@ -150,6 +209,8 @@ H5TEST_DLL herr_t h5_verify_cached_stabs(const char *base_name[], hid_t fapl); H5TEST_DLL H5FD_class_t *h5_get_dummy_vfd_class(void); H5TEST_DLL H5VL_class_t *h5_get_dummy_vol_class(void); H5TEST_DLL const char *h5_get_version_string(H5F_libver_t libver); +H5TEST_DLL int h5_compare_file_bytes(char *fname1, char *fname2); +H5TEST_DLL int h5_duplicate_file_by_bytes(const char *orig, const char *dest); /* Functions that will replace components of a FAPL */ H5TEST_DLL herr_t h5_get_vfd_fapl(hid_t fapl_id); diff --git a/test/hyperslab.c b/test/hyperslab.c index 8ed9c22..e702023 100644 --- a/test/hyperslab.c +++ b/test/hyperslab.c @@ -265,7 +265,7 @@ test_fill(size_t nx, size_t ny, size_t nz, } /* end for */ } /* end for */ - PASSED() + PASSED(); HDfree(dst); @@ -545,7 +545,7 @@ test_copy(int mode, } /* end for */ } /* end for */ - PASSED() + PASSED(); HDfree(src); HDfree(dst); @@ -666,7 +666,7 @@ test_multifill(size_t nx) } /* end if */ } /* end for */ - PASSED() + PASSED(); HDfree(src); HDfree(dst); @@ -753,7 +753,7 @@ test_endian(size_t nx) } /* end for */ } /* end for */ - PASSED() + PASSED(); HDfree(src); HDfree(dst); @@ -850,7 +850,7 @@ test_transpose(size_t nx, size_t ny) } /* end for */ } /* end for */ - PASSED() + PASSED(); HDfree(src); HDfree(dst); @@ -943,7 +943,7 @@ test_sub_super(size_t nx, size_t ny) } /* end if */ } /* end for */ } /* end for */ - PASSED() + PASSED(); /* * Test replicating pixels to produce an image twice as large in each @@ -1007,7 +1007,7 @@ test_sub_super(size_t nx, size_t ny) } /* end for */ } /* end for */ - PASSED() + PASSED(); HDfree(full); HDfree(half); diff --git a/test/mf.c b/test/mf.c index 141f5ec..7cfc954 100644 --- a/test/mf.c +++ b/test/mf.c @@ -318,7 +318,7 @@ test_mf_eoa(const char *env_h5_drvr, hid_t fapl) if(H5Pclose(fapl_new) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -460,7 +460,7 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) if(new_file_size != file_size) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -508,7 +508,7 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) if(new_file_size != (file_size + TBLOCK_SIZE30)) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -552,7 +552,7 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) if(new_file_size != (file_size + TBLOCK_SIZE30)) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -600,7 +600,7 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) if(H5Pclose(fapl_new) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -738,7 +738,7 @@ test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl) if(new_file_size != (file_size + TBLOCK_SIZE30 + TBLOCK_SIZE50)) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -801,7 +801,7 @@ test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl) if(H5Pclose(fapl_new) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -999,7 +999,7 @@ test_mf_tmp(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) if(new_file_size != file_size) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -1093,7 +1093,7 @@ test_mf_fs_start(hid_t fapl) if(H5Pclose(fapl_new) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); return(0); @@ -1242,7 +1242,7 @@ test_mf_fs_alloc_free(hid_t fapl) if (new_file_size != file_size) TEST_ERROR - PASSED() + PASSED(); TESTING("H5MF_alloc()/H5MF_xfree() of free-space manager:test 2"); @@ -1317,7 +1317,7 @@ test_mf_fs_alloc_free(hid_t fapl) if (new_file_size != file_size) TEST_ERROR - PASSED() + PASSED(); TESTING("H5MF_alloc()/H5MF_xfree() of free-space manager:test 3"); @@ -1405,7 +1405,7 @@ test_mf_fs_alloc_free(hid_t fapl) if(H5Pclose(fapl_new) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); return(0); @@ -1598,7 +1598,7 @@ test_mf_fs_extend(hid_t fapl) if (new_file_size != file_size) TEST_ERROR - PASSED() + PASSED(); TESTING("H5MF_try_extend() of free-space manager:test 2"); @@ -1700,7 +1700,7 @@ test_mf_fs_extend(hid_t fapl) if (new_file_size != file_size) TEST_ERROR - PASSED() + PASSED(); TESTING("H5MF_try_extend() of free-space manager:test 3"); @@ -1802,7 +1802,7 @@ test_mf_fs_extend(hid_t fapl) if (new_file_size != file_size) TEST_ERROR - PASSED() + PASSED(); TESTING("H5MF_try_extend() of free-space manager:test 4"); @@ -1911,7 +1911,7 @@ test_mf_fs_extend(hid_t fapl) if(H5Pclose(fapl_new) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); return(0); @@ -2023,7 +2023,7 @@ test_mf_fs_absorb(const char *env_h5_drvr, hid_t fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -2084,7 +2084,7 @@ test_mf_fs_absorb(const char *env_h5_drvr, hid_t fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -2226,7 +2226,7 @@ test_mf_aggr_alloc1(const char *env_h5_drvr, hid_t fapl) if(H5Pclose(fcpl) < 0) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -2368,7 +2368,7 @@ test_mf_aggr_alloc2(const char *env_h5_drvr, hid_t fapl) if (new_file_size != file_size) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -2528,7 +2528,7 @@ test_mf_aggr_alloc3(const char *env_h5_drvr, hid_t fapl) if(new_file_size != file_size) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -2695,7 +2695,7 @@ test_mf_aggr_alloc4(const char *env_h5_drvr, hid_t fapl) if(new_file_size != file_size) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -2818,7 +2818,7 @@ test_mf_aggr_alloc5(const char *env_h5_drvr, hid_t fapl) if(new_file_size != file_size) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -2974,7 +2974,7 @@ test_mf_aggr_alloc6(const char *env_h5_drvr, hid_t fapl) if(new_file_size != file_size) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -3158,7 +3158,7 @@ test_mf_aggr_alloc7(const char *env_h5_drvr, hid_t fapl) if (file_size != empty_size) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -3312,7 +3312,7 @@ test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl) if (file_size != empty_size) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -3382,7 +3382,7 @@ test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl) if(file_size != empty_size) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -3450,7 +3450,7 @@ test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl) if(file_size != empty_size) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -3559,7 +3559,7 @@ test_mf_aggr_absorb(const char *env_h5_drvr, hid_t fapl) if(file_size != empty_size) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -3618,7 +3618,7 @@ test_mf_aggr_absorb(const char *env_h5_drvr, hid_t fapl) if(file_size != empty_size) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -3680,7 +3680,7 @@ test_mf_aggr_absorb(const char *env_h5_drvr, hid_t fapl) if(file_size != empty_size) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -3847,7 +3847,7 @@ test_mf_align_eoa(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) if (new_file_size != file_size) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -3902,7 +3902,7 @@ test_mf_align_eoa(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) if (new_file_size != (file_size-TBLOCK_SIZE50)) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -3958,7 +3958,7 @@ test_mf_align_eoa(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) if (new_file_size != (file_size+TBLOCK_SIZE30)) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -4095,7 +4095,7 @@ test_mf_align_fs(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); TESTING("H5MF_alloc() of free-space manager with alignment: test 2"); @@ -4170,7 +4170,7 @@ test_mf_align_fs(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); TESTING("H5MF_alloc() of free-space manager with alignment: test 3"); @@ -4245,7 +4245,7 @@ test_mf_align_fs(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -4515,7 +4515,7 @@ test_mf_align_alloc1(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -4801,7 +4801,7 @@ test_mf_align_alloc2(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -5177,7 +5177,7 @@ test_mf_align_alloc3(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -5386,7 +5386,7 @@ test_mf_align_alloc4(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -5609,7 +5609,7 @@ test_mf_align_alloc5(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -5915,7 +5915,7 @@ test_mf_align_alloc6(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -6078,7 +6078,7 @@ test_mf_bug1(const char *env_h5_drvr, hid_t fapl) * the previous */ if((addr2 - addr1) != (3 * align)) TEST_ERROR - PASSED() + PASSED(); /* Close file */ if(H5Fclose(file) < 0) @@ -6358,7 +6358,7 @@ test_mf_fs_persist_split(void) if(H5Pclose(fcpl) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); return(0); @@ -6711,7 +6711,7 @@ test_mf_fs_persist_multi(void) if(H5Pclose(fcpl) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); return(0); @@ -6878,7 +6878,7 @@ test_mf_fs_persist(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) if(H5Pclose(fapl2) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); } else { SKIPPED(); @@ -7062,7 +7062,7 @@ test_mf_fs_gone(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) if(H5Pclose(fapl2) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); } else { SKIPPED(); @@ -7235,7 +7235,7 @@ test_mf_strat_thres_persist(const char *env_h5_drvr, hid_t fapl, hbool_t new_for if(H5Pclose(fapl2) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); return(0); @@ -7420,7 +7420,7 @@ test_mf_strat_thres_gone(const char *env_h5_drvr, hid_t fapl, hbool_t new_format if(H5Pclose(fapl2) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); return(0); @@ -7509,7 +7509,7 @@ test_dichotomy(hid_t fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); return(0); @@ -7763,7 +7763,7 @@ test_page_alloc_xfree(const char *env_h5_drvr, hid_t fapl) if(H5Pclose(fapl_new) < 0) TEST_ERROR - PASSED() + PASSED(); } else { SKIPPED(); @@ -7887,7 +7887,7 @@ test_page_try_shrink(const char *env_h5_drvr, hid_t fapl) if(H5Pclose(fcpl) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); } else { SKIPPED(); @@ -8042,7 +8042,7 @@ test_page_small_try_extend(const char *env_h5_drvr, hid_t fapl) if(H5Pclose(fcpl) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); } else { SKIPPED(); @@ -8183,7 +8183,7 @@ test_page_large_try_extend(const char *env_h5_drvr, hid_t fapl) if(H5Pclose(fcpl) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); } else { SKIPPED(); @@ -8336,7 +8336,7 @@ test_page_large(const char *env_h5_drvr, hid_t fapl) if(file_size % TBLOCK_SIZE4096) TEST_ERROR - PASSED() + PASSED(); } else { SKIPPED(); @@ -8499,7 +8499,7 @@ test_page_small(const char *env_h5_drvr, hid_t fapl) if(H5Pclose(fcpl) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); } else { SKIPPED(); @@ -8805,7 +8805,7 @@ test_page_alignment(const char *env_h5_drvr, hid_t fapl) if(H5Pclose(fapl_new) < 0) TEST_ERROR - PASSED() + PASSED(); } else { SKIPPED(); diff --git a/test/mirror_vfd.c b/test/mirror_vfd.c new file mode 100644 index 0000000..4da742f --- /dev/null +++ b/test/mirror_vfd.c @@ -0,0 +1,2761 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Test the Mirror VFD functionality. + */ + +/* WARNING: The use of realpath() is probably system-dependent, as are + * other things here such as the socket calls. + * Notable to realpath() in particular is the use of "PATH_MAX", which + * apparently has some major potential issues if paths are abused. + * http://insanecoding.blogspot.com/2007/11/pathmax-simply-isnt.html + * so BE CAREFUL about the paths we throw around? + */ + +#include "h5test.h" +#include "cache_common.h" +#include "genall5.h" + +#ifdef H5_HAVE_MIRROR_VFD + +/* For future consideration, IP address and port number might be + * environment variables? + */ +#define SERVER_IP_ADDRESS "127.0.0.1" + +/* Primary listening port on server. */ +#define SERVER_HANDSHAKE_PORT 3000 + +#define DATABUFFER_SIZE 128 +#define DSET_NAME_LEN 16 + +/* Parameters for the "large chunked dataset" writing */ +#define MAX_DSET_COUNT 255 +#define DSET_DIM 32 +#define CHUNK_DIM 8 + +#define CONCURRENT_COUNT 3 /* Number of files in concurrent test */ + +/* Macro: LOGPRINT() + * Prints logging and debugging messages to the output stream based + * on the level of verbosity. + * 0 : no logging + * 1 : errors only + * 2 : details + * 3 : all + */ +#define DEFAULT_VERBOSITY 1 +static unsigned int g_verbosity = DEFAULT_VERBOSITY; + +/* Macro for selective debug printing / logging */ +#define LOGPRINT(lvl, ...) \ +do { \ + if ((lvl) <= g_verbosity) { \ + fprintf(g_log_stream, __VA_ARGS__); \ + fflush(g_log_stream); \ + } \ +} while (0) + +#define MIRROR_RW_DIR "mirror_rw/" +#define MIRROR_WO_DIR "mirror_wo/" + +/* String buffer for error messages */ +#define MIRR_MESG_SIZE 128 +static char mesg[MIRR_MESG_SIZE + 1]; + +/* Convenience structure for passing file names via helper functions. + */ +struct mirrortest_filenames { + char rw[H5FD_SPLITTER_PATH_MAX+1]; + char wo[H5FD_SPLITTER_PATH_MAX+1]; + char log[H5FD_SPLITTER_PATH_MAX+1]; +}; + +static FILE *g_log_stream = NULL; /* initialized at runtime */ + +static herr_t _verify_datasets(unsigned min_dset, unsigned max_dset, + hid_t *filespace_id, hid_t *dataset_id, hid_t memspace_id); + +static herr_t _create_chunking_ids(hid_t file_id, unsigned min_dset, + unsigned max_dset, hsize_t *chunk_dims, hsize_t *dset_dims, + hid_t *dataspace_ids, hid_t *filespace_ids, hid_t *dataset_ids, + hid_t *memspace_id); + +static herr_t _close_chunking_ids(unsigned min_dset, unsigned max_dset, + hid_t *dataspace_ids, hid_t *filespace_ids, hid_t *dataset_ids, + hid_t *memspace_id); + +static herr_t _populate_filepath(const char *dirname, const char *_basename, + hid_t fapl_id, char *path_out, hbool_t h5suffix); + +static hid_t create_mirroring_split_fapl(const char *_basename, + struct mirrortest_filenames *names); + +static void mybzero(void *dest, size_t size); + + +/* ---------------------------------------------------------------------------- + * Function: mybzero + * + * Purpose: Have bzero simplicity and abstraction in (possible) absence of + * it being available. + * + * Programmer: Jacob Smith + * 2020-03-30 + * ---------------------------------------------------------------------------- + */ +static void +mybzero(void *dest, size_t size) +{ + size_t i = 0; + char *s = NULL; + HDassert(dest != NULL); + s = (char *)dest; + for (i = 0; i < size; i++) { + *(s+i) = 0; + } +} /* end mybzero() */ + + +/* ---------------------------------------------------------------------------- + * Function: _populate_filepath + * + * Purpose: Given a directory name and a base name, concatenate the two and + * run h5fixname() to get the "actual" path to the intented target. + * `h5suffix' should be FALSE to keep the base name unaltered; + * TRUE will append the '.h5' h5suffix to the basename... + * FALSE -> h5fixname_no_suffix(), TRUE -> h5fixname() + * / / <_basename> + * + * Programmer: Jacob Smith + * 2019-08-16 + * ---------------------------------------------------------------------------- + */ +static herr_t +_populate_filepath(const char *dirname, const char *_basename, hid_t fapl_id, + char *path_out, hbool_t h5suffix) +{ + char _path[H5FD_SPLITTER_PATH_MAX]; + + if ((_basename == NULL) || + (*_basename == 0) || + (dirname == NULL) || + (*dirname == 0) || + (path_out == NULL)) + { + TEST_ERROR; + } + + if (HDsnprintf(_path, H5FD_SPLITTER_PATH_MAX, "%s%s%s", dirname, + (dirname[strlen(dirname)] == '/') ? "" : "/", /* slash iff needed */ + _basename) + > H5FD_SPLITTER_PATH_MAX) + { + TEST_ERROR; + } + + if (h5suffix == TRUE) { + if (h5_fixname(_path, fapl_id, path_out, + H5FD_SPLITTER_PATH_MAX) + == NULL) + { + TEST_ERROR; + } + } + else { + if (h5_fixname_no_suffix(_path, fapl_id, path_out, + H5FD_SPLITTER_PATH_MAX) + == NULL) + { + TEST_ERROR; + } + } + + return SUCCEED; + +error: + return FAIL; +} /* end _populate_filepath() */ + + +/* --------------------------------------------------------------------------- + * Function: build_paths + * + * Purpose: Convenience function to create the three file paths used in + * most mirror tests. + * + * Return: SUCCEED/FAIL + * + * Programmer: Jacob Smith + * 2019-08-16 + * --------------------------------------------------------------------------- + */ +static herr_t +build_paths( + const char *_basename, + H5FD_splitter_vfd_config_t *splitter_config, + struct mirrortest_filenames *names) +{ + char baselogname[H5FD_SPLITTER_PATH_MAX]; + + if (_populate_filepath(MIRROR_RW_DIR, _basename, + splitter_config->rw_fapl_id, names->rw, TRUE) + == FAIL) + { + TEST_ERROR; + } + + if (_populate_filepath(MIRROR_WO_DIR, _basename, + splitter_config->wo_fapl_id, names->wo, TRUE) + == FAIL) + { + TEST_ERROR; + } + + if (_basename == NULL || *_basename == 0) + return FAIL; + if (HDsnprintf(baselogname, H5FD_SPLITTER_PATH_MAX, "%s_err.log", + _basename) + > H5FD_SPLITTER_PATH_MAX) + { + TEST_ERROR; + } + + if (_populate_filepath(MIRROR_WO_DIR, baselogname, + splitter_config->wo_fapl_id, names->log, FALSE) + == FAIL) + { + TEST_ERROR; + } + + return SUCCEED; + +error: + return FAIL; +} /* end build_paths() */ + + +/* --------------------------------------------------------------------------- + * Function: test_fapl_configuration + * + * Purpose: Test FAPL configuration and examination. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Jacob Smith + * 2019-03-12 + * --------------------------------------------------------------------------- + */ +static int +test_fapl_configuration(void) +{ + hid_t fapl_id; + H5FD_mirror_fapl_t mirror_conf = { + H5FD_MIRROR_FAPL_MAGIC, /* magic */ + H5FD_MIRROR_CURR_FAPL_T_VERSION, /* version */ + SERVER_HANDSHAKE_PORT, /* handhake_port */ + SERVER_IP_ADDRESS, /* remote_ip "IP address" */ + }; + H5FD_mirror_fapl_t fa_out = {0, 0, 0, ""}; + + TESTING("Mirror fapl configuration (set/get)"); + + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + if (H5I_INVALID_HID == fapl_id) { + TEST_ERROR; + } + + if (H5Pset_fapl_mirror(fapl_id, &mirror_conf) == FAIL) { + TEST_ERROR; + } + + if (H5Pget_fapl_mirror(fapl_id, &fa_out) == FAIL) { + TEST_ERROR; + } + if (H5FD_MIRROR_FAPL_MAGIC != fa_out.magic) { + TEST_ERROR; + } + if (H5FD_MIRROR_CURR_FAPL_T_VERSION != fa_out.version) { + TEST_ERROR; + } + if (SERVER_HANDSHAKE_PORT != fa_out.handshake_port) { + TEST_ERROR; + } + if (HDstrncmp(SERVER_IP_ADDRESS, (const char *)fa_out.remote_ip, + H5FD_MIRROR_MAX_IP_LEN)) + { + TEST_ERROR; + } + + if (H5Pclose(fapl_id) == FAIL) { + TEST_ERROR; + } + + PASSED(); + return 0; + +error: + if (H5I_INVALID_HID != fapl_id) { + (void)H5Pclose(fapl_id); + } + return -1; +} /* end test_fapl_configuration() */ + + + +#define PRINT_BUFFER_DIFF(act, exp, len) do { \ + size_t _x = 0; \ + while ((act)[_x] == (exp)[_x]) { \ + _x++; \ + } \ + if (_x != (len)) { \ + size_t _y = 0; \ + HDprintf("First bytes differ at %zu\n", _x); \ + HDprintf("exp "); \ + for (_y = _x; _y < (len); _y++) { \ + HDprintf("%02X", (unsigned char)(exp)[_y]); \ + } \ + HDprintf("\nact "); \ + for (_y = _x; _y < (len); _y++) { \ + HDprintf("%02X", (unsigned char)(act)[_y]); \ + } \ + HDprintf("\n"); \ + } \ +} while (0); /* end PRINT_BUFFER_DIFF */ + + +/* --------------------------------------------------------------------------- + * Function: test_xmit_encode_decode + * + * Purpose: Test byte-encoding operations for network transport. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Jacob Smith + * 2020-02-02 + * --------------------------------------------------------------------------- + */ +static int +test_xmit_encode_decode(void) +{ + H5FD_mirror_xmit_t xmit_mock; /* re-used header in various xmit tests */ + + TESTING("Mirror encode/decode of xmit elements"); + + /* Set bogus values matching expected; encoding doesn't care + * Use sequential values to easily generate the expected buffer with a + * for loop. + */ + xmit_mock.magic = 0x00010203; + xmit_mock.version = 0x04; + xmit_mock.session_token = 0x05060708; + xmit_mock.xmit_count = 0x090A0B0C; + xmit_mock.op = 0x0D; + + /* Test uint8_t encode/decode + */ + do { + unsigned char buf[8]; + unsigned char expected[8]; + const uint8_t v = 200; + unsigned char out = 0; + + /* Start of buffer uint8_t + */ + mybzero(buf, 8); + mybzero(expected, 8); + expected[0] = 200; + out = 0; + if (H5FD__mirror_xmit_encode_uint8(buf, v) != 1) { + TEST_ERROR; + } + if (HDmemcmp(buf, expected, 8) != 0) { + PRINT_BUFFER_DIFF(buf, expected, 8); + TEST_ERROR; + } + if (H5FD__mirror_xmit_decode_uint8(&out, buf) != 1) { + TEST_ERROR; + } + if (v != out) { + TEST_ERROR; + } + + /* Middle of buffer uint8_t + */ + mybzero(buf, 8); + mybzero(expected, 8); + expected[3] = v; + out = 0; + if (H5FD__mirror_xmit_encode_uint8((buf+3), v) != 1) { + TEST_ERROR; + } + if (HDmemcmp(buf, expected, 8) != 0) { + PRINT_BUFFER_DIFF(buf, expected, 8); + TEST_ERROR; + } + if (H5FD__mirror_xmit_decode_uint8(&out, (buf+3)) != 1) { + TEST_ERROR; + } + if (v != out) { + TEST_ERROR; + } + + /* End of buffer uint8_t + */ + mybzero(buf, 8); + mybzero(expected, 8); + expected[7] = v; + out = 0; + if (H5FD__mirror_xmit_encode_uint8((buf+7), v) != 1) { + TEST_ERROR; + } + if (HDmemcmp(buf, expected, 8) != 0) { + PRINT_BUFFER_DIFF(buf, expected, 8); + TEST_ERROR; + } + if (H5FD__mirror_xmit_decode_uint8(&out, (buf+7)) != 1) { + TEST_ERROR; + } + if (v != out) { + TEST_ERROR; + } + + } while (0); /* end uint8_t en/decode */ + + /* Test uint16_t encode/decode + */ + do { + unsigned char buf[8]; + unsigned char expected[8]; + const uint16_t v = 0x8F02; + uint16_t out = 0; + + /* Start of buffer uint16_t + */ + mybzero(buf, 8); + mybzero(expected, 8); + expected[0] = 0x8F; + expected[1] = 0x02; + out = 0; + if (H5FD__mirror_xmit_encode_uint16(buf, v) != 2) { + TEST_ERROR; + } + if (HDmemcmp(buf, expected, 8) != 0) { + PRINT_BUFFER_DIFF(buf, expected, 8); + TEST_ERROR; + } + if (H5FD__mirror_xmit_decode_uint16(&out, buf) != 2) { + TEST_ERROR; + } + if (out != v) { + TEST_ERROR; + } + + /* Middle of buffer uint16_t + */ + mybzero(buf, 8); + mybzero(expected, 8); + expected[3] = 0x8F; + expected[4] = 0x02; + out = 0; + if (H5FD__mirror_xmit_encode_uint16((buf+3), v) != 2) { + TEST_ERROR; + } + if (HDmemcmp(buf, expected, 8) != 0) { + PRINT_BUFFER_DIFF(buf, expected, 8); + TEST_ERROR; + } + if (H5FD__mirror_xmit_decode_uint16(&out, (buf+3)) != 2) { + TEST_ERROR; + } + if (out != v) { + TEST_ERROR; + } + /* slice */ + if (H5FD__mirror_xmit_decode_uint16(&out, (buf+4)) != 2) { + TEST_ERROR; + } + if (out != 0x0200) { + TEST_ERROR; + } + + /* End of buffer uint16_t + */ + mybzero(buf, 8); + mybzero(expected, 8); + expected[6] = 0x8F; + expected[7] = 0x02; + out = 0; + if (H5FD__mirror_xmit_encode_uint16((buf+6), v) != 2) { + TEST_ERROR; + } + if (HDmemcmp(buf, expected, 8) != 0) { + PRINT_BUFFER_DIFF(buf, expected, 8); + TEST_ERROR; + } + if (H5FD__mirror_xmit_decode_uint16(&out, (buf+6)) != 2) { + TEST_ERROR; + } + if (out != v) { + TEST_ERROR; + } + + } while (0); /* end uint16_t en/decode */ + + /* Test uint32_t encode/decode + */ + do { + unsigned char buf[8]; + unsigned char expected[8]; + const uint32_t v = 0x8F020048; + uint32_t out = 0; + + /* Start of buffer uint32_t + */ + mybzero(buf, 8); + mybzero(expected, 8); + expected[0] = 0x8F; + expected[1] = 0x02; + expected[2] = 0x00; + expected[3] = 0x48; + out = 0; + if (H5FD__mirror_xmit_encode_uint32(buf, v) != 4) { + TEST_ERROR; + } + if (HDmemcmp(buf, expected, 8) != 0) { + PRINT_BUFFER_DIFF(buf, expected, 8); + TEST_ERROR; + } + if (H5FD__mirror_xmit_decode_uint32(&out, buf) != 4) { + TEST_ERROR; + } + if (out != v) { + TEST_ERROR; + } + + /* Middle of buffer uint32_t + */ + mybzero(buf, 8); + mybzero(expected, 8); + expected[3] = 0x8F; + expected[4] = 0x02; + expected[5] = 0x00; + expected[6] = 0x48; + out = 0; + if (H5FD__mirror_xmit_encode_uint32((buf+3), v) != 4) { + TEST_ERROR; + } + if (HDmemcmp(buf, expected, 8) != 0) { + PRINT_BUFFER_DIFF(buf, expected, 8); + TEST_ERROR; + } + if (H5FD__mirror_xmit_decode_uint32(&out, (buf+3)) != 4) { + TEST_ERROR; + } + if (out != v) { + TEST_ERROR; + } + /* slice */ + if (H5FD__mirror_xmit_decode_uint32(&out, (buf+4)) != 4) { + TEST_ERROR; + } + if (out != 0x02004800) { + TEST_ERROR; + } + + /* End of buffer uint32_t + */ + mybzero(buf, 8); + mybzero(expected, 8); + expected[4] = 0x8F; + expected[5] = 0x02; + expected[6] = 0x00; + expected[7] = 0x48; + out = 0; + if (H5FD__mirror_xmit_encode_uint32((buf+4), v) != 4) { + TEST_ERROR; + } + if (HDmemcmp(buf, expected, 8) != 0) { + PRINT_BUFFER_DIFF(buf, expected, 8); + TEST_ERROR; + } + if (H5FD__mirror_xmit_decode_uint32(&out, (buf+4)) != 4) { + TEST_ERROR; + } + if (out != v) { + TEST_ERROR; + } + + } while (0); /* end uint32_t en/decode */ + + /* Test uint64_t encode/decode + */ + do { + unsigned char buf[16]; + unsigned char expected[16]; + const uint64_t v = 0x90DCBE17939CE4BB; + uint64_t out = 0; + + /* Start of buffer uint64_t + */ + mybzero(buf, 16); + mybzero(expected, 16); + expected[0] = 0x90; + expected[1] = 0xDC; + expected[2] = 0xBE; + expected[3] = 0x17; + expected[4] = 0x93; + expected[5] = 0x9C; + expected[6] = 0xE4; + expected[7] = 0xBB; + out = 0; + if (H5FD__mirror_xmit_encode_uint64(buf, v) != 8) { + TEST_ERROR; + } + if (HDmemcmp(buf, expected, 16) != 0) { + PRINT_BUFFER_DIFF(buf, expected, 16); + TEST_ERROR; + } + if (H5FD__mirror_xmit_decode_uint64(&out, buf) != 8) { + TEST_ERROR; + } + if (out != v) { + TEST_ERROR; + } + + /* Middle of buffer uint64_t + */ + mybzero(buf, 16); + mybzero(expected, 16); + expected[3] = 0x90; + expected[4] = 0xDC; + expected[5] = 0xBE; + expected[6] = 0x17; + expected[7] = 0x93; + expected[8] = 0x9C; + expected[9] = 0xE4; + expected[10] = 0xBB; + out = 0; + if (H5FD__mirror_xmit_encode_uint64((buf+3), v) != 8) { + TEST_ERROR; + } + if (HDmemcmp(buf, expected, 16) != 0) { + PRINT_BUFFER_DIFF(buf, expected, 16); + TEST_ERROR; + } + if (H5FD__mirror_xmit_decode_uint64(&out, (buf+3)) != 8) { + TEST_ERROR; + } + if (out != v) { + TEST_ERROR; + } + /* slice */ + if (H5FD__mirror_xmit_decode_uint64(&out, (buf+6)) != 8) { + TEST_ERROR; + } + if (out != 0x17939CE4BB000000) { + TEST_ERROR; + } + + /* End of buffer uint64_t + */ + mybzero(buf, 16); + mybzero(expected, 16); + expected[8] = 0x90; + expected[9] = 0xDC; + expected[10] = 0xBE; + expected[11] = 0x17; + expected[12] = 0x93; + expected[13] = 0x9C; + expected[14] = 0xE4; + expected[15] = 0xBB; + out = 0; + if (H5FD__mirror_xmit_encode_uint64((buf+8), v) != 8) { + TEST_ERROR; + } + if (HDmemcmp(buf, expected, 16) != 0) { + PRINT_BUFFER_DIFF(buf, expected, 16); + TEST_ERROR; + } + if (H5FD__mirror_xmit_decode_uint64(&out, (buf+8)) != 8) { + TEST_ERROR; + } + if (out != v) { + TEST_ERROR; + } + + } while (0); /* end uint64_t en/decode */ + + /* Test xmit header structure encode/decode + * Write bogus but easily verifiable data to inside a buffer, and compare. + * Then decode the buffer and compare the structure contents. + * Then repeat from a different offset in the buffer and compare. + */ + do { + unsigned char buf[H5FD_MIRROR_XMIT_HEADER_SIZE+8]; + unsigned char expected[H5FD_MIRROR_XMIT_HEADER_SIZE+8]; + H5FD_mirror_xmit_t xmit_out; + size_t i = 0; + + /* sanity check */ + if (14 != H5FD_MIRROR_XMIT_HEADER_SIZE) { + FAIL_PUTS_ERROR("Header size definition does not match test\n"); + } + + /* Populate the expected buffer; expect end padding of 0xFF + */ + HDmemset(expected, 0xFF, H5FD_MIRROR_XMIT_HEADER_SIZE+8); + for (i=0; i < H5FD_MIRROR_XMIT_HEADER_SIZE; i++) { + expected[i+2] = (unsigned char)i; + } + + /* Encode, and compare buffer contents + * Initial buffer is filled with 0xFF to match expected padding + */ + HDmemset(buf, 0xFF, H5FD_MIRROR_XMIT_HEADER_SIZE+8); + if (H5FD_mirror_xmit_encode_header((buf+2), &xmit_mock) + != H5FD_MIRROR_XMIT_HEADER_SIZE) + { + TEST_ERROR; + } + if (HDmemcmp(buf, expected, H5FD_MIRROR_XMIT_HEADER_SIZE+8) != 0) { + PRINT_BUFFER_DIFF(buf, expected, H5FD_MIRROR_XMIT_HEADER_SIZE+8); + TEST_ERROR; + } + + /* Decode from buffer + */ + if (H5FD_mirror_xmit_decode_header(&xmit_out, (buf+2)) + != H5FD_MIRROR_XMIT_HEADER_SIZE) + { + TEST_ERROR; + } + if (xmit_out.magic != xmit_mock.magic) TEST_ERROR; + if (xmit_out.version != xmit_mock.version) TEST_ERROR; + if (xmit_out.session_token != xmit_mock.session_token) TEST_ERROR; + if (xmit_out.xmit_count != xmit_mock.xmit_count) TEST_ERROR; + if (xmit_out.op != xmit_mock.op) TEST_ERROR; + + /* Decode from different offset in buffer + * Observe changes when ingesting the padding + */ + if (H5FD_mirror_xmit_decode_header(&xmit_out, (buf)) + != H5FD_MIRROR_XMIT_HEADER_SIZE) + { + TEST_ERROR; + } + if (xmit_out.magic != 0xFFFF0001) TEST_ERROR; + if (xmit_out.version != 0x02) TEST_ERROR; + if (xmit_out.session_token != 0x03040506) TEST_ERROR; + if (xmit_out.xmit_count != 0x0708090A) TEST_ERROR; + if (xmit_out.op != 0x0B) TEST_ERROR; + + } while (0); /* end xmit header en/decode */ + + /* Test xmit set-eoa structure encode/decode + * Write bogus but easily verifiable data to inside a buffer, and compare. + * Then decode the buffer and compare the structure contents. + * Then repeat from a different offset in the buffer and compare. + */ + do { + unsigned char buf[H5FD_MIRROR_XMIT_EOA_SIZE+8]; + unsigned char expected[H5FD_MIRROR_XMIT_EOA_SIZE+8]; + H5FD_mirror_xmit_eoa_t xmit_in; + H5FD_mirror_xmit_eoa_t xmit_out; + size_t i = 0; + + /* sanity check */ + if ((14+9) != H5FD_MIRROR_XMIT_EOA_SIZE) { + FAIL_PUTS_ERROR("Header size definition does not match test\n"); + } + if (xmit_mock.op != 0x0D) { + FAIL_PUTS_ERROR("shared header structure is not in expected state"); + } + + /* Populate the expected buffer; expect end padding of 0xFF + */ + HDmemset(expected, 0xFF, H5FD_MIRROR_XMIT_EOA_SIZE+8); + for (i=0; i < H5FD_MIRROR_XMIT_EOA_SIZE; i++) { + expected[i+2] = (unsigned char)i; + } + + /* Set xmit_in + */ + xmit_in.pub = xmit_mock; /* shared/common */ + xmit_in.type = 0x0E; + xmit_in.eoa_addr = 0x0F10111213141516; + + /* Encode, and compare buffer contents + * Initial buffer is filled with 0xFF to match expected padding + */ + HDmemset(buf, 0xFF, H5FD_MIRROR_XMIT_EOA_SIZE+8); + if (H5FD_mirror_xmit_encode_set_eoa((buf+2), &xmit_in) + != H5FD_MIRROR_XMIT_EOA_SIZE) + { + TEST_ERROR; + } + if (HDmemcmp(buf, expected, H5FD_MIRROR_XMIT_EOA_SIZE+8) != 0) { + PRINT_BUFFER_DIFF(buf, expected, H5FD_MIRROR_XMIT_EOA_SIZE+8); + TEST_ERROR; + } + + /* Decode from buffer + */ + if (H5FD_mirror_xmit_decode_set_eoa(&xmit_out, (buf+2)) + != H5FD_MIRROR_XMIT_EOA_SIZE) + { + TEST_ERROR; + } + if (xmit_out.pub.magic != xmit_mock.magic) TEST_ERROR; + if (xmit_out.pub.version != xmit_mock.version) TEST_ERROR; + if (xmit_out.pub.session_token != xmit_mock.session_token) TEST_ERROR; + if (xmit_out.pub.xmit_count != xmit_mock.xmit_count) TEST_ERROR; + if (xmit_out.pub.op != xmit_mock.op) TEST_ERROR; + if (xmit_out.type != 0x0E) TEST_ERROR; + if (xmit_out.eoa_addr != 0x0F10111213141516) TEST_ERROR; + + /* Decode from different offset in buffer + * Observe changes when ingesting the padding + */ + if (H5FD_mirror_xmit_decode_set_eoa(&xmit_out, (buf)) + != H5FD_MIRROR_XMIT_EOA_SIZE) + { + TEST_ERROR; + } + if (xmit_out.pub.magic != 0xFFFF0001) TEST_ERROR; + if (xmit_out.pub.version != 0x02) TEST_ERROR; + if (xmit_out.pub.session_token != 0x03040506) TEST_ERROR; + if (xmit_out.pub.xmit_count != 0x0708090A) TEST_ERROR; + if (xmit_out.pub.op != 0x0B) TEST_ERROR; + if (xmit_out.type != 0x0C) TEST_ERROR; + if (xmit_out.eoa_addr != 0x0D0E0F1011121314) TEST_ERROR; + + } while (0); /* end xmit set-eoa en/decode */ + + /* Test xmit lock structure encode/decode + * Write bogus but easily verifiable data to inside a buffer, and compare. + * Then decode the buffer and compare the structure contents. + * Then repeat from a different offset in the buffer and compare. + */ + do { + unsigned char buf[H5FD_MIRROR_XMIT_LOCK_SIZE+8]; + unsigned char expected[H5FD_MIRROR_XMIT_LOCK_SIZE+8]; + H5FD_mirror_xmit_lock_t xmit_in; + H5FD_mirror_xmit_lock_t xmit_out; + size_t i = 0; + + /* sanity check */ + if ((14+8) != H5FD_MIRROR_XMIT_LOCK_SIZE) { + FAIL_PUTS_ERROR("Header size definition does not match test\n"); + } + if (xmit_mock.op != 0x0D) { + FAIL_PUTS_ERROR("shared header structure is not in expected state"); + } + + /* Populate the expected buffer; expect end padding of 0xFF + */ + HDmemset(expected, 0xFF, H5FD_MIRROR_XMIT_LOCK_SIZE+8); + for (i=0; i < H5FD_MIRROR_XMIT_LOCK_SIZE; i++) { + expected[i+2] = (unsigned char)i; + } + + /* Set xmit_in + */ + xmit_in.pub = xmit_mock; /* shared/common */ + xmit_in.rw = 0x0E0F101112131415; + + /* Encode, and compare buffer contents + * Initial buffer is filled with 0xFF to match expected padding + */ + HDmemset(buf, 0xFF, H5FD_MIRROR_XMIT_LOCK_SIZE+8); + if (H5FD_mirror_xmit_encode_lock((buf+2), &xmit_in) + != H5FD_MIRROR_XMIT_LOCK_SIZE) + { + TEST_ERROR; + } + if (HDmemcmp(buf, expected, H5FD_MIRROR_XMIT_LOCK_SIZE+8) != 0) { + PRINT_BUFFER_DIFF(buf, expected, H5FD_MIRROR_XMIT_LOCK_SIZE+8); + TEST_ERROR; + } + + /* Decode from buffer + */ + if (H5FD_mirror_xmit_decode_lock(&xmit_out, (buf+2)) + != H5FD_MIRROR_XMIT_LOCK_SIZE) + { + TEST_ERROR; + } + if (xmit_out.pub.magic != xmit_mock.magic) TEST_ERROR; + if (xmit_out.pub.version != xmit_mock.version) TEST_ERROR; + if (xmit_out.pub.session_token != xmit_mock.session_token) TEST_ERROR; + if (xmit_out.pub.xmit_count != xmit_mock.xmit_count) TEST_ERROR; + if (xmit_out.pub.op != xmit_mock.op) TEST_ERROR; + if (xmit_out.rw != 0x0E0F101112131415) TEST_ERROR; + + /* Decode from different offset in buffer + * Observe changes when ingesting the padding + */ + if (H5FD_mirror_xmit_decode_lock(&xmit_out, (buf)) + != H5FD_MIRROR_XMIT_LOCK_SIZE) + { + TEST_ERROR; + } + if (xmit_out.pub.magic != 0xFFFF0001) TEST_ERROR; + if (xmit_out.pub.version != 0x02) TEST_ERROR; + if (xmit_out.pub.session_token != 0x03040506) TEST_ERROR; + if (xmit_out.pub.xmit_count != 0x0708090A) TEST_ERROR; + if (xmit_out.pub.op != 0x0B) TEST_ERROR; + if (xmit_out.rw != 0x0C0D0E0F10111213) TEST_ERROR; + + } while (0); /* end xmit lock en/decode */ + + /* Test xmit open structure encode/decode + * Write bogus but easily verifiable data to inside a buffer, and compare. + * Then decode the buffer and compare the structure contents. + * Then repeat from a different offset in the buffer and compare. + * + * Verifies that the first zero character in the filepath will end the + * string, with all following bytes in the encoded buffer being zeroed. + */ + do { + unsigned char buf[H5FD_MIRROR_XMIT_OPEN_SIZE+8]; + unsigned char expected[H5FD_MIRROR_XMIT_OPEN_SIZE+8]; + H5FD_mirror_xmit_open_t xmit_in; + H5FD_mirror_xmit_open_t xmit_out; + size_t i = 0; + + /* sanity check */ + if ((14+20+4097) != H5FD_MIRROR_XMIT_OPEN_SIZE) { + FAIL_PUTS_ERROR("Header size definition does not match test\n"); + } + if (xmit_mock.op != 0x0D) { + FAIL_PUTS_ERROR("shared header structure is not in expected state"); + } + + /* Populate the expected buffer; expect end padding of 0xFF + */ + HDmemset(expected, 0xFF, H5FD_MIRROR_XMIT_OPEN_SIZE+8); + for (i=0; i < H5FD_MIRROR_XMIT_OPEN_SIZE; i++) { + /* 0x100 is "zero" in a byte, so encode will treat it as a NULL- + * terminator in the filepath string. Expect all zeroes following. + */ + expected[i+2] = (i > 0xFF) ? 0 : (unsigned char)i; + } + + /* Set xmit_in + */ + xmit_in.pub = xmit_mock; /* shared/common */ + xmit_in.flags = 0x0E0F1011; + xmit_in.maxaddr = 0x1213141516171819; + xmit_in.size_t_blob = 0x1A1B1C1D1E1F2021; + for (i=0x22; i < H5FD_MIRROR_XMIT_FILEPATH_MAX+0x22; i++) { + /* nonzero values repeat after 0x100, but will not be encoded */ + xmit_in.filename[i-0x22] = (char)(i % 0x100); + } + xmit_in.filename[H5FD_MIRROR_XMIT_FILEPATH_MAX-1] = 0; + + /* Encode, and compare buffer contents + * Initial buffer is filled with 0xFF to match expected padding + */ + HDmemset(buf, 0xFF, H5FD_MIRROR_XMIT_OPEN_SIZE+8); + if (H5FD_mirror_xmit_encode_open((buf+2), &xmit_in) + != H5FD_MIRROR_XMIT_OPEN_SIZE) + { + TEST_ERROR; + } + if (HDmemcmp(buf, expected, H5FD_MIRROR_XMIT_OPEN_SIZE+8) != 0) { + PRINT_BUFFER_DIFF(buf, expected, H5FD_MIRROR_XMIT_OPEN_SIZE+8); + TEST_ERROR; + } + + /* Decode from buffer + */ + if (H5FD_mirror_xmit_decode_open(&xmit_out, (buf+2)) + != H5FD_MIRROR_XMIT_OPEN_SIZE) + { + TEST_ERROR; + } + if (xmit_out.pub.magic != xmit_mock.magic) TEST_ERROR; + if (xmit_out.pub.version != xmit_mock.version) TEST_ERROR; + if (xmit_out.pub.session_token != xmit_mock.session_token) TEST_ERROR; + if (xmit_out.pub.xmit_count != xmit_mock.xmit_count) TEST_ERROR; + if (xmit_out.pub.op != xmit_mock.op) TEST_ERROR; + if (xmit_out.flags != xmit_in.flags) TEST_ERROR; + if (xmit_out.maxaddr != xmit_in.maxaddr) TEST_ERROR; + if (xmit_out.size_t_blob != xmit_in.size_t_blob) TEST_ERROR; + if (HDstrncmp(xmit_out.filename, xmit_in.filename, + H5FD_MIRROR_XMIT_FILEPATH_MAX) + != 0) + { + PRINT_BUFFER_DIFF(xmit_out.filename, xmit_in.filename, + H5FD_MIRROR_XMIT_FILEPATH_MAX); + TEST_ERROR; + } + + /* Decode from different offset in buffer + * Observe changes when ingesting the padding + */ + if (H5FD_mirror_xmit_decode_open(&xmit_out, (buf)) + != H5FD_MIRROR_XMIT_OPEN_SIZE) + { + TEST_ERROR; + } + if (xmit_out.pub.magic != 0xFFFF0001) TEST_ERROR; + if (xmit_out.pub.version != 0x02) TEST_ERROR; + if (xmit_out.pub.session_token != 0x03040506) TEST_ERROR; + if (xmit_out.pub.xmit_count != 0x0708090A) TEST_ERROR; + if (xmit_out.pub.op != 0x0B) TEST_ERROR; + if (xmit_out.flags != 0x0C0D0E0F) TEST_ERROR; + if (xmit_out.maxaddr != 0x1011121314151617) TEST_ERROR; + if (xmit_out.size_t_blob != 0x18191A1B1C1D1E1F) TEST_ERROR; + /* update expected "filepath" in structure */ + for (i=0x20; i < H5FD_MIRROR_XMIT_FILEPATH_MAX+0x20; i++) { + xmit_in.filename[i-0x20] = (i > 0xFF) ? 0 : (char)i; + } + if (HDstrncmp(xmit_out.filename, xmit_in.filename, + H5FD_MIRROR_XMIT_FILEPATH_MAX) + != 0) + { + PRINT_BUFFER_DIFF(xmit_out.filename, xmit_in.filename, + H5FD_MIRROR_XMIT_FILEPATH_MAX); + TEST_ERROR; + } + + } while (0); /* end xmit open en/decode */ + + /* Test xmit reply structure encode/decode + * Write bogus but easily verifiable data to inside a buffer, and compare. + * Then decode the buffer and compare the structure contents. + * Then repeat from a different offset in the buffer and compare. + * + * Verifies that the first zero character in the filepath will end the + * string, with all following bytes in the encoded buffer being zeroed. + */ + do { + unsigned char buf[H5FD_MIRROR_XMIT_REPLY_SIZE+8]; + unsigned char expected[H5FD_MIRROR_XMIT_REPLY_SIZE+8]; + H5FD_mirror_xmit_reply_t xmit_in; + H5FD_mirror_xmit_reply_t xmit_out; + size_t i = 0; + + /* sanity check */ + if ((14+4+256) != H5FD_MIRROR_XMIT_REPLY_SIZE) { + FAIL_PUTS_ERROR("Header size definition does not match test\n"); + } + if (xmit_mock.op != 0x0D) { + FAIL_PUTS_ERROR("shared header structure is not in expected state"); + } + + /* Populate the expected buffer; expect end padding of 0xFF + */ + HDmemset(expected, 0xFF, H5FD_MIRROR_XMIT_REPLY_SIZE+8); + for (i=0; i < H5FD_MIRROR_XMIT_REPLY_SIZE; i++) { + /* 0x100 is "zero" in a byte, so encode will treat it as a NULL- + * terminator in the filepath string. Expect all zeroes following. + */ + expected[i+2] = (i > 0xFF) ? 0 : (unsigned char)i; + } + + /* Set xmit_in + */ + xmit_in.pub = xmit_mock; /* shared/common */ + xmit_in.status = 0x0E0F1011; + for (i=0x12; i < H5FD_MIRROR_STATUS_MESSAGE_MAX+0x12; i++) { + /* nonzero values repeat after 0x100, but will not be encoded */ + xmit_in.message[i-0x12] = (char)(i % 0x100); + } + xmit_in.message[H5FD_MIRROR_STATUS_MESSAGE_MAX-1] = 0; + + /* Encode, and compare buffer contents + * Initial buffer is filled with 0xFF to match expected padding + */ + HDmemset(buf, 0xFF, H5FD_MIRROR_XMIT_REPLY_SIZE+8); + if (H5FD_mirror_xmit_encode_reply((buf+2), &xmit_in) + != H5FD_MIRROR_XMIT_REPLY_SIZE) + { + TEST_ERROR; + } + if (HDmemcmp(buf, expected, H5FD_MIRROR_XMIT_REPLY_SIZE+8) != 0) { + PRINT_BUFFER_DIFF(buf, expected, H5FD_MIRROR_XMIT_REPLY_SIZE+8); + TEST_ERROR; + } + + /* Decode from buffer + */ + if (H5FD_mirror_xmit_decode_reply(&xmit_out, (buf+2)) + != H5FD_MIRROR_XMIT_REPLY_SIZE) + { + TEST_ERROR; + } + if (xmit_out.pub.magic != xmit_mock.magic) TEST_ERROR; + if (xmit_out.pub.version != xmit_mock.version) TEST_ERROR; + if (xmit_out.pub.session_token != xmit_mock.session_token) TEST_ERROR; + if (xmit_out.pub.xmit_count != xmit_mock.xmit_count) TEST_ERROR; + if (xmit_out.pub.op != xmit_mock.op) TEST_ERROR; + if (xmit_out.status != xmit_in.status) TEST_ERROR; + if (HDstrncmp(xmit_out.message, xmit_in.message, + H5FD_MIRROR_STATUS_MESSAGE_MAX) + != 0) + { + PRINT_BUFFER_DIFF(xmit_out.message, xmit_in.message, + H5FD_MIRROR_STATUS_MESSAGE_MAX); + TEST_ERROR; + } + + /* Decode from different offset in buffer + * Observe changes when ingesting the padding + */ + if (H5FD_mirror_xmit_decode_reply(&xmit_out, (buf)) + != H5FD_MIRROR_XMIT_REPLY_SIZE) + { + TEST_ERROR; + } + if (xmit_out.pub.magic != 0xFFFF0001) TEST_ERROR; + if (xmit_out.pub.version != 0x02) TEST_ERROR; + if (xmit_out.pub.session_token != 0x03040506) TEST_ERROR; + if (xmit_out.pub.xmit_count != 0x0708090A) TEST_ERROR; + if (xmit_out.pub.op != 0x0B) TEST_ERROR; + if (xmit_out.status != 0x0C0D0E0F) TEST_ERROR; + /* update expected "message" in structure */ + for (i=0x10; i < H5FD_MIRROR_STATUS_MESSAGE_MAX+0x10; i++) { + xmit_in.message[i-0x10] = (i > 0xFF) ? 0 : (char)i; + } + if (HDstrncmp(xmit_out.message, xmit_in.message, + H5FD_MIRROR_STATUS_MESSAGE_MAX) + != 0) + { + PRINT_BUFFER_DIFF(xmit_out.message, xmit_in.message, + H5FD_MIRROR_STATUS_MESSAGE_MAX); + TEST_ERROR; + } + + } while (0); /* end xmit reply en/decode */ + + /* Test xmit write structure encode/decode + * Write bogus but easily verifiable data to inside a buffer, and compare. + * Then decode the buffer and compare the structure contents. + * Then repeat from a different offset in the buffer and compare. + */ + do { + unsigned char buf[H5FD_MIRROR_XMIT_WRITE_SIZE+8]; + unsigned char expected[H5FD_MIRROR_XMIT_WRITE_SIZE+8]; + H5FD_mirror_xmit_write_t xmit_in; + H5FD_mirror_xmit_write_t xmit_out; + size_t i = 0; + + /* sanity check */ + if ((14+17) != H5FD_MIRROR_XMIT_WRITE_SIZE) { + FAIL_PUTS_ERROR("Header size definition does not match test\n"); + } + if (xmit_mock.op != 0x0D) { + FAIL_PUTS_ERROR("shared header structure is not in expected state"); + } + + /* Populate the expected buffer; expect end padding of 0xFF + */ + HDmemset(expected, 0xFF, H5FD_MIRROR_XMIT_WRITE_SIZE+8); + for (i=0; i < H5FD_MIRROR_XMIT_WRITE_SIZE; i++) { + expected[i+2] = (unsigned char)i; + } + + /* Set xmit_in + */ + xmit_in.pub = xmit_mock; /* shared/common */ + xmit_in.type = 0x0E; + xmit_in.offset = 0x0F10111213141516; + xmit_in.size = 0x1718191A1B1C1D1E; + + /* Encode, and compare buffer contents + * Initial buffer is filled with 0xFF to match expected padding + */ + HDmemset(buf, 0xFF, H5FD_MIRROR_XMIT_WRITE_SIZE+8); + if (H5FD_mirror_xmit_encode_write((buf+2), &xmit_in) + != H5FD_MIRROR_XMIT_WRITE_SIZE) + { + TEST_ERROR; + } + if (HDmemcmp(buf, expected, H5FD_MIRROR_XMIT_WRITE_SIZE+8) != 0) { + PRINT_BUFFER_DIFF(buf, expected, H5FD_MIRROR_XMIT_WRITE_SIZE+8); + TEST_ERROR; + } + + /* Decode from buffer + */ + if (H5FD_mirror_xmit_decode_write(&xmit_out, (buf+2)) + != H5FD_MIRROR_XMIT_WRITE_SIZE) + { + TEST_ERROR; + } + if (xmit_out.pub.magic != xmit_mock.magic) TEST_ERROR; + if (xmit_out.pub.version != xmit_mock.version) TEST_ERROR; + if (xmit_out.pub.session_token != xmit_mock.session_token) TEST_ERROR; + if (xmit_out.pub.xmit_count != xmit_mock.xmit_count) TEST_ERROR; + if (xmit_out.pub.op != xmit_mock.op) TEST_ERROR; + if (xmit_out.type != 0x0E) TEST_ERROR; + if (xmit_out.offset != 0x0F10111213141516) TEST_ERROR; + if (xmit_out.size != 0x1718191A1B1C1D1E) TEST_ERROR; + + /* Decode from different offset in buffer + * Observe changes when ingesting the padding + */ + if (H5FD_mirror_xmit_decode_write(&xmit_out, (buf)) + != H5FD_MIRROR_XMIT_WRITE_SIZE) + { + TEST_ERROR; + } + if (xmit_out.pub.magic != 0xFFFF0001) TEST_ERROR; + if (xmit_out.pub.version != 0x02) TEST_ERROR; + if (xmit_out.pub.session_token != 0x03040506) TEST_ERROR; + if (xmit_out.pub.xmit_count != 0x0708090A) TEST_ERROR; + if (xmit_out.pub.op != 0x0B) TEST_ERROR; + if (xmit_out.type != 0x0C) TEST_ERROR; + if (xmit_out.offset != 0x0D0E0F1011121314) TEST_ERROR; + if (xmit_out.size != 0x15161718191A1B1C) TEST_ERROR; + + } while (0); /* end xmit write en/decode */ + + PASSED(); + return 0; + +error: + return -1; +} /* end test_xmit_encode_decode */ + + +/* --------------------------------------------------------------------------- + * Function: create_mirroring_split_fapl + * + * Purpose: Create and populate a mirroring FAPL ID. + * Creates target files with the given base name -- ideally the + * test name -- and creates mirroring/split FAPL set to use the + * global mirroring info and a sec2 R/W channel driver. + * + * TODO: receive target IP from caller? + * + * Return: Success: HID of the top-level (splitter) FAPL, a non-negative + * value. + * Failure: H5I_INVALID_HID, a negative value. + * + * Programmer: Jacob Smith + * 2019 + * --------------------------------------------------------------------------- + */ +static hid_t +create_mirroring_split_fapl(const char *_basename, + struct mirrortest_filenames *names) +{ + H5FD_splitter_vfd_config_t splitter_config; + H5FD_mirror_fapl_t mirror_conf; + hid_t ret_value = H5I_INVALID_HID; + + if (_basename == NULL || *_basename == '\0') { + TEST_ERROR; + } + + splitter_config.magic = H5FD_SPLITTER_MAGIC; + splitter_config.version = H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION; + splitter_config.ignore_wo_errs = FALSE; + + /* Create Splitter R/W channel driver (sec2) + */ + splitter_config.rw_fapl_id = H5Pcreate(H5P_FILE_ACCESS); + if (H5I_INVALID_HID == splitter_config.rw_fapl_id) { + TEST_ERROR; + } + if (H5Pset_fapl_sec2(splitter_config.rw_fapl_id) == FAIL) { + TEST_ERROR; + } + + /* Create Splitter W/O channel driver (mirror) + */ + mirror_conf.magic = H5FD_MIRROR_FAPL_MAGIC; + mirror_conf.version = H5FD_MIRROR_CURR_FAPL_T_VERSION; + mirror_conf.handshake_port = SERVER_HANDSHAKE_PORT; + if (HDstrncpy(mirror_conf.remote_ip, SERVER_IP_ADDRESS, + H5FD_MIRROR_MAX_IP_LEN) + == NULL) + { + TEST_ERROR; + } + splitter_config.wo_fapl_id = H5Pcreate(H5P_FILE_ACCESS); + if (H5I_INVALID_HID == splitter_config.wo_fapl_id) { + TEST_ERROR; + } + if (H5Pset_fapl_mirror(splitter_config.wo_fapl_id, &mirror_conf) == FAIL) { + TEST_ERROR; + } + + /* Build r/w, w/o, and log file paths + */ + if (build_paths(_basename, &splitter_config, names) < 0) { + TEST_ERROR; + } + + /* Set file paths for w/o and logfile + */ + if (HDstrncpy(splitter_config.wo_path, (const char *)names->wo, + H5FD_SPLITTER_PATH_MAX) + == NULL) + { + TEST_ERROR; + } + if (HDstrncpy(splitter_config.log_file_path, (const char *)names->log, + H5FD_SPLITTER_PATH_MAX) + == NULL) + { + TEST_ERROR; + } + + /* Create Splitter FAPL + */ + ret_value = H5Pcreate(H5P_FILE_ACCESS); + if (H5I_INVALID_HID == ret_value) { + TEST_ERROR; + } + if (H5Pset_fapl_splitter(ret_value, &splitter_config) == FAIL) { + TEST_ERROR; + } + + /* Close FAPLs created for child channels + */ + if (H5Pclose(splitter_config.rw_fapl_id) < 0) { + TEST_ERROR; + } + splitter_config.rw_fapl_id = H5I_INVALID_HID; + if (H5Pclose(splitter_config.wo_fapl_id) < 0) { + TEST_ERROR; + } + splitter_config.wo_fapl_id = H5I_INVALID_HID; + + return ret_value; + +error: + if (splitter_config.wo_fapl_id >= 0) { + (void)H5Pclose(splitter_config.wo_fapl_id); + } + if (splitter_config.rw_fapl_id >= 0) { + (void)H5Pclose(splitter_config.rw_fapl_id); + } + if (ret_value >= 0) { + (void)H5Pclose(ret_value); + } + return H5I_INVALID_HID; +} /* end create_mirroring_split_fapl() */ + + +/* --------------------------------------------------------------------------- + * Function: test_create_and_close + * + * Purpose: Test/demonstrate a do-nothing file open and close. + * + * Verifying file existence and contents is part of other tests. + * + * TODO: receive target IP from caller? + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Jacob Smith + * 2019-12-17 + * --------------------------------------------------------------------------- + */ +static int +test_create_and_close(void) +{ + struct mirrortest_filenames names; + hid_t file_id = H5I_INVALID_HID; + hid_t fapl_id = H5P_DEFAULT; + + TESTING("File creation and immediate close"); + + /* Create FAPL for Splitter[sec2|mirror] + */ + fapl_id = create_mirroring_split_fapl("basic_create", &names); + if (H5I_INVALID_HID == fapl_id) { + TEST_ERROR; + } + + /* -------------------- */ + /* TEST: Create and Close */ + + file_id = H5Fcreate(names.rw, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + if (H5I_INVALID_HID == file_id) { + TEST_ERROR; + } + + /* -------------------- */ + /* Standard cleanup */ + + if (H5Fclose(file_id) == FAIL) { + TEST_ERROR; + } + if (fapl_id != H5P_DEFAULT && fapl_id >= 0) { + if (H5Pclose(fapl_id) == FAIL) { + TEST_ERROR; + } + } + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY{ + (void)H5Fclose(file_id); + (void)H5Pclose(fapl_id); + } H5E_END_TRY; + return -1; +} /* end test_create_and_close() */ + + +/* ---------------------------------------------------------------------------- + * Function: create_datasets + * + * Purpose: Given a file ID and least and greateset dataset indices, create + * populated chunked datasets in the target file from min_dset to + * (and including) max_dset. + * Uses #defined constants to determine chunk and dataset sizes + * and values. + * + * Return: SUCCEED/FAIL + * + * Programmer: Jacob Smith + * 2019-08-14 + * ---------------------------------------------------------------------------- + */ +static herr_t +create_datasets(hid_t file_id, + unsigned min_dset, + unsigned max_dset) +{ + hid_t dataspace_ids[MAX_DSET_COUNT + 1]; + hid_t dataset_ids[MAX_DSET_COUNT + 1]; + hid_t filespace_ids[MAX_DSET_COUNT + 1]; + int data_chunk[CHUNK_DIM][CHUNK_DIM]; + unsigned int i, j, k, l, m; + hsize_t offset[2]; + hid_t memspace_id = H5I_INVALID_HID; + hsize_t a_size[2] = {CHUNK_DIM, CHUNK_DIM}; + hsize_t chunk_dims[2] = {CHUNK_DIM, CHUNK_DIM}; + hsize_t dset_dims[2] = {DSET_DIM, DSET_DIM}; + + HDassert(file_id >= 0); + HDassert(min_dset <= max_dset); + HDassert(max_dset <= MAX_DSET_COUNT); + + LOGPRINT(2, "create_dataset()\n"); + + /* --------------------------------- + * "Clear" ID arrays + */ + + for (i = 0; i < MAX_DSET_COUNT; i++) { + LOGPRINT(3, "clearing IDs [%d]\n", i); + dataspace_ids[i] = H5I_INVALID_HID; + dataset_ids[i] = H5I_INVALID_HID; + filespace_ids[i] = H5I_INVALID_HID; + } + + /* --------------------------------- + * Generate dataspace, dataset, and 'filespace' IDs + */ + + if (_create_chunking_ids(file_id, min_dset, max_dset, chunk_dims, + dset_dims, dataspace_ids, filespace_ids, dataset_ids, &memspace_id) + == FAIL) + { + TEST_ERROR; + } + + /* --------------------------------- + * Initialize (write) all datasets in a "round robin"... + * for a given chunk 'location', write chunk data to each dataset. + */ + + for (i = 0; i < DSET_DIM; i += CHUNK_DIM) + { + LOGPRINT(3, "i: %d\n", i); + for (j = 0; j < DSET_DIM; j += CHUNK_DIM) + { + LOGPRINT(3, " j: %d\n", j); + for (m = min_dset; m <= max_dset; m++) + { + LOGPRINT(3, " m: %d\n", m); + for (k = 0; k < CHUNK_DIM; k++) + { + for (l = 0; l < CHUNK_DIM; l++) + { + data_chunk[k][l] = (int)((DSET_DIM * DSET_DIM * m) + + (DSET_DIM * (i + k)) + j + l); + LOGPRINT(3, " data_chunk[%d][%d]: %d\n", + k, l, data_chunk[k][l]); + } + } + + /* select on disk hyperslab */ + offset[0] = (hsize_t)i; + offset[1] = (hsize_t)j; + LOGPRINT(3, " H5Sselect_hyperslab()\n"); + if (H5Sselect_hyperslab(filespace_ids[m], H5S_SELECT_SET, + offset, NULL, a_size, NULL) + < 0) + { + TEST_ERROR; + } + + LOGPRINT(3, " H5Dwrite()\n"); + if (H5Dwrite(dataset_ids[m], H5T_NATIVE_INT, memspace_id, + filespace_ids[m], H5P_DEFAULT, data_chunk) + < 0) + { + TEST_ERROR; + } + + } + } + } + + /* --------------------------------- + * Read and verify data from datasets + */ + + if (_verify_datasets(min_dset, max_dset, filespace_ids, dataset_ids, + memspace_id) + == FAIL) + { + TEST_ERROR; + } + + /* --------------------------------- + * Cleanup + */ + + if (_close_chunking_ids(min_dset, max_dset, dataspace_ids, filespace_ids, + dataset_ids, &memspace_id) + == FAIL) + { + TEST_ERROR; + } + + return SUCCEED; + +error: + (void)_close_chunking_ids(min_dset, max_dset, dataspace_ids, + filespace_ids, dataset_ids, &memspace_id); + LOGPRINT(1, "create_datasets() FAILED\n"); + return FAIL; +} /* end create_datasets() */ + + +/* ---------------------------------------------------------------------------- + * Function: _create_chunking_ids + * + * Purpose: Create new IDs to be used with the associated file. + * + * Return: SUCCEED/FAIL + * + * Programer: Jacob Smith + * 2019 + * ---------------------------------------------------------------------------- + */ +static herr_t +_create_chunking_ids(hid_t file_id, + unsigned min_dset, + unsigned max_dset, + hsize_t *chunk_dims, + hsize_t *dset_dims, + hid_t *dataspace_ids, + hid_t *filespace_ids, + hid_t *dataset_ids, + hid_t *memspace_id) +{ + char dset_name[DSET_NAME_LEN + 1]; + unsigned m = 0; + hid_t dcpl_id = H5I_INVALID_HID; + + LOGPRINT(2, "_create_chunking_ids()\n"); + + /* -------------------- + * Create chunking DCPL + */ + + dcpl_id = H5Pcreate(H5P_DATASET_CREATE); + if (dcpl_id < 0) { + TEST_ERROR; + } + if (H5Pset_chunk(dcpl_id, 2, chunk_dims) == FAIL) { + TEST_ERROR; + } + + /* -------------------- + * Create dataspace IDs + */ + + for (m = min_dset; m <= max_dset; m++) { + dataspace_ids[m] = H5Screate_simple(2, dset_dims, NULL); + if (dataspace_ids[m] < 0) { + HDsnprintf(mesg, MIRR_MESG_SIZE, + "unable to create dataspace ID %d\n", m); + FAIL_PUTS_ERROR(mesg); + } + } + + /* -------------------- + * Create dataset IDs + */ + + for (m = min_dset; m <= max_dset; m++) { + if (HDsnprintf(dset_name, DSET_NAME_LEN, "/dset%03d", m) + > DSET_NAME_LEN) + { + HDsnprintf(mesg, MIRR_MESG_SIZE, + "unable to compose dset name %d\n", m); + FAIL_PUTS_ERROR(mesg); + } + + dataset_ids[m] = H5Dcreate(file_id, dset_name, H5T_STD_I32BE, + dataspace_ids[m], H5P_DEFAULT, dcpl_id, H5P_DEFAULT); + if (dataset_ids[m] < 0) { + HDsnprintf(mesg, MIRR_MESG_SIZE, + "unable to create dset ID %d\n", m); + FAIL_PUTS_ERROR(mesg); + } + } + + /* -------------------- + * Get file space IDs + */ + + for (m = min_dset; m <= max_dset; m++) { + filespace_ids[m] = H5Dget_space(dataset_ids[m]); + if (filespace_ids[m] < 0) { + HDsnprintf(mesg, MIRR_MESG_SIZE, + "unable to create filespace ID %d\n", m); + FAIL_PUTS_ERROR(mesg); + } + } + + /* -------------------- + * Create mem space to be used to read and write chunks + */ + + *memspace_id = H5Screate_simple(2, chunk_dims, NULL); + if (*memspace_id < 0) { + TEST_ERROR; + } + + /* -------------------- + * Clean up the DCPL, even if there were errors before + */ + + if (dcpl_id != H5P_DEFAULT && dcpl_id != H5I_INVALID_HID) { + if (H5Pclose(dcpl_id) == FAIL) { + TEST_ERROR; + } + } + + return SUCCEED; + +error: + if (dcpl_id != H5P_DEFAULT && dcpl_id != H5I_INVALID_HID) { + (void)H5Pclose(dcpl_id); + } + LOGPRINT(1, "_create_chunking_ids() FAILED\n"); + return FAIL; +} /* end _create_chunking_ids() */ + + +/* ---------------------------------------------------------------------------- + * Function: _open_chunking_ids + * + * Purpose: Open/access IDs from the given file. + * + * Return: SUCCEED/FAIL + * + * Programmer: Jacob Smith + * 2019 + * ---------------------------------------------------------------------------- + */ +static herr_t +_open_chunking_ids( + hid_t file_id, + unsigned min_dset, + unsigned max_dset, + hsize_t *chunk_dims, + hid_t *filespace_ids, + hid_t *dataset_ids, + hid_t *memspace_id) +{ + char dset_name[DSET_NAME_LEN+1]; + unsigned m = 0; + + LOGPRINT(2, "_open_chunking_ids()\n"); + + /* -------------------- + * Open dataset IDs + */ + + for (m = min_dset; m <= max_dset; m++) { + if (HDsnprintf(dset_name, DSET_NAME_LEN, "/dset%03d", m) + > DSET_NAME_LEN) + { + HDsnprintf(mesg, MIRR_MESG_SIZE, + "unable to compose dset name %d\n", m); + FAIL_PUTS_ERROR(mesg); + } + + dataset_ids[m] = H5Dopen2(file_id, dset_name, H5P_DEFAULT); + if (dataset_ids[m] < 0) { + HDsnprintf(mesg, MIRR_MESG_SIZE, "unable to open dset ID %d\n", m); + FAIL_PUTS_ERROR(mesg); + } + } + + /* -------------------- + * Open filespace IDs + */ + + for (m = min_dset; m <= max_dset; m++) { + filespace_ids[m] = H5Dget_space(dataset_ids[m]); + if (filespace_ids[m] < 0) { + HDsnprintf(mesg, MIRR_MESG_SIZE, + "unable to get filespace ID %d\n", m); + FAIL_PUTS_ERROR(mesg); + } + } + + /* -------------------- + * Create mem space to be used to read and write chunks + */ + + *memspace_id = H5Screate_simple(2, chunk_dims, NULL); + if (*memspace_id < 0) { + TEST_ERROR; + } + + return SUCCEED; + +error: + LOGPRINT(1, "_open_chunking_ids() FAILED\n"); + return FAIL; +} /* end _open_chunking_ids() */ + + +/* --------------------------------------------------------------------------- + * Function: _close_chunking_ids + * + * Purpose: Close IDs that were created or opened. + * Pass NULL into `dataspace_ids` when closing items opened with + * _open_chunking_ids(). (as opposed to created IDs) + * + * Return: SUCCEED/FAIL + * + * Programmer: Jacob Smith + * 2019 + * --------------------------------------------------------------------------- + */ +static herr_t +_close_chunking_ids(unsigned min_dset, + unsigned max_dset, + hid_t *dataspace_ids, + hid_t *filespace_ids, + hid_t *dataset_ids, + hid_t *memspace_id) +{ + unsigned m; + + LOGPRINT(2, "_close_chunking_ids()\n"); + + for (m = min_dset; m <= max_dset; m++) { + LOGPRINT(3, "closing ids[%d]\n", m); + if (dataspace_ids) { + if (H5Sclose(dataspace_ids[m]) < 0) { + HDsnprintf(mesg, MIRR_MESG_SIZE, + "unable to close dataspace_id[%d]\n", m); + FAIL_PUTS_ERROR(mesg); + } + } + if (H5Dclose(dataset_ids[m]) < 0) { + HDsnprintf(mesg, MIRR_MESG_SIZE, + "unable to close dataset_id[%d]\n", m); + FAIL_PUTS_ERROR(mesg); + } + if (H5Sclose(filespace_ids[m]) < 0) { + HDsnprintf(mesg, MIRR_MESG_SIZE, + "unable to close filespace_id[%d]\n", m); + FAIL_PUTS_ERROR(mesg); + } + } + + if ( (*memspace_id != H5I_INVALID_HID) && + (H5Sclose(*memspace_id) < 0) ) + { + TEST_ERROR; + } + + return SUCCEED; + +error: + LOGPRINT(1, "_close_chunking_ids() FAILED\n"); + return FAIL; +} /* end _close_chunking_ids() */ + + +/* --------------------------------------------------------------------------- + * Function: _verify_datasets + * + * Purpose: Check that each chunk's contents are as expected, as pertaining + * to create_datasets(). + * + * Return: SUCCEED/FAIL + * + * Programmer: Jacob Smith + * 2019 + * --------------------------------------------------------------------------- + */ +static herr_t +_verify_datasets(unsigned min_dset, + unsigned max_dset, + hid_t *filespace_ids, + hid_t *dataset_ids, + hid_t memspace_id) +{ + unsigned i, j, k, l, m; + int data_chunk[CHUNK_DIM][CHUNK_DIM]; + hsize_t offset[2]; + hsize_t a_size[2] = {CHUNK_DIM, CHUNK_DIM}; + + LOGPRINT(2, "_verify_datasets()\n"); + + for (i = 0; i < DSET_DIM; i += CHUNK_DIM) + { + LOGPRINT(3, "i: %d\n", i); + for (j = 0; j < DSET_DIM; j += CHUNK_DIM) + { + LOGPRINT(3, " j: %d\n", j); + for (m = min_dset; m <= max_dset; m++) + { + LOGPRINT(3, " m: %d\n", m); + + /* select on disk hyperslab */ + offset[0] = (hsize_t)i; + offset[1] = (hsize_t)j; + if (H5Sselect_hyperslab(filespace_ids[m], H5S_SELECT_SET, + offset, NULL, a_size, NULL) + < 0) + { + TEST_ERROR; + } + + if (H5Dread(dataset_ids[m], H5T_NATIVE_INT, memspace_id, + filespace_ids[m], H5P_DEFAULT, data_chunk) + < 0) + { + HDsnprintf(mesg, MIRR_MESG_SIZE, + " H5Dread() [%d][%d][%d]\n", + i, j, m); + FAIL_PUTS_ERROR(mesg); + } + + for (k = 0; k < CHUNK_DIM; k++) { + for (l = 0; l < CHUNK_DIM; l++) { + if ((unsigned)data_chunk[k][l] + != + ((DSET_DIM * DSET_DIM * m) + + (DSET_DIM * (i + k)) + j + l)) + { + HDsnprintf(mesg, MIRR_MESG_SIZE, + " MISMATCH [%d][%d][%d][%d][%d]\n", + i, j, m, k, l); + FAIL_PUTS_ERROR(mesg); + } + } + } + + } + } + } + + return SUCCEED; + +error: + LOGPRINT(1, "_verify_datasets() FAILED\n"); + return FAIL; +} /* end _verify_datasets() */ + + +/* --------------------------------------------------------------------------- + * Function: verify_datasets + * + * Purpose: Inspect the datasets in the file created by create_datasets(). + * Wrapper for _verify_datasets() -- this function sets up and + * tears down accessor information. + * + * Return: SUCCEED/FAIL + * + * Programmer: Jacob Smith + * 2019 + * --------------------------------------------------------------------------- + */ +static herr_t +verify_datasets(hid_t file_id, + unsigned min_dset, + unsigned max_dset) +{ + hid_t dataset_ids[MAX_DSET_COUNT + 1]; + hid_t filespace_ids[MAX_DSET_COUNT + 1]; + unsigned i; + hid_t memspace_id = H5I_INVALID_HID; + hsize_t chunk_dims[2] = {CHUNK_DIM, CHUNK_DIM}; + + HDassert(file_id >= 0); + HDassert(min_dset <= max_dset); + HDassert(max_dset <= MAX_DSET_COUNT); + + LOGPRINT(2, "verify_datasets()\n"); + + /* --------------------------------- + * "Clear" ID arrays + */ + + for (i = 0; i < MAX_DSET_COUNT; i++) { + LOGPRINT(3, "clearing IDs [%d]\n", i); + dataset_ids[i] = H5I_INVALID_HID; + filespace_ids[i] = H5I_INVALID_HID; + } + + /* --------------------------------- + * Generate dataspace, dataset, and 'filespace' IDs + */ + + if (_open_chunking_ids(file_id, min_dset, max_dset, chunk_dims, + filespace_ids, dataset_ids, &memspace_id) + == FAIL) + { + TEST_ERROR; + } + + /* --------------------------------- + * Read and verify data from datasets + */ + + if (_verify_datasets(min_dset, max_dset, filespace_ids, dataset_ids, + memspace_id) + == FAIL) + { + TEST_ERROR; + } + + /* --------------------------------- + * Cleanup + */ + + if (_close_chunking_ids(min_dset, max_dset, NULL, filespace_ids, + dataset_ids, &memspace_id) + == FAIL) + { + TEST_ERROR; + } + + return SUCCEED; + +error: + LOGPRINT(1, "verify_datasets() FAILED\n"); + (void)_close_chunking_ids(min_dset, max_dset, NULL, filespace_ids, + dataset_ids, &memspace_id); + return FAIL; + +} /* end verify_datasets() */ + + +/* --------------------------------------------------------------------------- + * Function: test_basic_dataset_write + * + * Purpose: Create and close files; repoen files and write a dataset, + * close; compare files. + * + * TODO: receive target IP from caller? + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Jacob Smith + * 2019 + * --------------------------------------------------------------------------- + */ +static int +test_basic_dataset_write(void) +{ + struct mirrortest_filenames names; + hid_t file_id = H5I_INVALID_HID; + hid_t fapl_id = H5P_DEFAULT; + hid_t dset_id = H5I_INVALID_HID; + hid_t dspace_id = H5I_INVALID_HID; + hid_t dtype_id = H5T_NATIVE_INT; + hsize_t dims[2] = { DATABUFFER_SIZE, DATABUFFER_SIZE }; + int *buf = NULL; + int i = 0; + int j = 0; + + TESTING("Mirror open and dataset writing"); + + /* Create FAPL for Splitter[sec2|mirror] + */ + fapl_id = create_mirroring_split_fapl("basic_write", &names); + if (H5I_INVALID_HID == fapl_id) { + TEST_ERROR; + } + + /* Prepare data to be written + */ + buf = (int *)HDmalloc(DATABUFFER_SIZE * DATABUFFER_SIZE * sizeof(int)); + if (NULL == buf) { + TEST_ERROR; + } + for (i = 0; i < DATABUFFER_SIZE; i++) { + for (j = 0; j < DATABUFFER_SIZE; j++) { + int k = i * DATABUFFER_SIZE + j; + buf[k] = k; + } + } + + /* -------------------- */ + /* TEST: Create and Close */ + + file_id = H5Fcreate(names.rw, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + if (H5I_INVALID_HID == file_id) { + TEST_ERROR; + } + if (H5Fclose(file_id) == FAIL) { + TEST_ERROR; + } + file_id = H5I_INVALID_HID; + + + /* -------------------- */ + /* TEST: Repoen and Write */ + + file_id = H5Fopen(names.rw, H5F_ACC_RDWR, fapl_id); + if (H5I_INVALID_HID == file_id) { + TEST_ERROR; + } + + dspace_id = H5Screate_simple(2, dims, NULL); + if (H5I_INVALID_HID == dspace_id) { + TEST_ERROR; + } + dset_id = H5Dcreate2(file_id, "dataset", dtype_id, dspace_id, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT); + if (H5I_INVALID_HID == dset_id) { + TEST_ERROR; + } + + if (H5Dwrite(dset_id, dtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) + == FAIL) + { + TEST_ERROR; + } + + /* -------------------- */ + /* Standard cleanup */ + + HDfree(buf); + buf = NULL; + if (H5Dclose(dset_id) == FAIL) { + TEST_ERROR; + } + if (H5Sclose(dspace_id) == FAIL) { + TEST_ERROR; + } + if (H5Fclose(file_id) == FAIL) { + TEST_ERROR; + } + if (fapl_id != H5P_DEFAULT && fapl_id > 0) { + if (H5Pclose(fapl_id) == FAIL) { + TEST_ERROR; + } + } + + /* -------------------- */ + /* TEST: Verify that the R/W and W/O files are identical */ + + if (h5_compare_file_bytes(names.rw, names.wo) < 0) { + TEST_ERROR; + } + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY{ + (void)H5Fclose(file_id); + if (buf) { + HDfree(buf); + } + (void)H5Dclose(dset_id); + (void)H5Sclose(dspace_id); + if (fapl_id != H5P_DEFAULT && fapl_id > 0) { + (void)H5Pclose(fapl_id); + } + } H5E_END_TRY; + return -1; +} /* end test_basic_dataset_write() */ + + +/* --------------------------------------------------------------------------- + * Function: test_chunked_dataset_write + * + * Purpose: Create and close files; repoen files and write a dataset, + * close; compare files. + * + * TODO: receive target IP from caller? + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Jacob Smith + * 2019 + * --------------------------------------------------------------------------- + */ +static int +test_chunked_dataset_write(void) +{ + struct mirrortest_filenames names; + hid_t file_id = H5I_INVALID_HID; + hid_t fapl_id = H5P_DEFAULT; + + TESTING("Mirror open and dataset writing (chunked)"); + + /* Create FAPL for Splitter[sec2|mirror] + */ + fapl_id = create_mirroring_split_fapl("chunked_write", &names); + if (H5I_INVALID_HID == fapl_id) { + TEST_ERROR; + } + + /* -------------------- */ + /* TEST: Create and Close */ + + file_id = H5Fcreate(names.rw, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + if (H5I_INVALID_HID == file_id) { + TEST_ERROR; + } + if (H5Fclose(file_id) == FAIL) { + TEST_ERROR; + } + file_id = H5I_INVALID_HID; + + /* -------------------- */ + /* TEST: Reopen and Write */ + + file_id = H5Fopen(names.rw, H5F_ACC_RDWR, fapl_id); + if (H5I_INVALID_HID == file_id) { + TEST_ERROR; + } + + /* Write datasets to file + */ + if (create_datasets(file_id, 0, MAX_DSET_COUNT) == FAIL) { + TEST_ERROR; + } + + /* Close to 'flush to disk', and reopen file + */ + if (H5Fclose(file_id) == FAIL) { + TEST_ERROR; + } + file_id = H5I_INVALID_HID; + + /* Reopen file + */ + file_id = H5Fopen(names.rw, H5F_ACC_RDWR, fapl_id); + if (H5I_INVALID_HID == file_id) { + TEST_ERROR; + } + + /* Verify written data integrity + */ + if (verify_datasets(file_id, 0, MAX_DSET_COUNT) == FAIL) { + TEST_ERROR; + } + + /* -------------------- */ + /* Standard cleanup */ + + if (H5Fclose(file_id) == FAIL) { + TEST_ERROR; + } + file_id = H5I_INVALID_HID; + if (fapl_id != H5P_DEFAULT && fapl_id > 0) { + if (H5Pclose(fapl_id) == FAIL) { + TEST_ERROR; + } + fapl_id = H5I_INVALID_HID; + } + + /* -------------------- */ + /* TEST: Verify that the R/W and W/O files are identical */ + + if (h5_compare_file_bytes(names.rw, names.wo) < 0) { + TEST_ERROR; + } + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + (void)H5Fclose(file_id); + if (fapl_id != H5P_DEFAULT && fapl_id > 0) { + (void)H5Pclose(fapl_id); + } + } H5E_END_TRY; + return -1; +} /* end test_chunked_dataset_write() */ + + +/* --------------------------------------------------------------------------- + * Function: test_on_disk_zoo + * + * Purpose: Verify that the mirror can handle the passing of all the + * various on-disk data structures over the wire, as implemented + * in genall5.c:create_zoo(). + * + * TODO: receive target IP from caller? + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Jacob Smith + * 2019 + * --------------------------------------------------------------------------- + */ +static int +test_on_disk_zoo(void) +{ + const char grp_name[] = "/only"; + struct mirrortest_filenames names; + hid_t file_id = H5I_INVALID_HID; + hid_t grp_id = H5I_INVALID_HID; + hid_t fapl_id = H5P_DEFAULT; + + TESTING("'Zoo' of on-disk structures"); + + /* Create FAPL for Splitter[sec2|mirror] + */ + fapl_id = create_mirroring_split_fapl("zoo", &names); + if (H5I_INVALID_HID == fapl_id) { + TEST_ERROR; + } + + /* -------------------- */ + /* TEST: Create file */ + file_id = H5Fcreate(names.rw, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + if (H5I_INVALID_HID == file_id) { + TEST_ERROR; + } + + grp_id = H5Gcreate2(file_id, grp_name, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT); + if (grp_id == H5I_INVALID_HID) { + TEST_ERROR; + } + + /* Create datasets in file, close (flush) and reopen, validate. + * Use of ( pass ) a conceit required for using create_ and validate_zoo() + * from cache_common and/or genall5. + */ + + if ( pass ) { + create_zoo(file_id, grp_name, 0); + } + if ( pass ) { + if (H5Fclose(file_id) == FAIL) { + TEST_ERROR; + } + file_id = H5Fopen(names.rw, H5F_ACC_RDWR, fapl_id); + if (H5I_INVALID_HID == file_id) { + TEST_ERROR; + } + } + if ( pass ) { + validate_zoo(file_id, grp_name, 0); /* sanity-check */ + } + if ( !pass ) { + HDprintf(failure_mssg); + TEST_ERROR; + } + + /* -------------------- */ + /* Standard cleanup */ + + if (fapl_id != H5P_DEFAULT && fapl_id >= 0) { + if (H5Pclose(fapl_id) == FAIL) { + TEST_ERROR; + } + } + if (H5Gclose(grp_id) == FAIL) { + TEST_ERROR; + } + if (H5Fclose(file_id) == FAIL) { + TEST_ERROR; + } + + /* -------------------- */ + /* TEST: Verify that the R/W and W/O files are identical */ + + if (h5_compare_file_bytes(names.rw, names.wo) < 0) { + TEST_ERROR; + } + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + (void)H5Fclose(file_id); + (void)H5Gclose(grp_id); + if (fapl_id != H5P_DEFAULT && fapl_id > 0) { + (void)H5Pclose(fapl_id); + } + } H5E_END_TRY; + return -1; +} /* end test_on_disk_zoo() */ + + +/* --------------------------------------------------------------------------- + * Function: test_vanishing_datasets + * + * Purpose: Verify behavior when writing to a file where data is deleted. + * + * Each dataset is populated with the value of its suffix + * (dset5 is all fives). + * + * Opens 0..15 create one new dataset each, '/dset[i]'. + * Opens 3..18 delete '/dset[1-3]' + * + * Should end with no data in file. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Jacob Smith + * 2019 + * --------------------------------------------------------------------------- + */ +static int +test_vanishing_datasets(void) +{ + struct mirrortest_filenames names; + hid_t file_id = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t dspace_id = H5I_INVALID_HID; + hid_t mirror_fapl_id = H5I_INVALID_HID; + hsize_t dims[2] = {DATABUFFER_SIZE, DATABUFFER_SIZE}; + uint32_t buf[DATABUFFER_SIZE][DATABUFFER_SIZE]; /* consider malloc? */ + H5G_info_t group_info; + unsigned int i, j, k; + const unsigned int max_loops = 20; + const unsigned int max_at_one_time = 3; + + TESTING("Vanishing Datasets"); + + /* -------------------- */ + /* Set up recurrent data (FAPL, dataspace) */ + + /* Create FAPL for Splitter[sec2|mirror] + */ + fapl_id = create_mirroring_split_fapl("vanishing", &names); + if (H5I_INVALID_HID == fapl_id) { + TEST_ERROR; + } + + dspace_id = H5Screate_simple(2, dims, NULL); + if (dspace_id < 0) { + TEST_ERROR; + } + + /* create file */ + file_id = H5Fcreate(names.rw, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + if (H5I_INVALID_HID == file_id) { + TEST_ERROR; + } + + for (i=0; i < max_loops; i++) { + char namebuf[DSET_NAME_LEN + 1]; + + /* deleting datasets */ + if (i >= max_at_one_time) { + if (HDsnprintf(namebuf, DSET_NAME_LEN, "/dset%02d", + (i - max_at_one_time) ) + > DSET_NAME_LEN) + { + TEST_ERROR; + } + if (H5Ldelete(file_id, namebuf, H5P_DEFAULT) < 0) { + TEST_ERROR; + } + } /* end if deleting a dataset */ + + /* writing datasets */ + if (i < (max_loops - max_at_one_time)) { + if (HDsnprintf(namebuf, DSET_NAME_LEN, "/dset%02d", i) + > DSET_NAME_LEN) + { + TEST_ERROR; + } + dset_id = H5Dcreate2(file_id, namebuf, H5T_STD_U32LE, dspace_id, + H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (H5I_INVALID_HID == dset_id) { + TEST_ERROR; + } + + for (j=0; j < DATABUFFER_SIZE; j++) { + for (k=0; k < DATABUFFER_SIZE; k++) { + buf[j][k] = (uint32_t)i; + } + } + + if (H5Dwrite(dset_id, H5T_STD_U32LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, + buf) + < 0) + { + TEST_ERROR; + } + + if (H5Dclose(dset_id) < 0) { + TEST_ERROR; + } + dset_id = H5I_INVALID_HID; + } /* end if writing a dataset */ + + } /* end for dataset create-destroy cycles */ + + if (H5Fclose(file_id) < 0) { + TEST_ERROR; + } + file_id = H5I_INVALID_HID; + + /* verify there are no datasets in file */ + file_id = H5Fopen(names.rw, H5F_ACC_RDONLY, H5P_DEFAULT); + if (file_id < 0) { + TEST_ERROR; + } + if (H5Gget_info(file_id, &group_info) < 0) { + TEST_ERROR; + } + if (group_info.nlinks > 0) { + HDfprintf(stderr, "links in rw file: %d\n", group_info.nlinks); + HDfflush(stderr); + TEST_ERROR; + } + if (H5Fclose(file_id) < 0) { + TEST_ERROR; + } + file_id = H5Fopen(names.wo, H5F_ACC_RDONLY, H5P_DEFAULT); + if (file_id < 0) { + TEST_ERROR; + } + if (H5Gget_info(file_id, &group_info) < 0) { + TEST_ERROR; + } + if (group_info.nlinks > 0) { + HDfprintf(stderr, "links in wo file: %d\n", group_info.nlinks); + HDfflush(stderr); + TEST_ERROR; + } + if (H5Fclose(file_id) < 0) { + TEST_ERROR; + } + file_id = H5I_INVALID_HID; + + if (h5_compare_file_bytes(names.rw, names.wo) < 0) + TEST_ERROR; + + /* -------------------- */ + /* Teardown */ + + if (H5Sclose(dspace_id) < 0) { + TEST_ERROR; + } + if (H5Pclose(fapl_id) < 0) { + TEST_ERROR; + } + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + if (mirror_fapl_id != H5I_INVALID_HID) { + H5Pclose(mirror_fapl_id); + } + if (fapl_id != H5I_INVALID_HID) { + H5Pclose(fapl_id); + } + if (file_id != H5I_INVALID_HID) { + H5Fclose(file_id); + } + if (dset_id != H5I_INVALID_HID) { + H5Dclose(dset_id); + } + if (dspace_id != H5I_INVALID_HID) { + H5Sclose(dspace_id); + } + } H5E_END_TRY; + return -1; +} /* test_vanishing_datasets() */ + + +/* --------------------------------------------------------------------------- + * Function: test_concurrent_access + * + * Purpose: Verify that more than one file may be opened at a time. + * + * TODO: receive target IP from caller? + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Jacob Smith + * 2020-03-09 + * --------------------------------------------------------------------------- + */ +static int +test_concurrent_access(void) +{ + struct file_bundle { + struct mirrortest_filenames names; + hid_t dset_id; + hid_t fapl_id; + hid_t file_id; + } bundle[CONCURRENT_COUNT]; + hid_t dspace_id = H5I_INVALID_HID; + hid_t dtype_id = H5T_NATIVE_INT; + hsize_t dims[2] = { DATABUFFER_SIZE, DATABUFFER_SIZE }; + int *buf = NULL; + int i = 0; + int j = 0; + + TESTING("Concurrent opened mirrored files"); + + /* blank bundle */ + for (i = 0; i < CONCURRENT_COUNT; i++) { + bundle[i].dset_id = H5I_INVALID_HID; + bundle[i].fapl_id = H5I_INVALID_HID; + bundle[i].file_id = H5I_INVALID_HID; + *bundle[i].names.rw = '\0'; + *bundle[i].names.wo = '\0'; + *bundle[i].names.log = '\0'; + } + + /* Create FAPL for Splitter[sec2|mirror] + */ + for (i = 0; i < CONCURRENT_COUNT; i++) { + char _name[16] = ""; + hid_t _fapl_id = H5I_INVALID_HID; + HDsnprintf(_name, 15, "concurrent%d", i); + _fapl_id = create_mirroring_split_fapl(_name, &bundle[i].names); + if (H5I_INVALID_HID == _fapl_id) { + TEST_ERROR; + } + bundle[i].fapl_id = _fapl_id; + } + + /* Prepare data to be written + */ + buf = (int *)HDmalloc(DATABUFFER_SIZE * DATABUFFER_SIZE * sizeof(int)); + if (NULL == buf) { + TEST_ERROR; + } + for (i = 0; i < DATABUFFER_SIZE; i++) { + for (j = 0; j < DATABUFFER_SIZE; j++) { + int k = i * DATABUFFER_SIZE + j; + buf[k] = k; + } + } + + /* Prepare generic dataspace + */ + dspace_id = H5Screate_simple(2, dims, NULL); + if (H5I_INVALID_HID == dspace_id) { + TEST_ERROR; + } + + /* -------------------- */ + /* TEST: Create file and open elements */ + + for (i = 0; i < CONCURRENT_COUNT; i++) { + hid_t _file_id = H5I_INVALID_HID; + hid_t _dset_id = H5I_INVALID_HID; + + _file_id = H5Fcreate(bundle[i].names.rw, H5F_ACC_TRUNC, H5P_DEFAULT, + bundle[i].fapl_id); + if (H5I_INVALID_HID == _file_id) { + TEST_ERROR; + } + + bundle[i].file_id = _file_id; + + _dset_id = H5Dcreate2(_file_id, "dataset", dtype_id, dspace_id, + H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (H5I_INVALID_HID == _dset_id) { + TEST_ERROR; + } + bundle[i].dset_id = _dset_id; + } + + /* -------------------- */ + /* TEST: Write to files */ + + for (i = 0; i < CONCURRENT_COUNT; i++) { + if (H5Dwrite(bundle[i].dset_id, dtype_id, H5S_ALL, H5S_ALL, + H5P_DEFAULT, buf) + == FAIL) + { + TEST_ERROR; + } + } + + /* -------------------- */ + /* TEST: Close elements */ + + for (i = 0; i < CONCURRENT_COUNT; i++) { + if (H5Dclose(bundle[i].dset_id) == FAIL) { + TEST_ERROR; + } + if (H5Fclose(bundle[i].file_id) == FAIL) { + TEST_ERROR; + } + if (H5Pclose(bundle[i].fapl_id) == FAIL) { + TEST_ERROR; + } + } + + /* -------------------- */ + /* Standard cleanup */ + + HDfree(buf); + buf = NULL; + if (H5Sclose(dspace_id) == FAIL) { + TEST_ERROR; + } + + /* -------------------- */ + /* TEST: Verify that the R/W and W/O files are identical */ + + for (i = 0; i < CONCURRENT_COUNT; i++) { + if (h5_compare_file_bytes(bundle[i].names.rw, bundle[i].names.wo) < 0) { + TEST_ERROR; + } + } + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY{ + if (buf) { + HDfree(buf); + } + (void)H5Sclose(dspace_id); + for (i = 0; i < CONCURRENT_COUNT; i++) { + (void)H5Dclose(bundle[i].dset_id); + (void)H5Fclose(bundle[i].file_id); + (void)H5Pclose(bundle[i].fapl_id); + } + } H5E_END_TRY; + return -1; +} /* end test_concurrent_access() */ + + +/* --------------------------------------------------------------------------- + * Function: main + * + * Purpose: Run tests. + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Jacob Smith + * 2019 + * --------------------------------------------------------------------------- + */ +int +main(void) +{ + int nerrors = 0; + + h5_reset(); + + g_log_stream = stdout; /* default debug/logging output stream */ + + HDprintf("Testing Mirror VFD functionality.\n"); + + /* -------------------- */ + /* SETUP */ + + /* Create directories for test-generated .h5 files + */ + if (nerrors == 0) { + if ((HDmkdir(MIRROR_RW_DIR, (mode_t)0755) < 0) && (errno != EEXIST)) { + nerrors++; + } + } + if (nerrors == 0) { + if ((HDmkdir(MIRROR_WO_DIR, (mode_t)0755) < 0) && (errno != EEXIST)) { + nerrors++; + } + } + + /* -------------------- */ + /* TESTS */ + /* Tests return negative values; `-=' increments nerrors count */ + + if (nerrors == 0) { + nerrors -= test_fapl_configuration(); + nerrors -= test_xmit_encode_decode(); + nerrors -= test_create_and_close(); + nerrors -= test_basic_dataset_write(); + nerrors -= test_chunked_dataset_write(); + nerrors -= test_on_disk_zoo(); + nerrors -= test_vanishing_datasets(); + nerrors -= test_concurrent_access(); + } + + if (nerrors) { + HDprintf("***** %d Mirror VFD TEST%s FAILED! *****\n", + nerrors, nerrors > 1 ? "S" : ""); + return EXIT_FAILURE; + } + + HDprintf("All Mirror Virtual File Driver tests passed.\n"); + return EXIT_SUCCESS; +} /* end main() */ + +#else /* H5_HAVE_MIRROR_VFD */ + +int +main(void) +{ + h5_reset(); + HDprintf("Testing Mirror VFD functionality.\n"); + HDprintf("SKIPPED - Mirror VFD not built.\n"); + return EXIT_SUCCESS; +} + +#endif /* H5_HAVE_MIRROR_VFD */ + + diff --git a/test/ohdr.c b/test/ohdr.c index 57090c8..ad76576 100644 --- a/test/ohdr.c +++ b/test/ohdr.c @@ -1142,7 +1142,7 @@ test_minimized_dset_ohdr_size_comparisons(hid_t fapl_id) if(H5Dclose(dset_F_N_id) < 0) TEST_ERROR if(H5Dclose(dset_F_Y_id) < 0) TEST_ERROR - PASSED() + PASSED(); } /* compact and non-compact */ @@ -1274,7 +1274,7 @@ test_minimized_dset_ohdr_with_filter(hid_t fapl_id) if(H5Dclose(dset_mZ_id) < 0) TEST_ERROR if(H5Fclose(file_id) < 0) TEST_ERROR - PASSED() + PASSED(); return SUCCEED; error: @@ -1448,7 +1448,7 @@ test_minimized_dset_ohdr_modification_times(hid_t _fapl_id) if(H5Pclose(dcpl_mT_id) < 0) TEST_ERROR if(H5Pclose(dcpl_mN_id) < 0) TEST_ERROR - PASSED() + PASSED(); return SUCCEED; error: @@ -1563,7 +1563,7 @@ test_minimized_dset_ohdr_fillvalue_backwards_compatability(hid_t _fapl_id) if(H5Dclose(dset_1_id) < 0) TEST_ERROR if(H5Fclose(file_id) < 0) TEST_ERROR; - PASSED() + PASSED(); return SUCCEED; error: diff --git a/test/page_buffer.c b/test/page_buffer.c index c4210b2..a508dc9 100644 --- a/test/page_buffer.c +++ b/test/page_buffer.c @@ -529,7 +529,7 @@ test_args(hid_t orig_fapl, const char *env_h5_drvr) if(H5Pclose(fapl) < 0) FAIL_STACK_ERROR; - PASSED() + PASSED(); return 0; error: @@ -803,7 +803,7 @@ test_raw_data_handling(hid_t orig_fapl, const char *env_h5_drvr) FAIL_STACK_ERROR; HDfree(data); - PASSED() + PASSED(); return 0; error: @@ -1056,7 +1056,7 @@ test_lru_processing(hid_t orig_fapl, const char *env_h5_drvr) FAIL_STACK_ERROR; HDfree(data); - PASSED() + PASSED(); return 0; error: @@ -1688,7 +1688,7 @@ test_min_threshold(hid_t orig_fapl, const char *env_h5_drvr) HDfree(data); - PASSED() + PASSED(); return 0; @@ -1994,7 +1994,7 @@ test_stats_collection(hid_t orig_fapl, const char *env_h5_drvr) HDfree(data); - PASSED() + PASSED(); return 0; error: @@ -2108,7 +2108,7 @@ verify_page_buffering_disabled(hid_t orig_fapl, const char *env_h5_drvr) if(H5Pclose(fapl) < 0) FAIL_STACK_ERROR; - PASSED() + PASSED(); return 0; diff --git a/test/set_extent.c b/test/set_extent.c index 17d439e..171fd05 100644 --- a/test/set_extent.c +++ b/test/set_extent.c @@ -2013,8 +2013,7 @@ static int test_external(hid_t fapl) { if (H5Fclose(fid) < 0) FAIL_STACK_ERROR - PASSED() - ; + PASSED(); return 0; diff --git a/test/tattr.c b/test/tattr.c index bcd8698..dab03a7 100644 --- a/test/tattr.c +++ b/test/tattr.c @@ -542,7 +542,7 @@ test_attr_flush(hid_t fapl) ret=H5Aread(att, H5T_NATIVE_DOUBLE, &rdata); CHECK(ret, FAIL, "H5Awrite"); - if(!H5_DBL_ABS_EQUAL(rdata, H5_DOUBLE(0.0))) + if(!H5_DBL_ABS_EQUAL(rdata, 0.0)) TestErrPrintf("attribute value wrong: rdata=%f, should be %f\n",rdata,(double)0.0F); ret=H5Fflush(fil, H5F_SCOPE_GLOBAL); @@ -551,7 +551,7 @@ test_attr_flush(hid_t fapl) ret=H5Aread(att, H5T_NATIVE_DOUBLE, &rdata); CHECK(ret, FAIL, "H5Awrite"); - if(!H5_DBL_ABS_EQUAL(rdata, H5_DOUBLE(0.0))) + if(!H5_DBL_ABS_EQUAL(rdata, 0.0)) TestErrPrintf("attribute value wrong: rdata=%f, should be %f\n",rdata,(double)0.0F); ret=H5Awrite(att, H5T_NATIVE_DOUBLE, &wdata); diff --git a/test/test_mirror.sh.in b/test/test_mirror.sh.in new file mode 100644 index 0000000..9635c38 --- /dev/null +++ b/test/test_mirror.sh.in @@ -0,0 +1,100 @@ +#! /bin/bash +# +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# +# Tests for the Mirror VFD feature. +# +# Created: +# Jacob Smith, 2019-12-30 + +############################################################################### +## test parameters +############################################################################### + +nerrors=0 + +SERVER_VERBOSITY="--verbosity=1" +SERVER_PORT="--port=3000" + + +############################################################################### +## Main +############################################################################### + +## TODO: arguments for main port, port range, verbosity? +# Parse options (none accepted at this time) +while [ $# -gt 0 ]; do + case "$1" in + *) # unknown option + echo "$0: Unknown option ($1)" + exit 1 + ;; + esac +done + + + +RUN_DIR=mirror_vfd_test +MIRROR_UTILS=../utils/mirror_vfd # TODO: presupposes from test/ + +mkdir $RUN_DIR + +# Copy program files into dedicated test directory +for FILE in $MIRROR_UTILS/mirror_* ; do + case "$FILE" in + *.o) continue ;; # Don't copy .o files + esac + cp $FILE $RUN_DIR +done +cp mirror_vfd $RUN_DIR + +# With the --disable-shared option, program files are built in their main +# directories; otherwise they are built in dir/.libs with a corresponding +# wrapper script. Copy these libs builds if appropriate. +if [ -f $MIRROR_UTILS/.libs/mirror_server ] ; then + RUN_LIBS=$RUN_DIR/.libs + mkdir $RUN_LIBS + for FILE in $MIRROR_UTILS/.libs/mirror_* ; do + case "$FILE" in + *.o) continue ;; # Don't copy .o files + esac + cp $FILE $RUN_LIBS + done + cp .libs/mirror_vfd $RUN_LIBS +fi + +cd $RUN_DIR + +echo "Launching Mirror Server" +SERVER_ARGS="$SERVER_PORT $SERVER_VERBOSITY" +./mirror_server $SERVER_ARGS & + +./mirror_vfd +nerrors=$? + +echo "Stopping Mirror Server" +./mirror_server_stop $SERVER_PORT + +############################################################################### +## Report and exit +############################################################################### +cd .. +if test $nerrors -eq 0 ; then + echo "Mirror VFD tests passed." + if test -z "$HDF5_NOCLEANUP" ; then + rm -rf $RUN_DIR + fi + exit 0 +else + echo "Mirror VFD tests FAILED." + exit 1 +fi + diff --git a/test/th5s.c b/test/th5s.c index a37070a..bb84353 100644 --- a/test/th5s.c +++ b/test/th5s.c @@ -2459,11 +2459,12 @@ test_h5s_compound_scalar_read(void) /* Close file */ ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); -} /* test_h5s_compound_scalar_read() */ +} /* end test_h5s_compound_scalar_read() */ -/* Data arrays for chunk test */ -double chunk_data_dbl[50000][3]; -float chunk_data_flt[50000][3]; + +/* Data array sizes for chunk test */ +#define CHUNK_DATA_NX 50000 +#define CHUNK_DATA_NY 3 /**************************************************************** ** @@ -2481,22 +2482,41 @@ test_h5s_chunk(void) hid_t space_id; hsize_t dims[2]; hsize_t csize[2]; + double **chunk_data_dbl = NULL; + double *chunk_data_dbl_data = NULL; + float **chunk_data_flt = NULL; + float *chunk_data_flt_data = NULL; int i,j; + /* Allocate memory */ + chunk_data_dbl_data = (double *)HDcalloc(CHUNK_DATA_NX * CHUNK_DATA_NY, sizeof(double)); + CHECK_PTR(chunk_data_dbl_data, "HDcalloc"); + chunk_data_dbl = (double **)HDcalloc(CHUNK_DATA_NX, sizeof(chunk_data_dbl_data)); + CHECK_PTR(chunk_data_dbl, "HDcalloc"); + for (i = 0; i < CHUNK_DATA_NX; i++) + chunk_data_dbl[i] = chunk_data_dbl_data + (i * CHUNK_DATA_NY); + + chunk_data_flt_data = (float *)HDcalloc(CHUNK_DATA_NX * CHUNK_DATA_NY, sizeof(float)); + CHECK_PTR(chunk_data_flt_data, "HDcalloc"); + chunk_data_flt = (float **)HDcalloc(CHUNK_DATA_NX, sizeof(chunk_data_flt_data)); + CHECK_PTR(chunk_data_flt, "HDcalloc"); + for (i = 0; i < CHUNK_DATA_NX; i++) + chunk_data_flt[i] = chunk_data_flt_data + (i * CHUNK_DATA_NY); + fileID = H5Fcreate(DATAFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(fileID, FAIL, "H5Fcreate"); plist_id = H5Pcreate(H5P_DATASET_CREATE); CHECK(plist_id, FAIL, "H5Pcreate"); - csize[0] = 50000; - csize[1] = 3; + csize[0] = CHUNK_DATA_NX; + csize[1] = CHUNK_DATA_NY; status = H5Pset_chunk(plist_id, 2, csize); CHECK(status, FAIL, "H5Pset_chunk"); /* Create the dataspace */ - dims[0] = 50000; - dims[1] = 3; + dims[0] = CHUNK_DATA_NX; + dims[1] = CHUNK_DATA_NY; space_id = H5Screate_simple(2, dims, NULL); CHECK(space_id, FAIL, "H5Screate_simple"); @@ -2504,11 +2524,11 @@ test_h5s_chunk(void) CHECK(dsetID, FAIL, "H5Dcreate2"); /* Initialize float array */ - for(i = 0; i < 50000; i++) - for(j = 0; j < 3; j++) + for(i = 0; i < CHUNK_DATA_NX; i++) + for(j = 0; j < CHUNK_DATA_NY; j++) chunk_data_flt[i][j] = (float)(i + 1) * 2.5F - (float)j * 100.3F; - status = H5Dwrite(dsetID, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, chunk_data_flt); + status = H5Dwrite(dsetID, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, chunk_data_flt_data); CHECK(status, FAIL, "H5Dwrite"); status = H5Pclose(plist_id); @@ -2521,17 +2541,17 @@ test_h5s_chunk(void) CHECK(status, FAIL, "H5Fclose"); /* Reset/initialize the data arrays to read in */ - HDmemset(chunk_data_dbl, 0, sizeof(double) * 50000 * 3); - HDmemset(chunk_data_flt, 0, sizeof(float) * 50000 * 3); + HDmemset(chunk_data_dbl_data, 0, sizeof(double) * CHUNK_DATA_NX * CHUNK_DATA_NY); + HDmemset(chunk_data_flt_data, 0, sizeof(float) * CHUNK_DATA_NX * CHUNK_DATA_NY); fileID = H5Fopen(DATAFILE, H5F_ACC_RDONLY, H5P_DEFAULT); CHECK(fileID, FAIL, "H5Fopen"); dsetID = H5Dopen2(fileID, "coords", H5P_DEFAULT); CHECK(dsetID, FAIL, "H5Dopen2"); - status= H5Dread(dsetID, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, chunk_data_dbl); + status= H5Dread(dsetID, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, chunk_data_dbl_data); CHECK(status, FAIL, "H5Dread"); - status= H5Dread(dsetID, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, chunk_data_flt); + status= H5Dread(dsetID, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, chunk_data_flt_data); CHECK(status, FAIL, "H5Dread"); status = H5Dclose(dsetID); @@ -2539,13 +2559,18 @@ test_h5s_chunk(void) status = H5Fclose(fileID); CHECK(status, FAIL, "H5Fclose"); - for(i=0; i<50000; i++) { - for(j=0; j<3; j++) { + for(i = 0; i < CHUNK_DATA_NX; i++) { + for(j = 0; j < CHUNK_DATA_NY; j++) { /* Check if the two values are within 0.001% range. */ if(!H5_DBL_REL_EQUAL(chunk_data_dbl[i][j], (double)chunk_data_flt[i][j], (double)0.00001F)) TestErrPrintf("%u: chunk_data_dbl[%d][%d]=%e, chunk_data_flt[%d][%d]=%e\n", (unsigned)__LINE__, i, j, chunk_data_dbl[i][j], i, j, (double)chunk_data_flt[i][j]); } /* end for */ } /* end for */ + + HDfree(chunk_data_dbl); + HDfree(chunk_data_dbl_data); + HDfree(chunk_data_flt); + HDfree(chunk_data_flt_data); } /* test_h5s_chunk() */ /**************************************************************** diff --git a/test/tid.c b/test/tid.c index d0ae3e4..7a839d2 100644 --- a/test/tid.c +++ b/test/tid.c @@ -19,6 +19,13 @@ #define H5I_FRIEND /*suppress error about including H5Ipkg */ #include "H5Ipkg.h" +static herr_t +free_wrapper(void *p) +{ + HDfree(p); + return SUCCEED; +} + /* Test basic functionality of registering and deleting types and IDs */ static int basic_id_test(void) { @@ -69,7 +76,7 @@ static int basic_id_test(void) goto out; /* Register a type */ - myType = H5Iregister_type((size_t)64, 0, (H5I_free_t) free ); + myType = H5Iregister_type((size_t)64, 0, free_wrapper); CHECK(myType, H5I_BADID, "H5Iregister_type"); if(myType == H5I_BADID) @@ -163,7 +170,7 @@ static int basic_id_test(void) H5E_END_TRY /* Register another type and another object in that type */ - myType = H5Iregister_type((size_t)64, 0, (H5I_free_t) free ); + myType = H5Iregister_type((size_t)64, 0, free_wrapper); CHECK(myType, H5I_BADID, "H5Iregister_type"); if(myType == H5I_BADID) @@ -238,7 +245,7 @@ out: /* A dummy search function for the next test */ -static int test_search_func(void H5_ATTR_UNUSED * ptr1, void H5_ATTR_UNUSED * ptr2) { return 0; } +static int test_search_func(void H5_ATTR_UNUSED * ptr1, hid_t H5_ATTR_UNUSED id, void H5_ATTR_UNUSED * ptr2) { return 0; } /* Ensure that public functions cannot access "predefined" ID types */ static int id_predefined_test(void ) @@ -264,7 +271,7 @@ static int id_predefined_test(void ) goto out; H5E_BEGIN_TRY - testPtr = H5Isearch(H5I_GENPROP_LST, (H5I_search_func_t) test_search_func, testObj); + testPtr = H5Isearch(H5I_GENPROP_LST, test_search_func, testObj); H5E_END_TRY CHECK_PTR_NULL(testPtr, "H5Isearch"); @@ -492,7 +499,7 @@ static int test_id_type_list(void) H5I_type_t testType; int i; /* Just a counter variable */ - startType = H5Iregister_type((size_t)8, 0, (H5I_free_t) free ); + startType = H5Iregister_type((size_t)8, 0, free_wrapper); CHECK(startType, H5I_BADID, "H5Iregister_type"); if(startType == H5I_BADID) goto out; @@ -507,7 +514,7 @@ static int test_id_type_list(void) /* Create types up to H5I_MAX_NUM_TYPES */ for(i = startType + 1; i < H5I_MAX_NUM_TYPES; i++) { - currentType = H5Iregister_type((size_t)8, 0, (H5I_free_t) free ); + currentType = H5Iregister_type((size_t)8, 0, free_wrapper); CHECK(currentType, H5I_BADID, "H5Iregister_type"); if(currentType == H5I_BADID) goto out; @@ -516,7 +523,7 @@ static int test_id_type_list(void) /* Wrap around to low type ID numbers */ for(i = H5I_NTYPES; i < startType; i++) { - currentType = H5Iregister_type((size_t)8, 0, (H5I_free_t) free ); + currentType = H5Iregister_type((size_t)8, 0, free_wrapper); CHECK(currentType, H5I_BADID, "H5Iregister_type"); if(currentType == H5I_BADID) goto out; @@ -524,7 +531,7 @@ static int test_id_type_list(void) /* There should be no room at the inn for a new ID type*/ H5E_BEGIN_TRY - testType = H5Iregister_type((size_t)8, 0, (H5I_free_t) free ); + testType = H5Iregister_type((size_t)8, 0, free_wrapper); H5E_END_TRY VERIFY(testType, H5I_BADID, "H5Iregister_type"); @@ -533,7 +540,7 @@ static int test_id_type_list(void) /* Now delete a type and try to insert again */ H5Idestroy_type(H5I_NTYPES); - testType = H5Iregister_type((size_t)8, 0, (H5I_free_t) free ); + testType = H5Iregister_type((size_t)8, 0, free_wrapper); VERIFY(testType, H5I_NTYPES, "H5Iregister_type"); if(testType != H5I_NTYPES) diff --git a/test/timer.c b/test/timer.c new file mode 100644 index 0000000..1014e75 --- /dev/null +++ b/test/timer.c @@ -0,0 +1,414 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Dana Robinson + * May, 2011 + * + * Purpose: Tests the operation of the platform-independent timers. + */ + +#include "h5test.h" + + + + +/*------------------------------------------------------------------------- + * Function: test_time_formatting + * + * Purpose: Tests time string creation. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Dana Robinson + * May 2011 + * + *------------------------------------------------------------------------- + */ +static herr_t +test_time_formatting(void) +{ + char *s = NULL; + + TESTING("Time string formats"); + + /* < 0, N/A */ + s = H5_timer_get_time_string(-1.0F); + if(NULL == s || HDstrcmp(s, "N/A") != 0) + TEST_ERROR; + HDfree(s); + + /* 0 0 */ + s = H5_timer_get_time_string(0.0F); + if(NULL == s || HDstrcmp(s, "0.0 s") != 0) + TEST_ERROR; + HDfree(s); + + /* < 1 us nanoseconds */ + s = H5_timer_get_time_string(123.0E-9F); + if(NULL == s || HDstrcmp(s, "123 ns") != 0) + TEST_ERROR; + HDfree(s); + + /* < 1 ms microseconds */ + s = H5_timer_get_time_string(23.456E-6F); + if(NULL == s || HDstrcmp(s, "23.5 us") != 0) + TEST_ERROR; + HDfree(s); + + /* < 1 s milliseconds */ + s = H5_timer_get_time_string(4.56789E-3F); + if(NULL == s || HDstrcmp(s, "4.6 ms") != 0) + TEST_ERROR; + HDfree(s); + + /* < 1 min seconds */ + s = H5_timer_get_time_string(3.14F); + if(NULL == s || HDstrcmp(s, "3.14 s") != 0) + TEST_ERROR; + HDfree(s); + + /* < 1 hr mins, secs */ + s = H5_timer_get_time_string(2521.0F); + if(NULL == s || HDstrcmp(s, "42 m 1 s") != 0) + TEST_ERROR; + HDfree(s); + + /* < 1 d hrs, mins, secs */ + s = H5_timer_get_time_string(9756.0F); + if(NULL == s || HDstrcmp(s, "2 h 42 m 36 s") != 0) + TEST_ERROR; + HDfree(s); + + /* > 1 d days, hrs, mins, secs */ + s = H5_timer_get_time_string(280802.0F); + if(NULL == s || HDstrcmp(s, "3 d 6 h 0 m 2 s") != 0) + TEST_ERROR; + HDfree(s); + + PASSED(); + return 0; + +error: + if(s) + HDfree(s); + return -1; + +} + + +/*------------------------------------------------------------------------- + * Function: test_timer_system_user + * + * Purpose: Tests the ability to get system and user times from the + * timers. + * Some platforms may require special code to get system and + * user times. If we do not support that particular platform + * dependent functionality, this test is skipped. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Dana Robinson + * May 2011 + * + *------------------------------------------------------------------------- + */ +static herr_t +test_timer_system_user(void) +{ + int i; + char *buf = NULL; + H5_timer_t timer; + H5_timevals_t times; + herr_t err; + + TESTING("system/user times"); + + err = H5_timer_init(&timer); + if(err < 0) + TEST_ERROR; + + err = H5_timer_start(&timer); + if(err < 0) + TEST_ERROR; + + /* The system and user times may not be present on some systems. They + * will be -1.0 if they are not. + */ + if(timer.initial.system < (double)0.0f || timer.initial.user < (double)0.0f) { + SKIPPED(); + printf("NOTE: No suitable way to get system/user times on this platform.\n"); + return 0; + } + + /* Do some fake work */ + for(i=0; i < 1024; i++) { + buf = (char *)HDmalloc(1024 * (size_t)i); + HDfree(buf); + } + + err = H5_timer_stop(&timer); + if(err < 0) + TEST_ERROR; + + err = H5_timer_get_times(timer, ×); + if(err < 0) + TEST_ERROR; + + /* System and user times should be non-negative. */ + if(times.system < (double)0.0f || times.user < (double)0.0f) + TEST_ERROR; + + PASSED(); + return 0; + +error: + return -1; +} + + +/*------------------------------------------------------------------------- + * Function: test_timer_elapsed + * + * Purpose: Tests the ability to get elapsed times from the timers. + * We should always be able to get an elapsed time, + * regardless of the time libraries or platform. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Dana Robinson + * May 2011 + * + *------------------------------------------------------------------------- + */ +static herr_t +test_timer_elapsed(void) +{ + int i; + char *buf = NULL; + H5_timer_t timer; + H5_timevals_t times; + herr_t err; + + TESTING("elapsed times"); + + err = H5_timer_init(&timer); + if(err < 0) + TEST_ERROR; + + err = H5_timer_start(&timer); + if(err < 0) + TEST_ERROR; + + /* Do some fake work */ + for(i=0; i < 1024; i++) { + buf = (char *)HDmalloc(1024 * (size_t)i); + HDfree(buf); + } + + err = H5_timer_stop(&timer); + if(err < 0) + TEST_ERROR; + + err = H5_timer_get_times(timer, ×); + if(err < 0) + TEST_ERROR; + + /* Elapsed time should be non-negative. */ + if(times.elapsed < (double)0.0f) + TEST_ERROR; + + PASSED(); + return 0; + +error: + return -1; +} + + + +static herr_t +test_timer_functionality(void) +{ + int i; + char *buf = NULL; + H5_timer_t timer; + + H5_timevals_t times; + double prev_etime; + double prev_total_etime; + + herr_t err; + + TESTING("timer functionality"); + + /***************** + * CHECK STARTUP * + *****************/ + + /* Timer should be running after start */ + err = H5_timer_init(&timer); + if(err < 0 || timer.is_running) + TEST_ERROR; + + /* Times should be initialized to zero */ + err = H5_timer_get_times(timer, ×); + if(err < 0 || !H5_DBL_ABS_EQUAL(times.elapsed, (double)0.0f)) + TEST_ERROR; + + err = H5_timer_get_total_times(timer, ×); + if(err < 0 || !H5_DBL_ABS_EQUAL(times.elapsed, (double)0.0f)) + TEST_ERROR; + + + /******************** + * CHECK START/STOP * + ********************/ + + /* Running state should change after start */ + err = H5_timer_start(&timer); + if(err < 0 || !timer.is_running) + TEST_ERROR; + + /* Do some fake work */ + for(i=0; i < 1024; i++) { + buf = (char *)HDmalloc(1024 * (size_t)i); + HDfree(buf); + } + + /* Running state should change after stop */ + err = H5_timer_stop(&timer); + if(err < 0 || timer.is_running) + TEST_ERROR; + + /* Times should be positive and non-negative */ + err = H5_timer_get_times(timer, ×); + if(err < 0 || times.elapsed < (double)0.0f) + TEST_ERROR; + + err = H5_timer_get_total_times(timer, ×); + if(err < 0 || times.elapsed < (double)0.0f) + TEST_ERROR; + + + /********************** + * CHECK INTERRUPTING * + **********************/ + + /* Timer should change stat and refresh to 0s */ + err = H5_timer_init(&timer); + if(err < 0 || timer.is_running) + TEST_ERROR; + + err = H5_timer_get_times(timer, ×); + if(err < 0 || !H5_DBL_ABS_EQUAL(times.elapsed, (double)0.0f)) + TEST_ERROR; + + err = H5_timer_get_total_times(timer, ×); + if(err < 0 || !H5_DBL_ABS_EQUAL(times.elapsed, (double)0.0f)) + TEST_ERROR; + + /* Timer state should flip */ + err = H5_timer_start(&timer); + if(err < 0 || !timer.is_running) + TEST_ERROR; + + /* Do some fake work */ + for(i=0; i < 1024; i++) { + buf = (char *)HDmalloc(1024 * (size_t)i); + HDfree(buf); + } + + /* Times should be non-negative */ + err = H5_timer_get_times(timer, ×); + if(err < 0 || times.elapsed < (double)0.0f) + TEST_ERROR; + prev_etime = times.elapsed; + + err = H5_timer_get_total_times(timer, ×); + if(err < 0 || times.elapsed < (double)0.0f) + TEST_ERROR; + prev_total_etime = times.elapsed; + + /* Do some fake work */ + for(i=0; i < 1024; i++) { + buf = (char *)HDmalloc(1024 * (size_t)i); + HDfree(buf); + } + + /* State should flip on stop */ + err = H5_timer_stop(&timer); + if(err < 0 || timer.is_running) + TEST_ERROR; + + /* Times should be >= than the cached intermediate times */ + err = H5_timer_get_times(timer, ×); + if(err < 0 || times.elapsed < prev_etime) + TEST_ERROR; + + err = H5_timer_get_total_times(timer, ×); + if(err < 0 || times.elapsed < prev_total_etime) + TEST_ERROR; + + + PASSED(); + return 0; + +error: + return -1; +} + + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: Tests the basic functionality of the platform-independent + * timers + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Dana Robinson + * May, 2011 + * + *------------------------------------------------------------------------- + */ +int +main(void) +{ + int nerrors = 0; + + h5_reset(); + + printf("Testing platform-independent timer functionality.\n"); + + nerrors += test_time_formatting() < 0 ? 1 : 0; + nerrors += test_timer_system_user() < 0 ? 1 : 0; + nerrors += test_timer_elapsed() < 0 ? 1 : 0; + nerrors += test_timer_functionality() < 0 ? 1 : 0; + + if(nerrors) { + printf("***** %d platform-independent timer TEST%s FAILED! *****\n", + nerrors, nerrors > 1 ? "S" : ""); + return 1; + } else { + printf("All platform-independent timer tests passed.\n"); + return 0; + } +} + diff --git a/test/tmisc.c b/test/tmisc.c index 539a027..6eb6872 100644 --- a/test/tmisc.c +++ b/test/tmisc.c @@ -5700,7 +5700,17 @@ test_misc35(void) { hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ hsize_t dims[] = {MISC35_SPACE_DIM1, MISC35_SPACE_DIM2, MISC35_SPACE_DIM3}; /* Dataspace dims */ - hsize_t coord[MISC35_NPOINTS][MISC35_SPACE_RANK]; /* Coordinates for point selection */ + hsize_t coord[MISC35_NPOINTS][MISC35_SPACE_RANK] = /* Coordinates for point selection */ + {{0,10, 5}, + {1, 2, 7}, + {2, 4, 9}, + {0, 6,11}, + {1, 8,13}, + {2,12, 0}, + {0,14, 2}, + {1, 0, 4}, + {2, 1, 6}, + {0, 3, 8}}; size_t reg_size_start; /* Initial amount of regular memory allocated */ size_t arr_size_start; /* Initial amount of array memory allocated */ size_t blk_size_start; /* Initial amount of block memory allocated */ @@ -5721,16 +5731,6 @@ test_misc35(void) CHECK(sid, H5I_INVALID_HID, "H5Screate_simple"); /* Select sequence of ten points */ - coord[0][0]=0; coord[0][1]=10; coord[0][2]= 5; - coord[1][0]=1; coord[1][1]= 2; coord[1][2]= 7; - coord[2][0]=2; coord[2][1]= 4; coord[2][2]= 9; - coord[3][0]=0; coord[3][1]= 6; coord[3][2]=11; - coord[4][0]=1; coord[4][1]= 8; coord[4][2]=13; - coord[5][0]=2; coord[5][1]=12; coord[5][2]= 0; - coord[6][0]=0; coord[6][1]=14; coord[6][2]= 2; - coord[7][0]=1; coord[7][1]= 0; coord[7][2]= 4; - coord[8][0]=2; coord[8][1]= 1; coord[8][2]= 6; - coord[9][0]=0; coord[9][1]= 3; coord[9][2]= 8; ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)MISC35_NPOINTS, (const hsize_t *)coord); CHECK(ret, FAIL, "H5Sselect_elements"); @@ -5745,24 +5745,16 @@ test_misc35(void) #if !defined H5_USING_MEMCHECKER /* All the free list values should be >0 */ - if(0 == reg_size_start) - ERROR("reg_size_start == 0"); - if(0 == arr_size_start) - ERROR("arr_size_start == 0"); - if(0 == blk_size_start) - ERROR("blk_size_start == 0"); - if(0 == fac_size_start) - ERROR("fac_size_start == 0"); + CHECK(reg_size_start, 0, "H5get_free_list_sizes"); + CHECK(arr_size_start, 0, "H5get_free_list_sizes"); + CHECK(blk_size_start, 0, "H5get_free_list_sizes"); + CHECK(fac_size_start, 0, "H5get_free_list_sizes"); #else /* H5_MEMORY_ALLOC_SANITY_CHECK */ /* All the values should be == 0 */ - if(0 != reg_size_start) - ERROR("reg_size_start != 0"); - if(0 != arr_size_start) - ERROR("arr_size_start != 0"); - if(0 != blk_size_start) - ERROR("blk_size_start != 0"); - if(0 != fac_size_start) - ERROR("fac_size_start != 0"); + VERIFY(reg_size_start, 0, "H5get_free_list_sizes"); + VERIFY(arr_size_start, 0, "H5get_free_list_sizes"); + VERIFY(blk_size_start, 0, "H5get_free_list_sizes"); + VERIFY(fac_size_start, 0, "H5get_free_list_sizes"); #endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ /* Garbage collect the free lists */ @@ -5789,36 +5781,22 @@ test_misc35(void) #if defined H5_MEMORY_ALLOC_SANITY_CHECK /* All the values should be >0 */ - if(0 == alloc_stats.total_alloc_bytes) - ERROR("alloc_stats.total_alloc_bytes == 0"); - if(0 == alloc_stats.curr_alloc_bytes) - ERROR("alloc_stats.curr_alloc_bytes == 0"); - if(0 == alloc_stats.peak_alloc_bytes) - ERROR("alloc_stats.peak_alloc_bytes == 0"); - if(0 == alloc_stats.max_block_size) - ERROR("alloc_stats.max_block_size == 0"); - if(0 == alloc_stats.total_alloc_blocks_count) - ERROR("alloc_stats.total_alloc_blocks_count == 0"); - if(0 == alloc_stats.curr_alloc_blocks_count) - ERROR("alloc_stats.curr_alloc_blocks_count == 0"); - if(0 == alloc_stats.peak_alloc_blocks_count) - ERROR("alloc_stats.peak_alloc_blocks_count == 0"); + CHECK(alloc_stats.total_alloc_bytes, 0, "H5get_alloc_stats"); + CHECK(alloc_stats.curr_alloc_bytes, 0, "H5get_alloc_stats"); + CHECK(alloc_stats.peak_alloc_bytes, 0, "H5get_alloc_stats"); + CHECK(alloc_stats.max_block_size, 0, "H5get_alloc_stats"); + CHECK(alloc_stats.total_alloc_blocks_count, 0, "H5get_alloc_stats"); + CHECK(alloc_stats.curr_alloc_blocks_count, 0, "H5get_alloc_stats"); + CHECK(alloc_stats.peak_alloc_blocks_count, 0, "H5get_alloc_stats"); #else /* H5_MEMORY_ALLOC_SANITY_CHECK */ /* All the values should be == 0 */ - if(0 != alloc_stats.total_alloc_bytes) - ERROR("alloc_stats.total_alloc_bytes != 0"); - if(0 != alloc_stats.curr_alloc_bytes) - ERROR("alloc_stats.curr_alloc_bytes != 0"); - if(0 != alloc_stats.peak_alloc_bytes) - ERROR("alloc_stats.peak_alloc_bytes != 0"); - if(0 != alloc_stats.max_block_size) - ERROR("alloc_stats.max_block_size != 0"); - if(0 != alloc_stats.total_alloc_blocks_count) - ERROR("alloc_stats.total_alloc_blocks_count != 0"); - if(0 != alloc_stats.curr_alloc_blocks_count) - ERROR("alloc_stats.curr_alloc_blocks_count != 0"); - if(0 != alloc_stats.peak_alloc_blocks_count) - ERROR("alloc_stats.peak_alloc_blocks_count != 0"); + VERIFY(alloc_stats.total_alloc_bytes, 0, "H5get_alloc_stats"); + VERIFY(alloc_stats.curr_alloc_bytes, 0, "H5get_alloc_stats"); + VERIFY(alloc_stats.peak_alloc_bytes, 0, "H5get_alloc_stats"); + VERIFY(alloc_stats.max_block_size, 0, "H5get_alloc_stats"); + VERIFY(alloc_stats.total_alloc_blocks_count, 0, "H5get_alloc_stats"); + VERIFY(alloc_stats.curr_alloc_blocks_count, 0, "H5get_alloc_stats"); + VERIFY(alloc_stats.peak_alloc_blocks_count, 0, "H5get_alloc_stats"); #endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ } /* end test_misc35() */ diff --git a/test/trefer.c b/test/trefer.c index 15f9d64..fd97239 100644 --- a/test/trefer.c +++ b/test/trefer.c @@ -23,6 +23,7 @@ #define FILE_REF_PARAM "trefer_param.h5" #define FILE_REF_OBJ "trefer_obj.h5" +#define FILE_REF_VL_OBJ "trefer_vl_obj.h5" #define FILE_REF_REG "trefer_reg.h5" #define FILE_REF_REG_1D "trefer_reg_1d.h5" #define FILE_REF_OBJ_DEL "trefer_obj_del.h5" @@ -247,9 +248,9 @@ test_reference_params(void) /* Test parameters to H5Ropen_object */ dset2 = H5Ropen_object(&rbuf[0], H5I_INVALID_HID, H5I_INVALID_HID); - VERIFY(dset2, FAIL, "H5Ropen_object oapl_id"); + VERIFY(dset2, H5I_INVALID_HID, "H5Ropen_object oapl_id"); dset2 = H5Ropen_object(NULL, H5P_DEFAULT, dapl_id); - VERIFY(dset2, FAIL, "H5Ropen_object ref"); + VERIFY(dset2, H5I_INVALID_HID, "H5Ropen_object ref"); /* Test parameters to H5Ropen_region */ ret_id = H5Ropen_region(NULL, H5I_INVALID_HID, H5I_INVALID_HID); @@ -538,6 +539,273 @@ test_reference_obj(void) /**************************************************************** ** +** test_reference_vlen_obj(): Test basic H5R (reference) object reference +** within a vlen type. +** Tests references to various kinds of objects +** +****************************************************************/ +static void +test_reference_vlen_obj(void) +{ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset, /* Dataset ID */ + dset2; /* Dereferenced dataset ID */ + hid_t group; /* Group ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1; /* Datatype ID */ + hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t vl_dims[] = {1}; + hid_t dapl_id; /* Dataset access property list */ + H5R_ref_t *wbuf, /* buffer to write to disk */ + *rbuf; /* buffer read from disk */ + unsigned *ibuf, *obuf; + unsigned i, j; /* Counters */ + H5O_type_t obj_type; /* Object type */ + herr_t ret; /* Generic return value */ + hvl_t vl_wbuf = {0, NULL}, vl_rbuf = {0, NULL}; + + /* Output message about test being performed */ + MESSAGE(5, ("Testing Object Reference Functions within VLEN type\n")); + + /* Allocate write & read buffers */ + wbuf = HDcalloc(sizeof(H5R_ref_t), SPACE1_DIM1); + rbuf = HDcalloc(sizeof(H5R_ref_t), SPACE1_DIM1); + ibuf = HDcalloc(sizeof(unsigned), SPACE1_DIM1); + obuf = HDcalloc(sizeof(unsigned), SPACE1_DIM1); + + for (i = 0; i < SPACE1_DIM1; i++) + obuf[i] = i * 3; + + /* Create file */ + fid1 = H5Fcreate(FILE_REF_VL_OBJ, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + CHECK(fid1, H5I_INVALID_HID, "H5Fcreate"); + + /* Create dataspace for datasets */ + sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); + CHECK(sid1, H5I_INVALID_HID, "H5Screate_simple"); + + /* Create dataset access property list */ + dapl_id = H5Pcreate(H5P_DATASET_ACCESS); + CHECK(dapl_id, H5I_INVALID_HID, "H5Pcreate"); + + /* Create a group */ + group = H5Gcreate2(fid1, "Group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(group, H5I_INVALID_HID, "H5Gcreate2"); + + /* Create a dataset (inside Group1) */ + dataset = H5Dcreate2(group, "Dataset1", H5T_NATIVE_UINT, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(dataset, H5I_INVALID_HID, "H5Dcreate2"); + + /* Write selection to disk */ + ret = H5Dwrite(dataset, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, obuf); + CHECK(ret, FAIL, "H5Dwrite"); + + /* Close Dataset */ + ret = H5Dclose(dataset); + CHECK(ret, FAIL, "H5Dclose"); + + /* Create another dataset (inside Group1) */ + dataset = H5Dcreate2(group, "Dataset2", H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(dataset, FAIL, "H5Dcreate2"); + + /* Close Dataset */ + ret = H5Dclose(dataset); + CHECK(ret, FAIL, "H5Dclose"); + + /* Close disk dataspace */ + ret = H5Sclose(sid1); + CHECK(ret, FAIL, "H5Sclose"); + + /* Create a datatype to refer to */ + tid1 = H5Tcreate(H5T_COMPOUND, sizeof(s1_t)); + CHECK(tid1, H5I_INVALID_HID, "H5Tcreate"); + + /* Insert fields */ + ret = H5Tinsert(tid1, "a", HOFFSET(s1_t,a), H5T_NATIVE_INT); + CHECK(ret, FAIL, "H5Tinsert"); + + ret = H5Tinsert(tid1, "b", HOFFSET(s1_t,b), H5T_NATIVE_INT); + CHECK(ret, FAIL, "H5Tinsert"); + + ret = H5Tinsert(tid1, "c", HOFFSET(s1_t,c), H5T_NATIVE_FLOAT); + CHECK(ret, FAIL, "H5Tinsert"); + + /* Save datatype for later */ + ret = H5Tcommit2(group, "Datatype1", tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Tcommit2"); + + /* Close datatype */ + ret = H5Tclose(tid1); + CHECK(ret, FAIL, "H5Tclose"); + + /* Close group */ + ret = H5Gclose(group); + CHECK(ret, FAIL, "H5Gclose"); + + /* Create vlen type */ + tid1 = H5Tvlen_create(H5T_STD_REF); + CHECK(tid1, H5I_INVALID_HID, "H5Tvlen_create"); + + /* Create dataspace for datasets */ + sid1 = H5Screate_simple(SPACE1_RANK, vl_dims, NULL); + CHECK(sid1, H5I_INVALID_HID, "H5Screate_simple"); + + /* Create a dataset */ + dataset = H5Dcreate2(fid1, "Dataset3", tid1, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(dataset, H5I_INVALID_HID, "H5Dcreate2"); + + /* Create reference to dataset */ + ret = H5Rcreate_object(fid1, "/Group1/Dataset1", H5P_DEFAULT, &wbuf[0]); + CHECK(ret, FAIL, "H5Rcreate_object"); + ret = H5Rget_obj_type3(&wbuf[0], H5P_DEFAULT, &obj_type); + CHECK(ret, FAIL, "H5Rget_obj_type3"); + VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); + + /* Create reference to dataset */ + ret = H5Rcreate_object(fid1, "/Group1/Dataset2", H5P_DEFAULT, &wbuf[1]); + CHECK(ret, FAIL, "H5Rcreate_object"); + ret = H5Rget_obj_type3(&wbuf[1], H5P_DEFAULT, &obj_type); + CHECK(ret, FAIL, "H5Rget_obj_type3"); + VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); + + /* Create reference to group */ + ret = H5Rcreate_object(fid1, "/Group1", H5P_DEFAULT, &wbuf[2]); + CHECK(ret, FAIL, "H5Rcreate_object"); + ret = H5Rget_obj_type3(&wbuf[2], H5P_DEFAULT, &obj_type); + CHECK(ret, FAIL, "H5Rget_obj_type3"); + VERIFY(obj_type, H5O_TYPE_GROUP, "H5Rget_obj_type3"); + + /* Create reference to named datatype */ + ret = H5Rcreate_object(fid1, "/Group1/Datatype1", H5P_DEFAULT, &wbuf[3]); + CHECK(ret, FAIL, "H5Rcreate_object"); + ret = H5Rget_obj_type3(&wbuf[3], H5P_DEFAULT, &obj_type); + CHECK(ret, FAIL, "H5Rget_obj_type3"); + VERIFY(obj_type, H5O_TYPE_NAMED_DATATYPE, "H5Rget_obj_type3"); + + /* Store references into vlen */ + vl_wbuf.len = SPACE1_DIM1; + vl_wbuf.p = wbuf; + + /* Write selection to disk */ + ret = H5Dwrite(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, &vl_wbuf); + CHECK(ret, FAIL, "H5Dwrite"); + + /* Close disk dataspace */ + ret = H5Sclose(sid1); + CHECK(ret, FAIL, "H5Sclose"); + + /* Close Dataset */ + ret = H5Dclose(dataset); + CHECK(ret, FAIL, "H5Dclose"); + + /* Close datatype */ + ret = H5Tclose(tid1); + CHECK(ret, FAIL, "H5Tclose"); + + /* Close file */ + ret = H5Fclose(fid1); + CHECK(ret, FAIL, "H5Fclose"); + + /* Re-open the file */ + fid1 = H5Fopen(FILE_REF_VL_OBJ, H5F_ACC_RDWR, H5P_DEFAULT); + CHECK(fid1, H5I_INVALID_HID, "H5Fopen"); + + /* Open the dataset */ + dataset = H5Dopen2(fid1, "/Dataset3", H5P_DEFAULT); + CHECK(dataset, H5I_INVALID_HID, "H5Dopen2"); + + tid1 = H5Dget_type(dataset); + CHECK(tid1, H5I_INVALID_HID, "H5Dget_type"); + + /* Read selection from disk */ + ret = H5Dread(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, &vl_rbuf); + CHECK(ret, FAIL, "H5Dread"); + + VERIFY(vl_rbuf.len, SPACE1_DIM1, "H5Dread"); + rbuf = vl_rbuf.p; + + /* Close datatype */ + ret = H5Tclose(tid1); + CHECK(ret, FAIL, "H5Tclose"); + + /* Open dataset object */ + dset2 = H5Ropen_object(&rbuf[0], H5P_DEFAULT, dapl_id); + CHECK(dset2, H5I_INVALID_HID, "H5Ropen_object"); + + /* Check information in referenced dataset */ + sid1 = H5Dget_space(dset2); + CHECK(sid1, H5I_INVALID_HID, "H5Dget_space"); + + ret = (int)H5Sget_simple_extent_npoints(sid1); + VERIFY(ret, SPACE1_DIM1, "H5Sget_simple_extent_npoints"); + + /* Read from disk */ + ret = H5Dread(dset2, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf); + CHECK(ret, FAIL, "H5Dread"); + + for(i = 0; i < SPACE1_DIM1; i++) + VERIFY(ibuf[i], i * 3, "Data"); + + /* Close dereferenced Dataset */ + ret = H5Dclose(dset2); + CHECK(ret, FAIL, "H5Dclose"); + + /* Open group object. GAPL isn't supported yet. But it's harmless to pass in */ + group = H5Ropen_object(&rbuf[2], H5P_DEFAULT, H5P_DEFAULT); + CHECK(group, H5I_INVALID_HID, "H5Ropen_object"); + + /* Close group */ + ret = H5Gclose(group); + CHECK(ret, FAIL, "H5Gclose"); + + /* Open datatype object. TAPL isn't supported yet. But it's harmless to pass in */ + tid1 = H5Ropen_object(&rbuf[3], H5P_DEFAULT, H5P_DEFAULT); + CHECK(tid1, H5I_INVALID_HID, "H5Ropen_object"); + + /* Verify correct datatype */ + { + H5T_class_t tclass; + + tclass = H5Tget_class(tid1); + VERIFY(tclass, H5T_COMPOUND, "H5Tget_class"); + + ret= H5Tget_nmembers(tid1); + VERIFY(ret, 3, "H5Tget_nmembers"); + } + + /* Close datatype */ + ret = H5Tclose(tid1); + CHECK(ret, FAIL, "H5Tclose"); + + /* Close Dataset */ + ret = H5Dclose(dataset); + CHECK(ret, FAIL, "H5Dclose"); + + /* Close dataset access property list */ + ret = H5Pclose(dapl_id); + CHECK(ret, FAIL, "H5Pclose"); + + /* Close file */ + ret = H5Fclose(fid1); + CHECK(ret, FAIL, "H5Fclose"); + + /* Destroy references */ + for(j = 0; j < SPACE1_DIM1; j++) { + ret = H5Rdestroy(&wbuf[j]); + CHECK(ret, FAIL, "H5Rdestroy"); + ret = H5Rdestroy(&rbuf[j]); + CHECK(ret, FAIL, "H5Rdestroy"); + } + + /* Free memory buffers */ + HDfree(wbuf); + HDfree(rbuf); + HDfree(ibuf); + HDfree(obuf); +} /* test_reference_vlen_obj() */ + +/**************************************************************** +** ** test_reference_region(): Test basic H5R (reference) object reference code. ** Tests references to various kinds of objects ** @@ -2258,7 +2526,7 @@ test_reference_compat_conv(void) /* Create a dataset with region reference datatype */ dataset = H5Dcreate2(fid1, "Dataset4", H5T_STD_REF_DSETREG, sid3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(dataset, FAIL, "H5Dcreate2"); + CHECK(dataset, H5I_INVALID_HID, "H5Dcreate2"); /* Select 6x6 hyperslab for first reference */ start[0] = 2; @@ -2316,11 +2584,11 @@ test_reference_compat_conv(void) /* Re-open the file */ fid1 = H5Fopen(FILE_REF_COMPAT, H5F_ACC_RDWR, H5P_DEFAULT); - CHECK(fid1, FAIL, "H5Fopen"); + CHECK(fid1, H5I_INVALID_HID, "H5Fopen"); /* Open the object reference dataset */ dataset = H5Dopen2(fid1, "/Dataset3", H5P_DEFAULT); - CHECK(dataset, FAIL, "H5Dopen2"); + CHECK(dataset, H5I_INVALID_HID, "H5Dopen2"); /* Read selection from disk */ ret = H5Dread(dataset, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf_obj); @@ -2376,7 +2644,7 @@ test_reference_compat_conv(void) /* Open the dataset region reference dataset */ dataset = H5Dopen2(fid1, "/Dataset4", H5P_DEFAULT); - CHECK(ret, H5I_INVALID_HID, "H5Dopen2"); + CHECK(dataset, H5I_INVALID_HID, "H5Dopen2"); /* Read selection from disk */ ret = H5Dread(dataset, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf_reg); @@ -2862,6 +3130,7 @@ test_reference(void) test_reference_params(); /* Test for correct parameter checking */ test_reference_obj(); /* Test basic H5R object reference code */ + test_reference_vlen_obj(); /* Test reference within vlen */ /* Loop through all the combinations of low/high version bounds */ for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { @@ -2907,6 +3176,7 @@ cleanup_reference(void) { HDremove(FILE_REF_PARAM); HDremove(FILE_REF_OBJ); + HDremove(FILE_REF_VL_OBJ); HDremove(FILE_REF_REG); HDremove(FILE_REF_REG_1D); HDremove(FILE_REF_OBJ_DEL); diff --git a/test/tselect.c b/test/tselect.c index cadd350..c98db5d 100644 --- a/test/tselect.c +++ b/test/tselect.c @@ -1666,10 +1666,10 @@ verify_select_hyper_contig_dr__run_test(const uint16_t *cube_buf, /**************************************************************** ** ** test_select_hyper_contig_dr__run_test(): Test H5S (dataspace) -** selection code with contiguous source and target having -** different ranks but the same shape. We have already -** tested H5Sselect_shape_same in isolation, so now we try to do -** I/O. +** selection code with contiguous source and target having +** different ranks but the same shape. We have already +** tested H5Sselect_shape_same in isolation, so now we try to do +** I/O. ** ****************************************************************/ static void @@ -6118,8 +6118,8 @@ test_select_hyper_chunk(hid_t fapl_plist, hid_t xfer_plist) */ tmpdata = data; for (j = 0; j < X; j++) - for (i = 0; i < Y; i++) - for (k = 0; k < Z; k++) + for (i = 0; i < Y; i++) + for (k = 0; k < Z; k++) *tmpdata++ = (short)((k+1)%256); /* @@ -6281,8 +6281,8 @@ test_select_hyper_chunk(hid_t fapl_plist, hid_t xfer_plist) tmpdata = data; tmpdata_out = data_out; for (j = 0; j < X; j++) - for (i = 0; i < Y; i++) - for (k = 0; k < Z; k++,tmpdata++,tmpdata_out++) { + for (i = 0; i < Y; i++) + for (k = 0; k < Z; k++,tmpdata++,tmpdata_out++) { if(*tmpdata!=*tmpdata_out) TestErrPrintf("Line %d: Error! j=%d, i=%d, k=%d, *tmpdata=%x, *tmpdata_out=%x\n",__LINE__,j,i,k,(unsigned)*tmpdata,(unsigned)*tmpdata_out); } /* end for */ @@ -6350,7 +6350,7 @@ test_select_point_chunk(void) */ tmpdata = data; for (i = 0; i < SPACE7_DIM1; i++) - for (j = 0; j < SPACE7_DIM1; j++) + for (j = 0; j < SPACE7_DIM1; j++) *tmpdata++ = ((i*SPACE7_DIM2)+j)%256; /* @@ -12026,16 +12026,16 @@ test_space_rebuild(void) if(rebuild_stat1 != H5S_DIMINFO_VALID_YES) { ret = FAIL; CHECK(ret,FAIL,"H5S_hyper_rebuild"); - } /* end if */ + } if(rebuild_stat2 != H5S_DIMINFO_VALID_YES) { ret = FAIL; CHECK(ret,FAIL,"H5S_hyper_rebuild"); - } /* end if */ + } if(ret != FAIL) { /* In this case, rebuild_check should be TRUE. */ rebuild_check = H5Sselect_shape_same(sid_reg1, sid_reg_ori1); CHECK(rebuild_check, FALSE, "H5Sselect_shape_same"); - } /* end if */ + } /* For irregular hyperslab */ sid_irreg1 = H5Screate_simple(SPACERE1_RANK,dims1,NULL); @@ -12062,11 +12062,11 @@ test_space_rebuild(void) if(rebuild_stat1 != H5S_DIMINFO_VALID_NO) { ret = FAIL; CHECK(ret,FAIL,"H5S_hyper_rebuild"); - } /* end if */ + } if(rebuild_stat2 != H5S_DIMINFO_VALID_IMPOSSIBLE) { ret = FAIL; CHECK(ret,FAIL,"H5S_hyper_rebuild"); - } /* end if */ + } /* No need to do shape comparision */ @@ -12114,7 +12114,7 @@ test_space_rebuild(void) if(rebuild_stat1 != H5S_DIMINFO_VALID_YES) { ret = FAIL; CHECK(ret,FAIL,"H5S_hyper_rebuild"); - } /* end if */ + } if(rebuild_stat2 != H5S_DIMINFO_VALID_YES) { ret = FAIL; CHECK(ret,FAIL,"H5S_hyper_rebuild"); @@ -12123,7 +12123,7 @@ test_space_rebuild(void) /* In this case, rebuild_check should be TRUE. */ rebuild_check = H5Sselect_shape_same(sid_reg2, sid_reg_ori2); CHECK(rebuild_check, FALSE, "H5Sselect_shape_same"); - } /* end if */ + } /* 2-D irregular case */ sid_irreg2 = H5Screate_simple(SPACERE2_RANK,dims2,NULL); @@ -12155,11 +12155,11 @@ test_space_rebuild(void) if(rebuild_stat1 != H5S_DIMINFO_VALID_NO) { ret = FAIL; CHECK(ret,FAIL,"H5S_hyper_rebuild"); - } /* end if */ + } if(rebuild_stat2 != H5S_DIMINFO_VALID_IMPOSSIBLE) { ret = FAIL; CHECK(ret,FAIL,"H5S_hyper_rebuild"); - } /* end if */ + } /* No need to do shape comparision */ MESSAGE(7, ("Testing functionality to rebuild 3-D hyperslab selection\n")); @@ -12212,16 +12212,16 @@ test_space_rebuild(void) if(rebuild_stat1 != H5S_DIMINFO_VALID_YES) { ret = FAIL; CHECK(ret,FAIL,"H5S_hyper_rebuild"); - } /* end if */ + } if(rebuild_stat2 != H5S_DIMINFO_VALID_YES) { ret = FAIL; CHECK(ret,FAIL,"H5S_hyper_rebuild"); - } /* end if */ + } if(ret != FAIL) { /* In this case, rebuild_check should be TRUE. */ rebuild_check = H5Sselect_shape_same(sid_reg3, sid_reg_ori3); CHECK(rebuild_check, FALSE, "H5Sselect_shape_same"); - } /* end if */ + } sid_irreg3 = H5Screate_simple(SPACERE3_RANK,dims3,NULL); @@ -12258,11 +12258,11 @@ test_space_rebuild(void) if(rebuild_stat1 != H5S_DIMINFO_VALID_NO) { ret = FAIL; CHECK(ret,FAIL,"H5S_hyper_rebuild"); - } /* end if */ + } if(rebuild_stat2 != H5S_DIMINFO_VALID_IMPOSSIBLE) { ret = FAIL; CHECK(ret,FAIL,"H5S_hyper_rebuild"); - } /* end if */ + } /* No need to do shape comparision */ MESSAGE(7, ("Testing functionality to rebuild 4-D hyperslab selection\n")); @@ -12323,16 +12323,16 @@ test_space_rebuild(void) if(rebuild_stat1 != H5S_DIMINFO_VALID_YES) { ret = FAIL; CHECK(ret,FAIL,"H5S_hyper_rebuild"); - } /* end if */ + } if(rebuild_stat2 != H5S_DIMINFO_VALID_YES) { ret = FAIL; CHECK(ret,FAIL,"H5S_hyper_rebuild"); - } /* end if */ + } if(ret != FAIL) { /* In this case, rebuild_check should be TRUE. */ rebuild_check = H5Sselect_shape_same(sid_reg4, sid_reg_ori4); CHECK(rebuild_check, FALSE, "H5Sselect_shape_same"); - } /* end if */ + } /* Testing irregular selection */ sid_irreg4 = H5Screate_simple(SPACERE4_RANK,dims4,NULL); @@ -12380,11 +12380,11 @@ test_space_rebuild(void) if(rebuild_stat1 != H5S_DIMINFO_VALID_NO) { ret = FAIL; CHECK(ret,FAIL,"H5S_hyper_rebuild"); - } /* end if */ + } if(rebuild_stat2 != H5S_DIMINFO_VALID_IMPOSSIBLE) { ret = FAIL; CHECK(ret,FAIL,"H5S_hyper_rebuild"); - } /* end if */ + } /* No need to do shape comparision */ MESSAGE(7, ("Testing functionality to rebuild 5-D hyperslab selection\n")); @@ -12449,16 +12449,16 @@ test_space_rebuild(void) if(rebuild_stat1 != H5S_DIMINFO_VALID_YES) { ret = FAIL; CHECK(ret,FAIL,"H5S_hyper_rebuild"); - } /* end if */ + } if(rebuild_stat2 != H5S_DIMINFO_VALID_YES) { ret = FAIL; CHECK(ret,FAIL,"H5S_hyper_rebuild"); - } /* end if */ + } if(ret != FAIL) { /* In this case, rebuild_check should be TRUE. */ rebuild_check = H5Sselect_shape_same(sid_reg5, sid_reg_ori5); CHECK(rebuild_check, FALSE, "H5Sselect_shape_same"); - } /* end if */ + } sid_irreg5 = H5Screate_simple(SPACERE5_RANK,dims5,NULL); @@ -12511,11 +12511,11 @@ test_space_rebuild(void) if(rebuild_stat1 != H5S_DIMINFO_VALID_NO) { ret = FAIL; CHECK(ret,FAIL,"H5S_hyper_rebuild"); - } /* end if */ + } if(rebuild_stat2 != H5S_DIMINFO_VALID_IMPOSSIBLE) { ret = FAIL; CHECK(ret,FAIL,"H5S_hyper_rebuild"); - } /* end if */ + } /* No need to do shape comparision */ /* We use 5-D to test a special case with @@ -12558,11 +12558,11 @@ test_space_rebuild(void) if(rebuild_stat1 != H5S_DIMINFO_VALID_YES) { ret = FAIL; CHECK(ret,FAIL,"H5S_hyper_rebuild"); - } /* end if */ + } if(rebuild_stat2 != H5S_DIMINFO_VALID_YES) { ret = FAIL; CHECK(ret,FAIL,"H5S_hyper_rebuild"); - } /* end if */ + } /* No need to do shape comparision */ /* Adding some selections to make it real irregular */ @@ -12586,11 +12586,11 @@ test_space_rebuild(void) if(rebuild_stat1 != H5S_DIMINFO_VALID_NO) { ret = FAIL; CHECK(ret,FAIL,"H5S_hyper_rebuild"); - } /* end if */ + } if(rebuild_stat2 != H5S_DIMINFO_VALID_IMPOSSIBLE) { ret = FAIL; CHECK(ret,FAIL,"H5S_hyper_rebuild"); - } /* end if */ + } /* No need to do shape comparision */ /* Add more selections to make it regular again */ @@ -12614,11 +12614,11 @@ test_space_rebuild(void) if(rebuild_stat1 != H5S_DIMINFO_VALID_NO) { ret = FAIL; CHECK(ret,FAIL,"H5S_hyper_rebuild"); - } /* end if */ + } if(rebuild_stat2 != H5S_DIMINFO_VALID_YES) { ret = FAIL; CHECK(ret,FAIL,"H5S_hyper_rebuild"); - } /* end if */ + } /* No need to do shape comparision */ H5Sclose(sid_reg1); @@ -15442,14 +15442,14 @@ test_hyper_io_1d(void) /* Get the dataset's dataspace */ sid = H5Dget_space(did); - CHECK(sid, H5I_INVALID_HID, "H5Pcreate"); + CHECK(sid, H5I_INVALID_HID, "H5Dget_space"); ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Set up contiguous memory dataspace for the selected elements */ dimsm[0] = count[0]; mid = H5Screate_simple(RANK, dimsm, NULL); - CHECK(mid, H5I_INVALID_HID, "H5Screate"); + CHECK(mid, H5I_INVALID_HID, "H5Screate_simple"); /* Read all the selected 10th elements in the dataset into "rdata" */ ret = H5Dread(did, H5T_NATIVE_INT, mid, sid, H5P_DEFAULT, rdata); @@ -15476,6 +15476,77 @@ test_hyper_io_1d(void) /**************************************************************** ** +** test_h5s_set_extent_none: +** Test to verify the behavior of dataspace code when passed +** a dataspace modified by H5Sset_extent_none(). +** +****************************************************************/ +static void +test_h5s_set_extent_none(void) +{ + hid_t sid = H5I_INVALID_HID; + hid_t dst_sid = H5I_INVALID_HID; + hid_t null_sid = H5I_INVALID_HID; + int rank = 1; + hsize_t current_dims = 123; + H5S_class_t cls; + int out_rank; + hsize_t out_dims; + hsize_t out_maxdims; + hssize_t out_points; + htri_t equal; + herr_t ret; + + /* Specific values here don't matter as we're just going to reset */ + sid = H5Screate_simple(rank, ¤t_dims, NULL); + CHECK(sid, H5I_INVALID_HID, "H5Screate_simple"); + + /* Dataspace class will be H5S_NULL after this. + * In versions prior to 1.10.7 / 1.12.1 this would produce a + * dataspace with the internal H5S_NO_CLASS class. + */ + ret = H5Sset_extent_none(sid); + CHECK(ret, FAIL, "H5Sset_extent_none"); + cls = H5Sget_simple_extent_type(sid); + VERIFY(cls, H5S_NULL, "H5Sget_simple_extent_type"); + + /* Extent getters should generate normal results and not segfault. + */ + out_rank = H5Sget_simple_extent_dims(sid, &out_dims, &out_maxdims); + VERIFY(out_rank, 0, "H5Sget_simple_extent_dims"); + out_rank = H5Sget_simple_extent_ndims(sid); + VERIFY(out_rank, 0, "H5Sget_simple_extent_ndims"); + out_points = H5Sget_simple_extent_npoints(sid); + VERIFY(out_points, 0, "H5Sget_simple_extent_npoints"); + + /* Check that copying the new (non-)extent works. + */ + dst_sid = H5Screate_simple(rank, ¤t_dims, NULL); + CHECK(dst_sid, H5I_INVALID_HID, "H5Screate_simple"); + ret = H5Sextent_copy(dst_sid, sid); + CHECK(ret, FAIL, "H5Sextent_copy"); + + /* Check that H5Sset_extent_none() produces the same extent as + * H5Screate(H5S_NULL). + */ + null_sid = H5Screate(H5S_NULL); + CHECK(null_sid, H5I_INVALID_HID, "H5Screate"); + equal = H5Sextent_equal(sid, null_sid); + VERIFY(equal, TRUE, "H5Sextent_equal"); + + /* Close */ + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); + ret = H5Sclose(dst_sid); + CHECK(ret, FAIL, "H5Sclose"); + ret = H5Sclose(null_sid); + CHECK(ret, FAIL, "H5Sclose"); + +} /* test_h5s_set_extent_none() */ + + +/**************************************************************** +** ** test_select(): Main H5S selection testing routine. ** ****************************************************************/ @@ -15660,6 +15731,11 @@ test_select(void) /* Test reading of 1-d disjoint file space to 1-d single block memory space */ test_hyper_io_1d(); + /* Test H5Sset_extent_none() functionality after we updated it to set + * the class to H5S_NULL instead of H5S_NO_CLASS. + */ + test_h5s_set_extent_none(); + } /* test_select() */ diff --git a/test/ttsafe_cancel.c b/test/ttsafe_cancel.c index dd52232..f6bcd0d 100644 --- a/test/ttsafe_cancel.c +++ b/test/ttsafe_cancel.c @@ -61,7 +61,7 @@ tts_cancel(void) pthread_attr_t attribute; hid_t dataset; int buffer; - int ret; + int H5_ATTR_NDEBUG_UNUSED ret; /* make thread scheduling global */ ret=pthread_attr_init(&attribute); diff --git a/test/tvltypes.c b/test/tvltypes.c index a6ed60e..e8c69b4 100644 --- a/test/tvltypes.c +++ b/test/tvltypes.c @@ -2398,17 +2398,17 @@ test_vltypes_fill_value(void) typedef struct dtype1_struct { unsigned int gui; unsigned int pgui; - char *str_id; - char *str_name; - char *str_desc; - char *str_orig; - char *str_stat; + const char *str_id; + const char *str_name; + const char *str_desc; + const char *str_orig; + const char *str_stat; unsigned int ver; double val; double ma; double mi; - char *str_form; - char *str_unit; + const char *str_form; + const char *str_unit; } dtype1_struct; herr_t ret; diff --git a/test/unregister.c b/test/unregister.c index a72b223..a2a507d 100644 --- a/test/unregister.c +++ b/test/unregister.c @@ -95,11 +95,20 @@ test_unregister_filters(hid_t fapl_id) char filename[FILENAME_BUF_SIZE]; const hsize_t chunk_dims[2] = {FILTER_CHUNK_DIM1, FILTER_CHUNK_DIM2}; /* Chunk dimensions */ hsize_t dims[2]; - int data[DSET_DIM1][DSET_DIM2]; + int **buf = NULL; + int *buf_data = NULL; herr_t ret; TESTING("Unregistering filter"); + /* Set up data array */ + if(NULL == (buf_data = (int *)HDcalloc(DSET_DIM1 * DSET_DIM2, sizeof(int)))) + TEST_ERROR; + if(NULL == (buf = (int **)HDcalloc(DSET_DIM1, sizeof(buf_data)))) + TEST_ERROR; + for (i = 0; i < DSET_DIM1; i++) + buf[i] = buf_data + (i * DSET_DIM2); + /* Create first file */ h5_fixname(FILENAME[0], fapl_id, filename, sizeof(filename)); if((fid1 = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) @@ -176,7 +185,7 @@ test_unregister_filters(hid_t fapl_id) /* Initialize the data for writing */ for(i = n = 0; i < DSET_DIM1; i++) for(j = 0; j < DSET_DIM2; j++) - data[i][j] = n++; + buf[i][j] = n++; /* Create the dataspace */ dims[0] = DSET_DIM1; @@ -189,7 +198,7 @@ test_unregister_filters(hid_t fapl_id) goto error; /* Write the data to the dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) goto error; /* Unregister the filter before closing the dataset. It should fail */ @@ -211,7 +220,7 @@ test_unregister_filters(hid_t fapl_id) goto error; /* Write the data to the dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) goto error; /* Close the dataset in the second file */ @@ -232,6 +241,9 @@ test_unregister_filters(hid_t fapl_id) if(H5Fclose(fid2) < 0) goto error; + HDfree(buf); + HDfree(buf_data); + PASSED(); return SUCCEED; @@ -247,6 +259,9 @@ error: H5Sclose(sid); } H5E_END_TRY; + HDfree(buf); + HDfree(buf_data); + return FAIL; } diff --git a/test/use.h b/test/use.h index d01b7d8..52537d6 100644 --- a/test/use.h +++ b/test/use.h @@ -41,23 +41,21 @@ typedef struct options_t { hsize_t chunkdims[UC_RANK]; /* chunk dims is (chunkplan, chunksize, chunksize) */ hsize_t dims[UC_RANK]; /* dataset initial dims */ hsize_t max_dims[UC_RANK]; /* dataset max dims */ - hsize_t nplanes; /* number of planes to write, default proportional to chunksize */ - char *filename; /* use case data filename */ - part_t launch; /* launch writer, reader or both */ - hbool_t use_swmr; /* use swmr open (1) or not */ - int iterations; /* iterations, default 1 */ + hsize_t nplanes; /* number of planes to write, default proportional to chunksize */ + char *filename; /* use case data filename */ + part_t launch; /* launch writer, reader or both */ + hbool_t use_swmr; /* use swmr open (1) or not */ + int iterations; /* iterations, default 1 */ + hid_t fapl_id; /* instance-specific FAPL ID */ + const char *progname; /* Program name (used in usage and dset name) */ } options_t; -/* global variables declarations */ -extern options_t UC_opts; /* Use Case Options */ -extern const char *progname_g; /* Program name */ - /* prototype declarations */ -int parse_option(int argc, char * const argv[]); -int setup_parameters(int argc, char * const argv[]); -void show_parameters(void); +int parse_option(int argc, char * const argv[], options_t * opts); +int setup_parameters(int argc, char * const argv[], options_t * opts); +void show_parameters(options_t * opts); void usage(const char *prog); -int create_uc_file(void); -int write_uc_file(hbool_t tosend, hid_t fid); -int read_uc_file(hbool_t towait); +int create_uc_file(options_t * opts); +int write_uc_file(hbool_t tosend, hid_t file_id, options_t * opts); +int read_uc_file(hbool_t towait, options_t * opts); diff --git a/test/use_append_chunk.c b/test/use_append_chunk.c index 8ab63bd..8fcf0d3 100644 --- a/test/use_append_chunk.c +++ b/test/use_append_chunk.c @@ -69,43 +69,40 @@ #include "use.h" -/* Global Variable definitions */ -options_t UC_opts; /* Use Case Options */ -const char *progname_g="use_append_chunk"; /* program name */ +#define USE_APPEND_CHUNK_PROGNAME "use_append_chunk" + +static options_t UC_opts; /* Use Case Options */ /* Setup parameters for the use case. * Return: 0 succeed; -1 fail. */ -int setup_parameters(int argc, char * const argv[]) +int +setup_parameters(int argc, char * const argv[], options_t * opts) { /* use case defaults */ - HDmemset(&UC_opts, 0, sizeof(options_t)); - UC_opts.chunksize = Chunksize_DFT; - UC_opts.use_swmr = TRUE; /* use swmr open */ - UC_opts.iterations = 1; - UC_opts.chunkplanes = 1; - - /* parse options */ - if (parse_option(argc, argv) < 0) - return(-1); - - /* set chunk dims */ - UC_opts.chunkdims[0] = UC_opts.chunkplanes; - UC_opts.chunkdims[1] = UC_opts.chunkdims[2] = UC_opts.chunksize; - - /* set dataset initial and max dims */ - UC_opts.dims[0] = 0; - UC_opts.max_dims[0] = H5S_UNLIMITED; - UC_opts.dims[1] = UC_opts.dims[2] = UC_opts.max_dims[1] = UC_opts.max_dims[2] = UC_opts.chunksize; - - /* set nplanes */ - if (UC_opts.nplanes == 0) - UC_opts.nplanes = (hsize_t)UC_opts.chunksize; - - /* show parameters and return */ - show_parameters(); + HDmemset(opts, 0, sizeof(options_t)); + opts->chunksize = Chunksize_DFT; + opts->use_swmr = TRUE; /* use swmr open */ + opts->iterations = 1; + opts->chunkplanes = 1; + opts->progname = USE_APPEND_CHUNK_PROGNAME; + + if (parse_option(argc, argv, opts) < 0) + return(-1); + + opts->chunkdims[0] = opts->chunkplanes; + opts->chunkdims[1] = opts->chunkdims[2] = opts->chunksize; + + opts->dims[0] = 0; + opts->max_dims[0] = H5S_UNLIMITED; + opts->dims[1] = opts->dims[2] = opts->max_dims[1] = opts->max_dims[2] = opts->chunksize; + + if (opts->nplanes == 0) + opts->nplanes = (hsize_t)opts->chunksize; + + show_parameters(opts); return(0); -} +} /* setup_parameters() */ /* Overall Algorithm: @@ -127,10 +124,8 @@ main(int argc, char *argv[]) hbool_t send_wait = FALSE; hid_t fapl = -1; /* File access property list */ hid_t fid = -1; /* File ID */ - char *name; /* Test file name */ - /* initialization */ - if (setup_parameters(argc, argv) < 0){ + if (setup_parameters(argc, argv, &UC_opts) < 0) { Hgoto_error(1); } @@ -150,33 +145,58 @@ main(int argc, char *argv[]) /* =========== */ if (UC_opts.launch != UC_READER) { HDprintf("Creating skeleton data file for test...\n"); - if (create_uc_file() < 0){ + if ((UC_opts.fapl_id = h5_fileaccess()) < 0) { + HDfprintf(stderr, "can't create creation FAPL\n"); + Hgoto_error(1); + } + if (H5Pset_libver_bounds(UC_opts.fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) { + HDfprintf(stderr, "can't set creation FAPL libver bounds\n"); + Hgoto_error(1); + } + if (create_uc_file(&UC_opts) < 0) { HDfprintf(stderr, "***encounter error\n"); Hgoto_error(1); - } else + } else { HDprintf("File created.\n"); + } + /* Close FAPL to prevent issues with forking later */ + if (H5Pclose(UC_opts.fapl_id) < 0) { + HDfprintf(stderr, "can't close creation FAPL\n"); + Hgoto_error(1); + } + UC_opts.fapl_id = H5I_INVALID_HID; } - if (UC_opts.launch==UC_READWRITE){ - /* fork process */ - if((childpid = HDfork()) < 0) { + /* ============ */ + /* Fork process */ + /* ============ */ + if (UC_opts.launch == UC_READWRITE) { + if ((childpid = HDfork()) < 0) { HDperror("fork"); Hgoto_error(1); - }; - }; + } + } mypid = HDgetpid(); /* ============= */ /* launch reader */ /* ============= */ - if (UC_opts.launch != UC_WRITER){ + if (UC_opts.launch != UC_WRITER) { /* child process launch the reader */ - if(0 == childpid) { + if (0 == childpid) { HDprintf("%d: launch reader process\n", mypid); - if (read_uc_file(send_wait) < 0){ + if ((UC_opts.fapl_id = h5_fileaccess()) < 0) { + HDfprintf(stderr, "can't create read FAPL\n"); + HDexit(EXIT_FAILURE); + } + if (read_uc_file(send_wait, &UC_opts) < 0) { HDfprintf(stderr, "read_uc_file encountered error\n"); HDexit(EXIT_FAILURE); } + if (H5Pclose(UC_opts.fapl_id) < 0) { + HDfprintf(stderr, "can't close read FAPL\n"); + HDexit(EXIT_FAILURE); + } HDexit(EXIT_SUCCESS); } } @@ -187,50 +207,49 @@ main(int argc, char *argv[]) /* this process continues to launch the writer */ HDprintf("%d: continue as the writer process\n", mypid); - name = UC_opts.filename; - - /* Set file access proeprty list */ - if((fapl = h5_fileaccess()) < 0) + if ((fapl = h5_fileaccess()) < 0) { + HDfprintf(stderr, "can't create write FAPL\n"); Hgoto_error(1); + } - if(UC_opts.use_swmr) - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (UC_opts.use_swmr) { + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) { + HDfprintf(stderr, "can't set write FAPL libver bounds\n"); Hgoto_error(1); + } + } - /* Open the file */ - if((fid = H5Fopen(name, H5F_ACC_RDWR | (UC_opts.use_swmr ? H5F_ACC_SWMR_WRITE : 0), fapl)) < 0) { + if ((fid = H5Fopen(UC_opts.filename, H5F_ACC_RDWR | (UC_opts.use_swmr ? H5F_ACC_SWMR_WRITE : 0), fapl)) < 0) { HDfprintf(stderr, "H5Fopen failed\n"); Hgoto_error(1); } - if(write_uc_file(send_wait, fid) < 0) { + if (write_uc_file(send_wait, fid, &UC_opts) < 0) { HDfprintf(stderr, "write_uc_file encountered error\n"); Hgoto_error(1); } + if (H5Fclose(fid) < 0) { + HDfprintf(stderr, "Failed to close write\n"); + Hgoto_error(1); + } + + if (H5Pclose(fapl) < 0) { + HDfprintf(stderr, "can't close write FAPL\n"); + Hgoto_error(1); + } + /* ================================================ */ /* If readwrite, collect exit code of child process */ /* ================================================ */ - if (UC_opts.launch == UC_READWRITE){ - if ((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0){ + if (UC_opts.launch == UC_READWRITE) { + if ((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0) { HDperror("waitpid"); Hgoto_error(1); } - /* Close the file */ - if(H5Fclose(fid) < 0) { - HDfprintf(stderr, "Failed to close file id\n"); - Hgoto_error(1); - } - - /* Close the property list */ - if(H5Pclose(fapl) < 0) { - HDfprintf(stderr, "Failed to close the property list\n"); - Hgoto_error(1); - } - - if (WIFEXITED(child_status)){ - if ((child_ret_value=WEXITSTATUS(child_status)) != 0){ + if (WIFEXITED(child_status)) { + if ((child_ret_value = WEXITSTATUS(child_status)) != 0) { HDprintf("%d: child process exited with non-zero code (%d)\n", mypid, child_ret_value); Hgoto_error(2); @@ -242,8 +261,7 @@ main(int argc, char *argv[]) } done: - /* Print result and exit */ - if (ret_value != 0){ + if (ret_value != 0) { HDprintf("Error(s) encountered\n"); } else { HDprintf("All passed\n"); diff --git a/test/use_append_chunk_mirror.c b/test/use_append_chunk_mirror.c new file mode 100644 index 0000000..6ee01c0 --- /dev/null +++ b/test/use_append_chunk_mirror.c @@ -0,0 +1,403 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* HACKED VERSION + * Demonstrate SWMR with a mirrored file. + * + * Must be built with SERVER_IP as the IP address of the target system + * with a running mirror server, and SERVER_PORT as the primary server port. + * + * In addition to the local file, 'shinano.h5' will be created on the remote + * system, mirroring the local file. The file location will be local to + * Server's/Writer's invocation directory. + * + * Template for demonstration purposes: + * + * # Launch mirror server on remote machine (in foreground to easily stop) + * REMOTE(1)$ ./mirror_server /path/to/mirror_worker + * + * # Launch chunk writer with plenty of chunks. + * LOCAL(1)$ ./use_append_chunk_mirror -l w -n 10000 + * + * # Wait one second for files to be created. + * + * # Launch chunk readers on both files. + * LOCAL(2)$ ./use_append_chunk_mirror -l r -n 10000 + * REMOTE(2)$ ./use_append_chunk_mirror -l r -n 10000 -f shinano.h5 + * + * # Hard-stop the server. + * REMOTE(1)$ ^C + * # alt, softer shutdown using echo and nc + * echo "SHUTDOWN" | nc localhost 3000 + */ + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Use Case 1.7 Appending a single chunk + * Description: + * Appending a single chunk of raw data to a dataset along an unlimited + * dimension within a pre-created file and reading the new data back. + * Goal: + * Read data appended by the Writer to a pre-existing dataset in a + * file. The dataset has one or more unlimited dimensions. The data is + * appended by a hyperslab that is contained in one chunk (for example, + * appending 2-dim planes along the slowest changing dimension in the + * 3-dim dataset). + * Level: + * User Level + * Guarantees: + * o Readers will see the modified dimension sizes after the Writer + * finishes HDF5 metadata updates and issues H5Fflush or H5Oflush calls. + * o Readers will see newly appended data after the Writer finishes + * the flush operation. + * + * Preconditions: + * o Readers are not allowed to modify the file. + * o All datasets that are modified by the Writer exist when the Writer + * opens the file. + * o All datasets that are modified by the Writer exist when a Reader + * opens the file. + * o Data is written by a hyperslab contained in one chunk. + * + * Main Success Scenario: + * 1. An application creates a file with required objects (groups, + * datasets, and attributes). + * 2. The Writer application opens the file and datasets in the file + * and starts adding data along the unlimited dimension using a hyperslab + * selection that corresponds to an HDF5 chunk. + * 3. A Reader opens the file and a dataset in a file, and queries + * the sizes of the dataset; if the extent of the dataset has changed, + * reads the appended data back. + * + * Discussion points: + * 1. Since the new data is written to the file, and metadata update + * operation of adding pointer to the newly written chunk is atomic and + * happens after the chunk is on the disk, only two things may happen + * to the Reader: + * o The Reader will not see new data. + * o The Reader will see all new data written by Writer. + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* Created: Jacob Smith, 2019 */ + +#include "use.h" + +/* This test uses many POSIX things that are not available on + * Windows. We're using a check for fork(2) here as a proxy for + * all POSIX/Unix/Linux things until this test can be made + * more platform-independent. + */ +#ifdef H5_HAVE_FORK + +#ifdef H5_HAVE_MIRROR_VFD + +#define THIS_PROGNAME "use_append_chunk_mirror" + +#define CONNECT_WITH_JELLY 0 + +#if CONNECT_WITH_JELLY +#define SERVER_IP "10.10.10.248" /* hard-coded IP address */ +#else +#define SERVER_IP "127.0.0.1" /* localhost */ +#endif /* CONNECT_WITH_JELLY */ +#define SERVER_PORT 3000 /* hard-coded port number */ +#define MIRROR_FILE_NAME "shinano.h5" /* hard-coded duplicate/mirror filename */ + +static options_t UC_opts; /* Use Case Options */ + +/* Setup parameters for the use case. + * Return: 0 succeed; -1 fail. + */ +int +setup_parameters(int argc, char * const argv[], options_t * opts) +{ + /* use case defaults */ + HDmemset(opts, 0, sizeof(options_t)); + opts->chunksize = Chunksize_DFT; + opts->use_swmr = TRUE; + opts->iterations = 1; + opts->chunkplanes = 1; + opts->progname = THIS_PROGNAME; + + if (parse_option(argc, argv, opts) < 0) + return(-1); + + opts->chunkdims[0] = opts->chunkplanes; + opts->chunkdims[1] = opts->chunkdims[2] = opts->chunksize; + + opts->dims[0] = 0; + opts->max_dims[0] = H5S_UNLIMITED; + opts->dims[1] = opts->dims[2] = opts->max_dims[1] = opts->max_dims[2] = opts->chunksize; + + if (opts->nplanes == 0) + opts->nplanes = (hsize_t)opts->chunksize; + + show_parameters(opts); + return(0); +} /* setup_parameters() */ + + +/* Overall Algorithm: + * Parse options from user; + * Generate/pre-created test files needed and close it; + * fork: child process becomes the reader process; + * while parent process continues as the writer process; + * both run till ending conditions are met. + */ +int +main(int argc, char *argv[]) +{ + pid_t childpid=0; + pid_t mypid, tmppid; + int child_status; + int child_wait_option=0; + int ret_value = 0; + int child_ret_value; + hbool_t send_wait = FALSE; + hid_t fid = -1; /* File ID */ + H5FD_mirror_fapl_t mirr_fa; + H5FD_splitter_vfd_config_t split_fa; + hid_t mirr_fapl_id = H5I_INVALID_HID; + + if (setup_parameters(argc, argv, &UC_opts) < 0) { + Hgoto_error(1); + } + + mirr_fa.magic = H5FD_MIRROR_FAPL_MAGIC; + mirr_fa.version = H5FD_MIRROR_CURR_FAPL_T_VERSION; + mirr_fa.handshake_port = SERVER_PORT; + HDstrncpy(mirr_fa.remote_ip, SERVER_IP, H5FD_MIRROR_MAX_IP_LEN); + + + split_fa.wo_fapl_id = H5I_INVALID_HID; + split_fa.rw_fapl_id = H5I_INVALID_HID; + split_fa.magic = H5FD_SPLITTER_MAGIC; + split_fa.version = H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION; + split_fa.log_file_path[0] = '\0'; /* none */ + split_fa.ignore_wo_errs = FALSE; + HDstrncpy(split_fa.wo_path, MIRROR_FILE_NAME, H5FD_SPLITTER_PATH_MAX); + + /* Determine the need to send/wait message file*/ + if (UC_opts.launch == UC_READWRITE) { + HDunlink(WRITER_MESSAGE); + send_wait = TRUE; + } + + /* ==============================================================*/ + /* UC_READWRITE: create datafile, launch both reader and writer. */ + /* UC_WRITER: create datafile, skip reader, launch writer. */ + /* UC_READER: skip create, launch reader, exit. */ + /* ==============================================================*/ + /* =========== */ + /* Create file */ + /* =========== */ + if (UC_opts.launch != UC_READER) { + HDprintf("Creating skeleton data file for test...\n"); + + /* Prepare mirror child driver */ + mirr_fapl_id = H5Pcreate(H5P_FILE_ACCESS); + if (mirr_fapl_id == H5I_INVALID_HID) { + HDfprintf(stderr, "can't create creation mirror FAPL\n"); + Hgoto_error(1); + } + if (H5Pset_fapl_mirror(mirr_fapl_id, &mirr_fa) < 0) { + HDfprintf(stderr, "can't set creation mirror FAPL\n"); + H5Eprint2(H5E_DEFAULT, stdout); + Hgoto_error(1); + } + + /* Prepare parent "splitter" driver in UC_opts */ + split_fa.wo_fapl_id = mirr_fapl_id; + split_fa.rw_fapl_id = H5P_DEFAULT; + UC_opts.fapl_id = H5Pcreate(H5P_FILE_ACCESS); + if (UC_opts.fapl_id == H5I_INVALID_HID) { + HDfprintf(stderr, "can't create creation FAPL\n"); + Hgoto_error(1); + } + if (H5Pset_fapl_splitter(UC_opts.fapl_id, &split_fa) < 0) { + HDfprintf(stderr, "can't set creation FAPL\n"); + H5Eprint2(H5E_DEFAULT, stdout); + Hgoto_error(1); + } + + if (H5Pset_libver_bounds(UC_opts.fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) { + HDfprintf(stderr, "can't set creation FAPL libver bounds\n"); + Hgoto_error(1); + } + + /* Create file */ + if (create_uc_file(&UC_opts) < 0) { + HDfprintf(stderr, "***encounter error\n"); + Hgoto_error(1); + } else { + HDprintf("File created.\n"); + } + + /* Close FAPLs to prevent issues with forking later */ + if (H5Pclose(UC_opts.fapl_id) < 0) { + HDfprintf(stderr, "can't close creation FAPL\n"); + Hgoto_error(1); + } + UC_opts.fapl_id = H5I_INVALID_HID; + if (H5Pclose(mirr_fapl_id) < 0) { + HDfprintf(stderr, "can't close creation mirror FAPL\n"); + Hgoto_error(1); + } + mirr_fapl_id = H5I_INVALID_HID; + } + + /* ============ */ + /* Fork process */ + /* ============ */ + if (UC_opts.launch == UC_READWRITE) { + if ((childpid = HDfork()) < 0) { + HDperror("fork"); + Hgoto_error(1); + } + } + mypid = HDgetpid(); + + /* ============= */ + /* launch reader */ + /* ============= */ + if (UC_opts.launch != UC_WRITER) { + /* child process -- launch the reader */ + /* reader only opens the one file -- separate reader needed for mirrored file 'shinano.h5' */ + if (0 == childpid) { + HDprintf("%d: launch reader process\n", mypid); + + UC_opts.fapl_id = H5P_DEFAULT; + if (read_uc_file(send_wait, &UC_opts) < 0) { + HDfprintf(stderr, "read_uc_file encountered error (%d)\n", mypid); + HDexit(1); + } + + HDexit(0); + } + } + + /* ============= */ + /* launch writer */ + /* ============= */ + /* this process continues to launch the writer */ + HDprintf("%d: continue as the writer process\n", mypid); + + /* Prepare mirror child driver */ + mirr_fapl_id = H5Pcreate(H5P_FILE_ACCESS); + if (mirr_fapl_id == H5I_INVALID_HID) { + HDfprintf(stderr, "can't create creation mirror FAPL\n"); + Hgoto_error(1); + } + if (H5Pset_fapl_mirror(mirr_fapl_id, &mirr_fa) < 0) { + HDfprintf(stderr, "can't set creation mirror FAPL\n"); + H5Eprint2(H5E_DEFAULT, stdout); + Hgoto_error(1); + } + + /* Prepare parent "splitter" driver in UC_opts */ + split_fa.wo_fapl_id = mirr_fapl_id; + split_fa.rw_fapl_id = H5P_DEFAULT; + UC_opts.fapl_id = H5Pcreate(H5P_FILE_ACCESS); + if (UC_opts.fapl_id == H5I_INVALID_HID) { + HDfprintf(stderr, "can't create creation FAPL\n"); + Hgoto_error(1); + } + if (H5Pset_fapl_splitter(UC_opts.fapl_id, &split_fa) < 0) { + HDfprintf(stderr, "can't set creation FAPL\n"); + H5Eprint2(H5E_DEFAULT, stdout); + Hgoto_error(1); + } + + if (UC_opts.use_swmr) { + if (H5Pset_libver_bounds(UC_opts.fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) { + HDfprintf(stderr, "can't set write FAPL libver bounds\n"); + Hgoto_error(1); + } + } + + if ((fid = H5Fopen(UC_opts.filename, H5F_ACC_RDWR | (UC_opts.use_swmr ? H5F_ACC_SWMR_WRITE : 0), UC_opts.fapl_id)) < 0) { + HDfprintf(stderr, "H5Fopen failed\n"); + Hgoto_error(1); + } + + if (write_uc_file(send_wait, fid, &UC_opts) < 0) { + HDfprintf(stderr, "write_uc_file encountered error\n"); + Hgoto_error(1); + } + + if (H5Fclose(fid) < 0) { + HDfprintf(stderr, "Failed to close write\n"); + Hgoto_error(1); + } + + if (H5Pclose(UC_opts.fapl_id) < 0) { + HDfprintf(stderr, "can't close write FAPL\n"); + Hgoto_error(1); + } + + if (H5Pclose(mirr_fapl_id) < 0) { + HDfprintf(stderr, "can't close write mirror FAPL\n"); + Hgoto_error(1); + } + + /* ================================================ */ + /* If readwrite, collect exit code of child process */ + /* ================================================ */ + if (UC_opts.launch == UC_READWRITE) { + if ((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0) { + HDperror("waitpid"); + Hgoto_error(1); + } + + if (WIFEXITED(child_status)) { + if ((child_ret_value = WEXITSTATUS(child_status)) != 0) { + HDprintf("%d: child process exited with non-zero code (%d)\n", + mypid, child_ret_value); + Hgoto_error(2); + } + } else { + HDprintf("%d: child process terminated abnormally\n", mypid); + Hgoto_error(2); + } + } + +done: + if (ret_value != 0) { + HDprintf("Error(s) encountered\n"); + } else { + HDprintf("All passed\n"); + } + + return(ret_value); +} + +#else /* H5_HAVE_MIRROR_VFD */ + +int +main(void) +{ + HDfprintf(stderr, "Mirror VFD is not built. Skipping.\n"); + return EXIT_SUCCESS; +} /* end main() */ + +#endif /* H5_HAVE_MIRROR_VFD */ + +#else /* H5_HAVE_FORK */ + +int +main(void) +{ + HDfprintf(stderr, "Non-POSIX platform. Skipping.\n"); + return EXIT_SUCCESS; +} /* end main() */ + +#endif /* H5_HAVE_FORK */ + diff --git a/test/use_append_mchunks.c b/test/use_append_mchunks.c index 41d355e..2eb5a1d 100644 --- a/test/use_append_mchunks.c +++ b/test/use_append_mchunks.c @@ -61,43 +61,42 @@ #include "use.h" -/* Global Variable definitions */ -options_t UC_opts; /* Use Case Options */ -const char *progname_g="use_append_mchunks"; /* program name */ +#define USE_APPEND_MCHUNKS_PROGNAME "use_append_mchunks" + +static options_t UC_opts; /* Use Case Options */ /* Setup parameters for the use case. * Return: 0 succeed; -1 fail. */ -int setup_parameters(int argc, char * const argv[]) +int +setup_parameters(int argc, char * const argv[], options_t * opts) { /* use case defaults */ - HDmemset(&UC_opts, 0, sizeof(options_t)); - UC_opts.chunksize = Chunksize_DFT; - UC_opts.use_swmr = 1; /* use swmr open */ - UC_opts.iterations = 1; - UC_opts.chunkplanes = 1; - - /* parse options */ - if (parse_option(argc, argv) < 0){ - return(-1); + HDmemset(opts, 0, sizeof(options_t)); + opts->chunksize = Chunksize_DFT; + opts->use_swmr = 1; /* use swmr open */ + opts->iterations = 1; + opts->chunkplanes = 1; + opts->progname = USE_APPEND_MCHUNKS_PROGNAME; + opts->fapl_id = H5I_INVALID_HID; + + if (parse_option(argc, argv, opts) < 0) { + return(-1); } - /* set chunk dims */ - UC_opts.chunkdims[0] = (hsize_t)UC_opts.chunkplanes; - UC_opts.chunkdims[1] = UC_opts.chunkdims[2] = (hsize_t)UC_opts.chunksize; - /* set dataset initial and max dims */ - UC_opts.dims[0] = 0; - UC_opts.max_dims[0] = H5S_UNLIMITED; - UC_opts.dims[1] = UC_opts.dims[2] = UC_opts.max_dims[1] = UC_opts.max_dims[2] = 2 * (hsize_t)UC_opts.chunksize; + opts->chunkdims[0] = (hsize_t)opts->chunkplanes; + opts->chunkdims[1] = opts->chunkdims[2] = (hsize_t)opts->chunksize; + + opts->dims[0] = 0; + opts->max_dims[0] = H5S_UNLIMITED; + opts->dims[1] = opts->dims[2] = opts->max_dims[1] = opts->max_dims[2] = 2 * (hsize_t)opts->chunksize; - /* set nplanes */ - if (UC_opts.nplanes == 0) - UC_opts.nplanes = 2 * (hsize_t)UC_opts.chunksize; + if (opts->nplanes == 0) + opts->nplanes = 2 * (hsize_t)opts->chunksize; - /* show parameters and return */ - show_parameters(); + show_parameters(opts); return(0); -} +} /* end setup_parameters() */ /* Overall Algorithm: @@ -119,10 +118,8 @@ main(int argc, char *argv[]) hbool_t send_wait = 0; hid_t fapl = -1; /* File access property list */ hid_t fid = -1; /* File ID */ - char *name; /* Test file name */ - /* initialization */ - if (setup_parameters(argc, argv) < 0){ + if (setup_parameters(argc, argv, &UC_opts) < 0) { Hgoto_error(1); } @@ -137,25 +134,42 @@ main(int argc, char *argv[]) /* UC_WRITER: create datafile, skip reader, launch writer. */ /* UC_READER: skip create, launch reader, exit. */ /* ==============================================================*/ - /* ============*/ + /* =========== */ /* Create file */ - /* ============*/ - if (UC_opts.launch != UC_READER){ + /* =========== */ + if (UC_opts.launch != UC_READER) { HDprintf("Creating skeleton data file for test...\n"); - if (create_uc_file() < 0){ - HDfprintf(stderr, "***encounter error\n"); - Hgoto_error(1); - }else - HDprintf("File created.\n"); + if ((UC_opts.fapl_id = h5_fileaccess()) < 0) { + HDfprintf(stderr, "can't create creation FAPL\n"); + Hgoto_error(1); + } + if (H5Pset_libver_bounds(UC_opts.fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) { + HDfprintf(stderr, "can't set creation FAPL libver bounds\n"); + Hgoto_error(1); + } + if (create_uc_file(&UC_opts) < 0) { + HDfprintf(stderr, "***encounter error\n"); + Hgoto_error(1); + } else { + HDprintf("File created.\n"); + } + /* Close FAPL to prevent issues with forking later */ + if (H5Pclose(UC_opts.fapl_id) < 0) { + HDfprintf(stderr, "can't close creation FAPL\n"); + Hgoto_error(1); + } + UC_opts.fapl_id = H5I_INVALID_HID; } - if (UC_opts.launch==UC_READWRITE){ - /* fork process */ - if((childpid = fork()) < 0) { + /* ============ */ + /* Fork process */ + /* ============ */ + if (UC_opts.launch==UC_READWRITE) { + if ((childpid = fork()) < 0) { perror("fork"); Hgoto_error(1); - }; - }; + } + } mypid = getpid(); /* ============= */ @@ -165,10 +179,18 @@ main(int argc, char *argv[]) /* child process launch the reader */ if (0 == childpid) { HDprintf("%d: launch reader process\n", mypid); - if (read_uc_file(send_wait) < 0){ + if ((UC_opts.fapl_id = h5_fileaccess()) < 0) { + HDfprintf(stderr, "can't create read FAPL\n"); + HDexit(EXIT_FAILURE); + } + if (read_uc_file(send_wait, &UC_opts) < 0) { HDfprintf(stderr, "read_uc_file encountered error\n"); HDexit(EXIT_FAILURE); } + if (H5Pclose(UC_opts.fapl_id) < 0) { + HDfprintf(stderr, "can't close read FAPL\n"); + HDexit(EXIT_FAILURE); + } HDexit(EXIT_SUCCESS); } } @@ -179,27 +201,38 @@ main(int argc, char *argv[]) /* this process continues to launch the writer */ HDprintf("%d: continue as the writer process\n", mypid); - name = UC_opts.filename; - /* Set the file access property list */ - if((fapl = h5_fileaccess()) < 0) + if ((fapl = h5_fileaccess()) < 0) { + HDfprintf(stderr, "can't get write FAPL\n"); Hgoto_error(1); + } - if(UC_opts.use_swmr) - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (UC_opts.use_swmr) { + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) { + HDfprintf(stderr, "can't set write FAPL libver bounds\n"); Hgoto_error(1); + } + } - /* Open the file */ - if((fid = H5Fopen(name, H5F_ACC_RDWR | (UC_opts.use_swmr ? H5F_ACC_SWMR_WRITE : 0), fapl)) < 0) { + if ((fid = H5Fopen(UC_opts.filename, H5F_ACC_RDWR | (UC_opts.use_swmr ? H5F_ACC_SWMR_WRITE : 0), fapl)) < 0) { HDfprintf(stderr, "H5Fopen failed\n"); Hgoto_error(1); } - if(write_uc_file(send_wait, fid) < 0) { + if (write_uc_file(send_wait, fid, &UC_opts) < 0) { HDfprintf(stderr, "write_uc_file encountered error\n"); Hgoto_error(1); } + if (H5Fclose(fid) < 0) { + HDfprintf(stderr, "Failed to close file id\n"); + Hgoto_error(1); + } + + if (H5Pclose(fapl) < 0) { + HDfprintf(stderr, "can't close write FAPL\n"); + Hgoto_error(1); + } /* ================================================ */ /* If readwrite, collect exit code of child process */ @@ -210,20 +243,8 @@ main(int argc, char *argv[]) Hgoto_error(1); } - /* Close the file */ - if(H5Fclose(fid) < 0) { - HDfprintf(stderr, "Failed to close file id\n"); - Hgoto_error(1); - } - - /* Close the property list */ - if(H5Pclose(fapl) < 0) { - HDfprintf(stderr, "Failed to close the property list\n"); - Hgoto_error(1); - } - - if (WIFEXITED(child_status)){ - if ((child_ret_value=WEXITSTATUS(child_status)) != 0){ + if (WIFEXITED(child_status)) { + if ((child_ret_value=WEXITSTATUS(child_status)) != 0) { HDprintf("%d: child process exited with non-zero code (%d)\n", mypid, child_ret_value); Hgoto_error(1); @@ -242,7 +263,7 @@ done: } return(ret_value); -} +} /* end main() */ #else /* H5_HAVE_FORK */ diff --git a/test/use_common.c b/test/use_common.c index 4111b24..7e19167 100644 --- a/test/use_common.c +++ b/test/use_common.c @@ -21,10 +21,11 @@ #include "use.h" -#define H5D_FRIEND /*suppress error about including H5Dpkg */ -#define H5D_TESTING -#include "H5Dpkg.h" - +/* ---------------------------------------------------------------------------- + * Print a common/shared usage message. + * Receives program name to show default test file name (.h5). + * ---------------------------------------------------------------------------- + */ void usage(const char *prog) { @@ -41,10 +42,13 @@ usage(const char *prog) HDfprintf(stderr, "\n"); } /* end usage() */ -/* Setup Use Case parameters by parsing command line options. -* Setup default values if not set by options. */ +/* ---------------------------------------------------------------------------- + * Setup Use Case parameters by parsing command line options. + * Includes default values for unspecified options. + * ---------------------------------------------------------------------------- + */ int -parse_option(int argc, char * const argv[]) +parse_option(int argc, char * const argv[], options_t * opts) { int ret_value=0; int c; @@ -56,302 +60,307 @@ parse_option(int argc, char * const argv[]) /* suppress getopt from printing error */ opterr = 0; - while (1){ - c = getopt (argc, argv, nagg_options); - if (-1 == c) - break; - switch (c) { - case 'h': - usage(progname_g); - HDexit(EXIT_SUCCESS); - break; - case 'f': /* usecase data file name */ - UC_opts.filename = optarg; - break; - case 'i': /* iterations */ - if ((UC_opts.iterations = HDatoi(optarg)) <= 0) { - HDfprintf(stderr, "bad iterations number %s, must be a positive integer\n", optarg); - usage(progname_g); - Hgoto_error(-1); - }; - break; - case 'l': /* launch reader or writer only */ - switch (*optarg) { - case 'r': /* reader only */ - UC_opts.launch = UC_READER; - break; - case 'w': /* writer only */ - UC_opts.launch = UC_WRITER; - break; + while (1) { + c = getopt(argc, argv, nagg_options); + if (-1 == c) + break; + switch (c) { + case 'h': + usage(opts->progname); + exit(EXIT_SUCCESS); + break; + case 'f': /* usecase data file name */ + opts->filename = HDstrdup(optarg); + break; + case 'i': /* iterations */ + if ((opts->iterations = HDatoi(optarg)) <= 0) { + HDfprintf(stderr, "bad iterations number %s, must be a positive integer\n", optarg); + usage(opts->progname); + Hgoto_error(-1); + } + break; + case 'l': /* launch reader or writer only */ + switch (*optarg) { + case 'r': /* reader only */ + opts->launch = UC_READER; + break; + case 'w': /* writer only */ + opts->launch = UC_WRITER; + break; + default: + HDfprintf(stderr, "launch value(%c) should be w or r only.\n", *optarg); + usage(opts->progname); + Hgoto_error(-1); + break; + } /* end switch (reader/writer-only mode toggle) */ + break; + case 'n': /* number of planes to write/read */ + if ((opts->nplanes = HDstrtoul(optarg, NULL, 0)) <= 0) { + HDfprintf(stderr, "bad number of planes %s, must be a positive integer\n", optarg); + usage(opts->progname); + Hgoto_error(-1); + } + break; + case 's': /* use swmr file open mode */ + use_swmr = HDatoi(optarg); + if (use_swmr != 0 && use_swmr != 1) { + HDfprintf(stderr, "swmr value should be 0(no) or 1(yes)\n"); + usage(opts->progname); + Hgoto_error(-1); + } + opts->use_swmr = (hbool_t)use_swmr; + break; + case 'y': /* Number of planes per chunk */ + if ((opts->chunkplanes = HDstrtoul(optarg, NULL, 0)) <= 0) { + HDfprintf(stderr, "bad number of planes per chunk %s, must be a positive integer\n", optarg); + usage(opts->progname); + Hgoto_error(-1); + } + break; + case 'z': /* size of chunk=(z,z) */ + if ((opts->chunksize = HDstrtoull(optarg, NULL, 0)) <= 0) { + HDfprintf(stderr, "bad chunksize %s, must be a positive integer\n", optarg); + usage(opts->progname); + Hgoto_error(-1); + } + break; + case '?': + HDfprintf(stderr, "getopt returned '%c'.\n", c); + Hgoto_error(-1); default: - HDfprintf(stderr, "launch value(%c) should be w or r only.\n", *optarg); - usage(progname_g); - Hgoto_error(-1); - break; - } - break; - case 'n': /* number of planes to write/read */ - if ((UC_opts.nplanes = HDstrtoul(optarg, NULL, 0)) <= 0) { - HDfprintf(stderr, "bad number of planes %s, must be a positive integer\n", optarg); - usage(progname_g); - Hgoto_error(-1); - }; - break; - case 's': /* use swmr file open mode */ - use_swmr = HDatoi(optarg); - if (use_swmr != 0 && use_swmr != 1) { - HDfprintf(stderr, "swmr value should be 0(no) or 1(yes)\n"); - usage(progname_g); + HDfprintf(stderr, "getopt returned unexpected value.\n"); + HDfprintf(stderr, "Unexpected value is %d\n", c); Hgoto_error(-1); - } - UC_opts.use_swmr = (hbool_t)use_swmr; - break; - case 'y': /* Number of planes per chunk */ - if ((UC_opts.chunkplanes = HDstrtoul(optarg, NULL, 0)) <= 0) { - HDfprintf(stderr, "bad number of planes per chunk %s, must be a positive integer\n", optarg); - usage(progname_g); - Hgoto_error(-1); - }; - break; - case 'z': /* size of chunk=(z,z) */ - if ((UC_opts.chunksize = HDstrtoull(optarg, NULL, 0)) <= 0) { - HDfprintf(stderr, "bad chunksize %s, must be a positive integer\n", optarg); - usage(progname_g); - Hgoto_error(-1); - }; - break; - case '?': - HDfprintf(stderr, "getopt returned '%c'.\n", c); - Hgoto_error(-1); - default: - HDfprintf(stderr, "getopt returned unexpected value.\n"); - HDfprintf(stderr, "Unexpected value is %d\n", c); - Hgoto_error(-1); - } - } + } /* end switch (argument symbol) */ + } /* end while (there are still arguments) */ /* set test file name if not given */ - if (!UC_opts.filename){ - /* default data file name is .h5 */ - if ((UC_opts.filename=(char*)HDmalloc(HDstrlen(progname_g)+4))==NULL) { - HDfprintf(stderr, "malloc: failed\n"); - Hgoto_error(-1); - }; - HDstrcpy(UC_opts.filename, progname_g); - HDstrcat(UC_opts.filename, ".h5"); + if (!opts->filename) { + /* default data file name is .h5 */ + if ((opts->filename=(char*)HDmalloc(HDstrlen(opts->progname)+4))==NULL) { + HDfprintf(stderr, "malloc: failed\n"); + Hgoto_error(-1); + } + HDstrcpy(opts->filename, opts->progname); + HDstrcat(opts->filename, ".h5"); } done: - /* All done. */ return(ret_value); -} +} /* end parse_option() */ -/* Show parameters used for this use case */ -void show_parameters(void){ +/* ---------------------------------------------------------------------------- + * Show parameters used for this use case. + * ---------------------------------------------------------------------------- + */ +void +show_parameters(options_t * opts) +{ HDprintf("===Parameters used:===\n"); - printf("chunk dims=(%llu, %llu, %llu)\n", (unsigned long long)UC_opts.chunkdims[0], - (unsigned long long)UC_opts.chunkdims[1], (unsigned long long)UC_opts.chunkdims[2]); - printf("dataset max dims=(%llu, %llu, %llu)\n", (unsigned long long)UC_opts.max_dims[0], - (unsigned long long)UC_opts.max_dims[1], (unsigned long long)UC_opts.max_dims[2]); - HDprintf("number of planes to write=%llu\n", (unsigned long long)UC_opts.nplanes); - HDprintf("using SWMR mode=%s\n", UC_opts.use_swmr ? "yes(1)" : "no(0)"); - HDprintf("data filename=%s\n", UC_opts.filename); + HDprintf("chunk dims=(%llu, %llu, %llu)\n", (unsigned long long)opts->chunkdims[0], + (unsigned long long)opts->chunkdims[1], (unsigned long long)opts->chunkdims[2]); + HDprintf("dataset max dims=(%llu, %llu, %llu)\n", (unsigned long long)opts->max_dims[0], + (unsigned long long)opts->max_dims[1], (unsigned long long)opts->max_dims[2]); + HDprintf("number of planes to write=%llu\n", (unsigned long long)opts->nplanes); + HDprintf("using SWMR mode=%s\n", opts->use_swmr ? "yes(1)" : "no(0)"); + HDprintf("data filename=%s\n", opts->filename); HDprintf("launch part="); - switch (UC_opts.launch){ - case UC_READWRITE: - printf("Reader/Writer\n"); - break; - case UC_WRITER: - printf("Writer\n"); - break; - case UC_READER: - printf("Reader\n"); - break; - default: - /* should not happen */ - printf("Illegal part(%d)\n", UC_opts.launch); - }; - HDprintf("number of iterations=%d (not used yet)\n", UC_opts.iterations); + switch (opts->launch) { + case UC_READWRITE: + HDprintf("Reader/Writer\n"); + break; + case UC_WRITER: + HDprintf("Writer\n"); + break; + case UC_READER: + HDprintf("Reader\n"); + break; + default: + /* should not happen */ + HDprintf("Illegal part(%d)\n", opts->launch); + } + HDprintf("number of iterations=%d (not used yet)\n", opts->iterations); HDprintf("===Parameters shown===\n"); -} +} /* end show_parameters() */ -/* Create the skeleton use case file for testing. +/* ---------------------------------------------------------------------------- + * Create the skeleton use case file for testing. * It has one 3d dataset using chunked storage. * The dataset is (unlimited, chunksize, chunksize). * Dataset type is 2 bytes integer. * It starts out "empty", i.e., first dimension is 0. * * Return: 0 succeed; -1 fail. + * ---------------------------------------------------------------------------- */ -int create_uc_file(void) +int +create_uc_file(options_t * opts) { - hsize_t dims[3]; /* Dataset starting dimensions */ - hid_t fid; /* File ID for new HDF5 file */ - hid_t dcpl; /* Dataset creation property list */ - hid_t sid; /* Dataspace ID */ - hid_t dsid; /* Dataset ID */ - hid_t fapl; /* File access property list */ + hsize_t dims[3]; /* Dataset starting dimensions */ + hid_t fid; /* File ID for new HDF5 file */ + hid_t dcpl; /* Dataset creation property list */ + hid_t sid; /* Dataspace ID */ + hid_t dsid; /* Dataset ID */ H5D_chunk_index_t idx_type; /* Chunk index type */ - /* Create the file */ - if((fapl = h5_fileaccess()) < 0) - return -1; - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) - return -1; - if((fid = H5Fcreate(UC_opts.filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(opts->filename, H5F_ACC_TRUNC, H5P_DEFAULT, opts->fapl_id)) < 0) return -1; /* Set up dimension sizes */ dims[0] = 0; - dims[1] = dims[2] = UC_opts.max_dims[1]; + dims[1] = dims[2] = opts->max_dims[1]; /* Create dataspace for creating datasets */ - if((sid = H5Screate_simple(3, dims, UC_opts.max_dims)) < 0) + if ((sid = H5Screate_simple(3, dims, opts->max_dims)) < 0) return -1; /* Create dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) return -1; - if(H5Pset_chunk(dcpl, 3, UC_opts.chunkdims) < 0) + if (H5Pset_chunk(dcpl, 3, opts->chunkdims) < 0) return -1; /* create dataset of progname */ - if((dsid = H5Dcreate2(fid, progname_g, UC_DATATYPE, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) - return -1; + if ((dsid = H5Dcreate2(fid, opts->progname, UC_DATATYPE, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + return -1; /* Check that the chunk index type is not version 1 B-tree. * Version 1 B-trees are not supported under SWMR. */ - if(H5D__layout_idx_type_test(dsid, &idx_type) < 0) + if (H5Dget_chunk_index_type(dsid, &idx_type) < 0) return -1; - if(idx_type == H5D_CHUNK_IDX_BTREE) { + if (idx_type == H5D_CHUNK_IDX_BTREE) { HDfprintf(stderr, "ERROR: Chunk index is version 1 B-tree: aborting.\n"); return -1; } /* Close everything */ - if(H5Dclose(dsid) < 0) - return -1; - if(H5Pclose(fapl) < 0) + if (H5Dclose(dsid) < 0) return -1; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) return -1; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) return -1; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; return 0; -} +} /* end create_uc_file() */ -/* Append planes, each of (1,2*chunksize,2*chunksize) to the dataset. +/* ---------------------------------------------------------------------------- + * Append planes, each of (1,2*chunksize,2*chunksize) to the dataset. * In other words, 4 chunks are appended to the dataset at a time. * Fill each plan with the plane number and then write it at the nth plane. * Increase the plane number and repeat till the end of dataset, when it * reaches chunksize long. End product is a (2*chunksize)^3 cube. * * Return: 0 succeed; -1 fail. + * ---------------------------------------------------------------------------- */ -int write_uc_file(hbool_t tosend, hid_t fid) +int +write_uc_file(hbool_t tosend, hid_t file_id, options_t * opts) { - hid_t dsid; /* dataset ID */ - hid_t dcpl; /* Dataset creation property list */ - UC_CTYPE *buffer, *bufptr; /* data buffer */ - hsize_t cz=UC_opts.chunksize; /* Chunk size */ - hid_t f_sid; /* dataset file space id */ - hid_t m_sid; /* memory space id */ - int rank; /* rank */ - hsize_t chunk_dims[3]; /* Chunk dimensions */ - hsize_t dims[3]; /* Dataspace dimensions */ - hsize_t memdims[3]; /* Memory space dimensions */ - hsize_t start[3] = {0,0,0}, count[3]; /* Hyperslab selection values */ - hsize_t i, j, k; - - if(tosend) + hid_t dsid; /* dataset ID */ + hid_t dcpl; /* Dataset creation property list */ + UC_CTYPE *buffer, *bufptr; /* data buffer */ + hsize_t cz=opts->chunksize; /* Chunk size */ + hid_t f_sid; /* dataset file space id */ + hid_t m_sid; /* memory space id */ + int rank; /* rank */ + hsize_t chunk_dims[3]; /* Chunk dimensions */ + hsize_t dims[3]; /* Dataspace dimensions */ + hsize_t memdims[3]; /* Memory space dimensions */ + hsize_t start[3] = {0,0,0}, count[3]; /* Hyperslab selection values */ + hsize_t i, j, k; + + if (TRUE == tosend) { /* Send a message that H5Fopen is complete--releasing the file lock */ h5_send_message(WRITER_MESSAGE, NULL, NULL); + } /* Open the dataset of the program name */ - if((dsid = H5Dopen2(fid, progname_g, H5P_DEFAULT)) < 0){ + if ((dsid = H5Dopen2(file_id, opts->progname, H5P_DEFAULT)) < 0) { HDfprintf(stderr, "H5Dopen2 failed\n"); return -1; } /* Find chunksize used */ - if ((dcpl = H5Dget_create_plist(dsid)) < 0){ + if ((dcpl = H5Dget_create_plist(dsid)) < 0) { HDfprintf(stderr, "H5Dget_create_plist failed\n"); return -1; } - if (H5D_CHUNKED != H5Pget_layout(dcpl)){ + if (H5D_CHUNKED != H5Pget_layout(dcpl)) { HDfprintf(stderr, "storage layout is not chunked\n"); return -1; } - if ((rank = H5Pget_chunk(dcpl, 3, chunk_dims)) != 3){ + if ((rank = H5Pget_chunk(dcpl, 3, chunk_dims)) != 3) { HDfprintf(stderr, "storage rank is not 3\n"); return -1; } /* verify chunk_dims against set paramenters */ - if (chunk_dims[0]!=UC_opts.chunkdims[0] || chunk_dims[1] != cz || chunk_dims[2] != cz){ + if (chunk_dims[0]!=opts->chunkdims[0] || chunk_dims[1] != cz || chunk_dims[2] != cz) { HDfprintf(stderr, "chunk size is not as expected. Got dims=(%llu,%llu,%llu)\n", - (unsigned long long)chunk_dims[0], (unsigned long long)chunk_dims[1], + (unsigned long long)chunk_dims[0], (unsigned long long)chunk_dims[1], (unsigned long long)chunk_dims[2]); return -1; } /* allocate space for data buffer 1 X dims[1] X dims[2] of UC_CTYPE */ memdims[0]=1; - memdims[1] = UC_opts.dims[1]; - memdims[2] = UC_opts.dims[2]; + memdims[1] = opts->dims[1]; + memdims[2] = opts->dims[2]; if ((buffer=(UC_CTYPE*)HDmalloc((size_t)memdims[1]*(size_t)memdims[2]*sizeof(UC_CTYPE)))==NULL) { HDfprintf(stderr, "malloc: failed\n"); return -1; - }; + } /* * Get dataset rank and dimension. */ f_sid = H5Dget_space(dsid); /* Get filespace handle first. */ rank = H5Sget_simple_extent_ndims(f_sid); - if (rank != UC_RANK){ + if (rank != UC_RANK) { HDfprintf(stderr, "rank(%d) of dataset does not match\n", rank); return -1; } - if (H5Sget_simple_extent_dims(f_sid, dims, NULL) < 0){ + if (H5Sget_simple_extent_dims(f_sid, dims, NULL) < 0) { HDfprintf(stderr, "H5Sget_simple_extent_dims got error\n"); return -1; } HDprintf("dataset rank %d, dimensions %llu x %llu x %llu\n", - rank, (unsigned long long)(dims[0]), (unsigned long long)(dims[1]), + rank, (unsigned long long)(dims[0]), (unsigned long long)(dims[1]), (unsigned long long)(dims[2])); /* verify that file space dims are as expected and are consistent with memory space dims */ - if (dims[0] != 0 || dims[1] != memdims[1] || dims[2] != memdims[2]){ + if (dims[0] != 0 || dims[1] != memdims[1] || dims[2] != memdims[2]) { HDfprintf(stderr, "dataset is not empty. Got dims=(%llu,%llu,%llu)\n", - (unsigned long long)dims[0], (unsigned long long)dims[1], + (unsigned long long)dims[0], (unsigned long long)dims[1], (unsigned long long)dims[2]); return -1; } /* setup mem-space for buffer */ - if ((m_sid=H5Screate_simple(rank, memdims, NULL))<0){ + if ((m_sid=H5Screate_simple(rank, memdims, NULL))<0) { HDfprintf(stderr, "H5Screate_simple for memory failed\n"); return -1; - }; + } /* write planes */ count[0]=1; count[1]=dims[1]; count[2]=dims[2]; - for (i=0; inplanes; i++) { /* fill buffer with value i+1 */ bufptr = buffer; - for (j=0; juse_swmr) { + if (H5Odisable_mdc_flushes(dsid) < 0) { HDfprintf(stderr, "H5Odisable_mdc_flushes failed\n"); return -1; } @@ -359,64 +368,65 @@ int write_uc_file(hbool_t tosend, hid_t fid) /* extend the dataset by one for new plane */ dims[0]=i+1; - if(H5Dset_extent(dsid, dims) < 0){ + if (H5Dset_extent(dsid, dims) < 0) { HDfprintf(stderr, "H5Dset_extent failed\n"); return -1; } /* Get the dataset's dataspace */ - if((f_sid = H5Dget_space(dsid)) < 0){ + if ((f_sid = H5Dget_space(dsid)) < 0) { HDfprintf(stderr, "H5Dset_extent failed\n"); return -1; } start[0]=i; /* Choose the next plane to write */ - if(H5Sselect_hyperslab(f_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0){ + if (H5Sselect_hyperslab(f_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) { HDfprintf(stderr, "Failed H5Sselect_hyperslab\n"); return -1; } /* Write plane to the dataset */ - if(H5Dwrite(dsid, UC_DATATYPE, m_sid, f_sid, H5P_DEFAULT, buffer) < 0){ + if (H5Dwrite(dsid, UC_DATATYPE, m_sid, f_sid, H5P_DEFAULT, buffer) < 0) { HDfprintf(stderr, "Failed H5Dwrite\n"); return -1; } /* Uncork the dataset's metadata from the cache, if SWMR is enabled */ - if(UC_opts.use_swmr) - if(H5Oenable_mdc_flushes(dsid) < 0) { + if (opts->use_swmr) { + if (H5Oenable_mdc_flushes(dsid) < 0) { HDfprintf(stderr, "H5Oenable_mdc_flushes failed\n"); return -1; } + } /* flush file to make the just written plane available. */ - if(H5Dflush(dsid) < 0) { + if (H5Dflush(dsid) < 0) { HDfprintf(stderr, "Failed to H5Fflush file\n"); return -1; } - } + } /* end for each plane to write */ /* Done writing. Free/Close all resources including data file */ HDfree(buffer); - if (H5Dclose(dsid) < 0){ + if (H5Dclose(dsid) < 0) { HDfprintf(stderr, "Failed to close datasete\n"); return -1; } - if (H5Sclose(m_sid) < 0){ + if (H5Sclose(m_sid) < 0) { HDfprintf(stderr, "Failed to close memory space\n"); return -1; } - if (H5Sclose(f_sid) < 0){ + if (H5Sclose(f_sid) < 0) { HDfprintf(stderr, "Failed to close file space\n"); return -1; } return 0; -} - +} /* end write_uc_file() */ -/* Read planes from the dataset. +/* ---------------------------------------------------------------------------- + * Read planes from the dataset. * It expects the dataset is being changed (growing). * It checks the unlimited dimension (1st one). When it increases, * it will read in the new planes, one by one, and verify the data correctness. @@ -425,61 +435,51 @@ int write_uc_file(hbool_t tosend, hid_t fid) * that is the expected end of data, the reader exits. * * Return: 0 succeed; -1 fail. + * ---------------------------------------------------------------------------- */ -int read_uc_file(hbool_t towait) +int +read_uc_file(hbool_t towait, options_t * opts) { - hid_t fapl; /* file access property list ID */ - hid_t fid; /* File ID for new HDF5 file */ - hid_t dsid; /* dataset ID */ - char *name; - UC_CTYPE *buffer, *bufptr; /* read data buffer */ - hid_t f_sid; /* dataset file space id */ - hid_t m_sid; /* memory space id */ - int rank; /* rank */ - hsize_t dims[3]; /* Dataspace dimensions */ - hsize_t memdims[3]; /* Memory space dimensions */ - hsize_t nplane=0, nplane_old=0; /* nth plane, last nth plane */ - hsize_t start[3] = {0,0,0}, count[3]; /* Hyperslab selection values */ - hsize_t j, k; - int nreadererr=0; - int nerrs; - int nonewplane; + hid_t fid; /* File ID for new HDF5 file */ + hid_t dsid; /* dataset ID */ + UC_CTYPE *buffer, *bufptr; /* read data buffer */ + hid_t f_sid; /* dataset file space id */ + hid_t m_sid; /* memory space id */ + int rank; /* rank */ + hsize_t dims[3]; /* Dataspace dimensions */ + hsize_t memdims[3]; /* Memory space dimensions */ + hsize_t nplane=0, nplanes_seen=0; /* nth plane, last nth plane */ + hsize_t start[3] = {0,0,0}, count[3]; /* Hyperslab selection values */ + hsize_t j, k; + int nreadererr=0; + int nerrs; + int loops_waiting_for_plane; /* Before reading, wait for the message that H5Fopen is complete--file lock is released */ - if(towait && h5_wait_message(WRITER_MESSAGE) < 0) { + if (towait && h5_wait_message(WRITER_MESSAGE) < 0) { HDfprintf(stderr, "Cannot find writer message file...failed\n"); return -1; } - name = UC_opts.filename; - - /* Open the file */ - if((fapl = h5_fileaccess()) < 0) - return -1; - if((fid = H5Fopen(name, H5F_ACC_RDONLY | (UC_opts.use_swmr ? H5F_ACC_SWMR_READ : 0), fapl)) < 0){ + HDfprintf(stderr, "Opening to read %s\n", opts->filename); + if ((fid = H5Fopen(opts->filename, H5F_ACC_RDONLY | (opts->use_swmr ? H5F_ACC_SWMR_READ : 0), opts->fapl_id)) < 0) { HDfprintf(stderr, "H5Fopen failed\n"); return -1; } - if (H5Pclose(fapl) < 0){ - HDfprintf(stderr, "Failed to property list\n"); - return -1; - } - - /* Open the dataset of the program name */ - if((dsid = H5Dopen2(fid, progname_g, H5P_DEFAULT)) < 0){ + if ((dsid = H5Dopen2(fid, opts->progname, H5P_DEFAULT)) < 0) { HDfprintf(stderr, "H5Dopen2 failed\n"); return -1; } - /* allocate space for data buffer 1 X dims[1] X dims[2] of UC_CTYPE */ - memdims[0]=1; - memdims[1] = UC_opts.dims[1]; - memdims[2] = UC_opts.dims[2]; + /* Allocate space for data buffer 1 X dims[1] X dims[2] of UC_CTYPE */ + memdims[0] = 1; + memdims[1] = opts->dims[1]; + memdims[2] = opts->dims[2]; if ((buffer=(UC_CTYPE*)HDmalloc((size_t)memdims[1]*(size_t)memdims[2]*sizeof(UC_CTYPE)))==NULL) { HDfprintf(stderr, "malloc: failed\n"); return -1; - }; + } /* * Get dataset rank and dimension. @@ -487,11 +487,11 @@ int read_uc_file(hbool_t towait) */ f_sid = H5Dget_space(dsid); /* Get filespace handle first. */ rank = H5Sget_simple_extent_ndims(f_sid); - if (rank != UC_RANK){ + if (rank != UC_RANK) { HDfprintf(stderr, "rank(%d) of dataset does not match\n", rank); return -1; } - if (H5Sget_simple_extent_dims(f_sid, dims, NULL) < 0){ + if (H5Sget_simple_extent_dims(f_sid, dims, NULL) < 0) { HDfprintf(stderr, "H5Sget_simple_extent_dims got error\n"); return -1; } @@ -499,7 +499,7 @@ int read_uc_file(hbool_t towait) rank, (unsigned long long)(dims[0]), (unsigned long long)(dims[1]), (unsigned long long)(dims[2])); /* verify that file space dims are as expected and are consistent with memory space dims */ - if (dims[1] != memdims[1] || dims[2] != memdims[2]){ + if (dims[1] != memdims[1] || dims[2] != memdims[2]) { HDfprintf(stderr, "dataset dimension is not as expected. Got dims=(%llu,%llu,%llu)\n", (unsigned long long)dims[0], (unsigned long long)dims[1], (unsigned long long)dims[2]); @@ -509,120 +509,101 @@ int read_uc_file(hbool_t towait) return -1; } - /* setup mem-space for buffer */ - if ((m_sid=H5Screate_simple(rank, memdims, NULL))<0){ + /* Setup mem-space for buffer */ + if ((m_sid=H5Screate_simple(rank, memdims, NULL)) < 0) { HDfprintf(stderr, "H5Screate_simple for memory failed\n"); return -1; - }; + } - /* Read 1 plane at a time whenever the dataset grows larger - * (along dim[0]) */ - count[0]=1; - count[1]=dims[1]; - count[2]=dims[2]; + /* Read 1 plane at a time whenever the dataset grows larger (along dim[0]) */ + count[0] = 1; + count[1] = dims[1]; + count[2] = dims[2]; /* quit when all nplanes have been read */ - nonewplane=0; - while (nplane_old < UC_opts.nplanes ){ - /* print progress message according to if new planes are availalbe */ - if (nplane_old < dims[0]) { - if (nonewplane){ - /* end the previous message */ - HDprintf("\n"); - nonewplane=0; - } - HDprintf("reading planes %llu to %llu\n", (unsigned long long)nplane_old, + loops_waiting_for_plane=0; + while (nplanes_seen < opts->nplanes) { + /* print progress message according to if new planes are availalbe */ + if (nplanes_seen < dims[0]) { + if (loops_waiting_for_plane) { + /* end the previous message */ + HDprintf("\n"); + loops_waiting_for_plane=0; + } + HDprintf("reading planes %llu to %llu\n", (unsigned long long)nplanes_seen, (unsigned long long)dims[0]); - }else{ - if (nonewplane){ - HDprintf("."); - if (nonewplane>=30){ - HDfprintf(stderr, "waited too long for new plane, quit.\n"); - return -1; - } - }else{ - /* print mesg only the first time; dots still no new plane */ - HDprintf("no new planes to read "); } - nonewplane++; - /* pause for a second */ - HDsleep(1); - } - for (nplane=nplane_old; nplane < dims[0]; nplane++){ - /* read planes between last old nplanes and current extent */ - /* Get the dataset's dataspace */ - if((f_sid = H5Dget_space(dsid)) < 0){ - HDfprintf(stderr, "H5Dget_space failed\n"); - return -1; + else { + if (loops_waiting_for_plane) { + HDprintf("."); + if (loops_waiting_for_plane>=30) { + HDfprintf(stderr, "waited too long for new plane, quit.\n"); + return -1; + } + } + else { + /* print mesg only the first time; dots still no new plane */ + HDprintf("waiting for new planes to read "); + } + loops_waiting_for_plane++; + /* pause for a second */ + HDsleep(1); } - start[0]=nplane; - /* Choose the next plane to read */ - if(H5Sselect_hyperslab(f_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0){ - HDfprintf(stderr, "H5Sselect_hyperslab failed\n"); - return -1; - } + for (nplane=nplanes_seen; nplane < dims[0]; nplane++) { + /* read planes between last old nplanes and current extent */ + /* Get the dataset's dataspace */ + if ((f_sid = H5Dget_space(dsid)) < 0) { + HDfprintf(stderr, "H5Dget_space failed\n"); + return -1; + } - /* Read the plane from the dataset */ - if(H5Dread(dsid, UC_DATATYPE, m_sid, f_sid, H5P_DEFAULT, buffer) < 0){ - HDfprintf(stderr, "H5Dread failed\n"); - return -1; - } + start[0]=nplane; + /* Choose the next plane to read */ + if (H5Sselect_hyperslab(f_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) { + HDfprintf(stderr, "H5Sselect_hyperslab failed\n"); + return -1; + } - /* compare read data with expected data value which is nplane */ - bufptr = buffer; - nerrs=0; - for (j=0; jrw_fapl_id == H5P_DEFAULT) { + if (H5Pget_driver(fetched_info.rw_fapl_id) != H5Pget_driver(H5P_FILE_ACCESS_DEFAULT)) { + SPLITTER_TEST_FAULT("Read-Write driver mismatch (default)\n"); + } + } + else { + if (H5Pget_driver(fetched_info.rw_fapl_id) != H5Pget_driver(info->rw_fapl_id)) { + SPLITTER_TEST_FAULT("Read-Write driver mismatch\n"); + } + } + if (info->wo_fapl_id == H5P_DEFAULT) { + if (H5Pget_driver(fetched_info.wo_fapl_id) != H5Pget_driver(H5P_FILE_ACCESS_DEFAULT)) { + SPLITTER_TEST_FAULT("Write-Only driver mismatch (default)\n"); + } + } + else { + if (H5Pget_driver(fetched_info.wo_fapl_id) != H5Pget_driver(info->wo_fapl_id)) { + SPLITTER_TEST_FAULT("Write-Only driver mismatch\n"); + } + } + if ( (HDstrlen(info->wo_path) != HDstrlen(fetched_info.wo_path)) || + HDstrncmp(info->wo_path, fetched_info.wo_path, H5FD_SPLITTER_PATH_MAX)) + { + HDfprintf(stderr, "MISMATCH: '%s' :: '%s'\n", info->wo_path, fetched_info.wo_path); + HEXPRINT(H5FD_SPLITTER_PATH_MAX, info->wo_path); + HEXPRINT(H5FD_SPLITTER_PATH_MAX, fetched_info.wo_path); + SPLITTER_TEST_FAULT("Write-Only file path mismatch\n"); + } + +done: + return ret_value; +} /* end compare_splitter_config_info() */ + + +/*------------------------------------------------------------------------- + * Function: run_splitter_test + * + * Purpose: Auxiliary function for test_splitter(). + * + * Return: Success: 0 + * Failure: -1 + * + * Description: + * Perform basic open-write-close with the Splitter VFD. + * Prior to operations, removes files from a previous run, + * if they exist. + * After writing, compares read-write and write-only files. + * Includes FAPL sanity testing. + * + *------------------------------------------------------------------------- + */ +static int +run_splitter_test(const struct splitter_dataset_def *data, + hbool_t ignore_wo_errors, + hbool_t provide_logfile_path, + hid_t sub_fapl_ids[2]) +{ + hid_t file_id = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t space_id = H5I_INVALID_HID; + hid_t fapl_id_out = H5I_INVALID_HID; + hid_t fapl_id_cpy = H5I_INVALID_HID; + H5FD_splitter_vfd_config_t vfd_config; + char filename_rw[H5FD_SPLITTER_PATH_MAX + 1]; + FILE *logfile = NULL; + int ret_value = 0; + + vfd_config.magic = H5FD_SPLITTER_MAGIC; + vfd_config.version = H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION; + vfd_config.ignore_wo_errs = ignore_wo_errors; + vfd_config.rw_fapl_id = sub_fapl_ids[0]; + vfd_config.wo_fapl_id = sub_fapl_ids[1]; + + if (splitter_prepare_file_paths(&vfd_config, filename_rw) < 0) { + SPLITTER_TEST_FAULT("can't prepare file paths\n"); + } + + if (provide_logfile_path == FALSE) { + *vfd_config.log_file_path = '\0'; /* reset as empty string */ + } + + /* Create a new fapl to use the SPLITTER file driver */ + if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) == H5I_INVALID_HID) { + SPLITTER_TEST_FAULT("can't create FAPL ID\n"); + } + if (H5Pset_fapl_splitter(fapl_id, &vfd_config) < 0) { + SPLITTER_TEST_FAULT("can't set splitter FAPL\n"); + } + if (H5Pget_driver(fapl_id) != H5FD_SPLITTER) { + SPLITTER_TEST_FAULT("set FAPL not SPLITTER\n"); + } + + if (compare_splitter_config_info(fapl_id, &vfd_config) < 0) { + SPLITTER_TEST_FAULT("information mismatch\n"); + } + + /* + * Copy property list, light compare, and close the copy. + * Helps test driver-implemented FAPL-copying and library ID management. + */ + + fapl_id_cpy = H5Pcopy(fapl_id); + if (H5I_INVALID_HID == fapl_id_cpy) { + SPLITTER_TEST_FAULT("can't copy FAPL\n"); + } + if (compare_splitter_config_info(fapl_id_cpy, &vfd_config) < 0) { + SPLITTER_TEST_FAULT("information mismatch\n"); + } + if (H5Pclose(fapl_id_cpy) < 0) { + SPLITTER_TEST_FAULT("can't close fapl copy\n"); + } + + /* + * Proceed with test. Create file. + */ + file_id = H5Fcreate(filename_rw, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + if (file_id < 0) { + SPLITTER_TEST_FAULT("can't create file\n"); + } + + /* + * Check driver from file + */ + + fapl_id_out = H5Fget_access_plist(file_id); + if (H5I_INVALID_HID == fapl_id_out) { + SPLITTER_TEST_FAULT("can't get file's FAPL\n"); + + } + if (H5Pget_driver(fapl_id_out) != H5FD_SPLITTER) { + SPLITTER_TEST_FAULT("wrong file FAPL driver\n"); + } + if (compare_splitter_config_info(fapl_id_out, &vfd_config) < 0) { + SPLITTER_TEST_FAULT("information mismatch\n"); + } + if (H5Pclose(fapl_id_out) < 0) { + SPLITTER_TEST_FAULT("can't close file's FAPL\n"); + } + + /* + * Create and write the dataset + */ + + space_id = H5Screate_simple(data->n_dims, data->dims, NULL); + if (space_id < 0) { + SPLITTER_TEST_FAULT("can't create dataspace\n"); + } + dset_id = H5Dcreate2(file_id, data->dset_name, data->mem_type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (dset_id < 0) { + SPLITTER_TEST_FAULT("can't create dataset\n"); + } + if (H5Dwrite(dset_id, data->mem_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, data->buf) < 0) { + SPLITTER_TEST_FAULT("can't write data to dataset\n"); + } + + /* Close everything */ + if (H5Dclose(dset_id) < 0) { + SPLITTER_TEST_FAULT("can't close dset\n"); + } + if (H5Sclose(space_id) < 0) { + SPLITTER_TEST_FAULT("can't close space\n"); + } + if (H5Pclose(fapl_id) < 0) { + SPLITTER_TEST_FAULT("can't close fapl\n"); + } + if (H5Fclose(file_id) < 0) { + SPLITTER_TEST_FAULT("can't close file\n"); + } + + /* Verify that the R/W and W/O files are identical */ + if (h5_compare_file_bytes(filename_rw, vfd_config.wo_path) < 0) { + SPLITTER_TEST_FAULT("files are not byte-for-byte equivalent\n"); + } + + /* Verify existence of logfile iff appropriate */ + logfile = fopen(vfd_config.log_file_path, "r"); + if ( (TRUE == provide_logfile_path && NULL == logfile) || + (FALSE == provide_logfile_path && NULL != logfile) ) + { + SPLITTER_TEST_FAULT("no logfile when one was expected\n"); + } + +done: + if (ret_value < 0) { + H5E_BEGIN_TRY { + (void)H5Dclose(dset_id); + (void)H5Sclose(space_id); + (void)H5Pclose(fapl_id_out); + (void)H5Pclose(fapl_id_cpy); + (void)H5Pclose(fapl_id); + (void)H5Fclose(file_id); + } H5E_END_TRY; + } + if (logfile != NULL) { + fclose(logfile); + } + return ret_value; + +} /* end run_splitter_test() */ + + +/*------------------------------------------------------------------------- + * Function: driver_is_splitter_compatible + * + * Purpose: Determine whether the driver set in the FAPL ID is compatible + * with the Splitter VFD -- specificially, Write-Only channel. + * + * Return: Success: 0 + * Failure: -1 + * + * Description: Attempts to put the given FAPL ID as the W/O channel. + * Uses driver's own mechanisms to generate error, and catches + * error. + * + *------------------------------------------------------------------------- + */ +static int +driver_is_splitter_compatible(hid_t fapl_id) +{ + H5FD_splitter_vfd_config_t vfd_config; + hid_t split_fapl_id = H5I_INVALID_HID; + herr_t ret = SUCCEED; + int ret_value = 0; + + split_fapl_id = H5Pcreate(H5P_FILE_ACCESS); + if (H5I_INVALID_HID == split_fapl_id) { + FAIL_PUTS_ERROR("Can't create contained FAPL"); + } + vfd_config.magic = H5FD_SPLITTER_MAGIC; + vfd_config.version = H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION; + vfd_config.ignore_wo_errs = FALSE; + vfd_config.rw_fapl_id = H5P_DEFAULT; + vfd_config.wo_fapl_id = fapl_id; + HDstrncpy(vfd_config.wo_path, "nonesuch", H5FD_SPLITTER_PATH_MAX); + *vfd_config.log_file_path = '\0'; + + H5E_BEGIN_TRY { + ret = H5Pset_fapl_splitter(split_fapl_id, &vfd_config); + } H5E_END_TRY; + if (SUCCEED == ret) { + ret_value = -1; + } + + if (H5Pclose(split_fapl_id) < 0) { + FAIL_PUTS_ERROR("Can't close contained FAPL") + } + split_fapl_id = H5I_INVALID_HID; + + return ret_value; + +error: + H5E_BEGIN_TRY { + (void)H5Pclose(split_fapl_id); + } H5E_END_TRY; + return -1; +} /* end driver_is_splitter_compatible() */ + + +/*------------------------------------------------------------------------- + * Function: splitter_RO_test + * + * Purpose: Verify Splitter VFD with the Read-Only access flag. + * + * Return: Success: 0 + * Failure: -1 + * + * Description: Attempt read-only opening of files with different + * permutations of files already existing on-disk. + * + *------------------------------------------------------------------------- + */ +static int +splitter_RO_test( + const struct splitter_dataset_def *data, + hid_t child_fapl_id) +{ + char filename_rw[H5FD_SPLITTER_PATH_MAX + 1]; + H5FD_splitter_vfd_config_t vfd_config; + hid_t fapl_id = H5I_INVALID_HID; + int ret_value = 0; + hid_t file_id = H5I_INVALID_HID; + + vfd_config.magic = H5FD_SPLITTER_MAGIC; + vfd_config.version = H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION; + vfd_config.ignore_wo_errs = FALSE; + vfd_config.rw_fapl_id = child_fapl_id; + vfd_config.wo_fapl_id = child_fapl_id; + + if (splitter_prepare_file_paths(&vfd_config, filename_rw) < 0) { + SPLITTER_TEST_FAULT("can't prepare splitter file paths\n"); + } + + /* Create a new fapl to use the SPLITTER file driver */ + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + if (H5I_INVALID_HID == fapl_id) { + SPLITTER_TEST_FAULT("can't create FAPL ID\n"); + } + if (H5Pset_fapl_splitter(fapl_id, &vfd_config) < 0) { + SPLITTER_TEST_FAULT("can't set splitter FAPL\n"); + } + if (H5Pget_driver(fapl_id) != H5FD_SPLITTER) { + SPLITTER_TEST_FAULT("set FAPL not SPLITTER\n"); + } + + /* Attempt R/O open when both files are nonexistent + * Should fail. + */ + + H5E_BEGIN_TRY { + file_id = H5Fopen(filename_rw, H5F_ACC_RDONLY, fapl_id); + } H5E_END_TRY; + if (file_id >= 0) { + SPLITTER_TEST_FAULT("R/O open on nonexistent files unexpectedly successful\n"); + } + + /* Attempt R/O open when only W/O file exists + * Should fail. + */ + + if (splitter_create_single_file_at(vfd_config.wo_path, vfd_config.wo_fapl_id, data) < 0) { + SPLITTER_TEST_FAULT("can't write W/O file\n"); + } + H5E_BEGIN_TRY { + file_id = H5Fopen(filename_rw, H5F_ACC_RDONLY, fapl_id); + } H5E_END_TRY; + if (file_id >= 0) { + SPLITTER_TEST_FAULT("R/O open with extant W/O file unexpectedly successful\n"); + } + HDremove(vfd_config.wo_path); + + /* Attempt R/O open when only R/W file exists + * Should fail. + */ + + if (splitter_create_single_file_at(filename_rw, vfd_config.rw_fapl_id, data) < 0) { + SPLITTER_TEST_FAULT("can't create R/W file\n"); + } + H5E_BEGIN_TRY { + file_id = H5Fopen(filename_rw, H5F_ACC_RDONLY, fapl_id); + } H5E_END_TRY; + if (file_id >= 0) { + SPLITTER_TEST_FAULT("R/O open with extant R/W file unexpectedly successful\n"); + } + + /* Attempt R/O open when both R/W and W/O files exist + */ + + if (splitter_create_single_file_at(vfd_config.wo_path, vfd_config.wo_fapl_id, data) < 0) { + SPLITTER_TEST_FAULT("can't create W/O file\n"); + } + file_id = H5Fopen(filename_rw, H5F_ACC_RDONLY, fapl_id); + if (file_id < 0) { + SPLITTER_TEST_FAULT("R/O open on two extant files failed\n"); + } + if (splitter_compare_expected_data(file_id, data) < 0) { + SPLITTER_TEST_FAULT("data mismatch in R/W file\n"); + } + if (H5Fclose(file_id) < 0) { + SPLITTER_TEST_FAULT("can't close file(s)\n"); + } + file_id = H5I_INVALID_HID; + + /* Cleanup + */ + + if (H5Pclose(fapl_id) < 0) { + SPLITTER_TEST_FAULT("can't close FAPL ID\n"); + } + fapl_id = H5I_INVALID_HID; + +done: + if (ret_value < 0) { + H5E_BEGIN_TRY { + (void)H5Pclose(fapl_id); + (void)H5Fclose(file_id); + } H5E_END_TRY; + } /* end if error */ + return ret_value; +} /* end splitter_RO_test() */ + + +/*------------------------------------------------------------------------- + * Function: splitter_prepare_file_paths + * + * Purpose: Get file paths ready for use by the Splitter VFD tests. + * + * Return: Success: 0 + * Failure: -1 + * + * Description: + * Use h5_fixname to adjust the splitter-relevant file paths + * from those given in FILENAMES. + * + * REMOVES EXISTING FILES AT THE PATH LOCATIONS PRIOR TO RETURN. + * + * The relevant file paths will be set in filename_rw_out and + * inside the config structure (wo_path, log_file_path). + * + * `filename_rw_out` must be at least H5FD_SPLITTER_PATH_MAX+1 + * characters long. + * + * `vfd_config` must have its child FAPL IDs preset. + * + *------------------------------------------------------------------------- + */ +static int +splitter_prepare_file_paths(H5FD_splitter_vfd_config_t *vfd_config, char *filename_rw_out) +{ + int ret_value = 0; + + if (vfd_config == NULL || vfd_config->magic != H5FD_SPLITTER_MAGIC) { + SPLITTER_TEST_FAULT("invalid splitter config pointer\n"); + } + if (filename_rw_out == NULL) { + SPLITTER_TEST_FAULT("NULL filename_rw pointer\n"); + } + + /* TODO: sanity-check fapl IDs? */ + + /* Build the r/w file, w/o file, and the log file paths. + * Output is stored in the associated string pointers. + */ + h5_fixname(FILENAME[11], vfd_config->rw_fapl_id, filename_rw_out, H5FD_SPLITTER_PATH_MAX); + h5_fixname(FILENAME[12], vfd_config->wo_fapl_id, vfd_config->wo_path, H5FD_SPLITTER_PATH_MAX); + h5_fixname_no_suffix(FILENAME[13], vfd_config->wo_fapl_id, vfd_config->log_file_path, H5FD_SPLITTER_PATH_MAX); + + /* Delete any existing files on disk. + */ + HDremove(filename_rw_out); + HDremove(vfd_config->wo_path); + HDremove(vfd_config->log_file_path); + +done: + return ret_value; +} /* end splitter_prepare_file_paths() */ + + +/*------------------------------------------------------------------------- + * Function: splitter_crate_single_file_at + * + * Purpose: Create a file, optionally w/ dataset. + * + * Return: Success: 0 + * Failure: -1 + * + * Description: + * Create a file at the given location with the given FAPL, + * and write data as defined in `data` in a pre-determined location in the file. + * + * If the dataset definition pointer is NULL, no data is written + * to the file. + * + * Will always overwrite an existing file with the given name/path. + * + *------------------------------------------------------------------------- + */ +static int +splitter_create_single_file_at( + const char *filename, + hid_t fapl_id, + const struct splitter_dataset_def *data) +{ + hid_t file_id = H5I_INVALID_HID; + hid_t space_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + int ret_value = 0; + + if (filename == NULL || *filename == '\0') { + SPLITTER_TEST_FAULT("filename is invalid\n"); + } + /* TODO: sanity-check fapl id? */ + + file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + if (file_id < 0) { + SPLITTER_TEST_FAULT("can't create file\n"); + } + + if (data) { + /* TODO: sanity-check data, if it exists? */ + space_id = H5Screate_simple(data->n_dims, data->dims, NULL); + if (space_id < 0) { + SPLITTER_TEST_FAULT("can't create dataspace\n"); + } + + dset_id = H5Dcreate2( + file_id, + data->dset_name, + data->mem_type_id, + space_id, + H5P_DEFAULT, + H5P_DEFAULT, + H5P_DEFAULT); + if (dset_id < 0) { + SPLITTER_TEST_FAULT("can't create dataset\n"); + } + + if (H5Dwrite(dset_id, data->mem_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, data->buf) < 0) { + SPLITTER_TEST_FAULT("can't write data to dataset\n"); + } + + if (H5Dclose(dset_id) < 0) { + SPLITTER_TEST_FAULT("can't close dset\n"); + } + if (H5Sclose(space_id) < 0) { + SPLITTER_TEST_FAULT("can't close space\n"); + } + } /* end if data definition is provided */ + + if (H5Fclose(file_id) < 0) { + SPLITTER_TEST_FAULT("can't close file\n"); + } + +done: + if (ret_value < 0) { + H5E_BEGIN_TRY { + (void)H5Dclose(dset_id); + (void)H5Sclose(space_id); + (void)H5Fclose(file_id); + } H5E_END_TRY; + } /* end if error */ + return ret_value; +} /* end splitter_create_single_file_at() */ + + +/*------------------------------------------------------------------------- + * Function: splitter_compare_expected_data + * + * Purpose: Compare data within a predermined dataset. + * + * Return: Success: 0 + * Failure: -1 + * + * Description: Read data from the file at a predetermined location, and + * compare its contents byte-for-byte with that expected in + * the `data` definition structure. + * + *------------------------------------------------------------------------- + */ +static int +splitter_compare_expected_data(hid_t file_id, + const struct splitter_dataset_def *data) +{ + hid_t dset_id = H5I_INVALID_HID; + int buf[SPLITTER_SIZE][SPLITTER_SIZE]; + int expected[SPLITTER_SIZE][SPLITTER_SIZE]; + size_t i = 0; + size_t j = 0; + int ret_value = 0; + + if (sizeof((void *)buf) != sizeof(data->buf)) { + SPLITTER_TEST_FAULT("invariant size of expected data does not match that received!\n"); + } + HDmemcpy(expected, data->buf, sizeof(expected)); + + dset_id = H5Dopen2(file_id, data->dset_name, H5P_DEFAULT); + if (dset_id < 0) { + SPLITTER_TEST_FAULT("can't open dataset\n"); + } + + if (H5Dread(dset_id, data->mem_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, (void *)buf) < 0) { + SPLITTER_TEST_FAULT("can't read dataset\n"); + } + + for (i=0; i < SPLITTER_SIZE; i++) { + for (j=0; j < SPLITTER_SIZE; j++) { + if (buf[i][j] != expected[i][j]) { + SPLITTER_TEST_FAULT("mismatch in expected data\n"); + } + } + } + + if (H5Dclose(dset_id) < 0) { + SPLITTER_TEST_FAULT("can't close dataset\n"); + } + +done: + if (ret_value < 0) { + H5E_BEGIN_TRY { + (void)H5Dclose(dset_id); + } H5E_END_TRY; + } + return ret_value; +} /* end splitter_compare_expected_data() */ + + +/*------------------------------------------------------------------------- + * Function: splitter_tentative_open_test() + * + * Purpose: Verifies Splitter behavior with "tentative" H5F_open. + * + * Return: Success: 0 + * Failure: -1 + * + * Description: + * H5F_open() has a two-stage opening process when given a + * Read/Write access flag -- first it performs a "tentative + * open", where it checks to see whether files already exist + * on the system, done in such a way as to not "alter its state" + * (i.e., truncate). + * This can cause problems with the Splitter VFD, as the + * file on the R/W channel might exist already, but that on the + * W/O channel will not, and vice-versa. + * + * This test exists to verify that in any event, files will be + * created as required. + * + *------------------------------------------------------------------------- + */ +static int +splitter_tentative_open_test(hid_t child_fapl_id) +{ + const char filename_tmp[H5FD_SPLITTER_PATH_MAX + 1] = "splitter_tmp.h5"; + char filename_rw[H5FD_SPLITTER_PATH_MAX + 1]; + H5FD_splitter_vfd_config_t vfd_config; + hid_t fapl_id = H5I_INVALID_HID; + hid_t file_id = H5I_INVALID_HID; + int buf[SPLITTER_SIZE][SPLITTER_SIZE]; /* for comparison */ + hsize_t dims[2] = { SPLITTER_SIZE, SPLITTER_SIZE }; /* for comparison */ + int i = 0; /* for comparison */ + int j = 0; /* for comparison */ + struct splitter_dataset_def data; /* for comparison */ + int ret_value = 0; + + /* pre-fill data buffer to write */ + for (i=0; i < SPLITTER_SIZE; i++) { + for (j=0; j < SPLITTER_SIZE; j++) { + buf[i][j] = i*100+j; + } + } + + /* Dataset info */ + data.buf = (void *)buf; + data.mem_type_id = H5T_NATIVE_INT; + data.dims = dims; + data.n_dims = 2; + data.dset_name = SPLITTER_DATASET_NAME; + + vfd_config.magic = H5FD_SPLITTER_MAGIC; + vfd_config.version = H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION; + vfd_config.ignore_wo_errs = FALSE; + vfd_config.rw_fapl_id = child_fapl_id; + vfd_config.wo_fapl_id = child_fapl_id; + + if (splitter_prepare_file_paths(&vfd_config, filename_rw) < 0) { + SPLITTER_TEST_FAULT("can't prepare splitter file paths\n"); + } + + /* Create a new fapl to use the SPLITTER file driver */ + if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) == H5I_INVALID_HID) { + SPLITTER_TEST_FAULT("can't create FAPL ID\n"); + } + if (H5Pset_fapl_splitter(fapl_id, &vfd_config) < 0) { + SPLITTER_TEST_FAULT("can't set splitter FAPL\n"); + } + if (H5Pget_driver(fapl_id) != H5FD_SPLITTER) { + SPLITTER_TEST_FAULT("set FAPL not SPLITTER\n"); + } + + /* Create instance of file on disk. + * Will be copied verbatim as needed, to avoid issues where differences in + * the creation time would befoul comparisons. + */ + if (splitter_create_single_file_at(filename_tmp, child_fapl_id, &data) < 0) { + SPLITTER_TEST_FAULT("can't write W/O file\n"); + } + + /* + * H5Fopen() with RDWR access. + * Neither file exist already + * Should fail. + */ + + H5E_BEGIN_TRY { + file_id = H5Fopen(filename_rw, H5F_ACC_RDWR, fapl_id); + } H5E_END_TRY; + if (file_id != H5I_INVALID_HID) { + SPLITTER_TEST_FAULT("open with both nonexistent files unexpectedly succeeded\n"); + } + if (file_exists(filename_rw, child_fapl_id)) { + SPLITTER_TEST_FAULT("R/W file unexpectedly created\n"); + } + if (file_exists(vfd_config.wo_path, child_fapl_id)) { + SPLITTER_TEST_FAULT("W/O file unexpectedly created\n"); + } + + /* + * H5Fopen() with RDWR access. + * Only W/O file present. + * Should fail. + */ + + if (h5_duplicate_file_by_bytes(filename_tmp, vfd_config.wo_path) < 0) { + SPLITTER_TEST_FAULT("Can't create W/O file copy.\n"); + } + H5E_BEGIN_TRY { + file_id = H5Fopen(filename_rw, H5F_ACC_RDWR, fapl_id); + } H5E_END_TRY; + if (file_id != H5I_INVALID_HID) { + SPLITTER_TEST_FAULT("open with nonexistent R/W file unexpectedly succeeded\n"); + } + if (file_exists(filename_rw, child_fapl_id)) { + SPLITTER_TEST_FAULT("R/W file unexpectedly created\n"); + } + if (!file_exists(vfd_config.wo_path, child_fapl_id)) { + SPLITTER_TEST_FAULT("W/O file mysteriously disappeared\n"); + } + HDremove(vfd_config.wo_path); + if (file_exists(vfd_config.wo_path, child_fapl_id)) { + SPLITTER_TEST_FAULT("failed to remove W/O file\n"); + } + + /* + * H5Fopen() with RDWR access. + * Only R/W file present. + * Should fail. + */ + + if (h5_duplicate_file_by_bytes(filename_tmp, filename_rw) < 0) { + SPLITTER_TEST_FAULT("Can't create R/W file copy.\n"); + } + H5E_BEGIN_TRY { + file_id = H5Fopen(filename_rw, H5F_ACC_RDWR, fapl_id); + } H5E_END_TRY; + if (file_id != H5I_INVALID_HID) { + SPLITTER_TEST_FAULT("open with nonexistent W/O unexpectedly succeeded\n"); + } + if (!file_exists(filename_rw, child_fapl_id)) { + SPLITTER_TEST_FAULT("R/W file mysteriously disappeared\n"); + } + if (file_exists(vfd_config.wo_path, child_fapl_id)) { + SPLITTER_TEST_FAULT("W/O file unexpectedly created\n"); + } + + /* + * H5Fopen() with RDWR access. + * Both files present. + */ + + if (h5_duplicate_file_by_bytes(filename_tmp, vfd_config.wo_path) < 0) { + SPLITTER_TEST_FAULT("Can't create W/O file copy.\n"); + } + file_id = H5Fopen(filename_rw, H5F_ACC_RDWR, fapl_id); + if (file_id == H5I_INVALID_HID) { + SPLITTER_TEST_FAULT("file-open failed with both present\n"); + } + /* Open successful; close file then inspect presence again */ + if (H5Fclose(file_id) < 0) { + SPLITTER_TEST_FAULT("can't close file ID\n"); + } + if (!file_exists(filename_rw, child_fapl_id)) { + SPLITTER_TEST_FAULT("R/W file mysteriously disappared\n"); + } + if (!file_exists(vfd_config.wo_path, child_fapl_id)) { + SPLITTER_TEST_FAULT("W/O file mysteriously disappeared\n"); + } + + /* + * H5Fcreate() with TRUNC access. + * Both files present. + */ + + file_id = H5Fcreate(filename_rw, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + if (file_id == H5I_INVALID_HID) { + SPLITTER_TEST_FAULT("file-open failed with both present\n"); + } + /* Open successful; close file then inspect presence again */ + if (H5Fclose(file_id) < 0) { + SPLITTER_TEST_FAULT("can't close file ID\n"); + } + if (!file_exists(filename_rw, child_fapl_id)) { + SPLITTER_TEST_FAULT("R/W file mysteriously disappared\n"); + } + if (!file_exists(vfd_config.wo_path, child_fapl_id)) { + SPLITTER_TEST_FAULT("W/O file mysteriously disappeared\n"); + } + if (h5_compare_file_bytes(filename_rw, vfd_config.wo_path) < 0) { + SPLITTER_TEST_FAULT("files are not byte-for-byte equivalent\n"); + } + HDremove(filename_rw); + HDremove(vfd_config.wo_path); + + /* + * H5Fcreate() with TRUNC access. + * R/W already exists. + */ + + if (h5_duplicate_file_by_bytes(filename_tmp, filename_rw) < 0) { + SPLITTER_TEST_FAULT("Can't create R/W file copy.\n"); + } + if (file_exists(vfd_config.wo_path, child_fapl_id)) { + SPLITTER_TEST_FAULT("failed to remove W/O file\n"); + } + file_id = H5Fcreate(filename_rw, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + if (file_id == H5I_INVALID_HID) { + SPLITTER_TEST_FAULT("file-open failed with both present\n"); + } + /* Open successful; close file then inspect presence again */ + if (H5Fclose(file_id) < 0) { + SPLITTER_TEST_FAULT("can't close file ID\n"); + } + if (!file_exists(filename_rw, child_fapl_id)) { + SPLITTER_TEST_FAULT("R/W file mysteriously disappared\n"); + } + if (!file_exists(vfd_config.wo_path, child_fapl_id)) { + SPLITTER_TEST_FAULT("W/O file mysteriously disappeared\n"); + } + if (h5_compare_file_bytes(filename_rw, vfd_config.wo_path) < 0) { + SPLITTER_TEST_FAULT("files are not byte-for-byte equivalent\n"); + } + HDremove(filename_rw); + HDremove(vfd_config.wo_path); + + /* + * H5Fcreate() with TRUNC access. + * Only W/O present. + */ + + if (h5_duplicate_file_by_bytes(filename_tmp, vfd_config.wo_path) < 0) { + SPLITTER_TEST_FAULT("Can't create W/O file copy.\n"); + } + if (file_exists(filename_rw, child_fapl_id)) { + SPLITTER_TEST_FAULT("failed to remove R/W file\n"); + } + file_id = H5Fcreate(filename_rw, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + if (file_id == H5I_INVALID_HID) { + SPLITTER_TEST_FAULT("file-open failed with both present\n"); + } + /* Open successful; close file then inspect presence again */ + if (H5Fclose(file_id) < 0) { + SPLITTER_TEST_FAULT("can't close file ID\n"); + } + if (!file_exists(filename_rw, child_fapl_id)) { + SPLITTER_TEST_FAULT("R/W file mysteriously disappared\n"); + } + if (!file_exists(vfd_config.wo_path, child_fapl_id)) { + SPLITTER_TEST_FAULT("W/O file mysteriously disappeared\n"); + } + if (h5_compare_file_bytes(filename_rw, vfd_config.wo_path) < 0) { + SPLITTER_TEST_FAULT("files are not byte-for-byte equivalent\n"); + } + HDremove(filename_rw); + HDremove(vfd_config.wo_path); + + /* H5Fcreate with both files absent is tested elsewhere */ + + /* + * Cleanup + */ + + if (H5Pclose(fapl_id) < 0) { + SPLITTER_TEST_FAULT("can't close splitter FAPL ID\n"); + } + +done: + if (ret_value < 0) { + H5E_BEGIN_TRY { + (void)H5Pclose(fapl_id); + (void)H5Fclose(file_id); + } H5E_END_TRY; + } /* end if error */ + return ret_value; +} /* end splitter_tentative_open_test() */ + + +/*------------------------------------------------------------------------- + * Function: file_exists() + * + * Purpose: Determine whether a file exists on-system + * + * Return: Non-zero (1) if it exists (H5Fopen successful), + * zero (0) if absent (cannot be opened). + * + * Description: Attempt H5Fopen with the given FAPL ID and RDONLY access flag. + * + *------------------------------------------------------------------------- + */ +static int +file_exists(const char *filename, hid_t fapl_id) +{ + hid_t file_id = H5I_INVALID_HID; + int ret_value = 0; + + H5E_BEGIN_TRY { + file_id = H5Fopen(filename, H5F_ACC_RDONLY, fapl_id); + } H5E_END_TRY; + if (file_id != H5I_INVALID_HID) { + ret_value = 1; + if (H5Fclose(file_id) < 0) { + FAIL_PUTS_ERROR("can't close file ID\n"); + } + } + + return ret_value; + +error: + H5E_BEGIN_TRY { + (void)H5Fclose(file_id); + } H5E_END_TRY; + return ret_value; +} /* end file_exists() */ + + +/*------------------------------------------------------------------------- + * Function: test_splitter + * + * Purpose: Tests the Splitter VFD + * + * Return: Success: 0 + * Failure: -1 + * + * Description: + * This test function uses the Splitter VFD to produce a r/w + * file and a w/o file. It will verify that the two files + * are identical. + * + *------------------------------------------------------------------------- + */ +static herr_t +test_splitter(void) +{ + int buf[SPLITTER_SIZE][SPLITTER_SIZE]; + hsize_t dims[2] = { SPLITTER_SIZE, SPLITTER_SIZE }; + hid_t child_fapl_id = H5I_INVALID_HID; + int i = 0; + int j = 0; + struct splitter_dataset_def data; + + TESTING("SPLITTER file driver"); + + /* pre-fill data buffer to write */ + for (i=0; i < SPLITTER_SIZE; i++) { + for (j=0; j < SPLITTER_SIZE; j++) { + buf[i][j] = i*100+j; + } + } + + /* Dataset info */ + data.buf = (void *)buf; + data.mem_type_id = H5T_NATIVE_INT; + data.dims = dims; + data.n_dims = 2; + data.dset_name = SPLITTER_DATASET_NAME; + + /* Stand-in for manual FAPL creation + * Enables verification with arbitrary VFDs via `make check-vfd` + */ + child_fapl_id = h5_fileaccess(); + if (child_fapl_id < 0) { + TEST_ERROR; + } + + if (!driver_is_splitter_compatible(child_fapl_id)) { + SKIPPED(); + HDprintf(" given driver is not Splitter W/O compatible.\n"); + return 0; + } + + /* Test Read-Only access, including when a file on the W/O channel + * does not exist. + */ + if (splitter_RO_test(&data, child_fapl_id) < 0) { + TEST_ERROR; + } + + /* Test opening of files when the W/O channel does not exist. + */ + if (splitter_tentative_open_test(child_fapl_id) < 0) { + TEST_ERROR; + } + + /* Test file creation, utilizing different child FAPLs (default vs. + * specified), logfile, and Write Channel error ignoring behavior. + */ + for (i=0; i < 4; i++) { + hbool_t ignore_wo_errors = (i & 1) ? TRUE : FALSE; + hbool_t provide_logfile_path = (i & 2) ? TRUE : FALSE; + hid_t child_fapl_ids[2] = { H5P_DEFAULT, H5P_DEFAULT }; + + /* Test child driver definition/default combination */ + for (j=0; j < 4; j++) { + + child_fapl_ids[0] = (j & 1) ? child_fapl_id : H5P_DEFAULT; + child_fapl_ids[1] = (j & 2) ? child_fapl_id : H5P_DEFAULT; + + if (run_splitter_test(&data, ignore_wo_errors, provide_logfile_path, child_fapl_ids) < 0) { + TEST_ERROR; + } + + } /* end for child fapl definition/pairing */ + + } /* end for behavior-flag loops */ + +/* TODO: SWMR open? */ +/* Concurrent opens with both drivers using the Splitter */ + + if (H5Pclose(child_fapl_id) == FAIL) { + TEST_ERROR; + } + + PASSED(); + return 0; + +error: + if (child_fapl_id != H5I_INVALID_HID) { + (void)H5Pclose(child_fapl_id); + } + return -1; +} /* end test_splitter() */ + +#undef SPLITTER_TEST_FAULT + + /*------------------------------------------------------------------------- * Function: main * @@ -2155,9 +3289,6 @@ error: * Return: Success: 0 * Failure: 1 * - * Programmer: Raymond Lu - * Tuesday, Sept 24, 2002 - * *------------------------------------------------------------------------- */ int @@ -2181,6 +3312,7 @@ main(void) nerrors += test_stdio() < 0 ? 1 : 0; nerrors += test_windows() < 0 ? 1 : 0; nerrors += test_ros3() < 0 ? 1 : 0; + nerrors += test_splitter() < 0 ? 1 : 0; if(nerrors) { HDprintf("***** %d Virtual File Driver TEST%s FAILED! *****\n", diff --git a/testpar/t_2Gio.c b/testpar/t_2Gio.c index 41ecf86..54ea546 100644 --- a/testpar/t_2Gio.c +++ b/testpar/t_2Gio.c @@ -1,5 +1,6 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -158,6 +159,9 @@ parse_options(int argc, char **argv) } paraprefix = *argv; break; + case 'i': /* Collective MPI-IO access with independent IO */ + dxfer_coll_type = DXFER_INDEPENDENT_IO; + break; case '2': /* Use the split-file driver with MPIO access */ /* Can use $HDF5_METAPREFIX to define the */ /* meta-file-prefix. */ @@ -257,15 +261,38 @@ create_faccess_plist(MPI_Comm comm, MPI_Info info, int l_facc_type) if (l_facc_type == FACC_DEFAULT) return (ret_pl); - /* set Parallel access with communicator */ - ret = H5Pset_fapl_mpio(ret_pl, comm, info); - VRFY((ret >= 0), ""); - ret = H5Pset_all_coll_metadata_ops(ret_pl, TRUE); - VRFY((ret >= 0), ""); - ret = H5Pset_coll_metadata_write(ret_pl, TRUE); - VRFY((ret >= 0), ""); + if (l_facc_type == FACC_MPIO){ + /* set Parallel access with communicator */ + ret = H5Pset_fapl_mpio(ret_pl, comm, info); + VRFY((ret >= 0), ""); + ret = H5Pset_all_coll_metadata_ops(ret_pl, TRUE); + VRFY((ret >= 0), ""); + ret = H5Pset_coll_metadata_write(ret_pl, TRUE); + VRFY((ret >= 0), ""); + return(ret_pl); + } + + if (l_facc_type == (FACC_MPIO | FACC_SPLIT)){ + hid_t mpio_pl; + + mpio_pl = H5Pcreate (H5P_FILE_ACCESS); + VRFY((mpio_pl >= 0), ""); + /* set Parallel access with communicator */ + ret = H5Pset_fapl_mpio(mpio_pl, comm, info); + VRFY((ret >= 0), ""); + + /* setup file access template */ + ret_pl = H5Pcreate (H5P_FILE_ACCESS); + VRFY((ret_pl >= 0), ""); + /* set Parallel access with communicator */ + ret = H5Pset_fapl_split(ret_pl, ".meta", mpio_pl, ".raw", mpio_pl); + VRFY((ret >= 0), "H5Pset_fapl_split succeeded"); + H5Pclose(mpio_pl); + return(ret_pl); + } - return(ret_pl); + /* unknown file access types */ + return (ret_pl); } @@ -525,34 +552,37 @@ dataset_vrfy(hsize_t start[], hsize_t count[], hsize_t stride[], hsize_t block[] #define H5FILE_NAME "hugefile.h5" #define DATASETNAME "dataset" -static int MpioTest2G( MPI_Comm comm, int mpi_rank ) +static int MpioTest2G( MPI_Comm comm ) { /* * HDF5 APIs definitions */ herr_t status; - hid_t dcpl_id; - hid_t filedataspace; - hid_t memorydataspace; hid_t file_id, dset_id; /* file and dataset identifiers */ hid_t plist_id; /* property list identifier */ hid_t filespace; /* file and memory dataspace identifiers */ int *data; /* pointer to data buffer to write */ - hsize_t shape[3] = {1024, 1024, 1152}; - size_t data_size, data_size_bytes, slice_per_process = shape[0]/2; - size_t tot_size_bytes = sizeof(int); - hsize_t chunk[3] = {4, shape[1], shape[2]}; - hsize_t h5_counts[3] = { slice_per_process, shape[1], shape[2] }; - hsize_t h5_offsets[3] = { (size_t)mpi_rank * slice_per_process, 0, 0}; + size_t tot_size_bytes; + hid_t dcpl_id; + hid_t memorydataspace; + hid_t filedataspace; + size_t slice_per_process; + size_t data_size; + size_t data_size_bytes; + hsize_t chunk[3]; + hsize_t h5_counts[3]; + hsize_t h5_offsets[3]; + hsize_t shape[3] = {1024, 1024, 1152}; /* * MPI variables */ - int mpi_size; + int mpi_size, mpi_rank; MPI_Info info = MPI_INFO_NULL; MPI_Comm_size(comm, &mpi_size); + MPI_Comm_rank(comm, &mpi_rank); if(mpi_rank == 0) { HDprintf("Using %d process on dataset shape [%llu, %llu, %llu]\n", @@ -578,6 +608,7 @@ static int MpioTest2G( MPI_Comm comm, int mpi_rank ) /* * Create the dataspace for the dataset. */ + tot_size_bytes = sizeof(int); for (int i = 0; i < 3; i++) { tot_size_bytes *= shape[i]; } @@ -592,6 +623,9 @@ static int MpioTest2G( MPI_Comm comm, int mpi_rank ) */ dcpl_id = H5Pcreate (H5P_DATASET_CREATE); VRFY((dcpl_id >= 0), "H5P_DATASET_CREATE"); + chunk[0] = 4; + chunk[1] = shape[1]; + chunk[2] = shape[2]; status = H5Pset_chunk(dcpl_id, 3, chunk); VRFY((status >= 0), "H5Pset_chunk succeeded"); @@ -601,7 +635,7 @@ static int MpioTest2G( MPI_Comm comm, int mpi_rank ) dset_id = H5Dcreate2(file_id, DATASETNAME, H5T_NATIVE_INT, filespace, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); - VRFY((dset_id >= 0), "H5Dcreate succeeded"); + VRFY((dset_id >= 0), "H5Dcreate2 succeeded"); H5Sclose(filespace); /* @@ -612,6 +646,7 @@ static int MpioTest2G( MPI_Comm comm, int mpi_rank ) status = H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE); VRFY((status >= 0), ""); + H5_CHECKED_ASSIGN(slice_per_process, size_t, (shape[0] + (hsize_t)mpi_size - 1) / (hsize_t)mpi_size, hsize_t); data_size = slice_per_process * shape[1] * shape[2]; data_size_bytes = sizeof(int) * data_size; data = HDmalloc(data_size_bytes); @@ -621,6 +656,12 @@ static int MpioTest2G( MPI_Comm comm, int mpi_rank ) data[i] = mpi_rank; } + h5_counts[0] = slice_per_process; + h5_counts[1] = shape[1]; + h5_counts[2] = shape[2]; + h5_offsets[0] = (size_t)mpi_rank * slice_per_process; + h5_offsets[1] = 0; + h5_offsets[2] = 0; filedataspace = H5Screate_simple(3, shape, NULL); VRFY((filedataspace >= 0), "H5Screate_simple succeeded"); @@ -651,7 +692,6 @@ static int MpioTest2G( MPI_Comm comm, int mpi_rank ) free(data); HDprintf("Proc %d - MpioTest2G test succeeded\n", mpi_rank, data_size_bytes); - HDfflush(stdout); if (mpi_rank == 0) HDremove(FILENAME[1]); @@ -4871,6 +4911,9 @@ main(int argc, char **argv) h5_show_hostname(); } + if (H5dont_atexit() < 0){ + HDprintf("Failed to turn off atexit processing. Continue.\n"); + }; H5open(); /* Set the internal transition size to allow use of derived datatypes * without having to actually read or write large datasets (>2GB). @@ -4934,7 +4977,7 @@ main(int argc, char **argv) express_test = GetTestExpress(); if ((express_test == 0) && (mpi_rank < 2)) { - MpioTest2G(test_comm, mpi_rank); + MpioTest2G(test_comm); } MPI_Barrier(MPI_COMM_WORLD); diff --git a/testpar/t_cache.c b/testpar/t_cache.c index 09d2ecc..954071d 100644 --- a/testpar/t_cache.c +++ b/testpar/t_cache.c @@ -4671,7 +4671,7 @@ verify_entry_reads(haddr_t addr, } } - if ( ! success ) { + if ( success ) { if ( reported_entry_reads != expected_entry_reads ) { @@ -4778,7 +4778,7 @@ verify_entry_writes(haddr_t addr, } } - if ( ! success ) { + if ( success ) { if ( reported_entry_writes != expected_entry_writes ) { diff --git a/testpar/t_init_term.c b/testpar/t_init_term.c index 537e5fa..0e40fe4 100644 --- a/testpar/t_init_term.c +++ b/testpar/t_init_term.c @@ -65,7 +65,7 @@ main (int argc, char **argv) if(MAINPROCESS) { if(0 == nerrors) - PASSED() + PASSED(); else H5_FAILED() } diff --git a/testpar/t_pflush2.c b/testpar/t_pflush2.c index f58e5a5..f4589c8 100644 --- a/testpar/t_pflush2.c +++ b/testpar/t_pflush2.c @@ -189,7 +189,7 @@ main(int argc, char *argv[]) goto error; } else if(mpi_rank == 0) { - PASSED() + PASSED(); } /* Check the case where the file was not flushed. This should give an error @@ -203,7 +203,7 @@ main(int argc, char *argv[]) h5_fixname(FILENAME[1], fapl_id2, name, sizeof(name)); if(check_test_file(name, fapl_id2)) { if(mpi_rank == 0) - PASSED() + PASSED(); } else { H5_FAILED() diff --git a/testpar/t_prestart.c b/testpar/t_prestart.c index 831f1a2..da6bbe0 100644 --- a/testpar/t_prestart.c +++ b/testpar/t_prestart.c @@ -128,7 +128,7 @@ main (int argc, char **argv) if(MAINPROCESS) { if(0 == nerrors) - PASSED() + PASSED(); else H5_FAILED() } diff --git a/testpar/t_pshutdown.c b/testpar/t_pshutdown.c index 731c719..6a35fb2 100644 --- a/testpar/t_pshutdown.c +++ b/testpar/t_pshutdown.c @@ -116,7 +116,7 @@ main (int argc, char **argv) if(MAINPROCESS) { if(0 == nerrors) - PASSED() + PASSED(); else H5_FAILED() } diff --git a/testpar/t_span_tree.c b/testpar/t_span_tree.c index fe8a618..8d2b61c 100644 --- a/testpar/t_span_tree.c +++ b/testpar/t_span_tree.c @@ -867,6 +867,12 @@ coll_read_test(void) VRFY((ret >= 0),"H5D contiguous irregular collective read succeed"); /* + * Free read buffers. + */ + HDfree(matrix_out); + HDfree(matrix_out1); + + /* * Close memory file and memory dataspaces. */ ret = H5Sclose(mspaceid); diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c index 86726b4..87a3b11 100644 --- a/tools/lib/h5diff.c +++ b/tools/lib/h5diff.c @@ -29,7 +29,7 @@ H5_ATTR_PURE int print_objname (diff_opt_t * opts, hsize_t nfound) { - return ((opts->m_verbose || nfound) && !opts->m_quiet) ? 1 : 0; + return ((opts->mode_verbose || nfound) && !opts->mode_quiet) ? 1 : 0; } /*------------------------------------------------------------------------- @@ -45,7 +45,7 @@ do_print_objname (const char *OBJ, const char *path1, const char *path2, diff_op * displaying any object or symbolic links. This improves * readability of the output. */ - if (opts->m_verbose_level >= 1) + if (opts->mode_verbose_level >= 1) parallel_print("\n"); parallel_print("%-7s: <%s> and <%s>\n", OBJ, path1, path2); } @@ -74,7 +74,7 @@ do_print_attrname (const char *attr, const char *path1, const char *path2) static int print_warn(diff_opt_t *opts) { - return ((opts->m_verbose)) ? 1: 0; + return ((opts->mode_verbose)) ? 1: 0; } @@ -141,7 +141,7 @@ is_valid_options(diff_opt_t *opts) /*----------------------------------------------- * no -q(quiet) with -v (verbose) or -r (report) */ - if(opts->m_quiet && (opts->m_verbose || opts->m_report)) { + if(opts->mode_quiet && (opts->mode_verbose || opts->mode_report)) { parallel_print("Error: -q (quiet mode) cannot be added to verbose or report modes\n"); opts->err_stat = H5DIFF_ERR; H5TOOLS_GOTO_DONE(0); @@ -169,9 +169,9 @@ done: * 0 - not excluded path *------------------------------------------------------------------------*/ static int -is_exclude_path (char * path, h5trav_type_t type, diff_opt_t *opts) +is_exclude_path (char *path, h5trav_type_t type, diff_opt_t *opts) { - struct exclude_path_list * exclude_path_ptr; + struct exclude_path_list *exclude_path_ptr; int ret_cmp; int ret_value = 0; @@ -210,7 +210,7 @@ is_exclude_path (char * path, h5trav_type_t type, diff_opt_t *opts) if (ret_cmp == 0) { /* found matching object */ /* excluded non-group object */ ret_value = 1; - /* remember the type of this maching object. + /* remember the type of this matching object. * if it's group, it can be used for excluding its member * objects in this while() loop */ exclude_path_ptr->obj_type = type; @@ -224,6 +224,71 @@ done: return ret_value; } +/*------------------------------------------------------------------------- + * Function: is_exclude_attr + * + * Purpose: check if 'paths' are part of exclude path list + * + * Return: + * 1 - excluded path + * 0 - not excluded path + *------------------------------------------------------------------------*/ +static int +is_exclude_attr (const char *path, h5trav_type_t type, diff_opt_t *opts) +{ + struct exclude_path_list *exclude_ptr; + int ret_cmp; + int ret_value = 0; + + /* check if exclude attr option is given */ + if (!opts->exclude_attr_path) + H5TOOLS_GOTO_DONE(0); + + /* assign to local exclude list pointer */ + exclude_ptr = opts->exclude_attr; + + /* search objects in exclude list */ + while (NULL != exclude_ptr) { + /* if exclude path is is group, exclude its members as well */ + if (exclude_ptr->obj_type == H5TRAV_TYPE_GROUP) { + ret_cmp = HDstrncmp(exclude_ptr->obj_path, path, + HDstrlen(exclude_ptr->obj_path)); + if (ret_cmp == 0) { /* found matching members */ + size_t len_grp; + + /* check if given path belong to an excluding group, if so + * exclude it as well. + * This verifies if “/grp1/dset1” is only under “/grp1”, but + * not under “/grp1xxx/” group. + */ + len_grp = HDstrlen(exclude_ptr->obj_path); + if (path[len_grp] == '/') { + /* belong to excluded group! */ + ret_value = 1; + break; /* while */ + } + } + } + /* exclude target is not group, just exclude the object */ + else { + ret_cmp = HDstrcmp(exclude_ptr->obj_path, path); + if (ret_cmp == 0) { /* found matching object */ + /* excluded non-group object */ + ret_value = 1; + /* remember the type of this matching object. + * if it's group, it can be used for excluding its member + * objects in this while() loop */ + exclude_ptr->obj_type = type; + break; /* while */ + } + } + exclude_ptr = exclude_ptr->next; + } + +done: + return ret_value; +} + /*------------------------------------------------------------------------- * Function: free_exclude_path_list @@ -243,6 +308,25 @@ free_exclude_path_list(diff_opt_t *opts) } } + +/*------------------------------------------------------------------------- + * Function: free_exclude_attr_list + * + * Purpose: free exclude object attribute list from diff options + *------------------------------------------------------------------------*/ +static void +free_exclude_attr_list(diff_opt_t *opts) +{ + struct exclude_path_list *curr = opts->exclude_attr; + struct exclude_path_list *next; + + while (NULL != curr) { + next = curr->next; + HDfree(curr); + curr = next; + } +} + /*------------------------------------------------------------------------- * Function: build_match_list * @@ -288,6 +372,7 @@ build_match_list (const char *objname1, trav_info_t *info1, const char *objname2 * All the objects belong to given groups are the candidates. * So prepare to compare paths without the group names. */ + H5TOOLS_DEBUG("objname1 = %s objname2 = %s ", objname1, objname2); /* if obj1 is not root */ if (HDstrcmp (objname1,"/") != 0) @@ -519,6 +604,8 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char { hid_t file1_id = H5I_INVALID_HID; hid_t file2_id = H5I_INVALID_HID; + hid_t fapl1_id = H5P_DEFAULT; + hid_t fapl2_id = H5P_DEFAULT; char filenames[2][MAX_FILENAME]; hsize_t nfound = 0; int l_ret1 = -1; @@ -570,17 +657,32 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char *------------------------------------------------------------------------- */ /* open file 1 */ - if((file1_id = h5tools_fopen(fname1, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0) { + if (opts->custom_vol[0]) { + if((fapl1_id = h5tools_get_fapl(H5P_DEFAULT, &(opts->vol_info[0]), NULL)) < 0 ) { + parallel_print("h5diff: unable to create fapl for input file\n"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "unable to create input fapl\n"); + } + } + + if((file1_id = h5tools_fopen(fname1, H5F_ACC_RDONLY, fapl1_id, FALSE, NULL, (size_t)0)) < 0) { parallel_print("h5diff: <%s>: unable to open file\n", fname1); H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "<%s>: unable to open file\n", fname1); - } /* end if */ + } H5TOOLS_DEBUG("file1_id = %s", fname1); /* open file 2 */ - if((file2_id = h5tools_fopen(fname2, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0) { + + if (opts->custom_vol[1]) { + if((fapl2_id = h5tools_get_fapl(H5P_DEFAULT, &(opts->vol_info[1]), NULL)) < 0 ) { + parallel_print("h5diff: unable to create fapl for output file\n"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "unable to create output fapl\n"); + } + } + + if((file2_id = h5tools_fopen(fname2, H5F_ACC_RDONLY, fapl2_id, FALSE, NULL, (size_t)0)) < 0) { parallel_print("h5diff: <%s>: unable to open file\n", fname2); H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "<%s>: unable to open file\n", fname2); - } /* end if */ + } H5TOOLS_DEBUG("file2_id = %s", fname2); /*------------------------------------------------------------------------- @@ -610,6 +712,7 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char } else obj1fullname = HDstrdup(objname1); + H5TOOLS_DEBUG("obj1fullname = %s", obj1fullname); /* make the given object2 fullpath, start with "/" */ if (HDstrncmp(objname2, "/", 1)) { @@ -627,6 +730,7 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char } else obj2fullname = HDstrdup(objname2); + H5TOOLS_DEBUG("obj2fullname = %s", obj2fullname); /*---------------------------------------------------------- * check if obj1 is root, group, single object or symlink @@ -760,12 +864,12 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char H5TOOLS_DEBUG("h5diff ... dangling link"); if (opts->no_dangle_links) { /* treat dangling link as error */ - if(opts->m_verbose) + if(opts->mode_verbose) parallel_print("Warning: <%s> is a dangling link.\n", obj1fullname); H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "treat dangling link as error"); } else { - if(opts->m_verbose) + if(opts->mode_verbose) parallel_print("obj1 <%s> is a dangling link.\n", obj1fullname); if (l_ret1 != 0 || l_ret2 != 0) { nfound++; @@ -801,12 +905,12 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char H5TOOLS_DEBUG("h5diff ... dangling link"); if (opts->no_dangle_links) { /* treat dangling link as error */ - if(opts->m_verbose) + if(opts->mode_verbose) parallel_print("Warning: <%s> is a dangling link.\n", obj2fullname); H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "treat dangling link as error"); } else { - if(opts->m_verbose) + if(opts->mode_verbose) parallel_print("obj2 <%s> is a dangling link.\n", obj2fullname); if (l_ret1 != 0 || l_ret2 != 0) { nfound++; @@ -840,8 +944,8 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char * comparing details of same objects. */ - if(!(opts->m_verbose || opts->m_report)) { - H5TOOLS_DEBUG("h5diff NOT (opts->m_verbose || opts->m_report)"); + if(!(opts->mode_verbose || opts->mode_report)) { + H5TOOLS_DEBUG("h5diff NOT (opts->mode_verbose || opts->mode_report)"); /* if no danglink links */ if (l_ret1 > 0 && l_ret2 > 0) if (h5tools_is_obj_same(file1_id, obj1fullname, file2_id, obj2fullname) != 0) @@ -907,9 +1011,14 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char /*------------------------------------------------------ * print the list */ - if(opts->m_verbose) { + if(opts->mode_verbose) { unsigned u; + if(opts->mode_verbose_level > 2) { + parallel_print("file1: %s\n", fname1); + parallel_print("file2: %s\n", fname2); + } + parallel_print("\n"); /* if given objects is group under root */ if (HDstrcmp (obj1fullname,"/") || HDstrcmp (obj2fullname,"/")) @@ -930,6 +1039,7 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char nfound = diff_match(file1_id, obj1fullname, info1_lp, file2_id, obj2fullname, info2_lp, match_list, opts); + H5TOOLS_DEBUG("diff_match nfound: %d - errstat:%d", nfound, opts->err_stat); done: opts->err_stat = opts->err_stat | ret_value; @@ -967,6 +1077,10 @@ done: { H5Fclose(file1_id); H5Fclose(file2_id); + if (fapl1_id != H5P_DEFAULT) + H5Pclose(fapl1_id); + if (fapl2_id != H5P_DEFAULT) + H5Pclose(fapl2_id); } H5E_END_TRY; H5TOOLS_ENDDEBUG(" - errstat:%d", opts->err_stat); @@ -1026,12 +1140,14 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, *------------------------------------------------------------------------- */ + H5TOOLS_DEBUG("exclude_path opts->contents:%d", opts->contents); /* not valid compare used when --exclude-path option is used */ if (!opts->exclude_path) { /* number of different objects */ if (info1->nused != info2->nused) { opts->contents = 0; } + H5TOOLS_DEBUG("opts->exclude_path opts->contents:%d", opts->contents); } /* objects in one file and not the other */ @@ -1040,6 +1156,7 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, opts->contents = 0; break; } + H5TOOLS_DEBUG("table->nobjs[%d] opts->contents:%d", i, opts->contents); } /*------------------------------------------------------------------------- @@ -1112,9 +1229,7 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, opts->cmn_objs = 1; if(!g_Parallel) { H5TOOLS_DEBUG("diff paths - errstat:%d", opts->err_stat); - nfound += diff(file1_id, obj1_fullpath, - file2_id, obj2_fullpath, - opts, &argdata); + nfound += diff(file1_id, obj1_fullpath, file2_id, obj2_fullpath, opts, &argdata); } /* end if */ #ifdef H5_HAVE_PARALLEL else { @@ -1359,6 +1474,8 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, opts->err_stat = opts->err_stat | ret_value; + free_exclude_attr_list (opts); + /* free table */ if (table) trav_table_free(table); @@ -1383,7 +1500,7 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, *------------------------------------------------------------------------- */ hsize_t -diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_opt_t * opts, diff_args_t *argdata) +diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_opt_t *opts, diff_args_t *argdata) { int status = -1; hid_t dset1_id = H5I_INVALID_HID; @@ -1432,7 +1549,7 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_ if (status == 0) { if (opts->no_dangle_links) { /* dangling link is error */ - if(opts->m_verbose) + if(opts->mode_verbose) parallel_print("Warning: <%s> is a dangling link.\n", path1); H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "dangling link is error"); } @@ -1447,7 +1564,7 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_ if (status == 0) { if (opts->no_dangle_links) { /* dangling link is error */ - if(opts->m_verbose) + if(opts->mode_verbose) parallel_print("Warning: <%s> is a dangling link.\n", path2); H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "dangling link is error"); } @@ -1473,11 +1590,11 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_ /* if objects are not the same type */ if (argdata->type[0] != argdata->type[1]) { H5TOOLS_DEBUG("diff objects are not the same"); - if (opts->m_verbose||opts->m_list_not_cmp) { + if (opts->mode_verbose||opts->mode_list_not_cmp) { parallel_print("Not comparable: <%s> is of type %s and <%s> is of type %s\n", - path1, get_type(argdata->type[0]), - path2, get_type(argdata->type[1])); + path1, get_type(argdata->type[0]), path2, get_type(argdata->type[1])); } + opts->not_cmp = 1; /* TODO: will need to update non-comparable is different * opts->contents = 0; @@ -1502,7 +1619,7 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_ object_type == H5TRAV_TYPE_GROUP); if (opts->follow_links || is_hard_link) { /* print information is only verbose option is used */ - if(opts->m_verbose || opts->m_report) { + if(opts->mode_verbose || opts->mode_report) { switch(object_type) { case H5TRAV_TYPE_DATASET: do_print_objname("dataset", path1, path2, opts); @@ -1531,7 +1648,7 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_ } /* switch(type)*/ print_found(nfound); - } /* if(opts->m_verbose || opts->m_report) */ + } /* if(opts->mode_verbose || opts->mode_report) */ /* exact same, so comparison is done */ H5TOOLS_GOTO_DONE(H5DIFF_NO_ERR); @@ -1549,15 +1666,16 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_ H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dopen2 failed"); if((dset2_id = H5Dopen2(file2_id, path2, H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dopen2 failed"); + H5TOOLS_DEBUG("paths: %s - %s", path1, path2); /* verbose (-v) and report (-r) mode */ - if(opts->m_verbose || opts->m_report) { + if(opts->mode_verbose || opts->mode_report) { do_print_objname("dataset", path1, path2, opts); H5TOOLS_DEBUG("call diff_dataset 1:%s 2:%s ", path1, path2); nfound = diff_dataset(file1_id, file2_id, path1, path2, opts); print_found(nfound); } /* quiet mode (-q), just count differences */ - else if(opts->m_quiet) { + else if(opts->mode_quiet) { nfound = diff_dataset(file1_id, file2_id, path1, path2, opts); } /* the rest (-c, none, ...) */ @@ -1577,7 +1695,7 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_ * referenced object *--------------------------------------------------------- */ - if(path1) { + if(path1 && !is_exclude_attr(path1, object_type, opts)) { H5TOOLS_DEBUG( "call diff_attr 1:%s 2:%s ", path1, path2); nfound += diff_attr(dset1_id, dset2_id, path1, path2, opts); } @@ -1609,7 +1727,7 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_ do_print_objname("datatype", path1, path2, opts); /* always print the number of differences found in verbose mode */ - if(opts->m_verbose) + if(opts->mode_verbose) print_found(nfound); /*----------------------------------------------------------------- @@ -1618,7 +1736,7 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_ * referenced object *----------------------------------------------------------------- */ - if(path1) { + if(path1 && !is_exclude_attr(path1, object_type, opts)) { H5TOOLS_DEBUG("call diff_attr 1:%s 2:%s ", path1, path2); nfound += diff_attr(type1_id, type2_id, path1, path2, opts); } @@ -1639,7 +1757,7 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_ do_print_objname("group", path1, path2, opts); /* always print the number of differences found in verbose mode */ - if(opts->m_verbose) + if(opts->mode_verbose) print_found(nfound); if((grp1_id = H5Gopen2(file1_id, path1, H5P_DEFAULT)) < 0) @@ -1653,7 +1771,7 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_ * referenced object *----------------------------------------------------------------- */ - if(path1) { + if(path1 && !is_exclude_attr(path1, object_type, opts)) { H5TOOLS_DEBUG("call diff_attr 1:%s 2:%s ", path1, path2); nfound += diff_attr(grp1_id, grp2_id, path1, path2, opts); } @@ -1681,7 +1799,7 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_ do_print_objname("link", path1, path2, opts); /* always print the number of differences found in verbose mode */ - if(opts->m_verbose) + if(opts->mode_verbose) print_found(nfound); } break; @@ -1731,14 +1849,14 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_ } /* end else */ /* always print the number of differences found in verbose mode */ - if(opts->m_verbose) + if(opts->mode_verbose) print_found(nfound); } break; case H5TRAV_TYPE_UNKNOWN: default: - if(opts->m_verbose) + if(opts->mode_verbose) parallel_print("Comparison not supported: <%s> and <%s> are of type %s\n", path1, path2, get_type(object_type) ); opts->not_cmp = 1; @@ -1760,7 +1878,7 @@ done: } /* path1 is dangling link */ else if (is_dangle_link1) { - if(opts->m_verbose) + if(opts->mode_verbose) parallel_print("obj1 <%s> is a dangling link.\n", path1); nfound++; if(print_objname(opts, nfound)) @@ -1768,7 +1886,7 @@ done: } /* path2 is dangling link */ else if (is_dangle_link2) { - if(opts->m_verbose) + if(opts->mode_verbose) parallel_print("obj2 <%s> is a dangling link.\n", path2); nfound++; if(print_objname(opts, nfound)) diff --git a/tools/lib/h5diff.h b/tools/lib/h5diff.h index b04ec23..f44f653 100644 --- a/tools/lib/h5diff.h +++ b/tools/lib/h5diff.h @@ -15,25 +15,9 @@ #define H5DIFF_H__ #include "hdf5.h" +#include "h5tools.h" #include "h5trav.h" -/* - * Debug printf macros. The prefix allows output filtering by test scripts. - */ -#ifdef H5DIFF_DEBUG -#define h5difftrace(x) HDfprintf(stderr, "h5diff debug: " x) -#define h5diffdebug2(x1, x2) HDfprintf(stderr, "h5diff debug: " x1, x2) -#define h5diffdebug3(x1, x2, x3) HDfprintf(stderr, "h5diff debug: " x1, x2, x3) -#define h5diffdebug4(x1, x2, x3, x4) HDfprintf(stderr, "h5diff debug: " x1, x2, x3, x4) -#define h5diffdebug5(x1, x2, x3, x4, x5) HDfprintf(stderr, "h5diff debug: " x1, x2, x3, x4, x5) -#else -#define h5difftrace(x) -#define h5diffdebug2(x1, x2) -#define h5diffdebug3(x1, x2, x3) -#define h5diffdebug4(x1, x2, x3, x4) -#define h5diffdebug5(x1, x2, x3, x4, x5) -#endif - #define MAX_FILENAME 1024 /*------------------------------------------------------------------------- @@ -52,11 +36,12 @@ typedef struct { */ /* linked list to keep exclude path list */ struct exclude_path_list { - char *obj_path; - h5trav_type_t obj_type; - struct exclude_path_list * next; + const char *obj_path; + h5trav_type_t obj_type; + struct exclude_path_list *next; }; + /* Enumeration value for keeping track of whether an error occurred or differences were found */ typedef enum { H5DIFF_NO_ERR, /* No error occurred */ @@ -65,27 +50,47 @@ typedef enum { } diff_err_t; typedef struct { - int m_quiet; /* quiet mode: no output at all */ - int m_report; /* report mode: print the data */ - int m_verbose; /* verbose mode: print the data, list of objcets, warnings */ - int m_verbose_level; /* control verbose details */ - int d; /* delta, absolute value to compare */ - double delta; /* delta value */ - int p; /* relative error to compare*/ - int use_system_epsilon; /* flag to use system epsilon (1 or 0) */ - double percent; /* relative error value */ - int n; /* count, compare up to count */ - hsize_t count; /* count value */ - hbool_t follow_links; /* follow symbolic links */ - int no_dangle_links; /* return error when find dangling link */ - diff_err_t err_stat; /* an error ocurred (2, error, 1, differences, 0, no error) */ - int cmn_objs; /* do we have common objects */ - int not_cmp; /* are the objects comparable */ - int contents; /* equal contents */ - int do_nans; /* consider Nans while diffing floats */ - int m_list_not_cmp; /* list not comparable messages */ - int exclude_path; /* exclude path to an object */ - struct exclude_path_list * exclude; /* keep exclude path list */ + int mode_quiet; /* quiet mode: no output at all */ + int mode_report; /* report mode: print the data */ + int mode_verbose; /* verbose mode: print the data, list of objcets, warnings */ + int mode_verbose_level; /* control verbose details */ + int mode_list_not_cmp; /* list not comparable messages */ + int print_header; /* print header */ + int print_percentage; /* print percentage */ + int print_dims; /* print dimension index */ + int delta_bool; /* delta, absolute value to compare */ + double delta; /* delta value */ + int use_system_epsilon; /* flag to use system epsilon (1 or 0) */ + int percent_bool; /* relative error to compare*/ + double percent; /* relative error value */ + hbool_t follow_links; /* follow symbolic links */ + int no_dangle_links; /* return error when find dangling link */ + int cmn_objs; /* do we have common objects */ + int not_cmp; /* are the objects comparable */ + int contents; /* equal contents */ + int do_nans; /* consider Nans while diffing floats */ + int exclude_path; /* exclude path to an object */ + int exclude_attr_path; /* exclude path to an object */ + struct exclude_path_list *exclude; /* keep exclude path list */ + struct exclude_path_list *exclude_attr; /* keep exclude attribute list */ + int count_bool; /* count, compare up to count */ + hsize_t count; /* count value */ + diff_err_t err_stat; /* an error ocurred (2, error, 1, differences, 0, no error) */ + hsize_t nelmts; /* total number of elements */ + hsize_t hs_nelmts; /* number of elements to read at a time*/ + int rank; /* dimensionality */ + size_t m_size; /* m_size for diff */ + hid_t m_tid; /* m_tid for diff */ + hsize_t dims[H5S_MAX_RANK]; /* dimensions of object */ + hsize_t p_min_idx[H5S_MAX_RANK]; /* min selected index */ + hsize_t p_max_idx[H5S_MAX_RANK]; /* max selected index */ + hsize_t acc[H5S_MAX_RANK]; /* accumulator position */ + hsize_t pos[H5S_MAX_RANK]; /* matrix position */ + hsize_t sm_pos[H5S_MAX_RANK]; /* stripmine position */ + char *obj_name[2]; /* name for object */ + struct subset_t *sset[2]; /* subsetting parameters */ + h5tools_vol_info_t vol_info[2]; /* VOL information for input file, output file */ + hbool_t custom_vol[2]; /* Using a custom input, output VOL? */ } diff_opt_t; @@ -98,18 +103,9 @@ typedef struct { extern "C" { #endif -H5TOOLS_DLL hsize_t h5diff(const char *fname1, - const char *fname2, - const char *objname1, - const char *objname2, - diff_opt_t *opts); +H5TOOLS_DLL hsize_t h5diff(const char *fname1, const char *fname2, const char *objname1, const char *objname2, diff_opt_t *opts); -H5TOOLS_DLL hsize_t diff( hid_t file1_id, - const char *path1, - hid_t file2_id, - const char *path2, - diff_opt_t *opts, - diff_args_t *argdata); +H5TOOLS_DLL hsize_t diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_opt_t *opts, diff_args_t *argdata); #ifdef H5_HAVE_PARALLEL H5TOOLS_DLL void phdiff_dismiss_workers(void); @@ -128,63 +124,29 @@ H5TOOLS_DLL void print_manager_output(void); */ -hsize_t diff_dataset( hid_t file1_id, - hid_t file2_id, - const char *obj1_name, - const char *obj2_name, - diff_opt_t *opts); - -hsize_t diff_datasetid( hid_t dset1_id, - hid_t dset2_id, - const char *obj1_name, - const char *obj2_name, - diff_opt_t *opts); - - -hsize_t diff_match( hid_t file1_id, const char *grp1, trav_info_t *info1, - hid_t file2_id, const char *grp2, trav_info_t *info2, - trav_table_t *table, diff_opt_t *opts ); - -hsize_t diff_array( void *_mem1, - void *_mem2, - hsize_t nelmts, - hsize_t hyper_start, - int rank, - hsize_t *dims, - diff_opt_t *opts, - const char *name1, - const char *name2, - hid_t m_type, - hid_t container1_id, - hid_t container2_id); /* dataset where the reference came from*/ - - -int diff_can_type( hid_t f_type1, /* file data type */ - hid_t f_type2, /* file data type */ - int rank1, - int rank2, - hsize_t *dims1, - hsize_t *dims2, - hsize_t *maxdim1, - hsize_t *maxdim2, - const char *obj1_name, - const char *obj2_name, - diff_opt_t *opts, - int is_compound); - -hsize_t diff_attr_data(hid_t attr1_id, - hid_t attr2_id, - const char *attr1_name, - const char *attr2_name, - const char *path1, - const char *path2, - diff_opt_t *opts); - -hsize_t diff_attr(hid_t loc1_id, - hid_t loc2_id, - const char *path1, - const char *path2, - diff_opt_t *opts); +hsize_t diff_dataset(hid_t file1_id, hid_t file2_id, + const char *obj1_name, const char *obj2_name, diff_opt_t *opts); + +hsize_t diff_datasetid(hid_t dset1_id, hid_t dset2_id, + const char *obj1_name, const char *obj2_name, diff_opt_t *opts); + + +hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, + hid_t file2_id, const char *grp2, trav_info_t *info2, + trav_table_t *table, diff_opt_t *opts); + +hsize_t diff_array(void *_mem1, void *_mem2, + diff_opt_t *opts, hid_t container1_id, hid_t container2_id); + +int diff_can_type(hid_t f_type1, hid_t f_type2, int rank1, int rank2, + hsize_t *dims1, hsize_t *dims2, hsize_t *maxdim1, hsize_t *maxdim2, + diff_opt_t *opts, int is_compound); + +hsize_t diff_attr_data(hid_t attr1_id, hid_t attr2_id, const char *name1, const char *name2, + const char *path1, const char *path2, diff_opt_t *opts); + +hsize_t diff_attr(hid_t loc1_id, hid_t loc2_id, + const char *path1, const char *path2, diff_opt_t *opts); /*------------------------------------------------------------------------- diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index 52bae51..1a4c727 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -132,97 +132,39 @@ typedef struct mcomp_t { * local prototypes *------------------------------------------------------------------------- */ -static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, - hid_t region2_id, diff_opt_t *opts); static hbool_t all_zero(const void *_mem, size_t size); static int ull2float(unsigned long long ull_value, float *f_value); -static hsize_t character_compare(char *mem1, char *mem2, hsize_t i, size_t u, - int rank, hsize_t *dims, hsize_t *acc, hsize_t *pos, - diff_opt_t *opts, const char *obj1, const char *obj2, int *ph); -static hsize_t character_compare_opt(unsigned char *mem1, unsigned char *mem2, - hsize_t i, int rank, hsize_t *dims, hsize_t *acc, hsize_t *pos, - diff_opt_t *opts, const char *obj1, const char *obj2, int *ph); +static hsize_t character_compare(char *mem1, char *mem2, hsize_t elemtno, size_t u, diff_opt_t *opts); +static hsize_t character_compare_opt(unsigned char *mem1, unsigned char *mem2, hsize_t elemtno, diff_opt_t *opts); static hbool_t equal_float(float value, float expected, diff_opt_t *opts); static hbool_t equal_double(double value, double expected, diff_opt_t *opts); #if H5_SIZEOF_LONG_DOUBLE !=0 static hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *opts); #endif + static int print_data(diff_opt_t *opts); -static void print_pos(int *ph, int pp, hsize_t curr_pos, hsize_t *acc, - hsize_t *pos, int rank, hsize_t *dims, const char *obj1, - const char *obj2); -static void print_char_pos(int *ph, int pp, hsize_t curr_pos, size_t u, - hsize_t *acc, hsize_t *pos, int rank, hsize_t *dims, const char *obj1, - const char *obj2); +static void print_pos(diff_opt_t *opts, hsize_t elemtno, size_t u); static void h5diff_print_char(char ch); -static hsize_t diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, - int rank, hsize_t *dims, hsize_t *acc, hsize_t *pos, - diff_opt_t *opts, const char *obj1, const char *obj2, - hid_t container1_id, hid_t container2_id, /*where the reference came from*/ - int *ph, /*print header */ - mcomp_t *members); /*compound members */ -static hsize_t diff_float(unsigned char *mem1, unsigned char *mem2, - hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, - const char *obj2, int *ph); -static hsize_t diff_double(unsigned char *mem1, unsigned char *mem2, - hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, - const char *obj2, int *ph); + +static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t region2_id, diff_opt_t *opts); +static hsize_t diff_datum(void *_mem1, void *_mem2, hsize_t elemtno, diff_opt_t *opts, + hid_t container1_id, hid_t container2_id, mcomp_t *members); +/* element diffs */ +static hsize_t diff_float_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts); +static hsize_t diff_double_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts); #if H5_SIZEOF_LONG_DOUBLE !=0 -static hsize_t diff_ldouble(unsigned char *mem1, - unsigned char *mem2, - hsize_t nelmts, - hsize_t hyper_start, - int rank, - hsize_t *dims, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *opts, - const char *obj1, - const char *obj2, - int *ph); +static hsize_t diff_ldouble_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts); #endif -static hsize_t diff_schar(unsigned char *mem1, unsigned char *mem2, - hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, - const char *obj2, int *ph); -static hsize_t diff_uchar(unsigned char *mem1, unsigned char *mem2, - hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, - const char *obj2, int *ph); -static hsize_t diff_short(unsigned char *mem1, unsigned char *mem2, - hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, - const char *obj2, int *ph); -static hsize_t diff_ushort(unsigned char *mem1, unsigned char *mem2, - hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, - const char *obj2, int *ph); -static hsize_t diff_int(unsigned char *mem1, unsigned char *mem2, - hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, - const char *obj2, int *ph); -static hsize_t diff_uint(unsigned char *mem1, unsigned char *mem2, - hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, - const char *obj2, int *ph); -static hsize_t diff_long(unsigned char *mem1, unsigned char *mem2, - hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, - const char *obj2, int *ph); -static hsize_t diff_ulong(unsigned char *mem1, unsigned char *mem2, - hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, - const char *obj2, int *ph); -static hsize_t diff_llong(unsigned char *mem1, unsigned char *mem2, - hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, - const char *obj2, int *ph); -static hsize_t diff_ullong(unsigned char *mem1, unsigned char *mem2, - hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, - const char *obj2, int *ph); +static hsize_t diff_schar_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts); +static hsize_t diff_uchar_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts); +static hsize_t diff_short_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts); +static hsize_t diff_ushort_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts); +static hsize_t diff_int_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts); +static hsize_t diff_uint_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts); +static hsize_t diff_long_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts); +static hsize_t diff_ulong_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts); +static hsize_t diff_llong_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts); +static hsize_t diff_ullong_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts); /*------------------------------------------------------------------------- * NaN detection @@ -260,26 +202,23 @@ static void close_member_types(mcomp_t *members); *------------------------------------------------------------------------- */ -hsize_t diff_array(void *_mem1, void *_mem2, hsize_t nelmts, hsize_t hyper_start, - int rank, hsize_t *dims, diff_opt_t *opts, const char *name1, const char *name2, - hid_t m_type, hid_t container1_id, hid_t container2_id) +hsize_t +diff_array(void *_mem1, void *_mem2, diff_opt_t *opts, hid_t container1_id, hid_t container2_id) { hsize_t nfound = 0; /* number of differences found */ size_t size; /* size of datum */ unsigned char *mem1 = (unsigned char*) _mem1; unsigned char *mem2 = (unsigned char*) _mem2; - hsize_t acc[32]; /* accumulator position */ - hsize_t pos[32]; /* matrix position */ - int ph = 1; /* print header */ hsize_t i; - int j; mcomp_t members; H5T_class_t type_class; - H5TOOLS_START_DEBUG(" - errstat:%d", opts->err_stat); + H5TOOLS_START_DEBUG(" - rank:%d hs_nelmts:%ld errstat:%d", opts->rank, opts->hs_nelmts, opts->err_stat); + opts->print_header = 1; /* enable print header */ + /* get the size. */ - size = H5Tget_size(m_type); - type_class = H5Tget_class(m_type); + size = H5Tget_size(opts->m_tid); + type_class = H5Tget_class(opts->m_tid); /* Fast comparison first for atomic type by memcmp(). * It is OK not to list non-atomic type here because it will not be caught @@ -289,24 +228,18 @@ hsize_t diff_array(void *_mem1, void *_mem2, hsize_t nelmts, hsize_t hyper_start type_class != H5T_COMPOUND && type_class != H5T_STRING && type_class != H5T_VLEN && - HDmemcmp(mem1, mem2, size*nelmts) == 0) + HDmemcmp(mem1, mem2, size * opts->hs_nelmts) == 0) { + H5TOOLS_ENDDEBUG(":Fast comparison - errstat:%d", opts->err_stat); return 0; - - if (rank > 0) { - acc[rank - 1] = 1; - for (j = (rank - 2); j >= 0; j--) { - acc[j] = acc[j + 1] * dims[j + 1]; - } - for (j = 0; j < rank; j++) - pos[j] = 0; } - H5TOOLS_DEBUG("diff_array type_class:%d", type_class); + H5TOOLS_DEBUG("type_class:%d", type_class); switch (type_class) { case H5T_NO_CLASS: case H5T_TIME: case H5T_NCLASSES: default: + H5TOOLS_DEBUG("type_class:INVALID"); HDassert(0); break; @@ -315,37 +248,142 @@ hsize_t diff_array(void *_mem1, void *_mem2, hsize_t nelmts, hsize_t hyper_start *------------------------------------------------------------------------- */ case H5T_FLOAT: - if (H5Tequal(m_type, H5T_NATIVE_FLOAT)) - nfound = diff_float(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph); - else if (H5Tequal(m_type, H5T_NATIVE_DOUBLE)) - nfound = diff_double(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph); + H5TOOLS_DEBUG("type_class:H5T_FLOAT"); + if (H5Tequal(opts->m_tid, H5T_NATIVE_FLOAT)) { + for (i = 0; i < opts->hs_nelmts; i++) { + nfound += diff_float_element(mem1, mem2, i, opts); + + mem1 += sizeof(float); + mem2 += sizeof(float); + if (opts->count_bool && nfound >= opts->count) + return nfound; + } /* nelmts */ + } + else if (H5Tequal(opts->m_tid, H5T_NATIVE_DOUBLE)){ + for (i = 0; i < opts->hs_nelmts; i++) { + nfound += diff_double_element(mem1, mem2, i, opts); + + mem1 += sizeof(double); + mem2 += sizeof(double); + if (opts->count_bool && nfound >= opts->count) + return nfound; + } /* nelmts */ + } #if H5_SIZEOF_LONG_DOUBLE != 0 - else if (H5Tequal(m_type, H5T_NATIVE_LDOUBLE)) - nfound = diff_ldouble(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph); + else if (H5Tequal(opts->m_tid, H5T_NATIVE_LDOUBLE)) { + for ( i = 0; i < opts->hs_nelmts; i++) { + nfound += diff_ldouble_element(mem1, mem2, i, opts); + + mem1 += sizeof(long double); + mem2 += sizeof(long double); + if (opts->count_bool && nfound >= opts->count) + return nfound; + } /* nelmts */ + } #endif break; case H5T_INTEGER: - if (H5Tequal(m_type, H5T_NATIVE_SCHAR)) - nfound = diff_schar(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph); - else if (H5Tequal(m_type, H5T_NATIVE_UCHAR)) - nfound = diff_uchar(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph); - else if (H5Tequal(m_type, H5T_NATIVE_SHORT)) - nfound = diff_short(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph); - else if (H5Tequal(m_type, H5T_NATIVE_USHORT)) - nfound = diff_ushort(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph); - else if (H5Tequal(m_type, H5T_NATIVE_INT)) - nfound = diff_int(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph); - else if (H5Tequal(m_type, H5T_NATIVE_UINT)) - nfound = diff_uint(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph); - else if (H5Tequal(m_type, H5T_NATIVE_LONG)) - nfound = diff_long(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph); - else if (H5Tequal(m_type, H5T_NATIVE_ULONG)) - nfound = diff_ulong(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph); - else if (H5Tequal(m_type, H5T_NATIVE_LLONG)) - nfound = diff_llong(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph); - else if (H5Tequal(m_type, H5T_NATIVE_ULLONG)) - nfound = diff_ullong(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph); + H5TOOLS_DEBUG("type_class:H5T_INTEGER"); + if (H5Tequal(opts->m_tid, H5T_NATIVE_SCHAR)) { + for (i = 0; i < opts->hs_nelmts; i++) { + nfound += diff_schar_element(mem1, mem2, i, opts); + mem1 += sizeof(char); + mem2 += sizeof(char); + if (opts->count_bool && nfound >= opts->count) + return nfound; + } /* nelmts */ + } + else if (H5Tequal(opts->m_tid, H5T_NATIVE_UCHAR)) { + for (i = 0; i < opts->hs_nelmts; i++) { + nfound += diff_uchar_element(mem1, mem2, i, opts); + + mem1 += sizeof(unsigned char); + mem2 += sizeof(unsigned char); + if (opts->count_bool && nfound >= opts->count) + return nfound; + } /* nelmts */ + } + else if (H5Tequal(opts->m_tid, H5T_NATIVE_SHORT)) { + for (i = 0; i < opts->hs_nelmts; i++) { + nfound += diff_short_element(mem1, mem2, i, opts); + + mem1 += sizeof(short); + mem2 += sizeof(short); + if (opts->count_bool && nfound >= opts->count) + return nfound; + } /* nelmts */ + } + else if (H5Tequal(opts->m_tid, H5T_NATIVE_USHORT)) { + for (i = 0; i < opts->hs_nelmts; i++) { + nfound += diff_ushort_element(mem1, mem2, i, opts); + + mem1 += sizeof(unsigned short); + mem2 += sizeof(unsigned short); + if (opts->count_bool && nfound >= opts->count) + return nfound; + } /* nelmts */ + } + else if (H5Tequal(opts->m_tid, H5T_NATIVE_INT)) { + for (i = 0; i < opts->hs_nelmts; i++) { + nfound += diff_int_element(mem1, mem2, i, opts); + + mem1 += sizeof(int); + mem2 += sizeof(int); + if (opts->count_bool && nfound >= opts->count) + return nfound; + } /* nelmts */ + } + else if (H5Tequal(opts->m_tid, H5T_NATIVE_UINT)) { + for (i = 0; i < opts->hs_nelmts; i++) { + nfound += diff_int_element(mem1, mem2, i, opts); + + mem1 += sizeof(unsigned int); + mem2 += sizeof(unsigned int); + if (opts->count_bool && nfound >= opts->count) + return nfound; + } /* nelmts */ + } + else if (H5Tequal(opts->m_tid, H5T_NATIVE_LONG)) { + for (i = 0; i < opts->hs_nelmts; i++) { + nfound += diff_long_element(mem1, mem2, i, opts); + + mem1 += sizeof(long); + mem2 += sizeof(long); + if (opts->count_bool && nfound >= opts->count) + return nfound; + } /* nelmts */ + } + else if (H5Tequal(opts->m_tid, H5T_NATIVE_ULONG)) { + for (i = 0; i < opts->hs_nelmts; i++) { + nfound += diff_ulong_element(mem1, mem2, i, opts); + + mem1 += sizeof(unsigned long); + mem2 += sizeof(unsigned long); + if (opts->count_bool && nfound >= opts->count) + return nfound; + } /* nelmts */ + } + else if (H5Tequal(opts->m_tid, H5T_NATIVE_LLONG)) { + for (i = 0; i < opts->hs_nelmts; i++) { + nfound += diff_llong_element(mem1, mem2, i, opts); + + mem1 += sizeof(long long); + mem2 += sizeof(long long); + if (opts->count_bool && nfound >= opts->count) + return nfound; + } /* nelmts */ + } + else if (H5Tequal(opts->m_tid, H5T_NATIVE_ULLONG)) { + for (i = 0; i < opts->hs_nelmts; i++) { + nfound += diff_ullong_element(mem1, mem2, i, opts); + + mem1 += sizeof(unsigned long long); + mem2 += sizeof(unsigned long long); + if (opts->count_bool && nfound >= opts->count) + return nfound; + } /* nelmts */ + } break; /*------------------------------------------------------------------------- @@ -360,13 +398,13 @@ hsize_t diff_array(void *_mem1, void *_mem2, hsize_t nelmts, hsize_t hyper_start case H5T_ARRAY: case H5T_VLEN: case H5T_REFERENCE: + H5TOOLS_DEBUG("type_class:OTHER"); HDmemset(&members, 0, sizeof(mcomp_t)); - get_member_types(m_type, &members); - H5TOOLS_DEBUG("call diff_datum nelmts:%d - errstat:%d", nelmts, opts->err_stat); - for (i = 0; i < nelmts; i++) { - nfound += diff_datum(mem1 + i * size, mem2 + i * size, m_type, i, rank, dims, acc, pos, opts, - name1, name2, container1_id, container2_id, &ph, &members); - if (opts->n && nfound >= opts->count) + get_member_types(opts->m_tid, &members); + for (i = 0; i < opts->hs_nelmts; i++) { + H5TOOLS_DEBUG("opts->pos[%ld]:%ld - nelmts:%ld", i, opts->pos[i], opts->hs_nelmts); + nfound += diff_datum(mem1 + i * size, mem2 + i * size, i, opts, container1_id, container2_id, &members); + if (opts->count_bool && nfound >= opts->count) break; } /* i */ close_member_types(&members); @@ -409,12 +447,7 @@ hsize_t diff_array(void *_mem1, void *_mem2, hsize_t nelmts, hsize_t hyper_start *------------------------------------------------------------------------- */ static hsize_t -diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank, - hsize_t *dims, hsize_t *acc, hsize_t *pos, diff_opt_t *opts, - const char *obj1, const char *obj2, - hid_t container1_id, hid_t container2_id, - int *ph, /*print header */ - mcomp_t *members) /*compound members */ +diff_datum(void *_mem1, void *_mem2, hsize_t elemtno, diff_opt_t *opts, hid_t container1_id, hid_t container2_id, mcomp_t *members) { unsigned char *mem1 = (unsigned char*) _mem1; unsigned char *mem2 = (unsigned char*) _mem2; @@ -425,7 +458,6 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank, size_t offset; unsigned nmembs; unsigned j; - hsize_t nelmts; size_t size = 0; hbool_t iszero1; hbool_t iszero2; @@ -434,10 +466,10 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank, hbool_t both_zero; diff_err_t ret_value = opts->err_stat; - H5TOOLS_START_DEBUG(" - errstat:%d", opts->err_stat); + H5TOOLS_START_DEBUG("ph:%d elemtno:%d - errstat:%d", opts->print_header, elemtno, opts->err_stat); - type_size = H5Tget_size(m_type); - type_class = H5Tget_class(m_type); + type_size = H5Tget_size(opts->m_tid); + type_class = H5Tget_class(opts->m_tid); /* Fast comparison first for atomic type by memcmp(). * It is OK not to list non-atomic type here because it will not be caught @@ -450,7 +482,7 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank, HDmemcmp(mem1, mem2, type_size) == 0) H5TOOLS_GOTO_DONE(opts->err_stat); - switch (H5Tget_class(m_type)) { + switch (H5Tget_class(opts->m_tid)) { case H5T_NO_CLASS: case H5T_TIME: case H5T_NCLASSES: @@ -463,18 +495,22 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank, *------------------------------------------------------------------------- */ case H5T_COMPOUND: - H5TOOLS_DEBUG("diff_datum H5T_COMPOUND"); + H5TOOLS_DEBUG("H5T_COMPOUND"); { - hid_t memb_type = H5I_INVALID_HID; + diff_opt_t cmpd_opts; + + cmpd_opts = *opts; nmembs = members->n; for (j = 0; j < nmembs; j++) { offset = members->offsets[j]; - memb_type = members->ids[j]; + cmpd_opts.m_tid = members->ids[j]; - nfound += diff_datum(mem1 + offset, mem2 + offset, memb_type, idx, - rank, dims, acc, pos, opts, obj1, obj2, container1_id, container2_id, ph, members->m[j]); + nfound += diff_datum(mem1 + offset, mem2 + offset, elemtno, &cmpd_opts, container1_id, container2_id, members->m[j]); } + opts->err_stat = opts->err_stat | cmpd_opts.err_stat; + opts->print_header = cmpd_opts.print_header; + opts->not_cmp = cmpd_opts.not_cmp; } break; @@ -483,7 +519,7 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank, *------------------------------------------------------------------------- */ case H5T_STRING: - H5TOOLS_DEBUG("diff_datum H5T_STRING"); + H5TOOLS_DEBUG("H5T_STRING"); { char *s = NULL; char *sx = NULL; @@ -492,12 +528,12 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank, size_t size1; size_t size2; size_t sizex; - size_t size_mtype = H5Tget_size(m_type); - H5T_str_t pad = H5Tget_strpad(m_type); + size_t size_mtype = H5Tget_size(opts->m_tid); + H5T_str_t pad = H5Tget_strpad(opts->m_tid); /* if variable length string */ - if (H5Tis_variable_str(m_type)) { - H5TOOLS_DEBUG("diff_datum H5T_STRING variable"); + if (H5Tis_variable_str(opts->m_tid)) { + H5TOOLS_DEBUG("H5T_STRING variable"); /* Get pointer to first string */ s1 = *(char **)((void *)mem1); if (s1) @@ -513,7 +549,7 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank, size2 = 0; } else if (H5T_STR_NULLTERM == pad) { - H5TOOLS_DEBUG("diff_datum H5T_STRING null term"); + H5TOOLS_DEBUG("H5T_STRING null term"); /* Get pointer to first string */ s1 = (char*) mem1; if (s1) @@ -550,10 +586,10 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank, * of length of strings. * For now mimic the previous way. */ - H5TOOLS_DEBUG("diff_datum string size:%d", size1); - H5TOOLS_DEBUG("diff_datum string size:%d", size2); + H5TOOLS_DEBUG("string size:%d", size1); + H5TOOLS_DEBUG("string size:%d", size2); if (size1 != size2) { - H5TOOLS_DEBUG("diff_datum string sizes difference"); + H5TOOLS_DEBUG("string sizes difference"); nfound++; } if (size1 < size2) { @@ -572,15 +608,13 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank, /* check for NULL pointer for string */ if (s != NULL) { /* try fast compare first */ - if (HDmemcmp(s, sx, size) == 0) { - if (size1 != size2) - if (print_data(opts)) - for (u = size; u < sizex; u++) - character_compare(s + u, sx + u, idx, u, rank, dims, acc, pos, opts, obj1, obj2, ph); + if ((HDmemcmp(s, sx, size) == 0) && (size1 != size2)) { + for (u = size; u < sizex; u++) + character_compare(s + u, sx + u, elemtno, u, opts); } else for (u = 0; u < size; u++) - nfound += character_compare(s + u, sx + u, idx, u, rank, dims, acc, pos, opts, obj1, obj2, ph); + nfound += character_compare(s + u, sx + u, elemtno, u, opts); } /* end check for NULL pointer for string */ } break; @@ -590,10 +624,10 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank, *------------------------------------------------------------------------- */ case H5T_BITFIELD: - H5TOOLS_DEBUG("diff_datum H5T_BITFIELD"); + H5TOOLS_DEBUG("H5T_BITFIELD"); /* byte-by-byte comparison */ for (u = 0; u < type_size; u++) - nfound += character_compare_opt(mem1 + u, mem2 + u, idx, rank, dims, acc, pos, opts, obj1, obj2, ph); + nfound += character_compare_opt(mem1 + u, mem2 + u, elemtno, opts); break; /*------------------------------------------------------------------------- @@ -601,10 +635,10 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank, *------------------------------------------------------------------------- */ case H5T_OPAQUE: - H5TOOLS_DEBUG("diff_datum H5T_OPAQUE"); + H5TOOLS_DEBUG("H5T_OPAQUE"); /* byte-by-byte comparison */ for (u = 0; u < type_size; u++) - nfound += character_compare_opt(mem1 + u, mem2 + u, idx, rank, dims, acc, pos, opts, obj1, obj2, ph); + nfound += character_compare_opt(mem1 + u, mem2 + u, elemtno, opts); break; /*------------------------------------------------------------------------- @@ -617,7 +651,7 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank, * compared, we convert both bit patterns to their corresponding * enumeration constant and do a string comparison */ - H5TOOLS_DEBUG("diff_datum H5T_ENUM"); + H5TOOLS_DEBUG("H5T_ENUM"); { char enum_name1[1024]; char enum_name2[1024]; @@ -629,11 +663,11 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank, /* If the enum value cannot be converted to a string * it is set to an error string for later output. */ - err1 = H5Tenum_nameof(m_type, mem1, enum_name1, sizeof enum_name1); + err1 = H5Tenum_nameof(opts->m_tid, mem1, enum_name1, sizeof enum_name1); if (err1 < 0) HDsnprintf(enum_name1, sizeof(enum_name1), "**INVALID VALUE**"); - err2 = H5Tenum_nameof(m_type, mem2, enum_name2, sizeof enum_name2); + err2 = H5Tenum_nameof(opts->m_tid, mem2, enum_name2, sizeof enum_name2); if (err2 < 0) HDsnprintf(enum_name2, sizeof(enum_name2), "**INVALID VALUE**"); @@ -644,9 +678,9 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank, * don't attempt to convert them - just report errors. */ nfound += 1; + opts->print_percentage = 0; + print_pos(opts, elemtno, 0); if (print_data(opts)) { - print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); parallel_print(S_FORMAT, enum_name1, enum_name2); } } @@ -654,15 +688,15 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank, /* Both enum values were valid */ if (HDstrcmp(enum_name1, enum_name2) != 0) { nfound = 1; + opts->print_percentage = 0; + print_pos(opts, elemtno, 0); if (print_data(opts)) { - print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); parallel_print(S_FORMAT, enum_name1, enum_name2); } } else { for (u = 0; u < type_size; u++) - nfound += character_compare_opt(mem1 + u, mem2 + u, idx, rank, dims, acc, pos, opts, obj1, obj2, ph); + nfound += character_compare_opt(mem1 + u, mem2 + u, elemtno, opts); } } /* enable error reporting */ @@ -676,26 +710,32 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank, */ case H5T_ARRAY: { - hid_t memb_type = H5I_INVALID_HID; hsize_t adims[H5S_MAX_RANK]; int ndims; + diff_opt_t arr_opts; + + H5TOOLS_DEBUG("H5T_ARRAY ph=%d", opts->print_header); - H5TOOLS_DEBUG("diff_datum H5T_ARRAY"); + arr_opts = *opts; + H5TOOLS_DEBUG("Check opts: hs_nelmts:%ld to %ld rank:%d to %ld", opts->hs_nelmts, arr_opts.hs_nelmts, opts->rank, arr_opts.rank); /* get the array's base datatype for each element */ - memb_type = H5Tget_super(m_type); - size = H5Tget_size(memb_type); - ndims = H5Tget_array_ndims(m_type); - H5Tget_array_dims2(m_type, adims); + arr_opts.m_tid = H5Tget_super(opts->m_tid); + size = H5Tget_size(arr_opts.m_tid); + ndims = H5Tget_array_ndims(opts->m_tid); + H5Tget_array_dims2(opts->m_tid, adims); HDassert(ndims >= 1 && ndims <= H5S_MAX_RANK); + H5TOOLS_DEBUG("attr ph=%d", arr_opts.print_header); /* calculate the number of array elements */ - for (u = 0, nelmts = 1; u < (unsigned) ndims; u++) - nelmts *= adims[u]; - for (u = 0; u < nelmts; u++) { - nfound += diff_datum(mem1 + u * size, mem2 + u * size, memb_type, idx, - rank, dims, acc, pos, opts, obj1, obj2, container1_id, container2_id, ph, members); - } - H5Tclose(memb_type); + for (u = 0, arr_opts.hs_nelmts = 1; u < (unsigned) ndims; u++) + arr_opts.hs_nelmts *= adims[u]; + for (u = 0; u < arr_opts.hs_nelmts; u++) { + nfound += diff_datum(mem1 + u * size, mem2 + u * size, elemtno, &arr_opts, container1_id, container2_id, members); + } + opts->err_stat = opts->err_stat | arr_opts.err_stat; + opts->print_header = arr_opts.print_header; + opts->not_cmp = arr_opts.not_cmp; + H5Tclose(arr_opts.m_tid); } break; @@ -704,9 +744,9 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank, *------------------------------------------------------------------------- */ case H5T_REFERENCE: - H5TOOLS_DEBUG("diff_datum H5T_REFERENCE"); - iszero1 = all_zero(_mem1, H5Tget_size(m_type)); - iszero2 = all_zero(_mem2, H5Tget_size(m_type)); + H5TOOLS_DEBUG("H5T_REFERENCE"); + iszero1 = all_zero(_mem1, H5Tget_size(opts->m_tid)); + iszero2 = all_zero(_mem2, H5Tget_size(opts->m_tid)); if (iszero1 != iszero2) { nfound++; H5TOOLS_GOTO_DONE(opts->err_stat); @@ -714,13 +754,17 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank, else if (!iszero1 && !iszero2) { hid_t obj1_id = H5I_INVALID_HID; hid_t obj2_id = H5I_INVALID_HID; + diff_opt_t ref_opts; /*------------------------------------------------------------------------- * H5T_STD_REF * Reference *------------------------------------------------------------------------- */ - if (H5Tequal(m_type, H5T_STD_REF)) { + ref_opts = *opts; + ref_opts.obj_name[0] = NULL; + ref_opts.obj_name[1] = NULL; + if (H5Tequal(ref_opts.m_tid, H5T_STD_REF)) { /* if (type_size == H5R_STD_REF_SIZE) */ hid_t region1_id = H5I_INVALID_HID; hid_t region2_id = H5I_INVALID_HID; @@ -730,66 +774,67 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank, H5O_type_t obj2_type = -1; /* Object type */ H5R_type_t ref_type; /* Reference type */ - H5TOOLS_DEBUG("diff_datum H5T_REFERENCE - H5T_STD_REF"); + H5TOOLS_DEBUG("H5T_REFERENCE - H5T_STD_REF"); ref_type = H5Rget_type(ref1_buf); switch (ref_type) { case H5R_OBJECT1: H5TOOLS_DEBUG("ref_type is H5R_OBJECT1"); - if (H5Rget_obj_type3(ref1_buf, H5P_DEFAULT, &obj1_type) < 0) { - opts->err_stat = H5DIFF_ERR; - H5TOOLS_INFO("H5Rget_obj_type3 object 1 failed"); - } - if (H5Rget_obj_type3(ref2_buf, H5P_DEFAULT, &obj2_type) < 0) { - opts->err_stat = H5DIFF_ERR; - H5TOOLS_INFO("H5Rget_obj_type3 object 2 failed"); - } - - /* check object type */ - if (obj1_type != obj2_type) { - parallel_print("Different object types referenced: <%s> and <%s>", obj1, obj2); - opts->not_cmp = 1; - H5TOOLS_GOTO_DONE(opts->err_stat); - } - - if((obj1_id = H5Ropen_object(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - opts->err_stat = H5DIFF_ERR; - H5TOOLS_INFO("H5Ropen_object object 1 failed"); - } - if((obj2_id = H5Ropen_object(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - opts->err_stat = H5DIFF_ERR; - H5TOOLS_INFO("H5Ropen_object object 2 failed"); - } - - switch (obj1_type) { - case H5O_TYPE_DATASET: - nfound = diff_datasetid(obj1_id, obj2_id, NULL, NULL, opts); - break; - - case H5O_TYPE_GROUP: - case H5O_TYPE_NAMED_DATATYPE: - case H5O_TYPE_MAP: - case H5O_TYPE_UNKNOWN: - case H5O_TYPE_NTYPES: - default: - if (opts->m_verbose) - parallel_print("Warning: Comparison not possible of object types referenced: <%s> and <%s>\n", obj1, obj2); - opts->not_cmp = 1; - break; - } /* end switch */ - if(obj1_id >= 0) - if(H5Oclose(obj1_id) < 0) { - opts->err_stat = H5DIFF_ERR; - H5TOOLS_INFO("H5Oclose H5R_OBJECT1 failed"); + if (H5Rget_obj_type3(ref1_buf, H5P_DEFAULT, &obj1_type) >= 0) { + if (H5Rget_obj_type3(ref2_buf, H5P_DEFAULT, &obj2_type) >= 0) { + /* check object type */ + if (obj1_type == obj2_type) { + switch (obj1_type) { + case H5O_TYPE_DATASET: + if((obj1_id = H5Ropen_object(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if((obj2_id = H5Ropen_object(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + nfound = diff_datasetid(obj1_id, obj2_id, opts->obj_name[0], opts->obj_name[1], &ref_opts); + if(H5Dclose(obj2_id) < 0) { + ref_opts.err_stat = H5DIFF_ERR; + H5TOOLS_INFO("H5Dclose H5R_OBJECT1 failed"); + } + } + else { + ref_opts.err_stat = H5DIFF_ERR; + H5TOOLS_INFO("H5Ropen_object object 2 failed"); + } + if(H5Dclose(obj1_id) < 0) { + ref_opts.err_stat = H5DIFF_ERR; + H5TOOLS_INFO("H5Dclose H5R_OBJECT1 failed"); + } + } + else { + ref_opts.err_stat = H5DIFF_ERR; + H5TOOLS_INFO("H5Ropen_object object 1 failed"); + } + break; + + case H5O_TYPE_GROUP: + case H5O_TYPE_NAMED_DATATYPE: + case H5O_TYPE_MAP: + case H5O_TYPE_UNKNOWN: + case H5O_TYPE_NTYPES: + default: + if (ref_opts.mode_verbose) + parallel_print("Warning: Comparison not possible of object types referenced: <%s> and <%s>\n", opts->obj_name[0], opts->obj_name[1]); + ref_opts.not_cmp = 1; + break; + } /* end switch */ + } + else { + parallel_print("Different object types referenced: <%s> and <%s>", opts->obj_name[0], opts->obj_name[1]); + ref_opts.not_cmp = 1; + ref_opts.err_stat = H5DIFF_ERR; + } } - if(obj2_id >= 0) - if(H5Oclose(obj2_id) < 0) { - opts->err_stat = H5DIFF_ERR; - H5TOOLS_INFO("H5Oclose H5R_OBJECT1 failed"); + else { + ref_opts.err_stat = H5DIFF_ERR; + H5TOOLS_INFO("H5Rget_obj_type3 object 2 failed"); } - if(H5Rdestroy(ref2_buf) < 0) - H5TOOLS_ERROR(H5DIFF_ERR, "H5Rdestroy H5R_OBJECT1 failed"); - if(H5Rdestroy(ref1_buf) < 0) - H5TOOLS_ERROR(H5DIFF_ERR, "H5Rdestroy H5R_OBJECT1 failed"); + } + else { + ref_opts.err_stat = H5DIFF_ERR; + H5TOOLS_INFO("H5Rget_obj_type3 object 1 failed"); + } break; case H5R_DATASET_REGION1: H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION1"); @@ -797,149 +842,143 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank, if((obj2_id = H5Ropen_object(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { if((region1_id = H5Ropen_region(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { if((region2_id = H5Ropen_region(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - nfound = diff_region(obj1_id, obj2_id, region1_id, region2_id, opts); + nfound = diff_region(obj1_id, obj2_id, region1_id, region2_id, &ref_opts); if(H5Sclose(region2_id) < 0) - H5TOOLS_ERROR(H5DIFF_ERR, "H5Sclose H5R_DATASET_REGION1 failed"); + H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION1 failed"); } if(H5Sclose(region1_id) < 0) - H5TOOLS_ERROR(H5DIFF_ERR, "H5Sclose H5R_DATASET_REGION1 failed"); + H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION1 failed"); } - if(H5Oclose(obj2_id) < 0) - H5TOOLS_ERROR(H5DIFF_ERR, "H5Oclose H5R_DATASET_REGION1 failed"); + if(H5Dclose(obj2_id) < 0) + H5TOOLS_INFO("H5Oclose H5R_DATASET_REGION1 failed"); } else { - H5TOOLS_ERROR(H5DIFF_ERR, "H5Ropen_object H5R_DATASET_REGION1 failed"); + H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION1 failed"); } - if(H5Oclose(obj1_id) < 0) - H5TOOLS_ERROR(H5DIFF_ERR, "H5Oclose H5R_DATASET_REGION1 failed"); + if(H5Dclose(obj1_id) < 0) + H5TOOLS_INFO("H5Oclose H5R_DATASET_REGION1 failed"); } else { - H5TOOLS_ERROR(H5DIFF_ERR, "H5Ropen_object H5R_DATASET_REGION1 failed"); + H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION1 failed"); } - if(H5Rdestroy(ref2_buf) < 0) - H5TOOLS_ERROR(H5DIFF_ERR, "H5Rdestroy H5R_DATASET_REGION1 failed"); - if(H5Rdestroy(ref1_buf) < 0) - H5TOOLS_ERROR(H5DIFF_ERR, "H5Rdestroy H5R_DATASET_REGION1 failed"); break; case H5R_OBJECT2: H5TOOLS_DEBUG("ref_type is H5R_OBJECT2"); - if (H5Rget_obj_type3(ref1_buf, H5P_DEFAULT, &obj1_type) < 0) { - opts->err_stat = H5DIFF_ERR; - H5TOOLS_INFO("H5Rget_obj_type3 object 1 failed"); - } - if (H5Rget_obj_type3(ref2_buf, H5P_DEFAULT, &obj2_type) < 0) { - opts->err_stat = H5DIFF_ERR; - H5TOOLS_INFO("H5Rget_obj_type3 object 2 failed"); - } - - /* check object type */ - if (obj1_type != obj2_type) { - parallel_print("Different object types referenced: <%s> and <%s>", obj1, obj2); - opts->not_cmp = 1; - H5TOOLS_GOTO_DONE(opts->err_stat); - } - - if((obj1_id = H5Ropen_object(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - opts->err_stat = H5DIFF_ERR; - H5TOOLS_INFO("H5Ropen_object object 1 failed"); - } - if((obj2_id = H5Ropen_object(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - opts->err_stat = H5DIFF_ERR; - H5TOOLS_INFO("H5Ropen_object object 2 failed"); - } - - switch (obj1_type) { - case H5O_TYPE_DATASET: - H5TOOLS_DEBUG("ref_type is H5R_OBJECT2 : DATASET"); - nfound = diff_datasetid(obj1_id, obj2_id, NULL, NULL, opts); - break; - - case H5O_TYPE_GROUP: - H5TOOLS_DEBUG("ref_type is H5R_OBJECT2 : GROUP"); - if (opts->m_verbose) - parallel_print("Warning: Comparison not possible of group object types referenced: <%s> and <%s>\n", obj1, obj2); - opts->not_cmp = 1; - break; - - case H5O_TYPE_NAMED_DATATYPE: - H5TOOLS_DEBUG("ref_type is H5R_OBJECT2 : NAMED"); - if (opts->m_verbose) - parallel_print("Warning: Comparison not possible of named datatypes object types referenced: <%s> and <%s>\n", obj1, obj2); - opts->not_cmp = 1; - break; - - case H5O_TYPE_MAP: - case H5O_TYPE_UNKNOWN: - case H5O_TYPE_NTYPES: - default: - if (opts->m_verbose) - parallel_print("Warning: Comparison not possible of object types referenced: <%s> and <%s>\n", obj1, obj2); - opts->not_cmp = 1; - break; - } /* end switch */ - if(obj1_id >= 0) - if(H5Oclose(obj1_id) < 0) { - opts->err_stat = H5DIFF_ERR; - H5TOOLS_INFO("H5Oclose H5R_OBJECT2 failed"); + if (H5Rget_obj_type3(ref1_buf, H5P_DEFAULT, &obj1_type) >= 0) { + if (H5Rget_obj_type3(ref2_buf, H5P_DEFAULT, &obj2_type) >= 0) { + /* check object type */ + if (obj1_type == obj2_type) { + if((obj1_id = H5Ropen_object(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if((obj2_id = H5Ropen_object(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + switch (obj1_type) { + case H5O_TYPE_DATASET: + H5TOOLS_DEBUG("ref_type is H5R_OBJECT2 : DATASET"); + nfound = diff_datasetid(obj1_id, obj2_id, opts->obj_name[0], opts->obj_name[1], &ref_opts); + break; + + case H5O_TYPE_GROUP: + H5TOOLS_DEBUG("ref_type is H5R_OBJECT2 : GROUP"); + if (ref_opts.mode_verbose) + parallel_print("Warning: Comparison not possible of group object types referenced: <%s> and <%s>\n", opts->obj_name[0], opts->obj_name[1]); + ref_opts.not_cmp = 1; + break; + + case H5O_TYPE_NAMED_DATATYPE: + H5TOOLS_DEBUG("ref_type is H5R_OBJECT2 : NAMED"); + if (ref_opts.mode_verbose) + parallel_print("Warning: Comparison not possible of named datatypes object types referenced: <%s> and <%s>\n", opts->obj_name[0], opts->obj_name[1]); + ref_opts.not_cmp = 1; + break; + + case H5O_TYPE_MAP: + case H5O_TYPE_UNKNOWN: + case H5O_TYPE_NTYPES: + default: + if (ref_opts.mode_verbose) + parallel_print("Warning: Comparison not possible of object types referenced: <%s> and <%s>\n", opts->obj_name[0], opts->obj_name[1]); + ref_opts.not_cmp = 1; + break; + } /* end switch */ + if(H5Oclose(obj2_id) < 0) { + ref_opts.err_stat = H5DIFF_ERR; + H5TOOLS_INFO("H5Oclose H5R_OBJECT2 failed"); + } + } + else { + ref_opts.err_stat = H5DIFF_ERR; + H5TOOLS_INFO("H5Ropen_object object 2 failed"); + } + if(H5Oclose(obj1_id) < 0) { + ref_opts.err_stat = H5DIFF_ERR; + H5TOOLS_INFO("H5Oclose H5R_OBJECT2 failed"); + } + } + else { + ref_opts.err_stat = H5DIFF_ERR; + H5TOOLS_INFO("H5Ropen_object object 1 failed"); + } + } + else { + parallel_print("Different object types referenced: <%s> and <%s>", opts->obj_name[0], opts->obj_name[1]); + ref_opts.not_cmp = 1; + ref_opts.err_stat = H5DIFF_ERR; + } } - if(obj2_id >= 0) - if(H5Oclose(obj2_id) < 0) { - opts->err_stat = H5DIFF_ERR; - H5TOOLS_INFO("H5Oclose H5R_OBJECT2 failed"); + else { + ref_opts.err_stat = H5DIFF_ERR; + H5TOOLS_INFO("H5Rget_obj_type3 object 2 failed"); } - if(H5Rdestroy(ref2_buf) < 0) - H5TOOLS_ERROR(H5DIFF_ERR, "H5Rdestroy H5R_OBJECT2 failed"); - if(H5Rdestroy(ref1_buf) < 0) - H5TOOLS_ERROR(H5DIFF_ERR, "H5Rdestroy H5R_OBJECT2 failed"); + } + else { + ref_opts.err_stat = H5DIFF_ERR; + H5TOOLS_INFO("H5Rget_obj_type3 object 1 failed"); + } break; case H5R_DATASET_REGION2: H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION2"); /* if (obj_id < 0) - could mean that no reference was written do not throw failure */ - obj1_id = H5Ropen_object(ref1_buf, H5P_DEFAULT, H5P_DEFAULT); - obj2_id = H5Ropen_object(ref2_buf, H5P_DEFAULT, H5P_DEFAULT); - if((obj1_id < 0) || (obj2_id < 0)) { - H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION2 failed"); + if((obj1_id = H5Ropen_object(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION2 object 1 failed"); } else { - H5TOOLS_DEBUG("open_region - H5R_DATASET_REGION2"); - if((region1_id = H5Ropen_region(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - if (h5tools_is_zero(ref1_buf, H5Tget_size(H5T_STD_REF))) { - H5TOOLS_DEBUG("NULL H5R_DATASET_REGION2"); - } - else { - if((region2_id = H5Ropen_region(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - if (h5tools_is_zero(ref2_buf, H5Tget_size(H5T_STD_REF))) { - H5TOOLS_DEBUG("NULL H5R_DATASET_REGION2"); - } - else { - nfound = diff_region(obj1_id, obj2_id, region1_id, region2_id, opts); - } - if(H5Sclose(region2_id) < 0) - H5TOOLS_ERROR(H5DIFF_ERR, "H5Sclose H5R_DATASET_REGION2 failed"); + if((obj2_id = H5Ropen_object(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + H5TOOLS_DEBUG("open_region - H5R_DATASET_REGION2"); + if((region1_id = H5Ropen_region(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if (h5tools_is_zero(ref1_buf, H5Tget_size(H5T_STD_REF))) { + H5TOOLS_DEBUG("NULL H5R_DATASET_REGION2"); } - else - H5TOOLS_ERROR(H5DIFF_ERR, "H5Ropen_region H5R_DATASET_REGION2 failed"); - } /* end else to if (h5tools_is_zero(... */ - if(H5Sclose(region1_id) < 0) - H5TOOLS_ERROR(H5DIFF_ERR, "H5Sclose H5R_DATASET_REGION2 failed"); - } - else - H5TOOLS_ERROR(H5DIFF_ERR, "H5Ropen_region H5R_DATASET_REGION2 failed"); - if (obj1_id >= 0) - if(H5Dclose(obj1_id) < 0) { - opts->err_stat = H5DIFF_ERR; - H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION2 failed"); + else { + if((region2_id = H5Ropen_region(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if (h5tools_is_zero(ref2_buf, H5Tget_size(H5T_STD_REF))) { + H5TOOLS_DEBUG("NULL H5R_DATASET_REGION2"); + } + else { + nfound = diff_region(obj1_id, obj2_id, region1_id, region2_id, &ref_opts); + } + if(H5Sclose(region2_id) < 0) + H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION2 failed"); + } + else + H5TOOLS_INFO("H5Ropen_region H5R_DATASET_REGION2 failed"); + } /* end else to if (h5tools_is_zero(... */ + if(H5Sclose(region1_id) < 0) + H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION2 failed"); } - if (obj2_id >= 0) + else + H5TOOLS_ERROR(H5DIFF_ERR, "H5Ropen_region H5R_DATASET_REGION2 failed"); if(H5Dclose(obj2_id) < 0) { - opts->err_stat = H5DIFF_ERR; + ref_opts.err_stat = H5DIFF_ERR; H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION2 failed"); } - if(H5Rdestroy(ref1_buf) < 0) - H5TOOLS_ERROR(H5DIFF_ERR, "H5Rdestroy H5R_DATASET_REGION2 failed"); - if(H5Rdestroy(ref2_buf) < 0) - H5TOOLS_ERROR(H5DIFF_ERR, "H5Rdestroy H5R_DATASET_REGION2 failed"); + } + else { + H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION2 object 2 failed"); + } + if(H5Dclose(obj1_id) < 0) { + ref_opts.err_stat = H5DIFF_ERR; + H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION2 failed"); + } } break; case H5R_ATTR: @@ -948,44 +987,42 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank, char name2[ATTR_NAME_MAX]; H5TOOLS_DEBUG("ref_type is H5R_ATTR"); - if((obj1_id = H5Ropen_attr(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - parallel_print("Warning: Cannot open referenced attribute: attribute 1\n"); - H5TOOLS_INFO("H5Ropen_attr object 1 failed"); - } - if((obj2_id = H5Ropen_attr(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - parallel_print("Warning: Cannot open referenced attribute: attribute 2\n"); - H5TOOLS_INFO("H5Ropen_attr object 2 failed"); - } - - if((obj1_id < 0) || (obj2_id < 0)) { - H5TOOLS_INFO("H5Ropen_attr H5R_ATTR failed"); - } - else { - /* get name */ - if(H5Aget_name(obj1_id, (size_t)ATTR_NAME_MAX, name1) < 0) - H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_name first attribute failed"); - /* get name */ - if(H5Aget_name(obj2_id, (size_t)ATTR_NAME_MAX, name2) < 0) - H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_name second attribute failed"); - - H5TOOLS_DEBUG("H5R_ATTR diff_attr_data - name1=%s, name2=%s", name1, name2); - nfound = diff_attr_data(obj1_id, obj2_id, name1, name2, NULL, NULL, opts); - } + if((obj1_id = H5Ropen_attr(ref1_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if((obj2_id = H5Ropen_attr(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + /* get name */ + if(H5Aget_name(obj1_id, (size_t)ATTR_NAME_MAX, name1) >= 0) { + /* get name */ + if(H5Aget_name(obj2_id, (size_t)ATTR_NAME_MAX, name2) >= 0) { + H5TOOLS_DEBUG("H5R_ATTR diff_attr_data - name1=%s, name2=%s", name1, name2); + nfound = diff_attr_data(obj1_id, obj2_id, name1, name2, opts->obj_name[0], opts->obj_name[1], &ref_opts); + } + else { + ref_opts.err_stat = H5DIFF_ERR; + H5TOOLS_INFO("H5Aget_name second attribute failed"); + } + } + else { + ref_opts.err_stat = H5DIFF_ERR; + H5TOOLS_INFO("H5Aget_name first attribute failed"); + } - if(obj1_id >= 0) - if(H5Aclose(obj1_id) < 0) { - opts->err_stat = H5DIFF_ERR; - H5TOOLS_INFO("H5Aclose H5R_ATTR failed"); + if(H5Aclose(obj2_id) < 0) { + ref_opts.err_stat = H5DIFF_ERR; + H5TOOLS_INFO("H5Aclose H5R_ATTR failed"); + } + } + else { + parallel_print("Warning: Cannot open referenced attribute2\n"); + H5TOOLS_INFO("H5Ropen_attr object 2 failed"); } - if(obj2_id >= 0) - if(H5Aclose(obj2_id) < 0) { - opts->err_stat = H5DIFF_ERR; + if(H5Aclose(obj1_id) < 0) { H5TOOLS_INFO("H5Aclose H5R_ATTR failed"); } - if(H5Rdestroy(ref2_buf) < 0) - H5TOOLS_ERROR(H5DIFF_ERR, "H5Rdestroy H5R_ATTR failed"); - if(H5Rdestroy(ref1_buf) < 0) - H5TOOLS_ERROR(H5DIFF_ERR, "H5Rdestroy H5R_ATTR failed"); + } + else { + parallel_print("Warning: Cannot open referenced attribute1\n"); + H5TOOLS_INFO("H5Ropen_attr object 1 failed"); + } } break; case H5R_BADTYPE: @@ -993,43 +1030,20 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank, default: break; } /* end switch */ - H5TOOLS_DEBUG("diff_datum H5T_REFERENCE - H5T_STD_REF complete nfound:%d - errstat:%d", nfound, opts->err_stat); + if(H5Rdestroy(ref2_buf) < 0) + H5TOOLS_INFO("H5Rdestroy H5R_OBJECT1 failed"); + if(H5Rdestroy(ref1_buf) < 0) + H5TOOLS_INFO("H5Rdestroy H5R_OBJECT1 failed"); + H5TOOLS_DEBUG("H5T_REFERENCE - H5T_STD_REF complete nfound:%d - errstat:%d", nfound, ref_opts.err_stat); } /*------------------------------------------------------------------------- * H5T_STD_REF_DSETREG * Dataset region reference *------------------------------------------------------------------------- */ - else if (H5Tequal(m_type, H5T_STD_REF_DSETREG)) { + else if (H5Tequal(ref_opts.m_tid, H5T_STD_REF_DSETREG)) { /* if (type_size == H5R_DSET_REG_REF_BUF_SIZE) */ - hid_t region1_id = H5I_INVALID_HID; - hid_t region2_id = H5I_INVALID_HID; - - H5TOOLS_INFO("H5T_STD_REF_DSETREG reference type"); - - if ((obj1_id = H5Rdereference2(container1_id, H5P_DEFAULT, H5R_DATASET_REGION, _mem1)) < 0) { - opts->err_stat = H5DIFF_ERR; - H5TOOLS_INFO("H5Rdereference2 object 1 failed"); - } - if ((obj2_id = H5Rdereference2(container2_id, H5P_DEFAULT, H5R_DATASET_REGION, _mem2)) < 0) { - opts->err_stat = H5DIFF_ERR; - H5TOOLS_INFO("H5Rdereference2 object 2 failed"); - } - if ((region1_id = H5Rget_region(container1_id, H5R_DATASET_REGION, _mem1)) < 0) { - opts->err_stat = H5DIFF_ERR; - H5TOOLS_INFO("H5Rget_region object 1 failed"); - } - if ((region2_id = H5Rget_region(container2_id, H5R_DATASET_REGION, _mem2)) < 0) { - opts->err_stat = H5DIFF_ERR; - H5TOOLS_INFO("H5Rget_region object 2 failed"); - } - - nfound = diff_region(obj1_id, obj2_id, region1_id, region2_id, opts); - - H5Oclose(obj1_id); - H5Oclose(obj2_id); - H5Sclose(region1_id); - H5Sclose(region2_id); + H5TOOLS_DEBUG("H5T_STD_REF_DSETREG"); }/*dataset reference*/ /*------------------------------------------------------------------------- @@ -1037,52 +1051,15 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank, * Object references. get the type and OID of the referenced object *------------------------------------------------------------------------- */ - else if (H5Tequal(m_type, H5T_STD_REF_OBJ)) { + else if (H5Tequal(ref_opts.m_tid, H5T_STD_REF_OBJ)) { /* if (type_size == H5R_OBJ_REF_BUF_SIZE) */ - H5O_type_t obj1_type; - H5O_type_t obj2_type; - - H5TOOLS_INFO("H5T_STD_REF_OBJ reference type"); - - if (H5Rget_obj_type2(container1_id, H5R_OBJECT, _mem1, &obj1_type) < 0) { - opts->err_stat = H5DIFF_ERR; - H5TOOLS_INFO("H5Rget_obj_type2 object 1 failed"); - } - if (H5Rget_obj_type2(container2_id, H5R_OBJECT, _mem2, &obj2_type) < 0) { - opts->err_stat = H5DIFF_ERR; - H5TOOLS_INFO("H5Rget_obj_type2 object 2 failed"); - } - - /* check object type */ - if (obj1_type != obj2_type) { - parallel_print("Different object types referenced: <%s> and <%s>", obj1, obj2); - opts->not_cmp = 1; - H5TOOLS_GOTO_DONE(opts->err_stat); - } - - if ((obj1_id = H5Rdereference2(container1_id, H5P_DEFAULT, H5R_OBJECT, _mem1)) < 0) { - opts->err_stat = H5DIFF_ERR; - H5TOOLS_INFO("H5Rdereference2 object 1 failed"); - } - if ((obj2_id = H5Rdereference2(container2_id, H5P_DEFAULT, H5R_OBJECT, _mem2)) < 0) { - opts->err_stat = H5DIFF_ERR; - H5TOOLS_INFO("H5Rdereference2 object 2 failed"); - } - - /* compare */ - if (obj1_type == H5O_TYPE_DATASET) - nfound = diff_datasetid(obj1_id, obj2_id, NULL, NULL, opts); - else { - if (opts->m_verbose) - parallel_print("Warning: Comparison not possible of object types referenced: <%s> and <%s>\n", obj1, obj2); - opts->not_cmp = 1; - } - - H5Oclose(obj1_id); - H5Oclose(obj2_id); + H5TOOLS_DEBUG("H5T_STD_REF_OBJ"); }/*object reference*/ + opts->print_header = ref_opts.print_header; + opts->not_cmp = ref_opts.not_cmp; + opts->err_stat = ref_opts.err_stat | ret_value; }/*is zero*/ - H5TOOLS_DEBUG("diff_datum H5T_REFERENCE complete"); + H5TOOLS_DEBUG("H5T_REFERENCE complete"); break; /*------------------------------------------------------------------------- @@ -1091,21 +1068,26 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank, */ case H5T_VLEN: { - hid_t memb_type = H5I_INVALID_HID; + diff_opt_t vl_opts; - H5TOOLS_DEBUG("diff_datum H5T_VLEN"); + H5TOOLS_DEBUG("H5T_VLEN"); + + vl_opts = *opts; /* get the VL sequences's base datatype for each element */ - memb_type = H5Tget_super(m_type); - size = H5Tget_size(memb_type); + vl_opts.m_tid = H5Tget_super(opts->m_tid); + size = H5Tget_size(vl_opts.m_tid); /* get the number of sequence elements */ - nelmts = ((hvl_t *)((void *)mem1))->len; + vl_opts.hs_nelmts = ((hvl_t *)((void *)mem1))->len; - for (j = 0; j < nelmts; j++) - nfound += diff_datum(((char *) (((hvl_t *)((void *)mem1))->p)) + j * size, ((char *) (((hvl_t *)((void *)mem2))->p)) + j * size, memb_type, idx, /* Extra (void *) cast to quiet "cast to create alignment" warning - 2019/07/05, QAK */ - rank, dims, acc, pos, opts, obj1, obj2, container1_id, container2_id, ph, members); + for (j = 0; j < vl_opts.hs_nelmts; j++) + nfound += diff_datum(((char *) (((hvl_t *)((void *)mem1))->p)) + j * size, ((char *) (((hvl_t *)((void *)mem2))->p)) + j * size, elemtno, /* Extra (void *) cast to quiet "cast to create alignment" warning - 2019/07/05, QAK */ + &vl_opts, container1_id, container2_id, members); + opts->print_header = vl_opts.print_header; + opts->not_cmp = vl_opts.not_cmp; + opts->err_stat = opts->err_stat | vl_opts.err_stat; - H5Tclose(memb_type); + H5Tclose(vl_opts.m_tid); } break; @@ -1114,81 +1096,16 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank, *------------------------------------------------------------------------- */ case H5T_INTEGER: - H5TOOLS_DEBUG("diff_datum H5T_INTEGER"); - type_sign = H5Tget_sign(m_type); + H5TOOLS_DEBUG("H5T_INTEGER"); + type_sign = H5Tget_sign(opts->m_tid); /*------------------------------------------------------------------------- * H5T_NATIVE_SCHAR *------------------------------------------------------------------------- */ if (type_size == 1 && type_sign != H5T_SGN_NONE) { - char temp1_char; - char temp2_char; - if(type_size != sizeof(char)) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not char size"); - HDmemcpy(&temp1_char, mem1, sizeof(char)); - HDmemcpy(&temp2_char, mem2, sizeof(char)); - /* -d and !-p */ - if (opts->d && !opts->p) { - if (ABS(temp1_char-temp2_char) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT, temp1_char, temp2_char, ABS(temp1_char - temp2_char)); - } - nfound++; - } - } - /* !-d and -p */ - else if (!opts->d && opts->p) { - PER(temp1_char, temp2_char); - - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P_NOTCOMP, temp1_char, temp2_char, ABS(temp1_char - temp2_char)); - } - nfound++; - } - else if (per > opts->percent) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P, temp1_char, temp2_char, ABS(temp1_char - temp2_char), per); - } - nfound++; - } - } - /* -d and -p */ - else if (opts->d && opts->p) { - PER(temp1_char, temp2_char); - - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P_NOTCOMP, temp1_char, temp2_char, ABS(temp1_char - temp2_char)); - } - nfound++; - } - else if (per > opts->percent && ABS(temp1_char - temp2_char) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P, temp1_char, temp2_char, ABS(temp1_char - temp2_char), per); - } - nfound++; - } - } - else if (temp1_char != temp2_char) { - if (print_data(opts)) { - print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT, temp1_char, temp2_char, ABS(temp1_char - temp2_char)); - } - nfound++; - } + nfound += diff_schar_element(mem1, mem2, elemtno, opts); } /*H5T_NATIVE_SCHAR*/ /*------------------------------------------------------------------------- @@ -1196,75 +1113,9 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank, *------------------------------------------------------------------------- */ else if (type_size == 1 && type_sign == H5T_SGN_NONE) { - unsigned char temp1_uchar; - unsigned char temp2_uchar; - if(type_size != sizeof(unsigned char)) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not unsigned char size"); - - HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char)); - HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char)); - /* -d and !-p */ - if (opts->d && !opts->p) { - if (PDIFF(temp1_uchar, temp2_uchar) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar)); - } - nfound++; - } - } - /* !-d and -p */ - else if (!opts->d && opts->p) { - PER_UNSIGN(signed char, temp1_uchar, temp2_uchar); - - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P_NOTCOMP, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar)); - } - nfound++; - } - else if (per > opts->percent) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar), per); - } - nfound++; - } - } - /* -d and -p */ - else if (opts->d && opts->p) { - PER_UNSIGN(signed char, temp1_uchar, temp2_uchar); - - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P_NOTCOMP, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar)); - } - nfound++; - } - else if (per > opts->percent && PDIFF(temp1_uchar, temp2_uchar) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar), per); - } - nfound++; - } - } - else if (temp1_uchar != temp2_uchar) { - if (print_data(opts)) { - print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar)); - } - nfound++; - } + nfound += diff_uchar_element(mem1, mem2, elemtno, opts); } /*H5T_NATIVE_UCHAR*/ /*------------------------------------------------------------------------- @@ -1272,75 +1123,9 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank, *------------------------------------------------------------------------- */ else if (type_size == 2 && type_sign != H5T_SGN_NONE) { - short temp1_short; - short temp2_short; - if(type_size != sizeof(short)) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not short size"); - - HDmemcpy(&temp1_short, mem1, sizeof(short)); - HDmemcpy(&temp2_short, mem2, sizeof(short)); - /* -d and !-p */ - if (opts->d && !opts->p) { - if (ABS(temp1_short - temp2_short) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT, temp1_short, temp2_short, ABS(temp1_short - temp2_short)); - } - nfound++; - } - } - /* !-d and -p */ - else if (!opts->d && opts->p) { - PER(temp1_short, temp2_short); - - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P_NOTCOMP, temp1_short, temp2_short, ABS(temp1_short - temp2_short)); - } - nfound++; - } - else if (per > opts->percent) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P, temp1_short, temp2_short, ABS(temp1_short - temp2_short), per); - } - nfound++; - } - } - /* -d and -p */ - else if (opts->d && opts->p) { - PER(temp1_short, temp2_short); - - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P_NOTCOMP, temp1_short, temp2_short, ABS(temp1_short - temp2_short)); - } - nfound++; - } - else if (per > opts->percent && ABS(temp1_short - temp2_short) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P, temp1_short, temp2_short, ABS(temp1_short - temp2_short), per); - } - nfound++; - } - } - else if (temp1_short != temp2_short) { - if (print_data(opts)) { - print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT, temp1_short, temp2_short, ABS(temp1_short - temp2_short)); - } - nfound++; - } + nfound += diff_short_element(mem1, mem2, elemtno, opts); } /*H5T_NATIVE_SHORT*/ /*------------------------------------------------------------------------- @@ -1348,227 +1133,29 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank, *------------------------------------------------------------------------- */ else if (type_size == 2 && type_sign == H5T_SGN_NONE) { - unsigned short temp1_ushort; - unsigned short temp2_ushort; - if(type_size != sizeof(unsigned short)) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not unsigned short size"); + nfound += diff_ushort_element(mem1, mem2, elemtno, opts); + } /*H5T_NATIVE_USHORT*/ - HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short)); - HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short)); - /* -d and !-p */ - if (opts->d && !opts->p) { - if (PDIFF(temp1_ushort, temp2_ushort) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort)); - } - nfound++; - } - } - /* !-d and -p */ - else if (!opts->d && opts->p) { - PER_UNSIGN(signed short, temp1_ushort, temp2_ushort); - - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P_NOTCOMP, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort)); - } - nfound++; - } - else if (per > opts->percent) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort), per); - } - nfound++; - } - } - /* -d and -p */ - else if (opts->d && opts->p) { - PER_UNSIGN(signed short, temp1_ushort, temp2_ushort); - - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P_NOTCOMP, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort)); - } - nfound++; - } - else if (per > opts->percent && PDIFF(temp1_ushort, temp2_ushort) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort), per); - } - nfound++; - } - } - else if (temp1_ushort != temp2_ushort) { - if (print_data(opts)) { - print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort)); - } - nfound++; - } - } /*H5T_NATIVE_USHORT*/ - - /*------------------------------------------------------------------------- - * H5T_NATIVE_INT - *------------------------------------------------------------------------- - */ - else if (type_size == 4 && type_sign != H5T_SGN_NONE) { - int temp1_int; - int temp2_int; - - if(type_size != sizeof(int)) - H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not int size"); - - HDmemcpy(&temp1_int, mem1, sizeof(int)); - HDmemcpy(&temp2_int, mem2, sizeof(int)); - /* -d and !-p */ - if (opts->d && !opts->p) { - if (ABS(temp1_int-temp2_int) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT, temp1_int, temp2_int, ABS(temp1_int - temp2_int)); - } - nfound++; - } - } - /* !-d and -p */ - else if (!opts->d && opts->p) { - PER(temp1_int, temp2_int); - - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P_NOTCOMP, temp1_int, temp2_int, ABS(temp1_int - temp2_int)); - } - nfound++; - } - else if (per > opts->percent) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P, temp1_int, temp2_int, ABS(temp1_int - temp2_int), per); - } - nfound++; - } - } - /* -d and -p */ - else if (opts->d && opts->p) { - PER(temp1_int, temp2_int); - - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P_NOTCOMP, temp1_int, temp2_int, ABS(temp1_int - temp2_int)); - } - nfound++; - } - else if (per > opts->percent && ABS(temp1_int - temp2_int) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P, temp1_int, temp2_int, ABS(temp1_int - temp2_int), per); - } - nfound++; - } - } - else if (temp1_int != temp2_int) { - if (print_data(opts)) { - print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT, temp1_int, temp2_int, ABS(temp1_int - temp2_int)); - } - nfound++; - } - } /*H5T_NATIVE_INT*/ + /*------------------------------------------------------------------------- + * H5T_NATIVE_INT + *------------------------------------------------------------------------- + */ + else if (type_size == 4 && type_sign != H5T_SGN_NONE) { + if(type_size != sizeof(int)) + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not int size"); + nfound += diff_int_element(mem1, mem2, elemtno, opts); + } /*H5T_NATIVE_INT*/ /*------------------------------------------------------------------------- * H5T_NATIVE_UINT *------------------------------------------------------------------------- */ else if (type_size == 4 && type_sign == H5T_SGN_NONE) { - unsigned int temp1_uint; - unsigned int temp2_uint; - if(type_size != sizeof(unsigned int)) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not unsigned int size"); - - HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int)); - HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int)); - /* -d and !-p */ - if (opts->d && !opts->p) { - if (PDIFF(temp1_uint, temp2_uint) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(UI_FORMAT, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint)); - } - nfound++; - } - } - /* !-d and -p */ - else if (!opts->d && opts->p) { - PER_UNSIGN(signed int, temp1_uint, temp2_uint); - - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(UI_FORMAT_P_NOTCOMP, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint)); - } - nfound++; - } - else if (per > opts->percent) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(UI_FORMAT_P, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint), per); - } - nfound++; - } - } - /* -d and -p */ - else if (opts->d && opts->p) { - PER_UNSIGN(signed int, temp1_uint, temp2_uint); - - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(UI_FORMAT_P_NOTCOMP, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint)); - } - nfound++; - } - else if (per > opts->percent && PDIFF(temp1_uint,temp2_uint) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(UI_FORMAT_P, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint), per); - } - nfound++; - } - } - else if (temp1_uint != temp2_uint) { - if (print_data(opts)) { - print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(UI_FORMAT, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint)); - } - nfound++; - } + nfound += diff_uint_element(mem1, mem2, elemtno, opts); } /*H5T_NATIVE_UINT*/ /*------------------------------------------------------------------------- @@ -1576,75 +1163,9 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank, *------------------------------------------------------------------------- */ else if (type_size == 8 && type_sign != H5T_SGN_NONE) { - long temp1_long; - long temp2_long; - if(type_size != sizeof(long)) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not long size"); - - HDmemcpy(&temp1_long, mem1, sizeof(long)); - HDmemcpy(&temp2_long, mem2, sizeof(long)); - /* -d and !-p */ - if (opts->d && !opts->p) { - if (ABS(temp1_long-temp2_long) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(LI_FORMAT, temp1_long, temp2_long, ABS(temp1_long - temp2_long)); - } - nfound++; - } - } - /* !-d and -p */ - else if (!opts->d && opts->p) { - PER(temp1_long, temp2_long); - - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(LI_FORMAT_P_NOTCOMP, temp1_long, temp2_long, ABS(temp1_long - temp2_long)); - } - nfound++; - } - else if (per > opts->percent) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(LI_FORMAT_P, temp1_long, temp2_long, ABS(temp1_long - temp2_long), per); - } - nfound++; - } - } - /* -d and -p */ - else if (opts->d && opts->p) { - PER(temp1_long, temp2_long); - - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(LI_FORMAT_P_NOTCOMP, temp1_long, temp2_long, ABS(temp1_long - temp2_long)); - } - nfound++; - } - else if (per > opts->percent && ABS(temp1_long-temp2_long) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(LI_FORMAT_P, temp1_long, temp2_long, ABS(temp1_long - temp2_long), per); - } - nfound++; - } - } - else if (temp1_long != temp2_long) { - if (print_data(opts)) { - print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(LI_FORMAT, temp1_long, temp2_long, ABS(temp1_long - temp2_long)); - } - nfound++; - } + nfound += diff_long_element(mem1, mem2, elemtno, opts); } /*H5T_NATIVE_LONG*/ /*------------------------------------------------------------------------- @@ -1652,76 +1173,30 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank, *------------------------------------------------------------------------- */ else if (type_size == 8 && type_sign == H5T_SGN_NONE) { - unsigned long temp1_ulong; - unsigned long temp2_ulong; - if(type_size != sizeof(unsigned long)) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not unsigned long size"); + nfound += diff_ulong_element(mem1, mem2, elemtno, opts); + } /*H5T_NATIVE_ULONG*/ - HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long)); - HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long)); - /* -d and !-p */ - if (opts->d && !opts->p) { - if (PDIFF(temp1_ulong, temp2_ulong) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(ULI_FORMAT, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong)); - } - nfound++; - } - } - /* !-d and -p */ - else if (!opts->d && opts->p) { - PER_UNSIGN(signed long, temp1_ulong, temp2_ulong); - - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(ULI_FORMAT_P_NOTCOMP, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong)); - } - nfound++; - } - else if (per > opts->percent) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(ULI_FORMAT_P, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong), per); - } - nfound++; - } - } - /* -d and -p */ - else if (opts->d && opts->p) { - PER_UNSIGN(signed long, temp1_ulong, temp2_ulong); + /*------------------------------------------------------------------------- + * H5T_NATIVE_LLONG + *------------------------------------------------------------------------- + */ + else if (type_size == 16 && type_sign != H5T_SGN_NONE) { + if(type_size != sizeof(long long)) + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not long long size"); + nfound += diff_llong_element(mem1, mem2, elemtno, opts); + } /*H5T_NATIVE_LLONG*/ - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(ULI_FORMAT_P_NOTCOMP, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong)); - } - nfound++; - } - else if (per > opts->percent && PDIFF(temp1_ulong,temp2_ulong) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(ULI_FORMAT_P, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong), per); - } - nfound++; - } - } - else if (temp1_ulong != temp2_ulong) { - if (print_data(opts)) { - print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(ULI_FORMAT, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong)); - } - nfound++; - } - } /*H5T_NATIVE_ULONG*/ + /*------------------------------------------------------------------------- + * H5T_NATIVE_ULLONG + *------------------------------------------------------------------------- + */ + else if (type_size == 16 && type_sign == H5T_SGN_NONE) { + if(type_size != sizeof(unsigned long long)) + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not unsigned long long size"); + nfound += diff_ullong_element(mem1, mem2, elemtno, opts); + } /*H5T_NATIVE_ULLONG*/ break; /* H5T_INTEGER class */ /*------------------------------------------------------------------------- @@ -1733,319 +1208,21 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank, * H5T_NATIVE_FLOAT *------------------------------------------------------------------------- */ - H5TOOLS_DEBUG("diff_datum H5T_FLOAT"); + H5TOOLS_DEBUG("H5T_FLOAT"); if (type_size == 4) { - float temp1_float; - float temp2_float; - hbool_t isnan1 = FALSE; - hbool_t isnan2 = FALSE; - if(type_size != sizeof(float)) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not float size"); - - HDmemcpy(&temp1_float, mem1, sizeof(float)); - HDmemcpy(&temp2_float, mem2, sizeof(float)); - - /* logic for detecting NaNs is different with opts -d, -p and no opts */ - - /*------------------------------------------------------------------------- - * -d and !-p - *------------------------------------------------------------------------- - */ - if (opts->d && !opts->p) { - /*------------------------------------------------------------------------- - * detect NaNs - *------------------------------------------------------------------------- - */ - if (opts->do_nans) { - isnan1 = HDisnan(temp1_float); - isnan2 = HDisnan(temp2_float); - } - - /* both not NaN, do the comparison */ - if (!isnan1 && !isnan2) { - if (ABS(temp1_float-temp2_float) > (float) opts->delta) { - if (print_data(opts)) { - print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); - } - nfound++; - } - } - /* only one is NaN, assume difference */ - else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { - if (print_data(opts)) { - print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); - } - nfound++; - } - } - /*------------------------------------------------------------------------- - * !-d and -p - *------------------------------------------------------------------------- - */ - else if (!opts->d && opts->p) { - /*------------------------------------------------------------------------- - * detect NaNs - *------------------------------------------------------------------------- - */ - if (opts->do_nans) { - isnan1 = HDisnan(temp1_float); - isnan2 = HDisnan(temp2_float); - } - - /* both not NaN, do the comparison */ - if (!isnan1 && !isnan2) { - PER(temp1_float, temp2_float); - - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT_P_NOTCOMP, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); - } - nfound++; - } - else if (per > opts->percent && (double) ABS(temp1_float - temp2_float) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT_P, (double) temp1_float, (double) temp2_float, - (double) ABS(temp1_float - temp2_float), (double) ABS(1 - temp2_float / temp1_float)); - } - nfound++; - } - } - /* only one is NaN, assume difference */ - else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { - if (print_data(opts)) { - print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); - } - nfound++; - } - } - /*------------------------------------------------------------------------- - * -d and -p - *------------------------------------------------------------------------- - */ - else if (opts->d && opts->p) { - /*------------------------------------------------------------------------- - * detect NaNs - *------------------------------------------------------------------------- - */ - if (opts->do_nans) { - isnan1 = HDisnan(temp1_float); - isnan2 = HDisnan(temp2_float); - } - - /* both not NaN, do the comparison */ - if (!isnan1 && !isnan2) { - PER(temp1_float, temp2_float); - - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT_P_NOTCOMP, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); - } - nfound++; - } - else if (per > opts->percent) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT_P, (double) temp1_float, (double) temp2_float, - (double) ABS(temp1_float - temp2_float), (double) ABS(1 - temp2_float / temp1_float)); - } - nfound++; - } - } - /* only one is NaN, assume difference */ - else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { - if (print_data(opts)) { - print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); - } - nfound++; - } - } - /*------------------------------------------------------------------------- - * no -d and -p - *------------------------------------------------------------------------- - */ - else if (equal_float(temp1_float, temp2_float, opts) == FALSE) { - if (print_data(opts)) { - print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); - } - nfound++; - } - } /*H5T_NATIVE_FLOAT*/ - + nfound += diff_float_element(mem1, mem2, elemtno, opts); + } /*------------------------------------------------------------------------- * H5T_NATIVE_DOUBLE *------------------------------------------------------------------------- */ else if (type_size == 8) { - double temp1_double; - double temp2_double; - hbool_t isnan1 = FALSE; - hbool_t isnan2 = FALSE; - if(type_size != sizeof(double)) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not double size"); - - HDmemcpy(&temp1_double, mem1, sizeof(double)); - HDmemcpy(&temp2_double, mem2, sizeof(double)); - - /* logic for detecting NaNs is different with opts -d, -p and no opts */ - /*------------------------------------------------------------------------- - * -d and !-p - *------------------------------------------------------------------------- - */ - if (opts->d && !opts->p) { - /*------------------------------------------------------------------------- - * detect NaNs - *------------------------------------------------------------------------- - */ - if (opts->do_nans) { - isnan1 = HDisnan(temp1_double); - isnan2 = HDisnan(temp2_double); - } - - /* both not NaN, do the comparison */ - if (!isnan1 && !isnan2) { - if (ABS(temp1_double-temp2_double) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); - } - nfound++; - } - } - /* only one is NaN, assume difference */ - else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { - if (print_data(opts)) { - print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); - } - nfound++; - } - } /* opts->d && !opts->p */ - /*------------------------------------------------------------------------- - * !-d and -p - *------------------------------------------------------------------------- - */ - else if (!opts->d && opts->p) { - /*------------------------------------------------------------------------- - * detect NaNs - *------------------------------------------------------------------------- - */ - if (opts->do_nans) { - isnan1 = HDisnan(temp1_double); - isnan2 = HDisnan(temp2_double); - } - - /* both not NaN, do the comparison */ - if (!isnan1 && !isnan2) { - PER(temp1_double, temp2_double); - - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); - } - nfound++; - } - else if (per > opts->percent) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT_P, temp1_double, temp2_double, ABS(temp1_double - temp2_double), ABS(1 - temp2_double / temp1_double)); - } - nfound++; - } - } - /* only one is NaN, assume difference */ - else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { - if (print_data(opts)) { - print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); - } - nfound++; - } - } - /*------------------------------------------------------------------------- - * -d and -p - *------------------------------------------------------------------------- - */ - else if (opts->d && opts->p) { - /*------------------------------------------------------------------------- - * detect NaNs - *------------------------------------------------------------------------- - */ - if (opts->do_nans) { - isnan1 = HDisnan(temp1_double); - isnan2 = HDisnan(temp2_double); - } - - /* both not NaN, do the comparison */ - if (!isnan1 && !isnan2) { - PER(temp1_double, temp2_double); - - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); - } - nfound++; - } - else if (per > opts->percent && - ABS(temp1_double-temp2_double) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT_P, temp1_double, temp2_double, ABS(temp1_double - temp2_double), ABS(1 - temp2_double / temp1_double)); - } - nfound++; - } - } - /* only one is NaN, assume difference */ - else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { - if (print_data(opts)) { - print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); - } - nfound++; - } - } - /*------------------------------------------------------------------------- - * no -d and -p - *------------------------------------------------------------------------- - */ - else if (equal_double(temp1_double, temp2_double, opts) == FALSE) { - if (print_data(opts)) { - print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); - } - nfound++; - } - } /*H5T_NATIVE_DOUBLE*/ - + nfound += diff_double_element(mem1, mem2, elemtno, opts); + } #if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE /*------------------------------------------------------------------------- @@ -2053,157 +1230,10 @@ diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t idx, int rank, *------------------------------------------------------------------------- */ else if (type_size == H5_SIZEOF_LONG_DOUBLE) { - long double temp1_double; - long double temp2_double; - hbool_t isnan1 = FALSE; - hbool_t isnan2 = FALSE; - if(type_size != sizeof(long double)) { H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not long double size"); } - - HDmemcpy(&temp1_double, mem1, sizeof(long double)); - HDmemcpy(&temp2_double, mem2, sizeof(long double)); - - /* logic for detecting NaNs is different with options -d, -p and no options */ - - /*------------------------------------------------------------------------- - * -d and !-p - *------------------------------------------------------------------------- - */ - if (opts->d && !opts->p) { - /*------------------------------------------------------------------------- - * detect NaNs - *------------------------------------------------------------------------- - */ - if (opts->do_nans) { - isnan1 = HDisnan(temp1_double); - isnan2 = HDisnan(temp2_double); - } - - /* both not NaN, do the comparison */ - if (!isnan1 && !isnan2) { - if (ABS(temp1_double-temp2_double) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(LD_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); - } - nfound++; - } - } /* NaN */ - /* only one is NaN, assume difference */ - else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { - if (print_data(opts)) { - print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); - } - nfound++; - } - } - /*------------------------------------------------------------------------- - * !-d and -p - *------------------------------------------------------------------------- - */ - else if (!opts->d && opts->p) { - /*------------------------------------------------------------------------- - * detect NaNs - *------------------------------------------------------------------------- - */ - if (opts->do_nans) { - isnan1 = HDisnan(temp1_double); - isnan2 = HDisnan(temp2_double); - } - - /* both not NaN, do the comparison */ - if (!isnan1 && !isnan2) { - PER(temp1_double,temp2_double); - - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(LD_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); - } - nfound++; - } - else if (per > opts->percent) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(LD_FORMAT_P, temp1_double, temp2_double, ABS(temp1_double - temp2_double), ABS(1 - temp2_double / temp1_double)); - } - nfound++; - } - } /* NaN */ - /* only one is NaN, assume difference */ - else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { - if (print_data(opts)) { - print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); - } - nfound++; - } - } - /*------------------------------------------------------------------------- - * -d and -p - *------------------------------------------------------------------------- - */ - else if (opts->d && opts->p) { - /*------------------------------------------------------------------------- - * detect NaNs - *------------------------------------------------------------------------- - */ - if (opts->do_nans) { - isnan1 = HDisnan(temp1_double); - isnan2 = HDisnan(temp2_double); - } - - /* both not NaN, do the comparison */ - if (!isnan1 && !isnan2) { - PER(temp1_double,temp2_double); - - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(LD_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); - } - nfound++; - } - else if (per > opts->percent && ABS(temp1_double-temp2_double) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 1, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(LD_FORMAT_P, temp1_double, temp2_double, ABS(temp1_double - temp2_double), ABS(1 - temp2_double / temp1_double)); - } - nfound++; - } - } /* NaN */ - /* only one is NaN, assume difference */ - else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { - if (print_data(opts)) { - print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); - } - nfound++; - } - } - /*------------------------------------------------------------------------- - * no -d and -p - *------------------------------------------------------------------------- - */ - else if (equal_ldouble(temp1_double, temp2_double, opts) == FALSE) { - if (print_data(opts)) { - print_pos(ph, 0, idx, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(LD_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); - } - nfound++; - } + nfound += diff_ldouble_element(mem1, mem2, elemtno, opts); } /*H5T_NATIVE_LDOUBLE*/ #endif /* H5_SIZEOF_LONG_DOUBLE */ @@ -2320,8 +1350,8 @@ static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t npoints1 = H5Sget_select_elem_npoints(region1_id); npoints2 = H5Sget_select_elem_npoints(region2_id); } H5E_END_TRY; - H5TOOLS_DEBUG("diff_region blocks: 1=%ld-2=%ld", nblocks1, nblocks2); - H5TOOLS_DEBUG("diff_region points: 1=%ld-2=%ld", npoints1, npoints2); + H5TOOLS_DEBUG("blocks: 1=%ld-2=%ld", nblocks1, nblocks2); + H5TOOLS_DEBUG("points: 1=%ld-2=%ld", npoints1, npoints2); if (nblocks1 != nblocks2 || npoints1 != npoints2 || ndims1 != ndims2) { opts->not_cmp = 1; @@ -2369,7 +1399,7 @@ static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t } /* print differences if found */ - if (nfound_b && opts->m_verbose) { + if (nfound_b && opts->mode_verbose) { H5O_info2_t oi1, oi2; char *obj1_str = NULL, *obj2_str = NULL; @@ -2437,7 +1467,7 @@ static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t } } - if (nfound_p && opts->m_verbose) { + if (nfound_p && opts->mode_verbose) { parallel_print("Region points\n"); for (i = 0; i < npoints1; i++) { hsize_t pt1, pt2; @@ -2497,8 +1527,7 @@ done: *------------------------------------------------------------------------- */ -static hsize_t character_compare(char *mem1, char *mem2, hsize_t i, size_t u, - int rank, hsize_t *dims, hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, const char *obj2, int *ph) +static hsize_t character_compare(char *mem1, char *mem2, hsize_t elemtno, size_t u, diff_opt_t *opts) { hsize_t nfound = 0; /* differences found */ char temp1_uchar; @@ -2506,12 +1535,14 @@ static hsize_t character_compare(char *mem1, char *mem2, hsize_t i, size_t u, HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char)); HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char)); - H5TOOLS_START_DEBUG(" %d=%d",temp1_uchar,temp2_uchar); + H5TOOLS_START_DEBUG(" %d=%d", temp1_uchar, temp2_uchar); if (temp1_uchar != temp2_uchar) { if (print_data(opts)) { - print_char_pos(ph, 0, i, u, acc, pos, rank, dims, obj1, obj2); - parallel_print(" "); + opts->print_percentage = 0; + opts->print_dims = 1; + print_pos(opts, elemtno, u); + parallel_print(" "); h5diff_print_char(temp1_uchar); parallel_print(" "); h5diff_print_char(temp2_uchar); @@ -2532,1953 +1563,1455 @@ static hsize_t character_compare(char *mem1, char *mem2, hsize_t i, size_t u, *------------------------------------------------------------------------- */ -static hsize_t character_compare_opt(unsigned char *mem1, unsigned char *mem2, - hsize_t i, int rank, hsize_t *dims, hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, const char *obj2, int *ph) +static hsize_t character_compare_opt(unsigned char *mem1, unsigned char *mem2, hsize_t elemtno, diff_opt_t *opts) { hsize_t nfound = 0; /* differences found */ unsigned char temp1_uchar; unsigned char temp2_uchar; + hbool_t both_zero = FALSE; double per; - hbool_t both_zero; HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char)); HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char)); + H5TOOLS_START_DEBUG(" %d=%d", temp1_uchar, temp2_uchar); /* -d and !-p */ - if (opts->d && !opts->p) { + if (opts->delta_bool && !opts->percent_bool) { if (PDIFF(temp1_uchar,temp2_uchar) > opts->delta) { + opts->print_percentage = 0; + print_pos(opts, elemtno, 0); if (print_data(opts)) { - print_pos(ph, 0, i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); parallel_print(I_FORMAT, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar)); } nfound++; } } /* !-d and -p */ - else if (!opts->d && opts->p) { + else if (!opts->delta_bool && opts->percent_bool) { PER_UNSIGN(signed char, temp1_uchar, temp2_uchar); if (per > opts->percent) { + opts->print_percentage = 1; + print_pos(opts, elemtno, 0); if (print_data(opts)) { - print_pos(ph, 1, i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); parallel_print(I_FORMAT_P, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar), per); } nfound++; } } /* -d and -p */ - else if (opts->d && opts->p) { + else if (opts->delta_bool && opts->percent_bool) { PER_UNSIGN(signed char, temp1_uchar, temp2_uchar); if (per > opts->percent && PDIFF(temp1_uchar,temp2_uchar) > opts->delta) { + opts->print_percentage = 1; + print_pos(opts, elemtno, 0); if (print_data(opts)) { - print_pos(ph, 1, i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); parallel_print(I_FORMAT_P, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar), per); } nfound++; } } else if (temp1_uchar != temp2_uchar) { + opts->print_percentage = 0; + print_pos(opts, elemtno, 0); if (print_data(opts)) { - print_pos(ph, 0, i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); parallel_print(I_FORMAT, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar)); } nfound++; } + H5TOOLS_ENDDEBUG(": %d zero:%d", nfound, both_zero); return nfound; } /*------------------------------------------------------------------------- - * Function: diff_float + * Function: diff_float_element * - * Purpose: diff a H5T_NATIVE_FLOAT type + * Purpose: diff a single H5T_NATIVE_FLOAT type * * Return: number of differences found * *------------------------------------------------------------------------- */ -static hsize_t diff_float(unsigned char *mem1, unsigned char *mem2, - hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, - const char *obj2, int *ph) - +static hsize_t diff_float_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) { hsize_t nfound = 0; /* number of differences found */ float temp1_float; float temp2_float; - hsize_t i; double per; - hbool_t both_zero; + hbool_t both_zero = FALSE; hbool_t isnan1 = FALSE; hbool_t isnan2 = FALSE; + H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool); + + HDmemcpy(&temp1_float, mem1, sizeof(float)); + HDmemcpy(&temp2_float, mem2, sizeof(float)); + + /* logic for detecting NaNs is different with opts -d, -p and no opts */ + /*------------------------------------------------------------------------- * -d and !-p *------------------------------------------------------------------------- */ + if (opts->delta_bool && !opts->percent_bool) { + /*------------------------------------------------------------------------- + * detect NaNs + *------------------------------------------------------------------------- + */ + if (opts->do_nans) { + isnan1 = HDisnan(temp1_float); + isnan2 = HDisnan(temp2_float); + } - if (opts->d && !opts->p) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_float, mem1, sizeof(float)); - HDmemcpy(&temp2_float, mem2, sizeof(float)); - - /*------------------------------------------------------------------------- - * detect NaNs - *------------------------------------------------------------------------- - */ - if (opts->do_nans) { - isnan1 = HDisnan(temp1_float); - isnan2 = HDisnan(temp2_float); - } - - /* both not NaN, do the comparison */ - if (!isnan1 && !isnan2) { - if ((double) ABS(temp1_float - temp2_float) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); - } - nfound++; - } - } - /* only one is NaN, assume difference */ - else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { + /* both not NaN, do the comparison */ + if (!isnan1 && !isnan2) { + if ((double) ABS(temp1_float - temp2_float) > opts->delta) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); if (print_data(opts)) { - print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); } nfound++; - } - mem1 += sizeof(float); - mem2 += sizeof(float); - if (opts->n && nfound >= opts->count) - return nfound; - } /* i */ + } + /* only one is NaN, assume difference */ + else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); + } + nfound++; + } } /*------------------------------------------------------------------------- - * !-d and -p - *------------------------------------------------------------------------- - */ - else if (!opts->d && opts->p) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_float, mem1, sizeof(float)); - HDmemcpy(&temp2_float, mem2, sizeof(float)); - - /*------------------------------------------------------------------------- - * detect NaNs - *------------------------------------------------------------------------- - */ - if (opts->do_nans) { - isnan1 = HDisnan(temp1_float); - isnan2 = HDisnan(temp2_float); - } - /* both not NaN, do the comparison */ - if ((!isnan1 && !isnan2)) { - PER(temp1_float, temp2_float); + * !-d and -p + *------------------------------------------------------------------------- + */ + else if (!opts->delta_bool && opts->percent_bool) { + /*------------------------------------------------------------------------- + * detect NaNs + *------------------------------------------------------------------------- + */ + if (opts->do_nans) { + isnan1 = HDisnan(temp1_float); + isnan2 = HDisnan(temp2_float); + } + /* both not NaN, do the comparison */ + if ((!isnan1 && !isnan2)) { + PER(temp1_float, temp2_float); - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT_P_NOTCOMP, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); - } - nfound++; - } - else if (per > opts->percent) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT_P, (double) temp1_float, (double) temp2_float, - (double) ABS(temp1_float - temp2_float), (double) ABS(1 - temp2_float / temp1_float)); - } - nfound++; + if (not_comparable && !both_zero) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(F_FORMAT_P_NOTCOMP, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); } + nfound++; } - /* only one is NaN, assume difference */ - else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { + else if (per > opts->percent) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); if (print_data(opts)) { - print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); + parallel_print(F_FORMAT_P, (double) temp1_float, (double) temp2_float, + (double) ABS(temp1_float - temp2_float), (double) ABS(1 - temp2_float / temp1_float)); } nfound++; - } - mem1 += sizeof(float); - mem2 += sizeof(float); - if (opts->n && nfound >= opts->count) - return nfound; - } /* i */ + } + /* only one is NaN, assume difference */ + else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); + } + nfound++; + } } /*------------------------------------------------------------------------- - * -d and -p - *------------------------------------------------------------------------- - */ - else if (opts->d && opts->p) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_float, mem1, sizeof(float)); - HDmemcpy(&temp2_float, mem2, sizeof(float)); - - /*------------------------------------------------------------------------- - * detect NaNs - *------------------------------------------------------------------------- - */ - if (opts->do_nans) { - isnan1 = HDisnan(temp1_float); - isnan2 = HDisnan(temp2_float); - } + * -d and -p + *------------------------------------------------------------------------- + */ + else if (opts->delta_bool && opts->percent_bool) { + /*------------------------------------------------------------------------- + * detect NaNs + *------------------------------------------------------------------------- + */ + if (opts->do_nans) { + isnan1 = HDisnan(temp1_float); + isnan2 = HDisnan(temp2_float); + } - /* both not NaN, do the comparison */ - if (!isnan1 && !isnan2) { - PER(temp1_float, temp2_float); + /* both not NaN, do the comparison */ + if (!isnan1 && !isnan2) { + PER(temp1_float, temp2_float); - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT_P_NOTCOMP, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); - } - nfound++; - } - else if (per > opts->percent && (double) ABS(temp1_float - temp2_float) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT_P, (double) temp1_float, (double) temp2_float, - (double) ABS(temp1_float - temp2_float), (double) ABS(1 - temp2_float / temp1_float)); - } - nfound++; + if (not_comparable && !both_zero) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(F_FORMAT_P_NOTCOMP, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); } - + nfound++; } - /* only one is NaN, assume difference */ - else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { + else if (per > opts->percent && (double) ABS(temp1_float - temp2_float) > opts->delta) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); if (print_data(opts)) { - print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); + parallel_print(F_FORMAT_P, (double) temp1_float, (double) temp2_float, + (double) ABS(temp1_float - temp2_float), (double) ABS(1 - temp2_float / temp1_float)); } nfound++; - } - mem1 += sizeof(float); - mem2 += sizeof(float); - if (opts->n && nfound >= opts->count) - return nfound; - } /* i */ + } + /* only one is NaN, assume difference */ + else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); + } + nfound++; + } } - /*------------------------------------------------------------------------- - * no -d and -p - *------------------------------------------------------------------------- - */ + * no -d and -p + *------------------------------------------------------------------------- + */ else { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_float, mem1, sizeof(float)); - HDmemcpy(&temp2_float, mem2, sizeof(float)); - - if (equal_float(temp1_float, temp2_float, opts) == FALSE) { - if (print_data(opts)) { - print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); - } - nfound++; + if (equal_float(temp1_float, temp2_float, opts) == FALSE) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); } - - mem1 += sizeof(float); - mem2 += sizeof(float); - if (opts->n && nfound >= opts->count) - return nfound; - } /* nelmts */ + nfound++; + } } + H5TOOLS_ENDDEBUG(": %d zero:%d", nfound, both_zero); return nfound; } /*------------------------------------------------------------------------- - * Function: diff_double + * Function: diff_double_element * - * Purpose: diff a H5T_NATIVE_DOUBLE type + * Purpose: diff a single H5T_NATIVE_DOUBLE type * * Return: number of differences found *------------------------------------------------------------------------- */ -static hsize_t diff_double(unsigned char *mem1, unsigned char *mem2, - hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, - const char *obj2, int *ph) - +static hsize_t diff_double_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) { hsize_t nfound = 0; /* number of differences found */ double temp1_double; double temp2_double; - hsize_t i; double per; - hbool_t both_zero; + hbool_t both_zero = FALSE; hbool_t isnan1 = FALSE; hbool_t isnan2 = FALSE; - /*------------------------------------------------------------------------- - * -d and !-p - *------------------------------------------------------------------------- - */ + H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool); - if (opts->d && !opts->p) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_double, mem1, sizeof(double)); - HDmemcpy(&temp2_double, mem2, sizeof(double)); + HDmemcpy(&temp1_double, mem1, sizeof(double)); + HDmemcpy(&temp2_double, mem2, sizeof(double)); - /*------------------------------------------------------------------------- - * detect NaNs - *------------------------------------------------------------------------- - */ - if (opts->do_nans) { - isnan1 = HDisnan(temp1_double); - isnan2 = HDisnan(temp2_double); - } + /*------------------------------------------------------------------------- + * -d and !-p + *------------------------------------------------------------------------- + */ + if (opts->delta_bool && !opts->percent_bool) { + /*------------------------------------------------------------------------- + * detect NaNs + *------------------------------------------------------------------------- + */ + if (opts->do_nans) { + isnan1 = HDisnan(temp1_double); + isnan2 = HDisnan(temp2_double); + } - /* both not NaN, do the comparison */ - if (!isnan1 && !isnan2) { - if (ABS(temp1_double-temp2_double) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); - } - nfound++; - } - } - /* only one is NaN, assume difference */ - else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { + /* both not NaN, do the comparison */ + if (!isnan1 && !isnan2) { + if (ABS(temp1_double-temp2_double) > opts->delta) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); if (print_data(opts)) { - print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); } nfound++; - } - mem1 += sizeof(double); - mem2 += sizeof(double); - if (opts->n && nfound >= opts->count) - return nfound; - } /* i */ + } + /* only one is NaN, assume difference */ + else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); + } + nfound++; + } } /*------------------------------------------------------------------------- - * !-d and -p - *------------------------------------------------------------------------- - */ - else if (!opts->d && opts->p) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_double, mem1, sizeof(double)); - HDmemcpy(&temp2_double, mem2, sizeof(double)); - - /*------------------------------------------------------------------------- - * detect NaNs - *------------------------------------------------------------------------- - */ - if (opts->do_nans) { - isnan1 = HDisnan(temp1_double); - isnan2 = HDisnan(temp2_double); - } - /* both not NaN, do the comparison */ - if (!isnan1 && !isnan2) { - PER(temp1_double, temp2_double); + * !-d and -p + *------------------------------------------------------------------------- + */ + else if (!opts->delta_bool && opts->percent_bool) { + /*------------------------------------------------------------------------- + * detect NaNs + *------------------------------------------------------------------------- + */ + if (opts->do_nans) { + isnan1 = HDisnan(temp1_double); + isnan2 = HDisnan(temp2_double); + } + /* both not NaN, do the comparison */ + if (!isnan1 && !isnan2) { + PER(temp1_double, temp2_double); - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); - } - nfound++; - } - else if (per > opts->percent) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT_P, temp1_double, temp2_double, - ABS(temp1_double - temp2_double), ABS(1 - temp2_double / temp1_double)); - } - nfound++; + if (not_comparable && !both_zero) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(F_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); } + nfound++; } - /* only one is NaN, assume difference */ - else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { + else if (per > opts->percent) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); if (print_data(opts)) { - print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); + parallel_print(F_FORMAT_P, temp1_double, temp2_double, + ABS(temp1_double - temp2_double), ABS(1 - temp2_double / temp1_double)); } nfound++; - } - mem1 += sizeof(double); - mem2 += sizeof(double); - if (opts->n && nfound >= opts->count) - return nfound; - } /* i */ + } + /* only one is NaN, assume difference */ + else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); + } + nfound++; + } } /*------------------------------------------------------------------------- - * -d and -p - *------------------------------------------------------------------------- - */ - else if (opts->d && opts->p) { - - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_double, mem1, sizeof(double)); - HDmemcpy(&temp2_double, mem2, sizeof(double)); - - /*------------------------------------------------------------------------- - * detect NaNs - *------------------------------------------------------------------------- - */ - if (opts->do_nans) { - isnan1 = HDisnan(temp1_double); - isnan2 = HDisnan(temp2_double); - } + * -d and -p + *------------------------------------------------------------------------- + */ + else if (opts->delta_bool && opts->percent_bool) { + /*------------------------------------------------------------------------- + * detect NaNs + *------------------------------------------------------------------------- + */ + if (opts->do_nans) { + isnan1 = HDisnan(temp1_double); + isnan2 = HDisnan(temp2_double); + } - /* both not NaN, do the comparison */ - if (!isnan1 && !isnan2) { - PER(temp1_double, temp2_double); + /* both not NaN, do the comparison */ + if (!isnan1 && !isnan2) { + PER(temp1_double, temp2_double); - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); - } - nfound++; - } - else if (per > opts->percent && ABS(temp1_double-temp2_double) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT_P, temp1_double, temp2_double, - ABS(temp1_double - temp2_double), ABS(1 - temp2_double / temp1_double)); - } - nfound++; + if (not_comparable && !both_zero) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(F_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); } + nfound++; } - /* only one is NaN, assume difference */ - else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { + else if (per > opts->percent && ABS(temp1_double-temp2_double) > opts->delta) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); if (print_data(opts)) { - print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); + parallel_print(F_FORMAT_P, temp1_double, temp2_double, + ABS(temp1_double - temp2_double), ABS(1 - temp2_double / temp1_double)); } nfound++; } - mem1 += sizeof(double); - mem2 += sizeof(double); - if (opts->n && nfound >= opts->count) - return nfound; - } /* i */ + } + /* only one is NaN, assume difference */ + else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); + } + nfound++; + } } /*------------------------------------------------------------------------- - * no -d and -p - *------------------------------------------------------------------------- - */ + * no -d and -p + *------------------------------------------------------------------------- + */ else { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_double, mem1, sizeof(double)); - HDmemcpy(&temp2_double, mem2, sizeof(double)); - - if (equal_double(temp1_double, temp2_double, opts) == FALSE) { - if (print_data(opts)) { - print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); - } - nfound++; + if (equal_double(temp1_double, temp2_double, opts) == FALSE) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); } - - mem1 += sizeof(double); - mem2 += sizeof(double); - if (opts->n && nfound >= opts->count) - return nfound; - } /* nelmts */ + nfound++; + } } + H5TOOLS_ENDDEBUG(":%d - errstat:%d", nfound, opts->err_stat); return nfound; } /*------------------------------------------------------------------------- - * Function: diff_ldouble + * Function: diff_ldouble_element * - * Purpose: diff a H5T_NATIVE_LDOUBLE type + * Purpose: diff a single H5T_NATIVE_LDOUBLE type * * Return: number of differences found *------------------------------------------------------------------------- */ #if H5_SIZEOF_LONG_DOUBLE !=0 -static hsize_t diff_ldouble(unsigned char *mem1, - unsigned char *mem2, - hsize_t nelmts, - hsize_t hyper_start, - int rank, - hsize_t *dims, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *opts, - const char *obj1, - const char *obj2, - int *ph) - +static hsize_t diff_ldouble_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) { hsize_t nfound = 0; /* number of differences found */ long double temp1_double; long double temp2_double; - hsize_t i; double per; - hbool_t both_zero; + hbool_t both_zero = FALSE; hbool_t isnan1 = FALSE; hbool_t isnan2 = FALSE; + H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool); + + HDmemcpy(&temp1_double, mem1, sizeof(long double)); + HDmemcpy(&temp2_double, mem2, sizeof(long double)); + + /* logic for detecting NaNs is different with options -d, -p and no options */ + /*------------------------------------------------------------------------- * -d and !-p *------------------------------------------------------------------------- */ + if (opts->delta_bool && !opts->percent_bool) { + /*------------------------------------------------------------------------- + * detect NaNs + *------------------------------------------------------------------------- + */ + if (opts->do_nans) { + isnan1 = HDisnan(temp1_double); + isnan2 = HDisnan(temp2_double); + } - if (opts->d && !opts->p) { - for ( i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_double, mem1, sizeof(long double)); - HDmemcpy(&temp2_double, mem2, sizeof(long double)); - - /*------------------------------------------------------------------------- - * detect NaNs - *------------------------------------------------------------------------- - */ - if (opts->do_nans) { - isnan1 = HDisnan(temp1_double); - isnan2 = HDisnan(temp2_double); - } - - /* both not NaN, do the comparison */ - if (!isnan1 && !isnan2) { - if (ABS(temp1_double-temp2_double) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); - } - nfound++; - } - } - /* only one is NaN, assume difference */ - else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { + /* both not NaN, do the comparison */ + if (!isnan1 && !isnan2) { + if (ABS(temp1_double-temp2_double) > opts->delta) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); if (print_data(opts)) { - print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); + parallel_print(LD_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); } nfound++; - } - mem1 += sizeof(long double); - mem2 += sizeof(long double); - if (opts->n && nfound >= opts->count) - return nfound; - } /* i */ + } /* NaN */ + /* only one is NaN, assume difference */ + else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); + } + nfound++; + } } - /*------------------------------------------------------------------------- * !-d and -p *------------------------------------------------------------------------- */ - else if (!opts->d && opts->p) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_double, mem1, sizeof(long double)); - HDmemcpy(&temp2_double, mem2, sizeof(long double)); + else if (!opts->delta_bool && opts->percent_bool) { + /*------------------------------------------------------------------------- + * detect NaNs + *------------------------------------------------------------------------- + */ + if (opts->do_nans) { + isnan1 = HDisnan(temp1_double); + isnan2 = HDisnan(temp2_double); + } - /*------------------------------------------------------------------------- - * detect NaNs - *------------------------------------------------------------------------- - */ - if (opts->do_nans) { - isnan1 = HDisnan(temp1_double); - isnan2 = HDisnan(temp2_double); - } - /* both not NaN, do the comparison */ - if (!isnan1 && !isnan2) { - PER(temp1_double, temp2_double); + /* both not NaN, do the comparison */ + if (!isnan1 && !isnan2) { + PER(temp1_double,temp2_double); - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); - } - nfound++; - } - else if (per > opts->percent) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT_P, temp1_double, temp2_double, - ABS(temp1_double - temp2_double), ABS(1-temp2_double / temp1_double)); - } - nfound++; + if (not_comparable && !both_zero) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(LD_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); } + nfound++; } - /* only one is NaN, assume difference */ - else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { + else if (per > opts->percent) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); if (print_data(opts)) { - print_pos(ph, 0, hyper_start+i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); + parallel_print(LD_FORMAT_P, temp1_double, temp2_double, ABS(temp1_double - temp2_double), ABS(1 - temp2_double / temp1_double)); } nfound++; } - mem1 += sizeof(long double); - mem2 += sizeof(long double); - if (opts->n && nfound >= opts->count) - return nfound; - } /* i */ + } /* NaN */ + /* only one is NaN, assume difference */ + else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); + } + nfound++; + } } /*------------------------------------------------------------------------- * -d and -p *------------------------------------------------------------------------- */ - else if (opts->d && opts->p) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_double, mem1, sizeof(long double)); - HDmemcpy(&temp2_double, mem2, sizeof(long double)); - - /*------------------------------------------------------------------------- - * detect NaNs - *------------------------------------------------------------------------- - */ - if (opts->do_nans) { - isnan1 = HDisnan(temp1_double); - isnan2 = HDisnan(temp2_double); - } + else if (opts->delta_bool && opts->percent_bool) { + /*------------------------------------------------------------------------- + * detect NaNs + *------------------------------------------------------------------------- + */ + if (opts->do_nans) { + isnan1 = HDisnan(temp1_double); + isnan2 = HDisnan(temp2_double); + } - /* both not NaN, do the comparison */ - if (!isnan1 && !isnan2) { - PER(temp1_double, temp2_double); + /* both not NaN, do the comparison */ + if (!isnan1 && !isnan2) { + PER(temp1_double,temp2_double); - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); - } - nfound++; - } - else if (per > opts->percent && ABS(temp1_double - temp2_double) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT_P, temp1_double, temp2_double, ABS(temp1_double - temp2_double), ABS(1-temp2_double / temp1_double)); - } - nfound++; + if (not_comparable && !both_zero) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(LD_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); } + nfound++; } - /* only one is NaN, assume difference */ - else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { - if (print_data(opts)) { - print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); + else if (per > opts->percent && ABS(temp1_double-temp2_double) > opts->delta) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(LD_FORMAT_P, temp1_double, temp2_double, ABS(temp1_double - temp2_double), ABS(1 - temp2_double / temp1_double)); } nfound++; } - mem1 += sizeof(long double); - mem2 += sizeof(long double); - if (opts->n && nfound >= opts->count) - return nfound; - } /* i */ + } /* NaN */ + /* only one is NaN, assume difference */ + else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); + } + nfound++; + } } /*------------------------------------------------------------------------- * no -d and -p *------------------------------------------------------------------------- */ - else { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_double, mem1, sizeof(long double)); - HDmemcpy(&temp2_double, mem2, sizeof(long double)); - - if (equal_ldouble(temp1_double, temp2_double, opts) == FALSE) { - if (print_data(opts)) { - print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); - } - nfound++; - } - mem1 += sizeof(long double); - mem2 += sizeof(long double); - if (opts->n && nfound >= opts->count) - return nfound; - } /* nelmts */ + else if (equal_ldouble(temp1_double, temp2_double, opts) == FALSE) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(LD_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); + } + nfound++; } + H5TOOLS_ENDDEBUG(":%d - errstat:%d", nfound, opts->err_stat); + return nfound; } #endif /* H5_SIZEOF_LONG_DOUBLE */ /*------------------------------------------------------------------------- - * Function: diff_schar + * Function: diff_schar_element * - * Purpose: diff a H5T_NATIVE_SCHAR type + * Purpose: diff a single H5T_NATIVE_SCHAR type * * Return: number of differences found *------------------------------------------------------------------------- */ -static hsize_t diff_schar(unsigned char *mem1, unsigned char *mem2, - hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, - const char *obj2, int *ph) - +static hsize_t diff_schar_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) { hsize_t nfound = 0; /* number of differences found */ char temp1_char; char temp2_char; - hsize_t i; double per; - hbool_t both_zero; + hbool_t both_zero = FALSE; - /* -d and !-p */ - if (opts->d && !opts->p) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_char, mem1, sizeof(char)); - HDmemcpy(&temp2_char, mem2, sizeof(char)); + H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool); + HDmemcpy(&temp1_char, mem1, sizeof(char)); + HDmemcpy(&temp2_char, mem2, sizeof(char)); - if (ABS(temp1_char-temp2_char) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT, temp1_char, temp2_char, ABS(temp1_char - temp2_char)); - } - nfound++; + /* -d and !-p */ + if (opts->delta_bool && !opts->percent_bool) { + if (ABS(temp1_char-temp2_char) > opts->delta) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(I_FORMAT, temp1_char, temp2_char, ABS(temp1_char - temp2_char)); } - mem1 += sizeof(char); - mem2 += sizeof(char); - if (opts->n && nfound >= opts->count) - return nfound; + nfound++; } } /* !-d and -p */ - else if (!opts->d && opts->p) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_char, mem1, sizeof(char)); - HDmemcpy(&temp2_char, mem2, sizeof(char)); + else if (!opts->delta_bool && opts->percent_bool) { + PER(temp1_char, temp2_char); - PER(temp1_char, temp2_char); - - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P_NOTCOMP, temp1_char, temp2_char, ABS(temp1_char - temp2_char)); - } - nfound++; + if (not_comparable && !both_zero) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(I_FORMAT_P_NOTCOMP, temp1_char, temp2_char, ABS(temp1_char - temp2_char)); } - else if (per > opts->percent) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P, temp1_char, temp2_char, ABS(temp1_char - temp2_char), per); - } - nfound++; + nfound++; + } + else if (per > opts->percent) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(I_FORMAT_P, temp1_char, temp2_char, ABS(temp1_char - temp2_char), per); } - mem1 += sizeof(char); - mem2 += sizeof(char); - if (opts->n && nfound >= opts->count) - return nfound; + nfound++; } } /* -d and -p */ - else if (opts->d && opts->p) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_char, mem1, sizeof(char)); - HDmemcpy(&temp2_char, mem2, sizeof(char)); - - PER(temp1_char, temp2_char); + else if (opts->delta_bool && opts->percent_bool) { + PER(temp1_char, temp2_char); - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P_NOTCOMP, temp1_char, temp2_char, ABS(temp1_char - temp2_char)); - } - nfound++; + if (not_comparable && !both_zero) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(I_FORMAT_P_NOTCOMP, temp1_char, temp2_char, ABS(temp1_char - temp2_char)); } - else if (per > opts->percent && ABS(temp1_char-temp2_char) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P, temp1_char, temp2_char, ABS(temp1_char - temp2_char), per); - } - nfound++; + nfound++; + } + else if (per > opts->percent && ABS(temp1_char - temp2_char) > opts->delta) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(I_FORMAT_P, temp1_char, temp2_char, ABS(temp1_char - temp2_char), per); } - mem1 += sizeof(char); - mem2 += sizeof(char); - if (opts->n && nfound >= opts->count) - return nfound; + nfound++; } } - else { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_char, mem1, sizeof(char)); - HDmemcpy(&temp2_char, mem2, sizeof(char)); - - if (temp1_char != temp2_char) { - if (print_data(opts)) { - print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT, temp1_char, temp2_char, ABS(temp1_char - temp2_char)); - } - nfound++; - } - - mem1 += sizeof(char); - mem2 += sizeof(char); - if (opts->n && nfound >= opts->count) - return nfound; - } /* nelmts */ + else if (temp1_char != temp2_char) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(I_FORMAT, temp1_char, temp2_char, ABS(temp1_char - temp2_char)); + } + nfound++; } + H5TOOLS_ENDDEBUG(":%d - errstat:%d", nfound, opts->err_stat); + return nfound; } /*------------------------------------------------------------------------- - * Function: diff_uchar + * Function: diff_uchar_element * - * Purpose: diff a H5T_NATIVE_UCHAR type + * Purpose: diff a single H5T_NATIVE_UCHAR type * * Return: number of differences found *------------------------------------------------------------------------- */ -static hsize_t diff_uchar(unsigned char *mem1, unsigned char *mem2, - hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, - const char *obj2, int *ph) +static hsize_t diff_uchar_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) { hsize_t nfound = 0; /* number of differences found */ unsigned char temp1_uchar; unsigned char temp2_uchar; - hsize_t i; double per; - hbool_t both_zero; + hbool_t both_zero = FALSE; - /* -d and !-p */ - if (opts->d && !opts->p) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char)); - HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char)); + H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool); - if (PDIFF(temp1_uchar,temp2_uchar) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar)); - } - nfound++; + HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char)); + HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char)); + /* -d and !-p */ + if (opts->delta_bool && !opts->percent_bool) { + if (PDIFF(temp1_uchar, temp2_uchar) > opts->delta) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(I_FORMAT, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar)); } - mem1 += sizeof(unsigned char); - mem2 += sizeof(unsigned char); - if (opts->n && nfound >= opts->count) - return nfound; + nfound++; } } /* !-d and -p */ - else if (!opts->d && opts->p) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char)); - HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char)); - - PER_UNSIGN(signed char, temp1_uchar, temp2_uchar); + else if (!opts->delta_bool && opts->percent_bool) { + PER_UNSIGN(signed char, temp1_uchar, temp2_uchar); - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P_NOTCOMP, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar)); - } - nfound++; + if (not_comparable && !both_zero) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(I_FORMAT_P_NOTCOMP, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar)); } - else if (per > opts->percent) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar), per); - } - nfound++; + nfound++; + } + else if (per > opts->percent) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(I_FORMAT_P, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar), per); } - mem1 += sizeof(unsigned char); - mem2 += sizeof(unsigned char); - if (opts->n && nfound >= opts->count) - return nfound; + nfound++; } } /* -d and -p */ - else if (opts->d && opts->p) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char)); - HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char)); - - PER_UNSIGN(signed char, temp1_uchar, temp2_uchar); + else if (opts->delta_bool && opts->percent_bool) { + PER_UNSIGN(signed char, temp1_uchar, temp2_uchar); - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P_NOTCOMP, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar)); - } - nfound++; + if (not_comparable && !both_zero) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(I_FORMAT_P_NOTCOMP, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar)); } - else if (per > opts->percent && PDIFF(temp1_uchar,temp2_uchar) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar), per); - } - nfound++; + nfound++; + } + else if (per > opts->percent && PDIFF(temp1_uchar, temp2_uchar) > opts->delta) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(I_FORMAT_P, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar), per); } - mem1 += sizeof(unsigned char); - mem2 += sizeof(unsigned char); - if (opts->n && nfound >= opts->count) - return nfound; + nfound++; } } - else { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char)); - HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char)); - - if (temp1_uchar != temp2_uchar) { - if (print_data(opts)) { - print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar)); - } - nfound++; - } - - mem1 += sizeof(unsigned char); - mem2 += sizeof(unsigned char); - if (opts->n && nfound >= opts->count) - return nfound; - } /* nelmts */ + else if (temp1_uchar != temp2_uchar) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(I_FORMAT, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar)); + } + nfound++; } + H5TOOLS_ENDDEBUG(":%d - errstat:%d", nfound, opts->err_stat); + return nfound; } /*------------------------------------------------------------------------- - * Function: diff_short + * Function: diff_short_element * * Purpose: diff a H5T_NATIVE_SHORT type * * Return: number of differences found *------------------------------------------------------------------------- */ -static hsize_t diff_short(unsigned char *mem1, unsigned char *mem2, - hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, - const char *obj2, int *ph) +static hsize_t diff_short_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) { hsize_t nfound = 0; /* number of differences found */ short temp1_short; short temp2_short; - hsize_t i; double per; - hbool_t both_zero; + hbool_t both_zero = FALSE; - /* -d and !-p */ - if (opts->d && !opts->p) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_short, mem1, sizeof(short)); - HDmemcpy(&temp2_short, mem2, sizeof(short)); + H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool); - if (ABS(temp1_short-temp2_short) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT, temp1_short, temp2_short, ABS(temp1_short - temp2_short)); - } - nfound++; + HDmemcpy(&temp1_short, mem1, sizeof(short)); + HDmemcpy(&temp2_short, mem2, sizeof(short)); + /* -d and !-p */ + if (opts->delta_bool && !opts->percent_bool) { + if (ABS(temp1_short - temp2_short) > opts->delta) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(I_FORMAT, temp1_short, temp2_short, ABS(temp1_short - temp2_short)); } - mem1 += sizeof(short); - mem2 += sizeof(short); - if (opts->n && nfound >= opts->count) - return nfound; + nfound++; } } /* !-d and -p */ - else if (!opts->d && opts->p) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_short, mem1, sizeof(short)); - HDmemcpy(&temp2_short, mem2, sizeof(short)); - - PER(temp1_short, temp2_short); + else if (!opts->delta_bool && opts->percent_bool) { + PER(temp1_short, temp2_short); - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P_NOTCOMP, temp1_short, temp2_short, ABS(temp1_short - temp2_short)); - } - nfound++; + if (not_comparable && !both_zero) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(I_FORMAT_P_NOTCOMP, temp1_short, temp2_short, ABS(temp1_short - temp2_short)); } - else if (per > opts->percent) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P, temp1_short, temp2_short, ABS(temp1_short - temp2_short), per); - } - nfound++; + nfound++; + } + else if (per > opts->percent) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(I_FORMAT_P, temp1_short, temp2_short, ABS(temp1_short - temp2_short), per); } - mem1 += sizeof(short); - mem2 += sizeof(short); - if (opts->n && nfound >= opts->count) - return nfound; + nfound++; } } /* -d and -p */ - else if (opts->d && opts->p) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_short, mem1, sizeof(short)); - HDmemcpy(&temp2_short, mem2, sizeof(short)); + else if (opts->delta_bool && opts->percent_bool) { + PER(temp1_short, temp2_short); - PER(temp1_short, temp2_short); - - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P_NOTCOMP, temp1_short, temp2_short, ABS(temp1_short - temp2_short)); - } - nfound++; + if (not_comparable && !both_zero) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(I_FORMAT_P_NOTCOMP, temp1_short, temp2_short, ABS(temp1_short - temp2_short)); } - else if (per > opts->percent && ABS(temp1_short-temp2_short) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P, temp1_short, temp2_short, ABS(temp1_short - temp2_short), per); - } - nfound++; + nfound++; + } + else if (per > opts->percent && ABS(temp1_short - temp2_short) > opts->delta) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(I_FORMAT_P, temp1_short, temp2_short, ABS(temp1_short - temp2_short), per); } - mem1 += sizeof(short); - mem2 += sizeof(short); - if (opts->n && nfound >= opts->count) - return nfound; + nfound++; } } - else { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_short, mem1, sizeof(short)); - HDmemcpy(&temp2_short, mem2, sizeof(short)); - - if (temp1_short != temp2_short) { - if (print_data(opts)) { - print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT, temp1_short, temp2_short, ABS(temp1_short - temp2_short)); - } - nfound++; - } - - mem1 += sizeof(short); - mem2 += sizeof(short); - if (opts->n && nfound >= opts->count) - return nfound; - } /* nelmts */ + else if (temp1_short != temp2_short) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(I_FORMAT, temp1_short, temp2_short, ABS(temp1_short - temp2_short)); + } + nfound++; } + H5TOOLS_ENDDEBUG(":%d - errstat:%d", nfound, opts->err_stat); + return nfound; } /*------------------------------------------------------------------------- - * Function: diff_ushort + * Function: diff_ushort_element * - * Purpose: diff a H5T_NATIVE_USHORT type + * Purpose: diff a single H5T_NATIVE_USHORT type * * Return: number of differences found *------------------------------------------------------------------------- */ -static hsize_t diff_ushort(unsigned char *mem1, unsigned char *mem2, - hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, - const char *obj2, int *ph) - +static hsize_t diff_ushort_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) { hsize_t nfound = 0; /* number of differences found */ unsigned short temp1_ushort; unsigned short temp2_ushort; - hsize_t i; double per; - hbool_t both_zero; + hbool_t both_zero = FALSE; - /* -d and !-p */ - if (opts->d && !opts->p) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short)); - HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short)); + H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool); - if (PDIFF(temp1_ushort,temp2_ushort) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort)); - } - nfound++; + HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short)); + HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short)); + /* -d and !-p */ + if (opts->delta_bool && !opts->percent_bool) { + if (PDIFF(temp1_ushort, temp2_ushort) > opts->delta) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(I_FORMAT, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort)); } - mem1 += sizeof(unsigned short); - mem2 += sizeof(unsigned short); - if (opts->n && nfound >= opts->count) - return nfound; + nfound++; } } /* !-d and -p */ - else if (!opts->d && opts->p) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short)); - HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short)); - - PER_UNSIGN(signed short, temp1_ushort, temp2_ushort); + else if (!opts->delta_bool && opts->percent_bool) { + PER_UNSIGN(signed short, temp1_ushort, temp2_ushort); - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P_NOTCOMP, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort)); - } - nfound++; + if (not_comparable && !both_zero) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(I_FORMAT_P_NOTCOMP, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort)); } - else if (per > opts->percent) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort), per); - } - nfound++; + nfound++; + } + else if (per > opts->percent) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(I_FORMAT_P, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort), per); } - mem1 += sizeof(unsigned short); - mem2 += sizeof(unsigned short); - if (opts->n && nfound >= opts->count) - return nfound; + nfound++; } } /* -d and -p */ - else if (opts->d && opts->p) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short)); - HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short)); + else if (opts->delta_bool && opts->percent_bool) { + PER_UNSIGN(signed short, temp1_ushort, temp2_ushort); - PER_UNSIGN(signed short, temp1_ushort, temp2_ushort); - - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P_NOTCOMP, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort)); - } - nfound++; + if (not_comparable && !both_zero) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(I_FORMAT_P_NOTCOMP, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort)); } - else if (per > opts->percent && PDIFF(temp1_ushort,temp2_ushort) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort), per); - } - nfound++; + nfound++; + } + else if (per > opts->percent && PDIFF(temp1_ushort, temp2_ushort) > opts->delta) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(I_FORMAT_P, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort), per); } - mem1 += sizeof(unsigned short); - mem2 += sizeof(unsigned short); - if (opts->n && nfound >= opts->count) - return nfound; + nfound++; } } - else { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short)); - HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short)); - - if (temp1_ushort != temp2_ushort) { - if (print_data(opts)) { - print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort)); - } - nfound++; - } - - mem1 += sizeof(unsigned short); - mem2 += sizeof(unsigned short); - if (opts->n && nfound >= opts->count) - return nfound; - } /* nelmts */ + else if (temp1_ushort != temp2_ushort) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(I_FORMAT, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort)); + } + nfound++; } + H5TOOLS_ENDDEBUG(":%d - errstat:%d", nfound, opts->err_stat); + return nfound; } /*------------------------------------------------------------------------- - * Function: diff_int + * Function: diff_int_element * - * Purpose: diff a H5T_NATIVE_INT type + * Purpose: diff a single H5T_NATIVE_INT type * * Return: number of differences found *------------------------------------------------------------------------- */ -static hsize_t diff_int(unsigned char *mem1, unsigned char *mem2, - hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, - const char *obj2, int *ph) +static hsize_t diff_int_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) { hsize_t nfound = 0; /* number of differences found */ int temp1_int; int temp2_int; - hsize_t i; double per; - hbool_t both_zero; + hbool_t both_zero = FALSE; - /* -d and !-p */ - if (opts->d && !opts->p) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_int, mem1, sizeof(int)); - HDmemcpy(&temp2_int, mem2, sizeof(int)); + H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool); - if (ABS(temp1_int-temp2_int) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT, temp1_int, temp2_int, ABS(temp1_int - temp2_int)); - } - nfound++; + HDmemcpy(&temp1_int, mem1, sizeof(int)); + HDmemcpy(&temp2_int, mem2, sizeof(int)); + /* -d and !-p */ + if (opts->delta_bool && !opts->percent_bool) { + if (ABS(temp1_int-temp2_int) > opts->delta) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(I_FORMAT, temp1_int, temp2_int, ABS(temp1_int - temp2_int)); } - mem1 += sizeof(int); - mem2 += sizeof(int); - if (opts->n && nfound >= opts->count) - return nfound; + nfound++; } } /* !-d and -p */ - else if (!opts->d && opts->p) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_int, mem1, sizeof(int)); - HDmemcpy(&temp2_int, mem2, sizeof(int)); + else if (!opts->delta_bool && opts->percent_bool) { + PER(temp1_int, temp2_int); - PER(temp1_int, temp2_int); - - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P_NOTCOMP, temp1_int, temp2_int, ABS(temp1_int - temp2_int)); - } - nfound++; + if (not_comparable && !both_zero) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(I_FORMAT_P_NOTCOMP, temp1_int, temp2_int, ABS(temp1_int - temp2_int)); } - else if (per > opts->percent) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P, temp1_int, temp2_int, ABS(temp1_int - temp2_int), per); - } - nfound++; + nfound++; + } + else if (per > opts->percent) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(I_FORMAT_P, temp1_int, temp2_int, ABS(temp1_int - temp2_int), per); } - mem1 += sizeof(int); - mem2 += sizeof(int); - if (opts->n && nfound >= opts->count) - return nfound; + nfound++; } } /* -d and -p */ - else if (opts->d && opts->p) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_int, mem1, sizeof(int)); - HDmemcpy(&temp2_int, mem2, sizeof(int)); - - PER(temp1_int, temp2_int); + else if (opts->delta_bool && opts->percent_bool) { + PER(temp1_int, temp2_int); - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P_NOTCOMP, temp1_int, temp2_int, ABS(temp1_int - temp2_int)); - } - nfound++; + if (not_comparable && !both_zero) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(I_FORMAT_P_NOTCOMP, temp1_int, temp2_int, ABS(temp1_int - temp2_int)); } - else if (per > opts->percent && ABS(temp1_int-temp2_int) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P, temp1_int, temp2_int, ABS(temp1_int - temp2_int), per); - } - nfound++; + nfound++; + } + else if (per > opts->percent && ABS(temp1_int - temp2_int) > opts->delta) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(I_FORMAT_P, temp1_int, temp2_int, ABS(temp1_int - temp2_int), per); } - mem1 += sizeof(int); - mem2 += sizeof(int); - if (opts->n && nfound >= opts->count) - return nfound; + nfound++; } } - else { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_int, mem1, sizeof(int)); - HDmemcpy(&temp2_int, mem2, sizeof(int)); - - if (temp1_int != temp2_int) { - if (print_data(opts)) { - print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT, temp1_int, temp2_int, ABS(temp1_int - temp2_int)); - } - nfound++; - } + else if (temp1_int != temp2_int) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(I_FORMAT, temp1_int, temp2_int, ABS(temp1_int - temp2_int)); + } + nfound++; + } - mem1 += sizeof(int); - mem2 += sizeof(int); - if (opts->n && nfound >= opts->count) - return nfound; - } /* nelmts */ + H5TOOLS_ENDDEBUG(":%d - errstat:%d", nfound, opts->err_stat); - } return nfound; } /*------------------------------------------------------------------------- - * Function: diff_uint + * Function: diff_uint_element * - * Purpose: diff a H5T_NATIVE_UINT type + * Purpose: diff a single H5T_NATIVE_UINT type * * Return: number of differences found *------------------------------------------------------------------------- */ -static hsize_t diff_uint(unsigned char *mem1, unsigned char *mem2, - hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, - const char *obj2, int *ph) +static hsize_t diff_uint_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) { hsize_t nfound = 0; /* number of differences found */ unsigned int temp1_uint; unsigned int temp2_uint; - hsize_t i; double per; - hbool_t both_zero; - - /* -d and !-p */ - if (opts->d && !opts->p) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int)); - HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int)); - - if (PDIFF(temp1_uint,temp2_uint) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint)); - } - nfound++; + hbool_t both_zero = FALSE; + + H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool); + + HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int)); + HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int)); + /* -d and !-p */ + if (opts->delta_bool && !opts->percent_bool) { + if (PDIFF(temp1_uint, temp2_uint) > opts->delta) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(UI_FORMAT, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint)); } - mem1 += sizeof(unsigned int); - mem2 += sizeof(unsigned int); - if (opts->n && nfound >= opts->count) - return nfound; + nfound++; } } /* !-d and -p */ - else if (!opts->d && opts->p) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int)); - HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int)); - - PER_UNSIGN(signed int, temp1_uint, temp2_uint); + else if (!opts->delta_bool && opts->percent_bool) { + PER_UNSIGN(signed int, temp1_uint, temp2_uint); - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P_NOTCOMP, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint)); - } - nfound++; + if (not_comparable && !both_zero) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(UI_FORMAT_P_NOTCOMP, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint)); } - else if (per > opts->percent) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint), per); - } - nfound++; + nfound++; + } + else if (per > opts->percent) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(UI_FORMAT_P, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint), per); } - mem1 += sizeof(unsigned int); - mem2 += sizeof(unsigned int); - if (opts->n && nfound >= opts->count) - return nfound; + nfound++; } } /* -d and -p */ - else if (opts->d && opts->p) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int)); - HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int)); + else if (opts->delta_bool && opts->percent_bool) { + PER_UNSIGN(signed int, temp1_uint, temp2_uint); - PER_UNSIGN(signed int, temp1_uint, temp2_uint); - - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P_NOTCOMP, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint)); - } - nfound++; + if (not_comparable && !both_zero) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(UI_FORMAT_P_NOTCOMP, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint)); } - else if (per > opts->percent - && PDIFF(temp1_uint,temp2_uint) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT_P, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint), per); - } - nfound++; + nfound++; + } + else if (per > opts->percent && PDIFF(temp1_uint,temp2_uint) > opts->delta) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(UI_FORMAT_P, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint), per); } - mem1 += sizeof(unsigned int); - mem2 += sizeof(unsigned int); - if (opts->n && nfound >= opts->count) - return nfound; + nfound++; } } - else { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int)); - HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int)); - - if (temp1_uint != temp2_uint) { - if (print_data(opts)) { - print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(I_FORMAT, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint)); - } - nfound++; - } - - mem1 += sizeof(unsigned int); - mem2 += sizeof(unsigned int); - if (opts->n && nfound >= opts->count) - return nfound; - } /* nelmts */ + else if (temp1_uint != temp2_uint) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(UI_FORMAT, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint)); + } + nfound++; } + H5TOOLS_ENDDEBUG(":%d - errstat:%d", nfound, opts->err_stat); + return nfound; } /*------------------------------------------------------------------------- - * Function: diff_long + * Function: diff_long_element * - * Purpose: diff a H5T_NATIVE_LONG type + * Purpose: diff a single H5T_NATIVE_LONG type * * Return: number of differences found *------------------------------------------------------------------------- */ -static hsize_t diff_long(unsigned char *mem1, unsigned char *mem2, - hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, - const char *obj2, int *ph) +static hsize_t diff_long_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) { hsize_t nfound = 0; /* number of differences found */ long temp1_long; long temp2_long; - hsize_t i; double per; - hbool_t both_zero; + hbool_t both_zero = FALSE; - /* -d and !-p */ - if (opts->d && !opts->p) { - for (i = 0; i < nelmts; i++) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_long, mem1, sizeof(long)); - HDmemcpy(&temp2_long, mem2, sizeof(long)); + H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool); - if (ABS(temp1_long-temp2_long) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(LI_FORMAT, temp1_long, temp2_long, ABS(temp1_long - temp2_long)); - } - nfound++; - } - mem1 += sizeof(long); - mem2 += sizeof(long); - if (opts->n && nfound >= opts->count) - return nfound; + HDmemcpy(&temp1_long, mem1, sizeof(long)); + HDmemcpy(&temp2_long, mem2, sizeof(long)); + /* -d and !-p */ + if (opts->delta_bool && !opts->percent_bool) { + if (ABS(temp1_long-temp2_long) > opts->delta) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(LI_FORMAT, temp1_long, temp2_long, ABS(temp1_long - temp2_long)); } + nfound++; } } /* !-d and -p */ - else if (!opts->d && opts->p) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_long, mem1, sizeof(long)); - HDmemcpy(&temp2_long, mem2, sizeof(long)); - - PER(temp1_long, temp2_long); + else if (!opts->delta_bool && opts->percent_bool) { + PER(temp1_long, temp2_long); - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(LI_FORMAT_P_NOTCOMP, temp1_long, temp2_long, ABS(temp1_long - temp2_long)); - } - nfound++; + if (not_comparable && !both_zero) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(LI_FORMAT_P_NOTCOMP, temp1_long, temp2_long, ABS(temp1_long - temp2_long)); } - else if (per > opts->percent) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(LI_FORMAT_P, temp1_long, temp2_long, ABS(temp1_long - temp2_long), per); - } - nfound++; + nfound++; + } + else if (per > opts->percent) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(LI_FORMAT_P, temp1_long, temp2_long, ABS(temp1_long - temp2_long), per); } - mem1 += sizeof(long); - mem2 += sizeof(long); - if (opts->n && nfound >= opts->count) - return nfound; + nfound++; } } /* -d and -p */ - else if (opts->d && opts->p) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_long, mem1, sizeof(long)); - HDmemcpy(&temp2_long, mem2, sizeof(long)); + else if (opts->delta_bool && opts->percent_bool) { + PER(temp1_long, temp2_long); - PER(temp1_long, temp2_long); - - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(LI_FORMAT_P_NOTCOMP, temp1_long, temp2_long, ABS(temp1_long - temp2_long)); - } - nfound++; + if (not_comparable && !both_zero) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(LI_FORMAT_P_NOTCOMP, temp1_long, temp2_long, ABS(temp1_long - temp2_long)); } - else if (per > opts->percent && ABS(temp1_long-temp2_long) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(LI_FORMAT_P, temp1_long, temp2_long, ABS(temp1_long - temp2_long), per); - } - nfound++; + nfound++; + } + else if (per > opts->percent && ABS(temp1_long-temp2_long) > opts->delta) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(LI_FORMAT_P, temp1_long, temp2_long, ABS(temp1_long - temp2_long), per); } - mem1 += sizeof(long); - mem2 += sizeof(long); - if (opts->n && nfound >= opts->count) - return nfound; + nfound++; } } - else { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_long, mem1, sizeof(long)); - HDmemcpy(&temp2_long, mem2, sizeof(long)); - - if (temp1_long != temp2_long) { - if (print_data(opts)) { - print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(LI_FORMAT, temp1_long, temp2_long, ABS(temp1_long - temp2_long)); - } - nfound++; - } - - mem1 += sizeof(long); - mem2 += sizeof(long); - if (opts->n && nfound >= opts->count) - return nfound; - } /* nelmts */ + else if (temp1_long != temp2_long) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(LI_FORMAT, temp1_long, temp2_long, ABS(temp1_long - temp2_long)); + } + nfound++; } + H5TOOLS_ENDDEBUG(":%d - errstat:%d", nfound, opts->err_stat); + return nfound; } /*------------------------------------------------------------------------- - * Function: diff_ulong + * Function: diff_ulong_element * - * Purpose: diff a H5T_NATIVE_ULONG type + * Purpose: diff a single H5T_NATIVE_ULONG type * * Return: number of differences found *------------------------------------------------------------------------- */ -static hsize_t diff_ulong(unsigned char *mem1, unsigned char *mem2, - hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, - const char *obj2, int *ph) +static hsize_t diff_ulong_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) { hsize_t nfound = 0; /* number of differences found */ unsigned long temp1_ulong; unsigned long temp2_ulong; - hsize_t i; double per; - hbool_t both_zero; + hbool_t both_zero = FALSE; - /* -d and !-p */ - if (opts->d && !opts->p) { - for (i = 0; i < nelmts; i++) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long)); - HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long)); + H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool); - if (PDIFF(temp1_ulong,temp2_ulong) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(LI_FORMAT, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong)); - } - nfound++; - } - mem1 += sizeof(unsigned long); - mem2 += sizeof(unsigned long); - if (opts->n && nfound >= opts->count) - return nfound; + HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long)); + HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long)); + /* -d and !-p */ + if (opts->delta_bool && !opts->percent_bool) { + if (PDIFF(temp1_ulong, temp2_ulong) > opts->delta) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(ULI_FORMAT, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong)); } + nfound++; } } /* !-d and -p */ - else if (!opts->d && opts->p) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long)); - HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long)); - - PER_UNSIGN(signed long, temp1_ulong, temp2_ulong); + else if (!opts->delta_bool && opts->percent_bool) { + PER_UNSIGN(signed long, temp1_ulong, temp2_ulong); - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(ULI_FORMAT_P_NOTCOMP, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong)); - } - nfound++; + if (not_comparable && !both_zero) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(ULI_FORMAT_P_NOTCOMP, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong)); } - else if (per > opts->percent) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(LI_FORMAT_P, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong), per); - } - nfound++; + nfound++; + } + else if (per > opts->percent) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(ULI_FORMAT_P, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong), per); } - mem1 += sizeof(unsigned long); - mem2 += sizeof(unsigned long); - if (opts->n && nfound >= opts->count) - return nfound; + nfound++; } } /* -d and -p */ - else if (opts->d && opts->p) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long)); - HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long)); + else if (opts->delta_bool && opts->percent_bool) { + PER_UNSIGN(signed long, temp1_ulong, temp2_ulong); - PER_UNSIGN(signed long, temp1_ulong, temp2_ulong); - - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(ULI_FORMAT_P_NOTCOMP, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong)); - } - nfound++; + if (not_comparable && !both_zero) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(ULI_FORMAT_P_NOTCOMP, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong)); } - else if (per > opts->percent - && PDIFF(temp1_ulong,temp2_ulong) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(LI_FORMAT_P, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong), per); - } - nfound++; + nfound++; + } + else if (per > opts->percent && PDIFF(temp1_ulong,temp2_ulong) > opts->delta) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(ULI_FORMAT_P, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong), per); } - mem1 += sizeof(unsigned long); - mem2 += sizeof(unsigned long); - if (opts->n && nfound >= opts->count) - return nfound; + nfound++; } } - else { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long)); - HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long)); - - if (temp1_ulong != temp2_ulong) { - if (print_data(opts)) { - print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(LI_FORMAT, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong)); - } - nfound++; - } - - mem1 += sizeof(unsigned long); - mem2 += sizeof(unsigned long); - if (opts->n && nfound >= opts->count) - return nfound; - } /* nelmts */ + else if (temp1_ulong != temp2_ulong) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(ULI_FORMAT, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong)); + } + nfound++; } + H5TOOLS_ENDDEBUG(":%d - errstat:%d", nfound, opts->err_stat); + return nfound; } /*------------------------------------------------------------------------- - * Function: diff_llong + * Function: diff_llong_element * - * Purpose: diff a H5T_NATIVE_LLONG type + * Purpose: diff a single H5T_NATIVE_LLONG type * * Return: number of differences found *------------------------------------------------------------------------- */ -static hsize_t diff_llong(unsigned char *mem1, unsigned char *mem2, - hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, - const char *obj2, int *ph) +static hsize_t diff_llong_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) { hsize_t nfound = 0; /* number of differences found */ long long temp1_llong; long long temp2_llong; - hsize_t i; double per; - hbool_t both_zero; + hbool_t both_zero = FALSE; - /* -d and !-p */ - if (opts->d && !opts->p) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_llong, mem1, sizeof(long long)); - HDmemcpy(&temp2_llong, mem2, sizeof(long long)); + H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool); - if (ABS( temp1_llong-temp2_llong) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(LLI_FORMAT, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong)); - } - nfound++; + HDmemcpy(&temp1_llong, mem1, sizeof(long long)); + HDmemcpy(&temp2_llong, mem2, sizeof(long long)); + + /* -d and !-p */ + if (opts->delta_bool && !opts->percent_bool) { + if (ABS( temp1_llong-temp2_llong) > opts->delta) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(LLI_FORMAT, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong)); } - mem1 += sizeof(long long); - mem2 += sizeof(long long); - if (opts->n && nfound >= opts->count) - return nfound; + nfound++; } } /* !-d and -p */ - else if (!opts->d && opts->p) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_llong, mem1, sizeof(long long)); - HDmemcpy(&temp2_llong, mem2, sizeof(long long)); - - PER(temp1_llong, temp2_llong); + else if (!opts->delta_bool && opts->percent_bool) { + PER(temp1_llong, temp2_llong); - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); + if (not_comparable && !both_zero) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { parallel_print(LLI_FORMAT_P_NOTCOMP, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong)); } nfound++; } else if (per > opts->percent) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); parallel_print(LLI_FORMAT_P, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong),per); } nfound++; } - mem1 += sizeof(long long); - mem2 += sizeof(long long); - if (opts->n && nfound >= opts->count) - return nfound; - } } /* -d and -p */ - else if (opts->d && opts->p) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_llong, mem1, sizeof(long long)); - HDmemcpy(&temp2_llong, mem2, sizeof(long long)); + else if (opts->delta_bool && opts->percent_bool) { + PER(temp1_llong, temp2_llong); - PER(temp1_llong, temp2_llong); - - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(LLI_FORMAT_P_NOTCOMP, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong)); - } - nfound++; + if (not_comparable && !both_zero) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(LLI_FORMAT_P_NOTCOMP, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong)); } - else if (per > opts->percent - && ABS(temp1_llong-temp2_llong) > opts->delta) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(LLI_FORMAT_P, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong),per); - } - nfound++; + nfound++; + } + else if (per > opts->percent && ABS(temp1_llong-temp2_llong) > opts->delta) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(LLI_FORMAT_P, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong),per); } - mem1 += sizeof(long long); - mem2 += sizeof(long long); - if (opts->n && nfound >= opts->count) - return nfound; + nfound++; } } else { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_llong, mem1, sizeof(long long)); - HDmemcpy(&temp2_llong, mem2, sizeof(long long)); - - if (temp1_llong != temp2_llong) { - if (print_data(opts)) { - print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(LLI_FORMAT, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong)); - } - nfound++; + if (temp1_llong != temp2_llong) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(LLI_FORMAT, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong)); } - - mem1 += sizeof(long long); - mem2 += sizeof(long long); - if (opts->n && nfound >= opts->count) - return nfound; - } /* nelmts */ + nfound++; + } } + H5TOOLS_ENDDEBUG(":%d - errstat:%d", nfound, opts->err_stat); + return nfound; } /*------------------------------------------------------------------------- - * Function: diff_ullong + * Function: diff_ullong_element * - * Purpose: diff a H5T_NATIVE_ULLONG type + * Purpose: diff a single H5T_NATIVE_ULLONG type * * Return: number of differences found *------------------------------------------------------------------------- */ -static hsize_t diff_ullong(unsigned char *mem1, unsigned char *mem2, - hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, hsize_t *acc, - hsize_t *pos, diff_opt_t *opts, const char *obj1, const char *obj2, int *ph) - +static hsize_t diff_ullong_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) { hsize_t nfound = 0; /* number of differences found */ unsigned long long temp1_ullong; unsigned long long temp2_ullong; - hsize_t i; float f1, f2; double per; - hbool_t both_zero; + hbool_t both_zero = FALSE; - /* -d and !-p */ - if (opts->d && !opts->p) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_ullong, mem1, sizeof(unsigned long long)); - HDmemcpy(&temp2_ullong, mem2, sizeof(unsigned long long)); + H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool); - if (PDIFF(temp1_ullong,temp2_ullong) > (unsigned long long) opts->delta) { - if (print_data(opts)) { - print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(ULLI_FORMAT,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong)); - } - nfound++; + HDmemcpy(&temp1_ullong, mem1, sizeof(unsigned long long)); + HDmemcpy(&temp2_ullong, mem2, sizeof(unsigned long long)); + + /* -d and !-p */ + if (opts->delta_bool && !opts->percent_bool) { + if (PDIFF(temp1_ullong,temp2_ullong) > (unsigned long long) opts->delta) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(ULLI_FORMAT, temp1_ullong, temp2_ullong, PDIFF(temp1_ullong, temp2_ullong)); } - mem1 += sizeof(unsigned long long); - mem2 += sizeof(unsigned long long); - if (opts->n && nfound >= opts->count) - return nfound; + nfound++; } } /* !-d and -p */ - else if (!opts->d && opts->p) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_ullong, mem1, sizeof(unsigned long long)); - HDmemcpy(&temp2_ullong, mem2, sizeof(unsigned long long)); - - ull2float(temp1_ullong, &f1); - ull2float(temp2_ullong, &f2); - PER(f1, f2); - - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(ULLI_FORMAT_P_NOTCOMP,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong)); - } - nfound++; + else if (!opts->delta_bool && opts->percent_bool) { + ull2float(temp1_ullong, &f1); + ull2float(temp2_ullong, &f2); + PER(f1, f2); + + if (not_comparable && !both_zero) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(ULLI_FORMAT_P_NOTCOMP, temp1_ullong, temp2_ullong, PDIFF(temp1_ullong, temp2_ullong)); } - else if (per > opts->percent) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(ULLI_FORMAT_P,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong),per); - } - nfound++; + nfound++; + } + else if (per > opts->percent) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(ULLI_FORMAT_P, temp1_ullong, temp2_ullong, PDIFF(temp1_ullong,temp2_ullong), per); } - mem1 += sizeof(unsigned long long); - mem2 += sizeof(unsigned long long); - if (opts->n && nfound >= opts->count) - return nfound; + nfound++; } } /* -d and -p */ - else if (opts->d && opts->p) { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_ullong, mem1, sizeof(unsigned long long)); - HDmemcpy(&temp2_ullong, mem2, sizeof(unsigned long long)); - - ull2float(temp1_ullong, &f1); - ull2float(temp2_ullong, &f2); - PER(f1, f2); - - if (not_comparable && !both_zero) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(ULLI_FORMAT_P_NOTCOMP,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong)); - } - nfound++; + else if (opts->delta_bool && opts->percent_bool) { + ull2float(temp1_ullong, &f1); + ull2float(temp2_ullong, &f2); + PER(f1, f2); + + if (not_comparable && !both_zero) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(ULLI_FORMAT_P_NOTCOMP, temp1_ullong, temp2_ullong, PDIFF(temp1_ullong, temp2_ullong)); } - else if (per > opts->percent - && PDIFF(temp1_ullong,temp2_ullong) > (unsigned long long) opts->delta) { - if (print_data(opts)) { - print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(ULLI_FORMAT_P,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong),per); - } - nfound++; + nfound++; + } + else if (per > opts->percent && PDIFF(temp1_ullong,temp2_ullong) > (unsigned long long) opts->delta) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(ULLI_FORMAT_P, temp1_ullong, temp2_ullong, PDIFF(temp1_ullong, temp2_ullong), per); } - mem1 += sizeof(unsigned long long); - mem2 += sizeof(unsigned long long); - if (opts->n && nfound >= opts->count) - return nfound; + nfound++; } } else { - for (i = 0; i < nelmts; i++) { - HDmemcpy(&temp1_ullong, mem1, sizeof(unsigned long long)); - HDmemcpy(&temp2_ullong, mem2, sizeof(unsigned long long)); - - if (temp1_ullong != temp2_ullong) { - if (print_data(opts)) { - print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); - parallel_print(SPACES); - parallel_print(ULLI_FORMAT,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong)); - } - nfound++; + if (temp1_ullong != temp2_ullong) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(ULLI_FORMAT, temp1_ullong, temp2_ullong, PDIFF(temp1_ullong, temp2_ullong)); } - - mem1 += sizeof(unsigned long long); - mem2 += sizeof(unsigned long long); - if (opts->n && nfound >= opts->count) - return nfound; - } /* nelmts */ + nfound++; + } } + H5TOOLS_ENDDEBUG(": %d zero:%d", nfound, both_zero); return nfound; } @@ -4681,7 +3214,7 @@ static hbool_t equal_float(float value, float expected, diff_opt_t *opts) { static int print_data(diff_opt_t *opts) { - return ((opts->m_report || opts->m_verbose) && !opts->m_quiet) ? 1 : 0; + return ((opts->mode_report || opts->mode_verbose) && !opts->mode_quiet) ? 1 : 0; } /*------------------------------------------------------------------------- @@ -4691,25 +3224,24 @@ int print_data(diff_opt_t *opts) *------------------------------------------------------------------------- */ static -void print_header(int pp, /* print percentage */ - int rank, hsize_t *dims, const char *obj1, const char *obj2) +void print_header(diff_opt_t *opts) { /* print header */ parallel_print("%-16s", "size:"); - print_dimensions(rank, dims); + print_dimensions(opts->rank, opts->dims); parallel_print("%-11s", ""); - print_dimensions(rank, dims); + print_dimensions(opts->rank, opts->dims); parallel_print("\n"); - if (pp) { + if (opts->print_percentage) { parallel_print("%-15s %-15s %-15s %-15s %-15s\n", "position", - (obj1 != NULL) ? obj1 : " ", (obj2 != NULL) ? obj2 : " ", "difference", "relative"); + opts->obj_name[0], opts->obj_name[1], "difference", "relative"); parallel_print( "------------------------------------------------------------------------\n"); } else { parallel_print("%-15s %-15s %-15s %-20s\n", "position", - (obj1 != NULL) ? obj1 : " ", (obj2 != NULL) ? obj2 : " ", "difference"); + opts->obj_name[0], opts->obj_name[1], "difference"); parallel_print( "------------------------------------------------------------\n"); } @@ -4722,77 +3254,94 @@ void print_header(int pp, /* print percentage */ *------------------------------------------------------------------------- */ static -void print_pos(int *ph, /* print header */ - int pp, /* print percentage */ - hsize_t curr_pos, hsize_t *acc, hsize_t *pos, int rank, hsize_t *dims, - const char *obj1, const char *obj2) +void print_pos(diff_opt_t *opts, hsize_t idx, size_t u) { - int i; - - /* print header */ - if (*ph == 1) { - *ph = 0; - - print_header(pp, rank, dims, obj1, obj2); - } /* end print header */ - - for (i = 0; i < rank; i++) { - pos[i] = curr_pos / acc[i]; - curr_pos -= acc[i] * pos[i]; - } - HDassert(curr_pos == 0); + int i,j; + + H5TOOLS_START_DEBUG(" -- idx:%ld", idx); + + if (print_data(opts)) { + /* print header */ + if (opts->print_header == 1) { + opts->print_header = 0; + + print_header(opts); + } /* end print header */ + + H5TOOLS_DEBUG("rank=%d", opts->rank); + if(opts->rank > 0) { + hsize_t curr_pos = idx; + + parallel_print("[ "); + H5TOOLS_DEBUG("do calc_acc_pos[%ld] nelmts:%d - errstat:%d", i, opts->hs_nelmts, opts->err_stat); + + if (opts->sset[0] != NULL) { + /* Subsetting is used - calculate total position */ + hsize_t elmnt_cnt = 1; + hsize_t dim_cnt = 0; /* previous dim size */ + hsize_t str_cnt = 0; /* previous dim stride */ + hsize_t curr_idx = idx; /* calculated running position */ + hsize_t str_idx = 0; + hsize_t blk_idx = 0; + hsize_t cnt_idx = 0; + hsize_t hs_idx = 0; + j = opts->rank-1; + do { + cnt_idx = opts->sset[0]->count.data[j]; /* Count value for current dim */ + H5TOOLS_DEBUG("... sset loop:%d with curr_pos:%ld (curr_idx:%ld) - count:%ld", j, curr_pos, curr_idx, cnt_idx); + blk_idx = opts->sset[0]->block.data[j]; /* Block value for current dim */ + H5TOOLS_DEBUG("... sset loop:%d with curr_pos:%ld (curr_idx:%ld) - block:%ld", j, curr_pos, curr_idx, blk_idx); + hs_idx = cnt_idx * blk_idx; /* hyperslab area value for current dim */ + H5TOOLS_DEBUG("... sset loop:%d with curr_pos:%ld (curr_idx:%ld) - hs:%ld", j, curr_pos, curr_idx, hs_idx); + str_idx = opts->sset[0]->stride.data[j]; /* Stride value for current dim */ + H5TOOLS_DEBUG("... sset loop:%d with curr_pos:%ld (curr_idx:%ld) - stride:%ld", j, curr_pos, curr_idx, str_idx); + elmnt_cnt *= opts->dims[j]; /* Total number of elements in dimension */ + H5TOOLS_DEBUG("... sset loop:%d with elmnt_cnt:%ld", j, elmnt_cnt); + if (str_idx > blk_idx) + curr_idx += dim_cnt * (str_idx - blk_idx); /* */ + else if (curr_idx >= hs_idx) + curr_idx += dim_cnt * str_cnt; + H5TOOLS_DEBUG("... sset loop:%d with idx:%ld (curr_idx:%ld) - stride:%ld", j, idx, curr_idx, str_idx); + dim_cnt = elmnt_cnt; /* */ + if (str_idx > blk_idx) + str_cnt = str_idx - blk_idx; /* */ + else + str_cnt = str_idx; /* */ + H5TOOLS_DEBUG("... sset loop:%d with dim_cnt:%ld - str_cnt:%ld", j, dim_cnt, str_cnt); + j--; + } while (curr_idx >= elmnt_cnt && j >= 0); + curr_pos = curr_idx; /* New current position */ + H5TOOLS_DEBUG("pos loop:%d,%d with elmnt_cnt:%ld - curr_pos:%ld", i, j, elmnt_cnt, curr_pos); + } /* if (opts->sset[0] != NULL) */ + /* + * Calculate the number of elements represented by a unit change in a + * certain index position. + */ + calc_acc_pos((unsigned)opts->rank, curr_pos, opts->acc, opts->pos); - if (rank > 0) { - parallel_print("[ "); - for (i = 0; i < rank; i++) { - parallel_print(HSIZE_T_FORMAT, (unsigned long long)pos[i]); - parallel_print(" "); + for (i = 0; i < opts->rank; i++) { + H5TOOLS_DEBUG("pos loop:%d with opts->pos=%ld opts->sm_pos=%ld", i, opts->pos[i], opts->sm_pos[i]); + opts->pos[i] += (unsigned long) opts->sm_pos[i]; + H5TOOLS_DEBUG("pos loop:%d with opts->pos=%ld", i, opts->pos[i]); + parallel_print(HSIZE_T_FORMAT, (unsigned long long)opts->pos[i]); + parallel_print(" "); + } + parallel_print("]"); } - parallel_print("]"); - } - else - parallel_print(" "); -} - -/*------------------------------------------------------------------------- - * Function: print_char_pos - * - * Purpose: print character position in string - *------------------------------------------------------------------------- - */ -static -void print_char_pos(int *ph, /* print header */ - int pp, /* print percentage */ - hsize_t curr_pos, size_t u, hsize_t *acc, hsize_t *pos, int rank, hsize_t *dims, - const char *obj1, const char *obj2) -{ - int i; - - /* print header */ - if (*ph == 1) { - *ph = 0; - - print_header(pp, rank, dims, obj1, obj2); - } /* end print header */ - - for (i = 0; i < rank; i++) { - pos[i] = curr_pos / acc[i]; - curr_pos -= acc[i] * pos[i]; - } - HDassert(curr_pos == 0); - - parallel_print("[ "); - if (rank > 0) { - for (i = 0; i < rank; i++) { - parallel_print(HSIZE_T_FORMAT, (unsigned long long)pos[i]); - parallel_print(" "); + else { + if (opts->print_dims) { + parallel_print("[ "); + parallel_print("%zu", u); + parallel_print("]"); + opts->print_dims = 0; + } + else + parallel_print(" "); } - + parallel_print(SPACES); } - else - parallel_print("%zu", u); - parallel_print("]"); + H5TOOLS_ENDDEBUG(""); } /*------------------------------------------------------------------------- diff --git a/tools/lib/h5diff_attr.c b/tools/lib/h5diff_attr.c index 5ad29fc..b7ec2e8 100644 --- a/tools/lib/h5diff_attr.c +++ b/tools/lib/h5diff_attr.c @@ -137,7 +137,7 @@ static void table_attr_mark_exist(unsigned *exist, char *name, table_attrs_t *ta * Parameter: * table_out [OUT] : return the list *------------------------------------------------------------------------*/ -static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t ** table_out, diff_opt_t *opts) +static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t ** table_out, diff_opt_t *opts) { table_attrs_t *table_lp = NULL; H5O_info2_t oinfo1, oinfo2; /* Object info */ @@ -171,8 +171,8 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t * build the list */ while(curr1 < oinfo1.num_attrs && curr2 < oinfo2.num_attrs) { - H5TOOLS_DEBUG("build_match_list_attrs 1: %ld - %ld", curr1, oinfo1.num_attrs); - H5TOOLS_DEBUG("build_match_list_attrs 2: %ld - %ld", curr2, oinfo2.num_attrs); + H5TOOLS_DEBUG("list_attrs 1: %ld - %ld", curr1, oinfo1.num_attrs); + H5TOOLS_DEBUG("list_attrs 2: %ld - %ld", curr2, oinfo2.num_attrs); /*------------------ * open attribute1 */ @@ -226,7 +226,7 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t infile[0] = 1; infile[1] = 0; while(curr1 < oinfo1.num_attrs) { - H5TOOLS_DEBUG("build_match_list_attrs 1: %ld - %ld", curr1, oinfo1.num_attrs); + H5TOOLS_DEBUG("list_attrs 1: %ld - %ld", curr1, oinfo1.num_attrs); /*------------------ * open attribute1 */ @@ -235,7 +235,7 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t /* get name */ if(H5Aget_name(attr1_id, (size_t)ATTR_NAME_MAX, name1) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Aget_name first attribute failed"); - H5TOOLS_DEBUG("build_match_list_attrs #1 name - %s", name1); + H5TOOLS_DEBUG("list_attrs 1 name - %s", name1); table_attr_mark_exist(infile, name1, table_lp); table_lp->nattrs_only1++; @@ -250,7 +250,7 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t infile[0] = 0; infile[1] = 1; while(curr2 < oinfo2.num_attrs) { - H5TOOLS_DEBUG("build_match_list_attrs 2: %ld - %ld", curr2, oinfo2.num_attrs); + H5TOOLS_DEBUG("list_attrs 2: %ld - %ld", curr2, oinfo2.num_attrs); /*------------------ * open attribute2 */ if((attr2_id = H5Aopen_by_idx(loc2_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)curr2, H5P_DEFAULT, H5P_DEFAULT)) < 0) @@ -258,7 +258,7 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t /* get name */ if(H5Aget_name(attr2_id, (size_t)ATTR_NAME_MAX, name2) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Aget_name second attribute failed"); - H5TOOLS_DEBUG("build_match_list_attrs #2 name - %s", name2); + H5TOOLS_DEBUG("list_attrs 2 name - %s", name2); table_attr_mark_exist(infile, name2, table_lp); table_lp->nattrs_only2++; @@ -272,7 +272,7 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t /*------------------------------------------------------ * print the list */ - if(opts->m_verbose_level == 2) { + if(opts->mode_verbose_level == 2) { /* if '-v2' is detected */ parallel_print(" obj1 obj2\n"); parallel_print(" --------------------------------------\n"); @@ -284,7 +284,7 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t } /* end for */ } - if(opts->m_verbose_level >= 1) + if(opts->mode_verbose_level >= 1) parallel_print("Attributes status: %d common, %d only in obj1, %d only in obj2\n", table_lp->nattrs - table_lp->nattrs_only1 - table_lp->nattrs_only2, table_lp->nattrs_only1, table_lp->nattrs_only2); @@ -313,7 +313,8 @@ done: *------------------------------------------------------------------------- */ -hsize_t diff_attr_data(hid_t attr1_id, hid_t attr2_id, const char *name1, const char *name2, const char *path1, const char *path2, diff_opt_t *opts) +hsize_t diff_attr_data(hid_t attr1_id, hid_t attr2_id, + const char *name1, const char *name2, const char *path1, const char *path2, diff_opt_t *opts) { hid_t space1_id = H5I_INVALID_HID; /* space ID */ hid_t space2_id = H5I_INVALID_HID; /* space ID */ @@ -327,19 +328,15 @@ hsize_t diff_attr_data(hid_t attr1_id, hid_t attr2_id, const char *name1, const void *buf2 = NULL; /* data buffer */ hbool_t buf1hasdata = FALSE; /* buffer has data */ hbool_t buf2hasdata = FALSE; /* buffer has data */ - hsize_t nelmts1; /* number of elements in dataset */ int rank1; /* rank of dataset */ int rank2; /* rank of dataset */ hsize_t dims1[H5S_MAX_RANK]; /* dimensions of dataset */ hsize_t dims2[H5S_MAX_RANK]; /* dimensions of dataset */ - char np1[512]; - char np2[512]; hsize_t nfound = 0; int j; diff_err_t ret_value = opts->err_stat; H5TOOLS_START_DEBUG(" - errstat:%d", opts->err_stat); - /* get the datatypes */ if((ftype1_id = H5Aget_type(attr1_id)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_type first attribute failed"); @@ -383,11 +380,30 @@ hsize_t diff_attr_data(hid_t attr1_id, hid_t attr2_id, const char *name1, const * check for comparable TYPE and SPACE *---------------------------------------------------------------------- */ - H5TOOLS_DEBUG("diff_attr_data check for comparable TYPE and SPACE"); + H5TOOLS_DEBUG("Check for comparable TYPE and SPACE"); + + H5TOOLS_DEBUG("attr_names: %s - %s", name1, name2); + if (name1) { + j = (int)HDstrlen(name1); + H5TOOLS_DEBUG("attr1_name: %s - %d", name1, j); + if (j > 0) { + opts->obj_name[0] = (char *)HDmalloc((size_t)j + 1); + HDstrncpy(opts->obj_name[0], name1, (size_t)j + 1); + } + } + if (name2) { + j = (int)HDstrlen(name2); + H5TOOLS_DEBUG("attr2_name: %s - %d", name2, j); + if (j > 0) { + opts->obj_name[1] = (char *)HDmalloc((size_t)j + 1); + HDstrncpy(opts->obj_name[1], name2, (size_t)j + 1); + } + } + H5TOOLS_DEBUG("attr_names: %s - %s", opts->obj_name[0], opts->obj_name[1]); /* pass dims1 and dims2 for maxdims as well since attribute's maxdims * are always same */ - if(diff_can_type(ftype1_id, ftype2_id, rank1, rank2, dims1, dims2, dims1, dims2, name1, name2, opts, 0) == 1) { + if(diff_can_type(ftype1_id, ftype2_id, rank1, rank2, dims1, dims2, dims1, dims2, opts, 0) == 1) { /*----------------------------------------------------------------- * "upgrade" the smaller memory size *------------------------------------------------------------------ @@ -395,17 +411,26 @@ hsize_t diff_attr_data(hid_t attr1_id, hid_t attr2_id, const char *name1, const if(FAIL == match_up_memsize(ftype1_id, ftype2_id, &mtype1_id, &mtype2_id, &msize1, &msize2)) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "match_up_memsize failed"); - H5TOOLS_DEBUG("diff_attr_data read"); + H5TOOLS_DEBUG("initialize read"); /*--------------------------------------------------------------------- - * read + * initialize diff_opt_t structure for dimensions *---------------------------------------------------------------------- */ - nelmts1 = 1; - for(j = 0; j < rank1; j++) - nelmts1 *= dims1[j]; + opts->nelmts = 1; + for(j = 0; j < rank1; j++) { + opts->dims[j] = dims1[j]; + opts->nelmts *= dims1[j]; + } + opts->rank = rank1; + init_acc_pos((unsigned)opts->rank, opts->dims, opts->acc, opts->pos, opts->p_min_idx); - buf1 = (void *)HDcalloc((size_t)(nelmts1), msize1); - buf2 = (void *)HDcalloc((size_t)(nelmts1), msize2); + /*--------------------------------------------------------------------- + * read + *---------------------------------------------------------------------- + */ + buf1 = (void *)HDcalloc((size_t)(opts->nelmts), msize1); + buf2 = (void *)HDcalloc((size_t)(opts->nelmts), msize2); + H5TOOLS_DEBUG("attr buffer size %ld * %ld", opts->nelmts, msize1); if(buf1 == NULL || buf2 == NULL) { parallel_print("cannot read into memory\n"); H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "buffer allocation failed"); @@ -416,6 +441,7 @@ hsize_t diff_attr_data(hid_t attr1_id, hid_t attr2_id, const char *name1, const } else buf1hasdata = TRUE; + H5TOOLS_DEBUG("attr H5Aread 1"); if(H5Aread(attr2_id, mtype2_id, buf2) < 0) { parallel_print("Failed reading attribute2 %s\n", name2); @@ -423,49 +449,84 @@ hsize_t diff_attr_data(hid_t attr1_id, hid_t attr2_id, const char *name1, const } else buf2hasdata = TRUE; + H5TOOLS_DEBUG("attr H5Aread 2"); /* format output string */ - HDsnprintf(np1, sizeof(np1), "%s of <%s>", name1, path1); - HDsnprintf(np2, sizeof(np1), "%s of <%s>", name2, path2); + if (opts->obj_name[0] != NULL) + HDfree(opts->obj_name[0]); + opts->obj_name[0] = NULL; + if (opts->obj_name[1] != NULL) + HDfree(opts->obj_name[1]); + opts->obj_name[1] = NULL; + + H5TOOLS_DEBUG("attr_names: %s - %s : %s - %s", name1, name2, path1, path2); + if (name1) { + j = (int)HDstrlen(name1) + (int)HDstrlen(path1) + 7; + H5TOOLS_DEBUG("attr1_name: %s - %d", name1, j); + if (j > 0) { + opts->obj_name[0] = (char *)HDcalloc((size_t)j + 1, sizeof(char)); + HDsnprintf(opts->obj_name[0], j, "%s of <%s>", name1, path1); + opts->obj_name[0][j] = '\0'; + } + } + if (name2) { + j = (int)HDstrlen(name2) + (int)HDstrlen(path2) + 7; + H5TOOLS_DEBUG("attr2_name: %s - %d", name2, j); + if (j > 0) { + opts->obj_name[1] = (char *)HDcalloc((size_t)j + 1, sizeof(char)); + HDsnprintf(opts->obj_name[1], j, "%s of <%s>", name2, path2); + opts->obj_name[1][j] = '\0'; + } + } /*--------------------------------------------------------------------- * array compare *---------------------------------------------------------------------- */ - H5TOOLS_DEBUG("diff_attr_data array compare %s - %s", name1, name1); + H5TOOLS_DEBUG("array compare %s - %s", opts->obj_name[0], opts->obj_name[1]); + + opts->hs_nelmts = opts->nelmts; + opts->m_tid = mtype1_id; + + /* initialize the current stripmine position; this is necessary to print the array indices */ + for (j = 0; j < opts->rank; j++) + opts->sm_pos[j] = (hsize_t)0; /* always print name */ /* verbose (-v) and report (-r) mode */ - if(opts->m_verbose || opts->m_report) { - do_print_attrname("attribute", np1, np2); + if(opts->mode_verbose || opts->mode_report) { + do_print_attrname("attribute", opts->obj_name[0], opts->obj_name[1]); - nfound = diff_array(buf1, buf2, nelmts1, (hsize_t) 0, rank1, - dims1, opts, np1, np2, mtype1_id, attr1_id, attr2_id); + nfound = diff_array(buf1, buf2, opts, attr1_id, attr2_id); print_found(nfound); } /* quiet mode (-q), just count differences */ - else if(opts->m_quiet) { - nfound = diff_array(buf1, buf2, nelmts1, (hsize_t) 0, rank1, - dims1, opts, np1, np2, mtype1_id, attr1_id, attr2_id); + else if(opts->mode_quiet) { + nfound = diff_array(buf1, buf2, opts, attr1_id, attr2_id); } /* the rest (-c, none, ...) */ else { - nfound = diff_array(buf1, buf2, nelmts1, (hsize_t) 0, rank1, - dims1, opts, np1, np2, mtype1_id, attr1_id, attr2_id); + nfound = diff_array(buf1, buf2, opts, attr1_id, attr2_id); /* print info if compatible and difference found */ if (nfound) { - do_print_attrname("attribute", np1, np2); + do_print_attrname("attribute", opts->obj_name[0], opts->obj_name[1]); print_found(nfound); } /* end if */ } /* end else */ } - H5TOOLS_DEBUG("diff_attr_data check for comparable TYPE and SPACE complete nfound:%d - errstat:%d", nfound, opts->err_stat); + H5TOOLS_DEBUG("check for comparable TYPE and SPACE complete nfound:%d - errstat:%d", nfound, opts->err_stat); /*---------------------------------------------------------------------- * close *---------------------------------------------------------------------- */ + if (opts->obj_name[0] != NULL) + HDfree(opts->obj_name[0]); + opts->obj_name[0] = NULL; + if (opts->obj_name[1] != NULL) + HDfree(opts->obj_name[1]); + opts->obj_name[1] = NULL; /* Free buf1 and buf2, check both VLEN-data VLEN-string to reclaim any * VLEN memory first */ @@ -543,28 +604,32 @@ hsize_t diff_attr(hid_t loc1_id, hid_t loc2_id, const char *path1, const char *p unsigned u; /* Local index variable */ hsize_t nfound = 0; hsize_t nfound_total = 0; + diff_opt_t attr_opts; diff_err_t ret_value = opts->err_stat; H5TOOLS_START_DEBUG(" - errstat:%d", opts->err_stat); + attr_opts = *opts; + attr_opts.obj_name[0] = NULL; + attr_opts.obj_name[1] = NULL; - if(build_match_list_attrs(loc1_id, loc2_id, &match_list_attrs, opts) < 0) { + if(build_match_list_attrs(loc1_id, loc2_id, &match_list_attrs, &attr_opts) < 0) { H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "build_match_list_attrs failed"); } - H5TOOLS_DEBUG("build_match_list_attrs - errstat:%d", opts->err_stat); + H5TOOLS_DEBUG("check match_list_attrs - opts->contents:%d - errstat:%d", attr_opts.contents, attr_opts.err_stat); /* if detect any unique extra attr */ if(match_list_attrs->nattrs_only1 || match_list_attrs->nattrs_only2) { - H5TOOLS_DEBUG("diff_attr attributes only in one file"); + H5TOOLS_DEBUG("attributes only in one file"); /* exit will be 1 */ - opts->contents = 0; + attr_opts.contents = 0; } - H5TOOLS_DEBUG("match_list_attrs info - errstat:%d", opts->err_stat); + H5TOOLS_DEBUG("match_list_attrs info - opts->contents:%d", attr_opts.contents); for(u = 0; u < (unsigned)match_list_attrs->nattrs; u++) { - H5TOOLS_DEBUG("match_list_attrs loop[%d] - errstat:%d", u, opts->err_stat); + H5TOOLS_DEBUG("match_list_attrs loop[%d] - errstat:%d", u, attr_opts.err_stat); if((match_list_attrs->attrs[u].exist[0]) && (match_list_attrs->attrs[u].exist[1])) { name1 = name2 = match_list_attrs->attrs[u].name; - H5TOOLS_DEBUG("diff_attr name - %s", name1); + H5TOOLS_DEBUG("name - %s", name1); /*-------------- * attribute 1 */ @@ -576,8 +641,8 @@ hsize_t diff_attr(hid_t loc1_id, hid_t loc2_id, const char *path1, const char *p if((attr2_id = H5Aopen(loc2_id, name2, H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aopen second attribute failed"); - H5TOOLS_DEBUG("diff_attr got attributes"); - nfound = diff_attr_data(attr1_id, attr2_id, name1, name2, path1, path2, opts); + H5TOOLS_DEBUG("got attributes"); + nfound = diff_attr_data(attr1_id, attr2_id, name1, name2, path1, path2, &attr_opts); if(H5Aclose(attr1_id) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_type first attribute failed"); if(H5Aclose(attr2_id) < 0) @@ -588,7 +653,10 @@ hsize_t diff_attr(hid_t loc1_id, hid_t loc2_id, const char *path1, const char *p } /* u */ done: - opts->err_stat = opts->err_stat | ret_value; + opts->print_header = attr_opts.print_header; + opts->contents = attr_opts.contents; + opts->not_cmp = attr_opts.not_cmp; + opts->err_stat = attr_opts.err_stat | ret_value; H5E_BEGIN_TRY { table_attrs_free(match_list_attrs); diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c index cea20a8..944440e 100644 --- a/tools/lib/h5diff_dset.c +++ b/tools/lib/h5diff_dset.c @@ -27,7 +27,8 @@ * Return: Number of differences found *------------------------------------------------------------------------- */ -hsize_t diff_dataset(hid_t file1_id, hid_t file2_id, const char *obj1_name, const char *obj2_name, diff_opt_t *opts) +hsize_t +diff_dataset(hid_t file1_id, hid_t file2_id, const char *obj1_name, const char *obj2_name, diff_opt_t *opts) { int status = -1; hid_t did1 = H5I_INVALID_HID; @@ -35,9 +36,15 @@ hsize_t diff_dataset(hid_t file1_id, hid_t file2_id, const char *obj1_name, cons hid_t dcpl1 = H5I_INVALID_HID; hid_t dcpl2 = H5I_INVALID_HID; hsize_t nfound = 0; + diff_opt_t diff_opts; diff_err_t ret_value = opts->err_stat; H5TOOLS_START_DEBUG(" - errstat:%d", opts->err_stat); + diff_opts = *opts; + diff_opts.obj_name[0] = NULL; + diff_opts.obj_name[1] = NULL; + + H5TOOLS_DEBUG("obj_names: %s - %s", obj1_name, obj2_name); /*------------------------------------------------------------------------- * open the handles *------------------------------------------------------------------------- @@ -64,20 +71,22 @@ hsize_t diff_dataset(hid_t file1_id, hid_t file2_id, const char *obj1_name, cons * 2) the internal filters might be turned off *------------------------------------------------------------------------- */ - H5TOOLS_DEBUG("diff_dataset h5tools_canreadf then diff_datasetid"); - if ((status = h5tools_canreadf((opts->m_verbose ? obj1_name : NULL), dcpl1) == 1) && - (status = h5tools_canreadf((opts->m_verbose ? obj2_name : NULL), dcpl2) == 1)) - nfound = diff_datasetid(did1, did2, obj1_name, obj2_name, opts); + H5TOOLS_DEBUG("h5tools_canreadf then diff_datasetid"); + if ((status = h5tools_canreadf((opts->mode_verbose ? obj1_name : NULL), dcpl1) == 1) && + (status = h5tools_canreadf((opts->mode_verbose ? obj2_name : NULL), dcpl2) == 1)) + nfound = diff_datasetid(did1, did2, obj1_name, obj2_name, &diff_opts); else if (status < 0) { H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "h5tools_canreadf failed"); } else { ret_value = 1; - opts->not_cmp = 1; + diff_opts.not_cmp = 1; } done: - opts->err_stat = opts->err_stat | ret_value; + opts->print_header = diff_opts.print_header; + opts->not_cmp = diff_opts.not_cmp; + opts->err_stat = diff_opts.err_stat | ret_value; /* disable error reporting */ H5E_BEGIN_TRY { @@ -143,36 +152,31 @@ done: * *------------------------------------------------------------------------- */ -hsize_t diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char *obj2_name, diff_opt_t *opts) +hsize_t +diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char *obj2_name, diff_opt_t *opts) { hid_t sid1 = H5I_INVALID_HID; hid_t sid2 = H5I_INVALID_HID; hid_t f_tid1 = H5I_INVALID_HID; hid_t f_tid2 = H5I_INVALID_HID; - hid_t dam_tid = H5I_INVALID_HID; /* m_tid for diff_array function */ hid_t m_tid1 = H5I_INVALID_HID; hid_t m_tid2 = H5I_INVALID_HID; hid_t dcpl1 = H5I_INVALID_HID; hid_t dcpl2 = H5I_INVALID_HID; H5D_layout_t stl1 = -1; H5D_layout_t stl2 = -1; - size_t dam_size; /* m_size for diff_array function */ size_t m_size1; size_t m_size2; H5T_sign_t sign1; H5T_sign_t sign2; int rank1; int rank2; - hsize_t danelmts; /* nelmts for diff_array function */ hsize_t nelmts1; hsize_t nelmts2; - hsize_t *dadims; /* dims for diff_array function */ hsize_t dims1[H5S_MAX_RANK]; hsize_t dims2[H5S_MAX_RANK]; hsize_t maxdim1[H5S_MAX_RANK]; hsize_t maxdim2[H5S_MAX_RANK]; - const char *name1 = NULL; /* relative names */ - const char *name2 = NULL; hsize_t storage_size1; hsize_t storage_size2; hsize_t nfound = 0; /* number of differences found */ @@ -181,9 +185,10 @@ hsize_t diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char void *buf2 = NULL; void *sm_buf1 = NULL; void *sm_buf2 = NULL; - hid_t sm_space = H5I_INVALID_HID; /*stripmine data space */ + hid_t sm_space1 = H5I_INVALID_HID; /*stripmine data space */ + hid_t sm_space2 = H5I_INVALID_HID; /*stripmine data space */ size_t need; /* bytes needed for malloc */ - int i; + int i, j; unsigned int vl_data1 = 0; /*contains VL datatypes */ unsigned int vl_data2 = 0; /*contains VL datatypes */ diff_err_t ret_value = opts->err_stat; @@ -233,13 +238,15 @@ hsize_t diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char */ if((dcpl1 = H5Dget_create_plist(did1)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dget_create_plist failed"); - if((dcpl2 = H5Dget_create_plist(did2)) < 0) - H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dget_create_plist failed"); - if((stl1 = H5Pget_layout(dcpl1)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Pget_layout failed"); + H5Pclose(dcpl1); + + if((dcpl2 = H5Dget_create_plist(did2)) < 0) + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dget_create_plist failed"); if((stl2 = H5Pget_layout(dcpl2)) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Pget_layout failed"); + H5Pclose(dcpl2); /*------------------------------------------------------------------------- * check for empty datasets @@ -253,27 +260,46 @@ hsize_t diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char if(storage_size1 == 0 || storage_size2 == 0) { if(stl1 == H5D_VIRTUAL || stl2 == H5D_VIRTUAL) { - if((opts->m_verbose||opts->m_list_not_cmp) && obj1_name && obj2_name) + if((opts->mode_verbose||opts->mode_list_not_cmp) && obj1_name && obj2_name) parallel_print("Warning: <%s> or <%s> is a virtual dataset\n", obj1_name, obj2_name); } else { - if((opts->m_verbose || opts->m_list_not_cmp) && obj1_name && obj2_name) + if((opts->mode_verbose || opts->mode_list_not_cmp) && obj1_name && obj2_name) parallel_print("Not comparable: <%s> or <%s> is an empty dataset\n", obj1_name, obj2_name); can_compare = 0; opts->not_cmp = 1; } } + H5TOOLS_DEBUG("obj_names: %s - %s", obj1_name, obj2_name); + opts->obj_name[0] = NULL; + if (obj1_name) { + j = (int)HDstrlen(obj1_name); + H5TOOLS_DEBUG("obj1_name: %s - %d", obj1_name, j); + if (j > 0) { + opts->obj_name[0] = (char *)HDmalloc((size_t)j + 1); + HDstrncpy(opts->obj_name[0], obj1_name, (size_t)j + 1); + } + } + + + opts->obj_name[1] = NULL; + if (obj2_name) { + j = (int)HDstrlen(obj2_name); + H5TOOLS_DEBUG("obj2_name: %s - %d", obj2_name, j); + if (j > 0) { + opts->obj_name[1] = (char *)HDmalloc((size_t)j + 1); + HDstrncpy(opts->obj_name[1], obj2_name, (size_t)j + 1); + } + } + /*------------------------------------------------------------------------- * check for comparable TYPE and SPACE *------------------------------------------------------------------------- */ - if (diff_can_type(f_tid1, f_tid2, rank1, rank2, - dims1, dims2, maxdim1, maxdim2, - obj1_name, obj2_name, - opts, 0) != 1) + if (diff_can_type(f_tid1, f_tid2, rank1, rank2, dims1, dims2, maxdim1, maxdim2, opts, 0) != 1) can_compare = 0; - H5TOOLS_DEBUG("diff_can_type - errstat:%d", opts->err_stat); + H5TOOLS_DEBUG("diff_can_type returned errstat:%d", opts->err_stat); /*------------------------------------------------------------------------- * memory type and sizes @@ -312,7 +338,7 @@ hsize_t diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char sign2 = H5Tget_sign(m_tid2); if(sign1 != sign2) { H5TOOLS_DEBUG("sign1 != sign2"); - if((opts->m_verbose || opts->m_list_not_cmp) && obj1_name && obj2_name) { + if((opts->mode_verbose || opts->mode_list_not_cmp) && obj1_name && obj2_name) { parallel_print("Not comparable: <%s> has sign %s ", obj1_name, get_sign(sign1)); parallel_print("and <%s> has sign %s\n", obj2_name, get_sign(sign2)); } @@ -360,41 +386,56 @@ hsize_t diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char *------------------------------------------------------------------ */ H5TOOLS_DEBUG("NOT H5T_ARRAY, upgrade the smaller memory size?"); - if (FAIL == match_up_memsize (f_tid1, f_tid2, - &m_tid1, &m_tid2, - &m_size1, &m_size2)) + if (FAIL == match_up_memsize (f_tid1, f_tid2, &m_tid1, &m_tid2, &m_size1, &m_size2)) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "match_up_memsize failed"); H5TOOLS_DEBUG("m_size: %ld - %ld", m_size1, m_size2); - dadims = dims1; - dam_size = m_size1; - dam_tid = m_tid1; - danelmts = nelmts1; + opts->rank = rank1; + for(i = 0; i < rank1; i++) + opts->dims[i] = dims1[i]; + opts->m_size = m_size1; + opts->m_tid = m_tid1; + opts->nelmts = nelmts1; need = (size_t)(nelmts1 * m_size1); /* bytes needed */ } else { H5TOOLS_DEBUG("Array dims: %d - %d", dims1[0], dims2[0]); /* Compare the smallest array, but create the largest buffer */ if(m_size1 <= m_size2) { - dadims = dims1; - dam_size = m_size1; - dam_tid = m_tid1; - danelmts = nelmts1; + opts->rank = rank1; + for(i = 0; i < rank1; i++) + opts->dims[i] = dims1[i]; + opts->m_size = m_size1; + opts->m_tid = m_tid1; + opts->nelmts = nelmts1; need = (size_t)(nelmts2 * m_size2); /* bytes needed */ } else { - dadims = dims2; - dam_size = m_size2; - dam_tid = m_tid2; - danelmts = nelmts2; + opts->rank = rank2; + for(i = 0; i < rank2; i++) + opts->dims[i] = dims2[i]; + opts->m_size = m_size2; + opts->m_tid = m_tid2; + opts->nelmts = nelmts2; need = (size_t)(nelmts1 * m_size1); /* bytes needed */ } } + opts->hs_nelmts = opts->nelmts; + H5TOOLS_DEBUG("need: %ld", need); /* print names */ + H5TOOLS_DEBUG("obj_names: %s - %s", obj1_name, obj2_name); + + if (opts->obj_name[0] != NULL) + HDfree(opts->obj_name[0]); + opts->obj_name[0] = NULL; + if (opts->obj_name[1] != NULL) + HDfree(opts->obj_name[1]); + opts->obj_name[1] = NULL; + if(obj1_name) - name1 = diff_basename(obj1_name); + opts->obj_name[0] = HDstrdup(diff_basename(obj1_name)); if(obj2_name) - name2 = diff_basename(obj2_name); - H5TOOLS_DEBUG("obj_names: %s - %s", name1, name2); + opts->obj_name[1] = HDstrdup(diff_basename(obj2_name)); + H5TOOLS_DEBUG("obj_names: %s - %s", opts->obj_name[0], opts->obj_name[1]); H5TOOLS_DEBUG("read/compare"); @@ -407,7 +448,14 @@ hsize_t diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char buf2 = HDmalloc(need); } /* end if */ - if(buf1 != NULL && buf2 != NULL) { + /* Assume entire data space to be printed */ + init_acc_pos((unsigned)opts->rank, opts->dims, opts->acc, opts->pos, opts->p_min_idx); + + for(i = 0; i < opts->rank; i++) { + opts->p_max_idx[i] = opts->dims[i]; + } + + if(buf1 != NULL && buf2 != NULL && opts->sset[0] == NULL && opts->sset[1] == NULL) { H5TOOLS_DEBUG("buf1 != NULL && buf2 != NULL"); H5TOOLS_DEBUG("H5Dread did1"); if(H5Dread(did1, m_tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1) < 0) @@ -416,10 +464,13 @@ hsize_t diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char if(H5Dread(did2, m_tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dread failed"); + /* initialize the current stripmine position; this is necessary to print the array indices */ + for (j = 0; j < opts->rank; j++) + opts->sm_pos[j] = (hsize_t)0; + /* array diff */ - nfound = diff_array(buf1, buf2, danelmts, (hsize_t)0, rank1, dadims, - opts, name1, name2, dam_tid, did1, did2); - H5TOOLS_DEBUG("diff_array nfound:%d - errstat:%d", nfound, opts->err_stat); + nfound = diff_array(buf1, buf2, opts, did1, did2); + H5TOOLS_DEBUG("diff_array ret nfound:%d - errstat:%d", nfound, opts->err_stat); /* reclaim any VL memory, if necessary */ H5TOOLS_DEBUG("check vl_data1:%d", vl_data1); @@ -438,111 +489,369 @@ hsize_t diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char } } /* end if */ else { /* possibly not enough memory, read/compare by hyperslabs */ - size_t p_type_nbytes = dam_size; /*size of memory type */ - hsize_t p_nelmts = danelmts; /*total selected elmts */ - hsize_t elmtno; /*counter */ - int carry; /*counter carry value */ + hsize_t elmtno; /* counter */ + int carry; /* counter carry value */ /* stripmine info */ - hsize_t sm_size[H5S_MAX_RANK]; /*stripmine size */ - hsize_t sm_nbytes; /*bytes per stripmine */ - hsize_t sm_nelmts; /*elements per stripmine*/ + hsize_t sm_size[H5S_MAX_RANK]; /* stripmine size */ + hsize_t sm_block[H5S_MAX_RANK]; /* stripmine block size */ + hsize_t sm_nbytes; /* bytes per stripmine */ + hsize_t sm_nelmts1; /* elements per stripmine */ + hsize_t sm_nelmts2; /* elements per stripmine */ + hssize_t ssm_nelmts; /* elements temp */ /* hyperslab info */ - hsize_t hs_offset[H5S_MAX_RANK]; /*starting offset */ - hsize_t hs_size[H5S_MAX_RANK]; /*size this pass */ - hsize_t hs_nelmts; /*elements in request */ - hsize_t zero[8]; /*vector of zeros */ + hsize_t hs_offset1[H5S_MAX_RANK]; /* starting offset */ + hsize_t hs_count1[H5S_MAX_RANK]; /* number of blocks */ + hsize_t hs_block1[H5S_MAX_RANK]; /* size of blocks */ + hsize_t hs_stride1[H5S_MAX_RANK]; /* stride */ + hsize_t hs_size1[H5S_MAX_RANK]; /* size this pass */ + hsize_t hs_offset2[H5S_MAX_RANK]; /* starting offset */ + hsize_t hs_count2[H5S_MAX_RANK]; /* number of blocks */ + hsize_t hs_block2[H5S_MAX_RANK]; /* size of blocks */ + hsize_t hs_stride2[H5S_MAX_RANK]; /* stride */ + hsize_t hs_size2[H5S_MAX_RANK]; /* size this pass */ + hsize_t hs_nelmts1 = 0; /* elements in request */ + hsize_t hs_nelmts2 = 0; /* elements in request */ + hsize_t zero[8]; /* vector of zeros */ + hsize_t low[H5S_MAX_RANK]; /* low bound of hyperslab */ + hsize_t high[H5S_MAX_RANK]; /* higher bound of hyperslab */ + + H5TOOLS_DEBUG("reclaim any VL memory and free unused buffers"); + if(buf1 != NULL) { + /* reclaim any VL memory, if necessary */ + if(vl_data1) + H5Treclaim(m_tid1, sid1, H5P_DEFAULT, buf1); + HDfree(buf1); + buf1 = NULL; + } + if(buf2 != NULL) { + /* reclaim any VL memory, if necessary */ + if(vl_data2) + H5Treclaim(m_tid2, sid2, H5P_DEFAULT, buf2); + HDfree(buf2); + buf2 = NULL; + } + + /* the stripmine loop */ + HDmemset(hs_offset1, 0, sizeof hs_offset1); + HDmemset(hs_stride1, 0, sizeof hs_stride1); + HDmemset(hs_count1, 0, sizeof hs_count1); + HDmemset(hs_block1, 0, sizeof hs_block1); + HDmemset(hs_size1, 0, sizeof hs_size1); + HDmemset(hs_offset2, 0, sizeof hs_offset2); + HDmemset(hs_stride2, 0, sizeof hs_stride2); + HDmemset(hs_count2, 0, sizeof hs_count2); + HDmemset(hs_block2, 0, sizeof hs_block2); + HDmemset(hs_size2, 0, sizeof hs_size2); + HDmemset(zero, 0, sizeof zero); + + /* if subsetting was requested - initialize the subsetting variables */ + H5TOOLS_DEBUG("compare by hyperslabs: opts->nelmts=%ld - opts->m_size=%ld", opts->nelmts, opts->m_size); + if (opts->sset[0] != NULL) { + H5TOOLS_DEBUG("opts->sset[0] != NULL"); + + /* Check for valid settings - default if not specified */ + if(!opts->sset[0]->start.data || !opts->sset[0]->stride.data || !opts->sset[0]->count.data || !opts->sset[0]->block.data) { + /* they didn't specify a ``stride'' or ``block''. default to 1 in all + * dimensions */ + if(!opts->sset[0]->start.data) { + /* default to (0, 0, ...) for the start coord */ + opts->sset[0]->start.data = (hsize_t *)HDcalloc((size_t)rank1, sizeof(hsize_t)); + opts->sset[0]->start.len = (unsigned)rank1; + } + + if(!opts->sset[0]->stride.data) { + opts->sset[0]->stride.data = (hsize_t *)HDcalloc((size_t)rank1, sizeof(hsize_t)); + opts->sset[0]->stride.len = (unsigned)rank1; + for (i = 0; i < rank1; i++) + opts->sset[0]->stride.data[i] = 1; + } + + if(!opts->sset[0]->count.data) { + opts->sset[0]->count.data = (hsize_t *)HDcalloc((size_t)rank1, sizeof(hsize_t)); + opts->sset[0]->count.len = (unsigned)rank1; + for (i = 0; i < rank1; i++) + opts->sset[0]->count.data[i] = 1; + } + + if(!opts->sset[0]->block.data) { + opts->sset[0]->block.data = (hsize_t *)HDcalloc((size_t)rank1, sizeof(hsize_t)); + opts->sset[0]->block.len = (unsigned)rank1; + for (i = 0; i < rank1; i++) + opts->sset[0]->block.data[i] = 1; + } + + /*------------------------------------------------------------------------- + * check for block overlap + *------------------------------------------------------------------------- + */ + for(i = 0; i < rank1; i++) { + if(opts->sset[0]->count.data[i] > 1) { + if(opts->sset[0]->stride.data[i] < opts->sset[0]->block.data[i]) { + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "wrong subset selection[0]; blocks overlap"); + } /* end if */ + } /* end if */ + } /* end for */ + } + + /* Reset the total number of elements to the subset from the command */ + opts->nelmts = 1; + for (i = 0; i < rank1; i++) { + hs_offset1[i] = opts->sset[0]->start.data[i]; + hs_stride1[i] = opts->sset[0]->stride.data[i]; + hs_count1[i] = opts->sset[0]->count.data[i]; + hs_block1[i] = opts->sset[0]->block.data[i]; + opts->nelmts *= hs_count1[i] * hs_block1[i]; + hs_size1[i] = 0; + H5TOOLS_DEBUG("[%d]hs_offset1:%ld, hs_stride1:%ld, hs_count1:%ld, hs_block1:%ld", i, hs_offset1[i], hs_stride1[i], hs_count1[i], hs_block1[i]); + } + } + if (opts->sset[1] != NULL) { + H5TOOLS_DEBUG("opts->sset[1] != NULL"); + + /* Check for valid settings - default if not specified */ + if(!opts->sset[1]->start.data || !opts->sset[1]->stride.data || !opts->sset[1]->count.data || !opts->sset[1]->block.data) { + /* they didn't specify a ``stride'' or ``block''. default to 1 in all + * dimensions */ + if(!opts->sset[1]->start.data) { + /* default to (0, 0, ...) for the start coord */ + opts->sset[1]->start.data = (hsize_t *)HDcalloc((size_t)rank2, sizeof(hsize_t)); + opts->sset[1]->start.len = (unsigned)rank2; + } + + if(!opts->sset[1]->stride.data) { + opts->sset[1]->stride.data = (hsize_t *)HDcalloc((size_t)rank2, sizeof(hsize_t)); + opts->sset[1]->stride.len = (unsigned)rank2; + for (i = 0; i < rank2; i++) + opts->sset[1]->stride.data[i] = 1; + } + + if(!opts->sset[1]->count.data) { + opts->sset[1]->count.data = (hsize_t *)HDcalloc((size_t)rank2, sizeof(hsize_t)); + opts->sset[1]->count.len = (unsigned)rank2; + for (i = 0; i < rank2; i++) + opts->sset[1]->count.data[i] = 1; + } + + if(!opts->sset[1]->block.data) { + opts->sset[1]->block.data = (hsize_t *)HDcalloc((size_t)rank2, sizeof(hsize_t)); + opts->sset[1]->block.len = (unsigned)rank2; + for (i = 0; i < rank2; i++) + opts->sset[1]->block.data[i] = 1; + } + + /*------------------------------------------------------------------------- + * check for block overlap + *------------------------------------------------------------------------- + */ + for(i = 0; i < rank2; i++) { + if(opts->sset[1]->count.data[i] > 1) { + if(opts->sset[1]->stride.data[i] < opts->sset[1]->block.data[i]) { + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "wrong subset selection[1]; blocks overlap"); + } /* end if */ + } /* end if */ + } /* end for */ + } + + for (i = 0; i < rank2; i++) { + hs_offset2[i] = opts->sset[1]->start.data[i]; + hs_stride2[i] = opts->sset[1]->stride.data[i]; + hs_count2[i] = opts->sset[1]->count.data[i]; + hs_block2[i] = opts->sset[1]->block.data[i]; + hs_size2[i] = 0; + H5TOOLS_DEBUG("[%d]hs_offset2:%ld, hs_stride2:%ld, hs_count2:%ld, hs_block2:%ld", i, hs_offset2[i], hs_stride2[i], hs_count2[i], hs_block2[i]); + } + } /* * determine the strip mine size and allocate a buffer. The strip mine is * a hyperslab whose size is manageable. */ - sm_nbytes = p_type_nbytes; - - for(i = rank1; i > 0; --i) { - hsize_t size = H5TOOLS_BUFSIZE / sm_nbytes; - - if(size == 0) /* datum size > H5TOOLS_BUFSIZE */ - size = 1; - sm_size[i - 1] = MIN(dadims[i - 1], size); - sm_nbytes *= sm_size[i - 1]; - H5TOOLS_DEBUG("sm_nbytes: %ld", sm_nbytes); - } /* end for */ - - /* malloc return code should be verified. - * If fail, need to handle the error. - * This else branch should be recoded as a separate function. - * Note that there are many "goto error" within this branch - * that fails to address freeing other objects created here. - * E.g., sm_space. - */ - if((sm_buf1 = HDmalloc((size_t)sm_nbytes)) == NULL) - H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "HDmalloc failed"); - if((sm_buf2 = HDmalloc((size_t)sm_nbytes)) == NULL) - H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "HDmalloc failed"); + sm_nbytes = opts->m_size; + if(opts->rank > 0) { + for (i = opts->rank; i > 0; --i) { + hsize_t size = H5TOOLS_BUFSIZE / sm_nbytes; + if (size == 0) /* datum size > H5TOOLS_BUFSIZE */ + size = 1; + H5TOOLS_DEBUG("opts->dims[%d]: %ld - size: %ld", i - 1, opts->dims[i - 1], size); + if (opts->sset[1] != NULL) { + sm_size[i - 1] = MIN(hs_block1[i - 1] * hs_count1[i - 1], size); + sm_block[i - 1] = MIN(hs_block1[i - 1], sm_size[i - 1]); + } + else { + sm_size[i - 1] = MIN(opts->dims[i - 1], size); + sm_block[i - 1] = sm_size[i - 1]; + } + H5TOOLS_DEBUG("sm_size[%d]: %ld - sm_block:%ld", i - 1, sm_size[i - 1], sm_block[i - 1]); + sm_nbytes *= sm_size[i - 1]; + H5TOOLS_DEBUG("sm_nbytes: %ld", sm_nbytes); + } + } - sm_nelmts = sm_nbytes / p_type_nbytes; - sm_space = H5Screate_simple(1, &sm_nelmts, NULL); + H5TOOLS_DEBUG("opts->nelmts: %ld", opts->nelmts); + for(elmtno = 0; elmtno < opts->nelmts; elmtno += opts->hs_nelmts) { + H5TOOLS_DEBUG("elmtno: %ld - hs_nelmts1: %ld", elmtno, hs_nelmts1); - /* the stripmine loop */ - HDmemset(hs_offset, 0, sizeof hs_offset); - HDmemset(zero, 0, sizeof zero); + if(NULL == (sm_buf1 = (unsigned char *)HDmalloc((size_t) sm_nbytes))) + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Could not allocate buffer for strip-mine"); + if(NULL == (sm_buf2 = (unsigned char *)HDmalloc((size_t) sm_nbytes))) + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Could not allocate buffer for strip-mine"); - for(elmtno = 0; elmtno < p_nelmts; elmtno += hs_nelmts) { /* calculate the hyperslab size */ - if(rank1 > 0) { - for(i = 0, hs_nelmts = 1; i < rank1; i++) { - hs_size[i] = MIN(dadims[i] - hs_offset[i], sm_size[i]); - hs_nelmts *= hs_size[i]; - } /* end for */ - if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0) - H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sselect_hyperslab failed"); - if(H5Sselect_hyperslab(sid2, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0) + /* initialize subset */ + if(opts->rank > 0) { + if (opts->sset[0] != NULL) { + H5TOOLS_DEBUG("sset1 has data"); + /* calculate the potential number of elements */ + for(i = 0; i < rank1; i++) { + H5TOOLS_DEBUG("[%d]opts->dims: %ld - hs_offset1: %ld - sm_block: %ld", i, opts->dims[i], hs_offset1[i], sm_block[i]); + hs_size1[i] = MIN(opts->dims[i] - hs_offset1[i], sm_block[i]); + H5TOOLS_DEBUG("hs_size1[%d]: %ld", i, hs_size1[i]); + } + if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, hs_offset1, hs_stride1, hs_count1, hs_size1) < 0) + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sselect_hyperslab sid1 failed"); + } + else { + for(i = 0, hs_nelmts1 = 1; i < rank1; i++) { + H5TOOLS_DEBUG("[%d]opts->dims: %ld - hs_offset1: %ld - sm_block: %ld", i, opts->dims[i], hs_offset1[i], sm_block[i]); + hs_size1[i] = MIN(opts->dims[i] - hs_offset1[i], sm_block[i]); + H5TOOLS_DEBUG("hs_size1[%d]: %ld", i, hs_size1[i]); + hs_nelmts1 *= hs_size1[i]; + H5TOOLS_DEBUG("hs_nelmts1:%ld *= hs_size1[%d]: %ld", hs_nelmts1, i, hs_size1[i]); + } + if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, hs_offset1, NULL, hs_size1, NULL) < 0) + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sselect_hyperslab sid1 failed"); + } + + if((ssm_nelmts = H5Sget_select_npoints(sid1)) < 0) + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sget_select_npoints failed"); + sm_nelmts1 = (hsize_t)ssm_nelmts; + H5TOOLS_DEBUG("sm_nelmts1: %ld", sm_nelmts1); + hs_nelmts1 = sm_nelmts1; + + if((sm_space1 = H5Screate_simple(1, &sm_nelmts1, NULL)) < 0) + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Screate_simple failed"); + + if(H5Sselect_hyperslab(sm_space1, H5S_SELECT_SET, zero, NULL, &sm_nelmts1, NULL) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sselect_hyperslab failed"); - if(H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &hs_nelmts, NULL) < 0) + + if (opts->sset[1] != NULL) { + H5TOOLS_DEBUG("sset2 has data"); + for(i = 0; i < rank2; i++) { + H5TOOLS_DEBUG("[%d]opts->dims: %ld - hs_offset2: %ld - sm_block: %ld", i, opts->dims[i], hs_offset2[i], sm_block[i]); + hs_size2[i] = MIN(opts->dims[i] - hs_offset2[i], sm_block[i]); + H5TOOLS_DEBUG("hs_size2[%d]: %ld", i, hs_size2[i]); + } + if(H5Sselect_hyperslab(sid2, H5S_SELECT_SET, hs_offset2, hs_stride2, hs_count2, hs_size2) < 0) + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sselect_hyperslab sid2 failed"); + } + else { + for(i = 0, hs_nelmts2 = 1; i < rank2; i++) { + H5TOOLS_DEBUG("[%d]opts->dims: %ld - hs_offset2: %ld - sm_block: %ld", i, opts->dims[i], hs_offset2[i], sm_block[i]); + hs_size2[i] = MIN(opts->dims[i] - hs_offset2[i], sm_block[i]); + H5TOOLS_DEBUG("hs_size2[%d]: %ld", i, hs_size2[i]); + hs_nelmts2 *= hs_size2[i]; + H5TOOLS_DEBUG("hs_nelmts2:%ld *= hs_size2[%d]: %ld", hs_nelmts2, i, hs_size2[i]); + } + if(H5Sselect_hyperslab(sid2, H5S_SELECT_SET, hs_offset2, NULL, hs_size2, NULL) < 0) + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sselect_hyperslab sid2 failed"); + } + + if((ssm_nelmts = H5Sget_select_npoints(sid2)) < 0) + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sget_select_npoints failed"); + sm_nelmts2 = (hsize_t)ssm_nelmts; + H5TOOLS_DEBUG("sm_nelmts2: %ld", sm_nelmts2); + hs_nelmts2 = sm_nelmts2; + + if((sm_space2 = H5Screate_simple(1, &sm_nelmts2, NULL)) < 0) + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Screate_simple failed"); + + if(H5Sselect_hyperslab(sm_space2, H5S_SELECT_SET, zero, NULL, &sm_nelmts2, NULL) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sselect_hyperslab failed"); - } /* end if */ + } else - hs_nelmts = 1; + hs_nelmts1 = 1; + opts->hs_nelmts = hs_nelmts1; + H5TOOLS_DEBUG("hs_nelmts: %ld", opts->hs_nelmts); - if(H5Dread(did1, m_tid1, sm_space, sid1, H5P_DEFAULT, sm_buf1) < 0) + /* read the data */ + if(H5Dread(did1, m_tid1, sm_space1, sid1, H5P_DEFAULT, sm_buf1) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dread failed"); - if(H5Dread(did2, m_tid2, sm_space, sid2, H5P_DEFAULT, sm_buf2) < 0) + if(H5Dread(did2, m_tid2, sm_space2, sid2, H5P_DEFAULT, sm_buf2) < 0) H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dread failed"); + /* print array indices. get the lower bound of the hyperslab and calculate + the element position at the start of hyperslab */ + if(H5Sget_select_bounds(sid1, low, high) < 0) + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sget_select_bounds failed"); + /* initialize the current stripmine position; this is necessary to print the array indices */ + for (j = 0; j < opts->rank; j++) + opts->sm_pos[j] = low[j]; + + /* Assume entire data space to be printed */ + init_acc_pos((unsigned)opts->rank, opts->dims, opts->acc, opts->pos, opts->p_min_idx); + /* get array differences. in the case of hyperslab read, increment the number of differences found in each hyperslab and pass the position at the beginning for printing */ - nfound += diff_array(sm_buf1, sm_buf2, hs_nelmts, elmtno, rank1, - dadims, opts, name1, name2, dam_tid, did1, did2); - - /* reclaim any VL memory, if necessary */ - if(vl_data1) - H5Treclaim(m_tid1, sm_space, H5P_DEFAULT, sm_buf1); - if(vl_data2) - H5Treclaim(m_tid2, sm_space, H5P_DEFAULT, sm_buf2); + nfound += diff_array(sm_buf1, sm_buf2, opts, did1, did2); + + if(sm_buf1 != NULL) { + /* reclaim any VL memory, if necessary */ + if(vl_data1) + H5Treclaim(m_tid1, sm_space1, H5P_DEFAULT, sm_buf1); + HDfree(sm_buf1); + sm_buf1 = NULL; + } + if(sm_buf2 != NULL) { + /* reclaim any VL memory, if necessary */ + if(vl_data2) + H5Treclaim(m_tid2, sm_space2, H5P_DEFAULT, sm_buf2); + HDfree(sm_buf2); + sm_buf2 = NULL; + } + + H5Sclose(sm_space1); + H5Sclose(sm_space2); /* calculate the next hyperslab offset */ - for(i = rank1, carry = 1; i > 0 && carry; --i) { - hs_offset[i - 1] += hs_size[i - 1]; - if(hs_offset[i - 1] == dadims[i - 1]) - hs_offset[i - 1] = 0; + for(i = opts->rank, carry = 1; i > 0 && carry; --i) { + if (opts->sset[0] != NULL) { + H5TOOLS_DEBUG("[%d]hs_size1:%ld - hs_block1:%ld - hs_stride1:%ld", i-1, hs_size1[i-1], hs_block1[i - 1], hs_stride1[i - 1]); + if(hs_size1[i - 1] >= hs_block1[i - 1]) { + hs_offset1[i - 1] += hs_size1[i - 1]; + } + else { + hs_offset1[i - 1] += hs_stride1[i - 1]; + } + } + else + hs_offset1[i - 1] += hs_size1[i - 1]; + H5TOOLS_DEBUG("[%d]hs_offset1:%ld - opts->dims:%ld", i-1, hs_offset1[i-1], opts->dims[i - 1]); + if(hs_offset1[i - 1] >= opts->dims[i - 1]) + hs_offset1[i - 1] = 0; else carry = 0; - } /* i */ - } /* elmtno */ - if(sm_buf1 != NULL) { - HDfree(sm_buf1); - sm_buf1 = NULL; - } - if(sm_buf2 != NULL) { - HDfree(sm_buf2); - sm_buf2 = NULL; - } - - H5Sclose(sm_space); + H5TOOLS_DEBUG("[%d]hs_offset1:%ld", i-1, hs_offset1[i-1]); + if (opts->sset[1] != NULL) { + H5TOOLS_DEBUG("[%d]hs_size2:%ld - hs_block2:%ld - hs_stride2:%ld", i-1, hs_size2[i-1], hs_block2[i - 1], hs_stride2[i - 1]); + if(hs_size2[i - 1] >= hs_block2[i - 1]) { + hs_offset2[i - 1] += hs_size2[i - 1]; + } + else { + hs_offset2[i - 1] += hs_stride2[i - 1]; + } + } + else + hs_offset2[i - 1] += hs_size2[i - 1]; + H5TOOLS_DEBUG("[%d]hs_offset2:%ld - opts->dims:%ld", i-1, hs_offset2[i-1], opts->dims[i - 1]); + if(hs_offset2[i - 1] >= opts->dims[i - 1]) + hs_offset2[i - 1] = 0; + H5TOOLS_DEBUG("[%d]hs_offset2:%ld", i-1, hs_offset2[i-1]); + } + } /* elmtno for loop */ } /* hyperslab read */ - H5TOOLS_DEBUG("can_compare complete"); + H5TOOLS_DEBUG("can compare complete"); } /*can_compare*/ @@ -550,12 +859,20 @@ hsize_t diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char * close *------------------------------------------------------------------------- */ - H5TOOLS_DEBUG("reclaim any VL memory - errstat:%d", opts->err_stat); done: opts->err_stat = opts->err_stat | ret_value; + H5TOOLS_DEBUG("free names - errstat:%d", opts->err_stat); /* free */ + if (opts->obj_name[0] != NULL) + HDfree(opts->obj_name[0]); + opts->obj_name[0] = NULL; + if (opts->obj_name[1] != NULL) + HDfree(opts->obj_name[1]); + opts->obj_name[1] = NULL; + + H5TOOLS_DEBUG("reclaim any VL memory"); if(buf1 != NULL) { /* reclaim any VL memory, if necessary */ if(vl_data1) @@ -570,26 +887,31 @@ done: HDfree(buf2); buf2 = NULL; } + H5TOOLS_DEBUG("reclaim any stripmine VL memory"); if(sm_buf1 != NULL) { /* reclaim any VL memory, if necessary */ if(vl_data1) - H5Treclaim(m_tid1, sm_space, H5P_DEFAULT, sm_buf1); + H5Treclaim(m_tid1, sm_space1, H5P_DEFAULT, sm_buf1); HDfree(sm_buf1); sm_buf1 = NULL; } if(sm_buf2 != NULL) { /* reclaim any VL memory, if necessary */ if(vl_data2) - H5Treclaim(m_tid2, sm_space, H5P_DEFAULT, sm_buf2); + H5Treclaim(m_tid2, sm_space2, H5P_DEFAULT, sm_buf2); HDfree(sm_buf2); sm_buf2 = NULL; } + H5TOOLS_DEBUG("close ids"); /* disable error reporting */ H5E_BEGIN_TRY { H5Sclose(sid1); H5Sclose(sid2); - H5Sclose(sm_space); + H5Sclose(sm_space1); + H5Sclose(sm_space2); + H5Pclose(dcpl1); + H5Pclose(dcpl2); H5Tclose(f_tid1); H5Tclose(f_tid2); H5Tclose(m_tid1); @@ -613,10 +935,9 @@ done: *------------------------------------------------------------------------- */ -int diff_can_type(hid_t f_tid1, hid_t f_tid2, int rank1, int rank2, - hsize_t *dims1, hsize_t *dims2, hsize_t *maxdim1, hsize_t *maxdim2, - const char *obj1_name, const char *obj2_name, - diff_opt_t *opts, int is_compound) +int +diff_can_type(hid_t f_tid1, hid_t f_tid2, int rank1, int rank2, hsize_t *dims1, hsize_t *dims2, + hsize_t *maxdim1, hsize_t *maxdim2, diff_opt_t *opts, int is_compound) { H5T_class_t tclass1; H5T_class_t tclass2; @@ -635,19 +956,21 @@ int diff_can_type(hid_t f_tid1, hid_t f_tid2, int rank1, int rank2, if((tclass2 = H5Tget_class(f_tid2)) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Tget_class second object failed"); + H5TOOLS_DEBUG("obj_names: %s - %s", opts->obj_name[0], opts->obj_name[1]); if(tclass1 != tclass2) { - if((opts->m_verbose || opts->m_list_not_cmp) && obj1_name && obj2_name) { + if((opts->mode_verbose || opts->mode_list_not_cmp) && opts->obj_name[0] && opts->obj_name[1]) { if(is_compound) { parallel_print("Not comparable: <%s> has a class %s and <%s> has a class %s\n", - obj1_name, get_class(tclass1), - obj2_name, get_class(tclass2)); + opts->obj_name[0], get_class(tclass1), + opts->obj_name[1], get_class(tclass2)); } else { parallel_print("Not comparable: <%s> is of class %s and <%s> is of class %s\n", - obj1_name, get_class(tclass1), - obj2_name, get_class(tclass2)); + opts->obj_name[0], get_class(tclass1), + opts->obj_name[1], get_class(tclass2)); } } + opts->not_cmp = 1; H5TOOLS_GOTO_DONE(0); } @@ -658,10 +981,11 @@ int diff_can_type(hid_t f_tid1, hid_t f_tid2, int rank1, int rank2, */ switch (tclass1) { case H5T_TIME: - if((opts->m_verbose || opts->m_list_not_cmp) && obj1_name && obj2_name) { + if((opts->mode_verbose || opts->mode_list_not_cmp) && opts->obj_name[0] && opts->obj_name[1]) { parallel_print("Not comparable: <%s> and <%s> are of class %s\n", - obj1_name, obj2_name, get_class(tclass2)); + opts->obj_name[0], opts->obj_name[1], get_class(tclass2)); } /* end if */ + opts->not_cmp = 1; H5TOOLS_GOTO_DONE(0); break; @@ -679,7 +1003,7 @@ int diff_can_type(hid_t f_tid1, hid_t f_tid2, int rank1, int rank2, case H5T_NO_CLASS: case H5T_NCLASSES: default: - H5TOOLS_DEBUG("diff_can_type class - %s", get_class(tclass1)); + H5TOOLS_DEBUG("class - %s", get_class(tclass1)); break; } /* end switch */ @@ -687,15 +1011,15 @@ int diff_can_type(hid_t f_tid1, hid_t f_tid2, int rank1, int rank2, * check for equal file datatype; warning only *------------------------------------------------------------------------- */ - if((H5Tequal(f_tid1, f_tid2) == 0) && (opts->m_verbose) && obj1_name && obj2_name) { + if((H5Tequal(f_tid1, f_tid2) == 0) && (opts->mode_verbose) && opts->obj_name[0] && opts->obj_name[1]) { H5T_class_t cl = H5Tget_class(f_tid1); parallel_print("Warning: different storage datatype\n"); if(cl == H5T_INTEGER || cl == H5T_FLOAT) { - parallel_print("<%s> has file datatype ", obj1_name); + parallel_print("<%s> has file datatype ", opts->obj_name[0]); print_type(f_tid1); parallel_print("\n"); - parallel_print("<%s> has file datatype ", obj2_name); + parallel_print("<%s> has file datatype ", opts->obj_name[1]); print_type(f_tid2); parallel_print("\n"); } @@ -706,18 +1030,19 @@ int diff_can_type(hid_t f_tid1, hid_t f_tid2, int rank1, int rank2, *------------------------------------------------------------------------- */ if(rank1 != rank2) { - if((opts->m_verbose || opts->m_list_not_cmp) && obj1_name && obj2_name) { - parallel_print("Not comparable: <%s> has rank %d, dimensions ", obj1_name, rank1); + if((opts->mode_verbose || opts->mode_list_not_cmp) && opts->obj_name[0] && opts->obj_name[1]) { + parallel_print("Not comparable: <%s> has rank %d, dimensions ", opts->obj_name[0], rank1); print_dimensions(rank1, dims1); parallel_print(", max dimensions "); print_dimensions(rank1, maxdim1); parallel_print("\n" ); - parallel_print("and <%s> has rank %d, dimensions ", obj2_name, rank2); + parallel_print("and <%s> has rank %d, dimensions ", opts->obj_name[1], rank2); print_dimensions(rank2, dims2); parallel_print(", max dimensions "); print_dimensions(rank2, maxdim2); parallel_print("\n"); } + opts->not_cmp = 1; H5TOOLS_GOTO_DONE(0); } @@ -740,20 +1065,21 @@ int diff_can_type(hid_t f_tid1, hid_t f_tid2, int rank1, int rank2, *------------------------------------------------------------------------- */ if(dim_diff == 1) { - if((opts->m_verbose || opts->m_list_not_cmp) && obj1_name && obj2_name) { - parallel_print("Not comparable: <%s> has rank %d, dimensions ", obj1_name, rank1); + if((opts->mode_verbose || opts->mode_list_not_cmp) && opts->obj_name[0] && opts->obj_name[1]) { + parallel_print("Not comparable: <%s> has rank %d, dimensions ", opts->obj_name[0], rank1); print_dimensions(rank1, dims1); if(maxdim1 && maxdim2) { parallel_print(", max dimensions "); print_dimensions(rank1, maxdim1); parallel_print("\n" ); - parallel_print("and <%s> has rank %d, dimensions ", obj2_name, rank2); + parallel_print("and <%s> has rank %d, dimensions ", opts->obj_name[1], rank2); print_dimensions(rank2, dims2); parallel_print(", max dimensions "); print_dimensions(rank2, maxdim2); parallel_print("\n"); } } + opts->not_cmp = 1; H5TOOLS_GOTO_DONE(0); } @@ -762,13 +1088,13 @@ int diff_can_type(hid_t f_tid1, hid_t f_tid2, int rank1, int rank2, * maximum dimensions; just give a warning *------------------------------------------------------------------------- */ - if(maxdim1 && maxdim2 && maxdim_diff == 1 && obj1_name) { - if(opts->m_verbose) { + if(maxdim1 && maxdim2 && maxdim_diff == 1 && opts->obj_name[0]) { + if(opts->mode_verbose) { parallel_print( "Warning: different maximum dimensions\n"); - parallel_print("<%s> has max dimensions ", obj1_name); + parallel_print("<%s> has max dimensions ", opts->obj_name[0]); print_dimensions(rank1, maxdim1); parallel_print("\n"); - parallel_print("<%s> has max dimensions ", obj2_name); + parallel_print("<%s> has max dimensions ", opts->obj_name[1]); print_dimensions(rank2, maxdim2); parallel_print("\n"); } @@ -777,16 +1103,17 @@ int diff_can_type(hid_t f_tid1, hid_t f_tid2, int rank1, int rank2, if(tclass1 == H5T_STRING) { htri_t vstrtype1 = -1; htri_t vstrtype2 = -1; - H5TOOLS_DEBUG("diff_can_type end - H5T_STRING"); + H5TOOLS_DEBUG(" - H5T_STRING"); vstrtype1 = H5Tis_variable_str(f_tid1); vstrtype2 = H5Tis_variable_str(f_tid2); /* no compare if either one but not both are variable string type */ if (vstrtype1 != vstrtype2) { - if((opts->m_verbose || opts->m_list_not_cmp) && obj1_name && obj2_name) + if((opts->mode_verbose || opts->mode_list_not_cmp) && opts->obj_name[0] && opts->obj_name[1]) parallel_print("Not comparable: <%s> or <%s> is of mixed string type\n", - obj1_name, obj2_name); + opts->obj_name[0], opts->obj_name[1]); + opts->not_cmp = 1; H5TOOLS_GOTO_DONE(0); } @@ -798,17 +1125,18 @@ int diff_can_type(hid_t f_tid1, hid_t f_tid2, int rank1, int rank2, int j; hid_t memb_type1 = H5I_INVALID_HID; hid_t memb_type2 = H5I_INVALID_HID; - H5TOOLS_DEBUG("diff_can_type end - H5T_COMPOUND"); + H5TOOLS_DEBUG(" - H5T_COMPOUND"); nmembs1 = H5Tget_nmembers(f_tid1); nmembs2 = H5Tget_nmembers(f_tid2); if(nmembs1 != nmembs2) { - if((opts->m_verbose || opts->m_list_not_cmp) && obj1_name && obj2_name) { - parallel_print("Not comparable: <%s> has %d members ", obj1_name, nmembs1); - parallel_print("<%s> has %d members ", obj2_name, nmembs2); + if((opts->mode_verbose || opts->mode_list_not_cmp) && opts->obj_name[0] && opts->obj_name[1]) { + parallel_print("Not comparable: <%s> has %d members ", opts->obj_name[0], nmembs1); + parallel_print("<%s> has %d members ", opts->obj_name[1], nmembs2); parallel_print("\n"); } + opts->not_cmp = 1; H5TOOLS_GOTO_DONE(0); } @@ -817,9 +1145,7 @@ int diff_can_type(hid_t f_tid1, hid_t f_tid2, int rank1, int rank2, memb_type1 = H5Tget_member_type(f_tid1, (unsigned)j); memb_type2 = H5Tget_member_type(f_tid2, (unsigned)j); - if (diff_can_type(memb_type1, memb_type2, rank1, rank2, - dims1, dims2, maxdim1, maxdim2, obj1_name, obj2_name, - opts, 1) != 1) { + if (diff_can_type(memb_type1, memb_type2, rank1, rank2, dims1, dims2, maxdim1, maxdim2, opts, 1) != 1) { opts->not_cmp = 1; H5Tclose(memb_type1); H5Tclose(memb_type2); @@ -838,19 +1164,17 @@ done: } +#if defined (H5DIFF_DEBUG_UNUSED) +/* this function is not currently used, but could be useful */ /*------------------------------------------------------------------------- * Function: print_sizes * * Purpose: Print datatype sizes *------------------------------------------------------------------------- */ -#if defined (H5DIFF_DEBUG) -void print_sizes( const char *obj1, - const char *obj2, - hid_t f_tid1, - hid_t f_tid2, - hid_t m_tid1, - hid_t m_tid2 ) +void print_sizes( const char *obj1, const char *obj2, hid_t f_tid1, hid_t f_tid2, hid_t m_tid1, hid_t m_tid2); + +void print_sizes( const char *obj1, const char *obj2, hid_t f_tid1, hid_t f_tid2, hid_t m_tid1, hid_t m_tid2) { size_t f_size1, f_size2; /* size of type in file */ size_t m_size1, m_size2; /* size of type in memory */ diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 33f1e11..55c69a7 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -29,60 +29,75 @@ int H5tools_INDENT_g = 0; /* global variables */ -hid_t H5tools_ERR_STACK_g = 0; +H5E_auto2_t lib_func; +H5E_auto2_t tools_func; +void *lib_edata; +void *tools_edata; + +hid_t H5tools_ERR_STACK_g = H5I_INVALID_HID; hid_t H5tools_ERR_CLS_g = H5I_INVALID_HID; hid_t H5E_tools_g = H5I_INVALID_HID; hid_t H5E_tools_min_id_g = H5I_INVALID_HID; hid_t H5E_tools_min_info_id_g = H5I_INVALID_HID; hid_t H5E_tools_min_dbg_id_g = H5I_INVALID_HID; -int compound_data; + FILE *rawattrstream = NULL; /* should initialize to stdout but gcc moans about it */ FILE *rawdatastream = NULL; /* should initialize to stdout but gcc moans about it */ FILE *rawinstream = NULL; /* should initialize to stdin but gcc moans about it */ FILE *rawoutstream = NULL; /* should initialize to stdout but gcc moans about it */ FILE *rawerrorstream = NULL; /* should initialize to stderr but gcc moans about it */ + int bin_output; /* binary output */ int bin_form = 0; /* binary form, default NATIVE */ int region_output; /* region output */ int oid_output; /* oid output */ int data_output; /* data output */ int attr_data_output; /* attribute data output */ +int compound_data; + unsigned packed_bits_num; /* number of packed bits to display */ unsigned packed_data_offset; /* offset of packed bits to display */ unsigned packed_data_length; /* length of packed bits to display */ unsigned long long packed_data_mask; /* mask in which packed bits to display */ + int enable_error_stack = 0; /* re-enable error stack; disable=0 enable=1 */ /* sort parameters */ -H5_index_t sort_by = H5_INDEX_NAME; /*sort_by [creation_order | name] */ -H5_iter_order_t sort_order = H5_ITER_INC; /*sort_order [ascending | descending] */ +H5_index_t sort_by = H5_INDEX_NAME; /* sort_by [creation_order | name] */ +H5_iter_order_t sort_order = H5_ITER_INC; /* sort_order [ascending | descending] */ /* module-scoped variables */ static int h5tools_init_g; /* if h5tools lib has been initialized */ -/* Names of VFDs */ -static const char *drivernames[]={ +/* Names of VOL connectors */ +const char *volnames[] = { + H5VL_NATIVE_NAME, + H5VL_PASSTHRU_NAME, +}; + +/* Names of VFDs. These names are always available so that + * the tools can emit special messages when a VFD is asked + * for by name but is not compiled into the library or is + * somehow otherwise not enabled. + * + */ +const char *drivernames[] = { "sec2", + "direct", + "log", + "windows", + "stdio", + "core", "family", "split", "multi", -#ifdef H5_HAVE_PARALLEL "mpio", -#endif /* H5_HAVE_PARALLEL */ + "ros3", + "hdfs", }; -/* This enum should match the entries in the above drivers_list since they - * are indexes into the drivers_list array. */ -typedef enum { - SEC2_IDX = 0 - ,FAMILY_IDX - ,SPLIT_IDX - ,MULTI_IDX -#ifdef H5_HAVE_PARALLEL - ,MPIO_IDX -#endif /* H5_HAVE_PARALLEL */ -} driver_idx; -#define NUM_DRIVERS (sizeof(drivernames) / sizeof(drivernames[0])) +#define NUM_VOLS (sizeof(volnames) / sizeof(volnames[0])) +#define NUM_DRIVERS (sizeof(drivernames) / sizeof(drivernames[0])) /*------------------------------------------------------------------------- * Function: h5tools_init @@ -97,6 +112,10 @@ typedef enum { void h5tools_init(void) { + /* Disable error reporting */ + H5Eget_auto2(H5E_DEFAULT, &lib_func, &lib_edata); + H5Eset_auto2(H5E_DEFAULT, NULL, NULL); + if (!h5tools_init_g) { H5TOOLS_INIT_ERROR(); @@ -115,6 +134,29 @@ h5tools_init(void) h5tools_init_g++; } + + /* Disable tools error reporting */ + H5Eget_auto2(H5tools_ERR_STACK_g, &tools_func, &tools_edata); + H5Eset_auto2(H5tools_ERR_STACK_g, NULL, NULL); +} + +/*------------------------------------------------------------------------- + * Function: h5tools_error_report + * + * Purpose: Enable error stack reporting after command line is parsed. + * + * Return: None + *------------------------------------------------------------------------- + */ +void +h5tools_error_report(void) +{ + if (h5tools_init_g) { + if (enable_error_stack > 0) { + H5Eset_auto2(H5E_DEFAULT, lib_func, lib_edata); + H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata); + } + } } /*------------------------------------------------------------------------- @@ -131,16 +173,14 @@ h5tools_init(void) void h5tools_close(void) { - H5E_auto2_t tools_func; - void *tools_edata; if (h5tools_init_g) { /* special case where only data is output to stdout */ - if((rawoutstream == NULL) && rawdatastream && (rawdatastream == stdout)) + if ((rawoutstream == NULL) && rawdatastream && (rawdatastream == stdout)) HDfprintf(rawdatastream, "\n"); - H5Eget_auto2(H5tools_ERR_STACK_g, &tools_func, &tools_edata); - if(tools_func!=NULL) + if (tools_func) H5Eprint2(H5tools_ERR_STACK_g, rawerrorstream); + if (rawattrstream && rawattrstream != stdout) { if (fclose(rawattrstream)) perror("closing rawattrstream"); @@ -175,6 +215,10 @@ h5tools_close(void) /* Clean up the reference path table, if it's been used */ term_ref_path_table(); + /* Restore error stacks from init */ + H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata); + H5Eset_auto2(H5E_DEFAULT, lib_func, lib_edata); + H5TOOLS_CLOSE_ERROR(); /* Shut down the library */ @@ -425,189 +469,537 @@ h5tools_set_error_file(const char *fname, int is_bin) } /*------------------------------------------------------------------------- - * Function: h5tools_get_fapl + * Function: h5tools_set_fapl_vfd * - * Purpose: Get a FAPL for a given VFL driver name. + * Purpose: Given a VFL driver name, sets the appropriate driver on the + * specified FAPL. * * Return: positive - succeeded * negative - failed *------------------------------------------------------------------------- */ -static hid_t -h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum) +static herr_t +h5tools_set_fapl_vfd(hid_t fapl_id, h5tools_vfd_info_t *vfd_info) { - hid_t new_fapl = H5I_INVALID_HID; /* Copy of file access property list passed in, or new property list */ herr_t ret_value = SUCCEED; - /* 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) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pcreate failed"); - } /* end if */ - else { - if ((new_fapl = H5Pcopy(fapl)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pcopy failed"); - } /* end else */ - - /* Determine which driver the user wants to open the file with. Try - * that driver. If it can't open it, then fail. */ - if (!HDstrcmp(driver, drivernames[SEC2_IDX])) { - /* SEC2 driver */ - if (H5Pset_fapl_sec2(new_fapl) < 0) + /* Determine which driver the user wants to open the file with */ + if (!HDstrcmp(vfd_info->name, drivernames[SEC2_VFD_IDX])) { + /* SEC2 Driver */ + if (H5Pset_fapl_sec2(fapl_id) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_sec2 failed"); + } + else if (!HDstrcmp(vfd_info->name, drivernames[DIRECT_VFD_IDX])) { +#ifdef H5_HAVE_DIRECT + /* Direct Driver */ + if (H5Pset_fapl_direct(fapl_id, 1024, 4096, 8 * 4096) < 0) + H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_direct failed"); +#else + H5TOOLS_GOTO_ERROR(FAIL, "Direct VFD is not enabled"); +#endif + } + else if (!HDstrcmp(vfd_info->name, drivernames[LOG_VFD_IDX])) { + unsigned long long log_flags = H5FD_LOG_LOC_IO | H5FD_LOG_ALLOC; - if (drivernum) - *drivernum = SEC2_IDX; + /* Log Driver */ + if (H5Pset_fapl_log(fapl_id, NULL, log_flags, (size_t) 0) < 0) + H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_log failed"); + } + else if (!HDstrcmp(vfd_info->name, drivernames[WINDOWS_VFD_IDX])) { +#ifdef H5_HAVE_WINDOWS + /* There is no Windows VFD - use SEC2 */ + if (H5Pset_fapl_sec2(fapl_id) < 0) + H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_sec2 failed"); +#else + H5TOOLS_GOTO_ERROR(FAIL, "Windows VFD is not enabled"); +#endif } - else if (!HDstrcmp(driver, drivernames[FAMILY_IDX])) { + else if (!HDstrcmp(vfd_info->name, drivernames[STDIO_VFD_IDX])) { + /* Stdio Driver */ + if (H5Pset_fapl_stdio(fapl_id) < 0) + H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_stdio failed"); + } + else if (!HDstrcmp(vfd_info->name, drivernames[CORE_VFD_IDX])) { + /* Core Driver */ + if (H5Pset_fapl_core(fapl_id, (size_t) H5_MB, TRUE) < 0) + H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_core failed"); + } + else if (!HDstrcmp(vfd_info->name, drivernames[FAMILY_VFD_IDX])) { /* FAMILY Driver */ - /* Set member size to be 0 to indicate the current first member size * is the member size. */ - if (H5Pset_fapl_family(new_fapl, (hsize_t) 0, H5P_DEFAULT) < 0) + if (H5Pset_fapl_family(fapl_id, (hsize_t) 0, H5P_DEFAULT) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_family failed"); - - if (drivernum) - *drivernum = FAMILY_IDX; } - else if (!HDstrcmp(driver, drivernames[SPLIT_IDX])) { + else if (!HDstrcmp(vfd_info->name, drivernames[SPLIT_VFD_IDX])) { /* SPLIT Driver */ - if (H5Pset_fapl_split(new_fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT) < 0) + if (H5Pset_fapl_split(fapl_id, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_split failed"); - - if (drivernum) - *drivernum = SPLIT_IDX; } - else if (!HDstrcmp(driver, drivernames[MULTI_IDX])) { + else if (!HDstrcmp(vfd_info->name, drivernames[MULTI_VFD_IDX])) { /* MULTI Driver */ - if (H5Pset_fapl_multi(new_fapl, NULL, NULL, NULL, NULL, TRUE) < 0) + if (H5Pset_fapl_multi(fapl_id, NULL, NULL, NULL, NULL, TRUE) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_multi failed"); - - if(drivernum) - *drivernum = MULTI_IDX; } + else if (!HDstrcmp(vfd_info->name, drivernames[MPIO_VFD_IDX])) { #ifdef H5_HAVE_PARALLEL - else if(!HDstrcmp(driver, drivernames[MPIO_IDX])) { int mpi_initialized, mpi_finalized; /* MPI-I/O Driver */ + /* check if MPI is available. */ MPI_Initialized(&mpi_initialized); MPI_Finalized(&mpi_finalized); - if(mpi_initialized && !mpi_finalized) { - if(H5Pset_fapl_mpio(new_fapl, MPI_COMM_WORLD, MPI_INFO_NULL) < 0) + if (mpi_initialized && !mpi_finalized) { + if (H5Pset_fapl_mpio(fapl_id, MPI_COMM_WORLD, MPI_INFO_NULL) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_mpio failed"); - if(drivernum) - *drivernum = MPIO_IDX; - } /* end if */ - } + } +#else + H5TOOLS_GOTO_ERROR(FAIL, "MPI-I/O VFD is not enabled"); #endif /* H5_HAVE_PARALLEL */ + } + else if (!HDstrcmp(vfd_info->name, drivernames[ROS3_VFD_IDX])) { +#ifdef H5_HAVE_ROS3_VFD + if (!vfd_info->info) + H5TOOLS_GOTO_ERROR(FAIL, "Read-only S3 VFD info is invalid"); + if (H5Pset_fapl_ros3(fapl_id, (H5FD_ros3_fapl_t *)vfd_info->info) < 0) + H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_ros3() failed"); +#else + H5TOOLS_GOTO_ERROR(FAIL, "Read-only S3 VFD is not enabled"); +#endif + } + else if (!HDstrcmp(vfd_info->name, drivernames[HDFS_VFD_IDX])) { +#ifdef H5_HAVE_LIBHDFS + if (!vfd_info->info) + H5TOOLS_GOTO_ERROR(FAIL, "HDFS VFD info is invalid"); + if (H5Pset_fapl_hdfs(fapl_id, (H5FD_hdfs_fapl_t *)vfd_info->info) < 0) + H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_hdfs() failed"); +#else + H5TOOLS_GOTO_ERROR(FAIL, "The HDFS VFD is not enabled"); +#endif + } else - ret_value = -1; + H5TOOLS_GOTO_ERROR(FAIL, "invalid VFD name"); + +done: + return ret_value; +} + +/*------------------------------------------------------------------------- + * Function: h5tools_set_fapl_vol + * + * Purpose: Given a VOL connector name or ID, sets the appropriate + * connector on the specified FAPL. + * + * Return: positive - succeeded + * negative - failed + *------------------------------------------------------------------------- + */ +static herr_t +h5tools_set_fapl_vol(hid_t fapl_id, h5tools_vol_info_t *vol_info) +{ + htri_t connector_is_registered; + hid_t connector_id = H5I_INVALID_HID; + void *connector_info = NULL; + herr_t ret_value = SUCCEED; + + switch (vol_info->type) { + case VOL_BY_NAME: + /* Retrieve VOL connector by name */ + if ((connector_is_registered = H5VLis_connector_registered_by_name(vol_info->u.name)) < 0) + H5TOOLS_GOTO_ERROR(FAIL, "can't check if VOL connector is registered"); + if (connector_is_registered) { + if ((connector_id = H5VLget_connector_id_by_name(vol_info->u.name)) < 0) + H5TOOLS_GOTO_ERROR(FAIL, "can't get VOL connector ID"); + } + else { + /* Check for VOL connectors that ship with the library, then try + * registering by name if that fails. + */ + if (!HDstrcmp(vol_info->u.name, H5VL_NATIVE_NAME)) { + connector_id = H5VL_NATIVE; + } + else if (!HDstrcmp(vol_info->u.name, H5VL_PASSTHRU_NAME)) { + connector_id = H5VL_PASSTHRU; + } + else { + /* NOTE: Not being able to pass in a VIPL may be a limitation for some + * connectors. + */ + if ((connector_id = H5VLregister_connector_by_name(vol_info->u.name, H5P_DEFAULT)) < 0) + H5TOOLS_GOTO_ERROR(FAIL, "can't register VOL connector"); + } + } + + break; + + case VOL_BY_VALUE: + /* Retrieve VOL connector by ID */ + if ((connector_is_registered = H5VLis_connector_registered_by_value(vol_info->u.value)) < 0) + H5TOOLS_GOTO_ERROR(FAIL, "can't check if VOL connector is registered"); + if (connector_is_registered) { + if ((connector_id = H5VLget_connector_id_by_value(vol_info->u.value)) < 0) + H5TOOLS_GOTO_ERROR(FAIL, "can't get VOL connector ID"); + } + else { + /* Check for VOL connectors that ship with the library */ + if (vol_info->u.value == H5VL_NATIVE_VALUE) { + connector_id = H5VL_NATIVE; + } + else if (vol_info->u.value == H5VL_PASSTHRU_VALUE) { + connector_id = H5VL_PASSTHRU; + } + else { + /* NOTE: Not being able to pass in a VIPL may be a limitation for some + * connectors. + */ + if ((connector_id = H5VLregister_connector_by_value(vol_info->u.value, H5P_DEFAULT)) < 0) + H5TOOLS_GOTO_ERROR(FAIL, "can't register VOL connector"); + } + } + + break; + + default: + H5TOOLS_GOTO_ERROR(FAIL, "invalid VOL retrieval type"); + } + + /* Convert the info string, if provided */ + if (vol_info->info_string) + if (H5VLconnector_str_to_info(vol_info->info_string, connector_id, &connector_info) < 0) + H5TOOLS_GOTO_ERROR(FAIL, "can't get VOL connector info from string"); + + /* Set the VOL connector on the fapl */ + if (H5Pset_vol(fapl_id, connector_id, connector_info) < 0) + H5TOOLS_GOTO_ERROR(FAIL, "can't set VOL connector on FAPL"); + +done: + if (connector_info) + if (H5VLfree_connector_info(connector_id, connector_info)) + H5TOOLS_ERROR(FAIL, "failed to free VOL connector-specific info"); + + if (ret_value < 0) { + if (connector_id >= 0 && H5Idec_ref(connector_id) < 0) + H5TOOLS_ERROR(FAIL, "failed to decrement refcount on VOL connector ID"); + } + + return ret_value; +} + +/*------------------------------------------------------------------------- + * Function: h5tools_get_fapl + * + * Purpose: Copies an input fapl and then sets a VOL and/or a VFD on it. + * + * The returned fapl must be closed by the caller. + * + * Return: positive - succeeded + * negative - failed + *------------------------------------------------------------------------- + */ +hid_t +h5tools_get_fapl(hid_t prev_fapl_id, h5tools_vol_info_t *vol_info, + h5tools_vfd_info_t *vfd_info) +{ + hid_t new_fapl_id = H5I_INVALID_HID; + hid_t ret_value = H5I_INVALID_HID; + + if (prev_fapl_id < 0) + H5TOOLS_GOTO_ERROR(FAIL, "invalid FAPL"); + + /* Make a copy of the FAPL or create one if H5P_DEFAULT is specified. */ + if (H5P_DEFAULT == prev_fapl_id) { + if ((new_fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) + H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "H5Pcreate failed"); + } + else { + if ((new_fapl_id = H5Pcopy(prev_fapl_id)) < 0) + H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "H5Pcopy failed"); + } + + /* Set non-default VOL connector, if requested */ + if (vol_info) + if (h5tools_set_fapl_vol(new_fapl_id, vol_info) < 0) + H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "failed to set VOL on FAPL"); + + /* Set non-default virtual file driver, if requested */ + if (vfd_info) + if (h5tools_set_fapl_vfd(new_fapl_id, vfd_info) < 0) + H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "failed to set VFD on FAPL"); + + ret_value = new_fapl_id; done: - if((new_fapl != H5P_DEFAULT) && (ret_value < 0)) { - H5Pclose(new_fapl); - new_fapl = H5I_INVALID_HID; + if ((new_fapl_id >= 0) && (ret_value < 0)) { + H5Pclose(new_fapl_id); + new_fapl_id = H5I_INVALID_HID; } - return(new_fapl); + return ret_value; +} + +/*------------------------------------------------------------------------- + * Function: h5tools_get_vfd_name + * + * Purpose: Given a FAPL, retrieves the name of the VFL driver set on it + * if using a native-terminal VOL connector. If a + * non-native-terminal VOL connector is set on the FAPL, the + * first byte of the returned driver name will be set to the null + * terminator. + * + * Return: SUCCEED/FAIL + *------------------------------------------------------------------------- + */ +herr_t +h5tools_get_vfd_name(hid_t fapl_id, char *drivername, size_t drivername_size) +{ + hid_t fapl_vol_id = H5I_INVALID_HID; + herr_t ret_value = SUCCEED; + + if (fapl_id < 0) + H5TOOLS_GOTO_ERROR(FAIL, "invalid FAPL"); + if (!drivername) + H5TOOLS_GOTO_ERROR(FAIL, "drivername is NULL"); + if (drivername && !drivername_size) + H5TOOLS_GOTO_ERROR(FAIL, "drivername_size must be non-zero"); + + /* Initialize the driver name */ + drivername[0] = '\0'; + + if (fapl_id == H5P_DEFAULT) + fapl_id = H5P_FILE_ACCESS_DEFAULT; + + /* Retrieve ID of the VOL connector set on the FAPL */ + if (H5Pget_vol_id(fapl_id, &fapl_vol_id) < 0) + H5TOOLS_ERROR(FAIL, "failed to retrieve VOL ID from FAPL"); + + /* TODO: For now, we have no way of determining if an arbitrary + * VOL connector is native-terminal. */ + if (fapl_vol_id == H5VL_NATIVE || fapl_vol_id == H5VL_PASSTHRU) { + const char *driver_name; + hid_t driver_id; + + if ((driver_id = H5Pget_driver(fapl_id)) < 0) + H5TOOLS_GOTO_ERROR(FAIL, "failed to retrieve VFL driver ID from FAPL"); + + if (driver_id == H5FD_SEC2) + driver_name = drivernames[SEC2_VFD_IDX]; +#ifdef H5_HAVE_DIRECT + else if (driver_id == H5FD_DIRECT) + driver_name = drivernames[DIRECT_VFD_IDX]; +#endif + else if (driver_id == H5FD_LOG) + driver_name = drivernames[LOG_VFD_IDX]; +#ifdef H5_HAVE_WINDOWS + else if (driver_id == H5FD_WINDOWS) + driver_name = drivernames[WINDOWS_VFD_IDX]; +#endif + else if (driver_id == H5FD_STDIO) + driver_name = drivernames[STDIO_VFD_IDX]; + else if (driver_id == H5FD_CORE) + driver_name = drivernames[CORE_VFD_IDX]; + else if (driver_id == H5FD_FAMILY) + driver_name = drivernames[FAMILY_VFD_IDX]; + else if (driver_id == H5FD_MULTI) + driver_name = drivernames[MULTI_VFD_IDX]; +#ifdef H5_HAVE_PARALLEL + else if (driver_id == H5FD_MPIO) + driver_name = drivernames[MPIO_VFD_IDX]; +#endif +#ifdef H5_HAVE_ROS3_VFD + else if (driver_id == H5FD_ROS3) + driver_name = drivernames[ROS3_VFD_IDX]; +#endif +#ifdef H5_HAVE_LIBHDFS + else if (driver_id == H5FD_HDFS) + driver_name = drivernames[HDFS_VFD_IDX]; +#endif + else + driver_name = "unknown"; + + HDstrncpy(drivername, driver_name, drivername_size); + drivername[drivername_size - 1] = '\0'; + } + +done: + /* Close retrieved VOL ID */ + if (fapl_vol_id >= 0) + if (H5VLclose(fapl_vol_id) < 0) + H5TOOLS_ERROR(FAIL, "failed to close VOL ID"); + + return ret_value; } /*------------------------------------------------------------------------- * Function: h5tools_fopen * - * Purpose: Loop through the various types of VFL drivers trying to open FNAME. - * If the HDF5 library is version 1.2 or less, then we have only the SEC2 - * driver to try out. If the HDF5 library is greater than version 1.2, - * then we have the FAMILY, SPLIT, and MULTI drivers to play with. + * Purpose: Opens file FNAME using the specified flags and FAPL. + * + * The 'use_specific_driver' parameter is used to control the + * VFD/VOL connector that this routine uses to open the file + * with. If 'use_specific_driver' is set to TRUE, this routine + * assumes that the caller has already set a specific VFD or VOL + * connector on the given FAPL and will attempt to directly use + * the FAPL for opening the file. We assume that the caller knows + * what they are doing; if the file is unable to be opened using + * that FAPL, this routine will return H5I_INVALID_HID. * - * If DRIVER is non-NULL, then it will try to open the file with that - * driver first. We assume that the user knows what they are doing so, if - * we fail, then we won't try other file drivers. + * However, if 'use_specific_driver' is set to FALSE, this + * routine assumes that the caller HAS NOT set a specific VFD or + * VOL connector on the given FAPL and will instead loop through + * the various available VFL drivers and VOL connectors trying to + * open FNAME. + * + * The list of available VFL drivers is as follows: + * - If the HDF5 library is version 1.2 or less, then we have + * only the SEC2 driver to try out. + * - If the HDF5 library is greater than version 1.2, then we + * have the FAMILY, SPLIT, and MULTI drivers to play with. + * + * The list of available VOL connectors is as follows: + * - "Native" VOL connector + * - Pass-through VOL connector * * Return: - * On success, returns a file id for the opened file. If DRIVERNAME is - * non-null then the first DRIVERNAME_SIZE-1 characters of the driver - * name are copied into the DRIVERNAME array and null terminated. + * On success, returns a file ID for the opened file. If DRIVERNAME is + * non-null and the native VOL connector is the terminal connector, + * then the first DRIVERNAME_SIZE-1 characters of the driver name are + * copied into the DRIVERNAME array and null terminated. If the + * native VOL connector is NOT the terminal connector, then the first + * byte of DRIVERNAME will be set to the null terminator. * - * Otherwise, the function returns FAIL. If DRIVERNAME is non-null then - * the first byte is set to the null terminator. + * On failure, the function returns H5I_INVALID_HID and DRIVERNAME + * will not be set. *------------------------------------------------------------------------- */ hid_t -h5tools_fopen(const char *fname, unsigned flags, hid_t fapl, const char *driver, +h5tools_fopen(const char *fname, unsigned flags, hid_t fapl_id, hbool_t use_specific_driver, char *drivername, size_t drivername_size) { - unsigned drivernum; - hid_t fid = FAIL; - hid_t my_fapl = H5P_DEFAULT; + hid_t fid = H5I_INVALID_HID; + hid_t tmp_fapl_id = H5I_INVALID_HID; + hid_t used_fapl_id = H5I_INVALID_HID; + unsigned volnum, drivernum; + hid_t ret_value = H5I_INVALID_HID; - if (driver && *driver) { - /* Get the correct FAPL for the given driver */ - if ((my_fapl = h5tools_get_fapl(fapl, driver, &drivernum)) < 0) - goto done; + /* + * First try to open the file using just the given FAPL. If the + * HDF5_VOL_CONNECTOR environment variable has been set, this will + * allow us to attempt to open the file using the specified VOL + * connector before we go looping through all available ones, + * which will override any VOL connector set by use of the + * environment variable. + */ - /* allow error stack display if enable-error-stack has optional arg number */ - if (enable_error_stack > 1) { - fid = H5Fopen(fname, flags, my_fapl); + /* Allow error stack display if --enable-error-stack has optional arg number */ + if (enable_error_stack > 1) { + fid = H5Fopen(fname, flags, fapl_id); + } + else { + H5E_BEGIN_TRY { + fid = H5Fopen(fname, flags, fapl_id); + } H5E_END_TRY; + } + + /* If we succeeded in opening the file, we're done. */ + if (fid >= 0) { + used_fapl_id = fapl_id; + H5TOOLS_GOTO_DONE(fid); + } + + /* + * If we failed to open the file and the caller specified 'use_specific_driver' + * as TRUE, we should return failure now since the file couldn't be opened with + * the VFL driver/VOL connector that was set on the FAPL by the caller. + */ + if (fid < 0 && use_specific_driver) + H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "failed to open file using specified FAPL"); + + /* + * As a final resort, try to open the file using each of the available + * VOL connectors. When the native VOL connector is the current "terminal" + * connector being looked at, also try using each of the available VFL drivers. + */ + for (volnum = 0; volnum < NUM_VOLS; volnum++) { + h5tools_vol_info_t vol_info; + + vol_info.type = VOL_BY_NAME; + vol_info.info_string = NULL; + vol_info.u.name = volnames[volnum]; + + /* TODO: For now, we have no way of determining if an arbitrary + * VOL connector is native-terminal so we only try VFDs with the + * actual native VOL connector. + */ + if (NATIVE_VOL_IDX == volnum) { + /* + * If using the native VOL connector, or a VOL connector which has the + * native connector as its terminal connector, loop through all of the + * VFL drivers as well. + */ + for (drivernum = 0; drivernum < NUM_DRIVERS; drivernum++) { + h5tools_vfd_info_t vfd_info; + + /* Skip the log VFD as it prints out to standard out + * and is fundamentally SEC2 anyway. + */ + if (drivernum == LOG_VFD_IDX) + continue; + + vfd_info.info = NULL; + vfd_info.name = drivernames[drivernum]; + + /* Get a fapl reflecting the selected VOL connector and VFD */ + if ((tmp_fapl_id = h5tools_get_fapl(fapl_id, &vol_info, &vfd_info)) < 0) + continue; + + /* Can we open the file with this combo? */ + if ((fid = h5tools_fopen(fname, flags, tmp_fapl_id, TRUE, drivername, drivername_size)) >= 0) { + used_fapl_id = tmp_fapl_id; + H5TOOLS_GOTO_DONE(fid); + } + else { + /* Close the temporary fapl */ + H5Pclose(tmp_fapl_id); + tmp_fapl_id = H5I_INVALID_HID; + } + } } else { - H5E_BEGIN_TRY { - fid = H5Fopen(fname, flags, my_fapl); - } H5E_END_TRY; - } + /* NOT the native VOL connector */ - if (fid == FAIL) - goto done; + /* Get a FAPL for the current VOL connector */ + if ((tmp_fapl_id = h5tools_get_fapl(fapl_id, &vol_info, NULL)) < 0) + continue; - } - else { - /* Try to open the file using each of the drivers */ - for (drivernum = 0; drivernum < NUM_DRIVERS; drivernum++) { - /* Get the correct FAPL for the given driver */ - if((my_fapl = h5tools_get_fapl(fapl, drivernames[drivernum], NULL)) < 0) - goto done; - - /* allow error stack display if enable-error-stack has optional arg number */ - if (enable_error_stack > 1) { - fid = H5Fopen(fname, flags, my_fapl); + /* Can we open the file with this connector? */ + if ((fid = h5tools_fopen(fname, flags, tmp_fapl_id, TRUE, drivername, drivername_size)) >= 0) { + used_fapl_id = tmp_fapl_id; + H5TOOLS_GOTO_DONE(fid); } else { - H5E_BEGIN_TRY { - fid = H5Fopen(fname, flags, my_fapl); - } H5E_END_TRY; + /* Close the temporary VOL FAPL */ + H5Pclose(tmp_fapl_id); + tmp_fapl_id = H5I_INVALID_HID; } - - if (fid != FAIL) - break; - else { - /* Close the FAPL */ - H5Pclose(my_fapl); - my_fapl = H5P_DEFAULT; - } /* end else */ } } - /* Save the driver name */ - if (drivername && drivername_size) { - if (fid != FAIL) { - HDstrncpy(drivername, drivernames[drivernum], drivername_size); - drivername[drivername_size - 1] = '\0'; - } - else { - /*no file opened*/ - drivername[0] = '\0'; - } - } + /* File was unable to be opened at all */ + ret_value = H5I_INVALID_HID; done: - if(my_fapl != H5P_DEFAULT) - H5Pclose(my_fapl); + /* Save the driver name if using a native-terminal VOL connector */ + if (drivername && drivername_size && ret_value >= 0) + if (used_fapl_id >= 0 && h5tools_get_vfd_name(used_fapl_id, drivername, drivername_size) < 0) + H5TOOLS_ERROR(H5I_INVALID_HID, "failed to retrieve name of VFD used to open file"); + + if (tmp_fapl_id >= 0) + H5Pclose(tmp_fapl_id); - return fid; + return ret_value; } /*------------------------------------------------------------------------- @@ -733,8 +1125,8 @@ done: *------------------------------------------------------------------------- */ void -h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, - h5tools_context_t *ctx, hsize_t elmtno, int secnum) +h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, + hsize_t elmtno, int secnum) { h5tools_str_t prefix; h5tools_str_t str; /*temporary for indentation */ @@ -762,7 +1154,7 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, H5TOOLS_DEBUG("after CR elmtno=%ld, ctx->ndims=%d", elmtno, ctx->ndims); /* Calculate new prefix */ - h5tools_str_prefix(&prefix, info, elmtno, ctx->ndims, ctx); + h5tools_str_prefix(&prefix, info, elmtno, ctx); H5TOOLS_DEBUG("prefix=%s - str=%s", prefix.s, str.s); /* Write new prefix to output */ @@ -829,8 +1221,8 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, *------------------------------------------------------------------------- */ void -h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info, - h5tools_context_t *ctx, hsize_t elmtno, hsize_t *ptdata, int secnum) +h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, + hsize_t elmtno, hsize_t *ptdata, int secnum) { h5tools_str_t prefix; h5tools_str_t str; /*temporary for indentation */ @@ -854,7 +1246,7 @@ h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info, } /* Calculate new prefix */ - h5tools_str_region_prefix(&prefix, info, elmtno, ptdata, ctx->ndims, ctx->p_max_idx, ctx); + h5tools_str_region_prefix(&prefix, info, elmtno, ptdata, ctx); /* Write new prefix to output */ if (ctx->indent_level > 0) @@ -927,9 +1319,8 @@ h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info, *------------------------------------------------------------------------- */ hbool_t -h5tools_render_element(FILE *stream, const h5tool_format_t *info, - h5tools_context_t *ctx, h5tools_str_t *buffer, hsize_t *curr_pos, - size_t ncols, hsize_t local_elmt_counter, hsize_t elmt_counter) +h5tools_render_element(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, + h5tools_str_t *buffer, hsize_t *curr_pos, size_t ncols, hsize_t local_elmt_counter, hsize_t elmt_counter) { hbool_t dimension_break = TRUE; char *s = NULL; @@ -1098,9 +1489,8 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info, *------------------------------------------------------------------------- */ hbool_t -h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, - h5tools_context_t *ctx, h5tools_str_t *buffer, hsize_t *curr_pos, - size_t ncols, hsize_t *ptdata, hsize_t local_elmt_counter, hsize_t elmt_counter) +h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, + h5tools_str_t *buffer, hsize_t *curr_pos, size_t ncols, hsize_t *ptdata, hsize_t local_elmt_counter, hsize_t elmt_counter) { hbool_t dimension_break = TRUE; char *s = NULL; @@ -1117,8 +1507,10 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, * If the element would split on multiple lines if printed at our * current location... */ - if (info->line_multi_new == 1 && (ctx->cur_column + h5tools_count_ncols(s) + - HDstrlen(OPT(info->elmt_suf2, " ")) + HDstrlen(OPT(info->line_suf, ""))) > ncols) { + if (info->line_multi_new == 1 && + (ctx->cur_column + h5tools_count_ncols(s) + + HDstrlen(OPT(info->elmt_suf2, " ")) + + HDstrlen(OPT(info->line_suf, ""))) > ncols) { if (ctx->prev_multiline) { /* * ... and the previous element also occupied more than one @@ -1127,7 +1519,8 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, ctx->need_prefix = TRUE; } else if ((ctx->prev_prefix_len + h5tools_count_ncols(s) + - HDstrlen(OPT(info->elmt_suf2, " ")) + HDstrlen(OPT(info->line_suf, ""))) <= ncols) { + HDstrlen(OPT(info->elmt_suf2, " ")) + + HDstrlen(OPT(info->line_suf, ""))) <= ncols) { /* * ...but *could* fit on one line otherwise, then we * should end the current line and start this element on its @@ -1158,7 +1551,9 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, * beginning of the line. */ if (info->line_multi_new == 1 && ctx->prev_multiline && - (ctx->cur_column + h5tools_count_ncols(s) + HDstrlen(OPT(info->elmt_suf2, " ")) + HDstrlen(OPT(info->line_suf, ""))) > ncols) + (ctx->cur_column + h5tools_count_ncols(s) + + HDstrlen(OPT(info->elmt_suf2, " ")) + + HDstrlen(OPT(info->line_suf, ""))) > ncols) ctx->need_prefix = TRUE; /* @@ -1186,7 +1581,9 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, * this check to happen for the first line */ if ((!info->skip_first || local_elmt_counter) && - (ctx->cur_column + HDstrlen(section) + HDstrlen(OPT(info->elmt_suf2, " ")) + HDstrlen(OPT(info->line_suf, ""))) > ncols) + (ctx->cur_column + HDstrlen(section) + + HDstrlen(OPT(info->elmt_suf2, " ")) + + HDstrlen(OPT(info->line_suf, ""))) > ncols) ctx->need_prefix = 1; /* @@ -1232,24 +1629,62 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, *------------------------------------------------------------------------- */ void -init_acc_pos(h5tools_context_t *ctx, hsize_t *dims) +init_acc_pos(unsigned ndims, hsize_t *dims, hsize_t *acc, hsize_t *pos, hsize_t *p_min_idx) { int i; unsigned j; H5TOOLS_START_DEBUG(""); - if(ctx->ndims > 0) { - ctx->acc[ctx->ndims - 1] = 1; - for (i = ((int)ctx->ndims - 2); i >= 0; i--) { - ctx->acc[i] = ctx->acc[i + 1] * dims[i + 1]; - H5TOOLS_DEBUG("ctx->acc[%d]=%ld", i, ctx->acc[i]); + for (i = 0; (unsigned)i < ndims; i++) + p_min_idx[i] = 0; + + if(ndims > 0) { + acc[ndims - 1] = 1; + for (i = ((int)ndims - 2); i >= 0; i--) { + acc[i] = acc[i + 1] * dims[i + 1]; + H5TOOLS_DEBUG("acc[%d]=%ld", i, acc[i]); + } + for (j = 0; j < ndims; j++) + pos[j] = 0; + } + + H5TOOLS_ENDDEBUG(""); +} + +/*------------------------------------------------------------------------- + * Function: calc_acc_pos + * + * Purpose: Calculate the number of elements represented by a unit change + * in a certain index position. + * + * Return: void + *------------------------------------------------------------------------- + */ +hsize_t +calc_acc_pos(unsigned ndims, hsize_t elmtno, hsize_t *acc, hsize_t *pos) +{ + int i; + hsize_t curr_pos = elmtno; + + H5TOOLS_START_DEBUG(""); + + if(ndims > 0) { + for(i = 0; i < (int)ndims; i++) { + if(curr_pos > 0) { + H5TOOLS_DEBUG("curr_pos=%ld - ctx->acc[%d]=%ld", curr_pos, i, acc[i]); + pos[i] = curr_pos / acc[i]; + curr_pos -= acc[i] * pos[i]; + } + else + pos[i] = 0; + H5TOOLS_DEBUG("curr_pos=%ld - pos[%d]=%ld - acc[%d]=%ld", curr_pos, i, pos[i], i, acc[i]); } - for (j = 0; j < ctx->ndims; j++) - ctx->pos[j] = 0; } H5TOOLS_ENDDEBUG(""); + + return curr_pos; } /*------------------------------------------------------------------------- @@ -1436,10 +1871,10 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t for (block_index = 0; block_index < block_nelmts; block_index++) { mem = ((unsigned char*)_mem) + block_index * size; - if((region_id = H5Ropen_object((const H5R_ref_t *)mem, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if((region_id = H5Ropen_object((H5R_ref_t *)mem, H5P_DEFAULT, H5P_DEFAULT)) < 0) H5TOOLS_INFO("H5Ropen_object H5T_STD_REF failed"); else { - if((region_space = H5Ropen_region((const H5R_ref_t *)mem, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if((region_space = H5Ropen_region((H5R_ref_t *)mem, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { if (!h5tools_is_zero(mem, H5Tget_size(H5T_STD_REF))) { region_type = H5Sget_select_type(region_space); if(region_type == H5S_SEL_POINTS) diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h index 9440e7a..152ec1a 100644 --- a/tools/lib/h5tools.h +++ b/tools/lib/h5tools.h @@ -539,20 +539,83 @@ typedef struct h5tools_context_t { int display_char; /* */ } h5tools_context_t; +/* VOL and VFD info structs used to set the file access property + * lists in the tools. + */ + +typedef enum { + VOL_BY_NAME, + VOL_BY_VALUE +} h5tools_vol_info_type_t; + +typedef struct h5tools_vol_info_t { + h5tools_vol_info_type_t type; + + /* Pointer to information string to be passed to the connector for its setup */ + const char *info_string; + + /* Field specifying either the connector's name or value (ID) */ + union { + const char *name; + H5VL_class_value_t value; + } u; +} h5tools_vol_info_t; + +typedef struct h5tools_vfd_info_t { + + /* Pointer to information to be passed to the driver for its setup */ + const void *info; + + /* Name of the VFD */ + const char *name; +} h5tools_vfd_info_t; + +/* This enum should match the entries in the above 'volnames' + * since they are indices into the 'volnames' array. */ +typedef enum { + NATIVE_VOL_IDX = 0, + PASS_THROUGH_VOL_IDX, +} vol_idx; + +/* This enum should match the entries in the above 'drivernames' + * since they are indices into the 'drivernames' array. */ +typedef enum { + SEC2_VFD_IDX = 0, + DIRECT_VFD_IDX, + LOG_VFD_IDX, + WINDOWS_VFD_IDX, + STDIO_VFD_IDX, + CORE_VFD_IDX, + FAMILY_VFD_IDX, + SPLIT_VFD_IDX, + MULTI_VFD_IDX, + MPIO_VFD_IDX, + ROS3_VFD_IDX, + HDFS_VFD_IDX, +} driver_idx; + /* 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" -H5TOOLS_DLLVAR h5tool_format_t h5tools_dataformat; -H5TOOLS_DLLVAR const h5tools_dump_header_t h5tools_standardformat; -H5TOOLS_DLLVAR const h5tools_dump_header_t* h5tools_dump_header_format; #ifdef __cplusplus extern "C" { #endif +H5TOOLS_DLLVAR const char *volnames[]; +H5TOOLS_DLLVAR const char *drivernames[]; + +H5TOOLS_DLLVAR h5tool_format_t h5tools_dataformat; +H5TOOLS_DLLVAR const h5tools_dump_header_t h5tools_standardformat; +H5TOOLS_DLLVAR const h5tools_dump_header_t* h5tools_dump_header_format; +H5TOOLS_DLLVAR H5E_auto2_t lib_func; +H5TOOLS_DLLVAR H5E_auto2_t tools_func; +H5TOOLS_DLLVAR void *lib_edata; +H5TOOLS_DLLVAR void *tools_edata; + H5TOOLS_DLLVAR unsigned packed_bits_num; /* number of packed bits to display */ H5TOOLS_DLLVAR unsigned packed_data_offset; /* offset of packed bits to display */ H5TOOLS_DLLVAR unsigned packed_data_length; /* length of packed bits to display */ @@ -586,48 +649,47 @@ H5TOOLS_DLLVAR int enable_error_stack; /* re-enable error stack; disable=0 e /* Definitions of useful routines */ H5TOOLS_DLL void h5tools_init(void); H5TOOLS_DLL void h5tools_close(void); + +H5TOOLS_DLL void h5tools_error_report(void); H5TOOLS_DLL int h5tools_set_data_output_file(const char *fname, int is_bin); H5TOOLS_DLL int h5tools_set_attr_output_file(const char *fname, int is_bin); H5TOOLS_DLL int h5tools_set_input_file(const char *fname, int is_bin); H5TOOLS_DLL int h5tools_set_output_file(const char *fname, int is_bin); H5TOOLS_DLL int h5tools_set_error_file(const char *fname, int is_bin); + +H5TOOLS_DLL hid_t h5tools_get_fapl(hid_t prev_fapl_id, h5tools_vol_info_t *vol_info, h5tools_vfd_info_t *vfd_info); +H5TOOLS_DLL herr_t h5tools_get_vfd_name(hid_t fapl_id, + char *drivername, size_t drivername_size); H5TOOLS_DLL hid_t h5tools_fopen(const char *fname, unsigned flags, hid_t fapl, - const char *driver, char *drivername, size_t drivername_len); + hbool_t use_specific_driver, char *drivername, size_t drivername_size); H5TOOLS_DLL hid_t h5tools_get_little_endian_type(hid_t type); H5TOOLS_DLL hid_t h5tools_get_big_endian_type(hid_t type); H5TOOLS_DLL htri_t h5tools_detect_vlen(hid_t tid); H5TOOLS_DLL htri_t h5tools_detect_vlen_str(hid_t tid); H5TOOLS_DLL hbool_t h5tools_is_obj_same(hid_t loc_id1, const char *name1, hid_t loc_id2, const char *name2); -H5TOOLS_DLL void init_acc_pos(h5tools_context_t *ctx, hsize_t *dims); +H5TOOLS_DLL void init_acc_pos(unsigned ndims, hsize_t *dims, hsize_t *acc, hsize_t *pos, hsize_t *p_min_idx); +H5TOOLS_DLL hsize_t calc_acc_pos(unsigned ndims, hsize_t elemtno, hsize_t *acc, hsize_t *pos); H5TOOLS_DLL hbool_t h5tools_is_zero(const void *_mem, size_t size); H5TOOLS_DLL int h5tools_canreadf(const char* name, hid_t dcpl_id); H5TOOLS_DLL int h5tools_can_encode(H5Z_filter_t filtn); -H5TOOLS_DLL void h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, - h5tools_context_t *ctx, hsize_t elmtno, int secnum); -H5TOOLS_DLL void h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info, - h5tools_context_t *ctx, hsize_t elmtno, hsize_t *ptdata, int secnum); +H5TOOLS_DLL void h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, + hsize_t elmtno, int secnum); +H5TOOLS_DLL void h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, + hsize_t elmtno, hsize_t *ptdata, int secnum); H5TOOLS_DLL int render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t nelmts); -H5TOOLS_DLL int render_bin_output_region_data_blocks(hid_t region_id, FILE *stream, - hid_t container, unsigned ndims, hid_t type_id, hsize_t nblocks, hsize_t *ptdata); -H5TOOLS_DLL hbool_t render_bin_output_region_blocks(hid_t region_space, hid_t region_id, - FILE *stream, hid_t container); -H5TOOLS_DLL int render_bin_output_region_data_points(hid_t region_space, hid_t region_id, - FILE* stream, hid_t container, unsigned ndims, hid_t type_id, hsize_t npoints); -H5TOOLS_DLL hbool_t render_bin_output_region_points(hid_t region_space, hid_t region_id, - FILE *stream, hid_t container); - -H5TOOLS_DLL hbool_t h5tools_render_element(FILE *stream, const h5tool_format_t *info, - h5tools_context_t *ctx, h5tools_str_t *buffer, hsize_t *curr_pos, - size_t ncols, hsize_t local_elmt_counter, hsize_t elmt_counter); -H5TOOLS_DLL hbool_t h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, - h5tools_context_t *ctx, /*in,out*/ - h5tools_str_t *buffer, /*string into which to render */ - hsize_t *curr_pos, /*total data element position*/ - size_t ncols, hsize_t *ptdata, - hsize_t local_elmt_counter, /*element counter*/ - hsize_t elmt_counter); +H5TOOLS_DLL int render_bin_output_region_data_blocks(hid_t region_id, FILE *stream, hid_t container, + unsigned ndims, hid_t type_id, hsize_t nblocks, hsize_t *ptdata); +H5TOOLS_DLL hbool_t render_bin_output_region_blocks(hid_t region_space, hid_t region_id, FILE *stream, hid_t container); +H5TOOLS_DLL int render_bin_output_region_data_points(hid_t region_space, hid_t region_id, FILE* stream, hid_t container, + unsigned ndims, hid_t type_id, hsize_t npoints); +H5TOOLS_DLL hbool_t render_bin_output_region_points(hid_t region_space, hid_t region_id, FILE *stream, hid_t container); + +H5TOOLS_DLL hbool_t h5tools_render_element(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, h5tools_str_t *buffer, + hsize_t *curr_pos, size_t ncols, hsize_t local_elmt_counter, hsize_t elmt_counter); +H5TOOLS_DLL hbool_t h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, h5tools_str_t *buffer, + hsize_t *curr_pos, size_t ncols, hsize_t *ptdata, hsize_t local_elmt_counter, hsize_t elmt_counter); #ifdef __cplusplus } diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c index 3cca910..b1be577 100644 --- a/tools/lib/h5tools_dump.c +++ b/tools/lib/h5tools_dump.c @@ -253,9 +253,8 @@ h5tools_dump_init(void) *------------------------------------------------------------------------- */ int -h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t container, - h5tools_context_t *ctx, /* in,out */ - unsigned flags, hsize_t nelmts, hid_t type, void *_mem) +h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, /* in,out */ + hid_t container, unsigned flags, hsize_t nelmts, hid_t type, void *_mem) { unsigned char *mem = (unsigned char*) _mem; hsize_t i; /* element counter */ @@ -568,9 +567,11 @@ h5tools_print_region_data_blocks(hid_t region_id, FILE *stream, const h5tool_for ctx.indent_level++; if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) >= 0) { /* assume entire data space to be printed */ + init_acc_pos(ctx.ndims, total_size, ctx.acc, ctx.pos, ctx.p_min_idx); + + /* reset data space to be printed */ for (indx = 0; indx < (unsigned)ctx.ndims; indx++) ctx.p_min_idx[indx] = start[indx]; - init_acc_pos(&ctx, total_size); /* print the data */ region_flags = START_OF_DATA; @@ -939,9 +940,7 @@ h5tools_print_region_data_points(hid_t region_space, hid_t region_id, if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) >= 0) { /* assume entire data space to be printed */ - for (indx = 0; indx < ctx.ndims; indx++) - ctx.p_min_idx[indx] = 0; - init_acc_pos(&ctx, total_size); + init_acc_pos(ctx.ndims, total_size, ctx.acc, ctx.pos, ctx.p_min_idx); /* print the data */ region_flags = START_OF_DATA; @@ -1253,7 +1252,6 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c size_t j; /* counters */ hsize_t zero[1] = {0}; /* vector of zeros */ unsigned int flags; /* buffer extent flags */ - hsize_t elmtno; /* elemnt index */ hsize_t low[H5S_MAX_RANK]; /* low bound of hyperslab */ hsize_t high[H5S_MAX_RANK]; /* higher bound of hyperslab */ size_t p_type_nbytes; /* size of memory type */ @@ -1274,9 +1272,6 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c if ((size_t) ctx->ndims > NELMTS(sm_size)) H5TOOLS_THROW(FAIL, "ndims and sm_size comparision failed"); - if (ctx->ndims > 0) - init_acc_pos(ctx, total_size); - size_row_block = ctx->sset->block.data[row_dim]; /* Check if we have VL data in the dataset's datatype */ @@ -1347,27 +1342,25 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c for (i = 0; i < ctx->ndims; i++) ctx->p_max_idx[i] = ctx->p_min_idx[i] + MIN(total_size[i], sm_size[i]); - /* print array indices. get the lower bound of the hyperslab and calulate - the element position at the start of hyperslab */ + /* print array indices. get the lower bound of the hyperslab and calculate + the element position at the start of hyperslab */ if(H5Sget_select_bounds(f_space, low, high) < 0) H5TOOLS_THROW(FAIL, "H5Sget_select_bounds failed"); - elmtno = 0; + /* initialize the current stripmine position; this is necessary to print the array indices */ + ctx->sm_pos = 0; for (i = 0; i < (size_t) ctx->ndims - 1; i++) { hsize_t offset = 1; /* accumulation of the previous dimensions */ for (j = i + 1; j < (size_t) ctx->ndims; j++) offset *= total_size[j]; - elmtno += low[i] * offset; + ctx->sm_pos += low[i] * offset; } - elmtno += low[ctx->ndims - 1]; + ctx->sm_pos += low[ctx->ndims - 1]; - /* initialize the current stripmine position; this is necessary to print the array - indices */ - ctx->sm_pos = elmtno; ctx->need_prefix = TRUE; - if(h5tools_dump_simple_data(stream, info, dset, ctx, flags, sm_nelmts, p_type, sm_buf) < 0) + if(h5tools_dump_simple_data(stream, info, ctx, dset, flags, sm_nelmts, p_type, sm_buf) < 0) H5TOOLS_THROW(FAIL, "h5tools_dump_simple_data failed"); /* Reclaim any VL memory, if necessary */ @@ -1571,9 +1564,8 @@ static herr_t h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t dset, hid_t p_type) { int sndims; - hid_t f_space = H5I_INVALID_HID; /* file data space */ - size_t i; /* counters */ - hsize_t total_size[H5S_MAX_RANK];/* total size of dataset*/ + hid_t f_space = H5I_INVALID_HID; /* file data space */ + hsize_t total_size[H5S_MAX_RANK]; /* total size of dataset*/ hbool_t past_catch = FALSE; herr_t ret_value = SUCCEED; @@ -1586,12 +1578,10 @@ h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_co ctx->ndims = (unsigned)sndims; /* assume entire data space to be printed */ - if (ctx->ndims > 0) - for (i = 0; i < (size_t) ctx->ndims; i++) - ctx->p_min_idx[i] = 0; - if(H5Sget_simple_extent_dims(f_space, total_size, NULL) < 0) H5TOOLS_THROW(FAIL, "H5Sget_simple_extent_dims failed"); + init_acc_pos(ctx->ndims, total_size, ctx->acc, ctx->pos, ctx->p_min_idx); + ctx->size_last_dim = total_size[ctx->ndims - 1]; /* Set the compound datatype field list for display */ @@ -1623,38 +1613,37 @@ CATCH *------------------------------------------------------------------------- */ static int -h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, - hid_t dset, hid_t p_type) +h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t dset, hid_t p_type) { - hid_t f_space = H5I_INVALID_HID; /* file data space */ - hsize_t elmtno; /* counter */ - size_t i; /* counter */ - int sndims; /* rank of dataspace */ - int carry; /* counter carry value */ - hsize_t zero[8]; /* vector of zeros */ - unsigned int flags; /* buffer extent flags */ - hsize_t total_size[H5S_MAX_RANK]; /* total size of dataset*/ - hbool_t past_catch = FALSE; + hid_t f_space = H5I_INVALID_HID; /* file data space */ + hsize_t elmtno; /* counter */ + size_t i = 0; /* counter */ + int sndims; /* rank of dataspace */ + int carry; /* counter carry value */ + hsize_t zero[8]; /* vector of zeros */ + unsigned int flags; /* buffer extent flags */ + hsize_t total_size[H5S_MAX_RANK]; /* total size of dataset*/ + hbool_t past_catch = FALSE; /* Print info */ - size_t p_type_nbytes; /* size of memory type */ - hsize_t p_nelmts; /* total selected elmts */ + size_t p_type_nbytes; /* size of memory type */ + hsize_t p_nelmts; /* total selected elmts */ /* Stripmine info */ - hsize_t sm_size[H5S_MAX_RANK]; /* stripmine size */ - hsize_t sm_nbytes; /* bytes per stripmine */ - hsize_t sm_nelmts; /* elements per stripmine*/ - unsigned char *sm_buf = NULL; /* buffer for raw data */ - hid_t sm_space = H5I_INVALID_HID; /* stripmine data space */ + hsize_t sm_size[H5S_MAX_RANK]; /* stripmine size */ + hsize_t sm_nbytes; /* bytes per stripmine */ + hsize_t sm_nelmts; /* elements per stripmine*/ + unsigned char *sm_buf = NULL; /* buffer for raw data */ + hid_t sm_space = H5I_INVALID_HID; /* stripmine data space */ /* Hyperslab info */ - hsize_t hs_offset[H5S_MAX_RANK]; /* starting offset */ - hsize_t hs_size[H5S_MAX_RANK]; /* size this pass */ - hsize_t hs_nelmts; /* elements in request */ + hsize_t hs_offset[H5S_MAX_RANK]; /* starting offset */ + hsize_t hs_size[H5S_MAX_RANK]; /* size this pass */ + hsize_t hs_nelmts; /* elements in request */ /* VL data special information */ - unsigned int vl_data = 0; /* contains VL datatypes */ - int ret_value = 0; + unsigned int vl_data = 0; /* contains VL datatypes */ + int ret_value = 0; H5TOOLS_START_DEBUG(""); if (H5I_INVALID_HID == (f_space = H5Dget_space(dset))) @@ -1670,11 +1659,8 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont H5TOOLS_GOTO_ERROR((-1), "ctx->ndims > NELMTS(sm_size) failed"); /* Assume entire data space to be printed */ - if (ctx->ndims > 0) - for (i = 0; i < (size_t)ctx->ndims; i++) - ctx->p_min_idx[i] = 0; - H5Sget_simple_extent_dims(f_space, total_size, NULL); + init_acc_pos(ctx->ndims, total_size, ctx->acc, ctx->pos, ctx->p_min_idx); /* calculate the number of elements we're going to print */ p_nelmts = 1; @@ -1720,8 +1706,6 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont sm_space = H5Screate_simple(1, &sm_nelmts, NULL); H5TOOLS_DEBUG("sm_nelmts size:%ld", sm_nelmts); - if (ctx->ndims > 0) - init_acc_pos(ctx, total_size); H5TOOLS_DEBUG("ctx->ndims:%d", ctx->ndims); /* The stripmine loop */ @@ -1762,7 +1746,7 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont indices */ ctx->sm_pos = elmtno; - if(h5tools_dump_simple_data(stream, info, dset, ctx, flags, hs_nelmts, p_type, sm_buf) < 0) + if(h5tools_dump_simple_data(stream, info, ctx, dset, flags, hs_nelmts, p_type, sm_buf) < 0) H5TOOLS_ERROR((-1), "h5tools_dump_simple_data failed"); /* Reclaim any VL memory, if necessary */ @@ -1841,11 +1825,8 @@ h5tools_dump_simple_mem(FILE *stream, const h5tool_format_t *info, h5tools_conte H5TOOLS_THROW((-1), "ctx->ndims > NELMTS(ctx->p_min_idx) failed"); /* Assume entire data space to be printed */ - if (ctx->ndims > 0) - for (i = 0; i < (size_t)ctx->ndims; i++) - ctx->p_min_idx[i] = 0; - H5Sget_simple_extent_dims(f_space, total_size, NULL); + init_acc_pos(ctx->ndims, total_size, ctx->acc, ctx->pos, ctx->p_min_idx); /* calculate the number of elements we're going to print */ p_nelmts = 1; @@ -1868,14 +1849,12 @@ h5tools_dump_simple_mem(FILE *stream, const h5tool_format_t *info, h5tools_conte alloc_size = p_nelmts * H5Tget_size(p_type); HDassert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/ if (NULL != (buf = (unsigned char *)HDmalloc((size_t)alloc_size))) { - if (ctx->ndims > 0) - init_acc_pos(ctx, total_size); H5TOOLS_DEBUG("ctx->ndims:%d", ctx->ndims); H5TOOLS_DEBUG("Read the data"); /* Read the data */ if (H5Aread(attr_id, p_type, buf) >= 0) { - if(h5tools_dump_simple_data(stream, info, attr_id, ctx, START_OF_DATA | END_OF_DATA, p_nelmts, p_type, buf) < 0) + if(h5tools_dump_simple_data(stream, info, ctx, attr_id, START_OF_DATA | END_OF_DATA, p_nelmts, p_type, buf) < 0) H5TOOLS_ERROR((-1), "h5tools_dump_simple_data failed"); /* Reclaim any VL memory, if necessary */ @@ -2099,11 +2078,11 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ if(obj) { if(!obj->recorded) { - char *obj_addr_str = NULL; + char *obj_tok_str = NULL; - H5Otoken_to_str(type, &oinfo.token, &obj_addr_str); - h5tools_str_append(buffer,"\"/#%s\"", obj_addr_str); - H5free_memory(obj_addr_str); + H5Otoken_to_str(type, &oinfo.token, &obj_tok_str); + h5tools_str_append(buffer,"\"/#%s\"", obj_tok_str); + H5free_memory(obj_tok_str); } else h5tools_str_append(buffer, "\"%s\"", obj->objname); @@ -3110,7 +3089,7 @@ h5tools_print_fill_value(h5tools_str_t *buffer/*in,out*/, const h5tool_format_t */ void h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, - h5tools_context_t *ctx, hid_t dcpl_id, hid_t type_id, hid_t obj_id) + h5tools_context_t *ctx, hid_t dcpl_id, hid_t type_id, hid_t dset_id) { int nfilters; /* number of filters */ int rank; /* rank */ @@ -3141,7 +3120,7 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, if (info->line_ncols > 0) ncols = info->line_ncols; - storage_size = H5Dget_storage_size(obj_id); + storage_size = H5Dget_storage_size(dset_id); nfilters = H5Pget_nfilters(dcpl_id); HDstrcpy(f_name,"\0"); @@ -3182,8 +3161,8 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, double ratio = 0; int ok = 0; - hid_t tid = H5Dget_type(obj_id); - hid_t sid = H5Dget_space(obj_id); + hid_t tid = H5Dget_type(dset_id); + hid_t sid = H5Dget_space(dset_id); size_t datum_size = H5Tget_size(tid); int ndims = H5Sget_simple_extent_dims(sid, dims, NULL); @@ -3241,16 +3220,15 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, break; case H5D_CONTIGUOUS: { - int next; + int n_external; - next = H5Pget_external_count(dcpl_id); + n_external = H5Pget_external_count(dcpl_id); - /*------------------------------------------------------------------------- - * EXTERNAL_FILE - *------------------------------------------------------------------------- - */ ctx->indent_level++; - if (next) { + if (n_external) { + + /* EXTERNAL FILE */ + ctx->need_prefix = TRUE; h5tools_str_reset(&buffer); @@ -3264,7 +3242,7 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0); ctx->indent_level++; - for (j = 0; j < (unsigned) next; j++) { + for (j = 0; j < (unsigned) n_external; j++) { H5Pget_external(dcpl_id, j, sizeof(name), name, &offset, &size); ctx->need_prefix = TRUE; @@ -3284,6 +3262,9 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, } else { haddr_t ioffset; + hbool_t supported = FALSE; + + /* NORMAL FILE */ ctx->need_prefix = TRUE; @@ -3297,12 +3278,23 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, h5tools_str_append(&buffer,"SIZE " HSIZE_T_FORMAT, storage_size); h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0); - ctx->need_prefix = TRUE; + /* Only dump the offset if the VOL connector implements + * the functionality. + */ + H5VLquery_optional(dset_id, H5VL_SUBCLS_DATASET, H5VL_NATIVE_DATASET_GET_OFFSET, &supported); - h5tools_str_reset(&buffer); - ioffset = H5Dget_offset(obj_id); - h5tools_str_append(&buffer, "OFFSET "H5_PRINTF_HADDR_FMT, ioffset); - h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0); + if (supported) { + + ctx->need_prefix = TRUE; + + h5tools_str_reset(&buffer); + ioffset = H5Dget_offset(dset_id); + if (HADDR_UNDEF == ioffset) + h5tools_str_append(&buffer, "OFFSET HADDR_UNDEF"); + else + h5tools_str_append(&buffer, "OFFSET "H5_PRINTF_HADDR_FMT, ioffset); + h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0); + } } ctx->indent_level--; } @@ -3311,23 +3303,23 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, case H5D_VIRTUAL: { char dsetname[256]; /* virtual datset name */ - size_t vmaps; + size_t n_vmaps; - H5Pget_virtual_count(dcpl_id, &vmaps); + H5Pget_virtual_count(dcpl_id, &n_vmaps); - if (vmaps) { - size_t next; + if (n_vmaps) { + size_t curr_vmap; ssize_t H5_ATTR_NDEBUG_UNUSED ssize_out; ctx->indent_level++; - for (next = 0; next < (unsigned) vmaps; next++) { - hid_t virtual_vspace = H5Pget_virtual_vspace(dcpl_id, next); - hid_t virtual_srcspace = H5Pget_virtual_srcspace(dcpl_id, next); + for (curr_vmap = 0; curr_vmap < n_vmaps; curr_vmap++) { + hid_t virtual_vspace = H5Pget_virtual_vspace(dcpl_id, curr_vmap); + hid_t virtual_srcspace = H5Pget_virtual_srcspace(dcpl_id, curr_vmap); ctx->need_prefix = TRUE; h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s %ld %s ", VDS_MAPPING, next, BEGIN); + h5tools_str_append(&buffer, "%s %ld %s ", VDS_MAPPING, curr_vmap, BEGIN); h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0); ctx->indent_level++; @@ -3358,14 +3350,14 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, ctx->indent_level++; - ssize_out = H5Pget_virtual_filename(dcpl_id, next, NULL, 0); + ssize_out = H5Pget_virtual_filename(dcpl_id, curr_vmap, NULL, 0); HDassert(ssize_out > 0); HDassert((size_t)ssize_out < sizeof(name)); - H5Pget_virtual_filename(dcpl_id, next, name, sizeof(name)); - ssize_out = H5Pget_virtual_dsetname(dcpl_id, next, NULL, 0); + H5Pget_virtual_filename(dcpl_id, curr_vmap, name, sizeof(name)); + ssize_out = H5Pget_virtual_dsetname(dcpl_id, curr_vmap, NULL, 0); HDassert(ssize_out > 0); HDassert((size_t)ssize_out < sizeof(name)); - H5Pget_virtual_dsetname(dcpl_id, next, dsetname, sizeof(dsetname)); + H5Pget_virtual_dsetname(dcpl_id, curr_vmap, dsetname, sizeof(dsetname)); ctx->need_prefix = TRUE; @@ -3629,7 +3621,7 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, break; case H5D_FILL_VALUE_USER_DEFINED: ctx->indent_level--; - h5tools_print_fill_value(&buffer, info, ctx, dcpl_id, type_id, obj_id); + h5tools_print_fill_value(&buffer, info, ctx, dcpl_id, type_id, dset_id); ctx->indent_level++; break; case H5D_FILL_VALUE_ERROR: @@ -3714,6 +3706,13 @@ h5tools_dump_comment(FILE *stream, const h5tool_format_t *info, h5tools_context_ * instead of the current stripmine position i; this is necessary * to print the array indices */ + hbool_t supported = FALSE; + + /* Check if comments are supported and return if not */ + H5VLquery_optional(obj_id, H5VL_SUBCLS_OBJECT, H5VL_NATIVE_OBJECT_GET_COMMENT, &supported); + + if (!supported) + return; /* setup */ HDmemset(&buffer, 0, sizeof(h5tools_str_t)); @@ -3723,8 +3722,7 @@ h5tools_dump_comment(FILE *stream, const h5tool_format_t *info, h5tools_context_ cmt_bufsize = H5Oget_comment(obj_id, comment, buf_size); - /* call H5Oget_comment again with the correct value. - * If the call to H5Oget_comment returned an error, skip this block */ + /* call H5Oget_comment again with the correct value */ if (cmt_bufsize > 0) { comment = (char *)HDmalloc((size_t)(cmt_bufsize+1)); /* new_size including null terminator */ if(comment) { @@ -3739,7 +3737,7 @@ h5tools_dump_comment(FILE *stream, const h5tool_format_t *info, h5tools_context_ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); h5tools_str_close(&buffer); - } /* end if */ + } HDfree(comment); } } @@ -3968,6 +3966,226 @@ h5tools_dump_subsetting_header(FILE *stream, const h5tool_format_t *info, h5tool } /*------------------------------------------------------------------------- + * Function: dump_reference + * + * Purpose: Dump reference data + * + * Return: void + *------------------------------------------------------------------------- + */ +void +h5tools_dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t container, H5R_ref_t *ref_buf, int ndims) +{ + hid_t new_obj_id = H5I_INVALID_HID; + hid_t new_obj_sid = H5I_INVALID_HID; + hsize_t elmt_counter = 0; /*counts the # elements printed. */ + size_t ncols = 80; /* available output width */ + int i; + hsize_t curr_pos = 0; /* total data element position */ + h5tools_str_t buffer; /* string into which to render */ + h5tools_context_t datactx; /* print context */ + + H5TOOLS_START_DEBUG(""); + + datactx = *ctx; /* print context */ + /* Assume entire data space to be printed */ + datactx.need_prefix = TRUE; + + HDmemset(&buffer, 0, sizeof(h5tools_str_t)); + for(i = 0; i < ndims; i++, datactx.cur_elmt++, elmt_counter++) { + H5O_type_t obj_type = -1; /* Object type */ + H5R_type_t ref_type; /* Reference type */ + + H5TOOLS_DEBUG("reference loop:%d with curr_pos=%ld", i, curr_pos); + + datactx.need_prefix = TRUE; + h5tools_str_reset(&buffer); + H5TOOLS_DEBUG("reference loop - h5tools_str_sprint with H5T_STD_REF:%d", i); + h5tools_str_sprint(&buffer, info, container, H5T_STD_REF, &ref_buf[i], &datactx); + h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)i, (hsize_t)ndims); + + ref_type = H5Rget_type((const H5R_ref_t *)&ref_buf[i]); + switch (ref_type) { + case H5R_OBJECT1: + H5TOOLS_DEBUG("ref_type is H5R_OBJECT1"); + if (H5Rget_obj_type3(&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) { + switch (obj_type) { + case H5O_TYPE_DATASET: + if((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + datactx.indent_level++; + h5tools_dump_data(stream, info, &datactx, new_obj_id, TRUE); + //h5tools_dump_dset(stream, info, &datactx, new_obj_id); + datactx.indent_level--; + if(H5Dclose(new_obj_id) < 0) + H5TOOLS_INFO("H5Dclose H5R_OBJECT1:H5O_TYPE_DATASET failed"); + } + else + H5TOOLS_INFO("H5Ropen_object H5R_OBJECT1:H5O_TYPE_DATASET failed"); + break; + + case H5O_TYPE_GROUP: + case H5O_TYPE_NAMED_DATATYPE: + case H5O_TYPE_MAP: + case H5O_TYPE_UNKNOWN: + case H5O_TYPE_NTYPES: + default: + break; + } /* end switch */ + } + else + H5TOOLS_INFO("H5Rget_obj_type3 H5R_OBJECT1 failed"); + break; + case H5R_DATASET_REGION1: + H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION1"); + if((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + datactx.indent_level++; + h5tools_dump_data(stream, info, &datactx, new_obj_id, TRUE); + //h5tools_dump_dset(stream, info, &datactx, new_obj_id); + datactx.indent_level--; + if(H5Dclose(new_obj_id) < 0) + H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION1 failed"); + } + else + H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION1 failed"); + break; + case H5R_OBJECT2: + H5TOOLS_DEBUG("ref_type is H5R_OBJECT2"); + if (H5Rget_obj_type3(&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) { + switch (obj_type) { + case H5O_TYPE_GROUP: + break; + + case H5O_TYPE_DATASET: + if((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + datactx.indent_level++; + h5tools_dump_data(stream, info, &datactx, new_obj_id, TRUE); + //h5tools_dump_dset(stream, info, &datactx, new_obj_id); + datactx.indent_level--; + if(H5Oclose(new_obj_id) < 0) + H5TOOLS_INFO("H5Oclose H5R_OBJECT2 failed"); + } + else + H5TOOLS_INFO("H5Ropen_object H5R_OBJECT2 failed"); + break; + + case H5O_TYPE_NAMED_DATATYPE: + break; + + case H5O_TYPE_MAP: + case H5O_TYPE_UNKNOWN: + case H5O_TYPE_NTYPES: + default: + break; + } /* end switch */ + } + else + H5TOOLS_INFO("H5Rget_obj_type3 H5R_OBJECT2 failed"); + break; + case H5R_DATASET_REGION2: + H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION2"); + + if (info->line_ncols > 0) + ncols = info->line_ncols; + + /* if (new_obj_id < 0) - could mean that no reference was written do not throw failure */ + if((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) < 0) + H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION2 failed"); + else { + if((new_obj_sid = H5Ropen_region(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + if (h5tools_is_zero(&ref_buf[i], H5Tget_size(H5T_STD_REF))) { + H5TOOLS_DEBUG("NULL H5R_DATASET_REGION2"); + + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, " {"); + h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + + datactx.need_prefix = TRUE; + datactx.indent_level++; + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "NULL"); + h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + datactx.indent_level--; + datactx.need_prefix = TRUE; + + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "}"); + h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + } + else { + H5S_sel_type region_type; + + region_type = H5Sget_select_type(new_obj_sid); + if(region_type == H5S_SEL_POINTS) { + /* Print point information */ + H5TOOLS_DEBUG("H5S_SEL_POINTS H5R_DATASET_REGION2"); + h5tools_dump_region_data_points(new_obj_sid, new_obj_id, stream, info, &datactx, + &buffer, &curr_pos, ncols, (hsize_t)i, elmt_counter); + } + else if(region_type == H5S_SEL_HYPERSLABS) { + /* Print block information */ + H5TOOLS_DEBUG("H5S_SEL_HYPERSLABS H5R_DATASET_REGION2"); + h5tools_dump_region_data_blocks(new_obj_sid, new_obj_id, stream, info, &datactx, + &buffer, &curr_pos, ncols, (hsize_t)i, elmt_counter); + } + else + H5TOOLS_INFO("invalid region type"); + } /* end else to if (h5tools_is_zero(... */ + if(H5Sclose(new_obj_sid) < 0) + H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION2 failed"); + } + else + H5TOOLS_INFO("H5Ropen_region H5R_DATASET_REGION2 failed"); + if(H5Dclose(new_obj_id) < 0) + H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION2 failed"); + } + break; + case H5R_ATTR: + H5TOOLS_DEBUG("ref_type is H5R_ATTR"); + if((new_obj_id = H5Ropen_attr(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { + h5tools_dump_region_attribute(new_obj_id, stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + if(H5Aclose(new_obj_id) < 0) + H5TOOLS_INFO("H5Aclose H5R_ATTR failed"); + } + else { + H5TOOLS_DEBUG("NULL H5R_ATTR"); + + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, " {"); + h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + + datactx.need_prefix = TRUE; + datactx.indent_level++; + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "NULL"); + h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + datactx.indent_level--; + datactx.need_prefix = TRUE; + + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "}"); + h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); + + H5TOOLS_INFO("H5Ropen_attr H5R_ATTR failed"); + } + break; + case H5R_BADTYPE: + case H5R_MAXTYPE: + default: + break; + } /* end switch */ + + if(H5Rdestroy(&ref_buf[i]) < 0) + H5TOOLS_INFO("H5Rdestroy failed"); + + H5TOOLS_DEBUG("finished reference loop:%d",i); + } /* end for(i = 0; i < ndims; i++, ctx->cur_elmt++, elmt_counter++) */ + + h5tools_str_close(&buffer); + + H5TOOLS_ENDDEBUG(""); +} + +/*------------------------------------------------------------------------- * Function: dump_data * * Purpose: Dump attribute, obj_data is FALSE, or dataset data, obj_data is TRUE @@ -3978,16 +4196,12 @@ h5tools_dump_subsetting_header(FILE *stream, const h5tool_format_t *info, h5tool void h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t obj_id, int obj_data) { - H5S_class_t space_type; - int ndims; - size_t i; - hid_t space = H5I_INVALID_HID; - hid_t f_type = H5I_INVALID_HID; - hid_t new_obj_id = H5I_INVALID_HID; - hid_t new_obj_sid = H5I_INVALID_HID; - hsize_t total_size[H5S_MAX_RANK]; - hsize_t elmt_counter = 0; /*counts the # elements printed. */ - int status = -1; + H5S_class_t space_type; + int ndims; + hid_t space = H5I_INVALID_HID; + hid_t f_type = H5I_INVALID_HID; + hsize_t total_size[H5S_MAX_RANK]; + int status = -1; h5tools_context_t datactx; /* print context */ h5tools_str_t buffer; /* string into which to render */ hsize_t curr_pos = 0; /* total data element position */ @@ -4051,221 +4265,27 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t * H5TOOLS_DEBUG("ndims=%d - datactx.ndims=%d", ndims, datactx.ndims); /* Assume entire data space to be printed */ - if (datactx.ndims > 0) - for (i = 0; i < (size_t)datactx.ndims; i++) - datactx.p_min_idx[i] = 0; - H5Sget_simple_extent_dims(space, total_size, NULL); - if (datactx.ndims > 0) - init_acc_pos(&datactx, total_size); + init_acc_pos(datactx.ndims, total_size, datactx.acc, datactx.pos, datactx.p_min_idx); + datactx.need_prefix = TRUE; if (NULL != (ref_buf = (H5R_ref_t *)HDcalloc(MAX(sizeof(unsigned), sizeof(H5R_ref_t)), (size_t)ndims))) { - if(obj_data) { - if(H5Dread(obj_id, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_buf) < 0) { + if (obj_data) { + if (H5Dread(obj_id, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_buf) < 0) { HDfree(ref_buf); H5TOOLS_INFO("H5Dread reference failed"); H5TOOLS_GOTO_DONE_NO_RET(); } } else { - if(H5Aread(obj_id, H5T_STD_REF, ref_buf) < 0) { + if (H5Aread(obj_id, H5T_STD_REF, ref_buf) < 0) { HDfree(ref_buf); H5TOOLS_INFO("H5Aread reference failed"); H5TOOLS_GOTO_DONE_NO_RET(); } } - for(i = 0; i < (size_t)ndims; i++, datactx.cur_elmt++, elmt_counter++) { - H5O_type_t obj_type = -1; /* Object type */ - H5R_type_t ref_type; /* Reference type */ - - H5TOOLS_DEBUG("reference loop:%d with curr_pos=%ld", i, curr_pos); - - datactx.need_prefix = TRUE; - h5tools_str_reset(&buffer); - H5TOOLS_DEBUG("reference loop - h5tools_str_sprint with H5T_STD_REF:%d", i); - h5tools_str_sprint(&buffer, &outputformat, obj_id, H5T_STD_REF, &ref_buf[i], &datactx); - h5tools_render_element(stream, &outputformat, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)i, (hsize_t)ndims); - - ref_type = H5Rget_type((const H5R_ref_t *)&ref_buf[i]); - switch (ref_type) { - case H5R_OBJECT1: - H5TOOLS_DEBUG("ref_type is H5R_OBJECT1"); - if (H5Rget_obj_type3((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) { - switch (obj_type) { - case H5O_TYPE_DATASET: - if((new_obj_id = H5Ropen_object((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - datactx.indent_level++; - h5tools_dump_data(stream, &outputformat, &datactx, new_obj_id, TRUE); - datactx.indent_level--; - if(H5Dclose(new_obj_id) < 0) - H5TOOLS_INFO("H5Dclose H5R_OBJECT1:H5O_TYPE_DATASET failed"); - } - else - H5TOOLS_INFO("H5Ropen_object H5R_OBJECT1:H5O_TYPE_DATASET failed"); - break; - - case H5O_TYPE_GROUP: - case H5O_TYPE_NAMED_DATATYPE: - case H5O_TYPE_MAP: - case H5O_TYPE_UNKNOWN: - case H5O_TYPE_NTYPES: - default: - break; - } /* end switch */ - } - else - H5TOOLS_INFO("H5Rget_obj_type3 H5R_OBJECT1 failed"); - break; - case H5R_DATASET_REGION1: - H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION1"); - if((new_obj_id = H5Ropen_object((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - datactx.indent_level++; - h5tools_dump_data(stream, &outputformat, &datactx, new_obj_id, TRUE); - datactx.indent_level--; - if(H5Dclose(new_obj_id) < 0) - H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION1 failed"); - } - else - H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION1 failed"); - break; - case H5R_OBJECT2: - H5TOOLS_DEBUG("ref_type is H5R_OBJECT2"); - if (H5Rget_obj_type3((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) { - switch (obj_type) { - case H5O_TYPE_GROUP: - break; - - case H5O_TYPE_DATASET: - if((new_obj_id = H5Ropen_object((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - datactx.indent_level++; - h5tools_dump_data(stream, &outputformat, &datactx, new_obj_id, TRUE); - datactx.indent_level--; - if(H5Oclose(new_obj_id) < 0) - H5TOOLS_INFO("H5Oclose H5R_OBJECT2 failed"); - } - else - H5TOOLS_INFO("H5Ropen_object H5R_OBJECT2 failed"); - break; - - case H5O_TYPE_NAMED_DATATYPE: - break; - - case H5O_TYPE_MAP: - case H5O_TYPE_UNKNOWN: - case H5O_TYPE_NTYPES: - default: - break; - } /* end switch */ - } - else - H5TOOLS_INFO("H5Rget_obj_type3 H5R_OBJECT2 failed"); - break; - case H5R_DATASET_REGION2: - H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION2"); - - if (outputformat.line_ncols > 0) - ncols = outputformat.line_ncols; - - /* if (new_obj_id < 0) - could mean that no reference was written do not throw failure */ - if((new_obj_id = H5Ropen_object((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) < 0) - H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION2 failed"); - else { - if((new_obj_sid = H5Ropen_region((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - if (h5tools_is_zero(&ref_buf[i], H5Tget_size(H5T_STD_REF))) { - H5TOOLS_DEBUG("NULL H5R_DATASET_REGION2"); - - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, " {"); - h5tools_render_element(stream, &outputformat, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); - - datactx.indent_level++; - datactx.need_prefix = TRUE; - - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "NULL"); - h5tools_render_element(stream, &outputformat, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); - - datactx.indent_level--; - datactx.need_prefix = TRUE; - - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "}"); - h5tools_render_element(stream, &outputformat, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); - } - else { - H5S_sel_type region_type; - - region_type = H5Sget_select_type(new_obj_sid); - if(region_type == H5S_SEL_POINTS) { - /* Print point information */ - H5TOOLS_DEBUG("H5S_SEL_POINTS H5R_DATASET_REGION2"); - h5tools_dump_region_data_points(new_obj_sid, new_obj_id, stream, &outputformat, &datactx, - &buffer, &curr_pos, ncols, i, elmt_counter); - } - else if(region_type == H5S_SEL_HYPERSLABS) { - /* Print block information */ - H5TOOLS_DEBUG("H5S_SEL_HYPERSLABS H5R_DATASET_REGION2"); - h5tools_dump_region_data_blocks(new_obj_sid, new_obj_id, stream, &outputformat, &datactx, - &buffer, &curr_pos, ncols, i, elmt_counter); - } - else - H5TOOLS_INFO("invalid region type"); - } /* end else to if (h5tools_is_zero(... */ - if(H5Sclose(new_obj_sid) < 0) - H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION2 failed"); - } - else - H5TOOLS_INFO("H5Ropen_region H5R_DATASET_REGION2 failed"); - if(H5Dclose(new_obj_id) < 0) - H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION2 failed"); - } - break; - case H5R_ATTR: - H5TOOLS_DEBUG("ref_type is H5R_ATTR"); - if((new_obj_id = H5Ropen_attr((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - h5tools_dump_region_attribute(new_obj_id, stream, &outputformat, &datactx, - &buffer, &curr_pos, ncols, i, elmt_counter); - if(H5Aclose(new_obj_id) < 0) - H5TOOLS_INFO("H5Aclose H5R_ATTR failed"); - } - else { - H5TOOLS_DEBUG("NULL H5R_ATTR"); - - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, " {"); - h5tools_render_element(stream, &outputformat, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); - - datactx.indent_level++; - datactx.need_prefix = TRUE; - - datactx.indent_level++; - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "NULL"); - h5tools_render_element(stream, &outputformat, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); - datactx.indent_level--; - - datactx.indent_level--; - datactx.need_prefix = TRUE; - - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "}"); - h5tools_render_element(stream, &outputformat, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); - - H5TOOLS_INFO("H5Ropen_attr H5R_ATTR failed"); - } - break; - case H5R_BADTYPE: - case H5R_MAXTYPE: - default: - break; - } /* end switch */ - - if(H5Rdestroy(&ref_buf[i]) < 0) - H5TOOLS_INFO("H5Rdestroy failed"); - - H5TOOLS_DEBUG("finished reference loop:%d",i); - } /* end for(i = 0; i < ndims; i++, datactx->cur_elmt++, elmt_counter++) */ + h5tools_dump_reference(stream, &outputformat, &datactx, obj_id, ref_buf, ndims); HDfree(ref_buf); } ctx->indent_level--; diff --git a/tools/lib/h5tools_dump.h b/tools/lib/h5tools_dump.h index 2cd0bc1..add2e46 100644 --- a/tools/lib/h5tools_dump.h +++ b/tools/lib/h5tools_dump.h @@ -36,63 +36,53 @@ H5TOOLS_DLLVAR table_t *h5dump_type_table; /*type table reference for datatype /* Definitions of useful routines */ H5TOOLS_DLL void h5tools_dump_init(void); -H5TOOLS_DLL int h5tools_dump_dset(FILE *stream, const h5tool_format_t *info, - h5tools_context_t *ctx/*in,out*/, hid_t dset); -H5TOOLS_DLL int h5tools_dump_mem(FILE *stream, const h5tool_format_t *info, - h5tools_context_t *ctx/*in,out*/, hid_t obj_id); -H5TOOLS_DLL int h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t container, - h5tools_context_t *ctx/*in,out*/, unsigned flags, - hsize_t nelmts, hid_t type, void *_mem); -H5TOOLS_DLL void h5tools_dump_datatype(FILE *stream, const h5tool_format_t *info, - h5tools_context_t *ctx/*in,out*/, hid_t type); -H5TOOLS_DLL void h5tools_dump_dataspace(FILE *stream, const h5tool_format_t *info, - h5tools_context_t *ctx/*in,out*/, hid_t space); -H5TOOLS_DLL void h5tools_dump_attribute(FILE *stream, const h5tool_format_t *info, - h5tools_context_t *ctx/*in,out*/, const char *attr_name, hid_t attr_id); -H5TOOLS_DLL void h5tools_dump_oid(FILE *stream, const h5tool_format_t *info, - h5tools_context_t *ctx/*in,out*/, hid_t oid); -H5TOOLS_DLL void h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, - h5tools_context_t *ctx/*in,out*/, hid_t dcpl, hid_t type_id, hid_t obj_id); -H5TOOLS_DLL void h5tools_dump_comment(FILE *stream, const h5tool_format_t *info, - h5tools_context_t *ctx/*in,out*/, hid_t obj_id); -H5TOOLS_DLL void h5tools_dump_data(FILE *stream, const h5tool_format_t *info, - h5tools_context_t *ctx, hid_t obj_id, int obj_data); +H5TOOLS_DLL int h5tools_dump_dset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, + hid_t dset); +H5TOOLS_DLL int h5tools_dump_mem(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, + hid_t obj_id); +H5TOOLS_DLL int h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, + hid_t container, unsigned flags, hsize_t nelmts, hid_t type, void *_mem); +H5TOOLS_DLL void h5tools_dump_datatype(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, + hid_t type); +H5TOOLS_DLL void h5tools_dump_dataspace(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, + hid_t space); +H5TOOLS_DLL void h5tools_dump_attribute(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, + const char *attr_name, hid_t attr_id); +H5TOOLS_DLL void h5tools_dump_oid(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, + hid_t oid); +H5TOOLS_DLL void h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, + hid_t dcpl, hid_t type_id, hid_t obj_id); +H5TOOLS_DLL void h5tools_dump_comment(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, + hid_t obj_id); +H5TOOLS_DLL void h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, + hid_t obj_id, int obj_data); +H5TOOLS_DLL void h5tools_dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, + hid_t container, H5R_ref_t *ref_buf, int ndims); H5TOOLS_DLL hbool_t h5tools_dump_region_attribute(hid_t region_id, - FILE *stream, const h5tool_format_t *info, - h5tools_context_t *ctx/*in,out*/, - h5tools_str_t *buffer/*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); + FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, + h5tools_str_t *buffer, hsize_t *curr_pos, size_t ncols, hsize_t region_elmt_counter, hsize_t elmt_counter); H5TOOLS_DLL hbool_t h5tools_dump_region_data_points(hid_t region_space, hid_t region_id, - FILE *stream, const h5tool_format_t *info, - h5tools_context_t *ctx/*in,out*/, - h5tools_str_t *buffer/*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); + FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, + h5tools_str_t *buffer, hsize_t *curr_pos, size_t ncols, hsize_t region_elmt_counter, hsize_t elmt_counter); H5TOOLS_DLL hbool_t h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, - FILE *stream, const h5tool_format_t *info, - h5tools_context_t *ctx/*in,out*/, - h5tools_str_t *buffer/*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); + FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, + h5tools_str_t *buffer, hsize_t *curr_pos, size_t ncols, hsize_t region_elmt_counter, hsize_t elmt_counter); -H5TOOLS_DLL int h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer/*in,out*/, - const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, +H5TOOLS_DLL int h5tools_print_datatype(FILE *stream, + h5tools_str_t *buffer/*in,out*/, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, hid_t type, int object_search); H5TOOLS_DLL int h5tools_print_dataspace(h5tools_str_t *buffer/*in,out*/, hid_t space); -H5TOOLS_DLL int h5tools_print_enum(FILE *stream, h5tools_str_t *buffer/*in,out*/, - const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, +H5TOOLS_DLL int h5tools_print_enum(FILE *stream, + h5tools_str_t *buffer/*in,out*/, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, hid_t type); -H5TOOLS_DLL void h5tools_print_fill_value(h5tools_str_t *buffer/*in,out*/, - const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, +H5TOOLS_DLL void h5tools_print_fill_value( + h5tools_str_t *buffer/*in,out*/, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, hid_t dcpl, hid_t type_id, hid_t obj_id); H5TOOLS_DLL void h5tools_print_packed_bits(h5tools_str_t *buffer/*in,out*/, hid_t type); + #ifdef __cplusplus } #endif diff --git a/tools/lib/h5tools_error.h b/tools/lib/h5tools_error.h index 4e2e935..764fb91 100644 --- a/tools/lib/h5tools_error.h +++ b/tools/lib/h5tools_error.h @@ -101,14 +101,16 @@ do { * H5TOOLS_PUSH_ERROR macro, used to push an error to an error stack. Not meant to * be called directly. */ -#define H5TOOLS_PUSH_ERROR(estack_id, err_cls, maj_err_id, min_err_id, ...) \ -do { \ - if (estack_id >= 0 && err_cls >= 0) \ - H5Epush2(estack_id, __FILE__, FUNC, __LINE__, err_cls, maj_err_id, min_err_id, __VA_ARGS__); \ - else { \ - HDfprintf(stderr, __VA_ARGS__); \ - HDfprintf(stderr, "\n"); \ - } \ +#define H5TOOLS_PUSH_ERROR(estack_id, err_cls, maj_err_id, min_err_id, ...) \ +do { \ + if (enable_error_stack > 0) { \ + if (estack_id >= 0 && err_cls >= 0) \ + H5Epush2(estack_id, __FILE__, FUNC, __LINE__, err_cls, maj_err_id, min_err_id, __VA_ARGS__); \ + else { \ + HDfprintf(stderr, __VA_ARGS__); \ + HDfprintf(stderr, "\n"); \ + } \ + } \ } while(0) /* @@ -167,30 +169,30 @@ do { #ifdef H5_TOOLS_DEBUG -#define H5TOOLS_START_DEBUG(...) \ -do { \ - H5tools_INDENT_g += 2; \ +#define H5TOOLS_START_DEBUG(...) \ +do { \ + H5tools_INDENT_g += 2; \ HDfprintf(stderr, "%*sENTER %s:%d in %s()...", H5tools_INDENT_g, "", __FILE__, __LINE__, FUNC); \ - HDfprintf(stderr, __VA_ARGS__); \ - HDfprintf(stderr, "\n"); \ - HDfflush(stderr); \ + HDfprintf(stderr, __VA_ARGS__); \ + HDfprintf(stderr, "\n"); \ + HDfflush(stderr); \ } while(0) -#define H5TOOLS_DEBUG(...) \ -do { \ +#define H5TOOLS_DEBUG(...) \ +do { \ HDfprintf(stderr, "%*s %s:%d in %s()...", H5tools_INDENT_g, "", __FILE__, __LINE__, FUNC); \ - HDfprintf(stderr, __VA_ARGS__); \ - HDfprintf(stderr, "\n"); \ - HDfflush(stderr); \ + HDfprintf(stderr, __VA_ARGS__); \ + HDfprintf(stderr, "\n"); \ + HDfflush(stderr); \ } while(0) -#define H5TOOLS_ENDDEBUG(...) \ -do { \ +#define H5TOOLS_ENDDEBUG(...) \ +do { \ HDfprintf(stderr, "%*sEXIT %s:%d in %s()...", H5tools_INDENT_g, "", __FILE__, __LINE__, FUNC); \ - HDfprintf(stderr, __VA_ARGS__); \ - HDfprintf(stderr, "\n"); \ - H5tools_INDENT_g -= 2; \ - HDfflush(stderr); \ + HDfprintf(stderr, __VA_ARGS__); \ + HDfprintf(stderr, "\n"); \ + H5tools_INDENT_g -= 2; \ + HDfflush(stderr); \ } while(0) #else diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index 6515ecd..1c573a7 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -278,47 +278,28 @@ h5tools_str_fmt(h5tools_str_t *str/*in,out*/, size_t start, const char *fmt) * Purpose: Renders the line prefix value into string STR. * * Return: Success: Pointer to the prefix. - * * Failure: NULL - * - * Programmer: Robb Matzke - * Thursday, July 23, 1998 *------------------------------------------------------------------------- */ char * -h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info, - hsize_t elmtno, unsigned ndims, h5tools_context_t *ctx) +h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info, hsize_t elmtno, + h5tools_context_t *ctx) { size_t i = 0; - hsize_t curr_pos = elmtno; H5TOOLS_START_DEBUG(""); H5TOOLS_DEBUG("elmtno=%ld, ctx->ndims=%d", elmtno, ctx->ndims); h5tools_str_reset(str); - H5TOOLS_DEBUG("ndims=%d", ndims); - 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++) { - H5TOOLS_DEBUG("curr_pos=%ld - ctx->acc[%d]=%ld", curr_pos, i, ctx->acc[i]); - ctx->pos[i] = curr_pos / ctx->acc[i]; - curr_pos -= ctx->acc[i] * ctx->pos[i]; - H5TOOLS_DEBUG("curr_pos=%ld - ctx->pos[%d]=%ld - ctx->acc[%d]=%ld", curr_pos, i, ctx->pos[i], i, ctx->acc[i]); - } - HDassert(curr_pos == 0); - + calc_acc_pos(ctx->ndims, elmtno, ctx->acc, ctx->pos); + if(ctx->ndims > 0) { /* Print the index values */ - for(i = 0; i < (size_t) ndims; i++) { + for(i = 0; i < (size_t) ctx->ndims; i++) { if (i) h5tools_str_append(str, "%s", OPT(info->idx_sep, ",")); - h5tools_str_append(str, OPT(info->idx_n_fmt, HSIZE_T_FORMAT), - (hsize_t) ctx->pos[i]); - + h5tools_str_append(str, OPT(info->idx_n_fmt, HSIZE_T_FORMAT), (hsize_t) ctx->pos[i]); } } else /* Scalar */ @@ -338,52 +319,35 @@ h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info, * * Return: Success: Pointer to the prefix. * Failure: NULL - * - * In/Out: - * h5tools_context_t *ctx - * h5tools_str_t *str *------------------------------------------------------------------------- */ char * -h5tools_str_region_prefix(h5tools_str_t *str, const h5tool_format_t *info, - hsize_t elmtno, hsize_t *ptdata, unsigned ndims, hsize_t max_idx[], - h5tools_context_t *ctx) +h5tools_str_region_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info, hsize_t elmtno, + hsize_t *ptdata, h5tools_context_t *ctx) { size_t i = 0; - hsize_t curr_pos = elmtno; - hsize_t p_prod[H5S_MAX_RANK]; - - h5tools_str_reset(str); - if(ndims > 0) { - /* - * Calculate the number of elements represented by a unit change in a - * certain index position. - */ - for(i = ndims - 1, p_prod[ndims - 1] = 1; i > 0; --i) - p_prod[i - 1] = (max_idx[i]) * p_prod[i]; + H5TOOLS_START_DEBUG(""); - for(i = 0; i < (size_t) ndims; i++) { - if(curr_pos > 0) { - ctx->pos[i] = curr_pos / p_prod[i]; - curr_pos -= p_prod[i] * ctx->pos[i]; - } - else - ctx->pos[i] = 0; - ctx->pos[i] += (unsigned long) ptdata[ctx->sm_pos+i]; - } + H5TOOLS_DEBUG("elmtno=%ld, ctx->ndims=%d", elmtno, ctx->ndims); + h5tools_str_reset(str); + calc_acc_pos(ctx->ndims, elmtno, ctx->acc, ctx->pos); + if(ctx->ndims > 0) { /* Print the index values */ - for(i = 0; i < (size_t) ndims; i++) { - if(i) + for(i = 0; i < (size_t) ctx->ndims; i++) { + ctx->pos[i] += (unsigned long) ptdata[ctx->sm_pos+i]; + if (i) h5tools_str_append(str, "%s", OPT(info->idx_sep, ",")); h5tools_str_append(str, OPT(info->idx_n_fmt, HSIZE_T_FORMAT), (hsize_t) ctx->pos[i]); - } - } /* 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); + H5TOOLS_DEBUG("str=%s", str->s); + + H5TOOLS_ENDDEBUG(""); /* Add prefix and suffix to the index */ return h5tools_str_fmt(str, (size_t)0, OPT(info->idx_fmt, "%s: ")); @@ -708,6 +672,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai if(info->raw) { size_t i; + H5TOOLS_DEBUG("info->raw"); if(1 == nsize) h5tools_str_append(str, OPT(info->fmt_raw, "0x%02x"), ucp_vp[0]); else @@ -718,8 +683,11 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai } } else { - if((type_class = H5Tget_class(type)) < 0) + H5TOOLS_DEBUG("H5Tget_class(type)"); + if((type_class = H5Tget_class(type)) < 0) { + H5TOOLS_ENDDEBUG(" with %s", "NULL"); return NULL; + } switch (type_class) { case H5T_FLOAT: H5TOOLS_DEBUG("H5T_FLOAT"); @@ -1101,12 +1069,12 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai { /* Object references -- show the type and OID of the referenced object. */ H5O_info2_t oi; - char *obj_addr_str = NULL; + char *obj_tok_str = NULL; H5TOOLS_DEBUG("ref_type is H5R_OBJECT1"); if((obj = H5Ropen_object(ref_vp, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { H5Oget_info3(obj, &oi, H5O_INFO_BASIC); - H5Otoken_to_str(obj, &oi.token, &obj_addr_str); + H5Otoken_to_str(obj, &oi.token, &obj_tok_str); } else H5TOOLS_ERROR(NULL, "H5Ropen_object H5R_OBJECT1 failed"); @@ -1137,13 +1105,13 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai /* Print OID */ if(info->obj_hidefileno) - h5tools_str_append(str, info->obj_format, obj_addr_str); + h5tools_str_append(str, info->obj_format, obj_tok_str); else - h5tools_str_append(str, info->obj_format, oi.fileno, obj_addr_str); + h5tools_str_append(str, info->obj_format, oi.fileno, obj_tok_str); - if(obj_addr_str) { - H5free_memory(obj_addr_str); - obj_addr_str = NULL; + if(obj_tok_str) { + H5free_memory(obj_tok_str); + obj_tok_str = NULL; } if(obj >= 0) diff --git a/tools/lib/h5tools_str.h b/tools/lib/h5tools_str.h index 02bfe40..074e86d 100644 --- a/tools/lib/h5tools_str.h +++ b/tools/lib/h5tools_str.h @@ -31,13 +31,12 @@ H5TOOLS_DLL char *h5tools_str_reset(h5tools_str_t *str); H5TOOLS_DLL char *h5tools_str_trunc(h5tools_str_t *str, size_t size); H5TOOLS_DLL char *h5tools_str_fmt(h5tools_str_t *str, size_t start, const char *fmt); H5TOOLS_DLL char *h5tools_str_prefix(h5tools_str_t *str, const h5tool_format_t *info, - hsize_t elmtno, unsigned ndims, h5tools_context_t *ctx); + hsize_t elmtno, h5tools_context_t *ctx); /* * new functions needed to display region reference data */ H5TOOLS_DLL char *h5tools_str_region_prefix(h5tools_str_t *str, const h5tool_format_t *info, - hsize_t elmtno, hsize_t *ptdata, unsigned ndims, - hsize_t max_idx[], h5tools_context_t *ctx); + hsize_t elmtno, hsize_t *ptdata, h5tools_context_t *ctx); H5TOOLS_DLL void h5tools_str_dump_space_slabs(h5tools_str_t *, hid_t, const h5tool_format_t *, h5tools_context_t *ctx); H5TOOLS_DLL void h5tools_str_dump_space_blocks(h5tools_str_t *, hid_t, const h5tool_format_t *); H5TOOLS_DLL void h5tools_str_dump_space_points(h5tools_str_t *, hid_t, const h5tool_format_t *); diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c index 45e436c..1a1c2db 100644 --- a/tools/lib/h5tools_utils.c +++ b/tools/lib/h5tools_utils.c @@ -648,17 +648,17 @@ static void dump_table(hid_t fid, char* tablename, table_t *table) { unsigned u; - char *obj_addr_str = NULL; + char *obj_tok_str = NULL; PRINTSTREAM(rawoutstream,"%s: # of entries = %d\n", tablename,table->nobjs); for (u = 0; u < table->nobjs; u++) { - H5VLconnector_token_to_str(fid, table->objs[u].obj_token, &obj_addr_str); + H5VLconnector_token_to_str(fid, table->objs[u].obj_token, &obj_tok_str); - PRINTSTREAM(rawoutstream,"%s %s %d %d\n", obj_addr_str, + PRINTSTREAM(rawoutstream,"%s %s %d %d\n", obj_tok_str, table->objs[u].objname, table->objs[u].displayed, table->objs[u].recorded); - H5VLfree_token_str(fid, obj_addr_str); + H5VLfree_token_str(fid, obj_tok_str); } } @@ -1079,6 +1079,55 @@ done: return ret_value; } +#ifdef H5_HAVE_ROS3_VFD +/*---------------------------------------------------------------------------- + * + * Function: h5tools_parse_ros3_fapl_tuple + * + * Purpose: A convenience function that parses a string containing a tuple + * of S3 VFD credential information and then passes the result to + * `h5tools_populate_ros3_fapl()` in order to setup a valid + * configuration for the S3 VFD. + * + * Return: SUCCEED/FAIL + * + *---------------------------------------------------------------------------- + */ +herr_t +h5tools_parse_ros3_fapl_tuple(const char *tuple_str, int delim, + H5FD_ros3_fapl_t *fapl_config_out) +{ + const char *ccred[3]; + unsigned nelems = 0; + char *start = NULL; + char *s3cred_src = NULL; + char **s3cred = NULL; + herr_t ret_value = SUCCEED; + + /* Attempt to parse S3 credentials tuple */ + if (parse_tuple(tuple_str, delim, &s3cred_src, &nelems, &s3cred) < 0) + H5TOOLS_GOTO_ERROR(FAIL, "failed to parse S3 VFD info tuple"); + + /* Sanity-check tuple count */ + if (nelems != 3) + H5TOOLS_GOTO_ERROR(FAIL, "invalid S3 VFD credentials"); + + ccred[0] = (const char *)s3cred[0]; + ccred[1] = (const char *)s3cred[1]; + ccred[2] = (const char *)s3cred[2]; + + if (0 == h5tools_populate_ros3_fapl(fapl_config_out, ccred)) + H5TOOLS_GOTO_ERROR(FAIL, "failed to populate S3 VFD FAPL config"); + +done: + if (s3cred) + HDfree(s3cred); + if (s3cred_src) + HDfree(s3cred_src); + + return ret_value; +} + /*---------------------------------------------------------------------------- * @@ -1142,7 +1191,6 @@ done: * *---------------------------------------------------------------------------- */ -#ifdef H5_HAVE_ROS3_VFD int h5tools_populate_ros3_fapl(H5FD_ros3_fapl_t *fa, const char **values) @@ -1266,73 +1314,72 @@ h5tools_populate_ros3_fapl(H5FD_ros3_fapl_t *fa, done: return ret_value; - } /* h5tools_populate_ros3_fapl */ #endif /* H5_HAVE_ROS3_VFD */ - -/*----------------------------------------------------------------------------- - * - * Function: h5tools_set_configured_fapl - * - * Purpose: prepare fapl_id with the given property list, according to - * VFD prototype. +#ifdef H5_HAVE_LIBHDFS +/*---------------------------------------------------------------------------- * - * Return: 0 on failure, 1 on success + * Function: h5tools_parse_hdfs_fapl_tuple * - * Programmer: Jacob Smith - * 2018-05-21 + * Purpose: A convenience function that parses a string containing a tuple + * of HDFS VFD configuration information. * - * Changes: None. + * Return: SUCCEED/FAIL * - *----------------------------------------------------------------------------- + *---------------------------------------------------------------------------- */ -int -h5tools_set_configured_fapl(hid_t fapl_id, - const char vfd_name[], - void *fapl_t_ptr) +herr_t +h5tools_parse_hdfs_fapl_tuple(const char *tuple_str, int delim, + H5FD_hdfs_fapl_t *fapl_config_out) { - int ret_value = 1; - - if (fapl_id < 0) { - return 0; + unsigned long k = 0; + unsigned nelems = 0; + char *props_src = NULL; + char **props = NULL; + herr_t ret_value = SUCCEED; + + /* Attempt to parse HDFS configuration tuple */ + if (parse_tuple(tuple_str, delim, &props_src, &nelems, &props) < 0) + H5TOOLS_GOTO_ERROR(FAIL, "failed to parse HDFS VFD configuration tuple"); + + /* Sanity-check tuple count */ + if (nelems != 5) + H5TOOLS_GOTO_ERROR(FAIL, "invalid HDFS VFD configuration"); + + /* Populate fapl configuration structure with given properties. + * WARNING: No error-checking is done on length of input strings... + * Silent overflow is possible, albeit unlikely. + */ + if (HDstrncmp(props[0], "", 1)) { + HDstrncpy(fapl_config_out->namenode_name, (const char *)props[0], HDstrlen(props[0])); } - - if (!strcmp("", vfd_name)) { - goto done; - -#ifdef H5_HAVE_ROS3_VFD - } else if (!strcmp("ros3", vfd_name)) { - if ((fapl_id == H5P_DEFAULT) || - (fapl_t_ptr == NULL) || - (FAIL == H5Pset_fapl_ros3( - fapl_id, - (H5FD_ros3_fapl_t *)fapl_t_ptr))) - { - ret_value = 0; - goto done; - } -#endif /* H5_HAVE_ROS3_VFD */ - -#ifdef H5_HAVE_LIBHDFS - } else if (!strcmp("hdfs", vfd_name)) { - if ((fapl_id == H5P_DEFAULT) || - (fapl_t_ptr == NULL) || - (FAIL == H5Pset_fapl_hdfs( - fapl_id, - (H5FD_hdfs_fapl_t *)fapl_t_ptr))) - { - ret_value = 0; - goto done; - } -#endif /* H5_HAVE_LIBHDFS */ - - } else { - ret_value = 0; /* unrecognized fapl type "name" */ + if (HDstrncmp(props[1], "", 1)) { + k = strtoul((const char *)props[1], NULL, 0); + if (errno == ERANGE) + H5TOOLS_GOTO_ERROR(FAIL, "supposed port number wasn't"); + fapl_config_out->namenode_port = (int32_t)k; + } + if (HDstrncmp(props[2], "", 1)) { + HDstrncpy(fapl_config_out->kerberos_ticket_cache, (const char *)props[2], HDstrlen(props[2])); + } + if (HDstrncmp(props[3], "", 1)) { + HDstrncpy(fapl_config_out->user_name, (const char *)props[3], HDstrlen(props[3])); + } + if (HDstrncmp(props[4], "", 1)) { + k = HDstrtoul((const char *)props[4], NULL, 0); + if (errno == ERANGE) + H5TOOLS_GOTO_ERROR(FAIL, "supposed buffersize number wasn't"); + fapl_config_out->stream_buffer_size = (int32_t)k; } done: - return ret_value; + if (props) + HDfree(props); + if (props_src) + HDfree(props_src); -} /* h5tools_set_configured_fapl() */ + return ret_value; +} +#endif /* H5_HAVE_LIBHDFS */ diff --git a/tools/lib/h5tools_utils.h b/tools/lib/h5tools_utils.h index 598930c..42144cc 100644 --- a/tools/lib/h5tools_utils.h +++ b/tools/lib/h5tools_utils.h @@ -173,10 +173,15 @@ H5TOOLS_DLL void h5tools_setprogname(const char*progname); H5TOOLS_DLL int h5tools_getstatus(void); H5TOOLS_DLL void h5tools_setstatus(int d_status); H5TOOLS_DLL int h5tools_getenv_update_hyperslab_bufsize(void); -H5TOOLS_DLL int h5tools_set_configured_fapl(hid_t fapl_id, const char vfd_name[], void *fapl_t_ptr); #ifdef H5_HAVE_ROS3_VFD +H5TOOLS_DLL herr_t h5tools_parse_ros3_fapl_tuple(const char *tuple_str, int delim, + H5FD_ros3_fapl_t *fapl_config_out); H5TOOLS_DLL int h5tools_populate_ros3_fapl(H5FD_ros3_fapl_t *fa, const char **values); #endif /* H5_HAVE_ROS3_VFD */ +#ifdef H5_HAVE_LIBHDFS +H5TOOLS_DLL herr_t h5tools_parse_hdfs_fapl_tuple(const char *tuple_str, int delim, + H5FD_hdfs_fapl_t *fapl_config_out); +#endif #ifdef __cplusplus } diff --git a/tools/lib/io_timer.c b/tools/lib/io_timer.c index 472824b..5c0c31d 100644 --- a/tools/lib/io_timer.c +++ b/tools/lib/io_timer.c @@ -23,7 +23,6 @@ */ #include "H5private.h" -#include "hdf5.h" #include "io_timer.h" diff --git a/tools/libtest/h5tools_test_utils.c b/tools/libtest/h5tools_test_utils.c index 726f4c4..12360a7 100644 --- a/tools/libtest/h5tools_test_utils.c +++ b/tools/libtest/h5tools_test_utils.c @@ -16,6 +16,7 @@ * Jacob Smith 2017-11-10 */ +#include "h5tools.h" #include "h5tools_utils.h" #include "h5test.h" @@ -960,7 +961,7 @@ error : * * Function: test_set_configured_fapl() * - * Purpose: Verify `h5tools_set_configured_fapl()` with ROS3 VFD + * Purpose: Verify `h5tools_get_fapl()` with ROS3 and HDFS VFDs * * Return: 0 if test passes * 1 if failure @@ -1147,7 +1148,8 @@ test_set_configured_fapl(void) TESTING("programmatic fapl set"); for (i = 0; i < n_cases; i++) { - int result; + h5tools_vfd_info_t vfd_info; + hid_t result; testcase C = cases[i]; fapl_id = H5I_INVALID_HID; @@ -1169,11 +1171,13 @@ test_set_configured_fapl(void) #endif /* UTIL_TEST_DEBUG */ /* test */ - result = h5tools_set_configured_fapl( - fapl_id, - C.vfdname, - C.conf_fa); - JSVERIFY( result, C.expected, C.message ) + vfd_info.info = C.conf_fa; + vfd_info.name = C.vfdname; + result = h5tools_get_fapl(H5P_DEFAULT, NULL, &vfd_info); + if (C.expected == 0) + JSVERIFY( result, H5I_INVALID_HID, C.message) + else + JSVERIFY_NOT( result, H5I_INVALID_HID, C.message) #if UTIL_TEST_DEBUG HDfprintf(stderr, "after test\n"); fflush(stderr); diff --git a/tools/src/h5copy/h5copy.c b/tools/src/h5copy/h5copy.c index e1370e2..5b19ae7 100644 --- a/tools/src/h5copy/h5copy.c +++ b/tools/src/h5copy/h5copy.c @@ -207,10 +207,6 @@ static int parse_flag(const char* s_flag, unsigned *flag) int main (int argc, const char *argv[]) { - H5E_auto2_t func; - H5E_auto2_t tools_func; - void *edata; - void *tools_edata; hid_t fid_src = H5I_INVALID_HID; hid_t fid_dst = H5I_INVALID_HID; unsigned flag = 0; @@ -226,17 +222,9 @@ main (int argc, const char *argv[]) h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); - /* Disable error reporting */ - H5Eget_auto2(H5E_DEFAULT, &func, &edata); - H5Eset_auto2(H5E_DEFAULT, NULL, NULL); - /* Initialize h5tools lib */ h5tools_init(); - /* Disable tools error reporting */ - H5Eget_auto2(H5tools_ERR_STACK_g, &tools_func, &tools_edata); - H5Eset_auto2(H5tools_ERR_STACK_g, NULL, NULL); - /* init linkinfo struct */ HDmemset(&linkinfo, 0, sizeof(h5tool_link_info_t)); @@ -330,10 +318,8 @@ main (int argc, const char *argv[]) leave(EXIT_FAILURE); } - if (enable_error_stack > 0) { - H5Eset_auto2(H5E_DEFAULT, func, edata); - H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata); - } + /* enable error reporting if command line option */ + h5tools_error_report(); /*------------------------------------------------------------------------- * open output file @@ -342,13 +328,13 @@ main (int argc, const char *argv[]) /* Attempt to open an existing HDF5 file first. Need to open the dst file before the src file just in case that the dst and src are the same file */ - fid_dst = h5tools_fopen(fname_dst, H5F_ACC_RDWR, H5P_DEFAULT, NULL, NULL, 0); + fid_dst = h5tools_fopen(fname_dst, H5F_ACC_RDWR, H5P_DEFAULT, FALSE, NULL, 0); /*------------------------------------------------------------------------- * open input file *-------------------------------------------------------------------------*/ - fid_src = h5tools_fopen(fname_src, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, 0); + fid_src = h5tools_fopen(fname_src, H5F_ACC_RDONLY, H5P_DEFAULT, FALSE, NULL, 0); /*------------------------------------------------------------------------- * test for error in opening input file diff --git a/tools/src/h5diff/h5diff_common.c b/tools/src/h5diff/h5diff_common.c index 3b0fe1c..a02ad5a 100644 --- a/tools/src/h5diff/h5diff_common.c +++ b/tools/src/h5diff/h5diff_common.c @@ -25,7 +25,7 @@ static int check_d_input(const char*); * Command-line options: The user can specify short or long-named * parameters. */ -static const char *s_opts = "hVrv:qn:d:p:NcelxE:S"; +static const char *s_opts = "hVrv:qn:d:p:NcelxE:A:S"; static struct long_options l_opts[] = { { "help", no_arg, 'h' }, { "version", no_arg, 'V' }, @@ -41,7 +41,14 @@ static struct long_options l_opts[] = { { "follow-symlinks", no_arg, 'l' }, { "no-dangling-links", no_arg, 'x' }, { "exclude-path", require_arg, 'E' }, + { "exclude-attribute", require_arg, 'A' }, { "enable-error-stack", no_arg, 'S' }, + { "vol-value-1", require_arg, '1' }, + { "vol-name-1", require_arg, '2' }, + { "vol-info-1", require_arg, '3' }, + { "vol-value-2", require_arg, '4' }, + { "vol-name-2", require_arg, '5' }, + { "vol-info-2", require_arg, '6' }, { NULL, 0, '\0' } }; @@ -49,7 +56,6 @@ static struct long_options l_opts[] = { * Function: check_options * * Purpose: parse command line input - * *------------------------------------------------------------------------- */ static void check_options(diff_opt_t* opts) @@ -61,7 +67,7 @@ static void check_options(diff_opt_t* opts) /* check between -d , -p, --use-system-epsilon. * These options are mutually exclusive. */ - if ((opts->d + opts->p + opts->use_system_epsilon) > 1) { + if ((opts->delta_bool + opts->percent_bool + opts->use_system_epsilon) > 1) { HDprintf("%s error: -d, -p and --use-system-epsilon options are mutually-exclusive;\n", PROGRAMNAME); HDprintf("use no more than one.\n"); HDprintf("Try '-h' or '--help' option for more information or see the %s entry in the 'HDF5 Reference Manual'.\n", PROGRAMNAME); @@ -69,12 +75,127 @@ static void check_options(diff_opt_t* opts) } } +/*------------------------------------------------------------------------- + * Function: parse_hsize_list + * + * Purpose: Parse a list of comma or space separated integers and return + * them in a list. The string being passed into this function + * should be at the start of the list you want to parse. You are + * responsible for freeing the array returned from here. + * + * Lists in the so-called "terse" syntax are separated by + * semicolons (;). The lists themselves can be separated by + * either commas (,) or white spaces. + * + * Return: + *------------------------------------------------------------------------- + */ +static void +parse_hsize_list(const char *h_list, subset_d *d) +{ + hsize_t *p_list; + const char *ptr; + unsigned int size_count = 0; + unsigned int i = 0; + unsigned int last_digit = 0; + + if (!h_list || !*h_list || *h_list == ';') + return; + + H5TOOLS_START_DEBUG(" - h_list:%s", h_list); + /* count how many integers do we have */ + for (ptr = h_list; ptr && *ptr && *ptr != ';' && *ptr != ']'; ptr++) + if (HDisdigit(*ptr)) { + if (!last_digit) + /* the last read character wasn't a digit */ + size_count++; + + last_digit = 1; + } + else + last_digit = 0; + + if (size_count == 0) { + /* there aren't any integers to read */ + H5TOOLS_ENDDEBUG("No integers to read"); + return; + } + H5TOOLS_DEBUG("Number integers to read=%ld", size_count); + + /* allocate an array for the integers in the list */ + if((p_list = (hsize_t *)HDcalloc(size_count, sizeof(hsize_t))) == NULL) + H5TOOLS_INFO("Unable to allocate space for subset data"); + + for (ptr = h_list; i < size_count && ptr && *ptr && *ptr != ';' && *ptr != ']'; ptr++) + if(HDisdigit(*ptr)) { + /* we should have an integer now */ + p_list[i++] = (hsize_t)HDstrtoull(ptr, NULL, 0); + + while (HDisdigit(*ptr)) + /* scroll to end of integer */ + ptr++; + } + d->data = p_list; + d->len = size_count; + H5TOOLS_ENDDEBUG(""); +} + +/*------------------------------------------------------------------------- + * Function: parse_subset_params + * + * Purpose: Parse the so-called "terse" syntax for specifying subsetting parameters. + * + * Return: Success: struct subset_t object + * Failure: NULL + *------------------------------------------------------------------------- + */ +static struct subset_t * +parse_subset_params(const char *dset) +{ + struct subset_t *s = NULL; + char *brace; + + H5TOOLS_START_DEBUG(" - dset:%s", dset); + if ((brace = HDstrrchr(dset, '[')) != NULL) { + *brace++ = '\0'; + + s = (struct subset_t *)HDcalloc(1, sizeof(struct subset_t)); + parse_hsize_list(brace, &s->start); + + while (*brace && *brace != ';') + brace++; + + if (*brace) + brace++; + + parse_hsize_list(brace, &s->stride); + + while (*brace && *brace != ';') + brace++; + + if (*brace) + brace++; + + parse_hsize_list(brace, &s->count); + + while (*brace && *brace != ';') + brace++; + + if (*brace) + brace++; + + parse_hsize_list(brace, &s->block); + } + H5TOOLS_ENDDEBUG(""); + + return s; +} + /*------------------------------------------------------------------------- * Function: parse_command_line * * Purpose: parse command line input - * *------------------------------------------------------------------------- */ @@ -83,9 +204,11 @@ void parse_command_line(int argc, const char* argv[], const char** fname1, const int i; int opt; struct exclude_path_list *exclude_head, *exclude_prev, *exclude_node; + struct exclude_path_list *exclude_attr_head, *exclude_attr_prev, *exclude_attr_node; + H5TOOLS_START_DEBUG(""); /* process the command-line */ - memset(opts, 0, sizeof (diff_opt_t)); + HDmemset(opts, 0, sizeof (diff_opt_t)); /* assume equal contents initially */ opts->contents = 1; @@ -94,15 +217,18 @@ void parse_command_line(int argc, const char* argv[], const char** fname1, const opts->do_nans = 1; /* not Listing objects that are not comparable */ - opts->m_list_not_cmp = 0; + opts->mode_list_not_cmp = 0; /* initially no not-comparable. */ /**this is bad in mixing option with results**/ - opts->not_cmp=0; + opts->not_cmp = 0; /* init for exclude-path option */ exclude_head = NULL; + /* init for exclude-attribute option */ + exclude_attr_head = NULL; + /* parse command line options */ while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { switch ((char)opt) { @@ -122,7 +248,7 @@ void parse_command_line(int argc, const char* argv[], const char** fname1, const break; case 'v': - opts->m_verbose = 1; + opts->mode_verbose = 1; /* This for loop is for handling style like * -v, -v1, --verbose, --verbose=1. */ @@ -132,11 +258,11 @@ void parse_command_line(int argc, const char* argv[], const char** fname1, const */ if (!strcmp (argv[i], "-v")) { /* no arg */ opt_ind--; - opts->m_verbose_level = 0; + opts->mode_verbose_level = 0; break; } else if (!strncmp (argv[i], "-v", (size_t)2)) { - opts->m_verbose_level = atoi(&argv[i][2]); + opts->mode_verbose_level = atoi(&argv[i][2]); break; } @@ -144,11 +270,11 @@ void parse_command_line(int argc, const char* argv[], const char** fname1, const * long opt */ if (!strcmp (argv[i], "--verbose")) { /* no arg */ - opts->m_verbose_level = 0; + opts->mode_verbose_level = 0; break; } - else if ( !strncmp (argv[i], "--verbose", (size_t)9) && argv[i][9]=='=') { - opts->m_verbose_level = atoi(&argv[i][10]); + else if (!strncmp (argv[i], "--verbose", (size_t)9) && argv[i][9]=='=') { + opts->mode_verbose_level = atoi(&argv[i][10]); break; } } @@ -156,11 +282,11 @@ void parse_command_line(int argc, const char* argv[], const char** fname1, const case 'q': /* use quiet mode; supress the message "0 differences found" */ - opts->m_quiet = 1; + opts->mode_quiet = 1; break; case 'r': - opts->m_report = 1; + opts->mode_report = 1; break; case 'l': @@ -185,7 +311,7 @@ void parse_command_line(int argc, const char* argv[], const char** fname1, const } /* init */ - exclude_node->obj_path = (char*)opt_arg; + exclude_node->obj_path = opt_arg; exclude_node->obj_type = H5TRAV_TYPE_UNKNOWN; exclude_prev = exclude_head; @@ -202,38 +328,62 @@ void parse_command_line(int argc, const char* argv[], const char** fname1, const } break; + case 'A': + opts->exclude_attr_path = 1; + + /* create linked list of excluding objects */ + if( (exclude_attr_node = (struct exclude_path_list*) HDmalloc(sizeof(struct exclude_path_list))) == NULL) { + HDprintf("Error: lack of memory!\n"); + h5diff_exit(EXIT_FAILURE); + } + + /* init */ + exclude_attr_node->obj_path = opt_arg; + exclude_attr_node->obj_type = H5TRAV_TYPE_UNKNOWN; + exclude_attr_prev = exclude_attr_head; + + if (NULL == exclude_attr_head) { + exclude_attr_head = exclude_attr_node; + exclude_attr_head->next = NULL; + } + else { + while(NULL != exclude_attr_prev->next) + exclude_attr_prev = exclude_attr_prev->next; + + exclude_attr_node->next = NULL; + exclude_attr_prev->next = exclude_attr_node; + } + break; + case 'd': - opts->d = 1; + opts->delta_bool = 1; - if (check_d_input(opt_arg) == - 1) { + if (check_d_input(opt_arg) == -1) { HDprintf("<-d %s> is not a valid option\n", opt_arg); usage(); h5diff_exit(EXIT_FAILURE); } - opts->delta = atof(opt_arg); - - /* -d 0 is the same as default */ - if (H5_DBL_ABS_EQUAL(opts->delta, (double)0.0F)) - opts->d=0; + opts->delta = HDatof(opt_arg); + /* do not check against default, the DBL_EPSILON is being replaced by user */ break; case 'p': - opts->p = 1; + opts->percent_bool = 1; if (check_p_input(opt_arg) == -1) { HDprintf("<-p %s> is not a valid option\n", opt_arg); usage(); h5diff_exit(EXIT_FAILURE); } - opts->percent = atof(opt_arg); + opts->percent = HDatof(opt_arg); /* -p 0 is the same as default */ if (H5_DBL_ABS_EQUAL(opts->percent, (double)0.0F)) - opts->p = 0; + opts->percent_bool = 0; break; case 'n': - opts->n = 1; - if ( check_n_input(opt_arg) == -1) { + opts->count_bool = 1; + if (check_n_input(opt_arg) == -1) { HDprintf("<-n %s> is not a valid option\n", opt_arg); usage(); h5diff_exit(EXIT_FAILURE); @@ -246,12 +396,44 @@ void parse_command_line(int argc, const char* argv[], const char** fname1, const break; case 'c': - opts->m_list_not_cmp = 1; + opts->mode_list_not_cmp = 1; break; case 'e': opts->use_system_epsilon = 1; break; + + case '1': + opts->vol_info[0].type = VOL_BY_VALUE; + opts->vol_info[0].u.value = (H5VL_class_value_t)HDatoi(opt_arg); + opts->custom_vol[0] = TRUE; + break; + + case '2': + opts->vol_info[0].type = VOL_BY_NAME; + opts->vol_info[0].u.name = opt_arg; + opts->custom_vol[0] = TRUE; + break; + + case '3': + opts->vol_info[0].info_string = opt_arg; + break; + + case '4': + opts->vol_info[1].type = VOL_BY_VALUE; + opts->vol_info[1].u.value = (H5VL_class_value_t)HDatoi(opt_arg); + opts->custom_vol[1] = TRUE; + break; + + case '5': + opts->vol_info[1].type = VOL_BY_NAME; + opts->vol_info[1].u.name = opt_arg; + opts->custom_vol[1] = TRUE; + break; + + case '6': + opts->vol_info[1].info_string = opt_arg; + break; } } @@ -262,30 +444,46 @@ void parse_command_line(int argc, const char* argv[], const char** fname1, const if (opts->exclude_path) opts->exclude = exclude_head; + /* if exclude-attribute option is used, keep the exclude attr list */ + if (opts->exclude_attr_path) + opts->exclude_attr = exclude_attr_head; + /* check for file names to be processed */ - if (argc <= opt_ind || argv[ opt_ind + 1 ] == NULL) { + if (argc <= opt_ind || argv[opt_ind + 1] == NULL) { error_msg("missing file names\n"); usage(); h5diff_exit(EXIT_FAILURE); } - *fname1 = argv[ opt_ind ]; - *fname2 = argv[ opt_ind + 1 ]; - *objname1 = argv[ opt_ind + 2 ]; + *fname1 = argv[opt_ind]; + *fname2 = argv[opt_ind + 1]; + *objname1 = argv[opt_ind + 2]; + H5TOOLS_DEBUG("file1 = %s", *fname1); + H5TOOLS_DEBUG("file2 = %s", *fname2); if (*objname1 == NULL) { *objname2 = NULL; + H5TOOLS_ENDDEBUG("No obj names"); return; } + H5TOOLS_DEBUG("objname1 = %s", *objname1); - if (argv[ opt_ind + 3 ] != NULL) { - *objname2 = argv[ opt_ind + 3 ]; + if (argv[opt_ind + 3] != NULL) { + *objname2 = argv[opt_ind + 3]; } else { *objname2 = *objname1; } + H5TOOLS_DEBUG("objname2 = %s", *objname2); + /* + * TRILABS-227 is complete except for an issue with printing indices + * the following calls will enable subsetting + opts->sset[0] = parse_subset_params(*objname1); + opts->sset[1] = parse_subset_params(*objname2); + */ + H5TOOLS_ENDDEBUG(""); } @@ -293,26 +491,25 @@ void parse_command_line(int argc, const char* argv[], const char** fname1, const * Function: print_info * * Purpose: print several information messages after h5diff call - * *------------------------------------------------------------------------- */ void print_info(diff_opt_t* opts) { - if (opts->m_quiet || opts->err_stat) + if (opts->mode_quiet || opts->err_stat) return; if (opts->cmn_objs == 0) { HDprintf("No common objects found. Files are not comparable.\n"); - if (!opts->m_verbose) + if (!opts->mode_verbose) HDprintf("Use -v for a list of objects.\n"); } if (opts->not_cmp == 1) { - if (opts->m_list_not_cmp == 0) { + if (opts->mode_list_not_cmp == 0) { HDprintf("--------------------------------\n"); HDprintf("Some objects are not comparable\n"); HDprintf("--------------------------------\n"); - if (opts->m_verbose) + if (opts->mode_verbose) HDprintf("Use -c for a list of objects without details of differences.\n"); else HDprintf("Use -c for a list of objects.\n"); @@ -326,19 +523,10 @@ void print_info(diff_opt_t* opts) * Purpose: check for valid input * * Return: 1 for ok, -1 for fail - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: May 9, 2003 - * - * Comments: - * - * Modifications: - * *------------------------------------------------------------------------- */ H5_ATTR_PURE static int -check_n_input( const char *str ) +check_n_input(const char *str) { unsigned i; char c; @@ -362,28 +550,21 @@ check_n_input( const char *str ) * Purpose: check for a valid p option input * * Return: 1 for ok, -1 for fail - * - * Date: May 9, 2003 - * - * Comments: - * - * Modifications: - * *------------------------------------------------------------------------- */ static int -check_p_input( const char *str ) +check_p_input(const char *str) { double x; /* - the atof return value on a hexadecimal input is different - on some systems; we do a character check for this - */ + * the atof return value on a hexadecimal input is different + * on some systems; we do a character check for this + */ if (HDstrlen(str) > 2 && str[0] == '0' && str[1] == 'x') return -1; - x = atof(str); + x = HDatof(str); if (x < 0) return -1; @@ -396,28 +577,21 @@ check_p_input( const char *str ) * Purpose: check for a valid d option input * * Return: 1 for ok, -1 for fail - * - * Date: November 11, 2007 - * - * Comments: - * - * Modifications: - * *------------------------------------------------------------------------- */ static int -check_d_input( const char *str ) +check_d_input(const char *str) { double x; /* - the atof return value on a hexadecimal input is different - on some systems; we do a character check for this - */ + * the atof return value on a hexadecimal input is different + * on some systems; we do a character check for this + */ if (HDstrlen(str) > 2 && str[0] == '0' && str[1] == 'x') return -1; - x = atof(str); + x = HDatof(str); if (x < 0) return -1; @@ -430,7 +604,6 @@ check_d_input( const char *str ) * Purpose: print a usage message * * Return: void - * *------------------------------------------------------------------------- */ @@ -455,14 +628,25 @@ void usage(void) PRINTVALSTREAM(rawoutstream, " Verbose mode with level. Print differences and list of objects.\n"); PRINTVALSTREAM(rawoutstream, " Level of detail depends on value of N:\n"); PRINTVALSTREAM(rawoutstream, " 0 : Identical to '-v' or '--verbose'.\n"); - PRINTVALSTREAM(rawoutstream, " 1 : All level 0 information plus one-line attribute\n"); - PRINTVALSTREAM(rawoutstream, " status summary.\n"); - PRINTVALSTREAM(rawoutstream, " 2 : All level 1 information plus extended attribute\n"); - PRINTVALSTREAM(rawoutstream, " status report.\n"); + PRINTVALSTREAM(rawoutstream, " 1 : All level 0 information plus one-line attribute status summary.\n"); + PRINTVALSTREAM(rawoutstream, " 2 : All level 1 information plus extended attribute status report.\n"); + PRINTVALSTREAM(rawoutstream, " 3 : All level 2 information plus file names.\n"); PRINTVALSTREAM(rawoutstream, " -q, --quiet\n"); PRINTVALSTREAM(rawoutstream, " Quiet mode. Do not produce output.\n"); PRINTVALSTREAM(rawoutstream, " --enable-error-stack\n"); PRINTVALSTREAM(rawoutstream, " Prints messages from the HDF5 error stack as they occur.\n"); + PRINTVALSTREAM(rawoutstream, " --vol-value-1 Value (ID) of the VOL connector to use for opening the\n"); + PRINTVALSTREAM(rawoutstream, " first HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, " --vol-name-1 Name of the VOL connector to use for opening the first\n"); + PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, " --vol-info-1 VOL-specific info to pass to the VOL connector used for\n"); + PRINTVALSTREAM(rawoutstream, " opening the first HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, " --vol-value-2 Value (ID) of the VOL connector to use for opening the\n"); + PRINTVALSTREAM(rawoutstream, " second HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, " --vol-name-2 Name of the VOL connector to use for opening the second\n"); + PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, " --vol-info-2 VOL-specific info to pass to the VOL connector used for\n"); + PRINTVALSTREAM(rawoutstream, " opening the second HDF5 file specified\n"); PRINTVALSTREAM(rawoutstream, " --follow-symlinks\n"); PRINTVALSTREAM(rawoutstream, " Follow symbolic links (soft links and external links and compare the)\n"); PRINTVALSTREAM(rawoutstream, " links' target objects.\n"); @@ -535,7 +719,14 @@ void usage(void) PRINTVALSTREAM(rawoutstream, " excluded.\n"); PRINTVALSTREAM(rawoutstream, " This option can be used repeatedly to exclude multiple paths.\n"); PRINTVALSTREAM(rawoutstream, "\n"); - + PRINTVALSTREAM(rawoutstream, " --exclude-attribute \"path/to/object/with/attribute\"\n"); + PRINTVALSTREAM(rawoutstream, " Exclude attributes on the specified path to an object when comparing files or groups.\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, " If there are multiple paths to an object, only the specified path(s)\n"); + PRINTVALSTREAM(rawoutstream, " will be excluded; the comparison will include any path not explicitly\n"); + PRINTVALSTREAM(rawoutstream, " excluded.\n"); + PRINTVALSTREAM(rawoutstream, " This option can be used repeatedly to exclude multiple paths.\n"); + PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " Modes of output:\n"); PRINTVALSTREAM(rawoutstream, " Default mode: print the number of differences found and where they occured\n"); PRINTVALSTREAM(rawoutstream, " -r Report mode: print the above plus the differences\n"); @@ -566,7 +757,22 @@ void usage(void) PRINTVALSTREAM(rawoutstream, " (The option --follow-symlinks overrides the default behavior when\n"); PRINTVALSTREAM(rawoutstream, " symbolic links are compared.).\n"); PRINTVALSTREAM(rawoutstream, "\n"); - + /* + * TRILABS-227 is complete except for an issue with printing indices + * the following will be needed for subsetting + PRINTVALSTREAM(rawoutstream, " Subsetting options:\n"); + PRINTVALSTREAM(rawoutstream, " Subsetting is available by using the fcompact form of subsetting, as follows:\n"); + PRINTVALSTREAM(rawoutstream, " obj1 /foo/mydataset[START;STRIDE;COUNT;BLOCK]\n"); + PRINTVALSTREAM(rawoutstream, " It is not required to use all parameters, but until the last parameter value used,\n"); + PRINTVALSTREAM(rawoutstream, " all of the semicolons (;) are required, even when a parameter value is not specified. Example:\n"); + PRINTVALSTREAM(rawoutstream, " obj1 /foo/mydataset[START;;COUNT;BLOCK]\n"); + PRINTVALSTREAM(rawoutstream, " obj1 /foo/mydataset[START]\n"); + PRINTVALSTREAM(rawoutstream, " The STRIDE, COUNT, and BLOCK parameters are optional and will default to 1 in\n"); + PRINTVALSTREAM(rawoutstream, " each dimension. START is optional and will default to 0 in each dimension.\n"); + PRINTVALSTREAM(rawoutstream, " Each of START, STRIDE, COUNT, and BLOCK must be a comma-separated list of integers with\n"); + PRINTVALSTREAM(rawoutstream, " one integer for each dimension of the dataset.\n"); + PRINTVALSTREAM(rawoutstream, "\n"); +*/ PRINTVALSTREAM(rawoutstream, " Exit code:\n"); PRINTVALSTREAM(rawoutstream, " 0 if no differences, 1 if differences found, 2 if error\n"); PRINTVALSTREAM(rawoutstream, "\n"); diff --git a/tools/src/h5diff/h5diff_main.c b/tools/src/h5diff/h5diff_main.c index c5a0cbf..33d6570 100644 --- a/tools/src/h5diff/h5diff_main.c +++ b/tools/src/h5diff/h5diff_main.c @@ -69,10 +69,7 @@ int main(int argc, const char *argv[]) { int ret; - H5E_auto2_t func; - H5E_auto2_t tools_func; - void *edata; - void *tools_edata; + int i; const char *fname1 = NULL; const char *fname2 = NULL; const char *objname1 = NULL; @@ -83,27 +80,17 @@ int main(int argc, const char *argv[]) h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); - /* Disable error reporting */ - H5Eget_auto2(H5E_DEFAULT, &func, &edata); - H5Eset_auto2(H5E_DEFAULT, NULL, NULL); - /* Initialize h5tools lib */ h5tools_init(); - /* Disable tools error reporting */ - H5Eget_auto2(H5tools_ERR_STACK_g, &tools_func, &tools_edata); - H5Eset_auto2(H5tools_ERR_STACK_g, NULL, NULL); - /*------------------------------------------------------------------------- * process the command-line *------------------------------------------------------------------------- */ parse_command_line(argc, argv, &fname1, &fname2, &objname1, &objname2, &opts); - if (enable_error_stack > 0) { - H5Eset_auto2(H5E_DEFAULT, func, edata); - H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata); - } + /* enable error reporting if command line option */ + h5tools_error_report(); /*------------------------------------------------------------------------- * do the diff @@ -130,6 +117,23 @@ int main(int argc, const char *argv[]) if (opts.err_stat) ret = 2; + /* free any buffers */ + for (i = 0; i < 2; i++) { + if (opts.sset[i]) { + if(opts.sset[i]->start.data) + HDfree(opts.sset[i]->start.data); + if(opts.sset[i]->stride.data) + HDfree(opts.sset[i]->stride.data); + if(opts.sset[i]->count.data) + HDfree(opts.sset[i]->count.data); + if(opts.sset[i]->block.data) + HDfree(opts.sset[i]->block.data); + + HDfree(opts.sset[i]); + opts.sset[i]=NULL; + } + } + h5diff_exit(ret); } diff --git a/tools/src/h5dump/h5dump.c b/tools/src/h5dump/h5dump.c index d9ea4b0..2b21b1c 100644 --- a/tools/src/h5dump/h5dump.c +++ b/tools/src/h5dump/h5dump.c @@ -18,30 +18,35 @@ /* Name of tool */ #define PROGRAMNAME "h5dump" -static const char *driver = NULL; /* The driver to open the file with. */ -const char *outfname=NULL; -static int doxml = 0; -static int useschema = 1; -static const char *xml_dtd_uri = NULL; +static const char *driver_name_g = NULL; /* The driver to open the file with. */ +const char *outfname_g = NULL; +static hbool_t doxml_g = FALSE; +static hbool_t useschema_g = TRUE; +static const char *xml_dtd_uri_g = NULL; + +static hbool_t use_custom_vol_g = FALSE; +static h5tools_vol_info_t vol_info_g; #ifdef H5_HAVE_ROS3_VFD -static H5FD_ros3_fapl_t ros3_fa = { - 1, /* version */ - false, /* authenticate */ - "", /* aws region */ - "", /* access key id */ - "", /* secret access key */ +/* Default "anonymous" S3 configuration */ +static H5FD_ros3_fapl_t ros3_fa_g = { + 1, /* Structure Version */ + false, /* Authenticate? */ + "", /* AWS Region */ + "", /* Access Key ID */ + "", /* Secret Access Key */ }; #endif /* H5_HAVE_ROS3_VFD */ #ifdef H5_HAVE_LIBHDFS -static H5FD_hdfs_fapl_t hdfs_fa = { - 1, /* fapl version */ - "localhost", /* namenode name */ - 0, /* namenode port */ - "", /* kerberos ticket cache */ - "", /* user name */ - 2048, /* stream buffer size */ +/* "Default" HDFS configuration */ +static H5FD_hdfs_fapl_t hdfs_fa_g = { + 1, /* Structure Version */ + "localhost", /* Namenode Name */ + 0, /* Namenode Port */ + "", /* Kerberos ticket cache */ + "", /* User name */ + 2048, /* Stream buffer size */ }; #endif /* H5_HAVE_LIBHDFS */ @@ -211,6 +216,9 @@ static struct long_options l_opts[] = { { "vds-gap-size", require_arg, 'G' }, { "s3-cred", require_arg, '$' }, { "hdfs-attrs", require_arg, '#' }, + { "vol-value", require_arg, '1' }, + { "vol-name", require_arg, '2' }, + { "vol-info", require_arg, '3' }, { NULL, 0, '\0' } }; @@ -268,6 +276,12 @@ usage(const char *prog) PRINTVALSTREAM(rawoutstream, " ,,\n"); PRINTVALSTREAM(rawoutstream, " )\n"); PRINTVALSTREAM(rawoutstream, " Any absent attribute will use a default value.\n"); + PRINTVALSTREAM(rawoutstream, " --vol-value Value (ID) of the VOL connector to use for opening the\n"); + PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, " --vol-name Name of the VOL connector to use for opening the\n"); + PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, " --vol-info VOL-specific info to pass to the VOL connector used for\n"); + PRINTVALSTREAM(rawoutstream, " opening the HDF5 file specified\n"); PRINTVALSTREAM(rawoutstream, "--------------- Object Options ---------------\n"); PRINTVALSTREAM(rawoutstream, " -a P, --attribute=P Print the specified attribute\n"); PRINTVALSTREAM(rawoutstream, " If an attribute name contains a slash (/), escape the\n"); @@ -641,12 +655,12 @@ parse_hsize_list(const char *h_list, subset_d *d) *------------------------------------------------------------------------- */ static struct subset_t * -parse_subset_params(char *dset) +parse_subset_params(const char *dset) { struct subset_t *s = NULL; char *brace; - if (!disable_compact_subset && ((brace = HDstrrchr(dset, '[')) != NULL)) { + if (!dump_opts.disable_compact_subset && ((brace = HDstrrchr(dset, '[')) != NULL)) { *brace++ = '\0'; s = (struct subset_t *)HDcalloc(1, sizeof(struct subset_t)); @@ -877,50 +891,50 @@ parse_command_line(int argc, const char *argv[]) parse_start: switch ((char)opt) { case 'R': - display_region = TRUE; + dump_opts.display_region = TRUE; region_output = TRUE; break; case 'B': - display_bb = TRUE; + dump_opts.display_bb = TRUE; last_was_dset = FALSE; break; case 'n': - display_fi = TRUE; + dump_opts.display_fi = TRUE; last_was_dset = FALSE; if (opt_arg != NULL) h5trav_set_verbose(HDatoi(opt_arg)); break; case 'p': - display_dcpl = TRUE; + dump_opts.display_dcpl = TRUE; break; case 'y': - display_ai = FALSE; + dump_opts.display_ai = FALSE; break; case 'e': - display_escape = TRUE; + dump_opts.display_escape = TRUE; break; case 'H': - display_data = FALSE; - display_attr_data = FALSE; + dump_opts.display_data = FALSE; + dump_opts.display_attr_data = FALSE; last_was_dset = FALSE; break; case 'A': if (opt_arg != NULL) { if(0 == HDatoi(opt_arg)) - include_attrs = FALSE; + dump_opts.include_attrs = FALSE; } else { - display_data = FALSE; - display_attr_data = TRUE; + dump_opts.display_data = FALSE; + dump_opts.display_attr_data = TRUE; last_was_dset = FALSE; } break; case 'i': - display_oid = TRUE; + dump_opts.display_oid = TRUE; last_was_dset = FALSE; break; case 'r': - display_char = TRUE; + dump_opts.display_char = TRUE; break; case 'V': print_version(h5tools_getprogname()); @@ -941,7 +955,7 @@ parse_start: } break; case 'N': - display_all = 0; + dump_opts.display_all = 0; for (i = 0; i < argc; i++) if (!hand[i].func) { @@ -953,7 +967,7 @@ parse_start: last_was_dset = FALSE; break; case 'a': - display_all = 0; + dump_opts.display_all = 0; for (i = 0; i < argc; i++) if (!hand[i].func) { @@ -965,7 +979,7 @@ parse_start: last_was_dset = FALSE; break; case 'd': - display_all = 0; + dump_opts.display_all = 0; for (i = 0; i < argc; i++) if (!hand[i].func) { @@ -979,10 +993,10 @@ parse_start: last_was_dset = TRUE; break; case 'f': - driver = opt_arg; + driver_name_g = opt_arg; break; case 'g': - display_all = 0; + dump_opts.display_all = 0; for (i = 0; i < argc; i++) if (!hand[i].func) { @@ -994,7 +1008,7 @@ parse_start: last_was_dset = FALSE; break; case 'l': - display_all = 0; + dump_opts.display_all = 0; for (i = 0; i < argc; i++) if (!hand[i].func) { @@ -1006,7 +1020,7 @@ parse_start: last_was_dset = FALSE; break; case 't': - display_all = 0; + dump_opts.display_all = 0; for (i = 0; i < argc; i++) if (!hand[i].func) { @@ -1033,13 +1047,13 @@ parse_start: } } else { - if(display_attr_data && !display_data) { + if(dump_opts.display_attr_data && !dump_opts.display_data) { if (h5tools_set_attr_output_file(opt_arg, 0) < 0) { usage(h5tools_getprogname()); goto error; } } - if(display_data || display_all) { + if(dump_opts.display_data || dump_opts.display_all) { if (h5tools_set_data_output_file(opt_arg, 0) < 0) { usage(h5tools_getprogname()); goto error; @@ -1047,9 +1061,9 @@ parse_start: } } - usingdasho = TRUE; + dump_opts.usingdasho = TRUE; last_was_dset = FALSE; - outfname = opt_arg; + outfname_g = opt_arg; break; case 'b': @@ -1061,8 +1075,8 @@ parse_start: } } bin_output = TRUE; - if (outfname!=NULL) { - if (h5tools_set_data_output_file(outfname, 1) < 0) { + if (outfname_g != NULL) { + if (h5tools_set_data_output_file(outfname_g, 1) < 0) { /* failed to set output file */ usage(h5tools_getprogname()); goto error; @@ -1097,14 +1111,14 @@ parse_start: usage(h5tools_getprogname()); goto error; } - display_packed_bits = TRUE; + dump_opts.display_packed_bits = TRUE; break; case 'v': - display_vds_first = TRUE; + dump_opts.display_vds_first = TRUE; break; case 'G': - vds_gap_size = HDatoi(opt_arg); - if (vds_gap_size < 0) { + dump_opts.vds_gap_size = HDatoi(opt_arg); + if (dump_opts.vds_gap_size < 0) { usage(h5tools_getprogname()); goto error; } @@ -1113,15 +1127,15 @@ parse_start: /** begin XML parameters **/ case 'x': /* select XML output */ - doxml = TRUE; - useschema = TRUE; + doxml_g = TRUE; + useschema_g = TRUE; h5tools_dump_header_format = NULL; dump_function_table = &xml_function_table; h5tools_nCols = 0; break; case 'u': - doxml = TRUE; - useschema = FALSE; + doxml_g = TRUE; + useschema_g = FALSE; xmlnsprefix = ""; h5tools_dump_header_format = NULL; dump_function_table = &xml_function_table; @@ -1130,7 +1144,7 @@ parse_start: case 'D': /* specify alternative XML DTD or schema */ /* To Do: check format of this value? */ - xml_dtd_uri = opt_arg; + xml_dtd_uri_g = opt_arg; h5tools_nCols = 0; break; @@ -1143,7 +1157,7 @@ parse_start: case 'X': /* specify XML namespace (default="hdf5:"), or none */ /* To Do: check format of this value? */ - if (!useschema) { + if (!useschema_g) { usage(h5tools_getprogname()); goto error; } @@ -1241,7 +1255,7 @@ end_collect: enable_error_stack = 1; break; case 'C': - disable_compact_subset = TRUE; + dump_opts.disable_compact_subset = TRUE; break; case 'h': usage(h5tools_getprogname()); @@ -1251,106 +1265,53 @@ end_collect: goto done; case '$': -#ifndef H5_HAVE_ROS3_VFD +#ifdef H5_HAVE_ROS3_VFD + if (h5tools_parse_ros3_fapl_tuple(opt_arg, ',', &ros3_fa_g) < 0) { + error_msg("failed to parse S3 VFD credential info\n"); + usage(h5tools_getprogname()); + free_handler(hand, argc); + hand = NULL; + h5tools_setstatus(EXIT_FAILURE); + goto done; + } +#else error_msg("Read-Only S3 VFD not enabled.\n"); h5tools_setstatus(EXIT_FAILURE); goto done; -#else - /* s3 credential */ - { - char **s3_cred = NULL; - char *s3_cred_string = NULL; - const char *ccred[3]; - unsigned nelems = 0; - if (FAIL == parse_tuple(opt_arg, ',', &s3_cred_string, &nelems, &s3_cred)) { - error_msg("unable to parse malformed s3 credentials\n"); - usage(h5tools_getprogname()); - free_handler(hand, argc); - hand = NULL; - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - if (nelems != 3) { - error_msg("s3 credentials expects 3 elements\n"); - usage(h5tools_getprogname()); - free_handler(hand, argc); - hand = NULL; - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - ccred[0] = (const char *)s3_cred[0]; - ccred[1] = (const char *)s3_cred[1]; - ccred[2] = (const char *)s3_cred[2]; - if (0 == h5tools_populate_ros3_fapl(&ros3_fa, ccred)) { - error_msg("Invalid S3 credentials\n"); - usage(h5tools_getprogname()); - free_handler(hand, argc); - hand = NULL; - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - HDfree(s3_cred); - HDfree(s3_cred_string); - } /* s3 credential block */ +#endif break; -#endif /* H5_HAVE_ROS3_VFD */ case '#': -#ifndef H5_HAVE_LIBHDFS - error_msg("HDFS VFD is not enabled.\n"); - goto error; +#ifdef H5_HAVE_LIBHDFS + if (h5tools_parse_hdfs_fapl_tuple(opt_arg, ',', &hdfs_fa_g) < 0) { + error_msg("failed to parse HDFS VFD configuration info\n"); + usage(h5tools_getprogname()); + free_handler(hand, argc); + hand = NULL; + h5tools_setstatus(EXIT_FAILURE); + goto done; + } #else - { - /* read hdfs properties tuple and store values in `hdfs_fa` */ - unsigned nelems = 0; - char *props_src = NULL; - char **props = NULL; - unsigned long k = 0; - if (FAIL == parse_tuple((const char *)opt_arg, ',', &props_src, &nelems, &props)) { - error_msg("unable to parse hdfs properties tuple\n"); - goto error; - } - /* sanity-check tuple count - */ - if (nelems != 5) { - h5tools_setstatus(EXIT_FAILURE); - goto error; - } - /* Populate fapl configuration structure with given - * properties. - * WARNING: No error-checking is done on length of input - * strings... Silent overflow is possible, albeit - * unlikely. - */ - if (strncmp(props[0], "", 1)) - HDstrncpy(hdfs_fa.namenode_name, (const char *)props[0], HDstrlen(props[0])); + error_msg("HDFS VFD not enabled.\n"); + h5tools_setstatus(EXIT_FAILURE); + goto done; +#endif + break; - if (strncmp(props[1], "", 1)) { - k = strtoul((const char *)props[1], NULL, 0); - if (errno == ERANGE) { - h5tools_setstatus(EXIT_FAILURE); - goto error; - } - hdfs_fa.namenode_port = (int32_t)k; - } - if (strncmp(props[2], "", 1)) - HDstrncpy(hdfs_fa.kerberos_ticket_cache, (const char *)props[2], HDstrlen(props[2])); + case '1': + vol_info_g.type = VOL_BY_VALUE; + vol_info_g.u.value = (H5VL_class_value_t)HDatoi(opt_arg); + use_custom_vol_g = TRUE; + break; - if (strncmp(props[3], "", 1)) - HDstrncpy(hdfs_fa.user_name, (const char *)props[3], HDstrlen(props[3])); + case '2': + vol_info_g.type = VOL_BY_NAME; + vol_info_g.u.name = opt_arg; + use_custom_vol_g = TRUE; + break; - if (strncmp(props[4], "", 1)) { - k = strtoul((const char *)props[4], NULL, 0); - if (errno == ERANGE) { - h5tools_setstatus(EXIT_FAILURE); - goto error; - } - hdfs_fa.stream_buffer_size = (int32_t)k; - } - HDfree(props); - HDfree(props_src); - } -#endif /* H5_HAVE_LIBHDFS */ + case '3': + vol_info_g.info_string = opt_arg; break; case '?': @@ -1396,14 +1357,10 @@ main(int argc, const char *argv[]) hid_t fid = H5I_INVALID_HID; hid_t gid = H5I_INVALID_HID; hid_t fapl_id = H5P_DEFAULT; - H5E_auto2_t func; - H5E_auto2_t tools_func; H5O_info2_t oi; struct handler_t *hand = NULL; int i; unsigned u; - void *edata; - void *tools_edata; char *fname = NULL; h5tools_setprogname(PROGRAMNAME); @@ -1412,63 +1369,50 @@ main(int argc, const char *argv[]) dump_function_table = &ddl_function_table; dump_indent = 0; - /* Disable error reporting */ - H5Eget_auto2(H5E_DEFAULT, &func, &edata); - H5Eset_auto2(H5E_DEFAULT, NULL, NULL); - /* Initialize h5tools lib */ h5tools_init(); - /* Disable tools error reporting */ - H5Eget_auto2(H5tools_ERR_STACK_g, &tools_func, &tools_edata); - H5Eset_auto2(H5tools_ERR_STACK_g, NULL, NULL); - if((hand = parse_command_line(argc, argv))==NULL) { goto done; } - if (bin_output && outfname == NULL) { + if (bin_output && outfname_g == NULL) { error_msg("binary output requires a file name, use -o \n"); h5tools_setstatus(EXIT_FAILURE); goto done; } - if (enable_error_stack > 0) { - H5Eset_auto2(H5E_DEFAULT, func, edata); - H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata); - } - /* Check for conflicting options */ - if (doxml) { - if (!display_all) { + if (doxml_g) { + if (!dump_opts.display_all) { error_msg("option \"%s\" not available for XML\n", "to display selected objects"); h5tools_setstatus(EXIT_FAILURE); goto done; } - else if (display_bb) { + else if (dump_opts.display_bb) { error_msg("option \"%s\" not available for XML\n", "--boot-block"); h5tools_setstatus(EXIT_FAILURE); goto done; } - else if (display_oid == 1) { + else if (dump_opts.display_oid == 1) { error_msg("option \"%s\" not available for XML\n", "--object-ids"); h5tools_setstatus(EXIT_FAILURE); goto done; } - else if (display_char == TRUE) { + else if (dump_opts.display_char == TRUE) { error_msg("option \"%s\" not available for XML\n", "--string"); h5tools_setstatus(EXIT_FAILURE); goto done; } - else if (usingdasho) { + else if (dump_opts.usingdasho) { error_msg("option \"%s\" not available for XML\n", "--output"); h5tools_setstatus(EXIT_FAILURE); goto done; } } else { - if (xml_dtd_uri) { - warn_msg("option \"%s\" only applies with XML: %s\n", "--xml-dtd", xml_dtd_uri); + if (xml_dtd_uri_g) { + warn_msg("option \"%s\" only applies with XML: %s\n", "--xml-dtd", xml_dtd_uri_g); } } @@ -1478,57 +1422,58 @@ main(int argc, const char *argv[]) h5tools_setstatus(EXIT_FAILURE); goto done; } + + /* enable error reporting if command line option */ + h5tools_error_report(); + /* Initialize indexing options */ h5trav_set_index(sort_by, sort_order); - if (driver != NULL) { - void *conf_fa = NULL; + if (driver_name_g != NULL) { + h5tools_vfd_info_t vfd_info; - if (!strcmp(driver, "ros3")) { -#ifndef H5_HAVE_ROS3_VFD + vfd_info.info = NULL; + vfd_info.name = driver_name_g; + + if (!HDstrcmp(driver_name_g, drivernames[ROS3_VFD_IDX])) { +#ifdef H5_HAVE_ROS3_VFD + vfd_info.info = (void *)&ros3_fa_g; +#else error_msg("Read-Only S3 VFD not enabled.\n"); h5tools_setstatus(EXIT_FAILURE); goto done; +#endif + } + else if (!HDstrcmp(driver_name_g, drivernames[HDFS_VFD_IDX])) { +#ifdef H5_HAVE_LIBHDFS + vfd_info.info = (void *)&hdfs_fa_g; #else - conf_fa = (void *)&ros3_fa; -#endif /* H5_HAVE_ROS3_VFD */ + error_msg("The HDFS VFD is not enabled.\n"); + h5tools_setstatus(EXIT_FAILURE); + goto done; +#endif } - else if (!HDstrcmp(driver, "hdfs")) { -#ifndef H5_HAVE_LIBHDFS - error_msg("HDFS VFD is not enabled.\n"); + + if ((fapl_id = h5tools_get_fapl(H5P_DEFAULT, NULL, &vfd_info)) < 0) { + error_msg("unable to create FAPL for file access\n"); h5tools_setstatus(EXIT_FAILURE); goto done; -#else - conf_fa = (void *)&hdfs_fa; -#endif /* H5_HAVE_LIBHDFS */ } + } /* driver name defined */ - if (conf_fa != NULL) { - fapl_id = H5Pcreate(H5P_FILE_ACCESS); - if (fapl_id < 0) { - error_msg("unable to create fapl entry\n"); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - /* driver guaranteed "ros3" or "hdfs" */ - /* conf_fa appropriate to driver */ - if (0 == h5tools_set_configured_fapl(fapl_id, driver, conf_fa)) { - error_msg("unable to set fapl\n"); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } + if (use_custom_vol_g) { + if ((fapl_id = h5tools_get_fapl(H5P_DEFAULT, &vol_info_g, NULL)) < 0) { + error_msg("unable to create FAPL for file access\n"); + h5tools_setstatus(EXIT_FAILURE); + goto done; } - } /* driver defined */ + } while(opt_ind < argc) { fname = HDstrdup(argv[opt_ind++]); - if (fapl_id != H5P_DEFAULT) { - fid = H5Fopen(fname, H5F_ACC_RDONLY, fapl_id); - } - else { - fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, driver, NULL, 0); - } + fid = h5tools_fopen(fname, H5F_ACC_RDONLY, fapl_id, + (fapl_id == H5P_DEFAULT) ? FALSE : TRUE, NULL, 0); if (fid < 0) { error_msg("unable to open file \"%s\"\n", fname); @@ -1542,23 +1487,23 @@ main(int argc, const char *argv[]) /* Prepare to find objects that might be targets of a reference */ fill_ref_path_table(fid); - if(doxml) { + if(doxml_g) { /* initialize XML */ /* reset prefix! */ HDstrcpy(prefix, ""); /* make sure the URI is initialized to something */ - if (xml_dtd_uri == NULL) { - if (useschema) { - xml_dtd_uri = DEFAULT_XSD; + if (xml_dtd_uri_g == NULL) { + if (useschema_g) { + xml_dtd_uri_g = DEFAULT_XSD; } else { - xml_dtd_uri = DEFAULT_DTD; + xml_dtd_uri_g = DEFAULT_DTD; xmlnsprefix = ""; } } else { - if (useschema && HDstrcmp(xmlnsprefix,"")) { + if (useschema_g && HDstrcmp(xmlnsprefix,"")) { error_msg("Cannot set Schema URL for a qualified namespace--use -X or -U option with -D \n"); h5tools_setstatus(EXIT_FAILURE); goto done; @@ -1591,16 +1536,16 @@ main(int argc, const char *argv[]) } /* end if */ /* start to dump - display file header information */ - if (!doxml) { + if (!doxml_g) { begin_obj(h5tools_dump_header_format->filebegin, fname, h5tools_dump_header_format->fileblockbegin); } else { PRINTVALSTREAM(rawoutstream, "\n"); /* alternative first element, depending on schema or DTD. */ - if (useschema) { + if (useschema_g) { if (HDstrcmp(xmlnsprefix,"") == 0) { - PRINTSTREAM(rawoutstream, "\n", xml_dtd_uri); + PRINTSTREAM(rawoutstream, "\n", xml_dtd_uri_g); } else { /* TO DO: make -url option work in this case (may need new option) */ @@ -1620,13 +1565,13 @@ main(int argc, const char *argv[]) } } else { - PRINTSTREAM(rawoutstream, "\n", xml_dtd_uri); + PRINTSTREAM(rawoutstream, "\n", xml_dtd_uri_g); PRINTVALSTREAM(rawoutstream, "\n"); } } - if (!doxml) { - if (display_fi) { + if (!doxml_g) { + if (dump_opts.display_fi) { PRINTVALSTREAM(rawoutstream, "\n"); dump_fcontents(fid); end_obj(h5tools_dump_header_format->fileend,h5tools_dump_header_format->fileblockend); @@ -1634,20 +1579,20 @@ main(int argc, const char *argv[]) goto done; } - if (display_bb) + if (dump_opts.display_bb) dump_fcpl(fid); } - if(display_all) { + if(dump_opts.display_all) { if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) { error_msg("unable to open root group\n"); h5tools_setstatus(EXIT_FAILURE); } else { - if (!doxml) + if (!doxml_g) dump_indent += COL; dump_function_table->dump_group_function(gid, "/" ); - if (!doxml) + if (!doxml_g) dump_indent -= COL; PRINTVALSTREAM(rawoutstream, "\n"); } @@ -1660,7 +1605,7 @@ main(int argc, const char *argv[]) } else { /* Note: this option is not supported for XML */ - if(doxml) { + if(doxml_g) { error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__); h5tools_setstatus(EXIT_FAILURE); goto done; @@ -1674,7 +1619,7 @@ main(int argc, const char *argv[]) PRINTVALSTREAM(rawoutstream, "\n"); } - if (!doxml) { + if (!doxml_g) { end_obj(h5tools_dump_header_format->fileend, h5tools_dump_header_format->fileblockend); PRINTVALSTREAM(rawoutstream, "\n"); } @@ -1703,8 +1648,6 @@ main(int argc, const char *argv[]) /* To Do: clean up XML table */ - H5Eset_auto2(H5E_DEFAULT, func, edata); - leave(h5tools_getstatus()); done: @@ -1734,8 +1677,6 @@ done: /* To Do: clean up XML table */ - H5Eset_auto2(H5E_DEFAULT, func, edata); - leave(h5tools_getstatus()); } /* main */ diff --git a/tools/src/h5dump/h5dump.h b/tools/src/h5dump/h5dump.h index ca1fef6..548af09 100644 --- a/tools/src/h5dump/h5dump.h +++ b/tools/src/h5dump/h5dump.h @@ -52,8 +52,8 @@ typedef struct h5dump_table_list_t { h5dump_table_list_t table_list = {0, 0, NULL}; table_t *group_table = NULL, *dset_table = NULL, *type_table = NULL; -unsigned dump_indent = 0; /*how far in to indent the line */ +unsigned dump_indent = 0; /* how far in to indent the line */ int unamedtype = 0; /* shared datatype with no name */ hbool_t hit_elink = FALSE; /* whether we have traversed an external link */ size_t prefix_len = 1024; @@ -61,23 +61,26 @@ char *prefix = NULL; const char *fp_format = NULL; /* things to display or which are set via command line parameters */ -int display_all = TRUE; -int display_oid = FALSE; -int display_data = TRUE; -int display_attr_data = TRUE; -int display_char = FALSE; /*print 1-byte numbers as ASCII */ -int usingdasho = FALSE; -int display_bb = FALSE; /*superblock */ -int display_dcpl = FALSE; /*dcpl */ -int display_fi = FALSE; /*file index */ -int display_ai = TRUE; /*array index */ -int display_escape = FALSE; /*escape non printable characters */ -int display_region = FALSE; /*print region reference data */ -int disable_compact_subset= FALSE; /* disable compact form of subset notation */ -int display_packed_bits = FALSE; /*print 1-8 byte numbers as packed bits*/ -int include_attrs = TRUE; /* Display attributes */ -int display_vds_first = FALSE; /* vds display to all by default*/ -int vds_gap_size = 0; /* vds skip missing files default is none */ +typedef struct { + int display_all; + int display_oid; + int display_data; + int display_attr_data; + int display_char; /* print 1-byte numbers as ASCII */ + int usingdasho; + int display_bb; /* superblock */ + int display_dcpl; /* dcpl */ + int display_fi; /* file index */ + int display_ai; /* array index */ + int display_escape; /* escape non printable characters */ + int display_region; /* print region reference data */ + int disable_compact_subset; /* disable compact form of subset notation */ + int display_packed_bits; /* print 1-8 byte numbers as packed bits */ + int include_attrs; /* Display attributes */ + int display_vds_first; /* vds display to all by default */ + int vds_gap_size; /* vds skip missing files default is none */ +} dump_opt_t; +dump_opt_t dump_opts = {TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, 0}; #define PACKED_BITS_MAX 8 /* Maximum number of packed-bits to display */ #define PACKED_BITS_SIZE_MAX (8*sizeof(long long)) /* Maximum bits size of integer types of packed-bits */ diff --git a/tools/src/h5dump/h5dump_ddl.c b/tools/src/h5dump/h5dump_ddl.c index a410fda..b50ce52 100644 --- a/tools/src/h5dump/h5dump_ddl.c +++ b/tools/src/h5dump/h5dump_ddl.c @@ -103,13 +103,13 @@ dump_attr_cb(hid_t oid, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED * HDmemset(&ctx, 0, sizeof(ctx)); ctx.indent_level = dump_indent / COL; ctx.cur_column = dump_indent; - ctx.display_index = display_ai; - ctx.display_char = display_char; + ctx.display_index = dump_opts.display_ai; + ctx.display_char = dump_opts.display_char; attr_id = H5Aopen(oid, attr_name, H5P_DEFAULT); - oid_output = display_oid; - data_output = display_data; - attr_data_output = display_attr_data; + oid_output = dump_opts.display_oid; + data_output = dump_opts.display_data; + attr_data_output = dump_opts.display_attr_data; string_dataformat = *outputformat; @@ -125,7 +125,7 @@ dump_attr_cb(hid_t oid, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED * else string_dataformat.line_ncols = h5tools_nCols; - string_dataformat.do_escape = display_escape; + string_dataformat.do_escape = dump_opts.display_escape; outputformat = &string_dataformat; h5dump_type_table = type_table; @@ -185,7 +185,7 @@ dump_all_cb(hid_t group, const char *name, const H5L_info2_t *linfo, void H5_ATT else string_dataformat.line_ncols = h5tools_nCols; - string_dataformat.do_escape = display_escape; + string_dataformat.do_escape = dump_opts.display_escape; outputformat = &string_dataformat; /* Build the object's path name */ @@ -242,16 +242,16 @@ dump_all_cb(hid_t group, const char *name, const H5L_info2_t *linfo, void H5_ATT break; case H5O_TYPE_DATASET: - if(display_data) { + if(dump_opts.display_data) { if ((dapl_id = H5Pcreate(H5P_DATASET_ACCESS)) < 0) { error_msg("error in creating default access property list ID\n"); } - if (display_vds_first) { + if (dump_opts.display_vds_first) { if(H5Pset_virtual_view(dapl_id, H5D_VDS_FIRST_MISSING) < 0) error_msg("error in setting access property list ID, virtual_view\n"); } - if (vds_gap_size > 0) { - if(H5Pset_virtual_printf_gap(dapl_id, (hsize_t)vds_gap_size) < 0) + if (dump_opts.vds_gap_size > 0) { + if(H5Pset_virtual_printf_gap(dapl_id, (hsize_t)dump_opts.vds_gap_size) < 0) error_msg("error in setting access property list ID, virtual_printf_gap\n"); } } @@ -565,7 +565,7 @@ attr_iteration(hid_t gid, unsigned attr_crt_order_flags) { /* attribute iteration: if there is a request to do H5_INDEX_CRT_ORDER and tracking order is set in the group for attributes, then, sort by creation order, otherwise by name */ - if(include_attrs) { + if(dump_opts.include_attrs) { if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) { if(H5Aiterate2(gid, sort_by, sort_order, NULL, dump_attr_cb, NULL) < 0) { error_msg("error getting attribute information\n"); @@ -642,7 +642,7 @@ dump_named_datatype(hid_t tid, const char *name) else string_dataformat.line_ncols = h5tools_nCols; - string_dataformat.do_escape = display_escape; + string_dataformat.do_escape = dump_opts.display_escape; outputformat = &string_dataformat; if ((tcpl_id = H5Tget_create_plist(tid)) < 0) { @@ -795,7 +795,7 @@ dump_group(hid_t gid, const char *name) else string_dataformat.line_ncols = h5tools_nCols; - string_dataformat.do_escape = display_escape; + string_dataformat.do_escape = dump_opts.display_escape; outputformat = &string_dataformat; ctx.need_prefix = TRUE; @@ -816,14 +816,14 @@ dump_group(hid_t gid, const char *name) /* dump unamed type in root group */ for(u = 0; u < type_table->nobjs; u++) if(!type_table->objs[u].recorded) { - char *obj_addr_str = NULL; + char *obj_tok_str = NULL; dset = H5Dopen2(gid, type_table->objs[u].objname, H5P_DEFAULT); type = H5Dget_type(dset); - H5Otoken_to_str(dset, &type_table->objs[u].obj_token, &obj_addr_str); - HDsprintf(type_name, "#%s", obj_addr_str); - H5free_memory(obj_addr_str); + H5Otoken_to_str(dset, &type_table->objs[u].obj_token, &obj_tok_str); + HDsprintf(type_name, "#%s", obj_tok_str); + H5free_memory(obj_tok_str); dump_function_table->dump_named_datatype_function(type, type_name); H5Tclose(type); @@ -831,7 +831,7 @@ dump_group(hid_t gid, const char *name) } } /* end if */ - if(display_oid) + if(dump_opts.display_oid) h5tools_dump_oid(rawoutstream, outputformat, &ctx, gid); h5tools_dump_comment(rawoutstream, outputformat, &ctx, gid); @@ -926,7 +926,7 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset) else string_dataformat.line_ncols = h5tools_nCols; - string_dataformat.do_escape = display_escape; + string_dataformat.do_escape = dump_opts.display_escape; outputformat = &string_dataformat; if ((dcpl_id = H5Dget_create_plist(did)) < 0) { @@ -967,11 +967,11 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset) h5tools_dump_dataspace(rawoutstream, outputformat, &ctx, space); H5Sclose(space); - if(display_oid) { + if(dump_opts.display_oid) { h5tools_dump_oid(rawoutstream, outputformat, &ctx, did); } - if(display_dcpl) { + if(dump_opts.display_dcpl) { h5dump_type_table = type_table; h5tools_dump_dcpl(rawoutstream, outputformat, &ctx, dcpl_id, type, did); h5dump_type_table = NULL; @@ -979,16 +979,16 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset) H5Pclose(dcpl_id); ctx.sset = sset; - ctx.display_index = display_ai; - ctx.display_char = display_char; - if(display_data) { + ctx.display_index = dump_opts.display_ai; + ctx.display_char = dump_opts.display_char; + if(dump_opts.display_data) { unsigned data_loop = 1; unsigned u; - if(display_packed_bits) + if(dump_opts.display_packed_bits) data_loop = packed_bits_num; for(u = 0; u < data_loop; u++) { - if(display_packed_bits) { + if(dump_opts.display_packed_bits) { ctx.need_prefix = TRUE; h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); /* Render the element */ @@ -1091,7 +1091,7 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_index) else string_dataformat.line_ncols = h5tools_nCols; - string_dataformat.do_escape = display_escape; + string_dataformat.do_escape = dump_opts.display_escape; outputformat = &string_dataformat; HDmemset(&ctx, 0, sizeof(ctx)); @@ -1099,7 +1099,7 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_index) ctx.cur_column = dump_indent; ctx.sset = sset; ctx.display_index = display_index; - ctx.display_char = display_char; + ctx.display_char = dump_opts.display_char; if(obj_data == DATASET_DATA) print_dataset = TRUE; @@ -1136,6 +1136,18 @@ dump_fcpl(hid_t fid) unsigned sym_ik; /* symbol table B-tree internal 'K' value */ unsigned istore_ik; /* indexed storage B-tree internal 'K' value */ + hbool_t supported = FALSE; + + /* Dumping the information here only makes sense for the native + * VOL connector. The only VOL call here is H5Fget_info(), so we'll + * use that as a proxy for "native-ness". If that isn't supported, we'll + * just return. + */ + H5VLquery_optional(fid, H5VL_SUBCLS_FILE, H5VL_NATIVE_FILE_GET_INFO, &supported); + + if (!supported) + return; + fcpl=H5Fget_create_plist(fid); H5Fget_info2(fid, &finfo); H5Pget_userblock(fcpl,&userblock); @@ -1258,11 +1270,11 @@ dump_fcontents(hid_t fid) for (u = 0; u < type_table->nobjs; u++) { if (!type_table->objs[u].recorded) { - char *obj_addr_str = NULL; + char *obj_tok_str = NULL; - H5Otoken_to_str(fid, &type_table->objs[u].obj_token, &obj_addr_str); - PRINTSTREAM(rawoutstream, " %-10s /#%s\n", "datatype", obj_addr_str); - H5free_memory(obj_addr_str); + H5Otoken_to_str(fid, &type_table->objs[u].obj_token, &obj_tok_str); + PRINTSTREAM(rawoutstream, " %-10s /#%s\n", "datatype", obj_tok_str); + H5free_memory(obj_tok_str); } } } @@ -1515,8 +1527,8 @@ handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED *data, int H5 HDmemset(&ctx, 0, sizeof(ctx)); ctx.indent_level = dump_indent / COL; ctx.cur_column = dump_indent; - ctx.display_index = display_ai; - ctx.display_char = display_char; + ctx.display_index = dump_opts.display_ai; + ctx.display_char = dump_opts.display_char; string_dataformat = *outputformat; @@ -1532,7 +1544,7 @@ handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED *data, int H5 else string_dataformat.line_ncols = h5tools_nCols; - string_dataformat.do_escape = display_escape; + string_dataformat.do_escape = dump_opts.display_escape; outputformat = &string_dataformat; attr_name = h5tools_str_replace(attr + j + 1, "\\/", "/"); @@ -1571,9 +1583,9 @@ handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED *data, int H5 } /* end if */ attr_id = H5Aopen(oid, attr_name, H5P_DEFAULT); - oid_output = display_oid; - data_output = display_data; - attr_data_output = display_attr_data; + oid_output = dump_opts.display_oid; + data_output = dump_opts.display_data; + attr_data_output = dump_opts.display_attr_data; h5dump_type_table = type_table; h5tools_dump_attribute(rawoutstream, outputformat, &ctx, attr_name, attr_id); @@ -1625,16 +1637,16 @@ handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *dis struct subset_t *sset = (struct subset_t *)data; const char *real_name = display_name ? display_name : dset; - if(display_data) { + if(dump_opts.display_data) { if ((dapl_id = H5Pcreate(H5P_DATASET_ACCESS)) < 0) { error_msg("error in creating default access property list ID\n"); } - if (display_vds_first) { + if (dump_opts.display_vds_first) { if(H5Pset_virtual_view(dapl_id, H5D_VDS_FIRST_MISSING) < 0) error_msg("error in setting access property list ID, virtual_view\n"); } - if (vds_gap_size > 0) { - if(H5Pset_virtual_printf_gap(dapl_id, (hsize_t)vds_gap_size) < 0) + if (dump_opts.vds_gap_size > 0) { + if(H5Pset_virtual_printf_gap(dapl_id, (hsize_t)dump_opts.vds_gap_size) < 0) error_msg("error in setting access property list ID, virtual_printf_gap\n"); } } @@ -1914,12 +1926,12 @@ handle_datatypes(hid_t fid, const char *type, void H5_ATTR_UNUSED * data, int pe char name[128]; if(!type_table->objs[idx].recorded) { - char *obj_addr_string = NULL; + char *obj_tok_str = NULL; /* unamed datatype */ - H5Otoken_to_str(fid, &type_table->objs[idx].obj_token, &obj_addr_string); - HDsprintf(name, "/#%s", obj_addr_string); - H5free_memory(obj_addr_string); + H5Otoken_to_str(fid, &type_table->objs[idx].obj_token, &obj_tok_str); + HDsprintf(name, "/#%s", obj_tok_str); + H5free_memory(obj_tok_str); if(!HDstrcmp(name, real_name)) break; diff --git a/tools/src/h5dump/h5dump_extern.h b/tools/src/h5dump/h5dump_extern.h index 00d3bd2..c615621 100644 --- a/tools/src/h5dump/h5dump_extern.h +++ b/tools/src/h5dump/h5dump_extern.h @@ -50,32 +50,35 @@ typedef struct h5dump_table_list_t { extern h5dump_table_list_t table_list; extern table_t *group_table, *dset_table, *type_table; -extern unsigned dump_indent; /*how far in to indent the line */ -extern int unamedtype; /* shared datatype with no name */ -extern hbool_t hit_elink; /* whether we have traversed an external link */ +extern unsigned dump_indent; /* how far in to indent the line */ +extern int unamedtype; /* shared datatype with no name */ +extern hbool_t hit_elink; /* whether we have traversed an external link */ extern size_t prefix_len; extern char *prefix; extern const char *fp_format; /* things to display or which are set via command line parameters */ -extern int display_all; -extern int display_oid; -extern int display_data; -extern int display_attr_data; -extern int display_char; /*print 1-byte numbers as ASCII */ -extern int usingdasho; -extern int display_bb; /*superblock */ -extern int display_dcpl; /*dcpl */ -extern int display_fi; /*file index */ -extern int display_ai; /*array index */ -extern int display_escape; /*escape non printable characters */ -extern int display_region; /*print region reference data */ -extern int disable_compact_subset; /* disable compact form of subset notation */ -extern int display_packed_bits; /*print 1-8 byte numbers as packed bits*/ -extern int include_attrs; /* Display attributes */ -extern int display_vds_first; /* vds display to first missing */ -extern int vds_gap_size; /* vds skip missing files */ +typedef struct { + int display_all; + int display_oid; + int display_data; + int display_attr_data; + int display_char; /* print 1-byte numbers as ASCII */ + int usingdasho; + int display_bb; /* superblock */ + int display_dcpl; /* dcpl */ + int display_fi; /* file index */ + int display_ai; /* array index */ + int display_escape; /* escape non printable characters */ + int display_region; /* print region reference data */ + int disable_compact_subset; /* disable compact form of subset notation */ + int display_packed_bits; /* print 1-8 byte numbers as packed bits */ + int include_attrs; /* Display attributes */ + int display_vds_first; /* vds display to all by default */ + int vds_gap_size; /* vds skip missing files default is none */ +} dump_opt_t; +extern dump_opt_t dump_opts; #define PACKED_BITS_MAX 8 /* Maximum number of packed-bits to display */ #define PACKED_BITS_SIZE_MAX 8*sizeof(long long) /* Maximum bits size of integer types of packed-bits */ diff --git a/tools/src/h5dump/h5dump_xml.c b/tools/src/h5dump/h5dump_xml.c index 1a7c3ce..bb47f77 100644 --- a/tools/src/h5dump/h5dump_xml.c +++ b/tools/src/h5dump/h5dump_xml.c @@ -162,7 +162,7 @@ xml_dump_all_cb(hid_t group, const char *name, const H5L_info2_t *linfo, void H5 else string_dataformat.line_ncols = h5tools_nCols; - string_dataformat.do_escape = display_escape; + string_dataformat.do_escape = dump_opts.display_escape; outputformat = &string_dataformat; /* Build the object's path name */ @@ -578,7 +578,7 @@ int xml_name_to_XID(hid_t loc_id, const char *str, char *outstr, int outlen, int gen) { H5O_token_t obj_token; - char *obj_addr_str = NULL; + char *obj_tok_str = NULL; int lookup_ret; if (outlen < 22) return 1; @@ -591,9 +591,9 @@ xml_name_to_XID(hid_t loc_id, const char *str, char *outstr, int outlen, int gen if (gen) { ref_path_table_gen_fake(str, &obj_token); - H5Otoken_to_str(loc_id, &obj_token, &obj_addr_str); - HDsprintf(outstr, "xid_%s", obj_addr_str); - H5free_memory(obj_addr_str); + H5Otoken_to_str(loc_id, &obj_token, &obj_tok_str); + HDsprintf(outstr, "xid_%s", obj_tok_str); + H5free_memory(obj_tok_str); return 0; } @@ -606,9 +606,9 @@ xml_name_to_XID(hid_t loc_id, const char *str, char *outstr, int outlen, int gen if (gen) { ref_path_table_gen_fake(str, &obj_token); - H5Otoken_to_str(loc_id, &obj_token, &obj_addr_str); - HDsprintf(outstr, "xid_%s", obj_addr_str); - H5free_memory(obj_addr_str); + H5Otoken_to_str(loc_id, &obj_token, &obj_tok_str); + HDsprintf(outstr, "xid_%s", obj_tok_str); + H5free_memory(obj_tok_str); return 0; } @@ -618,9 +618,9 @@ xml_name_to_XID(hid_t loc_id, const char *str, char *outstr, int outlen, int gen } } - H5Otoken_to_str(loc_id, &obj_token, &obj_addr_str); - HDsprintf(outstr, "xid_%s", obj_addr_str); - H5free_memory(obj_addr_str); + H5Otoken_to_str(loc_id, &obj_token, &obj_tok_str); + HDsprintf(outstr, "xid_%s", obj_tok_str); + H5free_memory(obj_tok_str); return 0; } @@ -738,9 +738,9 @@ xml_escape_the_string(const char *str, int slen) size_t extra; size_t len; size_t i; - const char *cp; - char *ncp; - char *rcp; + const char *cp = NULL; + char *ncp = NULL; + char *rcp = NULL; size_t ncp_len; if (!str) @@ -783,29 +783,31 @@ xml_escape_the_string(const char *str, int slen) if (*cp == '\\') { *ncp++ = '\\'; + ncp_len--; *ncp = *cp; esc_len = 1; } else if (*cp == '\"') { *ncp++ = '\\'; + ncp_len--; *ncp = *cp; esc_len = 1; } else if (*cp == '\'') { + HDstrncpy(ncp, apos, ncp_len); esc_len = HDstrlen(apos); - HDstrncpy(ncp, apos, esc_len); } else if (*cp == '<') { + HDstrncpy(ncp, lt, ncp_len); esc_len = HDstrlen(lt); - HDstrncpy(ncp, lt, esc_len); } else if (*cp == '>') { + HDstrncpy(ncp, gt, ncp_len); esc_len = HDstrlen(gt); - HDstrncpy(ncp, gt, esc_len); } else if (*cp == '&') { + HDstrncpy(ncp, amp, ncp_len); esc_len = HDstrlen(amp); - HDstrncpy(ncp, amp, esc_len); } else { *ncp = *cp; @@ -886,7 +888,7 @@ xml_print_datatype(hid_t type, unsigned in_group) else string_dataformat.line_ncols = h5tools_nCols; - string_dataformat.do_escape = display_escape; + string_dataformat.do_escape = dump_opts.display_escape; outputformat = &string_dataformat; if(!in_group && H5Tcommitted(type) > 0) { @@ -1536,7 +1538,7 @@ xml_dump_datatype(hid_t type) else string_dataformat.line_ncols = h5tools_nCols; - string_dataformat.do_escape = display_escape; + string_dataformat.do_escape = dump_opts.display_escape; outputformat = &string_dataformat; ctx.indent_level++; @@ -1667,7 +1669,7 @@ xml_dump_dataspace(hid_t space) else string_dataformat.line_ncols = h5tools_nCols; - string_dataformat.do_escape = display_escape; + string_dataformat.do_escape = dump_opts.display_escape; outputformat = &string_dataformat; ctx.indent_level++; @@ -1990,7 +1992,7 @@ xml_dump_attr(hid_t attr, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED else string_dataformat.line_ncols = h5tools_nCols; - string_dataformat.do_escape = display_escape; + string_dataformat.do_escape = dump_opts.display_escape; outputformat = &string_dataformat; ctx.need_prefix = TRUE; @@ -2012,7 +2014,7 @@ xml_dump_attr(hid_t attr, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED ctx.indent_level++; dump_indent += COL; - if (display_attr_data && space_type != H5S_NULL) { + if (dump_opts.display_attr_data && space_type != H5S_NULL) { switch (H5Tget_class(type)) { case H5T_INTEGER: case H5T_FLOAT: @@ -2291,7 +2293,7 @@ xml_dump_named_datatype(hid_t type, const char *name) else string_dataformat.line_ncols = h5tools_nCols; - string_dataformat.do_escape = display_escape; + string_dataformat.do_escape = dump_opts.display_escape; outputformat = &string_dataformat; dtxid = (char *)HDmalloc((size_t)100); @@ -2504,7 +2506,7 @@ xml_dump_group(hid_t gid, const char *name) else string_dataformat.line_ncols = h5tools_nCols; - string_dataformat.do_escape = display_escape; + string_dataformat.do_escape = dump_opts.display_escape; outputformat = &string_dataformat; if(HDstrcmp(name, "/") == 0) { @@ -2659,14 +2661,14 @@ xml_dump_group(hid_t gid, const char *name) /* Very special case: dump unamed type in root group */ for(u = 0; u < type_table->nobjs; u++) { if(!type_table->objs[u].recorded) { - char *obj_addr_str = NULL; + char *obj_tok_str = NULL; dset = H5Dopen2(gid, type_table->objs[u].objname, H5P_DEFAULT); type = H5Dget_type(dset); - H5Otoken_to_str(dset, &type_table->objs[u].obj_token, &obj_addr_str); - HDsprintf(type_name, "#%s", obj_addr_str); - H5free_memory(obj_addr_str); + H5Otoken_to_str(dset, &type_table->objs[u].obj_token, &obj_tok_str); + HDsprintf(type_name, "#%s", obj_tok_str); + H5free_memory(obj_tok_str); dump_function_table->dump_named_datatype_function(type, type_name); H5Tclose(type); @@ -2747,14 +2749,14 @@ xml_dump_group(hid_t gid, const char *name) /* Very special case: dump unamed type in root group */ for(u = 0; u < type_table->nobjs; u++) { if(!type_table->objs[u].recorded) { - char *obj_addr_str = NULL; + char *obj_tok_str = NULL; dset = H5Dopen2(gid, type_table->objs[u].objname, H5P_DEFAULT); type = H5Dget_type(dset); - H5Otoken_to_str(dset, &type_table->objs[u].obj_token, &obj_addr_str); - HDsprintf(type_name, "#%s", obj_addr_str); - H5free_memory(obj_addr_str); + H5Otoken_to_str(dset, &type_table->objs[u].obj_token, &obj_tok_str); + HDsprintf(type_name, "#%s", obj_tok_str); + H5free_memory(obj_tok_str); dump_function_table->dump_named_datatype_function(type, type_name); H5Tclose(type); @@ -2887,7 +2889,7 @@ xml_print_refs(hid_t did, int source) else string_dataformat.line_ncols = h5tools_nCols; - string_dataformat.do_escape = display_escape; + string_dataformat.do_escape = dump_opts.display_escape; outputformat = &string_dataformat; for (i = 0; i < (hsize_t)ssiz; i++) { @@ -3037,7 +3039,7 @@ xml_print_strs(hid_t did, int source) else string_dataformat.line_ncols = h5tools_nCols; - string_dataformat.do_escape = display_escape; + string_dataformat.do_escape = dump_opts.display_escape; outputformat = &string_dataformat; for (i = 0; i < (hsize_t)ssiz; i++) { @@ -3149,7 +3151,7 @@ check_filters(hid_t dcpl) else string_dataformat.line_ncols = h5tools_nCols; - string_dataformat.do_escape = display_escape; + string_dataformat.do_escape = dump_opts.display_escape; outputformat = &string_dataformat; nfilt = H5Pget_nfilters(dcpl); @@ -3285,7 +3287,7 @@ xml_dump_fill_value(hid_t dcpl, hid_t type) else string_dataformat.line_ncols = h5tools_nCols; - string_dataformat.do_escape = display_escape; + string_dataformat.do_escape = dump_opts.display_escape; outputformat = &string_dataformat; ctx.indent_level++; @@ -3625,7 +3627,7 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *ss else string_dataformat.line_ncols = h5tools_nCols; - string_dataformat.do_escape = display_escape; + string_dataformat.do_escape = dump_opts.display_escape; outputformat = &string_dataformat; xml_name_to_XID(did, tmp, rstr, 100, 1); @@ -3914,7 +3916,7 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED *ss dump_indent -= COL; tempi = H5Dget_storage_size(did); - if (display_data && (tempi > 0)) { + if (dump_opts.display_data && (tempi > 0)) { switch (H5Tget_class(type)) { case H5T_INTEGER: case H5T_FLOAT: @@ -4170,7 +4172,7 @@ xml_print_enum(hid_t type) else string_dataformat.line_ncols = h5tools_nCols; - string_dataformat.do_escape = display_escape; + string_dataformat.do_escape = dump_opts.display_escape; outputformat = &string_dataformat; nmembs = (unsigned)H5Tget_nmembers(type); diff --git a/tools/src/h5format_convert/h5format_convert.c b/tools/src/h5format_convert/h5format_convert.c index 8e0d857..e60097b 100644 --- a/tools/src/h5format_convert/h5format_convert.c +++ b/tools/src/h5format_convert/h5format_convert.c @@ -60,6 +60,7 @@ static struct long_options l_opts[] = { { "noop", no_arg, 'n' }, { "noo", no_arg, 'n' }, { "no", no_arg, 'n' }, + { "enable-error-stack", no_arg, 'E' }, { NULL, 0, '\0' } }; @@ -108,7 +109,7 @@ static void usage(const char *prog) * Purpose: parse command line input * * Return: Success: 0 - * Failure: 1 + * Failure: 1 * *------------------------------------------------------------------------- */ @@ -126,47 +127,47 @@ parse_command_line(int argc, const char **argv) /* parse command line options */ while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { - switch((char) opt) { - case 'h': - usage(h5tools_getprogname()); - h5tools_setstatus(EXIT_SUCCESS); - goto error; - - case 'V': - print_version(h5tools_getprogname()); - h5tools_setstatus(EXIT_SUCCESS); - goto error; - - case 'v': - verbose_g = TRUE; - break; - - case 'd': /* -d dname */ - if(opt_arg != NULL && *opt_arg) - dname_g = HDstrdup(opt_arg); - if(dname_g == NULL) { - h5tools_setstatus(EXIT_FAILURE); - error_msg("No dataset name\n", opt_arg); - usage(h5tools_getprogname()); - goto error; - } - dset_g = TRUE; - break; - - case 'n': /* -n */ - noop_g = TRUE; - break; - - case 'E': - enable_error_stack = 1; - break; - - default: - h5tools_setstatus(EXIT_FAILURE); - usage(h5tools_getprogname()); - goto error; - break; - } /* switch */ + switch((char) opt) { + case 'h': + usage(h5tools_getprogname()); + h5tools_setstatus(EXIT_SUCCESS); + goto error; + + case 'V': + print_version(h5tools_getprogname()); + h5tools_setstatus(EXIT_SUCCESS); + goto error; + + case 'v': + verbose_g = TRUE; + break; + + case 'd': /* -d dname */ + if(opt_arg != NULL && *opt_arg) + dname_g = HDstrdup(opt_arg); + if(dname_g == NULL) { + h5tools_setstatus(EXIT_FAILURE); + error_msg("No dataset name\n", opt_arg); + usage(h5tools_getprogname()); + goto error; + } + dset_g = TRUE; + break; + + case 'n': /* -n */ + noop_g = TRUE; + break; + + case 'E': + enable_error_stack = 1; + break; + + default: + h5tools_setstatus(EXIT_FAILURE); + usage(h5tools_getprogname()); + goto error; + break; + } /* switch */ } /* while */ if (argc <= opt_ind) { @@ -206,17 +207,17 @@ leave(int ret) * Function: convert() * * Purpose: To downgrade a dataset's indexing type or layout version: - * For chunked: - * Downgrade the chunk indexing type to version 1 B-tree - * If type is already version 1 B-tree, no further action - * For compact/contiguous: - * Downgrade the layout version from 4 to 3 - * If version is already <= 3, no further action - * For virtual: - * No further action + * For chunked: + * Downgrade the chunk indexing type to version 1 B-tree + * If type is already version 1 B-tree, no further action + * For compact/contiguous: + * Downgrade the layout version from 4 to 3 + * If version is already <= 3, no further action + * For virtual: + * No further action * * Return: Success: 0 - * Failure: 1 + * Failure: 1 * *------------------------------------------------------------------------- */ @@ -311,7 +312,7 @@ convert(hid_t fid, const char *dname) } if(verbose_g) - HDfprintf(stdout, "Converting the dataset...\n"); + HDfprintf(stdout, "Converting the dataset...\n"); /* Downgrade the dataset */ if(H5Dformat_convert(did) < 0) { @@ -376,7 +377,7 @@ convert_dsets_cb(const char *path, const H5O_info2_t *oi, const char *already_vi if(verbose_g) HDfprintf(stdout, "Going to process dataset:%s...\n", path); if(convert(fid, path) < 0) - goto error; + goto error; } /* end if */ } /* end if */ @@ -391,57 +392,56 @@ error: * Function: main * * Purpose: To convert the chunk indexing type of a dataset in a file to - * version 1 B-tree. + * version 1 B-tree. * * Return: Success: 0 - * Failure: 1 + * Failure: 1 * *------------------------------------------------------------------------- */ int main(int argc, const char *argv[]) { - H5E_auto2_t func; - void *edata; hid_t fid = H5I_INVALID_HID; h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); - /* Disable error reporting */ - H5Eget_auto2(H5E_DEFAULT, &func, &edata); - H5Eset_auto2(H5E_DEFAULT, NULL, NULL); - /* Initialize h5tools lib */ h5tools_init(); /* Parse command line options */ if(parse_command_line(argc, argv) < 0) - goto done; + goto done; else if(verbose_g) - HDfprintf(stdout, "Process command line options\n"); + HDfprintf(stdout, "Process command line options\n"); if(noop_g && verbose_g) - HDfprintf(stdout, "It is noop...\n"); + HDfprintf(stdout, "It is noop...\n"); + + /* enable error reporting if command line option */ + h5tools_error_report(); /* Open the HDF5 file */ - if((fid = h5tools_fopen(fname_g, H5F_ACC_RDWR, H5P_DEFAULT, NULL, NULL, 0)) < 0) { - error_msg("unable to open file \"%s\"\n", fname_g); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } else if(verbose_g) - HDfprintf(stdout, "Open the file %s\n", fname_g); + if((fid = h5tools_fopen(fname_g, H5F_ACC_RDWR, H5P_DEFAULT, FALSE, NULL, 0)) < 0) { + error_msg("unable to open file \"%s\"\n", fname_g); + h5tools_setstatus(EXIT_FAILURE); + goto done; + } + else if(verbose_g) + HDfprintf(stdout, "Open the file %s\n", fname_g); if(dset_g) { /* Convert a specified dataset in the file */ - if(verbose_g) - HDfprintf(stdout, "Going to process dataset: %s...\n", dname_g); - if(convert(fid, dname_g) < 0) - goto done; - } else { /* Convert all datasets in the file */ - if(verbose_g) - HDfprintf(stdout, "Processing all datasets in the file...\n"); - if(h5trav_visit(fid, "/", TRUE, TRUE, convert_dsets_cb, NULL, &fid, H5O_INFO_BASIC) < 0) - goto done; + if(verbose_g) + HDfprintf(stdout, "Going to process dataset: %s...\n", dname_g); + if(convert(fid, dname_g) < 0) + goto done; + } + else { /* Convert all datasets in the file */ + if(verbose_g) + HDfprintf(stdout, "Processing all datasets in the file...\n"); + if(h5trav_visit(fid, "/", TRUE, TRUE, convert_dsets_cb, NULL, &fid, H5O_INFO_BASIC) < 0) + goto done; } /* end else */ if(verbose_g) { @@ -463,19 +463,20 @@ main(int argc, const char *argv[]) done: /* Close the file */ if(fid >= 0) { - if(H5Fclose(fid) < 0) { - error_msg("unable to close file \"%s\"\n", fname_g); - h5tools_setstatus(EXIT_FAILURE); - } else if(verbose_g) - HDfprintf(stdout, "Close the file\n"); + if(H5Fclose(fid) < 0) { + error_msg("unable to close file \"%s\"\n", fname_g); + h5tools_setstatus(EXIT_FAILURE); + } + else if(verbose_g) { + HDfprintf(stdout, "Close the file\n"); + } } /* end if */ if(fname_g) - HDfree(fname_g); + HDfree(fname_g); if(dname_g) - HDfree(dname_g); + HDfree(dname_g); - H5Eset_auto2(H5E_DEFAULT, func, edata); leave(h5tools_getstatus()); } /* end main() */ diff --git a/tools/src/h5import/h5import.c b/tools/src/h5import/h5import.c index f87f371..4a642e0 100644 --- a/tools/src/h5import/h5import.c +++ b/tools/src/h5import/h5import.c @@ -72,7 +72,7 @@ uint64_t swap_uint64(uint64_t val); int main(int argc, char *argv[]) { - struct Options opt; + struct Options *opt; int outfile_named = FALSE; int token; int i; @@ -99,8 +99,8 @@ int main(int argc, char *argv[]) (void) HDsetvbuf(stderr, (char *) NULL, _IOLBF, 0); (void) HDsetvbuf(stdout, (char *) NULL, _IOLBF, 0); - /* Initialize the file structure to 0 */ - HDmemset(&opt, 0, sizeof(struct Options)); + if((opt = (struct Options *)HDcalloc(1, sizeof(struct Options))) == NULL) + goto err; if (argv[1] && (HDstrcmp("-V", argv[1]) == 0)) { print_version(PROGRAMNAME); @@ -130,12 +130,12 @@ int main(int argc, char *argv[]) switch (state) { case 1: /* counting input files */ - if (opt.fcount < 29) { - (void) HDstrcpy(opt.infiles[opt.fcount].datafile, argv[i]); - in = &(opt.infiles[opt.fcount].in); - opt.infiles[opt.fcount].config = 0; - setDefaultValues(in, opt.fcount); - opt.fcount++; + if (opt->fcount < 29) { + (void) HDstrcpy(opt->infiles[opt->fcount].datafile, argv[i]); + in = &(opt->infiles[opt->fcount].in); + opt->infiles[opt->fcount].config = 0; + setDefaultValues(in, opt->fcount); + opt->fcount++; } else { (void) HDfprintf(stderr, err9, argv[i]); @@ -148,8 +148,8 @@ int main(int argc, char *argv[]) break; case 3: /* get configfile name */ - (void) HDstrcpy(opt.infiles[opt.fcount-1].configfile, argv[i]); - opt.infiles[opt.fcount - 1].config = 1; + (void) HDstrcpy(opt->infiles[opt->fcount-1].configfile, argv[i]); + opt->infiles[opt->fcount - 1].config = 1; break; case 4: /* -o found; look for outfile */ @@ -160,7 +160,7 @@ int main(int argc, char *argv[]) (void) HDfprintf(stderr, err10, argv[i]); goto err; } - (void) HDstrcpy(opt.outfile, argv[i]); + (void) HDstrcpy(opt->outfile, argv[i]); outfile_named = TRUE; break; @@ -232,11 +232,11 @@ int main(int argc, char *argv[]) goto err; } - if (process(&opt) == -1) + if (process(opt) == -1) goto err; - for (i = 0; i < opt.fcount; i++) { - in = &(opt.infiles[i].in); + for (i = 0; i < opt->fcount; i++) { + in = &(opt->infiles[i].in); if (in->sizeOfDimension) HDfree(in->sizeOfDimension); if (in->sizeOfChunk) @@ -248,12 +248,13 @@ int main(int argc, char *argv[]) if (in->data) HDfree(in->data); } + HDfree(opt); - return (EXIT_SUCCESS); + return EXIT_SUCCESS; err: (void) HDfprintf(stderr, "%s", err4); - for (i = 0; i < opt.fcount; i++) { - in = &(opt.infiles[i].in); + for (i = 0; i < opt->fcount; i++) { + in = &(opt->infiles[i].in); if (in->sizeOfDimension) HDfree(in->sizeOfDimension); if (in->sizeOfChunk) @@ -265,7 +266,9 @@ err: if (in->data) HDfree(in->data); } - return (EXIT_FAILURE); + HDfree(opt); + + return EXIT_FAILURE; } static int gtoken(char *s) @@ -3732,8 +3735,8 @@ static int getExternalFilename(struct Input *in, FILE *strm) return (-1); } - in->externFilename = (char *) HDmalloc ((size_t) (HDstrlen(temp)) * sizeof(char)); - (void) HDstrcpy(in->externFilename, temp); + in->externFilename = (char *) HDmalloc ((size_t) (HDstrlen(temp) + 1) * sizeof(char)); + (void) HDstrncpy(in->externFilename, temp, HDstrlen(temp) + 1); return (0); } diff --git a/tools/src/h5jam/h5jam.c b/tools/src/h5jam/h5jam.c index 009e527..8b61112 100644 --- a/tools/src/h5jam/h5jam.c +++ b/tools/src/h5jam/h5jam.c @@ -120,13 +120,6 @@ usage (const char *prog) static void leave(int ret) { - if (ub_file) - HDfree (ub_file); - if (input_file) - HDfree (input_file); - if (output_file) - HDfree (output_file); - h5tools_close(); HDexit(ret); @@ -195,8 +188,6 @@ main (int argc, const char *argv[]) int ufid = -1; int h5fid = -1; int ofid = -1; - void *edata; - H5E_auto2_t func; hid_t ifile = H5I_INVALID_HID; hid_t plist = H5I_INVALID_HID; herr_t status; @@ -214,20 +205,20 @@ main (int argc, const char *argv[]) h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); - /* Disable error reporting */ - H5Eget_auto2(H5E_DEFAULT, &func, &edata); - H5Eset_auto2(H5E_DEFAULT, NULL, NULL); - /* Initialize h5tools lib */ h5tools_init(); parse_command_line(argc, argv); + /* enable error reporting if command line option */ + h5tools_error_report(); + if (ub_file == NULL) { /* no user block */ error_msg("missing argument for -u .\n"); help_ref_msg(stderr); - leave (EXIT_FAILURE); + h5tools_setstatus(EXIT_FAILURE); + goto done; } testval = H5Fis_accessible(ub_file, H5P_DEFAULT); @@ -235,13 +226,15 @@ main (int argc, const char *argv[]) if (testval > 0) { error_msg("-u cannot be HDF5 file, but it appears to be an HDF5 file.\n"); help_ref_msg(stderr); - leave (EXIT_FAILURE); + h5tools_setstatus(EXIT_FAILURE); + goto done; } if (input_file == NULL) { error_msg("missing argument for -i .\n"); help_ref_msg(stderr); - leave (EXIT_FAILURE); + h5tools_setstatus(EXIT_FAILURE); + goto done; } testval = H5Fis_accessible(input_file, H5P_DEFAULT); @@ -249,45 +242,49 @@ main (int argc, const char *argv[]) if (testval <= 0) { error_msg("Input HDF5 file \"%s\" is not HDF5 format.\n", input_file); help_ref_msg(stderr); - leave (EXIT_FAILURE); + h5tools_setstatus(EXIT_FAILURE); + goto done; } ifile = H5Fopen(input_file, H5F_ACC_RDONLY, H5P_DEFAULT); if (ifile < 0) { error_msg("Can't open input HDF5 file \"%s\"\n", input_file); - leave (EXIT_FAILURE); + h5tools_setstatus(EXIT_FAILURE); + goto done; } plist = H5Fget_create_plist(ifile); if (plist < 0) { error_msg("Can't get file creation plist for file \"%s\"\n", input_file); - H5Fclose(ifile); - leave (EXIT_FAILURE); + h5tools_setstatus(EXIT_FAILURE); + goto done; } status = H5Pget_userblock(plist, &usize); if (status < 0) { error_msg("Can't get user block for file \"%s\"\n", input_file); - H5Pclose(plist); - H5Fclose(ifile); - leave (EXIT_FAILURE); + h5tools_setstatus(EXIT_FAILURE); + goto done; } H5Pclose(plist); + plist = H5I_INVALID_HID; H5Fclose(ifile); + ifile = H5I_INVALID_HID; ufid = HDopen(ub_file, O_RDONLY); if(ufid < 0) { error_msg("unable to open user block file \"%s\"\n", ub_file); - leave (EXIT_FAILURE); + h5tools_setstatus(EXIT_FAILURE); + goto done; } res = HDfstat(ufid, &sbuf); if(res < 0) { error_msg("Can't stat file \"%s\"\n", ub_file); - HDclose (ufid); - leave (EXIT_FAILURE); + h5tools_setstatus(EXIT_FAILURE); + goto done; } fsize = (off_t)sbuf.st_size; @@ -295,16 +292,15 @@ main (int argc, const char *argv[]) h5fid = HDopen(input_file, O_RDONLY); if(h5fid < 0) { error_msg("unable to open HDF5 file for read \"%s\"\n", input_file); - HDclose (ufid); - leave (EXIT_FAILURE); + h5tools_setstatus(EXIT_FAILURE); + goto done; } res = HDfstat(h5fid, &sbuf2); if(res < 0) { error_msg("Can't stat file \"%s\"\n", input_file); - HDclose (h5fid); - HDclose (ufid); - leave (EXIT_FAILURE); + h5tools_setstatus(EXIT_FAILURE); + goto done; } h5fsize = (hsize_t)sbuf2.st_size; @@ -314,9 +310,8 @@ main (int argc, const char *argv[]) if (ofid < 0) { error_msg("unable to open output file \"%s\"\n", output_file); - HDclose (h5fid); - HDclose (ufid); - leave (EXIT_FAILURE); + h5tools_setstatus(EXIT_FAILURE); + goto done; } } else { @@ -324,9 +319,8 @@ main (int argc, const char *argv[]) if (ofid < 0) { error_msg("unable to create output file \"%s\"\n", output_file); - HDclose (h5fid); - HDclose (ufid); - leave (EXIT_FAILURE); + h5tools_setstatus(EXIT_FAILURE); + goto done; } } @@ -365,12 +359,11 @@ main (int argc, const char *argv[]) /* pad the ub */ if(write_pad(ofid, where, &where) < 0) { error_msg("Can't pad file \"%s\"\n", output_file); - HDclose (h5fid); - HDclose (ufid); - HDclose (ofid); - leave (EXIT_FAILURE); + h5tools_setstatus(EXIT_FAILURE); + goto done; } /* end if */ +done: if(ub_file) HDfree(ub_file); if(input_file) @@ -378,6 +371,11 @@ main (int argc, const char *argv[]) if(output_file) HDfree(output_file); + if(plist >= 0) + H5Pclose(plist); + if(ifile >= 0) + H5Fclose(ifile); + if(ufid >= 0) HDclose(ufid); if(h5fid >= 0) @@ -385,7 +383,7 @@ main (int argc, const char *argv[]) if(ofid >= 0) HDclose(ofid); - return h5tools_getstatus(); + leave(h5tools_getstatus()); } /*------------------------------------------------------------------------- diff --git a/tools/src/h5jam/h5unjam.c b/tools/src/h5jam/h5unjam.c index 203522b..b48e2c1 100644 --- a/tools/src/h5jam/h5unjam.c +++ b/tools/src/h5jam/h5unjam.c @@ -185,6 +185,13 @@ done: return EXIT_FAILURE; } +static void +leave(int ret) +{ + h5tools_close(); + HDexit(ret); +} + /*------------------------------------------------------------------------- * Function: main * @@ -197,8 +204,6 @@ done: int main(int argc, const char *argv[]) { - void *edata; - H5E_auto2_t func; hid_t ifile = H5I_INVALID_HID; hid_t plist = H5I_INVALID_HID; off_t fsize; @@ -211,16 +216,15 @@ main(int argc, const char *argv[]) h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); - /* Disable error reporting */ - H5Eget_auto2(H5E_DEFAULT, &func, &edata); - H5Eset_auto2(H5E_DEFAULT, NULL, NULL); - /* Initialize h5tools lib */ h5tools_init(); if(EXIT_FAILURE == parse_command_line(argc, argv)) goto done; + /* enable error reporting if command line option */ + h5tools_error_report(); + if (input_file == NULL) { /* no user block */ error_msg("missing argument for HDF5 file input.\n"); @@ -319,9 +323,7 @@ done: HDfree(ub_file); } - h5tools_close(); - - return h5tools_getstatus(); + leave(h5tools_getstatus()); } /*------------------------------------------------------------------------- diff --git a/tools/src/h5ls/h5ls.c b/tools/src/h5ls/h5ls.c index f3f9ede..e239cbc 100644 --- a/tools/src/h5ls/h5ls.c +++ b/tools/src/h5ls/h5ls.c @@ -218,6 +218,12 @@ usage (void) PRINTVALSTREAM(rawoutstream, " ...,,)\n"); PRINTVALSTREAM(rawoutstream, " If absent or A == '(,,,,)', all default values are used.\n"); PRINTVALSTREAM(rawoutstream, " Has no effect if vfd flag is not 'hdfs'.\n"); + PRINTVALSTREAM(rawoutstream, " --vol-value Value (ID) of the VOL connector to use for opening the\n"); + PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, " --vol-name Name of the VOL connector to use for opening the\n"); + PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, " --vol-info VOL-specific info to pass to the VOL connector used for\n"); + PRINTVALSTREAM(rawoutstream, " opening the HDF5 file specified\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " file/OBJECT\n"); PRINTVALSTREAM(rawoutstream, " Each object consists of an HDF5 file name optionally followed by a\n"); @@ -1292,230 +1298,6 @@ print_type(h5tools_str_t *buffer, hid_t type, int ind) h5tools_str_append(buffer,"%lu-byte class-%u unknown", (unsigned long)H5Tget_size(type), (unsigned)data_class); } -/* - * - */ -static void -dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t container, H5R_ref_t *ref_buf, int ndims) -{ - hid_t new_obj_id = H5I_INVALID_HID; - hid_t new_obj_sid = H5I_INVALID_HID; - hsize_t elmt_counter = 0; /*counts the # elements printed. */ - size_t ncols = 80; /* available output width */ - int i; - hsize_t curr_pos = 0; /* total data element position */ - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t datactx; /* print context */ - - H5TOOLS_START_DEBUG(""); - - datactx = *ctx; /* print context */ - /* Assume entire data space to be printed */ - if (datactx.ndims > 0) - for (i = 0; (unsigned)i < datactx.ndims; i++) - datactx.p_min_idx[i] = 0; - datactx.need_prefix = TRUE; - - HDmemset(&buffer, 0, sizeof(h5tools_str_t)); - for(i = 0; i < ndims; i++, datactx.cur_elmt++, elmt_counter++) { - H5O_type_t obj_type = -1; /* Object type */ - H5R_type_t ref_type; /* Reference type */ - - H5TOOLS_DEBUG("reference loop:%d with curr_pos=%ld", i, curr_pos); - - datactx.need_prefix = TRUE; - h5tools_str_reset(&buffer); - H5TOOLS_DEBUG("reference loop - h5tools_str_sprint with H5T_STD_REF:%d", i); - h5tools_str_sprint(&buffer, info, container, H5T_STD_REF, &ref_buf[i], &datactx); - h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)i, (hsize_t)ndims); - - ref_type = H5Rget_type((const H5R_ref_t *)&ref_buf[i]); - switch (ref_type) { - case H5R_OBJECT1: - H5TOOLS_DEBUG("ref_type is H5R_OBJECT1"); - if (H5Rget_obj_type3((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) { - switch (obj_type) { - case H5O_TYPE_DATASET: - if((new_obj_id = H5Ropen_object((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - datactx.indent_level++; - h5tools_dump_dset(stream, info, &datactx, new_obj_id); - datactx.indent_level--; - if(H5Dclose(new_obj_id) < 0) - H5TOOLS_INFO("H5Dclose H5R_OBJECT1:H5O_TYPE_DATASET failed"); - if(H5Rdestroy(&ref_buf[i]) < 0) - H5TOOLS_INFO("H5Rdestroy H5R_OBJECT1:H5O_TYPE_DATASET failed"); - } - else - H5TOOLS_INFO("H5Ropen_object H5R_OBJECT1:H5O_TYPE_DATASET failed"); - break; - - case H5O_TYPE_GROUP: - case H5O_TYPE_NAMED_DATATYPE: - case H5O_TYPE_MAP: - case H5O_TYPE_UNKNOWN: - case H5O_TYPE_NTYPES: - default: - break; - } /* end switch */ - } - else - H5TOOLS_INFO("H5Rget_obj_type3 H5R_OBJECT1 failed"); - break; - case H5R_DATASET_REGION1: - H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION1"); - if((new_obj_id = H5Ropen_object((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - datactx.indent_level++; - h5tools_dump_dset(stream, info, &datactx, new_obj_id); - datactx.indent_level--; - if(H5Dclose(new_obj_id) < 0) - H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION1 failed"); - if(H5Rdestroy(&ref_buf[i]) < 0) - H5TOOLS_INFO("H5Rdestroy H5R_DATASET_REGION1 failed"); - } - else - H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION1 failed"); - break; - case H5R_OBJECT2: - H5TOOLS_DEBUG("ref_type is H5R_OBJECT2"); - if (H5Rget_obj_type3((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) { - switch (obj_type) { - case H5O_TYPE_GROUP: - break; - - case H5O_TYPE_DATASET: - if((new_obj_id = H5Ropen_object((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - datactx.indent_level++; - h5tools_dump_dset(stream, info, &datactx, new_obj_id); - datactx.indent_level--; - if(H5Oclose(new_obj_id) < 0) - H5TOOLS_INFO("H5Oclose H5R_OBJECT2 failed"); - if(H5Rdestroy(&ref_buf[i]) < 0) - H5TOOLS_INFO("H5Rdestroy H5R_OBJECT2 failed"); - } - else - H5TOOLS_INFO("H5Ropen_object H5R_OBJECT2 failed"); - break; - - case H5O_TYPE_NAMED_DATATYPE: - break; - - case H5O_TYPE_MAP: - case H5O_TYPE_UNKNOWN: - case H5O_TYPE_NTYPES: - default: - break; - } /* end switch */ - } - else - H5TOOLS_INFO("H5Rget_obj_type3 H5R_OBJECT2 failed"); - break; - case H5R_DATASET_REGION2: - H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION2"); - - if (info->line_ncols > 0) - ncols = info->line_ncols; - - /* if (new_obj_id < 0) - could mean that no reference was written do not throw failure */ - if((new_obj_id = H5Ropen_object((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) < 0) - H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION2 failed"); - else { - if((new_obj_sid = H5Ropen_region((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - if (h5tools_is_zero(&ref_buf[i], H5Tget_size(H5T_STD_REF))) { - H5TOOLS_DEBUG("NULL H5R_DATASET_REGION2"); - - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, " {"); - h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); - - datactx.need_prefix = TRUE; - datactx.indent_level++; - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "NULL"); - h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); - datactx.indent_level--; - datactx.need_prefix = TRUE; - - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "}"); - h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); - } - else { - H5S_sel_type region_type; - - region_type = H5Sget_select_type(new_obj_sid); - if(region_type == H5S_SEL_POINTS) { - /* Print point information */ - H5TOOLS_DEBUG("H5S_SEL_POINTS H5R_DATASET_REGION2"); - h5tools_dump_region_data_points(new_obj_sid, new_obj_id, stream, info, &datactx, - &buffer, &curr_pos, ncols, (hsize_t)i, elmt_counter); - } - else if(region_type == H5S_SEL_HYPERSLABS) { - /* Print block information */ - H5TOOLS_DEBUG("H5S_SEL_HYPERSLABS H5R_DATASET_REGION2"); - h5tools_dump_region_data_blocks(new_obj_sid, new_obj_id, stream, info, &datactx, - &buffer, &curr_pos, ncols, (hsize_t)i, elmt_counter); - } - else - H5TOOLS_INFO("invalid region type"); - } /* end else to if (h5tools_is_zero(... */ - if(H5Sclose(new_obj_sid) < 0) - H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION2 failed"); - } - else - H5TOOLS_INFO("H5Ropen_region H5R_DATASET_REGION2 failed"); - if(H5Dclose(new_obj_id) < 0) - H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION2 failed"); - if(H5Rdestroy(&ref_buf[i]) < 0) - H5TOOLS_INFO("H5Rdestroy H5R_DATASET_REGION2 failed"); - } - break; - case H5R_ATTR: - H5TOOLS_DEBUG("ref_type is H5R_ATTR"); - if((new_obj_id = H5Ropen_attr((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - h5tools_dump_region_attribute(new_obj_id, stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); - if(H5Aclose(new_obj_id) < 0) - H5TOOLS_INFO("H5Aclose H5R_ATTR failed"); - if(H5Rdestroy(&ref_buf[i]) < 0) - H5TOOLS_INFO("H5Rdestroy H5R_ATTR failed"); - } - else { - H5TOOLS_DEBUG("NULL H5R_ATTR"); - - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, " {"); - h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); - - datactx.need_prefix = TRUE; - datactx.indent_level++; - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "NULL"); - h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); - datactx.indent_level--; - datactx.need_prefix = TRUE; - - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "}"); - h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); - - H5TOOLS_INFO("H5Ropen_attr H5R_ATTR failed"); - } - break; - case H5R_BADTYPE: - case H5R_MAXTYPE: - default: - break; - } /* end switch */ - - H5TOOLS_DEBUG("finished reference loop:%d",i); - } /* end for(i = 0; i < ndims; i++, ctx->cur_elmt++, elmt_counter++) */ - - h5tools_str_close(&buffer); - - PRINTVALSTREAM(stream, "\n"); - - H5TOOLS_ENDDEBUG(""); -} - /*------------------------------------------------------------------------- * Function: dump_dataset_values * @@ -1531,7 +1313,6 @@ dump_dataset_values(hid_t dset) hid_t space = H5I_INVALID_HID; hsize_t total_size[H5S_MAX_RANK]; int ndims; - size_t i; char string_prefix[64]; static char fmt_double[16]; static char fmt_float[16]; @@ -1647,13 +1428,9 @@ dump_dataset_values(hid_t dset) H5TOOLS_DEBUG("ndims=%d - ctx.ndims=%d", ndims, ctx.ndims); /* 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(space, total_size, NULL); - if (ctx.ndims > 0) - init_acc_pos(&ctx, total_size); + init_acc_pos(ctx.ndims, total_size, ctx.acc, ctx.pos, ctx.p_min_idx); + ctx.need_prefix = TRUE; if (NULL != (ref_buf = (H5R_ref_t *)HDcalloc(MAX(sizeof(unsigned), sizeof(H5R_ref_t)), (size_t)ndims))) { @@ -1663,7 +1440,9 @@ dump_dataset_values(hid_t dset) H5TOOLS_INFO("H5Dread reference failed"); H5TOOLS_GOTO_DONE_NO_RET(); } - dump_reference(rawoutstream, info, &ctx, dset, ref_buf, ndims); + h5tools_dump_reference(rawoutstream, info, &ctx, dset, ref_buf, ndims); + + PRINTVALSTREAM(rawoutstream, "\n"); HDfree(ref_buf); } } @@ -1701,7 +1480,6 @@ dump_attribute_values(hid_t attr) hid_t space = H5I_INVALID_HID; hsize_t total_size[H5S_MAX_RANK]; int ndims; - size_t i; char string_prefix[64]; static char fmt_double[16]; static char fmt_float[16]; @@ -1818,13 +1596,9 @@ dump_attribute_values(hid_t attr) H5TOOLS_DEBUG("ndims=%d - ctx.ndims=%d", ndims, ctx.ndims); /* 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(space, total_size, NULL); - if (ctx.ndims > 0) - init_acc_pos(&ctx, total_size); + init_acc_pos(ctx.ndims, total_size, ctx.acc, ctx.pos, ctx.p_min_idx); + ctx.need_prefix = TRUE; if (NULL != (ref_buf = (H5R_ref_t *)HDcalloc(MAX(sizeof(unsigned), sizeof(H5R_ref_t)), (size_t)ndims))) { @@ -1835,7 +1609,9 @@ dump_attribute_values(hid_t attr) H5TOOLS_GOTO_DONE_NO_RET(); } ctx.indent_level++; - dump_reference(rawoutstream, info, &ctx, attr, ref_buf, ndims); + h5tools_dump_reference(rawoutstream, info, &ctx, attr, ref_buf, ndims); + + PRINTVALSTREAM(rawoutstream, "\n"); ctx.indent_level--; HDfree(ref_buf); } @@ -2334,13 +2110,13 @@ list_obj(const char *name, const H5O_info2_t *oinfo, const char *first_seen, voi h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); } /* end if */ else { - hid_t obj = H5I_INVALID_HID; /* ID of object opened */ + hid_t obj_id = H5I_INVALID_HID; /* ID of object opened */ /* Open the object. Not all objects can be opened. If this is the case * then return right away. */ H5TOOLS_DEBUG("Open object name=%s", name); - if (obj_type >= 0 && (obj = H5Oopen(iter->fid, name, H5P_DEFAULT)) < 0) { + if (obj_type >= 0 && (obj_id = H5Oopen(iter->fid, name, H5P_DEFAULT)) < 0) { h5tools_str_reset(&buffer); h5tools_str_append(&buffer, " *ERROR*\n"); h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); @@ -2350,7 +2126,7 @@ list_obj(const char *name, const H5O_info2_t *oinfo, const char *first_seen, voi /* List the first line of information for the object. */ H5TOOLS_DEBUG("Object type:%d", obj_type); if (obj_type >= 0 && dispatch_g[obj_type].list1) - (dispatch_g[obj_type].list1)(obj); + (dispatch_g[obj_type].list1)(obj_id); if (!iter->symlink_target || (verbose_g > 0)) { h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "\n"); @@ -2362,23 +2138,24 @@ list_obj(const char *name, const H5O_info2_t *oinfo, const char *first_seen, voi if (verbose_g > 0) { size_t buf_size = 0; char* comment = NULL; - char* obj_addr_str = NULL; + char* obj_tok_str = NULL; ssize_t cmt_bufsize = -1; + hbool_t supported = FALSE; /* Display attributes */ H5TOOLS_DEBUG("Display attributes"); if (obj_type >= 0) - H5Aiterate2(obj, H5_INDEX_NAME, H5_ITER_INC, NULL, list_attr, NULL); + H5Aiterate2(obj_id, H5_INDEX_NAME, H5_ITER_INC, NULL, list_attr, NULL); /* Object location & reference count */ - H5Otoken_to_str(obj, &oinfo->token, &obj_addr_str); + H5Otoken_to_str(obj_id, &oinfo->token, &obj_tok_str); h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, " %-10s %lu:%s\n", "Location:", oinfo->fileno, obj_addr_str); + h5tools_str_append(&buffer, " %-10s %lu:%s\n", "Location:", oinfo->fileno, obj_tok_str); h5tools_str_append(&buffer, " %-10s %u\n", "Links:", (unsigned)oinfo->rc); h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); - H5free_memory(obj_addr_str); + H5free_memory(obj_tok_str); /* Modification time */ if (oinfo->mtime > 0) { @@ -2397,36 +2174,42 @@ list_obj(const char *name, const H5O_info2_t *oinfo, const char *first_seen, voi } /* end if */ } /* end if */ - /* Object comment */ - cmt_bufsize = H5Oget_comment(obj, comment, buf_size); - - /* if the actual length of the comment is longer than cmt_bufsize, then call - * H5Oget_comment again with the correct value. - * If the call to H5Oget_comment returned an error, skip this block */ - if (cmt_bufsize > 0) { - comment = (char *)HDmalloc((size_t)cmt_bufsize + 1); /* new_size including null terminator */ - if (comment) { - cmt_bufsize = H5Oget_comment(obj, comment, (size_t)cmt_bufsize); - if (cmt_bufsize > 0) { - comment[cmt_bufsize] = 0; - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, " %-10s \"", "Comment:"); - print_string(&buffer, comment, FALSE); - h5tools_str_append(&buffer, "\"\n"); - h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); - } /* end if */ - HDfree(comment); + /* Only emit comments if the VOL connector supports that */ + H5VLquery_optional(obj_id, H5VL_SUBCLS_OBJECT, H5VL_NATIVE_OBJECT_GET_COMMENT, &supported); + + if (supported) { + + /* Object comment */ + cmt_bufsize = H5Oget_comment(obj_id, comment, buf_size); + + /* if the actual length of the comment is longer than cmt_bufsize, then call + * H5Oget_comment again with the correct value. + */ + if (cmt_bufsize > 0) { + comment = (char *)HDmalloc((size_t)cmt_bufsize + 1); /* new_size including null terminator */ + if (comment) { + cmt_bufsize = H5Oget_comment(obj_id, comment, (size_t)cmt_bufsize); + if (cmt_bufsize > 0) { + comment[cmt_bufsize] = 0; + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, " %-10s \"", "Comment:"); + print_string(&buffer, comment, FALSE); + h5tools_str_append(&buffer, "\"\n"); + h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); + } /* end if */ + HDfree(comment); + } } } } /* end if */ /* Detailed list for object */ if (obj_type >= 0 && dispatch_g[obj_type].list2) - (dispatch_g[obj_type].list2)(obj, name); + (dispatch_g[obj_type].list2)(obj_id, name); /* Close the object. */ if (obj_type >= 0) - H5Oclose(obj); + H5Oclose(obj_id); } /* end else */ done: @@ -2833,57 +2616,50 @@ leave(int ret) int main(int argc, const char *argv[]) { - hid_t file_id = H5I_INVALID_HID; - char *fname = NULL, *oname = NULL, *x; - const char *s = NULL; - char *rest; - int argno; - static char root_name[] = "/"; - char drivername[50]; - const char *preferred_driver = NULL; - int err_exit = 0; - hid_t fapl_id = H5P_DEFAULT; - H5E_auto2_t func; - H5E_auto2_t tools_func; - void *edata; - void *tools_edata; + hid_t file_id = H5I_INVALID_HID; + char *fname = NULL, *oname = NULL, *x; + const char *s = NULL; + char *rest; + int argno; + static char root_name[] = "/"; + char drivername[50]; + const char *preferred_driver = NULL; + int err_exit = 0; + hid_t fapl_id = H5P_DEFAULT; + hbool_t custom_vol_fapl = FALSE; + h5tools_vol_info_t vol_info; #ifdef H5_HAVE_ROS3_VFD - /* default "anonymous" s3 configuration */ + /* Default "anonymous" S3 configuration */ H5FD_ros3_fapl_t ros3_fa = { - 1, /* fapl version */ - false, /* authenticate */ - "", /* aws region */ - "", /* access key id */ - "", /* secret access key */ + 1, /* Structure Version */ + false, /* Authenticate? */ + "", /* AWS Region */ + "", /* Access Key ID */ + "", /* Secret Access Key */ }; -#endif /* H5_HVAE_ROS3_VFD */ +#endif /* H5_HAVE_ROS3_VFD */ #ifdef H5_HAVE_LIBHDFS - /* "default" HDFS configuration */ + /* "Default" HDFS configuration */ H5FD_hdfs_fapl_t hdfs_fa = { - 1, /* fapl version */ - "localhost", /* namenode name */ - 0, /* namenode port */ - "", /* kerberos ticket cache */ - "", /* user name */ - 2048, /* stream buffer size */ + 1, /* Structure Version */ + "localhost", /* Namenode Name */ + 0, /* Namenode Port */ + "", /* Kerberos ticket cache */ + "", /* User name */ + 2048, /* Stream buffer size */ }; #endif /* H5_HAVE_LIBHDFS */ h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); - /* Disable error reporting */ - H5Eget_auto2(H5E_DEFAULT, &func, &edata); - H5Eset_auto2(H5E_DEFAULT, NULL, NULL); - /* Initialize h5tools lib */ h5tools_init(); - /* Disable tools error reporting */ - H5Eget_auto2(H5tools_ERR_STACK_g, &tools_func, &tools_edata); - H5Eset_auto2(H5tools_ERR_STACK_g, NULL, NULL); + /* Initialize fapl info struct */ + HDmemset(&vol_info, 0, sizeof(h5tools_vol_info_t)); /* Build object display table */ DISPATCH(H5O_TYPE_GROUP, "Group", NULL, NULL); @@ -2948,6 +2724,19 @@ main(int argc, const char *argv[]) else if (!HDstrncmp(argv[argno], "--vfd=", (size_t)6)) { preferred_driver = argv[argno]+6; } + else if (!HDstrncmp(argv[argno], "--vol-value=", (size_t)12)) { + vol_info.type = VOL_BY_VALUE; + vol_info.u.value = (H5VL_class_value_t)HDatoi(argv[argno]+12); + custom_vol_fapl = TRUE; + } + else if (!HDstrncmp(argv[argno], "--vol-name=", (size_t)11)) { + vol_info.type = VOL_BY_NAME; + vol_info.u.name = argv[argno]+11; + custom_vol_fapl = TRUE; + } + else if (!HDstrncmp(argv[argno], "--vol-info=", (size_t)11)) { + vol_info.info_string = argv[argno]+11; + } else if (!HDstrncmp(argv[argno], "--width=", (size_t)8)) { width_g = (int)HDstrtol(argv[argno]+8, &rest, 0); @@ -3005,18 +2794,9 @@ main(int argc, const char *argv[]) } else if (!HDstrncmp(argv[argno], "--s3-cred=", (size_t)10)) { -#ifndef H5_HAVE_ROS3_VFD - HDfprintf(rawerrorstream, "Error: Read-Only S3 VFD is not enabled\n\n"); - usage(); - leave(EXIT_FAILURE); -#else - unsigned nelems = 0; - char *start = NULL; - char *s3cred_src = NULL; - char **s3cred = NULL; - char const *ccred[3]; - /* try to parse s3 credentials tuple - */ +#ifdef H5_HAVE_ROS3_VFD + char const *start = NULL; + start = strchr(argv[argno], '='); if (start == NULL) { HDfprintf(rawerrorstream, "Error: Unable to parse null credentials tuple\n" @@ -3025,124 +2805,38 @@ main(int argc, const char *argv[]) leave(EXIT_FAILURE); } start++; - if (FAIL == parse_tuple((const char *)start, ',', &s3cred_src, &nelems, &s3cred)) { - HDfprintf(rawerrorstream, "Error: Unable to parse S3 credentials\n\n"); - usage(); - leave(EXIT_FAILURE); - } - /* sanity-check tuple count - */ - if (nelems != 3) { - HDfprintf(rawerrorstream, "Error: Invalid S3 credentials\n\n"); - usage(); - leave(EXIT_FAILURE); - } - ccred[0] = (const char *)s3cred[0]; - ccred[1] = (const char *)s3cred[1]; - ccred[2] = (const char *)s3cred[2]; - if (0 == h5tools_populate_ros3_fapl(&ros3_fa, ccred)) { - HDfprintf(rawerrorstream, "Error: Invalid S3 credentials\n\n"); + + if (h5tools_parse_ros3_fapl_tuple(start, ',', &ros3_fa) < 0) { + HDfprintf(rawerrorstream, "Error: failed to parse S3 VFD credential info\n\n"); usage(); leave(EXIT_FAILURE); } - HDfree(s3cred); - HDfree(s3cred_src); -#endif /* H5_HAVE_ROS3_VFD */ - +#else + HDfprintf(rawerrorstream, "Error: Read-Only S3 VFD is not enabled\n\n"); + usage(); + leave(EXIT_FAILURE); +#endif } else if (!HDstrncmp(argv[argno], "--hdfs-attrs=", (size_t)13)) { -#ifndef H5_HAVE_LIBHDFS - PRINTVALSTREAM(rawoutstream, "The HDFS VFD is not enabled.\n"); - leave(EXIT_FAILURE); -#else - /* Parse received configuration data and set fapl config struct */ - - hbool_t _debug = FALSE; - unsigned nelems = 0; - char const *start = NULL; - char *props_src = NULL; - char **props = NULL; - unsigned long k = 0; - - /* try to parse tuple - */ - if (_debug) { - HDfprintf(stderr, "configuring hdfs...\n"); - } +#ifdef H5_HAVE_LIBHDFS + char const *start = NULL; + start = argv[argno]+13; /* should never segfault: worst case of */ if (*start != '(') { /* null-termintor after '='. */ - - if (_debug) { - HDfprintf(stderr, " no tuple.\n"); - } - usage(); - leave(EXIT_FAILURE); - } - if (FAIL == parse_tuple((const char *)start, ',', &props_src, &nelems, &props)) { - HDfprintf(stderr, " unable to parse tuple.\n"); usage(); leave(EXIT_FAILURE); } - /* sanity-check tuple count - */ - if (nelems != 5) { - HDfprintf(stderr, " expected 5-ple, got `%d`\n", nelems); + if (h5tools_parse_hdfs_fapl_tuple(start, ',', &hdfs_fa) < 0) { + HDfprintf(rawerrorstream, "Error: failed to parse HDFS VFD configuration info\n\n"); usage(); leave(EXIT_FAILURE); } - if (_debug) { - HDfprintf(stderr, " got hdfs-attrs tuple: `(%s,%s,%s,%s,%s)`\n", props[0], props[1], props[2], props[3], props[4]); - } - - /* Populate fapl configuration structure with given properties. - * WARNING: No error-checking is done on length of input strings... - * Silent overflow is possible, albeit unlikely. - */ - if (HDstrncmp(props[0], "", 1)) { - if (_debug) { - HDfprintf(stderr, " setting namenode name: %s\n", props[0]); - } - HDstrncpy(hdfs_fa.namenode_name, (const char *)props[0], HDstrlen(props[0])); - } - if (HDstrncmp(props[1], "", 1)) { - k = strtoul((const char *)props[1], NULL, 0); - if (errno == ERANGE) { - HDfprintf(stderr, " supposed port number wasn't.\n"); - leave(EXIT_FAILURE); - } - if (_debug) { - HDfprintf(stderr, " setting namenode port: %lu\n", k); - } - hdfs_fa.namenode_port = (int32_t)k; - } - if (HDstrncmp(props[2], "", 1)) { - if (_debug) { - HDfprintf(stderr, " setting kerb cache path: %s\n", props[2]); - } - HDstrncpy(hdfs_fa.kerberos_ticket_cache, (const char *)props[2], HDstrlen(props[2])); - } - if (HDstrncmp(props[3], "", 1)) { - if (_debug) { - HDfprintf(stderr, " setting username: %s\n", props[3]); - } - HDstrncpy(hdfs_fa.user_name, (const char *)props[3], HDstrlen(props[3])); - } - if (HDstrncmp(props[4], "", 1)) { - k = HDstrtoul((const char *)props[4], NULL, 0); - if (errno == ERANGE) { - HDfprintf(stderr, " supposed buffersize number wasn't.\n"); - leave(EXIT_FAILURE); - } - if (_debug) { - HDfprintf(stderr, " setting stream buffer size: %lu\n", k); - } - hdfs_fa.stream_buffer_size = (int32_t)k; - } - HDfree(props); - HDfree(props_src); -#endif /* H5_HAVE_LIBHDFS */ - +#else + HDfprintf(rawerrorstream, "Error: The HDFS VFD is not enabled\n\n"); + usage(); + leave(EXIT_FAILURE); +#endif } else if('-'!=argv[argno][1]) { /* Single-letter switches */ @@ -3222,6 +2916,9 @@ main(int argc, const char *argv[]) } } /* end for */ + /* enable error reporting if command line option */ + h5tools_error_report(); + /* If no arguments remain then print a usage message (instead of doing * absolutely nothing ;-) */ if (argno >= argc) { @@ -3235,46 +2932,41 @@ main(int argc, const char *argv[]) leave(EXIT_FAILURE); } + /* Setup a custom fapl for file accesses */ + if (custom_vol_fapl) { + if ((fapl_id = h5tools_get_fapl(H5P_DEFAULT, &vol_info, NULL)) < 0) { + error_msg("failed to setup file access property list (fapl) for file\n"); + leave(EXIT_FAILURE); + } + } + if (preferred_driver) { - void *conf_fa = NULL; + h5tools_vfd_info_t vfd_info; - if (!HDstrcmp(preferred_driver, "ros3")) { -#ifndef H5_HAVE_ROS3_VFD - HDfprintf(rawerrorstream, "Error: Read-Only S3 VFD not enabled.\n\n"); - usage(); - leave(EXIT_FAILURE); -#else - conf_fa = (void *)&ros3_fa; -#endif /* H5_HAVE_ROS3_VFD */ + vfd_info.info = NULL; + vfd_info.name = preferred_driver; - } - else if (!HDstrcmp(preferred_driver, "hdfs")) { -#ifndef H5_HAVE_LIBHDFS - PRINTVALSTREAM(rawoutstream, "The HDFS VFD is not enabled.\n"); + if (!HDstrcmp(preferred_driver, drivernames[ROS3_VFD_IDX])) { +#ifdef H5_HAVE_ROS3_VFD + vfd_info.info = (void *)&ros3_fa; +#else + HDfprintf(rawerrorstream, "Error: Read-Only S3 VFD is not enabled\n\n"); leave(EXIT_FAILURE); +#endif + } + else if (!HDstrcmp(preferred_driver, drivernames[HDFS_VFD_IDX])) { +#ifdef H5_HAVE_LIBHDFS + vfd_info.info = (void *)&hdfs_fa; #else - conf_fa = (void *)&hdfs_fa; -#endif /* H5_HAVE_LIBHDFS */ + HDfprintf(rawerrorstream, "Error: The HDFS VFD is not enabled\n\n"); + leave(EXIT_FAILURE); +#endif } - if (conf_fa != NULL) { - HDassert(fapl_id == H5P_DEFAULT); - fapl_id = H5Pcreate(H5P_FILE_ACCESS); - if (fapl_id < 0) { - HDfprintf(rawerrorstream, "Error: Unable to create fapl entry\n\n"); - leave(EXIT_FAILURE); - } - if (0 == h5tools_set_configured_fapl(fapl_id, preferred_driver, conf_fa)) { - HDfprintf(rawerrorstream, "Error: Unable to set fapl\n\n"); - usage(); - leave(EXIT_FAILURE); - } + if ((fapl_id = h5tools_get_fapl(H5P_DEFAULT, NULL, &vfd_info)) < 0) { + HDfprintf(rawerrorstream, "Error: Unable to create FAPL for file access\n\n"); + leave(EXIT_FAILURE); } - } /* preferred_driver defined */ - - if (enable_error_stack > 0) { - H5Eset_auto2(H5E_DEFAULT, func, edata); - H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata); } /* Each remaining argument is an hdf5 file followed by an optional slash @@ -3301,12 +2993,8 @@ main(int argc, const char *argv[]) file_id = H5I_INVALID_HID; while (fname && *fname) { - if (fapl_id != H5P_DEFAULT) { - file_id = H5Fopen(fname, H5F_ACC_RDONLY, fapl_id); - } - else { - file_id = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, preferred_driver, drivername, sizeof drivername); - } + file_id = h5tools_fopen(fname, H5F_ACC_RDONLY, fapl_id, + (fapl_id == H5P_DEFAULT) ? FALSE : TRUE, drivername, sizeof drivername); if (file_id >= 0) { if (verbose_g) @@ -3339,7 +3027,6 @@ main(int argc, const char *argv[]) x = oname; if (NULL == (oname = HDstrdup(oname))) { HDfprintf(rawerrorstream, "memory allocation failed\n"); - H5Eset_auto2(H5E_DEFAULT, func, edata); leave(EXIT_FAILURE); } *x = '\0'; @@ -3384,7 +3071,6 @@ main(int argc, const char *argv[]) h5tools_str_reset(&buffer); print_obj_name(&buffer, &iter, oname, "**NOT FOUND**"); h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0); - H5Eset_auto2(H5E_DEFAULT, func, edata); leave(EXIT_FAILURE); } /* end if */ } /* end if */ @@ -3394,7 +3080,6 @@ main(int argc, const char *argv[]) /* Open the object and display it's information */ if (li.type == H5L_TYPE_HARD) { if (visit_obj(file_id, oname, &iter) < 0) { - H5Eset_auto2(H5E_DEFAULT, func, edata); leave(EXIT_FAILURE); } } /* end if(li.type == H5L_TYPE_HARD) */ @@ -3425,12 +3110,10 @@ main(int argc, const char *argv[]) if (fapl_id != H5P_DEFAULT) { if (0 < H5Pclose(fapl_id)) { HDfprintf(rawerrorstream, "Error: Unable to set close fapl entry\n\n"); - H5Eset_auto2(H5E_DEFAULT, func, edata); leave(EXIT_FAILURE); } } - H5Eset_auto2(H5E_DEFAULT, func, edata); if (err_exit) leave(EXIT_FAILURE); else diff --git a/tools/src/h5repack/h5repack.c b/tools/src/h5repack/h5repack.c index 8eeaa0e..b2cb02b 100644 --- a/tools/src/h5repack/h5repack.c +++ b/tools/src/h5repack/h5repack.c @@ -79,6 +79,8 @@ h5repack_init(pack_opt_t *options, int verbose, hbool_t latest) options->layout_g = H5D_LAYOUT_ERROR; options->low_bound = H5F_LIBVER_EARLIEST; options->high_bound = H5F_LIBVER_LATEST; + options->fin_fapl = H5P_DEFAULT; + options->fout_fapl = H5P_DEFAULT; for (n = 0; n < H5_REPACK_MAX_NFILTERS; n++) { options->filter_g[n].filtn = -1; @@ -257,7 +259,7 @@ copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, t dt->next = *named_dt_head_p; *named_dt_head_p = dt; - /* Update the address and id */ + /* Update the token/address and id */ HDmemcpy(&dt->obj_token, &travt->objs[i].obj_token, sizeof(H5O_token_t)); dt->id_out = H5I_INVALID_HID; @@ -280,7 +282,7 @@ copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, t dt_ret->next = *named_dt_head_p; *named_dt_head_p = dt_ret; - /* Update the address and id */ + /* Update the token/address and id */ HDmemcpy(&dt_ret->obj_token, &oinfo.token, sizeof(H5O_token_t)); dt_ret->id_out = H5I_INVALID_HID; } /* end if requested datatype not found */ @@ -751,7 +753,8 @@ check_objects(const char* fname, pack_opt_t *options) * open the file *------------------------------------------------------------------------- */ - if ((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, 0)) < 0) + if ((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, options->fin_fapl, + (options->fin_fapl == H5P_DEFAULT) ? FALSE : TRUE, NULL, 0)) < 0) H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fname, H5FOPENERROR); /*------------------------------------------------------------------------- diff --git a/tools/src/h5repack/h5repack.h b/tools/src/h5repack/h5repack.h index 52ecb0e..caa1166 100644 --- a/tools/src/h5repack/h5repack.h +++ b/tools/src/h5repack/h5repack.h @@ -114,6 +114,8 @@ typedef struct { hbool_t latest; /*pack file with the latest file format */ H5F_libver_t low_bound; /* The file's low bound as in H5Fset_libver_bounds() */ H5F_libver_t high_bound; /* The file's high bound as in H5Fset_libver_bounds() */ + hid_t fin_fapl; /* FAPL to use for opening the input file */ + hid_t fout_fapl; /* FAPL to use for opening/creating the output file */ int grp_compact; /* Set the maximum number of links to store as header messages in the group */ int grp_indexed; /* Set the minimum number of links to store in the indexed format */ int msg_size[8]; /* Minimum size of shared messages: dataspace, @@ -151,7 +153,7 @@ int h5repack_addlayout(const char* str, pack_opt_t *options); int h5repack_init(pack_opt_t *options, int verbose, hbool_t latest); int h5repack_end(pack_opt_t *options); int h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options); -int h5repack_cmp_pl(const char *fname1, const char *fname2); +int h5repack_cmp_pl(const char *fname1, hid_t fname1_fapl, const char *fname2, hid_t fname2_fapl); /* Note: The below copy_named_datatype(), named_datatype_free(), copy_attr() * and struct named_dt_t were located in h5repack_copy.c as static prior to diff --git a/tools/src/h5repack/h5repack_copy.c b/tools/src/h5repack/h5repack_copy.c index 1044244..b1d6ab4 100644 --- a/tools/src/h5repack/h5repack_copy.c +++ b/tools/src/h5repack/h5repack_copy.c @@ -67,7 +67,6 @@ copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) hid_t grp_in = H5I_INVALID_HID; /* group ID */ hid_t gcpl_in = H5I_INVALID_HID; /* group creation property list */ hid_t fcpl = H5P_DEFAULT; /* file creation property list ID */ - hid_t fapl = H5P_DEFAULT; /* file access property list ID */ trav_table_t *travt = NULL; hsize_t ub_size = 0; /* size of user block */ H5F_fspace_strategy_t set_strategy; /* Strategy to be set in outupt file */ @@ -85,7 +84,8 @@ copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) * open input file *------------------------------------------------------------------------- */ - if ((fidin = h5tools_fopen(fnamein, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t) 0)) < 0) + if ((fidin = h5tools_fopen(fnamein, H5F_ACC_RDONLY, options->fin_fapl, + (options->fin_fapl == H5P_DEFAULT) ? FALSE : TRUE, NULL, (size_t) 0)) < 0) H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fnamein, H5FOPENERROR); /* get user block size and file space strategy/persist/threshold */ @@ -122,12 +122,14 @@ copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) if(options->latest) options->low_bound = options->high_bound = H5F_LIBVER_LATEST; + /* Create file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) - H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed to create file access property list"); + if (options->fout_fapl == H5P_DEFAULT) + if ((options->fout_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed to create file access property list"); /* It can be default, latest or other settings by users */ - if(H5Pset_libver_bounds(fapl, options->low_bound, options->high_bound) < 0) + if(H5Pset_libver_bounds(options->fout_fapl, options->low_bound, options->high_bound) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pset_libver_bounds failed to set format version bounds"); /* Check if we need to create a non-default file creation property list */ @@ -218,12 +220,12 @@ print_user_block(fnamein, fidin); */ if (options->alignment > 0) { /* either use the FAPL already created or create a new one */ - if (fapl == H5P_DEFAULT) + if (options->fout_fapl == H5P_DEFAULT) /* create a file access property list */ - if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((options->fout_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed to create file access property list"); - if (H5Pset_alignment(fapl, options->threshold, options->alignment) < 0) + if (H5Pset_alignment(options->fout_fapl, options->threshold, options->alignment) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pset_alignment failed to set alignment"); } @@ -233,12 +235,12 @@ print_user_block(fnamein, fidin); */ if (options->meta_block_size > 0) { /* either use the FAPL already created or create a new one */ - if (fapl == H5P_DEFAULT) + if (options->fout_fapl == H5P_DEFAULT) /* create a file access property list */ - if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((options->fout_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed to create file access property list"); - if (H5Pset_meta_block_size(fapl, options->meta_block_size) < 0) + if (H5Pset_meta_block_size(options->fout_fapl, options->meta_block_size) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pset_meta_block_size failed to set metadata block size"); } @@ -297,7 +299,7 @@ print_user_block(fnamein, fidin); if (options->verbose) HDprintf("Making new file ...\n"); - if ((fidout = H5Fcreate(fnameout, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((fidout = H5Fcreate(fnameout, H5F_ACC_TRUNC, fcpl, options->fout_fapl)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Fcreate could not create file <%s>:", fnameout); /*------------------------------------------------------------------------- @@ -352,7 +354,6 @@ done: H5E_BEGIN_TRY { H5Pclose(fcpl_in); H5Pclose(gcpl_in); - H5Pclose(fapl); H5Pclose(fcpl); H5Gclose(grp_in); H5Fclose(fidin); @@ -702,11 +703,14 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, break; - /*------------------------------------------------------------------------- - * H5TRAV_TYPE_DATASET - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * H5TRAV_TYPE_DATASET + *------------------------------------------------------------------------- + */ case H5TRAV_TYPE_DATASET: + { + hbool_t use_h5ocopy; + has_filter = 0; req_filter = 0; @@ -764,9 +768,47 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, * otherwise we do a copy using H5Ocopy *------------------------------------------------------------------------- */ - if (options->op_tbl->nelems || options->all_filter == 1 - || options->all_layout == 1 || is_ref || is_named) { + use_h5ocopy = !(options->op_tbl->nelems || options->all_filter == 1 + || options->all_layout == 1 || is_ref || is_named); + + /* + * Check if we are using different source and destination VOL connectors. + * In this case, we currently have to avoid usage of H5Ocopy since it + * doesn't support this. + */ + if (use_h5ocopy && (options->fin_fapl != H5P_DEFAULT || options->fout_fapl != H5P_DEFAULT)) { + hid_t in_vol_id; + hid_t out_vol_id; + hid_t default_vol_id; + + if (H5Pget_vol_id(H5P_FILE_ACCESS_DEFAULT, &default_vol_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pget_vol_id failed"); + + if (options->fin_fapl == H5P_DEFAULT) + in_vol_id = default_vol_id; + else + if (H5Pget_vol_id(options->fin_fapl, &in_vol_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pget_vol_id failed"); + if (options->fout_fapl == H5P_DEFAULT) + out_vol_id = default_vol_id; + else + if (H5Pget_vol_id(options->fout_fapl, &out_vol_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pget_vol_id failed"); + + if (in_vol_id != out_vol_id) + use_h5ocopy = FALSE; + + if (in_vol_id != default_vol_id) + if (H5VLclose(in_vol_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5VLclose failed"); + if (out_vol_id != default_vol_id) + if (H5VLclose(out_vol_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5VLclose failed"); + if (H5VLclose(default_vol_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5VLclose failed"); + } + if (!use_h5ocopy) { int j; if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) @@ -1135,7 +1177,9 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, HDprintf(FORMAT_OBJ, "dset", travt->objs[i].name); } /* end whether we have request for filter/chunking */ + break; + } /* H5TRAV_TYPE_DATASET */ /*------------------------------------------------------------------------- * H5TRAV_TYPE_NAMED_DATATYPE diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c index 72ed7d7..0ad61c0 100644 --- a/tools/src/h5repack/h5repack_main.c +++ b/tools/src/h5repack/h5repack_main.c @@ -62,6 +62,12 @@ static struct long_options l_opts[] = { { "sort_by", require_arg, 'q' }, { "sort_order", require_arg, 'z' }, { "enable-error-stack", no_arg, 'E' }, + { "src-vol-value", require_arg, '1' }, + { "src-vol-name", require_arg, '2' }, + { "src-vol-info", require_arg, '3' }, + { "dst-vol-value", require_arg, '4' }, + { "dst-vol-name", require_arg, '5' }, + { "dst-vol-info", require_arg, '6' }, { NULL, 0, '\0' } }; @@ -86,6 +92,18 @@ static void usage(const char *prog) { PRINTVALSTREAM(rawoutstream, " -n, --native Use a native HDF5 type when repacking\n"); PRINTVALSTREAM(rawoutstream, " --enable-error-stack Prints messages from the HDF5 error stack as they\n"); PRINTVALSTREAM(rawoutstream, " occur\n"); + PRINTVALSTREAM(rawoutstream, " --src-vol-value Value (ID) of the VOL connector to use for opening the\n"); + PRINTVALSTREAM(rawoutstream, " input HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, " --src-vol-name Name of the VOL connector to use for opening the input\n"); + PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, " --src-vol-info VOL-specific info to pass to the VOL connector used for\n"); + PRINTVALSTREAM(rawoutstream, " opening the input HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, " --dst-vol-value Value (ID) of the VOL connector to use for opening the\n"); + PRINTVALSTREAM(rawoutstream, " output HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, " --dst-vol-name Name of the VOL connector to use for opening the output\n"); + PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, " --dst-vol-info VOL-specific info to pass to the VOL connector used for\n"); + PRINTVALSTREAM(rawoutstream, " opening the output HDF5 file specified\n"); PRINTVALSTREAM(rawoutstream, " -L, --latest Use latest version of file format\n"); PRINTVALSTREAM(rawoutstream, " This option will take precedence over the options\n"); PRINTVALSTREAM(rawoutstream, " --low and --high\n"); @@ -139,7 +157,8 @@ static void usage(const char *prog) { PRINTVALSTREAM(rawoutstream, " 1: This is H5F_LIBVER_V18 in H5F_libver_t struct\n"); PRINTVALSTREAM(rawoutstream, " 2: This is H5F_LIBVER_V110 in H5F_libver_t struct\n"); PRINTVALSTREAM(rawoutstream, " 3: This is H5F_LIBVER_V112 in H5F_libver_t struct\n"); - PRINTVALSTREAM(rawoutstream, " (H5F_LIBVER_LATEST is aliased to H5F_LIBVER_V112 for this release\n"); + PRINTVALSTREAM(rawoutstream, " 4: This is H5F_LIBVER_V114 in H5F_libver_t struct\n"); + PRINTVALSTREAM(rawoutstream, " (H5F_LIBVER_LATEST is aliased to H5F_LIBVER_V114 for this release\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " FS_STRATEGY is a string indicating the file space strategy used:\n"); PRINTVALSTREAM(rawoutstream, " FSM_AGGR:\n"); @@ -292,6 +311,8 @@ int read_info(const char *filename, pack_opt_t *options) /* cycle until end of file reached */ while (1) { + if (EOF == fscanf(fp, "%9s", stype)) + break; /* Info indicator must be for layout or filter */ if (HDstrcmp(stype,"-l") && HDstrcmp(stype, "-f")) { @@ -333,7 +354,7 @@ int read_info(const char *filename, pack_opt_t *options) if (!HDstrcmp(stype, "-l")) { if (h5repack_addlayout(comp_info, options) == -1) { - error_msg("could not add chunck option\n"); + error_msg("could not add chunk option\n"); h5tools_setstatus(EXIT_FAILURE); ret_value = EXIT_FAILURE; goto done; @@ -411,9 +432,18 @@ set_sort_order(const char *form) static int parse_command_line(int argc, const char **argv, pack_opt_t* options) { + h5tools_vol_info_t in_vol_info; + h5tools_vol_info_t out_vol_info; + hbool_t custom_in_fapl = FALSE; + hbool_t custom_out_fapl = FALSE; + hid_t tmp_fapl = H5I_INVALID_HID; int bound, opt; int ret_value = 0; + /* Initialize fapl info structs */ + HDmemset(&in_vol_info, 0, sizeof(h5tools_vol_info_t)); + HDmemset(&out_vol_info, 0, sizeof(h5tools_vol_info_t)); + /* parse command line options */ while (EOF != (opt = get_option(argc, argv, s_opts, l_opts))) { switch ((char) opt) { @@ -433,13 +463,13 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) case 'h': usage(h5tools_getprogname()); h5tools_setstatus(EXIT_SUCCESS); - ret_value = -1; + ret_value = 1; goto done; case 'V': print_version(h5tools_getprogname()); h5tools_setstatus(EXIT_SUCCESS); - ret_value = -1; + ret_value = 1; goto done; case 'v': @@ -477,9 +507,12 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) break; case 'e': - ret_value = read_info(opt_arg, options); - if (ret_value < 0) + if ((ret_value = read_info(opt_arg, options)) < 0) { + error_msg("failed to read from repack options file <%s>\n", opt_arg); + h5tools_setstatus(EXIT_FAILURE); + ret_value = -1; goto done; + } break; case 'n': @@ -494,6 +527,8 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) bound = HDatoi(opt_arg); if (bound < H5F_LIBVER_EARLIEST || bound > H5F_LIBVER_LATEST) { error_msg("in parsing low bound\n"); + h5tools_setstatus(EXIT_FAILURE); + ret_value = -1; goto done; } options->low_bound = bound; @@ -503,6 +538,8 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) bound = HDatoi(opt_arg); if (bound < H5F_LIBVER_EARLIEST || bound > H5F_LIBVER_LATEST) { error_msg("in parsing high bound\n"); + h5tools_setstatus(EXIT_FAILURE); + ret_value = -1; goto done; } options->high_bound = bound; @@ -624,8 +661,8 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) break; case 'q': - if (H5_INDEX_UNKNOWN == set_sort_by(opt_arg)) { - error_msg(" failed to set sort by form <%s>\n", opt_arg); + if (H5_INDEX_UNKNOWN == (sort_by = set_sort_by(opt_arg))) { + error_msg("failed to set sort by form <%s>\n", opt_arg); h5tools_setstatus(EXIT_FAILURE); ret_value = -1; goto done; @@ -633,8 +670,8 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) break; case 'z': - if (set_sort_order(opt_arg) == H5_ITER_UNKNOWN) { - error_msg(" failed to set sort order form <%s>\n", opt_arg); + if (H5_ITER_UNKNOWN == (sort_order = set_sort_order(opt_arg))) { + error_msg("failed to set sort order form <%s>\n", opt_arg); h5tools_setstatus(EXIT_FAILURE); ret_value = -1; goto done; @@ -645,6 +682,38 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) enable_error_stack = 1; break; + case '1': + in_vol_info.type = VOL_BY_VALUE; + in_vol_info.u.value = (H5VL_class_value_t)HDatoi(opt_arg); + custom_in_fapl = TRUE; + break; + + case '2': + in_vol_info.type = VOL_BY_NAME; + in_vol_info.u.name = opt_arg; + custom_in_fapl = TRUE; + break; + + case '3': + in_vol_info.info_string = opt_arg; + break; + + case '4': + out_vol_info.type = VOL_BY_VALUE; + out_vol_info.u.value = (H5VL_class_value_t)HDatoi(opt_arg); + custom_out_fapl = TRUE; + break; + + case '5': + out_vol_info.type = VOL_BY_NAME; + out_vol_info.u.name = opt_arg; + custom_out_fapl = TRUE; + break; + + case '6': + out_vol_info.info_string = opt_arg; + break; + default: break; } /* end switch */ @@ -652,30 +721,71 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) /* If neither -i nor -o given, get in and out files positionally */ if (0 == (has_i + has_o)) { - if (argv[opt_ind] != NULL && argv[opt_ind + 1] != NULL) { - infile = argv[opt_ind]; - outfile = argv[opt_ind + 1]; - - if (!HDstrcmp(infile, outfile)) { - error_msg("file names cannot be the same\n"); - usage(h5tools_getprogname()); - h5tools_setstatus(EXIT_FAILURE); - ret_value = -1; - } - } - else { - error_msg("file names missing\n"); - usage(h5tools_getprogname()); - h5tools_setstatus(EXIT_FAILURE); - ret_value = -1; - } - } - else if (has_i != 1 || has_o != 1) { - error_msg("filenames must be either both -i -o or both positional\n"); - usage(h5tools_getprogname()); - h5tools_setstatus(EXIT_FAILURE); - ret_value = -1; - } + if (argv[opt_ind] != NULL && argv[opt_ind + 1] != NULL) { + infile = argv[opt_ind]; + outfile = argv[opt_ind + 1]; + + if (!HDstrcmp(infile, outfile)) { + error_msg("file names cannot be the same\n"); + usage(h5tools_getprogname()); + h5tools_setstatus(EXIT_FAILURE); + ret_value = -1; + } + } + else { + error_msg("file names missing\n"); + usage(h5tools_getprogname()); + h5tools_setstatus(EXIT_FAILURE); + ret_value = -1; + } + } + else if (has_i != 1 || has_o != 1) { + error_msg("filenames must be either both -i -o or both positional\n"); + usage(h5tools_getprogname()); + h5tools_setstatus(EXIT_FAILURE); + ret_value = -1; + } + + /* Setup FAPL for input and output file accesses */ + if (custom_in_fapl) { + if ((tmp_fapl = h5tools_get_fapl(options->fin_fapl, &in_vol_info, NULL)) < 0) { + error_msg("failed to setup FAPL for input file\n"); + h5tools_setstatus(EXIT_FAILURE); + ret_value = -1; + goto done; + } + + /* Close old FAPL */ + if (options->fin_fapl != H5P_DEFAULT) + if (H5Pclose(options->fin_fapl) < 0) { + error_msg("failed to close FAPL\n"); + h5tools_setstatus(EXIT_FAILURE); + ret_value = -1; + goto done; + } + + options->fin_fapl = tmp_fapl; + } + + if (custom_out_fapl) { + if ((tmp_fapl = h5tools_get_fapl(options->fout_fapl, &out_vol_info, NULL)) < 0) { + error_msg("failed to setup FAPL for output file\n"); + h5tools_setstatus(EXIT_FAILURE); + ret_value = -1; + goto done; + } + + /* Close old FAPL */ + if (options->fout_fapl != H5P_DEFAULT) + if (H5Pclose(options->fout_fapl) < 0) { + error_msg("failed to close FAPL\n"); + h5tools_setstatus(EXIT_FAILURE); + ret_value = -1; + goto done; + } + + options->fout_fapl = tmp_fapl; + } done: return ret_value; @@ -693,54 +803,64 @@ done: */ int main(int argc, const char **argv) { - pack_opt_t options; /*the global options */ - H5E_auto2_t func; - H5E_auto2_t tools_func; - void *edata; - void *tools_edata; + pack_opt_t options; /*the global options */ + int parse_ret; HDmemset(&options, 0, sizeof(pack_opt_t)); - h5tools_setprogname(PROGRAMNAME); - h5tools_setstatus(EXIT_SUCCESS); - - /* Disable error reporting */ - H5Eget_auto2(H5E_DEFAULT, &func, &edata); - H5Eset_auto2(H5E_DEFAULT, NULL, NULL); - /* Initialize h5tools lib */ h5tools_init(); - /* Disable tools error reporting */ - H5Eget_auto2(H5tools_ERR_STACK_g, &tools_func, &tools_edata); - H5Eset_auto2(H5tools_ERR_STACK_g, NULL, NULL); + h5tools_setprogname(PROGRAMNAME); + h5tools_setstatus(EXIT_SUCCESS); /* update hyperslab buffer size from H5TOOLS_BUFSIZE env if exist */ if (h5tools_getenv_update_hyperslab_bufsize() < 0) { + HDprintf("Error occurred while retrieving H5TOOLS_BUFSIZE value\n"); h5tools_setstatus(EXIT_FAILURE); goto done; } /* initialize options */ if (h5repack_init(&options, 0, FALSE) < 0) { + HDprintf("Error occurred while initializing repack options\n"); h5tools_setstatus(EXIT_FAILURE); goto done; } + /* Initialize default indexing options */ sort_by = H5_INDEX_CRT_ORDER; - if (parse_command_line(argc, argv, &options) < 0) + parse_ret = parse_command_line(argc, argv, &options); + if (parse_ret < 0) { + HDprintf("Error occurred while parsing command-line options\n"); + h5tools_setstatus(EXIT_FAILURE); goto done; - - if (enable_error_stack > 0) { - H5Eset_auto2(H5E_DEFAULT, func, edata); - H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata); } + else if (parse_ret > 0) { + /* Short-circuit success */ + h5tools_setstatus(EXIT_SUCCESS); + goto done; + } + + /* enable error reporting if command line option */ + h5tools_error_report(); /* pack it */ - h5tools_setstatus(h5repack(infile, outfile, &options)); + if (h5repack(infile, outfile, &options) < 0) { + HDprintf("Error occurred while repacking\n"); + h5tools_setstatus(EXIT_FAILURE); + goto done; + } + + h5tools_setstatus(EXIT_SUCCESS); done: + if (options.fin_fapl >= 0 && options.fin_fapl != H5P_DEFAULT) + H5Pclose(options.fin_fapl); + if (options.fout_fapl >= 0 && options.fout_fapl != H5P_DEFAULT) + H5Pclose(options.fout_fapl); + /* free tables */ h5repack_end(&options); diff --git a/tools/src/h5repack/h5repack_verify.c b/tools/src/h5repack/h5repack_verify.c index 683988c..7bb5dfd 100644 --- a/tools/src/h5repack/h5repack_verify.c +++ b/tools/src/h5repack/h5repack_verify.c @@ -353,16 +353,16 @@ int verify_layout(hid_t pid, pack_info_t *obj) *------------------------------------------------------------------------- */ -int h5repack_cmp_pl(const char *fname1, const char *fname2) +int h5repack_cmp_pl(const char *fname1, hid_t fname1_fapl, const char *fname2, hid_t fname2_fapl) { - hid_t fid1 =H5I_INVALID_HID; /* file ID */ - hid_t fid2 =H5I_INVALID_HID; /* file ID */ - hid_t dset1 =H5I_INVALID_HID; /* dataset ID */ - hid_t dset2 =H5I_INVALID_HID; /* dataset ID */ - hid_t gid =H5I_INVALID_HID; /* group ID */ - hid_t dcpl1 =H5I_INVALID_HID; /* dataset creation property list ID */ - hid_t dcpl2 =H5I_INVALID_HID; /* dataset creation property list ID */ - hid_t gcplid =H5I_INVALID_HID; /* group creation property list */ + hid_t fid1 = H5I_INVALID_HID; /* file ID */ + hid_t fid2 = H5I_INVALID_HID; /* file ID */ + hid_t dset1 = H5I_INVALID_HID; /* dataset ID */ + hid_t dset2 = H5I_INVALID_HID; /* dataset ID */ + hid_t gid = H5I_INVALID_HID; /* group ID */ + hid_t dcpl1 = H5I_INVALID_HID; /* dataset creation property list ID */ + hid_t dcpl2 = H5I_INVALID_HID; /* dataset creation property list ID */ + hid_t gcplid = H5I_INVALID_HID; /* group creation property list */ unsigned crt_order_flag1; /* group creation order flag */ unsigned crt_order_flag2; /* group creation order flag */ trav_table_t *trav = NULL; @@ -374,9 +374,9 @@ int h5repack_cmp_pl(const char *fname1, const char *fname2) *------------------------------------------------------------------------- */ /* Open the files */ - if ((fid1 = H5Fopen(fname1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid1 = h5tools_fopen(fname1, H5F_ACC_RDONLY, fname1_fapl, TRUE, NULL, 0)) < 0) H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fname1, H5FOPENERROR); - if ((fid2 = H5Fopen(fname2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid2 = h5tools_fopen(fname2, H5F_ACC_RDONLY, fname2_fapl, TRUE, NULL, 0)) < 0) H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fname2, H5FOPENERROR); /*------------------------------------------------------------------------- diff --git a/tools/src/h5stat/h5stat.c b/tools/src/h5stat/h5stat.c index adc905a..ec4b5ab 100644 --- a/tools/src/h5stat/h5stat.c +++ b/tools/src/h5stat/h5stat.c @@ -118,30 +118,28 @@ typedef struct iter_t { } iter_t; -static const char *drivername = ""; +static const char *drivername = NULL; #ifdef H5_HAVE_ROS3_VFD -/* default "anonymous" s3 configuration - */ +/* Default "anonymous" S3 configuration */ static H5FD_ros3_fapl_t ros3_fa = { - 1, /* fapl version */ - false, /* authenticate */ - "", /* aws region */ - "", /* access key id */ - "", /* secret access key */ + 1, /* Structure Version */ + false, /* Authenticate? */ + "", /* AWS Region */ + "", /* Access Key ID */ + "", /* Secret Access Key */ }; #endif /* H5_HAVE_ROS3_VFD */ #ifdef H5_HAVE_LIBHDFS -/* default HDFS access configuration - */ +/* "Default" HDFS configuration */ static H5FD_hdfs_fapl_t hdfs_fa = { - 1, /* fapl version */ - "localhost", /* namenode name */ - 0, /* namenode port */ - "", /* kerberos ticket cache */ - "", /* user name */ - 2048, /* stream buffer size */ + 1, /* Structure Version */ + "localhost", /* Namenode Name */ + 0, /* Namenode Port */ + "", /* Kerberos ticket cache */ + "", /* User name */ + 2048, /* Stream buffer size */ }; #endif /* H5_HAVE_LIBHDFS */ @@ -1065,103 +1063,32 @@ parse_command_line(int argc, const char *argv[], struct handler_t **hand_ret) break; case 'w': -#ifndef H5_HAVE_ROS3_VFD +#ifdef H5_HAVE_ROS3_VFD + if (h5tools_parse_ros3_fapl_tuple(opt_arg, ',', &ros3_fa) < 0) { + error_msg("failed to parse S3 VFD credential info\n"); + goto error; + } + + drivername = drivernames[ROS3_VFD_IDX]; +#else error_msg("Read-Only S3 VFD not enabled.\n"); goto error; -#else - { - char *cred_str = NULL; - unsigned nelems = 0; - char **cred = NULL; - char const *ccred[3]; - - if (FAIL == parse_tuple((const char *)opt_arg, ',', &cred_str, &nelems, &cred)) { - error_msg("Unable to parse s3 credential\n"); - goto error; - } - if (nelems != 3) { - error_msg("s3 credential must have three elements\n"); - goto error; - } - ccred[0] = (const char *)cred[0]; - ccred[1] = (const char *)cred[1]; - ccred[2] = (const char *)cred[2]; - if (0 == h5tools_populate_ros3_fapl(&ros3_fa, ccred)) { - error_msg("Unable to set ros3 fapl config\n"); - goto error; - } - HDfree(cred); - HDfree(cred_str); - } /* parse s3-cred block */ - drivername = "ros3"; +#endif break; -#endif /* H5_HAVE_ROS3_VFD */ case 'H': -#ifndef H5_HAVE_LIBHDFS - error_msg("HDFS VFD is not enabled.\n"); - goto error; -#else - { - unsigned nelems = 0; - char *props_src = NULL; - char **props = NULL; - unsigned long k = 0; - if (FAIL == parse_tuple((const char *)opt_arg, - ',', &props_src, &nelems, &props)) { - error_msg("unable to parse hdfs properties tuple\n"); - goto error; - } - /* sanity-check tuple count - */ - if (nelems != 5) { - char str[64] = ""; - HDsprintf(str, - "expected 5 elements in hdfs properties tuple " - "but found %u\n", - nelems); - HDfree(props); - HDfree(props_src); - error_msg(str); - goto error; - } - /* Populate fapl configuration structure with given - * properties. - * TODO/WARNING: No error-checking is done on length of - * input strings... Silent overflow is possible, - * albeit unlikely. - */ - if (HDstrncmp(props[0], "", 1)) { - HDstrncpy(hdfs_fa.namenode_name,(const char *)props[0], HDstrlen(props[0])); - } - if (HDstrncmp(props[1], "", 1)) { - k = strtoul((const char *)props[1], NULL, 0); - if (errno == ERANGE) { - error_msg("supposed port number wasn't.\n"); - goto error; - } - hdfs_fa.namenode_port = (int32_t)k; - } - if (HDstrncmp(props[2], "", 1)) { - HDstrncpy(hdfs_fa.kerberos_ticket_cache, (const char *)props[2], HDstrlen(props[2])); - } - if (HDstrncmp(props[3], "", 1)) { - HDstrncpy(hdfs_fa.user_name, (const char *)props[3], HDstrlen(props[3])); - } - if (strncmp(props[4], "", 1)) { - k = HDstrtoul((const char *)props[4], NULL, 0); - if (errno == ERANGE) { - error_msg("supposed buffersize number wasn't.\n"); - goto error; - } - hdfs_fa.stream_buffer_size = (int32_t)k; - } - HDfree(props); - HDfree(props_src); - drivername = "hdfs"; +#ifdef H5_HAVE_LIBHDFS + if (h5tools_parse_hdfs_fapl_tuple(opt_arg, ',', &hdfs_fa) < 0) { + error_msg("failed to parse HDFS VFD configuration info\n"); + goto error; } + + drivername = drivernames[HDFS_VFD_IDX]; +#else + error_msg("HDFS VFD not enabled.\n"); + goto error; +#endif break; -#endif /* H5_HAVE_LIBHDFS */ default: usage(h5tools_getprogname()); @@ -1859,75 +1786,54 @@ main(int argc, const char *argv[]) iter_t iter; const char *fname = NULL; hid_t fid = H5I_INVALID_HID; - H5E_auto2_t func; - H5E_auto2_t tools_func; - void *edata; - void *tools_edata; struct handler_t *hand = NULL; hid_t fapl_id = H5P_DEFAULT; h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); - /* Disable error reporting */ - H5Eget_auto2(H5E_DEFAULT, &func, &edata); - H5Eset_auto2(H5E_DEFAULT, NULL, NULL); - /* Initialize h5tools lib */ h5tools_init(); - /* Disable tools error reporting */ - H5Eget_auto2(H5tools_ERR_STACK_g, &tools_func, &tools_edata); - H5Eset_auto2(H5tools_ERR_STACK_g, NULL, NULL); - HDmemset(&iter, 0, sizeof(iter)); if(parse_command_line(argc, argv, &hand) < 0) goto done; - /* if drivername is not null, probably need to set the fapl */ - if (HDstrcmp(drivername, "")) { - void *conf_fa = NULL; + /* enable error reporting if command line option */ + h5tools_error_report(); - if (!HDstrcmp(drivername, "ros3")) { -#ifndef H5_HAVE_ROS3_VFD - error_msg("Read-Only S3 VFD not enabled.\n\n"); - goto done; -#else - conf_fa = (void *)&ros3_fa; -#endif /* H5_HAVE_ROS3_VFD */ + if (drivername) { + h5tools_vfd_info_t vfd_info; - } - else if (!HDstrcmp(drivername, "hdfs")) { -#ifndef H5_HAVE_LIBHDFS - error_msg("HDFS VFD not enabled.\n\n"); + vfd_info.info = NULL; + vfd_info.name = drivername; + + if (!HDstrcmp(drivername, drivernames[ROS3_VFD_IDX])) { +#ifdef H5_HAVE_ROS3_VFD + vfd_info.info = (void *)&ros3_fa; +#else + error_msg("Read-Only S3 VFD not enabled.\n"); goto done; +#endif + } + else if (!HDstrcmp(drivername, drivernames[HDFS_VFD_IDX])) { +#ifdef H5_HAVE_LIBHDFS + vfd_info.info = (void *)&hdfs_fa; #else - conf_fa = (void *)&hdfs_fa; -#endif /* H5_HAVE_LIBHDFS */ + error_msg("HDFS VFD not enabled.\n"); + goto done; +#endif } - if (conf_fa != NULL) { - HDassert(fapl_id == H5P_DEFAULT); - fapl_id = H5Pcreate(H5P_FILE_ACCESS); - if (fapl_id < 0) { - error_msg("Unable to create fapl entry\n"); - goto done; - } - if (1 > h5tools_set_configured_fapl(fapl_id, drivername, conf_fa)) { - error_msg("Unable to set fapl\n"); - goto done; - } + if ((fapl_id = h5tools_get_fapl(H5P_DEFAULT, NULL, &vfd_info)) < 0) { + error_msg("Unable to create FAPL for file access\n"); + goto done; } - } /* drivername set */ + } fname = argv[opt_ind]; - if(enable_error_stack > 0) { - H5Eset_auto2(H5E_DEFAULT, func, edata); - H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata); - } - /* Check for filename given */ if(fname) { hid_t fcpl; @@ -1935,7 +1841,9 @@ main(int argc, const char *argv[]) HDprintf("Filename: %s\n", fname); - fid = H5Fopen(fname, H5F_ACC_RDONLY, fapl_id); + fid = h5tools_fopen(fname, H5F_ACC_RDONLY, fapl_id, + (fapl_id == H5P_DEFAULT) ? FALSE : TRUE, NULL, 0); + if(fid < 0) { error_msg("unable to open file \"%s\"\n", fname); h5tools_setstatus(EXIT_FAILURE); @@ -2030,8 +1938,6 @@ done: h5tools_setstatus(EXIT_FAILURE); } /* end if */ - H5Eset_auto2(H5E_DEFAULT, func, edata); - leave(h5tools_getstatus()); } /* end main() */ diff --git a/tools/src/misc/h5clear.c b/tools/src/misc/h5clear.c index 42bb4ff..96cbf9c 100644 --- a/tools/src/misc/h5clear.c +++ b/tools/src/misc/h5clear.c @@ -266,9 +266,6 @@ main (int argc, const char *argv[]) h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); - /* Disable the HDF5 library's error reporting */ - H5Eset_auto2(H5E_DEFAULT, NULL, NULL); - /* initialize h5tools lib */ h5tools_init(); @@ -279,6 +276,9 @@ main (int argc, const char *argv[]) if(fname_g == NULL) goto done; + /* enable error reporting if command line option */ + h5tools_error_report(); + /* Print usage/exit if not using at least one of the options */ if(!clear_status_flags && !remove_cache_image && !increment_eoa_eof && !print_filesize) { @@ -344,7 +344,7 @@ main (int argc, const char *argv[]) } /* Open the file */ - if((fid = h5tools_fopen(fname, flags, fapl, NULL, NULL, (size_t)0)) < 0) { + if((fid = h5tools_fopen(fname, flags, fapl, FALSE, NULL, (size_t)0)) < 0) { error_msg("h5tools_fopen\n"); h5tools_setstatus(EXIT_FAILURE); goto done; @@ -385,7 +385,6 @@ main (int argc, const char *argv[]) warn_msg("No cache image in the file\n"); } - h5tools_setstatus(EXIT_SUCCESS); done: diff --git a/tools/src/misc/h5debug.c b/tools/src/misc/h5debug.c index a167709..e9a783b 100644 --- a/tools/src/misc/h5debug.c +++ b/tools/src/misc/h5debug.c @@ -77,65 +77,64 @@ static const H5B2_class_t * get_H5B2_class(const uint8_t *sig) { H5B2_subid_t subtype = (H5B2_subid_t)sig[H5_SIZEOF_MAGIC + 1]; - const H5B2_class_t *cls; + const H5B2_class_t *cls = NULL; switch(subtype) { - case H5B2_TEST_ID: - cls = H5B2_TEST; - break; - - case H5B2_FHEAP_HUGE_INDIR_ID: - cls = H5HF_HUGE_BT2_INDIR; - break; - - case H5B2_FHEAP_HUGE_FILT_INDIR_ID: - cls = H5HF_HUGE_BT2_FILT_INDIR; - break; - - case H5B2_FHEAP_HUGE_DIR_ID: - cls = H5HF_HUGE_BT2_DIR; - break; - - case H5B2_FHEAP_HUGE_FILT_DIR_ID: - cls = H5HF_HUGE_BT2_FILT_DIR; - break; - - case H5B2_GRP_DENSE_NAME_ID: - cls = H5G_BT2_NAME; - break; - - case H5B2_GRP_DENSE_CORDER_ID: - cls = H5G_BT2_CORDER; - break; - - case H5B2_SOHM_INDEX_ID: - cls = H5SM_INDEX; - break; - - case H5B2_ATTR_DENSE_NAME_ID: - cls = H5A_BT2_NAME; - break; - - case H5B2_ATTR_DENSE_CORDER_ID: - cls = H5A_BT2_CORDER; - break; - - case H5B2_CDSET_ID: - cls = H5D_BT2; - break; - - case H5B2_CDSET_FILT_ID: - cls = H5D_BT2_FILT; - break; - - case H5B2_TEST2_ID: - cls = H5B2_TEST2; - break; - - case H5B2_NUM_BTREE_ID: - default: - HDfprintf(stderr, "Unknown v2 B-tree subtype %u\n", (unsigned)(subtype)); - HDexit(4); + case H5B2_TEST_ID: + cls = H5B2_TEST; + break; + + case H5B2_FHEAP_HUGE_INDIR_ID: + cls = H5HF_HUGE_BT2_INDIR; + break; + + case H5B2_FHEAP_HUGE_FILT_INDIR_ID: + cls = H5HF_HUGE_BT2_FILT_INDIR; + break; + + case H5B2_FHEAP_HUGE_DIR_ID: + cls = H5HF_HUGE_BT2_DIR; + break; + + case H5B2_FHEAP_HUGE_FILT_DIR_ID: + cls = H5HF_HUGE_BT2_FILT_DIR; + break; + + case H5B2_GRP_DENSE_NAME_ID: + cls = H5G_BT2_NAME; + break; + + case H5B2_GRP_DENSE_CORDER_ID: + cls = H5G_BT2_CORDER; + break; + + case H5B2_SOHM_INDEX_ID: + cls = H5SM_INDEX; + break; + + case H5B2_ATTR_DENSE_NAME_ID: + cls = H5A_BT2_NAME; + break; + + case H5B2_ATTR_DENSE_CORDER_ID: + cls = H5A_BT2_CORDER; + break; + + case H5B2_CDSET_ID: + cls = H5D_BT2; + break; + + case H5B2_CDSET_FILT_ID: + cls = H5D_BT2_FILT; + break; + + case H5B2_TEST2_ID: + cls = H5B2_TEST2; + break; + + case H5B2_NUM_BTREE_ID: + default: + HDfprintf(stderr, "Unknown v2 B-tree subtype %u\n", (unsigned)(subtype)); } /* end switch */ return(cls); @@ -161,25 +160,24 @@ static const H5EA_class_t * get_H5EA_class(const uint8_t *sig) { H5EA_cls_id_t clsid = (H5EA_cls_id_t)sig[H5_SIZEOF_MAGIC + 1]; - const H5EA_class_t *cls; + const H5EA_class_t *cls = NULL; switch(clsid) { - case H5EA_CLS_TEST_ID: - cls = H5EA_CLS_TEST; - break; - - case H5EA_CLS_CHUNK_ID: - cls = H5EA_CLS_CHUNK; - break; - - case H5EA_CLS_FILT_CHUNK_ID: - cls = H5EA_CLS_FILT_CHUNK; - break; - - case H5EA_NUM_CLS_ID: - default: - HDfprintf(stderr, "Unknown extensible array class %u\n", (unsigned)(clsid)); - HDexit(4); + case H5EA_CLS_TEST_ID: + cls = H5EA_CLS_TEST; + break; + + case H5EA_CLS_CHUNK_ID: + cls = H5EA_CLS_CHUNK; + break; + + case H5EA_CLS_FILT_CHUNK_ID: + cls = H5EA_CLS_FILT_CHUNK; + break; + + case H5EA_NUM_CLS_ID: + default: + HDfprintf(stderr, "Unknown extensible array class %u\n", (unsigned)(clsid)); } /* end switch */ return(cls); @@ -205,25 +203,24 @@ static const H5FA_class_t * get_H5FA_class(const uint8_t *sig) { H5FA_cls_id_t clsid = (H5FA_cls_id_t)sig[H5_SIZEOF_MAGIC + 1]; - const H5FA_class_t *cls; + const H5FA_class_t *cls = NULL; switch(clsid) { - case H5FA_CLS_TEST_ID: - cls = H5FA_CLS_TEST; - break; - - case H5FA_CLS_CHUNK_ID: - cls = H5FA_CLS_CHUNK; - break; - - case H5FA_CLS_FILT_CHUNK_ID: - cls = H5FA_CLS_FILT_CHUNK; - break; - - case H5FA_NUM_CLS_ID: - default: - HDfprintf(stderr, "Unknown fixed array class %u\n", (unsigned)(clsid)); - HDexit(4); + case H5FA_CLS_TEST_ID: + cls = H5FA_CLS_TEST; + break; + + case H5FA_CLS_CHUNK_ID: + cls = H5FA_CLS_CHUNK; + break; + + case H5FA_CLS_FILT_CHUNK_ID: + cls = H5FA_CLS_FILT_CHUNK; + break; + + case H5FA_NUM_CLS_ID: + default: + HDfprintf(stderr, "Unknown fixed array class %u\n", (unsigned)(clsid)); } /* end switch */ return(cls); @@ -248,26 +245,32 @@ get_H5FA_class(const uint8_t *sig) int main(int argc, char *argv[]) { - hid_t fid, fapl; + hid_t fid = H5I_INVALID_HID; + hid_t fapl = H5I_INVALID_HID; H5VL_object_t *vol_obj; H5F_t *f; - haddr_t addr = 0, extra = 0, extra2 = 0, extra3 = 0, extra4 = 0; + haddr_t addr = 0; + int extra_count = 0; /* Number of extra arguments */ + haddr_t extra[10]; uint8_t sig[H5F_SIGNATURE_LEN]; size_t u; H5E_auto2_t func; void *edata; hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ herr_t status = SUCCEED; + int exit_value = 0; if(argc == 1) { - HDfprintf(stderr, "Usage: %s filename [signature-addr [extra]]\n", argv[0]); - HDexit(1); + HDfprintf(stderr, "Usage: %s filename [signature-addr [extra]*]\n", argv[0]); + exit_value = 1; + goto done; } /* end if */ /* Initialize the library */ if(H5open() < 0) { HDfprintf(stderr, "cannot initialize the library\n"); - HDexit(1); + exit_value = 1; + goto done; } /* end if */ /* Disable error reporting */ @@ -279,54 +282,71 @@ main(int argc, char *argv[]) */ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) { HDfprintf(stderr, "cannot create file access property list\n"); - HDexit(1); + exit_value = 1; + goto done; } /* end if */ if(HDstrchr(argv[1], '%')) if(H5Pset_fapl_family (fapl, (hsize_t)0, H5P_DEFAULT) < 0) { HDfprintf(stderr, "cannot set file access property list\n"); - HDexit(1); + exit_value = 1; + goto done; } if((fid = H5Fopen(argv[1], H5F_ACC_RDONLY, fapl)) < 0) { HDfprintf(stderr, "cannot open file\n"); - HDexit(1); + exit_value = 1; + goto done; } /* end if */ /* Push API context */ if(H5CX_push() < 0) { HDfprintf(stderr, "cannot set API context\n"); - HDexit(1); + exit_value = 1; + goto done; } api_ctx_pushed = TRUE; if(NULL == (vol_obj = (H5VL_object_t *)H5VL_vol_object(fid))) { HDfprintf(stderr, "cannot obtain vol_obj pointer\n"); - HDexit(2); + exit_value = 2; + goto done; } /* end if */ if(NULL == (f = (H5F_t *)H5VL_object_data(vol_obj))) { HDfprintf(stderr, "cannot obtain H5F_t pointer\n"); - HDexit(2); + exit_value = 2; + goto done; } /* end if */ /* Ignore metadata tags while using h5debug */ if(H5AC_ignore_tags(f) < 0) { HDfprintf(stderr, "cannot ignore metadata tags\n"); - HDexit(1); + exit_value = 1; + goto done; } /* * Parse command arguments. */ + + /* Primary data structure to dump */ if(argc > 2) addr = (haddr_t)HDstrtoll(argv[2], NULL, 0); - if(argc > 3) - extra = (haddr_t)HDstrtoll(argv[3], NULL, 0); - if(argc > 4) - extra2 = (haddr_t)HDstrtoll(argv[4], NULL, 0); - if(argc > 5) - extra3 = (haddr_t)HDstrtoll(argv[5], NULL, 0); - if(argc > 6) - extra4 = (haddr_t)HDstrtoll(argv[6], NULL, 0); + + /* Extra arguments for primary data structure */ + HDmemset(extra, 0, sizeof(extra)); + if(argc > 3) { + /* Number of extra arguments */ + extra_count = argc - 3; + + /* Range check against 'extra' array size */ + if(extra_count > (int)(sizeof(extra) / sizeof(haddr_t))) { + HDfprintf(stderr, "\nWARNING: Only using first %d extra parameters\n\n", (int)(sizeof(extra) / sizeof(haddr_t))); + extra_count = (int)(sizeof(extra) / sizeof(haddr_t)); + } /* end if */ + + for(u = 0; u < (size_t)extra_count; u++) + extra[u] = (haddr_t)HDstrtoll(argv[u + 3], NULL, 0); + } /* end if */ /* * Read the signature at the specified file position. @@ -334,7 +354,8 @@ main(int argc, char *argv[]) HDfprintf(stdout, "Reading signature at address %a (rel)\n", addr); if(H5F_block_read(f, H5FD_MEM_SUPER, addr, sizeof(sig), sig) < 0) { HDfprintf(stderr, "cannot read signature\n"); - HDexit(3); + exit_value = 3; + goto done; } if(!HDmemcmp(sig, H5F_SIGNATURE, (size_t)H5F_SIGNATURE_LEN)) { /* @@ -362,13 +383,13 @@ main(int argc, char *argv[]) */ /* Check for extra parameters */ - if(extra == 0) { + if(extra_count == 0 || extra[0] == 0) { HDfprintf(stderr, "\nWarning: Providing the group's local heap address will give more information\n"); HDfprintf(stderr, "Symbol table node usage:\n"); HDfprintf(stderr, "\th5debug
\n\n"); } /* end if */ - status = H5G_node_debug(f, addr, stdout, 0, VCOL, extra); + status = H5G_node_debug(f, addr, stdout, 0, VCOL, extra[0]); } else if(!HDmemcmp(sig, H5B_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { @@ -384,46 +405,51 @@ main(int argc, char *argv[]) switch(subtype) { case H5B_SNODE_ID: /* Check for extra parameters */ - if(extra == 0) { + if(extra_count == 0 || extra[0] == 0) { HDfprintf(stderr, "\nWarning: Providing the group's local heap address will give more information\n"); HDfprintf(stderr, "B-tree symbol table node usage:\n"); HDfprintf(stderr, "\th5debug
\n\n"); - HDexit(4); + exit_value = 4; + goto done; } /* end if */ - status = H5G_node_debug(f, addr, stdout, 0, VCOL, extra); + status = H5G_node_debug(f, addr, stdout, 0, VCOL, extra[0]); break; case H5B_CHUNK_ID: /* Check for extra parameters */ - if(extra == 0) { + if(extra_count == 0 || extra[0] == 0) { HDfprintf(stderr, "ERROR: Need number of dimensions of chunk in order to dump chunk B-tree node\n"); HDfprintf(stderr, "B-tree chunked storage node usage:\n"); HDfprintf(stderr, "\th5debug <# of dimensions> ...\n"); - HDexit(4); + exit_value = 4; + goto done; } /* end if */ - /* Build array of chunk dimensions */ - ndims = (unsigned)extra; - dim[0] = (uint32_t)extra2; - if(ndims > 1) - dim[1] = (uint32_t)extra3; - if(ndims > 2) - dim[2] = (uint32_t)extra4; + /* Set # of dimensions */ + ndims = (unsigned)extra[0]; /* Check for dimension error */ - if(ndims > 3) { - HDfprintf(stderr, "ERROR: Only 3 dimensions support currently (fix h5debug)\n"); + if(ndims > 9) { + HDfprintf(stderr, "ERROR: Only 9 dimensions support currently (fix h5debug)\n"); HDfprintf(stderr, "B-tree chunked storage node usage:\n"); HDfprintf(stderr, "\th5debug <# of dimensions> ...\n"); - HDexit(4); + exit_value = 4; + goto done; } /* end for */ + + /* Build array of chunk dimensions */ + for(u = 0; u < ndims; u++) + dim[u] = (uint32_t)extra[u + 1]; + + /* Check for dimension error */ for(u = 0; u < ndims; u++) if(0 == dim[u]) { HDfprintf(stderr, "ERROR: Chunk dimensions should be >0\n"); HDfprintf(stderr, "B-tree chunked storage node usage:\n"); HDfprintf(stderr, "\th5debug <# of dimensions> ...\n"); - HDexit(4); + exit_value = 4; + goto done; } /* end if */ /* Set the last dimension (the element size) to zero */ @@ -435,7 +461,8 @@ main(int argc, char *argv[]) case H5B_NUM_BTREE_ID: default: HDfprintf(stderr, "Unknown v1 B-tree subtype %u\n", (unsigned)(subtype)); - HDexit(4); + exit_value = 4; + goto done; } } @@ -446,14 +473,15 @@ main(int argc, char *argv[]) const H5B2_class_t *cls = get_H5B2_class(sig); HDassert(cls); - if((cls == H5D_BT2 || cls == H5D_BT2_FILT) && extra == 0) { + if((cls == H5D_BT2 || cls == H5D_BT2_FILT) && (extra_count == 0 || extra[0] == 0)) { HDfprintf(stderr, "ERROR: Need v2 B-tree header address and object header address containing the layout message in order to dump header\n"); HDfprintf(stderr, "v2 B-tree hdr usage:\n"); HDfprintf(stderr, "\th5debug \n"); - HDexit(4); + exit_value = 4; + goto done; } /* end if */ - status = H5B2__hdr_debug(f, addr, stdout, 0, VCOL, cls, (haddr_t)extra); + status = H5B2__hdr_debug(f, addr, stdout, 0, VCOL, cls, (haddr_t)extra[0]); } else if(!HDmemcmp(sig, H5B2_INT_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { @@ -464,23 +492,25 @@ main(int argc, char *argv[]) HDassert(cls); /* Check for enough valid parameters */ - if((cls == H5D_BT2 || cls == H5D_BT2_FILT) && (extra == 0 || extra2 == 0 || extra3 == 0 || extra4 == 0)) { + if((cls == H5D_BT2 || cls == H5D_BT2_FILT) && (extra_count == 0 || extra[0] == 0 || extra[1] == 0 || extra[2] == 0 || extra[3] == 0)) { HDfprintf(stderr, "ERROR: Need v2 B-tree header address, the node's number of records, depth, and object header address containing the layout message in order to dump internal node\n"); HDfprintf(stderr, "NOTE: Leaf nodes are depth 0, the internal nodes above them are depth 1, etc.\n"); HDfprintf(stderr, "v2 B-tree internal node usage:\n"); HDfprintf(stderr, "\th5debug \n"); - HDexit(4); + exit_value = 4; + goto done; } - else if(extra == 0 || extra2 == 0 || extra3 == 0) { + else if(extra_count == 0 || extra[0] == 0 || extra[1] == 0 || extra[2] == 0) { HDfprintf(stderr, "ERROR: Need v2 B-tree header address and the node's number of records and depth in order to dump internal node\n"); HDfprintf(stderr, "NOTE: Leaf nodes are depth 0, the internal nodes above them are depth 1, etc.\n"); HDfprintf(stderr, "v2 B-tree internal node usage:\n"); HDfprintf(stderr, "\th5debug \n"); - HDexit(4); + exit_value = 4; + goto done; } /* end if */ - status = H5B2__int_debug(f, addr, stdout, 0, VCOL, cls, extra, (unsigned)extra2, (unsigned)extra3, (haddr_t)extra4); + status = H5B2__int_debug(f, addr, stdout, 0, VCOL, cls, extra[0], (unsigned)extra[1], (unsigned)extra[2], (haddr_t)extra[3]); } else if(!HDmemcmp(sig, H5B2_LEAF_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { @@ -491,22 +521,24 @@ main(int argc, char *argv[]) HDassert(cls); /* Check for enough valid parameters */ - if((cls == H5D_BT2 || cls == H5D_BT2_FILT) && (extra == 0 || extra2 == 0 || extra3 == 0 )) { + if((cls == H5D_BT2 || cls == H5D_BT2_FILT) && (extra_count == 0 || extra[0] == 0 || extra[1] == 0 || extra[2] == 0 )) { HDfprintf(stderr, "ERROR: Need v2 B-tree header address, number of records, and object header address containing the layout message in order to dump leaf node\n"); HDfprintf(stderr, "v2 B-tree leaf node usage:\n"); HDfprintf(stderr, "\th5debug \n"); - HDexit(4); + exit_value = 4; + goto done; } - else if(extra == 0 || extra2 == 0) { + else if(extra_count == 0 || extra[0] == 0 || extra[1] == 0) { HDfprintf(stderr, "ERROR: Need v2 B-tree header address and number of records in order to dump leaf node\n"); HDfprintf(stderr, "v2 B-tree leaf node usage:\n"); HDfprintf(stderr, "\th5debug \n"); - HDexit(4); + exit_value = 4; + goto done; } /* end if */ - status = H5B2__leaf_debug(f, addr, stdout, 0, VCOL, cls, extra, (unsigned)extra2, (haddr_t)extra3); + status = H5B2__leaf_debug(f, addr, stdout, 0, VCOL, cls, extra[0], (unsigned)extra[1], (haddr_t)extra[2]); } else if(!HDmemcmp(sig, H5HF_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { @@ -522,14 +554,15 @@ main(int argc, char *argv[]) */ /* Check for enough valid parameters */ - if(extra == 0 || extra2 == 0) { + if(extra_count == 0 || extra[0] == 0 || extra[1] == 0) { HDfprintf(stderr, "ERROR: Need fractal heap header address and size of direct block in order to dump direct block\n"); HDfprintf(stderr, "Fractal heap direct block usage:\n"); HDfprintf(stderr, "\th5debug \n"); - HDexit(4); + exit_value = 4; + goto done; } /* end if */ - status = H5HF_dblock_debug(f, addr, stdout, 0, VCOL, extra, (size_t)extra2); + status = H5HF_dblock_debug(f, addr, stdout, 0, VCOL, extra[0], (size_t)extra[1]); } else if(!HDmemcmp(sig, H5HF_IBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { @@ -538,14 +571,15 @@ main(int argc, char *argv[]) */ /* Check for enough valid parameters */ - if(extra == 0 || extra2 == 0) { + if(extra_count == 0 || extra[0] == 0 || extra[1] == 0) { HDfprintf(stderr, "ERROR: Need fractal heap header address and number of rows in order to dump indirect block\n"); HDfprintf(stderr, "Fractal heap indirect block usage:\n"); HDfprintf(stderr, "\th5debug \n"); - HDexit(4); + exit_value = 4; + goto done; } /* end if */ - status = H5HF_iblock_debug(f, addr, stdout, 0, VCOL, extra, (unsigned)extra2); + status = H5HF_iblock_debug(f, addr, stdout, 0, VCOL, extra[0], (unsigned)extra[1]); } else if(!HDmemcmp(sig, H5FS_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { @@ -562,14 +596,15 @@ main(int argc, char *argv[]) */ /* Check for enough valid parameters */ - if(extra == 0 || extra2 == 0) { + if(extra_count == 0 || extra[0] == 0 || extra[1] == 0) { HDfprintf(stderr, "ERROR: Need free space header address and client address in order to dump serialized sections\n"); HDfprintf(stderr, "Free space serialized sections usage:\n"); HDfprintf(stderr, "\th5debug \n"); - HDexit(4); + exit_value = 4; + goto done; } /* end if */ - status = H5FS_sects_debug(f, addr, stdout, 0, VCOL, extra, extra2); + status = H5FS_sects_debug(f, addr, stdout, 0, VCOL, extra[0], extra[1]); } else if(!HDmemcmp(sig, H5SM_TABLE_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { @@ -586,14 +621,15 @@ main(int argc, char *argv[]) */ /* Check for enough valid parameters */ - if(extra == 0) { + if(extra_count == 0 || extra[0] == 0) { HDfprintf(stderr, "ERROR: Need shared message header address in order to shared message list\n"); HDfprintf(stderr, "Shared message list usage:\n"); HDfprintf(stderr, "\th5debug \n"); - HDexit(4); + exit_value = 4; + goto done; } /* end if */ - status = H5SM_list_debug(f, addr, stdout, 0, VCOL, (haddr_t)extra); + status = H5SM_list_debug(f, addr, stdout, 0, VCOL, (haddr_t)extra[0]); } else if(!HDmemcmp(sig, H5EA_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { @@ -604,14 +640,15 @@ main(int argc, char *argv[]) HDassert(cls); /* Check for enough valid parameters */ - if(extra == 0) { + if(extra_count == 0 || extra[0] == 0) { HDfprintf(stderr, "ERROR: Need object header address containing the layout message in order to dump header\n"); HDfprintf(stderr, "Extensible array header block usage:\n"); HDfprintf(stderr, "\th5debug \n"); - HDexit(4); + exit_value = 4; + goto done; } /* end if */ - status = H5EA__hdr_debug(f, addr, stdout, 0, VCOL, cls, extra); + status = H5EA__hdr_debug(f, addr, stdout, 0, VCOL, cls, extra[0]); } else if(!HDmemcmp(sig, H5EA_IBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { @@ -622,14 +659,15 @@ main(int argc, char *argv[]) HDassert(cls); /* Check for enough valid parameters */ - if(extra == 0 || extra2 == 0) { + if(extra_count == 0 || extra[0] == 0 || extra[1] == 0) { HDfprintf(stderr, "ERROR: Need extensible array header address and object header address containing the layout message in order to dump index block\n"); HDfprintf(stderr, "Extensible array index block usage:\n"); HDfprintf(stderr, "\th5debug \n"); - HDexit(4); + exit_value = 4; + goto done; } /* end if */ - status = H5EA__sblock_debug(f, addr, stdout, 0, VCOL, cls, extra, (unsigned)extra2, extra3); + status = H5EA__sblock_debug(f, addr, stdout, 0, VCOL, cls, extra[0], (unsigned)extra[1], extra[2]); } else if(!HDmemcmp(sig, H5EA_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { @@ -658,14 +697,15 @@ main(int argc, char *argv[]) HDassert(cls); /* Check for enough valid parameters */ - if(extra == 0 || extra2 == 0 || extra3 == 0) { + if(extra_count == 0 || extra[0] == 0 || extra[1] == 0 || extra[2] == 0) { HDfprintf(stderr, "ERROR: Need extensible array header address, # of elements in data block and object header address containing the layout message in order to dump data block\n"); HDfprintf(stderr, "Extensible array data block usage:\n"); HDfprintf(stderr, "\th5debug <# of elements in data block> \n"); - HDexit(4); + exit_value = 4; + goto done; } /* end if */ - status = H5FA__hdr_debug(f, addr, stdout, 0, VCOL, cls, extra); + status = H5FA__hdr_debug(f, addr, stdout, 0, VCOL, cls, extra[0]); } else if(!HDmemcmp(sig, H5FA_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { @@ -694,14 +735,15 @@ main(int argc, char *argv[]) HDassert(cls); /* Check for enough valid parameters */ - if(extra == 0 || extra2 == 0) { + if(extra_count == 0 || extra[0] == 0 || extra[1] == 0) { HDfprintf(stderr, "ERROR: Need fixed array header address and object header address containing the layout message in order to dump data block\n"); HDfprintf(stderr, "fixed array data block usage:\n"); HDfprintf(stderr, "\th5debug \n"); - HDexit(4); + exit_value = 4; + goto done; } /* end if */ - status = H5FA__dblock_debug(f, addr, stdout, 0, VCOL, cls, extra, extra2); + status = H5FA__dblock_debug(f, addr, stdout, 0, VCOL, cls, extra[0], extra[1]); } else if(!HDmemcmp(sig, H5O_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { @@ -738,24 +780,27 @@ main(int argc, char *argv[]) HDputchar('\n'); HDfprintf(stderr, "unknown signature\n"); - HDexit(4); + exit_value = 4; + goto done; } /* end else */ /* Check for an error when dumping information */ if(status < 0) { HDfprintf(stderr, "An error occurred!\n"); H5Eprint2(H5E_DEFAULT, stderr); - HDexit(5); + exit_value = 5; + goto done; } /* end if */ - H5Pclose(fapl); - H5Fclose(fid); +done: + if(fapl > 0) H5Pclose(fapl); + if(fid > 0) H5Fclose(fid); /* Pop API context */ if(api_ctx_pushed) H5CX_pop(); H5Eset_auto2(H5E_DEFAULT, func, edata); - return 0; + return exit_value; } /* main() */ diff --git a/tools/src/misc/h5mkgrp.c b/tools/src/misc/h5mkgrp.c index feb60d4..ad3b7b8 100644 --- a/tools/src/misc/h5mkgrp.c +++ b/tools/src/misc/h5mkgrp.c @@ -25,24 +25,29 @@ int d_status = EXIT_SUCCESS; /* command-line options: short and long-named parameters */ static const char *s_opts = "hlpvV"; static struct long_options l_opts[] = { - { "help", no_arg, 'h' }, - { "latest", no_arg, 'l' }, - { "parents", no_arg, 'p' }, - { "verbose", no_arg, 'v' }, - { "version", no_arg, 'V' }, + { "help", no_arg, 'h' }, + { "latest", no_arg, 'l' }, + { "parents", no_arg, 'p' }, + { "verbose", no_arg, 'v' }, + { "version", no_arg, 'V' }, + { "vol-value", require_arg, '1' }, + { "vol-name", require_arg, '2' }, + { "vol-info", require_arg, '3' }, { NULL, 0, '\0' } }; /* Command line parameter settings */ -typedef struct { +typedef struct mkgrp_opt_t { char *fname; /* File name to operate on */ hbool_t latest; /* Whether file should use latest format versions */ hbool_t verbose; /* Whether output should be verbose */ hbool_t parents; /* Whether to create intermediate groups */ size_t ngroups; /* Number of groups to create */ char **groups; /* Pointer to array of group names */ -} param_t; -param_t params; /* Command line parameter settings */ + hid_t fapl_id; /* fapl to use when opening the file */ +} mkgrp_opt_t; + +mkgrp_opt_t params_g; /* Command line parameter settings */ /*------------------------------------------------------------------------- @@ -61,13 +66,17 @@ leave(int ret) { size_t curr_group; - if (params.fname) - HDfree (params.fname); - if (params.ngroups) { - for(curr_group = 0; curr_group < params.ngroups; curr_group++) - HDfree (params.groups[curr_group]); - HDfree (params.groups); + if (params_g.fname) + HDfree(params_g.fname); + if (params_g.ngroups) { + for (curr_group = 0; curr_group < params_g.ngroups; curr_group++) + HDfree(params_g.groups[curr_group]); + HDfree(params_g.groups); } + if (H5I_INVALID_HID != params_g.fapl_id && H5P_DEFAULT != params_g.fapl_id) + if (H5Pclose(params_g.fapl_id) < 0) + error_msg("Could not close file access property list\n"); + h5tools_close(); HDexit(ret); } /* end leave() */ @@ -85,65 +94,79 @@ leave(int ret) *------------------------------------------------------------------------- */ static void -usage(void) +usage(const char *prog) { - HDfprintf(stdout, "\ -usage: h5mkgrp [OPTIONS] FILE GROUP...\n\ - OPTIONS\n\ - -h, --help Print a usage message and exit\n\ - -l, --latest Use latest version of file format to create groups\n\ - -p, --parents No error if existing, make parent groups as needed\n\ - -v, --verbose Print information about OBJECTS and OPTIONS\n\ - -V, --version Print version number and exit\n"); + FLUSHSTREAM(rawoutstream); + PRINTSTREAM(rawoutstream, "usage: %s [OPTIONS] FILE GROUP...\n", prog); + PRINTVALSTREAM(rawoutstream, " OPTIONS\n"); + PRINTVALSTREAM(rawoutstream, " -h, --help Print a usage message and exit\n"); + PRINTVALSTREAM(rawoutstream, " -l, --latest Use latest version of file format to create groups\n"); + PRINTVALSTREAM(rawoutstream, " -p, --parents No error if existing, make parent groups as needed\n"); + PRINTVALSTREAM(rawoutstream, " -v, --verbose Print information about OBJECTS and OPTIONS\n"); + PRINTVALSTREAM(rawoutstream, " -V, --version Print version number and exit\n"); + PRINTVALSTREAM(rawoutstream, " --vol-value Value (ID) of the VOL connector to use for opening the\n"); + PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, " --vol-name Name of the VOL connector to use for opening the\n"); + PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, " --vol-info VOL-specific info to pass to the VOL connector used for\n"); + PRINTVALSTREAM(rawoutstream, " opening the HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, "\n"); } /* end usage() */ /*------------------------------------------------------------------------- - * Function: parse_command_line + * Function: parse_command_line * - * Purpose: Parses command line and sets up global variable to control output + * Purpose: Parses command line and sets up global variable to control + * output * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * * Programmer: Quincey Koziol, 2/13/2007 * *------------------------------------------------------------------------- */ static int -parse_command_line(int argc, const char *argv[], param_t *parms) +parse_command_line(int argc, const char *argv[], mkgrp_opt_t *options) { int opt; /* Option from command line */ size_t curr_group; /* Current group name to copy */ + hbool_t custom_fapl = FALSE; + h5tools_vol_info_t vol_info; + hid_t tmp_fapl_id = H5I_INVALID_HID; /* Check for empty command line */ if(argc == 1) { - usage(); + usage(h5tools_getprogname()); leave(EXIT_SUCCESS); - } /* end if */ + } + + /* Initialize fapl info struct */ + HDmemset(&vol_info, 0, sizeof(h5tools_vol_info_t)); /* Parse command line options */ while((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { switch((char)opt) { /* Display 'help' */ case 'h': - usage(); + usage(h5tools_getprogname()); leave(EXIT_SUCCESS); break; /* Create objects with the latest version of the format */ case 'l': - parms->latest = TRUE; + options->latest = TRUE; break; /* Create parent groups */ case 'p': - parms->parents = TRUE; + options->parents = TRUE; break; /* Verbose output */ case 'v': - parms->verbose = TRUE; + options->verbose = TRUE; break; /* Display version */ @@ -152,9 +175,25 @@ parse_command_line(int argc, const char *argv[], param_t *parms) leave(EXIT_SUCCESS); break; + case '1': + vol_info.type = VOL_BY_VALUE; + vol_info.u.value = (H5VL_class_value_t)HDatoi(opt_arg); + custom_fapl = TRUE; + break; + + case '2': + vol_info.type = VOL_BY_NAME; + vol_info.u.name = opt_arg; + custom_fapl = TRUE; + break; + + case '3': + vol_info.info_string = opt_arg; + break; + /* Bad command line argument */ default: - usage(); + usage(h5tools_getprogname()); leave(EXIT_FAILURE); } /* end switch */ } /* end while */ @@ -162,43 +201,51 @@ parse_command_line(int argc, const char *argv[], param_t *parms) /* Check for file name to be processed */ if(argc <= opt_ind) { error_msg("missing file name\n"); - usage(); + usage(h5tools_getprogname()); leave(EXIT_FAILURE); - } /* end if */ + } /* Retrieve file name */ - parms->fname = HDstrdup(argv[opt_ind]); + options->fname = HDstrdup(argv[opt_ind]); opt_ind++; /* Check for group(s) to be created */ if(argc <= opt_ind) { error_msg("missing group name(s)\n"); - usage(); + usage(h5tools_getprogname()); leave(EXIT_FAILURE); - } /* end if */ + } /* Allocate space for the group name pointers */ - parms->ngroups = (size_t)(argc - opt_ind); - parms->groups = (char **)HDmalloc(parms->ngroups * sizeof(char *)); + options->ngroups = (size_t)(argc - opt_ind); + options->groups = (char **)HDmalloc(options->ngroups * sizeof(char *)); /* Retrieve the group names */ curr_group = 0; while(opt_ind < argc) { - parms->groups[curr_group] = HDstrdup(argv[opt_ind]); + options->groups[curr_group] = HDstrdup(argv[opt_ind]); curr_group++; opt_ind++; - } /* end while */ + } -#ifdef QAK -HDfprintf(stderr, "parms->parents = %t\n", parms->parents); -HDfprintf(stderr, "parms->verbose = %t\n", parms->verbose); -HDfprintf(stderr, "parms->fname = '%s'\n", parms->fname); -HDfprintf(stderr, "parms->ngroups = %Zu\n", parms->ngroups); -for(curr_group = 0; curr_group < parms->ngroups; curr_group++) - HDfprintf(stderr, "parms->group[%Zu] = '%s'\n", curr_group, parms->groups[curr_group]); -#endif /* QAK */ + /* Setup a custom fapl for file accesses */ + if (custom_fapl) { + if ((tmp_fapl_id = h5tools_get_fapl(options->fapl_id, &vol_info, NULL)) < 0) { + error_msg("failed to setup file access property list (fapl) for file\n"); + leave(EXIT_FAILURE); + } + + /* Close the old fapl */ + if (options->fapl_id != H5P_DEFAULT) + if (H5Pclose(options->fapl_id) < 0) { + error_msg("failed to close file access property list (fapl)\n"); + leave(EXIT_FAILURE); + } + + options->fapl_id = tmp_fapl_id; + } - return(0); + return 0; } /* parse_command_line() */ @@ -214,117 +261,112 @@ for(curr_group = 0; curr_group < parms->ngroups; curr_group++) int main(int argc, const char *argv[]) { - hid_t fid; /* HDF5 file ID */ - hid_t fapl_id; /* File access property list ID */ - hid_t lcpl_id; /* Link creation property list ID */ - size_t curr_group; /* Current group to create */ + hid_t fid = H5I_INVALID_HID; /* HDF5 file ID */ + hid_t lcpl_id = H5I_INVALID_HID; /* Link creation property list ID */ + size_t curr_group; /* Current group to create */ h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); - /* Disable the HDF5 library's error reporting */ - H5Eset_auto2(H5E_DEFAULT, NULL, NULL); - /* Initialize h5tools lib */ h5tools_init(); - /* Parse command line */ - HDmemset(¶ms, 0, sizeof(params)); - if(parse_command_line(argc, argv, ¶ms) < 0) { - error_msg("unable to parse command line arguments\n"); - leave(EXIT_FAILURE); - } /* end if */ + /* Initialize the parameters */ + HDmemset(¶ms_g, 0, sizeof(params_g)); /* Create file access property list */ - if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) { + if((params_g.fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) { error_msg("Could not create file access property list\n"); leave(EXIT_FAILURE); - } /* end if */ + } + + /* Parse command line */ + if(parse_command_line(argc, argv, ¶ms_g) < 0) { + error_msg("unable to parse command line arguments\n"); + leave(EXIT_FAILURE); + } + + /* enable error reporting if command line option */ + h5tools_error_report(); /* Check for creating groups with new format version */ - if(params.latest) { + if(params_g.latest) { /* Set the "use the latest version of the format" bounds */ - if(H5Pset_libver_bounds(fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) { + if(H5Pset_libver_bounds(params_g.fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) { error_msg("Could not set property for using latest version of the format\n"); leave(EXIT_FAILURE); - } /* end if */ + } /* Display some output if requested */ - if(params.verbose) + if(params_g.verbose) HDprintf("%s: Creating groups with latest version of the format\n", h5tools_getprogname()); - } /* end if */ + } /* Attempt to open an existing HDF5 file first */ - fid = h5tools_fopen(params.fname, H5F_ACC_RDWR, fapl_id, NULL, NULL, 0); + fid = h5tools_fopen(params_g.fname, H5F_ACC_RDWR, params_g.fapl_id, FALSE, NULL, 0); /* If we couldn't open an existing file, try creating file */ /* (use "EXCL" instead of "TRUNC", so we don't blow away existing non-HDF5 file) */ if(fid < 0) - fid = H5Fcreate(params.fname, H5F_ACC_EXCL, H5P_DEFAULT, fapl_id); + fid = H5Fcreate(params_g.fname, H5F_ACC_EXCL, H5P_DEFAULT, params_g.fapl_id); /* Test for error in opening file */ if(fid < 0) { - error_msg("Could not open output file '%s'\n", params.fname); + error_msg("Could not open output file '%s'\n", params_g.fname); leave(EXIT_FAILURE); - } /* end if */ + } /* Create link creation property list */ if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) { error_msg("Could not create link creation property list\n"); leave(EXIT_FAILURE); - } /* end if */ + } /* Check for creating intermediate groups */ - if(params.parents) { + if(params_g.parents) { /* Set the intermediate group creation property */ if(H5Pset_create_intermediate_group(lcpl_id, TRUE) < 0) { error_msg("Could not set property for creating parent groups\n"); leave(EXIT_FAILURE); - } /* end if */ + } /* Display some output if requested */ - if(params.verbose) + if(params_g.verbose) HDprintf("%s: Creating parent groups\n", h5tools_getprogname()); - } /* end if */ + } /* Loop over creating requested groups */ - for(curr_group = 0; curr_group < params.ngroups; curr_group++) { + for(curr_group = 0; curr_group < params_g.ngroups; curr_group++) { hid_t gid; /* Group ID */ /* Attempt to create a group */ - if((gid = H5Gcreate2(fid, params.groups[curr_group], lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - error_msg("Could not create group '%s'\n", params.groups[curr_group]); + if((gid = H5Gcreate2(fid, params_g.groups[curr_group], lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + error_msg("Could not create group '%s'\n", params_g.groups[curr_group]); leave(EXIT_FAILURE); - } /* end if */ + } /* Close the group */ if(H5Gclose(gid) < 0) { - error_msg("Could not close group '%s'??\n", params.groups[curr_group]); + error_msg("Could not close group '%s'??\n", params_g.groups[curr_group]); leave(EXIT_FAILURE); - } /* end if */ + } /* Display some output if requested */ - if(params.verbose) - HDprintf("%s: created group '%s'\n", h5tools_getprogname(), params.groups[curr_group]); + if(params_g.verbose) + HDprintf("%s: created group '%s'\n", h5tools_getprogname(), params_g.groups[curr_group]); } /* end for */ /* Close link creation property list */ if(H5Pclose(lcpl_id) < 0) { error_msg("Could not close link creation property list\n"); leave(EXIT_FAILURE); - } /* end if */ + } /* Close file */ if(H5Fclose(fid) < 0) { - error_msg("Could not close output file '%s'??\n", params.fname); - leave(EXIT_FAILURE); - } /* end if */ - - /* Close file access property list */ - if(H5Pclose(fapl_id) < 0) { - error_msg("Could not close file access property list\n"); + error_msg("Could not close output file '%s'??\n", params_g.fname); leave(EXIT_FAILURE); - } /* end if */ + } leave(EXIT_SUCCESS); } /* end main() */ diff --git a/tools/test/h5diff/CMakeTests.cmake b/tools/test/h5diff/CMakeTests.cmake index 3d9c6f5..5aa1d1a 100644 --- a/tools/test/h5diff/CMakeTests.cmake +++ b/tools/test/h5diff/CMakeTests.cmake @@ -66,8 +66,10 @@ ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/non_comparables2.h5 ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/tudfilter.h5 ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/tudfilter2.h5 - ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/diff_strings1.h5 - ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/diff_strings2.h5 + ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_strings1.h5 + ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_strings2.h5 + ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_eps1.h5 + ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_eps2.h5 # tools/testfiles/vds ${HDF5_TOOLS_DIR}/testfiles/vds/1_a.h5 ${HDF5_TOOLS_DIR}/testfiles/vds/1_b.h5 @@ -302,6 +304,7 @@ ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_v2.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_v3.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_vlstr.txt + ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_eps.txt ) set (LIST_WIN_TEST_FILES @@ -338,9 +341,10 @@ # Overwrite system dependent files (Windows) and not VS2015 # set (COPY_WINDOWS_FILES false) - if (MINGW) - set (COPY_WINDOWS_FILES true) - endif () + # MinGW tests may depend on host system + #if (MINGW) + # set (COPY_WINDOWS_FILES true) + #endif () if (WIN32 AND MSVC_VERSION LESS 1900) set (COPY_WINDOWS_FILES true) endif () @@ -539,8 +543,11 @@ set (ATTR_VERBOSE_LEVEL_FILE1 h5diff_attr_v_level1.h5) set (ATTR_VERBOSE_LEVEL_FILE2 h5diff_attr_v_level2.h5) # strings - set (STRINGS1 diff_strings1.h5) - set (STRINGS2 diff_strings2.h5) + set (STRINGS1 h5diff_strings1.h5) + set (STRINGS2 h5diff_strings2.h5) + # epsilon + set (EPS1 h5diff_eps1.h5) + set (EPS2 h5diff_eps2.h5) # VDS tests set (FILEV1 1_vds.h5) @@ -926,6 +933,8 @@ h5diff_v3.out.err h5diff_vlstr.out h5diff_vlstr.out.err + h5diff_eps.out + h5diff_eps.out.err ) set_tests_properties (H5DIFF-clearall-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") if (last_test) @@ -1107,6 +1116,9 @@ ADD_H5_TEST (h5diff_609 0 -d 200 ${FILE1} ${FILE2} g1/dset3 g1/dset4) # 6.10: number smaller than smallest difference ADD_H5_TEST (h5diff_610 1 -d 1 ${FILE1} ${FILE2} g1/dset3 g1/dset4) +# eps: number smaller than epsilon +ADD_H5_TEST (h5diff_eps 0 -v3 -d 1e-16 ${EPS1} ${EPS2}) + # ############################################################################## # # -p # ############################################################################## @@ -1492,9 +1504,9 @@ ADD_H5_TEST (h5diff_484 0 -v --exclude-path "/dset3" ${EXCLUDE_FILE1_1} ${EXCLUD # Only one file contains unique objs. Common objs are same. # (HDFFV-7837) # -ADD_H5_TEST (h5diff_485 0 -v --exclude-path "/group1" h5diff_exclude3-1.h5 h5diff_exclude3-2.h5) -ADD_H5_TEST (h5diff_486 0 -v --exclude-path "/group1" h5diff_exclude3-2.h5 h5diff_exclude3-1.h5) -ADD_H5_TEST (h5diff_487 1 -v --exclude-path "/group1/dset" h5diff_exclude3-1.h5 h5diff_exclude3-2.h5) +ADD_H5_TEST (h5diff_485 0 -v --exclude-path "/group1" ${EXCLUDE_FILE3_1} ${EXCLUDE_FILE3_2}) +ADD_H5_TEST (h5diff_486 0 -v --exclude-path "/group1" ${EXCLUDE_FILE3_2} ${EXCLUDE_FILE3_1}) +ADD_H5_TEST (h5diff_487 1 -v --exclude-path "/group1/dset" ${EXCLUDE_FILE3_1} ${EXCLUDE_FILE3_2}) # ############################################################################## # # diff various multiple vlen and fixed strings in a compound type dataset @@ -1528,8 +1540,6 @@ ADD_H5_TEST (h5diff_646 1 -v --use-system-epsilon -p 0.05 ${FILE1} ${FILE2} /g1/ # ############################################################################## # # Test array variances # ############################################################################## -# -# Test with -d , -p and --use-system-epsilon. ADD_H5_TEST (h5diff_800 1 -v ${FILE7} ${FILE8} /g1/array /g1/array) ADD_H5_TEST (h5diff_801 1 -v ${FILE7} ${FILE8A} /g1/array /g1/array) diff --git a/tools/test/h5diff/h5diffgentest.c b/tools/test/h5diff/h5diffgentest.c index 98001ff..bdc2ddc 100644 --- a/tools/test/h5diff/h5diffgentest.c +++ b/tools/test/h5diff/h5diffgentest.c @@ -94,8 +94,11 @@ size_t H5TOOLS_MALLOCSIZE = (128 * 1024 * 1024); #define NON_COMPARBLES1 "non_comparables1.h5" #define NON_COMPARBLES2 "non_comparables2.h5" /* string dataset and attribute */ -#define DIFF_STRINGS1 "diff_strings1.h5" -#define DIFF_STRINGS2 "diff_strings2.h5" +#define DIFF_STRINGS1 "h5diff_strings1.h5" +#define DIFF_STRINGS2 "h5diff_strings2.h5" +/* double dataset and epsilon */ +#define DIFF_EPS1 "h5diff_eps1.h5" +#define DIFF_EPS2 "h5diff_eps2.h5" #define UIMAX 4294967295u /*Maximum value for a variable of type unsigned int */ #define STR_SIZE 3 @@ -110,7 +113,7 @@ size_t H5TOOLS_MALLOCSIZE = (128 * 1024 * 1024); /* Error macros */ #define AT() HDprintf("ERROR at %s:%d in %s()...\n", __FILE__, __LINE__, FUNC); -#define PROGRAM_ERROR {AT(); goto error;} +#define PROGRAM_ERROR do {AT(); goto error;} while(0) /* A UD link traversal function. Shouldn't actually be called. */ static hid_t @@ -172,6 +175,7 @@ static void test_comps_vlen_arry(const char *fname, const char *dset, static void test_data_nocomparables(const char *fname, int diff); static void test_objs_nocomparables(const char *fname1, const char *fname2); static void test_objs_strings(const char *fname, const char *fname2); +static void test_double_epsilon(const char *fname1, const char *fname2); /* called by test_attributes() and test_datasets() */ static void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make_diffs); @@ -288,6 +292,9 @@ int main(void) /* string dataset and attribute. HDFFV-10028 */ test_objs_strings(DIFF_STRINGS1, DIFF_STRINGS2); + /* double dataset and epsilion. HDFFV-10897 */ + test_double_epsilon(DIFF_EPS1, DIFF_EPS2); + return EXIT_SUCCESS; } @@ -432,14 +439,12 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) /* epsilon = 0.0000000000000001 = 1e-16 * system epsilon for double : DBL_EPSILON = 2.22045E-16 */ - double data13[3][2] = { { H5_DOUBLE(0.0000000000000000), H5_DOUBLE( - 0.0000000000000001) }, { H5_DOUBLE(0.0000000000000001), - H5_DOUBLE(0.0000000000000000) }, { H5_DOUBLE( - 0.00000000000000033), H5_DOUBLE(0.0000000000000001) } }; - double data14[3][2] = { { H5_DOUBLE(0.0000000000000000), H5_DOUBLE( - 0.0000000000000004) }, { H5_DOUBLE(0.0000000000000002), - H5_DOUBLE(0.0000000000000001) }, { H5_DOUBLE( - 0.0000000000000001), H5_DOUBLE(0.00000000000000000) } }; + double data13[3][2] = { { 0.0000000000000000, 0.0000000000000001 }, + { 0.0000000000000001, 0.0000000000000000 }, + { 0.00000000000000033, 0.0000000000000001 } }; + double data14[3][2] = { { 0.0000000000000000, 0.0000000000000004 }, + { 0.0000000000000002, 0.0000000000000001 }, + { 0.0000000000000001, 0.00000000000000000 } }; write_dset(gid1, 2, dims2, "fp1", H5T_NATIVE_FLOAT, data11); write_dset(gid1, 2, dims2, "fp2", H5T_NATIVE_FLOAT, data12); @@ -4930,73 +4935,73 @@ test_objs_nocomparables(const char *fname1, const char *fname2) *------------------------------------------------------------------------*/ /* file1 */ if((fid1 = H5Fopen(fname1, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) - PROGRAM_ERROR + PROGRAM_ERROR; /* file2 */ if((fid2 = H5Fopen(fname2, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) - PROGRAM_ERROR + PROGRAM_ERROR; /*----------------------------------------------------------------------- * in file1 : add member objects *------------------------------------------------------------------------*/ /* parent group */ if((topgid1 = H5Gcreate2(fid1, "diffobjtypes", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - PROGRAM_ERROR + PROGRAM_ERROR; /* dataset */ if(write_dset(topgid1, 1, dims, "obj1", H5T_NATIVE_INT, data1) < 0) - PROGRAM_ERROR + PROGRAM_ERROR; /* group */ if((gid1 = H5Gcreate2(topgid1, "obj2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - PROGRAM_ERROR + PROGRAM_ERROR; /* committed type */ if((tid1 = H5Tcopy(H5T_NATIVE_INT)) < 0) - PROGRAM_ERROR + PROGRAM_ERROR; if(H5Tcommit2(topgid1, "obj3", tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) - PROGRAM_ERROR + PROGRAM_ERROR; /*----------------------------------------------------------------------- * in file2 : add member objects *------------------------------------------------------------------------*/ /* parent group */ if((topgid2 = H5Gcreate2(fid2, "diffobjtypes", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - PROGRAM_ERROR + PROGRAM_ERROR; /* group */ if((gid2 = H5Gcreate2(topgid2, "obj1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - PROGRAM_ERROR + PROGRAM_ERROR; /* committed type */ if((tid2 = H5Tcopy(H5T_NATIVE_INT)) < 0) - PROGRAM_ERROR + PROGRAM_ERROR; if(H5Tcommit2(topgid2, "obj2", tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) - PROGRAM_ERROR + PROGRAM_ERROR; /* dataset */ if(write_dset(topgid2, 1, dims, "obj3", H5T_NATIVE_INT, data2) < 0) - PROGRAM_ERROR + PROGRAM_ERROR; /*----------------------------------------------------------------------- * Close IDs *-----------------------------------------------------------------------*/ if(H5Fclose(fid1) < 0) - PROGRAM_ERROR + PROGRAM_ERROR; if(H5Fclose(fid2) < 0) - PROGRAM_ERROR + PROGRAM_ERROR; if(H5Gclose(topgid1) < 0) - PROGRAM_ERROR + PROGRAM_ERROR; if(H5Gclose(topgid2) < 0) - PROGRAM_ERROR + PROGRAM_ERROR; if(H5Gclose(gid1) < 0) - PROGRAM_ERROR + PROGRAM_ERROR; if(H5Gclose(gid2) < 0) - PROGRAM_ERROR + PROGRAM_ERROR; if(H5Tclose(tid1) < 0) - PROGRAM_ERROR + PROGRAM_ERROR; if(H5Tclose(tid2) < 0) - PROGRAM_ERROR + PROGRAM_ERROR; return; @@ -8020,6 +8025,60 @@ out: return -1; } +/* + * Function: test_double_epsilion + * + * Purpose: Create test files to compare data with epsilion + */ +static +void test_double_epsilon(const char *fname1, const char *fname2) +{ + hid_t fid1 = H5I_INVALID_HID, fid2 = H5I_INVALID_HID; + hsize_t dims1[2] = { 4, 7 }; + hsize_t dims2[2] = { 4, 7 }; + double wdata[4][7]; + int i, j; + + /*------------------------------------------------------------------------- + * create two files + *------------------------------------------------------------------------- + */ + if ((fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + PROGRAM_ERROR; + if ((fid2 = H5Fcreate(fname2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + PROGRAM_ERROR; + + /* + * Initialize data. + */ + for (i=0; i<4; i++) + for (j=0; j<7; j++) + wdata[i][j] = 0.0; + + /* dataset */ + if(write_dset(fid1, 2, dims1, "dataset", H5T_IEEE_F64LE, wdata) < 0) + PROGRAM_ERROR; + + /* + * Initialize data. + */ + for (i=0; i<4; i++) + for (j=0; j<7; j++) + wdata[i][j] = (double)1.e-19; + + /* dataset */ + if(write_dset(fid2, 2, dims1, "dataset", H5T_IEEE_F64LE, wdata) < 0) + PROGRAM_ERROR; + +error: + H5E_BEGIN_TRY { + H5Fclose(fid1); + H5Fclose(fid2); + } H5E_END_TRY; + + return; +} + /*------------------------------------------------------------------------- * Function: write_attr * @@ -8075,22 +8134,22 @@ write_dset(hid_t loc_id, int rank, hsize_t *dims, const char *name, hid_t tid, v /* create a space */ if((sid = H5Screate_simple(rank, dims, NULL)) < 0) - PROGRAM_ERROR + PROGRAM_ERROR; /* create the dataset */ if((did = H5Dcreate2(loc_id, name, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - PROGRAM_ERROR + PROGRAM_ERROR; /* write */ if(buf) if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - PROGRAM_ERROR + PROGRAM_ERROR; /* close */ if(H5Dclose(did) < 0) - PROGRAM_ERROR + PROGRAM_ERROR; if(H5Sclose(sid) < 0) - PROGRAM_ERROR + PROGRAM_ERROR; return SUCCEED; diff --git a/tools/test/h5diff/testfiles/diff_strings1.h5 b/tools/test/h5diff/testfiles/diff_strings1.h5 deleted file mode 100644 index 0f8b380..0000000 Binary files a/tools/test/h5diff/testfiles/diff_strings1.h5 and /dev/null differ diff --git a/tools/test/h5diff/testfiles/diff_strings2.h5 b/tools/test/h5diff/testfiles/diff_strings2.h5 deleted file mode 100644 index e8520ae..0000000 Binary files a/tools/test/h5diff/testfiles/diff_strings2.h5 and /dev/null differ diff --git a/tools/test/h5diff/testfiles/h5diff_10.txt b/tools/test/h5diff/testfiles/h5diff_10.txt index 11ad800..b5ff01a 100644 --- a/tools/test/h5diff/testfiles/h5diff_10.txt +++ b/tools/test/h5diff/testfiles/h5diff_10.txt @@ -17,14 +17,25 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] Verbose mode with level. Print differences and list of objects. Level of detail depends on value of N: 0 : Identical to '-v' or '--verbose'. - 1 : All level 0 information plus one-line attribute - status summary. - 2 : All level 1 information plus extended attribute - status report. + 1 : All level 0 information plus one-line attribute status summary. + 2 : All level 1 information plus extended attribute status report. + 3 : All level 2 information plus file names. -q, --quiet Quiet mode. Do not produce output. --enable-error-stack Prints messages from the HDF5 error stack as they occur. + --vol-value-1 Value (ID) of the VOL connector to use for opening the + first HDF5 file specified + --vol-name-1 Name of the VOL connector to use for opening the first + HDF5 file specified + --vol-info-1 VOL-specific info to pass to the VOL connector used for + opening the first HDF5 file specified + --vol-value-2 Value (ID) of the VOL connector to use for opening the + second HDF5 file specified + --vol-name-2 Name of the VOL connector to use for opening the second + HDF5 file specified + --vol-info-2 VOL-specific info to pass to the VOL connector used for + opening the second HDF5 file specified --follow-symlinks Follow symbolic links (soft links and external links and compare the) links' target objects. @@ -97,6 +108,14 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] excluded. This option can be used repeatedly to exclude multiple paths. + --exclude-attribute "path/to/object/with/attribute" + Exclude attributes on the specified path to an object when comparing files or groups. + + If there are multiple paths to an object, only the specified path(s) + will be excluded; the comparison will include any path not explicitly + excluded. + This option can be used repeatedly to exclude multiple paths. + Modes of output: Default mode: print the number of differences found and where they occured -r Report mode: print the above plus the differences diff --git a/tools/test/h5diff/testfiles/h5diff_58_ref.txt b/tools/test/h5diff/testfiles/h5diff_58_ref.txt index 6fa2299..48a4b33 100644 --- a/tools/test/h5diff/testfiles/h5diff_58_ref.txt +++ b/tools/test/h5diff/testfiles/h5diff_58_ref.txt @@ -1,32 +1,32 @@ dataset: and size: [2] [2] -position difference +position reference2D reference2D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference2D reference2D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference2D reference2D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference2D reference2D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference2D reference2D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference2D reference2D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 diff --git a/tools/test/h5diff/testfiles/h5diff_600.txt b/tools/test/h5diff/testfiles/h5diff_600.txt index 13d627c..f52d8cc 100644 --- a/tools/test/h5diff/testfiles/h5diff_600.txt +++ b/tools/test/h5diff/testfiles/h5diff_600.txt @@ -17,14 +17,25 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] Verbose mode with level. Print differences and list of objects. Level of detail depends on value of N: 0 : Identical to '-v' or '--verbose'. - 1 : All level 0 information plus one-line attribute - status summary. - 2 : All level 1 information plus extended attribute - status report. + 1 : All level 0 information plus one-line attribute status summary. + 2 : All level 1 information plus extended attribute status report. + 3 : All level 2 information plus file names. -q, --quiet Quiet mode. Do not produce output. --enable-error-stack Prints messages from the HDF5 error stack as they occur. + --vol-value-1 Value (ID) of the VOL connector to use for opening the + first HDF5 file specified + --vol-name-1 Name of the VOL connector to use for opening the first + HDF5 file specified + --vol-info-1 VOL-specific info to pass to the VOL connector used for + opening the first HDF5 file specified + --vol-value-2 Value (ID) of the VOL connector to use for opening the + second HDF5 file specified + --vol-name-2 Name of the VOL connector to use for opening the second + HDF5 file specified + --vol-info-2 VOL-specific info to pass to the VOL connector used for + opening the second HDF5 file specified --follow-symlinks Follow symbolic links (soft links and external links and compare the) links' target objects. @@ -97,6 +108,14 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] excluded. This option can be used repeatedly to exclude multiple paths. + --exclude-attribute "path/to/object/with/attribute" + Exclude attributes on the specified path to an object when comparing files or groups. + + If there are multiple paths to an object, only the specified path(s) + will be excluded; the comparison will include any path not explicitly + excluded. + This option can be used repeatedly to exclude multiple paths. + Modes of output: Default mode: print the number of differences found and where they occured -r Report mode: print the above plus the differences diff --git a/tools/test/h5diff/testfiles/h5diff_603.txt b/tools/test/h5diff/testfiles/h5diff_603.txt index 0d6b474..84111b3 100644 --- a/tools/test/h5diff/testfiles/h5diff_603.txt +++ b/tools/test/h5diff/testfiles/h5diff_603.txt @@ -18,14 +18,25 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] Verbose mode with level. Print differences and list of objects. Level of detail depends on value of N: 0 : Identical to '-v' or '--verbose'. - 1 : All level 0 information plus one-line attribute - status summary. - 2 : All level 1 information plus extended attribute - status report. + 1 : All level 0 information plus one-line attribute status summary. + 2 : All level 1 information plus extended attribute status report. + 3 : All level 2 information plus file names. -q, --quiet Quiet mode. Do not produce output. --enable-error-stack Prints messages from the HDF5 error stack as they occur. + --vol-value-1 Value (ID) of the VOL connector to use for opening the + first HDF5 file specified + --vol-name-1 Name of the VOL connector to use for opening the first + HDF5 file specified + --vol-info-1 VOL-specific info to pass to the VOL connector used for + opening the first HDF5 file specified + --vol-value-2 Value (ID) of the VOL connector to use for opening the + second HDF5 file specified + --vol-name-2 Name of the VOL connector to use for opening the second + HDF5 file specified + --vol-info-2 VOL-specific info to pass to the VOL connector used for + opening the second HDF5 file specified --follow-symlinks Follow symbolic links (soft links and external links and compare the) links' target objects. @@ -98,6 +109,14 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] excluded. This option can be used repeatedly to exclude multiple paths. + --exclude-attribute "path/to/object/with/attribute" + Exclude attributes on the specified path to an object when comparing files or groups. + + If there are multiple paths to an object, only the specified path(s) + will be excluded; the comparison will include any path not explicitly + excluded. + This option can be used repeatedly to exclude multiple paths. + Modes of output: Default mode: print the number of differences found and where they occured -r Report mode: print the above plus the differences diff --git a/tools/test/h5diff/testfiles/h5diff_606.txt b/tools/test/h5diff/testfiles/h5diff_606.txt index 94f44e8..d915d36 100644 --- a/tools/test/h5diff/testfiles/h5diff_606.txt +++ b/tools/test/h5diff/testfiles/h5diff_606.txt @@ -18,14 +18,25 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] Verbose mode with level. Print differences and list of objects. Level of detail depends on value of N: 0 : Identical to '-v' or '--verbose'. - 1 : All level 0 information plus one-line attribute - status summary. - 2 : All level 1 information plus extended attribute - status report. + 1 : All level 0 information plus one-line attribute status summary. + 2 : All level 1 information plus extended attribute status report. + 3 : All level 2 information plus file names. -q, --quiet Quiet mode. Do not produce output. --enable-error-stack Prints messages from the HDF5 error stack as they occur. + --vol-value-1 Value (ID) of the VOL connector to use for opening the + first HDF5 file specified + --vol-name-1 Name of the VOL connector to use for opening the first + HDF5 file specified + --vol-info-1 VOL-specific info to pass to the VOL connector used for + opening the first HDF5 file specified + --vol-value-2 Value (ID) of the VOL connector to use for opening the + second HDF5 file specified + --vol-name-2 Name of the VOL connector to use for opening the second + HDF5 file specified + --vol-info-2 VOL-specific info to pass to the VOL connector used for + opening the second HDF5 file specified --follow-symlinks Follow symbolic links (soft links and external links and compare the) links' target objects. @@ -98,6 +109,14 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] excluded. This option can be used repeatedly to exclude multiple paths. + --exclude-attribute "path/to/object/with/attribute" + Exclude attributes on the specified path to an object when comparing files or groups. + + If there are multiple paths to an object, only the specified path(s) + will be excluded; the comparison will include any path not explicitly + excluded. + This option can be used repeatedly to exclude multiple paths. + Modes of output: Default mode: print the number of differences found and where they occured -r Report mode: print the above plus the differences diff --git a/tools/test/h5diff/testfiles/h5diff_612.txt b/tools/test/h5diff/testfiles/h5diff_612.txt index 7f83c64..1ef8cdf 100644 --- a/tools/test/h5diff/testfiles/h5diff_612.txt +++ b/tools/test/h5diff/testfiles/h5diff_612.txt @@ -18,14 +18,25 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] Verbose mode with level. Print differences and list of objects. Level of detail depends on value of N: 0 : Identical to '-v' or '--verbose'. - 1 : All level 0 information plus one-line attribute - status summary. - 2 : All level 1 information plus extended attribute - status report. + 1 : All level 0 information plus one-line attribute status summary. + 2 : All level 1 information plus extended attribute status report. + 3 : All level 2 information plus file names. -q, --quiet Quiet mode. Do not produce output. --enable-error-stack Prints messages from the HDF5 error stack as they occur. + --vol-value-1 Value (ID) of the VOL connector to use for opening the + first HDF5 file specified + --vol-name-1 Name of the VOL connector to use for opening the first + HDF5 file specified + --vol-info-1 VOL-specific info to pass to the VOL connector used for + opening the first HDF5 file specified + --vol-value-2 Value (ID) of the VOL connector to use for opening the + second HDF5 file specified + --vol-name-2 Name of the VOL connector to use for opening the second + HDF5 file specified + --vol-info-2 VOL-specific info to pass to the VOL connector used for + opening the second HDF5 file specified --follow-symlinks Follow symbolic links (soft links and external links and compare the) links' target objects. @@ -98,6 +109,14 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] excluded. This option can be used repeatedly to exclude multiple paths. + --exclude-attribute "path/to/object/with/attribute" + Exclude attributes on the specified path to an object when comparing files or groups. + + If there are multiple paths to an object, only the specified path(s) + will be excluded; the comparison will include any path not explicitly + excluded. + This option can be used repeatedly to exclude multiple paths. + Modes of output: Default mode: print the number of differences found and where they occured -r Report mode: print the above plus the differences diff --git a/tools/test/h5diff/testfiles/h5diff_615.txt b/tools/test/h5diff/testfiles/h5diff_615.txt index 3cfe6b9..881362e 100644 --- a/tools/test/h5diff/testfiles/h5diff_615.txt +++ b/tools/test/h5diff/testfiles/h5diff_615.txt @@ -18,14 +18,25 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] Verbose mode with level. Print differences and list of objects. Level of detail depends on value of N: 0 : Identical to '-v' or '--verbose'. - 1 : All level 0 information plus one-line attribute - status summary. - 2 : All level 1 information plus extended attribute - status report. + 1 : All level 0 information plus one-line attribute status summary. + 2 : All level 1 information plus extended attribute status report. + 3 : All level 2 information plus file names. -q, --quiet Quiet mode. Do not produce output. --enable-error-stack Prints messages from the HDF5 error stack as they occur. + --vol-value-1 Value (ID) of the VOL connector to use for opening the + first HDF5 file specified + --vol-name-1 Name of the VOL connector to use for opening the first + HDF5 file specified + --vol-info-1 VOL-specific info to pass to the VOL connector used for + opening the first HDF5 file specified + --vol-value-2 Value (ID) of the VOL connector to use for opening the + second HDF5 file specified + --vol-name-2 Name of the VOL connector to use for opening the second + HDF5 file specified + --vol-info-2 VOL-specific info to pass to the VOL connector used for + opening the second HDF5 file specified --follow-symlinks Follow symbolic links (soft links and external links and compare the) links' target objects. @@ -98,6 +109,14 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] excluded. This option can be used repeatedly to exclude multiple paths. + --exclude-attribute "path/to/object/with/attribute" + Exclude attributes on the specified path to an object when comparing files or groups. + + If there are multiple paths to an object, only the specified path(s) + will be excluded; the comparison will include any path not explicitly + excluded. + This option can be used repeatedly to exclude multiple paths. + Modes of output: Default mode: print the number of differences found and where they occured -r Report mode: print the above plus the differences diff --git a/tools/test/h5diff/testfiles/h5diff_621.txt b/tools/test/h5diff/testfiles/h5diff_621.txt index 9c34945..ba39a99 100644 --- a/tools/test/h5diff/testfiles/h5diff_621.txt +++ b/tools/test/h5diff/testfiles/h5diff_621.txt @@ -18,14 +18,25 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] Verbose mode with level. Print differences and list of objects. Level of detail depends on value of N: 0 : Identical to '-v' or '--verbose'. - 1 : All level 0 information plus one-line attribute - status summary. - 2 : All level 1 information plus extended attribute - status report. + 1 : All level 0 information plus one-line attribute status summary. + 2 : All level 1 information plus extended attribute status report. + 3 : All level 2 information plus file names. -q, --quiet Quiet mode. Do not produce output. --enable-error-stack Prints messages from the HDF5 error stack as they occur. + --vol-value-1 Value (ID) of the VOL connector to use for opening the + first HDF5 file specified + --vol-name-1 Name of the VOL connector to use for opening the first + HDF5 file specified + --vol-info-1 VOL-specific info to pass to the VOL connector used for + opening the first HDF5 file specified + --vol-value-2 Value (ID) of the VOL connector to use for opening the + second HDF5 file specified + --vol-name-2 Name of the VOL connector to use for opening the second + HDF5 file specified + --vol-info-2 VOL-specific info to pass to the VOL connector used for + opening the second HDF5 file specified --follow-symlinks Follow symbolic links (soft links and external links and compare the) links' target objects. @@ -98,6 +109,14 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] excluded. This option can be used repeatedly to exclude multiple paths. + --exclude-attribute "path/to/object/with/attribute" + Exclude attributes on the specified path to an object when comparing files or groups. + + If there are multiple paths to an object, only the specified path(s) + will be excluded; the comparison will include any path not explicitly + excluded. + This option can be used repeatedly to exclude multiple paths. + Modes of output: Default mode: print the number of differences found and where they occured -r Report mode: print the above plus the differences diff --git a/tools/test/h5diff/testfiles/h5diff_622.txt b/tools/test/h5diff/testfiles/h5diff_622.txt index 2b2df2f..70421fc 100644 --- a/tools/test/h5diff/testfiles/h5diff_622.txt +++ b/tools/test/h5diff/testfiles/h5diff_622.txt @@ -18,14 +18,25 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] Verbose mode with level. Print differences and list of objects. Level of detail depends on value of N: 0 : Identical to '-v' or '--verbose'. - 1 : All level 0 information plus one-line attribute - status summary. - 2 : All level 1 information plus extended attribute - status report. + 1 : All level 0 information plus one-line attribute status summary. + 2 : All level 1 information plus extended attribute status report. + 3 : All level 2 information plus file names. -q, --quiet Quiet mode. Do not produce output. --enable-error-stack Prints messages from the HDF5 error stack as they occur. + --vol-value-1 Value (ID) of the VOL connector to use for opening the + first HDF5 file specified + --vol-name-1 Name of the VOL connector to use for opening the first + HDF5 file specified + --vol-info-1 VOL-specific info to pass to the VOL connector used for + opening the first HDF5 file specified + --vol-value-2 Value (ID) of the VOL connector to use for opening the + second HDF5 file specified + --vol-name-2 Name of the VOL connector to use for opening the second + HDF5 file specified + --vol-info-2 VOL-specific info to pass to the VOL connector used for + opening the second HDF5 file specified --follow-symlinks Follow symbolic links (soft links and external links and compare the) links' target objects. @@ -98,6 +109,14 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] excluded. This option can be used repeatedly to exclude multiple paths. + --exclude-attribute "path/to/object/with/attribute" + Exclude attributes on the specified path to an object when comparing files or groups. + + If there are multiple paths to an object, only the specified path(s) + will be excluded; the comparison will include any path not explicitly + excluded. + This option can be used repeatedly to exclude multiple paths. + Modes of output: Default mode: print the number of differences found and where they occured -r Report mode: print the above plus the differences diff --git a/tools/test/h5diff/testfiles/h5diff_623.txt b/tools/test/h5diff/testfiles/h5diff_623.txt index 3e80438..0d74268 100644 --- a/tools/test/h5diff/testfiles/h5diff_623.txt +++ b/tools/test/h5diff/testfiles/h5diff_623.txt @@ -18,14 +18,25 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] Verbose mode with level. Print differences and list of objects. Level of detail depends on value of N: 0 : Identical to '-v' or '--verbose'. - 1 : All level 0 information plus one-line attribute - status summary. - 2 : All level 1 information plus extended attribute - status report. + 1 : All level 0 information plus one-line attribute status summary. + 2 : All level 1 information plus extended attribute status report. + 3 : All level 2 information plus file names. -q, --quiet Quiet mode. Do not produce output. --enable-error-stack Prints messages from the HDF5 error stack as they occur. + --vol-value-1 Value (ID) of the VOL connector to use for opening the + first HDF5 file specified + --vol-name-1 Name of the VOL connector to use for opening the first + HDF5 file specified + --vol-info-1 VOL-specific info to pass to the VOL connector used for + opening the first HDF5 file specified + --vol-value-2 Value (ID) of the VOL connector to use for opening the + second HDF5 file specified + --vol-name-2 Name of the VOL connector to use for opening the second + HDF5 file specified + --vol-info-2 VOL-specific info to pass to the VOL connector used for + opening the second HDF5 file specified --follow-symlinks Follow symbolic links (soft links and external links and compare the) links' target objects. @@ -98,6 +109,14 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] excluded. This option can be used repeatedly to exclude multiple paths. + --exclude-attribute "path/to/object/with/attribute" + Exclude attributes on the specified path to an object when comparing files or groups. + + If there are multiple paths to an object, only the specified path(s) + will be excluded; the comparison will include any path not explicitly + excluded. + This option can be used repeatedly to exclude multiple paths. + Modes of output: Default mode: print the number of differences found and where they occured -r Report mode: print the above plus the differences diff --git a/tools/test/h5diff/testfiles/h5diff_624.txt b/tools/test/h5diff/testfiles/h5diff_624.txt index 7a2f585..cb8b8b4 100644 --- a/tools/test/h5diff/testfiles/h5diff_624.txt +++ b/tools/test/h5diff/testfiles/h5diff_624.txt @@ -18,14 +18,25 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] Verbose mode with level. Print differences and list of objects. Level of detail depends on value of N: 0 : Identical to '-v' or '--verbose'. - 1 : All level 0 information plus one-line attribute - status summary. - 2 : All level 1 information plus extended attribute - status report. + 1 : All level 0 information plus one-line attribute status summary. + 2 : All level 1 information plus extended attribute status report. + 3 : All level 2 information plus file names. -q, --quiet Quiet mode. Do not produce output. --enable-error-stack Prints messages from the HDF5 error stack as they occur. + --vol-value-1 Value (ID) of the VOL connector to use for opening the + first HDF5 file specified + --vol-name-1 Name of the VOL connector to use for opening the first + HDF5 file specified + --vol-info-1 VOL-specific info to pass to the VOL connector used for + opening the first HDF5 file specified + --vol-value-2 Value (ID) of the VOL connector to use for opening the + second HDF5 file specified + --vol-name-2 Name of the VOL connector to use for opening the second + HDF5 file specified + --vol-info-2 VOL-specific info to pass to the VOL connector used for + opening the second HDF5 file specified --follow-symlinks Follow symbolic links (soft links and external links and compare the) links' target objects. @@ -98,6 +109,14 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] excluded. This option can be used repeatedly to exclude multiple paths. + --exclude-attribute "path/to/object/with/attribute" + Exclude attributes on the specified path to an object when comparing files or groups. + + If there are multiple paths to an object, only the specified path(s) + will be excluded; the comparison will include any path not explicitly + excluded. + This option can be used repeatedly to exclude multiple paths. + Modes of output: Default mode: print the number of differences found and where they occured -r Report mode: print the above plus the differences diff --git a/tools/test/h5diff/testfiles/h5diff_70.txt b/tools/test/h5diff/testfiles/h5diff_70.txt index efa34ea..b0b8bf6 100644 --- a/tools/test/h5diff/testfiles/h5diff_70.txt +++ b/tools/test/h5diff/testfiles/h5diff_70.txt @@ -1183,10 +1183,42 @@ position opaque3D of opaque3D of difference [ 3 2 1 ] 24 0 24 24 differences found attribute: > and > +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset 0 differences found attribute: > and > +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset 0 differences found attribute: > and > +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset 0 differences found attribute: > and > size: [2] [2] diff --git a/tools/test/h5diff/testfiles/h5diff_700.txt b/tools/test/h5diff/testfiles/h5diff_700.txt index 851a407..6cf9893 100644 --- a/tools/test/h5diff/testfiles/h5diff_700.txt +++ b/tools/test/h5diff/testfiles/h5diff_700.txt @@ -1187,10 +1187,42 @@ position opaque3D of opaque3D of difference [ 3 2 1 ] 24 0 24 24 differences found attribute: > and > +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset 0 differences found attribute: > and > +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset 0 differences found attribute: > and > +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset 0 differences found attribute: > and > size: [2] [2] diff --git a/tools/test/h5diff/testfiles/h5diff_701.txt b/tools/test/h5diff/testfiles/h5diff_701.txt index 33f1a0f..4187754 100644 --- a/tools/test/h5diff/testfiles/h5diff_701.txt +++ b/tools/test/h5diff/testfiles/h5diff_701.txt @@ -1254,10 +1254,42 @@ position opaque3D of opaque3D of difference [ 3 2 1 ] 24 0 24 24 differences found attribute: > and > +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset 0 differences found attribute: > and > +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset 0 differences found attribute: > and > +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset 0 differences found attribute: > and > size: [2] [2] diff --git a/tools/test/h5diff/testfiles/h5diff_702.txt b/tools/test/h5diff/testfiles/h5diff_702.txt index 851a407..6cf9893 100644 --- a/tools/test/h5diff/testfiles/h5diff_702.txt +++ b/tools/test/h5diff/testfiles/h5diff_702.txt @@ -1187,10 +1187,42 @@ position opaque3D of opaque3D of difference [ 3 2 1 ] 24 0 24 24 differences found attribute: > and > +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset 0 differences found attribute: > and > +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset 0 differences found attribute: > and > +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset 0 differences found attribute: > and > size: [2] [2] diff --git a/tools/test/h5diff/testfiles/h5diff_703.txt b/tools/test/h5diff/testfiles/h5diff_703.txt index 33f1a0f..4187754 100644 --- a/tools/test/h5diff/testfiles/h5diff_703.txt +++ b/tools/test/h5diff/testfiles/h5diff_703.txt @@ -1254,10 +1254,42 @@ position opaque3D of opaque3D of difference [ 3 2 1 ] 24 0 24 24 differences found attribute: > and > +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset 0 differences found attribute: > and > +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset 0 differences found attribute: > and > +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset +Not comparable: > or > is an empty dataset 0 differences found attribute: > and > size: [2] [2] diff --git a/tools/test/h5diff/testfiles/h5diff_80.txt b/tools/test/h5diff/testfiles/h5diff_80.txt index b223eed..11dccd8 100644 --- a/tools/test/h5diff/testfiles/h5diff_80.txt +++ b/tools/test/h5diff/testfiles/h5diff_80.txt @@ -528,166 +528,166 @@ position opaque3D opaque3D difference 24 differences found dataset: and size: [2] [2] -position difference +position reference reference difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference reference difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 4 differences found dataset: and size: [2] [2] -position difference +position reference2D reference2D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference2D reference2D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference2D reference2D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference2D reference2D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference2D reference2D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference2D reference2D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 12 differences found dataset: and size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 size: [2] [2] -position difference +position reference3D reference3D difference ------------------------------------------------------------ [ 0 ] 1 0 1 [ 1 ] 2 0 2 diff --git a/tools/test/h5diff/testfiles/h5diff_eps.txt b/tools/test/h5diff/testfiles/h5diff_eps.txt new file mode 100644 index 0000000..3a71366 --- /dev/null +++ b/tools/test/h5diff/testfiles/h5diff_eps.txt @@ -0,0 +1,17 @@ +file1: h5diff_eps1.h5 +file2: h5diff_eps2.h5 + +file1 file2 +--------------------------------------- + x x / + x x /DS1 + + +group : and +0 differences found +Attributes status: 0 common, 0 only in obj1, 0 only in obj2 + +dataset: and +0 differences found +Attributes status: 0 common, 0 only in obj1, 0 only in obj2 +EXIT CODE: 0 diff --git a/tools/test/h5diff/testfiles/h5diff_eps1.h5 b/tools/test/h5diff/testfiles/h5diff_eps1.h5 new file mode 100644 index 0000000..2803a1d Binary files /dev/null and b/tools/test/h5diff/testfiles/h5diff_eps1.h5 differ diff --git a/tools/test/h5diff/testfiles/h5diff_eps2.h5 b/tools/test/h5diff/testfiles/h5diff_eps2.h5 new file mode 100644 index 0000000..4acf27a Binary files /dev/null and b/tools/test/h5diff/testfiles/h5diff_eps2.h5 differ diff --git a/tools/test/h5diff/testfiles/h5diff_reg.txt b/tools/test/h5diff/testfiles/h5diff_reg.txt index d4f5415..ecb6275 100644 --- a/tools/test/h5diff/testfiles/h5diff_reg.txt +++ b/tools/test/h5diff/testfiles/h5diff_reg.txt @@ -1,12 +1,11 @@ dataset: and -attribute: > and > +attribute: > and > 0 differences found -Warning: Cannot open referenced attribute: attribute 1 -Warning: Cannot open referenced attribute: attribute 2 -attribute: > and > +Warning: Cannot open referenced attribute1 +attribute: > and > 0 differences found -attribute: > and > +attribute: > and > 0 differences found 0 differences found obj1 obj2 diff --git a/tools/test/h5diff/testfiles/h5diff_strings1.h5 b/tools/test/h5diff/testfiles/h5diff_strings1.h5 new file mode 100644 index 0000000..0f8b380 Binary files /dev/null and b/tools/test/h5diff/testfiles/h5diff_strings1.h5 differ diff --git a/tools/test/h5diff/testfiles/h5diff_strings2.h5 b/tools/test/h5diff/testfiles/h5diff_strings2.h5 new file mode 100644 index 0000000..e8520ae Binary files /dev/null and b/tools/test/h5diff/testfiles/h5diff_strings2.h5 differ diff --git a/tools/test/h5diff/testh5diff.sh.in b/tools/test/h5diff/testh5diff.sh.in index 2d490a8..4e622ee 100644 --- a/tools/test/h5diff/testh5diff.sh.in +++ b/tools/test/h5diff/testh5diff.sh.in @@ -85,6 +85,7 @@ $SRC_H5DIFF_TESTFILES/h5diff_attr2.h5 $SRC_H5DIFF_TESTFILES/h5diff_attr3.h5 $SRC_H5DIFF_TESTFILES/h5diff_dset1.h5 $SRC_H5DIFF_TESTFILES/h5diff_dset2.h5 +$SRC_H5DIFF_TESTFILES/h5diff_dset3.h5 $SRC_H5DIFF_TESTFILES/h5diff_hyper1.h5 $SRC_H5DIFF_TESTFILES/h5diff_hyper2.h5 $SRC_H5DIFF_TESTFILES/h5diff_empty.h5 @@ -119,8 +120,10 @@ $SRC_H5DIFF_TESTFILES/h5diff_attr_v_level2.h5 $SRC_H5DIFF_TESTFILES/h5diff_enum_invalid_values.h5 $SRC_H5DIFF_TESTFILES/non_comparables1.h5 $SRC_H5DIFF_TESTFILES/non_comparables2.h5 -$SRC_H5DIFF_TESTFILES/diff_strings1.h5 -$SRC_H5DIFF_TESTFILES/diff_strings2.h5 +$SRC_H5DIFF_TESTFILES/h5diff_strings1.h5 +$SRC_H5DIFF_TESTFILES/h5diff_strings2.h5 +$SRC_H5DIFF_TESTFILES/h5diff_eps1.h5 +$SRC_H5DIFF_TESTFILES/h5diff_eps2.h5 $SRC_TOOLS_TESTFILES/tvlstr.h5 " @@ -349,6 +352,8 @@ $SRC_H5DIFF_TESTFILES/h5diff_708.txt $SRC_H5DIFF_TESTFILES/h5diff_709.txt $SRC_H5DIFF_TESTFILES/h5diff_710.txt $SRC_H5DIFF_TESTFILES/h5diff_80.txt +$SRC_H5DIFF_TESTFILES/h5diff_800.txt +$SRC_H5DIFF_TESTFILES/h5diff_801.txt $SRC_H5DIFF_TESTFILES/h5diff_90.txt $SRC_H5DIFF_TESTFILES/h5diff_8625.txt $SRC_H5DIFF_TESTFILES/h5diff_8639.txt @@ -357,6 +362,7 @@ $SRC_H5DIFF_TESTFILES/h5diff_v1.txt $SRC_H5DIFF_TESTFILES/h5diff_v2.txt $SRC_H5DIFF_TESTFILES/h5diff_v3.txt $SRC_H5DIFF_TESTFILES/h5diff_vlstr.txt +$SRC_H5DIFF_TESTFILES/h5diff_eps.txt " # @@ -717,10 +723,10 @@ TOOLTEST h5diff_59.txt -v h5diff_dtypes.h5 h5diff_dtypes.h5 dset11a dset11b # Strings # ( HDFFV-10128 ) -TOOLTEST h5diff_60.txt -v diff_strings1.h5 diff_strings2.h5 string1 string1 -TOOLTEST h5diff_61.txt -v diff_strings1.h5 diff_strings2.h5 string2 string2 -TOOLTEST h5diff_62.txt -v diff_strings1.h5 diff_strings2.h5 string3 string3 -TOOLTEST h5diff_63.txt -v diff_strings1.h5 diff_strings2.h5 string4 string4 +TOOLTEST h5diff_60.txt -v h5diff_strings1.h5 h5diff_strings2.h5 string1 string1 +TOOLTEST h5diff_61.txt -v h5diff_strings1.h5 h5diff_strings2.h5 string2 string2 +TOOLTEST h5diff_62.txt -v h5diff_strings1.h5 h5diff_strings2.h5 string3 string3 +TOOLTEST h5diff_63.txt -v h5diff_strings1.h5 h5diff_strings2.h5 string4 string4 # ############################################################################## # # Error messages @@ -763,6 +769,9 @@ TOOLTEST h5diff_609.txt -d 200 h5diff_basic1.h5 h5diff_basic2.h5 g1/dset3 g1/dse # 6.10: number smaller than smallest difference TOOLTEST h5diff_610.txt -d 1 h5diff_basic1.h5 h5diff_basic2.h5 g1/dset3 g1/dset4 +# eps: number smaller than epsilon +TOOLTEST h5diff_eps.txt -v3 -d 1e-16 h5diff_eps1.h5 h5diff_eps2.h5 + # ############################################################################## # # -p @@ -1184,6 +1193,12 @@ TOOLTEST h5diff_645.txt -v -p 0.05 --use-system-epsilon h5diff_basic1.h5 h5diff_ TOOLTEST h5diff_646.txt -v --use-system-epsilon -p 0.05 h5diff_basic1.h5 h5diff_basic2.h5 /g1/dset3 /g1/dset4 # ############################################################################## +# # Test array variances +# ############################################################################## +TOOLTEST h5diff_800.txt -v h5diff_dset1.h5 h5diff_dset2.h5 /g1/array /g1/array +TOOLTEST h5diff_801.txt -v h5diff_dset1.h5 h5diff_dset3.h5 /g1/array /g1/array + +# ############################################################################## # VDS tests # ############################################################################## TOOLTEST h5diff_v1.txt -v 1_vds.h5 2_vds.h5 diff --git a/tools/test/h5dump/CMakeLists.txt b/tools/test/h5dump/CMakeLists.txt index cfc542f..8a83699 100644 --- a/tools/test/h5dump/CMakeLists.txt +++ b/tools/test/h5dump/CMakeLists.txt @@ -35,7 +35,7 @@ endif () # -------------------------------------------------------------------- if (HDF5_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS) add_executable (h5dumpgentest ${HDF5_TOOLS_TEST_H5DUMP_SOURCE_DIR}/h5dumpgentest.c) - target_include_directories (h5dumpgentest PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") + target_include_directories (h5dumpgentest PRIVATE "${HDF5_SRC_DIR};${HDF5_TEST_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (h5dumpgentest STATIC) target_link_libraries (h5dumpgentest PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) set_target_properties (h5dumpgentest PROPERTIES FOLDER generator/tools) diff --git a/tools/test/h5dump/Makefile.am b/tools/test/h5dump/Makefile.am index a7a2bcb..21560fb 100644 --- a/tools/test/h5dump/Makefile.am +++ b/tools/test/h5dump/Makefile.am @@ -19,7 +19,7 @@ include $(top_srcdir)/config/commence.am # Include files in /src directory and /tools/lib directory -AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/tools/lib +AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/test -I$(top_srcdir)/tools/lib # Test programs and scripts TEST_PROG=h5dumpgentest diff --git a/tools/test/h5dump/h5dumpgentest.c b/tools/test/h5dump/h5dumpgentest.c index f09d200..731e233 100644 --- a/tools/test/h5dump/h5dumpgentest.c +++ b/tools/test/h5dump/h5dumpgentest.c @@ -22,7 +22,7 @@ */ #include "hdf5.h" -#include "H5private.h" +#include "h5test.h" #include "h5tools.h" #define FILE1 "tgroup.h5" @@ -463,10 +463,23 @@ gent_dataset(void) { hid_t fid, dataset, space; hsize_t dims[2]; - int dset1[10][20]; - double dset2[30][20]; + int **dset1 = NULL; + int *dset1_data = NULL; + double **dset2 = NULL; + double *dset2_data = NULL; int i, j; + /* Set up data arrays */ + dset1_data = (int *)HDcalloc(10 * 20, sizeof(int)); + dset1 = (int **)HDcalloc(10, sizeof(dset1_data)); + for (i = 0; i < 10; i++) + dset1[i] = dset1_data + (i * 20); + + dset2_data = (double *)HDcalloc(30 * 20, sizeof(double)); + dset2 = (double **)HDcalloc(30, sizeof(dset2_data)); + for (i = 0; i < 30; i++) + dset2[i] = dset2_data + (i * 20); + fid = H5Fcreate(FILE2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* dset1 */ @@ -478,7 +491,7 @@ gent_dataset(void) for(j = 0; j < 20; j++) dset1[i][j] = j + i; - H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset1); + H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset1_data); H5Sclose(space); H5Dclose(dataset); @@ -491,11 +504,16 @@ gent_dataset(void) for(j = 0; j < 20; j++) dset2[i][j] = 0.0001F * (float)j + (float)i; - H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2); + H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2_data); H5Sclose(space); H5Dclose(dataset); H5Fclose(fid); + + HDfree(dset1); + HDfree(dset1_data); + HDfree(dset2); + HDfree(dset2_data); } static void @@ -1773,9 +1791,17 @@ static void gent_str(void) { int a[8][10]; char s[12][33]; } compound_t; - compound_t comp1[3][6]; + + compound_t **comp1 = NULL; + compound_t *comp1_data = NULL; hsize_t mdims[2]; + /* Set up data array */ + comp1_data = (compound_t *)HDcalloc(3 * 6, sizeof(compound_t)); + comp1 = (compound_t **)HDcalloc(3, sizeof(comp1_data)); + for (i = 0; i < 3; i++) + comp1[i] = comp1_data + (i * 6); + fid = H5Fcreate(FILE13, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* string 1 : nullterm string */ @@ -1861,7 +1887,7 @@ static void gent_str(void) { } dataset = H5Dcreate2(fid, "/comp1", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Dwrite(dataset, f_type2, H5S_ALL, H5S_ALL, H5P_DEFAULT, comp1); + H5Dwrite(dataset, f_type2, H5S_ALL, H5S_ALL, H5P_DEFAULT, comp1_data); H5Tclose(f_type); H5Tclose(f_type2); @@ -1869,6 +1895,9 @@ static void gent_str(void) { H5Dclose(dataset); H5Fclose(fid); + + HDfree(comp1); + HDfree(comp1_data); } /* @@ -2084,6 +2113,7 @@ static void gent_objref(void) uint32_t *tu32; /* Temporary pointer to uint32 data */ int i; /* counting variables */ const char *write_comment = "Foo!"; /* Comments for group */ + hbool_t supports_comments = FALSE; /* Allocate write & read buffers */ wbuf = (hobj_ref_t*) HDmalloc(sizeof(hobj_ref_t) * SPACE1_DIM1); @@ -2099,8 +2129,12 @@ static void gent_objref(void) /* Create a group */ group = H5Gcreate2(fid1, "Group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + /* Check if we support comments in the current VOL connector */ + H5VLquery_optional(fid1, H5VL_SUBCLS_OBJECT, H5VL_NATIVE_OBJECT_SET_COMMENT, &supports_comments); + /* Set group's comment */ - H5Oset_comment(group, write_comment); + if (supports_comments) + H5Oset_comment(group, write_comment); /* Create a dataset (inside Group1) */ dataset = H5Dcreate2(group, "Dataset1", H5T_STD_U32BE, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -3064,7 +3098,7 @@ static void gent_array1(void) hsize_t sdims1[] = {SPACE1_DIM1}; hsize_t tdims1[] = {ARRAY1_DIM1}; int i,j; /* counting variables */ - herr_t ret; /* Generic return value */ + herr_t ret H5_ATTR_NDEBUG_UNUSED; /* Generic return value */ /* Allocate and initialize array data to write */ for(i=0; i=0); + /* Check if we support comments in the current VOL connector */ + H5VLquery_optional(fid, H5VL_SUBCLS_OBJECT, H5VL_NATIVE_OBJECT_SET_COMMENT, &supports_comments); + /* create a space */ sid = H5Screate_simple(SPACE2_RANK, dims1, NULL); @@ -5415,8 +5481,10 @@ static void gent_filters(void) ret=make_dset(fid,"compact",sid,H5T_NATIVE_INT,dcpl,buf1); HDassert(ret >= 0); - ret = H5Oset_comment_by_name(fid, "compact", "This is a dataset with compact storage", H5P_DEFAULT); - HDassert(ret >= 0); + if (supports_comments) { + ret = H5Oset_comment_by_name(fid, "compact", "This is a dataset with compact storage", H5P_DEFAULT); + HDassert(ret >= 0); + } ret = H5Pset_layout(dcpl, H5D_CONTIGUOUS); HDassert(ret >= 0); @@ -5424,8 +5492,10 @@ static void gent_filters(void) ret=make_dset(fid,"contiguous",sid,H5T_NATIVE_INT,dcpl,buf1); HDassert(ret >= 0); - ret = H5Oset_comment_by_name(fid, "contiguous", "This is a dataset with contiguous storage", H5P_DEFAULT); - HDassert(ret >= 0); + if (supports_comments) { + ret = H5Oset_comment_by_name(fid, "contiguous", "This is a dataset with contiguous storage", H5P_DEFAULT); + HDassert(ret >= 0); + } ret = H5Pset_layout(dcpl, H5D_CHUNKED); HDassert(ret >= 0); @@ -5436,8 +5506,10 @@ static void gent_filters(void) ret=make_dset(fid,"chunked",sid,H5T_NATIVE_INT,dcpl,buf1); HDassert(ret >= 0); - ret = H5Oset_comment_by_name(fid, "chunked", "This is a dataset with chunked storage", H5P_DEFAULT); - HDassert(ret >= 0); + if (supports_comments) { + ret = H5Oset_comment_by_name(fid, "chunked", "This is a dataset with chunked storage", H5P_DEFAULT); + HDassert(ret >= 0); + } /*------------------------------------------------------------------------- * make several dataset with filters @@ -5653,8 +5725,10 @@ static void gent_filters(void) ret = H5Tcommit2(fid, "mytype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); HDassert(ret >= 0); - ret = H5Oset_comment_by_name(fid, "mytype", "This is a commited datatype", H5P_DEFAULT); - HDassert(ret >= 0); + if (supports_comments) { + ret = H5Oset_comment_by_name(fid, "mytype", "This is a commited datatype", H5P_DEFAULT); + HDassert(ret >= 0); + } ret = H5Tclose(tid); HDassert(ret >= 0); @@ -7171,19 +7245,43 @@ gent_dataset_idx(void) static void gent_packedbits(void) { - hid_t fid, dataset, space; + hid_t fid = H5I_INVALID_HID; + hid_t dataset = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; hsize_t dims[2]; - uint8_t dsetu8[F66_XDIM][F66_YDIM8], valu8bits; - uint16_t dsetu16[F66_XDIM][F66_YDIM16], valu16bits; - uint32_t dsetu32[F66_XDIM][F66_YDIM32], valu32bits; - uint64_t dsetu64[F66_XDIM][F66_YDIM64], valu64bits; - int8_t dset8[F66_XDIM][F66_YDIM8], val8bits; - int16_t dset16[F66_XDIM][F66_YDIM16], val16bits; - int32_t dset32[F66_XDIM][F66_YDIM32], val32bits; - int64_t dset64[F66_XDIM][F66_YDIM64], val64bits; - double dsetdbl[F66_XDIM][F66_YDIM8]; + + uint8_t **dsetu8 = NULL; + uint16_t **dsetu16 = NULL; + uint32_t **dsetu32 = NULL; + uint64_t **dsetu64 = NULL; + int8_t **dset8 = NULL; + int16_t **dset16 = NULL; + int32_t **dset32 = NULL; + int64_t **dset64 = NULL; + double **dsetdbl = NULL; + + uint8_t valu8bits; + uint16_t valu16bits; + uint32_t valu32bits; + uint64_t valu64bits; + int8_t val8bits; + int16_t val16bits; + int32_t val32bits; + int64_t val64bits; + unsigned int i, j; + /* Create arrays */ + H5TEST_ALLOCATE_2D_ARRAY(dsetu8, uint8_t, F66_XDIM, F66_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dsetu16, uint16_t, F66_XDIM, F66_YDIM16); + H5TEST_ALLOCATE_2D_ARRAY(dsetu32, uint32_t, F66_XDIM, F66_YDIM32); + H5TEST_ALLOCATE_2D_ARRAY(dsetu64, uint64_t, F66_XDIM, F66_YDIM64); + H5TEST_ALLOCATE_2D_ARRAY(dset8, int8_t, F66_XDIM, F66_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dset16, int16_t, F66_XDIM, F66_YDIM16); + H5TEST_ALLOCATE_2D_ARRAY(dset32, int32_t, F66_XDIM, F66_YDIM32); + H5TEST_ALLOCATE_2D_ARRAY(dset64, int64_t, F66_XDIM, F66_YDIM64); + H5TEST_ALLOCATE_2D_ARRAY(dsetdbl, double, F66_XDIM, F66_YDIM8); + fid = H5Fcreate(FILE66, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Dataset of 8 bits unsigned int */ @@ -7199,7 +7297,7 @@ gent_packedbits(void) valu8bits = (uint8_t)(valu8bits << 1); } - H5Dwrite(dataset, H5T_NATIVE_UINT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu8); + H5Dwrite(dataset, H5T_NATIVE_UINT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu8[0]); H5Sclose(space); H5Dclose(dataset); @@ -7216,7 +7314,7 @@ gent_packedbits(void) valu16bits = (uint16_t)(valu16bits << 1); } - H5Dwrite(dataset, H5T_NATIVE_UINT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu16); + H5Dwrite(dataset, H5T_NATIVE_UINT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu16[0]); H5Sclose(space); H5Dclose(dataset); @@ -7233,7 +7331,7 @@ gent_packedbits(void) valu32bits <<= 1; } - H5Dwrite(dataset, H5T_NATIVE_UINT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu32); + H5Dwrite(dataset, H5T_NATIVE_UINT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu32[0]); H5Sclose(space); H5Dclose(dataset); @@ -7250,7 +7348,7 @@ gent_packedbits(void) valu64bits <<= 1; } - H5Dwrite(dataset, H5T_NATIVE_UINT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu64); + H5Dwrite(dataset, H5T_NATIVE_UINT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu64[0]); H5Sclose(space); H5Dclose(dataset); @@ -7267,7 +7365,7 @@ gent_packedbits(void) val8bits = (int8_t)(val8bits << 1); } - H5Dwrite(dataset, H5T_NATIVE_INT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset8); + H5Dwrite(dataset, H5T_NATIVE_INT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset8[0]); H5Sclose(space); H5Dclose(dataset); @@ -7284,7 +7382,7 @@ gent_packedbits(void) val16bits = (int16_t)(val16bits << 1); } - H5Dwrite(dataset, H5T_NATIVE_INT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset16); + H5Dwrite(dataset, H5T_NATIVE_INT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset16[0]); H5Sclose(space); H5Dclose(dataset); @@ -7301,7 +7399,7 @@ gent_packedbits(void) val32bits <<= 1; } - H5Dwrite(dataset, H5T_NATIVE_INT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset32); + H5Dwrite(dataset, H5T_NATIVE_INT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset32[0]); H5Sclose(space); H5Dclose(dataset); @@ -7318,7 +7416,7 @@ gent_packedbits(void) val64bits <<= 1; } - H5Dwrite(dataset, H5T_NATIVE_INT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset64); + H5Dwrite(dataset, H5T_NATIVE_INT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset64[0]); H5Sclose(space); H5Dclose(dataset); @@ -7331,11 +7429,21 @@ gent_packedbits(void) for(j = 0; j < dims[1]; j++) dsetdbl[i][j] = 0.0001F * (float)j + (float)i; - H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetdbl); + H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetdbl[0]); H5Sclose(space); H5Dclose(dataset); H5Fclose(fid); + + HDfree(dsetu8); + HDfree(dsetu16); + HDfree(dsetu32); + HDfree(dsetu64); + HDfree(dset8); + HDfree(dset16); + HDfree(dset32); + HDfree(dset64); + HDfree(dsetdbl); } /*------------------------------------------------------------------------- @@ -7352,19 +7460,44 @@ gent_packedbits(void) static void gent_attr_intsize(void) { - hid_t fid, attr, space, root; + hid_t fid = H5I_INVALID_HID; + hid_t attr = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t root = H5I_INVALID_HID; hsize_t dims[2]; - uint8_t dsetu8[F66_XDIM][F66_YDIM8], valu8bits; - uint16_t dsetu16[F66_XDIM][F66_YDIM16], valu16bits; - uint32_t dsetu32[F66_XDIM][F66_YDIM32], valu32bits; - uint64_t dsetu64[F66_XDIM][F66_YDIM64], valu64bits; - int8_t dset8[F66_XDIM][F66_YDIM8], val8bits; - int16_t dset16[F66_XDIM][F66_YDIM16], val16bits; - int32_t dset32[F66_XDIM][F66_YDIM32], val32bits; - int64_t dset64[F66_XDIM][F66_YDIM64], val64bits; - double dsetdbl[F66_XDIM][F66_YDIM8]; + + uint8_t **dsetu8 = NULL; + uint16_t **dsetu16 = NULL; + uint32_t **dsetu32 = NULL; + uint64_t **dsetu64 = NULL; + int8_t **dset8 = NULL; + int16_t **dset16 = NULL; + int32_t **dset32 = NULL; + int64_t **dset64 = NULL; + double **dsetdbl = NULL; + + uint8_t valu8bits; + uint16_t valu16bits; + uint32_t valu32bits; + uint64_t valu64bits; + int8_t val8bits; + int16_t val16bits; + int32_t val32bits; + int64_t val64bits; + unsigned int i, j; + /* Create arrays */ + H5TEST_ALLOCATE_2D_ARRAY(dsetu8, uint8_t, F66_XDIM, F66_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dsetu16, uint16_t, F66_XDIM, F66_YDIM16); + H5TEST_ALLOCATE_2D_ARRAY(dsetu32, uint32_t, F66_XDIM, F66_YDIM32); + H5TEST_ALLOCATE_2D_ARRAY(dsetu64, uint64_t, F66_XDIM, F66_YDIM64); + H5TEST_ALLOCATE_2D_ARRAY(dset8, int8_t, F66_XDIM, F66_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dset16, int16_t, F66_XDIM, F66_YDIM16); + H5TEST_ALLOCATE_2D_ARRAY(dset32, int32_t, F66_XDIM, F66_YDIM32); + H5TEST_ALLOCATE_2D_ARRAY(dset64, int64_t, F66_XDIM, F66_YDIM64); + H5TEST_ALLOCATE_2D_ARRAY(dsetdbl, double, F66_XDIM, F66_YDIM8); + fid = H5Fcreate(FILE69, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); root = H5Gopen2(fid, "/", H5P_DEFAULT); @@ -7382,7 +7515,7 @@ gent_attr_intsize(void) valu8bits = (uint8_t)(valu8bits << 1); } - H5Awrite(attr, H5T_NATIVE_UINT8, dsetu8); + H5Awrite(attr, H5T_NATIVE_UINT8, dsetu8[0]); H5Sclose(space); H5Aclose(attr); @@ -7400,7 +7533,7 @@ gent_attr_intsize(void) valu16bits = (uint16_t)(valu16bits << 1); } - H5Awrite(attr, H5T_NATIVE_UINT16, dsetu16); + H5Awrite(attr, H5T_NATIVE_UINT16, dsetu16[0]); H5Sclose(space); H5Aclose(attr); @@ -7418,7 +7551,7 @@ gent_attr_intsize(void) valu32bits <<= 1; } - H5Awrite(attr, H5T_NATIVE_UINT32, dsetu32); + H5Awrite(attr, H5T_NATIVE_UINT32, dsetu32[0]); H5Sclose(space); H5Aclose(attr); @@ -7436,7 +7569,7 @@ gent_attr_intsize(void) valu64bits <<= 1; } - H5Awrite(attr, H5T_NATIVE_UINT64, dsetu64); + H5Awrite(attr, H5T_NATIVE_UINT64, dsetu64[0]); H5Sclose(space); H5Aclose(attr); @@ -7454,7 +7587,7 @@ gent_attr_intsize(void) val8bits = (int8_t)(val8bits << 1); } - H5Awrite(attr, H5T_NATIVE_INT8, dset8); + H5Awrite(attr, H5T_NATIVE_INT8, dset8[0]); H5Sclose(space); H5Aclose(attr); @@ -7472,7 +7605,7 @@ gent_attr_intsize(void) val16bits = (int16_t)(val16bits << 1); } - H5Awrite(attr, H5T_NATIVE_INT16, dset16); + H5Awrite(attr, H5T_NATIVE_INT16, dset16[0]); H5Sclose(space); H5Aclose(attr); @@ -7490,7 +7623,7 @@ gent_attr_intsize(void) val32bits <<= 1; } - H5Awrite(attr, H5T_NATIVE_INT32, dset32); + H5Awrite(attr, H5T_NATIVE_INT32, dset32[0]); H5Sclose(space); H5Aclose(attr); @@ -7508,7 +7641,7 @@ gent_attr_intsize(void) val64bits <<= 1; } - H5Awrite(attr, H5T_NATIVE_INT64, dset64); + H5Awrite(attr, H5T_NATIVE_INT64, dset64[0]); H5Sclose(space); H5Aclose(attr); @@ -7521,13 +7654,23 @@ gent_attr_intsize(void) for(j = 0; j < dims[1]; j++) dsetdbl[i][j] = 0.0001F * (float)j + (float)i; - H5Awrite(attr, H5T_NATIVE_DOUBLE, dsetdbl); + H5Awrite(attr, H5T_NATIVE_DOUBLE, dsetdbl[0]); H5Sclose(space); H5Aclose(attr); H5Gclose(root); H5Fclose(fid); + + HDfree(dsetu8); + HDfree(dsetu16); + HDfree(dsetu32); + HDfree(dsetu64); + HDfree(dset8); + HDfree(dset16); + HDfree(dset32); + HDfree(dset64); + HDfree(dsetdbl); } static void @@ -7962,7 +8105,7 @@ static void gent_compound_attr_intsizes(void) { int64_t dset64[F70_XDIM][F70_YDIM64]; double dsetdbl[F70_XDIM][F70_YDIM8]; } Array1Struct; - Array1Struct Array1[F70_LENGTH]; + Array1Struct *Array1 = NULL; hid_t Array1Structid; /* File datatype identifier */ herr_t H5_ATTR_NDEBUG_UNUSED status; /* Error checking variable */ @@ -7970,6 +8113,8 @@ static void gent_compound_attr_intsizes(void) { int m, n, o; /* Array init loop vars */ + Array1 = (Array1Struct *)HDcalloc(F70_LENGTH, sizeof(Array1Struct)); + /* Initialize the data in the arrays/datastructure */ for (m = 0; m < F70_LENGTH; m++) { @@ -8201,6 +8346,8 @@ static void gent_compound_attr_intsizes(void) { status = H5Fclose(fid); HDassert(status >= 0); + + HDfree(Array1); } static void gent_nested_compound_dt(void) { /* test nested data type */ @@ -8365,19 +8512,44 @@ static void gent_nested_compound_dt(void) { /* test nested data type */ static void gent_intscalars(void) { - hid_t fid, dataset, space, tid; + hid_t fid = H5I_INVALID_HID; + hid_t dataset = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; hsize_t dims[2]; - uint8_t dsetu8[F73_XDIM][F73_YDIM8], valu8bits; - uint16_t dsetu16[F73_XDIM][F73_YDIM16], valu16bits; - uint32_t dsetu32[F73_XDIM][F73_YDIM32], valu32bits; - uint64_t dsetu64[F73_XDIM][F73_YDIM64], valu64bits; - int8_t dset8[F73_XDIM][F73_YDIM8], val8bits; - int16_t dset16[F73_XDIM][F73_YDIM16], val16bits; - int32_t dset32[F73_XDIM][F73_YDIM32], val32bits; - int64_t dset64[F73_XDIM][F73_YDIM64], val64bits; - double dsetdbl[F73_XDIM][F73_YDIM8]; + + uint8_t **dsetu8 = NULL; + uint16_t **dsetu16 = NULL; + uint32_t **dsetu32 = NULL; + uint64_t **dsetu64 = NULL; + int8_t **dset8 = NULL; + int16_t **dset16 = NULL; + int32_t **dset32 = NULL; + int64_t **dset64 = NULL; + double **dsetdbl = NULL; + + uint8_t valu8bits; + uint16_t valu16bits; + uint32_t valu32bits; + uint64_t valu64bits; + int8_t val8bits; + int16_t val16bits; + int32_t val32bits; + int64_t val64bits; + unsigned int i, j; + /* Create arrays */ + H5TEST_ALLOCATE_2D_ARRAY(dsetu8, uint8_t, F73_XDIM, F73_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dsetu16, uint16_t, F73_XDIM, F73_YDIM16); + H5TEST_ALLOCATE_2D_ARRAY(dsetu32, uint32_t, F73_XDIM, F73_YDIM32); + H5TEST_ALLOCATE_2D_ARRAY(dsetu64, uint64_t, F73_XDIM, F73_YDIM64); + H5TEST_ALLOCATE_2D_ARRAY(dset8, int8_t, F73_XDIM, F73_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dset16, int16_t, F73_XDIM, F73_YDIM16); + H5TEST_ALLOCATE_2D_ARRAY(dset32, int32_t, F73_XDIM, F73_YDIM32); + H5TEST_ALLOCATE_2D_ARRAY(dset64, int64_t, F73_XDIM, F73_YDIM64); + H5TEST_ALLOCATE_2D_ARRAY(dsetdbl, double, F73_XDIM, F73_YDIM8); + fid = H5Fcreate(FILE73, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Dataset of 8 bits unsigned int */ @@ -8395,7 +8567,7 @@ gent_intscalars(void) valu8bits = (uint8_t)(valu8bits << 1); } - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu8); + H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu8[0]); H5Sclose(space); H5Dclose(dataset); @@ -8414,7 +8586,7 @@ gent_intscalars(void) valu16bits = (uint16_t)(valu16bits << 1); } - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu16); + H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu16[0]); H5Sclose(space); H5Dclose(dataset); @@ -8433,7 +8605,7 @@ gent_intscalars(void) valu32bits <<= 1; } - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu32); + H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu32[0]); H5Sclose(space); H5Dclose(dataset); @@ -8452,7 +8624,7 @@ gent_intscalars(void) valu64bits <<= 1; } - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu64); + H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu64[0]); H5Sclose(space); H5Dclose(dataset); @@ -8471,7 +8643,7 @@ gent_intscalars(void) val8bits = (int8_t)(val8bits << 1); } - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset8); + H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset8[0]); H5Sclose(space); H5Dclose(dataset); @@ -8490,7 +8662,7 @@ gent_intscalars(void) val16bits = (int16_t)(val16bits << 1); } - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset16); + H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset16[0]); H5Sclose(space); H5Dclose(dataset); @@ -8509,7 +8681,7 @@ gent_intscalars(void) val32bits <<= 1; } - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset32); + H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset32[0]); H5Sclose(space); H5Dclose(dataset); @@ -8528,7 +8700,7 @@ gent_intscalars(void) val64bits <<= 1; } - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset64); + H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset64[0]); H5Sclose(space); H5Dclose(dataset); @@ -8542,11 +8714,21 @@ gent_intscalars(void) for(j = 0; j < dims[1]; j++) dsetdbl[i][j] = 0.0001F * (float)j + (float)i; - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetdbl); + H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetdbl[0]); H5Sclose(space); H5Dclose(dataset); H5Fclose(fid); + + HDfree(dsetu8); + HDfree(dsetu16); + HDfree(dsetu32); + HDfree(dsetu64); + HDfree(dset8); + HDfree(dset16); + HDfree(dset32); + HDfree(dset64); + HDfree(dsetdbl); } /*------------------------------------------------------------------------- @@ -8563,19 +8745,46 @@ gent_intscalars(void) static void gent_attr_intscalars(void) { - hid_t fid, attr, space, root, tid; + hid_t fid = H5I_INVALID_HID; + hid_t attr = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t root = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; hsize_t dims[2]; - uint8_t dsetu8[F73_XDIM][F73_YDIM8], valu8bits; - uint16_t dsetu16[F73_XDIM][F73_YDIM16], valu16bits; - uint32_t dsetu32[F73_XDIM][F73_YDIM32], valu32bits; - uint64_t dsetu64[F73_XDIM][F73_YDIM64], valu64bits; - int8_t dset8[F73_XDIM][F73_YDIM8], val8bits; - int16_t dset16[F73_XDIM][F73_YDIM16], val16bits; - int32_t dset32[F73_XDIM][F73_YDIM32], val32bits; - int64_t dset64[F73_XDIM][F73_YDIM64], val64bits; - double dsetdbl[F73_XDIM][F73_YDIM8]; + + + uint8_t **dsetu8 = NULL; + uint16_t **dsetu16 = NULL; + uint32_t **dsetu32 = NULL; + uint64_t **dsetu64 = NULL; + int8_t **dset8 = NULL; + int16_t **dset16 = NULL; + int32_t **dset32 = NULL; + int64_t **dset64 = NULL; + double **dsetdbl = NULL; + + uint8_t valu8bits; + uint16_t valu16bits; + uint32_t valu32bits; + uint64_t valu64bits; + int8_t val8bits; + int16_t val16bits; + int32_t val32bits; + int64_t val64bits; + unsigned int i, j; + /* Create arrays */ + H5TEST_ALLOCATE_2D_ARRAY(dsetu8, uint8_t, F73_XDIM, F73_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dsetu16, uint16_t, F73_XDIM, F73_YDIM16); + H5TEST_ALLOCATE_2D_ARRAY(dsetu32, uint32_t, F73_XDIM, F73_YDIM32); + H5TEST_ALLOCATE_2D_ARRAY(dsetu64, uint64_t, F73_XDIM, F73_YDIM64); + H5TEST_ALLOCATE_2D_ARRAY(dset8, int8_t, F73_XDIM, F73_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dset16, int16_t, F73_XDIM, F73_YDIM16); + H5TEST_ALLOCATE_2D_ARRAY(dset32, int32_t, F73_XDIM, F73_YDIM32); + H5TEST_ALLOCATE_2D_ARRAY(dset64, int64_t, F73_XDIM, F73_YDIM64); + H5TEST_ALLOCATE_2D_ARRAY(dsetdbl, double, F73_XDIM, F73_YDIM8); + fid = H5Fcreate(FILE74, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); root = H5Gopen2(fid, "/", H5P_DEFAULT); @@ -8594,7 +8803,7 @@ gent_attr_intscalars(void) valu8bits = (uint8_t)(valu8bits << 1); } - H5Awrite(attr, tid, dsetu8); + H5Awrite(attr, tid, dsetu8[0]); H5Sclose(space); H5Aclose(attr); @@ -8613,7 +8822,7 @@ gent_attr_intscalars(void) valu16bits = (uint16_t)(valu16bits << 1); } - H5Awrite(attr, tid, dsetu16); + H5Awrite(attr, tid, dsetu16[0]); H5Sclose(space); H5Aclose(attr); @@ -8632,7 +8841,7 @@ gent_attr_intscalars(void) valu32bits <<= 1; } - H5Awrite(attr, tid, dsetu32); + H5Awrite(attr, tid, dsetu32[0]); H5Sclose(space); H5Aclose(attr); @@ -8651,7 +8860,7 @@ gent_attr_intscalars(void) valu64bits <<= 1; } - H5Awrite(attr, tid, dsetu64); + H5Awrite(attr, tid, dsetu64[0]); H5Sclose(space); H5Aclose(attr); @@ -8670,7 +8879,7 @@ gent_attr_intscalars(void) val8bits = (int8_t)(val8bits << 1); } - H5Awrite(attr, tid, dset8); + H5Awrite(attr, tid, dset8[0]); H5Sclose(space); H5Aclose(attr); @@ -8689,7 +8898,7 @@ gent_attr_intscalars(void) val16bits = (int16_t)(val16bits << 1); } - H5Awrite(attr, tid, dset16); + H5Awrite(attr, tid, dset16[0]); H5Sclose(space); H5Aclose(attr); @@ -8708,7 +8917,7 @@ gent_attr_intscalars(void) val32bits <<= 1; } - H5Awrite(attr, tid, dset32); + H5Awrite(attr, tid, dset32[0]); H5Sclose(space); H5Aclose(attr); @@ -8727,7 +8936,7 @@ gent_attr_intscalars(void) val64bits <<= 1; } - H5Awrite(attr, tid, dset64); + H5Awrite(attr, tid, dset64[0]); H5Sclose(space); H5Aclose(attr); @@ -8741,13 +8950,23 @@ gent_attr_intscalars(void) for(j = 0; j < dims[1]; j++) dsetdbl[i][j] = 0.0001F * (float)j + (float)i; - H5Awrite(attr, tid, dsetdbl); + H5Awrite(attr, tid, dsetdbl[0]); H5Sclose(space); H5Aclose(attr); H5Gclose(root); H5Fclose(fid); + + HDfree(dsetu8); + HDfree(dsetu16); + HDfree(dsetu32); + HDfree(dsetu64); + HDfree(dset8); + HDfree(dset16); + HDfree(dset32); + HDfree(dset64); + HDfree(dsetdbl); } /*------------------------------------------------------------------------- @@ -9302,19 +9521,45 @@ static void gent_compound_ints(void) { static void gent_intattrscalars(void) { - hid_t fid, attr, dataset, space, tid; + hid_t fid = H5I_INVALID_HID; + hid_t attr = H5I_INVALID_HID; + hid_t dataset = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; hsize_t dims[2]; - uint8_t dsetu8[F73_XDIM][F73_YDIM8], valu8bits; - uint16_t dsetu16[F73_XDIM][F73_YDIM16], valu16bits; - uint32_t dsetu32[F73_XDIM][F73_YDIM32], valu32bits; - uint64_t dsetu64[F73_XDIM][F73_YDIM64], valu64bits; - int8_t dset8[F73_XDIM][F73_YDIM8], val8bits; - int16_t dset16[F73_XDIM][F73_YDIM16], val16bits; - int32_t dset32[F73_XDIM][F73_YDIM32], val32bits; - int64_t dset64[F73_XDIM][F73_YDIM64], val64bits; - double dsetdbl[F73_XDIM][F73_YDIM8]; + + uint8_t **dsetu8 = NULL; + uint16_t **dsetu16 = NULL; + uint32_t **dsetu32 = NULL; + uint64_t **dsetu64 = NULL; + int8_t **dset8 = NULL; + int16_t **dset16 = NULL; + int32_t **dset32 = NULL; + int64_t **dset64 = NULL; + double **dsetdbl = NULL; + + uint8_t valu8bits; + uint16_t valu16bits; + uint32_t valu32bits; + uint64_t valu64bits; + int8_t val8bits; + int16_t val16bits; + int32_t val32bits; + int64_t val64bits; + unsigned int i, j; + /* Create arrays */ + H5TEST_ALLOCATE_2D_ARRAY(dsetu8, uint8_t, F73_XDIM, F73_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dsetu16, uint16_t, F73_XDIM, F73_YDIM16); + H5TEST_ALLOCATE_2D_ARRAY(dsetu32, uint32_t, F73_XDIM, F73_YDIM32); + H5TEST_ALLOCATE_2D_ARRAY(dsetu64, uint64_t, F73_XDIM, F73_YDIM64); + H5TEST_ALLOCATE_2D_ARRAY(dset8, int8_t, F73_XDIM, F73_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dset16, int16_t, F73_XDIM, F73_YDIM16); + H5TEST_ALLOCATE_2D_ARRAY(dset32, int32_t, F73_XDIM, F73_YDIM32); + H5TEST_ALLOCATE_2D_ARRAY(dset64, int64_t, F73_XDIM, F73_YDIM64); + H5TEST_ALLOCATE_2D_ARRAY(dsetdbl, double, F73_XDIM, F73_YDIM8); + fid = H5Fcreate(FILE78, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Dataset of 8 bits unsigned int */ @@ -9335,7 +9580,7 @@ gent_intattrscalars(void) H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu8); /* Attribute of 8 bits unsigned int */ attr = H5Acreate2(dataset, F73_DATASETU08, tid, space, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, tid, dsetu8); + H5Awrite(attr, tid, dsetu8[0]); H5Aclose(attr); H5Sclose(space); H5Dclose(dataset); @@ -9358,7 +9603,7 @@ gent_intattrscalars(void) H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu16); /* Attribute of 16 bits unsigned int */ attr = H5Acreate2(dataset, F73_DATASETU16, tid, space, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, tid, dsetu16); + H5Awrite(attr, tid, dsetu16[0]); H5Aclose(attr); H5Sclose(space); H5Dclose(dataset); @@ -9381,7 +9626,7 @@ gent_intattrscalars(void) H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu32); /* Attribute of 32 bits unsigned int */ attr = H5Acreate2(dataset, F73_DATASETU32, tid, space, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, tid, dsetu32); + H5Awrite(attr, tid, dsetu32[0]); H5Aclose(attr); H5Sclose(space); H5Dclose(dataset); @@ -9404,7 +9649,7 @@ gent_intattrscalars(void) H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu64); /* Attribute of 64 bits unsigned int */ attr = H5Acreate2(dataset, F73_DATASETU64, tid, space, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, tid, dsetu64); + H5Awrite(attr, tid, dsetu64[0]); H5Aclose(attr); H5Sclose(space); H5Dclose(dataset); @@ -9427,7 +9672,7 @@ gent_intattrscalars(void) H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset8); /* Attribute of 8 bits signed int */ attr = H5Acreate2(dataset, F73_DATASETS08, tid, space, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, tid, dset8); + H5Awrite(attr, tid, dset8[0]); H5Aclose(attr); H5Sclose(space); H5Dclose(dataset); @@ -9450,7 +9695,7 @@ gent_intattrscalars(void) H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset16); /* Attribute of 16 bits signed int */ attr = H5Acreate2(dataset, F73_DATASETS16, tid, space, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, tid, dset16); + H5Awrite(attr, tid, dset16[0]); H5Aclose(attr); H5Sclose(space); H5Dclose(dataset); @@ -9473,7 +9718,7 @@ gent_intattrscalars(void) H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset32); /* Attribute of 32 bits signed int */ attr = H5Acreate2(dataset, F73_DATASETS32, tid, space, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, tid, dset32); + H5Awrite(attr, tid, dset32[0]); H5Aclose(attr); H5Sclose(space); H5Dclose(dataset); @@ -9496,7 +9741,7 @@ gent_intattrscalars(void) H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset64); /* Attribute of 64 bits signed int */ attr = H5Acreate2(dataset, F73_DATASETS64, tid, space, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, tid, dset64); + H5Awrite(attr, tid, dset64[0]); H5Aclose(attr); H5Sclose(space); H5Dclose(dataset); @@ -9514,11 +9759,22 @@ gent_intattrscalars(void) H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetdbl); /* Attribute of double */ attr = H5Acreate2(dataset, F73_DUMMYDBL, tid, space, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, tid, dsetdbl); + H5Awrite(attr, tid, dsetdbl[0]); + H5Aclose(attr); H5Sclose(space); H5Dclose(dataset); H5Fclose(fid); + + HDfree(dsetu8); + HDfree(dsetu16); + HDfree(dsetu32); + HDfree(dsetu64); + HDfree(dset8); + HDfree(dset16); + HDfree(dset32); + HDfree(dset64); + HDfree(dsetdbl); } /*------------------------------------------------------------------------- @@ -9534,19 +9790,66 @@ gent_intattrscalars(void) static void gent_intsattrs(void) { - hid_t fid, attr, dataset, space, aspace; + hid_t fid = H5I_INVALID_HID; + hid_t attr = H5I_INVALID_HID; + hid_t dataset = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t aspace = H5I_INVALID_HID; hsize_t dims[2], adims[1]; - uint8_t dsetu8[F66_XDIM][F66_YDIM8], asetu8[F66_XDIM*F66_YDIM8], valu8bits; - uint16_t dsetu16[F66_XDIM][F66_YDIM16], asetu16[F66_XDIM*F66_YDIM16], valu16bits; - uint32_t dsetu32[F66_XDIM][F66_YDIM32], asetu32[F66_XDIM*F66_YDIM32], valu32bits; - uint64_t dsetu64[F66_XDIM][F66_YDIM64], asetu64[F66_XDIM*F66_YDIM64], valu64bits; - int8_t dset8[F66_XDIM][F66_YDIM8], aset8[F66_XDIM*F66_YDIM8], val8bits; - int16_t dset16[F66_XDIM][F66_YDIM16], aset16[F66_XDIM*F66_YDIM16], val16bits; - int32_t dset32[F66_XDIM][F66_YDIM32], aset32[F66_XDIM*F66_YDIM32], val32bits; - int64_t dset64[F66_XDIM][F66_YDIM64], aset64[F66_XDIM*F66_YDIM64], val64bits; - double dsetdbl[F66_XDIM][F66_YDIM8], asetdbl[F66_XDIM*F66_YDIM8]; + + + uint8_t **dsetu8 = NULL; + uint16_t **dsetu16 = NULL; + uint32_t **dsetu32 = NULL; + uint64_t **dsetu64 = NULL; + int8_t **dset8 = NULL; + int16_t **dset16 = NULL; + int32_t **dset32 = NULL; + int64_t **dset64 = NULL; + double **dsetdbl = NULL; + + uint8_t *asetu8 = NULL; + uint16_t *asetu16 = NULL; + uint32_t *asetu32 = NULL; + uint64_t *asetu64 = NULL; + int8_t *aset8 = NULL; + int16_t *aset16 = NULL; + int32_t *aset32 = NULL; + int64_t *aset64 = NULL; + double *asetdbl = NULL; + + uint8_t valu8bits; + uint16_t valu16bits; + uint32_t valu32bits; + uint64_t valu64bits; + int8_t val8bits; + int16_t val16bits; + int32_t val32bits; + int64_t val64bits; + unsigned int i, j; + /* Create arrays */ + H5TEST_ALLOCATE_2D_ARRAY(dsetu8, uint8_t, F66_XDIM, F66_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dsetu16, uint16_t, F66_XDIM, F66_YDIM16); + H5TEST_ALLOCATE_2D_ARRAY(dsetu32, uint32_t, F66_XDIM, F66_YDIM32); + H5TEST_ALLOCATE_2D_ARRAY(dsetu64, uint64_t, F66_XDIM, F66_YDIM64); + H5TEST_ALLOCATE_2D_ARRAY(dset8, int8_t, F66_XDIM, F66_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dset16, int16_t, F66_XDIM, F66_YDIM16); + H5TEST_ALLOCATE_2D_ARRAY(dset32, int32_t, F66_XDIM, F66_YDIM32); + H5TEST_ALLOCATE_2D_ARRAY(dset64, int64_t, F66_XDIM, F66_YDIM64); + H5TEST_ALLOCATE_2D_ARRAY(dsetdbl, double, F66_XDIM, F66_YDIM8); + + asetu8 = HDcalloc(F66_XDIM * F66_YDIM8, sizeof(uint8_t)); + asetu16 = HDcalloc(F66_XDIM * F66_YDIM16, sizeof(uint16_t)); + asetu32 = HDcalloc(F66_XDIM * F66_YDIM32, sizeof(uint32_t)); + asetu64 = HDcalloc(F66_XDIM * F66_YDIM64, sizeof(uint64_t)); + aset8 = HDcalloc(F66_XDIM * F66_YDIM8, sizeof(int8_t)); + aset16 = HDcalloc(F66_XDIM * F66_YDIM16, sizeof(int16_t)); + aset32 = HDcalloc(F66_XDIM * F66_YDIM32, sizeof(int32_t)); + aset64 = HDcalloc(F66_XDIM * F66_YDIM64, sizeof(int64_t)); + asetdbl = HDcalloc(F66_XDIM * F66_YDIM8, sizeof(double)); + fid = H5Fcreate(FILE79, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Dataset of 8 bits unsigned int */ @@ -9565,7 +9868,7 @@ gent_intsattrs(void) valu8bits = (uint8_t)(valu8bits << 1); } - H5Dwrite(dataset, H5T_NATIVE_UINT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu8); + H5Dwrite(dataset, H5T_NATIVE_UINT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu8[0]); /* Attribute of 8 bits unsigned int */ adims[0] = F66_XDIM * F66_YDIM8; aspace = H5Screate_simple(1, adims, NULL); @@ -9592,7 +9895,7 @@ gent_intsattrs(void) valu16bits = (uint16_t)(valu16bits << 1); } - H5Dwrite(dataset, H5T_NATIVE_UINT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu16); + H5Dwrite(dataset, H5T_NATIVE_UINT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu16[0]); /* Attribute of 16 bits unsigned int */ adims[0] = F66_XDIM * F66_YDIM16; aspace = H5Screate_simple(1, adims, NULL); @@ -9619,7 +9922,7 @@ gent_intsattrs(void) valu32bits <<= 1; } - H5Dwrite(dataset, H5T_NATIVE_UINT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu32); + H5Dwrite(dataset, H5T_NATIVE_UINT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu32[0]); /* Attribute of 32 bits unsigned int */ adims[0] = F66_XDIM * F66_YDIM32; aspace = H5Screate_simple(1, adims, NULL); @@ -9646,7 +9949,7 @@ gent_intsattrs(void) valu64bits <<= 1; } - H5Dwrite(dataset, H5T_NATIVE_UINT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu64); + H5Dwrite(dataset, H5T_NATIVE_UINT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu64[0]); /* Attribute of 64 bits unsigned int */ adims[0] = F66_XDIM * F66_YDIM64; aspace = H5Screate_simple(1, adims, NULL); @@ -9673,7 +9976,7 @@ gent_intsattrs(void) val8bits = (int8_t)(val8bits << 1); } - H5Dwrite(dataset, H5T_NATIVE_INT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset8); + H5Dwrite(dataset, H5T_NATIVE_INT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset8[0]); /* Attribute of 8 bits signed int */ adims[0] = F66_XDIM * F66_YDIM8; aspace = H5Screate_simple(1, adims, NULL); @@ -9700,7 +10003,7 @@ gent_intsattrs(void) val16bits = (int16_t)(val16bits << 1); } - H5Dwrite(dataset, H5T_NATIVE_INT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset16); + H5Dwrite(dataset, H5T_NATIVE_INT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset16[0]); /* Attribute of 16 bits signed int */ adims[0] = F66_XDIM * F66_YDIM16; aspace = H5Screate_simple(1, adims, NULL); @@ -9727,7 +10030,7 @@ gent_intsattrs(void) val32bits <<= 1; } - H5Dwrite(dataset, H5T_NATIVE_INT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset32); + H5Dwrite(dataset, H5T_NATIVE_INT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset32[0]); /* Attribute of 32 bits signed int */ adims[0] = F66_XDIM * F66_YDIM32; aspace = H5Screate_simple(1, adims, NULL); @@ -9754,7 +10057,7 @@ gent_intsattrs(void) val64bits <<= 1; } - H5Dwrite(dataset, H5T_NATIVE_INT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset64); + H5Dwrite(dataset, H5T_NATIVE_INT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset64[0]); /* Attribute of 64 bits signed int */ adims[0] = F66_XDIM * F66_YDIM64; aspace = H5Screate_simple(1, adims, NULL); @@ -9776,7 +10079,7 @@ gent_intsattrs(void) asetdbl[i*dims[1]+j] = dsetdbl[i][j]; } - H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetdbl); + H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetdbl[0]); /* Attribute of double */ adims[0] = F66_XDIM * F66_YDIM8; aspace = H5Screate_simple(1, adims, NULL); @@ -9787,6 +10090,26 @@ gent_intsattrs(void) H5Sclose(space); H5Dclose(dataset); H5Fclose(fid); + + HDfree(dsetu8); + HDfree(dsetu16); + HDfree(dsetu32); + HDfree(dsetu64); + HDfree(dset8); + HDfree(dset16); + HDfree(dset32); + HDfree(dset64); + HDfree(dsetdbl); + + HDfree(asetu8); + HDfree(asetu16); + HDfree(asetu32); + HDfree(asetu64); + HDfree(aset8); + HDfree(aset16); + HDfree(aset32); + HDfree(aset64); + HDfree(asetdbl); } static void gent_bitnopaquefields(void) diff --git a/tools/test/h5format_convert/h5fc_chk_idx.c b/tools/test/h5format_convert/h5fc_chk_idx.c index 570e3a1..2fbbec4 100644 --- a/tools/test/h5format_convert/h5fc_chk_idx.c +++ b/tools/test/h5format_convert/h5fc_chk_idx.c @@ -60,7 +60,7 @@ main(int argc, char *argv[]) dname = HDstrdup(argv[2]); /* Try opening the file */ - if((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0) { + if((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, FALSE, NULL, (size_t)0)) < 0) { HDfprintf(stderr, "h5fc_chk_idx: unable to open the file\n"); HDexit(EXIT_FAILURE); } /* end if */ diff --git a/tools/test/h5format_convert/testfiles/h5fc_v_err.ddl.err b/tools/test/h5format_convert/testfiles/h5fc_v_err.ddl.err index d85a999..e72892d 100644 --- a/tools/test/h5format_convert/testfiles/h5fc_v_err.ddl.err +++ b/tools/test/h5format_convert/testfiles/h5fc_v_err.ddl.err @@ -1,8 +1 @@ h5format_convert error: unable to downgrade dataset "/DSET_ERR" -H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5trav_visit(): traverse failed - major: Failure in tools library - minor: error in function - #001: (file name) line (number) in traverse(): H5Lvisit_by_name failed - major: Failure in tools library - minor: error in function diff --git a/tools/test/h5import/h5importtest.c b/tools/test/h5import/h5importtest.c index 560f1b3..580530a 100644 --- a/tools/test/h5import/h5importtest.c +++ b/tools/test/h5import/h5importtest.c @@ -68,13 +68,12 @@ main(void) double rowi8 = 1.0F, coli8 = 2.0F, plni8 = 5.0F; /* Initialize machine endian */ - volatile uint32_t ibyte=0x01234567; + volatile uint32_t ibyte = 0x01234567; /* 0 for big endian, 1 for little endian. */ - if ((*((uint8_t*)(&ibyte))) == 0x67) - HDstrncpy(machine_order, "LE", 2); + if ((*((volatile uint8_t *)(&ibyte))) == 0x67) + HDstrcpy(machine_order, "LE"); else - HDstrncpy(machine_order, "BE", 2); - + HDstrcpy(machine_order, "BE"); /* * initialize the row, column, and plane vectors diff --git a/tools/test/h5jam/tellub.c b/tools/test/h5jam/tellub.c index 559c677..453444d 100644 --- a/tools/test/h5jam/tellub.c +++ b/tools/test/h5jam/tellub.c @@ -70,11 +70,12 @@ parse_command_line (int argc, const char *argv[]) switch ((char) opt) { case 'h': usage (h5tools_getprogname()); - HDexit(EXIT_SUCCESS); + h5tools_setstatus(EXIT_SUCCESS); + break; case '?': default: usage (h5tools_getprogname()); - HDexit(EXIT_FAILURE); + h5tools_setstatus(EXIT_FAILURE); } } @@ -82,10 +83,17 @@ parse_command_line (int argc, const char *argv[]) if (argc <= opt_ind) { error_msg("missing file name\n"); usage (h5tools_getprogname()); - HDexit(EXIT_FAILURE); + h5tools_setstatus(EXIT_FAILURE); } } /* end parse_command_line() */ +static void +leave(int ret) +{ + h5tools_close(); + HDexit(ret); +} + /*------------------------------------------------------------------------- * Function: main * @@ -98,9 +106,7 @@ int main (int argc, const char *argv[]) { char *ifname; - void *edata; - H5E_auto2_t func; - hid_t ifile; + hid_t ifile = H5I_INVALID_HID; hsize_t usize; htri_t testval; herr_t status; @@ -112,16 +118,16 @@ main (int argc, const char *argv[]) /* Initialize h5tools lib */ h5tools_init(); - /* Disable error reporting */ - H5Eget_auto2(H5E_DEFAULT, &func, &edata); - H5Eset_auto2(H5E_DEFAULT, NULL, NULL); - parse_command_line(argc, argv); + /* enable error reporting if command line option */ + h5tools_error_report(); + if(argc <= (opt_ind)) { error_msg("missing file name\n"); usage (h5tools_getprogname()); - return EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); + goto done; } ifname = HDstrdup(argv[opt_ind]); @@ -130,33 +136,39 @@ main (int argc, const char *argv[]) if(testval <= 0) { error_msg("Input HDF5 file is not HDF \"%s\"\n", ifname); - return EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); + goto done; } ifile = H5Fopen(ifname, H5F_ACC_RDONLY, H5P_DEFAULT); if(ifile < 0) { error_msg("Can't open input HDF5 file \"%s\"\n", ifname); - return EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); + goto done; } plist = H5Fget_create_plist(ifile); if(plist < 0) { error_msg("Can't get file creation plist for file \"%s\"\n", ifname); - return EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); + goto done; } status = H5Pget_userblock(plist, &usize); if(status < 0) { error_msg("Can't get user block for file \"%s\"\n", ifname); - return EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); + goto done; } HDprintf("%ld\n", (long) usize); +done: H5Pclose (plist); - H5Fclose (ifile); + if(ifile >= 0) + H5Fclose (ifile); - return EXIT_SUCCESS; + leave(h5tools_getstatus()); } /* end main() */ diff --git a/tools/test/h5repack/CMakeLists.txt b/tools/test/h5repack/CMakeLists.txt index 6f0b284..54cff64 100644 --- a/tools/test/h5repack/CMakeLists.txt +++ b/tools/test/h5repack/CMakeLists.txt @@ -28,7 +28,7 @@ set (REPACK_COMMON_SOURCES ) add_executable (h5repacktest ${REPACK_COMMON_SOURCES} ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/h5repacktst.c) target_include_directories (h5repacktest - PRIVATE "${HDF5_TOOLS_SRC_H5REPACK_SOURCE_DIR};${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" + PRIVATE "${HDF5_TOOLS_SRC_H5REPACK_SOURCE_DIR};${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_TEST_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" ) if (NOT ONLY_SHARED_LIBS) TARGET_C_PROPERTIES (h5repacktest STATIC) diff --git a/tools/test/h5repack/CMakeTests.cmake b/tools/test/h5repack/CMakeTests.cmake index 027b49f..4823d07 100644 --- a/tools/test/h5repack/CMakeTests.cmake +++ b/tools/test/h5repack/CMakeTests.cmake @@ -662,7 +662,7 @@ COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" - -D "TEST_ARGS:STRING=${testfile};out-${testname}_N.${testname}.h5" + -D "TEST_ARGS:STRING=-v;${testfile};out-${testname}_N.${testname}.h5" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" -D "TEST_OUTPUT=out-${testname}_N.${testname}.out" -D "TEST_EXPECT=0" @@ -684,7 +684,7 @@ COMMAND "${CMAKE_COMMAND}" -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$" - -D "TEST_ARGS:STRING=${testfile};out-${testname}_M.${testname}.h5" + -D "TEST_ARGS:STRING=-v;${testfile};out-${testname}_M.${testname}.h5" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" -D "TEST_OUTPUT=out-${testname}_M.${testname}.out" -D "TEST_EXPECT=0" diff --git a/tools/test/h5repack/h5repack.sh.in b/tools/test/h5repack/h5repack.sh.in index 6e63136..ad6fef8 100644 --- a/tools/test/h5repack/h5repack.sh.in +++ b/tools/test/h5repack/h5repack.sh.in @@ -745,7 +745,7 @@ TOOLTEST1() TESTING $H5REPACK $@ ( cd $TESTDIR - $RUNSERIAL $H5REPACK_BIN "$@" $infile $outfile + $ENVCMD $RUNSERIAL $H5REPACK_BIN "$@" $infile $outfile ) RET=$? if [ $RET != 0 ] ; then diff --git a/tools/test/h5repack/h5repacktst.c b/tools/test/h5repack/h5repacktst.c index 2654685..ab0dbb7 100644 --- a/tools/test/h5repack/h5repacktst.c +++ b/tools/test/h5repack/h5repacktst.c @@ -382,7 +382,7 @@ int main (void) GOERROR; if (h5repack_verify(FNAME0, FNAME0OUT, &pack_options) <= 0) GOERROR; - if (h5repack_cmp_pl(FNAME0, FNAME0OUT) <= 0) + if (h5repack_cmp_pl(FNAME0, pack_options.fin_fapl, FNAME0OUT, pack_options.fout_fapl) <= 0) GOERROR; if (h5repack_end(&pack_options) < 0) GOERROR; @@ -402,7 +402,7 @@ int main (void) GOERROR; if (h5repack_verify(FNAME1, FNAME1OUT, &pack_options) <= 0) GOERROR; - if (h5repack_cmp_pl(FNAME1, FNAME1OUT) <= 0) + if (h5repack_cmp_pl(FNAME1, pack_options.fin_fapl, FNAME1OUT, pack_options.fout_fapl) <= 0) GOERROR; if (h5repack_end(&pack_options) < 0) GOERROR; @@ -422,7 +422,7 @@ int main (void) GOERROR; if (h5repack_verify(FNAME2, FNAME2OUT, &pack_options) <= 0) GOERROR; - if (h5repack_cmp_pl(FNAME2, FNAME2OUT) <= 0) + if (h5repack_cmp_pl(FNAME2, pack_options.fin_fapl, FNAME2OUT, pack_options.fout_fapl) <= 0) GOERROR; if (h5repack_end(&pack_options) < 0) GOERROR; @@ -441,7 +441,7 @@ int main (void) GOERROR; if (h5repack_verify(FNAME3, FNAME3OUT, &pack_options) <= 0) GOERROR; - if (h5repack_cmp_pl(FNAME3, FNAME3OUT) <= 0) + if (h5repack_cmp_pl(FNAME3, pack_options.fin_fapl, FNAME3OUT, pack_options.fout_fapl) <= 0) GOERROR; if (h5repack_end(&pack_options) < 0) GOERROR; @@ -1132,7 +1132,7 @@ int main (void) GOERROR; if (h5repack_verify(FNAME7, FNAME7OUT, &pack_options) <= 0) GOERROR; - if (h5repack_cmp_pl(FNAME7, FNAME7OUT) <= 0) + if (h5repack_cmp_pl(FNAME7, pack_options.fin_fapl, FNAME7OUT, pack_options.fout_fapl) <= 0) GOERROR; if (h5repack_end(&pack_options) < 0) GOERROR; @@ -2479,24 +2479,24 @@ int make_szip(hid_t loc_id) unsigned szip_pixels_per_block = 8; hsize_t dims[RANK] = {DIM1, DIM2}; hsize_t chunk_dims[RANK] = {CDIM1, CDIM2}; - int buf[DIM1][DIM2]; - int i, j, n; + int **buf = NULL; int szip_can_encode = 0; - for (i = n = 0; i < DIM1; i++) { - for (j = 0; j < DIM2; j++) { - buf[i][j] = n++; - } - } + /* Create and fill array */ + H5TEST_ALLOCATE_2D_ARRAY(buf, int, DIM1, DIM2); + if (NULL == buf) + goto error; + H5TEST_FILL_2D_ARRAY(buf, int, DIM1, DIM2); + /* create a space */ if((sid = H5Screate_simple(RANK, dims, NULL)) < 0) - return -1; + goto error; /* create a dcpl */ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - goto out; + goto error; /* set up chunk */ if(H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) - goto out; + goto error; /*------------------------------------------------------------------------- * SZIP @@ -2509,25 +2509,30 @@ int make_szip(hid_t loc_id) if (szip_can_encode) { /* set szip data */ if(H5Pset_szip (dcpl, szip_options_mask, szip_pixels_per_block) < 0) - goto out; - if (make_dset(loc_id, "dset_szip", sid, dcpl, buf) < 0) - goto out; + goto error; + if (make_dset(loc_id, "dset_szip", sid, dcpl, buf[0]) < 0) + goto error; } else /* WARNING? SZIP is decoder only, can't generate test files */ if(H5Sclose(sid) < 0) - goto out; + goto error; if(H5Pclose(dcpl) < 0) - goto out; + goto error; + + HDfree(buf); return 0; -out: +error: H5E_BEGIN_TRY { H5Pclose(dcpl); H5Sclose(sid); } H5E_END_TRY; + + HDfree(buf); + return -1; } #endif /* H5_HAVE_FILTER_SZIP */ @@ -2548,26 +2553,25 @@ int make_deflate(hid_t loc_id) hid_t sid = H5I_INVALID_HID; /* dataspace ID */ hsize_t dims[RANK] = {DIM1,DIM2}; hsize_t chunk_dims[RANK] = {CDIM1,CDIM2}; - int buf[DIM1][DIM2]; + int **buf = NULL; hobj_ref_t bufref[1]; /* reference */ hsize_t dims1r[1] = {1}; - int i, j, n; - for (i = n = 0; i < DIM1; i++) { - for (j = 0; j < DIM2; j++) { - buf[i][j] = n++; - } - } + /* Create and fill array */ + H5TEST_ALLOCATE_2D_ARRAY(buf, int, DIM1, DIM2); + if (NULL == buf) + goto error; + H5TEST_FILL_2D_ARRAY(buf, int, DIM1, DIM2); /* create a space */ if((sid = H5Screate_simple(RANK, dims, NULL)) < 0) - return -1; + goto error; /* create a dcpl */ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - goto out; + goto error; /* set up chunk */ if(H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) - goto out; + goto error; /*------------------------------------------------------------------------- * GZIP @@ -2576,16 +2580,16 @@ int make_deflate(hid_t loc_id) #if defined (H5_HAVE_FILTER_DEFLATE) /* set deflate data */ if(H5Pset_deflate(dcpl, 9) < 0) - goto out; - if (make_dset(loc_id, "dset_deflate", sid, dcpl, buf) < 0) - goto out; + goto error; + if (make_dset(loc_id, "dset_deflate", sid, dcpl, buf[0]) < 0) + goto error; /* create a reference to the dataset, test second seeep of file for references */ if (H5Rcreate(&bufref[0], loc_id, "dset_deflate", H5R_OBJECT, (hid_t)-1) < 0) - goto out; + goto error; if (write_dset(loc_id, 1, dims1r, "ref", H5T_STD_REF_OBJ, bufref) < 0) - goto out; + goto error; #endif @@ -2594,17 +2598,22 @@ int make_deflate(hid_t loc_id) *------------------------------------------------------------------------- */ if(H5Sclose(sid) < 0) - goto out; + goto error; if(H5Pclose(dcpl) < 0) - goto out; + goto error; + + HDfree(buf); return 0; -out: +error: H5E_BEGIN_TRY { H5Pclose(dcpl); H5Sclose(sid); } H5E_END_TRY; + + HDfree(buf); + return -1; } @@ -2619,29 +2628,27 @@ out: static int make_shuffle(hid_t loc_id) { - hid_t dcpl; /* dataset creation property list */ - hid_t sid; /* dataspace ID */ + hid_t dcpl = H5I_INVALID_HID; /* dataset creation property list */ + hid_t sid = H5I_INVALID_HID; /* dataspace ID */ hsize_t dims[RANK]={DIM1,DIM2}; hsize_t chunk_dims[RANK]={CDIM1,CDIM2}; - int buf[DIM1][DIM2]; - int i, j, n; + int **buf = NULL; + + /* Create and fill array */ + H5TEST_ALLOCATE_2D_ARRAY(buf, int, DIM1, DIM2); + if (NULL == buf) + goto error; + H5TEST_FILL_2D_ARRAY(buf, int, DIM1, DIM2); - for (i=n=0; i) add_executable (h5clear_gentest ${HDF5_TOOLS_TEST_MISC_SOURCE_DIR}/h5clear_gentest.c) - target_include_directories (h5clear_gentest PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") + target_include_directories (h5clear_gentest PRIVATE "${HDF5_SRC_DIR};${HDF5_TEST_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") if (NOT ONLY_SHARED_LIBS) TARGET_C_PROPERTIES (h5clear_gentest STATIC) target_link_libraries (h5clear_gentest PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) diff --git a/tools/test/misc/Makefile.am b/tools/test/misc/Makefile.am index f2d2489..c58ba38 100644 --- a/tools/test/misc/Makefile.am +++ b/tools/test/misc/Makefile.am @@ -21,7 +21,7 @@ include $(top_srcdir)/config/commence.am SUBDIRS=vds # Include src directory -AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/tools/lib +AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/test -I$(top_srcdir)/tools/lib #test scripts and programs TEST_PROG=h5repart_gentest h5clear_gentest talign diff --git a/tools/test/misc/clear_open_chk.c b/tools/test/misc/clear_open_chk.c index 3a61385..7d22ca6 100644 --- a/tools/test/misc/clear_open_chk.c +++ b/tools/test/misc/clear_open_chk.c @@ -53,7 +53,7 @@ main(int argc, char *argv[]) fname = HDstrdup(argv[1]); /* Try opening the file */ - if((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0) { + if((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, FALSE, NULL, (size_t)0)) < 0) { HDfprintf(stderr, "clear_open_chk: unable to open the file\n"); HDfree(fname); HDexit(EXIT_FAILURE); diff --git a/tools/test/misc/h5clear_gentest.c b/tools/test/misc/h5clear_gentest.c index d5f415e..8d6883c 100644 --- a/tools/test/misc/h5clear_gentest.c +++ b/tools/test/misc/h5clear_gentest.c @@ -11,7 +11,7 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "hdf5.h" -#include "H5private.h" +#include "h5test.h" /* The HDF5 test files */ const char *FILENAME[] = { @@ -62,13 +62,21 @@ gen_cache_image_file(const char *fname) hid_t dcpl = H5I_INVALID_HID; /* Dataset creation property list */ hsize_t dims[2]; /* Dimension sizes */ hsize_t chunks[2]; /* Chunked dimension sizes */ - int buf[50][100]; /* Buffer for data to write */ int i, j; /* Local index variables */ + int **buf = NULL; /* Buffer for data to write */ H5AC_cache_image_config_t cache_image_config = /* Cache image input configuration */ { H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION, TRUE, FALSE, H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE}; + /* Create and fill array */ + H5TEST_ALLOCATE_2D_ARRAY(buf, int, 50, 100); + if (NULL == buf) + goto error; + for(i = 0; i < 50; i++) + for(j = 0; j < 100; j++) + buf[i][j] = i * j; + /* Create a copy of file access property list */ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; @@ -91,11 +99,6 @@ gen_cache_image_file(const char *fname) if((sid = H5Screate_simple(2, dims, NULL)) < 0) goto error; - /* Initialize buffer for writing to dataset */ - for(i = 0; i < 50; i++) - for(j = 0; j < 100; j++) - buf[i][j] = i * j; - /* Set up to create a chunked dataset */ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; @@ -107,7 +110,7 @@ gen_cache_image_file(const char *fname) goto error; /* Write to the dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) goto error; /* Closing */ @@ -121,6 +124,9 @@ gen_cache_image_file(const char *fname) goto error; if(H5Fclose(fid) < 0) goto error; + + HDfree(buf); + return 0; error: @@ -132,6 +138,9 @@ error: H5Pclose(fapl); H5Pclose(dcpl); } H5E_END_TRY; + + HDfree(buf); + return 1; } /* gen_cache_image_file() */ diff --git a/tools/test/misc/testfiles/h5mkgrp_help.txt b/tools/test/misc/testfiles/h5mkgrp_help.txt index ba130f6..9525230 100644 --- a/tools/test/misc/testfiles/h5mkgrp_help.txt +++ b/tools/test/misc/testfiles/h5mkgrp_help.txt @@ -5,3 +5,10 @@ usage: h5mkgrp [OPTIONS] FILE GROUP... -p, --parents No error if existing, make parent groups as needed -v, --verbose Print information about OBJECTS and OPTIONS -V, --version Print version number and exit + --vol-value Value (ID) of the VOL connector to use for opening the + HDF5 file specified + --vol-name Name of the VOL connector to use for opening the + HDF5 file specified + --vol-info VOL-specific info to pass to the VOL connector used for + opening the HDF5 file specified + diff --git a/tools/test/perform/CMakeLists.txt b/tools/test/perform/CMakeLists.txt index 6780c06..3c45e85 100644 --- a/tools/test/perform/CMakeLists.txt +++ b/tools/test/perform/CMakeLists.txt @@ -78,7 +78,7 @@ set (chunk_cache_SOURCES ${HDF5_TOOLS_TEST_PERFORM_SOURCE_DIR}/chunk_cache.c ) add_executable (chunk_cache ${chunk_cache_SOURCES}) -target_include_directories (chunk_cache PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") +target_include_directories (chunk_cache PRIVATE "${HDF5_TEST_SRC_DIR};${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (chunk_cache STATIC) target_link_libraries (chunk_cache PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) diff --git a/tools/test/perform/chunk_cache.c b/tools/test/perform/chunk_cache.c index e594e34..d7c56af 100644 --- a/tools/test/perform/chunk_cache.c +++ b/tools/test/perform/chunk_cache.c @@ -19,6 +19,7 @@ */ #include "hdf5.h" #include "H5private.h" +#include "h5test.h" #define FILENAME "chunk_cache_perf.h5" @@ -79,18 +80,6 @@ counter (unsigned H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, } /*---------------------------------------------------------------------------*/ -static double retrieve_time(void) -{ -#ifdef H5_HAVE_GETTIMEOFDAY - struct timeval t; - HDgettimeofday(&t, NULL); - return ((double)t.tv_sec + (double)t.tv_usec / 1000000); -#else - return 0.0; -#endif -} - -/*---------------------------------------------------------------------------*/ static void cleanup (void) { @@ -110,8 +99,7 @@ static int create_dset1(hid_t file) hid_t dcpl = H5I_INVALID_HID; hsize_t dims[RANK] = {DSET1_DIM1, DSET1_DIM2}; hsize_t chunk_dims[RANK] = {CHUNK1_DIM1, CHUNK1_DIM2}; - int data[DSET1_DIM1][DSET1_DIM2]; /* data for writing */ - int i, j; + int **data; /* data for writing */ /* Create the data space. */ if((dataspace = H5Screate_simple (RANK, dims, NULL)) < 0) @@ -135,9 +123,10 @@ static int create_dset1(hid_t file) H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - for (i = 0; i < DSET1_DIM1; i++) - for (j = 0; j < DSET1_DIM2; j++) - data[i][j] = i+j; + /* Create & fill array */ + H5TEST_ALLOCATE_2D_ARRAY(data, int, DSET1_DIM1, DSET1_DIM2); + H5TEST_FILL_2D_ARRAY(data, int, DSET1_DIM1, DSET1_DIM2); + /* Write data to dataset */ if(H5Dwrite (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, @@ -171,17 +160,16 @@ static int create_dset2(hid_t file) hid_t dcpl = H5I_INVALID_HID; hsize_t dims[RANK] = {DSET2_DIM1, DSET2_DIM2}; hsize_t chunk_dims[RANK] = {CHUNK2_DIM1, CHUNK2_DIM2}; - int data[DSET2_DIM1][DSET2_DIM2]; /* data for writing */ - int i, j; + int **data; /* data for writing */ /* Create the data space. */ - if((dataspace = H5Screate_simple (RANK, dims, NULL)) < 0) + if((dataspace = H5Screate_simple(RANK, dims, NULL)) < 0) goto error; /* Modify dataset creation properties, i.e. enable chunking */ - if((dcpl = H5Pcreate (H5P_DATASET_CREATE)) < 0) + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk (dcpl, RANK, chunk_dims) < 0) + if(H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) goto error; /* Set the dummy filter simply for counting the number of bytes being read into the memory */ @@ -191,35 +179,35 @@ static int create_dset2(hid_t file) goto error; /* Create a new dataset within the file using chunk creation properties. */ - if((dataset = H5Dcreate2 (file, DSET2_NAME, H5T_NATIVE_INT, dataspace, + if((dataset = H5Dcreate2(file, DSET2_NAME, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - for (i = 0; i < DSET2_DIM1; i++) - for (j = 0; j < DSET2_DIM2; j++) - data[i][j] = i+j; + /* Create & fill array */ + H5TEST_ALLOCATE_2D_ARRAY(data, int, DSET2_DIM1, DSET2_DIM2); + H5TEST_FILL_2D_ARRAY(data, int, DSET2_DIM1, DSET2_DIM2); /* Write data to dataset */ - if(H5Dwrite (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, data) < 0) + if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) goto error; /* Close resources */ - H5Dclose (dataset); - H5Pclose (dcpl); - H5Sclose (dataspace); + H5Dclose(dataset); + H5Pclose(dcpl); + H5Sclose(dataspace); return 0; error: H5E_BEGIN_TRY { - H5Dclose (dataset); - H5Pclose (dcpl); - H5Sclose (dataspace); + H5Dclose(dataset); + H5Pclose(dcpl); + H5Sclose(dataspace); } H5E_END_TRY; return 1; } + /*--------------------------------------------------------------------------- * Check the performance of the chunk cache when partial chunks exist * along the dataset dimensions. @@ -253,7 +241,7 @@ static int check_partial_chunks_perf(hid_t file) nbytes_global = 0; - start_t = retrieve_time(); + start_t = H5_get_time(); /* Read the data row by row */ for(i = 0; i < DSET1_DIM1; i++) { @@ -267,13 +255,12 @@ static int check_partial_chunks_perf(hid_t file) goto error; } - end_t = retrieve_time(); + end_t = H5_get_time(); -#ifdef H5_HAVE_GETTIMEOFDAY - printf("1. Partial chunks: total read time is %lf; number of bytes being read from file is %lu\n", (end_t -start_t), nbytes_global); -#else - printf("1. Partial chunks: no total read time because gettimeofday() is not available; number of bytes being read from file is %lu\n", nbytes_global); -#endif + if((end_t - start_t) > (double)0.0f) + printf("1. Partial chunks: total read time is %lf; number of bytes being read from file is %lu\n", (end_t -start_t), nbytes_global); + else + printf("1. Partial chunks: no total read time because timer is not available; number of bytes being read from file is %lu\n", nbytes_global); H5Dclose (dataset); H5Sclose (filespace); @@ -328,7 +315,7 @@ static int check_hash_value_perf(hid_t file) nbytes_global = 0; - start_t = retrieve_time(); + start_t = H5_get_time(); /* Read the data column by column */ for(i = 0; i < DSET2_DIM2; i++) { @@ -342,13 +329,12 @@ static int check_hash_value_perf(hid_t file) goto error; } - end_t = retrieve_time(); + end_t = H5_get_time(); -#ifdef H5_HAVE_GETTIMEOFDAY - printf("2. Hash value: total read time is %lf; number of bytes being read from file is %lu\n", (end_t -start_t), nbytes_global); -#else - printf("2. Hash value: no total read time because gettimeofday() is not available; number of bytes being read from file is %lu\n", nbytes_global); -#endif + if((end_t - start_t) > (double)0.0f) + printf("2. Hash value: total read time is %lf; number of bytes being read from file is %lu\n", (end_t -start_t), nbytes_global); + else + printf("2. Hash value: no total read time because timer is not available; number of bytes being read from file is %lu\n", nbytes_global); H5Dclose (dataset); H5Sclose (filespace); diff --git a/tools/test/perform/iopipe.c b/tools/test/perform/iopipe.c index bf4728d..de56281 100644 --- a/tools/test/perform/iopipe.c +++ b/tools/test/perform/iopipe.c @@ -21,10 +21,6 @@ #include "H5private.h" -#ifdef H5_HAVE_SYS_TIMEB -#include -#endif - #define RAW_FILE_NAME "iopipe.raw" #define HDF5_FILE_NAME "iopipe.h5" @@ -56,25 +52,18 @@ * Programmer: Robb Matzke * Thursday, March 12, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ -#ifdef H5_HAVE_GETRUSAGE static void -print_stats (const char *prefix, +print_stats(const char *prefix, +#ifdef H5_HAVE_GETRUSAGE struct rusage *r_start, struct rusage *r_stop, - struct timeval *t_start, struct timeval *t_stop, - size_t nbytes) -#else /* H5_HAVE_GETRUSAGE */ -static void -print_stats (const char *prefix, - struct timeval *r_start, struct timeval *r_stop, - struct timeval *t_start, struct timeval *t_stop, - size_t nbytes) #endif /* H5_HAVE_GETRUSAGE */ + double t_start, double t_stop, + size_t nbytes) { - double e_time, bw; + double e_time; + char bw[16]; #ifdef H5_HAVE_GETRUSAGE double u_time, s_time; @@ -88,27 +77,16 @@ print_stats (const char *prefix, ((double)(r_start->ru_stime.tv_sec)+ (double)(r_start->ru_stime.tv_usec)/(double)1000000.0F); #endif -#ifndef H5_HAVE_SYS_TIMEB - e_time = ((double)(t_stop->tv_sec)+ - (double)(t_stop->tv_usec)/(double)1000000.0F) - - ((double)(t_start->tv_sec)+ - (double)(t_start->tv_usec)/(double)1000000.0F); -#else - e_time = ((double)(t_stop->tv_sec)+ - (double)(t_stop->tv_usec)/(double)1000.0F) - - ((double)(t_start->tv_sec)+ - (double)(t_start->tv_usec)/(double)1000.0F); -#endif - bw = (double)nbytes / e_time; + e_time = t_stop - t_start; + H5_bandwidth(bw, (double)nbytes, e_time); #ifdef H5_HAVE_GETRUSAGE - printf (HEADING "%1.2fuser %1.2fsystem %1.2felapsed %1.2fMB/s\n", - prefix, u_time, s_time, e_time, bw/(1024*1024)); + HDprintf(HEADING "%1.2fuser %1.2fsystem %1.2felapsed %s\n", + prefix, u_time, s_time, e_time, bw); #else - printf (HEADING "%1.2felapsed %1.2fMB/s\n", - prefix, e_time, bw/(1024*1024)); + HDprintf(HEADING "%1.2felapsed %s\n", + prefix, e_time, bw); #endif - } @@ -122,12 +100,10 @@ print_stats (const char *prefix, * Programmer: Robb Matzke * Thursday, March 12, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ static void -synchronize (void) +synchronize(void) { #ifdef H5_HAVE_SYSTEM #if defined(H5_HAVE_WIN32_API) && ! defined(__CYGWIN__) @@ -157,24 +133,20 @@ synchronize (void) * Programmer: Robb Matzke * Thursday, March 12, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ int -main (void) +main(void) { - static hsize_t size[2] = {REQUEST_SIZE_X, REQUEST_SIZE_Y}; - static unsigned nread = NREAD_REQUESTS, nwrite = NWRITE_REQUESTS; + hsize_t size[2] = {REQUEST_SIZE_X, REQUEST_SIZE_Y}; + unsigned nread = NREAD_REQUESTS, nwrite = NWRITE_REQUESTS; unsigned char *the_data = NULL; hid_t file, dset, file_space = H5I_INVALID_HID; #ifdef H5_HAVE_GETRUSAGE struct rusage r_start, r_stop; -#else - struct timeval r_start, r_stop; #endif - struct timeval t_start, t_stop; + double t_start, t_stop; int fd; unsigned u; herr_t H5_ATTR_NDEBUG_UNUSED status; @@ -184,322 +156,221 @@ main (void) hsize_t count[2]; -#ifdef H5_HAVE_SYS_TIMEB - struct _timeb *tbstart = malloc(sizeof(struct _timeb)); - struct _timeb *tbstop = malloc(sizeof(struct _timeb)); -#endif /* * The extra cast in the following statement is a bug workaround for the * Win32 version 5.0 compiler. * 1998-11-06 ptl */ - printf ("I/O request size is %1.1fMB\n", - (double)(hssize_t)(size[0]*size[1])/(double)1024.0F*(double)1024); + HDprintf("I/O request size is %1.1fMB\n", + (double)(hssize_t)(size[0] * size[1]) / (double)1024.0F * (double)1024); /* Open the files */ - file = H5Fcreate (HDF5_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDassert (file>=0); - fd = HDopen (RAW_FILE_NAME, O_RDWR|O_CREAT|O_TRUNC, 0666); - HDassert (fd>=0); + file = H5Fcreate(HDF5_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + HDassert(file >= 0); + fd = HDopen(RAW_FILE_NAME, O_RDWR|O_CREAT|O_TRUNC, 0666); + HDassert(fd >= 0); /* Create the dataset */ - file_space = H5Screate_simple (2, size, size); + file_space = H5Screate_simple(2, size, size); HDassert(file_space >= 0); dset = H5Dcreate2(file, "dset", H5T_NATIVE_UCHAR, file_space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); HDassert(dset >= 0); - the_data = (unsigned char *)malloc((size_t)(size[0] * size[1])); + the_data = (unsigned char *)HDmalloc((size_t)(size[0] * size[1])); /* initial fill for lazy malloc */ HDmemset(the_data, 0xAA, (size_t)(size[0] * size[1])); + /* Fill raw */ - synchronize (); + synchronize(); #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_start); #endif -#ifdef H5_HAVE_GETTIMEOFDAY - HDgettimeofday(&t_start, NULL); -#else -#ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstart); -#endif -#endif - HDfprintf (stderr, HEADING, "fill raw"); + t_start = H5_get_time(); + HDfprintf(stderr, HEADING, "fill raw"); for(u = 0; u < nwrite; u++) { - putc (PROGRESS, stderr); - HDfflush(stderr); - HDmemset(the_data, 0xAA, (size_t)(size[0]*size[1])); + HDputc(PROGRESS, stderr); + HDfflush(stderr); + HDmemset(the_data, 0xAA, (size_t)(size[0] * size[1])); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); #endif -#ifdef H5_HAVE_GETTIMEOFDAY - HDgettimeofday(&t_stop, NULL); -#else -#ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstop); - t_start.tv_sec = tbstart->time; - t_start.tv_usec = tbstart->millitm; - t_stop.tv_sec = tbstop->time; - t_stop.tv_usec = tbstop->millitm; -#endif -#endif - putc ('\n', stderr); - print_stats ("fill raw", - &r_start, &r_stop, &t_start, &t_stop, - (size_t)(nread*size[0]*size[1])); + t_stop = H5_get_time(); + HDputc('\n', stderr); + print_stats("fill raw", +#ifdef H5_HAVE_GETRUSAGE + &r_start, &r_stop, +#endif /* H5_HAVE_GETRUSAGE */ + t_start, t_stop, (size_t)(nread * size[0] * size[1])); /* Fill hdf5 */ - synchronize (); + synchronize(); #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_start); #endif -#ifdef H5_HAVE_GETTIMEOFDAY - HDgettimeofday(&t_start, NULL); -#else -#ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstart); -#endif -#endif - HDfprintf (stderr, HEADING, "fill hdf5"); + t_start = H5_get_time(); + HDfprintf(stderr, HEADING, "fill hdf5"); for(u = 0; u < nread; u++) { - putc (PROGRESS, stderr); - HDfflush(stderr); - status = H5Dread (dset, H5T_NATIVE_UCHAR, file_space, file_space, - H5P_DEFAULT, the_data); - HDassert (status>=0); + HDputc(PROGRESS, stderr); + HDfflush(stderr); + status = H5Dread(dset, H5T_NATIVE_UCHAR, file_space, file_space, + H5P_DEFAULT, the_data); + HDassert(status >= 0); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); #endif -#ifdef H5_HAVE_GETTIMEOFDAY - HDgettimeofday(&t_stop, NULL); -#else -#ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstop); - t_start.tv_sec = tbstart->time; - t_start.tv_usec = tbstart->millitm; - t_stop.tv_sec = tbstop->time; - t_stop.tv_usec = tbstop->millitm; -#endif -#endif - putc ('\n', stderr); - print_stats ("fill hdf5", - &r_start, &r_stop, &t_start, &t_stop, - (size_t)(nread*size[0]*size[1])); + t_stop = H5_get_time(); + HDputc('\n', stderr); + print_stats("fill hdf5", +#ifdef H5_HAVE_GETRUSAGE + &r_start, &r_stop, +#endif /* H5_HAVE_GETRUSAGE */ + t_start, t_stop, (size_t)(nread * size[0] * size[1])); /* Write the raw dataset */ - synchronize (); + synchronize(); #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_start); #endif -#ifdef H5_HAVE_GETTIMEOFDAY - HDgettimeofday(&t_start, NULL); -#else -#ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstart); -#endif -#endif - HDfprintf (stderr, HEADING, "out raw"); + t_start = H5_get_time(); + HDfprintf(stderr, HEADING, "out raw"); for(u = 0; u < nwrite; u++) { - putc (PROGRESS, stderr); - HDfflush(stderr); - offset = HDlseek (fd, (off_t)0, SEEK_SET); - HDassert (0==offset); - n = HDwrite (fd, the_data, (size_t)(size[0]*size[1])); - HDassert (n>=0 && (size_t)n==size[0]*size[1]); + HDputc(PROGRESS, stderr); + HDfflush(stderr); + offset = HDlseek(fd, (off_t)0, SEEK_SET); + HDassert(0 == offset); + n = HDwrite(fd, the_data, (size_t)(size[0] * size[1])); + HDassert(n >= 0 && (size_t)n == (size[0] * size[1])); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); #endif -#ifdef H5_HAVE_GETTIMEOFDAY - HDgettimeofday(&t_stop, NULL); -#else -#ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstop); - t_start.tv_sec = tbstart->time; - t_start.tv_usec = tbstart->millitm; - t_stop.tv_sec = tbstop->time; - t_stop.tv_usec = tbstop->millitm; -#endif -#endif - putc ('\n', stderr); - print_stats ("out raw", - &r_start, &r_stop, &t_start, &t_stop, - (size_t)(nread*size[0]*size[1])); + t_stop = H5_get_time(); + HDputc('\n', stderr); + print_stats("out raw", +#ifdef H5_HAVE_GETRUSAGE + &r_start, &r_stop, +#endif /* H5_HAVE_GETRUSAGE */ + t_start, t_stop, (size_t)(nread * size[0] * size[1])); /* Write the hdf5 dataset */ - synchronize (); + synchronize(); #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_start); #endif -#ifdef H5_HAVE_GETTIMEOFDAY - HDgettimeofday(&t_start, NULL); -#else -#ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstart); -#endif -#endif - HDfprintf (stderr, HEADING, "out hdf5"); + t_start = H5_get_time(); + HDfprintf(stderr, HEADING, "out hdf5"); for(u = 0; u < nwrite; u++) { - putc (PROGRESS, stderr); - HDfflush(stderr); - status = H5Dwrite (dset, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, - H5P_DEFAULT, the_data); - HDassert (status>=0); + HDputc(PROGRESS, stderr); + HDfflush(stderr); + status = H5Dwrite(dset, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, + H5P_DEFAULT, the_data); + HDassert(status >= 0); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); #endif -#ifdef H5_HAVE_GETTIMEOFDAY - HDgettimeofday(&t_stop, NULL); -#else -#ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstop); - t_start.tv_sec = tbstart->time; - t_start.tv_usec = tbstart->millitm; - t_stop.tv_sec = tbstop->time; - t_stop.tv_usec = tbstop->millitm; -#endif -#endif - putc ('\n', stderr); - print_stats ("out hdf5", - &r_start, &r_stop, &t_start, &t_stop, - (size_t)(nread*size[0]*size[1])); + t_stop = H5_get_time(); + HDputc('\n', stderr); + print_stats("out hdf5", +#ifdef H5_HAVE_GETRUSAGE + &r_start, &r_stop, +#endif /* H5_HAVE_GETRUSAGE */ + t_start, t_stop, (size_t)(nread * size[0] * size[1])); /* Read the raw dataset */ - synchronize (); + synchronize(); #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_start); #endif -#ifdef H5_HAVE_GETTIMEOFDAY - HDgettimeofday(&t_start, NULL); -#else -#ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstart); -#endif -#endif - HDfprintf (stderr, HEADING, "in raw"); + t_start = H5_get_time(); + HDfprintf(stderr, HEADING, "in raw"); for(u = 0; u < nread; u++) { - putc (PROGRESS, stderr); - HDfflush(stderr); - offset = HDlseek (fd, (off_t)0, SEEK_SET); - HDassert (0==offset); - n = HDread (fd, the_data, (size_t)(size[0]*size[1])); - HDassert (n>=0 && (size_t)n==size[0]*size[1]); + HDputc(PROGRESS, stderr); + HDfflush(stderr); + offset = HDlseek(fd, (off_t)0, SEEK_SET); + HDassert(0 == offset); + n = HDread(fd, the_data, (size_t)(size[0] * size[1])); + HDassert(n >= 0 && (size_t)n == (size[0] * size[1])); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); #endif -#ifdef H5_HAVE_GETTIMEOFDAY - HDgettimeofday(&t_stop, NULL); -#else -#ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstop); - t_start.tv_sec = tbstart->time; - t_start.tv_usec = tbstart->millitm; - t_stop.tv_sec = tbstop->time; - t_stop.tv_usec = tbstop->millitm; -#endif -#endif - putc ('\n', stderr); - print_stats ("in raw", - &r_start, &r_stop, &t_start, &t_stop, - (size_t)(nread*size[0]*size[1])); + t_stop = H5_get_time(); + HDputc('\n', stderr); + print_stats("in raw", +#ifdef H5_HAVE_GETRUSAGE + &r_start, &r_stop, +#endif /* H5_HAVE_GETRUSAGE */ + t_start, t_stop, (size_t)(nread * size[0] * size[1])); /* Read the hdf5 dataset */ - synchronize (); + synchronize(); #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_start); #endif -#ifdef H5_HAVE_GETTIMEOFDAY - HDgettimeofday(&t_start, NULL); -#else -#ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstart); -#endif -#endif - HDfprintf (stderr, HEADING, "in hdf5"); + t_start = H5_get_time(); + HDfprintf(stderr, HEADING, "in hdf5"); for(u = 0; u < nread; u++) { - putc (PROGRESS, stderr); - HDfflush(stderr); - status = H5Dread (dset, H5T_NATIVE_UCHAR, file_space, file_space, - H5P_DEFAULT, the_data); - HDassert (status>=0); + HDputc(PROGRESS, stderr); + HDfflush(stderr); + status = H5Dread(dset, H5T_NATIVE_UCHAR, file_space, file_space, + H5P_DEFAULT, the_data); + HDassert(status >= 0); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); #endif -#ifdef H5_HAVE_GETTIMEOFDAY - HDgettimeofday(&t_stop, NULL); -#else -#ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstop); - t_start.tv_sec = tbstart->time; - t_start.tv_usec = tbstart->millitm; - t_stop.tv_sec = tbstop->time; - t_stop.tv_usec = tbstop->millitm; -#endif -#endif - putc ('\n', stderr); - print_stats ("in hdf5", - &r_start, &r_stop, &t_start, &t_stop, - (size_t)(nread*size[0]*size[1])); + t_stop = H5_get_time(); + HDputc('\n', stderr); + print_stats("in hdf5", +#ifdef H5_HAVE_GETRUSAGE + &r_start, &r_stop, +#endif /* H5_HAVE_GETRUSAGE */ + t_start, t_stop, (size_t)(nread * size[0] * size[1])); /* Read hyperslab */ - HDassert (size[0]>20 && size[1]>20); + HDassert(size[0] > 20 && size[1] > 20); start[0] = start[1] = 10; - count[0] = count[1] = size[0]-20; - status = H5Sselect_hyperslab (file_space, H5S_SELECT_SET, start, NULL, count, NULL); - HDassert (status>=0); - synchronize (); + count[0] = count[1] = size[0] - 20; + status = H5Sselect_hyperslab(file_space, H5S_SELECT_SET, start, NULL, count, NULL); + HDassert(status >= 0); + synchronize(); #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_start); #endif -#ifdef H5_HAVE_GETTIMEOFDAY - HDgettimeofday(&t_start, NULL); -#else -#ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstart); -#endif -#endif - HDfprintf (stderr, HEADING, "in hdf5 partial"); + t_start = H5_get_time(); + HDfprintf(stderr, HEADING, "in hdf5 partial"); for(u = 0; u < nread; u++) { - putc (PROGRESS, stderr); - HDfflush(stderr); - status = H5Dread (dset, H5T_NATIVE_UCHAR, file_space, file_space, - H5P_DEFAULT, the_data); - HDassert (status>=0); + HDputc(PROGRESS, stderr); + HDfflush(stderr); + status = H5Dread(dset, H5T_NATIVE_UCHAR, file_space, file_space, + H5P_DEFAULT, the_data); + HDassert(status >= 0); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); #endif -#ifdef H5_HAVE_GETTIMEOFDAY - HDgettimeofday(&t_stop, NULL); -#else -#ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstop); - t_start.tv_sec = tbstart->time; - t_start.tv_usec = tbstart->millitm; - t_stop.tv_sec = tbstop->time; - t_stop.tv_usec = tbstop->millitm; -#endif -#endif - putc('\n', stderr); + t_stop = H5_get_time(); + HDputc('\n', stderr); print_stats("in hdf5 partial", - &r_start, &r_stop, &t_start, &t_stop, - (size_t)(nread*count[0]*count[1])); - - +#ifdef H5_HAVE_GETRUSAGE + &r_start, &r_stop, +#endif /* H5_HAVE_GETRUSAGE */ + t_start, t_stop, (size_t)(nread * size[0] * size[1])); /* Close everything */ HDclose(fd); + H5Dclose(dset); H5Sclose(file_space); H5Fclose(file); - free(the_data); + + HDfree(the_data); return 0; } diff --git a/tools/test/perform/pio_perf.c b/tools/test/perform/pio_perf.c index 8146d84..cb15f64 100644 --- a/tools/test/perform/pio_perf.c +++ b/tools/test/perform/pio_perf.c @@ -327,7 +327,7 @@ static off_t squareo(off_t); * Modifications: */ int -main(int argc, char **argv) +main(int argc, char *argv[]) { int ret; int exit_value = EXIT_SUCCESS; diff --git a/tools/test/perform/pio_standalone.h b/tools/test/perform/pio_standalone.h index cf6d980..f2cda4f 100644 --- a/tools/test/perform/pio_standalone.h +++ b/tools/test/perform/pio_standalone.h @@ -213,7 +213,7 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); #define HDgetpwnam(S) getpwnam(S) #define HDgetpwuid(U) getpwuid(U) #define HDgetrusage(X,S) getrusage(X,S) -#define HDgets(S) gets(S) +/* Don't define a macro for gets() - it was removed in C11 */ #ifdef H5_HAVE_WIN32_API H5_DLL int Wgettimeofday(struct timeval *tv, struct timezone *tz); #define HDgettimeofday(V,Z) Wgettimeofday(V,Z) diff --git a/tools/test/perform/sio_perf.c b/tools/test/perform/sio_perf.c index a56558e..d2eb3fc 100644 --- a/tools/test/perform/sio_perf.c +++ b/tools/test/perform/sio_perf.c @@ -303,7 +303,7 @@ typedef struct _minmax { /* local functions */ static hsize_t parse_size_directive(const char *size); -static struct options *parse_command_line(int argc, char *argv[]); +static struct options *parse_command_line(int argc, const char *argv[]); static void run_test_loop(struct options *options); static int run_test(iotype iot, parameters parms, struct options *opts); static void output_all_info(minmax *mm, int count, int indent_level); @@ -324,7 +324,7 @@ static void report_parameters(struct options *opts); * Modifications: */ int -main(int argc, char **argv) +main(int argc, const char *argv[]) { int exit_value = EXIT_SUCCESS; struct options *opts = NULL; @@ -944,7 +944,7 @@ report_parameters(struct options *opts) * Added multidimensional testing (Christian Chilan, April, 2008) */ static struct options * -parse_command_line(int argc, char *argv[]) +parse_command_line(int argc, const char *argv[]) { int opt; struct options *cl_opts; @@ -984,7 +984,7 @@ parse_command_line(int argc, char *argv[]) cl_opts->h5_extendable = FALSE; /* Use extendable dataset */ cl_opts->verify = FALSE; /* No Verify data correctness by default */ - while ((opt = get_option(argc, (const char **)argv, s_opts, l_opts)) != EOF) { + while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { switch ((char)opt) { case 'a': cl_opts->h5_alignment = parse_size_directive(opt_arg); diff --git a/tools/test/perform/sio_standalone.h b/tools/test/perform/sio_standalone.h index 45f6d25..99e13bc 100644 --- a/tools/test/perform/sio_standalone.h +++ b/tools/test/perform/sio_standalone.h @@ -228,7 +228,7 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); #define HDgetpwnam(S) getpwnam(S) #define HDgetpwuid(U) getpwuid(U) #define HDgetrusage(X,S) getrusage(X,S) -#define HDgets(S) gets(S) +/* Don't define a macro for gets() - it was removed in C11 */ #ifdef H5_HAVE_WIN32_API H5_DLL int Wgettimeofday(struct timeval *tv, struct timezone *tz); #define HDgettimeofday(V,Z) Wgettimeofday(V,Z) diff --git a/tools/test/perform/zip_perf.c b/tools/test/perform/zip_perf.c index e301bb3..8f1f584 100644 --- a/tools/test/perform/zip_perf.c +++ b/tools/test/perform/zip_perf.c @@ -552,7 +552,7 @@ do_write_test(unsigned long file_size, unsigned long min_buf_size, * Modifications: */ int -main(int argc, char **argv) +main(int argc, const char *argv[]) { unsigned long min_buf_size = 128 * ONE_KB, max_buf_size = ONE_MB; unsigned long file_size = 64 * ONE_MB; @@ -563,7 +563,7 @@ main(int argc, char **argv) /* Initialize h5tools lib */ h5tools_init(); - while ((opt = get_option(argc, (const char **)argv, s_opts, l_opts)) > 0) { + while ((opt = get_option(argc, argv, s_opts, l_opts)) > 0) { switch ((char)opt) { case '0': case '1': case '2': case '3': case '4': case '5': diff --git a/tools/testfiles/h5dump-help.txt b/tools/testfiles/h5dump-help.txt index 95dfc3b..a122dee 100644 --- a/tools/testfiles/h5dump-help.txt +++ b/tools/testfiles/h5dump-help.txt @@ -22,6 +22,12 @@ usage: h5dump [OPTIONS] files ,, ) Any absent attribute will use a default value. + --vol-value Value (ID) of the VOL connector to use for opening the + HDF5 file specified + --vol-name Name of the VOL connector to use for opening the + HDF5 file specified + --vol-info VOL-specific info to pass to the VOL connector used for + opening the HDF5 file specified --------------- Object Options --------------- -a P, --attribute=P Print the specified attribute If an attribute name contains a slash (/), escape the diff --git a/tools/testfiles/help-1.ls b/tools/testfiles/help-1.ls index 7409c16..0926c4c 100644 --- a/tools/testfiles/help-1.ls +++ b/tools/testfiles/help-1.ls @@ -46,6 +46,12 @@ usage: h5ls [OPTIONS] file[/OBJECT] [file[/[OBJECT]...] ...,,) If absent or A == '(,,,,)', all default values are used. Has no effect if vfd flag is not 'hdfs'. + --vol-value Value (ID) of the VOL connector to use for opening the + HDF5 file specified + --vol-name Name of the VOL connector to use for opening the + HDF5 file specified + --vol-info VOL-specific info to pass to the VOL connector used for + opening the HDF5 file specified file/OBJECT Each object consists of an HDF5 file name optionally followed by a diff --git a/tools/testfiles/help-2.ls b/tools/testfiles/help-2.ls index 7409c16..0926c4c 100644 --- a/tools/testfiles/help-2.ls +++ b/tools/testfiles/help-2.ls @@ -46,6 +46,12 @@ usage: h5ls [OPTIONS] file[/OBJECT] [file[/[OBJECT]...] ...,,) If absent or A == '(,,,,)', all default values are used. Has no effect if vfd flag is not 'hdfs'. + --vol-value Value (ID) of the VOL connector to use for opening the + HDF5 file specified + --vol-name Name of the VOL connector to use for opening the + HDF5 file specified + --vol-info VOL-specific info to pass to the VOL connector used for + opening the HDF5 file specified file/OBJECT Each object consists of an HDF5 file name optionally followed by a diff --git a/tools/testfiles/help-3.ls b/tools/testfiles/help-3.ls index 7409c16..0926c4c 100644 --- a/tools/testfiles/help-3.ls +++ b/tools/testfiles/help-3.ls @@ -46,6 +46,12 @@ usage: h5ls [OPTIONS] file[/OBJECT] [file[/[OBJECT]...] ...,,) If absent or A == '(,,,,)', all default values are used. Has no effect if vfd flag is not 'hdfs'. + --vol-value Value (ID) of the VOL connector to use for opening the + HDF5 file specified + --vol-name Name of the VOL connector to use for opening the + HDF5 file specified + --vol-info VOL-specific info to pass to the VOL connector used for + opening the HDF5 file specified file/OBJECT Each object consists of an HDF5 file name optionally followed by a diff --git a/tools/testfiles/pbits/tnofilename-with-packed-bits.ddl b/tools/testfiles/pbits/tnofilename-with-packed-bits.ddl index 95dfc3b..a122dee 100644 --- a/tools/testfiles/pbits/tnofilename-with-packed-bits.ddl +++ b/tools/testfiles/pbits/tnofilename-with-packed-bits.ddl @@ -22,6 +22,12 @@ usage: h5dump [OPTIONS] files ,, ) Any absent attribute will use a default value. + --vol-value Value (ID) of the VOL connector to use for opening the + HDF5 file specified + --vol-name Name of the VOL connector to use for opening the + HDF5 file specified + --vol-info VOL-specific info to pass to the VOL connector used for + opening the HDF5 file specified --------------- Object Options --------------- -a P, --attribute=P Print the specified attribute If an attribute name contains a slash (/), escape the diff --git a/tools/testfiles/pbits/tpbitsIncomplete.ddl b/tools/testfiles/pbits/tpbitsIncomplete.ddl index 95dfc3b..a122dee 100644 --- a/tools/testfiles/pbits/tpbitsIncomplete.ddl +++ b/tools/testfiles/pbits/tpbitsIncomplete.ddl @@ -22,6 +22,12 @@ usage: h5dump [OPTIONS] files ,, ) Any absent attribute will use a default value. + --vol-value Value (ID) of the VOL connector to use for opening the + HDF5 file specified + --vol-name Name of the VOL connector to use for opening the + HDF5 file specified + --vol-info VOL-specific info to pass to the VOL connector used for + opening the HDF5 file specified --------------- Object Options --------------- -a P, --attribute=P Print the specified attribute If an attribute name contains a slash (/), escape the diff --git a/tools/testfiles/pbits/tpbitsLengthExceeded.ddl b/tools/testfiles/pbits/tpbitsLengthExceeded.ddl index 95dfc3b..a122dee 100644 --- a/tools/testfiles/pbits/tpbitsLengthExceeded.ddl +++ b/tools/testfiles/pbits/tpbitsLengthExceeded.ddl @@ -22,6 +22,12 @@ usage: h5dump [OPTIONS] files ,, ) Any absent attribute will use a default value. + --vol-value Value (ID) of the VOL connector to use for opening the + HDF5 file specified + --vol-name Name of the VOL connector to use for opening the + HDF5 file specified + --vol-info VOL-specific info to pass to the VOL connector used for + opening the HDF5 file specified --------------- Object Options --------------- -a P, --attribute=P Print the specified attribute If an attribute name contains a slash (/), escape the diff --git a/tools/testfiles/pbits/tpbitsLengthPositive.ddl b/tools/testfiles/pbits/tpbitsLengthPositive.ddl index 95dfc3b..a122dee 100644 --- a/tools/testfiles/pbits/tpbitsLengthPositive.ddl +++ b/tools/testfiles/pbits/tpbitsLengthPositive.ddl @@ -22,6 +22,12 @@ usage: h5dump [OPTIONS] files ,, ) Any absent attribute will use a default value. + --vol-value Value (ID) of the VOL connector to use for opening the + HDF5 file specified + --vol-name Name of the VOL connector to use for opening the + HDF5 file specified + --vol-info VOL-specific info to pass to the VOL connector used for + opening the HDF5 file specified --------------- Object Options --------------- -a P, --attribute=P Print the specified attribute If an attribute name contains a slash (/), escape the diff --git a/tools/testfiles/pbits/tpbitsMaxExceeded.ddl b/tools/testfiles/pbits/tpbitsMaxExceeded.ddl index 95dfc3b..a122dee 100644 --- a/tools/testfiles/pbits/tpbitsMaxExceeded.ddl +++ b/tools/testfiles/pbits/tpbitsMaxExceeded.ddl @@ -22,6 +22,12 @@ usage: h5dump [OPTIONS] files ,, ) Any absent attribute will use a default value. + --vol-value Value (ID) of the VOL connector to use for opening the + HDF5 file specified + --vol-name Name of the VOL connector to use for opening the + HDF5 file specified + --vol-info VOL-specific info to pass to the VOL connector used for + opening the HDF5 file specified --------------- Object Options --------------- -a P, --attribute=P Print the specified attribute If an attribute name contains a slash (/), escape the diff --git a/tools/testfiles/pbits/tpbitsOffsetExceeded.ddl b/tools/testfiles/pbits/tpbitsOffsetExceeded.ddl index 95dfc3b..a122dee 100644 --- a/tools/testfiles/pbits/tpbitsOffsetExceeded.ddl +++ b/tools/testfiles/pbits/tpbitsOffsetExceeded.ddl @@ -22,6 +22,12 @@ usage: h5dump [OPTIONS] files ,, ) Any absent attribute will use a default value. + --vol-value Value (ID) of the VOL connector to use for opening the + HDF5 file specified + --vol-name Name of the VOL connector to use for opening the + HDF5 file specified + --vol-info VOL-specific info to pass to the VOL connector used for + opening the HDF5 file specified --------------- Object Options --------------- -a P, --attribute=P Print the specified attribute If an attribute name contains a slash (/), escape the diff --git a/tools/testfiles/pbits/tpbitsOffsetNegative.ddl b/tools/testfiles/pbits/tpbitsOffsetNegative.ddl index 95dfc3b..a122dee 100644 --- a/tools/testfiles/pbits/tpbitsOffsetNegative.ddl +++ b/tools/testfiles/pbits/tpbitsOffsetNegative.ddl @@ -22,6 +22,12 @@ usage: h5dump [OPTIONS] files ,, ) Any absent attribute will use a default value. + --vol-value Value (ID) of the VOL connector to use for opening the + HDF5 file specified + --vol-name Name of the VOL connector to use for opening the + HDF5 file specified + --vol-info VOL-specific info to pass to the VOL connector used for + opening the HDF5 file specified --------------- Object Options --------------- -a P, --attribute=P Print the specified attribute If an attribute name contains a slash (/), escape the diff --git a/tools/testfiles/textlinksrc-nodangle-1.ls b/tools/testfiles/textlinksrc-nodangle-1.ls index 7409c16..0926c4c 100644 --- a/tools/testfiles/textlinksrc-nodangle-1.ls +++ b/tools/testfiles/textlinksrc-nodangle-1.ls @@ -46,6 +46,12 @@ usage: h5ls [OPTIONS] file[/OBJECT] [file[/[OBJECT]...] ...,,) If absent or A == '(,,,,)', all default values are used. Has no effect if vfd flag is not 'hdfs'. + --vol-value Value (ID) of the VOL connector to use for opening the + HDF5 file specified + --vol-name Name of the VOL connector to use for opening the + HDF5 file specified + --vol-info VOL-specific info to pass to the VOL connector used for + opening the HDF5 file specified file/OBJECT Each object consists of an HDF5 file name optionally followed by a diff --git a/tools/testfiles/tgroup-1.ls b/tools/testfiles/tgroup-1.ls index 7409c16..0926c4c 100644 --- a/tools/testfiles/tgroup-1.ls +++ b/tools/testfiles/tgroup-1.ls @@ -46,6 +46,12 @@ usage: h5ls [OPTIONS] file[/OBJECT] [file[/[OBJECT]...] ...,,) If absent or A == '(,,,,)', all default values are used. Has no effect if vfd flag is not 'hdfs'. + --vol-value Value (ID) of the VOL connector to use for opening the + HDF5 file specified + --vol-name Name of the VOL connector to use for opening the + HDF5 file specified + --vol-info VOL-specific info to pass to the VOL connector used for + opening the HDF5 file specified file/OBJECT Each object consists of an HDF5 file name optionally followed by a diff --git a/tools/testfiles/tgrpnullspace.ddl b/tools/testfiles/tgrpnullspace.ddl index 2b91527..7c1ef6c 100644 --- a/tools/testfiles/tgrpnullspace.ddl +++ b/tools/testfiles/tgrpnullspace.ddl @@ -13,7 +13,7 @@ GROUP "/" { STORAGE_LAYOUT { CONTIGUOUS SIZE 0 - OFFSET 18446744073709551615 + OFFSET HADDR_UNDEF } FILTERS { NONE diff --git a/tools/testfiles/tintsnodata.ddl b/tools/testfiles/tintsnodata.ddl index c20f337..a1516af 100644 --- a/tools/testfiles/tintsnodata.ddl +++ b/tools/testfiles/tintsnodata.ddl @@ -6,7 +6,7 @@ GROUP "/" { STORAGE_LAYOUT { CONTIGUOUS SIZE 0 - OFFSET 18446744073709551615 + OFFSET HADDR_UNDEF } FILTERS { NONE @@ -35,7 +35,7 @@ GROUP "/" { STORAGE_LAYOUT { CONTIGUOUS SIZE 0 - OFFSET 18446744073709551615 + OFFSET HADDR_UNDEF } FILTERS { NONE @@ -64,7 +64,7 @@ GROUP "/" { STORAGE_LAYOUT { CONTIGUOUS SIZE 0 - OFFSET 18446744073709551615 + OFFSET HADDR_UNDEF } FILTERS { NONE @@ -101,7 +101,7 @@ GROUP "/" { STORAGE_LAYOUT { CONTIGUOUS SIZE 0 - OFFSET 18446744073709551615 + OFFSET HADDR_UNDEF } FILTERS { NONE @@ -154,7 +154,7 @@ GROUP "/" { STORAGE_LAYOUT { CONTIGUOUS SIZE 0 - OFFSET 18446744073709551615 + OFFSET HADDR_UNDEF } FILTERS { NONE @@ -183,7 +183,7 @@ GROUP "/" { STORAGE_LAYOUT { CONTIGUOUS SIZE 0 - OFFSET 18446744073709551615 + OFFSET HADDR_UNDEF } FILTERS { NONE @@ -212,7 +212,7 @@ GROUP "/" { STORAGE_LAYOUT { CONTIGUOUS SIZE 0 - OFFSET 18446744073709551615 + OFFSET HADDR_UNDEF } FILTERS { NONE @@ -249,7 +249,7 @@ GROUP "/" { STORAGE_LAYOUT { CONTIGUOUS SIZE 0 - OFFSET 18446744073709551615 + OFFSET HADDR_UNDEF } FILTERS { NONE @@ -302,7 +302,7 @@ GROUP "/" { STORAGE_LAYOUT { CONTIGUOUS SIZE 0 - OFFSET 18446744073709551615 + OFFSET HADDR_UNDEF } FILTERS { NONE diff --git a/tools/testfiles/trefer_attrR.ddl b/tools/testfiles/trefer_attrR.ddl index e64c8e6..118e7bf 100644 --- a/tools/testfiles/trefer_attrR.ddl +++ b/tools/testfiles/trefer_attrR.ddl @@ -12,16 +12,16 @@ GROUP "/" { } } ATTRIBUTE "trefer_attr.h5/Group1/Dataset2/Attr1" { - NULL + NULL } - ATTRIBUTE "trefer_attr.h5/Group1/Attr2" { + ATTRIBUTE "trefer_attr.h5/Group1/Attr2" { DATATYPE H5T_STD_U32LE DATASPACE SIMPLE { ( 4 ) / ( 4 ) } DATA { (0): 1, 4, 7, 10 } } - ATTRIBUTE "trefer_attr.h5/Group1/Datatype1/Attr3" { + ATTRIBUTE "trefer_attr.h5/Group1/Datatype1/Attr3" { DATATYPE H5T_STD_U32LE DATASPACE SIMPLE { ( 4 ) / ( 4 ) } DATA { diff --git a/tools/testfiles/trefer_extR.ddl b/tools/testfiles/trefer_extR.ddl index 3d4647d..a96e5fd 100644 --- a/tools/testfiles/trefer_extR.ddl +++ b/tools/testfiles/trefer_extR.ddl @@ -12,16 +12,16 @@ GROUP "/" { } } ATTRIBUTE "trefer_ext1.h5/Group1/Dataset2/Attr1" { - NULL + NULL } - ATTRIBUTE "trefer_ext1.h5/Group1/Attr2" { + ATTRIBUTE "trefer_ext1.h5/Group1/Attr2" { DATATYPE H5T_STD_U32LE DATASPACE SIMPLE { ( 4 ) / ( 4 ) } DATA { (0): 1, 4, 7, 10 } } - ATTRIBUTE "trefer_ext1.h5/Group1/Datatype1/Attr3" { + ATTRIBUTE "trefer_ext1.h5/Group1/Datatype1/Attr3" { DATATYPE H5T_STD_U32LE DATASPACE SIMPLE { ( 4 ) / ( 4 ) } DATA { diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt new file mode 100644 index 0000000..2d5626e --- /dev/null +++ b/utils/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required (VERSION 3.10) +project (HDF5_UTILS C) + +add_subdirectory (mirror_vfd) diff --git a/utils/COPYING b/utils/COPYING new file mode 100644 index 0000000..4a23112 --- /dev/null +++ b/utils/COPYING @@ -0,0 +1,12 @@ + + Copyright by The HDF Group. + All rights reserved. + + The files and subdirectories in this directory are part of HDF5. + The full HDF5 copyright notice, including terms governing use, + modification, and redistribution, is contained in the COPYING file + which can be found at the root of the source code distribution tree + or in https://support.hdfgroup.org/ftp/HDF5/releases. If you do + not have access to either file, you may request a copy from + help@hdfgroup.org. + diff --git a/utils/Makefile.am b/utils/Makefile.am new file mode 100644 index 0000000..b4409ac --- /dev/null +++ b/utils/Makefile.am @@ -0,0 +1,26 @@ +# +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +## +## Makefile.am +## Run automake to generate a Makefile.in from this file. +## +# +# Utils HDF5 Makefile(.in) +# + +include $(top_srcdir)/config/commence.am + +CONFIG=ordered + +# All subdirectories +SUBDIRS=mirror_vfd + +include $(top_srcdir)/config/conclude.am diff --git a/utils/mirror_vfd/CMakeLists.txt b/utils/mirror_vfd/CMakeLists.txt new file mode 100644 index 0000000..1926352 --- /dev/null +++ b/utils/mirror_vfd/CMakeLists.txt @@ -0,0 +1,64 @@ +cmake_minimum_required (VERSION 3.10) +project (HDF5_UTILS_MIRRORVFD C) + +#----------------------------------------------------------------------------- +# Add the mirror_server executable +#----------------------------------------------------------------------------- + +set (mirror_server_SOURCES + ${HDF5_UTILS_MIRRORVFD_SOURCE_DIR}/mirror_remote.c + ${HDF5_UTILS_MIRRORVFD_SOURCE_DIR}/mirror_server.c + ${HDF5_UTILS_MIRRORVFD_SOURCE_DIR}/mirror_writer.c) +add_executable (mirror_server ${mirror_server_SOURCES}) +target_include_directories (mirror_server PRIVATE "${HDF5_UITLS_DIR};${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") +if (NOT BUILD_SHARED_LIBS) + TARGET_C_PROPERTIES (mirror_server STATIC) + target_link_libraries (mirror_server PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) +else () + TARGET_C_PROPERTIES (mirror_server SHARED) + target_link_libraries (mirror_server PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) +endif () +set_target_properties (mirror_server PROPERTIES FOLDER utils) +set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};mirror_server") +set (H5_DEP_EXECUTABLES ${H5_DEP_EXECUTABLES} mirror_server) + +#----------------------------------------------------------------------------- +# Add the mirror_server_stop executable +#----------------------------------------------------------------------------- + +set (mirror_server_stop_SOURCES ${HDF5_UTILS_MIRRORVFD_SOURCE_DIR}/mirror_server_stop.c) +add_executable (mirror_server_stop ${mirror_server_stop_SOURCES}) +target_include_directories (mirror_server_stop PRIVATE "${HDF5_UITLS_DIR};${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") +if (NOT BUILD_SHARED_LIBS) + TARGET_C_PROPERTIES (mirror_server_stop STATIC) + target_link_libraries (mirror_server_stop PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) +else () + TARGET_C_PROPERTIES (mirror_server_stop SHARED) + target_link_libraries (mirror_server_stop PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) +endif () +set_target_properties (mirror_server_stop PROPERTIES FOLDER utils) +set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};mirror_server_stop") +set (H5_DEP_EXECUTABLES ${H5_DEP_EXECUTABLES} mirror_server_stop) + +############################################################################## +############################################################################## +### I N S T A L L A T I O N ### +############################################################################## +############################################################################## + +#----------------------------------------------------------------------------- +# Rules for Installation of tools using make Install target +#----------------------------------------------------------------------------- +if (HDF5_EXPORTED_TARGETS) + foreach (exec ${H5_DEP_EXECUTABLES}) + INSTALL_PROGRAM_PDB (${exec} ${HDF5_INSTALL_BIN_DIR} utilsapplications) + endforeach () + + install ( + TARGETS + ${H5_DEP_EXECUTABLES} + EXPORT + ${HDF5_EXPORTED_TARGETS} + RUNTIME DESTINATION ${HDF5_INSTALL_BIN_DIR} COMPONENT utilsapplications + ) +endif () diff --git a/utils/mirror_vfd/Makefile.am b/utils/mirror_vfd/Makefile.am new file mode 100644 index 0000000..96d3104 --- /dev/null +++ b/utils/mirror_vfd/Makefile.am @@ -0,0 +1,30 @@ +# +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +## +## Makefile.am +## Run automake to generate a Makefile.in from this file. +# +# HDF5 Library Makefile(.in) +# + +include $(top_srcdir)/config/commence.am + +AM_CPPFLAGS+=-I$(top_srcdir)/src + +bin_PROGRAMS = mirror_server mirror_server_stop + +mirror_server_SOURCES = mirror_server.c mirror_writer.c mirror_remote.c +#mirror_writer_SOURCES = mirror_writer.c mirror_remote.c + +# All programs depend on the hdf5 library +LDADD=$(LIBHDF5) + +include $(top_srcdir)/config/conclude.am diff --git a/utils/mirror_vfd/mirror_remote.c b/utils/mirror_vfd/mirror_remote.c new file mode 100644 index 0000000..81a3625 --- /dev/null +++ b/utils/mirror_vfd/mirror_remote.c @@ -0,0 +1,225 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* Common operations for "remote" processes for the Mirror VFD. + * + * Jacob Smith, 2020-03-06 + */ + +#include "mirror_remote.h" + +#ifdef H5_HAVE_MIRROR_VFD + + +/* --------------------------------------------------------------------------- + * Function: mirror_log + * + * Purpose: Write message to the logging stream/file. + * If logging info pointer is NULL, uses logging defaults. + * ---------------------------------------------------------------------------- + */ +void +mirror_log(struct mirror_log_info *info, + unsigned int level, + const char *format, + ...) +{ + FILE *stream = MIRROR_LOG_DEFAULT_STREAM; + unsigned int verbosity = MIRROR_LOG_DEFAULT_VERBOSITY; + hbool_t custom = FALSE; + + if (info != NULL && info->magic == MIRROR_LOG_INFO_MAGIC) { + stream = info->stream; + verbosity = info->verbosity; + custom = TRUE; + } + + if (level == V_NONE) { + return; + } + else + if (level <= verbosity) { + if (custom == TRUE && info->prefix[0] != '\0') { + HDfprintf(stream, "%s", info->prefix); + } + + switch (level) { + case (V_ERR) : + HDfprintf(stream, "ERROR "); + break; + case (V_WARN) : + HDfprintf(stream, "WARNING "); + break; + default: + break; + } + + if (format != NULL) { + va_list args; + HDva_start(args, format); + HDvfprintf(stream, format, args); + HDva_end(args); + } + + HDfprintf(stream, "\n"); + HDfflush(stream); + } /* end if sufficiently verbose to print */ +} /* end mirror_log() */ + + +/* --------------------------------------------------------------------------- + * Function: session_log_bytes + * + * Purpose: "Pretty-print" raw binary data to logging stream/file. + * If info pointer is NULL, uses logging defaults. + * ---------------------------------------------------------------------------- + */ +void +mirror_log_bytes(struct mirror_log_info *info, + unsigned int level, + size_t n_bytes, + const unsigned char *buf) +{ + FILE *stream = MIRROR_LOG_DEFAULT_STREAM; + unsigned int verbosity = MIRROR_LOG_DEFAULT_VERBOSITY; + + if (buf == NULL) { + return; + } + + if (info != NULL && info->magic == MIRROR_LOG_INFO_MAGIC) { + stream = info->stream; + verbosity = info->verbosity; + } + + if (level <= verbosity) { + size_t bytes_written = 0; + const unsigned char *b = NULL; + + /* print whole lines */ + while ((n_bytes - bytes_written) >= 32) { + b = buf + bytes_written; /* point to region in buffer */ + HDfprintf(stream, + "%04zX %02X%02X%02X%02X %02X%02X%02X%02X" \ + " %02X%02X%02X%02X %02X%02X%02X%02X" \ + " %02X%02X%02X%02X %02X%02X%02X%02X" \ + " %02X%02X%02X%02X %02X%02X%02X%02X\n", + bytes_written, + b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7], + b[8], b[9], b[10],b[11], b[12],b[13],b[14],b[15], + b[16],b[17],b[18],b[19], b[20],b[21],b[22],b[23], + b[24],b[25],b[26],b[27], b[28],b[29],b[30],b[31]); + bytes_written += 32; + } + + /* start partial line */ + if (n_bytes > bytes_written) { + HDfprintf(stream, "%04zX ", bytes_written); + } + + /* partial line blocks */ + while ((n_bytes - bytes_written) >= 4) { + HDfprintf(stream, " %02X%02X%02X%02X", + buf[bytes_written], buf[bytes_written+1], + buf[bytes_written+2], buf[bytes_written+3]); + bytes_written += 4; + } + + /* block separator before partial block */ + if (n_bytes > bytes_written) { + HDfprintf(stream, " "); + } + + /* partial block individual bytes */ + while (n_bytes > bytes_written) { + HDfprintf(stream, "%02X", buf[bytes_written++]); + } + + /* end partial line */ + HDfprintf(stream, "\n"); + } /* end if suitably verbose to log */ +} /* end mirror_log_bytes() */ + + +/* --------------------------------------------------------------------------- + * Function: mirror_log_init + * + * Purpose: Prepare a loginfo_t structure for use. + * + * Return: Success: Pointer to newly-ceated info. + * Failure: NULL. Either unable to allocate or cannot open file. + * ---------------------------------------------------------------------------- + */ +loginfo_t * +mirror_log_init(char *path, char *prefix, unsigned int verbosity) +{ + loginfo_t *info = NULL; + + info = (loginfo_t *)HDmalloc(sizeof(loginfo_t)); + if (info != NULL) { + info->magic = MIRROR_LOG_INFO_MAGIC; + info->verbosity = verbosity; + info->stream = MIRROR_LOG_DEFAULT_STREAM; + info->prefix[0] = '\0'; + + if (prefix && *prefix) { + HDstrncpy(info->prefix, prefix, MIRROR_LOG_PREFIX_MAX); + } + + if (path && *path) { + FILE *f = NULL; + f = HDfopen(path, "w"); + if (NULL == f) { + HDfprintf(MIRROR_LOG_DEFAULT_STREAM, + "WARN custom logging path could not be opened: %s\n", + path); + info->magic += 1; + HDfree(info); + } + else { + info->stream = f; + } + } + + } /* end if able to allocate */ + + return info; +} /* end mirror_log_init() */ + + +/* --------------------------------------------------------------------------- + * Function: mirror_log_term + * + * Purpose: Shut down and clean up a loginfo_t structure. + * + * Return: Success: SUCCEED. Resources released. + * Failure: FAIL. Indeterminite state. + * ---------------------------------------------------------------------------- + */ +herr_t +mirror_log_term(loginfo_t *info) +{ + if (info == NULL || info->magic != MIRROR_LOG_INFO_MAGIC) { + return FAIL; + } + if (info->stream != stderr || info->stream != stdout) { + if (HDfclose(info->stream) < 0) { + return FAIL; + } + } + info->magic += 1; + HDfree(info); + return SUCCEED; +} /* end mirror_log_term() */ + +#endif /* H5_HAVE_MIRROR_VFD */ + diff --git a/utils/mirror_vfd/mirror_remote.h b/utils/mirror_vfd/mirror_remote.h new file mode 100644 index 0000000..9132d51 --- /dev/null +++ b/utils/mirror_vfd/mirror_remote.h @@ -0,0 +1,51 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* Common definitions for "remote" processes for the Mirror VFD. + * + * Jacob Smith, 2020-03-06 + */ + +#include "hdf5.h" +#include "H5private.h" + +#ifdef H5_HAVE_MIRROR_VFD + +#define V_NONE 0 +#define V_ERR 1 +#define V_WARN 2 +#define V_INFO 3 +#define V_ALL 4 + +#define MIRROR_LOG_DEFAULT_STREAM stdout +#define MIRROR_LOG_DEFAULT_VERBOSITY V_WARN +#define MIRROR_LOG_PREFIX_MAX 79 +#define MIRROR_LOG_INFO_MAGIC 0x569D589A + +typedef struct mirror_log_info { + uint32_t magic; + FILE *stream; + unsigned int verbosity; + char prefix[MIRROR_LOG_PREFIX_MAX+1]; +} loginfo_t; + +void mirror_log(loginfo_t *info, unsigned int level, + const char *format, ...); +void mirror_log_bytes(loginfo_t *info, unsigned int level, + size_t n_bytes, const unsigned char *buf); +loginfo_t *mirror_log_init(char *path, char *prefix, unsigned int verbosity); +int mirror_log_term(loginfo_t *loginfo); + +herr_t run_writer(int socketfd, H5FD_mirror_xmit_open_t *xmit_open); + +#endif /* H5_HAVE_MIRROR_VFD */ + diff --git a/utils/mirror_vfd/mirror_server.c b/utils/mirror_vfd/mirror_server.c new file mode 100644 index 0000000..db7cf04 --- /dev/null +++ b/utils/mirror_vfd/mirror_server.c @@ -0,0 +1,666 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * "Server" application to associate a Mirror VFD Driver with a Writer. + * + * Server waits on a dedicated port for a Driver to attempt to connect. + * When connection is made, reads a message from the Driver. + * If message is "SHUTDOWN", Server closes connection and terminates. + * Else, if it receives an encoded OPEN xmit (from Driver), the Server forks + * itself; the child becomes a dedicated Writer and maintains connection with + * the Driver instance, and the parent process remains a Server and returns + * to listening for incoming requests. + * Else, the message is not recognized and is ignored. + * + * + * + * mirror_server [args] + * + * Primary server for coordinating mirror VFD connections with the remote + * process. + * + * args: + * --help, -h Print help message and exit. + * --port=N Positive integer for primary listening port. + * --verbosity=N Debugging verbosity + * 0: none + * 1: errors + * 2: details + * 3: all + * --logpath=S File path to direct debugging output, if any. + * Default of none prints output to stdout. + * + */ + +#include "mirror_remote.h" + +#ifdef H5_HAVE_MIRROR_VFD + +#define MAXBUF 2048 /* max buffer length. */ +#define LISTENQ 80 /* max pending mirrorS requests */ +#define DEFAULT_PORT 3000 /* default listening port */ +#define MAX_PORT_LOOPS 20 /* max iteratations through port range */ +#define PORT_LOOP_RETRY_DELAY 1 /* seconds to wait between port scans */ + +/* semi-unique "magic" numbers to sanity-check structure pointers */ +#define OP_ARGS_MAGIC 0xCF074379u +#define SERVER_RUN_MAGIC 0x741B459Au + + +/* --------------------------------------------------------------------------- + * Structure: struct op_args + * + * Purpose: Convenience structure for holding arguments from command-line. + * + * `magic` (uint32_t) + * Semi-unique number to help validate a pointer to this struct type. + * Must be OP_ARGS_MAGIC to be considered valid. + * + * `help` (int) + * Flag that the help argument was present in the command line. + * + * `main_port` (int) + * Flag that the help argument was present in the command line. + * + * `verbosity` (int) + * Number between 0 (none) and 4 (all) that controls how much detail + * the program prints as a course of logging. + * + * `log_prepend_serv` (int) + * Flag that the logging messages should have 'S- ' at the start of each + * line. + * + * `log_prepend_type` (int) + * Flag that the logging messages should have the assocaited verbosity + * level present in the line (e.g., "WARN", "ERROR", or "INFO"). + * + * `log_path` (char *) + * Path string from the command line, giving the absolute path + * for the file for logging output. Can be empty. + * + * `writer_log_path` (char *) + * Path string from the command line, giving the absolute path + * for the file for writer's logging output. Can be empty. + * + * --------------------------------------------------------------------------- + */ +struct op_args { + uint32_t magic; + int help; + int main_port; + int verbosity; + int log_prepend_serv; + int log_prepend_type; + char log_path[PATH_MAX+1]; + char writer_log_path[PATH_MAX+1]; +}; + + +/* --------------------------------------------------------------------------- + * Structure: struct server_run + * + * Purpose: Convenience structure for holding information about a server + * in operation. + * + * `magic` (uint32_t) + * Semi-unique number to help validate a pointer to this struct type. + * Must be SERVER_RUN_MAGIC to be considered valid. + * + * `log_stream` (FILE *) + * File handle where logging output is directed. + * By default, is stdout. + * + * `opts` (struct opt_args) + * Contained structure, holds the server's configuration. + * + * `listenfd` (int) + * File descriptor of the listening socket. + * + * --------------------------------------------------------------------------- + */ +struct server_run { + uint32_t magic; + struct op_args opts; + struct mirror_log_info *loginfo; + int listenfd; +}; + + +/* --------------------------------------------------------------------------- + * Function: mybzero + * + * Purpose: Introduce bzero without neededing it on the system. + * + * Programmer: Jacob Smith + * 2020-03-30 + * --------------------------------------------------------------------------- + */ +static void mybzero(void *dest, size_t size) +{ + size_t i = 0; + char *s = NULL; + HDassert(dest); + s = (char *)dest; + for (i = 0; i < size; i++) { + *(s+i) = 0; + } +} /* end mybzero() */ + + +/* --------------------------------------------------------------------------- + * Function: usage + * + * Purpose: Print the usage message to stdout. + * --------------------------------------------------------------------------- + */ +static void +usage(void) +{ + HDfprintf(stdout, + "mirror_server [options]\n" \ + "\n" \ + "Application for providing Mirror Writer process to " \ + " Mirror VFD on file-open.\n" \ + "Listens on a dedicated socket; forks as a Writer upon receipt" \ + " of a valid OPEN xmit.\n" \ + "\n" \ + "Options:\n" \ + "--help [-h] : Print this help message and quit.\n" \ + "--logpath=PATH : File path for logging output " \ + "(default none, to stdout).\n" \ + "--port=PORT : Primary port (default %d).\n" \ + "--verbosity=NUM : Debug printing level " \ + "0..4, (default %d).\n", + DEFAULT_PORT, + MIRROR_LOG_DEFAULT_VERBOSITY); +} /* end usage() */ + + +/* --------------------------------------------------------------------------- + * Function: parse_args + * + * Purpose: Read command line options and store results in args_out + * structure. Fails in event of unrecognized option. + * + * Return: 0 on success, -1 on failure. + * --------------------------------------------------------------------------- + */ +static int +parse_args(int argc, char **argv, struct op_args *args_out) +{ + int i; + + /* preset default values + */ + args_out->main_port = DEFAULT_PORT; + args_out->help = 0; + args_out->log_prepend_serv = 1; + args_out->log_prepend_type = 1; + args_out->verbosity = MIRROR_LOG_DEFAULT_VERBOSITY; + /* preset empty strings */ + mybzero(args_out->log_path, PATH_MAX+1); + mybzero(args_out->writer_log_path, PATH_MAX+1); + + if (argv == NULL || *argv == NULL) { + mirror_log(NULL, V_ERR, "invalid argv pointer"); + return -1; + } + + /* Loop over arguments after program name and writer_path */ + for (i=2; i < argc; i++) { + if (!HDstrncmp(argv[i], "-h", 3) || !HDstrncmp(argv[i], "--help", 7)) { + mirror_log(NULL, V_INFO, "found help argument"); + args_out->help = 1; + return 0; + } /* end if help */ + else + if (!HDstrncmp(argv[i], "--port=", 7)) { + mirror_log(NULL, V_INFO, "parsing 'main_port' (%s)", argv[i]+7); + args_out->main_port = HDatoi(argv[i]+7); + } /* end if port */ + else + if (!HDstrncmp(argv[i], "--verbosity=", 12)) { + mirror_log(NULL, V_INFO, "parsing 'verbosity' (%s)", argv[i]+12); + args_out->verbosity = HDatoi(argv[i]+12); + } /* end if verbosity */ + else + if (!HDstrncmp(argv[i], "--logpath=", 10)) { + mirror_log(NULL, V_INFO, "parsing 'logpath' (%s)", argv[i]+10); + HDstrncpy(args_out->log_path, argv[i]+10, PATH_MAX); + } /* end if logpath */ + else { + mirror_log(NULL, V_ERR, "unrecognized argument: %s", argv[i]); + return -1; + } /* end if unrecognized argument */ + } /* end for each arg after the path to writer "receiver process" */ + + mirror_log(NULL, V_INFO, "all args parsed"); + + return 0; +} /* end parse_args() */ + + +/* --------------------------------------------------------------------------- + * Function: prepare_listening_socket + * + * Purpose: Configure and open a socket. + * In event of error, attempts to undo its processes. + * + * Return: Success: non-negative (the file descriptor of the socket) + * Failure: -1 + * --------------------------------------------------------------------------- + */ +static int +prepare_listening_socket(struct server_run *run) +{ + struct sockaddr_in server_addr; + int _true = 1; /* needed for setsockopt() */ + int ret_value = -1; + int ret = 0; /* for checking return value of function calls */ + + if (run == NULL || run->magic != SERVER_RUN_MAGIC) { + mirror_log(NULL, V_ERR, "invalid server_run pointer"); + return -1; + } + + mirror_log(run->loginfo, V_INFO, "preparing socket"); + + server_addr.sin_family = AF_INET; + server_addr.sin_addr.s_addr = HDhtonl(INADDR_ANY); + server_addr.sin_port = HDhtons((uint16_t)run->opts.main_port); + + mirror_log(run->loginfo, V_INFO, "socket()"); + ret_value = HDsocket(AF_INET, SOCK_STREAM, 0); + if (ret_value < 0) { + mirror_log(run->loginfo, V_ERR, "listening socket:%d", ret_value); + goto error; + } + + mirror_log(run->loginfo, V_ALL, "setsockopt()"); + HDsetsockopt(ret_value, SOL_SOCKET, SO_REUSEADDR, &_true, sizeof(int)); + + mirror_log(run->loginfo, V_INFO, "bind()"); + ret = HDbind(ret_value, (struct sockaddr *)&server_addr, + sizeof(server_addr)); + if (ret < 0) { + mirror_log(run->loginfo, V_ERR, "bind() %s", HDstrerror(errno)); + goto error; + } + + mirror_log(run->loginfo, V_INFO, "listen()"); + ret = HDlisten(ret_value, LISTENQ); + if (ret < 0) { + mirror_log(run->loginfo, V_ERR, "H5FD server listen:%d", ret); + goto error; + } + + return ret_value; + +error: + if (ret_value >= 0) { + HDshutdown(ret_value, SHUT_RDWR); + HDclose(ret_value); + } + return -1; +} /* end prepare_listening_socket() */ + + +/* --------------------------------------------------------------------------- + * Function: init_server_run + * + * Purpose: Set up server_run struct with default and specified values. + * + * Return: Zero (0) if successful, -1 if an error occurred. + * --------------------------------------------------------------------------- + */ +static struct server_run * +init_server_run(int argc, char **argv) +{ + struct server_run *run; + + run = (struct server_run *)HDmalloc(sizeof(struct server_run)); + if (run == NULL) { + mirror_log(NULL, V_ERR, "can't allocate server_run struct"); + return NULL; + } + + run->magic = (uint32_t)SERVER_RUN_MAGIC; + run->opts.magic = (uint32_t)OP_ARGS_MAGIC; + run->listenfd = -1; + + if (parse_args(argc, argv, &(run->opts)) < 0) { + mirror_log(NULL, V_ERR, "can't parse arguments"); + usage(); + goto error; + } + + if (run->opts.help) { + usage(); + return run; /* early exit */ + } + + run->loginfo = mirror_log_init(run->opts.log_path, "s- ", + run->opts.verbosity); + + run->listenfd = prepare_listening_socket(run); + if (run->listenfd < 0) { + mirror_log(NULL, V_ERR, "can't prepare listening socket"); + goto error; + } + + return run; + +error: + if (run != NULL) { + HDfree(run); + } + return NULL; + +} /* end init_server_run() */ + + +/* --------------------------------------------------------------------------- + * Function: term_server_run + * + * Purpose: Close opened items in a sever_run and release the pointer. + * + * Return: Zero (0) if successful, -1 if an error occurred. + * --------------------------------------------------------------------------- + */ +static int +term_server_run(struct server_run *run) +{ + if (run == NULL || run->magic != SERVER_RUN_MAGIC) { + mirror_log(NULL, V_ERR, "invalid server_run pointer"); + return -1; + } + + mirror_log(run->loginfo, V_INFO, "shutting down"); + + if (run->listenfd >= 0) { + HDshutdown(run->listenfd, SHUT_RDWR); /* TODO: error-checking? */ + HDclose(run->listenfd); /* TODO: error-checking? */ + run->listenfd = -1; + } + + if (mirror_log_term(run->loginfo) < 0) { + mirror_log(NULL, V_ERR, "can't close logging stream"); + return -1; /* doesn't solve the problem, but informs of error */ + } + run->loginfo = NULL; + + (run->magic)++; + (run->opts.magic)++; + HDfree(run); + return 0; +} /* end term_server_run() */ + + +/* --------------------------------------------------------------------------- + * Function: accept_connection + * + * Purpose: Main working loop; process requests as they are received. + * Does nothing if the run option help is set. + * + * Return: -1 on error, else a non-negative file descriptor of the socket. + * --------------------------------------------------------------------------- + */ +static int +accept_connection(struct server_run *run) +{ + struct sockaddr_in client_addr; /**/ + socklen_t clilen; /**/ + struct hostent *host_port = NULL; /**/ + char *hostaddrp; /**/ + int connfd = -1; /* connection file descriptor */ + + if (run == NULL || run->magic != SERVER_RUN_MAGIC) { + mirror_log(NULL, V_ERR, "invalid server_run pointer"); + return -1; + } + + /*------------------------------*/ + /* accept a connection on a socket */ + clilen = sizeof(client_addr); + connfd = HDaccept(run->listenfd, (struct sockaddr *)&client_addr, &clilen); + if (connfd < 0) { + mirror_log(run->loginfo, V_ERR, "accept:%d", connfd); + goto error; + } + mirror_log(run->loginfo, V_INFO, "connection achieved"); + + /*------------------------------*/ + /* get client address information */ + host_port = HDgethostbyaddr( + (const char *)&client_addr.sin_addr.s_addr, + sizeof(client_addr.sin_addr.s_addr), + AF_INET); + if (host_port == NULL) { + mirror_log(run->loginfo, V_ERR, "gethostbyaddr()"); + goto error; + } + + /* function has the string space statically scoped -- OK until next call */ + hostaddrp = HDinet_ntoa(client_addr.sin_addr); + /* TODO? proper error-checking */ + + mirror_log(run->loginfo, V_INFO, + "server connected with %s (%s)", + host_port->h_name, + hostaddrp); + + return connfd; + +error: + if (connfd >= 0) { + close(connfd); + } + return -1; +} /* end accept_connection() */ + + +/* --------------------------------------------------------------------------- + * Function: wait_for_child + * + * Purpose: Signal handler to reap zombie processes. + * --------------------------------------------------------------------------- + */ +static void +wait_for_child(int sig) +{ + while (HDwaitpid(-1, NULL, WNOHANG) > 0); +} /* end wait_for_child() */ + + +/* --------------------------------------------------------------------------- + * Function: handle_requests + * + * Purpose: Main working loop; process requests as they are received. + * Does nothing if the run option `help` is set. + * + * Return: -1 on error, else 0 for successful operation. + * --------------------------------------------------------------------------- + */ +static int +handle_requests(struct server_run *run) +{ + int connfd = -1; /**/ + char mybuf[H5FD_MIRROR_XMIT_OPEN_SIZE]; /**/ + int ret; /* general-purpose error-checking */ + int pid; /* process ID of fork */ + struct sigaction sa; + int ret_value = 0; + + if (run == NULL || run->magic != SERVER_RUN_MAGIC) { + mirror_log(NULL, V_ERR, "invalid server_run pointer"); + return -1; + } + + if (run->opts.help) { + return 0; + } + + if (run->listenfd < 0) { + mirror_log(NULL, V_ERR, "invalid listening socket"); + return -1; + } + + /* Set up the signal handler */ + sa.sa_handler = wait_for_child; + HDsigemptyset(&sa.sa_mask); + sa.sa_flags = SA_RESTART; + if (HDsigaction(SIGCHLD, &sa, NULL) == -1) { + perror("sigaction"); + return 1; + } + + /* Keep listening for attempts to connect. + */ + + while (1) { /* infinite loop, exited via break or goto */ + mirror_log(run->loginfo, V_INFO, "server waiting for connections..."); + + connfd = -1; + + connfd = accept_connection(run); + if (connfd < 0) { + mirror_log(run->loginfo, V_ERR, "unable to receive connection"); + goto error; + } + + /* Read handshake from port connection. + */ + + ret = (int)HDread(connfd, &mybuf, H5FD_MIRROR_XMIT_OPEN_SIZE); + if (-1 == ret) { + mirror_log(run->loginfo, V_ERR, "read:%d", ret); + goto error; + } + mirror_log(run->loginfo, V_INFO, "received %d bytes", ret); + mirror_log(run->loginfo, V_ALL, "```"); + mirror_log_bytes(run->loginfo, V_ALL, ret, + (const unsigned char *)mybuf); + mirror_log(run->loginfo, V_ALL, "```"); + + /* Respond to handshake message. + */ + + if (!HDstrncmp("SHUTDOWN", mybuf, 8)) { + /* Stop operation if told to stop */ + mirror_log(run->loginfo, V_INFO, "received SHUTDOWN!", ret); + HDclose(connfd); + connfd = -1; + goto done; + } /* end if explicit "SHUTDOWN" directive */ + else + if (H5FD_MIRROR_XMIT_OPEN_SIZE == ret) { + H5FD_mirror_xmit_open_t xopen; + + mirror_log(run->loginfo, V_INFO, + "probable OPEN xmit received"); + + H5FD_mirror_xmit_decode_open(&xopen, (const unsigned char *)mybuf); + if (FALSE == H5FD_mirror_xmit_is_open(&xopen)) { + mirror_log(run->loginfo, V_WARN, + "expected OPEN xmit was malformed"); + HDclose(connfd); + continue; + } + + mirror_log(run->loginfo, V_INFO, + "probable OPEN xmit confirmed"); + + pid = HDfork(); + if (pid < 0) { /* fork error */ + mirror_log(run->loginfo, V_ERR, "cannot fork"); + goto error; + } /* end if fork error */ + else + if (pid == 0) { /* child process (writer side of fork) */ + mirror_log(run->loginfo, V_INFO, + "executing writer"); + if (run_writer(connfd, &xopen) < 0) { + HDprintf("can't run writer\n"); + } + else { + HDprintf("writer OK\n"); + } + HDclose(connfd); + + HDexit(EXIT_SUCCESS); + } /* end if writer side of fork */ + else { /* parent process (server side of fork) */ + mirror_log(run->loginfo, V_INFO, "tidying up from handshake"); + HDclose(connfd); + } /* end if server side of fork */ + + } /* end else-if valid request for service */ + else { + /* Ignore unrecognized messages */ + HDclose(connfd); + continue; + } /* end else (not a valid message, to be ignored) */ + + } /* end while listening for new connections */ + +done: + if (connfd >= 0) { + mirror_log(run->loginfo, V_WARN, "connfd still open upon cleanup"); + HDclose(connfd); + } + + return ret_value; + +error: + if (connfd >= 0) { + HDclose(connfd); + } + return -1; +} /* end handle_requests() */ + + +/* ------------------------------------------------------------------------- */ +int +main(int argc, char **argv) +{ + struct server_run *run; + + run = init_server_run(argc, argv); + if (NULL == run) { + mirror_log(NULL, V_ERR, "can't initialize run"); + HDexit(EXIT_FAILURE); + } + + if (handle_requests(run) < 0) { + mirror_log(run->loginfo, V_ERR, "problem handling requests"); + } + + if (term_server_run(run) < 0) { + mirror_log(NULL, V_ERR, "problem closing server run"); + HDexit(EXIT_FAILURE); + } + + HDexit(EXIT_SUCCESS); +} /* end main() */ + +#else /* H5_HAVE_MIRROR_VFD */ + +int +main(void) +{ + HDprintf("Mirror VFD was not built -- cannot launch server.\n"); + HDexit(EXIT_FAILURE); +} + +#endif /* H5_HAVE_MIRROR_VFD */ + diff --git a/utils/mirror_vfd/mirror_server_stop.c b/utils/mirror_vfd/mirror_server_stop.c new file mode 100644 index 0000000..f2414e0 --- /dev/null +++ b/utils/mirror_vfd/mirror_server_stop.c @@ -0,0 +1,214 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Stop the mirror server + * Exists for cross-platform, optionally remote shutdown. + */ + +#include "H5private.h" /* System compatability call-wrapper macros */ + +#ifdef H5_HAVE_MIRROR_VFD + +#define MSHS_OPTS_MAGIC 0x613B1C15u /* sanity-checking constant */ +#define MSHS_IP_STR_SIZE 20 +#define MSHS_DEFAULT_IP "127.0.0.1" +#define MSHS_DEFAULT_PORTNO 3000 + + +/* ---------------------------------------------------------------------------- + * Structure: struct mshs_opts + * + * Purpose: Convenience structure to hold options as parsed from the + * command line. + * + * `magic` (uint32_t) + * Semi-unique constant to help verify pointer integrity. + * + * `help` (int) + * Flag that the help argument was present. + * + * `portno` (int) + * Port number, as received from arguments. + * + * `ip` (char *) + * IP address string as received from arguments. + * + * ---------------------------------------------------------------------------- + */ +struct mshs_opts { + uint32_t magic; + int help; + int portno; + char ip[MSHS_IP_STR_SIZE + 1]; +}; + + +/* ---------------------------------------------------------------------------- + * Function: usage + * + * Purpose: Print usage message to stdout. + * ---------------------------------------------------------------------------- + */ +static void +usage(void) +{ + HDprintf("mirror_server_halten_sie [options]\n" \ + "System-independent Mirror Server shutdown program.\n" \ + "Sends shutdown message to Mirror Server at given IP:port\n" \ + "\n" \ + "Options:\n" \ + " -h | --help Print this usage message and exit.\n" \ + " --ip=ADDR IP Address of remote server (defaut %s)\n" \ + " --port=PORT Handshake port of remote server (default %d)\n", + MSHS_DEFAULT_IP, + MSHS_DEFAULT_PORTNO); +} /* end usage() */ + + +/* ---------------------------------------------------------------------------- + * Function: parse_args + * + * Purpose: Parse command-line arguments, populating the options struct + * pointer as appropriate. + * Default values will be set for unspecified options. + * + * Return: 0 on success, negative (-1) if error. + * ---------------------------------------------------------------------------- + */ +static int +parse_args(int argc, char **argv, struct mshs_opts *opts) +{ + int i = 0; + + opts->magic = MSHS_OPTS_MAGIC; + opts->help = 0; + opts->portno = MSHS_DEFAULT_PORTNO; + HDstrncpy(opts->ip, MSHS_DEFAULT_IP, MSHS_IP_STR_SIZE); + + for (i=1; i < argc; i++) { /* start with first possible option argument */ + if (!HDstrncmp(argv[i], "-h", 3) || !HDstrncmp(argv[i], "--help", 7)) { + opts->help = 1; + } + else + if (!HDstrncmp(argv[i], "--ip=", 5)) { + HDstrncpy(opts->ip, argv[i]+5, MSHS_IP_STR_SIZE); + } + else + if (!HDstrncmp(argv[i], "--port=", 7)) { + opts->portno = HDatoi(argv[i]+7); + } + else { + HDprintf("Unrecognized option: '%s'\n", argv[i]); + usage(); + opts->magic++; /* invalidate for sanity */ + return -1; + } + } /* end for each argument from command line */ + + /* auto-replace 'localhost' with numeric IP */ + if (!HDstrncmp(opts->ip, "localhost", 10)) { /* include null terminator */ + HDstrncpy(opts->ip, "127.0.0.1", MSHS_IP_STR_SIZE); + } + + return 0; +} /* end parse_args() */ + + +/* ---------------------------------------------------------------------------- + * Function: send_shutdown + * + * Purpose: Create socket and send shutdown signal to remote server. + * + * Return: 0 on success, negative (-1) if error. + * ---------------------------------------------------------------------------- + */ +static int +send_shutdown(struct mshs_opts *opts) +{ + int live_socket; + struct sockaddr_in target_addr; + + if (opts->magic != MSHS_OPTS_MAGIC) { + HDprintf("invalid options structure\n"); + return -1; + } + + live_socket = HDsocket(AF_INET, SOCK_STREAM, 0); + if (live_socket < 0) { + HDprintf("ERROR socket()\n"); + return -1; + } + + target_addr.sin_family = AF_INET; + target_addr.sin_port = HDhtons((uint16_t)opts->portno); + target_addr.sin_addr.s_addr = HDinet_addr(opts->ip); + HDmemset(target_addr.sin_zero, '\0', sizeof(target_addr.sin_zero)); + + if (HDconnect(live_socket, (struct sockaddr *)&target_addr, + (socklen_t)sizeof(target_addr)) + < 0) + { + HDprintf("ERROR connect() (%d)\n%s\n", errno, HDstrerror(errno)); + return -1; + } + + if (HDwrite(live_socket, "SHUTDOWN", 9) == -1) { + HDprintf("ERROR write() (%d)\n%s\n", errno, HDstrerror(errno)); + return -1; + } + + if (HDclose(live_socket) < 0) { + HDprintf("ERROR close() can't close socket\n"); + return -1; + } + + return 0; +} /* end send_shutdown() */ + + +/* ------------------------------------------------------------------------- */ +int +main(int argc, char **argv) +{ + struct mshs_opts opts; + + if (parse_args(argc, argv, &opts) < 0) { + HDprintf("Unable to parse arguments\n"); + HDexit(EXIT_FAILURE); + } + + if (opts.help) { + usage(); + HDexit(EXIT_FAILURE); + } + + if (send_shutdown(&opts) < 0) { + HDprintf("Unable to send shutdown command\n"); + HDexit(EXIT_FAILURE); + } + + HDexit(EXIT_SUCCESS); +} /* end main() */ + +#else /* H5_HAVE_MIRROR_VFD */ + + +/* ------------------------------------------------------------------------- */ +int +main(void) +{ + HDprintf("Mirror VFD not built -- unable to perform shutdown.\n"); + HDexit(EXIT_FAILURE); +} + +#endif /* H5_HAVE_MIRROR_VFD */ diff --git a/utils/mirror_vfd/mirror_writer.c b/utils/mirror_vfd/mirror_writer.c new file mode 100644 index 0000000..e1ab1b2 --- /dev/null +++ b/utils/mirror_vfd/mirror_writer.c @@ -0,0 +1,1103 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Remote writer process for the mirror (socket) VFD. + * + * Writer is started with arguments for slaved port. + * Awaits a connection on the socket. + * Handles instructions from the master 'Driver' process. + * + * Current implementation uses Sec2 as the underlying driver when opening a + * file. This is reflected in the source (H5FDmirror.c) of the Mirror driver. + */ + +#include "mirror_remote.h" + +#ifdef H5_HAVE_MIRROR_VFD + +#define HEXDUMP_XMITS 1 /* Toggle whether to print xmit bytes-blob */ + /* in detailed logging */ +#define HEXDUMP_WRITEDATA 0 /* Toggle whether to print bytes to write */ + /* in detailed logging */ +#define LISTENQ 80 /* max pending Driver requests */ + +#define MW_SESSION_MAGIC 0x88F36B32u +#define MW_SOCK_COMM_MAGIC 0xDF10A157u +#define MW_OPTS_MAGIC 0x3BA8B462u + + +/* --------------------------------------------------------------------------- + * Structure: struct mirror_session + * + * Bundle of information used to manage the operation of this remote Writer + * in a "session" with the Driver process. + * + * magic (uint32_t) + * Semi-unique "magic" number used to sanity-check a structure for + * validity. MUST equal MW_SESSION_MAGIC to be valid. + * + * sockfd (int) + * File descriptor to the socket. + * Used for receiving bytes from and writing bytes to the Driver + * across the network. + * If not NULL, should be a valid descriptor. + * + * token (uint32t) + * Number used to help sanity-check received transmission from the Writer. + * Each Driver/Writer pairing should have a semi-unique "token" to help + * guard against commands from the wrong entity. + * + * xmit_count (uint32_t) + * Record of trasmissions received from the Driver. While the transmission + * protocol should be trustworthy, this serves as an additional guard. + * Starts a 0 and should be incremented for each one-way transmission. + * + * file (H5FD_t *) + * Virtual File handle for the hdf5 file. + * Set on file open if H5Fopen() is successful. If NULL, it is invalid. + * + * log_verbosity (unsigned int) + * The verbosity level for logging. Should be set to one of the values + * defined at the top of this file. + * + * log_stream (FILE *) + * File pointer to which logging output is written. Starts (and ends) + * with a default stream, such as stdout, but can be overridden at + * runtime. + * + * reply (H5FD_mirror_xmit_reply_t) + * Structure space for persistent reply data. + * Should be initialized with basic header info (magic, version, op), + * then with session info (token, xmit count), and finally with specific + * reply info (update xmit_count, status code, and message) before + * transmission. + * + * ---------------------------------------------------------------------------- + */ +struct mirror_session { + uint32_t magic; + int sockfd; + uint32_t token; + uint32_t xmit_count; + H5FD_t *file; + loginfo_t *loginfo; + H5FD_mirror_xmit_reply_t reply; +}; + + +/* --------------------------------------------------------------------------- + * Structure: struct sock_comm + * + * Structure for placing the data read and pre-processed from Driver in an + * organized fashion. Useful for pre-processing a received xmit. + * + * magic (uint32_t) + * Semi-unique number to sanity-check structure pointer and validity. + * Must equal MW_SOCK_COMM_MAGIC to be valid. + * + * recd_die (int) + * "Boolean" flag indicating that an explicit shutdown/kill/die command + * was received. Potentially useful for debugging and or "manual" + * operation of the program. + * 0 indicates normal operation, non-0 (1) indicates to die. + * + * xmit_recd (H5FD_mirror_xmit_t *) + * Structure pointer for the "xmit header" as decoded from the raw + * binary stream read from the socket. + * + * raw (char *) + * Pointer to a raw byte array, for storing data as read from the + * socket. Bytes buffer is decoded into xmit_t header and derivative + * structures. + * + * raw_size (size_t) + * Give the size of the `raw` buffer. + * + * --------------------------------------------------------------------------- + */ +struct sock_comm { + uint32_t magic; + int recd_die; + H5FD_mirror_xmit_t *xmit_recd; + char *raw; + size_t raw_size; +}; + + +/* --------------------------------------------------------------------------- + * Structure: struct mirror_writer_opts + * + * Container for default values and options as parsed from the command line. + * Currently rather vestigal, but may be expanded and/or moved to be set by + * Server and passed around as an argument. + * + * magic (uint32_t) + * Semi-unique number to sanity-check structure pointer and validity. + * Must equal MW_OPTS_MAGIC to be valid. + * + * logpath (char *) + * String pointer. Allocated at runtime. + * Specifies file location for logging output. + * May be NULL -- uses default output (e.g., stdout). + * + * ---------------------------------------------------------------------------- + */ +struct mirror_writer_opts { + uint32_t magic; + char *logpath; +}; + +static void mybzero(void *dest, size_t size); + +static int do_open(struct mirror_session *session, + const H5FD_mirror_xmit_open_t *xmit_open); + + +/* --------------------------------------------------------------------------- + * Function: mybzero + * + * Purpose: Introduce bzero without neededing it on the system. + * + * Programmer: Jacob Smith + * 2020-03-30 + * --------------------------------------------------------------------------- + */ +static void mybzero(void *dest, size_t size) +{ + size_t i = 0; + char *s = NULL; + HDassert(dest); + s = (char *)dest; + for (i = 0; i < size; i++) { + *(s+i) = 0; + } +} /* end mybzero() */ + + +/* --------------------------------------------------------------------------- + * Function: session_init + * + * Purpose: Populate mirror_session structure with default and + * options-drived values. + * + * Return: An allocated mirror_session structure pointer on success, + * else NULL. + * ---------------------------------------------------------------------------- + */ +static struct mirror_session * +session_init(struct mirror_writer_opts *opts) +{ + struct mirror_session *session = NULL; + + mirror_log(NULL, V_INFO, "session_init()"); + + if (NULL == opts || opts->magic != MW_OPTS_MAGIC) { + mirror_log(NULL, V_ERR, "invalid opts pointer"); + goto error; + } + + session = (struct mirror_session *)HDmalloc(sizeof(struct mirror_session)); + if (session == NULL) { + mirror_log(NULL, V_ERR, "can't allocate session structure"); + goto error; + } + + session->magic = MW_SESSION_MAGIC; + session->sockfd = -1; + session->xmit_count = 0; + session->token = 0; + session->file = NULL; + + session->reply.pub.magic = H5FD_MIRROR_XMIT_MAGIC; + session->reply.pub.version = H5FD_MIRROR_XMIT_CURR_VERSION; + session->reply.pub.op = H5FD_MIRROR_OP_REPLY; + session->reply.pub.session_token = 0; + mybzero(session->reply.message, H5FD_MIRROR_STATUS_MESSAGE_MAX); + + /* Options-derived population + */ + + session->loginfo = mirror_log_init(opts->logpath, "W- ", + MIRROR_LOG_DEFAULT_VERBOSITY); + + return session; + +error: + if (session) { + HDfree(session); + } + return NULL; +} /* end session_init() */ + + +/* --------------------------------------------------------------------------- + * Function: session_stop + * + * Purpose: Stop and clean up a session. + * Only do this as part of program termination or aborting startup. + * + * Return: 0 on success, or negative sum of errors encountered. + * ---------------------------------------------------------------------------- + */ +static int +session_stop(struct mirror_session *session) +{ + int ret_value = 0; + + HDassert(session && (session->magic == MW_SESSION_MAGIC)); + + mirror_log(session->loginfo, V_INFO, "session_stop()"); + + /* Close HDF5 file if it is still open (probably in error) */ + if (session->file) { + mirror_log(session->loginfo, V_WARN, "HDF5 file still open at cleanup"); + if (H5FDclose(session->file) < 0) { + mirror_log(session->loginfo, V_ERR, "H5FDclose() during cleanup!"); + ret_value--; + } + } + + /* Socket will be closed by parent side of server fork after exit */ + + /* Close custom logging stream */ + if (mirror_log_term(session->loginfo) < 0) { + mirror_log(NULL, V_ERR, "Problem closing logging stream"); + ret_value--; + } + session->loginfo = NULL; + + /* Invalidate and release structure */ + session->magic++; + HDfree(session); + + return ret_value; +} /* end session_stop() */ + + +/* --------------------------------------------------------------------------- + * Function: session_start + * + * Purpose: Initiate session, open files. + * + * Return: Success: A valid mirror_session pointer which must later be + * cleaned up with session_stop(). + * Failure: NULL, after cleaning up after itself. + * --------------------------------------------------------------------------- + */ +static struct mirror_session * +session_start(int socketfd, const H5FD_mirror_xmit_open_t *xmit_open) +{ + struct mirror_session *session = NULL; + struct mirror_writer_opts opts; +#if 0 /* TODO: behaviro option */ + char logpath[H5FD_MIRROR_XMIT_FILEPATH_MAX] = ""; +#endif + + mirror_log(NULL, V_INFO, "session_start()"); + + if (FALSE == H5FD_mirror_xmit_is_open(xmit_open)) { + mirror_log(NULL, V_ERR, "invalid OPEN xmit"); + return NULL; + } + + opts.magic = MW_OPTS_MAGIC; +#if 0 /* TODO: behavior option */ + HDsnprintf(logpath, H5FD_MIRROR_XMIT_FILEPATH_MAX, "%s.log", + xmit_open->filename); + opts.logpath = logpath; +#else + opts.logpath = NULL; +#endif + + session = session_init(&opts); + if (NULL == session) { + mirror_log(NULL, V_ERR, "can't instantiate session"); + goto error; + } + + session->sockfd = socketfd; + + if (do_open(session, xmit_open) < 0) { + mirror_log(NULL, V_ERR, "unable to open file"); + goto error; + } + + return session; + +error: + if (session != NULL) { + if (session_stop(session) < 0) { + mirror_log(NULL, V_WARN, "Can't abort session init"); + } + session = NULL; + } + return NULL; +} + + +/* --------------------------------------------------------------------------- + * Function: _xmit_reply + * + * Purpose: Common operations to send a reply xmit through the session. + * + * Return: 0 on success, -1 if error. + * ---------------------------------------------------------------------------- + */ +static int +_xmit_reply(struct mirror_session *session) +{ + unsigned char xmit_buf[H5FD_MIRROR_XMIT_REPLY_SIZE]; + H5FD_mirror_xmit_reply_t *reply = &(session->reply); + + HDassert(session && (session->magic == MW_SESSION_MAGIC)); + + mirror_log(session->loginfo, V_ALL, "_xmit_reply()"); + + reply->pub.xmit_count = session->xmit_count++; + if (H5FD_mirror_xmit_encode_reply(xmit_buf, + (const H5FD_mirror_xmit_reply_t *)reply) + != H5FD_MIRROR_XMIT_REPLY_SIZE) + { + mirror_log(session->loginfo, V_ERR, "can't encode reply"); + return -1; + } + + mirror_log(session->loginfo, V_ALL, "reply xmit data\n```"); + mirror_log_bytes(session->loginfo, V_ALL, H5FD_MIRROR_XMIT_REPLY_SIZE, + (const unsigned char *)xmit_buf); + mirror_log(session->loginfo, V_ALL, "```"); + + if (HDwrite(session->sockfd, xmit_buf, H5FD_MIRROR_XMIT_REPLY_SIZE) < 0) { + mirror_log(session->loginfo, V_ERR, "can't write reply to Driver"); + return -1; + } + + return 0; +} /* end _xmit_reply() */ + + +/* --------------------------------------------------------------------------- + * Function: reply_ok + * + * Purpose: Send an OK reply through the session. + * + * Return: 0 on success, -1 if error. + * --------------------------------------------------------------------------- + */ +static int +reply_ok(struct mirror_session *session) +{ + H5FD_mirror_xmit_reply_t *reply = &(session->reply); + + HDassert(session && (session->magic == MW_SESSION_MAGIC)); + + mirror_log(session->loginfo, V_ALL, "reply_ok()"); + + reply->status = H5FD_MIRROR_STATUS_OK; + mybzero(reply->message, H5FD_MIRROR_STATUS_MESSAGE_MAX); + return _xmit_reply(session); +} /* end reply_ok() */ + + +/* --------------------------------------------------------------------------- + * Function: reply_error + * + * Purpose: Send an ERROR reply with message through the session. + * Message may be cut short if it would overflow the available + * buffer in the xmit. + * + * Return: 0 on success, -1 if error. + * --------------------------------------------------------------------------- + */ +static int +reply_error(struct mirror_session *session, + const char *msg) +{ + H5FD_mirror_xmit_reply_t *reply = &(session->reply); + + HDassert(session && (session->magic == MW_SESSION_MAGIC)); + + mirror_log(session->loginfo, V_ALL, "reply_error(%s)", msg); + + reply->status = H5FD_MIRROR_STATUS_ERROR; + HDsnprintf(reply->message, H5FD_MIRROR_STATUS_MESSAGE_MAX-1, "%s", msg); + return _xmit_reply(session); +} /* end reply_error() */ + + +/* --------------------------------------------------------------------------- + * Function: do_close + * + * Purpose: Handle an CLOSE operation. + * + * Return: 0 on success, -1 if error. + * --------------------------------------------------------------------------- + */ +static int +do_close(struct mirror_session *session) +{ + + HDassert(session && (session->magic == MW_SESSION_MAGIC)); + + mirror_log(session->loginfo, V_INFO, "do_close()"); + + if (NULL == session->file) { + mirror_log(session->loginfo, V_ERR, "no file to close!"); + reply_error(session, "no file to close"); + return -1; + } + + if (H5FDclose(session->file) < 0) { + mirror_log(session->loginfo, V_ERR, "H5FDclose()"); + reply_error(session, "H5FDclose()"); + return -1; + } + session->file = NULL; + + if (reply_ok(session) < 0) { + mirror_log(session->loginfo, V_ERR, "can't reply"); + reply_error(session, "ok reply failed; session contaminated"); + return -1; + } + + return 0; +} /* end do_close() */ + + +/* --------------------------------------------------------------------------- + * Function: do_lock + * + * Purpose: Handle a LOCK operation. + * + * Return: 0 on success, -1 if error. + * --------------------------------------------------------------------------- + */ +static int +do_lock(struct mirror_session *session, + const unsigned char *xmit_buf) +{ + size_t decode_ret = 0; + H5FD_mirror_xmit_lock_t xmit_lock; + + HDassert(session && (session->magic == MW_SESSION_MAGIC) && xmit_buf); + + mirror_log(session->loginfo, V_INFO, "do_lock()"); + + decode_ret = H5FD_mirror_xmit_decode_lock(&xmit_lock, xmit_buf); + if (H5FD_MIRROR_XMIT_LOCK_SIZE != decode_ret) { + mirror_log(session->loginfo, V_ERR, "can't decode set-eoa xmit"); + reply_error(session, "remote xmit_eoa_t decoding size failure"); + return -1; + } + + if (!H5FD_mirror_xmit_is_lock(&xmit_lock)) { + mirror_log(session->loginfo, V_ERR, "not a set-eoa xmit"); + reply_error(session, "remote xmit_eoa_t decode failure"); + return -1; + } + mirror_log(session->loginfo, V_INFO, "lock rw: (%d)", xmit_lock.rw); + + if (H5FDlock(session->file, (hbool_t)xmit_lock.rw) < 0) { + mirror_log(session->loginfo, V_ERR, "H5FDlock()"); + reply_error(session, "remote H5FDlock() failure"); + return -1; + } + + if (reply_ok(session) < 0) { + mirror_log(session->loginfo, V_ERR, "can't reply"); + reply_error(session, "ok reply failed; session contaminated"); + return -1; + } + + return 0; +} /* end do_lock() */ + + +/* --------------------------------------------------------------------------- + * Function: do_open + * + * Purpose: Handle an OPEN operation. + * + * Return: 0 on success, -1 if error. + * --------------------------------------------------------------------------- + */ +static int +do_open(struct mirror_session *session, + const H5FD_mirror_xmit_open_t *xmit_open) +{ + hid_t fapl_id = H5I_INVALID_HID; + unsigned _flags = 0; + haddr_t _maxaddr = HADDR_UNDEF; + + HDassert(session && (session->magic == MW_SESSION_MAGIC) && xmit_open && + TRUE == H5FD_mirror_xmit_is_open(xmit_open)); + + mirror_log(session->loginfo, V_INFO, "do_open()"); + + if (0 != xmit_open->pub.xmit_count) { + mirror_log(session->loginfo, V_ERR, "open with xmit count not zero!"); + reply_error(session, "initial transmission count not zero"); + goto error; + } + if (0 != session->token) { + mirror_log(session->loginfo, V_ERR, "open with token already set!"); + reply_error(session, "initial session token not zero"); + goto error; + } + + session->xmit_count = 1; + session->token = xmit_open->pub.session_token; + session->reply.pub.session_token = session->token; + + _flags = (unsigned)xmit_open->flags; + _maxaddr = (haddr_t)xmit_open->maxaddr; + + /* Check whether the native size_t on the remote machine (Driver) is larger + * than that on the local machine; if so, issue a warning. + * The blob is always an 8-byte bitfield -- check its contents. + */ + if (xmit_open->size_t_blob > (uint64_t)((size_t)(-1))) { + mirror_log(session->loginfo, V_WARN, + "Driver size_t is larger than our own"); + } + + mirror_log(session->loginfo, V_INFO, + "to open file %s (flags %d) (maxaddr %d)", + xmit_open->filename, _flags, _maxaddr); + + /* Explicitly use Sec2 as the underlying driver for now. + */ + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + if (fapl_id < 0) { + mirror_log(session->loginfo, V_ERR, "can't create FAPL"); + reply_error(session, "H5Pcreate() failure"); + goto error; + } + if (H5Pset_fapl_sec2(fapl_id) < 0) { + mirror_log(session->loginfo, V_ERR, "can't set FAPL as Sec2"); + reply_error(session, "H5Pset_fapl_sec2() failure"); + goto error; + } + + session->file = H5FDopen(xmit_open->filename, _flags, fapl_id, _maxaddr); + if (NULL == session->file) { + mirror_log(session->loginfo, V_ERR, "H5FDopen()"); + reply_error(session, "remote H5FDopen() failure"); + goto error; + } + + /* FAPL is set and in use; clean up */ + if (H5Pclose(fapl_id) < 0) { + mirror_log(session->loginfo, V_ERR, "can't set FAPL as Sec2"); + reply_error(session, "H5Pset_fapl_sec2() failure"); + goto error; + } + + if (reply_ok(session) < 0) { + mirror_log(session->loginfo, V_ERR, "can't reply"); + reply_error(session, "ok reply failed; session contaminated"); + return -1; + } + + return 0; + +error: + if (fapl_id > 0) { + H5E_BEGIN_TRY { + (void)H5Pclose(fapl_id); + } H5E_END_TRY; + } + return -1; +} /* end do_open() */ + + +/* --------------------------------------------------------------------------- + * Function: do_set_eoa + * + * Purpose: Handle a SET_EOA operation. + * + * Return: 0 on success, -1 if error. + * --------------------------------------------------------------------------- + */ +static int +do_set_eoa(struct mirror_session *session, + const unsigned char *xmit_buf) +{ + size_t decode_ret = 0; + H5FD_mirror_xmit_eoa_t xmit_seoa; + + HDassert(session && (session->magic == MW_SESSION_MAGIC) && xmit_buf); + + mirror_log(session->loginfo, V_INFO, "do_set_eoa()"); + + decode_ret = H5FD_mirror_xmit_decode_set_eoa(&xmit_seoa, xmit_buf); + if (H5FD_MIRROR_XMIT_EOA_SIZE != decode_ret) { + mirror_log(session->loginfo, V_ERR, "can't decode set-eoa xmit"); + reply_error(session, "remote xmit_eoa_t decoding size failure"); + return -1; + } + + if (!H5FD_mirror_xmit_is_set_eoa(&xmit_seoa)) { + mirror_log(session->loginfo, V_ERR, "not a set-eoa xmit"); + reply_error(session, "remote xmit_eoa_t decode failure"); + return -1; + } + + mirror_log(session->loginfo, V_INFO, "set EOA addr %d", + xmit_seoa.eoa_addr); + + if (H5FDset_eoa(session->file, (H5FD_mem_t)xmit_seoa.type, + (haddr_t)xmit_seoa.eoa_addr) + < 0) + { + mirror_log(session->loginfo, V_ERR, "H5FDset_eoa()"); + reply_error(session, "remote H5FDset_eoa() failure"); + return -1; + } + + if (reply_ok(session) < 0) { + mirror_log(session->loginfo, V_ERR, "can't reply"); + reply_error(session, "ok reply failed; session contaminated"); + return -1; + } + + return 0; +} /* end do_set_eoa() */ + + +/* --------------------------------------------------------------------------- + * Function: do_truncate + * + * Purpose: Handle a TRUNCATE operation. + * + * Return: 0 on success, -1 if error. + * --------------------------------------------------------------------------- + */ +static int +do_truncate(struct mirror_session *session) +{ + + HDassert(session && (session->magic == MW_SESSION_MAGIC)); + + mirror_log(session->loginfo, V_INFO, "do_truncate()"); + + /* default DXPL ID (0), 0 for "FALSE" closing -- both probably unused */ + if (H5FDtruncate(session->file, 0, 0) < 0) { + mirror_log(session->loginfo, V_ERR, "H5FDtruncate()"); + reply_error(session, "remote H5FDtruncate() failure"); + return -1; + } + + if (reply_ok(session) < 0) { + mirror_log(session->loginfo, V_ERR, "can't reply"); + reply_error(session, "ok reply failed; session contaminated"); + return -1; + } + + return 0; +} /* end do_truncate() */ + + +/* --------------------------------------------------------------------------- + * Function: do_unlock + * + * Purpose: Handle an UNLOCK operation. + * + * Return: 0 on success, -1 if error. + * --------------------------------------------------------------------------- + */ +static int +do_unlock(struct mirror_session *session) +{ + HDassert(session && (session->magic == MW_SESSION_MAGIC)); + + mirror_log(session->loginfo, V_INFO, "do_unlock()"); + + if (H5FDunlock(session->file) < 0) { + mirror_log(session->loginfo, V_ERR, "H5FDunlock()"); + reply_error(session, "remote H5FDunlock() failure"); + return -1; + } + + if (reply_ok(session) < 0) { + mirror_log(session->loginfo, V_ERR, "can't reply"); + reply_error(session, "ok reply failed; session contaminated"); + return -1; + } + + return 0; +} /* end do_unlock() */ + + +/* --------------------------------------------------------------------------- + * Function: do_write + * + * Purpose: Handle a WRITE operation. + * Receives command, replies; receives & writes data, replies. + * + * It is known that this results in suboptimal performance, + * but handling both small and very, very large write buffers + * with a single "over the wire" exchange + * poses design challenges not worth tackling as of March 2020. + * + * Return: 0 on success, -1 if error. + * --------------------------------------------------------------------------- + */ +static int +do_write(struct mirror_session *session, + const unsigned char *xmit_buf) +{ + size_t decode_ret = 0; + haddr_t addr = 0; + haddr_t sum_bytes_written = 0; + H5FD_mem_t type = 0; + char *buf = NULL; + ssize_t nbytes_in_packet = 0; + H5FD_mirror_xmit_write_t xmit_write; + + HDassert(session && (session->magic == MW_SESSION_MAGIC) && xmit_buf); + + mirror_log(session->loginfo, V_INFO, "do_write()"); + + if (NULL == session->file) { + mirror_log(session->loginfo, V_ERR, "no open file!"); + reply_error(session, "no file open on remote"); + return -1; + } + + decode_ret = H5FD_mirror_xmit_decode_write(&xmit_write, xmit_buf); + if (H5FD_MIRROR_XMIT_WRITE_SIZE != decode_ret) { + mirror_log(session->loginfo, V_ERR, "can't decode write xmit"); + reply_error(session, "remote xmit_write_t decoding size failure"); + return -1; + } + + if (!H5FD_mirror_xmit_is_write(&xmit_write)) { + mirror_log(session->loginfo, V_ERR, "not a write xmit"); + reply_error(session, "remote xmit_write_t decode failure"); + return -1; + } + + addr = (haddr_t)xmit_write.offset; + type = (H5FD_mem_t)xmit_write.type; + + /* Allocate the buffer once -- re-use between loops. + */ + buf = (char *)HDmalloc(sizeof(char) * H5FD_MIRROR_DATA_BUFFER_MAX); + if (NULL == buf) { + mirror_log(session->loginfo, V_ERR, "can't allocate databuffer"); + reply_error(session, "can't allocate buffer for receiving data"); + return -1; + } + + /* got write signal; ready for data */ + if (reply_ok(session) < 0) { + mirror_log(session->loginfo, V_ERR, "can't reply"); + reply_error(session, "ok reply failed; session contaminated"); + return -1; + } + + mirror_log(session->loginfo, V_INFO, "to write %zu bytes at %zu", + xmit_write.size, + addr); + + /* The given write may be: + * 1. larger than the allowed single buffer size + * 2. larger than the native size_t of this system + * + * Handle all cases by looping, ingesting as much of the stream as possible + * and writing that part to the file. + */ + sum_bytes_written = 0; + do { + nbytes_in_packet = HDread(session->sockfd, buf, + H5FD_MIRROR_DATA_BUFFER_MAX); + if (-1 == nbytes_in_packet) { + mirror_log(session->loginfo, V_ERR, "can't read into databuffer"); + reply_error(session, "can't read data buffer"); + return -1; + } + + mirror_log(session->loginfo, V_INFO, "received %zd bytes", + nbytes_in_packet); + if (HEXDUMP_WRITEDATA) { + mirror_log(session->loginfo, V_ALL, "DATA:\n```"); + mirror_log_bytes(session->loginfo, V_ALL, nbytes_in_packet, + (const unsigned char *)buf); + mirror_log(session->loginfo, V_ALL, "```"); + } + + mirror_log(session->loginfo, V_INFO, "writing %zd bytes at %zu", + nbytes_in_packet, + (addr + sum_bytes_written)); + + if (H5FDwrite(session->file, type, H5P_DEFAULT, + (addr + sum_bytes_written), (size_t)nbytes_in_packet, buf) + < 0) + { + mirror_log(session->loginfo, V_ERR, "H5FDwrite()"); + reply_error(session, "remote H5FDwrite() failure"); + return -1; + } + + sum_bytes_written += (haddr_t)nbytes_in_packet; + + } while (sum_bytes_written < xmit_write.size); /* end while ingesting */ + + HDfree(buf); + + /* signal that we're done here and a-ok */ + if (reply_ok(session) < 0) { + mirror_log(session->loginfo, V_ERR, "can't reply"); + reply_error(session, "ok reply failed; session contaminated"); + return -1; + } + + return 0; +} /* end do_write() */ + + +/* --------------------------------------------------------------------------- + * Function: receive_communique + * + * Purpose: Accept bytes from the socket, check for emergency shutdown, and + * sanity-check received bytes. + * The raw bytes read are stored in the sock_comm structure at + * comm->raw. + * The raw bytes are decoded and a xmit_t (header) struct pointer + * in comm is populated at comm->xmit_recd. + * + * Return: 0 on success, -1 if error. + * --------------------------------------------------------------------------- + */ +static int +receive_communique( + struct mirror_session *session, + struct sock_comm *comm) +{ + ssize_t read_ret = 0; + size_t decode_ret; + H5FD_mirror_xmit_t *X = comm->xmit_recd; + + HDassert((session != NULL) && \ + (session->magic == MW_SESSION_MAGIC) && \ + (comm != NULL) && \ + (comm->magic == MW_SOCK_COMM_MAGIC) && \ + (comm->xmit_recd != NULL) && \ + (comm->raw != NULL) && \ + (comm->raw_size >= H5FD_MIRROR_XMIT_BUFFER_MAX) ); + + mirror_log(session->loginfo, V_INFO, "receive_communique()"); + + mybzero(comm->raw, comm->raw_size); + comm->recd_die = 0; + + mirror_log(session->loginfo, V_INFO, "ready to receive"); /* TODO */ + + read_ret = HDread(session->sockfd, comm->raw, H5FD_MIRROR_XMIT_BUFFER_MAX); + if (-1 == read_ret) { + mirror_log(session->loginfo, V_ERR, "read:%zd", read_ret); + goto error; + } + + mirror_log(session->loginfo, V_INFO, "received %zd bytes", read_ret); + if (HEXDUMP_XMITS) { + mirror_log(session->loginfo, V_ALL, "```", read_ret); + mirror_log_bytes(session->loginfo, V_ALL, (size_t)read_ret, + (const unsigned char *)comm->raw); + mirror_log(session->loginfo, V_ALL, "```"); + } /* end if hexdump transmissions received */ + + /* old-fashioned manual kill (for debugging) */ + if (!HDstrncmp("GOODBYE", comm->raw, 7)) { + mirror_log(session->loginfo, V_INFO, "received GOODBYE"); + comm->recd_die = 1; + goto done; + } + + decode_ret = H5FD_mirror_xmit_decode_header(X, + (const unsigned char *)comm->raw); + if (H5FD_MIRROR_XMIT_HEADER_SIZE != decode_ret) { + mirror_log(session->loginfo, V_ERR, + "header decode size mismatch: expected (%z), got (%z)", + H5FD_MIRROR_XMIT_HEADER_SIZE, decode_ret); + /* Try to tell Driver that it should stop */ + reply_error(session, "xmit size mismatch"); + goto error; + } + + if (!H5FD_mirror_xmit_is_xmit(X)) { + mirror_log(session->loginfo, V_ERR, "bad magic: 0x%X", X->magic); + /* Try to tell Driver that it should stop */ + reply_error(session, "bad magic"); + goto error; + } + + if (session->xmit_count != X->xmit_count) { + mirror_log(session->loginfo, V_ERR, + "xmit_count mismatch exp:%d recd:%d", + session->xmit_count, X->xmit_count); + /* Try to tell Driver that it should stop */ + reply_error(session, "xmit_count mismatch"); + goto error; + } + + if ( (session->token > 0) && (session->token != X->session_token) ) { + mirror_log(session->loginfo, V_ERR, "wrong session"); + /* Try to tell Driver that it should stop */ + reply_error(session, "wrong session"); + goto error; + } + + session->xmit_count++; + +done: + return 0; + +error: + return -1; +} /* end receive_communique() */ + + +/* --------------------------------------------------------------------------- + * Function: process_instructions + * + * Purpose: Receive and handle all instructions from Driver. + * + * Return: 0 on success, -1 if error. + * --------------------------------------------------------------------------- + */ +static int +process_instructions(struct mirror_session *session) +{ + struct sock_comm comm; + char xmit_buf[H5FD_MIRROR_XMIT_BUFFER_MAX]; /* raw bytes */ + H5FD_mirror_xmit_t xmit_recd; /* for decoded xmit header */ + + HDassert(session && (session->magic == MW_SESSION_MAGIC)); + + mirror_log(session->loginfo, V_INFO, "process_instructions()"); + + comm.magic = MW_SOCK_COMM_MAGIC; + comm.recd_die = 0; /* Flag for program to terminate */ + comm.xmit_recd = &xmit_recd; + comm.raw = xmit_buf; + comm.raw_size = sizeof(xmit_buf); + + while (1) { /* sill-listening infinite loop */ + + /* Use convenience structure for raw/decoded info in/out */ + if (receive_communique(session, &comm) < 0) { + mirror_log(session->loginfo, V_ERR, "problem reading socket"); + return -1; + } + + if (comm.recd_die) { + goto done; + } + + switch(xmit_recd.op) { + case H5FD_MIRROR_OP_CLOSE: + if (do_close(session) < 0) { + return -1; + } + goto done; + case H5FD_MIRROR_OP_LOCK: + if (do_lock(session, (const unsigned char *)xmit_buf) < 0) { + return -1; + } + break; + case H5FD_MIRROR_OP_OPEN: + mirror_log(session->loginfo, V_ERR, "OPEN xmit during session"); + reply_error(session, "illegal OPEN xmit during session"); + return -1; + case H5FD_MIRROR_OP_SET_EOA: + if (do_set_eoa(session, (const unsigned char *)xmit_buf) < 0) { + return -1; + } + break; + case H5FD_MIRROR_OP_TRUNCATE: + if (do_truncate(session) < 0) { + return -1; + } + break; + case H5FD_MIRROR_OP_UNLOCK: + if (do_unlock(session) < 0) { + return -1; + } + break; + case H5FD_MIRROR_OP_WRITE: + if (do_write(session, (const unsigned char *)xmit_buf) < 0) { + return -1; + } + break; + default: + mirror_log(session->loginfo, V_ERR, "unrecognized transmission"); + reply_error(session, "unrecognized transmission"); + return -1; + } /* end switch (xmit_recd.op) */ + + } /* end while still listening */ + +done: + comm.magic = 0; /* invalidate structure, on principle */ + xmit_recd.magic = 0; /* invalidate structure, on principle */ + return 0; +} /* end process_instructions() */ + + +/* --------------------------------------------------------------------------- + * Function: run_writer + * + * Purpose: Initiate Writer operations. + * + * Receives as parameters a socket which has accepted the + * connection to the Driver and the OPEN xmit (which must be + * decoded into the structure and verified prior to being passed + * to this function). + * + * Is not responsible for closing or cleaning up any of the + * received parameters. + * + * Return: Success: SUCCEED + * Failure: FAIL + * --------------------------------------------------------------------------- + */ +herr_t +run_writer(int socketfd, H5FD_mirror_xmit_open_t *xmit_open) +{ + struct mirror_session *session = NULL; + int ret_value = SUCCEED; + + session = session_start(socketfd, xmit_open); + if (NULL == session) { + mirror_log(NULL, V_ERR, "Can't start session -- aborting"); + ret_value = FAIL; + } + else { + if (process_instructions(session) < 0) { + mirror_log(session->loginfo, V_ERR, + "problem processing instructions"); + ret_value = FAIL; + } + if (session_stop(session) < 0) { + mirror_log(NULL, V_ERR, "Can't stop session -- going down hard"); + ret_value = FAIL; + } + } + + return ret_value; +} /* end run_writer */ + +#endif /* H5_HAVE_MIRROR_VFD */ + -- cgit v0.12