diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2016-10-27 15:04:42 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2016-10-27 15:04:42 (GMT) |
commit | 5b562d9ce9b2945d0378b9c03e01f42923da80f4 (patch) | |
tree | 3fa67d9656f2b32330e3fe31996952f60f71cdb9 /tools/h5dump | |
parent | b34423f620b470e1c5dc38cdd3abbd5fe8adc4ec (diff) | |
download | hdf5-5b562d9ce9b2945d0378b9c03e01f42923da80f4.zip hdf5-5b562d9ce9b2945d0378b9c03e01f42923da80f4.tar.gz hdf5-5b562d9ce9b2945d0378b9c03e01f42923da80f4.tar.bz2 |
Split tools into src and test - remove folders
Diffstat (limited to 'tools/h5dump')
58 files changed, 0 insertions, 25756 deletions
diff --git a/tools/h5dump/CMakeLists.txt b/tools/h5dump/CMakeLists.txt deleted file mode 100644 index 91c9650..0000000 --- a/tools/h5dump/CMakeLists.txt +++ /dev/null @@ -1,66 +0,0 @@ -cmake_minimum_required (VERSION 3.1.0) -PROJECT (HDF5_TOOLS_H5DUMP) - -#----------------------------------------------------------------------------- -# Setup include Directories -#----------------------------------------------------------------------------- -INCLUDE_DIRECTORIES (${HDF5_TOOLS_DIR}/lib) - -# -------------------------------------------------------------------- -# Add the h5dump executables -# -------------------------------------------------------------------- -add_executable (h5dump - ${HDF5_TOOLS_H5DUMP_SOURCE_DIR}/h5dump.c - ${HDF5_TOOLS_H5DUMP_SOURCE_DIR}/h5dump_ddl.c - ${HDF5_TOOLS_H5DUMP_SOURCE_DIR}/h5dump_xml.c -) -TARGET_NAMING (h5dump STATIC) -TARGET_C_PROPERTIES (h5dump STATIC " " " ") -target_link_libraries (h5dump ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) -set_target_properties (h5dump PROPERTIES FOLDER tools) -set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};h5dump") - -set (H5_DEP_EXECUTABLES h5dump) - -if (BUILD_TESTING) - # -------------------------------------------------------------------- - # Add the h5dump test executable - # -------------------------------------------------------------------- - if (HDF5_BUILD_GENERATORS) - add_executable (h5dumpgentest ${HDF5_TOOLS_H5DUMP_SOURCE_DIR}/h5dumpgentest.c) - TARGET_NAMING (h5dumpgentest STATIC) - TARGET_C_PROPERTIES (h5dumpgentest STATIC " " " ") - target_link_libraries (h5dumpgentest ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET}) - set_target_properties (h5dumpgentest PROPERTIES FOLDER generator/tools) - - #add_test (NAME h5dumpgentest COMMAND $<TARGET_FILE:h5dumpgentest>) - endif (HDF5_BUILD_GENERATORS) - - include (CMakeTests.cmake) - - include (CMakeTestsPBITS.cmake) - - include (CMakeTestsVDS.cmake) - - include (CMakeTestsXML.cmake) -endif (BUILD_TESTING) - -############################################################################## -############################################################################## -### I N S T A L L A T I O N ### -############################################################################## -############################################################################## - -#----------------------------------------------------------------------------- -# Rules for Installation of tools using make Install target -#----------------------------------------------------------------------------- - -#INSTALL_PROGRAM_PDB (h5dump ${HDF5_INSTALL_BIN_DIR} toolsapplications) - -install ( - TARGETS - h5dump - EXPORT - ${HDF5_EXPORTED_TARGETS} - RUNTIME DESTINATION ${HDF5_INSTALL_BIN_DIR} COMPONENT toolsapplications -) diff --git a/tools/h5dump/CMakeTests.cmake b/tools/h5dump/CMakeTests.cmake deleted file mode 100644 index 895855c..0000000 --- a/tools/h5dump/CMakeTests.cmake +++ /dev/null @@ -1,1412 +0,0 @@ - -############################################################################## -############################################################################## -### T E S T I N G ### -############################################################################## -############################################################################## - - # -------------------------------------------------------------------- - # Copy all the HDF5 files from the test directory into the source directory - # -------------------------------------------------------------------- - set (HDF5_REFERENCE_FILES - ${HDF5_TOOLS_DIR}/testfiles/charsets.ddl - ${HDF5_TOOLS_DIR}/testfiles/file_space.ddl - ${HDF5_TOOLS_DIR}/testfiles/filter_fail.ddl - ${HDF5_TOOLS_DIR}/testfiles/non_existing.ddl - ${HDF5_TOOLS_DIR}/testfiles/packedbits.ddl - ${HDF5_TOOLS_DIR}/testfiles/tall-1.ddl - ${HDF5_TOOLS_DIR}/testfiles/tall-2.ddl - ${HDF5_TOOLS_DIR}/testfiles/tall-2A.ddl - ${HDF5_TOOLS_DIR}/testfiles/tall-2A0.ddl - ${HDF5_TOOLS_DIR}/testfiles/tall-2B.ddl - ${HDF5_TOOLS_DIR}/testfiles/tall-3.ddl - ${HDF5_TOOLS_DIR}/testfiles/tall-4s.ddl - ${HDF5_TOOLS_DIR}/testfiles/tall-5s.ddl - ${HDF5_TOOLS_DIR}/testfiles/tall-6.ddl - ${HDF5_TOOLS_DIR}/testfiles/tall-7.ddl - ${HDF5_TOOLS_DIR}/testfiles/tall-7N.ddl - ${HDF5_TOOLS_DIR}/testfiles/tallfilters.ddl - ${HDF5_TOOLS_DIR}/testfiles/tarray1.ddl - ${HDF5_TOOLS_DIR}/testfiles/tarray1_big.ddl - ${HDF5_TOOLS_DIR}/testfiles/tarray2.ddl - ${HDF5_TOOLS_DIR}/testfiles/tarray3.ddl - ${HDF5_TOOLS_DIR}/testfiles/tarray4.ddl - ${HDF5_TOOLS_DIR}/testfiles/tarray5.ddl - ${HDF5_TOOLS_DIR}/testfiles/tarray6.ddl - ${HDF5_TOOLS_DIR}/testfiles/tarray7.ddl - ${HDF5_TOOLS_DIR}/testfiles/tarray8.ddl - ${HDF5_TOOLS_DIR}/testfiles/tattr-1.ddl - ${HDF5_TOOLS_DIR}/testfiles/tattr-2.ddl - ${HDF5_TOOLS_DIR}/testfiles/tattr-3.ddl - ${HDF5_TOOLS_DIR}/testfiles/tattr-4_be.ddl - ${HDF5_TOOLS_DIR}/testfiles/tattrcontents1.ddl - ${HDF5_TOOLS_DIR}/testfiles/tattrcontents2.ddl - ${HDF5_TOOLS_DIR}/testfiles/tattrintsize.ddl - ${HDF5_TOOLS_DIR}/testfiles/tattrreg.ddl - ${HDF5_TOOLS_DIR}/testfiles/tattrregR.ddl - ${HDF5_TOOLS_DIR}/testfiles/tbin1.ddl - ${HDF5_TOOLS_DIR}/testfiles/tbin1.ddl - ${HDF5_TOOLS_DIR}/testfiles/tbin2.ddl - ${HDF5_TOOLS_DIR}/testfiles/tbin3.ddl - ${HDF5_TOOLS_DIR}/testfiles/tbin4.ddl - ${HDF5_TOOLS_DIR}/testfiles/tbinregR.ddl - ${HDF5_TOOLS_DIR}/testfiles/tbigdims.ddl - ${HDF5_TOOLS_DIR}/testfiles/tbitnopaque.ddl - ${HDF5_TOOLS_DIR}/testfiles/tboot1.ddl - ${HDF5_TOOLS_DIR}/testfiles/tboot2.ddl - ${HDF5_TOOLS_DIR}/testfiles/tboot2A.ddl - ${HDF5_TOOLS_DIR}/testfiles/tboot2B.ddl - ${HDF5_TOOLS_DIR}/testfiles/tchar1.ddl - ${HDF5_TOOLS_DIR}/testfiles/tchunked.ddl - ${HDF5_TOOLS_DIR}/testfiles/tcmpdattrintsize.ddl - ${HDF5_TOOLS_DIR}/testfiles/tcmpdintarray.ddl - ${HDF5_TOOLS_DIR}/testfiles/tcmpdints.ddl - ${HDF5_TOOLS_DIR}/testfiles/tcmpdintsize.ddl - ${HDF5_TOOLS_DIR}/testfiles/tcompound_complex2.ddl - ${HDF5_TOOLS_DIR}/testfiles/tcomp-1.ddl - ${HDF5_TOOLS_DIR}/testfiles/tcomp-2.ddl - ${HDF5_TOOLS_DIR}/testfiles/tcomp-3.ddl - ${HDF5_TOOLS_DIR}/testfiles/tcomp-4.ddl - ${HDF5_TOOLS_DIR}/testfiles/tcompact.ddl - ${HDF5_TOOLS_DIR}/testfiles/tcontents.ddl - ${HDF5_TOOLS_DIR}/testfiles/tcontiguos.ddl - ${HDF5_TOOLS_DIR}/testfiles/tdatareg.ddl - ${HDF5_TOOLS_DIR}/testfiles/tdataregR.ddl - ${HDF5_TOOLS_DIR}/testfiles/tdeflate.ddl - ${HDF5_TOOLS_DIR}/testfiles/tdset-1.ddl - ${HDF5_TOOLS_DIR}/testfiles/tdset-2.ddl - ${HDF5_TOOLS_DIR}/testfiles/tdset-3s.ddl - ${HDF5_TOOLS_DIR}/testfiles/tempty.ddl - ${HDF5_TOOLS_DIR}/testfiles/texceedsubstart.ddl - ${HDF5_TOOLS_DIR}/testfiles/texceedsubcount.ddl - ${HDF5_TOOLS_DIR}/testfiles/texceedsubstride.ddl - ${HDF5_TOOLS_DIR}/testfiles/texceedsubblock.ddl - ${HDF5_TOOLS_DIR}/testfiles/texternal.ddl - ${HDF5_TOOLS_DIR}/testfiles/textlinksrc.ddl - ${HDF5_TOOLS_DIR}/testfiles/textlinkfar.ddl - ${HDF5_TOOLS_DIR}/testfiles/textlink.ddl - ${HDF5_TOOLS_DIR}/testfiles/tfamily.ddl - ${HDF5_TOOLS_DIR}/testfiles/tfill.ddl - ${HDF5_TOOLS_DIR}/testfiles/tfletcher32.ddl - ${HDF5_TOOLS_DIR}/testfiles/tfpformat.ddl - ${HDF5_TOOLS_DIR}/testfiles/tgroup-1.ddl - ${HDF5_TOOLS_DIR}/testfiles/tgroup-2.ddl - ${HDF5_TOOLS_DIR}/testfiles/tgrp_comments.ddl - ${HDF5_TOOLS_DIR}/testfiles/thlink-1.ddl - ${HDF5_TOOLS_DIR}/testfiles/thlink-2.ddl - ${HDF5_TOOLS_DIR}/testfiles/thlink-3.ddl - ${HDF5_TOOLS_DIR}/testfiles/thlink-4.ddl - ${HDF5_TOOLS_DIR}/testfiles/thlink-5.ddl - ${HDF5_TOOLS_DIR}/testfiles/thyperslab.ddl - ${HDF5_TOOLS_DIR}/testfiles/tindicesno.ddl - ${HDF5_TOOLS_DIR}/testfiles/tindicessub1.ddl - ${HDF5_TOOLS_DIR}/testfiles/tindicessub2.ddl - ${HDF5_TOOLS_DIR}/testfiles/tindicessub3.ddl - ${HDF5_TOOLS_DIR}/testfiles/tindicessub4.ddl - ${HDF5_TOOLS_DIR}/testfiles/tindicesyes.ddl - ${HDF5_TOOLS_DIR}/testfiles/tints4dims.ddl - ${HDF5_TOOLS_DIR}/testfiles/tints4dimsBlock2.ddl - ${HDF5_TOOLS_DIR}/testfiles/tints4dimsBlockEq.ddl - ${HDF5_TOOLS_DIR}/testfiles/tints4dimsCount2.ddl - ${HDF5_TOOLS_DIR}/testfiles/tints4dimsCountEq.ddl - ${HDF5_TOOLS_DIR}/testfiles/tints4dimsStride2.ddl - ${HDF5_TOOLS_DIR}/testfiles/tintsattrs.ddl - ${HDF5_TOOLS_DIR}/testfiles/tlarge_objname.ddl - #${HDF5_TOOLS_DIR}/testfiles/tldouble.ddl - ${HDF5_TOOLS_DIR}/testfiles/tlonglinks.ddl - ${HDF5_TOOLS_DIR}/testfiles/tloop-1.ddl - ${HDF5_TOOLS_DIR}/testfiles/tmulti.ddl - ${HDF5_TOOLS_DIR}/testfiles/tmultifile.ddl - #${HDF5_TOOLS_DIR}/testfiles/tqmarkfile.ddl - #${HDF5_TOOLS_DIR}/testfiles/tstarfile.ddl - ${HDF5_TOOLS_DIR}/testfiles/tnamed_dtype_attr.ddl - ${HDF5_TOOLS_DIR}/testfiles/tnestcomp-1.ddl - ${HDF5_TOOLS_DIR}/testfiles/tnestedcmpddt.ddl - ${HDF5_TOOLS_DIR}/testfiles/tnbit.ddl - ${HDF5_TOOLS_DIR}/testfiles/tnoattrdata.ddl - ${HDF5_TOOLS_DIR}/testfiles/tnoattrddl.ddl - ${HDF5_TOOLS_DIR}/testfiles/tnodata.ddl - ${HDF5_TOOLS_DIR}/testfiles/tnoddl.ddl - ${HDF5_TOOLS_DIR}/testfiles/tnoddlfile.ddl - ${HDF5_TOOLS_DIR}/testfiles/tno-subset.ddl - ${HDF5_TOOLS_DIR}/testfiles/tnullspace.ddl - ${HDF5_TOOLS_DIR}/testfiles/tordergr1.ddl - ${HDF5_TOOLS_DIR}/testfiles/tordergr2.ddl - ${HDF5_TOOLS_DIR}/testfiles/tordergr3.ddl - ${HDF5_TOOLS_DIR}/testfiles/tordergr4.ddl - ${HDF5_TOOLS_DIR}/testfiles/tordergr5.ddl - ${HDF5_TOOLS_DIR}/testfiles/torderattr1.ddl - ${HDF5_TOOLS_DIR}/testfiles/torderattr2.ddl - ${HDF5_TOOLS_DIR}/testfiles/torderattr3.ddl - ${HDF5_TOOLS_DIR}/testfiles/torderattr4.ddl - ${HDF5_TOOLS_DIR}/testfiles/tordercontents1.ddl - ${HDF5_TOOLS_DIR}/testfiles/tordercontents2.ddl - ${HDF5_TOOLS_DIR}/testfiles/torderlinks1.ddl - ${HDF5_TOOLS_DIR}/testfiles/torderlinks2.ddl - ${HDF5_TOOLS_DIR}/testfiles/tperror.ddl - ${HDF5_TOOLS_DIR}/testfiles/trawdatafile.ddl - ${HDF5_TOOLS_DIR}/testfiles/trawssetfile.ddl - ${HDF5_TOOLS_DIR}/testfiles/treadfilter.ddl - ${HDF5_TOOLS_DIR}/testfiles/treadintfilter.ddl - ${HDF5_TOOLS_DIR}/testfiles/treference.ddl - ${HDF5_TOOLS_DIR}/testfiles/tsaf.ddl - ${HDF5_TOOLS_DIR}/testfiles/tscalarattrintsize.ddl - ${HDF5_TOOLS_DIR}/testfiles/tscalarintattrsize.ddl - ${HDF5_TOOLS_DIR}/testfiles/tscalarintsize.ddl - ${HDF5_TOOLS_DIR}/testfiles/tscalarstring.ddl - ${HDF5_TOOLS_DIR}/testfiles/tscaleoffset.ddl - ${HDF5_TOOLS_DIR}/testfiles/tshuffle.ddl - ${HDF5_TOOLS_DIR}/testfiles/tslink-1.ddl - ${HDF5_TOOLS_DIR}/testfiles/tslink-2.ddl - ${HDF5_TOOLS_DIR}/testfiles/tslink-D.ddl - ${HDF5_TOOLS_DIR}/testfiles/tsplit_file.ddl - ${HDF5_TOOLS_DIR}/testfiles/tstr-1.ddl - ${HDF5_TOOLS_DIR}/testfiles/tstr-2.ddl - ${HDF5_TOOLS_DIR}/testfiles/tstring.ddl - ${HDF5_TOOLS_DIR}/testfiles/tstring2.ddl - ${HDF5_TOOLS_DIR}/testfiles/tstringe.ddl - ${HDF5_TOOLS_DIR}/testfiles/tszip.ddl - ${HDF5_TOOLS_DIR}/testfiles/tudlink-1.ddl - ${HDF5_TOOLS_DIR}/testfiles/tudlink-2.ddl - ${HDF5_TOOLS_DIR}/testfiles/tuserfilter.ddl - ${HDF5_TOOLS_DIR}/testfiles/tvldtypes1.ddl - ${HDF5_TOOLS_DIR}/testfiles/tvldtypes2.ddl - ${HDF5_TOOLS_DIR}/testfiles/tvldtypes3.ddl - ${HDF5_TOOLS_DIR}/testfiles/tvldtypes4.ddl - ${HDF5_TOOLS_DIR}/testfiles/tvldtypes5.ddl - ${HDF5_TOOLS_DIR}/testfiles/tvlenstr_array.ddl - ${HDF5_TOOLS_DIR}/testfiles/tvlstr.ddl - ${HDF5_TOOLS_DIR}/testfiles/tvms.ddl - ${HDF5_TOOLS_DIR}/testfiles/twidedisplay.ddl - ${HDF5_TOOLS_DIR}/testfiles/twithddlfile.ddl - ${HDF5_TOOLS_DIR}/testfiles/h5dump-help.txt - ${HDF5_TOOLS_DIR}/testfiles/out3.h5import - ${HDF5_TOOLS_DIR}/testfiles/zerodim.ddl - ) - set (HDF5_REFERENCE_EXP_FILES - tall-6.exp - tnoddlfile.exp - trawdatafile.exp - trawssetfile.exp - tstr2bin2.exp - tstr2bin6.exp - twithddl.exp - twithddlfile.exp - ) - set (HDF5_REFERENCE_TEST_FILES - ${HDF5_TOOLS_DIR}/testfiles/charsets.h5 - ${HDF5_TOOLS_DIR}/testfiles/file_space.h5 - ${HDF5_TOOLS_DIR}/testfiles/filter_fail.h5 - ${HDF5_TOOLS_DIR}/testfiles/packedbits.h5 - ${HDF5_TOOLS_DIR}/testfiles/taindices.h5 - ${HDF5_TOOLS_DIR}/testfiles/tall.h5 - ${HDF5_TOOLS_DIR}/testfiles/tarray1.h5 - ${HDF5_TOOLS_DIR}/testfiles/tarray1_big.h5 - ${HDF5_TOOLS_DIR}/testfiles/tarray2.h5 - ${HDF5_TOOLS_DIR}/testfiles/tarray3.h5 - ${HDF5_TOOLS_DIR}/testfiles/tarray4.h5 - ${HDF5_TOOLS_DIR}/testfiles/tarray5.h5 - ${HDF5_TOOLS_DIR}/testfiles/tarray6.h5 - ${HDF5_TOOLS_DIR}/testfiles/tarray7.h5 - ${HDF5_TOOLS_DIR}/testfiles/tarray8.h5 - ${HDF5_TOOLS_DIR}/testfiles/tattr.h5 - ${HDF5_TOOLS_DIR}/testfiles/tattr2.h5 - ${HDF5_TOOLS_DIR}/testfiles/tattr4_be.h5 - ${HDF5_TOOLS_DIR}/testfiles/tattrintsize.h5 - ${HDF5_TOOLS_DIR}/testfiles/tattrreg.h5 - ${HDF5_TOOLS_DIR}/testfiles/tbigdims.h5 - ${HDF5_TOOLS_DIR}/testfiles/tbinary.h5 - ${HDF5_TOOLS_DIR}/testfiles/tbitnopaque.h5 - ${HDF5_TOOLS_DIR}/testfiles/tchar.h5 - ${HDF5_TOOLS_DIR}/testfiles/tcmpdattrintsize.h5 - ${HDF5_TOOLS_DIR}/testfiles/tcmpdintarray.h5 - ${HDF5_TOOLS_DIR}/testfiles/tcmpdints.h5 - ${HDF5_TOOLS_DIR}/testfiles/tcmpdintsize.h5 - ${HDF5_TOOLS_DIR}/testfiles/tcompound.h5 - ${HDF5_TOOLS_DIR}/testfiles/tcompound_complex.h5 - ${HDF5_TOOLS_DIR}/testfiles/tcompound_complex2.h5 - ${HDF5_TOOLS_DIR}/testfiles/tdatareg.h5 - ${HDF5_TOOLS_DIR}/testfiles/tdset.h5 - ${HDF5_TOOLS_DIR}/testfiles/tempty.h5 - ${HDF5_TOOLS_DIR}/testfiles/tsoftlinks.h5 - ${HDF5_TOOLS_DIR}/testfiles/textlinkfar.h5 - ${HDF5_TOOLS_DIR}/testfiles/textlinksrc.h5 - ${HDF5_TOOLS_DIR}/testfiles/textlinktar.h5 - ${HDF5_TOOLS_DIR}/testfiles/textlink.h5 - ${HDF5_TOOLS_DIR}/testfiles/tfamily00000.h5 - ${HDF5_TOOLS_DIR}/testfiles/tfamily00001.h5 - ${HDF5_TOOLS_DIR}/testfiles/tfamily00002.h5 - ${HDF5_TOOLS_DIR}/testfiles/tfamily00003.h5 - ${HDF5_TOOLS_DIR}/testfiles/tfamily00004.h5 - ${HDF5_TOOLS_DIR}/testfiles/tfamily00005.h5 - ${HDF5_TOOLS_DIR}/testfiles/tfamily00006.h5 - ${HDF5_TOOLS_DIR}/testfiles/tfamily00007.h5 - ${HDF5_TOOLS_DIR}/testfiles/tfamily00008.h5 - ${HDF5_TOOLS_DIR}/testfiles/tfamily00009.h5 - ${HDF5_TOOLS_DIR}/testfiles/tfamily00010.h5 - ${HDF5_TOOLS_DIR}/testfiles/tfcontents1.h5 - ${HDF5_TOOLS_DIR}/testfiles/tfcontents2.h5 - ${HDF5_TOOLS_DIR}/testfiles/tfilters.h5 - ${HDF5_TOOLS_DIR}/testfiles/tfpformat.h5 - ${HDF5_TOOLS_DIR}/testfiles/tfvalues.h5 - ${HDF5_TOOLS_DIR}/testfiles/tgroup.h5 - ${HDF5_TOOLS_DIR}/testfiles/tgrp_comments.h5 - ${HDF5_TOOLS_DIR}/testfiles/thlink.h5 - ${HDF5_TOOLS_DIR}/testfiles/thyperslab.h5 - ${HDF5_TOOLS_DIR}/testfiles/tints4dims.h5 - ${HDF5_TOOLS_DIR}/testfiles/tintsattrs.h5 - ${HDF5_TOOLS_DIR}/testfiles/tlarge_objname.h5 - #${HDF5_TOOLS_DIR}/testfiles/tldouble.h5 - ${HDF5_TOOLS_DIR}/testfiles/tlonglinks.h5 - ${HDF5_TOOLS_DIR}/testfiles/tloop.h5 - ${HDF5_TOOLS_DIR}/testfiles/tmulti-b.h5 - ${HDF5_TOOLS_DIR}/testfiles/tmulti-g.h5 - ${HDF5_TOOLS_DIR}/testfiles/tmulti-l.h5 - ${HDF5_TOOLS_DIR}/testfiles/tmulti-o.h5 - ${HDF5_TOOLS_DIR}/testfiles/tmulti-r.h5 - ${HDF5_TOOLS_DIR}/testfiles/tmulti-s.h5 - ${HDF5_TOOLS_DIR}/testfiles/tnamed_dtype_attr.h5 - ${HDF5_TOOLS_DIR}/testfiles/tnestedcomp.h5 - ${HDF5_TOOLS_DIR}/testfiles/tnestedcmpddt.h5 - ${HDF5_TOOLS_DIR}/testfiles/tno-subset.h5 - ${HDF5_TOOLS_DIR}/testfiles/tnullspace.h5 - ${HDF5_TOOLS_DIR}/testfiles/torderattr.h5 - ${HDF5_TOOLS_DIR}/testfiles/tordergr.h5 - ${HDF5_TOOLS_DIR}/testfiles/tsaf.h5 - ${HDF5_TOOLS_DIR}/testfiles/tscalarattrintsize.h5 - ${HDF5_TOOLS_DIR}/testfiles/tscalarintattrsize.h5 - ${HDF5_TOOLS_DIR}/testfiles/tscalarintsize.h5 - ${HDF5_TOOLS_DIR}/testfiles/tscalarstring.h5 - ${HDF5_TOOLS_DIR}/testfiles/tslink.h5 - ${HDF5_TOOLS_DIR}/testfiles/tsplit_file-m.h5 - ${HDF5_TOOLS_DIR}/testfiles/tsplit_file-r.h5 - ${HDF5_TOOLS_DIR}/testfiles/tstr.h5 - ${HDF5_TOOLS_DIR}/testfiles/tstr2.h5 - ${HDF5_TOOLS_DIR}/testfiles/tstr3.h5 - ${HDF5_TOOLS_DIR}/testfiles/tudlink.h5 - ${HDF5_TOOLS_DIR}/testfiles/tvldtypes1.h5 - ${HDF5_TOOLS_DIR}/testfiles/tvldtypes2.h5 - ${HDF5_TOOLS_DIR}/testfiles/tvldtypes3.h5 - ${HDF5_TOOLS_DIR}/testfiles/tvldtypes4.h5 - ${HDF5_TOOLS_DIR}/testfiles/tvldtypes5.h5 - ${HDF5_TOOLS_DIR}/testfiles/tvlenstr_array.h5 - ${HDF5_TOOLS_DIR}/testfiles/tvlstr.h5 - ${HDF5_TOOLS_DIR}/testfiles/tvms.h5 - ${HDF5_TOOLS_DIR}/testfiles/zerodim.h5 - ) - set (HDF5_ERROR_REFERENCE_TEST_FILES - ${PROJECT_SOURCE_DIR}/errfiles/filter_fail.err - ${PROJECT_SOURCE_DIR}/errfiles/non_existing.err - ${PROJECT_SOURCE_DIR}/errfiles/tall-1.err - ${PROJECT_SOURCE_DIR}/errfiles/tall-2A.err - ${PROJECT_SOURCE_DIR}/errfiles/tall-2A0.err - ${PROJECT_SOURCE_DIR}/errfiles/tall-2B.err - ${PROJECT_SOURCE_DIR}/errfiles/tarray1_big.err - ${PROJECT_SOURCE_DIR}/errfiles/tattrregR.err - ${PROJECT_SOURCE_DIR}/errfiles/tattr-3.err - ${PROJECT_SOURCE_DIR}/errfiles/tcomp-3.err - ${PROJECT_SOURCE_DIR}/errfiles/tdataregR.err - ${PROJECT_SOURCE_DIR}/errfiles/tdset-2.err - ${PROJECT_SOURCE_DIR}/errfiles/texceedsubblock.err - ${PROJECT_SOURCE_DIR}/errfiles/texceedsubcount.err - ${PROJECT_SOURCE_DIR}/errfiles/texceedsubstart.err - ${PROJECT_SOURCE_DIR}/errfiles/texceedsubstride.err - ${PROJECT_SOURCE_DIR}/errfiles/textlink.err - ${PROJECT_SOURCE_DIR}/errfiles/textlinkfar.err - ${PROJECT_SOURCE_DIR}/errfiles/textlinksrc.err - ${PROJECT_SOURCE_DIR}/errfiles/torderlinks1.err - ${PROJECT_SOURCE_DIR}/errfiles/torderlinks2.err - ${PROJECT_SOURCE_DIR}/errfiles/tgroup-2.err - ${PROJECT_SOURCE_DIR}/errfiles/tperror.err - ${PROJECT_SOURCE_DIR}/errfiles/tslink-D.err - ) - - # make test dir - file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") - - # - # copy test files from source dir to test dir - # - foreach (tst_h5_file ${HDF5_REFERENCE_TEST_FILES}) - get_filename_component (fname "${tst_h5_file}" NAME) - HDFTEST_COPY_FILE("${tst_h5_file}" "${PROJECT_BINARY_DIR}/testfiles/std/${fname}" "h5dump_std_files") - endforeach (tst_h5_file ${HDF5_REFERENCE_TEST_FILES}) - - foreach (tst_exp_file ${HDF5_REFERENCE_EXP_FILES}) - if (WIN32) - file (READ ${HDF5_TOOLS_SRC_DIR}/testfiles/${tst_exp_file} TEST_STREAM) - file (WRITE ${PROJECT_BINARY_DIR}/testfiles/std/${tst_exp_file} "${TEST_STREAM}") - else (WIN32) - HDFTEST_COPY_FILE("${HDF5_TOOLS_SRC_DIR}/testfiles/${tst_exp_file}" "${PROJECT_BINARY_DIR}/testfiles/std/${tst_exp_file}" "h5dump_std_files") - endif (WIN32) - endforeach (tst_exp_file ${HDF5_REFERENCE_EXP_FILES}) - - foreach (tst_other_file ${HDF5_REFERENCE_FILES}) - get_filename_component (fname "${tst_other_file}" NAME) - HDFTEST_COPY_FILE("${tst_other_file}" "${PROJECT_BINARY_DIR}/testfiles/std/${fname}" "h5dump_std_files") - endforeach (tst_other_file ${HDF5_REFERENCE_FILES}) - - foreach (tst_error_file ${HDF5_ERROR_REFERENCE_TEST_FILES}) - get_filename_component (fname "${tst_error_file}" NAME) - HDFTEST_COPY_FILE("${tst_error_file}" "${PROJECT_BINARY_DIR}/testfiles/std/${fname}" "h5dump_std_files") - endforeach (tst_error_file ${HDF5_ERROR_REFERENCE_TEST_FILES}) - - # -------------------------------------------------------------------- - # Special file handling - # -------------------------------------------------------------------- - HDFTEST_COPY_FILE("${HDF5_TOOLS_SOURCE_DIR}/testfiles/tbin1.ddl" "${PROJECT_BINARY_DIR}/testfiles/std/tbin1LE.ddl" "h5dump_std_files") - - if (WIN32) - file (READ ${HDF5_TOOLS_SRC_DIR}/testfiles/tbinregR.exp TEST_STREAM) - file (WRITE ${PROJECT_BINARY_DIR}/testfiles/std/tbinregR.exp "${TEST_STREAM}") - else (WIN32) - HDFTEST_COPY_FILE("${HDF5_TOOLS_SRC_DIR}/testfiles/tbinregR.exp" "${PROJECT_BINARY_DIR}/testfiles/std/tbinregR.exp" "h5dump_std_files") - endif (WIN32) - add_custom_target(h5dump_std_files ALL COMMENT "Copying files needed by h5dump_std tests" DEPENDS ${h5dump_std_files_list}) - -############################################################################## -############################################################################## -### T H E T E S T S M A C R O S ### -############################################################################## -############################################################################## - - MACRO (ADD_HELP_TEST testname resultcode) - # If using memchecker add tests without using scripts - if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5DUMP-${testname} COMMAND $<TARGET_FILE:h5dump> ${ARGN}) - set_tests_properties (H5DUMP-${testname} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5DUMP-${testname} PROPERTIES DEPENDS ${last_test}) - endif (NOT "${last_test}" STREQUAL "") - set (last_test "H5DUMP-${testname}") - else (HDF5_ENABLE_USING_MEMCHECKER) - add_test ( - NAME H5DUMP-h5dump-${testname} - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump>" - -D "TEST_ARGS:STRING=${ARGN}" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/std" - -D "TEST_OUTPUT=h5dump-${testname}.out" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_REFERENCE=h5dump-${testname}.txt" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" - ) - endif (HDF5_ENABLE_USING_MEMCHECKER) - ENDMACRO (ADD_HELP_TEST) - - MACRO (ADD_SKIP_H5_TEST skipresultfile skipresultcode testtype) - if (${testtype} STREQUAL "SKIP") - if (NOT HDF5_ENABLE_USING_MEMCHECKER) - add_test ( - NAME H5DUMP-${skipresultfile}-SKIPPED - COMMAND ${CMAKE_COMMAND} -E echo "SKIP ${skipresultfile} ${ARGN}" - ) - endif (NOT HDF5_ENABLE_USING_MEMCHECKER) - else (${testtype} STREQUAL "SKIP") - ADD_H5_TEST (${skipresultfile} ${skipresultcode} ${ARGN}) - endif (${testtype} STREQUAL "SKIP") - ENDMACRO (ADD_SKIP_H5_TEST) - - MACRO (ADD_H5_TEST resultfile resultcode) - # If using memchecker add tests without using scripts - if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5DUMP-${resultfile} COMMAND $<TARGET_FILE:h5dump> ${ARGN}) - set_tests_properties (H5DUMP-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") - if (NOT ${resultcode} STREQUAL "0") - set_tests_properties (H5DUMP-${resultfile} PROPERTIES WILL_FAIL "true") - endif (NOT ${resultcode} STREQUAL "0") - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5DUMP-${resultfile} PROPERTIES DEPENDS ${last_test}) - endif (NOT "${last_test}" STREQUAL "") - else (HDF5_ENABLE_USING_MEMCHECKER) - add_test ( - NAME H5DUMP-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove ${resultfile}.bin - ) - set_tests_properties (H5DUMP-${resultfile}-clear-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") - add_test ( - NAME H5DUMP-${resultfile} - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump>" - -D "TEST_ARGS:STRING=${ARGN}" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/std" - -D "TEST_OUTPUT=${resultfile}.out" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_REFERENCE=${resultfile}.ddl" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" - ) - set_tests_properties (H5DUMP-${resultfile} PROPERTIES DEPENDS "H5DUMP-${resultfile}-clear-objects") - endif (HDF5_ENABLE_USING_MEMCHECKER) - ENDMACRO (ADD_H5_TEST file) - - MACRO (ADD_H5_TEST_N resultfile resultcode) - # If using memchecker add tests without using scripts - if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5DUMP-N-${resultfile} COMMAND $<TARGET_FILE:h5dump> ${ARGN}) - set_tests_properties (H5DUMP-N-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") - if (NOT ${resultcode} STREQUAL "0") - set_tests_properties (H5DUMP-N-${resultfile} PROPERTIES WILL_FAIL "true") - endif (NOT ${resultcode} STREQUAL "0") - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5DUMP-N-${resultfile} PROPERTIES DEPENDS ${last_test}) - endif (NOT "${last_test}" STREQUAL "") - else (HDF5_ENABLE_USING_MEMCHECKER) - add_test ( - NAME H5DUMP-N-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove ${resultfile}-N.bin - ) - set_tests_properties (H5DUMP-N-${resultfile}-clear-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") - add_test ( - NAME H5DUMP-N-${resultfile} - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump>" - -D "TEST_ARGS:STRING=${ARGN}" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/std" - -D "TEST_OUTPUT=${resultfile}-N.out" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_REFERENCE=${resultfile}.ddl" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" - ) - set_tests_properties (H5DUMP-N-${resultfile} PROPERTIES DEPENDS "H5DUMP-N-${resultfile}-clear-objects") - endif (HDF5_ENABLE_USING_MEMCHECKER) - ENDMACRO (ADD_H5_TEST_N file) - - MACRO (ADD_H5_TEST_EXPORT resultfile targetfile resultcode) - # If using memchecker add tests without using scripts - if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5DUMP-${resultfile} COMMAND $<TARGET_FILE:h5dump> ${ARGN} ${resultfile}.txt ${targetfile}) - set_tests_properties (H5DUMP-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") - if (NOT ${resultcode} STREQUAL "0") - set_tests_properties (H5DUMP-${resultfile} PROPERTIES WILL_FAIL "true") - endif (NOT ${resultcode} STREQUAL "0") - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5DUMP-${resultfile} PROPERTIES DEPENDS ${last_test}) - endif (NOT "${last_test}" STREQUAL "") - else (HDF5_ENABLE_USING_MEMCHECKER) - add_test ( - NAME H5DUMP-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove ${resultfile}.txt - ) - set_tests_properties (H5DUMP-${resultfile}-clear-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") - add_test ( - NAME H5DUMP-${resultfile} - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump>" - -D "TEST_ARGS:STRING=${ARGN};${resultfile}.txt;${targetfile}" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/std" - -D "TEST_OUTPUT=${resultfile}.out" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_REFERENCE=${resultfile}.ddl" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" - ) - set_tests_properties (H5DUMP-${resultfile} PROPERTIES DEPENDS "H5DUMP-${resultfile}-clear-objects") - add_test ( - NAME H5DUMP-${resultfile}-output-cmp - COMMAND ${CMAKE_COMMAND} - -E compare_files ${resultfile}.txt ${resultfile}.exp - ) - set_tests_properties (H5DUMP-${resultfile}-output-cmp PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") - set_tests_properties (H5DUMP-${resultfile}-output-cmp PROPERTIES DEPENDS H5DUMP-${resultfile}) - endif (HDF5_ENABLE_USING_MEMCHECKER) - ENDMACRO (ADD_H5_TEST_EXPORT file) - - MACRO (ADD_H5_TEST_EXPORT_DDL resultfile targetfile resultcode ddlfile) - # If using memchecker add tests without using scripts - if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5DUMP-${resultfile} COMMAND $<TARGET_FILE:h5dump> --ddl=${ddlfile}.txt ${ARGN} ${resultfile}.txt ${targetfile}) - set_tests_properties (H5DUMP-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") - if (NOT ${resultcode} STREQUAL "0") - set_tests_properties (H5DUMP-${resultfile} PROPERTIES WILL_FAIL "true") - endif (NOT ${resultcode} STREQUAL "0") - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5DUMP-${resultfile} PROPERTIES DEPENDS ${last_test}) - endif (NOT "${last_test}" STREQUAL "") - else (HDF5_ENABLE_USING_MEMCHECKER) - add_test ( - NAME H5DUMP-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove ${ddlfile}.txt ${resultfile}.txt - ) - set_tests_properties (H5DUMP-${resultfile}-clear-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") - add_test ( - NAME H5DUMP-${resultfile} - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump>" - -D "TEST_ARGS:STRING=--ddl=${ddlfile}.txt;${ARGN};${resultfile}.txt;${targetfile}" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/std" - -D "TEST_OUTPUT=${resultfile}.out" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_REFERENCE=${resultfile}.ddl" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" - ) - set_tests_properties (H5DUMP-${resultfile} PROPERTIES DEPENDS "H5DUMP-${resultfile}-clear-objects") - add_test ( - NAME H5DUMP-${resultfile}-output-cmp - COMMAND ${CMAKE_COMMAND} - -E compare_files ${resultfile}.txt ${resultfile}.exp - ) - set_tests_properties (H5DUMP-${resultfile}-output-cmp PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") - set_tests_properties (H5DUMP-${resultfile}-output-cmp PROPERTIES DEPENDS H5DUMP-${resultfile}) - add_test ( - NAME H5DUMP-${resultfile}-output-cmp-ddl - COMMAND ${CMAKE_COMMAND} - -E compare_files ${ddlfile}.txt ${ddlfile}.exp - ) - set_tests_properties (H5DUMP-${resultfile}-output-cmp-ddl PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") - set_tests_properties (H5DUMP-${resultfile}-output-cmp-ddl PROPERTIES DEPENDS H5DUMP-${resultfile}-output-cmp) - endif (HDF5_ENABLE_USING_MEMCHECKER) - ENDMACRO (ADD_H5_TEST_EXPORT_DDL file) - - MACRO (ADD_H5_EXPORT_TEST resultfile targetfile resultcode) - if (NOT HDF5_ENABLE_USING_MEMCHECKER) - add_test ( - NAME H5DUMP-output-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove ${resultfile}.txt - ) - set_tests_properties (H5DUMP-output-${resultfile}-clear-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") - add_test ( - NAME H5DUMP-output-${resultfile} - COMMAND $<TARGET_FILE:h5dump> ${ARGN} ${resultfile}.txt ${targetfile} - ) - set_tests_properties (H5DUMP-output-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") - set_tests_properties (H5DUMP-output-${resultfile} PROPERTIES DEPENDS H5DUMP-output-${resultfile}-clear-objects) - add_test ( - NAME H5DUMP-output-cmp-${resultfile} - COMMAND ${CMAKE_COMMAND} - -E compare_files ${resultfile}.txt ${resultfile}.exp - ) - set_tests_properties (H5DUMP-output-cmp-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") - set_tests_properties (H5DUMP-output-cmp-${resultfile} PROPERTIES DEPENDS H5DUMP-output-${resultfile}) - endif (NOT HDF5_ENABLE_USING_MEMCHECKER) - ENDMACRO (ADD_H5_EXPORT_TEST file) - - MACRO (ADD_H5_MASK_TEST resultfile resultcode) - if (NOT HDF5_ENABLE_USING_MEMCHECKER) - add_test ( - NAME H5DUMP-${resultfile} - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump>" - -D "TEST_ARGS:STRING=${ARGN}" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/std" - -D "TEST_OUTPUT=${resultfile}.out" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_REFERENCE=${resultfile}.ddl" - -D "TEST_MASK_ERROR=true" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" - ) - endif (NOT HDF5_ENABLE_USING_MEMCHECKER) - ENDMACRO (ADD_H5_MASK_TEST file) - - MACRO (ADD_H5ERR_MASK_TEST resultfile resultcode) - if (NOT HDF5_ENABLE_USING_MEMCHECKER) - add_test ( - NAME H5DUMP-${resultfile} - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump>" - -D "TEST_ARGS:STRING=${ARGN}" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/std" - -D "TEST_OUTPUT=${resultfile}.out" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_REFERENCE=${resultfile}.ddl" - -D "TEST_ERRREF=${resultfile}.err" - -D "TEST_MASK_ERROR=true" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" - ) - endif (NOT HDF5_ENABLE_USING_MEMCHECKER) - ENDMACRO (ADD_H5ERR_MASK_TEST file) - - MACRO (ADD_H5ERR_MASK_ENV_TEST resultfile resultcode envvar envval) - if (NOT HDF5_ENABLE_USING_MEMCHECKER) - add_test ( - NAME H5DUMP-${resultfile} - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump>" - -D "TEST_ARGS:STRING=${ARGN}" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/std" - -D "TEST_OUTPUT=${resultfile}.out" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_REFERENCE=${resultfile}.ddl" - -D "TEST_ERRREF=${resultfile}.err" - -D "TEST_MASK_ERROR=true" - -D "TEST_ENV_VAR:STRING=${envvar}" - -D "TEST_ENV_VALUE:STRING=${envval}" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" - ) - endif (NOT HDF5_ENABLE_USING_MEMCHECKER) - ENDMACRO (ADD_H5ERR_MASK_ENV_TEST) - - MACRO (ADD_H5_TEST_IMPORT conffile resultfile testfile resultcode) - # If using memchecker add tests without using scripts - if (NOT HDF5_ENABLE_USING_MEMCHECKER) - add_test ( - NAME H5DUMP-IMPORT-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove ${resultfile}.bin ${resultfile}.h5 - ) - set_tests_properties (H5DUMP-IMPORT-${resultfile}-clear-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") - add_test ( - NAME H5DUMP-IMPORT-${resultfile} - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump>" - -D "TEST_ARGS:STRING=${ARGN};-o;${resultfile}.bin;${testfile}" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/std" - -D "TEST_OUTPUT=${conffile}.out" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_REFERENCE=${conffile}.ddl" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" - ) - set_tests_properties (H5DUMP-IMPORT-${resultfile} PROPERTIES DEPENDS "H5DUMP-IMPORT-${resultfile}-clear-objects") - add_test (NAME H5DUMP-IMPORT-h5import-${resultfile} COMMAND h5import ${resultfile}.bin -c ${conffile}.out -o ${resultfile}.h5) - set_tests_properties (H5DUMP-IMPORT-h5import-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") - set_tests_properties (H5DUMP-IMPORT-h5import-${resultfile} PROPERTIES DEPENDS H5DUMP-IMPORT-${resultfile}) - add_test (NAME H5DUMP-IMPORT-h5diff-${resultfile} COMMAND h5diff ${testfile} ${resultfile}.h5 /integer /integer) - set_tests_properties (H5DUMP-IMPORT-h5diff-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") - set_tests_properties (H5DUMP-IMPORT-h5diff-${resultfile} PROPERTIES DEPENDS H5DUMP-IMPORT-h5import-${resultfile}) - endif (NOT HDF5_ENABLE_USING_MEMCHECKER) - ENDMACRO (ADD_H5_TEST_IMPORT file) - -############################################################################## -############################################################################## -### T H E T E S T S HDF5_ENABLE_USING_MEMCHECKER ### -############################################################################## -############################################################################## - - if (HDF5_ENABLE_USING_MEMCHECKER) - # Remove any output file left over from previous test run - add_test ( - NAME H5DUMP-clearall-objects - COMMAND ${CMAKE_COMMAND} - -E remove - h5dump-help.out - charsets.out - charsets.out.err - file_space.out - file_space.out.err - filter_fail.out - filter_fail.out.err - non_existing.out - non_existing.out.err - packedbits.out - packedbits.out.err - tall-1.out - tall-1.out.err - tall-2.out - tall-2.out.err - tall-2A.out - tall-2A.out.err - tall-2A0.out - tall-2A0.out.err - tall-2B.out - tall-2B.out.err - tall-3.out - tall-3.out.err - tall-4s.out - tall-4s.out.err - tall-5s.out - tall-5s.out.err - tall-6.txt - tall-6.out - tall-6.out.err - tall-7.out - tall-7.out.err - tall-7N.out - tall-7N.out.err - tallfilters.out - tallfilters.out.err - tarray1.out - tarray1.out.err - tarray1_big.out - tarray1_big.out.err - tarray2.out - tarray2.out.err - tarray3.out - tarray3.out.err - tarray4.out - tarray4.out.err - tarray5.out - tarray5.out.err - tarray6.out - tarray6.out.err - tarray7.out - tarray7.out.err - tarray8.out - tarray8.out.err - tattr-1.out - tattr-1.out.err - tattr-2.out - tattr-2.out.err - tattr-3.out - tattr-3.out.err - tattr-4_be.out - tattr-4_be.out.err - tattrcontents1.out - tattrcontents1.out.err - tattrcontents2.out - tattrcontents2.out.err - tattrintsize.out - tattrintsize.out.err - tattrreg.out - tattrreg.out.err - tattrregR.out - tattrregR.out.err - tbin1LE.bin - tbinregR.txt - tbinregR.out - tbinregR.out.err - tbigdims.out - tbigdims.out.err - tbitnopaque.out - tbitnopaque.out.err - tboot1.out - tboot1.out.err - tboot2.out - tboot2.out.err - tboot2A.out - tboot2A.out.err - tboot2B.out - tboot2B.out.err - tchar1.out - tchar1.out.err - tchunked.out - tchunked.out.err - tcmpdattrintsize.out - tcmpdattrintsize.out.err - tcmpdintarray.out - tcmpdintarray.out.err - tcmpdints.out - tcmpdints.out.err - tcmpdintsize.out - tcmpdintsize.out.err - tcomp-1.out - tcomp-1.out.err - tcomp-2.out - tcomp-2.out.err - tcomp-3.out - tcomp-3.out.err - tcomp-4.out - tcomp-4.out.err - tcompact.out - tcompact.out.err - tcompound_complex.out - tcompound_complex.out.err - tcontents.out - tcontents.out.err - tcontiguos.out - tcontiguos.out.err - tdatareg.out - tdatareg.out.err - tdataregR.out - tdataregR.out.err - tdeflate.out - tdeflate.out.err - tdset-1.out - tdset-1.out.err - tdset-2.out - tdset-2.out.err - tdset-3s.out - tdset-3s.out.err - tempty.out - tempty.out.err - texternal.out - texternal.out.err - textlinksrc.out - textlinksrc.out.err - textlinkfar.out - textlinkfar.out.err - textlink.out - textlink.out.err - tfamily.out - tfamily.out.err - tfill.out - tfill.out.err - tfletcher32.out - tfletcher32.out.err - tfpformat.out - tfpformat.out.err - tgroup-1.out - tgroup-1.out.err - tgroup-2.out - tgroup-2.out.err - tgrp_comments.out - tgrp_comments.out.err - thlink-1.out - thlink-1.out.err - thlink-2.out - thlink-2.out.err - thlink-3.out - thlink-3.out.err - thlink-4.out - thlink-4.out.err - thlink-5.out - thlink-5.out.err - thyperslab.out - thyperslab.out.err - tindicesno.out - tindicesno.out.err - tindicessub1.out - tindicessub1.out.err - tindicessub2.out - tindicessub2.out.err - tindicessub3.out - tindicessub3.out.err - tindicessub4.out - tindicessub4.out.err - texceedsubstart.out - texceedsubstart.out.err - texceedsubcount.out - texceedsubcount.out.err - texceedsubstride.out - texceedsubstride.out.err - texceedsubblock.out - texceedsubblock.out.err - tindicesyes.out - tindicesyes.out.err - tints4dims.out - tints4dims.out.err - tints4dimsBlock2.out - tints4dimsBlock2.out.err - tints4dimsBlockEq.out - tints4dimsBlockEq.out.err - tints4dimsCount2.out - tints4dimsCount2.out.err - tints4dimsCountEq.out - tints4dimsCountEq.out.err - tints4dimsStride2.out - tints4dimsStride2.out.err - tintsattrs.out - tintsattrs.out.err - tlarge_objname.out - tlarge_objname.out.err - tldouble.out - tldouble.out.err - tlonglinks.out - tlonglinks.out.err - tloop-1.out - tloop-1.out.err - tmulti.out - tmulti.out.err - tmultifile.out - tmultifile.out.err -# tqmarkfile.out -# tqmarkfile.out.err -# tstarfile.out -# tstarfile.out.err - tnamed_dtype_attr.out - tnamed_dtype_attr.out.err - tnbit.out - tnbit.out.err - tnestcomp-1.out - tnestcomp-1.out.err - tnestedcmpddt.out - tnestedcmpddt.out.err - tnoattrdata.out - tnoattrdata.out.err - tnoattrddl.out - tnoattrddl.out.err - tnodata.out - tnodata.out.err - tnoddl.out - tnoddl.out.err - tnoddlfile.out - tnoddlfile.out.err - tno-subset.out - tno-subset.out.err - tnullspace.out - tnullspace.out.err - tordergr1.out - tordergr1.out.err - tordergr2.out - tordergr2.out.err - tordergr3.out - tordergr3.out.err - tordergr4.out - tordergr4.out.err - tordergr5.out - tordergr5.out.err - torderattr1.out - torderattr1.out.err - torderattr2.out - torderattr2.out.err - torderattr3.out - torderattr3.out.err - torderattr4.out - torderattr4.out.err - tordercontents1.out - tordercontents1.out.err - tordercontents2.out - tordercontents2.out.err - torderlinks1.out - torderlinks1.out.err - torderlinks2.out - torderlinks2.out.err - tperror.out - tperror.out.err - trawdatafile.out - trawdatafile.out.err - trawdatafile.txt - trawssetfile.out - trawssetfile.out.err - trawssetfile.txt - treadfilter.out - treadfilter.out.err - treadintfilter.out - treadintfilter.out.err - treference.out - treference.out.err - tsaf.out - tsaf.out.err - tscalarattrintsize.out - tscalarattrintsize.out.err - tscalarintattrsize.out - tscalarintattrsize.out.err - tscalarintsize.out - tscalarintsize.out.err - tscalarstring.out - tscalarstring.out.err - tscaleoffset.out - tscaleoffset.out.err - tshuffle.out - tshuffle.out.err - tslink-1.out - tslink-1.out.err - tslink-2.out - tslink-2.out.err - tslink-D.out - tslink-D.out.err - tsplit_file.out - tsplit_file.out.err - tstr-1.out - tstr-1.out.err - tstr-2.out - tstr-2.out.err - tstr2bin2.txt - tstr2bin6.txt - tstring.out - tstring.out.err - tstring2.out - tstring2.out.err - tstringe.out - tstringe.out.err - tszip.out - tszip.out.err - tudlink-1.out - tudlink-1.out.err - tudlink-2.out - tudlink-2.out.err - tuserfilter.out - tuserfilter.out.err - tvldtypes1.out - tvldtypes1.out.err - tvldtypes2.out - tvldtypes2.out.err - tvldtypes3.out - tvldtypes3.out.err - tvldtypes4.out - tvldtypes4.out.err - tvldtypes5.out - tvldtypes5.out.err - tvlenstr_array.out - tvlenstr_array.out.err - tvlstr.out - tvlstr.out.err - tvms.out - tvms.out.err - twidedisplay.out - twidedisplay.out.err - twithddl.txt - twithddlfile.out - twithddlfile.out.err - twithddlfile.txt - zerodim.out - zerodim.out.err - ) - set_tests_properties (H5DUMP-clearall-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std") - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5DUMP-clearall-objects PROPERTIES DEPENDS ${last_test}) - endif (NOT "${last_test}" STREQUAL "") - set (last_test "H5DUMP-clearall-objects") - endif (HDF5_ENABLE_USING_MEMCHECKER) - - ADD_HELP_TEST(help 0 -h) - - # test data output redirection - #ADD_H5_TEST (tnoddl 0 --enable-error-stack -O -y packedbits.h5) - ADD_H5_TEST (tnoddl 0 --enable-error-stack --ddl -y packedbits.h5) - #ADD_H5_TEST (tnodata 0 --enable-error-stack -o packedbits.h5) - ADD_H5_TEST (tnodata 0 --enable-error-stack --output packedbits.h5) - ADD_H5_TEST (tnoattrddl 0 --enable-error-stack -O -y tattr.h5) - ADD_H5_TEST (tnoattrdata 0 --enable-error-stack -A -o tattr.h5) - ADD_H5_TEST_EXPORT (trawdatafile packedbits.h5 0 --enable-error-stack -y -o) - ADD_H5_TEST_EXPORT (tnoddlfile packedbits.h5 0 --enable-error-stack -O -y -o) - ADD_H5_TEST_EXPORT (trawssetfile tdset.h5 0 --enable-error-stack -d "/dset1[1,1;;;]" -y -o) - - ADD_H5_TEST_EXPORT_DDL (twithddlfile packedbits.h5 0 twithddl --enable-error-stack --ddl=twithddl.txt -y -o) - - # test for maximum display datasets - ADD_H5_TEST (twidedisplay 0 --enable-error-stack -w0 packedbits.h5) - - # test for signed/unsigned datasets - ADD_H5_TEST (packedbits 0 --enable-error-stack packedbits.h5) - # test for compound signed/unsigned datasets - ADD_H5_TEST (tcmpdintarray 0 --enable-error-stack tcmpdintarray.h5) - ADD_H5_TEST (tcmpdints 0 --enable-error-stack tcmpdints.h5) - ADD_H5_TEST (tcmpdintsize 0 --enable-error-stack tcmpdintsize.h5) - # test for signed/unsigned scalar datasets - ADD_H5_TEST (tscalarintsize 0 --enable-error-stack tscalarintsize.h5) - # test for signed/unsigned attributes - ADD_H5_TEST (tattrintsize 0 --enable-error-stack tattrintsize.h5) - # test for compound signed/unsigned attributes - ADD_H5_TEST (tcmpdattrintsize 0 --enable-error-stack tcmpdattrintsize.h5) - # test for signed/unsigned scalar attributes - ADD_H5_TEST (tscalarattrintsize 0 --enable-error-stack tscalarattrintsize.h5) - # test for string scalar dataset and attribute - ADD_H5_TEST (tscalarstring 0 --enable-error-stack tscalarstring.h5) - # test for signed/unsigned scalar datasets with attributes - ADD_H5_TEST (tscalarintattrsize 0 --enable-error-stack tscalarintattrsize.h5) - # test for signed/unsigned datasets attributes - ADD_H5_TEST (tintsattrs 0 --enable-error-stack tintsattrs.h5) - # test for displaying groups - ADD_H5_TEST (tgroup-1 0 --enable-error-stack tgroup.h5) - # test for displaying the selected groups - ADD_H5ERR_MASK_TEST (tgroup-2 1 --enable-error-stack --group=/g2 --group / -g /y tgroup.h5) - - # test for displaying simple space datasets - ADD_H5_TEST (tdset-1 0 --enable-error-stack tdset.h5) - # test for displaying selected datasets - ADD_H5ERR_MASK_TEST (tdset-2 1 --enable-error-stack -H -d dset1 -d /dset2 --dataset=dset3 tdset.h5) - - # test for displaying attributes - ADD_H5_TEST (tattr-1 0 --enable-error-stack tattr.h5) - # test for displaying the selected attributes of string type and scalar space - ADD_H5_TEST (tattr-2 0 --enable-error-stack -a /\\\\/attr1 --attribute /attr4 --attribute=/attr5 tattr.h5) - ADD_H5_TEST_N (tattr-2 0 --enable-error-stack -N /\\\\/attr1 --any_path /attr4 --any_path=/attr5 tattr.h5) - # test for header and error messages - ADD_H5ERR_MASK_TEST (tattr-3 1 --enable-error-stack --header -a /attr2 --attribute=/attr tattr.h5) - # test for displaying at least 9 attributes on root from a be machine - ADD_H5_TEST (tattr-4_be 0 --enable-error-stack tattr4_be.h5) - # test for displaying attributes in shared datatype (also in group and dataset) - ADD_H5_TEST (tnamed_dtype_attr 0 --enable-error-stack tnamed_dtype_attr.h5) - - # test for displaying soft links and user-defined links - ADD_H5_TEST (tslink-1 0 --enable-error-stack tslink.h5) - ADD_H5_TEST (tudlink-1 0 --enable-error-stack tudlink.h5) - # test for displaying the selected link - ADD_H5_TEST (tslink-2 0 --enable-error-stack -l slink2 tslink.h5) - ADD_H5_TEST_N (tslink-2 0 --enable-error-stack -N slink2 tslink.h5) - ADD_H5_TEST (tudlink-2 0 --enable-error-stack -l udlink2 tudlink.h5) - # test for displaying dangling soft links - ADD_H5ERR_MASK_TEST (tslink-D 0 --enable-error-stack -d /slink1 tslink.h5) - - # tests for hard links - ADD_H5_TEST (thlink-1 0 --enable-error-stack thlink.h5) - ADD_H5_TEST (thlink-2 0 --enable-error-stack -d /g1/dset2 --dataset /dset1 --dataset=/g1/g1.1/dset3 thlink.h5) - ADD_H5_TEST (thlink-3 0 --enable-error-stack -d /g1/g1.1/dset3 --dataset /g1/dset2 --dataset=/dset1 thlink.h5) - ADD_H5_TEST (thlink-4 0 --enable-error-stack -g /g1 thlink.h5) - ADD_H5_TEST_N (thlink-4 0 --enable-error-stack -N /g1 thlink.h5) - ADD_H5_TEST (thlink-5 0 --enable-error-stack -d /dset1 -g /g2 -d /g1/dset2 thlink.h5) - ADD_H5_TEST_N (thlink-5 0 --enable-error-stack -N /dset1 -N /g2 -N /g1/dset2 thlink.h5) - - # tests for compound data types - ADD_H5_TEST (tcomp-1 0 --enable-error-stack tcompound.h5) - # test for named data types - ADD_H5_TEST (tcomp-2 0 --enable-error-stack -t /type1 --datatype /type2 --datatype=/group1/type3 tcompound.h5) - ADD_H5_TEST_N (tcomp-2 0 --enable-error-stack -N /type1 --any_path /type2 --any_path=/group1/type3 tcompound.h5) - # test for unamed type - ADD_H5ERR_MASK_TEST (tcomp-3 0 "--enable-error-stack;-t;/#6632;-g;/group2;tcompound.h5") - # test complicated compound datatype - ADD_H5_TEST (tcomp-4 0 --enable-error-stack tcompound_complex.h5) - ADD_H5_TEST (tcompound_complex2 0 --enable-error-stack tcompound_complex2.h5) - # tests for bitfields and opaque data types - ADD_H5_TEST (tbitnopaque 0 --enable-error-stack tbitnopaque.h5) - - #test for the nested compound type - ADD_H5_TEST (tnestcomp-1 0 --enable-error-stack tnestedcomp.h5) - ADD_H5_TEST (tnestedcmpddt 0 --enable-error-stack tnestedcmpddt.h5) - - # test for options - ADD_H5ERR_MASK_TEST (tall-1 0 --enable-error-stack tall.h5) - ADD_H5_TEST (tall-2 0 --enable-error-stack --header -g /g1/g1.1 -a attr2 tall.h5) - ADD_H5_TEST (tall-3 0 --enable-error-stack -d /g2/dset2.1 -l /g1/g1.2/g1.2.1/slink tall.h5) - ADD_H5_TEST_N (tall-3 0 --enable-error-stack -N /g2/dset2.1 -N /g1/g1.2/g1.2.1/slink tall.h5) - ADD_H5_TEST (tall-7 0 --enable-error-stack -a attr1 tall.h5) - ADD_H5_TEST (tall-7N 0 --enable-error-stack -N attr1 tall.h5) - - # test for loop detection - ADD_H5_TEST (tloop-1 0 --enable-error-stack tloop.h5) - - # test for string - ADD_H5_TEST (tstr-1 0 --enable-error-stack tstr.h5) - ADD_H5_TEST (tstr-2 0 --enable-error-stack tstr2.h5) - - # test for file created by Lib SAF team - ADD_H5_TEST (tsaf 0 --enable-error-stack tsaf.h5) - - # test for file with variable length data - ADD_H5_TEST (tvldtypes1 0 --enable-error-stack tvldtypes1.h5) - ADD_H5_TEST (tvldtypes2 0 --enable-error-stack tvldtypes2.h5) - ADD_H5_TEST (tvldtypes3 0 --enable-error-stack tvldtypes3.h5) - ADD_H5_TEST (tvldtypes4 0 --enable-error-stack tvldtypes4.h5) - ADD_H5_TEST (tvldtypes5 0 --enable-error-stack tvldtypes5.h5) - - #test for file with variable length string data - ADD_H5_TEST (tvlstr 0 --enable-error-stack tvlstr.h5) - ADD_H5_TEST (tvlenstr_array 0 --enable-error-stack tvlenstr_array.h5) - - # test for files with array data - ADD_H5_TEST (tarray1 0 --enable-error-stack tarray1.h5) - # # added for bug# 2092 - tarray1_big.h5 - ADD_H5ERR_MASK_TEST (tarray1_big 0 --enable-error-stack -R tarray1_big.h5) - ADD_H5_TEST (tarray2 0 --enable-error-stack tarray2.h5) - ADD_H5_TEST (tarray3 0 --enable-error-stack tarray3.h5) - ADD_H5_TEST (tarray4 0 --enable-error-stack tarray4.h5) - ADD_H5_TEST (tarray5 0 --enable-error-stack tarray5.h5) - ADD_H5_TEST (tarray6 0 --enable-error-stack tarray6.h5) - ADD_H5_TEST (tarray7 0 --enable-error-stack tarray7.h5) - ADD_H5_TEST (tarray8 0 --enable-error-stack tarray8.h5) - - # test for wildcards in filename (does not work with cmake) - #ADD_H5_MASK_TEST (tstarfile 0 --enable-error-stack -H -d Dataset1 tarr*.h5) - #ADD_H5_MASK_TEST (tqmarkfile 0 --enable-error-stack -H -d Dataset1 tarray?.h5) - ADD_H5_TEST (tmultifile 0 --enable-error-stack -H -d Dataset1 tarray2.h5 tarray3.h5 tarray4.h5 tarray5.h5 tarray6.h5 tarray7.h5) - - # test for files with empty data - ADD_H5_TEST (tempty 0 --enable-error-stack tempty.h5) - - # test for files with groups that have comments - ADD_H5_TEST (tgrp_comments 0 --enable-error-stack tgrp_comments.h5) - - # test the --filedriver flag - ADD_H5_TEST (tsplit_file 0 --enable-error-stack --filedriver=split tsplit_file) - ADD_H5_TEST (tfamily 0 --enable-error-stack --filedriver=family tfamily%05d.h5) - ADD_H5_TEST (tmulti 0 --enable-error-stack --filedriver=multi tmulti) - - # test for files with group names which reach > 1024 bytes in size - ADD_H5_TEST (tlarge_objname 0 --enable-error-stack -w157 tlarge_objname.h5) - - # test '-A' to suppress data but print attr's - ADD_H5ERR_MASK_TEST (tall-2A 0 --enable-error-stack -A tall.h5) - - # test '-A' to suppress attr's but print data - ADD_H5ERR_MASK_TEST (tall-2A0 0 --enable-error-stack -A 0 tall.h5) - - # test '-r' to print attributes in ASCII instead of decimal - ADD_H5ERR_MASK_TEST (tall-2B 0 --enable-error-stack -A -r tall.h5) - - # test Subsetting - ADD_H5_TEST (tall-4s 0 --enable-error-stack --dataset=/g1/g1.1/dset1.1.1 --start=1,1 --stride=2,3 --count=3,2 --block=1,1 tall.h5) - ADD_H5_TEST (tall-5s 0 --enable-error-stack -d "/g1/g1.1/dset1.1.2[0;2;10;]" tall.h5) - ADD_H5_TEST (tdset-3s 0 --enable-error-stack -d "/dset1[1,1;;;]" tdset.h5) - ADD_H5_TEST (tno-subset 0 --enable-error-stack --no-compact-subset -d "AHFINDERDIRECT::ah_centroid_t[0] it=0 tl=0" tno-subset.h5) - - ADD_H5_TEST (tints4dimsCount2 0 --enable-error-stack -d FourDimInts -s 0,0,0,0 -c 2,2,2,2 tints4dims.h5) - ADD_H5_TEST (tints4dimsBlock2 0 --enable-error-stack -d FourDimInts -s 0,0,0,0 -c 1,1,1,1 -k 2,2,2,2 tints4dims.h5) - ADD_H5_TEST (tints4dimsStride2 0 --enable-error-stack -d FourDimInts -s 0,0,0,0 -S 2,2,2,2 -c 2,2,2,2 tints4dims.h5) - ADD_H5_TEST (tints4dimsCountEq 0 --enable-error-stack -d FourDimInts -s 0,0,0,0 -S 2,2,1,1 -k 1,2,1,1 -c 2,2,4,4 tints4dims.h5) - ADD_H5_TEST (tints4dimsBlockEq 0 --enable-error-stack -d FourDimInts -s 0,0,0,0 -S 2,2,1,1 -c 2,2,1,1 -k 1,2,4,4 tints4dims.h5) - - # test printing characters in ASCII instead of decimal - ADD_H5_TEST (tchar1 0 --enable-error-stack -r tchar.h5) - - # test datatypes in ASCII and UTF8 - ADD_H5_TEST (charsets 0 --enable-error-stack charsets.h5) - - # rev. 2004 - # tests for super block - ADD_H5_TEST (tboot1 0 --enable-error-stack -H -B -d dset tfcontents1.h5) - ADD_H5_TEST (tboot2 0 --enable-error-stack -B tfcontents2.h5) - ADD_H5_TEST (tboot2A 0 --enable-error-stack --boot-block tfcontents2.h5) - ADD_H5_TEST (tboot2B 0 --enable-error-stack --superblock tfcontents2.h5) - ADD_H5_TEST (file_space 0 --enable-error-stack -B file_space.h5) - - # test -p with a non existing dataset - ADD_H5ERR_MASK_TEST (tperror 1 --enable-error-stack -p -d bogus tfcontents1.h5) - - # test for file contents - ADD_H5_TEST (tcontents 0 --enable-error-stack -n tfcontents1.h5) - ADD_H5_TEST (tordercontents1 0 --enable-error-stack -n --sort_by=name --sort_order=ascending tfcontents1.h5) - ADD_H5_TEST (tordercontents2 0 --enable-error-stack -n --sort_by=name --sort_order=descending tfcontents1.h5) - ADD_H5_TEST (tattrcontents1 0 --enable-error-stack -n 1 --sort_order=ascending tall.h5) - ADD_H5_TEST (tattrcontents2 0 --enable-error-stack -n 1 --sort_order=descending tall.h5) - - # tests for storage layout - # compact - ADD_H5_TEST (tcompact 0 --enable-error-stack -H -p -d compact tfilters.h5) - # contiguous - ADD_H5_TEST (tcontiguos 0 --enable-error-stack -H -p -d contiguous tfilters.h5) - # chunked - ADD_H5_TEST (tchunked 0 --enable-error-stack -H -p -d chunked tfilters.h5) - # external - ADD_H5_TEST (texternal 0 --enable-error-stack -H -p -d external tfilters.h5) - - # fill values - ADD_H5_TEST (tfill 0 --enable-error-stack -p tfvalues.h5) - - # several datatype, with references , print path - ADD_H5_TEST (treference 0 --enable-error-stack tattr2.h5) - - # escape/not escape non printable characters - ADD_H5_TEST (tstringe 0 --enable-error-stack -e tstr3.h5) - ADD_H5_TEST (tstring 0 --enable-error-stack tstr3.h5) - # char data as ASCII with non escape - ADD_H5_TEST (tstring2 0 --enable-error-stack -r -d str4 tstr3.h5) - - # array indices print/not print - ADD_H5_TEST (tindicesyes 0 --enable-error-stack taindices.h5) - ADD_H5_TEST (tindicesno 0 --enable-error-stack -y taindices.h5) - - ########## array indices with subsetting - # 1D case - ADD_H5_TEST (tindicessub1 0 --enable-error-stack -d 1d -s 1 -S 10 -c 2 -k 3 taindices.h5) - - # 2D case - ADD_H5_TEST (tindicessub2 0 --enable-error-stack -d 2d -s 1,2 -S 3,3 -c 3,2 -k 2,2 taindices.h5) - - # 3D case - ADD_H5_TEST (tindicessub3 0 --enable-error-stack -d 3d -s 0,1,2 -S 1,3,3 -c 2,2,2 -k 1,2,2 taindices.h5) - - # 4D case - ADD_H5_TEST (tindicessub4 0 --enable-error-stack -d 4d -s 0,0,1,2 -c 2,2,3,2 -S 1,1,3,3 -k 1,1,2,2 taindices.h5) - - # Exceed the dimensions for subsetting - ADD_H5_TEST (texceedsubstart 1 --enable-error-stack -d 1d -s 1,3 taindices.h5) - ADD_H5_TEST (texceedsubcount 1 --enable-error-stack -d 1d -c 1,3 taindices.h5) - ADD_H5_TEST (texceedsubstride 1 --enable-error-stack -d 1d -S 1,3 taindices.h5) - ADD_H5_TEST (texceedsubblock 1 --enable-error-stack -d 1d -k 1,3 taindices.h5) - - # tests for filters - # SZIP - ADD_H5_TEST (tszip 0 --enable-error-stack -H -p -d szip tfilters.h5) - - # deflate - ADD_H5_TEST (tdeflate 0 --enable-error-stack -H -p -d deflate tfilters.h5) - - # shuffle - ADD_H5_TEST (tshuffle 0 --enable-error-stack -H -p -d shuffle tfilters.h5) - - # fletcher32 - ADD_H5_TEST (tfletcher32 0 --enable-error-stack -H -p -d fletcher32 tfilters.h5) - - # nbit - ADD_H5_TEST (tnbit 0 --enable-error-stack -H -p -d nbit tfilters.h5) - - # scaleoffset - ADD_H5_TEST (tscaleoffset 0 --enable-error-stack -H -p -d scaleoffset tfilters.h5) - - # all - ADD_H5_TEST (tallfilters 0 --enable-error-stack -H -p -d all tfilters.h5) - - # user defined - ADD_H5_TEST (tuserfilter 0 --enable-error-stack -H -p -d myfilter tfilters.h5) - - -# See which filters are usable (and skip tests for filters we -# don't have). Do this by searching H5pubconf.h to see which -# filters are defined. - -# detect whether the encoder is present. - if (H5_HAVE_FILTER_DEFLATE) - set (USE_FILTER_DEFLATE "true") - endif (H5_HAVE_FILTER_DEFLATE) - - if (H5_HAVE_FILTER_SZIP) - set (USE_FILTER_SZIP "true") - endif (H5_HAVE_FILTER_SZIP) - - if (USE_FILTER_DEFLATE) - # data read internal filters - ADD_H5_TEST (treadintfilter 0 --enable-error-stack -d deflate -d shuffle -d fletcher32 -d nbit -d scaleoffset tfilters.h5) - if (HDF5_ENABLE_SZIP_SUPPORT) - # data read all filters - ADD_H5_TEST (treadfilter 0 --enable-error-stack -d all -d szip tfilters.h5) - endif (HDF5_ENABLE_SZIP_SUPPORT) - endif (USE_FILTER_DEFLATE) - - # test for displaying objects with very long names - ADD_H5_TEST (tlonglinks 0 --enable-error-stack tlonglinks.h5) - - # dimensions over 4GB, print boundary - ADD_H5_TEST (tbigdims 0 --enable-error-stack -d dset4gb -s 4294967284 -c 22 tbigdims.h5) - - # hyperslab read - ADD_H5_TEST (thyperslab 0 --enable-error-stack thyperslab.h5) - - # test for displaying dataset and attribute of null space - ADD_H5_TEST (tnullspace 0 --enable-error-stack tnullspace.h5) - - # test for displaying dataset and attribute of space with 0 dimension size - ADD_H5_TEST (zerodim 0 --enable-error-stack zerodim.h5) - - # test for long double (some systems do not have long double) - #ADD_H5_TEST (tldouble 0 --enable-error-stack tldouble.h5) - - # test for vms - ADD_H5_TEST (tvms 0 --enable-error-stack tvms.h5) - - # test for binary output - ADD_H5_TEST (tbin1LE 0 --enable-error-stack -d integer -o tbin1LE.bin -b LE tbinary.h5) - - # test for string binary output - ADD_H5_EXPORT_TEST (tstr2bin2 tstr2.h5 0 --enable-error-stack -d /g2/dset2 -b -o) - ADD_H5_EXPORT_TEST (tstr2bin6 tstr2.h5 0 --enable-error-stack -d /g6/dset6 -b -o) - - # NATIVE default. the NATIVE test can be validated with h5import/h5diff - ADD_H5_TEST_IMPORT (tbin1 out1D tbinary.h5 0 --enable-error-stack -d integer -b) - - if (NOT HDF5_ENABLE_USING_MEMCHECKER) - ADD_H5_TEST (tbin2 0 --enable-error-stack -b BE -d float -o tbin2.bin tbinary.h5) - endif (NOT HDF5_ENABLE_USING_MEMCHECKER) - - # the NATIVE test can be validated with h5import/h5diff - ADD_H5_TEST_IMPORT (tbin3 out3D tbinary.h5 0 --enable-error-stack -d integer -b NATIVE) - - if (NOT HDF5_ENABLE_USING_MEMCHECKER) - ADD_H5_TEST (tbin4 0 --enable-error-stack -d double -b FILE -o tbin4.bin tbinary.h5) - endif (NOT HDF5_ENABLE_USING_MEMCHECKER) - - # test for dataset region references - ADD_H5_TEST (tdatareg 0 --enable-error-stack tdatareg.h5) - ADD_H5ERR_MASK_TEST (tdataregR 0 --enable-error-stack -R tdatareg.h5) - ADD_H5_TEST (tattrreg 0 --enable-error-stack tattrreg.h5) - ADD_H5ERR_MASK_TEST (tattrregR 0 -R --enable-error-stack tattrreg.h5) - ADD_H5_EXPORT_TEST (tbinregR tdatareg.h5 0 --enable-error-stack -d /Dataset1 -s 0 -R -y -o) - - # tests for group creation order - # "1" tracked, "2" name, root tracked - ADD_H5_TEST (tordergr1 0 --enable-error-stack --group=1 --sort_by=creation_order --sort_order=ascending tordergr.h5) - ADD_H5_TEST (tordergr2 0 --enable-error-stack --group=1 --sort_by=creation_order --sort_order=descending tordergr.h5) - ADD_H5_TEST (tordergr3 0 --enable-error-stack -g 2 -q name -z ascending tordergr.h5) - ADD_H5_TEST (tordergr4 0 --enable-error-stack -g 2 -q name -z descending tordergr.h5) - ADD_H5_TEST (tordergr5 0 --enable-error-stack -q creation_order tordergr.h5) - - # tests for attribute order - ADD_H5_TEST (torderattr1 0 --enable-error-stack -H --sort_by=name --sort_order=ascending torderattr.h5) - ADD_H5_TEST (torderattr2 0 --enable-error-stack -H --sort_by=name --sort_order=descending torderattr.h5) - ADD_H5_TEST (torderattr3 0 --enable-error-stack -H --sort_by=creation_order --sort_order=ascending torderattr.h5) - ADD_H5_TEST (torderattr4 0 --enable-error-stack -H --sort_by=creation_order --sort_order=descending torderattr.h5) - - # tests for link references and order - ADD_H5ERR_MASK_TEST (torderlinks1 0 --enable-error-stack --sort_by=name --sort_order=ascending tfcontents1.h5) - ADD_H5ERR_MASK_TEST (torderlinks2 0 --enable-error-stack --sort_by=name --sort_order=descending tfcontents1.h5) - - # tests for floating point user defined printf format - ADD_H5_TEST (tfpformat 0 --enable-error-stack -m %.7f tfpformat.h5) - - # tests for traversal of external links - ADD_H5ERR_MASK_TEST (textlinksrc 0 --enable-error-stack textlinksrc.h5) - ADD_H5ERR_MASK_TEST (textlinkfar 0 --enable-error-stack textlinkfar.h5) - - # test for dangling external links - ADD_H5ERR_MASK_TEST (textlink 0 --enable-error-stack textlink.h5) - - # test for error stack display (BZ2048) - ADD_H5ERR_MASK_ENV_TEST (filter_fail 1 "HDF5_PLUGIN_PRELOAD" "::" --enable-error-stack filter_fail.h5) - - # test for -o -y for dataset with attributes - ADD_H5_TEST_EXPORT (tall-6 tall.h5 0 --enable-error-stack -d /g1/g1.1/dset1.1.1 -y -o) - - # test for non-existing file - ADD_H5_TEST (non_existing 1 --enable-error-stack tgroup.h5 non_existing.h5) diff --git a/tools/h5dump/CMakeTestsPBITS.cmake b/tools/h5dump/CMakeTestsPBITS.cmake deleted file mode 100644 index 681479a..0000000 --- a/tools/h5dump/CMakeTestsPBITS.cmake +++ /dev/null @@ -1,340 +0,0 @@ - -############################################################################## -############################################################################## -### T E S T I N G ### -############################################################################## -############################################################################## - - # -------------------------------------------------------------------- - # Packed Bits - # -------------------------------------------------------------------- - #-- Copy all the HDF5 files from the test directory into the source directory - set (HDF5_REFERENCE_PBITS - tnofilename-with-packed-bits.ddl - tpbitsArray.ddl - tpbitsCompound.ddl - tpbitsIncomplete.ddl - tpbitsLengthExceeded.ddl - tpbitsCharLengthExceeded.ddl - tpbitsIntLengthExceeded.ddl - tpbitsLongLengthExceeded.ddl - tpbitsLengthPositive.ddl - tpbitsMax.ddl - tpbitsMaxExceeded.ddl - tpbitsOffsetExceeded.ddl - tpbitsCharOffsetExceeded.ddl - tpbitsIntOffsetExceeded.ddl - tpbitsLongOffsetExceeded.ddl - tpbitsOffsetNegative.ddl - tpbitsOverlapped.ddl - tpbitsSigned.ddl - tpbitsUnsigned.ddl - tpbitsSignedInt.ddl - tpbitsUnsignedInt.ddl - tpbitsSignedLong.ddl - tpbitsUnsignedLong.ddl - tpbitsSignedLongLong.ddl - tpbitsUnsignedLongLong.ddl - tpbitsSignedWhole.ddl - tpbitsUnsignedWhole.ddl - tpbitsSignedIntWhole.ddl - tpbitsUnsignedIntWhole.ddl - tpbitsSignedLongWhole.ddl - tpbitsUnsignedLongWhole.ddl - tpbitsSignedLongLongWhole.ddl - tpbitsUnsignedLongLongWhole.ddl - tpbitsSignedLongLongWhole1.ddl - tpbitsUnsignedLongLongWhole1.ddl - tpbitsSignedLongLongWhole63.ddl - tpbitsUnsignedLongLongWhole63.ddl - tpbitsSigned4.ddl - tpbitsUnsigned4.ddl - tpbitsSignedInt8.ddl - tpbitsUnsignedInt8.ddl - tpbitsSignedLong16.ddl - tpbitsUnsignedLong16.ddl - tpbitsSignedLongLong32.ddl - tpbitsUnsignedLongLong32.ddl - tpbitsSigned2.ddl - tpbitsUnsigned2.ddl - tpbitsSignedInt4.ddl - tpbitsUnsignedInt4.ddl - tpbitsSignedLong8.ddl - tpbitsUnsignedLong8.ddl - tpbitsSignedLongLong16.ddl - tpbitsUnsignedLongLong16.ddl - ) - set (HDF5_REFERENCE_TEST_PBITS - ${HDF5_TOOLS_DIR}/testfiles/packedbits.h5 - ${HDF5_TOOLS_DIR}/testfiles/tarray1.h5 - ${HDF5_TOOLS_DIR}/testfiles/tcompound.h5 - ) - set (HDF5_ERROR_REFERENCE_PBITS - tnofilename-with-packed-bits.err - tpbitsCharLengthExceeded.err - tpbitsCharOffsetExceeded.err - tpbitsIncomplete.err - tpbitsIntLengthExceeded.err - tpbitsIntOffsetExceeded.err - tpbitsLengthExceeded.err - tpbitsLengthPositive.err - tpbitsLongLengthExceeded.err - tpbitsLongOffsetExceeded.err - tpbitsMaxExceeded.err - tpbitsOffsetExceeded.err - tpbitsOffsetNegative.err - ) - - foreach (pbits_h5_file ${HDF5_REFERENCE_TEST_PBITS}) - get_filename_component(fname "${pbits_h5_file}" NAME) - HDFTEST_COPY_FILE("${pbits_h5_file}" "${PROJECT_BINARY_DIR}/testfiles/pbits/${fname}" "h5dump_pbits_files") - endforeach (pbits_h5_file ${HDF5_REFERENCE_TEST_PBITS}) - - - foreach (ddl_pbits ${HDF5_REFERENCE_PBITS}) - get_filename_component(fname "${ddl_pbits}" NAME) - HDFTEST_COPY_FILE("${HDF5_TOOLS_SRC_DIR}/testfiles/pbits/${ddl_pbits}" "${PROJECT_BINARY_DIR}/testfiles/pbits/${fname}" "h5dump_pbits_files") - endforeach (ddl_pbits ${HDF5_REFERENCE_PBITS}) - - foreach (ddl_pbits ${HDF5_ERROR_REFERENCE_PBITS}) - get_filename_component(fname "${ddl_pbits}" NAME) - HDFTEST_COPY_FILE("${PROJECT_SOURCE_DIR}/errfiles/${ddl_pbits}" "${PROJECT_BINARY_DIR}/testfiles/pbits/${fname}" "h5dump_pbits_files") - endforeach (ddl_pbits ${HDF5_ERROR_REFERENCE_PBITS}) - add_custom_target(h5dump_pbits_files ALL COMMENT "Copying files needed by h5dump_pbits tests" DEPENDS ${h5dump_pbits_files_list}) - -############################################################################## -############################################################################## -### T H E T E S T S M A C R O S ### -############################################################################## -############################################################################## - - MACRO (ADD_H5_PBITS_TEST resultfile resultcode) - # If using memchecker add tests without using scripts - if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5DUMP-${resultfile} COMMAND $<TARGET_FILE:h5dump> ${ARGN}) - set_tests_properties (H5DUMP-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/pbits") - if (NOT ${resultcode} STREQUAL "0") - set_tests_properties (H5DUMP-${resultfile} PROPERTIES WILL_FAIL "true") - endif () - if (NOT "${last_pbits_test}" STREQUAL "") - set_tests_properties (H5DUMP-${resultfile} PROPERTIES DEPENDS ${last_pbits_test}) - endif () - else (HDF5_ENABLE_USING_MEMCHECKER) - add_test ( - NAME H5DUMP-${resultfile} - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump>" - -D "TEST_ARGS:STRING=${ARGN}" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/pbits" - -D "TEST_OUTPUT=${resultfile}.out" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_REFERENCE=${resultfile}.ddl" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" - ) - endif (HDF5_ENABLE_USING_MEMCHECKER) - ENDMACRO (ADD_H5_PBITS_TEST file) - -############################################################################## -############################################################################## -### T H E T E S T S ### -############################################################################## -############################################################################## - - if (HDF5_ENABLE_USING_MEMCHECKER) - # Remove any output file left over from previous test run - add_test ( - NAME H5DUMP_PACKED_BITS-clearall-objects - COMMAND ${CMAKE_COMMAND} - -E remove - tnofilename-with-packed-bits.out - tnofilename-with-packed-bits.out.err - tpbitsArray.out - tpbitsArray.out.err - tpbitsCompound.out - tpbitsCompound.out.err - tpbitsIncomplete.out - tpbitsIncomplete.out.err - tpbitsLengthExceeded.out - tpbitsLengthExceeded.out.err - tpbitsCharLengthExceeded.out - tpbitsCharLengthExceeded.out.err - tpbitsIntLengthExceeded.out - tpbitsIntLengthExceeded.out.err - tpbitsLongLengthExceeded.out - tpbitsLongLengthExceeded.out.err - tpbitsLengthPositive.out - tpbitsLengthPositive.out.err - tpbitsMax.out - tpbitsMax.out.err - tpbitsMaxExceeded.out - tpbitsMaxExceeded.out.err - tpbitsOffsetExceeded.out - tpbitsOffsetExceeded.out.err - tpbitsCharOffsetExceeded.out - tpbitsCharOffsetExceeded.out.err - tpbitsIntOffsetExceeded.out - tpbitsIntOffsetExceeded.out.err - tpbitsLongOffsetExceeded.out - tpbitsLongOffsetExceeded.out.err - tpbitsOffsetNegative.out - tpbitsOffsetNegative.out.err - tpbitsOverlapped.out - tpbitsOverlapped.out.err - tpbitsSigned.out - tpbitsSigned.out.err - tpbitsUnsigned.out - tpbitsUnsigned.out.err - tpbitsSignedInt.out - tpbitsSignedInt.out.err - tpbitsUnsignedInt.out - tpbitsUnsignedInt.out.err - tpbitsSignedLong.out - tpbitsSignedLong.out.err - tpbitsUnsignedLong.out - tpbitsUnsignedLong.out.err - tpbitsSignedLongLong.out - tpbitsSignedLongLong.out.err - tpbitsUnsignedLongLong.out - tpbitsUnsignedLongLong.out.err - tpbitsSignedWhole.out - tpbitsSignedWhole.out.err - tpbitsUnsignedWhole.out - tpbitsUnsignedWhole.out.err - tpbitsSignedIntWhole.out - tpbitsSignedIntWhole.out.err - tpbitsUnsignedIntWhole.out - tpbitsUnsignedIntWhole.out.err - tpbitsSignedLongWhole.out - tpbitsSignedLongWhole.out.err - tpbitsUnsignedLongWhole.out - tpbitsUnsignedLongWhole.out.err - tpbitsSignedLongLongWhole.out - tpbitsSignedLongLongWhole.out.err - tpbitsUnsignedLongLongWhole.out - tpbitsUnsignedLongLongWhole.out.err - tpbitsSignedLongLongWhole1.out - tpbitsSignedLongLongWhole1.out.err - tpbitsUnsignedLongLongWhole1.out - tpbitsUnsignedLongLongWhole1.out.err - tpbitsSignedLongLongWhole63.out - tpbitsSignedLongLongWhole63.out.err - tpbitsUnsignedLongLongWhole63.out - tpbitsUnsignedLongLongWhole63.out.err - tpbitsSigned4.out - tpbitsSigned4.out.err - tpbitsUnsigned4.out - tpbitsUnsigned4.out.err - tpbitsSignedInt8.out - tpbitsSignedInt8.out.err - tpbitsUnsignedInt8.out - tpbitsUnsignedInt8.out.err - tpbitsSignedLong16.out - tpbitsSignedLong16.out.err - tpbitsUnsignedLong16.out - tpbitsUnsignedLong16.out.err - tpbitsSignedLongLong32.out - tpbitsSignedLongLong32.out.err - tpbitsUnsignedLongLong32.out - tpbitsUnsignedLongLong32.out.err - tpbitsSigned2.out - tpbitsSigned2.out.err - tpbitsUnsigned2.out - tpbitsUnsigned2.out.err - tpbitsSignedInt4.out - tpbitsSignedInt4.out.err - tpbitsUnsignedInt4.out - tpbitsUnsignedInt4.out.err - tpbitsSignedLong8.out - tpbitsSignedLong8.out.err - tpbitsUnsignedLong8.out - tpbitsUnsignedLong8.out.err - tpbitsSignedLongLong16.out - tpbitsSignedLongLong16.out.err - tpbitsUnsignedLongLong16.out - tpbitsUnsignedLongLong16.out.err - ) - set_tests_properties (H5DUMP_PACKED_BITS-clearall-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/pbits") - if (NOT "${last_pbits_test}" STREQUAL "") - set_tests_properties (H5DUMP_PACKED_BITS-clearall-objects PROPERTIES DEPENDS ${last_pbits_test}) - endif (NOT "${last_pbits_test}" STREQUAL "") - set (last_pbits_test "H5DUMP_PACKED_BITS-clearall-objects") - endif (HDF5_ENABLE_USING_MEMCHECKER) - - # test failure handling - # Missing file name - ADD_H5_PBITS_TEST (tnofilename-with-packed-bits 1 --enable-error-stack) - # Limits: - # Maximum number of packed bits is 8 (for now). - # Maximum integer size is 8*sizeof(long long). - # Maximun Offset is Maximum size - 1. - # Maximum Offset+Length is Maximum size. - # Tests: - # Normal operation on both signed and unsigned int datasets. - # Sanity check - # Their rawdata output should be the same. - ADD_H5_PBITS_TEST (tpbitsSignedWhole 0 --enable-error-stack -d /DS08BITS -M 0,8 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsUnsignedWhole 0 --enable-error-stack -d /DU08BITS -M 0,8 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsSignedIntWhole 0 --enable-error-stack -d /DS16BITS -M 0,16 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsUnsignedIntWhole 0 --enable-error-stack -d /DU16BITS -M 0,16 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsSignedLongWhole 0 --enable-error-stack -d /DS32BITS -M 0,32 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsUnsignedLongWhole 0 --enable-error-stack -d /DU32BITS -M 0,32 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsSignedLongLongWhole 0 --enable-error-stack -d /DS64BITS -M 0,64 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsUnsignedLongLongWhole 0 --enable-error-stack -d /DU64BITS -M 0,64 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsSignedLongLongWhole63 0 --enable-error-stack -d /DS64BITS -M 0,63 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsUnsignedLongLongWhole63 0 --enable-error-stack -d /DU64BITS -M 0,63 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsSignedLongLongWhole1 0 --enable-error-stack -d /DS64BITS -M 1,63 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsUnsignedLongLongWhole1 0 --enable-error-stack -d /DU64BITS -M 1,63 packedbits.h5) - # Half sections - ADD_H5_PBITS_TEST (tpbitsSigned4 0 --enable-error-stack -d /DS08BITS -M 0,4,4,4 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsUnsigned4 0 --enable-error-stack -d /DU08BITS -M 0,4,4,4 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsSignedInt8 0 --enable-error-stack -d /DS16BITS -M 0,8,8,8 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsUnsignedInt8 0 --enable-error-stack -d /DU16BITS -M 0,8,8,8 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsSignedLong16 0 --enable-error-stack -d /DS32BITS -M 0,16,16,16 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsUnsignedLong16 0 --enable-error-stack -d /DU32BITS -M 0,16,16,16 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsSignedLongLong32 0 --enable-error-stack -d /DS64BITS -M 0,32,32,32 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsUnsignedLongLong32 0 --enable-error-stack -d /DU64BITS -M 0,32,32,32 packedbits.h5) - # Quarter sections - ADD_H5_PBITS_TEST (tpbitsSigned2 0 --enable-error-stack -d /DS08BITS -M 0,2,2,2,4,2,6,2 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsUnsigned2 0 --enable-error-stack -d /DU08BITS -M 0,2,2,2,4,2,6,2 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsSignedInt4 0 --enable-error-stack -d /DS16BITS -M 0,4,4,4,8,4,12,4 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsUnsignedInt4 0 --enable-error-stack -d /DU16BITS -M 0,4,4,4,8,4,12,4 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsSignedLong8 0 --enable-error-stack -d /DS32BITS -M 0,8,8,8,16,8,24,8 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsUnsignedLong8 0 --enable-error-stack -d /DU32BITS -M 0,8,8,8,16,8,24,8 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsSignedLongLong16 0 --enable-error-stack -d /DS64BITS -M 0,16,16,16,32,16,48,16 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsUnsignedLongLong16 0 --enable-error-stack -d /DU64BITS -M 0,16,16,16,32,16,48,16 packedbits.h5) - # Begin and End - ADD_H5_PBITS_TEST (tpbitsSigned 0 --enable-error-stack -d /DS08BITS -M 0,2,2,6 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsUnsigned 0 --enable-error-stack -d /DU08BITS -M 0,2,2,6 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsSignedInt 0 --enable-error-stack -d /DS16BITS -M 0,2,10,6 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsUnsignedInt 0 --enable-error-stack -d /DU16BITS -M 0,2,10,6 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsSignedLong 0 --enable-error-stack -d /DS32BITS -M 0,2,26,6 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsUnsignedLong 0 --enable-error-stack -d /DU32BITS -M 0,2,26,6 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsSignedLongLong 0 --enable-error-stack -d /DS64BITS -M 0,2,58,6 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsUnsignedLongLong 0 --enable-error-stack -d /DU64BITS -M 0,2,58,6 packedbits.h5) - # Overlapped packed bits. - ADD_H5_PBITS_TEST (tpbitsOverlapped 0 --enable-error-stack -d /DS08BITS -M 0,1,1,1,2,1,0,3 packedbits.h5) - # Maximum number of packed bits. - ADD_H5_PBITS_TEST (tpbitsMax 0 --enable-error-stack -d /DS08BITS -M 0,1,1,1,2,1,3,1,4,1,5,1,6,1,7,1 packedbits.h5) - # Compound type. - ADD_H5_PBITS_TEST (tpbitsCompound 0 --enable-error-stack -d /dset1 -M 0,1,1,1 tcompound.h5) - # Array type. - ADD_H5_PBITS_TEST (tpbitsArray 0 --enable-error-stack -d /Dataset1 -M 0,1,1,1 tarray1.h5) - # Test Error handling. - # Too many packed bits requested. Max is 8 for now. - ADD_H5_PBITS_TEST (tpbitsMaxExceeded 1 --enable-error-stack -d /DS08BITS -M 0,1,0,1,1,1,2,1,3,1,4,1,5,1,6,1,7,1 packedbits.h5) - # Offset too large. Max is 8*sizeof(long long. - ADD_H5_PBITS_TEST (tpbitsOffsetExceeded 1 --enable-error-stack -d /DS08BITS -M 64,1 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsCharOffsetExceeded 0 --enable-error-stack -d /DS08BITS -M 8,1 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsIntOffsetExceeded 0 --enable-error-stack -d /DS16BITS -M 16,1 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsLongOffsetExceeded 0 --enable-error-stack -d /DS32BITS -M 32,1 packedbits.h5) - # Bad offset, must not be negative. - ADD_H5_PBITS_TEST (tpbitsOffsetNegative 1 --enable-error-stack -d /DS08BITS -M -1,1 packedbits.h5) - # Bad length, must not be positive. - ADD_H5_PBITS_TEST (tpbitsLengthPositive 1 --enable-error-stack -d /DS08BITS -M 4,0 packedbits.h5) - # Offset+Length is too large. Max is 8*sizeof(long long). - ADD_H5_PBITS_TEST (tpbitsLengthExceeded 1 --enable-error-stack -d /DS08BITS -M 37,28 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsCharLengthExceeded 0 --enable-error-stack -d /DS08BITS -M 2,7 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsIntLengthExceeded 0 --enable-error-stack -d /DS16BITS -M 10,7 packedbits.h5) - ADD_H5_PBITS_TEST (tpbitsLongLengthExceeded 0 --enable-error-stack -d /DS32BITS -M 26,7 packedbits.h5) - # Incomplete pair of packed bits request. - ADD_H5_PBITS_TEST (tpbitsIncomplete 1 --enable-error-stack -d /DS08BITS -M 0,2,2,1,0,2,2, packedbits.h5) diff --git a/tools/h5dump/CMakeTestsVDS.cmake b/tools/h5dump/CMakeTestsVDS.cmake deleted file mode 100644 index 32056db..0000000 --- a/tools/h5dump/CMakeTestsVDS.cmake +++ /dev/null @@ -1,233 +0,0 @@ - -############################################################################## -############################################################################## -### T E S T I N G ### -############################################################################## -############################################################################## - - # -------------------------------------------------------------------- - # VDS - # -------------------------------------------------------------------- - #-- Copy all the HDF5 files from the test directory into the source directory - set (HDF5_REFERENCE_VDS - tvds-1.ddl - tvds-2.ddl - tvds-3_1.ddl - tvds-3_2.ddl - tvds-4.ddl - tvds-5.ddl - tvds_layout-1.ddl - tvds_layout-2.ddl - tvds_layout-3_1.ddl - tvds_layout-3_2.ddl - tvds_layout-4.ddl - tvds_layout-5.ddl - vds-first.ddl - vds-gap1.ddl - vds-gap2.ddl - vds_layout-eiger.ddl - vds_layout-maxmin.ddl - ) - set (HDF5_REFERENCE_TEST_VDS - 1_a.h5 - 1_b.h5 - 1_c.h5 - 1_d.h5 - 1_e.h5 - 1_f.h5 - 1_vds.h5 - 2_a.h5 - 2_b.h5 - 2_c.h5 - 2_d.h5 - 2_e.h5 - 2_vds.h5 - 3_1_vds.h5 - 3_2_vds.h5 - 4_0.h5 - 4_1.h5 - 4_2.h5 - 4_vds.h5 - 5_a.h5 - 5_b.h5 - 5_c.h5 - 5_vds.h5 - a.h5 - b.h5 - c.h5 - d.h5 - vds-percival-unlim-maxmin.h5 - f-0.h5 - f-3.h5 - vds-eiger.h5 - ) - set (HDF5_ERROR_REFERENCE_VDS - ) - - foreach (vds_h5_file ${HDF5_REFERENCE_TEST_VDS}) - get_filename_component(fname "${vds_h5_file}" NAME) - HDFTEST_COPY_FILE("${HDF5_TOOLS_SRC_DIR}/testfiles/vds/${vds_h5_file}" "${PROJECT_BINARY_DIR}/testfiles/vds/${fname}" "h5dump_vds_files") - endforeach (vds_h5_file ${HDF5_REFERENCE_TEST_VDS}) - - - foreach (ddl_vds ${HDF5_REFERENCE_VDS}) - get_filename_component(fname "${ddl_vds}" NAME) - HDFTEST_COPY_FILE("${HDF5_TOOLS_SRC_DIR}/testfiles/vds/${ddl_vds}" "${PROJECT_BINARY_DIR}/testfiles/vds/${fname}" "h5dump_vds_files") - endforeach (ddl_vds ${HDF5_REFERENCE_VDS}) - - foreach (ddl_vds ${HDF5_ERROR_REFERENCE_VDS}) - get_filename_component(fname "${ddl_vds}" NAME) - HDFTEST_COPY_FILE("${PROJECT_SOURCE_DIR}/errfiles/${ddl_vds}" "${PROJECT_BINARY_DIR}/testfiles/vds/${fname}" "h5dump_vds_files") - endforeach (ddl_vds ${HDF5_ERROR_REFERENCE_VDS}) - add_custom_target(h5dump_vds_files ALL COMMENT "Copying files needed by h5dump_vds tests" DEPENDS ${h5dump_vds_files_list}) - -############################################################################## -############################################################################## -### T H E T E S T S M A C R O S ### -############################################################################## -############################################################################## - - MACRO (ADD_H5_VDS_TEST resultfile resultcode) - # If using memchecker add tests without using scripts - if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5DUMP-${resultfile} COMMAND $<TARGET_FILE:h5dump> ${ARGN}) - set_tests_properties (H5DUMP-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/vds") - if (NOT ${resultcode} STREQUAL "0") - set_tests_properties (H5DUMP-${resultfile} PROPERTIES WILL_FAIL "true") - endif () - if (NOT "${last_vds_test}" STREQUAL "") - set_tests_properties (H5DUMP-${resultfile} PROPERTIES DEPENDS ${last_VDS_test}) - endif () - else (HDF5_ENABLE_USING_MEMCHECKER) - add_test ( - NAME H5DUMP-${resultfile} - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump>" - -D "TEST_ARGS:STRING=${ARGN}" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/vds" - -D "TEST_OUTPUT=${resultfile}.out" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_REFERENCE=${resultfile}.ddl" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" - ) - endif (HDF5_ENABLE_USING_MEMCHECKER) - ENDMACRO (ADD_H5_VDS_TEST file) - - MACRO (ADD_H5_VDS_LAYOUT resultfile resultcode) - # If using memchecker add tests without using scripts - if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5DUMP-${resultfile} COMMAND $<TARGET_FILE:h5dump> -p ${ARGN}) - set_tests_properties (H5DUMP-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/vds") - if (NOT ${resultcode} STREQUAL "0") - set_tests_properties (H5DUMP-${resultfile} PROPERTIES WILL_FAIL "true") - endif () - if (NOT "${last_vds_test}" STREQUAL "") - set_tests_properties (H5DUMP-${resultfile} PROPERTIES DEPENDS ${last_VDS_test}) - endif () - else (HDF5_ENABLE_USING_MEMCHECKER) - add_test ( - NAME H5DUMP-${resultfile} - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump>" - -D "TEST_ARGS:STRING=-p;${ARGN}" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/vds" - -D "TEST_OUTPUT=${resultfile}.out" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_REFERENCE=${resultfile}.ddl" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" - ) - set_tests_properties (H5DUMP-${resultfile} PROPERTIES DEPENDS "H5DUMP-${resultfile}-clear-objects") - endif (HDF5_ENABLE_USING_MEMCHECKER) - ENDMACRO (ADD_H5_VDS_LAYOUT file) - -############################################################################## -############################################################################## -### T H E T E S T S ### -############################################################################## -############################################################################## - - if (HDF5_ENABLE_USING_MEMCHECKER) - # Remove any output file left over from previous test run - add_test ( - NAME H5DUMP_VDS-clearall-objects - COMMAND ${CMAKE_COMMAND} - -E remove - tvds-1.out - tvds-1.out.err - tvds-2.out - tvds-2.out.err - tvds-3_1.out - tvds-3_1.out.err - tvds-3_2.out - tvds-3_2.out.err - tvds-4.out - tvds-4.out.err - tvds-5.out - tvds-5.out.err - vds-first.out - vds-first.out.err - vds-gap1.out - vds-gap1.out.err - vds-gap2.out - vds-gap2.out.err - tvds_layout-1.out - tvds_layout-1.out.err - tvds_layout-2.out - tvds_layout-2.out.err - tvds_layout-3_1.out - tvds_layout-3_1.out.err - tvds_layout-3_2.out - tvds_layout-3_2.out.err - tvds_layout-4.out - tvds_layout-4.out.err - tvds_layout-5.out - tvds_layout-5.out.err - vds_layout-eiger.out - vds_layout-eiger.out.err - vds_layout-maxmin.out - vds_layout-maxmin.out.err - ) - set_tests_properties (H5DUMP_VDS-clearall-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/vds") - if (NOT "${last_vds_test}" STREQUAL "") - set_tests_properties (H5DUMP_VDS-clearall-objects PROPERTIES DEPENDS ${last_vds_test}) - endif (NOT "${last_vds_test}" STREQUAL "") - set (last_VDS_test "H5DUMP_VDS-clearall-objects") - endif (HDF5_ENABLE_USING_MEMCHECKER) - -# See which filters are usable (and skip tests for filters we -# don't have). Do this by searching H5pubconf.h to see which -# filters are defined. - -# detect whether the encoder is present. - if (H5_HAVE_FILTER_DEFLATE) - set (USE_FILTER_DEFLATE "true") - endif (H5_HAVE_FILTER_DEFLATE) - - if (H5_HAVE_FILTER_SZIP) - set (USE_FILTER_SZIP "true") - endif (H5_HAVE_FILTER_SZIP) - - # Data read - if (USE_FILTER_DEFLATE) - ADD_H5_VDS_TEST (tvds-1 0 --enable-error-stack 1_vds.h5) - ADD_H5_VDS_TEST (tvds-2 0 --enable-error-stack 2_vds.h5) - ADD_H5_VDS_TEST (tvds-3_1 0 --enable-error-stack 3_1_vds.h5) - ADD_H5_VDS_TEST (tvds-3_2 0 --enable-error-stack 3_2_vds.h5) - ADD_H5_VDS_TEST (tvds-4 0 --enable-error-stack 4_vds.h5) - ADD_H5_VDS_TEST (tvds-5 0 --enable-error-stack 5_vds.h5) - ADD_H5_VDS_TEST (vds-first 0 --vds-view-first-missing --enable-error-stack vds-percival-unlim-maxmin.h5) - ADD_H5_VDS_TEST (vds-gap1 0 -d /VDS-Eiger --vds-gap-size=1 --enable-error-stack vds-eiger.h5) - ADD_H5_VDS_TEST (vds-gap2 0 --vds-gap-size=2 --enable-error-stack vds-eiger.h5) - endif (USE_FILTER_DEFLATE) - - # Layout read - if (USE_FILTER_DEFLATE) - ADD_H5_VDS_LAYOUT (tvds_layout-1 0 --enable-error-stack 1_vds.h5) - ADD_H5_VDS_LAYOUT (tvds_layout-2 0 --enable-error-stack 2_vds.h5) - ADD_H5_VDS_LAYOUT (tvds_layout-3_1 0 --enable-error-stack 3_1_vds.h5) - ADD_H5_VDS_LAYOUT (tvds_layout-3_2 0 --enable-error-stack 3_2_vds.h5) - ADD_H5_VDS_LAYOUT (tvds_layout-4 0 --enable-error-stack 4_vds.h5) - ADD_H5_VDS_LAYOUT (tvds_layout-5 0 --enable-error-stack 5_vds.h5) - ADD_H5_VDS_LAYOUT (vds_layout-eiger 0 --enable-error-stack vds-eiger.h5) - ADD_H5_VDS_LAYOUT (vds_layout-maxmin 0 --enable-error-stack vds-percival-unlim-maxmin.h5) - endif (USE_FILTER_DEFLATE) diff --git a/tools/h5dump/CMakeTestsXML.cmake b/tools/h5dump/CMakeTestsXML.cmake deleted file mode 100644 index 79d3ff8..0000000 --- a/tools/h5dump/CMakeTestsXML.cmake +++ /dev/null @@ -1,414 +0,0 @@ - -############################################################################## -############################################################################## -### T E S T I N G ### -############################################################################## -############################################################################## - - # - # copy XML test files from source dir to test dir - # - set (HDF5_XML_REFERENCE_TEST_FILES - ${HDF5_TOOLS_DIR}/testfiles/tall.h5 - ${HDF5_TOOLS_DIR}/testfiles/tarray1.h5 - ${HDF5_TOOLS_DIR}/testfiles/tarray2.h5 - ${HDF5_TOOLS_DIR}/testfiles/tarray3.h5 - ${HDF5_TOOLS_DIR}/testfiles/tarray6.h5 - ${HDF5_TOOLS_DIR}/testfiles/tarray7.h5 - ${HDF5_TOOLS_DIR}/testfiles/tattr.h5 - ${HDF5_TOOLS_DIR}/testfiles/tbitfields.h5 - ${HDF5_TOOLS_DIR}/testfiles/tcompound.h5 - ${HDF5_TOOLS_DIR}/testfiles/tcompound2.h5 - ${HDF5_TOOLS_DIR}/testfiles/tcompound_complex.h5 - ${HDF5_TOOLS_DIR}/testfiles/tdatareg.h5 - ${HDF5_TOOLS_DIR}/testfiles/tdset.h5 - ${HDF5_TOOLS_DIR}/testfiles/tdset2.h5 - ${HDF5_TOOLS_DIR}/testfiles/tempty.h5 - ${HDF5_TOOLS_DIR}/testfiles/tenum.h5 - ${HDF5_TOOLS_DIR}/testfiles/textlink.h5 - ${HDF5_TOOLS_DIR}/testfiles/tfpformat.h5 - ${HDF5_TOOLS_DIR}/testfiles/tgroup.h5 - ${HDF5_TOOLS_DIR}/testfiles/thlink.h5 - ${HDF5_TOOLS_DIR}/testfiles/tloop.h5 - ${HDF5_TOOLS_DIR}/testfiles/tloop2.h5 - ${HDF5_TOOLS_DIR}/testfiles/tmany.h5 - ${HDF5_TOOLS_DIR}/testfiles/tname-amp.h5 - ${HDF5_TOOLS_DIR}/testfiles/tname-apos.h5 - ${HDF5_TOOLS_DIR}/testfiles/tname-gt.h5 - ${HDF5_TOOLS_DIR}/testfiles/tname-lt.h5 - ${HDF5_TOOLS_DIR}/testfiles/tname-quot.h5 - ${HDF5_TOOLS_DIR}/testfiles/tname-sp.h5 - ${HDF5_TOOLS_DIR}/testfiles/tnamed_dtype_attr.h5 - ${HDF5_TOOLS_DIR}/testfiles/tnestedcomp.h5 - ${HDF5_TOOLS_DIR}/testfiles/tnodata.h5 - ${HDF5_TOOLS_DIR}/testfiles/tobjref.h5 - ${HDF5_TOOLS_DIR}/testfiles/topaque.h5 - ${HDF5_TOOLS_DIR}/testfiles/torderattr.h5 - ${HDF5_TOOLS_DIR}/testfiles/tref.h5 - ${HDF5_TOOLS_DIR}/testfiles/tref-escapes.h5 - ${HDF5_TOOLS_DIR}/testfiles/tref-escapes-at.h5 - ${HDF5_TOOLS_DIR}/testfiles/tsaf.h5 - ${HDF5_TOOLS_DIR}/testfiles/tslink.h5 - ${HDF5_TOOLS_DIR}/testfiles/tstring.h5 - ${HDF5_TOOLS_DIR}/testfiles/tstring-at.h5 - ${HDF5_TOOLS_DIR}/testfiles/tstr.h5 - ${HDF5_TOOLS_DIR}/testfiles/tstr2.h5 - ${HDF5_TOOLS_DIR}/testfiles/tudlink.h5 - ${HDF5_TOOLS_DIR}/testfiles/tvldtypes1.h5 - ${HDF5_TOOLS_DIR}/testfiles/tvldtypes2.h5 - ${HDF5_TOOLS_DIR}/testfiles/tvldtypes3.h5 - ${HDF5_TOOLS_DIR}/testfiles/tvldtypes4.h5 - ${HDF5_TOOLS_DIR}/testfiles/tvldtypes5.h5 - ${HDF5_TOOLS_DIR}/testfiles/tvlstr.h5 - ) - set (HDF5_XML_REFERENCE_FILES - ${HDF5_TOOLS_DIR}/testfiles/tall.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tall-2A.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tarray1.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tarray2.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tarray3.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tarray6.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tarray7.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tattr.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tbitfields.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tcompound_complex.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tcompound.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tcompound2.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tdatareg.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tdset.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tdset2.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tempty.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tempty-dtd.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tempty-dtd-2.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tempty-dtd-uri.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tempty-nons.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tempty-nons-2.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tempty-nons-uri.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tempty-ns.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tempty-ns-2.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tenum.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/textlink.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tfpformat.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tgroup.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/thlink.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tloop.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tloop2.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tmany.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tname-amp.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tname-apos.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tnamed_dtype_attr.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tname-gt.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tname-lt.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tname-quot.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tname-sp.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tnestedcomp.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tnodata.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tobjref.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/topaque.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/torderattr1.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/torderattr2.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/torderattr3.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/torderattr4.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tref.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tref-escapes.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tref-escapes-at.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tsaf.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tslink.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tstr.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tstr2.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tstring.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tstring-at.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tudlink.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tvldtypes1.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tvldtypes2.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tvldtypes3.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tvldtypes4.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tvldtypes5.h5.xml - ${HDF5_TOOLS_DIR}/testfiles/tvlstr.h5.xml - ) - - foreach (tst_xml_h5_file ${HDF5_XML_REFERENCE_TEST_FILES}) - get_filename_component(fname "${tst_xml_h5_file}" NAME) - HDFTEST_COPY_FILE("${tst_xml_h5_file}" "${PROJECT_BINARY_DIR}/testfiles/xml/${fname}" "h5dump_xml_files") - endforeach (tst_xml_h5_file ${HDF5_XML_REFERENCE_TEST_FILES}) - - foreach (tst_xml_other_file ${HDF5_XML_REFERENCE_FILES}) - get_filename_component(fname "${tst_xml_other_file}" NAME) - HDFTEST_COPY_FILE("${tst_xml_other_file}" "${PROJECT_BINARY_DIR}/testfiles/xml/${fname}" "h5dump_xml_files") - endforeach (tst_xml_other_file ${HDF5_XML_REFERENCE_FILES}) - add_custom_target(h5dump_xml_files ALL COMMENT "Copying files needed by h5dump_xml tests" DEPENDS ${h5dump_xml_files_list}) - -############################################################################## -############################################################################## -### T H E T E S T S M A C R O S ### -############################################################################## -############################################################################## - - MACRO (ADD_XML_SKIP_H5_TEST skipresultfile skipresultcode testtype) - if (${testtype} STREQUAL "SKIP") - if (NOT HDF5_ENABLE_USING_MEMCHECKER) - add_test ( - NAME H5DUMP-XML-${skipresultfile}-SKIPPED - COMMAND ${CMAKE_COMMAND} -E echo "SKIP ${skipresultfile}.xml --xml ${ARGN}" - ) - endif (NOT HDF5_ENABLE_USING_MEMCHECKER) - else (${testtype} STREQUAL "SKIP") - ADD_XML_H5_TEST (${skipresultfile} ${skipresultcode} ${ARGN}) - endif (${testtype} STREQUAL "SKIP") - ENDMACRO (ADD_XML_SKIP_H5_TEST) - - MACRO (ADD_XML_H5_TEST resultfile resultcode) - if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5DUMP-XML-${resultfile} COMMAND $<TARGET_FILE:h5dump> --xml ${ARGN}) - set_tests_properties (H5DUMP-XML-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/xml") - if (NOT ${resultcode} STREQUAL "0") - set_tests_properties (H5DUMP-XML-${resultfile} PROPERTIES WILL_FAIL "true") - endif () - if (NOT "${last_xml_test}" STREQUAL "") - set_tests_properties (H5DUMP-XML-${resultfile} PROPERTIES DEPENDS ${last_xml_test}) - endif () - else (HDF5_ENABLE_USING_MEMCHECKER) - add_test ( - NAME H5DUMP-XML-${resultfile} - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump>" - -D "TEST_ARGS:STRING=--xml;${ARGN}" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/xml" - -D "TEST_OUTPUT=${resultfile}.out" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_REFERENCE=${resultfile}.xml" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" - ) - endif (HDF5_ENABLE_USING_MEMCHECKER) - ENDMACRO (ADD_XML_H5_TEST file) - -############################################################################## -############################################################################## -### T H E T E S T S ### -############################################################################## -############################################################################## - - if (HDF5_ENABLE_USING_MEMCHECKER) - # Remove any output file left over from previous test run - add_test ( - NAME H5DUMP-XML-clearall-objects - COMMAND ${CMAKE_COMMAND} - -E remove - tall.h5.out - tall.h5.out.err - tall-2A.h5.out - tall-2A.h5.out.err - tarray1.h5.out - tarray1.h5.out.err - tarray2.h5.out - tarray2.h5.out.err - tarray3.h5.out - tarray3.h5.out.err - tarray6.h5.out - tarray6.h5.out.err - tarray7.h5.out - tarray7.h5.out.err - tattr.h5.out - tattr.h5.out.err - tbitfields.h5.out - tbitfields.h5.out.err - tcompound.h5.out - tcompound.h5.out.err - tcompound2.h5.out - tcompound2.h5.out.err - tcompound_complex.h5.out - tcompound_complex.h5.out.err - tdatareg.h5.out - tdatareg.h5.out.err - tdset.h5.out - tdset.h5.out.err - tdset2.h5.out - tdset2.h5.out.err - tempty-dtd-2.h5.out - tempty-dtd-2.h5.out.err - tempty-dtd-uri.h5.out - tempty-dtd-uri.h5.out.err - tempty-dtd.h5.out - tempty-dtd.h5.out.err - tempty-nons-2.h5.out - tempty-nons-2.h5.out.err - tempty-nons-uri.h5.out - tempty-nons-uri.h5.out.err - tempty-nons.h5.out - tempty-nons.h5.out.err - tempty-ns-2.h5.out - tempty-ns-2.h5.out.err - tempty-ns.h5.out - tempty-ns.h5.out.err - tempty.h5.out - tempty.h5.out.err - tenum.h5.out - tenum.h5.out.err - textlink.h5.out - textlink.h5.out.err - tfpformat.h5.out - tfpformat.h5.out.err - tgroup.h5.out - tgroup.h5.out.err - thlink.h5.out - thlink.h5.out.err - tloop.h5.out - tloop.h5.out.err - tloop2.h5.out - tloop2.h5.out.err - tmany.h5.out - tmany.h5.out.err - tname-amp.h5.out - tname-amp.h5.out.err - tname-apos.h5.out - tname-apos.h5.out.err - tname-gt.h5.out - tname-gt.h5.out.err - tname-lt.h5.out - tname-lt.h5.out.err - tname-quot.h5.out - tname-quot.h5.out.err - tname-sp.h5.out - tname-sp.h5.out.err - tnamed_dtype_attr.h5.out - tnamed_dtype_attr.h5.out.err - tnestedcomp.h5.out - tnestedcomp.h5.out.err - tnodata.h5.out - tnodata.h5.out.err - tnoname.h5.out - tnoname.h5.out.err - tobjref.h5.out - tobjref.h5.out.err - topaque.h5.out - topaque.h5.out.err - torderattr1.h5.out - torderattr1.h5.out.err - torderattr2.h5.out - torderattr2.h5.out.err - torderattr3.h5.out - torderattr3.h5.out.err - torderattr4.h5.out - torderattr4.h5.out.err - tref-escapes-at.h5.out - tref-escapes-at.h5.out.err - tref-escapes.h5.out - tref-escapes.h5.out.err - tref.h5.out - tref.h5.out.err - tsaf.h5.out - tsaf.h5.out.err - tslink.h5.out - tslink.h5.out.err - tstr.h5.out - tstr.h5.out.err - tstr2.h5.out - tstr2.h5.out.err - tstring.h5.out - tstring.h5.out.err - tstring-at.h5.out - tstring-at.h5.out.err - tudlink.h5.out - tudlink.h5.out.err - tvldtypes1.h5.out - tvldtypes1.h5.out.err - tvldtypes2.h5.out - tvldtypes2.h5.out.err - tvldtypes3.h5.out - tvldtypes3.h5.out.err - tvldtypes4.h5.out - tvldtypes4.h5.out.err - tvldtypes5.h5.out - tvldtypes5.h5.out.err - tvlstr.h5.out - tvlstr.h5.out.err - ) - set_tests_properties (H5DUMP-XML-clearall-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/xml") - if (NOT "${last_xml_test}" STREQUAL "") - set_tests_properties (H5DUMP-XML-clearall-objects PROPERTIES DEPENDS ${last_xml_test}) - endif (NOT "${last_xml_test}" STREQUAL "") - set (last_test "H5DUMP-XML-clearall-objects") - endif (HDF5_ENABLE_USING_MEMCHECKER) - - ########## test XML - ADD_XML_H5_TEST (tall.h5 0 tall.h5) - ADD_XML_H5_TEST (tattr.h5 0 tattr.h5) - ADD_XML_H5_TEST (tbitfields.h5 0 tbitfields.h5) - ADD_XML_H5_TEST (tcompound.h5 0 tcompound.h5) - ADD_XML_H5_TEST (tcompound2.h5 0 tcompound2.h5) - ADD_XML_H5_TEST (tdatareg.h5 0 tdatareg.h5) - ADD_XML_H5_TEST (tdset.h5 0 tdset.h5) - ADD_XML_H5_TEST (tdset2.h5 0 tdset2.h5) - ADD_XML_H5_TEST (tenum.h5 0 tenum.h5) - ADD_XML_H5_TEST (tgroup.h5 0 tgroup.h5) - ADD_XML_H5_TEST (thlink.h5 0 thlink.h5) - ADD_XML_H5_TEST (tloop.h5 0 tloop.h5) - ADD_XML_H5_TEST (tloop2.h5 0 tloop2.h5) - ADD_XML_H5_TEST (tmany.h5 0 tmany.h5) - ADD_XML_H5_TEST (tnestedcomp.h5 0 tnestedcomp.h5) - ADD_XML_H5_TEST (tcompound_complex.h5 0 tcompound_complex.h5) - ADD_XML_H5_TEST (tobjref.h5 0 tobjref.h5) - ADD_XML_H5_TEST (topaque.h5 0 topaque.h5) - ADD_XML_H5_TEST (tslink.h5 0 tslink.h5) - ADD_XML_H5_TEST (tudlink.h5 0 tudlink.h5) - ADD_XML_H5_TEST (textlink.h5 0 textlink.h5) - ADD_XML_H5_TEST (tstr.h5 0 tstr.h5) - ADD_XML_H5_TEST (tstr2.h5 0 tstr2.h5) - ADD_XML_H5_TEST (tref.h5 0 tref.h5) - ADD_XML_H5_TEST (tname-amp.h5 0 tname-amp.h5) - ADD_XML_H5_TEST (tname-apos.h5 0 tname-apos.h5) - ADD_XML_H5_TEST (tname-gt.h5 0 tname-gt.h5) - ADD_XML_H5_TEST (tname-lt.h5 0 tname-lt.h5) - ADD_XML_H5_TEST (tname-quot.h5 0 tname-quot.h5) - ADD_XML_H5_TEST (tname-sp.h5 0 tname-sp.h5) - ADD_XML_H5_TEST (tstring.h5 0 tstring.h5) - ADD_XML_H5_TEST (tstring-at.h5 0 tstring-at.h5) - ADD_XML_H5_TEST (tref-escapes.h5 0 tref-escapes.h5) - ADD_XML_H5_TEST (tref-escapes-at.h5 0 tref-escapes-at.h5) - ADD_XML_H5_TEST (tnodata.h5 0 tnodata.h5) - ADD_XML_H5_TEST (tarray1.h5 0 tarray1.h5) - ADD_XML_H5_TEST (tarray2.h5 0 tarray2.h5) - ADD_XML_H5_TEST (tarray3.h5 0 tarray3.h5) - ADD_XML_H5_TEST (tarray6.h5 0 tarray6.h5) - ADD_XML_H5_TEST (tarray7.h5 0 tarray7.h5) - ADD_XML_H5_TEST (tvldtypes1.h5 0 tvldtypes1.h5) - ADD_XML_H5_TEST (tvldtypes2.h5 0 tvldtypes2.h5) - ADD_XML_H5_TEST (tvldtypes3.h5 0 tvldtypes3.h5) - ADD_XML_H5_TEST (tvldtypes4.h5 0 tvldtypes4.h5) - ADD_XML_H5_TEST (tvldtypes5.h5 0 tvldtypes5.h5) - ADD_XML_H5_TEST (tvlstr.h5 0 tvlstr.h5) - ADD_XML_H5_TEST (tsaf.h5 0 tsaf.h5) - ADD_XML_H5_TEST (tempty.h5 0 tempty.h5) - ADD_XML_H5_TEST (tnamed_dtype_attr.h5 0 tnamed_dtype_attr.h5) - ##Test dataset and attribute of null space. Commented out: - ## wait until the XML schema is updated for null space. - ## ADD_XML_H5_TEST (tnullspace.h5 0 tnulspace.h5) - ## So is dataspace with 0 dimension size. - ## ADD_XML_H5_TEST (zerodim.h5 0 zerodim.h5) - - # other options for xml - - ADD_XML_H5_TEST (tempty-dtd.h5 0 --use-dtd tempty.h5) - ADD_XML_H5_TEST (tempty-dtd-2.h5 0 -u tempty.h5) - - ADD_XML_H5_TEST (tempty-nons-2.h5 0 --xml-ns=: tempty.h5) - - ## Some of these combinations are syntactically correct but - ## the URLs are dummies - ADD_XML_H5_TEST (tempty-ns.h5 0 -X thing: tempty.h5) - ADD_XML_H5_TEST (tempty-ns-2.h5 0 --xml-ns=thing: tempty.h5) - ADD_XML_H5_TEST (tempty-nons-uri.h5 0 --xml-ns=: --xml-dtd=http://somewhere.net tempty.h5) - ADD_XML_H5_TEST (tempty-dtd-uri.h5 0 --use-dtd --xml-dtd=http://somewhere.net tempty.h5) - - ADD_XML_H5_TEST (tall-2A.h5 0 -A tall.h5) - - - # tests for attribute order - ADD_XML_H5_TEST (torderattr1.h5 0 -H --sort_by=name --sort_order=ascending torderattr.h5) - ADD_XML_H5_TEST (torderattr2.h5 0 -H --sort_by=name --sort_order=descending torderattr.h5) - ADD_XML_H5_TEST (torderattr3.h5 0 -H --sort_by=creation_order --sort_order=ascending torderattr.h5) - ADD_XML_H5_TEST (torderattr4.h5 0 -H --sort_by=creation_order --sort_order=descending torderattr.h5) - - # tests for floating point user defined printf format - ADD_XML_H5_TEST (tfpformat.h5 0 -u -m %.7f tfpformat.h5) - diff --git a/tools/h5dump/Makefile.am b/tools/h5dump/Makefile.am deleted file mode 100644 index 93ba195..0000000 --- a/tools/h5dump/Makefile.am +++ /dev/null @@ -1,51 +0,0 @@ -# -# Copyright by The HDF Group. -# Copyright by the Board of Trustees of the University of Illinois. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the files COPYING and Copyright.html. COPYING can be found at the root -# of the source code distribution tree; Copyright.html can be found at the -# root level of an installed copy of the electronic HDF5 document set and -# is linked from the top-level documents page. It can also be found at -# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have -# access to either file, you may request a copy from help@hdfgroup.org. -## -## Makefile.am -## Run automake to generate a Makefile.in from this file. -# -# HDF5 Library Makefile(.in) -# - -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 - -# Test programs and scripts -TEST_PROG=h5dumpgentest -TEST_SCRIPT=testh5dump.sh testh5dumppbits.sh testh5dumpvds.sh testh5dumpxml.sh - -check_PROGRAMS=$(TEST_PROG) binread -check_SCRIPTS=$(TEST_SCRIPT) -SCRIPT_DEPEND=h5dump$(EXEEXT) - -# Our main target, the h5dump tool. -bin_PROGRAMS=h5dump - -# Add h5dump specific linker flags here -h5dump_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS) - -# All the programs depend on the hdf5 and h5tools libraries -LDADD=$(LIBH5TOOLS) $(LIBHDF5) - -# Source files for the program -h5dump_SOURCES=h5dump.c h5dump_ddl.c h5dump_xml.c - -# Temporary files. *.h5 are generated by h5dumpgentest. They should -# copied to the testfiles/ directory if update is required. -CHECK_CLEANFILES+=*.h5 *.bin -DISTCLEANFILES=testh5dump.sh testh5dumppbits.sh testh5dumpxml.sh - -include $(top_srcdir)/config/conclude.am diff --git a/tools/h5dump/binread.c b/tools/h5dump/binread.c deleted file mode 100644 index 74db92c..0000000 --- a/tools/h5dump/binread.c +++ /dev/null @@ -1,97 +0,0 @@ - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -/* - This program reads binary output from h5dump (-b option). - To use change the following 3 symbols accordingly. - For example, to read 2 elements of a float type , define - - #define NELMTS 2 - #define TYPE float - #define FORMAT "%f " - -*/ - -#define NELMTS 6 -#define TYPE int -#define FORMAT "%d " - -/*------------------------------------------------------------------------- - * Function: usage - * - * Purpose: Prints a usage message on stderr and then returns. - * - * Return: void - * - * Programmer: Pedro Vicente Nunes - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static void -usage (void) -{ - fprintf(stderr, "usage: binread FILE_NAME\n"); -} - -/*------------------------------------------------------------------------- - * Function: main - * - * Purpose: main program. - * - *------------------------------------------------------------------------- - */ - -int -main (int argc, const char *argv[]) -{ - FILE *stream; - size_t numread; - TYPE buf[NELMTS]; - size_t i, nelmts = NELMTS; - char *fname=NULL; - - if (argc != 2) { - usage(); - exit(1); - } - - fname = strdup(argv[1]); - - if((stream = fopen(fname, "rb")) != NULL) { - numread = fread(buf, sizeof( TYPE ), nelmts, stream); - printf("Number of items read = %llu\n", (unsigned long long)numread); - - for (i = 0; i < nelmts; i++) { - printf(FORMAT,buf[i]); - } - printf("\n"); - - fclose(stream); - } - else - printf("File %s could not be opened\n", fname); - - free(fname); - - return 0; -} - diff --git a/tools/h5dump/errfiles/filter_fail.err b/tools/h5dump/errfiles/filter_fail.err deleted file mode 100644 index db21044..0000000 --- a/tools/h5dump/errfiles/filter_fail.err +++ /dev/null @@ -1,24 +0,0 @@ -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Dread(): can't read data - major: Dataset - minor: Read failed - #001: (file name) line (number) in H5D__read(): can't read data - major: Dataset - minor: Read failed - #002: (file name) line (number) in H5D__chunk_read(): unable to read raw data chunk - major: Low-level I/O - minor: Read failed - #003: (file name) line (number) in H5D__chunk_lock(): data pipeline read failed - major: Data filters - minor: Filter operation failed - #004: (file name) line (number) in H5Z_pipeline(): required filter 'filter_fail_test' is not registered - major: Data filters - minor: Read failed - #005: (file name) line (number) in H5PL_load(): required dynamically loaded plugin filter '312' is not available - major: Plugin for dynamically loaded library - minor: Unable to load metadata into cache -h5dump error: unable to print data -H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5tools_dump_simple_dset(): H5Dread failed - major: Failure in tools library - minor: error in function diff --git a/tools/h5dump/errfiles/non_existing.err b/tools/h5dump/errfiles/non_existing.err deleted file mode 100644 index f7e3afa..0000000 --- a/tools/h5dump/errfiles/non_existing.err +++ /dev/null @@ -1 +0,0 @@ -h5dump error: unable to open file "non_existing.h5" diff --git a/tools/h5dump/errfiles/tall-1.err b/tools/h5dump/errfiles/tall-1.err deleted file mode 100644 index ab9dbe3..0000000 --- a/tools/h5dump/errfiles/tall-1.err +++ /dev/null @@ -1,25 +0,0 @@ -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Oopen(): unable to open object - major: Object header - minor: Can't open object - #001: (file name) line (number) in H5O_open_name(): object not found - major: Object header - minor: Object not found - #002: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #003: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #004: (file name) line (number) in H5G_traverse_real(): special link traversal failed - major: Links - minor: Link traversal failure - #005: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed - major: Links - minor: Link traversal failure - #006: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID - major: Symbol table - minor: Unable to find atom information (already closed?) - #007: (file name) line (number) in H5L_extern_traverse(): unable to open external file, external link file name = 'somefile', temp_file_name = 'somefile' - major: Links - minor: Unable to open file diff --git a/tools/h5dump/errfiles/tall-2A.err b/tools/h5dump/errfiles/tall-2A.err deleted file mode 100644 index ab9dbe3..0000000 --- a/tools/h5dump/errfiles/tall-2A.err +++ /dev/null @@ -1,25 +0,0 @@ -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Oopen(): unable to open object - major: Object header - minor: Can't open object - #001: (file name) line (number) in H5O_open_name(): object not found - major: Object header - minor: Object not found - #002: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #003: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #004: (file name) line (number) in H5G_traverse_real(): special link traversal failed - major: Links - minor: Link traversal failure - #005: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed - major: Links - minor: Link traversal failure - #006: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID - major: Symbol table - minor: Unable to find atom information (already closed?) - #007: (file name) line (number) in H5L_extern_traverse(): unable to open external file, external link file name = 'somefile', temp_file_name = 'somefile' - major: Links - minor: Unable to open file diff --git a/tools/h5dump/errfiles/tall-2A0.err b/tools/h5dump/errfiles/tall-2A0.err deleted file mode 100644 index ab9dbe3..0000000 --- a/tools/h5dump/errfiles/tall-2A0.err +++ /dev/null @@ -1,25 +0,0 @@ -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Oopen(): unable to open object - major: Object header - minor: Can't open object - #001: (file name) line (number) in H5O_open_name(): object not found - major: Object header - minor: Object not found - #002: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #003: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #004: (file name) line (number) in H5G_traverse_real(): special link traversal failed - major: Links - minor: Link traversal failure - #005: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed - major: Links - minor: Link traversal failure - #006: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID - major: Symbol table - minor: Unable to find atom information (already closed?) - #007: (file name) line (number) in H5L_extern_traverse(): unable to open external file, external link file name = 'somefile', temp_file_name = 'somefile' - major: Links - minor: Unable to open file diff --git a/tools/h5dump/errfiles/tall-2B.err b/tools/h5dump/errfiles/tall-2B.err deleted file mode 100644 index ab9dbe3..0000000 --- a/tools/h5dump/errfiles/tall-2B.err +++ /dev/null @@ -1,25 +0,0 @@ -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Oopen(): unable to open object - major: Object header - minor: Can't open object - #001: (file name) line (number) in H5O_open_name(): object not found - major: Object header - minor: Object not found - #002: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #003: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #004: (file name) line (number) in H5G_traverse_real(): special link traversal failed - major: Links - minor: Link traversal failure - #005: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed - major: Links - minor: Link traversal failure - #006: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID - major: Symbol table - minor: Unable to find atom information (already closed?) - #007: (file name) line (number) in H5L_extern_traverse(): unable to open external file, external link file name = 'somefile', temp_file_name = 'somefile' - major: Links - minor: Unable to open file diff --git a/tools/h5dump/errfiles/tarray1_big.err b/tools/h5dump/errfiles/tarray1_big.err deleted file mode 100644 index 7a0fd7b..0000000 --- a/tools/h5dump/errfiles/tarray1_big.err +++ /dev/null @@ -1,31 +0,0 @@ -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Rdereference2(): unable to dereference object - major: References - minor: Unable to initialize object - #001: (file name) line (number) in H5R_dereference(): Undefined reference pointer - major: Invalid arguments to routine - minor: Bad value -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Rdereference2(): unable to dereference object - major: References - minor: Unable to initialize object - #001: (file name) line (number) in H5R_dereference(): Undefined reference pointer - major: Invalid arguments to routine - minor: Bad value -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Rdereference2(): unable to dereference object - major: References - minor: Unable to initialize object - #001: (file name) line (number) in H5R_dereference(): Undefined reference pointer - major: Invalid arguments to routine - minor: Bad value -H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5tools_dump_simple_data(): H5Rdereference failed - major: Failure in tools library - minor: error in function - #001: (file name) line (number) in h5tools_dump_simple_data(): H5Rdereference failed - major: Failure in tools library - minor: error in function - #002: (file name) line (number) in h5tools_dump_simple_data(): H5Rdereference failed - major: Failure in tools library - minor: error in function diff --git a/tools/h5dump/errfiles/tattr-3.err b/tools/h5dump/errfiles/tattr-3.err deleted file mode 100644 index ce8ddda..0000000 --- a/tools/h5dump/errfiles/tattr-3.err +++ /dev/null @@ -1,8 +0,0 @@ -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Aopen(): unable to load attribute info from object header for attribute: 'attr' - major: Attribute - minor: Unable to initialize object - #001: (file name) line (number) in H5O_attr_open_by_name(): can't locate attribute: 'attr' - major: Attribute - minor: Object not found -h5dump error: unable to open attribute "attr" diff --git a/tools/h5dump/errfiles/tattrregR.err b/tools/h5dump/errfiles/tattrregR.err deleted file mode 100644 index 9449a6d..0000000 --- a/tools/h5dump/errfiles/tattrregR.err +++ /dev/null @@ -1,21 +0,0 @@ -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Rdereference2(): unable to dereference object - major: References - minor: Unable to initialize object - #001: (file name) line (number) in H5R_dereference(): Undefined reference pointer - major: Invalid arguments to routine - minor: Bad value -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Rdereference2(): unable to dereference object - major: References - minor: Unable to initialize object - #001: (file name) line (number) in H5R_dereference(): Undefined reference pointer - major: Invalid arguments to routine - minor: Bad value -H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5tools_dump_simple_data(): H5Rdereference failed - major: Failure in tools library - minor: error in function - #001: (file name) line (number) in h5tools_dump_simple_data(): H5Rdereference failed - major: Failure in tools library - minor: error in function diff --git a/tools/h5dump/errfiles/tcomp-3.err b/tools/h5dump/errfiles/tcomp-3.err deleted file mode 100644 index ee47ee5..0000000 --- a/tools/h5dump/errfiles/tcomp-3.err +++ /dev/null @@ -1,16 +0,0 @@ -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Topen2(): not found - major: Datatype - minor: Object not found - #001: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #002: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #003: (file name) line (number) in H5G_traverse_real(): traversal operator failed - major: Symbol table - minor: Callback failed - #004: (file name) line (number) in H5G_loc_find_cb(): object '#6632' doesn't exist - major: Symbol table - minor: Object not found diff --git a/tools/h5dump/errfiles/tdataregR.err b/tools/h5dump/errfiles/tdataregR.err deleted file mode 100644 index 9449a6d..0000000 --- a/tools/h5dump/errfiles/tdataregR.err +++ /dev/null @@ -1,21 +0,0 @@ -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Rdereference2(): unable to dereference object - major: References - minor: Unable to initialize object - #001: (file name) line (number) in H5R_dereference(): Undefined reference pointer - major: Invalid arguments to routine - minor: Bad value -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Rdereference2(): unable to dereference object - major: References - minor: Unable to initialize object - #001: (file name) line (number) in H5R_dereference(): Undefined reference pointer - major: Invalid arguments to routine - minor: Bad value -H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5tools_dump_simple_data(): H5Rdereference failed - major: Failure in tools library - minor: error in function - #001: (file name) line (number) in h5tools_dump_simple_data(): H5Rdereference failed - major: Failure in tools library - minor: error in function diff --git a/tools/h5dump/errfiles/tdset-2.err b/tools/h5dump/errfiles/tdset-2.err deleted file mode 100644 index e594c1b..0000000 --- a/tools/h5dump/errfiles/tdset-2.err +++ /dev/null @@ -1,36 +0,0 @@ -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Dopen2(): unable to open dataset - major: Dataset - minor: Can't open object - #001: (file name) line (number) in H5D__open_name(): not found - major: Dataset - minor: Object not found - #002: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #003: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #004: (file name) line (number) in H5G_traverse_real(): traversal operator failed - major: Symbol table - minor: Callback failed - #005: (file name) line (number) in H5G_loc_find_cb(): object 'dset3' doesn't exist - major: Symbol table - minor: Object not found -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Lget_info(): unable to get link info - major: Links - minor: Object not found - #001: (file name) line (number) in H5L_get_info(): name doesn't exist - major: Symbol table - minor: Object already exists - #002: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #003: (file name) line (number) in H5G_traverse_real(): traversal operator failed - major: Symbol table - minor: Callback failed - #004: (file name) line (number) in H5L_get_info_cb(): name doesn't exist - major: Symbol table - minor: Object not found -h5dump error: unable to get link info from "dset3" diff --git a/tools/h5dump/errfiles/texceedsubblock.err b/tools/h5dump/errfiles/texceedsubblock.err deleted file mode 100644 index 4c87ab9..0000000 --- a/tools/h5dump/errfiles/texceedsubblock.err +++ /dev/null @@ -1 +0,0 @@ -h5dump error: number of block dims (2) exceed dataset dims (1) diff --git a/tools/h5dump/errfiles/texceedsubcount.err b/tools/h5dump/errfiles/texceedsubcount.err deleted file mode 100644 index de1c9d1..0000000 --- a/tools/h5dump/errfiles/texceedsubcount.err +++ /dev/null @@ -1 +0,0 @@ -h5dump error: number of count dims (2) exceed dataset dims (1) diff --git a/tools/h5dump/errfiles/texceedsubstart.err b/tools/h5dump/errfiles/texceedsubstart.err deleted file mode 100644 index 4555224..0000000 --- a/tools/h5dump/errfiles/texceedsubstart.err +++ /dev/null @@ -1 +0,0 @@ -h5dump error: number of start dims (2) exceed dataset dims (1) diff --git a/tools/h5dump/errfiles/texceedsubstride.err b/tools/h5dump/errfiles/texceedsubstride.err deleted file mode 100644 index 32d5725..0000000 --- a/tools/h5dump/errfiles/texceedsubstride.err +++ /dev/null @@ -1 +0,0 @@ -h5dump error: number of stride dims (2) exceed dataset dims (1) diff --git a/tools/h5dump/errfiles/textlink.err b/tools/h5dump/errfiles/textlink.err deleted file mode 100644 index 95556db..0000000 --- a/tools/h5dump/errfiles/textlink.err +++ /dev/null @@ -1,50 +0,0 @@ -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Oopen(): unable to open object - major: Object header - minor: Can't open object - #001: (file name) line (number) in H5O_open_name(): object not found - major: Object header - minor: Object not found - #002: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #003: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #004: (file name) line (number) in H5G_traverse_real(): special link traversal failed - major: Links - minor: Link traversal failure - #005: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed - major: Links - minor: Link traversal failure - #006: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID - major: Symbol table - minor: Unable to find atom information (already closed?) - #007: (file name) line (number) in H5L_extern_traverse(): unable to open external file, external link file name = 'filename', temp_file_name = 'filename' - major: Links - minor: Unable to open file -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Oopen(): unable to open object - major: Object header - minor: Can't open object - #001: (file name) line (number) in H5O_open_name(): object not found - major: Object header - minor: Object not found - #002: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #003: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #004: (file name) line (number) in H5G_traverse_real(): special link traversal failed - major: Links - minor: Link traversal failure - #005: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed - major: Links - minor: Link traversal failure - #006: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID - major: Symbol table - minor: Unable to find atom information (already closed?) - #007: (file name) line (number) in H5L_extern_traverse(): unable to open external file, external link file name = 'anotherfile', temp_file_name = 'anotherfile' - major: Links - minor: Unable to open file diff --git a/tools/h5dump/errfiles/textlinkfar.err b/tools/h5dump/errfiles/textlinkfar.err deleted file mode 100644 index 5aa7f87..0000000 --- a/tools/h5dump/errfiles/textlinkfar.err +++ /dev/null @@ -1,243 +0,0 @@ -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Oopen(): unable to open object - major: Object header - minor: Can't open object - #001: (file name) line (number) in H5O_open_name(): object not found - major: Object header - minor: Object not found - #002: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #003: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #004: (file name) line (number) in H5G_traverse_real(): special link traversal failed - major: Links - minor: Link traversal failure - #005: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed - major: Links - minor: Link traversal failure - #006: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID - major: Symbol table - minor: Unable to find atom information (already closed?) - #007: (file name) line (number) in H5L_extern_traverse(): unable to open object - major: Symbol table - minor: Can't open object - #008: (file name) line (number) in H5O_open_name(): object not found - major: Object header - minor: Object not found - #009: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #010: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #011: (file name) line (number) in H5G_traverse_real(): special link traversal failed - major: Links - minor: Link traversal failure - #012: (file name) line (number) in H5G__traverse_special(): symbolic link traversal failed - major: Links - minor: Link traversal failure - #013: (file name) line (number) in H5G_traverse_slink(): unable to follow symbolic link - major: Symbol table - minor: Object not found - #014: (file name) line (number) in H5G_traverse_real(): traversal operator failed - major: Symbol table - minor: Callback failed - #015: (file name) line (number) in H5G_traverse_slink_cb(): component not found - major: Symbol table - minor: Object not found -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #001: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #002: (file name) line (number) in H5G_traverse_real(): special link traversal failed - major: Links - minor: Link traversal failure - #003: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed - major: Links - minor: Link traversal failure - #004: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID - major: Symbol table - minor: Unable to find atom information (already closed?) - #005: (file name) line (number) in H5L_extern_traverse(): unable to open object - major: Symbol table - minor: Can't open object - #006: (file name) line (number) in H5O_open_name(): object not found - major: Object header - minor: Object not found - #007: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #008: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #009: (file name) line (number) in H5G_traverse_real(): special link traversal failed - major: Links - minor: Link traversal failure - #010: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed - major: Links - minor: Link traversal failure - #011: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID - major: Symbol table - minor: Unable to find atom information (already closed?) - #012: (file name) line (number) in H5L_extern_traverse(): unable to open object - major: Symbol table - minor: Can't open object - #013: (file name) line (number) in H5O_open_name(): object not found - major: Object header - minor: Object not found - #014: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #015: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #016: (file name) line (number) in H5G_traverse_real(): special link traversal failed - major: Links - minor: Link traversal failure - #017: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed - major: Links - minor: Link traversal failure - #018: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID - major: Symbol table - minor: Unable to find atom information (already closed?) - #019: (file name) line (number) in H5L_extern_traverse(): unable to open object - major: Symbol table - minor: Can't open object - #020: (file name) line (number) in H5O_open_name(): object not found - major: Object header - minor: Object not found - #021: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #022: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #023: (file name) line (number) in H5G_traverse_real(): special link traversal failed - major: Links - minor: Link traversal failure - #024: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed - major: Links - minor: Link traversal failure - #025: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID - major: Symbol table - minor: Unable to find atom information (already closed?) - #026: (file name) line (number) in H5L_extern_traverse(): unable to open object - major: Symbol table - minor: Can't open object - #027: (file name) line (number) in H5O_open_name(): object not found - major: Object header - minor: Object not found - #028: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #029: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #030: (file name) line (number) in H5G_traverse_real(): special link traversal failed - major: Links - minor: Link traversal failure - #031: (file name) line (number) in H5G__traverse_special(): too many links - major: Links - minor: Too many soft links in path -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #001: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #002: (file name) line (number) in H5G_traverse_real(): special link traversal failed - major: Links - minor: Link traversal failure - #003: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed - major: Links - minor: Link traversal failure - #004: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID - major: Symbol table - minor: Unable to find atom information (already closed?) - #005: (file name) line (number) in H5L_extern_traverse(): unable to open object - major: Symbol table - minor: Can't open object - #006: (file name) line (number) in H5O_open_name(): object not found - major: Object header - minor: Object not found - #007: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #008: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #009: (file name) line (number) in H5G_traverse_real(): special link traversal failed - major: Links - minor: Link traversal failure - #010: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed - major: Links - minor: Link traversal failure - #011: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID - major: Symbol table - minor: Unable to find atom information (already closed?) - #012: (file name) line (number) in H5L_extern_traverse(): unable to open object - major: Symbol table - minor: Can't open object - #013: (file name) line (number) in H5O_open_name(): object not found - major: Object header - minor: Object not found - #014: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #015: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #016: (file name) line (number) in H5G_traverse_real(): special link traversal failed - major: Links - minor: Link traversal failure - #017: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed - major: Links - minor: Link traversal failure - #018: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID - major: Symbol table - minor: Unable to find atom information (already closed?) - #019: (file name) line (number) in H5L_extern_traverse(): unable to open object - major: Symbol table - minor: Can't open object - #020: (file name) line (number) in H5O_open_name(): object not found - major: Object header - minor: Object not found - #021: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #022: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #023: (file name) line (number) in H5G_traverse_real(): special link traversal failed - major: Links - minor: Link traversal failure - #024: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed - major: Links - minor: Link traversal failure - #025: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID - major: Symbol table - minor: Unable to find atom information (already closed?) - #026: (file name) line (number) in H5L_extern_traverse(): unable to open object - major: Symbol table - minor: Can't open object - #027: (file name) line (number) in H5O_open_name(): object not found - major: Object header - minor: Object not found - #028: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #029: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #030: (file name) line (number) in H5G_traverse_real(): special link traversal failed - major: Links - minor: Link traversal failure - #031: (file name) line (number) in H5G__traverse_special(): too many links - major: Links - minor: Too many soft links in path diff --git a/tools/h5dump/errfiles/textlinksrc.err b/tools/h5dump/errfiles/textlinksrc.err deleted file mode 100644 index 5aa7f87..0000000 --- a/tools/h5dump/errfiles/textlinksrc.err +++ /dev/null @@ -1,243 +0,0 @@ -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Oopen(): unable to open object - major: Object header - minor: Can't open object - #001: (file name) line (number) in H5O_open_name(): object not found - major: Object header - minor: Object not found - #002: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #003: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #004: (file name) line (number) in H5G_traverse_real(): special link traversal failed - major: Links - minor: Link traversal failure - #005: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed - major: Links - minor: Link traversal failure - #006: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID - major: Symbol table - minor: Unable to find atom information (already closed?) - #007: (file name) line (number) in H5L_extern_traverse(): unable to open object - major: Symbol table - minor: Can't open object - #008: (file name) line (number) in H5O_open_name(): object not found - major: Object header - minor: Object not found - #009: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #010: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #011: (file name) line (number) in H5G_traverse_real(): special link traversal failed - major: Links - minor: Link traversal failure - #012: (file name) line (number) in H5G__traverse_special(): symbolic link traversal failed - major: Links - minor: Link traversal failure - #013: (file name) line (number) in H5G_traverse_slink(): unable to follow symbolic link - major: Symbol table - minor: Object not found - #014: (file name) line (number) in H5G_traverse_real(): traversal operator failed - major: Symbol table - minor: Callback failed - #015: (file name) line (number) in H5G_traverse_slink_cb(): component not found - major: Symbol table - minor: Object not found -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #001: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #002: (file name) line (number) in H5G_traverse_real(): special link traversal failed - major: Links - minor: Link traversal failure - #003: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed - major: Links - minor: Link traversal failure - #004: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID - major: Symbol table - minor: Unable to find atom information (already closed?) - #005: (file name) line (number) in H5L_extern_traverse(): unable to open object - major: Symbol table - minor: Can't open object - #006: (file name) line (number) in H5O_open_name(): object not found - major: Object header - minor: Object not found - #007: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #008: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #009: (file name) line (number) in H5G_traverse_real(): special link traversal failed - major: Links - minor: Link traversal failure - #010: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed - major: Links - minor: Link traversal failure - #011: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID - major: Symbol table - minor: Unable to find atom information (already closed?) - #012: (file name) line (number) in H5L_extern_traverse(): unable to open object - major: Symbol table - minor: Can't open object - #013: (file name) line (number) in H5O_open_name(): object not found - major: Object header - minor: Object not found - #014: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #015: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #016: (file name) line (number) in H5G_traverse_real(): special link traversal failed - major: Links - minor: Link traversal failure - #017: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed - major: Links - minor: Link traversal failure - #018: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID - major: Symbol table - minor: Unable to find atom information (already closed?) - #019: (file name) line (number) in H5L_extern_traverse(): unable to open object - major: Symbol table - minor: Can't open object - #020: (file name) line (number) in H5O_open_name(): object not found - major: Object header - minor: Object not found - #021: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #022: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #023: (file name) line (number) in H5G_traverse_real(): special link traversal failed - major: Links - minor: Link traversal failure - #024: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed - major: Links - minor: Link traversal failure - #025: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID - major: Symbol table - minor: Unable to find atom information (already closed?) - #026: (file name) line (number) in H5L_extern_traverse(): unable to open object - major: Symbol table - minor: Can't open object - #027: (file name) line (number) in H5O_open_name(): object not found - major: Object header - minor: Object not found - #028: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #029: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #030: (file name) line (number) in H5G_traverse_real(): special link traversal failed - major: Links - minor: Link traversal failure - #031: (file name) line (number) in H5G__traverse_special(): too many links - major: Links - minor: Too many soft links in path -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #001: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #002: (file name) line (number) in H5G_traverse_real(): special link traversal failed - major: Links - minor: Link traversal failure - #003: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed - major: Links - minor: Link traversal failure - #004: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID - major: Symbol table - minor: Unable to find atom information (already closed?) - #005: (file name) line (number) in H5L_extern_traverse(): unable to open object - major: Symbol table - minor: Can't open object - #006: (file name) line (number) in H5O_open_name(): object not found - major: Object header - minor: Object not found - #007: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #008: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #009: (file name) line (number) in H5G_traverse_real(): special link traversal failed - major: Links - minor: Link traversal failure - #010: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed - major: Links - minor: Link traversal failure - #011: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID - major: Symbol table - minor: Unable to find atom information (already closed?) - #012: (file name) line (number) in H5L_extern_traverse(): unable to open object - major: Symbol table - minor: Can't open object - #013: (file name) line (number) in H5O_open_name(): object not found - major: Object header - minor: Object not found - #014: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #015: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #016: (file name) line (number) in H5G_traverse_real(): special link traversal failed - major: Links - minor: Link traversal failure - #017: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed - major: Links - minor: Link traversal failure - #018: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID - major: Symbol table - minor: Unable to find atom information (already closed?) - #019: (file name) line (number) in H5L_extern_traverse(): unable to open object - major: Symbol table - minor: Can't open object - #020: (file name) line (number) in H5O_open_name(): object not found - major: Object header - minor: Object not found - #021: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #022: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #023: (file name) line (number) in H5G_traverse_real(): special link traversal failed - major: Links - minor: Link traversal failure - #024: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed - major: Links - minor: Link traversal failure - #025: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID - major: Symbol table - minor: Unable to find atom information (already closed?) - #026: (file name) line (number) in H5L_extern_traverse(): unable to open object - major: Symbol table - minor: Can't open object - #027: (file name) line (number) in H5O_open_name(): object not found - major: Object header - minor: Object not found - #028: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #029: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #030: (file name) line (number) in H5G_traverse_real(): special link traversal failed - major: Links - minor: Link traversal failure - #031: (file name) line (number) in H5G__traverse_special(): too many links - major: Links - minor: Too many soft links in path diff --git a/tools/h5dump/errfiles/tgroup-2.err b/tools/h5dump/errfiles/tgroup-2.err deleted file mode 100644 index 3659b5c..0000000 --- a/tools/h5dump/errfiles/tgroup-2.err +++ /dev/null @@ -1,20 +0,0 @@ -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Gopen2(): unable to open group - major: Symbol table - minor: Can't open object - #001: (file name) line (number) in H5G__open_name(): group not found - major: Symbol table - minor: Object not found - #002: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #003: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #004: (file name) line (number) in H5G_traverse_real(): traversal operator failed - major: Symbol table - minor: Callback failed - #005: (file name) line (number) in H5G_loc_find_cb(): object 'y' doesn't exist - major: Symbol table - minor: Object not found -h5dump error: unable to open group "/y" diff --git a/tools/h5dump/errfiles/tnofilename-with-packed-bits.err b/tools/h5dump/errfiles/tnofilename-with-packed-bits.err deleted file mode 100644 index 84a7011..0000000 --- a/tools/h5dump/errfiles/tnofilename-with-packed-bits.err +++ /dev/null @@ -1 +0,0 @@ -h5dump error: missing file name diff --git a/tools/h5dump/errfiles/torderlinks1.err b/tools/h5dump/errfiles/torderlinks1.err deleted file mode 100644 index e665f03..0000000 --- a/tools/h5dump/errfiles/torderlinks1.err +++ /dev/null @@ -1,25 +0,0 @@ -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Oopen(): unable to open object - major: Object header - minor: Can't open object - #001: (file name) line (number) in H5O_open_name(): object not found - major: Object header - minor: Object not found - #002: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #003: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #004: (file name) line (number) in H5G_traverse_real(): special link traversal failed - major: Links - minor: Link traversal failure - #005: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed - major: Links - minor: Link traversal failure - #006: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID - major: Symbol table - minor: Unable to find atom information (already closed?) - #007: (file name) line (number) in H5L_extern_traverse(): unable to open external file, external link file name = 'fname', temp_file_name = 'fname' - major: Links - minor: Unable to open file diff --git a/tools/h5dump/errfiles/torderlinks2.err b/tools/h5dump/errfiles/torderlinks2.err deleted file mode 100644 index e665f03..0000000 --- a/tools/h5dump/errfiles/torderlinks2.err +++ /dev/null @@ -1,25 +0,0 @@ -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Oopen(): unable to open object - major: Object header - minor: Can't open object - #001: (file name) line (number) in H5O_open_name(): object not found - major: Object header - minor: Object not found - #002: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #003: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #004: (file name) line (number) in H5G_traverse_real(): special link traversal failed - major: Links - minor: Link traversal failure - #005: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed - major: Links - minor: Link traversal failure - #006: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID - major: Symbol table - minor: Unable to find atom information (already closed?) - #007: (file name) line (number) in H5L_extern_traverse(): unable to open external file, external link file name = 'fname', temp_file_name = 'fname' - major: Links - minor: Unable to open file diff --git a/tools/h5dump/errfiles/tpbitsCharLengthExceeded.err b/tools/h5dump/errfiles/tpbitsCharLengthExceeded.err deleted file mode 100644 index e5854ea..0000000 --- a/tools/h5dump/errfiles/tpbitsCharLengthExceeded.err +++ /dev/null @@ -1 +0,0 @@ -h5dump error: Packed Bit offset+length value(9) too large. Max is 8 diff --git a/tools/h5dump/errfiles/tpbitsCharOffsetExceeded.err b/tools/h5dump/errfiles/tpbitsCharOffsetExceeded.err deleted file mode 100644 index e5854ea..0000000 --- a/tools/h5dump/errfiles/tpbitsCharOffsetExceeded.err +++ /dev/null @@ -1 +0,0 @@ -h5dump error: Packed Bit offset+length value(9) too large. Max is 8 diff --git a/tools/h5dump/errfiles/tpbitsIncomplete.err b/tools/h5dump/errfiles/tpbitsIncomplete.err deleted file mode 100644 index e0abee5..0000000 --- a/tools/h5dump/errfiles/tpbitsIncomplete.err +++ /dev/null @@ -1 +0,0 @@ -h5dump error: Bad mask list(0,2,2,1,0,2,2,) diff --git a/tools/h5dump/errfiles/tpbitsIntLengthExceeded.err b/tools/h5dump/errfiles/tpbitsIntLengthExceeded.err deleted file mode 100644 index 7dd88ed..0000000 --- a/tools/h5dump/errfiles/tpbitsIntLengthExceeded.err +++ /dev/null @@ -1 +0,0 @@ -h5dump error: Packed Bit offset+length value(17) too large. Max is 16 diff --git a/tools/h5dump/errfiles/tpbitsIntOffsetExceeded.err b/tools/h5dump/errfiles/tpbitsIntOffsetExceeded.err deleted file mode 100644 index 7dd88ed..0000000 --- a/tools/h5dump/errfiles/tpbitsIntOffsetExceeded.err +++ /dev/null @@ -1 +0,0 @@ -h5dump error: Packed Bit offset+length value(17) too large. Max is 16 diff --git a/tools/h5dump/errfiles/tpbitsLengthExceeded.err b/tools/h5dump/errfiles/tpbitsLengthExceeded.err deleted file mode 100644 index d4673f2..0000000 --- a/tools/h5dump/errfiles/tpbitsLengthExceeded.err +++ /dev/null @@ -1 +0,0 @@ -h5dump error: Packed Bit offset+length value(65) too large. Max is 64 diff --git a/tools/h5dump/errfiles/tpbitsLengthPositive.err b/tools/h5dump/errfiles/tpbitsLengthPositive.err deleted file mode 100644 index 4928007..0000000 --- a/tools/h5dump/errfiles/tpbitsLengthPositive.err +++ /dev/null @@ -1 +0,0 @@ -h5dump error: Packed Bit length value(0) must be positive. diff --git a/tools/h5dump/errfiles/tpbitsLongLengthExceeded.err b/tools/h5dump/errfiles/tpbitsLongLengthExceeded.err deleted file mode 100644 index 0318f79..0000000 --- a/tools/h5dump/errfiles/tpbitsLongLengthExceeded.err +++ /dev/null @@ -1 +0,0 @@ -h5dump error: Packed Bit offset+length value(33) too large. Max is 32 diff --git a/tools/h5dump/errfiles/tpbitsLongOffsetExceeded.err b/tools/h5dump/errfiles/tpbitsLongOffsetExceeded.err deleted file mode 100644 index 0318f79..0000000 --- a/tools/h5dump/errfiles/tpbitsLongOffsetExceeded.err +++ /dev/null @@ -1 +0,0 @@ -h5dump error: Packed Bit offset+length value(33) too large. Max is 32 diff --git a/tools/h5dump/errfiles/tpbitsMaxExceeded.err b/tools/h5dump/errfiles/tpbitsMaxExceeded.err deleted file mode 100644 index a8d12fc..0000000 --- a/tools/h5dump/errfiles/tpbitsMaxExceeded.err +++ /dev/null @@ -1 +0,0 @@ -h5dump error: Too many masks requested (max. 8). Mask list(0,1,0,1,1,1,2,1,3,1,4,1,5,1,6,1,7,1) diff --git a/tools/h5dump/errfiles/tpbitsOffsetExceeded.err b/tools/h5dump/errfiles/tpbitsOffsetExceeded.err deleted file mode 100644 index b7d6dad..0000000 --- a/tools/h5dump/errfiles/tpbitsOffsetExceeded.err +++ /dev/null @@ -1 +0,0 @@ -h5dump error: Packed Bit offset value(64) must be between 0 and 63 diff --git a/tools/h5dump/errfiles/tpbitsOffsetNegative.err b/tools/h5dump/errfiles/tpbitsOffsetNegative.err deleted file mode 100644 index 8a027c1..0000000 --- a/tools/h5dump/errfiles/tpbitsOffsetNegative.err +++ /dev/null @@ -1 +0,0 @@ -h5dump error: Bad mask list(-1,1) diff --git a/tools/h5dump/errfiles/tperror.err b/tools/h5dump/errfiles/tperror.err deleted file mode 100644 index b469029..0000000 --- a/tools/h5dump/errfiles/tperror.err +++ /dev/null @@ -1,36 +0,0 @@ -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Dopen2(): unable to open dataset - major: Dataset - minor: Can't open object - #001: (file name) line (number) in H5D__open_name(): not found - major: Dataset - minor: Object not found - #002: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #003: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #004: (file name) line (number) in H5G_traverse_real(): traversal operator failed - major: Symbol table - minor: Callback failed - #005: (file name) line (number) in H5G_loc_find_cb(): object 'bogus' doesn't exist - major: Symbol table - minor: Object not found -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Lget_info(): unable to get link info - major: Links - minor: Object not found - #001: (file name) line (number) in H5L_get_info(): name doesn't exist - major: Symbol table - minor: Object already exists - #002: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #003: (file name) line (number) in H5G_traverse_real(): traversal operator failed - major: Symbol table - minor: Callback failed - #004: (file name) line (number) in H5L_get_info_cb(): name doesn't exist - major: Symbol table - minor: Object not found -h5dump error: unable to get link info from "bogus" diff --git a/tools/h5dump/errfiles/tqmarkfile.err b/tools/h5dump/errfiles/tqmarkfile.err deleted file mode 100644 index 06519fb..0000000 --- a/tools/h5dump/errfiles/tqmarkfile.err +++ /dev/null @@ -1,33 +0,0 @@ -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Dopen2(): not found - major: Dataset - minor: Object not found - #001: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #002: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #003: (file name) line (number) in H5G_traverse_real(): traversal operator failed - major: Symbol table - minor: Callback failed - #004: (file name) line (number) in H5G_loc_find_cb(): object 'Dataset1' doesn't exist - major: Symbol table - minor: Object not found -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Lget_info(): unable to get link info - major: Symbol table - minor: Object not found - #001: (file name) line (number) in H5L_get_info(): name doesn't exist - major: Symbol table - minor: Object already exists - #002: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #003: (file name) line (number) in H5G_traverse_real(): traversal operator failed - major: Symbol table - minor: Callback failed - #004: (file name) line (number) in H5L_get_info_cb(): name doesn't exist - major: Symbol table - minor: Object not found -h5dump error: unable to get link info from "Dataset1" diff --git a/tools/h5dump/errfiles/tslink-D.err b/tools/h5dump/errfiles/tslink-D.err deleted file mode 100644 index 924e9cf..0000000 --- a/tools/h5dump/errfiles/tslink-D.err +++ /dev/null @@ -1,28 +0,0 @@ -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Dopen2(): unable to open dataset - major: Dataset - minor: Can't open object - #001: (file name) line (number) in H5D__open_name(): not found - major: Dataset - minor: Object not found - #002: (file name) line (number) in H5G_loc_find(): can't find object - major: Symbol table - minor: Object not found - #003: (file name) line (number) in H5G_traverse(): internal path traversal failed - major: Symbol table - minor: Object not found - #004: (file name) line (number) in H5G_traverse_real(): special link traversal failed - major: Links - minor: Link traversal failure - #005: (file name) line (number) in H5G__traverse_special(): symbolic link traversal failed - major: Links - minor: Link traversal failure - #006: (file name) line (number) in H5G_traverse_slink(): unable to follow symbolic link - major: Symbol table - minor: Object not found - #007: (file name) line (number) in H5G_traverse_real(): traversal operator failed - major: Symbol table - minor: Callback failed - #008: (file name) line (number) in H5G_traverse_slink_cb(): component not found - major: Symbol table - minor: Object not found diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c deleted file mode 100644 index 562cfd5..0000000 --- a/tools/h5dump/h5dump.c +++ /dev/null @@ -1,1802 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include <stdio.h> -#include <stdlib.h> - -#include "h5dump.h" -#include "h5dump_ddl.h" -#include "h5dump_xml.h" - -/* 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; - -/* module-scoped variables for XML option */ -#define DEFAULT_XSD "http://www.hdfgroup.org/HDF5/XML/schema/HDF5-File.xsd" -#define DEFAULT_DTD "http://www.hdfgroup.org/HDF5/XML/DTD/HDF5-File.dtd" - -/* Standard DDL output */ -static const dump_functions ddl_function_table = { - dump_group, - dump_named_datatype, - dump_dataset, - dump_dataspace, - dump_datatype, - dump_attr_cb, - dump_data -}; - -/* XML output */ -static const dump_functions xml_function_table = { - xml_dump_group, - xml_dump_named_datatype, - xml_dump_dataset, - xml_dump_dataspace, - xml_dump_datatype, - xml_dump_attr, - xml_dump_data -}; - -/* internal functions */ -static void init_prefix(char **prfx, size_t prfx_len); - -/* a structure for handling the order command-line parameters come in */ -struct handler_t { - void (*func)(hid_t, const char *, void *, int, const char *); - char *obj; - struct subset_t *subset_info; -}; - -/* - * Command-line options: The user can specify short or long-named - * parameters. The long-named ones can be partially spelled. When - * adding more, make sure that they don't clash with each other. - */ -/* The following initialization makes use of C language cancatenating */ -/* "xxx" "yyy" into "xxxyyy". */ -static const char *s_opts = "hn*peyBHirVa:c:d:f:g:k:l:t:w:xD:uX:o*b*F:s:S:A*q:z:m:RECM:O*N:vG:"; -static struct long_options l_opts[] = { - { "help", no_arg, 'h' }, - { "hel", no_arg, 'h' }, - { "contents", optional_arg, 'n' }, - { "properties", no_arg, 'p' }, - { "superblock", no_arg, 'B' }, - { "boot-block", no_arg, 'B' }, - { "boot-bloc", no_arg, 'B' }, - { "boot-blo", no_arg, 'B' }, - { "boot-bl", no_arg, 'B' }, - { "boot-b", no_arg, 'B' }, - { "boot", no_arg, 'B' }, - { "boo", no_arg, 'B' }, - { "bo", no_arg, 'B' }, - { "header", no_arg, 'H' }, - { "heade", no_arg, 'H' }, - { "head", no_arg, 'H' }, - { "hea", no_arg, 'H' }, - { "object-ids", no_arg, 'i' }, - { "object-id", no_arg, 'i' }, - { "object-i", no_arg, 'i' }, - { "object", no_arg, 'i' }, - { "objec", no_arg, 'i' }, - { "obje", no_arg, 'i' }, - { "obj", no_arg, 'i' }, - { "ob", no_arg, 'i' }, - { "version", no_arg, 'V' }, - { "versio", no_arg, 'V' }, - { "versi", no_arg, 'V' }, - { "vers", no_arg, 'V' }, - { "ver", no_arg, 'V' }, - { "ve", no_arg, 'V' }, - { "attribute", require_arg, 'a' }, - { "attribut", require_arg, 'a' }, - { "attribu", require_arg, 'a' }, - { "attrib", require_arg, 'a' }, - { "attri", require_arg, 'a' }, - { "attr", require_arg, 'a' }, - { "att", require_arg, 'a' }, - { "at", require_arg, 'a' }, - { "block", require_arg, 'k' }, - { "bloc", require_arg, 'k' }, - { "blo", require_arg, 'k' }, - { "bl", require_arg, 'k' }, - { "count", require_arg, 'c' }, - { "coun", require_arg, 'c' }, - { "cou", require_arg, 'c' }, - { "co", require_arg, 'c' }, - { "dataset", require_arg, 'd' }, - { "datase", require_arg, 'd' }, - { "datas", require_arg, 'd' }, - { "datatype", require_arg, 't' }, - { "datatyp", require_arg, 't' }, - { "dataty", require_arg, 't' }, - { "datat", require_arg, 't' }, - { "filedriver", require_arg, 'f' }, - { "filedrive", require_arg, 'f' }, - { "filedriv", require_arg, 'f' }, - { "filedri", require_arg, 'f' }, - { "filedr", require_arg, 'f' }, - { "filed", require_arg, 'f' }, - { "file", require_arg, 'f' }, - { "fil", require_arg, 'f' }, - { "fi", require_arg, 'f' }, - { "group", require_arg, 'g' }, - { "grou", require_arg, 'g' }, - { "gro", require_arg, 'g' }, - { "gr", require_arg, 'g' }, - { "output", optional_arg, 'o' }, - { "outpu", optional_arg, 'o' }, - { "outp", optional_arg, 'o' }, - { "out", optional_arg, 'o' }, - { "ou", optional_arg, 'o' }, - { "soft-link", require_arg, 'l' }, - { "soft-lin", require_arg, 'l' }, - { "soft-li", require_arg, 'l' }, - { "soft-l", require_arg, 'l' }, - { "soft", require_arg, 'l' }, - { "sof", require_arg, 'l' }, - { "start", require_arg, 's' }, - { "star", require_arg, 's' }, - { "sta", require_arg, 's' }, - { "stride", require_arg, 'S' }, - { "strid", require_arg, 'S' }, - { "string", no_arg, 'r' }, - { "strin", no_arg, 'r' }, - { "use-dtd", no_arg, 'u' }, - { "use-dt", no_arg, 'u' }, - { "use-d", no_arg, 'u' }, - { "use-", no_arg, 'u' }, - { "use", no_arg, 'u' }, - { "us", no_arg, 'u' }, - { "u", no_arg, 'u' }, - { "width", require_arg, 'w' }, - { "widt", require_arg, 'w' }, - { "wid", require_arg, 'w' }, - { "wi", require_arg, 'w' }, - { "xml-dtd", require_arg, 'D' }, - { "xml-dt", require_arg, 'D' }, - { "xml-d", require_arg, 'D' }, - { "xml-ns", require_arg, 'X' }, - { "xml-n", require_arg, 'X' }, - { "xml", no_arg, 'x' }, - { "xm", no_arg, 'x' }, - { "onlyattr", optional_arg, 'A' }, - { "escape", no_arg, 'e' }, - { "noindex", no_arg, 'y' }, - { "binary", optional_arg, 'b' }, - { "form", require_arg, 'F' }, - { "sort_by", require_arg, 'q' }, - { "sort_order", require_arg, 'z' }, - { "format", require_arg, 'm' }, - { "region", no_arg, 'R' }, - { "enable-error-stack", no_arg, 'E' }, - { "packed-bits", require_arg, 'M' }, - { "no-compact-subset", no_arg, 'C' }, - { "ddl", optional_arg, 'O' }, - { "any_path", require_arg, 'N' }, - { "vds-view-first-missing", no_arg, 'v' }, - { "vds-gap-size", require_arg, 'G' }, - { NULL, 0, '\0' } -}; - - -/*------------------------------------------------------------------------- - * Function: leave - * - * Purpose: Shutdown MPI & HDF5 and call exit() - * - * Return: Does not return - * - * Programmer: Quincey Koziol - * Saturday, 31. January 2004 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static void -leave(int ret) -{ - h5tools_close(); - - HDexit(ret); -} - - -/*------------------------------------------------------------------------- - * Function: usage - * - * Purpose: Print the usage message about dumper - * - * Return: void - *------------------------------------------------------------------------- - */ -static void -usage(const char *prog) -{ - FLUSHSTREAM(rawoutstream); - PRINTSTREAM(rawoutstream, "usage: %s [OPTIONS] files\n", prog); - PRINTVALSTREAM(rawoutstream, " OPTIONS\n"); - PRINTVALSTREAM(rawoutstream, " -h, --help Print a usage message and exit\n"); - PRINTVALSTREAM(rawoutstream, " -V, --version Print version number and exit\n"); - PRINTVALSTREAM(rawoutstream, "--------------- File Options ---------------\n"); - PRINTVALSTREAM(rawoutstream, " -n, --contents Print a list of the file contents and exit\n"); - PRINTVALSTREAM(rawoutstream, " Optional value 1 also prints attributes.\n"); - PRINTVALSTREAM(rawoutstream, " -B, --superblock Print the content of the super block\n"); - PRINTVALSTREAM(rawoutstream, " -H, --header Print the header only; no data is displayed\n"); - PRINTVALSTREAM(rawoutstream, " -f D, --filedriver=D Specify which driver to open the file with\n"); - PRINTVALSTREAM(rawoutstream, " -o F, --output=F Output raw data into file F\n"); - PRINTVALSTREAM(rawoutstream, " -b B, --binary=B Binary file output, of form B\n"); - PRINTVALSTREAM(rawoutstream, " -O F, --ddl=F Output ddl text into file F\n"); - PRINTVALSTREAM(rawoutstream, " Use blank(empty) filename F to suppress ddl display\n"); - PRINTVALSTREAM(rawoutstream, "--------------- Object Options ---------------\n"); - PRINTVALSTREAM(rawoutstream, " -a P, --attribute=P Print the specified attribute\n"); - PRINTVALSTREAM(rawoutstream, " If an attribute name contains a slash (/), escape the\n"); - PRINTVALSTREAM(rawoutstream, " slash with a preceding backslash (\\).\n"); - PRINTVALSTREAM(rawoutstream, " (See example section below.)\n"); - PRINTVALSTREAM(rawoutstream, " -d P, --dataset=P Print the specified dataset\n"); - PRINTVALSTREAM(rawoutstream, " -g P, --group=P Print the specified group and all members\n"); - PRINTVALSTREAM(rawoutstream, " -l P, --soft-link=P Print the value(s) of the specified soft link\n"); - PRINTVALSTREAM(rawoutstream, " -t P, --datatype=P Print the specified named datatype\n"); - PRINTVALSTREAM(rawoutstream, " -N P, --any_path=P Print any attribute, dataset, group, datatype, or link that matches P\n"); - PRINTVALSTREAM(rawoutstream, " P can be the absolute path or just a relative path.\n"); - PRINTVALSTREAM(rawoutstream, " -A, --onlyattr Print the header and value of attributes\n"); - PRINTVALSTREAM(rawoutstream, " Optional value 0 suppresses printing attributes.\n"); - PRINTVALSTREAM(rawoutstream, " --vds-view-first-missing Set the VDS bounds to first missing mapped elements.\n"); - PRINTVALSTREAM(rawoutstream, " --vds-gap-size=N Set the missing file gap size, N=non-negative integers\n"); - PRINTVALSTREAM(rawoutstream, "--------------- Object Property Options ---------------\n"); - PRINTVALSTREAM(rawoutstream, " -i, --object-ids Print the object ids\n"); - PRINTVALSTREAM(rawoutstream, " -p, --properties Print dataset filters, storage layout and fill value\n"); - PRINTVALSTREAM(rawoutstream, " -M L, --packedbits=L Print packed bits as unsigned integers, using mask\n"); - PRINTVALSTREAM(rawoutstream, " format L for an integer dataset specified with\n"); - PRINTVALSTREAM(rawoutstream, " option -d. L is a list of offset,length values,\n"); - PRINTVALSTREAM(rawoutstream, " separated by commas. Offset is the beginning bit in\n"); - PRINTVALSTREAM(rawoutstream, " the data value and length is the number of bits of\n"); - PRINTVALSTREAM(rawoutstream, " the mask.\n"); - PRINTVALSTREAM(rawoutstream, " -R, --region Print dataset pointed by region references\n"); - PRINTVALSTREAM(rawoutstream, "--------------- Formatting Options ---------------\n"); - PRINTVALSTREAM(rawoutstream, " -e, --escape Escape non printing characters\n"); - PRINTVALSTREAM(rawoutstream, " -r, --string Print 1-byte integer datasets as ASCII\n"); - PRINTVALSTREAM(rawoutstream, " -y, --noindex Do not print array indices with the data\n"); - PRINTVALSTREAM(rawoutstream, " -m T, --format=T Set the floating point output format\n"); - PRINTVALSTREAM(rawoutstream, " -q Q, --sort_by=Q Sort groups and attributes by index Q\n"); - PRINTVALSTREAM(rawoutstream, " -z Z, --sort_order=Z Sort groups and attributes by order Z\n"); - PRINTVALSTREAM(rawoutstream, " --enable-error-stack Prints messages from the HDF5 error stack as they\n"); - PRINTVALSTREAM(rawoutstream, " occur.\n"); - PRINTVALSTREAM(rawoutstream, " --no-compact-subset Disable compact form of subsetting and allow the use\n"); - PRINTVALSTREAM(rawoutstream, " of \"[\" in dataset names.\n"); - PRINTVALSTREAM(rawoutstream, " -w N, --width=N Set the number of columns of output. A value of 0 (zero)\n"); - PRINTVALSTREAM(rawoutstream, " sets the number of columns to the maximum (65535).\n"); - PRINTVALSTREAM(rawoutstream, " Default width is 80 columns.\n"); - PRINTVALSTREAM(rawoutstream, "--------------- XML Options ---------------\n"); - PRINTVALSTREAM(rawoutstream, " -x, --xml Output in XML using Schema\n"); - PRINTVALSTREAM(rawoutstream, " -u, --use-dtd Output in XML using DTD\n"); - PRINTVALSTREAM(rawoutstream, " -D U, --xml-dtd=U Use the DTD or schema at U\n"); - PRINTVALSTREAM(rawoutstream, " -X S, --xml-ns=S (XML Schema) Use qualified names n the XML\n"); - PRINTVALSTREAM(rawoutstream, " \":\": no namespace, default: \"hdf5:\"\n"); - PRINTVALSTREAM(rawoutstream, " E.g., to dump a file called `-f', use h5dump -- -f\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, "--------------- Subsetting Options ---------------\n"); - PRINTVALSTREAM(rawoutstream, " Subsetting is available by using the following options with a dataset\n"); - PRINTVALSTREAM(rawoutstream, " option. Subsetting is done by selecting a hyperslab from the data.\n"); - PRINTVALSTREAM(rawoutstream, " Thus, the options mirror those for performing a hyperslab selection.\n"); - PRINTVALSTREAM(rawoutstream, " One of the START, COUNT, STRIDE, or BLOCK parameters are mandatory if you do subsetting.\n"); - PRINTVALSTREAM(rawoutstream, " The STRIDE, COUNT, and BLOCK parameters are optional and will default to 1 in\n"); - PRINTVALSTREAM(rawoutstream, " each dimension. START is optional and will default to 0 in each dimension.\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " -s START, --start=START Offset of start of subsetting selection\n"); - PRINTVALSTREAM(rawoutstream, " -S STRIDE, --stride=STRIDE Hyperslab stride\n"); - PRINTVALSTREAM(rawoutstream, " -c COUNT, --count=COUNT Number of blocks to include in selection\n"); - PRINTVALSTREAM(rawoutstream, " -k BLOCK, --block=BLOCK Size of block in hyperslab\n"); - PRINTVALSTREAM(rawoutstream, " START, COUNT, STRIDE, and BLOCK - is a list of integers the number of which are equal to the\n"); - PRINTVALSTREAM(rawoutstream, " number of dimensions in the dataspace being queried\n"); - PRINTVALSTREAM(rawoutstream, " (Alternate compact form of subsetting is described in the Reference Manual)\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, "--------------- Option Argument Conventions ---------------\n"); - PRINTVALSTREAM(rawoutstream, " D - is the file driver to use in opening the file. Acceptable values\n"); - PRINTVALSTREAM(rawoutstream, " are \"sec2\", \"family\", \"split\", \"multi\", \"direct\", and \"stream\". Without\n"); - PRINTVALSTREAM(rawoutstream, " the file driver flag, the file will be opened with each driver in\n"); - PRINTVALSTREAM(rawoutstream, " turn and in the order specified above until one driver succeeds\n"); - PRINTVALSTREAM(rawoutstream, " in opening the file.\n"); - PRINTVALSTREAM(rawoutstream, " See examples below for family, split, and multi driver special file name usage.\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " F - is a filename.\n"); - PRINTVALSTREAM(rawoutstream, " P - is the full path from the root group to the object.\n"); - PRINTVALSTREAM(rawoutstream, " N - is an integer greater than 1.\n"); - PRINTVALSTREAM(rawoutstream, " T - is a string containing the floating point format, e.g '%%.3f'\n"); - PRINTVALSTREAM(rawoutstream, " U - is a URI reference (as defined in [IETF RFC 2396],\n"); - PRINTVALSTREAM(rawoutstream, " updated by [IETF RFC 2732])\n"); - PRINTVALSTREAM(rawoutstream, " B - is the form of binary output: NATIVE for a memory type, FILE for the\n"); - PRINTVALSTREAM(rawoutstream, " file type, LE or BE for pre-existing little or big endian types.\n"); - PRINTVALSTREAM(rawoutstream, " Must be used with -o (output file) and it is recommended that\n"); - PRINTVALSTREAM(rawoutstream, " -d (dataset) is used. B is an optional argument, defaults to NATIVE\n"); - PRINTVALSTREAM(rawoutstream, " Q - is the sort index type. It can be \"creation_order\" or \"name\" (default)\n"); - PRINTVALSTREAM(rawoutstream, " Z - is the sort order type. It can be \"descending\" or \"ascending\" (default)\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, "--------------- Examples ---------------\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " 1) Attribute foo of the group /bar_none in file quux.h5\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " h5dump -a /bar_none/foo quux.h5\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " Attribute \"high/low\" of the group /bar_none in the file quux.h5\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " h5dump -a \"/bar_none/high\\/low\" quux.h5\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " 2) Selecting a subset from dataset /foo in file quux.h5\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " h5dump -d /foo -s \"0,1\" -S \"1,1\" -c \"2,3\" -k \"2,2\" quux.h5\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " 3) Saving dataset 'dset' in file quux.h5 to binary file 'out.bin'\n"); - PRINTVALSTREAM(rawoutstream, " using a little-endian type\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " h5dump -d /dset -b LE -o out.bin quux.h5\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " 4) Display two packed bits (bits 0-1 and bits 4-6) in the dataset /dset\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " h5dump -d /dset -M 0,1,4,3 quux.h5\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " 5) Dataset foo in files file1.h5 file2.h5 file3.h5\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " h5dump -d /foo file1.h5 file2.h5 file3.h5\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " 6) Dataset foo in split files splitfile-m.h5 splitfile-r.h5\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " h5dump -d /foo -f split splitfile\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " 7) Dataset foo in multi files mf-s.h5, mf-b.h5, mf-r.h5, mf-g.h5, mf-l.h5 and mf-o.h5\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " h5dump -d /foo -f multi mf\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " 8) Dataset foo in family files fam00000.h5 fam00001.h5 and fam00002.h5\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " h5dump -d /foo -f family fam%%05d.h5\n"); - PRINTVALSTREAM(rawoutstream, "\n"); -} - - -/*------------------------------------------------------------------------- - * Function: table_list_add - * - * Purpose: Add a new set of tables - * - * Return: index of added table on success, -1 on failure - * - * Programmer: Neil Fortner, nfortne2@hdfgroup.org - * Adapted from trav_addr_add in h5trav.c by Quincey Koziol - * - * Date: October 13, 2008 - * - *------------------------------------------------------------------------- - */ -ssize_t -table_list_add(hid_t oid, unsigned long file_no) -{ - size_t idx; /* Index of table to use */ - find_objs_t info; - - /* Allocate space if necessary */ - if(table_list.nused == table_list.nalloc) { - h5dump_table_items_t *tmp_ptr; - - table_list.nalloc = MAX(1, table_list.nalloc * 2); - if(NULL == (tmp_ptr = (h5dump_table_items_t *)HDrealloc(table_list.tables, table_list.nalloc * sizeof(table_list.tables[0])))) - return -1; - table_list.tables = tmp_ptr; - } /* end if */ - - /* Append it */ - idx = table_list.nused++; - table_list.tables[idx].fileno = file_no; - table_list.tables[idx].oid = oid; - if(H5Iinc_ref(oid) < 0) { - table_list.nused--; - return -1; - } - if(init_objs(oid, &info, &table_list.tables[idx].group_table, - &table_list.tables[idx].dset_table, &table_list.tables[idx].type_table) < 0) { - H5Idec_ref(oid); - table_list.nused--; - return -1; - } - -#ifdef H5DUMP_DEBUG - dump_tables(&info); -#endif /* H5DUMP_DEBUG */ - - return((ssize_t) idx); -} /* end table_list_add() */ - - -/*------------------------------------------------------------------------- - * Function: table_list_visited - * - * Purpose: Check if a table already exists for the specified fileno - * - * Return: The index of the matching table, or -1 if no matches found - * - * Programmer: Neil Fortner, nfortne2@hdfgroup.org - * Adapted from trav_addr_visited in h5trav.c by Quincey Koziol - * - * Date: October 13, 2008 - * - *------------------------------------------------------------------------- - */ -H5_ATTR_PURE ssize_t -table_list_visited(unsigned long file_no) -{ - size_t u; /* Local index variable */ - - /* Look for table */ - for(u = 0; u < table_list.nused; u++) - /* Check for fileno value already in array */ - if(table_list.tables[u].fileno == file_no) - return((ssize_t) u); - - /* Didn't find table */ - return(-1); -} /* end table_list_visited() */ - - -/*------------------------------------------------------------------------- - * Function: table_list_free - * - * Purpose: Frees the table list - * - * Return: void - * - * Programmer: Neil Fortner, nfortne2@hdfgroup.org - * - * Date: October 13, 2008 - * - *------------------------------------------------------------------------- - */ -static void -table_list_free(void) -{ - size_t u; /* Local index variable */ - - /* Iterate over tables */ - for(u = 0; u < table_list.nused; u++) { - /* Release object id */ - if(H5Idec_ref(table_list.tables[u].oid) < 0) - h5tools_setstatus(EXIT_FAILURE); - - /* Free each table */ - free_table(table_list.tables[u].group_table); - HDfree(table_list.tables[u].group_table); - free_table(table_list.tables[u].dset_table); - HDfree(table_list.tables[u].dset_table); - free_table(table_list.tables[u].type_table); - HDfree(table_list.tables[u].type_table); - } - - /* Free the table list */ - HDfree(table_list.tables); - table_list.tables = NULL; - table_list.nalloc = table_list.nused = 0; -} /* end table_list_free() */ - -/*------------------------------------------------------------------------- - * Function: set_binary_form - * - * Purpose: set the binary form of output by translating from a string input - * parameter to a integer return value - * - * Return: integer form of binary output or -1 if none found - * - * Programmer: Pedro Vicente Nunes - * June 28, 2006 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static int -set_binary_form(const char *form) -{ - int bform = -1; - - if (HDstrcmp(form,"NATIVE") == 0 || HDstrcmp(form,"MEMORY") == 0) { - /* native form */ - bform = 0; - } - else if (HDstrcmp(form,"FILE") == 0) /* file type form */ - bform = 1; - else if (HDstrcmp(form,"LE") == 0) /* convert to little endian */ - bform = 2; - else if (HDstrcmp(form,"BE") == 0) /* convert to big endian */ - bform = 3; - - return bform; -} - -/*------------------------------------------------------------------------- - * Function: set_sort_by - * - * Purpose: set the "by" form of sorting by translating from a string input - * parameter to a H5_index_t return value - * current sort values are [creation_order | name] - * - * Return: H5_index_t form of sort or H5_INDEX_UNKNOWN if none found - * - * Programmer: Pedro Vicente Nunes - * October 1, 2007 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static H5_index_t -set_sort_by(const char *form) -{ - H5_index_t idx_type = H5_INDEX_UNKNOWN; - - if (HDstrcmp(form,"name")==0) /* H5_INDEX_NAME */ - idx_type = H5_INDEX_NAME; - else if (HDstrcmp(form,"creation_order")==0) /* H5_INDEX_CRT_ORDER */ - idx_type = H5_INDEX_CRT_ORDER; - - return idx_type; -} - -/*------------------------------------------------------------------------- - * Function: set_sort_order - * - * Purpose: set the order of sorting by translating from a string input - * parameter to a H5_iter_order_t return value - * current order values are [ascending | descending ] - * - * Return: H5_iter_order_t form of order or H5_ITER_UNKNOWN if none found - * - * Programmer: Pedro Vicente Nunes - * October 1, 2007 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static H5_iter_order_t -set_sort_order(const char *form) -{ - H5_iter_order_t iter_order = H5_ITER_UNKNOWN; - - if (HDstrcmp(form,"ascending")==0) /* H5_ITER_INC */ - iter_order = H5_ITER_INC; - else if (HDstrcmp(form,"descending")==0) /* H5_ITER_DEC */ - iter_order = H5_ITER_DEC; - - return iter_order; -} - -/*------------------------------------------------------------------------- - * Function: parse_hsize_list - * - * Purpose: Parse a list of comma or space separated integers and return - * them in a list. The string being passed into this function - * should be at the start of the list you want to parse. You are - * responsible for freeing the array returned from here. - * - * Lists in the so-called "terse" syntax are separated by - * semicolons (;). The lists themselves can be separated by - * either commas (,) or white spaces. - * - * Return: <none> - * - * Programmer: Bill Wendling - * Tuesday, 6. February 2001 - * - *------------------------------------------------------------------------- - */ -static void -parse_hsize_list(const char *h_list, subset_d *d) -{ - hsize_t *p_list; - const char *ptr; - unsigned int size_count = 0; - unsigned int i = 0; - unsigned int last_digit = 0; - - if (!h_list || !*h_list || *h_list == ';') - return; - - /* 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 */ - return; - - /* allocate an array for the integers in the list */ - p_list = (hsize_t *)HDcalloc(size_count, sizeof(hsize_t)); - - for (ptr = h_list; i < size_count && ptr && *ptr && *ptr != ';' && *ptr != ']'; ptr++) - if(HDisdigit(*ptr)) { - /* 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; -} - -/*------------------------------------------------------------------------- - * Function: parse_subset_params - * - * Purpose: Parse the so-called "terse" syntax for specifying subsetting - * parameters. - * - * Return: Success: struct subset_t object - * Failure: NULL - * - * Programmer: Bill Wendling - * Tuesday, 6. February 2001 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static struct subset_t * -parse_subset_params(char *dset) -{ - struct subset_t *s = NULL; - char *brace; - - if (!disable_compact_subset && ((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); - } - - return s; -} - -/*------------------------------------------------------------------------- - * Function: parse_mask_list - * - * Purpose: Parse a list of comma or space separated integers and fill - * the packed_bits list and counter. The string being passed into this function - * should be at the start of the list you want to parse. - * - * Return: Success: SUCCEED - * - * Failure: FAIL - * - *------------------------------------------------------------------------- - */ -static int -parse_mask_list(const char *h_list) -{ - int soffset_value; - unsigned offset_value; - int slength_value; - unsigned length_value; - unsigned long long temp_mask; - const char *ptr = NULL; - - /* sanity check */ - HDassert(h_list); - - HDmemset(packed_mask,0,sizeof(packed_mask)); - - packed_bits_num = 0; - /* scan in pair of offset,length separated by commas. */ - ptr = h_list; - while (*ptr) { - /* scan for an offset which is an unsigned int */ - if (!HDisdigit(*ptr)) { - error_msg("Bad mask list(%s)\n", h_list); - return FAIL; - } - soffset_value = HDatoi(ptr); - offset_value = (unsigned)soffset_value; - if (soffset_value < 0 || offset_value >= PACKED_BITS_SIZE_MAX) { - error_msg("Packed Bit offset value(%d) must be between 0 and %u\n", - soffset_value, (unsigned)(PACKED_BITS_SIZE_MAX - 1)); - return FAIL; - } - - /* skip to end of integer */ - while (HDisdigit(*++ptr)) - ; - /* Look for the common separator */ - if (*ptr++ != ',') { - error_msg("Bad mask list(%s), missing expected comma separator.\n", h_list); - return FAIL; - } - - /* scan for a length which is a positive int */ - if (!HDisdigit(*ptr)) { - error_msg("Bad mask list(%s)\n", h_list); - return FAIL; - } - slength_value = HDatoi(ptr); - if (slength_value <= 0) { - error_msg("Packed Bit length value(%d) must be positive.\n", slength_value); - return FAIL; - } - length_value = (unsigned)slength_value; - if ((offset_value + length_value) > PACKED_BITS_SIZE_MAX) { - error_msg("Packed Bit offset+length value(%u) too large. Max is %u\n", - offset_value+length_value, (unsigned)PACKED_BITS_SIZE_MAX); - return FAIL; - } - - /* skip to end of int */ - while (HDisdigit(*++ptr)) - ; - - /* store the offset,length pair */ - if (packed_bits_num >= PACKED_BITS_MAX) { - /* too many requests */ - error_msg("Too many masks requested (max. %d). Mask list(%s)\n", PACKED_BITS_MAX, h_list); - return FAIL; - } - packed_offset[packed_bits_num] = offset_value; - packed_length[packed_bits_num] = length_value; - /* create the bit mask by left shift 1's by length, then negate it. */ - /* After packed_mask is calculated, packed_length is not needed but */ - /* keep it for debug purpose. */ - temp_mask = ~0ULL; - if(length_value < (int)(8 *sizeof(unsigned long long))) { - temp_mask = temp_mask << length_value; - packed_mask[packed_bits_num] = ~temp_mask; - } - else - packed_mask[packed_bits_num] = temp_mask; - packed_bits_num++; - - /* skip a possible comma separator */ - if (*ptr == ',') { - if (!(*++ptr)) { - /* unexpected end of string */ - error_msg("Bad mask list(%s), unexpected end of string.\n", h_list); - return FAIL; - } - } - } - HDassert(packed_bits_num <= PACKED_BITS_MAX); - if (packed_bits_num == 0) { - /* got no masks! */ - error_msg("Bad mask list(%s)\n", h_list); - return FAIL; - } - return SUCCEED; -} - - -/*------------------------------------------------------------------------- - * Function: free_handler - * - * Purpose: Convenience function to free the handler_t structures. Needs a - * length variable (LEN) to know how many in the array it needs - * to free - * - * Return: Nothing - * - * Programmer: Bill Wendling - * Tuesday, 20. February 2001 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static void -free_handler(struct handler_t *hand, int len) -{ - int i; - - if(hand) { - for (i = 0; i < len; i++) { - if(hand[i].obj) { - HDfree(hand[i].obj); - hand[i].obj=NULL; - } - - if (hand[i].subset_info) { - if(hand[i].subset_info->start.data) - HDfree(hand[i].subset_info->start.data); - if(hand[i].subset_info->stride.data) - HDfree(hand[i].subset_info->stride.data); - if(hand[i].subset_info->count.data) - HDfree(hand[i].subset_info->count.data); - if(hand[i].subset_info->block.data) - HDfree(hand[i].subset_info->block.data); - - HDfree(hand[i].subset_info); - hand[i].subset_info=NULL; - } - } - - HDfree(hand); - } -} - - -/*------------------------------------------------------------------------- - * Function: parse_command_line - * - * Purpose: Parse the command line for the h5dumper. - * - * Return: Success: A pointer to an array of handler_t structures. - * These contain all the information needed to dump - * the necessary object. - * - * Failure: Exits program with EXIT_FAILURE value. - * - * Programmer: Bill Wendling - * Tuesday, 20. February 2001 - * - * Modifications: - * pvn June, 1, 2006. Add a switch for binary output - * - *------------------------------------------------------------------------- - */ -static struct handler_t * -parse_command_line(int argc, const char *argv[]) -{ - struct handler_t *hand = NULL; - struct handler_t *last_dset = NULL; - int i; - int opt; - int last_was_dset = FALSE; - - /* no arguments */ - if (argc == 1) { - usage(h5tools_getprogname()); - goto error; - } - - /* this will be plenty big enough to hold the info */ - if((hand = (struct handler_t *)HDcalloc((size_t)argc, sizeof(struct handler_t)))==NULL) { - goto error; - } - - /* parse command line options */ - while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { -parse_start: - switch ((char)opt) { - case 'R': - display_region = TRUE; - region_output = TRUE; - break; - case 'B': - display_bb = TRUE; - last_was_dset = FALSE; - break; - case 'n': - display_fi = TRUE; - last_was_dset = FALSE; - if ( opt_arg != NULL) { - h5trav_set_verbose(HDatoi(opt_arg)); - } - break; - case 'p': - display_dcpl = TRUE; - break; - case 'y': - display_ai = FALSE; - break; - case 'e': - display_escape = TRUE; - break; - case 'H': - display_data = FALSE; - display_attr_data = FALSE; - last_was_dset = FALSE; - break; - case 'A': - if ( opt_arg != NULL) { - if(0 == HDatoi(opt_arg)) include_attrs = FALSE; - } - else { - display_data = FALSE; - display_attr_data = TRUE; - last_was_dset = FALSE; - } - break; - case 'i': - display_oid = TRUE; - last_was_dset = FALSE; - break; - case 'r': - display_char = TRUE; - break; - case 'V': - print_version(h5tools_getprogname()); - free_handler(hand, argc); - hand = NULL; - h5tools_setstatus(EXIT_SUCCESS); - goto done; - break; - case 'w': - { - int sh5tools_nCols = HDatoi(opt_arg); - - if (sh5tools_nCols <= 0) - h5tools_nCols = 65535; - else - h5tools_nCols = (unsigned)sh5tools_nCols; - last_was_dset = FALSE; - } - break; - case 'N': - display_all = 0; - - for (i = 0; i < argc; i++) - if (!hand[i].func) { - hand[i].func = handle_paths; - hand[i].obj = HDstrdup(opt_arg); - break; - } - - last_was_dset = FALSE; - break; - case 'a': - display_all = 0; - - for (i = 0; i < argc; i++) - if (!hand[i].func) { - hand[i].func = handle_attributes; - hand[i].obj = HDstrdup(opt_arg); - break; - } - - last_was_dset = FALSE; - break; - case 'd': - display_all = 0; - - for (i = 0; i < argc; i++) - if (!hand[i].func) { - hand[i].func = handle_datasets; - hand[i].obj = HDstrdup(opt_arg); - hand[i].subset_info = parse_subset_params(hand[i].obj); - last_dset = &hand[i]; - break; - } - - last_was_dset = TRUE; - break; - case 'f': - driver = opt_arg; - break; - case 'g': - display_all = 0; - - for (i = 0; i < argc; i++) - if (!hand[i].func) { - hand[i].func = handle_groups; - hand[i].obj = HDstrdup(opt_arg); - break; - } - - last_was_dset = FALSE; - break; - case 'l': - display_all = 0; - - for (i = 0; i < argc; i++) - if (!hand[i].func) { - hand[i].func = handle_links; - hand[i].obj = HDstrdup(opt_arg); - break; - } - - last_was_dset = FALSE; - break; - case 't': - display_all = 0; - - for (i = 0; i < argc; i++) - if (!hand[i].func) { - hand[i].func = handle_datatypes; - hand[i].obj = HDstrdup(opt_arg); - break; - } - - last_was_dset = FALSE; - break; - - case 'O': - if (h5tools_set_output_file(opt_arg, 0) < 0) { - usage(h5tools_getprogname()); - goto error; - } - break; - - case 'o': - if ( bin_output ) { - if (h5tools_set_data_output_file(opt_arg, 1) < 0) { - usage(h5tools_getprogname()); - goto error; - } - } - else { - if(display_attr_data && !display_data) { - if (h5tools_set_attr_output_file(opt_arg, 0) < 0) { - usage(h5tools_getprogname()); - goto error; - } - } - if(display_data || display_all) { - if (h5tools_set_data_output_file(opt_arg, 0) < 0) { - usage(h5tools_getprogname()); - goto error; - } - } - } - - usingdasho = TRUE; - last_was_dset = FALSE; - outfname = opt_arg; - break; - - case 'b': - if ( opt_arg != NULL) { - if ( ( bin_form = set_binary_form(opt_arg)) < 0) { - /* failed to set binary form */ - usage(h5tools_getprogname()); - goto error; - } - } - bin_output = TRUE; - if (outfname!=NULL) { - if (h5tools_set_data_output_file(outfname, 1) < 0) { - /* failed to set output file */ - usage(h5tools_getprogname()); - goto error; - } - - last_was_dset = FALSE; - } - break; - - case 'q': - if ( ( sort_by = set_sort_by(opt_arg)) < 0) { - /* failed to set "sort by" form */ - usage(h5tools_getprogname()); - goto error; - } - break; - - case 'z': - if ( ( sort_order = set_sort_order(opt_arg)) < 0) { - /* failed to set "sort order" form */ - usage(h5tools_getprogname()); - goto error; - } - break; - - case 'M': - if (!last_was_dset) { - error_msg("option `-%c' can only be used after --dataset option\n", opt); - goto error; - } - if (parse_mask_list(opt_arg) != SUCCEED){ - usage(h5tools_getprogname()); - goto error; - } - display_packed_bits = TRUE; - break; - case 'v': - display_vds_first = TRUE; - break; - case 'G': - vds_gap_size = HDatoi(opt_arg); - if (vds_gap_size < 0) { - usage(h5tools_getprogname()); - goto error; - } - break; - - /** begin XML parameters **/ - case 'x': - /* select XML output */ - doxml = TRUE; - useschema = TRUE; - h5tools_dump_header_format = NULL; - dump_function_table = &xml_function_table; - h5tools_nCols = 0; - break; - case 'u': - doxml = TRUE; - useschema = FALSE; - xmlnsprefix = ""; - h5tools_dump_header_format = NULL; - dump_function_table = &xml_function_table; - h5tools_nCols = 0; - break; - case 'D': - /* specify alternative XML DTD or schema */ - /* To Do: check format of this value? */ - xml_dtd_uri = opt_arg; - h5tools_nCols = 0; - break; - - case 'm': - /* specify alternative floating point printing format */ - fp_format = opt_arg; - h5tools_nCols = 0; - break; - - case 'X': - /* specify XML namespace (default="hdf5:"), or none */ - /* To Do: check format of this value? */ - if (!useschema) { - usage(h5tools_getprogname()); - goto error; - } - if (HDstrcmp(opt_arg,":") == 0) - xmlnsprefix = ""; - else - xmlnsprefix = opt_arg; - h5tools_nCols = 0; - break; - /** end XML parameters **/ - - /** begin subsetting parameters **/ - case 's': - case 'S': - case 'c': - case 'k': { - struct subset_t *s; - - if (!last_was_dset) { - error_msg("option `-%c' can only be used after --dataset option\n", opt); - goto error; - } - - if (last_dset->subset_info) { - /* - * This overrides the "terse" syntax if they actually mixed - * the two. - */ - s = last_dset->subset_info; - } - else { - last_dset->subset_info = s = (struct subset_t *)HDcalloc(1, sizeof(struct subset_t)); - } - - /* - * slightly convoluted, but...we are only interested in options - * for subsetting: "--start", "--stride", "--count", and "--block" - * which can come in any order. If we run out of parameters (EOF) - * or run into one which isn't a subsetting parameter (NOT s, S, - * c, or K), then we exit the do-while look, set the subset_info - * to the structure we've been filling. If we've reached the end - * of the options, we exit the parsing (goto parse_end) otherwise, - * since we've "read" the next option, we need to parse it. So we - * jump to the beginning of the switch statement (goto parse_start). - */ - do { - switch ((char)opt) { - case 's': - if (s->start.data) { - HDfree(s->start.data); - s->start.data = NULL; - } - parse_hsize_list(opt_arg, &s->start); - break; - case 'S': - if (s->stride.data) { - HDfree(s->stride.data); - s->stride.data = NULL; - } - parse_hsize_list(opt_arg, &s->stride); - break; - case 'c': - if (s->count.data) { - HDfree(s->count.data); - s->count.data = NULL; - } - parse_hsize_list(opt_arg, &s->count); - break; - case 'k': - if (s->block.data) { - HDfree(s->block.data); - s->block.data = NULL; - } - parse_hsize_list(opt_arg, &s->block); - break; - default: - goto end_collect; - } - } while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF); - -end_collect: - last_was_dset = FALSE; - - if (opt != EOF) - goto parse_start; - else - goto parse_end; - } - /** end subsetting parameters **/ - - case 'E': - enable_error_stack = TRUE; - break; - case 'C': - disable_compact_subset = TRUE; - break; - case 'h': - usage(h5tools_getprogname()); - free_handler(hand, argc); - hand = NULL; - h5tools_setstatus(EXIT_SUCCESS); - goto done; - case '?': - default: - usage(h5tools_getprogname()); - goto error; - } - } - -parse_end: - /* check for file name to be processed */ - if (argc <= opt_ind) { - error_msg("missing file name\n"); - usage(h5tools_getprogname()); - goto error; - } -done: - return hand; - -error: - if (hand) { - free_handler(hand, argc); - hand = NULL; - } - h5tools_setstatus(EXIT_FAILURE); - - return hand; -} - - -/*------------------------------------------------------------------------- - * Function: main - * - * Purpose: HDF5 dumper - * - * Return: Success: 0 - * Failure: 1 - * - * Programmer: Ruey-Hsia Li - * - * Modifications: - * Albert Cheng - * 30. September 2000 - * Add the -o option--output file for datasets raw data - * - * REMcG - * November 2000 - * Changes to support XML. - * - * Bill Wendling - * Wednesday, 10. January 2001 - * Modified the way command line parameters are interpreted. They go - * through one function call now (get_option). - * - * Bill Wendling - * Tuesday, 20. February 2001 - * Moved command line parsing to separate function. Made various - * "display_*" flags global. - * - * REMcG - * August 2003 - * Major upgrade to XML support. - * - * Pedro Vicente - * September 2007 - * list objects in requested order (creation order or alphabetically) - * - *------------------------------------------------------------------------- - */ -int -main(int argc, const char *argv[]) -{ - hid_t fid = -1; - hid_t gid = -1; - H5E_auto2_t func; - H5E_auto2_t tools_func; - H5O_info_t oi; - struct handler_t *hand = NULL; - int i; - unsigned u; - void *edata; - void *tools_edata; - char *fname = NULL; - - h5tools_setprogname(PROGRAMNAME); - h5tools_setstatus(EXIT_SUCCESS); - h5tools_dump_header_format = &h5tools_standardformat; - dump_function_table = &ddl_function_table; - dump_indent = 0; - - /* Disable error reporting */ - H5Eget_auto2(H5E_DEFAULT, &func, &edata); - H5Eset_auto2(H5E_DEFAULT, NULL, NULL); - - /* 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) { - error_msg("binary output requires a file name, use -o <filename>\n"); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - - if (enable_error_stack) { - H5Eset_auto2(H5E_DEFAULT, func, edata); - H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata); - } - - /* Check for conflicting options */ - if (doxml) { - if (!display_all) { - error_msg("option \"%s\" not available for XML\n", - "to display selected objects"); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - else if (display_bb) { - error_msg("option \"%s\" not available for XML\n", "--boot-block"); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - else if (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) { - error_msg("option \"%s\" not available for XML\n", "--string"); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - else if (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 (argc <= opt_ind) { - error_msg("missing file name\n"); - usage(h5tools_getprogname()); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - /* Initialize indexing options */ - h5trav_set_index(sort_by, sort_order); - - while(opt_ind < argc) { - fname = HDstrdup(argv[opt_ind++]); - - fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, driver, NULL, 0); - - if (fid < 0) { - error_msg("unable to open file \"%s\"\n", fname); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - - /* allocate and initialize internal data structure */ - init_prefix(&prefix, prefix_len); - - /* Prepare to find objects that might be targets of a reference */ - fill_ref_path_table(fid); - - if(doxml) { - /* 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; - } - else { - xml_dtd_uri = DEFAULT_DTD; - xmlnsprefix = ""; - } - } - else { - if (useschema && HDstrcmp(xmlnsprefix,"")) { - error_msg("Cannot set Schema URL for a qualified namespace--use -X or -U option with -D \n"); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - } - } - - /* Get object info for root group */ - if(H5Oget_info_by_name(fid, "/", &oi, H5P_DEFAULT) < 0) { - error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - - /* Initialize object tables */ - if(table_list_add(fid, oi.fileno) < 0) { - error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - group_table = table_list.tables[0].group_table; - dset_table = table_list.tables[0].dset_table; - type_table = table_list.tables[0].type_table; - - /* does there exist unamed committed datatype */ - for (u = 0; u < type_table->nobjs; u++) - if (!type_table->objs[u].recorded) { - unamedtype = 1; - break; - } /* end if */ - - /* start to dump - display file header information */ - if (!doxml) { - begin_obj(h5tools_dump_header_format->filebegin, fname, h5tools_dump_header_format->fileblockbegin); - } - else { - PRINTVALSTREAM(rawoutstream, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); - - /* alternative first element, depending on schema or DTD. */ - if (useschema) { - if (HDstrcmp(xmlnsprefix,"") == 0) { - PRINTSTREAM(rawoutstream, "<HDF5-File xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"%s\">\n", - xml_dtd_uri); - } - else { - /* TO DO: make -url option work in this case (may need new option) */ - char *ns; - char *indx; - - ns = HDstrdup(xmlnsprefix); - indx = HDstrrchr(ns,(int)':'); - if (indx) *indx = '\0'; - - PRINTSTREAM(rawoutstream, "<%sHDF5-File xmlns:%s=\"http://hdfgroup.org/HDF5/XML/schema/HDF5-File.xsd\" " - "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " - "xsi:schemaLocation=\"http://hdfgroup.org/HDF5/XML/schema/HDF5-File " - "http://www.hdfgroup.org/HDF5/XML/schema/HDF5-File.xsd\">\n",xmlnsprefix,ns); - HDfree(ns); - } - } - else { - PRINTSTREAM(rawoutstream, "<!DOCTYPE HDF5-File PUBLIC \"HDF5-File.dtd\" \"%s\">\n", xml_dtd_uri); - PRINTVALSTREAM(rawoutstream, "<HDF5-File>\n"); - } - } - - if (!doxml) { - if (display_fi) { - PRINTVALSTREAM(rawoutstream, "\n"); - dump_fcontents(fid); - end_obj(h5tools_dump_header_format->fileend,h5tools_dump_header_format->fileblockend); - PRINTVALSTREAM(rawoutstream, "\n"); - goto done; - } - - if (display_bb) - dump_fcpl(fid); - } - - if(display_all) { - if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) { - error_msg("unable to open root group\n"); - h5tools_setstatus(EXIT_FAILURE); - } - else { - if (!doxml) - dump_indent += COL; - dump_function_table->dump_group_function(gid, "/" ); - if (!doxml) - dump_indent -= COL; - PRINTVALSTREAM(rawoutstream, "\n"); - } - - if(H5Gclose(gid) < 0) { - error_msg("unable to close root group\n"); - h5tools_setstatus(EXIT_FAILURE); - } - - } - else { - /* Note: this option is not supported for XML */ - if(doxml) { - error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } /* end if */ - - for(i = 0; i < argc; i++) { - if(hand[i].func) { - hand[i].func(fid, hand[i].obj, hand[i].subset_info, 1, NULL); - } - } - PRINTVALSTREAM(rawoutstream, "\n"); - } - - if (!doxml) { - end_obj(h5tools_dump_header_format->fileend, h5tools_dump_header_format->fileblockend); - PRINTVALSTREAM(rawoutstream, "\n"); - } - else { - PRINTSTREAM(rawoutstream, "</%sHDF5-File>\n", xmlnsprefix); - } - /* Free tables for objects */ - table_list_free(); - - if(fid >=0) - if (H5Fclose(fid) < 0) - h5tools_setstatus(EXIT_FAILURE); - - if(prefix) { - HDfree(prefix); - prefix = NULL; - } - if(fname) { - HDfree(fname); - fname = NULL; - } - } /* end while */ - - if(hand) - free_handler(hand, argc); - - /* To Do: clean up XML table */ - - leave(h5tools_getstatus()); - -done: - /* Free tables for objects */ - table_list_free(); - - if(fid >=0) - if (H5Fclose(fid) < 0) - h5tools_setstatus(EXIT_FAILURE); - - if(prefix) { - HDfree(prefix); - prefix = NULL; - } - if(fname) { - HDfree(fname); - fname = NULL; - } - - if(hand) - free_handler(hand, argc); - - /* To Do: clean up XML table */ - - H5Eset_auto2(H5E_DEFAULT, func, edata); - - leave(h5tools_getstatus()); -} - -/*------------------------------------------------------------------------- - * Function: h5_fileaccess - * - * Purpose: Returns a file access template which is the default template - * but with a file driver set according to the constant or - * environment variable HDF5_DRIVER - * - * Return: Success: A file access property list - * - * Failure: -1 - * - * Programmer: Robb Matzke - * Thursday, November 19, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -hid_t -h5_fileaccess(void) -{ - static const char *multi_letters = "msbrglo"; - const char *val = NULL; - const char *name; - char s[1024]; - hid_t fapl = -1; - - /* First use the environment variable, then the constant */ - val = HDgetenv("HDF5_DRIVER"); -#ifdef HDF5_DRIVER - if (!val) val = HDF5_DRIVER; -#endif - - if ((fapl=H5Pcreate(H5P_FILE_ACCESS))<0) return -1; - if (!val || !*val) return fapl; /*use default*/ - - HDstrncpy(s, val, sizeof s); - s[sizeof(s)-1] = '\0'; - if (NULL==(name=HDstrtok(s, " \t\n\r"))) return fapl; - - if (!HDstrcmp(name, "sec2")) { - /* Unix read() and write() system calls */ - if (H5Pset_fapl_sec2(fapl)<0) return -1; - } - else if (!HDstrcmp(name, "stdio")) { - /* Standard C fread() and fwrite() system calls */ - if (H5Pset_fapl_stdio(fapl)<0) return -1; - } - else if (!HDstrcmp(name, "core")) { - /* In-core temporary file with 1MB increment */ - if (H5Pset_fapl_core(fapl, 1024*1024, FALSE)<0) return -1; - } - else if (!HDstrcmp(name, "split")) { - /* Split meta data and raw data each using default driver */ - if (H5Pset_fapl_split(fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT) < 0) - return -1; - } - else if (!HDstrcmp(name, "multi")) { - /* Multi-file driver, general case of the split driver */ - H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; - hid_t memb_fapl[H5FD_MEM_NTYPES]; - const char *memb_name[H5FD_MEM_NTYPES]; - char sv[H5FD_MEM_NTYPES][1024]; - haddr_t memb_addr[H5FD_MEM_NTYPES]; - H5FD_mem_t mt; - - HDmemset(memb_map, 0, sizeof memb_map); - HDmemset(memb_fapl, 0, sizeof memb_fapl); - HDmemset(memb_name, 0, sizeof memb_name); - HDmemset(memb_addr, 0, sizeof memb_addr); - - HDassert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES); - for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) { - memb_fapl[mt] = H5P_DEFAULT; - memb_map[mt] = mt; - sprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]); - memb_name[mt] = sv[mt]; - memb_addr[mt] = (haddr_t)MAX(mt - 1, 0) * (HADDR_MAX / 10); - } - - if (H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, memb_addr, FALSE) < 0) - return -1; - } - else if (!HDstrcmp(name, "family")) { - hsize_t fam_size = 100*1024*1024; /*100 MB*/ - - /* Family of files, each 1MB and using the default driver */ - if ((val=HDstrtok(NULL, " \t\n\r"))) - fam_size = (hsize_t)(HDstrtod(val, NULL) * 1024*1024); - if (H5Pset_fapl_family(fapl, fam_size, H5P_DEFAULT)<0) - return -1; - } - else if (!HDstrcmp(name, "log")) { - long log_flags = H5FD_LOG_LOC_IO; - - /* Log file access */ - if ((val = HDstrtok(NULL, " \t\n\r"))) - log_flags = HDstrtol(val, NULL, 0); - - if (H5Pset_fapl_log(fapl, NULL, (unsigned)log_flags, 0) < 0) - return -1; - } - else if (!HDstrcmp(name, "direct")) { - /* Substitute Direct I/O driver with sec2 driver temporarily because - * some output has sec2 driver as the standard. */ - if (H5Pset_fapl_sec2(fapl)<0) return -1; - } - else { - /* Unknown driver */ - return -1; - } - - return fapl; -} - - -/*------------------------------------------------------------------------- - * Function: init_prefix - * - * Purpose: allocate and initialize prefix - * - * Return: void - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static void -init_prefix(char **prfx, size_t prfx_len) -{ - HDassert(prfx_len > 0); - *prfx = (char *)HDcalloc(prfx_len, 1); -} - - -/*------------------------------------------------------------------------- - * Function: add_prefix - * - * Purpose: Add object to prefix - * - * Return: void - * - *------------------------------------------------------------------------- - */ -void -add_prefix(char **prfx, size_t *prfx_len, const char *name) -{ - size_t new_len = HDstrlen(*prfx) + HDstrlen(name) + 2; - - /* Check if we need more space */ - if(*prfx_len <= new_len) { - *prfx_len = new_len + 1; - *prfx = (char *)HDrealloc(*prfx, *prfx_len); - } - - /* Append object name to prefix */ - HDstrcat(HDstrcat(*prfx, "/"), name); -} /* end add_prefix */ - diff --git a/tools/h5dump/h5dump.h b/tools/h5dump/h5dump.h deleted file mode 100644 index 8224c02..0000000 --- a/tools/h5dump/h5dump.h +++ /dev/null @@ -1,115 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef H5DUMP_H__ -#define H5DUMP_H__ - -#include "hdf5.h" -#include "H5private.h" -#include "h5tools.h" -#include "h5tools_utils.h" -#include "h5tools_ref.h" -#include "h5trav.h" -#include "h5dump_defines.h" - -/** - ** This is the global dispatch table for the dump functions. - **/ -/* the table of dump functions */ -typedef struct dump_functions_t { - void (*dump_group_function) (hid_t, const char *); - void (*dump_named_datatype_function) (hid_t, const char *); - void (*dump_dataset_function) (hid_t, const char *, struct subset_t *); - void (*dump_dataspace_function) (hid_t); - void (*dump_datatype_function) (hid_t); - herr_t (*dump_attribute_function) (hid_t, const char *, const H5A_info_t *, void *); - void (*dump_data_function) (hid_t, int, struct subset_t *, int); -} dump_functions; - -/* List of table structures. There is one table structure for each file */ -typedef struct h5dump_table_items_t { - unsigned long fileno; /* File number that these tables refer to */ - hid_t oid; /* ID of an object in this file, held open so fileno is consistent */ - table_t *group_table; /* Table of groups */ - table_t *dset_table; /* Table of datasets */ - table_t *type_table; /* Table of datatypes */ -} h5dump_table_items_t; -typedef struct h5dump_table_list_t { - size_t nalloc; - size_t nused; - h5dump_table_items_t *tables; -} h5dump_table_list_t; - -h5dump_table_list_t table_list = {0, 0, NULL}; -table_t *group_table = NULL, *dset_table = NULL, *type_table = NULL; -unsigned dump_indent = 0; /*how far in to indent the line */ - -int unamedtype = 0; /* shared datatype with no name */ -hbool_t hit_elink = FALSE; /* whether we have traversed an external link */ -size_t prefix_len = 1024; -char *prefix = NULL; -const char *fp_format = NULL; - -/* things to display or which are set via command line parameters */ -int display_all = TRUE; -int display_oid = FALSE; -int display_data = TRUE; -int display_attr_data = TRUE; -int display_char = FALSE; /*print 1-byte numbers as ASCII */ -int usingdasho = FALSE; -int display_bb = FALSE; /*superblock */ -int display_dcpl = FALSE; /*dcpl */ -int display_fi = FALSE; /*file index */ -int display_ai = TRUE; /*array index */ -int display_escape = FALSE; /*escape non printable characters */ -int display_region = FALSE; /*print region reference data */ -int disable_compact_subset= FALSE; /* disable compact form of subset notation */ -int display_packed_bits = FALSE; /*print 1-8 byte numbers as packed bits*/ -int include_attrs = TRUE; /* Display attributes */ -int display_vds_first = FALSE; /* vds display to all by default*/ -int vds_gap_size = 0; /* vds skip missing files default is none */ - -/* 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] */ - -#define PACKED_BITS_MAX 8 /* Maximum number of packed-bits to display */ -#define PACKED_BITS_SIZE_MAX (8*sizeof(long long)) /* Maximum bits size of integer types of packed-bits */ -/* mask list for packed bits */ -unsigned long long packed_mask[PACKED_BITS_MAX]; /* packed bits are restricted to 8*sizeof(llong) bytes */ - -/* packed bits display parameters */ -unsigned packed_offset[PACKED_BITS_MAX]; -unsigned packed_length[PACKED_BITS_MAX]; - -/* - * The global table is set to either ddl_function_table or - * xml_function_table in the initialization. - */ -const dump_functions *dump_function_table; - -#ifdef __cplusplus -"C" { -#endif - -void add_prefix(char **prfx, size_t *prfx_len, const char *name); -hid_t h5_fileaccess(void); -ssize_t table_list_add(hid_t oid, unsigned long file_no); -ssize_t table_list_visited(unsigned long file_no); - -#ifdef __cplusplus -} -#endif - -#endif /* !H5DUMP_H__ */ diff --git a/tools/h5dump/h5dump_ddl.c b/tools/h5dump/h5dump_ddl.c deleted file mode 100644 index 182d570..0000000 --- a/tools/h5dump/h5dump_ddl.c +++ /dev/null @@ -1,2178 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include <stdio.h> -#include <stdlib.h> - -#include "H5private.h" -#include "h5tools.h" -#include "h5tools_dump.h" -#include "h5tools_utils.h" -#include "h5tools_ref.h" -#include "h5trav.h" -#include "h5dump_extern.h" -#include "h5dump_ddl.h" - -typedef struct { - hid_t fid; /* File ID being traversed */ - const char *op_name; /* Object name wanted */ -} trav_handle_udata_t; - -typedef struct { - const char *path; /* Path of object being searched */ - const char *op_name; /* Object name wanted */ -} trav_attr_udata_t; - -/* callback function used by H5Literate() */ -static herr_t dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void *op_data); -static int dump_extlink(hid_t group, const char *linkname, const char *objname); - -/*------------------------------------------------------------------------- - * Function: dump_datatype - * - * Purpose: Dump the datatype. Datatype can be HDF5 predefined - * atomic datatype or committed/transient datatype. - * - * Return: void - * - * Programmer: Ruey-Hsia Li - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -void -dump_datatype(hid_t type) -{ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &h5tools_dataformat; - - HDmemset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; - - h5dump_type_table = type_table; - h5tools_dump_datatype(rawoutstream, outputformat, &ctx, type); - h5dump_type_table = NULL; -} - -/*------------------------------------------------------------------------- - * Function: dump_dataspace - * - * Purpose: Dump the dataspace. Dataspace can be named dataspace, - * array, or others. - * - * Return: void - * - * Programmer: Ruey-Hsia Li - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -void -dump_dataspace(hid_t space) -{ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &h5tools_dataformat; - - HDmemset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; - - h5tools_dump_dataspace(rawoutstream, outputformat, &ctx, space); -} - - -/*------------------------------------------------------------------------- - * Function: dump_attr_cb - * - * Purpose: attribute function callback called by H5Aiterate2, displays the attribute - * - * Return: Success: SUCCEED - * - * Failure: FAIL - * - * Programmer: Ruey-Hsia Li - * - * Modifications: Pedro Vicente, October 4, 2007 - * Added H5A_info_t parameter to conform with H5Aiterate2 - * - *------------------------------------------------------------------------- - */ -herr_t -dump_attr_cb(hid_t oid, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *info, void H5_ATTR_UNUSED *_op_data) -{ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &h5tools_dataformat; - h5tool_format_t string_dataformat; - - hid_t attr_id; - herr_t ret = SUCCEED; - - HDmemset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; - - attr_id = H5Aopen(oid, attr_name, H5P_DEFAULT); - oid_output = display_oid; - data_output = display_data; - attr_data_output = display_attr_data; - - string_dataformat = *outputformat; - - if (fp_format) { - string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; - } - - if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; - string_dataformat.line_per_line = 1; - } - else - string_dataformat.line_ncols = h5tools_nCols; - - string_dataformat.do_escape = display_escape; - outputformat = &string_dataformat; - - h5dump_type_table = type_table; - h5tools_dump_attribute(rawoutstream, outputformat, &ctx, attr_name, attr_id, display_ai, display_char); - h5dump_type_table = NULL; - - if(attr_id < 0) { - h5tools_setstatus(EXIT_FAILURE); - ret = FAIL; - } - - return ret; -} - - -/*------------------------------------------------------------------------- - * Function: dump_all_cb - * - * Purpose: function callback called by H5Literate, - * displays everything in the specified object - * - * Return: Success: SUCCEED - * - * Failure: FAIL - * - * Programmer: Ruey-Hsia Li - * - * Modifications: - * RMcG, November 2000 - * Added XML support. Also, optionally checks the op_data argument - * - * PVN, May 2008 - * Dump external links - * - *------------------------------------------------------------------------- - */ -static herr_t -dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void H5_ATTR_UNUSED *op_data) -{ - hid_t obj; - hid_t dapl_id = H5P_DEFAULT; /* dataset access property list ID */ - herr_t ret = SUCCEED; - char *obj_path = NULL; /* Full path of object */ - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &h5tools_dataformat; - h5tool_format_t string_dataformat; - hsize_t curr_pos = 0; /* total data element position */ - - /* setup */ - HDmemset(&buffer, 0, sizeof(h5tools_str_t)); - - HDmemset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; - - string_dataformat = *outputformat; - - if (fp_format) { - string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; - } - - if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; - string_dataformat.line_per_line = 1; - } - else - string_dataformat.line_ncols = h5tools_nCols; - - string_dataformat.do_escape = display_escape; - outputformat = &string_dataformat; - - /* Build the object's path name */ - obj_path = (char *)HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2); - if(!obj_path) { - ret = FAIL; - goto done; - } - - HDstrcpy(obj_path, prefix); - HDstrcat(obj_path, "/"); - HDstrcat(obj_path, name); - - if(linfo->type == H5L_TYPE_HARD) { - H5O_info_t oinfo; - - /* Stat the object */ - if(H5Oget_info_by_name(group, name, &oinfo, H5P_DEFAULT) < 0) { - error_msg("unable to get object information for \"%s\"\n", name); - h5tools_setstatus(EXIT_FAILURE); - ret = FAIL; - goto done; - } /* end if */ - - switch(oinfo.type) { - case H5O_TYPE_GROUP: - if((obj = H5Gopen2(group, name, H5P_DEFAULT)) < 0) { - error_msg("unable to dump group \"%s\"\n", name); - h5tools_setstatus(EXIT_FAILURE); - ret = FAIL; - } - else { - char *old_prefix; /* Pointer to previous prefix */ - - /* Keep copy of prefix before iterating into group */ - old_prefix = HDstrdup(prefix); - HDassert(old_prefix); - - /* Append group name to prefix */ - add_prefix(&prefix, &prefix_len, name); - - /* Iterate into group */ - dump_function_table->dump_group_function(obj, name); - - /* Restore old prefix name */ - HDstrcpy(prefix, old_prefix); - HDfree(old_prefix); - - /* Close group */ - H5Gclose(obj); - } - break; - - case H5O_TYPE_DATASET: - if(display_data) { - if ((dapl_id = H5Pcreate(H5P_DATASET_ACCESS)) < 0) { - error_msg("error in creating default access property list ID\n"); - } - if (display_vds_first) { - if(H5Pset_virtual_view(dapl_id, H5D_VDS_FIRST_MISSING) < 0) - 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) - error_msg("error in setting access property list ID, virtual_printf_gap\n"); - } - } - if((obj = H5Dopen2(group, name, dapl_id)) >= 0) { - if(oinfo.rc > 1 || hit_elink) { - obj_t *found_obj; /* Found object */ - - found_obj = search_obj(dset_table, oinfo.addr); - - if(found_obj == NULL) { - ctx.indent_level++; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s \"%s\" %s", - h5tools_dump_header_format->datasetbegin, name, - h5tools_dump_header_format->datasetblockbegin); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - if(HDstrlen(h5tools_dump_header_format->datasetblockend)) { - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetblockend); - if(HDstrlen(h5tools_dump_header_format->datasetend)) - h5tools_str_append(&buffer, " "); - } - if(HDstrlen(h5tools_dump_header_format->datasetend)) - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetend); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level--; - - h5tools_setstatus(EXIT_FAILURE); - ret = FAIL; - if (dapl_id != H5P_DEFAULT) - H5Pclose(dapl_id); - H5Dclose(obj); - goto done; - } - else if(found_obj->displayed) { - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s \"%s\" %s", - h5tools_dump_header_format->datasetbegin, name, - h5tools_dump_header_format->datasetblockbegin); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level++; - - ctx.need_prefix = TRUE; - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s \"%s\"", HARDLINK, found_obj->objname); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level--; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - if(HDstrlen(h5tools_dump_header_format->datasetblockend)) { - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetblockend); - if(HDstrlen(h5tools_dump_header_format->datasetend)) - h5tools_str_append(&buffer, " "); - } - if(HDstrlen(h5tools_dump_header_format->datasetend)) - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetend); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - if (dapl_id != H5P_DEFAULT) - H5Pclose(dapl_id); - H5Dclose(obj); - goto done; - } - else { - found_obj->displayed = TRUE; - } - } /* end if */ - - dump_function_table->dump_dataset_function(obj, name, NULL); - if (dapl_id != H5P_DEFAULT) - H5Pclose(dapl_id); - H5Dclose(obj); - } - else { - if (dapl_id != H5P_DEFAULT) - H5Pclose(dapl_id); - error_msg("unable to dump dataset \"%s\"\n", name); - h5tools_setstatus(EXIT_FAILURE); - ret = FAIL; - } - break; - - case H5O_TYPE_NAMED_DATATYPE: - if((obj = H5Topen2(group, name, H5P_DEFAULT)) < 0) { - error_msg("unable to dump datatype \"%s\"\n", name); - h5tools_setstatus(EXIT_FAILURE); - ret = FAIL; - } - else { - dump_function_table->dump_named_datatype_function(obj, name); - H5Tclose(obj); - } - break; - - case H5O_TYPE_UNKNOWN: - case H5O_TYPE_NTYPES: - default: - error_msg("unknown object \"%s\"\n", name); - h5tools_setstatus(EXIT_FAILURE); - ret = FAIL; - } - } /* end if */ - else { - char *targbuf; - - switch(linfo->type) { - case H5L_TYPE_SOFT: - targbuf = (char *)HDmalloc(linfo->u.val_size); - HDassert(targbuf); - - ctx.need_prefix = TRUE; - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s \"%s\" %s", - h5tools_dump_header_format->softlinkbegin, name, - h5tools_dump_header_format->softlinkblockbegin); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level++; - - if(H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) { - error_msg("unable to get link value\n"); - h5tools_setstatus(EXIT_FAILURE); - ret = FAIL; - } - else { - /* print the value of a soft link */ - /* Standard DDL: no modification */ - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "LINKTARGET \"%s\"", targbuf); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - - ctx.indent_level--; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - if(HDstrlen(h5tools_dump_header_format->softlinkblockend)) { - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->softlinkblockend); - if(HDstrlen(h5tools_dump_header_format->softlinkend)) - h5tools_str_append(&buffer, " "); - } - if(HDstrlen(h5tools_dump_header_format->softlinkend)) - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->softlinkend); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - HDfree(targbuf); - break; - - case H5L_TYPE_EXTERNAL: - targbuf = (char *)HDmalloc(linfo->u.val_size); - HDassert(targbuf); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s \"%s\" %s", - h5tools_dump_header_format->extlinkbegin, name, - h5tools_dump_header_format->extlinkblockbegin); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - if(H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) { - indentation(dump_indent); - error_msg("unable to get external link value\n"); - h5tools_setstatus(EXIT_FAILURE); - ret = FAIL; - } /* end if */ - else { - const char *filename; - const char *targname; - - if(H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL, &filename, &targname) < 0) { - indentation(dump_indent); - error_msg("unable to unpack external link value\n"); - h5tools_setstatus(EXIT_FAILURE); - ret = FAIL; - } /* end if */ - else { - ctx.indent_level++; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "TARGETFILE \"%s\"", filename); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "TARGETPATH \"%s\"", targname); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - /* dump the external link */ - dump_extlink(group, name, targname); - ctx.indent_level--; - } /* end else */ - } /* end else */ - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - if(HDstrlen(h5tools_dump_header_format->extlinkblockend)) { - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->extlinkblockend); - if(HDstrlen(h5tools_dump_header_format->extlinkend)) - h5tools_str_append(&buffer, " "); - } - if(HDstrlen(h5tools_dump_header_format->extlinkend)) - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->extlinkend); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - HDfree(targbuf); - break; - - case H5L_TYPE_ERROR: - case H5L_TYPE_MAX: - HDassert(0); - /* fall through */ - case H5L_TYPE_HARD: - default: - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s \"%s\" %s", - h5tools_dump_header_format->udlinkbegin, name, - h5tools_dump_header_format->udlinkblockbegin); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level++; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "LINKCLASS %d", linfo->type); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level--; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - /* Render the element */ - h5tools_str_reset(&buffer); - if(HDstrlen(h5tools_dump_header_format->udlinkblockend)) { - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->udlinkblockend); - if(HDstrlen(h5tools_dump_header_format->udlinkend)) - h5tools_str_append(&buffer, " "); - } - if(HDstrlen(h5tools_dump_header_format->udlinkend)) - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->udlinkend); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - break; - } /* end switch */ - } /* end else */ - -done: - - h5tools_str_close(&buffer); - - if(obj_path) - HDfree(obj_path); - return ret; -} - -/*------------------------------------------------------------------------- - * Function: attr_iteration - * - * Purpose: Iterate and display attributes within the specified group - * - * Return: void - * - *------------------------------------------------------------------------- - */ -void -attr_iteration(hid_t gid, unsigned attr_crt_order_flags) -{ - /* attribute iteration: if there is a request to do H5_INDEX_CRT_ORDER and tracking order is set - in the group for attributes, then, sort by creation order, otherwise by name */ - if(include_attrs) { - if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) { - if(H5Aiterate2(gid, sort_by, sort_order, NULL, dump_attr_cb, NULL) < 0) { - error_msg("error getting attribute information\n"); - h5tools_setstatus(EXIT_FAILURE); - } /* end if */ - } /* end if */ - else { - if(H5Aiterate2(gid, H5_INDEX_NAME, sort_order, NULL, dump_attr_cb, NULL) < 0) { - error_msg("error getting attribute information\n"); - h5tools_setstatus(EXIT_FAILURE); - } /* end if */ - } /* end else */ - } -} - -/*------------------------------------------------------------------------- - * Function: link_iteration - * - * Purpose: Iterate and display links within the specified group - * - * Return: void - * - *------------------------------------------------------------------------- - */ -void -link_iteration(hid_t gid, unsigned crt_order_flags) -{ - - /* if there is a request to do H5_INDEX_CRT_ORDER and tracking order is set - in the group, then, sort by creation order, otherwise by name */ - if((sort_by == H5_INDEX_CRT_ORDER) && (crt_order_flags & H5P_CRT_ORDER_TRACKED)) - H5Literate(gid, sort_by, sort_order, NULL, dump_all_cb, NULL); - else - H5Literate(gid, H5_INDEX_NAME, sort_order, NULL, dump_all_cb, NULL); -} - -/*------------------------------------------------------------------------- - * Function: dump_named_datatype - * - * Purpose: Dump named datatype - * - * Return: void - * - * Programmer: Ruey-Hsia Li - * - * Modifications: - * Pedro Vicente, March 27, 2006 - * added display of attributes - * Pedro Vicente, October 4, 2007, added parameters to H5Aiterate2() to allow for - * other iteration orders - * - *------------------------------------------------------------------------- - */ -void -dump_named_datatype(hid_t tid, const char *name) -{ - H5O_info_t oinfo; - unsigned attr_crt_order_flags; - hid_t tcpl_id = -1; /* datatype creation property list ID */ - hsize_t curr_pos = 0; /* total data element position */ - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &h5tools_dataformat; - h5tool_format_t string_dataformat; - - /* setup */ - HDmemset(&buffer, 0, sizeof(h5tools_str_t)); - - HDmemset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; - - string_dataformat = *outputformat; - - if (fp_format) { - string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; - } - - if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; - string_dataformat.line_per_line = 1; - } - else - string_dataformat.line_ncols = h5tools_nCols; - - string_dataformat.do_escape = display_escape; - outputformat = &string_dataformat; - - if ((tcpl_id = H5Tget_create_plist(tid)) < 0) { - error_msg("error in getting creation property list ID\n"); - h5tools_setstatus(EXIT_FAILURE); - } - - /* query the creation properties for attributes */ - if (H5Pget_attr_creation_order(tcpl_id, &attr_crt_order_flags) < 0) { - error_msg("error in getting creation properties\n"); - h5tools_setstatus(EXIT_FAILURE); - } - - if(H5Pclose(tcpl_id) < 0) { - error_msg("error in closing creation property list ID\n"); - h5tools_setstatus(EXIT_FAILURE); - } - - ctx.need_prefix = TRUE; - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s \"%s\" %s", - h5tools_dump_header_format->datatypebegin, name, - h5tools_dump_header_format->datatypeblockbegin); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - H5Oget_info(tid, &oinfo); - - /* Must check for uniqueness of all objects if we've traversed an elink, - * otherwise only check if the reference count > 1. - */ - if(oinfo.rc > 1 || hit_elink) { - obj_t *found_obj; /* Found object */ - - found_obj = search_obj(type_table, oinfo.addr); - - if (found_obj == NULL) { - error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - else if (found_obj->displayed) { - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s \"%s\"", HARDLINK, found_obj->objname); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - goto done; - } - else - found_obj->displayed = TRUE; - } /* end if */ - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_print_datatype(rawoutstream, &buffer, outputformat, &ctx, tid, FALSE); - - if(H5Tget_class(tid) != H5T_COMPOUND) { - h5tools_str_append(&buffer, ";"); - } - - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - /* print attributes */ - dump_indent += COL; - - attr_iteration(tid, attr_crt_order_flags); - - dump_indent -= COL; - -done: - /* Render the element */ - h5tools_str_reset(&buffer); - if(HDstrlen(h5tools_dump_header_format->datatypeblockend)) { - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datatypeblockend); - if(HDstrlen(h5tools_dump_header_format->datatypeend)) - h5tools_str_append(&buffer, " "); - } - if(HDstrlen(h5tools_dump_header_format->datatypeend)) - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datatypeend); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - h5tools_str_close(&buffer); -} - -/*------------------------------------------------------------------------- - * Function: dump_group - * - * Purpose: Dump everything within the specified group - * - * Return: void - * - * Programmer: Ruey-Hsia Li - * - * Modifications: - * - * Call to dump_all_cb -- add parameter to select everything. - * - * Pedro Vicente, October 1, 2007 - * handle several iteration orders for attributes and groups - * - *------------------------------------------------------------------------- - */ -void -dump_group(hid_t gid, const char *name) -{ - H5O_info_t oinfo; - hid_t dset; - hid_t type; - hid_t gcpl_id; - unsigned crt_order_flags; - unsigned attr_crt_order_flags; - char type_name[1024]; - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &h5tools_dataformat; - h5tool_format_t string_dataformat; - hsize_t curr_pos = 0; /* total data element position */ - - if ((gcpl_id = H5Gget_create_plist(gid)) < 0) { - error_msg("error in getting group creation property list ID\n"); - h5tools_setstatus(EXIT_FAILURE); - } - - /* query the group creation properties for attributes */ - if (H5Pget_attr_creation_order(gcpl_id, &attr_crt_order_flags) < 0) { - error_msg("error in getting group creation properties\n"); - h5tools_setstatus(EXIT_FAILURE); - } - - /* query the group creation properties */ - if(H5Pget_link_creation_order(gcpl_id, &crt_order_flags) < 0) { - error_msg("error in getting group creation properties\n"); - h5tools_setstatus(EXIT_FAILURE); - } - - if(H5Pclose(gcpl_id) < 0) { - error_msg("error in closing group creation property list ID\n"); - h5tools_setstatus(EXIT_FAILURE); - } - - /* setup */ - HDmemset(&buffer, 0, sizeof(h5tools_str_t)); - - HDmemset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; - - string_dataformat = *outputformat; - - if (fp_format) { - string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; - } - - if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; - string_dataformat.line_per_line = 1; - } - else - string_dataformat.line_ncols = h5tools_nCols; - - string_dataformat.do_escape = display_escape; - outputformat = &string_dataformat; - - ctx.need_prefix = TRUE; - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s \"%s\" %s", - h5tools_dump_header_format->groupbegin, name, - h5tools_dump_header_format->groupblockbegin); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level++; - dump_indent += COL; - - if(!HDstrcmp(name, "/") && unamedtype) { - unsigned u; /* Local index variable */ - - /* dump unamed type in root group */ - for(u = 0; u < type_table->nobjs; u++) - if(!type_table->objs[u].recorded) { - dset = H5Dopen2(gid, type_table->objs[u].objname, H5P_DEFAULT); - type = H5Dget_type(dset); - sprintf(type_name, "#"H5_PRINTF_HADDR_FMT, type_table->objs[u].objno); - dump_function_table->dump_named_datatype_function(type, type_name); - H5Tclose(type); - H5Dclose(dset); - } - } /* end if */ - - if(display_oid) - h5tools_dump_oid(rawoutstream, outputformat, &ctx, gid); - - h5tools_dump_comment(rawoutstream, outputformat, &ctx, gid); - - H5Oget_info(gid, &oinfo); - - /* Must check for uniqueness of all objects if we've traversed an elink, - * otherwise only check if the reference count > 1. - */ - if(oinfo.rc > 1 || hit_elink) { - obj_t *found_obj; /* Found object */ - - found_obj = search_obj(group_table, oinfo.addr); - - if (found_obj == NULL) { - error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__); - h5tools_setstatus(EXIT_FAILURE); - } - else if (found_obj->displayed) { - ctx.need_prefix = TRUE; - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s \"%s\"", HARDLINK, found_obj->objname); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - else { - found_obj->displayed = TRUE; - attr_iteration(gid, attr_crt_order_flags); - link_iteration(gid, crt_order_flags); - } - } - else { - attr_iteration(gid, attr_crt_order_flags); - link_iteration(gid, crt_order_flags); - } - - dump_indent -= COL; - ctx.indent_level--; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - if(HDstrlen(h5tools_dump_header_format->groupblockend)) { - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->groupblockend); - if(HDstrlen(h5tools_dump_header_format->groupend)) - h5tools_str_append(&buffer, " "); - } - if(HDstrlen(h5tools_dump_header_format->groupend)) - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->groupend); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - h5tools_str_close(&buffer); -} - -/*------------------------------------------------------------------------- - * Function: dump_dataset - * - * Purpose: Dump the specified data set - * - * Return: void - * - * Programmer: Ruey-Hsia Li - * - * Modifications: - * Pedro Vicente, 2004, added dataset creation property list display - * Pedro Vicente, October 4, 2007, added parameters to H5Aiterate2() to allow for - * other iteration orders - * - *------------------------------------------------------------------------- - */ -void -dump_dataset(hid_t did, const char *name, struct subset_t *sset) -{ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &h5tools_dataformat; - h5tool_format_t string_dataformat; - hid_t type, space; - unsigned attr_crt_order_flags; - hid_t dcpl_id; /* dataset creation property list ID */ - h5tools_str_t buffer; /* string into which to render */ - hsize_t curr_pos = 0; /* total data element position */ - - HDmemset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; - - string_dataformat = *outputformat; - - if (fp_format) { - string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; - } - - if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; - string_dataformat.line_per_line = 1; - } - else - string_dataformat.line_ncols = h5tools_nCols; - - string_dataformat.do_escape = display_escape; - outputformat = &string_dataformat; - - if ((dcpl_id = H5Dget_create_plist(did)) < 0) { - error_msg("error in getting creation property list ID\n"); - h5tools_setstatus(EXIT_FAILURE); - } - - /* query the creation properties for attributes */ - if (H5Pget_attr_creation_order(dcpl_id, &attr_crt_order_flags) < 0) { - error_msg("error in getting creation properties\n"); - h5tools_setstatus(EXIT_FAILURE); - } - - /* setup */ - HDmemset(&buffer, 0, sizeof(h5tools_str_t)); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s \"%s\" %s", - h5tools_dump_header_format->datasetbegin, name, - h5tools_dump_header_format->datasetblockbegin); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - h5tools_dump_comment(rawoutstream, outputformat, &ctx, did); - - dump_indent += COL; - ctx.indent_level++; - - type = H5Dget_type(did); - h5dump_type_table = type_table; - h5tools_dump_datatype(rawoutstream, outputformat, &ctx, type); - h5dump_type_table = NULL; - - space = H5Dget_space(did); - h5tools_dump_dataspace(rawoutstream, outputformat, &ctx, space); - H5Sclose(space); - - if(display_oid) { - h5tools_dump_oid(rawoutstream, outputformat, &ctx, did); - } - - if(display_dcpl) { - h5dump_type_table = type_table; - h5tools_dump_dcpl(rawoutstream, outputformat, &ctx, dcpl_id, type, did); - h5dump_type_table = NULL; - } - H5Pclose(dcpl_id); - - if(display_data) { - unsigned data_loop = 1; - unsigned u; - - if(display_packed_bits) - data_loop = packed_bits_num; - for(u = 0; u < data_loop; u++) { - if(display_packed_bits) { - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - /* Render the element */ - h5tools_str_reset(&buffer); - packed_data_mask = packed_mask[u]; - packed_data_offset = packed_offset[u]; - packed_data_length = packed_length[u]; - h5tools_print_packed_bits(&buffer, type); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - switch(H5Tget_class(type)) { - case H5T_TIME: - ctx.indent_level++; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "DATA{ not yet implemented.}"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level--; - break; - - case H5T_INTEGER: - case H5T_FLOAT: - case H5T_STRING: - case H5T_BITFIELD: - case H5T_OPAQUE: - case H5T_COMPOUND: - case H5T_REFERENCE: - case H5T_ENUM: - case H5T_VLEN: - case H5T_ARRAY: - { - h5tools_dump_data(rawoutstream, outputformat, &ctx, did, TRUE, sset, display_ai, display_char); - } - break; - - case H5T_NO_CLASS: - case H5T_NCLASSES: - default: - HDassert(0); - break; - } /* end switch */ - } /* for(u=0; u<data_loop; u++) */ - } - H5Tclose(type); - - if (!bin_output) { - attr_iteration(did, attr_crt_order_flags); - } - ctx.indent_level--; - dump_indent -= COL; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - if(HDstrlen(h5tools_dump_header_format->datasetblockend)) { - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetblockend); - if(HDstrlen(h5tools_dump_header_format->datasetend)) - h5tools_str_append(&buffer, " "); - } - if(HDstrlen(h5tools_dump_header_format->datasetend)) - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetend); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - h5tools_str_close(&buffer); -} - -/*------------------------------------------------------------------------- - * Function: dump_data - * - * Purpose: Dump attribute or dataset data - * - * Return: void - * - * Programmer: Ruey-Hsia Li - * - * Modifications: pvn, print the matrix indices - * Albert Cheng, 2004/11/18 - * Add --string printing for attributes too. - * - *------------------------------------------------------------------------- - */ -void -dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_index) -{ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &h5tools_dataformat; - h5tool_format_t string_dataformat; - int print_dataset = FALSE; - - string_dataformat = *outputformat; - - if (fp_format) { - string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; - } - - if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; - string_dataformat.line_per_line = 1; - } - else - string_dataformat.line_ncols = h5tools_nCols; - - string_dataformat.do_escape = display_escape; - outputformat = &string_dataformat; - - HDmemset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; - - if(obj_data == DATASET_DATA) - print_dataset = TRUE; - h5tools_dump_data(rawoutstream, outputformat, &ctx, obj_id, print_dataset, sset, display_index, display_char); -} - - -/*------------------------------------------------------------------------- - * Function: dump_fcpl - * - * Purpose: prints file creation property list information - * - * Return: void - * - * Programmer: pvn - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -void -dump_fcpl(hid_t fid) -{ - hid_t fcpl; /* file creation property list ID */ - hsize_t userblock; /* userblock size retrieved from FCPL */ - size_t off_size; /* size of offsets in the file */ - size_t len_size; /* size of lengths in the file */ - H5F_file_space_type_t fs_strategy; /* file space strategy */ - hsize_t fs_threshold; /* free-space section threshold */ - H5F_info2_t finfo; /* file information */ -#ifdef SHOW_FILE_DRIVER - hid_t fapl; /* file access property list ID */ - hid_t fdriver; /* file driver */ - char dname[32]; /* buffer to store driver name */ -#endif - unsigned sym_lk; /* symbol table B-tree leaf 'K' value */ - unsigned sym_ik; /* symbol table B-tree internal 'K' value */ - unsigned istore_ik; /* indexed storage B-tree internal 'K' value */ - - fcpl=H5Fget_create_plist(fid); - H5Fget_info2(fid, &finfo); - H5Pget_userblock(fcpl,&userblock); - H5Pget_sizes(fcpl,&off_size,&len_size); - H5Pget_sym_k(fcpl,&sym_ik,&sym_lk); - H5Pget_istore_k(fcpl,&istore_ik); - H5Pget_file_space(fcpl, &fs_strategy, &fs_threshold); - H5Pclose(fcpl); -#ifdef SHOW_FILE_DRIVER - fapl=h5_fileaccess(); - fdriver=H5Pget_driver(fapl); - H5Pclose(fapl); -#endif - - /*------------------------------------------------------------------------- - * SUPER_BLOCK - *------------------------------------------------------------------------- - */ - PRINTSTREAM(rawoutstream, "\n%s %s\n",SUPER_BLOCK, BEGIN); - indentation(dump_indent + COL); - PRINTSTREAM(rawoutstream, "%s %u\n","SUPERBLOCK_VERSION", finfo.super.version); - indentation(dump_indent + COL); - PRINTSTREAM(rawoutstream, "%s %u\n","FREELIST_VERSION", finfo.free.version); - indentation(dump_indent + COL); - PRINTSTREAM(rawoutstream, "%s %u\n","SYMBOLTABLE_VERSION", 0); /* Retain this for backward compatibility, for now (QAK) */ - indentation(dump_indent + COL); - PRINTSTREAM(rawoutstream, "%s %u\n","OBJECTHEADER_VERSION", finfo.sohm.version); - indentation(dump_indent + COL); - PRINTSTREAM(rawoutstream,"%s %zu\n","OFFSET_SIZE", off_size); - indentation(dump_indent + COL); - PRINTSTREAM(rawoutstream,"%s %zu\n","LENGTH_SIZE", len_size); - indentation(dump_indent + COL); - PRINTSTREAM(rawoutstream, "%s %u\n","BTREE_RANK", sym_ik); - indentation(dump_indent + COL); - PRINTSTREAM(rawoutstream, "%s %d\n","BTREE_LEAF", sym_lk); - -#ifdef SHOW_FILE_DRIVER - if(H5FD_CORE==fdriver) - HDstrcpy(dname,"H5FD_CORE"); -#ifdef H5_HAVE_DIRECT - else if(H5FD_DIRECT==fdriver) - HDstrcpy(dname,"H5FD_DIRECT"); -#endif - else if(H5FD_FAMILY==fdriver) - HDstrcpy(dname,"H5FD_FAMILY"); - else if(H5FD_LOG==fdriver) - HDstrcpy(dname,"H5FD_LOG"); - else if(H5FD_MPIO==fdriver) - HDstrcpy(dname,"H5FD_MPIO"); - else if(H5FD_MULTI==fdriver) - HDstrcpy(dname,"H5FD_MULTI"); - else if(H5FD_SEC2==fdriver) - HDstrcpy(dname,"H5FD_SEC2"); - else if(H5FD_STDIO==fdriver) - HDstrcpy(dname,"H5FD_STDIO"); - else - HDstrcpy(dname,"Unknown driver"); - - /* Take out this because the driver used can be different from the - * standard output. */ - /*indentation(dump_indent + COL); - PRINTSTREAM(rawoutstream, "%s %s\n","FILE_DRIVER", dname);*/ -#endif - indentation(dump_indent + COL); - PRINTSTREAM(rawoutstream, "%s %u\n","ISTORE_K", istore_ik); - - indentation(dump_indent + COL); - if(fs_strategy == H5F_FILE_SPACE_ALL_PERSIST) { - PRINTSTREAM(rawoutstream, "%s %s\n", "FILE_SPACE_STRATEGY", "H5F_FILE_SPACE_ALL_PERSIST"); - } else if(fs_strategy == H5F_FILE_SPACE_ALL) { - PRINTSTREAM(rawoutstream, "%s %s\n", "FILE_SPACE_STRATEGY", "H5F_FILE_SPACE_ALL"); - } else if(fs_strategy == H5F_FILE_SPACE_AGGR_VFD) { - PRINTSTREAM(rawoutstream, "%s %s\n", "FILE_SPACE_STRATEGY", "H5F_FILE_SPACE_AGGR_VFD"); - } else if(fs_strategy == H5F_FILE_SPACE_VFD) { - PRINTSTREAM(rawoutstream, "%s %s\n", "FILE_SPACE_STRATEGY", "H5F_FILE_SPACE_VFD"); - } else - PRINTSTREAM(rawoutstream, "%s %s\n", "FILE_SPACE_STRATEGY", "Unknown strategy"); - indentation(dump_indent + COL); - PRINTSTREAM(rawoutstream, "%s %Hu\n","FREE_SPACE_THRESHOLD", fs_threshold); - - /*------------------------------------------------------------------------- - * USER_BLOCK - *------------------------------------------------------------------------- - */ - indentation(dump_indent + COL); - PRINTSTREAM(rawoutstream, "USER_BLOCK %s\n",BEGIN); - indentation(dump_indent + COL + COL); - PRINTSTREAM(rawoutstream,"%s %Hu\n","USERBLOCK_SIZE", userblock); - indentation(dump_indent + COL); - PRINTSTREAM(rawoutstream, "%s\n",END); - - PRINTSTREAM(rawoutstream, "%s",END); -} - -/*------------------------------------------------------------------------- - * Function: dump_fcontents - * - * Purpose: prints all objects - * - * Return: void - * - * Programmer: pvn - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -void -dump_fcontents(hid_t fid) -{ - PRINTSTREAM(rawoutstream, "%s %s\n",FILE_CONTENTS, BEGIN); - - /* special case of unamed types in root group */ - if (unamedtype) { - unsigned u; - - for (u = 0; u < type_table->nobjs; u++) { - if (!type_table->objs[u].recorded) - PRINTSTREAM(rawoutstream, " %-10s /#"H5_PRINTF_HADDR_FMT"\n", "datatype", type_table->objs[u].objno); - } - } - - /* print objects in the files */ - h5trav_print(fid); - - PRINTSTREAM(rawoutstream, " %s\n",END); -} - -static herr_t -attr_search(hid_t oid, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *ainfo, void *_op_data) -{ - herr_t ret = SUCCEED; - int j; - char *obj_op_name; - char *obj_name; - trav_attr_udata_t *attr_data = (trav_attr_udata_t*)_op_data; - const char *buf = attr_data->path; - const char *op_name = attr_data->op_name; - - j = (int)HDstrlen(op_name) - 1; - /* find the last / */ - while(j >= 0) { - if(op_name[j] == '/' && (j == 0 || (j > 0 && op_name[j - 1] != '\\'))) - break; - j--; - } - - obj_op_name = h5tools_str_replace(op_name + j + 1, "\\/", "/"); - - if(obj_op_name == NULL) { - h5tools_setstatus(EXIT_FAILURE); - ret = FAIL; - } - else { - if(HDstrcmp(attr_name, obj_op_name)==0) { - size_t u, v, w; - - /* object name */ - u = HDstrlen(buf); - v = HDstrlen(op_name); - w = u + 1 + v + 1 + 2; - obj_name = (char *)HDmalloc(w); - if(obj_name == NULL) { - h5tools_setstatus(EXIT_FAILURE); - ret = FAIL; - } - else { - HDmemset(obj_name, '\0', w); - if(op_name[0] != '/') { - HDstrncat(obj_name, buf, u + 1); - if(buf[u - 1] != '/') - HDstrncat(obj_name, "/", (size_t)2); - } - HDstrncat(obj_name, op_name, v + 1); - - handle_attributes(oid, obj_name, NULL, 0, NULL); - HDfree(obj_name); - } - } - HDfree(obj_op_name); - } - return ret; -} /* end attr_search() */ - -static herr_t -obj_search(const char *path, const H5O_info_t *oi, const char H5_ATTR_UNUSED *already_visited, void *_op_data) -{ - trav_handle_udata_t *handle_data = (trav_handle_udata_t*)_op_data; - const char *op_name = handle_data->op_name; - trav_attr_udata_t attr_data; - - attr_data.path = path; - attr_data.op_name = op_name; - H5Aiterate_by_name(handle_data->fid, path, H5_INDEX_NAME, H5_ITER_INC, NULL, attr_search, (void*)&attr_data, H5P_DEFAULT); - - if(HDstrcmp(path, op_name) == 0) { - switch(oi->type) { - case H5O_TYPE_GROUP: - handle_groups(handle_data->fid, path, NULL, 0, NULL); - break; - - case H5O_TYPE_DATASET: - handle_datasets(handle_data->fid, path, NULL, 0, NULL); - break; - - case H5O_TYPE_NAMED_DATATYPE: - handle_datatypes(handle_data->fid, path, NULL, 0, NULL); - break; - - case H5O_TYPE_UNKNOWN: - case H5O_TYPE_NTYPES: - default: - error_msg("unknown object type value\n"); - h5tools_setstatus(EXIT_FAILURE); - } /* end switch */ - } - - return 0; -} /* end obj_search() */ - -static herr_t -lnk_search(const char *path, const H5L_info_t *li, void *_op_data) -{ - size_t search_len; - size_t k; - char *search_name; - trav_handle_udata_t *handle_data = (trav_handle_udata_t*)_op_data; - const char *op_name = handle_data->op_name; - - search_len = HDstrlen(op_name); - if(search_len > 0 && op_name[0] != '/') - k = 2; - else - k = 1; - search_name = (char *)HDmalloc(search_len + k); - if(search_name == NULL) { - error_msg("creating temporary link\n"); - h5tools_setstatus(EXIT_FAILURE); - } - else { - if (k == 2) { - HDstrcpy(search_name, "/"); - HDstrncat(search_name, op_name, search_len + 1); - } - else - HDstrncpy(search_name, op_name, search_len + 1); - search_name[search_len + k - 1] = '\0'; - - if(HDstrcmp(path, search_name) == 0) { - switch(li->type) { - case H5L_TYPE_SOFT: - case H5L_TYPE_EXTERNAL: - handle_links(handle_data->fid, op_name, NULL, 0, NULL); - break; - - case H5L_TYPE_HARD: - case H5L_TYPE_MAX: - case H5L_TYPE_ERROR: - default: - error_msg("unknown link type value\n"); - h5tools_setstatus(EXIT_FAILURE); - break; - } /* end switch() */ - } - HDfree(search_name); - } - return 0; -} /* end lnk_search() */ - -/*------------------------------------------------------------------------- - * Function: handle_paths - * - * Purpose: Handle objects from the command. - * - * Return: void - * - *------------------------------------------------------------------------- - */ -void -handle_paths(hid_t fid, const char *path_name, void H5_ATTR_UNUSED * data, int H5_ATTR_UNUSED pe, const char H5_ATTR_UNUSED *display_name) -{ - hid_t gid = -1; - - if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) { - error_msg("unable to open root group\n"); - h5tools_setstatus(EXIT_FAILURE); - } - else { - hid_t gcpl_id; - unsigned crt_order_flags; - unsigned attr_crt_order_flags; - trav_handle_udata_t handle_udata; /* User data for traversal */ - - if ((gcpl_id = H5Gget_create_plist(gid)) < 0) { - error_msg("error in getting group creation property list ID\n"); - h5tools_setstatus(EXIT_FAILURE); - } - - /* query the group creation properties for attributes */ - if (H5Pget_attr_creation_order(gcpl_id, &attr_crt_order_flags) < 0) { - error_msg("error in getting group creation properties\n"); - h5tools_setstatus(EXIT_FAILURE); - } - - /* query the group creation properties */ - if(H5Pget_link_creation_order(gcpl_id, &crt_order_flags) < 0) { - error_msg("error in getting group creation properties\n"); - h5tools_setstatus(EXIT_FAILURE); - } - - if(H5Pclose(gcpl_id) < 0) { - error_msg("error in closing group creation property list ID\n"); - h5tools_setstatus(EXIT_FAILURE); - } - - handle_udata.fid = fid; - handle_udata.op_name = path_name; - if(h5trav_visit(fid, "/", TRUE, TRUE, obj_search, lnk_search, &handle_udata) < 0) { - error_msg("error traversing information\n"); - h5tools_setstatus(EXIT_FAILURE); - } - } -} - -/*------------------------------------------------------------------------- - * Function: handle_attributes - * - * Purpose: Handle the attributes from the command. - * - * Return: void - * - * Programmer: Bill Wendling - * Tuesday, 9. January 2001 - * - * Modifications: - * - * PVN, May 2008 - * add an extra parameter PE, to allow printing/not printing of error messages - * - *------------------------------------------------------------------------- - */ -void -handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED * data, int H5_ATTR_UNUSED pe, const char H5_ATTR_UNUSED *display_name) -{ - hid_t oid = -1; - hid_t attr_id = -1; - char *obj_name = NULL; - char *attr_name = NULL; - int j; - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &h5tools_dataformat; - h5tool_format_t string_dataformat; - hsize_t curr_pos = 0; /* total data element position */ - - j = (int)HDstrlen(attr) - 1; - obj_name = (char *)HDmalloc((size_t)j + 2); - if(obj_name == NULL) - goto error; - - /* find the last / */ - while(j >= 0) { - if (attr[j] == '/' && (j==0 || (j>0 && attr[j-1]!='\\'))) - break; - j--; - } - - /* object name */ - if(j == -1) - HDstrcpy(obj_name, "/"); - else { - HDstrncpy(obj_name, attr, (size_t)j + 1); - obj_name[j + 1] = '\0'; - } /* end else */ - - dump_indent += COL; - HDmemset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; - - string_dataformat = *outputformat; - - if (fp_format) { - string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; - } - - if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; - string_dataformat.line_per_line = 1; - } - else - string_dataformat.line_ncols = h5tools_nCols; - - string_dataformat.do_escape = display_escape; - outputformat = &string_dataformat; - - attr_name = h5tools_str_replace(attr + j + 1, "\\/", "/"); - - /* handle error case: cannot open the object with the attribute */ - if((oid = H5Oopen(fid, obj_name, H5P_DEFAULT)) < 0) { - /* setup */ - HDmemset(&buffer, 0, sizeof(h5tools_str_t)); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s \"%s\" %s", - h5tools_dump_header_format->attributebegin, attr, - h5tools_dump_header_format->attributeblockbegin); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - error_msg("unable to open object \"%s\"\n", obj_name); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - /* Render the element */ - h5tools_str_reset(&buffer); - if(HDstrlen(h5tools_dump_header_format->attributeblockend)) { - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->attributeblockend); - if(HDstrlen(h5tools_dump_header_format->attributeend)) - h5tools_str_append(&buffer, " "); - } - if(HDstrlen(h5tools_dump_header_format->attributeend)) - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->attributeend); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - h5tools_str_close(&buffer); - - goto error; - } /* end if */ - - attr_id = H5Aopen(oid, attr_name, H5P_DEFAULT); - oid_output = display_oid; - data_output = display_data; - attr_data_output = display_attr_data; - - h5dump_type_table = type_table; - h5tools_dump_attribute(rawoutstream, outputformat, &ctx, attr_name, attr_id, display_ai, display_char); - h5dump_type_table = NULL; - - if(attr_id < 0) { - goto error; - } - - /* Close object */ - if(H5Oclose(oid) < 0) { - goto error; - } /* end if */ - - HDfree(obj_name); - HDfree(attr_name); - dump_indent -= COL; - return; - -error: - h5tools_setstatus(EXIT_FAILURE); - if(obj_name) - HDfree(obj_name); - - if (attr_name) - HDfree(attr_name); - - H5E_BEGIN_TRY { - H5Oclose(oid); - H5Aclose(attr_id); - } H5E_END_TRY; - dump_indent -= COL; -} - -/*------------------------------------------------------------------------- - * Function: handle_datasets - * - * Purpose: Handle the datasets from the command. - * - * Return: void - * - * Programmer: Bill Wendling - * Tuesday, 9. January 2001 - * - * Modifications: - * Pedro Vicente, Tuesday, January 15, 2008 - * check for block overlap\ - * - * Pedro Vicente, May 8, 2008 - * added a flag PE that prints/not prints error messages - * added for cases of external links not found, to avoid printing of - * objects not found, since external links are dumped on a trial error basis - * - *------------------------------------------------------------------------- - */ -void -handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *display_name) -{ - H5O_info_t oinfo; - hid_t dsetid; - hid_t dapl_id = H5P_DEFAULT; /* dataset access property list ID */ - struct subset_t *sset = (struct subset_t *)data; - const char *real_name = display_name ? display_name : dset; - - if(display_data) { - if ((dapl_id = H5Pcreate(H5P_DATASET_ACCESS)) < 0) { - error_msg("error in creating default access property list ID\n"); - } - if (display_vds_first) { - if(H5Pset_virtual_view(dapl_id, H5D_VDS_FIRST_MISSING) < 0) - 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) - error_msg("error in setting access property list ID, virtual_printf_gap\n"); - } - } - if((dsetid = H5Dopen2(fid, dset, dapl_id)) < 0) { - if (pe) - handle_links(fid, dset, data, pe, display_name); - return; - } /* end if */ - - if(sset) { - unsigned int i; - unsigned int ndims; - hid_t sid = H5Dget_space(dsetid); - int ndims_res = H5Sget_simple_extent_ndims(sid); - - H5Sclose(sid); - if(ndims_res < 0) { - error_msg("H5Sget_simple_extent_ndims failed\n"); - h5tools_setstatus(EXIT_FAILURE); - return; - } - ndims = (unsigned)ndims_res; - - if(!sset->start.data || !sset->stride.data || !sset->count.data || !sset->block.data) { - /* they didn't specify a ``stride'' or ``block''. default to 1 in all - * dimensions */ - if(!sset->start.data) { - /* default to (0, 0, ...) for the start coord */ - sset->start.data = (hsize_t *)HDcalloc((size_t)ndims, sizeof(hsize_t)); - sset->start.len = ndims; - } - - if(!sset->stride.data) { - sset->stride.data = (hsize_t *)HDcalloc((size_t)ndims, sizeof(hsize_t)); - sset->stride.len = ndims; - for (i = 0; i < ndims; i++) - sset->stride.data[i] = 1; - } - - if(!sset->count.data) { - sset->count.data = (hsize_t *)HDcalloc((size_t)ndims, sizeof(hsize_t)); - sset->count.len = ndims; - for (i = 0; i < ndims; i++) - sset->count.data[i] = 1; - } - - if(!sset->block.data) { - sset->block.data = (hsize_t *)HDcalloc((size_t)ndims, sizeof(hsize_t)); - sset->block.len = ndims; - for (i = 0; i < ndims; i++) - sset->block.data[i] = 1; - } - } - - /*------------------------------------------------------------------------- - * check for dimension overflow - *------------------------------------------------------------------------- - */ - if(sset->start.len > ndims) { - error_msg("number of start dims (%u) exceed dataset dims (%u)\n", sset->start.len, ndims); - h5tools_setstatus(EXIT_FAILURE); - return; - } - if(sset->stride.len > ndims) { - error_msg("number of stride dims (%u) exceed dataset dims (%u)\n", sset->stride.len, ndims); - h5tools_setstatus(EXIT_FAILURE); - return; - } - if(sset->count.len > ndims) { - error_msg("number of count dims (%u) exceed dataset dims (%u)\n", sset->count.len, ndims); - h5tools_setstatus(EXIT_FAILURE); - return; - } - if(sset->block.len > ndims) { - error_msg("number of block dims (%u) exceed dataset dims (%u)\n", sset->block.len, ndims); - h5tools_setstatus(EXIT_FAILURE); - return; - } - - /*------------------------------------------------------------------------- - * check for block overlap - *------------------------------------------------------------------------- - */ - for(i = 0; i < ndims; i++) { - if(sset->count.data[i] > 1) { - if(sset->stride.data[i] < sset->block.data[i]) { - error_msg("wrong subset selection; blocks overlap\n"); - h5tools_setstatus(EXIT_FAILURE); - return; - } /* end if */ - } /* end if */ - } /* end for */ - } /* end if */ - - - H5Oget_info(dsetid, &oinfo); - if(oinfo.rc > 1 || hit_elink) { - obj_t *found_obj; /* Found object */ - - found_obj = search_obj(dset_table, oinfo.addr); - - if(found_obj) { - if (found_obj->displayed) { - PRINTVALSTREAM(rawoutstream, "\n"); - indentation(dump_indent); - begin_obj(h5tools_dump_header_format->datasetbegin, real_name, h5tools_dump_header_format->datasetblockbegin); - PRINTVALSTREAM(rawoutstream, "\n"); - indentation(dump_indent + COL); - PRINTSTREAM(rawoutstream, "%s \"%s\"\n", HARDLINK, found_obj->objname); - indentation(dump_indent); - end_obj(h5tools_dump_header_format->datasetend, h5tools_dump_header_format->datasetblockend); - } - else { - found_obj->displayed = TRUE; - dump_indent += COL; - dump_dataset(dsetid, real_name, sset); - dump_indent -= COL; - } - } - else - h5tools_setstatus(EXIT_FAILURE); - } - else { - dump_indent += COL; - dump_dataset(dsetid, real_name, sset); - dump_indent -= COL; - } - if (dapl_id != H5P_DEFAULT) - H5Pclose(dapl_id); - if(H5Dclose(dsetid) < 0) - h5tools_setstatus(EXIT_FAILURE); -} - -/*------------------------------------------------------------------------- - * Function: handle_groups - * - * Purpose: Handle the groups from the command. - * - * Return: void - * - * Programmer: Bill Wendling - * Tuesday, 9. January 2001 - * - * Modifications: Pedro Vicente, September 26, 2007 - * handle creation order - * - * Pedro Vicente, May 8, 2008 - * added a flag PE that prints/not prints error messages - * added for cases of external links not found, to avoid printing of - * objects not found, since external links are dumped on a trial error basis - * - *------------------------------------------------------------------------- - */ -void -handle_groups(hid_t fid, const char *group, void H5_ATTR_UNUSED *data, int pe, const char *display_name) -{ - hid_t gid; - const char *real_name = display_name ? display_name : group; - - if((gid = H5Gopen2(fid, group, H5P_DEFAULT)) < 0) { - if (pe) { - PRINTVALSTREAM(rawoutstream, "\n"); - begin_obj(h5tools_dump_header_format->groupbegin, real_name, h5tools_dump_header_format->groupblockbegin); - PRINTVALSTREAM(rawoutstream, "\n"); - indentation(COL); - error_msg("unable to open group \"%s\"\n", real_name); - end_obj(h5tools_dump_header_format->groupend, h5tools_dump_header_format->groupblockend); - h5tools_setstatus(EXIT_FAILURE); - } - } - else { - size_t new_len = HDstrlen(group) + 1; - - if(prefix_len <= new_len) { - prefix_len = new_len; - prefix = (char *)HDrealloc(prefix, prefix_len); - } /* end if */ - - HDstrcpy(prefix, group); - - dump_indent += COL; - dump_group(gid, real_name); - dump_indent -= COL; - - if(H5Gclose(gid) < 0) - h5tools_setstatus(EXIT_FAILURE); - } /* end else */ -} /* end handle_groups() */ - -/*------------------------------------------------------------------------- - * Function: handle_links - * - * Purpose: Handle soft or UD links from the command. - * - * Return: void - * - * Programmer: Bill Wendling - * Tuesday, 9. January 2001 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -void -handle_links(hid_t fid, const char *links, void H5_ATTR_UNUSED * data, int H5_ATTR_UNUSED pe, const char H5_ATTR_UNUSED *display_name) -{ - H5L_info_t linfo; - - if(H5Lget_info(fid, links, &linfo, H5P_DEFAULT) < 0) { - error_msg("unable to get link info from \"%s\"\n", links); - h5tools_setstatus(EXIT_FAILURE); - } - else if(linfo.type == H5L_TYPE_HARD) { - error_msg("\"%s\" is a hard link\n", links); - h5tools_setstatus(EXIT_FAILURE); - } - else { - char *buf = (char *)HDmalloc(linfo.u.val_size); - PRINTVALSTREAM(rawoutstream, "\n"); - - switch(linfo.type) { - case H5L_TYPE_SOFT: /* Soft link */ - begin_obj(h5tools_dump_header_format->softlinkbegin, links, h5tools_dump_header_format->softlinkblockbegin); - PRINTVALSTREAM(rawoutstream, "\n"); - indentation(COL); - if(H5Lget_val(fid, links, buf, linfo.u.val_size, H5P_DEFAULT) >= 0) { - PRINTSTREAM(rawoutstream, "LINKTARGET \"%s\"\n", buf); - } - else { - error_msg("h5dump error: unable to get link value for \"%s\"\n", links); - h5tools_setstatus(EXIT_FAILURE); - } - end_obj(h5tools_dump_header_format->softlinkend, h5tools_dump_header_format->softlinkblockend); - break; - - case H5L_TYPE_EXTERNAL: - begin_obj(h5tools_dump_header_format->udlinkbegin, links, h5tools_dump_header_format->udlinkblockbegin); - PRINTVALSTREAM(rawoutstream, "\n"); - indentation(COL); - begin_obj(h5tools_dump_header_format->extlinkbegin, links, h5tools_dump_header_format->extlinkblockbegin); - PRINTVALSTREAM(rawoutstream, "\n"); - if(H5Lget_val(fid, links, buf, linfo.u.val_size, H5P_DEFAULT) >= 0) { - const char *elink_file; - const char *elink_path; - - if(H5Lunpack_elink_val(buf, linfo.u.val_size, NULL, &elink_file, &elink_path)>=0) { - indentation(COL); - PRINTSTREAM(rawoutstream, "LINKCLASS %d\n", linfo.type); - indentation(COL); - PRINTSTREAM(rawoutstream, "TARGETFILE \"%s\"\n", elink_file); - indentation(COL); - PRINTSTREAM(rawoutstream, "TARGETPATH \"%s\"\n", elink_path); - } - else { - error_msg("h5dump error: unable to unpack external link value for \"%s\"\n", links); - h5tools_setstatus(EXIT_FAILURE); - } - } - else { - error_msg("h5dump error: unable to get external link value for \"%s\"\n", links); - h5tools_setstatus(EXIT_FAILURE); - } - end_obj(h5tools_dump_header_format->extlinkend, h5tools_dump_header_format->extlinkblockend); - break; - - case H5L_TYPE_ERROR: - case H5L_TYPE_MAX: - HDassert(0); - /* fall through */ - case H5L_TYPE_HARD: - default: - begin_obj(h5tools_dump_header_format->udlinkbegin, links, h5tools_dump_header_format->udlinkblockbegin); - PRINTVALSTREAM(rawoutstream, "\n"); - indentation(COL); - begin_obj(h5tools_dump_header_format->udlinkbegin, links, h5tools_dump_header_format->udlinkblockbegin); - PRINTVALSTREAM(rawoutstream, "\n"); - indentation(COL); - PRINTSTREAM(rawoutstream, "LINKCLASS %d\n", linfo.type); - end_obj(h5tools_dump_header_format->udlinkend, h5tools_dump_header_format->udlinkblockend); - break; - } /* end switch */ - HDfree(buf); - } /* end else */ -} - -/*------------------------------------------------------------------------- - * Function: handle_datatypes - * - * Purpose: Handle the datatypes from the command. - * - * Return: void - * - * Programmer: Bill Wendling - * Tuesday, 9. January 2001 - * - * Modifications: - * - * Pedro Vicente, May 8, 2008 - * added a flag PE that prints/not prints error messages - * added for cases of external links not found, to avoid printing of - * objects not found, since external links are dumped on a trial error basis - * - *------------------------------------------------------------------------- - */ -void -handle_datatypes(hid_t fid, const char *type, void H5_ATTR_UNUSED * data, int pe, const char *display_name) -{ - hid_t type_id; - const char *real_name = display_name ? display_name : type; - - if((type_id = H5Topen2(fid, type, H5P_DEFAULT)) < 0) { - /* check if type is unamed datatype */ - unsigned idx = 0; - - while(idx < type_table->nobjs ) { - char name[128]; - - if(!type_table->objs[idx].recorded) { - /* unamed datatype */ - sprintf(name, "/#"H5_PRINTF_HADDR_FMT, type_table->objs[idx].objno); - - if(!HDstrcmp(name, real_name)) - break; - } /* end if */ - - idx++; - } /* end while */ - - if(idx == type_table->nobjs) { - if (pe) { - /* unknown type */ - PRINTVALSTREAM(rawoutstream, "\n"); - begin_obj(h5tools_dump_header_format->datatypebegin, real_name, h5tools_dump_header_format->datatypeblockbegin); - PRINTVALSTREAM(rawoutstream, "\n"); - indentation(COL); - error_msg("unable to open datatype \"%s\"\n", real_name); - end_obj(h5tools_dump_header_format->datatypeend, h5tools_dump_header_format->datatypeblockend); - h5tools_setstatus(EXIT_FAILURE); - } - } - else { - hid_t dsetid = H5Dopen2(fid, type_table->objs[idx].objname, H5P_DEFAULT); - type_id = H5Dget_type(dsetid); - - dump_indent += COL; - dump_named_datatype(type_id, real_name); - dump_indent -= COL; - - H5Tclose(type_id); - H5Dclose(dsetid); - } - } - else { - dump_indent += COL; - dump_named_datatype(type_id, real_name); - dump_indent -= COL; - - if(H5Tclose(type_id) < 0) - h5tools_setstatus(EXIT_FAILURE); - } -} - - -/*------------------------------------------------------------------------- - * Function: dump_extlink - * - * made by: PVN - * - * Purpose: Dump an external link - * Since external links are soft links, they are dumped on a trial error - * basis, attempting to dump as a dataset, as a group and as a named datatype - * Error messages are supressed - * - * Modifications: - * Neil Fortner - * 13 October 2008 - * Function basically rewritten. No longer directly opens the target file, - * now initializes a new set of tables for the external file. No longer - * dumps on a trial and error basis, but errors are still suppressed. - * - *------------------------------------------------------------------------- - */ -static int -dump_extlink(hid_t group, const char *linkname, const char *objname) -{ - hid_t oid; - H5O_info_t oi; - table_t *old_group_table = group_table; - table_t *old_dset_table = dset_table; - table_t *old_type_table = type_table; - hbool_t old_hit_elink; - ssize_t idx; - - /* Open target object */ - if ((oid = H5Oopen(group, linkname, H5P_DEFAULT)) < 0) - goto fail; - - /* Get object info */ - if (H5Oget_info(oid, &oi) < 0) { - H5Oclose(oid); - goto fail; - } - - /* Check if we have visited this file already */ - if ((idx = table_list_visited(oi.fileno)) < 0) { - /* We have not visited this file, build object tables */ - if ((idx = table_list_add(oid, oi.fileno)) < 0) { - H5Oclose(oid); - goto fail; - } - } - - /* Do not recurse through an external link into the original file (idx=0) */ - if (idx) { - /* Update table pointers */ - group_table = table_list.tables[idx].group_table; - dset_table = table_list.tables[idx].dset_table; - type_table = table_list.tables[idx].type_table; - - /* We will now traverse the external link, set this global to indicate this */ - old_hit_elink = hit_elink; - hit_elink = TRUE; - - /* add some indentation to distinguish that these objects are external */ - dump_indent += COL; - - /* Recurse into the external file */ - switch (oi.type) { - case H5O_TYPE_GROUP: - handle_groups(group, linkname, NULL, 0, objname); - break; - - case H5O_TYPE_DATASET: - handle_datasets(group, linkname, NULL, 0, objname); - break; - - case H5O_TYPE_NAMED_DATATYPE: - handle_datatypes(group, linkname, NULL, 0, objname); - break; - - case H5O_TYPE_UNKNOWN: - case H5O_TYPE_NTYPES: - default: - h5tools_setstatus(EXIT_FAILURE); - } - - dump_indent -= COL; - - /* Reset table pointers */ - group_table = old_group_table; - dset_table = old_dset_table; - type_table = old_type_table; - - /* Reset hit_elink */ - hit_elink = old_hit_elink; - } /* end if */ - - if (H5Idec_ref(oid) < 0) - h5tools_setstatus(EXIT_FAILURE); - - return SUCCEED; - -fail: - return FAIL; -} - diff --git a/tools/h5dump/h5dump_ddl.h b/tools/h5dump/h5dump_ddl.h deleted file mode 100644 index 2b3f61e..0000000 --- a/tools/h5dump/h5dump_ddl.h +++ /dev/null @@ -1,52 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef H5DUMP_DDL_H__ -#define H5DUMP_DDL_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* The dump functions of the dump_function_table */ -/* standard format: no change */ -void dump_group(hid_t, const char *); -void dump_named_datatype(hid_t, const char *); -void dump_dataset(hid_t, const char *, struct subset_t *); -void dump_dataspace(hid_t space); -void dump_datatype(hid_t type); -void dump_data(hid_t, int, struct subset_t *, int); -void dump_fcpl(hid_t fid); -void dump_fcontents(hid_t fid); - -/* callback function used by H5Aiterate2() */ -herr_t dump_attr_cb(hid_t loc_id, const char *attr_name, const H5A_info_t *info, void *_op_data); - -/* other iteration functions */ -void link_iteration(hid_t gid, unsigned crt_order_flags); -void attr_iteration(hid_t gid, unsigned attr_crt_order_flags); - -void handle_paths(hid_t fid, const char *path_name, void *data, int pe, const char *display_name); -void handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *display_name); -void handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED * data, int H5_ATTR_UNUSED pe, const char H5_ATTR_UNUSED *display_name); -void handle_groups(hid_t fid, const char *group, void H5_ATTR_UNUSED *data, int pe, const char *display_name); -void handle_links(hid_t fid, const char *links, void H5_ATTR_UNUSED * data, int H5_ATTR_UNUSED pe, const char H5_ATTR_UNUSED *display_name); -void handle_datatypes(hid_t fid, const char *type, void H5_ATTR_UNUSED * data, int pe, const char *display_name); - -#ifdef __cplusplus -} -#endif - -#endif /* !H5DUMP_DDL_H__ */ diff --git a/tools/h5dump/h5dump_defines.h b/tools/h5dump/h5dump_defines.h deleted file mode 100644 index 2be2dcc..0000000 --- a/tools/h5dump/h5dump_defines.h +++ /dev/null @@ -1,56 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef H5DUMP_DEFINES_H__ -#define H5DUMP_DEFINES_H__ - -#define H5DUMP_MAX_RANK H5S_MAX_RANK - -#define ATTRIBUTE_DATA 0 -#define DATASET_DATA 1 -#define ENUM_DATA 2 -#define COL 3 - -/* Macros for displaying objects */ -#define begin_obj(obj,name,begin) \ - do { \ - if ((name)) { \ - PRINTSTREAM(rawoutstream, "%s \"%s\" %s", (obj), (name), (begin)); \ - } \ - else { \ - PRINTSTREAM(rawoutstream, "%s %s", (obj), (begin)); \ - } \ - } while(0); - -#define end_obj(obj,end) \ - do { \ - if(HDstrlen(end)) { \ - PRINTSTREAM(rawoutstream, "%s", end); \ - if(HDstrlen(obj)) \ - PRINTVALSTREAM(rawoutstream, " "); \ - } \ - if(HDstrlen(obj)) \ - PRINTSTREAM(rawoutstream, "%s", obj); \ - } while(0); - - -/* 3 private values: can't be set, but can be read. - Note: these are defined in H5Zprivate, they are - duplicated here. - */ -#define H5_SZIP_LSB_OPTION_MASK 8 -#define H5_SZIP_MSB_OPTION_MASK 16 -#define H5_SZIP_RAW_OPTION_MASK 128 - -#endif /* !H5DUMP_DEFINES_H__ */ diff --git a/tools/h5dump/h5dump_extern.h b/tools/h5dump/h5dump_extern.h deleted file mode 100644 index 8fef1b9..0000000 --- a/tools/h5dump/h5dump_extern.h +++ /dev/null @@ -1,114 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef H5DUMP_EXTERN_H__ -#define H5DUMP_EXTERN_H__ - -#include "hdf5.h" -#include "H5private.h" -#include "h5tools.h" -#include "h5tools_utils.h" -#include "h5tools_ref.h" -#include "h5trav.h" -#include "h5dump_defines.h" - -/** - ** This is the global dispatch table for the dump functions. - **/ -/* the table of dump functions */ -typedef struct dump_functions_t { - void (*dump_group_function) (hid_t, const char *); - void (*dump_named_datatype_function) (hid_t, const char *); - void (*dump_dataset_function) (hid_t, const char *, struct subset_t *); - void (*dump_dataspace_function) (hid_t); - void (*dump_datatype_function) (hid_t); - herr_t (*dump_attribute_function) (hid_t, const char *, const H5A_info_t *, void *); - void (*dump_data_function) (hid_t, int, struct subset_t *, int); -} dump_functions; - -/* List of table structures. There is one table structure for each file */ -typedef struct h5dump_table_list_t { - size_t nalloc; - size_t nused; - struct { - unsigned long fileno; /* File number that these tables refer to */ - hid_t oid; /* ID of an object in this file, held open so fileno is consistent */ - table_t *group_table; /* Table of groups */ - table_t *dset_table; /* Table of datasets */ - table_t *type_table; /* Table of datatypes */ - } *tables; -} 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 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 */ - -/* sort parameters */ -extern H5_index_t sort_by; /*sort_by [creation_order | name] */ -extern H5_iter_order_t sort_order; /*sort_order [ascending | descending] */ - -#define PACKED_BITS_MAX 8 /* Maximum number of packed-bits to display */ -#define PACKED_BITS_SIZE_MAX 8*sizeof(long long) /* Maximum bits size of integer types of packed-bits */ -/* mask list for packed bits */ -extern unsigned long long packed_mask[PACKED_BITS_MAX]; /* packed bits are restricted to 8*sizeof(llong) bytes */ - -/* packed bits display parameters */ -extern unsigned packed_offset[PACKED_BITS_MAX]; -extern unsigned packed_length[PACKED_BITS_MAX]; - -/* - * The global table is set to either ddl_function_table or - * xml_function_table in the initialization. - */ -extern const dump_functions *dump_function_table; - -#ifdef __cplusplus -extern "C" { -#endif - -void add_prefix(char **prfx, size_t *prfx_len, const char *name); -hid_t h5_fileaccess(void); -ssize_t table_list_add(hid_t oid, unsigned long file_no); -ssize_t table_list_visited(unsigned long file_no); - -#ifdef __cplusplus -} -#endif - -#endif /* !H5DUMP_EXTERN_H__ */ diff --git a/tools/h5dump/h5dump_xml.c b/tools/h5dump/h5dump_xml.c deleted file mode 100644 index 41f3914..0000000 --- a/tools/h5dump/h5dump_xml.c +++ /dev/null @@ -1,4567 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include <stdio.h> -#include <stdlib.h> - -#include "H5private.h" -#include "h5tools.h" -#include "h5tools_dump.h" -#include "h5tools_utils.h" -#include "h5tools_ref.h" -#include "h5trav.h" -#include "h5dump_extern.h" -#include "h5dump_xml.h" - -const char *xmlnsprefix="hdf5:"; - -/* - * Alternative formating for data dumped to XML - * In general, the numbers are the same, but separators - * except spaces are not used. - * - * Some of these are not used, as some kinds of data are - * dumped in completely new subroutines. - * - * Some of this formatting may yet need to change. - * - * This table only affects XML output. - */ -static h5tool_format_t xml_dataformat = { - 0, /*raw */ - - "", /*fmt_raw */ - "%d", /*fmt_int */ - "%u", /*fmt_uint */ - "%hhd", /*fmt_schar */ - "%u", /*fmt_uchar */ - "%d", /*fmt_short */ - "%u", /*fmt_ushort */ - "%ld", /*fmt_long */ - "%lu", /*fmt_ulong */ - NULL, /*fmt_llong */ - NULL, /*fmt_ullong */ - "%g", /*fmt_double */ - "%g", /*fmt_float */ - - 0, /*ascii */ - 0, /*str_locale */ - 0, /*str_repeat */ - - "", /*arr_pre */ - "", /*arr_sep */ - "", /*arr_suf */ - 1, /*arr_linebreak */ - - "", /*cmpd_name */ - "", /*cmpd_sep */ - "", /*cmpd_pre */ - "", /*cmpd_suf */ - "", /*cmpd_end */ - - " ", /*vlen_sep */ - " ", /*vlen_pre */ - "", /*vlen_suf */ - "", /*vlen_end */ - - "%s", /*elmt_fmt */ - "", /*elmt_suf1 */ - " ", /*elmt_suf2 */ - - "", /*idx_n_fmt */ - "", /*idx_sep */ - "", /*idx_fmt */ - - 80, /*line_ncols *//*standard default columns */ - 0, /*line_per_line */ - "", /*line_pre */ - "%s", /*line_1st */ - "%s", /*line_cont */ - "", /*line_suf */ - "", /*line_sep */ - 1, /*line_multi_new */ - " ", /*line_indent */ - - 1, /*skip_first */ - - 1, /*obj_hidefileno */ - " "H5_PRINTF_HADDR_FMT, /*obj_format */ - - 1, /*dset_hidefileno */ - "DATASET %s ", /*dset_format */ - "%s", /*dset_blockformat_pre */ - "%s", /*dset_ptformat_pre */ - "%s", /*dset_ptformat */ - 0, /*array indices */ - 0 /*escape non printable characters */ -}; - - -/* internal functions */ -static int xml_name_to_XID(const char *, char *, int , int ); - -/* internal functions used by XML option */ -static void xml_print_datatype(hid_t, unsigned); -static void xml_print_enum(hid_t); -static int xml_print_refs(hid_t, int); -static int xml_print_strs(hid_t, int); -static char *xml_escape_the_string(const char *, int); -static char *xml_escape_the_name(const char *); - -/*------------------------------------------------------------------------- - * Function: xml_dump_all_cb - * - * Purpose: function callback called by H5Literate, - * displays everything in the specified object - * - * Return: Success: SUCCEED - * - * Failure: FAIL - * - * Programmer: Ruey-Hsia Li - * - * Modifications: - * RMcG, November 2000 - * Added XML support. Also, optionally checks the op_data argument - * - * PVN, May 2008 - * Dump external links - * - *------------------------------------------------------------------------- - */ -static herr_t -xml_dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void H5_ATTR_UNUSED *op_data) -{ - hid_t obj; - herr_t ret = SUCCEED; - char *obj_path = NULL; /* Full path of object */ - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &xml_dataformat; - h5tool_format_t string_dataformat; - hsize_t curr_pos = 0; /* total data element position */ - - /* setup */ - HDmemset(&buffer, 0, sizeof(h5tools_str_t)); - - HDmemset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; - - string_dataformat = *outputformat; - - if (fp_format) { - string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; - } - - if (h5tools_nCols==0) { - string_dataformat.line_ncols = 65535; - string_dataformat.line_per_line = 1; - } - else - string_dataformat.line_ncols = h5tools_nCols; - - string_dataformat.do_escape = display_escape; - outputformat = &string_dataformat; - - /* Build the object's path name */ - obj_path = (char *)HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2); - if(!obj_path) { - ret = FAIL; - goto done; - } - - HDstrcpy(obj_path, prefix); - HDstrcat(obj_path, "/"); - HDstrcat(obj_path, name); - - if(linfo->type == H5L_TYPE_HARD) { - H5O_info_t oinfo; - - /* Stat the object */ - if(H5Oget_info_by_name(group, name, &oinfo, H5P_DEFAULT) < 0) { - error_msg("unable to get object information for \"%s\"\n", name); - h5tools_setstatus(EXIT_FAILURE); - ret = FAIL; - goto done; - } /* end if */ - - switch(oinfo.type) { - case H5O_TYPE_GROUP: - if((obj = H5Gopen2(group, name, H5P_DEFAULT)) < 0) { - error_msg("unable to dump group \"%s\"\n", name); - h5tools_setstatus(EXIT_FAILURE); - ret = FAIL; - } - else { - char *old_prefix; /* Pointer to previous prefix */ - - /* Keep copy of prefix before iterating into group */ - old_prefix = HDstrdup(prefix); - HDassert(old_prefix); - - /* Append group name to prefix */ - add_prefix(&prefix, &prefix_len, name); - - /* Iterate into group */ - dump_function_table->dump_group_function(obj, name); - - /* Restore old prefix name */ - HDstrcpy(prefix, old_prefix); - HDfree(old_prefix); - - /* Close group */ - H5Gclose(obj); - } - break; - - case H5O_TYPE_DATASET: - if((obj = H5Dopen2(group, name, H5P_DEFAULT)) >= 0) { - if(oinfo.rc > 1 || hit_elink) { - obj_t *found_obj; /* Found object */ - - found_obj = search_obj(dset_table, oinfo.addr); - - if(found_obj == NULL) { - ctx.indent_level++; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s \"%s\" %s", - h5tools_dump_header_format->datasetbegin, name, - h5tools_dump_header_format->datasetblockbegin); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - if(HDstrlen(h5tools_dump_header_format->datasetblockend)) { - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetblockend); - if(HDstrlen(h5tools_dump_header_format->datasetend)) - h5tools_str_append(&buffer, " "); - } - if(HDstrlen(h5tools_dump_header_format->datasetend)) - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datasetend); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level--; - - h5tools_setstatus(EXIT_FAILURE); - ret = FAIL; - H5Dclose(obj); - goto done; - } - else if(found_obj->displayed) { - /* the XML version */ - char *t_obj_path = xml_escape_the_name(obj_path); - char *t_prefix = xml_escape_the_name(HDstrcmp(prefix,"") ? prefix : "/"); - char *t_name = xml_escape_the_name(name); - char *t_objname = xml_escape_the_name(found_obj->objname); - char dsetxid[100]; - char parentxid[100]; - char pointerxid[100]; - - /* Create OBJ-XIDs for the parent and object */ - xml_name_to_XID(obj_path, dsetxid, (int)sizeof(dsetxid), 1); - xml_name_to_XID(prefix, parentxid, (int)sizeof(parentxid), 1); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDataset Name=\"%s\" OBJ-XID=\"%s-%d\" " - "H5Path=\"%s\" Parents=\"%s\" " - "H5ParentPaths=\"%s\">", - xmlnsprefix, - t_name, /* Dataset Name */ - dsetxid, get_next_xid(), /* OBJ-XID */ - t_obj_path, /* H5Path */ - parentxid, /* Parents */ - t_prefix); /* H5ParentPaths */ - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - xml_name_to_XID(found_obj->objname, pointerxid, (int)sizeof(pointerxid), 1); - - ctx.indent_level++; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDatasetPtr OBJ-XID=\"%s\" H5Path=\"%s\"/>", - xmlnsprefix, - pointerxid,t_objname); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level--; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sDataset>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - HDfree(t_name); - HDfree(t_obj_path); - HDfree(t_prefix); - HDfree(t_objname); - - H5Dclose(obj); - goto done; - } - else - found_obj->displayed = TRUE; - } /* end if */ - - dump_function_table->dump_dataset_function(obj, name, NULL); - H5Dclose(obj); - } - else { - error_msg("unable to dump dataset \"%s\"\n", name); - h5tools_setstatus(EXIT_FAILURE); - ret = FAIL; - } - break; - - case H5O_TYPE_NAMED_DATATYPE: - if((obj = H5Topen2(group, name, H5P_DEFAULT)) < 0) { - error_msg("unable to dump datatype \"%s\"\n", name); - h5tools_setstatus(EXIT_FAILURE); - ret = FAIL; - } - else { - dump_function_table->dump_named_datatype_function(obj, name); - H5Tclose(obj); - } - break; - - case H5O_TYPE_UNKNOWN: - case H5O_TYPE_NTYPES: - default: - error_msg("unknown object \"%s\"\n", name); - h5tools_setstatus(EXIT_FAILURE); - ret = FAIL; - } - } /* end if */ - else { - char *targbuf; - - switch(linfo->type) { - case H5L_TYPE_SOFT: - targbuf = (char *)HDmalloc(linfo->u.val_size); - HDassert(targbuf); - - if(H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) { - error_msg("unable to get link value\n"); - h5tools_setstatus(EXIT_FAILURE); - ret = FAIL; - } - else { - /* print the value of a soft link */ - /* XML */ - char linkxid[100]; - char parentxid[100]; - char targetxid[100]; - char *t_prefix = xml_escape_the_name(HDstrcmp(prefix,"") ? prefix : "/"); - char *t_name = xml_escape_the_name(name); - char *t_targbuf = xml_escape_the_name(targbuf); - char *t_obj_path = xml_escape_the_name(obj_path); - char *t_link_path; - int res; - - t_link_path = (char *)HDmalloc(HDstrlen(prefix) + linfo->u.val_size + 1); - if(targbuf[0] == '/') - HDstrcpy(t_link_path, targbuf); - else { - HDstrcpy(t_link_path, prefix); - HDstrcat(HDstrcat(t_link_path, "/"), targbuf); - } /* end else */ - - /* Create OBJ-XIDs for the parent and object */ - xml_name_to_XID(t_obj_path, linkxid, (int)sizeof(linkxid), 1); - xml_name_to_XID(prefix, parentxid, (int)sizeof(parentxid), 1); - - /* Try to create an OBJ-XID for the object pointed to */ - res = xml_name_to_XID(t_link_path, targetxid, (int)sizeof(targetxid), 0); - if (res == 0) { - /* target obj found */ - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sSoftLink LinkName=\"%s\" " - "OBJ-XID=\"%s\" " - "H5SourcePath=\"%s\" " - "TargetPath=\"%s\" TargetObj=\"%s\" " - "Parents=\"%s\" H5ParentPaths=\"%s\" />", - xmlnsprefix, - t_name, /* LinkName */ - linkxid, /* OBJ-XID */ - t_obj_path, /* H5SourcePath */ - t_targbuf, /* TargetPath */ - targetxid, /* TargetObj */ - parentxid, /* Parents */ - t_prefix); /* H5ParentPaths */ - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - else { - /* dangling link -- omit from xml attributes */ - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sSoftLink LinkName=\"%s\" " - "OBJ-XID=\"%s\" " - "H5SourcePath=\"%s\" " - "TargetPath=\"%s\" " - "Parents=\"%s\" H5ParentPaths=\"%s\" />", - xmlnsprefix, - t_name, /* LinkName */ - linkxid, /* OBJ-XID */ - t_obj_path, /* H5SourcePath */ - t_targbuf, /* TargetPath */ - parentxid, /* Parents */ - t_prefix); /* H5ParentPaths */ - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - - HDfree(t_prefix); - HDfree(t_name); - HDfree(t_targbuf); - HDfree(t_obj_path); - HDfree(t_link_path); - } - - HDfree(targbuf); - break; - - case H5L_TYPE_EXTERNAL: - targbuf = (char *)HDmalloc(linfo->u.val_size); - HDassert(targbuf); - - if(H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) { - error_msg("unable to get external link value\n"); - h5tools_setstatus(EXIT_FAILURE); - ret = FAIL; - } /* end if */ - else { - const char *filename; - const char *targname; - - if(H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL, &filename, &targname) < 0) { - error_msg("unable to unpack external link value\n"); - h5tools_setstatus(EXIT_FAILURE); - ret = FAIL; - } /* end if */ - else { - char linkxid[100]; - char parentxid[100]; - char *t_name = xml_escape_the_name(name); - char *t_prefix = xml_escape_the_name(HDstrcmp(prefix,"") ? prefix : "/"); - char *t_obj_path = xml_escape_the_name(obj_path); - char *t_filename = xml_escape_the_name(filename); - char *t_targname = xml_escape_the_name(targname); - - /* Create OBJ-XIDs for the parent and object */ - xml_name_to_XID(t_obj_path, linkxid, (int)sizeof(linkxid), 1); - xml_name_to_XID(prefix, parentxid, (int)sizeof(parentxid), 1); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sExternalLink LinkName=\"%s\" " - "OBJ-XID=\"%s\" " - "H5SourcePath=\"%s\" " - "TargetFilename=\"%s\" " - "TargetPath=\"%s\" " - "Parents=\"%s\" H5ParentPaths=\"%s\" />", - xmlnsprefix, - t_name, /* LinkName */ - linkxid, /* OBJ-XID */ - t_obj_path, /* H5SourcePath */ - filename, /* TargetFilename */ - targname, /* TargetPath*/ - parentxid, /* Parents */ - t_prefix); /* H5ParentPaths */ - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - HDfree(t_prefix); - HDfree(t_name); - HDfree(t_filename); - HDfree(t_targname); - HDfree(t_obj_path); - } /* end else */ - } /* end else */ - HDfree(targbuf); - break; - - case H5L_TYPE_ERROR: - case H5L_TYPE_MAX: - HDassert(0); - /* fall through */ - case H5L_TYPE_HARD: - default: - { - char linkxid[100]; - char parentxid[100]; - char *t_name = xml_escape_the_name(name); - char *t_prefix = xml_escape_the_name(HDstrcmp(prefix,"") ? prefix : "/"); - char *t_obj_path = xml_escape_the_name(obj_path); - - /* Create OBJ-XIDs for the parent and object */ - xml_name_to_XID(t_obj_path, linkxid, (int)sizeof(linkxid), 1); - xml_name_to_XID(prefix, parentxid, (int)sizeof(parentxid), 1); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sUserDefined LinkName=\"%s\" " - "OBJ-XID=\"%s\" " - "H5SourcePath=\"%s\" " - "LinkClass=\"%d\" " - "Parents=\"%s\" H5ParentPaths=\"%s\" />", - xmlnsprefix, - t_name, /* LinkName */ - linkxid, /* OBJ-XID */ - t_obj_path, /* H5SourcePath */ - linfo->type, /* LinkClass */ - parentxid, /* Parents */ - t_prefix); /* H5ParentPaths */ - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - HDfree(t_prefix); - HDfree(t_name); - HDfree(t_obj_path); - } - break; - - } /* end switch */ - } /* end else */ - -done: - - h5tools_str_close(&buffer); - - if(obj_path) - HDfree(obj_path); - return ret; -} - -/* - * create a string suitable for and XML NCNAME. Uses the - * object reference to create the string. - * - * 'gen'; 0 - return null if not found - * 1 - generate a fake entry and return fake id. - */ -int -xml_name_to_XID(const char *str , char *outstr, int outlen, int gen) -{ - haddr_t objno; /* Object ID for object at path */ - - if (outlen < 22) return 1; - - objno = ref_path_table_lookup(str); - if (objno == HADDR_UNDEF) { - if (HDstrlen(str) == 0) { - objno = ref_path_table_lookup("/"); - if (objno == HADDR_UNDEF) { - if (gen) { - objno = ref_path_table_gen_fake(str); - sprintf(outstr, "xid_"H5_PRINTF_HADDR_FMT, objno); - return 0; - } - else { - return 1; - } - } - } - else { - if (gen) { - objno = ref_path_table_gen_fake(str); - sprintf(outstr, "xid_"H5_PRINTF_HADDR_FMT, objno); - return 0; - } - else { - return 1; - } - } - } - - sprintf(outstr, "xid_"H5_PRINTF_HADDR_FMT, objno); - - return(0); -} - -static const char *quote = """; -static const char *amp = "&"; -static const char *lt = "<"; -static const char *gt = ">"; -static const char *apos = "'"; - -/*------------------------------------------------------------------------- - * Function: xml_escape_the_name - * - * Purpose: Escape XML reserved chars in a name, so HDF5 strings - * and paths can be correctly read back in XML element. - * - * Return: The revised string. - * - * Programmer: REMcG - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static char * -xml_escape_the_name(const char *str) -{ - size_t extra; - size_t len; - size_t i; - const char *cp; - char *ncp; - char *rcp; - size_t ncp_len; - - if (!str) - return NULL; - - cp = str; - len = HDstrlen(str); - extra = 0; - - for (i = 0; i < len; i++) { - if (*cp == '\"') - extra += (HDstrlen(quote) - 1); - else if (*cp == '\'') - extra += (HDstrlen(apos) - 1); - else if (*cp == '<') - extra += (HDstrlen(lt) - 1); - else if (*cp == '>') - extra += (HDstrlen(gt) - 1); - else if (*cp == '&') - extra += (HDstrlen(amp) - 1); - - cp++; - } - - if (extra == 0) - return HDstrdup(str); - - cp = str; - ncp_len = len + extra + 1; - rcp = ncp = (char *)HDmalloc(ncp_len); - - if (!ncp) - return NULL; /* ?? */ - - for (i = 0; i < len; i++) { - size_t esc_len; - - HDassert(ncp_len); - if (*cp == '\'') { - HDstrncpy(ncp, apos, ncp_len); - esc_len = HDstrlen(apos); - } - else if (*cp == '<') { - HDstrncpy(ncp, lt, ncp_len); - esc_len = HDstrlen(lt); - } - else if (*cp == '>') { - HDstrncpy(ncp, gt, ncp_len); - esc_len = HDstrlen(gt); - } - else if (*cp == '\"') { - HDstrncpy(ncp, quote, ncp_len); - esc_len = HDstrlen(quote); - } - else if (*cp == '&') { - HDstrncpy(ncp, amp, ncp_len); - esc_len = HDstrlen(amp); - } - else { - *ncp = *cp; - esc_len = 1; - } - ncp += esc_len; - ncp_len -= esc_len; - cp++; - } - - *ncp = '\0'; - return rcp; -} - -/*------------------------------------------------------------------------- - * Function: xml_escape_the_string - * - * Purpose: Escape XML reserved chars in a string, so HDF5 strings - * and paths can be correctly read back in XML CDATA. - * - * Return: The revised string. - * - * Programmer: REMcG - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static char * -xml_escape_the_string(const char *str, int slen) -{ - size_t extra; - size_t len; - size_t i; - const char *cp; - char *ncp; - char *rcp; - size_t ncp_len; - - if (!str) - return NULL; - - cp = str; - - if (slen < 0) - len = HDstrlen(str); - else - len = (size_t)slen; - - extra = 0; - - for (i = 0; i < len; i++) { - if (*cp == '\\') - extra++; - else if (*cp == '\"') - extra++; - else if (*cp == '\'') - extra += (HDstrlen(apos) - 1); - else if (*cp == '<') - extra += (HDstrlen(lt) - 1); - else if (*cp == '>') - extra += (HDstrlen(gt) - 1); - else if (*cp == '&') - extra += (HDstrlen(amp) - 1); - cp++; - } - - cp = str; - ncp_len = len + extra + 1; - rcp = ncp = (char *) HDcalloc(ncp_len, sizeof(char)); - - if (ncp == NULL) - return NULL; /* ?? */ - - for (i = 0; i < len; i++) { - size_t esc_len; - - HDassert(ncp_len); - if (*cp == '\\') { - *ncp++ = '\\'; - *ncp = *cp; - esc_len = 1; - } - else if (*cp == '\"') { - *ncp++ = '\\'; - *ncp = *cp; - esc_len = 1; - } - else if (*cp == '\'') { - HDstrncpy(ncp, apos, ncp_len); - esc_len = HDstrlen(apos); - } - else if (*cp == '<') { - HDstrncpy(ncp, lt, ncp_len); - esc_len = HDstrlen(lt); - } - else if (*cp == '>') { - HDstrncpy(ncp, gt, ncp_len); - esc_len = HDstrlen(gt); - } - else if (*cp == '&') { - HDstrncpy(ncp, amp, ncp_len); - esc_len = HDstrlen(amp); - } - else { - *ncp = *cp; - esc_len = 1; - } - ncp += esc_len; - ncp_len -= esc_len; - cp++; - } - - *ncp = '\0'; - return rcp; -} - -/** - ** XML print functions--these replace some functions in the - ** h5tools.c suite. - **/ - -/*------------------------------------------------------------------------- - * Function: xml_print_datatype - * - * Purpose: Print description of a datatype in XML. - * Note: this is called inside a <DataType> element. - * - * Return: void - * - * Programmer: REMcG - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static void -xml_print_datatype(hid_t type, unsigned in_group) -{ - char *mname; - hid_t mtype; - unsigned nmembers; - unsigned ndims; - unsigned i; - size_t size; - hsize_t dims[H5DUMP_MAX_RANK]; - H5T_str_t str_pad; - H5T_cset_t cset; - hid_t super; - H5T_order_t ord; - H5T_sign_t sgn; - size_t sz; - size_t spos; - size_t epos; - size_t esize; - size_t mpos; - size_t msize; - int nmembs; - htri_t is_vlstr=FALSE; - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &xml_dataformat; - h5tool_format_t string_dataformat; - hsize_t curr_pos = 0; /* total data element position */ - - /* setup */ - HDmemset(&buffer, 0, sizeof(h5tools_str_t)); - - HDmemset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; - - string_dataformat = *outputformat; - - if (fp_format) { - string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; - } - - if (h5tools_nCols==0) { - string_dataformat.line_ncols = 65535; - string_dataformat.line_per_line = 1; - } - else - string_dataformat.line_ncols = h5tools_nCols; - - string_dataformat.do_escape = display_escape; - outputformat = &string_dataformat; - - if(!in_group && H5Tcommitted(type) > 0) { - H5O_info_t oinfo; - obj_t *found_obj; /* Found object */ - - /* detect a shared datatype, output only once */ - H5Oget_info(type, &oinfo); - found_obj = search_obj(type_table, oinfo.addr); - - if(found_obj) { - /* This should be defined somewhere else */ - /* These 2 cases are handled the same right now, but - probably will have something different eventually */ - char * dtxid = (char *)HDmalloc((size_t)100); - - xml_name_to_XID(found_obj->objname, dtxid, 100, 1); - if (!found_obj->recorded) { - /* 'anonymous' NDT. Use it's object num. - as it's name. */ - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNamedDataTypePtr OBJ-XID=\"/%s\"/>", - xmlnsprefix, dtxid); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - else { - /* point to the NDT by name */ - char *t_objname = xml_escape_the_name(found_obj->objname); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNamedDataTypePtr OBJ-XID=\"%s\" H5Path=\"%s\"/>", - xmlnsprefix, dtxid, t_objname); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - HDfree(t_objname); - } - HDfree(dtxid); - } - else { - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<!-- h5dump error: unknown committed type. -->"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - h5tools_setstatus(EXIT_FAILURE); - } - } - else { - switch (H5Tget_class(type)) { - case H5T_INTEGER: - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level++; - - /* <hdf5:IntegerType ByteOrder="bo" Sign="torf" Size="bytes"/> */ - ord = H5Tget_order(type); - sgn = H5Tget_sign(type); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sIntegerType ByteOrder=\"",xmlnsprefix); - switch (ord) { - case H5T_ORDER_LE: - h5tools_str_append(&buffer, "LE"); - break; - case H5T_ORDER_BE: - h5tools_str_append(&buffer, "BE"); - break; - case H5T_ORDER_VAX: - case H5T_ORDER_MIXED: - case H5T_ORDER_NONE: - case H5T_ORDER_ERROR: - default: - h5tools_str_append(&buffer, "ERROR_UNKNOWN"); - break; - } /* end switch */ - - h5tools_str_append(&buffer, "\" Sign=\""); - - switch (sgn) { - case H5T_SGN_NONE: - h5tools_str_append(&buffer, "false"); - break; - case H5T_SGN_2: - h5tools_str_append(&buffer, "true"); - break; - case H5T_SGN_ERROR: - case H5T_NSGN: - default: - h5tools_str_append(&buffer, "ERROR_UNKNOWN"); - break; - } /* end switch */ - - h5tools_str_append(&buffer, "\" Size=\""); - sz = H5Tget_size(type); - h5tools_str_append(&buffer, "%lu", (unsigned long)sz); - h5tools_str_append(&buffer, "\" />"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level--; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; - - case H5T_FLOAT: - /* <hdf5:FloatType ByteOrder="bo" Size="bytes" - SignBitLocation="bytes" - ExponentBits="eb" ExponentLocation="el" - MantissaBits="mb" MantissaLocation="ml" /> */ - ord = H5Tget_order(type); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level++; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sFloatType ByteOrder=\"",xmlnsprefix); - - switch (ord) { - case H5T_ORDER_LE: - h5tools_str_append(&buffer, "LE"); - break; - case H5T_ORDER_BE: - h5tools_str_append(&buffer, "BE"); - break; - case H5T_ORDER_VAX: - h5tools_str_append(&buffer, "VAX"); - break; - case H5T_ORDER_MIXED: - case H5T_ORDER_NONE: - case H5T_ORDER_ERROR: - default: - h5tools_str_append(&buffer, "ERROR_UNKNOWN"); - } /* end switch */ - - h5tools_str_append(&buffer, "\" Size=\""); - sz = H5Tget_size(type); - h5tools_str_append(&buffer, "%lu", (unsigned long)sz); - H5Tget_fields(type, &spos, &epos, &esize, &mpos, &msize); - h5tools_str_append(&buffer, "\" SignBitLocation=\"%lu\" ", (unsigned long)spos); - h5tools_str_append(&buffer, "ExponentBits=\"%lu\" ExponentLocation=\"%lu\" ", (unsigned long)esize, (unsigned long)epos); - h5tools_str_append(&buffer, "MantissaBits=\"%lu\" MantissaLocation=\"%lu\" />", (unsigned long)msize, (unsigned long)mpos); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level--; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; - - case H5T_TIME: - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level++; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sTimeType />",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - h5tools_str_append(&buffer, "<!-- H5T_TIME: not yet implemented -->"); - ctx.indent_level--; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; - - case H5T_STRING: - /* <hdf5:StringType Cset="cs" StrSize="chars" StrPad="pad" /> */ - size = H5Tget_size(type); - str_pad = H5Tget_strpad(type); - cset = H5Tget_cset(type); - is_vlstr = H5Tis_variable_str(type); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level++; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sStringType Cset=\"",xmlnsprefix); - - if (cset == H5T_CSET_ASCII) - h5tools_str_append(&buffer, "H5T_CSET_ASCII\" "); - else - h5tools_str_append(&buffer, "unknown_cset\" "); - - if(is_vlstr) - h5tools_str_append(&buffer, "StrSize=\"H5T_VARIABLE\" StrPad=\""); - else - h5tools_str_append(&buffer, "StrSize=\"%d\" StrPad=\"", (int) size); - - if (str_pad == H5T_STR_NULLTERM) - h5tools_str_append(&buffer, "H5T_STR_NULLTERM\"/>"); - else if (str_pad == H5T_STR_NULLPAD) - h5tools_str_append(&buffer, "H5T_STR_NULLPAD\"/>"); - else if (str_pad == H5T_STR_SPACEPAD) - h5tools_str_append(&buffer, "H5T_STR_SPACEPAD\"/>"); - else - h5tools_str_append(&buffer, "H5T_STR_ERROR\"/>"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level--; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; - - case H5T_BITFIELD: - /* <hdf5:BitfieldType ByteOrder="bo" Size="bytes"/> */ - ord = H5Tget_order(type); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level++; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sBitfieldType ByteOrder=\"",xmlnsprefix); - - switch (ord) { - case H5T_ORDER_LE: - h5tools_str_append(&buffer, "LE"); - break; - case H5T_ORDER_BE: - h5tools_str_append(&buffer, "BE"); - break; - case H5T_ORDER_VAX: - case H5T_ORDER_MIXED: - case H5T_ORDER_NONE: - case H5T_ORDER_ERROR: - default: - h5tools_str_append(&buffer, "ERROR_UNKNOWN"); - } /* end switch */ - - size = H5Tget_size(type); - h5tools_str_append(&buffer, "\" Size=\"%lu\"/>", (unsigned long)size); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level--; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; - - case H5T_OPAQUE: - /* <hdf5:OpaqueType Tag="tag" Size="bytes" /> */ - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level++; - mname = H5Tget_tag(type); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sOpaqueType Tag=\"%s\" ",xmlnsprefix, mname); - H5free_memory(mname); - size = H5Tget_size(type); - h5tools_str_append(&buffer, "Size=\"%lu\"/>", (unsigned long)size); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level--; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; - - case H5T_COMPOUND: - /* recursively describe the components of a compound datatype */ - - /* type of a dataset */ - nmembers = (unsigned)H5Tget_nmembers(type); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sCompoundType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - /* List each member Field of the type */ - /* <hdf5:Field FieldName="name" > */ - /* <hdf5:DataType > */ - ctx.indent_level++; - dump_indent += COL; - for (i = 0; i < nmembers; i++) { - char *t_fname; - - mname = H5Tget_member_name(type, i); - mtype = H5Tget_member_type(type, i); - t_fname = xml_escape_the_name(mname); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sField FieldName=\"%s\">",xmlnsprefix, t_fname); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - H5free_memory(mname); - HDfree(t_fname); - dump_indent += COL; - ctx.indent_level++; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDataType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level++; - dump_indent += COL; - xml_print_datatype(mtype,0); - dump_indent -= COL; - ctx.indent_level--; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sDataType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - dump_indent -= COL; - ctx.indent_level--; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sField>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - dump_indent -= COL; - ctx.indent_level--; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sCompoundType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; - - case H5T_REFERENCE: - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level++; - /* Only Object references supported at this time */ - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sReferenceType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level++; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sObjectReferenceType />",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level--; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sReferenceType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level--; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; - - case H5T_ENUM: - /* <hdf5:EnumType Nelems="ne" > list Name, values of enum */ - nmembs = H5Tget_nmembers(type); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sAtomicType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - dump_indent += COL; - ctx.indent_level++; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sEnumType Nelems=\"%d\">",xmlnsprefix, nmembs); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - xml_print_enum(type); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sEnumType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - dump_indent -= COL; - ctx.indent_level--; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sAtomicType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; - - case H5T_VLEN: - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sVLType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - super = H5Tget_super(type); - dump_indent += COL; - ctx.indent_level++; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDataType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - dump_indent += COL; - ctx.indent_level++; - xml_print_datatype(super,0); - dump_indent -= COL; - ctx.indent_level--; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sDataType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - dump_indent -= COL; - ctx.indent_level--; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sVLType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - H5Tclose(super); - - break; - - case H5T_ARRAY: - /* Get array base type */ - super = H5Tget_super(type); - - /* Print lead-in */ - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sArrayType Ndims=\"",xmlnsprefix); - ndims = (unsigned)H5Tget_array_ndims(type); - h5tools_str_append(&buffer, "%u\">", ndims); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - /* Get array information */ - H5Tget_array_dims2(type, dims); - - /* list of dimensions */ - ctx.indent_level++; - for (i = 0; i < ndims; i++) { - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sArrayDimension DimSize=\"%u\"/>", xmlnsprefix, (int) dims[i]); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - ctx.indent_level--; - - dump_indent += COL; - ctx.indent_level++; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDataType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - dump_indent += COL; - ctx.indent_level++; - xml_print_datatype(super,0); - dump_indent -= COL; - ctx.indent_level--; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sDataType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - dump_indent -= COL; - ctx.indent_level--; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sArrayType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - /* Close array base type */ - H5Tclose(super); - break; - - case H5T_NO_CLASS: - case H5T_NCLASSES: - HDassert(0); - /* fall through */ - default: - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<!-- unknown datatype -->"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - h5tools_setstatus(EXIT_FAILURE); - break; - } - } /* end else */ - - h5tools_str_close(&buffer); -} - -/*------------------------------------------------------------------------- - * Function: xml_dump_datatype - * - * Purpose: Dump description of a datatype in XML. - * - * Return: void - * - * Programmer: REMcG - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -void -xml_dump_datatype(hid_t type) -{ - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &xml_dataformat; - h5tool_format_t string_dataformat; - hsize_t curr_pos = 0; /* total data element position */ - - /* setup */ - HDmemset(&buffer, 0, sizeof(h5tools_str_t)); - - HDmemset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; - - string_dataformat = *outputformat; - - if (fp_format) { - string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; - } - - if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; - string_dataformat.line_per_line = 1; - } - else - string_dataformat.line_ncols = h5tools_nCols; - - string_dataformat.do_escape = display_escape; - outputformat = &string_dataformat; - - ctx.indent_level++; - dump_indent += COL; - - if(H5Tcommitted(type) > 0) { - H5O_info_t oinfo; - obj_t *found_obj; /* Found object */ - - /* Datatype is a shared or named datatype */ - H5Oget_info(type, &oinfo); - found_obj = search_obj(type_table, oinfo.addr); - - if(found_obj) { - /* Shared datatype, must be entered as an object */ - /* These 2 cases are the same now, but may change */ - char *dtxid = (char *)HDmalloc((size_t)100); - - xml_name_to_XID(found_obj->objname, dtxid, 100, 1); - if (!found_obj->recorded) { - /* anonymous stored datatype: - following the dumper's current - practice: - use it's object ref as its name - */ - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNamedDataTypePtr OBJ-XID=\"%s\"/>", - xmlnsprefix, dtxid); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - else { - /* pointer to a named datatype already in XML */ - char *t_objname = xml_escape_the_name(found_obj->objname); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNamedDataTypePtr OBJ-XID=\"%s\" H5Path=\"%s\" />", - xmlnsprefix, dtxid, t_objname); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - HDfree(t_objname); - } - HDfree(dtxid); - } - else { - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<!-- h5dump error: unknown committed type. -->"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - } - else { - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDataType>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level++; - dump_indent += COL; - xml_print_datatype(type, 0); - ctx.indent_level--; - dump_indent -= COL; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sDataType>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - ctx.indent_level--; - dump_indent -= COL; - - h5tools_str_close(&buffer); -} - -/*------------------------------------------------------------------------- - * Function: xml_dump_dataspace - * - * Purpose: Dump description of a dataspace in XML. - * - * Return: void - * - * Programmer: REMcG - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -void -xml_dump_dataspace(hid_t space) -{ - hsize_t size[H5DUMP_MAX_RANK]; - hsize_t maxsize[H5DUMP_MAX_RANK]; - int i; - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &xml_dataformat; - h5tool_format_t string_dataformat; - hsize_t curr_pos = 0; /* total data element position */ - - int ndims = H5Sget_simple_extent_dims(space, size, maxsize); - H5S_class_t space_type = H5Sget_simple_extent_type(space); - - /* setup */ - HDmemset(&buffer, 0, sizeof(h5tools_str_t)); - - HDmemset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; - - string_dataformat = *outputformat; - - if (fp_format) { - string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; - } - - if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; - string_dataformat.line_per_line = 1; - } - else - string_dataformat.line_ncols = h5tools_nCols; - - string_dataformat.do_escape = display_escape; - outputformat = &string_dataformat; - - ctx.indent_level++; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDataspace>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level++; - - switch (space_type) { - case H5S_SCALAR: - /* scalar dataspace (just a tag, no XML attrs. defined */ - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sScalarDataspace />",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; - - case H5S_SIMPLE: - /* simple dataspace */ - /* <hdf5:SimpleDataspace Ndims="nd"> */ - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sSimpleDataspace Ndims=\"%d\">",xmlnsprefix, ndims); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - /* print the <hdf5:Dimension> elements */ - ctx.indent_level++; - for (i = 0; i < ndims; i++) { - if (maxsize[i] == H5S_UNLIMITED) { - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDimension DimSize=\"%" H5_PRINTF_LL_WIDTH "u\" MaxDimSize=\"UNLIMITED\"/>", - xmlnsprefix,size[i]); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - else if (maxsize[i] == (hsize_t) 0) { - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDimension DimSize=\"%" H5_PRINTF_LL_WIDTH "u\" MaxDimSize=\"%" H5_PRINTF_LL_WIDTH "u\"/>", - xmlnsprefix,size[i], size[i]); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - else { - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDimension DimSize=\"%" H5_PRINTF_LL_WIDTH "u\" MaxDimSize=\"%" H5_PRINTF_LL_WIDTH "u\"/>", - xmlnsprefix, size[i], maxsize[i]); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - } - ctx.indent_level--; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sSimpleDataspace>", xmlnsprefix ); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; - -#ifdef TMP - /* Commented out: wait until the schema is updated first */ - case H5S_NULL: - /* null dataspace (just a tag, no XML attrs. defined */ - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNullDataspace />",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; -#endif /* TMP */ - - case H5S_NULL: - case H5S_NO_CLASS: - default: - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<!-- unknown dataspace -->"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - - ctx.indent_level--; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sDataspace>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level--; - - h5tools_str_close(&buffer); -} - -/*------------------------------------------------------------------------- - * Function: xml_dump_data - * - * Purpose: Dump description of data in XML. - * Note that this calls the h5dump_xxx calls in - * the h5tools library. - * - * Return: void - * - * Programmer: REMcG - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -void -xml_dump_data(hid_t obj_id, int obj_data, struct subset_t H5_ATTR_UNUSED * sset, int H5_ATTR_UNUSED pindex) -{ - hid_t space = -1; - hid_t type = -1; - hid_t p_type = -1; - hsize_t size[64]; - hsize_t nelmts = 1; - int ndims; - int i; - int status = -1; - void *buf = NULL; - hsize_t curr_pos = 0; /* total data element position */ - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &xml_dataformat; - h5tool_format_t string_dataformat; - - HDmemset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; - - /* Print all the values. */ - /* setup */ - HDmemset(&buffer, 0, sizeof(h5tools_str_t)); - - string_dataformat = *outputformat; - - if (fp_format) { - string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; - } - - if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; - string_dataformat.line_per_line = 1; - } - else - string_dataformat.line_ncols = h5tools_nCols; - string_dataformat.cmpd_sep = " "; - string_dataformat.cmpd_pre = ""; - string_dataformat.cmpd_suf = ""; - string_dataformat.cmpd_end = ""; - string_dataformat.arr_linebreak = 0; - string_dataformat.arr_pre = ""; - outputformat = &string_dataformat; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sData>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level++; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level--; - - dump_indent += COL; - ctx.indent_level++; - - if (obj_data == DATASET_DATA) { - type = H5Dget_type(obj_id); - if (H5Tget_class(type) == H5T_REFERENCE) - status = xml_print_refs(obj_id, DATASET_DATA); - else if (H5Tget_class(type) == H5T_STRING) - status = xml_print_strs(obj_id, DATASET_DATA); - else { - h5tools_context_t datactx; - HDmemset(&datactx, 0, sizeof(datactx)); - datactx.need_prefix = TRUE; - datactx.indent_level = ctx.indent_level; - datactx.cur_column = ctx.cur_column; - status = h5tools_dump_dset(rawoutstream, outputformat, &datactx, obj_id, NULL); - } - } - else { - /* Attribute data */ - type = H5Aget_type(obj_id); - - if (H5Tget_class(type) == H5T_REFERENCE) { - /* references are done differently than - the standard output: - XML dumps a path to the object - referenced. - */ - status = xml_print_refs(obj_id, ATTRIBUTE_DATA); - H5Tclose(type); - } - else if (H5Tget_class(type) == H5T_STRING) { - status = xml_print_strs(obj_id, ATTRIBUTE_DATA); - } - else { /* all other data */ - /* VL data special information */ - unsigned int vl_data = 0; /* contains VL datatypes */ - - p_type = h5tools_get_native_type(type); - - /* Check if we have VL data in the dataset's datatype */ - if (h5tools_detect_vlen(p_type) == TRUE) - vl_data = TRUE; - - H5Tclose(type); - - space = H5Aget_space(obj_id); - - ndims = H5Sget_simple_extent_dims(space, size, NULL); - - for (i = 0; i < ndims; i++) - nelmts *= size[i]; - - buf = HDmalloc((size_t)(nelmts * MAX(H5Tget_size(type), H5Tget_size(p_type)))); - HDassert(buf); - - if (H5Aread(obj_id, p_type, buf) >= 0) { - h5tools_context_t datactx; - HDmemset(&datactx, 0, sizeof(datactx)); - datactx.need_prefix = TRUE; - datactx.indent_level = ctx.indent_level; - datactx.cur_column = ctx.cur_column; - status = h5tools_dump_mem(rawoutstream, outputformat, &datactx, obj_id, p_type, space, buf); - } - /* Reclaim any VL memory, if necessary */ - if (vl_data) - H5Dvlen_reclaim(p_type, space, H5P_DEFAULT, buf); - - HDfree(buf); - H5Tclose(p_type); - H5Sclose(space); - H5Tclose(type); - } - } - - if (status == FAIL) { - ctx.indent_level++; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "Unable to print data."); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level--; - - status = 1; - } - ctx.indent_level--; - dump_indent -= COL; - - ctx.indent_level++; - - ctx.need_prefix = TRUE; - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sDataFromFile>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level--; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sData>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - h5tools_str_close(&buffer); -} - -/*------------------------------------------------------------------------- - * Function: xml_dump_attr - * - * Purpose: Dump a description of an HDF5 attribute in XML. - * - * Return: herr_t - * - * Programmer: REMcG - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -herr_t -xml_dump_attr(hid_t attr, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *info, - void H5_ATTR_UNUSED * op_data) -{ - hid_t attr_id = -1; - hid_t type = -1; - hid_t space = -1; - H5S_class_t space_type; - hsize_t curr_pos = 0; /* total data element position */ - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &xml_dataformat; - h5tool_format_t string_dataformat; - - char *t_aname = xml_escape_the_name(attr_name); - - /* setup */ - HDmemset(&buffer, 0, sizeof(h5tools_str_t)); - - HDmemset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; - - string_dataformat = *outputformat; - - if (fp_format) { - string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; - } - - if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; - string_dataformat.line_per_line = 1; - } - else - string_dataformat.line_ncols = h5tools_nCols; - - string_dataformat.do_escape = display_escape; - outputformat = &string_dataformat; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sAttribute Name=\"%s\">", xmlnsprefix, t_aname); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - HDfree(t_aname); - - if ((attr_id = H5Aopen(attr, attr_name, H5P_DEFAULT)) >= 0) { - type = H5Aget_type(attr_id); - space = H5Aget_space(attr_id); - space_type = H5Sget_simple_extent_type(space); - - dump_function_table->dump_dataspace_function(space); - dump_function_table->dump_datatype_function(type); - - ctx.indent_level++; - dump_indent += COL; - - if (display_attr_data && space_type != H5S_NULL) { - switch (H5Tget_class(type)) { - case H5T_INTEGER: - case H5T_FLOAT: - case H5T_STRING: - case H5T_BITFIELD: - case H5T_OPAQUE: - case H5T_ENUM: - case H5T_ARRAY: - dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0); - break; - - case H5T_TIME: - ctx.indent_level++; - dump_indent += COL; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sData>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<!-- Time data not yet implemented. -->"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNoData/>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<hdf5:Data>"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sData>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level--; - dump_indent -= COL; - break; - - case H5T_COMPOUND: - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<!-- Note: format of compound data not specified -->"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0); - break; - - case H5T_REFERENCE: - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sData>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - if (!H5Tequal(type, H5T_STD_REF_OBJ)) { - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<!-- Note: Region references not supported -->"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - else { - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - xml_print_refs(attr_id, ATTRIBUTE_DATA); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sDataFromFile>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sData>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; - - case H5T_VLEN: - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<!-- Note: format of VL data not specified -->"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - dump_function_table->dump_data_function(attr_id, ATTRIBUTE_DATA, NULL, 0); - break; - case H5T_NO_CLASS: - case H5T_NCLASSES: - HDassert(0); - /* fall through */ - default: - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sData>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<!-- Unknown datatype: %d -->", H5Tget_class(type)); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNoData/>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sData>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; - } - } - else { - /* The case of an attribute never yet written ?? - * Or dataspace is H5S_NULL. */ - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sData>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level++; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNoData/>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level--; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sData>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - ctx.indent_level--; - dump_indent -= COL; - - H5Tclose(type); - H5Sclose(space); - H5Aclose(attr_id); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sAttribute>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - h5tools_str_close(&buffer); - return SUCCEED; - } - else { - /* ?? failed */ - ctx.indent_level++; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<!-- h5dump error: unable to open attribute. -->"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level--; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sAttribute>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - h5tools_str_close(&buffer); - - h5tools_setstatus(EXIT_FAILURE); - return FAIL; - } -} - -/*------------------------------------------------------------------------- - * Function: xml_dump_named_datatype - * - * Purpose: Dump a description of an HDF5 NDT in XML. - * - * Return: herr_t - * - * Programmer: REMcG - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -void -xml_dump_named_datatype(hid_t type, const char *name) -{ - hsize_t curr_pos = 0; /* total data element position */ - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &xml_dataformat; - h5tool_format_t string_dataformat; - char *tmp; - char *dtxid; - char *parentxid; - char *t_tmp; - char *t_prefix; - char *t_name; - - tmp = (char *)HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2); - HDstrcpy(tmp, prefix); - HDstrcat(tmp, "/"); - HDstrcat(tmp, name); - - /* setup */ - HDmemset(&buffer, 0, sizeof(h5tools_str_t)); - - HDmemset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; - - string_dataformat = *outputformat; - - if (fp_format) { - string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; - } - - if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; - string_dataformat.line_per_line = 1; - } - else - string_dataformat.line_ncols = h5tools_nCols; - - string_dataformat.do_escape = display_escape; - outputformat = &string_dataformat; - - dtxid = (char *)HDmalloc((size_t)100); - parentxid = (char *)HDmalloc((size_t)100); - t_tmp = xml_escape_the_name(tmp); - t_prefix = xml_escape_the_name(prefix); - t_name = xml_escape_the_name(name); - - xml_name_to_XID(tmp, dtxid, 100, 1); - xml_name_to_XID(prefix, parentxid, 100, 1); - if(HDstrncmp(name, "#", (size_t)1) == 0) { - /* Special: this is an 'anonymous' NDT, deleted but - still in use. - We follow the dumper's undocumented practice, and - use its object id as its name. - Exactly the same as normal, but a separate case - in the event we want to do something else in - the future. - */ - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNamedDataType Name=\"%s\" OBJ-XID=\"%s\" " - "Parents=\"%s\" H5ParentPaths=\"%s\">", - xmlnsprefix, - name, dtxid, - parentxid, HDstrcmp(prefix,"") ? t_prefix : "/"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - else { - H5O_info_t oinfo; /* Object info */ - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNamedDataType Name=\"%s\" OBJ-XID=\"%s\" " - "H5Path=\"%s\" Parents=\"%s\" H5ParentPaths=\"%s\">", - xmlnsprefix, - t_name, dtxid, - t_tmp, parentxid, (HDstrcmp(prefix, "") ? t_prefix : "/")); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - /* Check uniqueness of named datatype */ - H5Oget_info(type, &oinfo); - if(oinfo.rc > 1) { - obj_t *found_obj; /* Found object */ - - /* Group with more than one link to it... */ - found_obj = search_obj(type_table, oinfo.addr); - - if (found_obj == NULL) { - indentation(dump_indent); - error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - else if(found_obj->displayed) { - /* We have already printed this named datatype, print it as a - * NamedDatatypePtr - */ - char pointerxid[100]; - char *t_objname = xml_escape_the_name(found_obj->objname); - - ctx.indent_level++; - - xml_name_to_XID(found_obj->objname, pointerxid, (int)sizeof(pointerxid), 1); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNamedDatatypePtr OBJ-XID=\"%s\" H5Path=\"%s\"/>", xmlnsprefix, pointerxid, t_objname); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level--; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sNamedDataType>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - HDfree(t_objname); - goto done; - } - else - found_obj->displayed = TRUE; - } - } - - ctx.indent_level++; - dump_indent += COL; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDataType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level++; - dump_indent += COL; - xml_print_datatype(type,1); - ctx.indent_level--; - dump_indent -= COL; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sDataType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level--; - dump_indent -= COL; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sNamedDataType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - -done: - - h5tools_str_close(&buffer); - - HDfree(dtxid); - HDfree(parentxid); - HDfree(t_tmp); - HDfree(t_prefix); - HDfree(t_name); - HDfree(tmp); -} - -/*------------------------------------------------------------------------- - * Function: xml_dump_group - * - * Purpose: Dump a description of an HDF5 Group (and its members) in XML. - * - * Return: void - * - * Programmer: REMcG - * - * Modifications: - * Pedro Vicente, October 9, 2007 - * added parameters to H5A(L)iterate to allow for other iteration orders - * - *------------------------------------------------------------------------- - */ -void -xml_dump_group(hid_t gid, const char *name) -{ - H5O_info_t oinfo; - hid_t gcpl_id; - hid_t dset, type; - unsigned crt_order_flags; - unsigned attr_crt_order_flags; - int isRoot = 0; - char type_name[1024]; - char *t_objname = NULL; - char *par_name = NULL; - char *cp = NULL; - char *tmp = NULL; - char *par = NULL; - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &xml_dataformat; - h5tool_format_t string_dataformat; - hsize_t curr_pos = 0; /* total data element position */ - - if ((gcpl_id = H5Gget_create_plist(gid)) < 0) { - error_msg("error in getting group creation property list ID\n"); - h5tools_setstatus(EXIT_FAILURE); - } - - /* query the group creation properties for attributes */ - if (H5Pget_attr_creation_order(gcpl_id, &attr_crt_order_flags) < 0) { - error_msg("error in getting group creation properties\n"); - h5tools_setstatus(EXIT_FAILURE); - } - - /* query the group creation properties */ - if(H5Pget_link_creation_order(gcpl_id, &crt_order_flags) < 0) { - error_msg("error in getting group creation properties\n"); - h5tools_setstatus(EXIT_FAILURE); - } - - if(H5Pclose(gcpl_id) < 0) { - error_msg("error in closing group creation property list ID\n"); - h5tools_setstatus(EXIT_FAILURE); - } - - /* setup */ - HDmemset(&buffer, 0, sizeof(h5tools_str_t)); - - HDmemset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; - - string_dataformat = *outputformat; - - if (fp_format) { - string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; - } - - if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; - string_dataformat.line_per_line = 1; - } - else - string_dataformat.line_ncols = h5tools_nCols; - - string_dataformat.do_escape = display_escape; - outputformat = &string_dataformat; - - if(HDstrcmp(name, "/") == 0) { - isRoot = 1; - tmp = HDstrdup("/"); - } - else { - tmp = (char *)HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2); - HDstrcpy(tmp, prefix); - par = HDstrdup(tmp); - cp = HDstrrchr(par, '/'); - if(cp) { - if((cp == par) && HDstrlen(par) > 1) - *(cp + 1) = '\0'; - else - *cp = '\0'; - } - } - - H5Oget_info(gid, &oinfo); - - if(oinfo.rc > 1) { - obj_t *found_obj; /* Found object */ - - /* Group with more than one link to it... */ - found_obj = search_obj(group_table, oinfo.addr); - - if (found_obj == NULL) { - indentation(dump_indent); - error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__); - h5tools_setstatus(EXIT_FAILURE); - } - else { - char *t_name = xml_escape_the_name(name); - char *grpxid = (char *)HDmalloc((size_t)100); - char *parentxid = (char *)HDmalloc((size_t)100); - - if(found_obj->displayed) { - char *ptrstr = (char *)HDmalloc((size_t)100); - - /* already seen: enter a groupptr */ - if(isRoot) { - /* probably can't happen! */ - xml_name_to_XID("/", grpxid, 100, 1); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sRootGroup OBJ-XID=\"%s\" H5Path=\"%s\">", - xmlnsprefix, grpxid, "/"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - else { - t_objname = xml_escape_the_name(found_obj->objname); - par_name = xml_escape_the_name(par); - xml_name_to_XID(tmp, grpxid, 100, 1); - xml_name_to_XID(par, parentxid, 100, 1); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sGroup Name=\"%s\" OBJ-XID=\"%s-%d\" H5Path=\"%s\" " - "Parents=\"%s\" H5ParentPaths=\"%s\">", - xmlnsprefix,t_name, grpxid, get_next_xid(), - t_objname, parentxid, par_name); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - HDfree(t_objname); - HDfree(par_name); - - ctx.indent_level++; - - t_objname = xml_escape_the_name(found_obj->objname);/* point to the NDT by name */ - par_name = xml_escape_the_name(par); - xml_name_to_XID(found_obj->objname, ptrstr, 100, 1); - xml_name_to_XID(par, parentxid, 100, 1); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sGroupPtr OBJ-XID=\"%s\" H5Path=\"%s\" " - "Parents=\"%s\" H5ParentPaths=\"%s\" />", - xmlnsprefix, - ptrstr, t_objname, parentxid, par_name); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level--; - - HDfree(t_objname); - HDfree(par_name); - } - HDfree(ptrstr); - } - else { - - /* first time this group has been seen -- describe it */ - if(isRoot) { - xml_name_to_XID("/", grpxid, 100, 1); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sRootGroup OBJ-XID=\"%s\" H5Path=\"%s\">", - xmlnsprefix, grpxid, "/"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - else { - char *t_tmp = xml_escape_the_name(tmp); - - par_name = xml_escape_the_name(par); - xml_name_to_XID(tmp, grpxid, 100, 1); - xml_name_to_XID(par, parentxid, 100, 1); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sGroup Name=\"%s\" OBJ-XID=\"%s\" H5Path=\"%s\" " - "Parents=\"%s\" H5ParentPaths=\"%s\" >", - xmlnsprefix,t_name, grpxid, t_tmp, parentxid, par_name); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - HDfree(t_tmp); - HDfree(par_name); - } - found_obj->displayed = TRUE; - - /* 1. do all the attributes of the group */ - - ctx.indent_level++; - dump_indent += COL; - - if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) { - if(H5Aiterate2(gid, sort_by, sort_order, NULL, dump_function_table->dump_attribute_function, NULL) < 0) { - error_msg("error getting attribute information\n"); - h5tools_setstatus(EXIT_FAILURE); - } /* end if */ - } /* end if */ - else { - if(H5Aiterate2(gid, H5_INDEX_NAME, sort_order, NULL, dump_function_table->dump_attribute_function, NULL) < 0) { - error_msg("error getting attribute information\n"); - h5tools_setstatus(EXIT_FAILURE); - } /* end if */ - } /* end else */ - - if(isRoot && unamedtype) { - unsigned u; - - /* Very special case: dump unamed type in root group */ - for(u = 0; u < type_table->nobjs; u++) { - if(!type_table->objs[u].recorded) { - dset = H5Dopen2(gid, type_table->objs[u].objname, H5P_DEFAULT); - type = H5Dget_type(dset); - sprintf(type_name, "#"H5_PRINTF_HADDR_FMT, type_table->objs[u].objno); - dump_function_table->dump_named_datatype_function(type, type_name); - H5Tclose(type); - H5Dclose(dset); - } - } - } - - /* iterate through all the links */ - - if((sort_by == H5_INDEX_CRT_ORDER) && (crt_order_flags & H5P_CRT_ORDER_TRACKED)) - H5Literate(gid, sort_by, sort_order, NULL, xml_dump_all_cb, NULL); - else - H5Literate(gid, H5_INDEX_NAME, sort_order, NULL, xml_dump_all_cb, NULL); - - dump_indent -= COL; - ctx.indent_level--; - } - HDfree(t_name); - HDfree(grpxid); - HDfree(parentxid); - } - } - else { - /* only link -- must be first time! */ - char *t_name = xml_escape_the_name(name); - char *grpxid = (char *)HDmalloc((size_t)100); - char *parentxid = (char *)HDmalloc((size_t)100); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - - if(isRoot) { - xml_name_to_XID("/", grpxid, 100, 1); - h5tools_str_append(&buffer, "<%sRootGroup OBJ-XID=\"%s\" H5Path=\"%s\">", xmlnsprefix, grpxid, "/"); - } - else { - char *t_tmp = xml_escape_the_name(tmp); - - par_name = xml_escape_the_name(par); - xml_name_to_XID(tmp, grpxid, 100, 1); - xml_name_to_XID(par, parentxid, 100, 1); - h5tools_str_append(&buffer, "<%sGroup Name=\"%s\" OBJ-XID=\"%s\" H5Path=\"%s\" " - "Parents=\"%s\" H5ParentPaths=\"%s\" >", - xmlnsprefix, t_name, grpxid, t_tmp, parentxid, par_name); - HDfree(t_tmp); - HDfree(par_name); - } - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - HDfree(t_name); - HDfree(grpxid); - HDfree(parentxid); - - /* 1. do all the attributes of the group */ - - ctx.indent_level++; - dump_indent += COL; - - if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) { - if(H5Aiterate2(gid, sort_by, sort_order, NULL, dump_function_table->dump_attribute_function, NULL) < 0) { - error_msg("error getting attribute information\n"); - h5tools_setstatus(EXIT_FAILURE); - } /* end if */ - } /* end if */ - else { - if(H5Aiterate2(gid, H5_INDEX_NAME, sort_order, NULL, dump_function_table->dump_attribute_function, NULL) < 0) { - error_msg("error getting attribute information\n"); - h5tools_setstatus(EXIT_FAILURE); - } /* end if */ - } /* end else */ - - if(isRoot && unamedtype) { - unsigned u; - - /* Very special case: dump unamed type in root group */ - for(u = 0; u < type_table->nobjs; u++) { - if(!type_table->objs[u].recorded) { - dset = H5Dopen2(gid, type_table->objs[u].objname, H5P_DEFAULT); - type = H5Dget_type(dset); - sprintf(type_name, "#"H5_PRINTF_HADDR_FMT, type_table->objs[u].objno); - dump_function_table->dump_named_datatype_function(type, type_name); - H5Tclose(type); - H5Dclose(dset); - } - } - } - - /* iterate through all the links */ - - if((sort_by == H5_INDEX_CRT_ORDER) && (crt_order_flags & H5P_CRT_ORDER_TRACKED)) - H5Literate(gid, sort_by, sort_order, NULL, xml_dump_all_cb, NULL); - else - H5Literate(gid, H5_INDEX_NAME, sort_order, NULL, xml_dump_all_cb, NULL); - - dump_indent -= COL; - ctx.indent_level--; - } - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - if(isRoot) - h5tools_str_append(&buffer, "</%sRootGroup>", xmlnsprefix); - else - h5tools_str_append(&buffer, "</%sGroup>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - h5tools_str_close(&buffer); - - if(par) - HDfree(par); - if(tmp) - HDfree(tmp); -} - -/*------------------------------------------------------------------------- - * Function: xml_print_refs - * - * Purpose: Print a path to the objects referenced by HDF5 Referneces. - * - * Return: void - * - * Programmer: REMcG - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static int -xml_print_refs(hid_t did, int source) -{ - herr_t e; - hid_t type = -1; - hid_t space = -1; - hssize_t ssiz = -1; - hsize_t i; - size_t tsiz; - hobj_ref_t *refbuf = NULL; - char *buf = NULL; - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &xml_dataformat; - h5tool_format_t string_dataformat; - hsize_t curr_pos = 0; /* total data element position */ - - if (source == DATASET_DATA) { - type = H5Dget_type(did); - } - else if (source == ATTRIBUTE_DATA) { - type = H5Aget_type(did); - } - else { - /* return an error */ - return FAIL; - } - if (H5Tget_class(type) != H5T_REFERENCE) { - /* return an error */ - goto error; - } - if (!H5Tequal(type, H5T_STD_REF_OBJ)) { - /* region ref not supported yet... */ - /* return an error */ - goto error; - } - if (source == DATASET_DATA) { - space = H5Dget_space(did); - if ((ssiz = H5Sget_simple_extent_npoints(space)) < 0) - goto error; - if ((tsiz = H5Tget_size(type)) == 0) - goto error; - - buf = (char *) HDcalloc((size_t)ssiz, tsiz); - if (buf == NULL) - goto error; - e = H5Dread(did, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); - /* need to check result here */ - if (e < 0) - goto error; - } - else if (source == ATTRIBUTE_DATA) { - space = H5Aget_space(did); - if ((ssiz = H5Sget_simple_extent_npoints(space)) < 0) - goto error; - if ((tsiz = H5Tget_size(type)) == 0) - goto error; - - buf = (char *) HDcalloc((size_t)ssiz, tsiz); - if (buf == NULL) - goto error; - e = H5Aread(did, H5T_STD_REF_OBJ, buf); - /* need to check the result here */ - if (e < 0) - goto error; - } - - refbuf = (hobj_ref_t *) buf; - - /* setup */ - HDmemset(&buffer, 0, sizeof(h5tools_str_t)); - - HDmemset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; - - string_dataformat = *outputformat; - - if (fp_format) { - string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; - } - - if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; - string_dataformat.line_per_line = 1; - } - else - string_dataformat.line_ncols = h5tools_nCols; - - string_dataformat.do_escape = display_escape; - outputformat = &string_dataformat; - - for (i = 0; i < (hsize_t)ssiz; i++) { - const char *path = lookup_ref_path(*refbuf); - ctx.indent_level++; - - if (!path) { - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "\"%s\"", "NULL"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - else { - char *t_path = xml_escape_the_string(path, -1); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "\"%s\"", t_path); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - HDfree(t_path); - } - ctx.indent_level--; - - refbuf++; - } - - h5tools_str_close(&buffer); - - HDfree(buf); - H5Tclose(type); - H5Sclose(space); - return SUCCEED; - -error: - if(buf) - HDfree(buf); - - H5E_BEGIN_TRY { - H5Tclose(type); - H5Sclose(space); - } H5E_END_TRY; - return FAIL; -} - -/*------------------------------------------------------------------------- - * Function: xml_print_strs - * - * Purpose: Print strings. - * - * Return: void - * - * Programmer: REMcG - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static int -xml_print_strs(hid_t did, int source) -{ - herr_t e; - hid_t type = -1; - hid_t space = -1; - hssize_t ssiz = -1; - htri_t is_vlstr = FALSE; - size_t tsiz = 0; - hsize_t i; - size_t str_size = 0; - char *bp = NULL; - char *onestring = NULL; - void *buf = NULL; - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &xml_dataformat; - h5tool_format_t string_dataformat; - hsize_t curr_pos = 0; /* total data element position */ - - if (source == DATASET_DATA) - type = H5Dget_type(did); - else if (source == ATTRIBUTE_DATA) - type = H5Aget_type(did); - else - /* return an error */ - return FAIL; - if (H5Tget_class(type) != H5T_STRING) - /* return an error */ - goto error; - /* Check if we have VL data in the dataset's datatype */ - is_vlstr = H5Tis_variable_str(type); - - if (source == DATASET_DATA) { - space = H5Dget_space(did); - if((ssiz = H5Sget_simple_extent_npoints(space)) < 0) - goto error; - if((tsiz = H5Tget_size(type)) == 0) - goto error; - - buf = HDmalloc((size_t)ssiz * tsiz); - if (buf == NULL) - goto error; - - e = H5Dread(did, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); - if (e < 0) - goto error; - } - else if (source == ATTRIBUTE_DATA) { - space = H5Aget_space(did); - if((ssiz = H5Sget_simple_extent_npoints(space)) < 0) - goto error; - if((tsiz = H5Tget_size(type)) == 0) - goto error; - - buf = HDmalloc((size_t)ssiz * tsiz); - if (buf == NULL) - goto error; - - e = H5Aread(did, type, buf); - if (e < 0) - goto error; - } - - bp = (char*) buf; - if (!is_vlstr) - onestring = (char *) HDcalloc(tsiz, sizeof(char)); - - /* setup */ - HDmemset(&buffer, 0, sizeof(h5tools_str_t)); - - HDmemset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; - - string_dataformat = *outputformat; - - if (fp_format) { - string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; - } - - if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; - string_dataformat.line_per_line = 1; - } - else - string_dataformat.line_ncols = h5tools_nCols; - - string_dataformat.do_escape = display_escape; - outputformat = &string_dataformat; - - for (i = 0; i < (hsize_t)ssiz; i++) { - if (is_vlstr) { - onestring = *(char **) bp; - if (onestring) - str_size = HDstrlen(onestring); - } - else { - HDstrncpy(onestring, bp, tsiz); - str_size = tsiz; - } - - if (!onestring) { - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "NULL"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - else { - char *t_onestring = xml_escape_the_string(onestring, (int)str_size); - if (t_onestring) { - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "\"%s\"", t_onestring); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - HDfree(t_onestring); - } - } - bp += tsiz; - } - - h5tools_str_close(&buffer); - - /* Reclaim any VL memory, if necessary */ - if (!is_vlstr) - if (onestring) - HDfree(onestring); - if (buf) { - if (is_vlstr) - H5Dvlen_reclaim(type, space, H5P_DEFAULT, buf); - HDfree(buf); - } - H5Tclose(type); - H5Sclose(space); - return SUCCEED; - -error: - if(buf) - HDfree(buf); - - H5E_BEGIN_TRY { - H5Tclose(type); - H5Sclose(space); - } H5E_END_TRY; - return FAIL; -} - -/*------------------------------------------------------------------------- - * Function: check_filters - * - * Purpose: private function to check for the filters and - * put tags in the XML. - * - * Return: void - * - * Programmer: REMcG - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static void -check_filters(hid_t dcpl) -{ - int nfilt; - int i; - H5Z_filter_t filter; - char namebuf[120]; - size_t cd_nelmts = 20; - unsigned int cd_values[20]; - unsigned int flags; - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &xml_dataformat; - h5tool_format_t string_dataformat; - hsize_t curr_pos = 0; /* total data element position */ - - /* setup */ - HDmemset(&buffer, 0, sizeof(h5tools_str_t)); - - HDmemset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; - - string_dataformat = *outputformat; - - if (fp_format) { - string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; - } - - if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; - string_dataformat.line_per_line = 1; - } - else - string_dataformat.line_ncols = h5tools_nCols; - - string_dataformat.do_escape = display_escape; - outputformat = &string_dataformat; - - nfilt = H5Pget_nfilters(dcpl); - if (nfilt <= 0) - return; - for (i = 0; i < nfilt; i++) { - filter = H5Pget_filter2(dcpl, (unsigned) i, &flags, (size_t *) &cd_nelmts, cd_values, (size_t)120, namebuf, NULL); - if (filter == H5Z_FILTER_DEFLATE) { - ctx.indent_level++; - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDeflate Level=\"", xmlnsprefix); - if (cd_nelmts < 1) { - /* not sure what this means? */ - h5tools_str_append(&buffer, "6"); - } - else { - h5tools_str_append(&buffer, "%d", cd_values[0]); - } - h5tools_str_append(&buffer, "\"/>"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level--; - } - else if (filter == H5Z_FILTER_FLETCHER32) { - ctx.indent_level++; - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sFletcher32 />", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level--; - } - else if (filter == H5Z_FILTER_SHUFFLE) { - ctx.indent_level++; - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sShuffle />", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level--; - } - else if (filter == H5Z_FILTER_SZIP) { - ctx.indent_level++; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sSZIP ", xmlnsprefix); - if (cd_nelmts < 2) { - /* no pixels ? */ - h5tools_str_append(&buffer, "Pixels_per_block=\"-1\" "); - } - else { - h5tools_str_append(&buffer, "Pixels_per_block=\"%d\" ", cd_values[1]); - } - /* analyse the options mask */ - if (cd_values[0] & H5_SZIP_CHIP_OPTION_MASK) { - h5tools_str_append(&buffer, "Mode =\"Hardware\" "); - } - else if (cd_values[0] & H5_SZIP_ALLOW_K13_OPTION_MASK) { - h5tools_str_append(&buffer, "Mode =\"K13\" "); - } - h5tools_str_append(&buffer, "Coding=\""); - if (cd_values[0] & H5_SZIP_EC_OPTION_MASK) { - h5tools_str_append(&buffer, "Entropy"); - } - else if (cd_values[0] & H5_SZIP_NN_OPTION_MASK) { - h5tools_str_append(&buffer, "NN"); - } - h5tools_str_append(&buffer, "\" "); - - h5tools_str_append(&buffer, "ByteOrder=\""); - if (cd_values[0] & H5_SZIP_LSB_OPTION_MASK) { - h5tools_str_append(&buffer, "LSB"); - } - else if (cd_values[0] & H5_SZIP_MSB_OPTION_MASK) { - h5tools_str_append(&buffer, "MSB"); - } - h5tools_str_append(&buffer, "\" "); - - if (cd_values[0] & H5_SZIP_RAW_OPTION_MASK) { - h5tools_str_append(&buffer, "Header=\"Raw\""); - } - h5tools_str_append(&buffer, "/>"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level--; - } - else { - /* unknown option */ - } - } - - h5tools_str_close(&buffer); -} - -static void -xml_dump_fill_value(hid_t dcpl, hid_t type) -{ - size_t sz; - size_t i; - hsize_t space; - void *buf; - char *name; - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &xml_dataformat; - h5tool_format_t string_dataformat; - hsize_t curr_pos = 0; /* total data element position */ - - /* setup */ - HDmemset(&buffer, 0, sizeof(h5tools_str_t)); - - HDmemset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; - - string_dataformat = *outputformat; - - if (fp_format) { - string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; - } - - if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; - string_dataformat.line_per_line = 1; - } - else - string_dataformat.line_ncols = h5tools_nCols; - - string_dataformat.do_escape = display_escape; - outputformat = &string_dataformat; - - ctx.indent_level++; - dump_indent += COL; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sData>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level++; - dump_indent += COL; - - space = H5Tget_size(type); - buf = HDmalloc((size_t) space); - - H5Pget_fill_value(dcpl, type, buf); - - if (H5Tget_class(type) == H5T_REFERENCE) { - const char * path = lookup_ref_path(*(hobj_ref_t *) buf); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - if (!path) { - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "\"%s\"", "NULL"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - else { - char *t_path = xml_escape_the_string(path, -1); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "\"%s\"", t_path); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - HDfree(t_path); - } - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sDataFromFile>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - else if (H5Tget_class(type) == H5T_STRING) { - /* ????? */ - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<!-- String fill values not yet implemented. -->"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - else { - /* all other data */ - switch (H5Tget_class(type)) { - case H5T_INTEGER: - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "\"%d\"", *(int *) buf); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sDataFromFile>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; - case H5T_FLOAT: - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "\"%f\"", (double)*(float *)buf); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sDataFromFile>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; - case H5T_BITFIELD: - case H5T_OPAQUE: - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - sz = H5Tget_size(type); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "\""); - for (i = 0; i < sz; i++) { - h5tools_str_append(&buffer, "%x ", *(unsigned int *) buf); - buf = (char *) buf + sizeof(unsigned int); - } - h5tools_str_append(&buffer, "\""); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sDataFromFile>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; - case H5T_ENUM: - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - name = H5Tget_member_name(type, *(unsigned *) buf); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "\"%s\"", name); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - if(name) - H5free_memory(name); - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sDataFromFile>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; - case H5T_ARRAY: - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<!-- Array fill values not yet implemented. -->"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; - case H5T_TIME: - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<!-- Time fill not yet implemented. -->"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; - case H5T_COMPOUND: - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<!-- Compound fill not yet implemented. -->"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; - case H5T_VLEN: - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<!-- VL fill not yet implemented. -->"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; - case H5T_NO_CLASS: - case H5T_NCLASSES: - HDassert(0); - /* fall through */ - case H5T_STRING: - case H5T_REFERENCE: - default: - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<!-- Unknown fill datatype: %d -->", H5Tget_class(type)); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNoData/>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; - } - } - HDfree(buf); - ctx.indent_level--; - dump_indent -= COL; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sData>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level--; - dump_indent -= COL; - - h5tools_str_close(&buffer); -} - -/*------------------------------------------------------------------------- - * Function: xml_dump_dataset - * - * Purpose: Dump a description of an HDF5 dataset in XML. - * - * Return: void - * - * Programmer: REMcG - * - * Modifications: - * Pedro Vicente, October 9, 2007 - * added parameters to H5Aiterate2 to allow for other iteration orders - * - *------------------------------------------------------------------------- - */ -void -xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED * sset) -{ - hid_t type; - hid_t space; - hid_t dcpl; - H5D_fill_value_t fvstatus; - int maxdims; - hsize_t *chsize; - int ndims; - int i; - H5D_alloc_time_t at; - H5D_fill_time_t ft; - hsize_t tempi; - char *tmp; - char *t_name; - char *t_tmp; - char *t_prefix; - unsigned attr_crt_order_flags; - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &xml_dataformat; - h5tool_format_t string_dataformat; - hsize_t curr_pos = 0; /* total data element position */ - - char *rstr = (char*) HDmalloc((size_t)100); - char *pstr = (char*) HDmalloc((size_t)100); - - tmp = (char*) HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2); - HDstrcpy(tmp, prefix); - HDstrcat(tmp, "/"); - HDstrcat(tmp, name); - - /* setup */ - HDmemset(&buffer, 0, sizeof(h5tools_str_t)); - - HDmemset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; - - t_name = xml_escape_the_name(name); - t_tmp = xml_escape_the_name(tmp); - t_prefix = xml_escape_the_name(prefix); - - string_dataformat = *outputformat; - - if (fp_format) { - string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; - } - - if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; - string_dataformat.line_per_line = 1; - } - else - string_dataformat.line_ncols = h5tools_nCols; - - string_dataformat.do_escape = display_escape; - outputformat = &string_dataformat; - - xml_name_to_XID(tmp, rstr, 100, 1); - xml_name_to_XID(prefix, pstr, 100, 1); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDataset Name=\"%s\" OBJ-XID=\"%s\" H5Path= \"%s\" Parents=\"%s\" H5ParentPaths=\"%s\">", - xmlnsprefix, t_name, rstr, t_tmp, pstr, - strcmp(prefix, "") ? t_prefix : "/"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - HDfree(t_name); - HDfree(t_tmp); - HDfree(t_prefix); - HDfree(rstr); - HDfree(pstr); - HDfree(tmp); - - dcpl = H5Dget_create_plist(did); - type = H5Dget_type(did); - space = H5Dget_space(did); - - /* query the creation properties for attributes */ - H5Pget_attr_creation_order(dcpl, &attr_crt_order_flags); - - /* Print information about storage layout */ - if (H5D_CHUNKED == H5Pget_layout(dcpl)) { - maxdims = H5Sget_simple_extent_ndims(space); - HDassert(maxdims >= 0); - chsize = (hsize_t *)HDmalloc((size_t)maxdims * sizeof(hsize_t)); - ctx.indent_level++; - dump_indent += COL; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sStorageLayout>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level++; - dump_indent += COL; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sChunkedLayout ", xmlnsprefix); - ndims = H5Pget_chunk(dcpl, maxdims, chsize); - h5tools_str_append(&buffer, "Ndims=\"%d\">", ndims); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level++; - dump_indent += COL; - - for (i = 0; i < ndims; i++) { - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sChunkDimension DimSize=\"%" H5_PRINTF_LL_WIDTH "u\" />", xmlnsprefix, chsize[i]); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sRequiredFilter>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level++; - dump_indent += COL; - check_filters(dcpl); - ctx.indent_level--; - dump_indent -= COL; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sRequiredFilter>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level--; - dump_indent -= COL; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sChunkedLayout>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level--; - dump_indent -= COL; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sStorageLayout>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level--; - dump_indent -= COL; - HDfree(chsize); - } - else if (H5D_CONTIGUOUS == H5Pget_layout(dcpl)) { - ctx.indent_level++; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sStorageLayout>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level++; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sContiguousLayout/>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level--; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sStorageLayout>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level--; - } - else if (H5D_COMPACT == H5Pget_layout(dcpl)) { - ctx.indent_level++; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sStorageLayout>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level++; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sCompactLayout/>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level--; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sStorageLayout>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level--; - } - /* and check for external.... ?? */ - - /* fill value */ - - ctx.indent_level++; - dump_indent += COL; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sFillValueInfo ", xmlnsprefix); - H5Pget_fill_time(dcpl, &ft); - h5tools_str_append(&buffer, "FillTime=\""); - switch (ft) { - case H5D_FILL_TIME_ALLOC: - h5tools_str_append(&buffer, "FillOnAlloc"); - break; - case H5D_FILL_TIME_NEVER: - h5tools_str_append(&buffer, "FillNever"); - break; - case H5D_FILL_TIME_IFSET: - h5tools_str_append(&buffer, "FillIfSet"); - break; - case H5D_FILL_TIME_ERROR: - HDassert(0); - /* fall through */ - default: - h5tools_str_append(&buffer, "?"); - break; - } /* end switch */ - h5tools_str_append(&buffer, "\" "); - H5Pget_alloc_time(dcpl, &at); - h5tools_str_append(&buffer, "AllocationTime=\""); - switch (at) { - case H5D_ALLOC_TIME_EARLY: - h5tools_str_append(&buffer, "Early"); - break; - case H5D_ALLOC_TIME_INCR: - h5tools_str_append(&buffer, "Incremental"); - break; - case H5D_ALLOC_TIME_LATE: - h5tools_str_append(&buffer, "Late"); - break; - case H5D_ALLOC_TIME_DEFAULT: - case H5D_ALLOC_TIME_ERROR: - HDassert(0); - /* fall through */ - default: - h5tools_str_append(&buffer, "?"); - break; - } /* end switch */ - h5tools_str_append(&buffer, "\""); - h5tools_str_append(&buffer, ">"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level++; - dump_indent += COL; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sFillValue>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - H5Pfill_value_defined(dcpl, &fvstatus); - if (fvstatus == H5D_FILL_VALUE_UNDEFINED || (fvstatus == H5D_FILL_VALUE_DEFAULT && ft == H5D_FILL_TIME_IFSET)) { - ctx.indent_level++; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNoFill/>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level--; - } - else { - xml_dump_fill_value(dcpl, type); - } - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sFillValue>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level--; - dump_indent -= COL; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sFillValueInfo>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level--; - dump_indent -= COL; - - dump_function_table->dump_dataspace_function(space); - dump_function_table->dump_datatype_function(type); - - ctx.indent_level++; - dump_indent += COL; - - if ((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) { - if (H5Aiterate2(did, sort_by, sort_order, NULL, dump_function_table->dump_attribute_function, NULL) < 0) { - error_msg("error getting attribute information\n"); - h5tools_setstatus(EXIT_FAILURE); - } /* end if */ - } /* end if */ - else { - if (H5Aiterate2(did, H5_INDEX_NAME, sort_order, NULL, dump_function_table->dump_attribute_function, NULL) < 0) { - error_msg("error getting attribute information\n"); - h5tools_setstatus(EXIT_FAILURE); - } /* end if */ - } /* end else */ - - ctx.indent_level--; - dump_indent -= COL; - tempi = H5Dget_storage_size(did); - - if (display_data && (tempi > 0)) { - switch (H5Tget_class(type)) { - case H5T_INTEGER: - case H5T_FLOAT: - case H5T_STRING: - case H5T_BITFIELD: - case H5T_OPAQUE: - case H5T_ENUM: - case H5T_ARRAY: - ctx.indent_level++; - dump_indent += COL; - dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0); - ctx.indent_level--; - dump_indent -= COL; - break; - - case H5T_TIME: - ctx.indent_level++; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sData>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<!-- Time data not yet implemented. -->"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sData>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level--; - break; - - case H5T_COMPOUND: - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<!-- Note: format of compound data not specified -->"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level++; - dump_indent += COL; - dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0); - ctx.indent_level--; - dump_indent -= COL; - break; - - case H5T_REFERENCE: - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sData>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - if (!H5Tequal(type, H5T_STD_REF_OBJ)) { - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<!-- Note: Region references not supported -->"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNoData />", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - else { - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDataFromFile>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - xml_print_refs(did, DATASET_DATA); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sDataFromFile>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sData>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; - - case H5T_VLEN: - ctx.indent_level--; - dump_indent -= COL; - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<!-- Note: format of VL data not specified -->"); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level++; - dump_indent += COL; - - ctx.indent_level++; - dump_indent += COL; - dump_function_table->dump_data_function(did, DATASET_DATA, NULL, 0); - ctx.indent_level--; - dump_indent -= COL; - break; - case H5T_NO_CLASS: - case H5T_NCLASSES: - HDassert(0); - /* fall through */ - - default: - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sData>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<!-- Unknown datatype: %d -->", H5Tget_class(type)); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNoData/>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sData>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - break; - } - } - else { - /* no data written */ - ctx.indent_level++; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sData>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level++; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sNoData/>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level--; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sData>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level--; - } - - H5Tclose(type); - H5Sclose(space); - H5Pclose(dcpl); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sDataset>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - h5tools_str_close(&buffer); -} - -/*------------------------------------------------------------------------- - * Function: xml_print_enum - * - * Purpose: Print the values of an HDF5 ENUM in XML. - * Very similar to regular DDL output. - * - * Return: void - * - * Programmer: REMcG - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static void -xml_print_enum(hid_t type) -{ - char **name = NULL; /*member names */ - unsigned char *value = NULL; /*value array */ - unsigned nmembs; /*number of members */ - hid_t super; /*enum base integer type */ - hid_t native = -1; /*native integer datatype */ - size_t dst_size; /*destination value type size */ - unsigned i; /*miscellaneous counters */ - size_t j; - h5tools_str_t buffer; /* string into which to render */ - h5tools_context_t ctx; /* print context */ - h5tool_format_t *outputformat = &xml_dataformat; - h5tool_format_t string_dataformat; - hsize_t curr_pos = 0; /* total data element position */ - - /* setup */ - HDmemset(&buffer, 0, sizeof(h5tools_str_t)); - - HDmemset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = dump_indent / COL; - ctx.cur_column = dump_indent; - - string_dataformat = *outputformat; - - if (fp_format) { - string_dataformat.fmt_double = fp_format; - string_dataformat.fmt_float = fp_format; - } - - if (h5tools_nCols == 0) { - string_dataformat.line_ncols = 65535; - string_dataformat.line_per_line = 1; - } - else - string_dataformat.line_ncols = h5tools_nCols; - - string_dataformat.do_escape = display_escape; - outputformat = &string_dataformat; - - nmembs = (unsigned)H5Tget_nmembers(type); - super = H5Tget_super(type); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sDataType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - xml_print_datatype(super,0); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sDataType>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - /* - * Determine what datatype to use for the native values. To simplify - * things we entertain three possibilities: - * 1. long long -- the largest native signed integer - * 2. unsigned long long -- the largest native unsigned integer - * 3. raw format - */ - if (H5Tget_size(type) <= sizeof(long long)) { - dst_size = sizeof(long long); - - if (H5T_SGN_NONE == H5Tget_sign(type)) { - native = H5T_NATIVE_ULLONG; - } - else { - native = H5T_NATIVE_LLONG; - } - } - else { - dst_size = H5Tget_size(type); - } - - /* Get the names and raw values of all members */ - name = (char **)HDcalloc((size_t)nmembs, sizeof(char *)); - value = (unsigned char *)HDcalloc((size_t)nmembs, MAX(H5Tget_size(type), dst_size)); - - for (i = 0; i < nmembs; i++) { - name[i] = H5Tget_member_name(type, i); - H5Tget_member_value(type, i, value + i * H5Tget_size(type)); - } - - /* Convert values to native datatype */ - if (native > 0) - H5Tconvert(super, native, (size_t)nmembs, value, NULL, H5P_DEFAULT); - - /* Sort members by increasing value */ - /*not implemented yet */ - - /* Print members */ - ctx.indent_level++; - dump_indent += COL; - for (i = 0; i < nmembs; i++) { - char *t_name = xml_escape_the_name(name[i]); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sEnumElement>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level++; - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s", t_name); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - HDfree(t_name); - ctx.indent_level--; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sEnumElement>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sEnumValue>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level++; - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - if (native < 0) { - h5tools_str_append(&buffer, "0x"); - - for (j = 0; j < dst_size; j++) - h5tools_str_append(&buffer, "%02x", value[i * dst_size + j]); - } - else if (H5T_SGN_NONE == H5Tget_sign(native)) { - h5tools_str_append(&buffer,"%" H5_PRINTF_LL_WIDTH "u", *((unsigned long long *) - ((void *) (value + i * dst_size)))); - } - else { - h5tools_str_append(&buffer,"%" H5_PRINTF_LL_WIDTH "d", - *((long long *) ((void *) (value + i * dst_size)))); - } - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level--; - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "</%sEnumValue>",xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - ctx.indent_level--; - dump_indent -= COL; - - h5tools_str_close(&buffer); - - /* Release resources */ - for (i = 0; i < nmembs; i++) - H5free_memory(name[i]); - - HDfree(name); - HDfree(value); - H5Tclose(super); -} - diff --git a/tools/h5dump/h5dump_xml.h b/tools/h5dump/h5dump_xml.h deleted file mode 100644 index c1d6c62..0000000 --- a/tools/h5dump/h5dump_xml.h +++ /dev/null @@ -1,39 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef H5DUMP_XML_H__ -#define H5DUMP_XML_H__ - -extern const char *xmlnsprefix; - -#ifdef __cplusplus -extern "C" { -#endif - -/* The dump functions of the dump_function_table */ -/* XML format: same interface, alternative output */ - -void xml_dump_group(hid_t, const char *); -void xml_dump_named_datatype(hid_t, const char *); -void xml_dump_dataset(hid_t, const char *, struct subset_t *); -void xml_dump_dataspace(hid_t space); -void xml_dump_datatype(hid_t type); -herr_t xml_dump_attr(hid_t, const char *, const H5A_info_t *, void *); -void xml_dump_data(hid_t, int, struct subset_t *, int); - -#ifdef __cplusplus -} -#endif - -#endif /* !H5DUMP_XML_H__ */ diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c deleted file mode 100644 index bbec813..0000000 --- a/tools/h5dump/h5dumpgentest.c +++ /dev/null @@ -1,10388 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* - * Generate the binary hdf5 files for the h5dump tests. - * Usage: just execute the program without any arguments will - * generate all the binary hdf5 files in the local directory. - * - * If you regenerate the test files (e.g., changing some code, - * trying it on a new platform, ...), you need to verify the correctness - * of the expected output and update the corresponding *.ddl files. - */ -#include <limits.h> - -#include "hdf5.h" -#include "H5private.h" -#include "h5tools.h" - -#define FILE1 "tgroup.h5" -#define FILE2 "tdset.h5" -#define FILE3 "tattr.h5" -#define FILE4 "tslink.h5" -#define FILE4_1 "tsoftlinks.h5" -#define FILE5 "thlink.h5" -#define FILE6 "tcompound.h5" -#define FILE7 "tall.h5" -#define FILE8 "tdset2.h5" -#define FILE9 "tcompound2.h5" -#define FILE10 "tloop.h5" -#define FILE11 "tloop2.h5" -#define FILE12 "tmany.h5" -#define FILE13 "tstr.h5" -#define FILE14 "tstr2.h5" -#define FILE15 "tenum.h5" -#define FILE16 "tobjref.h5" -#define FILE17 "tdatareg.h5" -#define FILE18 "tnestedcomp.h5" -#define FILE19 "topaque.h5" -#define FILE20 "tbitfields.h5" -#define FILE21 "tvldtypes1.h5" -#define FILE22 "tvldtypes2.h5" -#define FILE23 "tvldtypes3.h5" -#define FILE24 "tvldtypes4.h5" -#define FILE25 "tarray1.h5" -#define FILE25_BIG "tarray1_big.h5" -#define FILE26 "tarray2.h5" -#define FILE27 "tarray3.h5" -#define FILE28 "tarray4.h5" -#define FILE29 "tarray5.h5" -#define FILE30 "tarray6.h5" -#define FILE31 "tarray7.h5" -#define FILE32 "tempty.h5" -#define FILE33 "tgrp_comments.h5" -#define FILE34 "tsplit_file" -#define FILE35 "tfamily%05d.h5" -#define FILE36 "tmulti" -#define FILE37 "tlarge_objname.h5" -#define FILE38 "tvlstr.h5" -#define FILE39 "tchar.h5" -#define FILE40 "tattr2.h5" -#define FILE41 "tcompound_complex.h5" -#define FILE42 "tnamed_dtype_attr.h5" -#define FILE43 "tvldtypes5.h5" -#define FILE44 "tfilters.h5" -#define FILE45 "tnullspace.h5" -#define FILE46 "tfcontents1.h5" -#define FILE47 "tfcontents2.h5" -#define FILE48 "tfvalues.h5" -#define FILE49 "tstr3.h5" -#define FILE50 "taindices.h5" -#define FILE51 "tlonglinks.h5" -#define FILE52 "tldouble.h5" -#define FILE53 "textlink.h5" -#define FILE54 "tudlink.h5" -#define FILE55 "tbinary.h5" -#define FILE56 "tbigdims.h5" -#define FILE57 "thyperslab.h5" -#define FILE58 "tordergr.h5" -#define FILE59 "torderattr.h5" -#define FILE60 "tfpformat.h5" -#define FILE61 "textlinksrc.h5" -#define FILE62 "textlinktar.h5" -#define FILE63 "textlinkfar.h5" -#define FILE64 "tattrreg.h5" -#define FILE65 "file_space.h5" -#define FILE66 "packedbits.h5" -#define FILE67 "zerodim.h5" -#define FILE68 "charsets.h5" -#define FILE68a "tdset_idx.h5" -#define FILE69 "tattrintsize.h5" -#define FILE70 "tcmpdintsize.h5" -#define FILE71 "tcmpdattrintsize.h5" -#define FILE72 "tnestedcmpddt.h5" -#define FILE73 "tscalarintsize.h5" -#define FILE74 "tscalarattrintsize.h5" -#define FILE75 "tscalarstring.h5" -#define FILE76 "tcmpdintarray.h5" -#define FILE77 "tcmpdints.h5" -#define FILE78 "tscalarintattrsize.h5" -#define FILE79 "tintsattrs.h5" -#define FILE80 "tbitnopaque.h5" -#define FILE81 "tints4dims.h5" -#define FILE82 "tcompound_complex2.h5" -#define FILE83 "tvlenstr_array.h5" - -/*------------------------------------------------------------------------- - * prototypes - *------------------------------------------------------------------------- - */ - -/* utility functions */ -static int -make_dset(hid_t loc_id, const char *name, hid_t sid, hid_t tid, hid_t dcpl, void *buf); -static int -write_attr(hid_t loc_id, int rank, hsize_t *dims, const char *attr_name, - hid_t tid, void *buf); -static int -write_dset( hid_t loc_id, int rank, hsize_t *dims, const char *dset_name, - hid_t tid, void *buf ); - -/* a filter operation callback function */ -static size_t -myfilter(unsigned int H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, - const unsigned int H5_ATTR_UNUSED *cd_values, size_t nbytes, - size_t H5_ATTR_UNUSED *buf_size, void H5_ATTR_UNUSED **buf); - -/* a "set local" callback */ -static herr_t -set_local_myfilter(hid_t dcpl_id, hid_t tid, hid_t H5_ATTR_UNUSED sid); - -#define MYFILTER_ID 405 - -/* This message derives from H5Z */ -const H5Z_class2_t H5Z_MYFILTER[1] = {{ - H5Z_CLASS_T_VERS, - MYFILTER_ID, /* Filter id number */ - 1, 1, - "myfilter", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - set_local_myfilter, /* The "set local" callback */ - myfilter, /* The actual filter function */ -}}; - - -/* A UD link traversal function. Shouldn't actually be called. */ -static hid_t UD_traverse(H5_ATTR_UNUSED const char * link_name, H5_ATTR_UNUSED hid_t cur_group, - H5_ATTR_UNUSED const void * udata, H5_ATTR_UNUSED size_t udata_size, H5_ATTR_UNUSED hid_t lapl_id) -{ - return -1; -} - -#define MY_LINKCLASS 187 - -const H5L_class_t UD_link_class[1] = {{ - H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ - (H5L_type_t)MY_LINKCLASS, /* Link type id number */ - "UD link class", /* name for debugging */ - NULL, /* Creation callback */ - NULL, /* Move/rename callback */ - NULL, /* Copy callback */ - UD_traverse, /* The actual traversal function */ - NULL, /* Deletion callback */ - NULL /* Query callback */ -}}; - - -#define LENSTR 50 -#define LENSTR2 11 - -#define SPACE2_RANK 2 -#define SPACE2_DIM1 10 -#define SPACE2_DIM2 10 - -#define SPACE1_RANK 1 -#define SPACE1_DIM1 4 - -#define DIM1 20 -#define DIM2 10 -#define CDIM1 DIM1/2 -#define CDIM2 DIM2/2 -#define RANK 2 - -/* Dataspace of 0 dimension size */ -#define SPACE3_RANK 2 -#define SPACE3_DIM1 0 -#define SPACE3_DIM2 0 - -/* Element selection information */ -#define POINT1_NPOINTS 10 - -typedef enum{ - RED, - GREEN, - BLUE, - WHITE, - BLACK -} enumtype; - -/* Compound datatype */ -typedef struct s1_t { - unsigned int a; - unsigned int b; - float c; -} s1_t; - - -/* 1-D array datatype */ -#define ARRAY1_RANK 1 -#define ARRAY1_DIM1 4 - -/* 3-D array datatype */ -#define ARRAY2_RANK 3 -#define ARRAY2_DIM1 3 -#define ARRAY2_DIM2 4 -#define ARRAY2_DIM3 5 - -/* 2-D array datatype */ -#define ARRAY3_RANK 2 -#define ARRAY3_DIM1 6 -#define ARRAY3_DIM2 3 - -/* VL string datatype name */ -/* TODO remove complier error not used, remove the link when everything is OK */ -/* #define VLSTR_TYPE "vl_string_type" */ - -/* "File 41" macros */ -/* Name of dataset to create in datafile */ -#define F41_DATASETNAME "CompoundComplex" -/* Dataset dimensions */ -#define F41_LENGTH 6 -#define F41_RANK 1 -#define F41_ARRAY_RANK 1 -#define F41_ARRAY_RANKd 2 -#define F41_DIMb 4 -#define F41_ARRAY_DIMc 6 -#define F41_ARRAY_DIMd1 5 -#define F41_ARRAY_DIMd2 6 -#define F41_ARRAY_DIMf 10 - -/* "File 42" macros */ -/* Name of dataset to create in datafile */ -#define F42_DSETNAME "Dataset" -#define F42_TYPENAME "Datatype" -#define F42_ATTRNAME "Attribute" -#define F42_LINKNAME "Link_to_Datatype" - -/* "File 43" macros */ -/* Name of dataset to create in datafile */ -#define F43_DSETNAME "Dataset" - -/* "File 51" macros */ -#define F51_MAX_NAME_LEN ((64*1024)+1024) - -/* "File 64" macros */ -#define F64_FILE "tarray8.h5" -#define F64_DATASET "DS1" -#define F64_DIM0 1 -#define F64_ARRAY_BUF_LEN (4*1024) -#define F64_DIM1 (F64_ARRAY_BUF_LEN / sizeof(int) + 1) - -/* File 65 macros */ -#define STRATEGY H5F_FILE_SPACE_AGGR_VFD /* File space handling strategy */ -#define THRESHOLD10 10 /* Free space section threshold */ - -/* "FILE66" macros and for FILE69 */ -#define F66_XDIM 8 -#define F66_DATASETU08 "DU08BITS" -#define F66_DATASETS08 "DS08BITS" -#define F66_YDIM8 8 -#define F66_DATASETU16 "DU16BITS" -#define F66_DATASETS16 "DS16BITS" -#define F66_YDIM16 16 -#define F66_DATASETU32 "DU32BITS" -#define F66_DATASETS32 "DS32BITS" -#define F66_YDIM32 32 -#define F66_DATASETU64 "DU64BITS" -#define F66_DATASETS64 "DS64BITS" -#define F66_YDIM64 64 -#define F66_DUMMYDBL "DummyDBL" - -/* Declarations for gent_dataset_idx() for "FILE68a" */ -#define F68a_DSET_FIXED "dset_fixed" -#define F68a_DSET_FIXED_FILTER "dset_filter" -#define F68a_DSET_BTREE "dset_btree" -#define F68a_DIM200 200 -#define F68a_DIM100 100 -#define F68a_DIM20 20 -#define F68a_DIM10 10 -#define F68a_CHUNK 5 - -/* "FILE70" macros and for FILE71 */ -/* Name of dataset to create in datafile */ -#define F70_DATASETNAME "CompoundIntSize" -#define F70_LENGTH 4 -#define F70_RANK 1 -#define F70_ARRAY_RANK 2 -#define F70_XDIM 8 -#define F70_DATASETU08 "DU08BITS" -#define F70_DATASETS08 "DS08BITS" -#define F70_YDIM8 8 -#define F70_DATASETU16 "DU16BITS" -#define F70_DATASETS16 "DS16BITS" -#define F70_YDIM16 16 -#define F70_DATASETU32 "DU32BITS" -#define F70_DATASETS32 "DS32BITS" -#define F70_YDIM32 32 -#define F70_DATASETU64 "DU64BITS" -#define F70_DATASETS64 "DS64BITS" -#define F70_YDIM64 64 -#define F70_DUMMYDBL "DummyDBL" -/* Name of dataset to create in datafile */ -#define F71_DATASETNAME "CompoundAttrIntSize" - -/* "FILE73" macros and for FILE69 and FILE78 */ -#define F73_ARRAY_RANK 2 -#define F73_XDIM 8 -#define F73_DATASETU08 "DU08BITS" -#define F73_DATASETS08 "DS08BITS" -#define F73_YDIM8 8 -#define F73_DATASETU16 "DU16BITS" -#define F73_DATASETS16 "DS16BITS" -#define F73_YDIM16 16 -#define F73_DATASETU32 "DU32BITS" -#define F73_DATASETS32 "DS32BITS" -#define F73_YDIM32 32 -#define F73_DATASETU64 "DU64BITS" -#define F73_DATASETS64 "DS64BITS" -#define F73_YDIM64 64 -#define F73_DUMMYDBL "DummyDBL" - -/* "FILE76 and FILE77 */ -/* Name of dataset to create in datafile */ -#define F76_DATASETNAME "CompoundIntArray" -#define F76_LENGTH 4 -#define F76_RANK 1 -#define F76_ARRAY_RANK 1 -#define F76_DATASETU08 "DU08BITS" -#define F76_DATASETS08 "DS08BITS" -#define F76_DIM8 8 -#define F76_DATASETU16 "DU16BITS" -#define F76_DATASETS16 "DS16BITS" -#define F76_DIM16 16 -#define F76_DATASETU32 "DU32BITS" -#define F76_DATASETS32 "DS32BITS" -#define F76_DIM32 32 -#define F76_DATASETU64 "DU64BITS" -#define F76_DATASETS64 "DS64BITS" -#define F76_DIM64 64 -#define F76_DUMMYDBL "DummyDBL" -/* Name of dataset to create in datafile */ -#define F77_DATASETNAME1 "CompoundInts" -#define F77_DATASETNAME2 "CompoundRInts" -#define F77_LENGTH 64 - -#define F80_DIM32 32 - -#define F81_DATASETNAME "FourDimInts" -#define F81_RANK 4 -#define F81_WDIM 10 -#define F81_XDIM 8 -#define F81_YDIM 6 -#define F81_ZDIM 4 - -/* "File 82" macros */ -/* Name of dataset to create in datafile */ -#define F82_DATASETNAME "CompoundComplex1D" -/* Dataset dimensions */ -#define F82_DIM32 32 -#define F82_RANK 1 -//#define F82_RANK2 2 -//#define F82_RANK3 3 -//#define F82_RANK4 4 - -/* "File 83" macros */ -/* Name of dataset to create in datafile */ -#define F83_DATASETNAME "ScalarArrayOfVlenStr" -#define F83_DATASETNAME2 "CompoundArrayOfVlenStr" -/* Dataset dimensions */ -#define F83_DIM 5 -#define F83_RANK 1 -#define F83_ARRAYDIM 3 - -static void -gent_group(void) -{ - hid_t fid, group; - - fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* / */ - group = H5Gcreate2(fid, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - group = H5Gcreate2(fid, "/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - group = H5Gcreate2(fid, "/g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - /* /g1 */ - group = H5Gcreate2(fid, "/g1/g1.1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - group = H5Gcreate2(fid, "/g1/g1.2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - /* /g2 */ - group = H5Gcreate2(fid, "/g2/g2.1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - /* /g3 */ - group = H5Gcreate2(fid, "/g3/g3.1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - group = H5Gcreate2(fid, "/g3/g3.2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - group = H5Gcreate2(fid, "/g3/g3.3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - group = H5Gcreate2(fid, "/g3/g3.4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - /* /g2/g2.1 */ - group = H5Gcreate2(fid, "/g2/g2.1/g2.1.1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - group = H5Gcreate2(fid, "/g2/g2.1/g2.1.2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - group = H5Gcreate2(fid, "/g2/g2.1/g2.1.3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - H5Fclose(fid); -} - -static void -gent_dataset(void) -{ - hid_t fid, dataset, space; - hsize_t dims[2]; - int dset1[10][20]; - double dset2[30][20]; - int i, j; - - fid = H5Fcreate(FILE2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* dset1 */ - dims[0] = 10; dims[1] = 20; - space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(fid, "/dset1", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - for(i = 0; i < 10; i++) - for(j = 0; j < 20; j++) - dset1[i][j] = j + i; - - H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset1); - H5Sclose(space); - H5Dclose(dataset); - - /* dset2 */ - dims[0] = 30; dims[1] = 20; - space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(fid, "/dset2", H5T_IEEE_F64BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - for(i = 0; i < 30; i++) - 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); - - H5Sclose(space); - H5Dclose(dataset); - H5Fclose(fid); -} - -static void -gent_dataset2(void) -{ - hid_t fid, dataset, space, create_plist; - hsize_t dims[2]; - hsize_t maxdims[2]; - int dset1[10][20]; - double dset2[30][10]; - int i, j; - - fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - create_plist = H5Pcreate(H5P_DATASET_CREATE); - dims[0] = 5; dims[1] = 5; - H5Pset_chunk(create_plist, 2, dims); - - /* dset1 */ - dims[0] = 10; dims[1] = 20; - maxdims[0] = H5S_UNLIMITED; maxdims[1] = 20; - space = H5Screate_simple(2, dims, maxdims); - dataset = H5Dcreate2(fid, "/dset1", H5T_STD_I32BE, space, H5P_DEFAULT, create_plist, H5P_DEFAULT); - - for(i = 0; i < 10; i++) - for(j = 0; j < 20; j++) - dset1[i][j] = j; - - H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset1); - H5Sclose(space); - H5Dclose(dataset); - - /* dset2 */ - dims[0] = 30; dims[1] = 10; - maxdims[0] = 30; maxdims[1] = H5S_UNLIMITED; - space = H5Screate_simple(2, dims, maxdims); - dataset = H5Dcreate2(fid, "/dset2", H5T_IEEE_F64BE, space, H5P_DEFAULT, create_plist, H5P_DEFAULT); - - for(i = 0; i < 30; i++) - for(j = 0; j < 10; j++) - dset2[i][j] = j; - - H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2); - - H5Sclose(space); - H5Dclose(dataset); - H5Pclose(create_plist); - H5Fclose(fid); -} - -static void -gent_attribute(void) -{ - hid_t fid, root, space, attr, type; - hsize_t dims[2]; - char buf[60]; - int i, data[10]; - double d[10]; - char string[]= "string attribute"; - int point = 100; - - fid = H5Fcreate(FILE3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - root = H5Gopen2(fid, "/", H5P_DEFAULT); - - /* attribute 1 */ - dims[0] = 24; - space = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(root, "/attr1", H5T_STD_I8BE, space, H5P_DEFAULT, H5P_DEFAULT); - sprintf(buf, "attribute of root group"); - H5Awrite(attr, H5T_NATIVE_SCHAR, buf); - H5Sclose(space); - H5Aclose(attr); - - /* attribute 2 */ - dims[0] = 10; - space = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(root, "attr2", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT); - - for(i = 0; i < 10; i++) data[i] = i+1; - - H5Awrite(attr, H5T_NATIVE_INT, data); - H5Sclose(space); - H5Aclose(attr); - - /* attribute 3 */ - dims[0] = 10; - space = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(root, "attr3", H5T_IEEE_F64BE, space, H5P_DEFAULT, H5P_DEFAULT); - - for(i = 0; i < 10; i++) d[i] = 0.1F * (float)i; - - H5Awrite(attr, H5T_NATIVE_DOUBLE, d); - H5Sclose(space); - H5Aclose(attr); - - /* attribute 4 */ - space = H5Screate(H5S_SCALAR); - attr = H5Acreate2(root, "attr4", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, H5T_NATIVE_INT, &point); - H5Sclose(space); - H5Aclose(attr); - - /* attribute 5 */ - space = H5Screate(H5S_SCALAR); - type = H5Tcopy(H5T_C_S1); - H5Tset_size(type, 17); - attr = H5Acreate2(root, "attr5", type, space, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, type, string); - - H5Tclose(type); - H5Sclose(space); - H5Aclose(attr); - H5Gclose(root); - H5Fclose(fid); -} - -static void gent_softlink(void) -{ - hid_t fid, root; - - fid = H5Fcreate(FILE4, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - root = H5Gopen2(fid, "/", H5P_DEFAULT); - H5Lcreate_soft("somevalue", root, "slink1", H5P_DEFAULT, H5P_DEFAULT); - H5Lcreate_soft("linkvalue", root, "slink2", H5P_DEFAULT, H5P_DEFAULT); - - H5Gclose(root); - H5Fclose(fid); -} - -/*------------------------------------------------------------------------- - * Function: gent_softlink2 - * - * Purpose: Create soft links to various objects. - * Return: - * SUCCEED - * FAIL - * Programmer: Jonathan Kim - * Date: May 26, 2010 - *-------------------------------------------------------------------------*/ -#define NX 4 -#define NY 2 -static int gent_softlink2(void) -{ - hid_t fileid1 = -1; - hid_t gid1 = -1, gid2 = -1; - hid_t datatype = -1; - hid_t dset1 = -1, dset2 = -1; - hid_t dataspace = -1; - hsize_t dimsf[2]; /* dataset dimensions */ - int data1[NX][NY] = {{0,0},{1,1},{2,2},{3,3}}; - int data2[NX][NY] = {{0,0},{0,1},{0,2},{3,3}}; - herr_t status = SUCCEED; - - /*----------------------------------------------------------------------- - * FILE - *------------------------------------------------------------------------*/ - /* Create a new file */ - fileid1 = H5Fcreate(FILE4_1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - if (fileid1 < 0) - { - fprintf(stderr, "Error: %s> H5Fcreate failed.\n", FILE4_1); - status = FAIL; - goto out; - } - - /*----------------------------------------------------------------------- - * Groups - *------------------------------------------------------------------------*/ - gid1 = H5Gcreate2(fileid1, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (gid1 < 0) - { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", FILE4_1); - status = FAIL; - goto out; - } - - gid2 = H5Gcreate2(fileid1, "group_empty", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (gid2 < 0) - { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", FILE4_1); - status = FAIL; - goto out; - } - - /*----------------------------------------------------------------------- - * Named datatype - *------------------------------------------------------------------------*/ - datatype = H5Tcopy(H5T_NATIVE_INT); - status = H5Tcommit2(fileid1, "dtype", datatype, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { - fprintf(stderr, "Error: %s> H5Tcommit2 failed.\n", FILE4_1); - status = FAIL; - goto out; - } - - /*----------------------------------------------------------------------- - * Datasets - *------------------------------------------------------------------------*/ - /* - * Describe the size of the array and create the data space for fixed - * size dataset. - */ - dimsf[0] = NX; - dimsf[1] = NY; - dataspace = H5Screate_simple(2, dimsf, NULL); - - /* - * We will store little endian INT numbers. - */ - - /*--------------- - * dset1 - */ - /* Create a new dataset as sample object */ - dset1 = H5Dcreate2(fileid1, "/dset1", H5T_NATIVE_INT, dataspace, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (dset1 < 0) - { - fprintf(stderr, "Error: %s> H5Dcreate2 failed.\n", FILE4_1); - status = FAIL; - goto out; - } - - status = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data1); - if (status < 0) - { - fprintf(stderr, "Error: %s> H5Dwrite failed.\n", FILE4_1); - status = FAIL; - goto out; - } - - /*--------------- - * dset2 - */ - /* Create a new dataset as sample object */ - dset2 = H5Dcreate2(fileid1, "/dset2", H5T_NATIVE_INT, dataspace, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (dset2 < 0) - { - fprintf(stderr, "Error: %s> H5Dcreate2 failed.\n", FILE4_1); - status = FAIL; - goto out; - } - - status = H5Dwrite(dset2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data2); - if (status < 0) - { - fprintf(stderr, "Error: %s> H5Dwrite failed.\n", FILE4_1); - status = FAIL; - goto out; - } - - /*----------------------------------------------------------------------- - * Soft links - *------------------------------------------------------------------------*/ - /* - * create various soft links under '/' root - */ - /* link to dset1 */ - status = H5Lcreate_soft("/dset1", fileid1, "soft_dset1", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", FILE4_1); - status = FAIL; - goto out; - } - - /* link to data type */ - status = H5Lcreate_soft("/dtype", fileid1, "soft_dtype", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", FILE4_1); - status = FAIL; - goto out; - } - - /* link to group1 */ - status = H5Lcreate_soft("/group1", fileid1, "soft_group1", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", FILE4_1); - status = FAIL; - goto out; - } - - /* link to empty group */ - status = H5Lcreate_soft("/group_empty", fileid1, "soft_empty_grp", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", FILE4_1); - status = FAIL; - goto out; - } - - /* dangling link */ - status = H5Lcreate_soft("not_yet", fileid1, "soft_dangle", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", FILE4_1); - status = FAIL; - goto out; - } - - /*----------------------------------------- - * create various soft links under a group - */ - /* link to dset1 */ - status = H5Lcreate_soft("/dset1", gid1, "soft_dset1", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", FILE4_1); - status = FAIL; - goto out; - } - - /* link to dset2 */ - status = H5Lcreate_soft("/dset2", gid1, "soft_dset2", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", FILE4_1); - status = FAIL; - goto out; - } - - /* link to data type */ - status = H5Lcreate_soft("/dtype", gid1, "soft_dtype", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", FILE4_1); - status = FAIL; - goto out; - } - - /* link to empty group */ - status = H5Lcreate_soft("/group_empty", gid1, "soft_empty_grp", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", FILE4_1); - status = FAIL; - goto out; - } - - /* dangling link */ - status = H5Lcreate_soft("not_yet", gid1, "soft_dangle", H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", FILE4_1); - status = FAIL; - goto out; - } - - out: - /* - * Close/release resources. - */ - if(dataspace >= 0 && H5Sclose(dataspace) < 0) { - fprintf(stderr, "Error: %s> H5Sclose failed.\n", FILE4_1); - status = FAIL; - } - if(gid1 >= 0 && H5Gclose(gid1) < 0) { - fprintf(stderr, "Error: %s> H5Gclose failed.\n", FILE4_1); - status = FAIL; - } - if(gid2 >= 0 && H5Gclose(gid2) < 0) { - fprintf(stderr, "Error: %s> H5Gclose failed.\n", FILE4_1); - status = FAIL; - } - if(datatype >= 0 && H5Tclose(datatype) < 0) { - fprintf(stderr, "Error: %s> H5Tclose failed.\n", FILE4_1); - status = FAIL; - } - if(dset1 >= 0 && H5Dclose(dset1) < 0) { - fprintf(stderr, "Error: %s> H5Dclose failed.\n", FILE4_1); - status = FAIL; - } - if(dset2 >= 0 && H5Dclose(dset2) < 0) { - fprintf(stderr, "Error: %s> H5Dclose failed.\n", FILE4_1); - status = FAIL; - } - if(fileid1 >= 0 && H5Fclose(fileid1) < 0) { - fprintf(stderr, "Error: %s> H5Fclose failed.\n", FILE4_1); - status = FAIL; - } - - return status; -} - -/* - / - - / | \ the dataset is hardlinked to three names - /dset1, /g1/dset2, and /g1/g1.1/dset3 - dset1 g1 g2 - /g2 and /g1/g1.1 are hardlinked to the same object. - / \ - dset2 g1.1 - | - dset3 - */ - -static void gent_hardlink(void) -{ - hid_t fid, group, dataset, space; - hsize_t dim = 5; - int i, dset[5]; - - fid = H5Fcreate(FILE5, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - space = H5Screate_simple(1, &dim, NULL); - dataset = H5Dcreate2(fid, "/dset1", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - for(i = 0; i < 5; i++) dset[i] = i; - - H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset); - H5Sclose(space); - H5Dclose(dataset); - - group = H5Gcreate2(fid, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Lcreate_hard(group, "/dset1", H5L_SAME_LOC, "dset2", H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - group = H5Gcreate2(fid, "/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Lcreate_hard(group, "/dset1", H5L_SAME_LOC, "dset3", H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - group = H5Gopen2(fid, "/g1", H5P_DEFAULT); - H5Lcreate_hard(group, "/g2", H5L_SAME_LOC, "g1.1", H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - /* create a link to the root group */ - H5Lcreate_hard(fid, "/", H5L_SAME_LOC, "g3", H5P_DEFAULT, H5P_DEFAULT); - H5Fclose(fid); -} - -static void gent_extlink(void) -{ - hid_t fid; - - /* This external link will dangle, but that's okay */ - fid = H5Fcreate(FILE53, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - H5Lcreate_external("filename", "objname", fid, "extlink1", H5P_DEFAULT, H5P_DEFAULT); - H5Lcreate_external("anotherfile", "anotherobj", fid, "extlink2", H5P_DEFAULT, H5P_DEFAULT); - - H5Fclose(fid); -} - -static void gent_udlink(void) -{ - hid_t fid; - char buf[4]; - - H5Lregister(UD_link_class); - - /* This ud link will dangle, but that's okay */ - fid = H5Fcreate(FILE54, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - H5Lcreate_ud(fid, "udlink1", (H5L_type_t)MY_LINKCLASS, NULL, 0, H5P_DEFAULT, H5P_DEFAULT); - strcpy(buf, "foo"); - H5Lcreate_ud(fid, "udlink2", (H5L_type_t)MY_LINKCLASS, buf, 4, H5P_DEFAULT, H5P_DEFAULT); - - H5Fclose(fid); -} - - -/* - / - / | \ \ - dset1 group1 type1 type2 - | - dset2 - - */ -static void gent_compound_dt(void) { /* test compound data type */ - hid_t fid, group, dataset, space, space3, type, type2; - hid_t array_dt; - typedef struct { - int a; - float b; - double c; - } dset1_t; - dset1_t dset1[5]; - - typedef struct { - int a; - float b; - } dset2_t; - dset2_t dset2[5]; - - typedef struct { - int a[4]; - float b[5][6]; - } dset3_t; - dset3_t dset3[3][6]; - - typedef struct { - int a; - float b; - } dset4_t; - dset4_t dset4[5]; - - typedef struct { - int a; - float b; - } dset5_t; - dset5_t dset5[5]; - - int i, j, k, l; - unsigned ndims; - hsize_t dim[2]; - - hsize_t sdim = 5; - hsize_t dset3_dim[2]; - - - for(i = 0; i < (int)sdim; i++) { - dset1[i].a = i; - dset1[i].b = (float)(i*i); - dset1[i].c = (float)(1.0F/(float)(i+1)); - - dset2[i].a = i; - dset2[i].b = (float)((float)i+ (float)i*0.1F); - - dset4[i].a = i; - dset4[i].b = (float)(i+3); - - dset5[i].a = i; - dset5[i].b = (float)((float)i*0.1F); - } - - - fid = H5Fcreate(FILE6, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - space = H5Screate_simple(1, &sdim, NULL); - - type = H5Tcreate (H5T_COMPOUND, sizeof(dset1[0])); - type2 = H5Tcreate(H5T_COMPOUND, sizeof(dset1[0])); - H5Tinsert(type, "a_name", HOFFSET(dset1_t, a), H5T_STD_I32BE); - H5Tinsert(type, "b_name", HOFFSET(dset1_t, b), H5T_IEEE_F32BE); - H5Tinsert(type, "c_name", HOFFSET(dset1_t, c), H5T_IEEE_F64BE); - H5Tinsert(type2, "a_name", HOFFSET(dset1_t, a), H5T_NATIVE_INT); - H5Tinsert(type2, "b_name", HOFFSET(dset1_t, b), H5T_NATIVE_FLOAT); - H5Tinsert(type2, "c_name", HOFFSET(dset1_t, c), H5T_NATIVE_DOUBLE); - dataset = H5Dcreate2(fid, "/dset1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Dwrite(dataset, type2, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset1); - H5Tclose(type2); - H5Tclose(type); - H5Dclose(dataset); - - /* shared data type 1 */ - type = H5Tcreate (H5T_COMPOUND, sizeof(dset2_t)); - H5Tinsert(type, "int_name", HOFFSET(dset2_t, a), H5T_STD_I32BE); - H5Tinsert(type, "float_name", HOFFSET(dset2_t, b), H5T_IEEE_F32BE); - H5Tcommit2(fid, "type1", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - type2 = H5Tcreate (H5T_COMPOUND, sizeof(dset2_t)); - H5Tinsert(type2, "int_name", HOFFSET(dset2_t, a), H5T_NATIVE_INT); - H5Tinsert(type2, "float_name", HOFFSET(dset2_t, b), H5T_NATIVE_FLOAT); - group = H5Gcreate2(fid, "/group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - dataset = H5Dcreate2(group, "dset2", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Dwrite(dataset, type2, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2); - H5Tclose(type2); - H5Tclose(type); - H5Dclose(dataset); - - - /* shared data type 2 */ - type = H5Tcreate (H5T_COMPOUND, sizeof(dset3_t)); - type2 = H5Tcreate (H5T_COMPOUND, sizeof(dset3_t)); - - ndims = 1; dim[0] = 4; - - array_dt = H5Tarray_create2(H5T_STD_I32BE, ndims, dim); - H5Tinsert(type, "int_array", HOFFSET(dset3_t, a), array_dt); - H5Tclose(array_dt); - - array_dt = H5Tarray_create2(H5T_NATIVE_INT, ndims, dim); - H5Tinsert(type2, "int_array", HOFFSET(dset3_t, a), array_dt); - H5Tclose(array_dt); - - ndims = 2; dim[0] = 5; dim[1] = 6; - - array_dt = H5Tarray_create2(H5T_IEEE_F32BE, ndims, dim); - H5Tinsert(type, "float_array", HOFFSET(dset3_t, b), array_dt); - H5Tclose(array_dt); - - array_dt = H5Tarray_create2(H5T_NATIVE_FLOAT, ndims, dim); - H5Tinsert(type2, "float_array", HOFFSET(dset3_t, b), array_dt); - H5Tclose(array_dt); - - H5Tcommit2(fid, "type2", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - - dset3_dim[0] = 3; dset3_dim[1] = 6; - space3 = H5Screate_simple(2, dset3_dim, NULL); - dataset = H5Dcreate2(group, "dset3", type, space3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < (int)dset3_dim[0]; i++) - for(j = 0; j < (int)dset3_dim[1]; j++) { - for(k = 0; k < 4; k++) - dset3[i][j].a[k] = k + j + i; - for(k = 0; k < 5; k++) - for(l = 0; l < 6; l++) - dset3[i][j].b[k][l] = (float)((k + 1) + l + j + i); - } - H5Dwrite(dataset, type2, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset3); - H5Sclose(space3); - H5Tclose(type); - H5Tclose(type2); - H5Dclose(dataset); - - /* shared data type 3 */ - type = H5Tcreate (H5T_COMPOUND, sizeof(dset4_t)); - type2 = H5Tcreate (H5T_COMPOUND, sizeof(dset4_t)); - H5Tinsert(type, "int", HOFFSET(dset4_t, a), H5T_STD_I32BE); - H5Tinsert(type, "float", HOFFSET(dset4_t, b), H5T_IEEE_F32BE); - H5Tcommit2(group, "type3", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Tinsert(type2, "int", HOFFSET(dset4_t, a), H5T_NATIVE_INT); - H5Tinsert(type2, "float", HOFFSET(dset4_t, b), H5T_NATIVE_FLOAT); - dataset = H5Dcreate2(group, "dset4", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Dwrite(dataset, type2, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset4); - - H5Tclose(type); - H5Tclose(type2); - H5Dclose(dataset); - H5Gclose(group); - - - /* unamed data type */ - group = H5Gcreate2(fid, "/group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - type = H5Tcreate(H5T_COMPOUND, sizeof(dset5_t)); - H5Tinsert(type, "int", HOFFSET(dset5_t, a), H5T_STD_I32BE); - H5Tinsert(type, "float", HOFFSET(dset5_t, b), H5T_IEEE_F32BE); - H5Tcommit2(group, "type4", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - type2 = H5Tcreate(H5T_COMPOUND, sizeof(dset5_t)); - H5Tinsert(type2, "int", HOFFSET(dset5_t, a), H5T_NATIVE_INT); - H5Tinsert(type2, "float", HOFFSET(dset5_t, b), H5T_NATIVE_FLOAT); - dataset = H5Dcreate2(group, "dset5", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Dwrite(dataset, type2, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset5); - - H5Ldelete(group, "type4", H5P_DEFAULT); - - H5Tclose(type); - H5Tclose(type2); - H5Dclose(dataset); - H5Sclose(space); - H5Gclose(group); - - H5Fclose(fid); -} - -/* - / - / | \ \ - dset1 group1 type1 type2 - | - dset2 - - */ -static void gent_compound_dt2(void) { /* test compound data type */ - hid_t fid, group, dataset, space, type, create_plist, type2; - hid_t array_dt; - - typedef struct { - int a; - float b; - double c; - } dset1_t; - dset1_t dset1[10]; - - typedef struct { - int a; - float b; - } dset2_t; - dset2_t dset2[10]; - - typedef struct { - int a[4]; - float b[5][6]; - } dset3_t; - - typedef struct { - int a; - float b; - } dset4_t; - dset4_t dset4[10]; - - typedef struct { - int a; - float b; - } dset5_t; - dset5_t dset5[10]; - - int i; - unsigned ndims; - hsize_t dim[2]; - - hsize_t sdim, maxdim; - - sdim = 10; - for(i = 0; i < (int)sdim; i++) { - dset1[i].a = i; - dset1[i].b = (float)(i*i); - dset1[i].c = (float)(1.0F / (float)(i+ 1)); - - dset2[i].a = i; - dset2[i].b = (float)((float)i + (float)i * 0.1F); - - dset4[i].a = i; - dset4[i].b = (float)((float)i * 1.0F); - - dset5[i].a = i; - dset5[i].b = (float)((float)i * 1.0F); - } - - fid = H5Fcreate(FILE9, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - create_plist = H5Pcreate(H5P_DATASET_CREATE); - - sdim = 2; - H5Pset_chunk(create_plist, 1, &sdim); - - sdim = 6; - maxdim = H5S_UNLIMITED; - - space = H5Screate_simple(1, &sdim, &maxdim); - - type = H5Tcreate (H5T_COMPOUND, sizeof(dset1[0])); - - H5Tinsert(type, "a_name", HOFFSET(dset1_t, a), H5T_STD_I32BE); - H5Tinsert(type, "b_name", HOFFSET(dset1_t, b), H5T_IEEE_F32BE); - H5Tinsert(type, "c_name", HOFFSET(dset1_t, c), H5T_IEEE_F64BE); - - dataset = H5Dcreate2(fid, "/dset1", type, space, H5P_DEFAULT, create_plist, H5P_DEFAULT); - - type2 = H5Tcreate (H5T_COMPOUND, sizeof(dset1[0])); - - H5Tinsert(type2, "a_name", HOFFSET(dset1_t, a), H5T_NATIVE_INT); - H5Tinsert(type2, "b_name", HOFFSET(dset1_t, b), H5T_NATIVE_FLOAT); - H5Tinsert(type2, "c_name", HOFFSET(dset1_t, c), H5T_NATIVE_DOUBLE); - - H5Dwrite(dataset, type2, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset1); - - H5Tclose(type); - H5Tclose(type2); - H5Sclose(space); - H5Dclose(dataset); - - sdim = 6; - maxdim = 10; - - space = H5Screate_simple(1, &sdim, &maxdim); - - /* shared data type 1 */ - type = H5Tcreate(H5T_COMPOUND, sizeof(dset2_t)); - H5Tinsert(type, "int_name", HOFFSET(dset2_t, a), H5T_STD_I32BE); - H5Tinsert(type, "float_name", HOFFSET(dset2_t, b), H5T_IEEE_F32BE); - H5Tcommit2(fid, "type1", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - group = H5Gcreate2(fid, "/group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - dataset = H5Dcreate2(group, "dset2", type, space, H5P_DEFAULT, create_plist, H5P_DEFAULT); - - type2 = H5Tcreate (H5T_COMPOUND, sizeof(dset2_t)); - H5Tinsert(type2, "int_name", HOFFSET(dset2_t, a), H5T_NATIVE_INT); - H5Tinsert(type2, "float_name", HOFFSET(dset2_t, b), H5T_NATIVE_FLOAT); - H5Dwrite(dataset, type2, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2); - - H5Tclose(type); - H5Tclose(type2); - H5Dclose(dataset); - - - /* shared data type 2 */ - type = H5Tcreate (H5T_COMPOUND, sizeof(dset3_t)); - - ndims = 1; dim[0] = 4; - array_dt = H5Tarray_create2(H5T_STD_I32BE, ndims, dim); - H5Tinsert(type, "int_array", HOFFSET(dset3_t, a), array_dt); - H5Tclose(array_dt); - - ndims = 2; dim[0] = 5; dim[1] = 6; - array_dt = H5Tarray_create2(H5T_IEEE_F32BE, ndims, dim); - H5Tinsert(type, "float_array", HOFFSET(dset3_t, b), array_dt); - H5Tclose(array_dt); - - H5Tcommit2(fid, "type2", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Tclose(type); - - /* shared data type 3 */ - type = H5Tcreate(H5T_COMPOUND, sizeof(dset4_t)); - H5Tinsert(type, "int", HOFFSET(dset4_t, a), H5T_STD_I32BE); - H5Tinsert(type, "float", HOFFSET(dset4_t, b), H5T_IEEE_F32BE); - H5Tcommit2(group, "type3", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - dataset = H5Dcreate2(group, "dset4", type, space, H5P_DEFAULT, create_plist, H5P_DEFAULT); - - type2 = H5Tcreate (H5T_COMPOUND, sizeof(dset4_t)); - H5Tinsert(type2, "int", HOFFSET(dset4_t, a), H5T_NATIVE_INT); - H5Tinsert(type2, "float", HOFFSET(dset4_t, b), H5T_NATIVE_FLOAT); - H5Dwrite(dataset, type2, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset4); - - H5Tclose(type); - H5Tclose(type2); - H5Dclose(dataset); - H5Gclose(group); - - - /* unamed data type */ - group = H5Gcreate2(fid, "/group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - type = H5Tcreate(H5T_COMPOUND, sizeof(dset5_t)); - H5Tinsert(type, "int", HOFFSET(dset5_t, a), H5T_STD_I32BE); - H5Tinsert(type, "float", HOFFSET(dset5_t, b), H5T_IEEE_F32BE); - H5Tcommit2(group, "type4", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - dataset = H5Dcreate2(group, "dset5", type, space, H5P_DEFAULT, create_plist, H5P_DEFAULT); - type2 = H5Tcreate(H5T_COMPOUND, sizeof(dset5_t)); - H5Tinsert(type2, "int", HOFFSET(dset5_t, a), H5T_NATIVE_INT); - H5Tinsert(type2, "float", HOFFSET(dset5_t, b), H5T_NATIVE_FLOAT); - H5Dwrite(dataset, type2, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset5); - - H5Ldelete(group, "type4", H5P_DEFAULT); - - H5Tclose(type); - H5Tclose(type2); - H5Dclose(dataset); - H5Sclose(space); - H5Gclose(group); - H5Pclose(create_plist); - - H5Fclose(fid); - -} - - -/* - -/ : g1 g2 attr1 attr2 -g1 : g1.1 g1.2 -g1.1 : dset1.1.1(attr1, attr2) dset1.1.2 -g1.2 : g1.2.1 extlink -g1.2.1 : slink -g2 : dset2.1 dset2.2 udlink - - */ - -static void gent_all(void) -{ - hid_t fid, group, attr, dataset, space; - hsize_t dims[2]; - int data[2][2], dset1[10][10], dset2[20]; - char buf[60]; - int i, j; - float dset2_1[10], dset2_2[3][5]; - - fid = H5Fcreate(FILE7, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* create groups */ - group = H5Gcreate2(fid, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - group = H5Gcreate2(fid, "/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - group = H5Gcreate2(fid, "/g1/g1.1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - group = H5Gcreate2(fid, "/g1/g1.2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - group = H5Gcreate2(fid, "/g1/g1.2/g1.2.1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - /* root attributes */ - group = H5Gopen2(fid, "/", H5P_DEFAULT); - - dims[0] = 10; - space = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(group, "attr1", H5T_STD_I8BE, space, H5P_DEFAULT, H5P_DEFAULT); - sprintf(buf, "abcdefghi"); - H5Awrite(attr, H5T_NATIVE_SCHAR, buf); - H5Sclose(space); - H5Aclose(attr); - - dims[0] = 2; dims[1] = 2; - space = H5Screate_simple(2, dims, NULL); - attr = H5Acreate2(group, "attr2", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT); - data[0][0] = 0; data[0][1] = 1; data[1][0] = 2; data[1][1] = 3; - H5Awrite(attr, H5T_NATIVE_INT, data); - H5Sclose(space); - H5Aclose(attr); - - H5Gclose(group); - - group = H5Gopen2(fid, "/g1/g1.1", H5P_DEFAULT); - - /* dset1.1.1 */ - dims[0] = 10; dims[1] = 10; - space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(group, "dset1.1.1", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 10; i++) - for(j = 0; j < 10; j++) - dset1[i][j] = j * i; - H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset1); - H5Sclose(space); - - /* attributes of dset1.1.1 */ - dims[0] = 27; - space = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(dataset, "attr1", H5T_STD_I8BE, space, H5P_DEFAULT, H5P_DEFAULT); - sprintf(buf, "1st attribute of dset1.1.1"); - H5Awrite(attr, H5T_NATIVE_SCHAR, buf); - H5Sclose(space); - H5Aclose(attr); - - dims[0] = 27; - space = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(dataset, "attr2", H5T_STD_I8BE, space, H5P_DEFAULT, H5P_DEFAULT); - sprintf(buf, "2nd attribute of dset1.1.1"); - H5Awrite(attr, H5T_NATIVE_SCHAR, buf); - H5Sclose(space); - H5Aclose(attr); - - H5Dclose(dataset); - - /* dset1.1.2 */ - dims[0] = 20; - space = H5Screate_simple(1, dims, NULL); - dataset = H5Dcreate2(group, "dset1.1.2", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 20; i++) - dset2[i] = i; - H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2); - H5Sclose(space); - H5Dclose(dataset); - - H5Gclose(group); - - /* external link */ - H5Lcreate_external("somefile", "somepath", fid, "/g1/g1.2/extlink", H5P_DEFAULT, H5P_DEFAULT); - - /* soft link */ - group = H5Gopen2(fid, "/g1/g1.2/g1.2.1", H5P_DEFAULT); - H5Lcreate_soft("somevalue", group, "slink", H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - group = H5Gopen2(fid, "/g2", H5P_DEFAULT); - - /* dset2.1 */ - dims[0] = 10; - space = H5Screate_simple(1, dims, NULL); - dataset = H5Dcreate2(group, "dset2.1", H5T_IEEE_F32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 10; i++) - dset2_1[i] = (float)((float)i * 0.1F + 1); - H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2_1); - H5Sclose(space); - H5Dclose(dataset); - - /* dset2.2 */ - dims[0] = 3; dims[1] = 5; - space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(group, "dset2.2", H5T_IEEE_F32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 3; i++) - for(j = 0; j < 5; j++) - dset2_2[i][j] = (float)((float)(i + 1) * (float)j * 0.1F); - H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2_2); - H5Sclose(space); - H5Dclose(dataset); - - H5Gclose(group); - - /* user-defined link */ - H5Lregister(UD_link_class); - H5Lcreate_ud(fid, "/g2/udlink", (H5L_type_t)MY_LINKCLASS, NULL, 0, H5P_DEFAULT, H5P_DEFAULT); - - H5Fclose(fid); -} - -/* - o - /___\ - g1 o/ \o g2 - \___/ - - -o - group objects - - */ - -static void gent_loop(void) { - hid_t fid, group; - - fid = H5Fcreate(FILE10, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - group = H5Gcreate2(fid, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - group = H5Gcreate2(fid, "/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - H5Lcreate_hard(fid, "/g2", H5L_SAME_LOC, "/g1/g1.1", H5P_DEFAULT, H5P_DEFAULT); - H5Lcreate_hard(fid, "/g1", H5L_SAME_LOC, "/g2/g2.1", H5P_DEFAULT, H5P_DEFAULT); - - H5Fclose(fid); -} - -static void gent_loop2(void) -{ - hid_t fid, group; - - fid = H5Fcreate(FILE11, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* create group object g1 and implcit path from root object */ - group = H5Gcreate2(fid, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - /* create group object g2 and implcit path from root object */ - group = H5Gcreate2(fid, "/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - /* create path from object at /g1 to object at /g2 and name it g1.1 */ - H5Lcreate_hard(fid, "/g2", H5L_SAME_LOC, "/g1/g1.1", H5P_DEFAULT, H5P_DEFAULT); - - /* create path from object at /g2 to object at /g1 and name it g2.1 */ - H5Lcreate_soft("/g1", fid, "/g2/g2.1", H5P_DEFAULT, H5P_DEFAULT); - - H5Fclose(fid); -} - -/* - / - | | | \ \ \ \ \ - g1 g2 g3 g4 g5 g6 g7 g8 - / \ | | \ \ \ \ \ - g1.1 g1.2 slink2 link3 dset2 slink4 dset3 slink5 elink - | | (g1) (dset2) (dset3) (elink) udlink - dset1 link1 slink6 - (dset1) (udlink) - */ - -static void -gent_many(void) -{ - hid_t fid, group, attr, dataset, space, space2, type, create_plist, type2; - hid_t array_dt; - hsize_t dims[2]; - int data[2][2], dset2[10][10], dset3[10][10]; - double d[10]; - - char buf[60]; - int i, j; - int i0, i1, i2, i3; - hsize_t sdim, maxdim; - - typedef struct { /* compound type has members with rank > 1 */ - int a[2][2][2][2]; /* arrays are 2x2x2x2 */ - double b[2][2][2][2]; - double c[2][2][2][2]; - } dset1_t; - dset1_t dset1[6]; - - hsize_t dim[4]; - herr_t ret; - - fid = H5Fcreate(FILE12, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - group = H5Gcreate2(fid, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - create_plist = H5Pcreate(H5P_DATASET_CREATE); - - sdim = 2; - H5Pset_chunk(create_plist, 1, &sdim); - - group = H5Gcreate2(fid, "/g1/g1.1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - type = H5Tcreate (H5T_COMPOUND, sizeof(dset1[0])); - - dim[0] = dim[1] = dim[2] = dim[3] = 2; - array_dt = H5Tarray_create2(H5T_STD_I32BE, 4, dim); - H5Tinsert(type, "a_array", HOFFSET(dset1_t, a), array_dt); - H5Tclose(array_dt); - - array_dt = H5Tarray_create2(H5T_IEEE_F64BE, 4, dim); - H5Tinsert(type, "b_array", HOFFSET(dset1_t, b), array_dt); - H5Tclose(array_dt); - - array_dt = H5Tarray_create2(H5T_IEEE_F64BE, 4, dim); - H5Tinsert(type, "c_array", HOFFSET(dset1_t, c), array_dt); - H5Tclose(array_dt); - - type2 = H5Tcreate (H5T_COMPOUND, sizeof(dset1[0])); - - array_dt = H5Tarray_create2(H5T_NATIVE_INT, 4, dim); - H5Tinsert(type2, "a_array", HOFFSET(dset1_t, a), array_dt); - H5Tclose(array_dt); - - array_dt = H5Tarray_create2(H5T_NATIVE_DOUBLE, 4, dim); - H5Tinsert(type2, "b_array", HOFFSET(dset1_t, b), array_dt); - H5Tclose(array_dt); - - array_dt = H5Tarray_create2(H5T_NATIVE_DOUBLE, 4, dim); - H5Tinsert(type2, "c_array", HOFFSET(dset1_t, c), array_dt); - H5Tclose(array_dt); - - - /* dset1 */ - sdim = 6; - maxdim = H5S_UNLIMITED; - space = H5Screate_simple(1, &sdim, &maxdim); - dataset = H5Dcreate2(group, "dset1", type, space, H5P_DEFAULT, create_plist, H5P_DEFAULT); - - /* add attributes to dset1 */ - dims[0] = 10; - space2 = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(dataset, "attr1", H5T_STD_I8BE, space2, H5P_DEFAULT, H5P_DEFAULT); - sprintf(buf, "abcdefghi"); - H5Awrite(attr, H5T_NATIVE_CHAR, buf); - H5Sclose(space2); - H5Aclose(attr); - - dims[0] = 2; dims[1] = 2; - space2 = H5Screate_simple(2, dims, NULL); - attr = H5Acreate2(dataset, "attr2", H5T_STD_I32BE, space2, H5P_DEFAULT, H5P_DEFAULT); - data[0][0] = 0; data[0][1] = 1; data[1][0] = 2; data[1][1] = 3; - H5Awrite(attr, H5T_NATIVE_INT, data); - H5Sclose(space2); - H5Aclose(attr); - - dims[0] = 10; - space2 = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(dataset, "attr3", H5T_IEEE_F64BE, space2, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 10; i++) - d[i] = 0.1F * (float)i; - H5Awrite(attr, H5T_NATIVE_DOUBLE, d); - H5Sclose(space2); - H5Aclose(attr); - - for(j=0; j<(int)sdim; j++) { - for(i3 = 0; i3 < 2; i3++) { - for(i2 = 0; i2 < 2; i2++) { - for(i1 = 0; i1 < 2; i1++) { - for(i0 = 0; i0 < 2; i0++) { - dset1[j].a[i3][i2][i1][i0] = i0 + j; - dset1[j].b[i3][i2][i1][i0] = (double)(i0 + j); - dset1[j].c[i3][i2][i1][i0] = (double)((hsize_t)i0 + (hsize_t)j + sdim); - } - } - } - } - } - - H5Dwrite(dataset, type2, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset1); - - H5Dclose(dataset); - H5Sclose(space); - - H5Tclose(type); - H5Tclose(type2); - H5Gclose(group); - - group = H5Gcreate2(fid, "/g1/g1.2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Lcreate_hard(group, "/g1/g1.1/dset1", H5L_SAME_LOC, "link1", H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - group = H5Gcreate2(fid, "/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Lcreate_soft("/g1", group, "slink2", H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - group = H5Gcreate2(fid, "/g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - group = H5Gcreate2(fid, "/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - /* dset2 */ - dims[0] = 10; dims[1] = 10; - space = H5Screate_simple(2, dims, NULL); - - dataset = H5Dcreate2(group, "dset2", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 10; i++) - for(j = 0; j < 10; j++) - dset2[i][j] = j; - H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2); - - H5Dclose(dataset); - - H5Sclose(space); - H5Gclose(group); - - group = H5Gopen2(fid, "/g3", H5P_DEFAULT); - H5Lcreate_hard(group, "/g4/dset2", H5L_SAME_LOC, "link3", H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - group = H5Gcreate2(fid, "/g5", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - group = H5Gcreate2(fid, "/g6", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - /* dset3 */ - dims[0] = 10; dims[1] = 10; - space = H5Screate_simple(2, dims, NULL); - - dataset = H5Dcreate2(group, "dset3", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for(i = 0; i < 10; i++) - for(j = 0; j < 10; j++) - dset3[i][j] = i; - H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset3); - - H5Dclose(dataset); - - H5Sclose(space); - H5Gclose(group); - - group = H5Gopen2(fid, "/g5", H5P_DEFAULT); - H5Lcreate_soft("/g6/dset3", group, "slink4", H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - H5Pclose(create_plist); - - group = H5Gcreate2(fid, "/g7", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - group = H5Gcreate2(fid, "/g8", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - /* Create dangling external and UD links */ - H5Lcreate_external("somefile", "somepath", fid, "/g8/elink", H5P_DEFAULT, H5P_DEFAULT); - H5Lregister(UD_link_class); - H5Lcreate_ud(fid, "/g8/udlink", (H5L_type_t)MY_LINKCLASS, NULL, 0, H5P_DEFAULT, H5P_DEFAULT); - - /* Create links to external and UD links */ - ret = H5Lcreate_soft("/g8/elink", fid, "/g7/slink5", H5P_DEFAULT, H5P_DEFAULT); - HDassert(ret >= 0); - ret = H5Lcreate_soft("/g8/udlink", fid, "/g7/slink6", H5P_DEFAULT, H5P_DEFAULT); - HDassert(ret >= 0); - - H5Fclose(fid); -} - -static hid_t mkstr(int size, H5T_str_t pad) { - hid_t type; - - if((type=H5Tcopy(H5T_C_S1)) < 0) return -1; - if(H5Tset_size(type, (size_t)size) < 0) return -1; - if(H5Tset_strpad(type, pad) < 0) return -1; - - return type; -} - -static void gent_str(void) { - hid_t fid, dataset, space, f_type, m_type, str_type, f_type2; - hid_t array_dt; - - hsize_t dims1[] = { 3, 4}; - char string1[12][3] = {"s1","s2","s3","s4","s5","s6","s7","s8","s9", - "s0","s1","s2"}; - - hsize_t dims2[]={20}; - char string2[20][10] = {"ab cd ef1", "ab cd ef2", "ab cd ef3", "ab cd ef4", - "ab cd ef5", "ab cd ef6", "ab cd ef7", "ab cd ef8", - "ab cd ef9", "ab cd ef0", "ab cd ef1", "ab cd ef2", - "ab cd ef3", "ab cd ef4", "ab cd ef5", "ab cd ef6", - "ab cd ef7", "ab cd ef8", "ab cd ef9", "ab cd ef0"}; - - hsize_t dims3[] = { 27}; - char string3[27][6] = {"abcd0", "abcd1", "abcd2", "abcd3", - "abcd4", "abcd5", "abcd6", "abcd7", - "abcd8", "abcd9", "abcd0", "abcd1", - "abcd2", "abcd3", "abcd4", "abcd5", - "abcd6", "abcd7", "abcd8", "abcd9", - "abcd0", "abcd1", "abcd2", "abcd3", - "abcd4", "abcd5", "abcd6"}; - - int i, j, k, l; - - hsize_t dims4[] = { 3 }; - char string4[3][21] = { "s1234567890123456789", "s1234567890123456789", - "s1234567890123456789"}; - - hsize_t dims5[] = { 3, 6}; - typedef struct { - int a[8][10]; - char s[12][33]; - } compound_t; - compound_t comp1[3][6]; - hsize_t mdims[2]; - - fid = H5Fcreate(FILE13, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* string 1 : nullterm string */ - space = H5Screate_simple(2, dims1, NULL); - f_type = mkstr(5, H5T_STR_NULLTERM); - m_type = mkstr(3, H5T_STR_NULLTERM); - dataset = H5Dcreate2(fid, "/string1", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Dwrite(dataset, m_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, string1); - H5Tclose(m_type); - H5Tclose(f_type); - H5Sclose(space); - H5Dclose(dataset); - - /* string 2 : space pad string */ - space = H5Screate_simple(1, dims2, NULL); - f_type = mkstr(11, H5T_STR_SPACEPAD); - m_type = mkstr(10, H5T_STR_NULLTERM); - dataset = H5Dcreate2(fid, "/string2", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Dwrite(dataset, m_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, string2); - H5Tclose(m_type); - H5Tclose(f_type); - H5Sclose(space); - H5Dclose(dataset); - - /* string 3 : null pad string */ - space = H5Screate_simple(1, dims3, NULL); - f_type = mkstr(8, H5T_STR_NULLPAD); - m_type = mkstr(6, H5T_STR_NULLTERM); - dataset = H5Dcreate2(fid, "/string3", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Dwrite(dataset, m_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, string3); - H5Tclose(m_type); - H5Tclose(f_type); - H5Sclose(space); - H5Dclose(dataset); - - /* string 4 : space pad long string */ - space = H5Screate_simple(1, dims4, NULL); - f_type = mkstr(168, H5T_STR_SPACEPAD); - m_type = mkstr(21, H5T_STR_NULLTERM); - dataset = H5Dcreate2(fid, "/string4", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Dwrite(dataset, m_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, string4); - H5Tclose(m_type); - H5Tclose(f_type); - H5Sclose(space); - H5Dclose(dataset); - - /* compound data */ - space = H5Screate_simple(2, dims5, NULL); - f_type = H5Tcreate (H5T_COMPOUND, sizeof(compound_t)); - f_type2 = H5Tcreate (H5T_COMPOUND, sizeof(compound_t)); - - mdims[0] = 8; mdims[1] = 10; - - array_dt = H5Tarray_create2(H5T_STD_I32BE, 2, mdims); - H5Tinsert(f_type, "int_array", HOFFSET(compound_t, a), array_dt); - H5Tclose(array_dt); - - array_dt = H5Tarray_create2(H5T_NATIVE_INT, 2, mdims); - H5Tinsert(f_type2, "int_array", HOFFSET(compound_t, a), array_dt); - H5Tclose(array_dt); - - mdims[0] = 3; mdims[1] = 4; - - str_type = mkstr(32, H5T_STR_SPACEPAD); - array_dt = H5Tarray_create2(str_type, 2, mdims); - H5Tinsert(f_type, "string", HOFFSET(compound_t, s), array_dt); - H5Tclose(array_dt); - H5Tclose(str_type); - - str_type = mkstr(33, H5T_STR_NULLTERM); - array_dt = H5Tarray_create2(str_type, 2, mdims); - H5Tinsert(f_type2, "string", HOFFSET(compound_t, s), array_dt); - H5Tclose(array_dt); - H5Tclose(str_type); - - for(i = 0; i < 3; i++) - for(j = 0; j < 6; j++) { - for(k = 0 ; k < 8; k++) - for(l = 0; l < 10; l++) - comp1[i][j].a[k][l] = (l + j + k) * (l + j + k); - for(k = 0 ; k < 12; k++) - strcpy(comp1[i][j].s[k], "abcdefgh12345678abcdefgh12345678"); - } - - dataset = H5Dcreate2(fid, "/comp1", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Dwrite(dataset, f_type2, H5S_ALL, H5S_ALL, H5P_DEFAULT, comp1); - - H5Tclose(f_type); - H5Tclose(f_type2); - H5Sclose(space); - H5Dclose(dataset); - - H5Fclose(fid); -} - -/* - / - / / | \ \ \ - g1 g2 g3 g4 g5 g6 - | | | | \ \ - string1 string3 string5 - string2 string4 string6 - */ - -static void gent_str2(void) -{ - hid_t fid, group, attr, dataset, space, space2, mem_space, hyper_space; - hid_t fxdlenstr, fxdlenstr2, memtype; - hsize_t dims[1], size[1], stride[1], count[1], block[1]; - hsize_t start[1]; - - - int i; - char buf[LENSTR+10]; - char buf2[3*LENSTR2]; - hsize_t sdim; - - fid = H5Fcreate(FILE14, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - fxdlenstr = H5Tcopy(H5T_C_S1); - H5Tset_size(fxdlenstr, LENSTR); - H5Tset_cset(fxdlenstr, H5T_CSET_ASCII); - H5Tset_strpad(fxdlenstr, H5T_STR_NULLTERM); - - memtype = H5Tcopy(H5T_C_S1); - H5Tset_size(memtype, LENSTR); - H5Tset_cset(memtype, H5T_CSET_ASCII); - H5Tset_strpad(memtype, H5T_STR_NULLTERM); - - sdim = 10; - size[0] = sdim; - space = H5Screate_simple(1, size, NULL); - size[0] = 1; - mem_space = H5Screate_simple(1,size,NULL); - hyper_space = H5Scopy(space); - - /* dset1 */ - - group = H5Gcreate2(fid, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - dataset = H5Dcreate2(group, "dset1", fxdlenstr, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - /* add attributes to dset1 */ - - fxdlenstr2 = H5Tcopy(H5T_C_S1); - H5Tset_size(fxdlenstr2, LENSTR2); - H5Tset_cset(fxdlenstr2, H5T_CSET_ASCII); - H5Tset_strpad(fxdlenstr2, H5T_STR_NULLTERM); - - dims[0] = 3; - space2 = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(dataset, "attr1", fxdlenstr2, space2, H5P_DEFAULT, H5P_DEFAULT); - sprintf(&(buf2[0*LENSTR2]), "0123456789"); - sprintf(&(buf2[1*LENSTR2]), "abcdefghij"); - sprintf(&(buf2[2*LENSTR2]), "ABCDEFGHIJ"); - H5Awrite(attr, fxdlenstr2, buf2); - H5Sclose(space2); - H5Tclose(fxdlenstr2); - H5Aclose(attr); - - stride[0]=1; - count[0]=1; - block[0]=1; - - for(i = 0; (hsize_t)i < sdim; i++) { - start[0] = (hsize_t)i; - sprintf(buf, "This is row %1d of type H5T_STR_NULLTERM of", i); - H5Tset_size(memtype, HDstrlen(buf)+1); - H5Sselect_hyperslab(hyper_space, H5S_SELECT_SET, start, stride, count, block); - H5Dwrite(dataset, memtype, mem_space, hyper_space, H5P_DEFAULT, buf); - } - H5Dclose(dataset); - H5Gclose(group); - - group = H5Gcreate2(fid, "/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - dataset = H5Dcreate2(group, "dset2", fxdlenstr, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - for(i = 0; (hsize_t)i < sdim; i++) { - start[0] = (hsize_t)i; - sprintf(buf, "This is row %1d of type H5T_STR_NULLTERM of string array", i); - H5Tset_size(memtype, HDstrlen(buf)+1); - H5Sselect_hyperslab(hyper_space, H5S_SELECT_SET, start, stride, count, block); - H5Dwrite(dataset, memtype, mem_space, hyper_space, H5P_DEFAULT, buf); - } - H5Dclose(dataset); - H5Gclose(group); - - - H5Tclose(fxdlenstr); - fxdlenstr = H5Tcopy(H5T_C_S1); - H5Tset_size(fxdlenstr, LENSTR); - H5Tset_cset(fxdlenstr, H5T_CSET_ASCII); - H5Tset_strpad(fxdlenstr, H5T_STR_NULLPAD); - - group = H5Gcreate2(fid, "/g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - dataset = H5Dcreate2(group, "dset3", fxdlenstr, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - for(i = 0;(hsize_t) i < sdim; i++) { - start[0] = (hsize_t)i; - sprintf(buf, "This is row %1d of type H5T_STR_NULLPAD of", i); - H5Tset_size(memtype, HDstrlen(buf)+1); - H5Sselect_hyperslab(hyper_space, H5S_SELECT_SET, start, stride, count, block); - H5Dwrite(dataset, memtype, mem_space, hyper_space, H5P_DEFAULT, buf); - } - H5Dclose(dataset); - H5Gclose(group); - - - group = H5Gcreate2(fid, "/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - dataset = H5Dcreate2(group, "dset4", fxdlenstr, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - for(i = 0; (hsize_t)i < sdim; i++) { - start[0] = (hsize_t)i; - sprintf(buf, "This is row %1d of type H5T_STR_NULLPAD of string array", i); - H5Tset_size(memtype, HDstrlen(buf)+1); - H5Sselect_hyperslab(hyper_space, H5S_SELECT_SET, start, stride, count, block); - H5Dwrite(dataset, memtype, mem_space, hyper_space, H5P_DEFAULT, buf); - } - H5Dclose(dataset); - H5Gclose(group); - - H5Tclose(fxdlenstr); - fxdlenstr = H5Tcopy(H5T_C_S1); - H5Tset_size(fxdlenstr, LENSTR); - H5Tset_cset(fxdlenstr, H5T_CSET_ASCII); - H5Tset_strpad(fxdlenstr, H5T_STR_SPACEPAD); - - group = H5Gcreate2(fid, "/g5", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - dataset = H5Dcreate2(group, "dset5", fxdlenstr, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - for(i = 0; (hsize_t)i < sdim; i++) { - start[0] = (hsize_t)i; - sprintf(buf, "This is row %1d of type H5T_STR_SPACEPAD of", i); - H5Tset_size(memtype, HDstrlen(buf) + 1); - H5Sselect_hyperslab(hyper_space, H5S_SELECT_SET, start, stride, count, block); - H5Dwrite(dataset, memtype, mem_space, hyper_space, H5P_DEFAULT, buf); - } - H5Dclose(dataset); - H5Gclose(group); - - - group = H5Gcreate2(fid, "/g6", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - dataset = H5Dcreate2(group, "dset6", fxdlenstr, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - for(i = 0; (hsize_t)i < sdim; i++) { - start[0] = (hsize_t)i; - sprintf(buf, "This is row %1d of type H5T_STR_SPACEPAD of string array", i); - H5Tset_size(memtype, HDstrlen(buf) + 1); - H5Sselect_hyperslab(hyper_space, H5S_SELECT_SET, start, stride, count, block); - H5Dwrite(dataset, memtype, mem_space, hyper_space, H5P_DEFAULT, buf); - } - - H5Dclose(dataset); - H5Gclose(group); - H5Tclose(fxdlenstr); - H5Tclose(memtype); - H5Sclose(mem_space); - H5Sclose(hyper_space); - H5Sclose(space); - H5Fclose(fid); -} - -static void gent_enum(void) -{ - /*some code is taken from enum.c in the test dir */ - hid_t file, type, space, dset; - int val; - enumtype data[] = {RED, GREEN, BLUE, GREEN, WHITE, - WHITE, BLACK, GREEN, BLUE, RED, - RED, BLUE, GREEN, BLACK, WHITE, - RED, WHITE, GREEN, GREEN, BLUE}; - hsize_t size[1] = {NELMTS(data)}; - - file = H5Fcreate(FILE15,H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* Try to test names with special characters */ - type = H5Tcreate(H5T_ENUM, sizeof(enumtype)); - H5Tenum_insert(type, "RED", (val = 0, &val)); - H5Tenum_insert(type, "GREEN\ngreen", (val = 1, &val)); - H5Tenum_insert(type, "BLUE blue", (val = 2, &val)); - H5Tenum_insert(type, "WHITE \"white\"", (val = 3, &val)); - H5Tenum_insert(type, "BLACK \'black\'", (val = 4, &val)); - H5Tcommit2(file, "enum normal", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - space = H5Screate_simple(1,size,NULL); - dset = H5Dcreate2(file,"table",type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Dwrite(dset, type, space, space, H5P_DEFAULT, data); - - H5Dclose(dset); - H5Sclose(space); - H5Fclose(file); -} - -static void gent_objref(void) -{ - /*some code is taken from enum.c in the test dir */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - - hid_t group; /* Group ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1; /* Datatype ID */ - hsize_t dims1[] = {SPACE1_DIM1}; - hobj_ref_t *wbuf, /* buffer to write to disk */ - *rbuf, /* buffer read from disk */ - *tbuf; /* temp. buffer read from disk */ - uint32_t *tu32; /* Temporary pointer to uint32 data */ - int i; /* counting variables */ - const char *write_comment = "Foo!"; /* Comments for group */ - - /* Allocate write & read buffers */ - wbuf = (hobj_ref_t*) HDmalloc(sizeof(hobj_ref_t) * SPACE1_DIM1); - rbuf = (hobj_ref_t*) HDmalloc(sizeof(hobj_ref_t) * SPACE1_DIM1); - tbuf = (hobj_ref_t*) HDmalloc(sizeof(hobj_ref_t) * SPACE1_DIM1); - - /* Create file */ - fid1 = H5Fcreate(FILE16, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* Create dataspace for datasets */ - sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); - - /* Create a group */ - group = H5Gcreate2(fid1, "Group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - /* Set group's comment */ - H5Oset_comment(group, write_comment); - - /* Create a dataset (inside Group1) */ - dataset = H5Dcreate2(group, "Dataset1", H5T_STD_U32BE, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - for(tu32 = (uint32_t *)((void*)wbuf), i = 0; i < SPACE1_DIM1; i++) - *tu32++ = (uint32_t)(i * 3); - - /* Write selection to disk */ - H5Dwrite(dataset, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf); - - /* Close Dataset */ - H5Dclose(dataset); - - /* Create another dataset (inside Group1) */ - dataset = H5Dcreate2(group, "Dataset2", H5T_STD_U8BE, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - /* Close Dataset */ - H5Dclose(dataset); - - /* Create a datatype to refer to */ - tid1 = H5Tcreate(H5T_COMPOUND, sizeof(s1_t)); - - /* Insert fields */ - H5Tinsert(tid1, "a", HOFFSET(s1_t,a), H5T_STD_I32BE); - - H5Tinsert(tid1, "b", HOFFSET(s1_t,b), H5T_IEEE_F32BE); - - H5Tinsert(tid1, "c", HOFFSET(s1_t,c), H5T_IEEE_F32BE); - - /* Save datatype for later */ - H5Tcommit2(group, "Datatype1", tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - /* Close datatype */ - H5Tclose(tid1); - - /* Close group */ - H5Gclose(group); - - /* Create a dataset */ - dataset = H5Dcreate2(fid1, "Dataset3", H5T_STD_REF_OBJ, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - /* Create reference to dataset */ - H5Rcreate(&wbuf[0], fid1, "/Group1/Dataset1", H5R_OBJECT, (hid_t)-1); - - /* Create reference to dataset */ - H5Rcreate(&wbuf[1], fid1, "/Group1/Dataset2", H5R_OBJECT, (hid_t)-1); - - /* Create reference to group */ - H5Rcreate(&wbuf[2], fid1, "/Group1", H5R_OBJECT, (hid_t)-1); - - /* Create reference to named datatype */ - H5Rcreate(&wbuf[3], fid1, "/Group1/Datatype1", H5R_OBJECT, (hid_t)-1); - - /* Write selection to disk */ - H5Dwrite(dataset, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf); - - /* Close disk dataspace */ - H5Sclose(sid1); - - /* Close Dataset */ - H5Dclose(dataset); - - /* Close file */ - H5Fclose(fid1); - - /* Free memory buffers */ - HDfree(wbuf); - HDfree(rbuf); - HDfree(tbuf); -} - -static void gent_datareg(void) -{ - /*some code is taken from enum.c in the test dir */ - - hid_t fid1; /* HDF5 File IDs */ - hid_t dset1, /* Dataset ID */ - dset2; /* Dereferenced dataset ID */ - hid_t sid1, /* Dataspace ID #1 */ - sid2; /* Dataspace ID #2 */ - hsize_t dims1[] = {SPACE1_DIM1}, - dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; - hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ - hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */ - hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ - hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ - hsize_t coord1[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */ - hdset_reg_ref_t *wbuf, /* buffer to write to disk */ - *rbuf; /* buffer read from disk */ - uint8_t *dwbuf, /* Buffer for writing numeric data to disk */ - *drbuf; /* Buffer for reading numeric data from disk */ - uint8_t *tu8; /* Temporary pointer to uint8 data */ - int i; /* counting variables */ - - /* Allocate write & read buffers */ - wbuf = (hdset_reg_ref_t*) HDcalloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1); - rbuf = (hdset_reg_ref_t*) HDmalloc(sizeof(hdset_reg_ref_t)*SPACE1_DIM1); - dwbuf = (uint8_t*) HDmalloc(sizeof(uint8_t)*SPACE2_DIM1*SPACE2_DIM2); - drbuf = (uint8_t*) HDcalloc(sizeof(uint8_t),SPACE2_DIM1*SPACE2_DIM2); - - /* Create file */ - fid1 = H5Fcreate(FILE17, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* Create dataspace for datasets */ - sid2 = H5Screate_simple(SPACE2_RANK, dims2, NULL); - - /* Create a dataset */ - dset2 = H5Dcreate2(fid1, "Dataset2", H5T_STD_U8BE, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - for(tu8 = dwbuf, i = 0; i < SPACE2_DIM1 * SPACE2_DIM2; i++) - *tu8++ = (uint8_t)(i * 3); - - /* Write selection to disk */ - H5Dwrite(dset2, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, dwbuf); - - /* Close Dataset */ - H5Dclose(dset2); - - /* Create dataspace for the reference dataset */ - sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); - - /* Create a dataset */ - dset1 = H5Dcreate2(fid1, "Dataset1", H5T_STD_REF_DSETREG, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - /* Create references */ - - /* Select 6x6 hyperslab for first reference */ - start[0] = 2; start[1] = 2; - stride[0] = 1; stride[1] = 1; - count[0] = 6; count[1] = 6; - block[0] = 1; block[1] = 1; - H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block); - - H5Sget_select_npoints(sid2); - - /* Store first dataset region */ - H5Rcreate(&wbuf[0], fid1, "/Dataset2", H5R_DATASET_REGION, sid2); - - /* Select sequence of ten points for second reference */ - coord1[0][0]=6; coord1[0][1]=9; - coord1[1][0]=2; coord1[1][1]=2; - coord1[2][0]=8; coord1[2][1]=4; - coord1[3][0]=1; coord1[3][1]=6; - coord1[4][0]=2; coord1[4][1]=8; - coord1[5][0]=3; coord1[5][1]=2; - coord1[6][0]=0; coord1[6][1]=4; - coord1[7][0]=9; coord1[7][1]=0; - coord1[8][0]=7; coord1[8][1]=1; - coord1[9][0]=3; coord1[9][1]=3; - H5Sselect_elements(sid2,H5S_SELECT_SET,POINT1_NPOINTS,(hsize_t *)coord1); - - H5Sget_select_npoints(sid2); - - /* Store second dataset region */ - H5Rcreate(&wbuf[1],fid1,"/Dataset2",H5R_DATASET_REGION,sid2); - - /* Write selection to disk */ - H5Dwrite(dset1,H5T_STD_REF_DSETREG,H5S_ALL,H5S_ALL,H5P_DEFAULT,wbuf); - - /* Close disk dataspace */ - H5Sclose(sid1); - - /* Close Dataset */ - H5Dclose(dset1); - - /* Close uint8 dataset dataspace */ - H5Sclose(sid2); - - /* Close file */ - H5Fclose(fid1); - - /* Free memory buffers */ - HDfree(wbuf); - HDfree(rbuf); - HDfree(dwbuf); - HDfree(drbuf); -} - -static void gent_attrreg(void) -{ - /*some code is taken from enum.c in the test dir */ - - hid_t fid1; /* HDF5 File IDs */ - hid_t dset1; /* Dataset ID */ - hid_t dset2; /* Dereferenced dataset ID */ - hid_t sid1; /* Dataspace ID #1 */ - hid_t sid2; /* Dataspace ID #2 */ - hid_t sid3; /* Dataspace ID #3 */ - hid_t attr1; /* Attribute ID */ - hsize_t dims1[] = {SPACE1_DIM1}; - hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; - hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ - hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */ - hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ - hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ - hsize_t coord1[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */ - hdset_reg_ref_t *wbuf; /* buffer to write to disk */ - hdset_reg_ref_t *rbuf; /* buffer read from disk */ - uint8_t *dwbuf; /* Buffer for writing numeric data to disk */ - uint8_t *drbuf; /* Buffer for reading numeric data from disk */ - uint8_t *tu8; /* Temporary pointer to uint8 data */ - int i; /* counting variables */ - - /* Allocate write & read buffers */ - wbuf = (hdset_reg_ref_t*) HDcalloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1); - rbuf = (hdset_reg_ref_t*) HDmalloc(sizeof(hdset_reg_ref_t)*SPACE1_DIM1); - dwbuf = (uint8_t*) HDmalloc(sizeof(uint8_t)*SPACE2_DIM1*SPACE2_DIM2); - drbuf = (uint8_t*) HDcalloc(sizeof(uint8_t),SPACE2_DIM1*SPACE2_DIM2); - - /* Create file */ - fid1 = H5Fcreate(FILE64, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* Create dataspace for datasets */ - sid2 = H5Screate_simple(SPACE2_RANK, dims2, NULL); - - /* Create a dataset */ - dset2 = H5Dcreate2(fid1, "Dataset2", H5T_STD_U8BE, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - for(tu8 = dwbuf, i = 0; i < SPACE2_DIM1 * SPACE2_DIM2; i++) - *tu8++ = (uint8_t)(i * 3); - - /* Write selection to disk */ - H5Dwrite(dset2, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, dwbuf); - - /* Close Dataset */ - H5Dclose(dset2); - - /* - * Create dataset with a null dataspace to serve as the parent for - * the attribute. - */ - sid1 = H5Screate (H5S_NULL); - dset1 = H5Dcreate2 (fid1, "Dataset1", H5T_STD_I32LE, sid1, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); - H5Sclose (sid1); - - /* Create references */ - - /* Select 6x6 hyperslab for first reference */ - start[0] = 2; start[1] = 2; - stride[0] = 1; stride[1] = 1; - count[0] = 6; count[1] = 6; - block[0] = 1; block[1] = 1; - H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block); - - H5Sget_select_npoints(sid2); - - /* Store first dataset region */ - H5Rcreate(&wbuf[0], fid1, "/Dataset2", H5R_DATASET_REGION, sid2); - - /* Select sequence of ten points for second reference */ - coord1[0][0]=6; coord1[0][1]=9; - coord1[1][0]=2; coord1[1][1]=2; - coord1[2][0]=8; coord1[2][1]=4; - coord1[3][0]=1; coord1[3][1]=6; - coord1[4][0]=2; coord1[4][1]=8; - coord1[5][0]=3; coord1[5][1]=2; - coord1[6][0]=0; coord1[6][1]=4; - coord1[7][0]=9; coord1[7][1]=0; - coord1[8][0]=7; coord1[8][1]=1; - coord1[9][0]=3; coord1[9][1]=3; - H5Sselect_elements(sid2,H5S_SELECT_SET,POINT1_NPOINTS,(hsize_t *)coord1); - - H5Sget_select_npoints(sid2); - - /* Store second dataset region */ - H5Rcreate(&wbuf[1],fid1,"/Dataset2",H5R_DATASET_REGION,sid2); - - /* Create dataspace for the attribute */ - sid3 = H5Screate_simple(SPACE1_RANK, dims1, NULL); - - /* Create the attribute and write the region references to it. */ - attr1 = H5Acreate2 (dset1, "Attribute1", H5T_STD_REF_DSETREG, sid3, H5P_DEFAULT, - H5P_DEFAULT); - H5Awrite (attr1, H5T_STD_REF_DSETREG, wbuf); - - /* Close attribute dataspace */ - H5Sclose(sid3); - - /* Close attribute */ - H5Aclose (attr1); - - /* Close Dataset */ - H5Dclose(dset1); - - /* Close uint8 dataset dataspace */ - H5Sclose(sid2); - - /* Close file */ - H5Fclose(fid1); - - /* Free memory buffers */ - HDfree(wbuf); - HDfree(rbuf); - HDfree(dwbuf); - HDfree(drbuf); -} - -/*taken from Elena's compound test file*/ -static void gent_nestcomp(void) -{ - /* Compound memeber of the compound datatype*/ - typedef struct cmp_t { - char a; - float b[2]; - } cmp_t; - - /* First structure and dataset*/ - typedef struct s1_t { - int a; - float b; - double c; - cmp_t d; - } s2_t; - hid_t cmp_tid; /* Handle for the compound datatype */ - hid_t char_id; /* Handle for the string datatype */ - hid_t array_dt; - hsize_t array_dims[] = {2}; /* Dataspace dimensions */ - unsigned ndims = 1; /* Number of dimensions in the array field */ - - s2_t s1[10]; - hid_t s2_tid; /* File datatype identifier */ - - int i; - hid_t file, dataset, space; /* Handles */ - herr_t status; - hsize_t dim[] = {10}; /* Dataspace dimensions */ - - char datasetname[] = "ArrayOfStructures"; - - - /* - * Initialize the data - */ - for(i = 0; i< 10; i++) { - s1[i].a = i; - s1[i].b = (float)(i*i); - s1[i].c = 1.0F/(float)(i + 1); - s1[i].d.a = (char)(65 + i); - s1[i].d.b[0] = -100.0F; - s1[i].d.b[1] = 100.0F; - } - - /* - * Create the data space. - */ - space = H5Screate_simple(1, dim, NULL); - - /* - * Create the file. - */ - file = H5Fcreate(FILE18, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* - * Create the memory data type. - */ - /* - * Create a datatype for compound field first. - */ - cmp_tid = H5Tcreate (H5T_COMPOUND, sizeof(cmp_t)); - - /* We are using C string of length one to represent "real" character */ - char_id = H5Tcopy(H5T_C_S1); - H5Tset_strpad(char_id, H5T_STR_NULLTERM); - H5Tinsert(cmp_tid, "char_name", HOFFSET(cmp_t, a), char_id); - - array_dt = H5Tarray_create2(H5T_NATIVE_FLOAT, ndims, array_dims); - H5Tinsert(cmp_tid, "array_name", HOFFSET(cmp_t, b), array_dt); - H5Tclose(array_dt); - - s2_tid = H5Tcreate (H5T_COMPOUND, sizeof(s2_t)); - H5Tinsert(s2_tid, "a_name", HOFFSET(s2_t, a), H5T_NATIVE_INT); - H5Tinsert(s2_tid, "c_name", HOFFSET(s2_t, c), H5T_NATIVE_DOUBLE); - H5Tinsert(s2_tid, "b_name", HOFFSET(s2_t, b), H5T_NATIVE_FLOAT); - - /* Insert compound memeber created above */ - H5Tinsert(s2_tid, "d_name", HOFFSET(s2_t, d), cmp_tid); - - /* - * Create the dataset. - */ - dataset = H5Dcreate2(file, datasetname, s2_tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - /* - * Wtite data to the dataset; - */ - status = H5Dwrite(dataset, s2_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, s1); - if(status < 0) - fprintf(stderr, "gent_nestcomp H5Dwrite failed\n"); - - /* - * Release resources - */ - H5Tclose(s2_tid); - H5Tclose(cmp_tid); - H5Tclose(char_id); - H5Sclose(space); - H5Dclose(dataset); - H5Fclose(file); -} - -static void gent_opaque(void) -{ - hid_t file, type, dataset, space; - char test[100][2]; - int x; - hsize_t dim = 2; - - for(x = 0; x < 100; x++){ - test[x][0] = (char)x; - test[x][1] = (char)(99 - x); - } - - /* - * Create the data space. - */ - space = H5Screate_simple(1, &dim, NULL); - - /* - * Create the file. - */ - file = H5Fcreate(FILE19, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* - * Create the memory datatype. - */ - type = H5Tcreate(H5T_OPAQUE, sizeof(char) * 100 * 2); - H5Tset_tag(type, "test opaque type"); - - /* - * Create the dataset. - */ - dataset = H5Dcreate2(file, "opaque test", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - /* - * Write data to the dataset; - */ - H5Dwrite(dataset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, test); - - H5Tclose(type); - H5Sclose(space); - H5Dclose(dataset); - H5Fclose(file); -} - -static void gent_bitfields(void) -{ - hid_t file, grp=-1, type=-1, space=-1, dset=-1; - size_t i; - hsize_t nelmts; - unsigned char buf[32]; - - file = H5Fcreate(FILE20, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - if((grp = H5Gcreate2(file, "typetests", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - - /* bitfield_1 */ - nelmts = sizeof(buf); - if((type = H5Tcopy(H5T_STD_B8LE)) < 0 || - (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 < sizeof buf; i++) - buf[i] = (unsigned char)0xff ^ (unsigned char)i; - if(H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - goto error; - if(H5Sclose(space) < 0) goto error; - if(H5Tclose(type) < 0) goto error; - if(H5Dclose(dset) < 0) goto error; - - /* bitfield_2 */ - nelmts = sizeof(buf)/2; - if((type = H5Tcopy(H5T_STD_B16LE)) < 0 || - (space = H5Screate_simple(1, &nelmts, NULL)) < 0 || - (dset = H5Dcreate2(grp, "bitfield_2", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; - for(i = 0; i < sizeof buf; i++) - buf[i] = (unsigned char)0xff ^ (unsigned char)i; - if(H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - goto error; - if(H5Sclose(space) < 0) goto error; - if(H5Tclose(type) < 0) goto error; - if(H5Dclose(dset) < 0) goto error; - if(H5Gclose(grp) < 0) goto error; - H5Fclose(file); - - error: - H5E_BEGIN_TRY { - H5Gclose(grp); - H5Tclose(type); - H5Sclose(space); - H5Dclose(dset); - } H5E_END_TRY; -} - -static void gent_vldatatypes(void) -{ - hvl_t adata, wdata[SPACE1_DIM1]; - hid_t file, dset, space, type; - hsize_t dims[] = { SPACE1_DIM1 }; - int i; - herr_t ret=0; - - file = H5Fcreate(FILE21, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* Allocate and initialize VL dataset to write */ - for(i = 0; i < SPACE1_DIM1; i++) { - int j; - - wdata[i].p = HDmalloc((size_t)(i + 1) * sizeof(int)); - wdata[i].len = (size_t)(i + 1); - - for(j = 0; j < i + 1; j++) - ((int *)wdata[i].p)[j] = i * 10 + j; - } - - /* write out the integers in little-endian format */ - space = H5Screate_simple(SPACE1_RANK, dims, NULL); - type = H5Tvlen_create(H5T_NATIVE_INT); - dset = H5Dcreate2(file, "Dataset1.0", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - ret = H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); - HDassert(ret >= 0); - ret = H5Dvlen_reclaim(type, space, H5P_DEFAULT, wdata); - HDassert(ret >= 0); - - ret = H5Dclose(dset); - HDassert(ret >= 0); - ret = H5Tclose(type); - HDassert(ret >= 0); - ret = H5Sclose(space); - HDassert(ret >= 0); - - /* Allocate and initialize VL dataset to write */ - for(i = 0; i < SPACE1_DIM1; i++) { - int j; - - wdata[i].p = HDmalloc((size_t)(i + 1) * sizeof(float)); - wdata[i].len = (size_t)(i + 1); - - for(j = 0; j < i + 1; j++) - ((float *)wdata[i].p)[j] = (float)((float)(i * 10) + ((float)j) / 10.0F); - } /* end for */ - - /* write out the floats in little-endian format */ - space = H5Screate_simple(SPACE1_RANK, dims, NULL); - type = H5Tvlen_create(H5T_NATIVE_FLOAT); - dset = H5Dcreate2(file, "Dataset2.0", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - ret = H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); - HDassert(ret >= 0); - ret = H5Dvlen_reclaim(type, space, H5P_DEFAULT, wdata); - HDassert(ret >= 0); - - ret = H5Dclose(dset); - HDassert(ret >= 0); - ret = H5Tclose(type); - HDassert(ret >= 0); - ret = H5Sclose(space); - HDassert(ret >= 0); - - /* Allocate and initialize a scalar VL dataset to write */ - adata.p = HDmalloc(37 * sizeof(int)); - adata.len = 37; - - for(i = 0; i < 37; i++) - ((int *)adata.p)[i] = i * 2; - - /* write out scalar VL dataset in little-endian format */ - space = H5Screate_simple(0, NULL, NULL); - type = H5Tvlen_create(H5T_NATIVE_INT); - dset = H5Dcreate2(file, "Dataset3.0", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - ret = H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, &adata); - HDassert(ret >= 0); - ret = H5Dvlen_reclaim(type, space, H5P_DEFAULT, &adata); - HDassert(ret >= 0); - - ret = H5Dclose(dset); - HDassert(ret >= 0); - ret = H5Tclose(type); - HDassert(ret >= 0); - ret = H5Sclose(space); - HDassert(ret >= 0); - ret = H5Fclose(file); - HDassert(ret >= 0); -} - -static void -gent_vldatatypes2(void) -{ - hvl_t wdata[SPACE1_DIM1]; /* Information to write */ - hvl_t *t1; /* Temporary pointer to VL information */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1, tid2; /* Datatype IDs */ - hsize_t dims1[] = {SPACE1_DIM1}; - unsigned i,j,k; /* counting variables */ - herr_t ret; /* Generic return value */ - - /* Allocate and initialize VL data to write */ - for(i = 0; i < SPACE1_DIM1; i++) { - wdata[i].p = (hvl_t *)HDmalloc((i + 1) * sizeof(hvl_t)); - if(wdata[i].p == NULL) { - printf("Cannot allocate memory for VL data! i=%u\n", i); - return; - } /* end if */ - wdata[i].len = i + 1; - for(t1 = (hvl_t *)wdata[i].p, j = 0; j < (i + 1); j++, t1++) { - t1->p = (unsigned *)HDmalloc((j + 1) * sizeof(unsigned)); - if(t1->p == NULL) { - printf("Cannot allocate memory for VL data! i=%u, j=%u\n",i,j); - return; - } /* end if */ - t1->len=j+1; - for(k=0; k<(j+1); k++) - ((unsigned int *)t1->p)[k]=i*100+j*10+k; - } /* end for */ - } /* end for */ - - /* Create file */ - fid1 = H5Fcreate(FILE22, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* Create dataspace for datasets */ - sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); - - /* Create a VL datatype to refer to */ - tid1 = H5Tvlen_create(H5T_NATIVE_UINT); - - /* Create the base VL type */ - tid2 = H5Tvlen_create(tid1); - - /* Create a dataset */ - dataset = H5Dcreate2(fid1, "Dataset1", tid2, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - /* Write dataset to disk */ - ret = H5Dwrite(dataset, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); - HDassert(ret >= 0); - - /* Reclaim the write VL data */ - ret = H5Dvlen_reclaim(tid2, sid1, H5P_DEFAULT, wdata); - HDassert(ret >= 0); - - /* Close Dataset */ - ret = H5Dclose(dataset); - HDassert(ret >= 0); - ret = H5Tclose(tid2); - HDassert(ret >= 0); - ret = H5Tclose(tid1); - HDassert(ret >= 0); - ret = H5Sclose(sid1); - HDassert(ret >= 0); - ret = H5Fclose(fid1); - HDassert(ret >= 0); - -} - -static void gent_vldatatypes3(void) -{ - typedef struct { /* Struct that the VL sequences are composed of */ - int i; - float f; - hvl_t v; - } s1; - s1 wdata[SPACE1_DIM1]; /* Information to write */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1, tid2; /* Datatype IDs */ - hsize_t dims1[] = {SPACE1_DIM1}; - unsigned i,j; /* counting variables */ - herr_t ret; /* Generic return value */ - - /* Allocate and initialize VL data to write */ - for(i=0; i<SPACE1_DIM1; i++) { - wdata[i].i = (int)(i * 10); - wdata[i].f = (float)((float)(i * 20)/3.0F); - wdata[i].v.p = HDmalloc((size_t)(i + 1) * sizeof(unsigned int)); - wdata[i].v.len = (size_t)(i + 1); - for(j = 0; j < (i + 1); j++) - ((unsigned int *)wdata[i].v.p)[j] = i * 10 + j; - } /* end for */ - - /* Create file */ - fid1 = H5Fcreate(FILE23, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* Create dataspace for datasets */ - sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); - - /* Create a VL datatype to refer to */ - tid1 = H5Tvlen_create(H5T_NATIVE_UINT); - - /* Create the base compound type */ - tid2 = H5Tcreate(H5T_COMPOUND, sizeof(s1)); - - /* Insert fields */ - ret = H5Tinsert(tid2, "i", HOFFSET(s1, i), H5T_NATIVE_INT); - HDassert(ret >= 0); - ret = H5Tinsert(tid2, "f", HOFFSET(s1, f), H5T_NATIVE_FLOAT); - HDassert(ret >= 0); - ret = H5Tinsert(tid2, "v", HOFFSET(s1, v), tid1); - HDassert(ret >= 0); - - /* Create a dataset */ - dataset = H5Dcreate2(fid1, "Dataset1", tid2, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - /* Write dataset to disk */ - ret = H5Dwrite(dataset, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); - HDassert(ret >= 0); - - /* Reclaim the write VL data */ - ret = H5Dvlen_reclaim(tid2, sid1, H5P_DEFAULT, wdata); - HDassert(ret >= 0); - - /* Close Dataset */ - ret = H5Dclose(dataset); - HDassert(ret >= 0); - ret = H5Tclose(tid2); - HDassert(ret >= 0); - ret = H5Tclose(tid1); - HDassert(ret >= 0); - ret = H5Sclose(sid1); - HDassert(ret >= 0); - ret = H5Fclose(fid1); - HDassert(ret >= 0); -} - -static void gent_vldatatypes4(void) -{ - typedef struct { /* Struct that the VL sequences are composed of */ - int i; - float f; - } s1; - hvl_t wdata[SPACE1_DIM1]; /* Information to write */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1, tid2; /* Datatype IDs */ - hsize_t dims1[] = {SPACE1_DIM1}; - unsigned i,j; /* counting variables */ - herr_t ret; /* Generic return value */ - - /* Allocate and initialize VL data to write */ - for(i=0; i<SPACE1_DIM1; i++) { - wdata[i].p = HDmalloc((i + 1) * sizeof(s1)); - wdata[i].len = i + 1; - for(j = 0; j < (i + 1); j++) { - ((s1 *)wdata[i].p)[j].i = (int)(i * 10 + j); - ((s1 *)wdata[i].p)[j].f = (float)((float)(i * 20 + j) / 3.0F); - } /* end for */ - } /* end for */ - - /* Create file */ - fid1 = H5Fcreate(FILE24, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* Create dataspace for datasets */ - sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); - - /* Create the base compound type */ - tid2 = H5Tcreate(H5T_COMPOUND, sizeof(s1)); - - /* Insert fields */ - ret = H5Tinsert(tid2, "i", HOFFSET(s1, i), H5T_NATIVE_INT); - HDassert(ret >= 0); - ret = H5Tinsert(tid2, "f", HOFFSET(s1, f), H5T_NATIVE_FLOAT); - HDassert(ret >= 0); - - /* Create a datatype to refer to */ - tid1 = H5Tvlen_create(tid2); - - /* Create a dataset */ - dataset = H5Dcreate2(fid1, "Dataset1", tid1, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - /* Write dataset to disk */ - ret = H5Dwrite(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); - HDassert(ret >= 0); - - /* Reclaim the write VL data */ - ret = H5Dvlen_reclaim(tid1, sid1, H5P_DEFAULT, wdata); - HDassert(ret >= 0); - - /* Close Dataset */ - ret = H5Dclose(dataset); - HDassert(ret >= 0); - ret = H5Tclose(tid1); - HDassert(ret >= 0); - ret = H5Tclose(tid2); - HDassert(ret >= 0); - ret = H5Sclose(sid1); - HDassert(ret >= 0); - ret = H5Fclose(fid1); - HDassert(ret >= 0); -} - -/* Generate a variable-length dataset with NULL values in it */ -static void gent_vldatatypes5(void) -{ - hvl_t wdata [SPACE1_DIM1]; - hid_t fid1; - hid_t dataset; - hid_t sid1; - hid_t tid1; - hsize_t dims1[] = {SPACE1_DIM1}; - int i,j; /* counting variable */ - herr_t ret; /* Generic return value */ - - /* initialize data for dataset */ - for(i=0; i<SPACE1_DIM1; i++) { - if(i%2) { - wdata[i].len=0; - wdata[i].p=NULL; - } /* end if */ - else { - wdata[i].len = (size_t)(i + 5); - wdata[i].p = HDmalloc(sizeof(unsigned) * (size_t)(i + 5)); - for(j = 0; j < i + 5; j++) - ((unsigned *)wdata[i].p)[j] = (unsigned)(j * 2); - } /* end else */ - } /* end for */ - - /* Create file */ - fid1 = H5Fcreate(FILE43, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDassert(fid1>0); - - /* Create dataspace for datasets */ - sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); - HDassert(sid1>0); - - /* Create a datatype to refer to */ - tid1 = H5Tvlen_create(H5T_NATIVE_UINT); - HDassert(tid1>0); - - /* Create a dataset */ - dataset = H5Dcreate2(fid1, F43_DSETNAME, tid1, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - HDassert(dataset>0); - - ret = H5Dwrite(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); - HDassert(ret >= 0); - - ret = H5Dclose(dataset); - HDassert(ret >= 0); - - ret = H5Dvlen_reclaim(tid1, sid1, H5P_DEFAULT, wdata); - HDassert(ret >= 0); - - ret = H5Tclose(tid1); - HDassert(ret >= 0); - - ret = H5Sclose (sid1); - HDassert(ret >= 0); - - ret = H5Fclose (fid1); - HDassert(ret >= 0); -} - -/* This is big enough to make h5dump to use hyperslap to read - from file and display portion by portion. This also prints out array indices - via region reference for testing refion reference output. - Note: this was added originally prepared for bug2092. before the fix h5dump didn't - display array indices every 262 x N (N > 0) based on 2000x1000 dims. - */ -#define SPACE_ARRAY1BIG_DIM 2000 -#define ARRAY1BIG_DIM 1000 - -static void gent_array1_big(void) -{ - int *wdata; /* Information to write */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1; /* Datatype ID */ - hsize_t sdims1[] = {SPACE_ARRAY1BIG_DIM}; - hsize_t tdims1[] = {ARRAY1BIG_DIM}; - int i,j; /* counting variables */ - herr_t ret; /* Generic return value */ - - - /* for region reference dataset */ - hid_t dset2; - hid_t sid2; - hsize_t dims2[] = {SPACE1_DIM1}; - hsize_t start[SPACE1_RANK]; /* Starting location of hyperslab */ - hsize_t stride[SPACE1_RANK]; /* Stride of hyperslab */ - hsize_t count[SPACE1_RANK]; /* Element count of hyperslab */ - hsize_t block[SPACE1_RANK]; /* Block size of hyperslab */ - hdset_reg_ref_t *wbuf; /* buffer to write to disk */ - - start[0] = 0; - stride[0] = 1; - count[0] = 999; - block[0] = 1; - - /* Allocate write & read buffers */ - wbuf = (hdset_reg_ref_t*) HDcalloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1); - wdata = (int *)HDmalloc(sizeof(int) * (size_t)(SPACE_ARRAY1BIG_DIM * ARRAY1BIG_DIM)); - - /* Allocate and initialize array data to write */ - for(i = 0; i < SPACE_ARRAY1BIG_DIM; i++) - for(j = 0; j < ARRAY1BIG_DIM; j++) - *(wdata + (i * ARRAY1BIG_DIM) + j) = i * 1; - - /* Create file */ - fid1 = H5Fcreate(FILE25_BIG, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /*------------------------- - * Array type dataset - */ - /* Create dataspace for datasets */ - sid1 = H5Screate_simple(SPACE1_RANK, sdims1, NULL); - - /* Create a datatype to refer to */ - tid1 = H5Tarray_create2(H5T_NATIVE_INT, ARRAY1_RANK, tdims1); - - /* Create a dataset */ - dataset = H5Dcreate2(fid1, "Dataset1", tid1, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - /* Write dataset to disk */ - ret = H5Dwrite(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); - HDassert(ret >= 0); - - /*--------------------------- - * Region Reference dataset - */ - /* Create dataspace for the reference dataset */ - sid2 = H5Screate_simple(SPACE1_RANK, dims2, NULL); - - /* Create a dataset */ - dset2 = H5Dcreate2(fid1, "Dataset2", H5T_STD_REF_DSETREG, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - /* Create references */ - H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, stride, count, block); - - H5Sget_select_npoints(sid1); - - /* Create Dataset1 region */ - H5Rcreate(&wbuf[0], fid1, "/Dataset1", H5R_DATASET_REGION, sid1); - - /* Write selection to disk */ - H5Dwrite(dset2,H5T_STD_REF_DSETREG,H5S_ALL,H5S_ALL,H5P_DEFAULT,wbuf); - - /* Close Dataset */ - ret = H5Dclose(dataset); - HDassert(ret >= 0); - ret = H5Tclose(tid1); - HDassert(ret >= 0); - ret = H5Sclose(sid1); - HDassert(ret >= 0); - ret = H5Fclose(fid1); - HDassert(ret >= 0); - - /* Release memory */ - HDfree(wbuf); - HDfree(wdata); -} - -static void gent_array1(void) -{ - int wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1; /* Datatype ID */ - hsize_t sdims1[] = {SPACE1_DIM1}; - hsize_t tdims1[] = {ARRAY1_DIM1}; - int i,j; /* counting variables */ - herr_t ret; /* Generic return value */ - - /* Allocate and initialize array data to write */ - for(i=0; i<SPACE1_DIM1; i++) - for(j=0; j<ARRAY1_DIM1; j++) - wdata[i][j]=i*10+j; - - /* Create file */ - fid1 = H5Fcreate(FILE25, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* Create dataspace for datasets */ - sid1 = H5Screate_simple(SPACE1_RANK, sdims1, NULL); - - /* Create a datatype to refer to */ - tid1 = H5Tarray_create2(H5T_NATIVE_INT, ARRAY1_RANK, tdims1); - - /* Create a dataset */ - dataset = H5Dcreate2(fid1, "Dataset1", tid1, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - /* Write dataset to disk */ - ret = H5Dwrite(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); - HDassert(ret >= 0); - - /* Close Dataset */ - ret = H5Dclose(dataset); - HDassert(ret >= 0); - ret = H5Tclose(tid1); - HDassert(ret >= 0); - ret = H5Sclose(sid1); - HDassert(ret >= 0); - ret = H5Fclose(fid1); - HDassert(ret >= 0); -} - -static void gent_array2(void) -{ - int wdata[SPACE1_DIM1][ARRAY2_DIM1][ARRAY2_DIM2][ARRAY2_DIM3]; /* Information to write */ - hid_t fid; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t tid; /* Datatype ID */ - hsize_t sdims1[] = {SPACE1_DIM1}; - hsize_t tdims2[] = {ARRAY2_DIM1,ARRAY2_DIM2,ARRAY2_DIM3}; - int i,j,k,l; /* counting variables */ - herr_t ret; /* Generic return value */ - - /* Allocate and initialize array data to write */ - for(i=0; i<SPACE1_DIM1; i++) - for(j=0; j<ARRAY2_DIM1; j++) - for(k=0; k<ARRAY2_DIM2; k++) - for(l=0; l<ARRAY2_DIM3; l++) - wdata[i][j][k][l]=i*1000+j*100+k*10+l; - - /* Create file */ - fid = H5Fcreate(FILE26, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* Create dataspace for datasets */ - sid = H5Screate_simple(SPACE1_RANK, sdims1, NULL); - - /* Create a datatype to refer to */ - tid = H5Tarray_create2(H5T_NATIVE_INT, ARRAY2_RANK, tdims2); - - /* Create a dataset */ - dataset = H5Dcreate2(fid, "Dataset1", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - /* Write dataset to disk */ - ret = H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); - HDassert(ret >= 0); - - /* Close Dataset */ - ret = H5Dclose(dataset); - HDassert(ret >= 0); - ret = H5Tclose(tid); - HDassert(ret >= 0); - ret = H5Sclose(sid); - HDassert(ret >= 0); - ret = H5Fclose(fid); - HDassert(ret >= 0); -} - -static void gent_array3(void) -{ - int wdata[SPACE1_DIM1][ARRAY1_DIM1][ARRAY3_DIM1][ARRAY3_DIM2]; /* Information to write */ - hid_t fid; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t tid1; /* 1-D array Datatype ID */ - hid_t tid2; /* 2-D array Datatype ID */ - hsize_t sdims1[] = {SPACE1_DIM1}; - hsize_t tdims1[] = {ARRAY1_DIM1}; - hsize_t tdims2[] = {ARRAY3_DIM1,ARRAY3_DIM2}; - int i,j,k,l; /* counting variables */ - herr_t ret; /* Generic return value */ - - /* Allocate and initialize array data to write */ - for(i=0; i<SPACE1_DIM1; i++) - for(j=0; j<ARRAY1_DIM1; j++) - for(k=0; k<ARRAY3_DIM1; k++) - for(l=0; l<ARRAY3_DIM2; l++) - wdata[i][j][k][l]=i*1000+j*100+k*10+l; - - /* Create file */ - fid = H5Fcreate(FILE27, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* Create dataspace for datasets */ - sid = H5Screate_simple(SPACE1_RANK, sdims1, NULL); - - /* Create a 2-D datatype to refer to */ - tid2 = H5Tarray_create2(H5T_NATIVE_INT, ARRAY3_RANK, tdims2); - - /* Create a 1-D datatype to refer to */ - tid1 = H5Tarray_create2(tid2, ARRAY1_RANK, tdims1); - - /* Create a dataset */ - dataset = H5Dcreate2(fid, "Dataset1", tid1, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - /* Write dataset to disk */ - ret = H5Dwrite(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); - HDassert(ret >= 0); - - /* Close Dataset */ - ret = H5Dclose(dataset); - HDassert(ret >= 0); - ret = H5Tclose(tid1); - HDassert(ret >= 0); - ret = H5Tclose(tid2); - HDassert(ret >= 0); - ret = H5Sclose(sid); - HDassert(ret >= 0); - ret = H5Fclose(fid); - HDassert(ret >= 0); -} - -static void gent_array4(void) -{ - typedef struct { /* Typedef for compound datatype */ - int i; - float f; - } s2_t; - s2_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1; /* Array Datatype ID */ - hid_t tid2; /* Compound Datatype ID */ - hsize_t sdims1[] = {SPACE1_DIM1}; - hsize_t tdims1[] = {ARRAY1_DIM1}; - int i,j; /* counting variables */ - herr_t ret; /* Generic return value */ - - /* Initialize array data to write */ - for(i=0; i<SPACE1_DIM1; i++) - for(j=0; j<ARRAY1_DIM1; j++) { - wdata[i][j].i = i * 10 + j; - wdata[i][j].f = (float)((float)i * 2.5F + (float)j); - } /* end for */ - - /* Create file */ - fid1 = H5Fcreate(FILE28, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* Create dataspace for datasets */ - sid1 = H5Screate_simple(SPACE1_RANK, sdims1, NULL); - - /* Create a compound datatype to refer to */ - tid2 = H5Tcreate(H5T_COMPOUND, sizeof(s2_t)); - - /* Insert integer field */ - ret = H5Tinsert(tid2, "i", HOFFSET(s2_t, i), H5T_NATIVE_INT); - HDassert(ret >= 0); - - /* Insert float field */ - ret = H5Tinsert(tid2, "f", HOFFSET(s2_t, f), H5T_NATIVE_FLOAT); - HDassert(ret >= 0); - - /* Create an array datatype to refer to */ - tid1 = H5Tarray_create2(tid2, ARRAY1_RANK, tdims1); - - /* Close compound datatype */ - ret = H5Tclose(tid2); - HDassert(ret >= 0); - - /* Create a dataset */ - dataset = H5Dcreate2(fid1, "Dataset1", tid1, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - /* Write dataset to disk */ - ret = H5Dwrite(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); - HDassert(ret >= 0); - - /* Close Dataset */ - ret = H5Dclose(dataset); - HDassert(ret >= 0); - ret = H5Tclose(tid1); - HDassert(ret >= 0); - ret = H5Sclose(sid1); - HDassert(ret >= 0); - ret = H5Fclose(fid1); - HDassert(ret >= 0); -} - -static void gent_array5(void) -{ - typedef struct { /* Typedef for compound datatype */ - int i; - float f[ARRAY1_DIM1]; - } s2_t; - s2_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1; /* Array Datatype ID */ - hid_t tid2; /* Compound Datatype ID */ - hid_t tid3; /* Nested Array Datatype ID */ - hsize_t sdims1[] = {SPACE1_DIM1}; - hsize_t tdims1[] = {ARRAY1_DIM1}; - int i,j,k; /* counting variables */ - herr_t ret; /* Generic return value */ - - /* Initialize array data to write */ - for(i=0; i<SPACE1_DIM1; i++) - for(j=0; j<ARRAY1_DIM1; j++) { - wdata[i][j].i = i * 10 + j; - for(k=0; k<ARRAY1_DIM1; k++) - wdata[i][j].f[k] = (float)((float)i * 10 + (float)j * 2.5F + (float)k); - } /* end for */ - - /* Create file */ - fid1 = H5Fcreate(FILE29, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* Create dataspace for datasets */ - sid1 = H5Screate_simple(SPACE1_RANK, sdims1, NULL); - - /* Create a compound datatype to refer to */ - tid2 = H5Tcreate(H5T_COMPOUND, sizeof(s2_t)); - - /* Insert integer field */ - ret = H5Tinsert (tid2, "i", HOFFSET(s2_t,i), H5T_NATIVE_INT); - HDassert(ret >= 0); - - /* Create an array of floats datatype */ - tid3 = H5Tarray_create2(H5T_NATIVE_FLOAT, ARRAY1_RANK, tdims1); - - /* Insert float array field */ - ret = H5Tinsert (tid2, "f", HOFFSET(s2_t,f), tid3); - HDassert(ret >= 0); - - /* Close array of floats field datatype */ - ret = H5Tclose(tid3); - HDassert(ret >= 0); - - /* Create an array datatype to refer to */ - tid1 = H5Tarray_create2(tid2, ARRAY1_RANK, tdims1); - - /* Close compound datatype */ - ret = H5Tclose(tid2); - HDassert(ret >= 0); - - /* Create a dataset */ - dataset = H5Dcreate2(fid1, "Dataset1", tid1, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - /* Write dataset to disk */ - ret = H5Dwrite(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); - HDassert(ret >= 0); - - /* Close Dataset */ - ret = H5Dclose(dataset); - HDassert(ret >= 0); - ret = H5Tclose(tid1); - HDassert(ret >= 0); - ret = H5Sclose(sid1); - HDassert(ret >= 0); - ret = H5Fclose(fid1); - HDassert(ret >= 0); -} - -static void gent_array6(void) -{ - hvl_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1; /* Array Datatype ID */ - hid_t tid2; /* VL Datatype ID */ - hsize_t sdims1[] = {SPACE1_DIM1}; - hsize_t tdims1[] = {ARRAY1_DIM1}; - int i,j,k; /* counting variables */ - herr_t ret; /* Generic return value */ - - /* Initialize array data to write */ - for(i=0; i<SPACE1_DIM1; i++) - for(j=0; j<ARRAY1_DIM1; j++) { - wdata[i][j].p = HDmalloc((size_t)(i + j + 1) * sizeof(unsigned int)); - wdata[i][j].len = (size_t)(i + j + 1); - for(k = 0; k < (i + j + 1); k++) - ((unsigned int *)wdata[i][j].p)[k] = (unsigned)(i * 100 + j * 10 + k); - } /* end for */ - - /* Create file */ - fid1 = H5Fcreate(FILE30, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* Create dataspace for datasets */ - sid1 = H5Screate_simple(SPACE1_RANK, sdims1, NULL); - - /* Create a compound datatype to refer to */ - tid2 = H5Tvlen_create(H5T_NATIVE_UINT); - - /* Create an array datatype to refer to */ - tid1 = H5Tarray_create2(tid2, ARRAY1_RANK, tdims1); - - /* Close VL datatype */ - ret = H5Tclose(tid2); - HDassert(ret >= 0); - - /* Create a dataset */ - dataset = H5Dcreate2(fid1, "Dataset1", tid1, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - /* Write dataset to disk */ - ret = H5Dwrite(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); - HDassert(ret >= 0); - - /* Reclaim the write VL data */ - ret = H5Dvlen_reclaim(tid1, sid1, H5P_DEFAULT, wdata); - HDassert(ret >= 0); - - /* Close Dataset */ - ret = H5Dclose(dataset); - HDassert(ret >= 0); - ret = H5Tclose(tid1); - HDassert(ret >= 0); - ret = H5Sclose(sid1); - HDassert(ret >= 0); - ret = H5Fclose(fid1); - HDassert(ret >= 0); -} - -static void gent_array7(void) -{ - hvl_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1; /* Array Datatype ID */ - hid_t tid2; /* VL Datatype ID */ - hid_t tid3; /* Nested Array Datatype ID */ - hsize_t sdims1[] = {SPACE1_DIM1}; - hsize_t tdims1[] = {ARRAY1_DIM1}; - int i,j,k,l; /* Index variables */ - herr_t ret; /* Generic return value */ - - /* Initialize array data to write */ - for(i=0; i<SPACE1_DIM1; i++) - for(j=0; j<ARRAY1_DIM1; j++) { - wdata[i][j].p = HDmalloc((size_t)(i + j + 1) * (sizeof(unsigned int) * ARRAY1_DIM1)); - wdata[i][j].len = (size_t)(i + j + 1); - for(k = 0; k < (i + j + 1); k++) - for(l = 0; l<ARRAY1_DIM1; l++) - ((unsigned int *)wdata[i][j].p)[k * ARRAY1_DIM1 + l] = (unsigned)(i * 1000+j * 100+k * 10 + l); - } /* end for */ - - /* Create file */ - fid1 = H5Fcreate(FILE31, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* Create dataspace for datasets */ - sid1 = H5Screate_simple(SPACE1_RANK, sdims1, NULL); - - /* Create the nested array datatype to refer to */ - tid3 = H5Tarray_create2(H5T_NATIVE_UINT, ARRAY1_RANK, tdims1); - - /* Create a VL datatype of 1-D arrays to refer to */ - tid2 = H5Tvlen_create(tid3); - - /* Close nested array datatype */ - ret = H5Tclose(tid3); - HDassert(ret >= 0); - - /* Create an array datatype to refer to */ - tid1 = H5Tarray_create2(tid2, ARRAY1_RANK, tdims1); - - /* Close VL datatype */ - ret = H5Tclose(tid2); - HDassert(ret >= 0); - - /* Create a dataset */ - dataset = H5Dcreate2(fid1, "Dataset1", tid1, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - /* Write dataset to disk */ - ret = H5Dwrite(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); - HDassert(ret >= 0); - - /* Reclaim the write VL data */ - ret = H5Dvlen_reclaim(tid1, sid1, H5P_DEFAULT, wdata); - HDassert(ret >= 0); - - /* Close Dataset */ - ret = H5Dclose(dataset); - HDassert(ret >= 0); - ret = H5Tclose(tid1); - HDassert(ret >= 0); - ret = H5Sclose(sid1); - HDassert(ret >= 0); - ret = H5Fclose(fid1); - HDassert(ret >= 0); -} - -/* Test the boundary of the display output buffer at the reallocation event */ -static void gent_array8(void) -{ - hid_t file = -1; /* Handles */ - hid_t filetype = -1; /* Handles */ - hid_t space = -1; /* Handles */ - hid_t dset = -1; /* Handles */ - herr_t status = -1; - hsize_t sdims[] = {F64_DIM0}; - hsize_t tdims[] = {F64_DIM1}; - int *wdata; /* Write buffer */ - unsigned int i; - - /* Allocate data buffer */ - wdata = HDmalloc(F64_DIM1 * sizeof(int)); - HDassert(wdata); - - /* - * Initialize data. i is the element in the dataspace, j and k the - * elements within the array datatype. - */ - for (i = 0; i < F64_DIM1; i++) - wdata[i] = (int)i; - - /* - * Create a new file using the default properties. - */ - file = H5Fcreate (F64_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* - * Create array datatypes for file and memory. - */ - filetype = H5Tarray_create2 (H5T_NATIVE_INT, 1, tdims); - - /* - * Create dataspace. Setting maximum size to NULL sets the maximum - * size to be the current size. - */ - space = H5Screate_simple (1, sdims, NULL); - - /* - * Create the dataset and write the array data to it. - */ - if(file>=0 && filetype>=0 && space>=0) { - dset = H5Dcreate2 (file, F64_DATASET, filetype, space, H5P_DEFAULT, H5P_DEFAULT, - H5P_DEFAULT); - if(dset>=0) - status = H5Dwrite (dset, filetype, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); - HDassert(status >= 0); - } - - /* - * Close and release resources. - */ - status = H5Dclose (dset); - HDassert(status >= 0); - status = H5Sclose (space); - HDassert(status >= 0); - status = H5Tclose (filetype); - HDassert(status >= 0); - status = H5Fclose (file); - HDassert(status >= 0); - HDfree(wdata); -} - -static void gent_empty(void) -{ - typedef struct { - int a; - float b; - char c; - } empty_struct; - hid_t file, dset, space, type; - hsize_t dims[] = { SPACE1_DIM1 }; - herr_t ret=0; - - file = H5Fcreate(FILE32, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - space = H5Screate_simple(SPACE1_RANK, dims, NULL); - - /* write out an empty vlen dataset */ - type = H5Tvlen_create(H5T_NATIVE_INT); - dset = H5Dcreate2(file, "Dataset1.0", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - /* Don't write any data */ - ret = H5Dclose(dset); - HDassert(ret >= 0); - ret = H5Tclose(type); - HDassert(ret >= 0); - - /* write out an empty native integer dataset dataset */ - dset = H5Dcreate2(file, "Dataset2.0", H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - /* Don't write any data */ - ret = H5Dclose(dset); - HDassert(ret >= 0); - - /* write out an empty native floating-point dataset dataset */ - dset = H5Dcreate2(file, "Dataset3.0", H5T_NATIVE_FLOAT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - /* Don't write any data */ - ret = H5Dclose(dset); - HDassert(ret >= 0); - - /* write out an empty array dataset */ - type = H5Tarray_create2(H5T_NATIVE_INT, SPACE1_RANK, dims); - dset = H5Dcreate2(file, "Dataset4.0", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - /* Don't write any data */ - ret = H5Dclose(dset); - HDassert(ret >= 0); - ret = H5Tclose(type); - HDassert(ret >= 0); - - /* write out an empty compound dataset */ - type = H5Tcreate(H5T_COMPOUND,sizeof(empty_struct)); - H5Tinsert(type, "a", HOFFSET(empty_struct, a),H5T_NATIVE_INT); - H5Tinsert(type, "b", HOFFSET(empty_struct, b),H5T_NATIVE_FLOAT); - H5Tinsert(type, "c", HOFFSET(empty_struct, c),H5T_NATIVE_CHAR); - dset = H5Dcreate2(file, "Dataset5.0", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - /* Don't write any data */ - ret = H5Dclose(dset); - HDassert(ret >= 0); - ret = H5Tclose(type); - HDassert(ret >= 0); - - ret = H5Sclose(space); - HDassert(ret >= 0); - - ret = H5Fclose(file); - HDassert(ret >= 0); -} - -static void -gent_group_comments(void) -{ - hid_t fid, group; - - fid = H5Fcreate(FILE33, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* / */ - group = H5Gcreate2(fid, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Oset_comment_by_name(group, "/g1", "Comment for group /g1", H5P_DEFAULT); - H5Gclose(group); - group = H5Gcreate2(fid, "/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Oset_comment_by_name(group, "/g2", "Comment for group /g2", H5P_DEFAULT); - H5Gclose(group); - group = H5Gcreate2(fid, "/g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Oset_comment_by_name(group, "/g3", "Comment for group /g3", H5P_DEFAULT); - H5Gclose(group); - - /* /g1 */ - group = H5Gcreate2(fid, "/g1/g1.1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Oset_comment_by_name(group, "/g1/g1.1", "Comment for group /g1/g1.1", H5P_DEFAULT); - H5Gclose(group); - group = H5Gcreate2(fid, "/g1/g1.2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Oset_comment_by_name(group, "/g1/g1.2", "Comment for group /g1/g1.2", H5P_DEFAULT); - H5Gclose(group); - - /* /g2 */ - group = H5Gcreate2(fid, "/g2/g2.1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Oset_comment_by_name(group, "/g2/g2.1", "Comment for group /g2/g2.1", H5P_DEFAULT); - H5Gclose(group); - - /* /g3 */ - group = H5Gcreate2(fid, "/g3/g3.1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Oset_comment_by_name(group, "/g3/g3.1", "Comment for group /g3/g3.1", H5P_DEFAULT); - H5Gclose(group); - group = H5Gcreate2(fid, "/g3/g3.2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Oset_comment_by_name(group, "/g3/g3.2", "Comment for group /g3/g3.2", H5P_DEFAULT); - H5Gclose(group); - group = H5Gcreate2(fid, "/g3/g3.3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Oset_comment_by_name(group, "/g3/g3.3", "Comment for group /g3/g3.3", H5P_DEFAULT); - H5Gclose(group); - group = H5Gcreate2(fid, "/g3/g3.4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Oset_comment_by_name(group, "/g3/g3.4", "Comment for group /g3/g3.4", H5P_DEFAULT); - H5Gclose(group); - - /* /g2/g2.1 */ - group = H5Gcreate2(fid, "/g2/g2.1/g2.1.1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Oset_comment_by_name(group, "/g2/g2.1/g2.1.1", "Comment for group /g2/g2.1/g2.1.1", H5P_DEFAULT); - H5Gclose(group); - group = H5Gcreate2(fid, "/g2/g2.1/g2.1.2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Oset_comment_by_name(group, "/g2/g2.1/g2.1.2", "Comment for group /g2/g2.1/g2.1.2", H5P_DEFAULT); - H5Gclose(group); - group = H5Gcreate2(fid, "/g2/g2.1/g2.1.3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Oset_comment_by_name(group, "/g2/g2.1/g2.1.3", "Comment for group /g2/g2.1/g2.1.3", H5P_DEFAULT); - H5Gclose(group); - - /* /glongcomment */ - group = H5Gcreate2(fid, "/glongcomment", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Oset_comment_by_name(group, "/glongcomment", "Comment for group /glongcomment with a really, really, really long, long, long comment", H5P_DEFAULT); - H5Gclose(group); - - H5Fclose(fid); -} - -static -void gent_split_file(void) -{ - hid_t fapl, fid, root, attr, space, dataset, atype; - char meta[] = "this is some metadata on this file"; - hsize_t dims[2]; - int i, j, dset[10][15]; - - fapl = H5Pcreate(H5P_FILE_ACCESS); - H5Pset_fapl_split(fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT); - fid = H5Fcreate(FILE34, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - root = H5Gopen2(fid, "/", H5P_DEFAULT); - - atype = H5Tcopy(H5T_C_S1); - H5Tset_size(atype, HDstrlen(meta) + 1); - H5Tset_strpad(atype, H5T_STR_NULLTERM); - - dims[0] = 1; - space = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(root, "Metadata", atype, space, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, atype, meta); - H5Tclose(atype); - H5Sclose(space); - H5Aclose(attr); - - /* create dataset */ - dims[0] = 10; - dims[1] = 15; - space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(fid, "/dset1", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - for(i = 0; i < 10; i++) - for(j = 0; j < 15; j++) - dset[i][j] = i + j; - - H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset); - H5Sclose(space); - H5Dclose(dataset); - H5Gclose(root); - H5Fclose(fid); - H5Pclose(fapl); -} - -static -void gent_family(void) -{ - hid_t fapl, fid, space, dataset; - hsize_t dims[2]; - int i, j, dset[10][15]; - -#define FAMILY_SIZE 256 - - fapl = H5Pcreate(H5P_FILE_ACCESS); - H5Pset_fapl_family(fapl, (hsize_t)FAMILY_SIZE, H5P_DEFAULT); - - fid = H5Fcreate(FILE35, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - - /* create dataset */ - dims[0] = 10; - dims[1] = 15; - space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(fid, "/dset1", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - for(i = 0; i < 10; i++) - for(j = 0; j < 15; j++) - dset[i][j] = i + j; - - H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset); - H5Sclose(space); - H5Dclose(dataset); - H5Fclose(fid); - H5Pclose(fapl); -} - -static const char *multi_letters = "msbrglo"; - -static -void gent_multi(void) -{ - hid_t fapl, fid, space, dataset; - hsize_t dims[2]; - int i, j, dset[10][15]; - - /* Multi-file driver, general case of the split driver */ - H5FD_mem_t mt, memb_map[H5FD_MEM_NTYPES]; - hid_t memb_fapl[H5FD_MEM_NTYPES]; - const char *memb_name[H5FD_MEM_NTYPES]; - char sv[H5FD_MEM_NTYPES][1024]; - haddr_t memb_addr[H5FD_MEM_NTYPES]; - - fapl = H5Pcreate(H5P_FILE_ACCESS); - - HDmemset(memb_map, 0, sizeof memb_map); - HDmemset(memb_fapl, 0, sizeof memb_fapl); - HDmemset(memb_name, 0, sizeof memb_name); - HDmemset(memb_addr, 0, sizeof memb_addr); - - HDassert(HDstrlen(multi_letters) == H5FD_MEM_NTYPES); - - for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) { - memb_fapl[mt] = H5P_DEFAULT; - memb_map[mt] = mt; - sprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]); - memb_name[mt] = sv[mt]; - /*printf("memb_name[%d]=%s, memb_map[%d]=%d; ", mt, memb_name[mt], mt, memb_map[mt]);*/ - memb_addr[mt] = (haddr_t)MAX(mt - 1, 0) * (HADDR_MAX / 10); - } - memb_map[H5FD_MEM_DEFAULT] = H5FD_MEM_SUPER; - - H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, - memb_addr, FALSE); - - fid = H5Fcreate(FILE36, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - - /* create dataset */ - dims[0] = 10; - dims[1] = 15; - space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(fid, "/dset1", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - for(i = 0; i < 10; i++) - for(j = 0; j < 15; j++) - dset[i][j] = i + j; - - H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset); - - H5Sclose(space); - H5Dclose(dataset); - H5Fclose(fid); - H5Pclose(fapl); -} - -static void gent_large_objname(void) -{ - hid_t fid, group, group2; - char grp_name[128]; - register int i; - - fid = H5Fcreate(FILE37, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - group = H5Gcreate2(fid, "this_is_a_large_group_name", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - for(i = 0; i < 50; ++i) { - sprintf(grp_name, "this_is_a_large_group_name%d", i); - group2 = H5Gcreate2(group, grp_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group2); - } - - H5Gclose(group); - H5Fclose(fid); -} - -static void gent_vlstr(void) -{ - const char *wdata[SPACE1_DIM1]= { - "Four score and seven years ago our forefathers brought forth on this continent a new nation,", - "conceived in liberty and dedicated to the proposition that all men are created equal.", - "", - NULL - }; /* Information to write */ - const char *string_att= "This is the string for the attribute"; - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset, root; /* Dataset ID */ - hid_t sid1, dataspace;/* Dataspace ID */ - hid_t tid1, att; /* Datatype ID */ - hsize_t dims1[] = {SPACE1_DIM1}; - - /* Create file */ - fid1 = H5Fcreate(FILE38, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); - - /* Create a VL string datatype to refer to */ - tid1 = H5Tcopy (H5T_C_S1); - H5Tset_size (tid1, H5T_VARIABLE); - - /* Create a dataset and write VL string to it. */ - dataset = H5Dcreate2(fid1, "Dataset1", tid1, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Dwrite(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); - H5Dclose(dataset); - - /* Create a named VL string type. Change padding of datatype */ - H5Tset_strpad(tid1, H5T_STR_NULLPAD); - H5Tcommit2(fid1, "vl_string_type", tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - /* Create an group attribute of VL string type */ - root = H5Gopen2(fid1, "/", H5P_DEFAULT); - dataspace = H5Screate(H5S_SCALAR); - - att = H5Acreate2(root, "test_scalar", tid1, dataspace, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(att, tid1, &string_att); - - /* Close */ - H5Tclose(tid1); - H5Sclose(sid1); - H5Sclose(dataspace); - H5Aclose(att); - H5Gclose(root); - H5Fclose(fid1); -} - -static void gent_char(void) -{ - const char *wdata = - "Four score and seven years ago our forefathers brought " - "forth on this continent a new nation, conceived in " - "liberty and dedicated to the proposition that all " - "men are created equal. Now we are engaged in a great " - "civil war, testing whether that nation or any nation " - "so conceived and so dedicated can long endure."; - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - hsize_t dims1[1]; - - dims1[0] = HDstrlen(wdata); - - /* Create file */ - fid1 = H5Fcreate(FILE39, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - sid1 = H5Screate_simple(1, dims1, NULL); - - /* Create a dataset */ - dataset = H5Dcreate2(fid1, "Dataset1", H5T_NATIVE_CHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - /* Write some characters to it. */ - H5Dwrite(dataset, H5T_NATIVE_CHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); - - /* Close */ - H5Dclose(dataset); - H5Sclose(sid1); - H5Fclose(fid1); -} - - - -/*------------------------------------------------------------------------- - * Function: write_attr_in - * - * Purpose: write attributes in LOC_ID (dataset, group, named datatype) - * - * Return: void - * - * Programmer: pvn@ncsa.uiuc.edu - * - * Date: May 28, 2003 - * - *------------------------------------------------------------------------- - */ - -static void write_attr_in(hid_t loc_id, - const char* dset_name, /* for saving reference to dataset*/ - hid_t fid) -{ - /* Compound datatype */ - typedef struct s_t - { - char a; - double b; - } s_t; - - typedef enum - { - E_RED, - E_GREEN - } e_t; - - hid_t aid; - hid_t sid; - hid_t tid; - herr_t status; - int val, i, j, k, n; - float f; - - /* create 1D attributes with dimension [2], 2 elements */ - hsize_t dims[1]={2}; - char buf1[2][3]= {"ab","de"}; /* string */ - char buf2[2]= {1,2}; /* bitfield, opaque */ - s_t buf3[2]= {{1,2},{3,4}}; /* compound */ - hobj_ref_t buf4[2]; /* reference */ - hvl_t buf5[2]; /* vlen */ - hsize_t dimarray[1]={3}; /* array dimension */ - int buf6[2][3]= {{1,2,3},{4,5,6}}; /* array */ - int buf7[2]= {1,2}; /* integer */ - float buf8[2]= {1,2}; /* float */ - - /* create 2D attributes with dimension [3][2], 6 elements */ - hsize_t dims2[2]={3,2}; - char buf12[6][3]= {"ab","cd","ef","gh","ij","kl"}; /* string */ - char buf22[3][2]= {{1,2},{3,4},{5,6}}; /* bitfield, opaque */ - s_t buf32[6]= {{1,2},{3,4},{5,6},{7,8},{9,10},{11,12}}; /* compound */ - hobj_ref_t buf42[3][2]; /* reference */ - hvl_t buf52[3][2]; /* vlen */ - int buf62[6][3]= {{1,2,3},{4,5,6},{7,8,9},{10,11,12},{13,14,15},{16,17,18}}; /* array */ - int buf72[3][2]= {{1,2},{3,4},{5,6}}; /* integer */ - float buf82[3][2]= {{1,2},{3,4},{5,6}}; /* float */ - - /* create 3D attributes with dimension [4][3][2], 24 elements */ - hsize_t dims3[3]={4,3,2}; - char buf13[24][3]= {"ab","cd","ef","gh","ij","kl","mn","pq", - "rs","tu","vw","xz","AB","CD","EF","GH", - "IJ","KL","MN","PQ","RS","TU","VW","XZ"}; /* string */ - char buf23[4][3][2]; /* bitfield, opaque */ - s_t buf33[4][3][2]; /* compound */ - hobj_ref_t buf43[4][3][2]; /* reference */ - hvl_t buf53[4][3][2]; /* vlen */ - int buf63[24][3]; /* array */ - int buf73[4][3][2]; /* integer */ - float buf83[4][3][2]; /* float */ - - - /*------------------------------------------------------------------------- - * 1D attributes - *------------------------------------------------------------------------- - */ - - /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, 2); - write_attr(loc_id,1,dims,"string",tid,buf1); - status = H5Tclose(tid); - - /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ - tid = H5Tcopy(H5T_STD_B8LE); - write_attr(loc_id,1,dims,"bitfield",tid,buf2); - status = H5Tclose(tid); - - /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ - tid = H5Tcreate(H5T_OPAQUE, 1); - status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ - write_attr(loc_id,1,dims,"opaque",tid,buf2); - status = H5Tclose(tid); - - /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ - tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t)); - H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR); - H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE); - write_attr(loc_id,1,dims,"compound",tid,buf3); - status = H5Tclose(tid); - - /*------------------------------------------------------------------------- - * H5T_REFERENCE - *------------------------------------------------------------------------- - */ - /* Create references to dataset */ - if(dset_name) - { - status=H5Rcreate(&buf4[0],fid,dset_name,H5R_OBJECT,(hid_t)-1); - status=H5Rcreate(&buf4[1],fid,dset_name,H5R_OBJECT,(hid_t)-1); - write_attr(loc_id,1,dims,"reference",H5T_STD_REF_OBJ,buf4); - } - - /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ - tid = H5Tcreate(H5T_ENUM, sizeof(e_t)); - H5Tenum_insert(tid, "RED", (val = 0, &val)); - H5Tenum_insert(tid, "GREEN", (val = 1, &val)); - write_attr(loc_id,1,dims,"enum",tid,0); - status = H5Tclose(tid); - - /*------------------------------------------------------------------------- - * H5T_VLEN - *------------------------------------------------------------------------- - */ - - /* Allocate and initialize VL dataset to write */ - - buf5[0].len = 1; - buf5[0].p = HDmalloc(1 * sizeof(int)); - ((int *)buf5[0].p)[0] = 1; - buf5[1].len = 2; - buf5[1].p = HDmalloc(2 * sizeof(int)); - ((int *)buf5[1].p)[0] = 2; - ((int *)buf5[1].p)[1] = 3; - - sid = H5Screate_simple(1, dims, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - aid = H5Acreate2(loc_id, "vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT); - status = H5Awrite(aid, tid, buf5); - HDassert(status >= 0); - status = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf5); - HDassert(status >= 0); - status = H5Aclose(aid); - status = H5Tclose(tid); - status = H5Sclose(sid); - - /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ - tid = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray); - write_attr(loc_id, 1, dims, "array", tid, buf6); - status = H5Tclose(tid); - - /*------------------------------------------------------------------------- - * H5T_INTEGER and H5T_FLOAT - *------------------------------------------------------------------------- - */ - write_attr(loc_id, 1, dims, "integer", H5T_NATIVE_INT, buf7); - write_attr(loc_id, 1, dims, "float", H5T_NATIVE_FLOAT, buf8); - - - /*------------------------------------------------------------------------- - * 2D attributes - *------------------------------------------------------------------------- - */ - - /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, 2); - write_attr(loc_id,2,dims2,"string2D",tid,buf12); - status = H5Tclose(tid); - - /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ - tid = H5Tcopy(H5T_STD_B8LE); - write_attr(loc_id,2,dims2,"bitfield2D",tid,buf22); - status = H5Tclose(tid); - - /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ - tid = H5Tcreate(H5T_OPAQUE, 1); - status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ - write_attr(loc_id,2,dims2,"opaque2D",tid,buf22); - status = H5Tclose(tid); - - /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ - tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t)); - H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR); - H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE); - write_attr(loc_id,2,dims2,"compound2D",tid,buf32); - status = H5Tclose(tid); - - /*------------------------------------------------------------------------- - * H5T_REFERENCE - *------------------------------------------------------------------------- - */ - /* Create references to dataset */ - if(dset_name) - { - for(i = 0; i < 3; i++) { - for(j = 0; j < 2; j++) { - status=H5Rcreate(&buf42[i][j],fid,dset_name,H5R_OBJECT,(hid_t)-1); - } - } - write_attr(loc_id,2,dims2,"reference2D",H5T_STD_REF_OBJ,buf42); - } - - /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ - tid = H5Tcreate(H5T_ENUM, sizeof(e_t)); - H5Tenum_insert(tid, "RED", (val = 0, &val)); - H5Tenum_insert(tid, "GREEN", (val = 1, &val)); - write_attr(loc_id,2,dims2,"enum2D",tid,0); - status = H5Tclose(tid); - - /*------------------------------------------------------------------------- - * H5T_VLEN - *------------------------------------------------------------------------- - */ - - /* Allocate and initialize VL dataset to write */ - n=0; - for(i = 0; i < 3; i++) { - for(j = 0; j < 2; j++) { - int l; - - buf52[i][j].p = HDmalloc((size_t)(i + 1) * sizeof(int)); - buf52[i][j].len = (size_t)(i + 1); - for(l = 0; l < i + 1; l++) - ((int *)buf52[i][j].p)[l] = n++; - } - } - - sid = H5Screate_simple(2, dims2, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - aid = H5Acreate2(loc_id, "vlen2D", tid, sid, H5P_DEFAULT, H5P_DEFAULT); - status = H5Awrite(aid, tid, buf52); - HDassert(status >= 0); - status = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf52); - HDassert(status >= 0); - status = H5Aclose(aid); - status = H5Tclose(tid); - status = H5Sclose(sid); - - /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ - tid = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray); - write_attr(loc_id, 2, dims2, "array2D", tid, buf62); - status = H5Tclose(tid); - - /*------------------------------------------------------------------------- - * H5T_INTEGER and H5T_FLOAT - *------------------------------------------------------------------------- - */ - write_attr(loc_id, 2, dims2, "integer2D", H5T_NATIVE_INT, buf72); - write_attr(loc_id, 2, dims2, "float2D", H5T_NATIVE_FLOAT, buf82); - - - /*------------------------------------------------------------------------- - * 3D attributes - *------------------------------------------------------------------------- - */ - - /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, 2); - write_attr(loc_id,3,dims3,"string3D",tid,buf13); - status = H5Tclose(tid); - - /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ - - n=1; - for(i = 0; i < 4; i++) { - for(j = 0; j < 3; j++) { - for(k = 0; k < 2; k++) { - buf23[i][j][k] = (char)n++; - } - } - } - tid = H5Tcopy(H5T_STD_B8LE); - write_attr(loc_id,3,dims3,"bitfield3D",tid,buf23); - status = H5Tclose(tid); - - /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ - tid = H5Tcreate(H5T_OPAQUE, 1); - status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ - write_attr(loc_id,3,dims3,"opaque3D",tid,buf23); - status = H5Tclose(tid); - - /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ - - n=1; - for(i = 0; i < 4; i++) { - for(j = 0; j < 3; j++) { - for(k = 0; k < 2; k++) { - buf33[i][j][k].a = (char)n++; - buf33[i][j][k].b=n++; - } - } - } - tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t)); - H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR); - H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE); - write_attr(loc_id,3,dims3,"compound3D",tid,buf33); - status = H5Tclose(tid); - - /*------------------------------------------------------------------------- - * H5T_REFERENCE - *------------------------------------------------------------------------- - */ - /* Create references to dataset */ - if(dset_name) - { - for(i = 0; i < 4; i++) { - for(j = 0; j < 3; j++) { - for(k = 0; k < 2; k++) - status=H5Rcreate(&buf43[i][j][k],fid,dset_name,H5R_OBJECT,(hid_t)-1); - } - } - write_attr(loc_id,3,dims3,"reference3D",H5T_STD_REF_OBJ,buf43); - } - - /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ - tid = H5Tcreate(H5T_ENUM, sizeof(e_t)); - H5Tenum_insert(tid, "RED", (val = 0, &val)); - H5Tenum_insert(tid, "GREEN", (val = 1, &val)); - write_attr(loc_id,3,dims3,"enum3D",tid,0); - status = H5Tclose(tid); - - /*------------------------------------------------------------------------- - * H5T_VLEN - *------------------------------------------------------------------------- - */ - - /* Allocate and initialize VL dataset to write */ - n = 0; - for(i = 0; i < 4; i++) { - for(j = 0; j < 3; j++) { - for(k = 0; k < 2; k++) { - int l; - - buf53[i][j][k].p = HDmalloc((size_t)(i + 1) * sizeof(int)); - buf53[i][j][k].len = (size_t)(i + 1); - for(l = 0; l < i + 1; l++) - ((int *)buf53[i][j][k].p)[l] = n++; - } - } - } - - sid = H5Screate_simple(3, dims3, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - aid = H5Acreate2(loc_id, "vlen3D", tid, sid, H5P_DEFAULT, H5P_DEFAULT); - status = H5Awrite(aid, tid, buf53); - HDassert(status >= 0); - status = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf53); - HDassert(status >= 0); - status = H5Aclose(aid); - status = H5Tclose(tid); - status = H5Sclose(sid); - - /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ - n = 1; - for(i = 0; i < 24; i++) - for(j = 0; j < (int)dimarray[0]; j++) - buf63[i][j] = n++; - - tid = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray); - write_attr(loc_id, 3, dims3, "array3D", tid, buf63); - status = H5Tclose(tid); - - /*------------------------------------------------------------------------- - * H5T_INTEGER and H5T_FLOAT - *------------------------------------------------------------------------- - */ - n=1; f=1; - for(i = 0; i < 4; i++) { - for(j = 0; j < 3; j++) { - for(k = 0; k < 2; k++) { - buf73[i][j][k]=n++; - buf83[i][j][k]=f++; - } - } - } - write_attr(loc_id,3,dims3,"integer3D",H5T_NATIVE_INT,buf73); - write_attr(loc_id,3,dims3,"float3D",H5T_NATIVE_FLOAT,buf83); -} - - - -/*------------------------------------------------------------------------- - * Function: write_dset_in - * - * Purpose: write datasets in LOC_ID - * - * Return: void - * - * Programmer: pvn@ncsa.uiuc.edu - * - * Date: May 28, 2003 - * - *------------------------------------------------------------------------- - */ - -static void write_dset_in(hid_t loc_id, - const char* dset_name, /* for saving reference to dataset*/ - hid_t fid) -{ - /* Compound datatype */ - typedef struct s_t - { - char a; - double b; - } s_t; - - typedef enum - { - E_RED, - E_GREEN - } e_t; - - hid_t did; - hid_t sid; - hid_t tid; - hid_t plist_id; - herr_t status; - int val, i, j, k, n; - float f; - int fillvalue=2; - - /* create 1D attributes with dimension [2], 2 elements */ - hsize_t dims[1]={2}; - char buf1[2][3]= {"ab","de"}; /* string */ - char buf2[2]= {1,2}; /* bitfield, opaque */ - s_t buf3[2]= {{1,2},{3,4}}; /* compound */ - hobj_ref_t buf4[2]; /* reference */ - hvl_t buf5[2]; /* vlen */ - hsize_t dimarray[1]={3}; /* array dimension */ - int buf6[2][3]= {{1,2,3},{4,5,6}}; /* array */ - int buf7[2]= {1,2}; /* integer */ - float buf8[2]= {1,2}; /* float */ - - /* create 2D attributes with dimension [3][2], 6 elements */ - hsize_t dims2[2]={3,2}; - char buf12[6][3]= {"ab","cd","ef","gh","ij","kl"}; /* string */ - char buf22[3][2]= {{1,2},{3,4},{5,6}}; /* bitfield, opaque */ - s_t buf32[6]= {{1,2},{3,4},{5,6},{7,8},{9,10},{11,12}}; /* compound */ - hobj_ref_t buf42[3][2]; /* reference */ - hvl_t buf52[3][2]; /* vlen */ - int buf62[6][3]= {{1,2,3},{4,5,6},{7,8,9},{10,11,12},{13,14,15},{16,17,18}}; /* array */ - int buf72[3][2]= {{1,2},{3,4},{5,6}}; /* integer */ - float buf82[3][2]= {{1,2},{3,4},{5,6}}; /* float */ - - /* create 3D attributes with dimension [4][3][2], 24 elements */ - hsize_t dims3[3]={4,3,2}; - char buf13[24][3]= {"ab","cd","ef","gh","ij","kl","mn","pq", - "rs","tu","vw","xz","AB","CD","EF","GH", - "IJ","KL","MN","PQ","RS","TU","VW","XZ"}; /* string */ - char buf23[4][3][2]; /* bitfield, opaque */ - s_t buf33[4][3][2]; /* compound */ - hobj_ref_t buf43[4][3][2]; /* reference */ - hvl_t buf53[4][3][2]; /* vlen */ - int buf63[24][3]; /* array */ - int buf73[4][3][2]; /* integer */ - float buf83[4][3][2]; /* float */ - - - /*------------------------------------------------------------------------- - * 1D - *------------------------------------------------------------------------- - */ - - /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, 2); - write_dset(loc_id,1,dims,"string",tid,buf1); - status = H5Tclose(tid); - - /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ - tid = H5Tcopy(H5T_STD_B8LE); - write_dset(loc_id,1,dims,"bitfield",tid,buf2); - status = H5Tclose(tid); - - /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ - tid = H5Tcreate(H5T_OPAQUE, 1); - status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ - write_dset(loc_id,1,dims,"opaque",tid,buf2); - status = H5Tclose(tid); - - /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ - tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t)); - H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR); - H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE); - write_dset(loc_id,1,dims,"compound",tid,buf3); - status = H5Tclose(tid); - - /*------------------------------------------------------------------------- - * H5T_REFERENCE - *------------------------------------------------------------------------- - */ - /* Create references to dataset */ - if(dset_name) - { - status=H5Rcreate(&buf4[0],fid,dset_name,H5R_OBJECT,(hid_t)-1); - status=H5Rcreate(&buf4[1],fid,dset_name,H5R_OBJECT,(hid_t)-1); - write_dset(loc_id,1,dims,"reference",H5T_STD_REF_OBJ,buf4); - } - - /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ - tid = H5Tcreate(H5T_ENUM, sizeof(e_t)); - H5Tenum_insert(tid, "RED", (val = 0, &val)); - H5Tenum_insert(tid, "GREEN", (val = 1, &val)); - write_dset(loc_id,1,dims,"enum",tid,0); - status = H5Tclose(tid); - - /*------------------------------------------------------------------------- - * H5T_VLEN - *------------------------------------------------------------------------- - */ - - /* Allocate and initialize VL dataset to write */ - - buf5[0].len = 1; - buf5[0].p = HDmalloc( 1 * sizeof(int)); - ((int *)buf5[0].p)[0]=1; - buf5[1].len = 2; - buf5[1].p = HDmalloc( 2 * sizeof(int)); - ((int *)buf5[1].p)[0]=2; - ((int *)buf5[1].p)[1]=3; - - sid = H5Screate_simple(1, dims, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - did = H5Dcreate2(loc_id, "vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf5); - HDassert(status >= 0); - status = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf5); - HDassert(status >= 0); - status = H5Dclose(did); - status = H5Tclose(tid); - status = H5Sclose(sid); - - /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ - tid = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray); - write_dset(loc_id, 1, dims, "array", tid, buf6); - status = H5Tclose(tid); - - /*------------------------------------------------------------------------- - * H5T_INTEGER and H5T_FLOAT - *------------------------------------------------------------------------- - */ - write_dset(loc_id,1,dims,"integer",H5T_NATIVE_INT,buf7); - write_dset(loc_id,1,dims,"float",H5T_NATIVE_FLOAT,buf8); - - - /*------------------------------------------------------------------------- - * 2D - *------------------------------------------------------------------------- - */ - - /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, 2); - write_dset(loc_id,2,dims2,"string2D",tid,buf12); - status = H5Tclose(tid); - - /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ - tid = H5Tcopy(H5T_STD_B8LE); - write_dset(loc_id,2,dims2,"bitfield2D",tid,buf22); - status = H5Tclose(tid); - - /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ - tid = H5Tcreate(H5T_OPAQUE, 1); - status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ - write_dset(loc_id,2,dims2,"opaque2D",tid,buf22); - status = H5Tclose(tid); - - /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ - tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t)); - H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR); - H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE); - write_dset(loc_id,2,dims2,"compound2D",tid,buf32); - status = H5Tclose(tid); - - /*------------------------------------------------------------------------- - * H5T_REFERENCE - *------------------------------------------------------------------------- - */ - /* Create references to dataset */ - if(dset_name) - { - for(i = 0; i < 3; i++) { - for(j = 0; j < 2; j++) { - status=H5Rcreate(&buf42[i][j],fid,dset_name,H5R_OBJECT,(hid_t)-1); - } - } - write_dset(loc_id,2,dims2,"reference2D",H5T_STD_REF_OBJ,buf42); - } - - /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ - tid = H5Tcreate(H5T_ENUM, sizeof(e_t)); - H5Tenum_insert(tid, "RED", (val = 0, &val)); - H5Tenum_insert(tid, "GREEN", (val = 1, &val)); - write_dset(loc_id,2,dims2,"enum2D",tid,0); - status = H5Tclose(tid); - - /*------------------------------------------------------------------------- - * H5T_VLEN - *------------------------------------------------------------------------- - */ - - /* Allocate and initialize VL dataset to write */ - n=0; - for(i = 0; i < 3; i++) - for(j = 0; j < 2; j++) { - int l; - - buf52[i][j].p = HDmalloc((size_t)(i + 1) * sizeof(int)); - buf52[i][j].len = (size_t)(i + 1); - for(l = 0; l < i + 1; l++) - ((int *)buf52[i][j].p)[l] = n++; - } - - sid = H5Screate_simple(2, dims2, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - did = H5Dcreate2(loc_id, "vlen2D", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf52); - HDassert(status >= 0); - status = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf52); - HDassert(status >= 0); - status = H5Dclose(did); - status = H5Tclose(tid); - status = H5Sclose(sid); - - /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ - tid = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray); - write_dset(loc_id, 2, dims2, "array2D", tid, buf62); - status = H5Tclose(tid); - - /*------------------------------------------------------------------------- - * H5T_INTEGER, write a fill value - *------------------------------------------------------------------------- - */ - plist_id = H5Pcreate(H5P_DATASET_CREATE); - status = H5Pset_fill_value(plist_id, H5T_NATIVE_INT, &fillvalue); - sid = H5Screate_simple(2, dims2, NULL); - did = H5Dcreate2(loc_id, "integer2D", H5T_NATIVE_INT, sid, H5P_DEFAULT, plist_id, H5P_DEFAULT); - status = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf72); - status = H5Pclose(plist_id); - status = H5Dclose(did); - status = H5Sclose(sid); - - /*------------------------------------------------------------------------- - * H5T_FLOAT - *------------------------------------------------------------------------- - */ - - write_dset(loc_id, 2, dims2, "float2D", H5T_NATIVE_FLOAT, buf82); - - - /*------------------------------------------------------------------------- - * 3D - *------------------------------------------------------------------------- - */ - - /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, 2); - write_dset(loc_id,3,dims3,"string3D",tid,buf13); - status = H5Tclose(tid); - - /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ - - n=1; - for(i = 0; i < 4; i++) - for(j = 0; j < 3; j++) - for(k = 0; k < 2; k++) - buf23[i][j][k] = (char)n++; - tid = H5Tcopy(H5T_STD_B8LE); - write_dset(loc_id,3,dims3,"bitfield3D",tid,buf23); - status = H5Tclose(tid); - - /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ - tid = H5Tcreate(H5T_OPAQUE, 1); - status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ - write_dset(loc_id,3,dims3,"opaque3D",tid,buf23); - status = H5Tclose(tid); - - /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ - - n=1; - for(i = 0; i < 4; i++) - for(j = 0; j < 3; j++) - for(k = 0; k < 2; k++) { - buf33[i][j][k].a = (char)n++; - buf33[i][j][k].b = n++; - } - tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t)); - H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR); - H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE); - write_dset(loc_id,3,dims3,"compound3D",tid,buf33); - status = H5Tclose(tid); - - /*------------------------------------------------------------------------- - * H5T_REFERENCE - *------------------------------------------------------------------------- - */ - /* Create references to dataset */ - if(dset_name) - { - for(i = 0; i < 4; i++) { - for(j = 0; j < 3; j++) { - for(k = 0; k < 2; k++) - status=H5Rcreate(&buf43[i][j][k],fid,dset_name,H5R_OBJECT,(hid_t)-1); - } - } - write_dset(loc_id,3,dims3,"reference3D",H5T_STD_REF_OBJ,buf43); - } - - /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ - tid = H5Tcreate(H5T_ENUM, sizeof(e_t)); - H5Tenum_insert(tid, "RED", (val = 0, &val)); - H5Tenum_insert(tid, "GREEN", (val = 1, &val)); - write_dset(loc_id,3,dims3,"enum3D",tid,0); - status = H5Tclose(tid); - - /*------------------------------------------------------------------------- - * H5T_VLEN - *------------------------------------------------------------------------- - */ - - /* Allocate and initialize VL dataset to write */ - n = 0; - for(i = 0; i < 4; i++) - for(j = 0; j < 3; j++) - for(k = 0; k < 2; k++) { - int l; - - buf53[i][j][k].p = HDmalloc(((size_t)i + 1) * sizeof(int)); - buf53[i][j][k].len = (size_t)(i + 1); - for(l = 0; l < i + 1; l++) - ((int *)buf53[i][j][k].p)[l] = n++; - } - - sid = H5Screate_simple(3, dims3, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - did = H5Dcreate2(loc_id, "vlen3D", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf53); - HDassert(status >= 0); - status = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf53); - HDassert(status >= 0); - status = H5Dclose(did); - status = H5Tclose(tid); - status = H5Sclose(sid); - - /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ - n=1; - for(i = 0; i < 24; i++) { - for(j = 0; j < (int)dimarray[0]; j++) { - buf63[i][j]=n++; - } - } - - tid = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray); - write_dset(loc_id, 3, dims3, "array3D", tid, buf63); - status = H5Tclose(tid); - - /*------------------------------------------------------------------------- - * H5T_INTEGER and H5T_FLOAT - *------------------------------------------------------------------------- - */ - n=1; f=1; - for(i = 0; i < 4; i++) { - for(j = 0; j < 3; j++) { - for(k = 0; k < 2; k++) { - buf73[i][j][k]=n++; - buf83[i][j][k]=f++; - } - } - } - write_dset(loc_id,3,dims3,"integer3D",H5T_NATIVE_INT,buf73); - write_dset(loc_id,3,dims3,"float3D",H5T_NATIVE_FLOAT,buf83); -} - - - - -/*------------------------------------------------------------------------- - * Function: gent_attr_all - * - * Purpose: generate all datatype attributes - * - * Return: void - * - * Programmer: pvn@ncsa.uiuc.edu - * - * Date: May 19, 2003 - * - *------------------------------------------------------------------------- - */ - -static void gent_attr_all(void) -{ - hid_t fid; - hid_t did; - hid_t group_id; - hid_t group2_id; - hid_t root_id; - hid_t sid; - hsize_t dims[1] = {2}; - herr_t status; - - /* Create a file and a dataset */ - fid = H5Fcreate(FILE40, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* Create a 1D dataset */ - sid = H5Screate_simple(1,dims,NULL); - did = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - status = H5Sclose(sid); - HDassert(status >= 0); - - /* Create groups */ - group_id = H5Gcreate2(fid, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - group2_id = H5Gcreate2(fid, "g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - root_id = H5Gopen2(fid, "/", H5P_DEFAULT); - - /*------------------------------------------------------------------------- - * write a series of attributes on the dataset, group - *------------------------------------------------------------------------- - */ - - write_attr_in(did,"dset",fid); - write_attr_in(group_id,NULL,(hid_t)0); - write_attr_in(root_id,NULL,(hid_t)0); - - /*------------------------------------------------------------------------- - * write a series of datasets on group 2 - *------------------------------------------------------------------------- - */ - - write_dset_in(group2_id,"/dset",fid); - - /* Close */ - status = H5Dclose(did); - HDassert(status >= 0); - status = H5Gclose(group_id); - HDassert(status >= 0); - status = H5Gclose(group2_id); - HDassert(status >= 0); - status = H5Gclose(root_id); - HDassert(status >= 0); - - /* Close file */ - status = H5Fclose(fid); - HDassert(status >= 0); -} - - -/*------------------------------------------------------------------------- - * Function: write_attr - * - * Purpose: utility function to write an attribute - * - * Programmer: pvn@ncsa.uiuc.edu - * - * Date: May 19, 2003 - * - *------------------------------------------------------------------------- - */ - -static -int write_attr(hid_t loc_id, int rank, hsize_t *dims, const char *attr_name, - hid_t tid, void *buf) -{ - hid_t aid; - hid_t sid; - herr_t status; - - /* Create a buf space */ - sid = H5Screate_simple(rank, dims, NULL); - - /* Create the attribute */ - aid = H5Acreate2(loc_id, attr_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT); - - /* Write the buf */ - if(buf) - status = H5Awrite(aid, tid, buf); - - /* Close */ - status = H5Aclose(aid); - status = H5Sclose(sid); - - return status; -} - -/*------------------------------------------------------------------------- - * Function: write_dset - * - * Purpose: utility function to create and write a dataset in LOC_ID - * - * Return: - * - * Programmer: pvn@ncsa.uiuc.edu - * - * Date: May 27, 2003 - * - *------------------------------------------------------------------------- - */ - -static -int write_dset( hid_t loc_id, int rank, hsize_t *dims, const char *dset_name, - hid_t tid, void *buf ) -{ - hid_t did; - hid_t sid; - herr_t status; - - /* Create a buf space */ - sid = H5Screate_simple(rank, dims, NULL); - - /* Create a dataset */ - did = H5Dcreate2(loc_id, dset_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - /* Write the buf */ - if(buf) - status = H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); - - /* Close */ - status = H5Dclose(did); - status = H5Sclose(sid); - - return status; -} - - -static void gent_compound_complex(void) -{ - /* Structure and array for compound types */ - typedef struct Array1Struct { - int a; - const char *b[F41_DIMb]; - char c[F41_ARRAY_DIMc]; - short d[F41_ARRAY_DIMd1][F41_ARRAY_DIMd2]; - float e; - double f[F41_ARRAY_DIMf]; - char g; - } Array1Struct; - Array1Struct Array1[F41_LENGTH]; - - /* Define the value of the string array */ - const char *quote [F41_DIMb] = { - "A fight is a contract that takes two people to honor.", - "A combative stance means that you've accepted the contract.", - "In which case, you deserve what you get.", - " -- Professor Cheng Man-ch'ing" - }; - - /* Define the value of the character array */ - char chararray [F41_ARRAY_DIMc] = {'H', 'e', 'l', 'l', 'o', '!'}; - - - hid_t Array1Structid; /* File datatype identifier */ - hid_t array_tid; /* Array datatype handle */ - hid_t array1_tid; /* Array datatype handle */ - hid_t array2_tid; /* Array datatype handle */ - hid_t array4_tid; /* Array datatype handle */ - hid_t datafile, dataset; /* Datafile/dataset handles */ - hid_t dataspace; /* Dataspace handle */ - herr_t status; /* Error checking variable */ - hsize_t dim[] = {F41_LENGTH}; /* Dataspace dimensions */ - hsize_t array_dimb[] = {F41_DIMb}; /* Array dimensions */ - hsize_t array_dimd[]={F41_ARRAY_DIMd1,F41_ARRAY_DIMd2}; /* Array dimensions */ - hsize_t array_dimf[]={F41_ARRAY_DIMf}; /* Array dimensions */ - hid_t str_array_id; - - int m, n, o; /* Array init loop vars */ - - /* Initialize the data in the arrays/datastructure */ - for(m = 0; m< F41_LENGTH; m++) { - Array1[m].a = m; - - for(n = 0; n < F41_DIMb; n++) - Array1[m].b[n] = quote[n]; - - for(n = 0; n < F41_ARRAY_DIMc; n++) - Array1[m].c[n] = chararray[n]; - - for(n = 0; n < F41_ARRAY_DIMd1; n++) - for(o = 0; o < F41_ARRAY_DIMd2; o++) - Array1[m].d[n][o] = (short)(m + n + o); - - Array1[m].e = (float)((float)m * 0.96F ); - - for(n = 0; n < F41_ARRAY_DIMf; n++) - Array1[m].f[n] = ((float)m * 1024.9637F ); - - Array1[m].g = 'm'; - } - - /* Create the dataspace */ - dataspace = H5Screate_simple(F41_RANK, dim, NULL); - HDassert(dataspace >= 0); - - /* Create the file */ - datafile = H5Fcreate(FILE41, H5F_ACC_TRUNC, H5P_DEFAULT, - H5P_DEFAULT); - HDassert(datafile >= 0); - - /* Copy the array data type for the string array */ - array_tid = H5Tcopy (H5T_C_S1); - HDassert(array_tid >= 0); - - /* Set the string array size to Variable */ - status = H5Tset_size (array_tid,H5T_VARIABLE); - HDassert(status >= 0); - - /* Create the array data type for the string array */ - str_array_id = H5Tarray_create2(array_tid, F41_ARRAY_RANK, array_dimb); - HDassert(str_array_id >= 0); - - /* Copy the array data type for the character array */ - array1_tid = H5Tcopy (H5T_C_S1); - HDassert(array1_tid >= 0); - - /* Set the character array size */ - status = H5Tset_size (array1_tid, F41_ARRAY_DIMc); - HDassert(status >= 0); - - /* Create the array data type for the character array */ - array2_tid = H5Tarray_create2(H5T_NATIVE_SHORT, F41_ARRAY_RANKd, array_dimd); - HDassert(array2_tid >= 0); - - /* Create the array data type for the character array */ - array4_tid = H5Tarray_create2(H5T_NATIVE_DOUBLE, F41_ARRAY_RANK, array_dimf); - HDassert(array4_tid >= 0); - - /* Create the memory data type */ - Array1Structid = H5Tcreate (H5T_COMPOUND, sizeof(Array1Struct)); - HDassert(Array1Structid >= 0); - - /* Insert the arrays and variables into the structure */ - status = H5Tinsert(Array1Structid, "a_name", - HOFFSET(Array1Struct, a), H5T_NATIVE_INT); - HDassert(status >= 0); - - status = H5Tinsert(Array1Structid, "b_name", - HOFFSET(Array1Struct, b), str_array_id); - HDassert(status >= 0); - - status = H5Tinsert(Array1Structid, "c_name", - HOFFSET(Array1Struct, c), array1_tid); - HDassert(status >= 0); - - status = H5Tinsert(Array1Structid, "d_name", - HOFFSET(Array1Struct, d), array2_tid); - HDassert(status >= 0); - - status = H5Tinsert(Array1Structid, "e_name", - HOFFSET(Array1Struct, e), H5T_NATIVE_FLOAT); - HDassert(status >= 0); - - status = H5Tinsert(Array1Structid, "f_name", - HOFFSET(Array1Struct, f), array4_tid); - HDassert(status >= 0); - - status = H5Tinsert(Array1Structid, "g_name", - HOFFSET(Array1Struct, g), H5T_NATIVE_CHAR); - HDassert(status >= 0); - - /* Create the dataset */ - dataset = H5Dcreate2(datafile, F41_DATASETNAME, Array1Structid, - dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - /* Write data to the dataset */ - status = H5Dwrite(dataset, Array1Structid, H5S_ALL, H5S_ALL, - H5P_DEFAULT, Array1); - HDassert(status >= 0); - - /* Release resources */ - status = H5Tclose(Array1Structid); - HDassert(status >= 0); - - status = H5Tclose(array_tid); - HDassert(status >= 0); - - status = H5Tclose(array1_tid); - HDassert(status >= 0); - - status = H5Tclose(array2_tid); - HDassert(status >= 0); - - status = H5Tclose(array4_tid); - HDassert(status >= 0); - - status = H5Tclose(str_array_id); - HDassert(status >= 0); - - status = H5Sclose(dataspace); - HDassert(status >= 0); - - status = H5Dclose(dataset); - HDassert(status >= 0); - - status = H5Fclose(datafile); - HDassert(status >= 0); -} - - -static void gent_named_dtype_attr(void) -{ - hid_t fid; - hid_t did; - hid_t sid; - hid_t tid; - hid_t aid; - hid_t gid; - int data=8; - herr_t ret; - - /* Create a file */ - fid=H5Fcreate(FILE42, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDassert(fid>0); - - /*------------------------------------------------------------------------- - * datatype - *------------------------------------------------------------------------- - */ - - /* Create a datatype to commit and use */ - tid=H5Tcopy(H5T_NATIVE_INT); - HDassert(tid>0); - - /* Commit datatype to file */ - ret = H5Tcommit2(fid, F42_TYPENAME, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - HDassert(ret >= 0); - - /* Create a hard link to the datatype */ - ret = H5Lcreate_hard(fid, F42_TYPENAME, fid, F42_LINKNAME, H5P_DEFAULT, H5P_DEFAULT); - HDassert(ret >= 0); - - /* Create a scalar dataspace used for all objects */ - sid = H5Screate(H5S_SCALAR); - HDassert(sid > 0); - - /* Create attribute on commited datatype */ - aid = H5Acreate2(tid, F42_ATTRNAME, H5T_STD_I32LE, sid, H5P_DEFAULT, H5P_DEFAULT); - HDassert(aid > 0); - - /* Write data into the attribute */ - ret = H5Awrite(aid, H5T_NATIVE_INT, &data); - HDassert(ret >= 0); - - /*------------------------------------------------------------------------- - * dataset - *------------------------------------------------------------------------- - */ - - /* Create dataset */ - did = H5Dcreate2(fid, F42_DSETNAME, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - HDassert(did > 0); - - /* Create attribute on dataset */ - aid = H5Acreate2(did, F42_ATTRNAME, tid, sid, H5P_DEFAULT, H5P_DEFAULT); - HDassert(aid > 0); - - /* Write data into the attribute */ - ret = H5Awrite(aid, H5T_NATIVE_INT, &data); - HDassert(ret >= 0); - - /*------------------------------------------------------------------------- - * group - *------------------------------------------------------------------------- - */ - - /* Create a group */ - gid = H5Gcreate2(fid, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - HDassert(gid > 0); - - /* Create attribute on group */ - aid = H5Acreate2(gid, F42_ATTRNAME, tid, sid, H5P_DEFAULT, H5P_DEFAULT); - HDassert(aid > 0); - - /* Write data into the attribute */ - ret = H5Awrite(aid, H5T_NATIVE_INT, &data); - HDassert(ret >= 0); - - /*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ - - /* Close attribute */ - ret = H5Aclose(aid); - HDassert(ret >= 0); - - /* Close dataset */ - ret = H5Dclose(did); - HDassert(ret >= 0); - - /* Close dataspace */ - ret = H5Sclose(sid); - HDassert(ret >= 0); - - /* Close datatype */ - ret = H5Tclose(tid); - HDassert(ret >= 0); - - /* Close file */ - ret = H5Fclose(fid); - HDassert(ret >= 0); -} - - -/*------------------------------------------------------------------------- - * Function: gent_null_space - * - * Purpose: generates dataset and attribute of null dataspace - *------------------------------------------------------------------------- - */ -static void gent_null_space(void) -{ - hid_t fid, root, dataset, space, attr; - int dset_buf = 10; - int point = 4; - - fid = H5Fcreate(FILE45, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - root = H5Gopen2(fid, "/", H5P_DEFAULT); - - /* null space */ - space = H5Screate(H5S_NULL); - - /* dataset */ - dataset = H5Dcreate2(fid, "dset", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - /* nothing should be written */ - H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &dset_buf); - - /* attribute */ - attr = H5Acreate2(root, "attr", H5T_NATIVE_UINT, space, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, H5T_NATIVE_INT, &point); /* Nothing can be written */ - - H5Dclose(dataset); - H5Aclose(attr); - H5Gclose(root); - H5Sclose(space); - H5Fclose(fid); -} - -/*------------------------------------------------------------------------- - * Function: gent_zero_dim_size - * - * Purpose: generates dataset and attribute with dataspace of 0 dimension size - *------------------------------------------------------------------------- - */ -static void gent_zero_dim_size(void) -{ - hid_t fid, root, dataset, space, attr; - hsize_t dims1[] = {SPACE3_DIM1, SPACE3_DIM2}; - int dset_buf = 10; - int point = 4; - - fid = H5Fcreate(FILE67, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - root = H5Gopen2(fid, "/", H5P_DEFAULT); - - /* dataspace of 0 dimension size */ - space = H5Screate_simple(SPACE3_RANK, dims1, NULL); - - /* dataset */ - dataset = H5Dcreate2(fid, "dset of 0 dimension size", H5T_STD_I32BE, space, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); - /* nothing should be written */ - H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &dset_buf); - - /* attribute */ - attr = H5Acreate2(root, "attr of 0 dimension size", H5T_NATIVE_UINT, space, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, H5T_NATIVE_INT, &point); /* Nothing can be written */ - - H5Dclose(dataset); - H5Aclose(attr); - H5Gclose(root); - H5Sclose(space); - H5Fclose(fid); -} - -/*------------------------------------------------------------------------- - * Function: make_dset - * - * Purpose: utility function to create and write a dataset in LOC_ID - * - *------------------------------------------------------------------------- - */ -static -int make_dset(hid_t loc_id, - const char *name, - hid_t sid, - hid_t tid, - hid_t dcpl, - void *buf) -{ - hid_t dsid; - - /* create the dataset */ - if((dsid = H5Dcreate2(loc_id, name, tid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) - return -1; - - /* write */ - if(H5Dwrite(dsid, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - goto out; - - /* close */ - if(H5Dclose(dsid) < 0) - return -1; - - return 0; - - out: - H5E_BEGIN_TRY { - H5Dclose(dsid); - } H5E_END_TRY; - return -1; -} - - - -/*------------------------------------------------------------------------- - * Function: make_external - * - * Purpose: make a dataset with external storage - * - *------------------------------------------------------------------------- - */ -static void -make_external(hid_t fid) -{ - hid_t dcpl; /*dataset creation property list */ - hid_t sid; /*dataspace ID */ - hid_t dsid; /*dataset ID */ - hsize_t cur_size[1]; /*data space current size */ - hsize_t max_size[1]; /*data space maximum size */ - hsize_t size; /*bytes reserved for data in the external file*/ - int ret; - - cur_size[0] = max_size[0] = 100; - size = (max_size[0]*sizeof(int)/2); - - dcpl = H5Pcreate(H5P_DATASET_CREATE); - ret = H5Pset_external(dcpl, "ext1.bin", (off_t)0, size); - HDassert(ret >= 0); - - ret = H5Pset_external(dcpl, "ext2.bin", (off_t)0, size); - HDassert(ret >= 0); - - sid = H5Screate_simple(1, cur_size, max_size); - HDassert(ret >= 0); - - dsid = H5Dcreate2(fid, "external", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); - HDassert(ret >= 0); - - H5Dclose(dsid); - HDassert(ret >= 0); - - H5Sclose(sid); - HDassert(ret >= 0); - - H5Pclose(dcpl); - HDassert(ret >= 0); -} - -/*------------------------------------------------------------------------- - * Function: gent_filters - * - * Purpose: make several datasets with filters, external dataset - * - *------------------------------------------------------------------------- - */ -static void gent_filters(void) -{ - hid_t fid; /* file id */ - hid_t dcpl; /* dataset creation property list */ - hid_t sid; /* dataspace ID */ - hid_t tid; /* datatype ID */ -#ifdef H5_HAVE_FILTER_SZIP - unsigned szip_options_mask=H5_SZIP_ALLOW_K13_OPTION_MASK|H5_SZIP_NN_OPTION_MASK; - unsigned szip_pixels_per_block=4; -#endif /* H5_HAVE_FILTER_SZIP */ - hsize_t dims1[RANK] = {DIM1,DIM2}; - hsize_t chunk_dims[RANK] = {CDIM1,CDIM2}; - int buf1[DIM1][DIM2]; - int i, j, n, ret; - - for(i=n=0; i<DIM1; i++){ - for(j=0; j<DIM2; j++){ - buf1[i][j]=n++; - } - } - - /* create a file */ - fid = H5Fcreate(FILE44, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDassert(fid>=0); - - /* create a space */ - sid = H5Screate_simple(SPACE2_RANK, dims1, NULL); - - /* create a dataset creation property list; the same DCPL is used for all dsets */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); - - /*------------------------------------------------------------------------- - * create a compact and contiguous storage layout dataset - * add a comment to the datasets - *------------------------------------------------------------------------- - */ - ret = H5Pset_layout(dcpl, H5D_COMPACT); - HDassert(ret >= 0); - - 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); - - ret = H5Pset_layout(dcpl, H5D_CONTIGUOUS); - HDassert(ret >= 0); - - 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); - - ret = H5Pset_layout(dcpl, H5D_CHUNKED); - HDassert(ret >= 0); - - ret = H5Pset_chunk(dcpl, SPACE2_RANK, chunk_dims); - HDassert(ret >= 0); - - 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); - - /*------------------------------------------------------------------------- - * make several dataset with filters - *------------------------------------------------------------------------- - */ - - /* set up chunk */ - ret = H5Pset_chunk(dcpl, SPACE2_RANK, chunk_dims); - HDassert(ret >= 0); - - /*------------------------------------------------------------------------- - * SZIP - *------------------------------------------------------------------------- - */ -#ifdef H5_HAVE_FILTER_SZIP - if(h5tools_can_encode(H5Z_FILTER_SZIP) == 1) { - /* remove the filters from the dcpl */ - ret = H5Premove_filter(dcpl,H5Z_FILTER_ALL); - HDassert(ret >= 0); - - /* set szip data */ - ret = H5Pset_szip (dcpl,szip_options_mask,szip_pixels_per_block); - HDassert(ret >= 0); - - ret=make_dset(fid,"szip",sid,H5T_NATIVE_INT,dcpl,buf1); - HDassert(ret >= 0); - } -#endif /* H5_HAVE_FILTER_SZIP */ - - /*------------------------------------------------------------------------- - * GZIP - *------------------------------------------------------------------------- - */ -#if defined (H5_HAVE_FILTER_DEFLATE) - /* remove the filters from the dcpl */ - ret = H5Premove_filter(dcpl,H5Z_FILTER_ALL); - HDassert(ret >= 0); - - /* set deflate data */ - ret = H5Pset_deflate(dcpl, 9); - HDassert(ret >= 0); - - ret=make_dset(fid,"deflate",sid,H5T_NATIVE_INT,dcpl,buf1); - HDassert(ret >= 0); -#endif - - - /*------------------------------------------------------------------------- - * shuffle - *------------------------------------------------------------------------- - */ - - /* remove the filters from the dcpl */ - ret = H5Premove_filter(dcpl,H5Z_FILTER_ALL); - HDassert(ret >= 0); - - /* set the shuffle filter */ - ret = H5Pset_shuffle(dcpl); - HDassert(ret >= 0); - - ret=make_dset(fid,"shuffle",sid,H5T_NATIVE_INT,dcpl,buf1); - HDassert(ret >= 0); - - - /*------------------------------------------------------------------------- - * checksum - *------------------------------------------------------------------------- - */ - - /* remove the filters from the dcpl */ - ret = H5Premove_filter(dcpl,H5Z_FILTER_ALL); - HDassert(ret >= 0); - - /* set the checksum filter */ - ret = H5Pset_fletcher32(dcpl); - HDassert(ret >= 0); - - ret=make_dset(fid,"fletcher32",sid,H5T_NATIVE_INT,dcpl,buf1); - HDassert(ret >= 0); - - /*------------------------------------------------------------------------- - * nbit - *------------------------------------------------------------------------- - */ - - /* remove the filters from the dcpl */ - ret = H5Premove_filter(dcpl,H5Z_FILTER_ALL); - HDassert(ret >= 0); - - /* set the checksum filter */ - ret = H5Pset_nbit(dcpl); - HDassert(ret >= 0); - - tid=H5Tcopy(H5T_NATIVE_INT); - H5Tset_precision(tid,H5Tget_size(tid)-1); - ret=make_dset(fid,"nbit",sid,tid,dcpl,buf1); - HDassert(ret >= 0); - - /*------------------------------------------------------------------------- - * scaleoffset - *------------------------------------------------------------------------- - */ - - /* remove the filters from the dcpl */ - ret = H5Premove_filter(dcpl,H5Z_FILTER_ALL); - HDassert(ret >= 0); - - /* set the scaleoffset filter */ - ret = H5Pset_scaleoffset(dcpl,H5Z_SO_INT,(int)H5Tget_size(H5T_NATIVE_INT)); - HDassert(ret >= 0); - - ret=make_dset(fid,"scaleoffset",sid,H5T_NATIVE_INT,dcpl,buf1); - HDassert(ret >= 0); - - /*------------------------------------------------------------------------- - * all filters - *------------------------------------------------------------------------- - */ - /* remove the filters from the dcpl */ - ret = H5Premove_filter(dcpl,H5Z_FILTER_ALL); - HDassert(ret >= 0); - - /* set the shuffle filter */ - ret = H5Pset_shuffle(dcpl); - HDassert(ret >= 0); - -#ifdef H5_HAVE_FILTER_SZIP - if(h5tools_can_encode(H5Z_FILTER_SZIP) == 1) { - szip_options_mask=H5_SZIP_CHIP_OPTION_MASK | H5_SZIP_EC_OPTION_MASK; - /* set szip data */ - ret = H5Pset_szip (dcpl,szip_options_mask,szip_pixels_per_block); - HDassert(ret >= 0); - } -#endif /* H5_HAVE_FILTER_SZIP */ - -#if defined (H5_HAVE_FILTER_DEFLATE) - /* set deflate data */ - ret = H5Pset_deflate(dcpl, 5); - HDassert(ret >= 0); -#endif - - /* set the checksum filter */ - ret = H5Pset_fletcher32(dcpl); - HDassert(ret >= 0); - - /* set the nbit filter */ - ret = H5Pset_nbit(dcpl); - HDassert(ret >= 0); - - ret=make_dset(fid,"all",sid,H5T_NATIVE_INT,dcpl,buf1); - HDassert(ret >= 0); - - - /*------------------------------------------------------------------------- - * user defined filter - *------------------------------------------------------------------------- - */ - /* remove the filters from the dcpl */ - ret = H5Premove_filter(dcpl,H5Z_FILTER_ALL); - HDassert(ret >= 0); - - ret = H5Zregister (H5Z_MYFILTER); - HDassert(ret >= 0); - - ret = H5Pset_filter (dcpl, MYFILTER_ID, 0, 0, NULL); - HDassert(ret >= 0); - - ret=make_dset(fid,"myfilter",sid,H5T_NATIVE_INT,dcpl,buf1); - HDassert(ret >= 0); - - /* remove the filters from the dcpl */ - ret = H5Premove_filter(dcpl,H5Z_FILTER_ALL); - HDassert(ret >= 0); - - /*------------------------------------------------------------------------- - * make an external dataset - *------------------------------------------------------------------------- - */ - make_external(fid); - - /*------------------------------------------------------------------------- - * H5D_ALLOC_TIME_EARLY - *------------------------------------------------------------------------- - */ - ret = H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY); - HDassert(ret >= 0); - ret=make_dset(fid,"alloc_time_early",sid,H5T_NATIVE_INT,dcpl,buf1); - HDassert(ret >= 0); - - /*------------------------------------------------------------------------- - * H5D_ALLOC_TIME_INCR - *------------------------------------------------------------------------- - */ - ret = H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_INCR); - HDassert(ret >= 0); - ret=make_dset(fid,"alloc_time_incr",sid,H5T_NATIVE_INT,dcpl,buf1); - HDassert(ret >= 0); - - /*------------------------------------------------------------------------- - * H5D_ALLOC_TIME_LATE - *------------------------------------------------------------------------- - */ - ret = H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE); - HDassert(ret >= 0); - ret=make_dset(fid,"alloc_time_late",sid,H5T_NATIVE_INT,dcpl,buf1); - HDassert(ret >= 0); - - /*------------------------------------------------------------------------- - * commit a H5G_TYPE type with a comment - *------------------------------------------------------------------------- - */ - tid = H5Tcopy(H5T_STD_B8LE); - 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); - - ret = H5Tclose(tid); - HDassert(ret >= 0); - - /*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ - ret = H5Sclose(sid); - HDassert(ret >= 0); - - ret = H5Pclose(dcpl); - HDassert(ret >= 0); - - ret = H5Fclose(fid); - HDassert(ret >= 0); -} - - -/*------------------------------------------------------------------------- - * Function: myfilter - * - * Purpose: filter operation callback function; the filter does nothing - * - *------------------------------------------------------------------------- - */ -static size_t -myfilter(unsigned int H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, - const unsigned int H5_ATTR_UNUSED *cd_values, size_t nbytes, - size_t H5_ATTR_UNUSED *buf_size, void H5_ATTR_UNUSED **buf) -{ - return nbytes; -} - - -/*------------------------------------------------------------------------- - * Function: set_local_myfilter - * - * Purpose: filter operation "set local" callback - * - *------------------------------------------------------------------------- - */ - -static herr_t -set_local_myfilter(hid_t dcpl_id, hid_t H5_ATTR_UNUSED tid, hid_t H5_ATTR_UNUSED sid) -{ - unsigned flags; /* Filter flags */ - size_t cd_nelmts = 0; /* Number of filter parameters */ - unsigned cd_values[2] = {5, 6}; /* Filter parameters */ - - /* Get the filter's current parameters */ - if(H5Pget_filter_by_id2(dcpl_id, MYFILTER_ID, &flags, &cd_nelmts, cd_values, 0, NULL, NULL) < 0) - return(FAIL); - - cd_nelmts = 2; - - /* Modify the filter's parameters for this dataset */ - if(H5Pmodify_filter(dcpl_id, MYFILTER_ID, flags, cd_nelmts, cd_values) < 0) - return(FAIL); - - return(SUCCEED); -} - -/*------------------------------------------------------------------------- - * Function: gent_fcontents - * - * Purpose: generate several files to list its contents - * - *------------------------------------------------------------------------- - */ -static void gent_fcontents(void) -{ - hid_t fid; /* file id */ - hid_t gid1; /* group ID */ - hid_t tid; /* datatype ID */ - hsize_t dims[1]={4}; - int buf[4]={1,2,3,4}; - int ret; - - - /* create a file */ - fid = H5Fcreate(FILE46, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDassert(fid>=0); - - - write_dset(fid,1,dims,"dset",H5T_NATIVE_INT,buf); - - - /*------------------------------------------------------------------------- - * links - *------------------------------------------------------------------------- - */ - - - /* hard link to "dset" */ - gid1 = H5Gcreate2(fid, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Lcreate_hard(gid1, "/dset", H5L_SAME_LOC, "dset1", H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(gid1); - - - /* hard link to "dset" */ - gid1 = H5Gcreate2(fid, "/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Lcreate_hard(gid1, "/dset", H5L_SAME_LOC, "dset2", H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(gid1); - - - /* hard link to "g2" */ - gid1 = H5Gopen2(fid, "/g1", H5P_DEFAULT); - H5Lcreate_hard(gid1, "/g2", H5L_SAME_LOC, "g1.1", H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(gid1); - - - /* hard link to "dset" */ - ret = H5Lcreate_hard(fid, "/dset", H5L_SAME_LOC, "dset3", H5P_DEFAULT, H5P_DEFAULT); - HDassert(ret >= 0); - - - /* hard link to "dset" */ - ret = H5Lcreate_hard(fid, "/dset", H5L_SAME_LOC, "dset4", H5P_DEFAULT, H5P_DEFAULT); - HDassert(ret >= 0); - - - /* soft link to itself */ - ret = H5Lcreate_soft("mylink", fid, "mylink", H5P_DEFAULT, H5P_DEFAULT); - HDassert(ret >= 0); - - - /* soft link to "dset" */ - ret = H5Lcreate_soft("/dset", fid, "softlink", H5P_DEFAULT, H5P_DEFAULT); - HDassert(ret >= 0); - - /* dangling external link */ - ret = H5Lcreate_external("fname", "oname", fid, "extlink", H5P_DEFAULT, H5P_DEFAULT); - HDassert(ret >= 0); - - /* dangling udlink */ - ret = H5Lcreate_ud(fid, "udlink", (H5L_type_t)MY_LINKCLASS, NULL, 0, H5P_DEFAULT, H5P_DEFAULT); - HDassert(ret >= 0); - - /*------------------------------------------------------------------------- - * datatypes - *------------------------------------------------------------------------- - */ - tid = H5Tcopy(H5T_NATIVE_INT); - ret = H5Tcommit2(fid, "mytype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - HDassert(ret >= 0); - ret = H5Tclose(tid); - HDassert(ret >= 0); - - - /* no name datatype */ - tid = H5Tcopy(H5T_NATIVE_INT); - ret = H5Tcommit2(fid, "mytype2", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - HDassert(ret >= 0); - write_dset(fid, 1, dims, "dsetmytype2", tid, buf); - ret = H5Ldelete(fid, "mytype2", H5P_DEFAULT); - HDassert(ret >= 0); - ret = H5Tclose(tid); - HDassert(ret >= 0); - - - /*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ - - - ret = H5Fclose(fid); - HDassert(ret >= 0); - - - /* create a file for the bootblock test */ - fid = H5Fcreate(FILE47, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDassert(fid>=0); - - - ret = H5Fclose(fid); - HDassert(ret >= 0); -} - -/*------------------------------------------------------------------------- - * Function: gent_fvalues - * - * Purpose: generate a file for the fill values test - * - *------------------------------------------------------------------------- - */ -static void gent_fvalues(void) -{ - /* compound datatype */ - typedef struct c_t - { - char a; - double b; - } c_t; - - - hid_t fid; /* file id */ - hid_t dcpl; /* dataset creation property list */ - hid_t sid; /* dataspace ID */ - hid_t tid; /* datatype ID */ - hid_t did; /* datasetID */ - hsize_t dims[1]={2}; - int buf[2]={1,2}; /* integer */ - int fillval1=-99; /* integer fill value */ - c_t buf2[2]={{1,2},{3,4}}; /* compound */ - c_t fillval2[1]={{1,2}}; /* compound fill value */ - hvl_t buf3[2]; /* vlen */ - hvl_t fillval3; /* vlen fill value */ - hsize_t dimarray[1]={3}; /* array dimension */ - int buf4[2][3]= {{1,2,3},{4,5,6}}; /* array */ - int ret; - - /* create a file */ - fid = H5Fcreate(FILE48, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDassert(fid>=0); - - /* create a space */ - sid = H5Screate_simple(1, dims, NULL); - - /* create a dataset creation property list */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); - - /*------------------------------------------------------------------------- - * make datasets with fill value combinations - * H5D_FILL_TIME_IFSET - *------------------------------------------------------------------------- - */ - ret = H5Pset_fill_time(dcpl, H5D_FILL_TIME_IFSET); - HDassert(ret >= 0); - - ret = H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval1); - HDassert(ret >= 0); - - ret=make_dset(fid,"fill_time_ifset",sid,H5T_NATIVE_INT,dcpl,buf); - HDassert(ret >= 0); - - /*------------------------------------------------------------------------- - * H5D_FILL_TIME_NEVER - *------------------------------------------------------------------------- - */ - ret = H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER); - HDassert(ret >= 0); - - ret = H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval1); - HDassert(ret >= 0); - - ret=make_dset(fid,"fill_time_never",sid,H5T_NATIVE_INT,dcpl,buf); - HDassert(ret >= 0); - - /*------------------------------------------------------------------------- - * H5D_FILL_TIME_ALLOC - *------------------------------------------------------------------------- - */ - ret = H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC); - HDassert(ret >= 0); - - ret = H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval1); - HDassert(ret >= 0); - - ret=make_dset(fid,"fill_time_alloc",sid,H5T_NATIVE_INT,dcpl,buf); - HDassert(ret >= 0); - - ret = H5Pclose(dcpl); - HDassert(ret >= 0); - - /*------------------------------------------------------------------------- - * dataset with no fill value - *------------------------------------------------------------------------- - */ - write_dset(fid,1,dims,"no_fill",H5T_NATIVE_INT,buf); - - /*------------------------------------------------------------------------- - * dataset with a H5T_COMPOUND fill value - *------------------------------------------------------------------------- - */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); - tid = H5Tcreate (H5T_COMPOUND, sizeof(c_t)); - H5Tinsert(tid, "a", HOFFSET(c_t, a), H5T_NATIVE_CHAR); - H5Tinsert(tid, "b", HOFFSET(c_t, b), H5T_NATIVE_DOUBLE); - ret = H5Pset_fill_value(dcpl, tid, &fillval2); - HDassert(ret >= 0); - ret=make_dset(fid,"fill_compound",sid,tid,dcpl,buf2); - HDassert(ret >= 0); - ret = H5Tclose(tid); - HDassert(ret >= 0); - ret = H5Pclose(dcpl); - HDassert(ret >= 0); - - /*------------------------------------------------------------------------- - * dataset with a H5T_VLEN fill value - *------------------------------------------------------------------------- - */ - buf3[0].len = 1; - buf3[0].p = HDmalloc( 1 * sizeof(int)); - ((int *)buf3[0].p)[0]=1; - buf3[1].len = 2; - buf3[1].p = HDmalloc(2 * sizeof(int)); - ((int *)buf3[1].p)[0] = 2; - ((int *)buf3[1].p)[1] = 3; - - tid = H5Tvlen_create(H5T_NATIVE_INT); - dcpl = H5Pcreate(H5P_DATASET_CREATE); - - fillval3.p=NULL; fillval3.len=0; - ret = H5Pset_fill_value(dcpl, tid, &fillval3); - HDassert(ret >= 0); - - did = H5Dcreate2(fid, "fill_vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - ret = H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf3); - HDassert(ret >= 0); - ret = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf3); - HDassert(ret >= 0); - ret = H5Dclose(did); - ret = H5Tclose(tid); - ret = H5Pclose(dcpl); - HDassert(ret >= 0); - - /*------------------------------------------------------------------------- - * dataset with a H5T_ARRAY fill value - *------------------------------------------------------------------------- - */ - tid = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray); - write_dset(fid, 1, dims, "fill_array", tid, buf4); - ret = H5Tclose(tid); - - - /*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ - ret = H5Sclose(sid); - HDassert(ret >= 0); - ret = H5Fclose(fid); - HDassert(ret >= 0); -} - - -/*------------------------------------------------------------------------- - * Function: gent_string - * - * Purpose: make several datasets for the string with escape/not escape test - * - *------------------------------------------------------------------------- - */ -static void gent_string(void) -{ - /* compound datatype */ - typedef struct c_t - { - int a; - char str[255]; - } c_t; - - hid_t fid; /* file id */ - hid_t sid; /* dataspace ID */ - hid_t tid; /* datatype ID */ - hid_t str_tid; /* datatype ID */ - hid_t did; /* dataset ID */ - char buf1[]={"quote \" backspace\b form feed\f new line\n tab\t new line\n carriage return\r"}; - const char *buf2[SPACE1_DIM1]= { - "Four score and seven\n years ago our forefathers brought forth on this continent a new nation,", - "conceived in liberty\n and dedicated to the proposition that all men are created equal.", - "Now we are engaged\n in a great civil war,", - "testing whether that\n nation or any nation so conceived and so dedicated can long endure." - }; - c_t buf3 = {24, "Four score and seven\n years ago our forefathers brought forth on this continent a new nation"}; - char buf4[] = {"Four score and seven\n years ago our forefathers brought forth on this continent a new nation"}; - hsize_t dims1[] = {1}; - hsize_t dims2[] = {SPACE1_DIM1}; - hsize_t dims4[1]; - int ret; - - dims4[0] = sizeof(buf4); - - /* create a file */ - fid = H5Fcreate(FILE49, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDassert(fid>=0); - - /*------------------------------------------------------------------------- - * str1 - *------------------------------------------------------------------------- - */ - - tid=H5Tcopy(H5T_C_S1); - ret = H5Tset_size(tid, sizeof(buf1)); - HDassert(ret >= 0); - write_dset(fid,1,dims1,"str1",tid,buf1); - HDassert(ret >= 0); - ret = H5Tclose(tid); - HDassert(ret >= 0); - - /*------------------------------------------------------------------------- - * str2 - *------------------------------------------------------------------------- - */ - sid = H5Screate_simple(SPACE1_RANK, dims2, NULL); - tid = H5Tcopy(H5T_C_S1); - ret = H5Tset_size(tid, H5T_VARIABLE); - HDassert(ret >= 0); - did = H5Dcreate2(fid, "str2", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - ret = H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2); - HDassert(ret >= 0); - ret = H5Tclose(tid); - HDassert(ret >= 0); - ret = H5Dclose(did); - HDassert(ret >= 0); - ret = H5Sclose(sid); - HDassert(ret >= 0); - - /*------------------------------------------------------------------------- - * str3 - *------------------------------------------------------------------------- - */ - sid = H5Screate_simple(SPACE1_RANK, dims1, NULL); - tid = H5Tcreate (H5T_COMPOUND, sizeof(c_t)); - str_tid = H5Tcopy( H5T_C_S1 ); - H5Tset_size( str_tid, 255 ); - H5Tinsert(tid, "a", HOFFSET(c_t, a), H5T_NATIVE_INT); - H5Tinsert(tid, "str", HOFFSET(c_t, str), str_tid ); - ret=make_dset(fid,"str3",sid,tid,H5P_DEFAULT,&buf3); - HDassert(ret >= 0); - ret = H5Tclose(tid); - HDassert(ret >= 0); - ret = H5Tclose(str_tid); - HDassert(ret >= 0); - ret = H5Sclose(sid); - HDassert(ret >= 0); - - /*------------------------------------------------------------------------- - * str4 - *------------------------------------------------------------------------- - */ - sid = H5Screate_simple(SPACE1_RANK, dims4, NULL); - ret=make_dset(fid,"str4",sid,H5T_NATIVE_CHAR,H5P_DEFAULT,buf4); - ret = H5Sclose(sid); - HDassert(ret >= 0); - - /*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ - ret = H5Fclose(fid); - HDassert(ret >= 0); -} - - -/*------------------------------------------------------------------------- - * Function: gent_aindices - * - * Purpose: make several datasets for the array indices and subsetting tests - * - *------------------------------------------------------------------------- - */ -static void gent_aindices(void) -{ - hid_t fid; /* file id */ - hid_t gid[6]; /* group ids */ - hsize_t dims1[1] = {100}; - hsize_t dims2[2] = {10,10}; - hsize_t dims3[3] = {2,10,10}; - hsize_t dims4[4] = {2,2,10,10}; - int buf1[100]; - int buf2[10][10]; - int buf3[2][10][10]; - int buf4[2][2][10][10]; - int i, j, k, l, n, ret; - - for(i = n = 0; i < 100; i++) - buf1[i] = n++; - - for(i = n = 0; i < 10; i++) - for(j = 0; j < 10; j++) - buf2[i][j] = n++; - for(i = n = 0; i < 2; i++) - for(j = 0; j < 10; j++) - for(k = 0; k < 10; k++) - buf3[i][j][k] = n++; - for(i = n = 0; i < 2; i++) - for(j = 0; j < 2; j++) - for(k = 0; k < 10; k++) - for(l = 0; l < 10; l++) - buf4[i][j][k][l] = n++; - - /* create a file */ - fid = H5Fcreate(FILE50, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDassert(fid>=0); - - /*------------------------------------------------------------------------- - * root datasets - *------------------------------------------------------------------------- - */ - write_dset(fid,1,dims1,"1d",H5T_NATIVE_INT,buf1); - write_dset(fid,2,dims2,"2d",H5T_NATIVE_INT,buf2); - write_dset(fid,3,dims3,"3d",H5T_NATIVE_INT,buf3); - write_dset(fid,4,dims4,"4d",H5T_NATIVE_INT,buf4); - - /*------------------------------------------------------------------------- - * test with group indentation - *------------------------------------------------------------------------- - */ - gid[0] = H5Gcreate2(fid, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - gid[1] = H5Gcreate2(fid, "g1/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - gid[2] = H5Gcreate2(fid, "g1/g2/g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - gid[3] = H5Gcreate2(fid, "g1/g2/g3/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - gid[4] = H5Gcreate2(fid, "g1/g2/g3/g4/g5", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - gid[5] = H5Gcreate2(fid, "g1/g2/g3/g4/g5/g6", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - write_dset(gid[5],1,dims1,"1d",H5T_NATIVE_INT,buf1); - write_dset(gid[5],2,dims2,"2d",H5T_NATIVE_INT,buf2); - write_dset(gid[5],3,dims3,"3d",H5T_NATIVE_INT,buf3); - write_dset(gid[5],4,dims4,"4d",H5T_NATIVE_INT,buf4); - for(i = 0; i < 6; i++) - H5Gclose(gid[i]); - - /*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ - ret = H5Fclose(fid); - HDassert(ret >= 0); - -} - - -/*------------------------------------------------------------------------- - * Function: gent_longlinks - * - * Purpose: make file with very long names for objects - * - *------------------------------------------------------------------------- - */ -static void gent_longlinks(void) -{ - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group ID */ - hid_t gid2 = (-1); /* Datatype ID */ - char *objname = NULL; /* Name of object [Long] */ - size_t u; /* Local index variable */ - - /* Create files */ - fid = H5Fcreate(FILE51, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDassert(fid >= 0); - - /* Create group with short name in file (used as target for hard links) */ - gid = H5Gcreate2(fid, "grp1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - HDassert(gid >= 0); - - /* Construct very long file name */ - objname = (char*) HDmalloc((size_t)(F51_MAX_NAME_LEN + 1)); - HDassert(objname); - for(u = 0; u < F51_MAX_NAME_LEN; u++) - objname[u] = 'a'; - objname[F51_MAX_NAME_LEN] = '\0'; - - /* Create hard link to existing object */ - HDassert(H5Lcreate_hard(fid, "grp1", fid, objname, H5P_DEFAULT, H5P_DEFAULT) >= 0); - - /* Create soft link to existing object */ - objname[0] = 'b'; - HDassert(H5Lcreate_soft("grp1", fid, objname, H5P_DEFAULT, H5P_DEFAULT) >= 0); - - /* Create group with long name in existing group */ - gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - HDassert(gid2 >= 0); - - /* Close objects */ - HDassert(H5Gclose(gid2) >= 0); - HDassert(H5Gclose(gid) >= 0); - HDassert(H5Fclose(fid) >= 0); - - /* Release memory */ - HDfree(objname); -} - -/*------------------------------------------------------------------------- - * Function: gent_ldouble - * - * Purpose: make file with a long double dataset - * - *------------------------------------------------------------------------- - */ -static int gent_ldouble(void) -{ - hid_t fid; - hid_t did; - hid_t tid; - hid_t sid; - hsize_t dims[1] = {3}; - long double buf[3] = {1,2,3}; - - if((fid = H5Fcreate(FILE52, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; - - if((sid = H5Screate_simple(1, dims, NULL)) < 0) - goto error; - - if((tid = H5Tcopy(H5T_NATIVE_LDOUBLE)) < 0) - goto error; - - if(H5Tget_size(tid) == 0) - goto error; - - if((did = H5Dcreate2(fid, "dset", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; - - if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - goto error; - - if(H5Sclose(sid) < 0) - goto error; - if(H5Tclose(tid) < 0) - goto error; - if(H5Dclose(did) < 0) - goto error; - if(H5Fclose(fid) < 0) - goto error; - - return 0; - - error: - printf("error !\n"); - return -1; - -} - - -/*------------------------------------------------------------------------- - * Function: gent_binary - * - * Purpose: Generate a file to be used in the binary output test - * Contains: - * 1) an integer dataset - * 2) a float dataset - * 3) a double dataset - * - *------------------------------------------------------------------------- - */ -static void -gent_binary(void) -{ - hid_t fid, sid, did, aid; - hsize_t dims[1] = {6}; - int ibuf[6] = {1,2,3,4,5,6}; - float fbuf[6] = {1,2,3,4,5,6}; - double dbuf[6] = {1,2,3,4,5,6}; - - fid = H5Fcreate(FILE55, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - sid = H5Screate_simple(1, dims, NULL); - - - /*------------------------------------------------------------------------- - * integer - *------------------------------------------------------------------------- - */ - - did = H5Dcreate2(fid, "integer", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf); - H5Dclose(did); - - /*------------------------------------------------------------------------- - * float - *------------------------------------------------------------------------- - */ - did = H5Dcreate2(fid, "float", H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Dwrite(did, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, fbuf); - H5Dclose(did); - - /*------------------------------------------------------------------------- - * double - *------------------------------------------------------------------------- - */ - did = H5Dcreate2(fid, "double", H5T_NATIVE_DOUBLE, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Dwrite(did, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dbuf); - /* create an attribute */ - aid = H5Acreate2(did, "attr", H5T_NATIVE_DOUBLE, sid, H5P_DEFAULT, H5P_DEFAULT); - H5Aclose(aid); - H5Dclose(did); - - - /* close */ - H5Sclose(sid); - H5Fclose(fid); -} - -/*------------------------------------------------------------------------- - * Function: gen_bigdims - * - * Purpose: generate a dataset with dimensions greater than 4GB - * and write one hyperslab on the boundary - * - *------------------------------------------------------------------------- - */ -#define GB4LL ((unsigned long long) 4*1024*1024*1024) -#define DIM_4GB (GB4LL + 10) - -static void -gent_bigdims(void) -{ - hid_t fid = -1; - hid_t did = -1; - hid_t f_sid = -1; - hid_t m_sid = -1; - hid_t tid = -1; - hid_t dcpl = -1; - hsize_t dims[1]={DIM_4GB}; /* dataset dimensions */ - hsize_t chunk_dims[1]={1024}; /* chunk dimensions */ - hsize_t hs_start[1]; - hsize_t hs_size[1]; /* hyperslab dimensions */ - size_t size; - char fillvalue=0; - char *buf=NULL; - hsize_t i; - char c; - size_t nelmts; - int ret; - - /* create a file */ - fid = H5Fcreate(FILE56, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDassert(fid >= 0); - - /* create dataset */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - goto out; - if(H5Pset_fill_value(dcpl, H5T_NATIVE_SCHAR, &fillvalue) < 0) - goto out; - if(H5Pset_chunk(dcpl, 1, chunk_dims) < 0) - goto out; - if((f_sid = H5Screate_simple(1, dims, NULL)) < 0) - goto out; - if((did = H5Dcreate2(fid, "dset4gb", H5T_NATIVE_SCHAR, f_sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) - goto out; - if((tid = H5Dget_type(did)) < 0) - goto out; - if((size = H5Tget_size(tid)) <= 0) - goto out; - - /* select an hyperslab */ - nelmts = 20; - hs_start[0] = GB4LL - 10; - hs_size[0] = nelmts; - - if((m_sid = H5Screate_simple(1, hs_size, hs_size)) < 0) - goto out; - - buf=(char *) HDmalloc((unsigned)(nelmts*size)); - - for(i=0, c=0; i<nelmts; i++, c++) - { - buf[i] = c; - } - - if(H5Sselect_hyperslab (f_sid,H5S_SELECT_SET,hs_start,NULL,hs_size,NULL) < 0) - goto out; - if(H5Dwrite (did,H5T_NATIVE_SCHAR,m_sid,f_sid,H5P_DEFAULT,buf) < 0) - goto out; - - - HDfree(buf); - buf=NULL; - - /* close */ - if(H5Tclose(tid) < 0) - goto out; - tid = -1; - if(H5Sclose(f_sid) < 0) - goto out; - f_sid = -1; - if(H5Sclose(m_sid) < 0) - goto out; - m_sid = -1; - if(H5Pclose(dcpl) < 0) - goto out; - dcpl = -1; - if(H5Dclose(did) < 0) - goto out; - did = -1; - - ret = H5Fclose(fid); - HDassert(ret >= 0); - - return; - - out: - printf("Error.....\n"); - H5E_BEGIN_TRY { - H5Pclose(dcpl); - H5Sclose(f_sid); - H5Sclose(m_sid); - H5Tclose(tid); - H5Dclose(did); - H5Fclose(fid); - } H5E_END_TRY; - return; -} - - - -/*------------------------------------------------------------------------- - * Function: gent_hyperslab - * - * Purpose: make a dataset for hyperslab read - * - *------------------------------------------------------------------------- - */ -static void -gent_hyperslab(void) -{ - hid_t fid; /* file id */ - hsize_t dims[2] = {32,4097}; /* big enough data size to force a second stripmine read */ - double *buf; - int i, ret; - - buf = (double*) HDmalloc(32 * 4097 * sizeof(double) ); - for(i = 0; i < 32 * 4097; i++) - buf[i] = 1; - - /* create a file */ - fid = H5Fcreate(FILE57, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDassert(fid>=0); - - write_dset(fid,2,dims,"stripmine",H5T_NATIVE_DOUBLE,buf); - - ret = H5Fclose(fid); - HDassert(ret >= 0); - - HDfree(buf); -} - -/*------------------------------------------------------------------------- - * Function: gent_group_creation_order - * - * Purpose: generate a file with several groups with creation order set and not - * set tru its hierarchy - * - *------------------------------------------------------------------------- - */ -static void -gent_group_creation_order(void) -{ - hid_t fid = -1; /* file ID */ - hid_t gid = -1; /* group ID */ - hid_t gcpl_id = -1; /* group creation property list ID */ - hid_t fcpl_id = -1; /* file creation property list ID (to set root group order) */ - - if((fcpl_id = H5Pcreate(H5P_FILE_CREATE)) < 0) - goto out; - - if(H5Pset_link_creation_order(fcpl_id, H5P_CRT_ORDER_TRACKED ) < 0) - goto out; - - if((fid = H5Fcreate(FILE58, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT)) < 0) - goto out; - - - /* create group creation property list */ - if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) - goto out; - - /*------------------------------------------------------------------------- - * create a group "2" - *------------------------------------------------------------------------- - */ - - - if((gid = H5Gcreate2(fid, "2", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) - goto out; - if(H5Gclose(gid) < 0) - goto out; - gid = -1; - - if((gid = H5Gcreate2(fid, "2/c", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto out; - if(H5Gclose(gid) < 0) - goto out; - gid = -1; - if((gid = H5Gcreate2(fid, "2/b", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto out; - if(H5Gclose(gid) < 0) - goto out; - gid = -1; - if((gid = H5Gcreate2(fid, "2/a", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto out; - if(H5Gclose(gid) < 0) - goto out; - gid = -1; - - if((gid = H5Gcreate2(fid, "2/a/a2", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) - goto out; - if(H5Gclose(gid) < 0) - goto out; - gid = -1; - if((gid = H5Gcreate2(fid, "2/a/a1", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) - goto out; - if(H5Gclose(gid) < 0) - goto out; - gid = -1; - - if((gid = H5Gcreate2(fid, "2/a/a2/a22", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto out; - if(H5Gclose(gid) < 0) - goto out; - gid = -1; - if((gid = H5Gcreate2(fid, "2/a/a2/a21", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto out; - if(H5Gclose(gid) < 0) - goto out; - gid = -1; - - - /*------------------------------------------------------------------------- - * create a group "1" with H5P_CRT_ORDER_TRACKED set - *------------------------------------------------------------------------- - */ - if(H5Pset_link_creation_order(gcpl_id, H5P_CRT_ORDER_TRACKED) < 0) - goto out; - - - if((gid = H5Gcreate2(fid, "1", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) - goto out; - if(H5Gclose(gid) < 0) - goto out; - gid = -1; - - if((gid = H5Gcreate2(fid, "1/c", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto out; - if(H5Gclose(gid) < 0) - goto out; - gid = -1; - if((gid = H5Gcreate2(fid, "1/b", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto out; - if(H5Gclose(gid) < 0) - goto out; - gid = -1; - if((gid = H5Gcreate2(fid, "1/a", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto out; - if(H5Gclose(gid) < 0) - goto out; - gid = -1; - - if((gid = H5Gcreate2(fid, "1/a/a2", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) - goto out; - if(H5Gclose(gid) < 0) - goto out; - gid = -1; - if((gid = H5Gcreate2(fid, "1/a/a1", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) - goto out; - if(H5Gclose(gid) < 0) - goto out; - gid = -1; - - if((gid = H5Gcreate2(fid, "1/a/a2/a22", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto out; - if(H5Gclose(gid) < 0) - goto out; - gid = -1; - if((gid = H5Gcreate2(fid, "1/a/a2/a21", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto out; - if(H5Gclose(gid) < 0) - goto out; - gid = -1; - - - if(H5Pclose(gcpl_id) < 0) - goto out; - gcpl_id = -1; - if(H5Pclose(fcpl_id) < 0) - goto out; - fcpl_id = -1; - if(H5Fclose(fid) < 0) - goto out; - fid = -1; - - return; - - out: - printf("Error.....\n"); - H5E_BEGIN_TRY { - H5Gclose(gid); - H5Pclose(gcpl_id); - H5Pclose(fcpl_id); - H5Fclose(fid); - - } H5E_END_TRY; - return; - -} - -/*------------------------------------------------------------------------- - * Function: gent_attr_creation_order - * - * Purpose: generate a file with several objects with attributes with creation - * order set and not set - * - *------------------------------------------------------------------------- - */ -static void -gent_attr_creation_order(void) -{ - hid_t fid = -1; /* file id */ - hid_t gid = -1; /* group id */ - hid_t did = -1; /* dataset id */ - hid_t sid = -1; /* space id */ - hid_t aid = -1; /* attribute id */ - hid_t tid = -1; /* datatype id */ - hid_t gcpl_id = -1; /* group creation property list ID */ - hid_t dcpl_id = -1; /* dataset creation property list ID */ - hid_t tcpl_id = -1; /* datatype creation property list ID */ - int i; - const char *attr_name[3] = {"c", "b", "a" }; - - if((fid = H5Fcreate(FILE59, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto out; - - /* create group creation property list */ - if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) - goto out; - - /* create dataset creation property list */ - if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) - goto out; - - /* create dataset creation property list */ - if((tcpl_id = H5Pcreate(H5P_DATATYPE_CREATE)) < 0) - goto out; - - /* enable attribute creation order tracking on dataset property list */ - if(H5Pset_attr_creation_order(dcpl_id, H5P_CRT_ORDER_TRACKED) < 0) - goto out; - - /* enable attribute creation order tracking on group property list */ - if(H5Pset_attr_creation_order(gcpl_id, H5P_CRT_ORDER_TRACKED) < 0) - goto out; - - /* enable attribute creation order tracking on datatype property list */ - if(H5Pset_attr_creation_order(tcpl_id, H5P_CRT_ORDER_TRACKED) < 0) - goto out; - - /* create a dataspace */ - if((sid = H5Screate(H5S_SCALAR)) < 0) - goto out; - - /*------------------------------------------------------------------------- - * create a dataset with creation order tracked for attributes and atributes in it - *------------------------------------------------------------------------- - */ - - /* create a dataset */ - if((did = H5Dcreate2(fid, "dt", H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) - goto out; - - /* add attributes */ - for(i = 0; i < 3; i++) - { - if((aid = H5Acreate2(did, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto out; - - /* close attribute */ - if(H5Aclose(aid) < 0) - goto out; - aid = -1; - } /* end for */ - - if(H5Dclose(did) < 0) - goto out; - did = -1; - - - /*------------------------------------------------------------------------- - * create a dataset without creation order tracked for attributes and atributes in it - *------------------------------------------------------------------------- - */ - - /* create a dataset */ - if((did = H5Dcreate2(fid, "d", H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto out; - - /* add attributes */ - for(i = 0; i < 3; i++) - { - if((aid = H5Acreate2(did, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto out; - - /* close attribute */ - if(H5Aclose(aid) < 0) - goto out; - aid = -1; - } /* end for */ - - if(H5Dclose(did) < 0) - goto out; - did = -1; - - - - /*------------------------------------------------------------------------- - * create a group with creation order tracked for attributes and atributes in it - *------------------------------------------------------------------------- - */ - - if((gid = H5Gcreate2(fid, "gt", H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) - goto out; - - /* add attributes */ - for(i = 0; i < 3; i++) - { - if((aid = H5Acreate2(gid, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto out; - - /* close attribute */ - if(H5Aclose(aid) < 0) - goto out; - aid = -1; - } /* end for */ - - if(H5Gclose(gid) < 0) - goto out; - gid = -1; - - /*------------------------------------------------------------------------- - * create a group without creation order tracked for attributes and atributes in it - *------------------------------------------------------------------------- - */ - - if((gid = H5Gcreate2(fid, "g", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto out; - - /* add attributes */ - for(i = 0; i < 3; i++) - { - if((aid = H5Acreate2(gid, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto out; - - /* close attribute */ - if(H5Aclose(aid) < 0) - goto out; - aid = -1; - } /* end for */ - - if(H5Gclose(gid) < 0) - goto out; - gid = -1; - - /*------------------------------------------------------------------------- - * create a named datatype with creation order tracked for attributes and atributes in it - *------------------------------------------------------------------------- - */ - - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) - goto out; - - if((H5Tcommit2(fid, "tt", tid, H5P_DEFAULT, tcpl_id, H5P_DEFAULT)) < 0) - goto out; - - /* add attributes */ - for(i = 0; i < 3; i++) - { - if((aid = H5Acreate2(tid, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto out; - - /* close attribute */ - if(H5Aclose(aid) < 0) - goto out; - aid = -1; - } /* end for */ - - if(H5Tclose(tid) < 0) - goto out; - tid = -1; - - /*------------------------------------------------------------------------- - * create a named datatype without creation order tracked for attributes and atributes in it - *------------------------------------------------------------------------- - */ - - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) - goto out; - - if((H5Tcommit2(fid, "t", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto out; - - /* add attributes */ - for(i = 0; i < 3; i++) - { - if((aid = H5Acreate2(tid, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto out; - - /* close attribute */ - if(H5Aclose(aid) < 0) - goto out; - aid = -1; - } /* end for */ - - if(H5Tclose(tid) < 0) - goto out; - tid = -1; - - /*------------------------------------------------------------------------- - * add some attributes to the root group - *------------------------------------------------------------------------- - */ - if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) - goto out; - - /* add attributes */ - for(i = 0; i < 3; i++) - { - if((aid = H5Acreate2(gid, attr_name[i], H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto out; - - /* close attribute */ - if(H5Aclose(aid) < 0) - goto out; - aid = -1; - } /* end for */ - - if(H5Gclose(gid) < 0) - goto out; - gid = -1; - - /*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ - if(H5Sclose(sid) < 0) - goto out; - sid = -1; - if(H5Pclose(dcpl_id) < 0) - goto out; - dcpl_id = -1; - if(H5Pclose(gcpl_id) < 0) - goto out; - gcpl_id = -1; - if(H5Pclose(tcpl_id) < 0) - goto out; - tcpl_id = -1; - if(H5Fclose(fid) < 0) - goto out; - fid = -1; - - - - return; - - out: - printf("Error.....\n"); - H5E_BEGIN_TRY { - H5Gclose(gid); - H5Dclose(did); - H5Sclose(sid); - H5Pclose(gcpl_id); - H5Pclose(dcpl_id); - H5Pclose(tcpl_id); - H5Fclose(fid); - - } H5E_END_TRY; - return; - -} - -/*------------------------------------------------------------------------- - * Function: gent_fpformat - * - * Purpose: Generate a file to be used in the floating point format test - * Contains: - * 1) a float dataset - * 2) a double dataset - * - *------------------------------------------------------------------------- - */ -static void -gent_fpformat(void) -{ - hid_t fid, sid, did; - hsize_t dims[1] = {6}; - double dbuf[6] = {-0.1234567f, 0.1234567f, 0, 0, 0, 0}; - float fbuf[6] = {-0.1234567f, 0.1234567f, 0, 0, 0, 0}; - - fid = H5Fcreate(FILE60, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - sid = H5Screate_simple(1, dims, NULL); - - /*------------------------------------------------------------------------- - * double - *------------------------------------------------------------------------- - */ - did = H5Dcreate2(fid, "double", H5T_NATIVE_DOUBLE, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Dwrite(did, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dbuf); - H5Dclose(did); - - - /*------------------------------------------------------------------------- - * float - *------------------------------------------------------------------------- - */ - did = H5Dcreate2(fid, "float", H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Dwrite(did, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, fbuf); - H5Dclose(did); - - - /* close */ - H5Sclose(sid); - H5Fclose(fid); -} - -/*------------------------------------------------------------------------- - * Function: gent_extlinks - * - * Purpose: Generate 3 files to be used in the external links test - * External links point from one HDF5 file to an object (Group, Dataset, - * or committed Datatype) in another file. Try to create cycles. - * - *------------------------------------------------------------------------- - */ -static void -gent_extlinks(void) -{ - hid_t source_fid, target_fid, far_fid, sid, did, gid, gid2, tid; - hsize_t dims[1] = {6}; - int buf[6] = {1, 2, 3, 4, 5, 6}; - - /* create two files, a source and a target */ - source_fid = H5Fcreate(FILE61, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - target_fid = H5Fcreate(FILE62, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - far_fid = H5Fcreate(FILE63, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - - /*------------------------------------------------------------------------- - * create Groups, a Dataset, a committed Datatype, external links, and a - * cycle in the target - *------------------------------------------------------------------------- - */ - - gid = H5Gcreate2(target_fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(H5Gcreate2(target_fid, "empty_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)); - sid = H5Screate_simple(1, dims, NULL); - did = H5Dcreate2(gid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); - H5Lcreate_external(FILE61, "/", gid, "elink_t1", H5P_DEFAULT, H5P_DEFAULT); - H5Lcreate_external(FILE61, "/ext_link4", gid, "elink_t2", H5P_DEFAULT, H5P_DEFAULT); - - gid2 = H5Gcreate2(gid, "subgroup", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Lcreate_hard(target_fid, "/group", gid2, "link_to_group", H5P_DEFAULT, H5P_DEFAULT); - - H5Dclose(did); - H5Sclose(sid); - H5Gclose(gid2); - H5Gclose(gid); - - - sid = H5Screate_simple(1, dims, NULL); - did = H5Dcreate2(target_fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); - H5Dclose(did); - H5Sclose(sid); - - tid = H5Tcopy(H5T_NATIVE_INT); - H5Tcommit2(target_fid, "type", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Tclose(tid); - - /*------------------------------------------------------------------------- - * create external links in the source file pointing to the target objects - *------------------------------------------------------------------------- - */ - - H5Lcreate_external(FILE62, "group", source_fid, "ext_link1", H5P_DEFAULT, H5P_DEFAULT); - H5Lcreate_external(FILE62, "dset", source_fid, "ext_link2", H5P_DEFAULT, H5P_DEFAULT); - H5Lcreate_external(FILE62, "type", source_fid, "ext_link3", H5P_DEFAULT, H5P_DEFAULT); - H5Lcreate_external(FILE62, "group/elink_t2", source_fid, "ext_link4", H5P_DEFAULT, H5P_DEFAULT); - H5Lcreate_external(FILE62, "empty_group", source_fid, "ext_link5", H5P_DEFAULT, H5P_DEFAULT); - /* external link to soft link which linked to a dataset */ - H5Lcreate_external(FILE4_1, "/soft_dset1", source_fid, "ext2soft_link1", H5P_DEFAULT, H5P_DEFAULT); - - /* external link to dangle soft link */ - H5Lcreate_external(FILE4_1, "/soft_dangle", source_fid, "ext2softdangle_link1", H5P_DEFAULT, H5P_DEFAULT); - - /*------------------------------------------------------------------------- - * create external link in the "far" file pointing to the source file - *------------------------------------------------------------------------- - */ - H5Lcreate_external(FILE61, "/", far_fid, "src_file", H5P_DEFAULT, H5P_DEFAULT); - - /* close */ - H5Fclose(source_fid); - H5Fclose(target_fid); - H5Fclose(far_fid); -} - -/*------------------------------------------------------------------------- - * Function: gent_fs_strategy_threshold - * - * Purpose: Generate a file with non-default file space strategy and - * non-default free-space section threshold. - *------------------------------------------------------------------------- - */ -static void -gent_fs_strategy_threshold(void) -{ - hid_t fid; /* File id */ - hid_t fcpl; /* File creation property */ - - /* Create file-creation template */ - fcpl = H5Pcreate(H5P_FILE_CREATE); - - /* Set file space information */ - H5Pset_file_space(fcpl, STRATEGY, (hsize_t)THRESHOLD10); - - /* Create the file with the specified strategy and threshold */ - fid = H5Fcreate(FILE65, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT); - - /* close */ - H5Fclose(fid); - H5Pclose(fcpl); -} - -/* - * Create a file with new format: - * Create one dataset with (set_chunk, fixed dims, null max. dims) - * so that Fixed Array indexing will be used. - * Create one dataset with (set_chunk, fixed dims, null max. dims, filter) - * so that Fixed Array indexing will be used. - * Create one dataset with (set_chunk, fixed dims, fixed max. dims) - * so that Fixed Array indexing will be used. - * - * Modifications: - * Fixed Array indexing will be used for chunked dataset - * with fixed max. dims setting. - * - */ -static void -gent_dataset_idx(void) -{ - hid_t fid, space, dcpl, fapl; - hsize_t dims[2]; - hsize_t maxdims[2]; - int buf[20][10]; - int i, j, ret; - - /* Get a copy of the file aaccess property */ - fapl = H5Pcreate(H5P_FILE_ACCESS); - - /* Set the "use the latest version of the format" bounds for creating objects in the file */ - ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); - assert(ret >= 0); - - fid = H5Fcreate(FILE68a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - dcpl = H5Pcreate(H5P_DATASET_CREATE); - - dims[0] = F68a_CHUNK; - dims[1] = F68a_CHUNK; - - /* set chunk */ - ret = H5Pset_chunk(dcpl, RANK, dims); - assert(ret >= 0); - - /* dataset with fixed dimensions */ - dims[0] = F68a_DIM20; - dims[1] = F68a_DIM10; - space = H5Screate_simple(RANK, dims, NULL); - - for(i = 0; i < F68a_DIM20; i++) - for(j = 0; j < F68a_DIM10; j++) - buf[i][j] = j; - - ret = make_dset(fid, F68a_DSET_FIXED, space, H5T_NATIVE_INT, dcpl, buf); - assert(ret >= 0); - H5Sclose(space); - - /* dataset with non-fixed dimensions */ - maxdims[0] = F68a_DIM200; - maxdims[1] = F68a_DIM100; - space = H5Screate_simple(RANK, dims, maxdims); - - ret = make_dset(fid, F68a_DSET_BTREE, space, H5T_NATIVE_INT, dcpl, buf); - assert(ret >= 0); - H5Sclose(space); - -#if defined (H5_HAVE_FILTER_DEFLATE) - - /* dataset with fixed dimensions and filters */ - /* remove the filters from the dcpl */ - ret = H5Premove_filter(dcpl, H5Z_FILTER_ALL); - assert(ret >= 0); - - /* set deflate data */ - ret = H5Pset_deflate(dcpl, 9); - assert(ret >= 0); - - space = H5Screate_simple(RANK, dims, NULL); - ret = make_dset(fid, F68a_DSET_FIXED_FILTER, space, H5T_NATIVE_INT, dcpl, buf); - assert(ret >= 0); - - H5Sclose(space); -#endif - - H5Pclose(dcpl); - H5Fclose(fid); -} - -/*------------------------------------------------------------------------- - * Function: gent_packedbits - * - * Purpose: Generate a file to be used in the h5dump packed bits tests. - * Four datasets of 1, 2, 4 and 8 bytes of unsigned int types are created. - * Four more datasets of 1, 2, 4 and 8 bytes of signed int types are created. - * Fill them with raw data such that no bit will be all zero in a dataset. - * A dummy dataset of double type is created for failure test. - * Created: Albert Cheng, 2010/5/10. - * Modified: Allen Byrne, 2011/1/5 Use file to test Signed/Unsigned datatypes - *------------------------------------------------------------------------- - */ -static void -gent_packedbits(void) -{ - hid_t fid, dataset, space; - 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]; - unsigned int i, j; - - fid = H5Fcreate(FILE66, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* Dataset of 8 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM8; - space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(fid, F66_DATASETU08, H5T_STD_U8LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - valu8bits = (uint8_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu8[i][0] = valu8bits; - for(j = 1; j < dims[1]; j++) - dsetu8[i][j] = (uint8_t)(dsetu8[i][j - 1] << 1); - valu8bits = (uint8_t)(valu8bits << 1); - } - - H5Dwrite(dataset, H5T_NATIVE_UINT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu8); - H5Sclose(space); - H5Dclose(dataset); - - /* Dataset of 16 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM16; - space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(fid, F66_DATASETU16, H5T_STD_U16LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - valu16bits = (uint16_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu16[i][0] = valu16bits; - for(j = 1; j < dims[1]; j++) - dsetu16[i][j] = (uint16_t)(dsetu16[i][j-1] << 1); - valu16bits = (uint16_t)(valu16bits << 1); - } - - H5Dwrite(dataset, H5T_NATIVE_UINT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu16); - H5Sclose(space); - H5Dclose(dataset); - - /* Dataset of 32 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM32; - space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(fid, F66_DATASETU32, H5T_STD_U32LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - valu32bits = (uint32_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu32[i][0] = valu32bits; - for(j = 1; j < dims[1]; j++) - dsetu32[i][j] = dsetu32[i][j-1] << 1; - valu32bits <<= 1; - } - - H5Dwrite(dataset, H5T_NATIVE_UINT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu32); - H5Sclose(space); - H5Dclose(dataset); - - /* Dataset of 64 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM64; - space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(fid, F66_DATASETU64, H5T_STD_U64LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - valu64bits = (uint64_t) ~0Lu; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu64[i][0] = valu64bits; - for(j = 1; j < dims[1]; j++) - dsetu64[i][j] = dsetu64[i][j-1] << 1; - valu64bits <<= 1; - } - - H5Dwrite(dataset, H5T_NATIVE_UINT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu64); - H5Sclose(space); - H5Dclose(dataset); - - /* Dataset of 8 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM8; - space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(fid, F66_DATASETS08, H5T_STD_I8LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - val8bits = (int8_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset8[i][0] = val8bits; - for(j = 1; j < dims[1]; j++) - dset8[i][j] = (int8_t)(dset8[i][j-1] << 1); - val8bits = (int8_t)(val8bits << 1); - } - - H5Dwrite(dataset, H5T_NATIVE_INT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset8); - H5Sclose(space); - H5Dclose(dataset); - - /* Dataset of 16 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM16; - space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(fid, F66_DATASETS16, H5T_STD_I16LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - val16bits = (int16_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset16[i][0] = val16bits; - for(j = 1; j < dims[1]; j++) - dset16[i][j] = (int16_t)(dset16[i][j-1] << 1); - val16bits = (int16_t)(val16bits << 1); - } - - H5Dwrite(dataset, H5T_NATIVE_INT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset16); - H5Sclose(space); - H5Dclose(dataset); - - /* Dataset of 32 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM32; - space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(fid, F66_DATASETS32, H5T_STD_I32LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - val32bits = (int32_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset32[i][0] = val32bits; - for(j = 1; j < dims[1]; j++) - dset32[i][j] = dset32[i][j-1] << 1; - val32bits <<= 1; - } - - H5Dwrite(dataset, H5T_NATIVE_INT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset32); - H5Sclose(space); - H5Dclose(dataset); - - /* Dataset of 64 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM64; - space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(fid, F66_DATASETS64, H5T_STD_I64LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - val64bits = (int64_t) ~0L; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset64[i][0] = val64bits; - for(j = 1; j < dims[1]; j++) - dset64[i][j] = dset64[i][j-1] << 1; - val64bits <<= 1; - } - - H5Dwrite(dataset, H5T_NATIVE_INT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset64); - H5Sclose(space); - H5Dclose(dataset); - - /* Double Dummy set for failure tests */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM8; - space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(fid, F66_DUMMYDBL, H5T_IEEE_F64BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - for(i = 0; i < dims[0]; i++) - 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); - - H5Sclose(space); - H5Dclose(dataset); - H5Fclose(fid); -} - -/*------------------------------------------------------------------------- - * Function: gent_attr_packedbits - * - * Purpose: Generate a file to be used in the h5dump packed bits tests. - * Four attributes of 1, 2, 4 and 8 bytes of unsigned int types are created. - * Four more datasets of 1, 2, 4 and 8 bytes of signed int types are created. - * Fill them with raw data such that no bit will be all zero in a dataset. - * A dummy dataset of double type is created for failure test. - * Use file to test Signed/Unsigned datatypes and keep in sync with gent_packedbits() - *------------------------------------------------------------------------- - */ -static void -gent_attr_intsize(void) -{ - hid_t fid, attr, space, root; - 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]; - unsigned int i, j; - - fid = H5Fcreate(FILE69, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - root = H5Gopen2(fid, "/", H5P_DEFAULT); - - /* Attribute of 8 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM8; - space = H5Screate_simple(2, dims, NULL); - attr = H5Acreate2(root, F66_DATASETU08, H5T_STD_U8LE, space, H5P_DEFAULT, H5P_DEFAULT); - - valu8bits = (uint8_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu8[i][0] = valu8bits; - for(j = 1; j < dims[1]; j++) { - dsetu8[i][j] = (uint8_t)(dsetu8[i][j-1] << 1); - } - valu8bits = (uint8_t)(valu8bits << 1); - } - - H5Awrite(attr, H5T_NATIVE_UINT8, dsetu8); - H5Sclose(space); - H5Aclose(attr); - - /* Attribute of 16 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM16; - space = H5Screate_simple(2, dims, NULL); - attr = H5Acreate2(root, F66_DATASETU16, H5T_STD_U16LE, space, H5P_DEFAULT, H5P_DEFAULT); - - valu16bits = (uint16_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu16[i][0] = valu16bits; - for(j = 1; j < dims[1]; j++) { - dsetu16[i][j] = (uint16_t)(dsetu16[i][j-1] << 1); - } - valu16bits = (uint16_t)(valu16bits << 1); - } - - H5Awrite(attr, H5T_NATIVE_UINT16, dsetu16); - H5Sclose(space); - H5Aclose(attr); - - /* Attribute of 32 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM32; - space = H5Screate_simple(2, dims, NULL); - attr = H5Acreate2(root, F66_DATASETU32, H5T_STD_U32LE, space, H5P_DEFAULT, H5P_DEFAULT); - - valu32bits = (uint32_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu32[i][0] = valu32bits; - for(j = 1; j < dims[1]; j++) { - dsetu32[i][j] = dsetu32[i][j-1] << 1; - } - valu32bits <<= 1; - } - - H5Awrite(attr, H5T_NATIVE_UINT32, dsetu32); - H5Sclose(space); - H5Aclose(attr); - - /* Attribute of 64 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM64; - space = H5Screate_simple(2, dims, NULL); - attr = H5Acreate2(root, F66_DATASETU64, H5T_STD_U64LE, space, H5P_DEFAULT, H5P_DEFAULT); - - valu64bits = (uint64_t) ~0Lu; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu64[i][0] = valu64bits; - for(j = 1; j < dims[1]; j++) { - dsetu64[i][j] = dsetu64[i][j-1] << 1; - } - valu64bits <<= 1; - } - - H5Awrite(attr, H5T_NATIVE_UINT64, dsetu64); - H5Sclose(space); - H5Aclose(attr); - - /* Attribute of 8 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM8; - space = H5Screate_simple(2, dims, NULL); - attr = H5Acreate2(root, F66_DATASETS08, H5T_STD_I8LE, space, H5P_DEFAULT, H5P_DEFAULT); - - val8bits = (int8_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset8[i][0] = val8bits; - for(j = 1; j < dims[1]; j++) { - dset8[i][j] = (int8_t)(dset8[i][j-1] << 1); - } - val8bits = (int8_t)(val8bits << 1); - } - - H5Awrite(attr, H5T_NATIVE_INT8, dset8); - H5Sclose(space); - H5Aclose(attr); - - /* Attribute of 16 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM16; - space = H5Screate_simple(2, dims, NULL); - attr = H5Acreate2(root, F66_DATASETS16, H5T_STD_I16LE, space, H5P_DEFAULT, H5P_DEFAULT); - - val16bits = (int16_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset16[i][0] = val16bits; - for(j = 1; j < dims[1]; j++) { - dset16[i][j] = (int16_t)(dset16[i][j-1] << 1); - } - val16bits = (int16_t)(val16bits << 1); - } - - H5Awrite(attr, H5T_NATIVE_INT16, dset16); - H5Sclose(space); - H5Aclose(attr); - - /* Attribute of 32 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM32; - space = H5Screate_simple(2, dims, NULL); - attr = H5Acreate2(root, F66_DATASETS32, H5T_STD_I32LE, space, H5P_DEFAULT, H5P_DEFAULT); - - val32bits = (int32_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset32[i][0] = val32bits; - for(j = 1; j < dims[1]; j++) { - dset32[i][j] = dset32[i][j-1] << 1; - } - val32bits <<= 1; - } - - H5Awrite(attr, H5T_NATIVE_INT32, dset32); - H5Sclose(space); - H5Aclose(attr); - - /* Attribute of 64 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM64; - space = H5Screate_simple(2, dims, NULL); - attr = H5Acreate2(root, F66_DATASETS64, H5T_STD_I64LE, space, H5P_DEFAULT, H5P_DEFAULT); - - val64bits = (int64_t) ~0L; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset64[i][0] = val64bits; - for(j = 1; j < dims[1]; j++) { - dset64[i][j] = dset64[i][j-1] << 1; - } - val64bits <<= 1; - } - - H5Awrite(attr, H5T_NATIVE_INT64, dset64); - H5Sclose(space); - H5Aclose(attr); - - /* Double Dummy set for failure tests */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM8; - space = H5Screate_simple(2, dims, NULL); - attr = H5Acreate2(root, F66_DUMMYDBL, H5T_IEEE_F64BE, space, H5P_DEFAULT, H5P_DEFAULT); - - for(i = 0; i < dims[0]; i++) - for(j = 0; j < dims[1]; j++) - dsetdbl[i][j] = 0.0001F * (float)j + (float)i; - - H5Awrite(attr, H5T_NATIVE_DOUBLE, dsetdbl); - - H5Sclose(space); - H5Aclose(attr); - - H5Gclose(root); - H5Fclose(fid); -} - -/*------------------------------------------------------------------------- - * Function: gent_charsets - * - * Purpose: Generate a file to be used in the character set test - * Contains: - * 1) a ascii datatype - * 2) a utf8 datatype - * - *------------------------------------------------------------------------- - */ -static void -gent_charsets(void) -{ - hid_t fid, did, sid; - herr_t status; - hsize_t dim[] = {1}; /* Dataspace dimensions */ - typedef struct CharSetInfo { - const char *ascii_p_; - const char *utf8_p_; - } CharSetInfo; - - hid_t charset_dtid = H5Tcreate( H5T_COMPOUND, sizeof( CharSetInfo ) ); - hid_t ascii_dtid = H5Tcreate( H5T_STRING, H5T_VARIABLE ); - hid_t utf8_dtid = H5Tcreate( H5T_STRING, H5T_VARIABLE ); - const char * writeData[] = { "ascii", "utf8", }; - - sid = H5Screate_simple( 1, dim, NULL ); - fid = H5Fcreate( FILE68, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT ); - status = H5Tset_cset( ascii_dtid, H5T_CSET_ASCII ); - HDassert(status >= 0); - H5Tinsert( charset_dtid, "ascii", HOFFSET(CharSetInfo, ascii_p_ ), ascii_dtid ); - - status = H5Tset_cset( utf8_dtid, H5T_CSET_UTF8 ); - HDassert(status >= 0); - H5Tinsert( charset_dtid, "utf8", HOFFSET( CharSetInfo, utf8_p_ ), utf8_dtid ); - - did = H5Dcreate2( fid, "CharSets", charset_dtid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT ); - - status = H5Dwrite( did, charset_dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, writeData ); - HDassert(status >= 0); - - H5Tclose( charset_dtid ); - H5Tclose( ascii_dtid ); - H5Tclose( utf8_dtid ); - H5Sclose( sid ); - H5Dclose( did ); - H5Fclose( fid ); -} - -static void gent_compound_intsizes(void) { - hid_t fid, dataset, space; - hsize_t dims[2]; - hsize_t array_dim8[]={F70_XDIM,F70_YDIM8}; /* Array dimensions */ - hsize_t array_dim16[]={F70_XDIM,F70_YDIM16}; /* Array dimensions */ - hsize_t array_dim32[]={F70_XDIM,F70_YDIM32}; /* Array dimensions */ - hsize_t array_dim64[]={F70_XDIM,F70_YDIM64}; /* Array dimensions */ - hid_t arrayu8_tid; /* Array datatype handle */ - hid_t arrayu16_tid; /* Array datatype handle */ - hid_t arrayu32_tid; /* Array datatype handle */ - hid_t arrayu64_tid; /* Array datatype handle */ - hid_t array8_tid; /* Array datatype handle */ - hid_t array16_tid; /* Array datatype handle */ - hid_t array32_tid; /* Array datatype handle */ - hid_t array64_tid; /* Array datatype handle */ - hid_t arraydbl_tid; /* Array datatype handle */ - uint8_t valu8bits; - uint16_t valu16bits; - uint32_t valu32bits; - uint64_t valu64bits; - int8_t val8bits; - int16_t val16bits; - int32_t val32bits; - int64_t val64bits; - /* Structure and array for compound types */ - typedef struct Array1Struct { - uint8_t dsetu8[F70_XDIM][F70_YDIM8]; - uint16_t dsetu16[F70_XDIM][F70_YDIM16]; - uint32_t dsetu32[F70_XDIM][F70_YDIM32]; - uint64_t dsetu64[F70_XDIM][F70_YDIM64]; - int8_t dset8[F70_XDIM][F70_YDIM8]; - int16_t dset16[F70_XDIM][F70_YDIM16]; - int32_t dset32[F70_XDIM][F70_YDIM32]; - int64_t dset64[F70_XDIM][F70_YDIM64]; - double dsetdbl[F70_XDIM][F70_YDIM8]; - } Array1Struct; - Array1Struct *Array1; - - hid_t Array1Structid; /* File datatype identifier */ - herr_t status; /* Error checking variable */ - hsize_t dim[] = { F70_LENGTH }; /* Dataspace dimensions */ - - int m, n, o; /* Array init loop vars */ - - /* Allocate buffer */ - Array1 = (Array1Struct *)HDmalloc(sizeof(Array1Struct) * F70_LENGTH); - HDassert(Array1); - - /* Initialize the data in the arrays/datastructure */ - for (m = 0; m < F70_LENGTH; m++) { - - /* Array of 8 bits unsigned int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM8; - - valu8bits = (uint8_t) ~0u; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ - Array1[m].dsetu8[n][0] = valu8bits; - for(o = 1; o < (int)dims[1]; o++) - Array1[m].dsetu8[n][o] = (uint8_t)(Array1[m].dsetu8[n][o-1] << 1); - valu8bits = (uint8_t)(valu8bits << 1); - } - - /* Array of 16 bits unsigned int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM16; - - valu16bits = (uint16_t) ~0u; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ - Array1[m].dsetu16[n][0] = valu16bits; - for(o = 1; o < (int)dims[1]; o++) - Array1[m].dsetu16[n][o] = (uint16_t)(Array1[m].dsetu16[n][o-1] << 1); - valu16bits = (uint16_t)(valu16bits << 1); - } - - /* Array of 32 bits unsigned int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM32; - - valu32bits = (uint32_t) ~0u; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ - Array1[m].dsetu32[n][0] = valu32bits; - for(o = 1; o < (int)dims[1]; o++) - Array1[m].dsetu32[n][o] = Array1[m].dsetu32[n][o-1] << 1; - valu32bits <<= 1; - } - - /* Array of 64 bits unsigned int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM64; - - valu64bits = (uint64_t) ~0Lu; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ - Array1[m].dsetu64[n][0] = valu64bits; - for(o = 1; o < (int)dims[1]; o++) - Array1[m].dsetu64[n][o] = Array1[m].dsetu64[n][o-1] << 1; - valu64bits <<= 1; - } - - /* Array of 8 bits signed int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM8; - - val8bits = (int8_t) ~0; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ - Array1[m].dset8[n][0] = val8bits; - for(o = 1; o < (int)dims[1]; o++) - Array1[m].dset8[n][o] = (int8_t)(Array1[m].dset8[n][o-1] << 1); - val8bits = (int8_t)(val8bits << 1); - } - - /* Array of 16 bits signed int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM16; - - val16bits = (int16_t) ~0; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ - Array1[m].dset16[n][0] = val16bits; - for(o = 1; o < (int)dims[1]; o++) - Array1[m].dset16[n][o] = (int16_t)(Array1[m].dset16[n][o-1] << 1); - val16bits = (int16_t)(val16bits << 1); - } - - /* Array of 32 bits signed int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM32; - - val32bits = (int32_t) ~0; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ - Array1[m].dset32[n][0] = val32bits; - for(o = 1; o < (int)dims[1]; o++) - Array1[m].dset32[n][o] = Array1[m].dset32[n][o-1] << 1; - val32bits <<= 1; - } - - /* Array of 64 bits signed int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM64; - - val64bits = (int64_t) ~0L; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ - Array1[m].dset64[n][0] = val64bits; - for(o = 1; o < (int)dims[1]; o++) - Array1[m].dset64[n][o] = Array1[m].dset64[n][o-1] << 1; - val64bits <<= 1; - } - - /* Double Dummy set for failure tests */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM8; - - for(n = 0; n < (int)dims[0]; n++) - for(o = 0; o < (int)dims[1]; o++) - Array1[m].dsetdbl[n][o] = 0.0001F * (float)o + (float)n; - } - - /* Create the array data type for the 8 bits signed int array */ - array8_tid = H5Tarray_create2(H5T_NATIVE_SCHAR, F70_ARRAY_RANK, array_dim8); - HDassert(array8_tid >= 0); - - /* Create the array data type for the 16 bits signed int array */ - array16_tid = H5Tarray_create2(H5T_NATIVE_SHORT, F70_ARRAY_RANK, array_dim16); - HDassert(array16_tid >= 0); - - /* Create the array data type for the 32 bits signed int array */ - array32_tid = H5Tarray_create2(H5T_NATIVE_INT, F70_ARRAY_RANK, array_dim32); - HDassert(array32_tid >= 0); - - /* Create the array data type for the 64 bits signed int array */ - array64_tid = H5Tarray_create2(H5T_NATIVE_LONG, F70_ARRAY_RANK, array_dim64); - HDassert(array64_tid >= 0); - - /* Create the array data type for the 8 bits signed int array */ - arrayu8_tid = H5Tarray_create2(H5T_NATIVE_UCHAR, F70_ARRAY_RANK, array_dim8); - HDassert(arrayu8_tid >= 0); - - /* Create the array data type for the 16 bits signed int array */ - arrayu16_tid = H5Tarray_create2(H5T_NATIVE_USHORT, F70_ARRAY_RANK, array_dim16); - HDassert(arrayu16_tid >= 0); - - /* Create the array data type for the 32 bits signed int array */ - arrayu32_tid = H5Tarray_create2(H5T_NATIVE_UINT, F70_ARRAY_RANK, array_dim32); - HDassert(arrayu32_tid >= 0); - - /* Create the array data type for the 64 bits signed int array */ - arrayu64_tid = H5Tarray_create2(H5T_NATIVE_ULONG, F70_ARRAY_RANK, array_dim64); - HDassert(arrayu64_tid >= 0); - - /* Create the array data type for the 32 bits double array */ - arraydbl_tid = H5Tarray_create2(H5T_NATIVE_DOUBLE, F70_ARRAY_RANK, array_dim8); - HDassert(arraydbl_tid >= 0); - - /* Create the dataspace */ - space = H5Screate_simple(F70_RANK, dim, NULL); - HDassert(space >= 0); - - /* Create the file */ - fid = H5Fcreate(FILE70, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDassert(fid >= 0); - - /* Create the memory data type */ - Array1Structid = H5Tcreate(H5T_COMPOUND, sizeof(Array1Struct)); - HDassert(Array1Structid >= 0); - - /* Insert the arrays and variables into the structure */ - status = H5Tinsert(Array1Structid, F70_DATASETU08, HOFFSET(Array1Struct, dsetu8), arrayu8_tid); - HDassert(status >= 0); - - status = H5Tinsert(Array1Structid, F70_DATASETU16, HOFFSET(Array1Struct, dsetu16), arrayu16_tid); - HDassert(status >= 0); - - status = H5Tinsert(Array1Structid, F70_DATASETU32, HOFFSET(Array1Struct, dsetu32), arrayu32_tid); - HDassert(status >= 0); - - status = H5Tinsert(Array1Structid, F70_DATASETU64, HOFFSET(Array1Struct, dsetu64), arrayu64_tid); - HDassert(status >= 0); - - status = H5Tinsert(Array1Structid, F70_DATASETS08, HOFFSET(Array1Struct, dset8), array8_tid); - HDassert(status >= 0); - - status = H5Tinsert(Array1Structid, F70_DATASETS16, HOFFSET(Array1Struct, dset16), array16_tid); - HDassert(status >= 0); - - status = H5Tinsert(Array1Structid, F70_DATASETS32, HOFFSET(Array1Struct, dset32), array32_tid); - HDassert(status >= 0); - - status = H5Tinsert(Array1Structid, F70_DATASETS64, HOFFSET(Array1Struct, dset64), array64_tid); - HDassert(status >= 0); - - status = H5Tinsert(Array1Structid, F70_DUMMYDBL, HOFFSET(Array1Struct, dsetdbl), arraydbl_tid); - HDassert(status >= 0); - - /* Create the dataset */ - dataset = H5Dcreate2(fid, F70_DATASETNAME, Array1Structid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - /* Write data to the dataset */ - status = H5Dwrite(dataset, Array1Structid, H5S_ALL, H5S_ALL, H5P_DEFAULT, Array1); - HDassert(status >= 0); - - /* Release resources */ - status = H5Tclose(Array1Structid); - HDassert(status >= 0); - - status = H5Tclose(arrayu8_tid); - HDassert(status >= 0); - - status = H5Tclose(arrayu16_tid); - HDassert(status >= 0); - - status = H5Tclose(arrayu32_tid); - HDassert(status >= 0); - - status = H5Tclose(arrayu64_tid); - HDassert(status >= 0); - - status = H5Tclose(array8_tid); - HDassert(status >= 0); - - status = H5Tclose(array16_tid); - HDassert(status >= 0); - - status = H5Tclose(array32_tid); - HDassert(status >= 0); - - status = H5Tclose(array64_tid); - HDassert(status >= 0); - - status = H5Tclose(arraydbl_tid); - HDassert(status >= 0); - - status = H5Sclose(space); - HDassert(status >= 0); - - status = H5Dclose(dataset); - HDassert(status >= 0); - - status = H5Fclose(fid); - HDassert(status >= 0); - - HDfree(Array1); -} - -static void gent_compound_attr_intsizes(void) { - hid_t fid, attr, space, root; - hsize_t dims[2]; - hsize_t array_dim8[]={F70_XDIM,F70_YDIM8}; /* Array dimensions */ - hsize_t array_dim16[]={F70_XDIM,F70_YDIM16}; /* Array dimensions */ - hsize_t array_dim32[]={F70_XDIM,F70_YDIM32}; /* Array dimensions */ - hsize_t array_dim64[]={F70_XDIM,F70_YDIM64}; /* Array dimensions */ - hid_t arrayu8_tid; /* Array datatype handle */ - hid_t arrayu16_tid; /* Array datatype handle */ - hid_t arrayu32_tid; /* Array datatype handle */ - hid_t arrayu64_tid; /* Array datatype handle */ - hid_t array8_tid; /* Array datatype handle */ - hid_t array16_tid; /* Array datatype handle */ - hid_t array32_tid; /* Array datatype handle */ - hid_t array64_tid; /* Array datatype handle */ - hid_t arraydbl_tid; /* Array datatype handle */ - uint8_t valu8bits; - uint16_t valu16bits; - uint32_t valu32bits; - uint64_t valu64bits; - int8_t val8bits; - int16_t val16bits; - int32_t val32bits; - int64_t val64bits; - /* Structure and array for compound types */ - typedef struct Array1Struct { - uint8_t dsetu8[F70_XDIM][F70_YDIM8]; - uint16_t dsetu16[F70_XDIM][F70_YDIM16]; - uint32_t dsetu32[F70_XDIM][F70_YDIM32]; - uint64_t dsetu64[F70_XDIM][F70_YDIM64]; - int8_t dset8[F70_XDIM][F70_YDIM8]; - int16_t dset16[F70_XDIM][F70_YDIM16]; - int32_t dset32[F70_XDIM][F70_YDIM32]; - int64_t dset64[F70_XDIM][F70_YDIM64]; - double dsetdbl[F70_XDIM][F70_YDIM8]; - } Array1Struct; - Array1Struct Array1[F70_LENGTH]; - - hid_t Array1Structid; /* File datatype identifier */ - herr_t status; /* Error checking variable */ - hsize_t dim[] = { F70_LENGTH }; /* Dataspace dimensions */ - - int m, n, o; /* Array init loop vars */ - - /* Initialize the data in the arrays/datastructure */ - for (m = 0; m < F70_LENGTH; m++) { - - /* Array of 8 bits unsigned int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM8; - - valu8bits = (uint8_t) ~0u; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ - Array1[m].dsetu8[n][0] = valu8bits; - for(o = 1; o < (int)dims[1]; o++) { - Array1[m].dsetu8[n][o] = (uint8_t)(Array1[m].dsetu8[n][o-1] << 1); - } - valu8bits = (uint8_t)(valu8bits << 1); - } - - /* Array of 16 bits unsigned int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM16; - - valu16bits = (uint16_t) ~0u; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ - Array1[m].dsetu16[n][0] = valu16bits; - for(o = 1; o < (int)dims[1]; o++) { - Array1[m].dsetu16[n][o] = (uint16_t)(Array1[m].dsetu16[n][o-1] << 1); - } - valu16bits = (uint16_t)(valu16bits << 1); - } - - /* Array of 32 bits unsigned int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM32; - - valu32bits = (uint32_t) ~0u; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ - Array1[m].dsetu32[n][0] = valu32bits; - for(o = 1; o < (int)dims[1]; o++) { - Array1[m].dsetu32[n][o] = Array1[m].dsetu32[n][o-1] << 1; - } - valu32bits <<= 1; - } - - /* Array of 64 bits unsigned int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM64; - - valu64bits = (uint64_t) ~0Lu; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ - Array1[m].dsetu64[n][0] = valu64bits; - for(o = 1; o < (int)dims[1]; o++) { - Array1[m].dsetu64[n][o] = Array1[m].dsetu64[n][o-1] << 1; - } - valu64bits <<= 1; - } - - /* Array of 8 bits signed int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM8; - - val8bits = (int8_t) ~0; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ - Array1[m].dset8[n][0] = val8bits; - for(o = 1; o < (int)dims[1]; o++) { - Array1[m].dset8[n][o] = (int8_t)(Array1[m].dset8[n][o-1] << 1); - } - val8bits = (int8_t)(val8bits << 1); - } - - /* Array of 16 bits signed int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM16; - - val16bits = (int16_t) ~0; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ - Array1[m].dset16[n][0] = val16bits; - for(o = 1; o < (int)dims[1]; o++) { - Array1[m].dset16[n][o] = (int16_t)(Array1[m].dset16[n][o-1] << 1); - } - val16bits = (int16_t)(val16bits << 1); - } - - /* Array of 32 bits signed int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM32; - - val32bits = (int32_t) ~0; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ - Array1[m].dset32[n][0] = val32bits; - for(o = 1; o < (int)dims[1]; o++) { - Array1[m].dset32[n][o] = Array1[m].dset32[n][o-1] << 1; - } - val32bits <<= 1; - } - - /* Array of 64 bits signed int */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM64; - - val64bits = (int64_t) ~0L; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ - Array1[m].dset64[n][0] = val64bits; - for(o = 1; o < (int)dims[1]; o++) { - Array1[m].dset64[n][o] = Array1[m].dset64[n][o-1] << 1; - } - val64bits <<= 1; - } - - /* Double Dummy set for failure tests */ - dims[0] = F70_XDIM; dims[1] = F70_YDIM8; - - for(n = 0; n < (int)dims[0]; n++) - for(o = 0; o < (int)dims[1]; o++) - Array1[m].dsetdbl[n][o] = 0.0001F * (float)o + (float)n; - } - - /* Create the array data type for the 8 bits signed int array */ - array8_tid = H5Tarray_create2(H5T_NATIVE_SCHAR, F70_ARRAY_RANK, array_dim8); - HDassert(array8_tid >= 0); - - /* Create the array data type for the 16 bits signed int array */ - array16_tid = H5Tarray_create2(H5T_NATIVE_SHORT, F70_ARRAY_RANK, array_dim16); - HDassert(array16_tid >= 0); - - /* Create the array data type for the 32 bits signed int array */ - array32_tid = H5Tarray_create2(H5T_NATIVE_INT, F70_ARRAY_RANK, array_dim32); - HDassert(array32_tid >= 0); - - /* Create the array data type for the 64 bits signed int array */ - array64_tid = H5Tarray_create2(H5T_NATIVE_LONG, F70_ARRAY_RANK, array_dim64); - HDassert(array64_tid >= 0); - - /* Create the array data type for the 8 bits signed int array */ - arrayu8_tid = H5Tarray_create2(H5T_NATIVE_UCHAR, F70_ARRAY_RANK, array_dim8); - HDassert(arrayu8_tid >= 0); - - /* Create the array data type for the 16 bits signed int array */ - arrayu16_tid = H5Tarray_create2(H5T_NATIVE_USHORT, F70_ARRAY_RANK, array_dim16); - HDassert(arrayu16_tid >= 0); - - /* Create the array data type for the 32 bits signed int array */ - arrayu32_tid = H5Tarray_create2(H5T_NATIVE_UINT, F70_ARRAY_RANK, array_dim32); - HDassert(arrayu32_tid >= 0); - - /* Create the array data type for the 64 bits signed int array */ - arrayu64_tid = H5Tarray_create2(H5T_NATIVE_ULONG, F70_ARRAY_RANK, array_dim64); - HDassert(arrayu64_tid >= 0); - - /* Create the array data type for the 32 bits double array */ - arraydbl_tid = H5Tarray_create2(H5T_NATIVE_DOUBLE, F70_ARRAY_RANK, array_dim8); - HDassert(arraydbl_tid >= 0); - - /* Create the dataspace */ - space = H5Screate_simple(F70_RANK, dim, NULL); - HDassert(space >= 0); - - /* Create the file */ - fid = H5Fcreate(FILE71, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDassert(fid >= 0); - - /* Create the memory data type */ - Array1Structid = H5Tcreate(H5T_COMPOUND, sizeof(Array1Struct)); - HDassert(Array1Structid >= 0); - - /* Insert the arrays and variables into the structure */ - status = H5Tinsert(Array1Structid, F70_DATASETU08, HOFFSET(Array1Struct, dsetu8), arrayu8_tid); - HDassert(status >= 0); - - status = H5Tinsert(Array1Structid, F70_DATASETU16, HOFFSET(Array1Struct, dsetu16), arrayu16_tid); - HDassert(status >= 0); - - status = H5Tinsert(Array1Structid, F70_DATASETU32, HOFFSET(Array1Struct, dsetu32), arrayu32_tid); - HDassert(status >= 0); - - status = H5Tinsert(Array1Structid, F70_DATASETU64, HOFFSET(Array1Struct, dsetu64), arrayu64_tid); - HDassert(status >= 0); - - status = H5Tinsert(Array1Structid, F70_DATASETS08, HOFFSET(Array1Struct, dset8), array8_tid); - HDassert(status >= 0); - - status = H5Tinsert(Array1Structid, F70_DATASETS16, HOFFSET(Array1Struct, dset16), array16_tid); - HDassert(status >= 0); - - status = H5Tinsert(Array1Structid, F70_DATASETS32, HOFFSET(Array1Struct, dset32), array32_tid); - HDassert(status >= 0); - - status = H5Tinsert(Array1Structid, F70_DATASETS64, HOFFSET(Array1Struct, dset64), array64_tid); - HDassert(status >= 0); - - status = H5Tinsert(Array1Structid, F70_DUMMYDBL, HOFFSET(Array1Struct, dsetdbl), arraydbl_tid); - HDassert(status >= 0); - - root = H5Gopen2(fid, "/", H5P_DEFAULT); - - /* Create the Attribute */ - attr = H5Acreate2(root, F71_DATASETNAME, Array1Structid, space, H5P_DEFAULT, H5P_DEFAULT); - - /* Write data to the attribute */ - status = H5Awrite(attr, Array1Structid, Array1); - HDassert(status >= 0); - - status = H5Tclose(arrayu8_tid); - HDassert(status >= 0); - - status = H5Tclose(arrayu16_tid); - HDassert(status >= 0); - - status = H5Tclose(arrayu32_tid); - HDassert(status >= 0); - - status = H5Tclose(arrayu64_tid); - HDassert(status >= 0); - - status = H5Tclose(array8_tid); - HDassert(status >= 0); - - status = H5Tclose(array16_tid); - HDassert(status >= 0); - - status = H5Tclose(array32_tid); - HDassert(status >= 0); - - status = H5Tclose(array64_tid); - HDassert(status >= 0); - - status = H5Tclose(arraydbl_tid); - HDassert(status >= 0); - - /* Release resources */ - status = H5Tclose(Array1Structid); - HDassert(status >= 0); - - status = H5Sclose(space); - HDassert(status >= 0); - - status = H5Aclose(attr); - HDassert(status >= 0); - - status = H5Fclose(fid); - HDassert(status >= 0); -} - -static void gent_nested_compound_dt(void) { /* test nested data type */ - hid_t fid, group, dataset, space, type, create_plist, type1, type2; - hid_t array_dt, enum_dt; - enumtype val; - - typedef struct { - int a; - float b; - } dset1_t; - dset1_t dset1[10]; - - typedef struct { - int a; - float b; - enumtype c; - } dset2_t; - dset2_t dset2[10]; - - typedef struct { - int a[5]; - float b[5][6]; - dset1_t c; - } dset3_t; - dset3_t dset3[10]; - - enumtype dset4[] = {RED, GREEN, BLUE, GREEN, WHITE, BLUE}; - - int i, j, k; - unsigned ndims; - hsize_t dim[2]; - - hsize_t sdim, maxdim; - - sdim = 10; - for(i = 0; i < (int)sdim; i++) { - dset1[i].a = i; - dset1[i].b = (float)(i*i); - - dset2[i].a = i; - dset2[i].b = (float)((float)i + (float)i * 0.1F); - dset2[i].c = GREEN; - - for(j = 0; j < 5; j++) { - dset3[i].a[j] = i * j; - for(k = 0; k < 6; k++) { - dset3[i].b[j][k] = (float)((float)i * (float)j * (float)k * 1.0F); - } - } - dset3[i].c.a = i; - dset3[i].c.b = (float)((float)i * 1.0F); - } - - fid = H5Fcreate(FILE72, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - create_plist = H5Pcreate(H5P_DATASET_CREATE); - - sdim = 2; - H5Pset_chunk(create_plist, 1, &sdim); - - - sdim = 6; - maxdim = H5S_UNLIMITED; - - space = H5Screate_simple(1, &sdim, &maxdim); - - type = H5Tcreate (H5T_COMPOUND, sizeof(dset1[0])); - H5Tinsert(type, "a_name", HOFFSET(dset1_t, a), H5T_STD_I32LE); - H5Tinsert(type, "b_name", HOFFSET(dset1_t, b), H5T_IEEE_F32LE); - - dataset = H5Dcreate2(fid, "/dset1", type, space, H5P_DEFAULT, create_plist, H5P_DEFAULT); - - H5Dwrite(dataset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset1); - - H5Tclose(type); - H5Dclose(dataset); - - /* Create the shared enumerated datatype. */ - enum_dt = H5Tenum_create (H5T_NATIVE_INT); - val = (enumtype) RED; - H5Tenum_insert (enum_dt, "Red", &val); - val = (enumtype) GREEN; - H5Tenum_insert (enum_dt, "Green", &val); - val = (enumtype) BLUE; - H5Tenum_insert (enum_dt, "Blue", &val); - val = (enumtype) WHITE; - H5Tenum_insert (enum_dt, "White", &val); - val = (enumtype) BLACK; - H5Tenum_insert (enum_dt, "Black", &val); - H5Tcommit2(fid, "enumtype", enum_dt, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - type2 = H5Tcreate (H5T_COMPOUND, sizeof(dset2[0])); - - H5Tinsert(type2, "a_name", HOFFSET(dset2_t, a), H5T_NATIVE_INT); - H5Tinsert(type2, "b_name", HOFFSET(dset2_t, b), H5T_NATIVE_FLOAT); - H5Tinsert(type2, "c_name", HOFFSET(dset2_t, c), enum_dt); - - dataset = H5Dcreate2(fid, "/dset2", type2, space, H5P_DEFAULT, create_plist, H5P_DEFAULT); - - H5Dwrite(dataset, type2, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2); - - H5Tclose(type2); - - dataset = H5Dcreate2(fid, "/dset4", enum_dt, space, H5P_DEFAULT, create_plist, H5P_DEFAULT); - H5Dwrite(dataset, enum_dt, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset4); - - H5Tclose(enum_dt); - H5Dclose(dataset); - - /* shared data type 1 */ - type1 = H5Tcreate(H5T_COMPOUND, sizeof(dset1_t)); - H5Tinsert(type1, "int_name", HOFFSET(dset1_t, a), H5T_STD_I32LE); - H5Tinsert(type1, "float_name", HOFFSET(dset1_t, b), H5T_IEEE_F32LE); - H5Tcommit2(fid, "type1", type1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - group = H5Gcreate2(fid, "/group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - type2 = H5Tcreate (H5T_COMPOUND, sizeof(dset3_t)); - - ndims = 1; dim[0] = 5; - array_dt = H5Tarray_create2(H5T_STD_I32LE, ndims, dim); - H5Tinsert(type2, "int_name", HOFFSET(dset3_t, a), array_dt); - H5Tclose(array_dt); - - ndims = 2; dim[0] = 5; dim[1] = 6; - array_dt = H5Tarray_create2(H5T_IEEE_F32LE, ndims, dim); - H5Tinsert(type2, "float_name", HOFFSET(dset3_t, b), array_dt); - H5Tclose(array_dt); - - H5Tinsert (type2, "cmpd_name", HOFFSET (dset3_t, c), type1); - - dataset = H5Dcreate2(group, "dset3", type2, space, H5P_DEFAULT, create_plist, H5P_DEFAULT); - - H5Dwrite(dataset, type2, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset3); - - dataset = H5Dcreate2(fid, "/dset5", type1, space, H5P_DEFAULT, create_plist, H5P_DEFAULT); - H5Dwrite(dataset, type1, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset1); - - H5Tclose(type1); - H5Tclose(type2); - H5Sclose(space); - H5Dclose(dataset); - H5Gclose(group); - - H5Pclose(create_plist); - - H5Fclose(fid); - -} - -/*------------------------------------------------------------------------- - * Function: gent_intscalars - * - * Purpose: Generate a file to be used in the h5dump scalar tests. - * Four datasets of 1, 2, 4 and 8 bytes of unsigned int types are created. - * Four more datasets of 1, 2, 4 and 8 bytes of signed int types are created. - * Fill them with raw data such that no bit will be all zero in a dataset. - * A dummy dataset of double type is created for failure test. - *------------------------------------------------------------------------- - */ -static void -gent_intscalars(void) -{ - hid_t fid, dataset, space, tid; - 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]; - unsigned int i, j; - - fid = H5Fcreate(FILE73, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* Dataset of 8 bits unsigned int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM8; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_U8LE, F73_ARRAY_RANK, dims); - dataset = H5Dcreate2(fid, F73_DATASETU08, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - valu8bits = (uint8_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu8[i][0] = valu8bits; - for(j = 1; j < dims[1]; j++) { - dsetu8[i][j] = (uint8_t)(dsetu8[i][j-1] << 1); - } - valu8bits = (uint8_t)(valu8bits << 1); - } - - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu8); - H5Sclose(space); - H5Dclose(dataset); - - /* Dataset of 16 bits unsigned int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM16; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_U16LE, F73_ARRAY_RANK, dims); - dataset = H5Dcreate2(fid, F73_DATASETU16, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - valu16bits = (uint16_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu16[i][0] = valu16bits; - for(j = 1; j < dims[1]; j++) { - dsetu16[i][j] = (uint16_t)(dsetu16[i][j-1] << 1); - } - valu16bits = (uint16_t)(valu16bits << 1); - } - - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu16); - H5Sclose(space); - H5Dclose(dataset); - - /* Dataset of 32 bits unsigned int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM32; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_U32LE, F73_ARRAY_RANK, dims); - dataset = H5Dcreate2(fid, F73_DATASETU32, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - valu32bits = (uint32_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu32[i][0] = valu32bits; - for(j = 1; j < dims[1]; j++) { - dsetu32[i][j] = dsetu32[i][j-1] << 1; - } - valu32bits <<= 1; - } - - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu32); - H5Sclose(space); - H5Dclose(dataset); - - /* Dataset of 64 bits unsigned int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM64; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_U64LE, F73_ARRAY_RANK, dims); - dataset = H5Dcreate2(fid, F73_DATASETU64, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - valu64bits = (uint64_t) ~0Lu; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu64[i][0] = valu64bits; - for(j = 1; j < dims[1]; j++) { - dsetu64[i][j] = dsetu64[i][j-1] << 1; - } - valu64bits <<= 1; - } - - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu64); - H5Sclose(space); - H5Dclose(dataset); - - /* Dataset of 8 bits signed int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM8; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_I8LE, F73_ARRAY_RANK, dims); - dataset = H5Dcreate2(fid, F73_DATASETS08, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - val8bits = (int8_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset8[i][0] = val8bits; - for(j = 1; j < dims[1]; j++) { - dset8[i][j] = (int8_t)(dset8[i][j-1] << 1); - } - val8bits = (int8_t)(val8bits << 1); - } - - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset8); - H5Sclose(space); - H5Dclose(dataset); - - /* Dataset of 16 bits signed int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM16; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_I16LE, F73_ARRAY_RANK, dims); - dataset = H5Dcreate2(fid, F73_DATASETS16, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - val16bits = (int16_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset16[i][0] = val16bits; - for(j = 1; j < dims[1]; j++) { - dset16[i][j] = (int16_t)(dset16[i][j-1] << 1); - } - val16bits = (int16_t)(val16bits << 1); - } - - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset16); - H5Sclose(space); - H5Dclose(dataset); - - /* Dataset of 32 bits signed int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM32; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_I32LE, F73_ARRAY_RANK, dims); - dataset = H5Dcreate2(fid, F73_DATASETS32, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - val32bits = (int32_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset32[i][0] = val32bits; - for(j = 1; j < dims[1]; j++) { - dset32[i][j] = dset32[i][j-1] << 1; - } - val32bits <<= 1; - } - - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset32); - H5Sclose(space); - H5Dclose(dataset); - - /* Dataset of 64 bits signed int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM64; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_I64LE, F73_ARRAY_RANK, dims); - dataset = H5Dcreate2(fid, F73_DATASETS64, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - val64bits = (int64_t) ~0L; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset64[i][0] = val64bits; - for(j = 1; j < dims[1]; j++) { - dset64[i][j] = dset64[i][j-1] << 1; - } - val64bits <<= 1; - } - - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset64); - H5Sclose(space); - H5Dclose(dataset); - - /* Double Dummy set for failure tests */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM8; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_NATIVE_DOUBLE, F73_ARRAY_RANK, dims); - dataset = H5Dcreate2(fid, F73_DUMMYDBL, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - for(i = 0; i < dims[0]; i++) - 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); - - H5Sclose(space); - H5Dclose(dataset); - H5Fclose(fid); -} - -/*------------------------------------------------------------------------- - * Function: gent_attr_intscalars - * - * Purpose: Generate a file to be used in the h5dump attribute scalar tests. - * Four attributes of 1, 2, 4 and 8 bytes of unsigned int types are created. - * Four more datasets of 1, 2, 4 and 8 bytes of signed int types are created. - * Fill them with raw data such that no bit will be all zero in a dataset. - * A dummy dataset of double type is created for failure test. - * Use file to test Signed/Unsigned datatypes and keep in sync with gent_packedbits() - *------------------------------------------------------------------------- - */ -static void -gent_attr_intscalars(void) -{ - hid_t fid, attr, space, root, tid; - 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]; - unsigned int i, j; - - fid = H5Fcreate(FILE74, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - root = H5Gopen2(fid, "/", H5P_DEFAULT); - - /* Attribute of 8 bits unsigned int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM8; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_U8LE, F73_ARRAY_RANK, dims); - attr = H5Acreate2(root, F73_DATASETU08, tid, space, H5P_DEFAULT, H5P_DEFAULT); - - valu8bits = (uint8_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu8[i][0] = valu8bits; - for(j = 1; j < dims[1]; j++) { - dsetu8[i][j] = (uint8_t)(dsetu8[i][j-1] << 1); - } - valu8bits = (uint8_t)(valu8bits << 1); - } - - H5Awrite(attr, tid, dsetu8); - H5Sclose(space); - H5Aclose(attr); - - /* Attribute of 16 bits unsigned int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM16; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_U16LE, F73_ARRAY_RANK, dims); - attr = H5Acreate2(root, F73_DATASETU16, tid, space, H5P_DEFAULT, H5P_DEFAULT); - - valu16bits = (uint16_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu16[i][0] = valu16bits; - for(j = 1; j < dims[1]; j++) { - dsetu16[i][j] = (uint16_t)(dsetu16[i][j-1] << 1); - } - valu16bits = (uint16_t)(valu16bits << 1); - } - - H5Awrite(attr, tid, dsetu16); - H5Sclose(space); - H5Aclose(attr); - - /* Attribute of 32 bits unsigned int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM32; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_U32LE, F73_ARRAY_RANK, dims); - attr = H5Acreate2(root, F73_DATASETU32, tid, space, H5P_DEFAULT, H5P_DEFAULT); - - valu32bits = (uint32_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu32[i][0] = valu32bits; - for(j = 1; j < dims[1]; j++) { - dsetu32[i][j] = dsetu32[i][j-1] << 1; - } - valu32bits <<= 1; - } - - H5Awrite(attr, tid, dsetu32); - H5Sclose(space); - H5Aclose(attr); - - /* Attribute of 64 bits unsigned int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM64; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_U64LE, F73_ARRAY_RANK, dims); - attr = H5Acreate2(root, F73_DATASETU64, tid, space, H5P_DEFAULT, H5P_DEFAULT); - - valu64bits = (uint64_t) ~0Lu; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu64[i][0] = valu64bits; - for(j = 1; j < dims[1]; j++) { - dsetu64[i][j] = dsetu64[i][j-1] << 1; - } - valu64bits <<= 1; - } - - H5Awrite(attr, tid, dsetu64); - H5Sclose(space); - H5Aclose(attr); - - /* Attribute of 8 bits signed int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM8; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_I8LE, F73_ARRAY_RANK, dims); - attr = H5Acreate2(root, F73_DATASETS08, tid, space, H5P_DEFAULT, H5P_DEFAULT); - - val8bits = (int8_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset8[i][0] = val8bits; - for(j = 1; j < dims[1]; j++) { - dset8[i][j] = (int8_t)(dset8[i][j-1] << 1); - } - val8bits = (int8_t)(val8bits << 1); - } - - H5Awrite(attr, tid, dset8); - H5Sclose(space); - H5Aclose(attr); - - /* Attribute of 16 bits signed int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM16; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_I16LE, F73_ARRAY_RANK, dims); - attr = H5Acreate2(root, F73_DATASETS16, tid, space, H5P_DEFAULT, H5P_DEFAULT); - - val16bits = (int16_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset16[i][0] = val16bits; - for(j = 1; j < dims[1]; j++) { - dset16[i][j] = (int16_t)(dset16[i][j-1] << 1); - } - val16bits = (int16_t)(val16bits << 1); - } - - H5Awrite(attr, tid, dset16); - H5Sclose(space); - H5Aclose(attr); - - /* Attribute of 32 bits signed int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM32; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_I32LE, F73_ARRAY_RANK, dims); - attr = H5Acreate2(root, F73_DATASETS32, tid, space, H5P_DEFAULT, H5P_DEFAULT); - - val32bits = (int32_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset32[i][0] = val32bits; - for(j = 1; j < dims[1]; j++) { - dset32[i][j] = dset32[i][j-1] << 1; - } - val32bits <<= 1; - } - - H5Awrite(attr, tid, dset32); - H5Sclose(space); - H5Aclose(attr); - - /* Attribute of 64 bits signed int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM64; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_I64LE, F73_ARRAY_RANK, dims); - attr = H5Acreate2(root, F73_DATASETS64, tid, space, H5P_DEFAULT, H5P_DEFAULT); - - val64bits = (int64_t) ~0L; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset64[i][0] = val64bits; - for(j = 1; j < dims[1]; j++) { - dset64[i][j] = dset64[i][j-1] << 1; - } - val64bits <<= 1; - } - - H5Awrite(attr, tid, dset64); - H5Sclose(space); - H5Aclose(attr); - - /* Double Dummy set for failure tests */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM8; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_NATIVE_DOUBLE, F73_ARRAY_RANK, dims); - attr = H5Acreate2(root, F73_DUMMYDBL, tid, space, H5P_DEFAULT, H5P_DEFAULT); - - for(i = 0; i < dims[0]; i++) - for(j = 0; j < dims[1]; j++) - dsetdbl[i][j] = 0.0001F * (float)j + (float)i; - - H5Awrite(attr, tid, dsetdbl); - - H5Sclose(space); - H5Aclose(attr); - - H5Gclose(root); - H5Fclose(fid); -} - -/*------------------------------------------------------------------------- - * Function: gent_string_scalars - * - * Purpose: Generate a file to be used in the h5dump string scalar tests. - * A dataset of string types are created. - * An attribute of string types are created. - * Fill them with raw data such that no bit will be all zero in a dataset. - *------------------------------------------------------------------------- - */ -static void -gent_string_scalars(void) -{ - hid_t fid, attr, dataset, space, tid, root; - hsize_t dims[2]; - char string[F73_XDIM][F73_YDIM8]; - unsigned int i, j; - - fid = H5Fcreate(FILE75, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - root = H5Gopen2(fid, "/", H5P_DEFAULT); - - /* string scalar */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM8; - space = H5Screate(H5S_SCALAR); - tid = H5Tcopy(H5T_C_S1); - H5Tset_size(tid, F73_XDIM * F73_YDIM8); - - memset(string, ' ', F73_XDIM * F73_YDIM8); - for(i = 0; i < dims[0]; i++) { - string[i][0] = (char)('A' + i); - for(j = 1; j < dims[1]; j++) { - string[i][j] = (char)(string[i][j-1] + 1); - } - } - string[dims[0]-1][dims[1]-1] = 0; - - /* Dataset of string scalar */ - dataset = H5Dcreate2(fid, "the_str", tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, string); - H5Dclose(dataset); - - /* attribute of string scalar */ - attr = H5Acreate2(root, "attr_str", tid, space, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, tid, string); - - H5Sclose(space); - H5Aclose(attr); - - H5Gclose(root); - H5Fclose(fid); -} - -static void gent_compound_int_array(void) { - hid_t fid, dataset, space; - hsize_t dims[1]; - uint8_t valu8bits; - uint16_t valu16bits; - uint32_t valu32bits; - uint64_t valu64bits; - int8_t val8bits; - int16_t val16bits; - int32_t val32bits; - int64_t val64bits; - hsize_t array_dim8[]={F76_DIM8}; /* Array dimensions */ - hsize_t array_dim16[]={F76_DIM16}; /* Array dimensions */ - hsize_t array_dim32[]={F76_DIM32}; /* Array dimensions */ - hsize_t array_dim64[]={F76_DIM64}; /* Array dimensions */ - hid_t arrayu8_tid; /* Array datatype handle */ - hid_t arrayu16_tid; /* Array datatype handle */ - hid_t arrayu32_tid; /* Array datatype handle */ - hid_t arrayu64_tid; /* Array datatype handle */ - hid_t array8_tid; /* Array datatype handle */ - hid_t array16_tid; /* Array datatype handle */ - hid_t array32_tid; /* Array datatype handle */ - hid_t array64_tid; /* Array datatype handle */ - hid_t arraydbl_tid; /* Array datatype handle */ - /* Structure and array for compound types */ - typedef struct Cmpd1Struct { - uint8_t dsetu8[F76_DIM8]; - uint16_t dsetu16[F76_DIM16]; - uint32_t dsetu32[F76_DIM32]; - uint64_t dsetu64[F76_DIM64]; - int8_t dset8[F76_DIM8]; - int16_t dset16[F76_DIM16]; - int32_t dset32[F76_DIM32]; - int64_t dset64[F76_DIM64]; - double dsetdbl[F76_DIM8]; - } Cmpd1Struct; - Cmpd1Struct *Cmpd1; - - hid_t Cmpd1Structid; /* File datatype identifier */ - herr_t status; /* Error checking variable */ - hsize_t dim[] = { F76_LENGTH }; /* Dataspace dimensions */ - - int m, n; /* Array init loop vars */ - - /* Allocate buffer */ - Cmpd1 = (Cmpd1Struct *)HDmalloc(sizeof(Cmpd1Struct) * F76_LENGTH); - HDassert(Cmpd1); - - /* Initialize the data in the arrays/datastructure */ - for (m = 0; m < F76_LENGTH; m++) { - - /* Array of 8 bits unsigned int */ - dims[0] = F76_DIM8; - - valu8bits = (uint8_t) ~0u; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ - Cmpd1[m].dsetu8[n] = valu8bits; - valu8bits = (uint8_t)(valu8bits << 1); - } - - /* Array of 16 bits unsigned int */ - dims[0] = F76_DIM16; - - valu16bits = (uint16_t) ~0u; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ - Cmpd1[m].dsetu16[n] = valu16bits; - valu16bits = (uint16_t)(valu16bits << 1); - } - - /* Array of 32 bits unsigned int */ - dims[0] = F76_DIM32; - - valu32bits = (uint32_t) ~0u; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ - Cmpd1[m].dsetu32[n] = valu32bits; - valu32bits <<= 1; - } - - /* Array of 64 bits unsigned int */ - dims[0] = F76_DIM64; - - valu64bits = (uint64_t) ~0Lu; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ - Cmpd1[m].dsetu64[n] = valu64bits; - valu64bits <<= 1; - } - - /* Array of 8 bits signed int */ - dims[0] = F76_DIM8; - - val8bits = (int8_t) ~0; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ - Cmpd1[m].dset8[n] = val8bits; - val8bits = (int8_t)(val8bits << 1); - } - - /* Array of 16 bits signed int */ - dims[0] = F76_DIM16; - - val16bits = (int16_t) ~0; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ - Cmpd1[m].dset16[n] = val16bits; - val16bits = (int16_t)(val16bits << 1); - } - - /* Array of 32 bits signed int */ - dims[0] = F76_DIM32; - - val32bits = (int32_t) ~0; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ - Cmpd1[m].dset32[n] = val32bits; - val32bits <<= 1; - } - - /* Array of 64 bits signed int */ - dims[0] = F76_DIM64; - - val64bits = (int64_t) ~0L; /* all 1s */ - for(n = 0; n < (int)dims[0]; n++){ - Cmpd1[m].dset64[n] = val64bits; - val64bits <<= 1; - } - - /* Double Dummy set for failure tests */ - dims[0] = F76_DIM8; - - for(n = 0; n < (int)dims[0]; n++) - Cmpd1[m].dsetdbl[n] = 0.0001F + (float)n; - } - - /* Create the array data type for the 8 bits signed int array */ - array8_tid = H5Tarray_create2(H5T_NATIVE_SCHAR, F76_ARRAY_RANK, array_dim8); - HDassert(array8_tid >= 0); - - /* Create the array data type for the 16 bits signed int array */ - array16_tid = H5Tarray_create2(H5T_NATIVE_SHORT, F76_ARRAY_RANK, array_dim16); - HDassert(array16_tid >= 0); - - /* Create the array data type for the 32 bits signed int array */ - array32_tid = H5Tarray_create2(H5T_NATIVE_INT, F76_ARRAY_RANK, array_dim32); - HDassert(array32_tid >= 0); - - /* Create the array data type for the 64 bits signed int array */ - array64_tid = H5Tarray_create2(H5T_NATIVE_LONG, F76_ARRAY_RANK, array_dim64); - HDassert(array64_tid >= 0); - - /* Create the array data type for the 8 bits signed int array */ - arrayu8_tid = H5Tarray_create2(H5T_NATIVE_UCHAR, F76_ARRAY_RANK, array_dim8); - HDassert(arrayu8_tid >= 0); - - /* Create the array data type for the 16 bits signed int array */ - arrayu16_tid = H5Tarray_create2(H5T_NATIVE_USHORT, F76_ARRAY_RANK, array_dim16); - HDassert(arrayu16_tid >= 0); - - /* Create the array data type for the 32 bits signed int array */ - arrayu32_tid = H5Tarray_create2(H5T_NATIVE_UINT, F76_ARRAY_RANK, array_dim32); - HDassert(arrayu32_tid >= 0); - - /* Create the array data type for the 64 bits signed int array */ - arrayu64_tid = H5Tarray_create2(H5T_NATIVE_ULONG, F76_ARRAY_RANK, array_dim64); - HDassert(arrayu64_tid >= 0); - - /* Create the array data type for the 32 bits double array */ - arraydbl_tid = H5Tarray_create2(H5T_NATIVE_DOUBLE, F76_ARRAY_RANK, array_dim8); - HDassert(arraydbl_tid >= 0); - - /* Create the dataspace */ - space = H5Screate_simple(F76_RANK, dim, NULL); - HDassert(space >= 0); - - /* Create the file */ - fid = H5Fcreate(FILE76, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDassert(fid >= 0); - - /* Create the memory data type */ - Cmpd1Structid = H5Tcreate(H5T_COMPOUND, sizeof(Cmpd1Struct)); - HDassert(Cmpd1Structid >= 0); - - /* Insert the arrays and variables into the structure */ - status = H5Tinsert(Cmpd1Structid, F76_DATASETU08, HOFFSET(Cmpd1Struct, dsetu8), arrayu8_tid); - HDassert(status >= 0); - - status = H5Tinsert(Cmpd1Structid, F76_DATASETU16, HOFFSET(Cmpd1Struct, dsetu16), arrayu16_tid); - HDassert(status >= 0); - - status = H5Tinsert(Cmpd1Structid, F76_DATASETU32, HOFFSET(Cmpd1Struct, dsetu32), arrayu32_tid); - HDassert(status >= 0); - - status = H5Tinsert(Cmpd1Structid, F76_DATASETU64, HOFFSET(Cmpd1Struct, dsetu64), arrayu64_tid); - HDassert(status >= 0); - - status = H5Tinsert(Cmpd1Structid, F76_DATASETS08, HOFFSET(Cmpd1Struct, dset8), array8_tid); - HDassert(status >= 0); - - status = H5Tinsert(Cmpd1Structid, F76_DATASETS16, HOFFSET(Cmpd1Struct, dset16), array16_tid); - HDassert(status >= 0); - - status = H5Tinsert(Cmpd1Structid, F76_DATASETS32, HOFFSET(Cmpd1Struct, dset32), array32_tid); - HDassert(status >= 0); - - status = H5Tinsert(Cmpd1Structid, F76_DATASETS64, HOFFSET(Cmpd1Struct, dset64), array64_tid); - HDassert(status >= 0); - - status = H5Tinsert(Cmpd1Structid, F76_DUMMYDBL, HOFFSET(Cmpd1Struct, dsetdbl), arraydbl_tid); - HDassert(status >= 0); - - /* Create the dataset */ - dataset = H5Dcreate2(fid, F76_DATASETNAME, Cmpd1Structid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - /* Write data to the dataset */ - status = H5Dwrite(dataset, Cmpd1Structid, H5S_ALL, H5S_ALL, H5P_DEFAULT, Cmpd1); - HDassert(status >= 0); - - /* Release resources */ - status = H5Tclose(Cmpd1Structid); - HDassert(status >= 0); - - status = H5Tclose(arrayu8_tid); - HDassert(status >= 0); - - status = H5Tclose(arrayu16_tid); - HDassert(status >= 0); - - status = H5Tclose(arrayu32_tid); - HDassert(status >= 0); - - status = H5Tclose(arrayu64_tid); - HDassert(status >= 0); - - status = H5Tclose(array8_tid); - HDassert(status >= 0); - - status = H5Tclose(array16_tid); - HDassert(status >= 0); - - status = H5Tclose(array32_tid); - HDassert(status >= 0); - - status = H5Tclose(array64_tid); - HDassert(status >= 0); - - status = H5Tclose(arraydbl_tid); - HDassert(status >= 0); - - status = H5Sclose(space); - HDassert(status >= 0); - - status = H5Dclose(dataset); - HDassert(status >= 0); - - status = H5Fclose(fid); - HDassert(status >= 0); - - HDfree(Cmpd1); -} - -static void gent_compound_ints(void) { - hid_t fid, dataset, space; - uint8_t valu8bits = (uint8_t) ~0u; /* all 1s */ - uint16_t valu16bits = (uint16_t) ~0u; /* all 1s */ - uint32_t valu32bits = (uint32_t) ~0u; /* all 1s */ - uint64_t valu64bits = (uint64_t) ~0Lu; /* all 1s */ - int8_t val8bits = (int8_t) ~0; /* all 1s */ - int16_t val16bits = (int16_t) ~0; /* all 1s */ - int32_t val32bits = (int32_t) ~0; /* all 1s */ - int64_t val64bits = (int64_t) ~0L; /* all 1s */ - /* Structure and array for compound types */ - typedef struct Cmpd1Struct { - uint8_t dsetu8; - uint16_t dsetu16; - uint32_t dsetu32; - uint64_t dsetu64; - int8_t dset8; - int16_t dset16; - int32_t dset32; - int64_t dset64; - double dsetdbl; - } Cmpd1Struct; - Cmpd1Struct *Cmpd1; - - typedef struct Cmpd2Struct { - uint64_t dsetu64; - uint32_t dsetu32; - uint16_t dsetu16; - uint8_t dsetu8; - int64_t dset64; - int32_t dset32; - int16_t dset16; - int8_t dset8; - double dsetdbl; - } Cmpd2Struct; - Cmpd2Struct *Cmpd2; - - hid_t Cmpd1Structid; /* File datatype identifier */ - hid_t Cmpd2Structid; /* File datatype identifier */ - herr_t status; /* Error checking variable */ - hsize_t dim[] = { F77_LENGTH }; /* Dataspace dimensions */ - - int m; /* Array init loop vars */ - - /* Allocate buffers */ - Cmpd1 = (Cmpd1Struct *)HDmalloc(sizeof(Cmpd1Struct) * F77_LENGTH); - HDassert(Cmpd1); - Cmpd2 = (Cmpd2Struct *)HDmalloc(sizeof(Cmpd2Struct) * F77_LENGTH); - HDassert(Cmpd2); - - /* Initialize the data in the arrays/datastructure */ - for (m = 0; m < F77_LENGTH; m++) { - - /* Array of 8 bits unsigned int */ - if((m % F76_DIM8) == 0) - valu8bits = (uint8_t) ~0u; /* all 1s */ - Cmpd1[m].dsetu8 = valu8bits; - Cmpd2[m].dsetu8 = valu8bits; - valu8bits = (uint8_t)(valu8bits << 1); - - /* Array of 16 bits unsigned int */ - if((m % F76_DIM16) == 0) - valu16bits = (uint16_t) ~0u; /* all 1s */ - Cmpd1[m].dsetu16 = valu16bits; - Cmpd2[m].dsetu16 = valu16bits; - valu16bits = (uint16_t)(valu16bits << 1); - - /* Array of 32 bits unsigned int */ - if((m % F76_DIM32) == 0) - valu32bits = (uint32_t) ~0u; /* all 1s */ - Cmpd1[m].dsetu32 = valu32bits; - Cmpd2[m].dsetu32 = valu32bits; - valu32bits <<= 1; - - /* Array of 64 bits unsigned int */ - if((m % F76_DIM64) == 0) - valu64bits = (uint64_t) ~0Lu; /* all 1s */ - Cmpd1[m].dsetu64 = valu64bits; - Cmpd2[m].dsetu64 = valu64bits; - valu64bits <<= 1; - - /* Array of 8 bits signed int */ - if((m % F76_DIM8) == 0) - val8bits = (int8_t) ~0; /* all 1s */ - Cmpd1[m].dset8 = val8bits; - Cmpd2[m].dset8 = val8bits; - val8bits = (int8_t)(val8bits << 1); - - /* Array of 16 bits signed int */ - if((m % F76_DIM16) == 0) - val16bits = (int16_t) ~0; /* all 1s */ - Cmpd1[m].dset16 = val16bits; - Cmpd2[m].dset16 = val16bits; - val16bits = (int16_t)(val16bits << 1); - - /* Array of 32 bits signed int */ - if((m % F76_DIM32) == 0) - val32bits = (int32_t) ~0; /* all 1s */ - Cmpd1[m].dset32 = val32bits; - Cmpd2[m].dset32 = val32bits; - val32bits <<= 1; - - /* Array of 64 bits signed int */ - if((m % F76_DIM64) == 0) - val64bits = (int64_t) ~0L; /* all 1s */ - Cmpd1[m].dset64 = val64bits; - Cmpd2[m].dset64 = val64bits; - val64bits <<= 1; - - /* Double Dummy set for failure tests */ - Cmpd1[m].dsetdbl = 0.0001F + (float)m; - Cmpd2[m].dsetdbl = 0.0001F + (float)m; - } - - /* Create the dataspace */ - space = H5Screate_simple(F76_RANK, dim, NULL); - HDassert(space >= 0); - - /* Create the file */ - fid = H5Fcreate(FILE77, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDassert(fid >= 0); - - /* Create the memory data type */ - Cmpd1Structid = H5Tcreate(H5T_COMPOUND, sizeof(Cmpd1Struct)); - HDassert(Cmpd1Structid >= 0); - - /* Insert the arrays and variables into the structure */ - status = H5Tinsert(Cmpd1Structid, F76_DATASETU08, HOFFSET(Cmpd1Struct, dsetu8), H5T_NATIVE_UCHAR); - HDassert(status >= 0); - - status = H5Tinsert(Cmpd1Structid, F76_DATASETU16, HOFFSET(Cmpd1Struct, dsetu16), H5T_NATIVE_USHORT); - HDassert(status >= 0); - - status = H5Tinsert(Cmpd1Structid, F76_DATASETU32, HOFFSET(Cmpd1Struct, dsetu32), H5T_NATIVE_UINT); - HDassert(status >= 0); - - status = H5Tinsert(Cmpd1Structid, F76_DATASETU64, HOFFSET(Cmpd1Struct, dsetu64), H5T_NATIVE_ULONG); - HDassert(status >= 0); - - status = H5Tinsert(Cmpd1Structid, F76_DATASETS08, HOFFSET(Cmpd1Struct, dset8), H5T_NATIVE_SCHAR); - HDassert(status >= 0); - - status = H5Tinsert(Cmpd1Structid, F76_DATASETS16, HOFFSET(Cmpd1Struct, dset16), H5T_NATIVE_SHORT); - HDassert(status >= 0); - - status = H5Tinsert(Cmpd1Structid, F76_DATASETS32, HOFFSET(Cmpd1Struct, dset32), H5T_NATIVE_INT); - HDassert(status >= 0); - - status = H5Tinsert(Cmpd1Structid, F76_DATASETS64, HOFFSET(Cmpd1Struct, dset64), H5T_NATIVE_LONG); - HDassert(status >= 0); - - status = H5Tinsert(Cmpd1Structid, F76_DUMMYDBL, HOFFSET(Cmpd1Struct, dsetdbl), H5T_NATIVE_DOUBLE); - HDassert(status >= 0); - - /* Create the dataset */ - dataset = H5Dcreate2(fid, F77_DATASETNAME1, Cmpd1Structid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - /* Write data to the dataset */ - status = H5Dwrite(dataset, Cmpd1Structid, H5S_ALL, H5S_ALL, H5P_DEFAULT, Cmpd1); - HDassert(status >= 0); - - /* Release resources */ - status = H5Tclose(Cmpd1Structid); - HDassert(status >= 0); - - status = H5Sclose(space); - HDassert(status >= 0); - - status = H5Dclose(dataset); - HDassert(status >= 0); - - /* Create the dataspace */ - space = H5Screate_simple(F76_RANK, dim, NULL); - HDassert(space >= 0); - - /* Create the memory data type */ - Cmpd2Structid = H5Tcreate(H5T_COMPOUND, sizeof(Cmpd2Struct)); - HDassert(Cmpd2Structid >= 0); - - /* Insert the arrays and variables into the structure */ - status = H5Tinsert(Cmpd2Structid, F76_DATASETU64, HOFFSET(Cmpd2Struct, dsetu64), H5T_NATIVE_ULONG); - HDassert(status >= 0); - - status = H5Tinsert(Cmpd2Structid, F76_DATASETU32, HOFFSET(Cmpd2Struct, dsetu32), H5T_NATIVE_UINT); - HDassert(status >= 0); - - status = H5Tinsert(Cmpd2Structid, F76_DATASETU16, HOFFSET(Cmpd2Struct, dsetu16), H5T_NATIVE_USHORT); - HDassert(status >= 0); - - status = H5Tinsert(Cmpd2Structid, F76_DATASETU08, HOFFSET(Cmpd2Struct, dsetu8), H5T_NATIVE_UCHAR); - HDassert(status >= 0); - - status = H5Tinsert(Cmpd2Structid, F76_DATASETS64, HOFFSET(Cmpd2Struct, dset64), H5T_NATIVE_LONG); - HDassert(status >= 0); - - status = H5Tinsert(Cmpd2Structid, F76_DATASETS32, HOFFSET(Cmpd2Struct, dset32), H5T_NATIVE_INT); - HDassert(status >= 0); - - status = H5Tinsert(Cmpd2Structid, F76_DATASETS16, HOFFSET(Cmpd2Struct, dset16), H5T_NATIVE_SHORT); - HDassert(status >= 0); - - status = H5Tinsert(Cmpd2Structid, F76_DATASETS08, HOFFSET(Cmpd2Struct, dset8), H5T_NATIVE_SCHAR); - HDassert(status >= 0); - - status = H5Tinsert(Cmpd2Structid, F76_DUMMYDBL, HOFFSET(Cmpd2Struct, dsetdbl), H5T_NATIVE_DOUBLE); - HDassert(status >= 0); - - /* Create the dataset */ - dataset = H5Dcreate2(fid, F77_DATASETNAME2, Cmpd2Structid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - /* Write data to the dataset */ - status = H5Dwrite(dataset, Cmpd2Structid, H5S_ALL, H5S_ALL, H5P_DEFAULT, Cmpd2); - HDassert(status >= 0); - - /* Release resources */ - status = H5Tclose(Cmpd2Structid); - HDassert(status >= 0); - - status = H5Sclose(space); - HDassert(status >= 0); - - status = H5Dclose(dataset); - HDassert(status >= 0); - - status = H5Fclose(fid); - HDassert(status >= 0); - - HDfree(Cmpd1); - HDfree(Cmpd2); -} - -/*------------------------------------------------------------------------- - * Function: gent_intscalars - * - * Purpose: Generate a file to be used in the h5dump scalar with attribute tests. - * Four datasets of 1, 2, 4 and 8 bytes of unsigned int types are created. - * Four more datasets of 1, 2, 4 and 8 bytes of signed int types are created. - * Fill them with raw data such that no bit will be all zero in a dataset. - * A dummy dataset of double type is created for failure test. - *------------------------------------------------------------------------- - */ -static void -gent_intattrscalars(void) -{ - hid_t fid, attr, dataset, space, tid; - 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]; - unsigned int i, j; - - fid = H5Fcreate(FILE78, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* Dataset of 8 bits unsigned int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM8; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_U8LE, F73_ARRAY_RANK, dims); - dataset = H5Dcreate2(fid, F73_DATASETU08, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - valu8bits = (uint8_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu8[i][0] = valu8bits; - for(j = 1; j < dims[1]; j++) { - dsetu8[i][j] = (uint8_t)(dsetu8[i][j-1] << 1); - } - valu8bits = (uint8_t)(valu8bits << 1); - } - - 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); - H5Aclose(attr); - H5Sclose(space); - H5Dclose(dataset); - - /* Dataset of 16 bits unsigned int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM16; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_U16LE, F73_ARRAY_RANK, dims); - dataset = H5Dcreate2(fid, F73_DATASETU16, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - valu16bits = (uint16_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu16[i][0] = valu16bits; - for(j = 1; j < dims[1]; j++) { - dsetu16[i][j] = (uint16_t)(dsetu16[i][j-1] << 1); - } - valu16bits = (uint16_t)(valu16bits << 1); - } - - 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); - H5Aclose(attr); - H5Sclose(space); - H5Dclose(dataset); - - /* Dataset of 32 bits unsigned int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM32; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_U32LE, F73_ARRAY_RANK, dims); - dataset = H5Dcreate2(fid, F73_DATASETU32, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - valu32bits = (uint32_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu32[i][0] = valu32bits; - for(j = 1; j < dims[1]; j++) { - dsetu32[i][j] = dsetu32[i][j-1] << 1; - } - valu32bits <<= 1; - } - - 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); - H5Aclose(attr); - H5Sclose(space); - H5Dclose(dataset); - - /* Dataset of 64 bits unsigned int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM64; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_U64LE, F73_ARRAY_RANK, dims); - dataset = H5Dcreate2(fid, F73_DATASETU64, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - valu64bits = (uint64_t) ~0Lu; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu64[i][0] = valu64bits; - for(j = 1; j < dims[1]; j++) { - dsetu64[i][j] = dsetu64[i][j-1] << 1; - } - valu64bits <<= 1; - } - - 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); - H5Aclose(attr); - H5Sclose(space); - H5Dclose(dataset); - - /* Dataset of 8 bits signed int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM8; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_I8LE, F73_ARRAY_RANK, dims); - dataset = H5Dcreate2(fid, F73_DATASETS08, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - val8bits = (int8_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset8[i][0] = val8bits; - for(j = 1; j < dims[1]; j++) { - dset8[i][j] = (int8_t)(dset8[i][j-1] << 1); - } - val8bits = (int8_t)(val8bits << 1); - } - - 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); - H5Aclose(attr); - H5Sclose(space); - H5Dclose(dataset); - - /* Dataset of 16 bits signed int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM16; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_I16LE, F73_ARRAY_RANK, dims); - dataset = H5Dcreate2(fid, F73_DATASETS16, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - val16bits = (int16_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset16[i][0] = val16bits; - for(j = 1; j < dims[1]; j++) { - dset16[i][j] = (int16_t)(dset16[i][j-1] << 1); - } - val16bits = (int16_t)(val16bits << 1); - } - - 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); - H5Aclose(attr); - H5Sclose(space); - H5Dclose(dataset); - - /* Dataset of 32 bits signed int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM32; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_I32LE, F73_ARRAY_RANK, dims); - dataset = H5Dcreate2(fid, F73_DATASETS32, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - val32bits = (int32_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset32[i][0] = val32bits; - for(j = 1; j < dims[1]; j++) { - dset32[i][j] = dset32[i][j-1] << 1; - } - val32bits <<= 1; - } - - 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); - H5Aclose(attr); - H5Sclose(space); - H5Dclose(dataset); - - /* Dataset of 64 bits signed int */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM64; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_STD_I64LE, F73_ARRAY_RANK, dims); - dataset = H5Dcreate2(fid, F73_DATASETS64, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - val64bits = (int64_t) ~0L; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset64[i][0] = val64bits; - for(j = 1; j < dims[1]; j++) { - dset64[i][j] = dset64[i][j-1] << 1; - } - val64bits <<= 1; - } - - 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); - H5Aclose(attr); - H5Sclose(space); - H5Dclose(dataset); - - /* Double Dummy set for failure tests */ - dims[0] = F73_XDIM; dims[1] = F73_YDIM8; - space = H5Screate(H5S_SCALAR); - tid = H5Tarray_create2(H5T_NATIVE_DOUBLE, F73_ARRAY_RANK, dims); - dataset = H5Dcreate2(fid, F73_DUMMYDBL, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - for(i = 0; i < dims[0]; i++) - 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); - /* Attribute of double */ - attr = H5Acreate2(dataset, F73_DUMMYDBL, tid, space, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, tid, dsetdbl); - H5Aclose(attr); - H5Sclose(space); - H5Dclose(dataset); - H5Fclose(fid); -} - -/*------------------------------------------------------------------------- - * Function: gent_packedbits - * - * Purpose: Generate a file to be used in the h5dump packed bits tests. - * Four datasets of 1, 2, 4 and 8 bytes of unsigned int types are created. - * Four more datasets of 1, 2, 4 and 8 bytes of signed int types are created. - * Fill them with raw data such that no bit will be all zero in a dataset. - * A dummy dataset of double type is created for failure test. - * Created: Albert Cheng, 2010/5/10. - * Modified: Allen Byrne, 2011/1/5 Use file to test Signed/Unsigned datatypes - *------------------------------------------------------------------------- - */ -static void -gent_intsattrs(void) -{ - hid_t fid, attr, dataset, space, aspace; - 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]; - unsigned int i, j; - - fid = H5Fcreate(FILE79, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* Dataset of 8 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM8; - space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(fid, F66_DATASETU08, H5T_STD_U8LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - valu8bits = (uint8_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu8[i][0] = valu8bits; - asetu8[i*dims[1]] = dsetu8[i][0]; - for(j = 1; j < dims[1]; j++) { - dsetu8[i][j] = (uint8_t)(dsetu8[i][j-1] << 1); - asetu8[i*dims[1]+j] = dsetu8[i][j]; - } - valu8bits = (uint8_t)(valu8bits << 1); - } - - H5Dwrite(dataset, H5T_NATIVE_UINT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu8); - /* Attribute of 8 bits unsigned int */ - adims[0] = F66_XDIM * F66_YDIM8; - aspace = H5Screate_simple(1, adims, NULL); - attr = H5Acreate2(dataset, F66_DATASETU08, H5T_STD_U8LE, aspace, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, H5T_NATIVE_UINT8, asetu8); - H5Aclose(attr); - H5Sclose(aspace); - H5Sclose(space); - H5Dclose(dataset); - - /* Dataset of 16 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM16; - space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(fid, F66_DATASETU16, H5T_STD_U16LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - valu16bits = (uint16_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu16[i][0] = valu16bits; - asetu16[i*dims[1]] = dsetu16[i][0]; - for(j = 1; j < dims[1]; j++) { - dsetu16[i][j] = (uint16_t)(dsetu16[i][j-1] << 1); - asetu16[i*dims[1]+j] = dsetu16[i][j]; - } - valu16bits = (uint16_t)(valu16bits << 1); - } - - H5Dwrite(dataset, H5T_NATIVE_UINT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu16); - /* Attribute of 16 bits unsigned int */ - adims[0] = F66_XDIM * F66_YDIM16; - aspace = H5Screate_simple(1, adims, NULL); - attr = H5Acreate2(dataset, F66_DATASETU16, H5T_STD_U16LE, aspace, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, H5T_NATIVE_UINT16, asetu16); - H5Aclose(attr); - H5Sclose(aspace); - H5Sclose(space); - H5Dclose(dataset); - - /* Dataset of 32 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM32; - space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(fid, F66_DATASETU32, H5T_STD_U32LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - valu32bits = (uint32_t) ~0u; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu32[i][0] = valu32bits; - asetu32[i*dims[1]] = dsetu32[i][0]; - for(j = 1; j < dims[1]; j++) { - dsetu32[i][j] = dsetu32[i][j-1] << 1; - asetu32[i*dims[1]+j] = dsetu32[i][j]; - } - valu32bits <<= 1; - } - - H5Dwrite(dataset, H5T_NATIVE_UINT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu32); - /* Attribute of 32 bits unsigned int */ - adims[0] = F66_XDIM * F66_YDIM32; - aspace = H5Screate_simple(1, adims, NULL); - attr = H5Acreate2(dataset, F66_DATASETU32, H5T_STD_U32LE, aspace, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, H5T_NATIVE_UINT32, asetu32); - H5Aclose(attr); - H5Sclose(aspace); - H5Sclose(space); - H5Dclose(dataset); - - /* Dataset of 64 bits unsigned int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM64; - space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(fid, F66_DATASETU64, H5T_STD_U64LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - valu64bits = (uint64_t) ~0Lu; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dsetu64[i][0] = valu64bits; - asetu64[i*dims[1]] = dsetu64[i][0]; - for(j = 1; j < dims[1]; j++) { - dsetu64[i][j] = dsetu64[i][j-1] << 1; - asetu64[i*dims[1]+j] = dsetu64[i][j]; - } - valu64bits <<= 1; - } - - H5Dwrite(dataset, H5T_NATIVE_UINT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu64); - /* Attribute of 64 bits unsigned int */ - adims[0] = F66_XDIM * F66_YDIM64; - aspace = H5Screate_simple(1, adims, NULL); - attr = H5Acreate2(dataset, F66_DATASETU64, H5T_STD_U64LE, aspace, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, H5T_NATIVE_UINT64, asetu64); - H5Aclose(attr); - H5Sclose(aspace); - H5Sclose(space); - H5Dclose(dataset); - - /* Dataset of 8 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM8; - space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(fid, F66_DATASETS08, H5T_STD_I8LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - val8bits = (int8_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset8[i][0] = val8bits; - aset8[i*dims[1]] = dset8[i][0]; - for(j = 1; j < dims[1]; j++) { - dset8[i][j] = (int8_t)(dset8[i][j-1] << 1); - aset8[i*dims[1]+j] = dset8[i][j]; - } - val8bits = (int8_t)(val8bits << 1); - } - - H5Dwrite(dataset, H5T_NATIVE_INT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset8); - /* Attribute of 8 bits signed int */ - adims[0] = F66_XDIM * F66_YDIM8; - aspace = H5Screate_simple(1, adims, NULL); - attr = H5Acreate2(dataset, F66_DATASETS08, H5T_STD_I8LE, aspace, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, H5T_NATIVE_INT8, aset8); - H5Aclose(attr); - H5Sclose(aspace); - H5Sclose(space); - H5Dclose(dataset); - - /* Dataset of 16 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM16; - space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(fid, F66_DATASETS16, H5T_STD_I16LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - val16bits = (int16_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset16[i][0] = val16bits; - aset16[i*dims[1]] = dset16[i][0]; - for(j = 1; j < dims[1]; j++) { - dset16[i][j] = (int16_t)(dset16[i][j-1] << 1); - aset16[i*dims[1]+j] = dset16[i][j]; - } - val16bits = (int16_t)(val16bits << 1); - } - - H5Dwrite(dataset, H5T_NATIVE_INT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset16); - /* Attribute of 16 bits signed int */ - adims[0] = F66_XDIM * F66_YDIM16; - aspace = H5Screate_simple(1, adims, NULL); - attr = H5Acreate2(dataset, F66_DATASETS16, H5T_STD_I16LE, aspace, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, H5T_NATIVE_INT16, aset16); - H5Aclose(attr); - H5Sclose(aspace); - H5Sclose(space); - H5Dclose(dataset); - - /* Dataset of 32 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM32; - space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(fid, F66_DATASETS32, H5T_STD_I32LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - val32bits = (int32_t) ~0; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset32[i][0] = val32bits; - aset32[i*dims[1]] = dset32[i][0]; - for(j = 1; j < dims[1]; j++) { - dset32[i][j] = dset32[i][j-1] << 1; - aset32[i*dims[1]+j] = dset32[i][j]; - } - val32bits <<= 1; - } - - H5Dwrite(dataset, H5T_NATIVE_INT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset32); - /* Attribute of 32 bits signed int */ - adims[0] = F66_XDIM * F66_YDIM32; - aspace = H5Screate_simple(1, adims, NULL); - attr = H5Acreate2(dataset, F66_DATASETS32, H5T_STD_I32LE, aspace, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, H5T_NATIVE_INT32, aset32); - H5Aclose(attr); - H5Sclose(aspace); - H5Sclose(space); - H5Dclose(dataset); - - /* Dataset of 64 bits signed int */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM64; - space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(fid, F66_DATASETS64, H5T_STD_I64LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - val64bits = (int64_t) ~0L; /* all 1s */ - for(i = 0; i < dims[0]; i++){ - dset64[i][0] = val64bits; - aset64[i*dims[1]] = dset64[i][0]; - for(j = 1; j < dims[1]; j++) { - dset64[i][j] = dset64[i][j-1] << 1; - aset64[i*dims[1]+j] = dset64[i][j]; - } - val64bits <<= 1; - } - - H5Dwrite(dataset, H5T_NATIVE_INT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset64); - /* Attribute of 64 bits signed int */ - adims[0] = F66_XDIM * F66_YDIM64; - aspace = H5Screate_simple(1, adims, NULL); - attr = H5Acreate2(dataset, F66_DATASETS64, H5T_STD_I64LE, aspace, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, H5T_NATIVE_INT64, aset64); - H5Aclose(attr); - H5Sclose(aspace); - H5Sclose(space); - H5Dclose(dataset); - - /* Double Dummy set for failure tests */ - dims[0] = F66_XDIM; dims[1] = F66_YDIM8; - space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(fid, F66_DUMMYDBL, H5T_IEEE_F64BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - for(i = 0; i < dims[0]; i++) - for(j = 0; j < dims[1]; j++) { - dsetdbl[i][j] = 0.0001F * (float)j + (float)i; - asetdbl[i*dims[1]+j] = dsetdbl[i][j]; - } - - H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetdbl); - /* Attribute of double */ - adims[0] = F66_XDIM * F66_YDIM8; - aspace = H5Screate_simple(1, adims, NULL); - attr = H5Acreate2(dataset, F66_DUMMYDBL, H5T_IEEE_F64BE, aspace, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, H5T_NATIVE_DOUBLE, asetdbl); - H5Aclose(attr); - H5Sclose(aspace); - H5Sclose(space); - H5Dclose(dataset); - H5Fclose(fid); -} - -static void gent_bitnopaquefields(void) -{ - /* Compound datatype */ - typedef struct s_t - { - unsigned char a; - unsigned int b; - unsigned long c; - unsigned long long d; - } s_t; - hid_t file, grp=-1, type=-1, space=-1, dset=-1; - size_t i; - hsize_t nelmts = F80_DIM32; - unsigned char buf[F80_DIM32]; /* bitfield, opaque */ - unsigned int buf2[F80_DIM32]; /* bitfield, opaque */ - unsigned long buf3[F80_DIM32]; /* bitfield, opaque */ - unsigned long long buf4[F80_DIM32]; /* bitfield, opaque */ - s_t buf5[F80_DIM32]; /* compound */ - - file = H5Fcreate(FILE80, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - if ((grp = H5Gcreate2(file, "bittypetests", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - /* bitfield_1 */ - if ((type = H5Tcopy(H5T_STD_B8LE)) >= 0) { - if ((space = H5Screate_simple(1, &nelmts, NULL)) >= 0) { - if ((dset = H5Dcreate2(grp, "bitfield_1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - for (i = 0; i < nelmts; i++) { - buf[i] = (unsigned char)0xff ^ (unsigned char)i; - } - H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); - H5Dclose(dset); - } - H5Sclose(space); - } - H5Tclose(type); - } - - /* bitfield_2 */ - if ((type = H5Tcopy(H5T_STD_B16LE)) >= 0) { - if ((space = H5Screate_simple(1, &nelmts, NULL)) >= 0) { - if ((dset = H5Dcreate2(grp, "bitfield_2", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - for (i = 0; i < nelmts; i++) { - buf2[i] = (unsigned int)0xffff ^ (unsigned int)(i * 16); - } - H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2); - H5Dclose(dset); - } - H5Sclose(space); - } - H5Tclose(type); - } - - /* bitfield_3 */ - if ((type = H5Tcopy(H5T_STD_B32LE)) >= 0) { - if ((space = H5Screate_simple(1, &nelmts, NULL)) >= 0) { - if ((dset = H5Dcreate2(grp, "bitfield_3", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - for (i = 0; i < nelmts; i++) { - buf3[i] = (unsigned long)0xffffffff ^ (unsigned long)(i * 32); - } - H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf3); - H5Dclose(dset); - } - H5Sclose(space); - } - H5Tclose(type); - } - - /* bitfield_4 */ - if ((type = H5Tcopy(H5T_STD_B64LE)) >= 0) { - if ((space = H5Screate_simple(1, &nelmts, NULL)) >= 0) { - if ((dset = H5Dcreate2(grp, "bitfield_4", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - for (i = 0; i < nelmts; i++) { - buf4[i] = (unsigned long long)0xffffffffffffffff ^ (unsigned long long)(i * 64); - } - H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf4); - H5Dclose(dset); - } - H5Sclose(space); - } - H5Tclose(type); - } - - H5Gclose(grp); - } - - if ((grp = H5Gcreate2(file, "opaquetypetests", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - /* opaque_1 */ - if ((type = H5Tcreate(H5T_OPAQUE, 1)) >= 0) { - if ((H5Tset_tag(type, "1-byte opaque type")) >= 0) { - if ((space = H5Screate_simple(1, &nelmts, NULL)) >= 0) { - if ((dset = H5Dcreate2(grp, "opaque_1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - for(i = 0; i < nelmts; i++) - buf[i] = (unsigned char)0xff ^ (unsigned char)i; - H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); - H5Dclose(dset); - } - H5Sclose(space); - } - } - H5Tclose(type); - } - - /* opaque_2 */ - if ((type = H5Tcreate(H5T_OPAQUE, 2)) >= 0) { - if ((H5Tset_tag(type, "2-byte opaque type")) >= 0) { - if ((space = H5Screate_simple(1, &nelmts, NULL)) >= 0) { - if ((dset = H5Dcreate2(grp, "opaque_2", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - for(i = 0; i < nelmts; i++) - buf2[i] = (unsigned int)0xffff ^ (unsigned int)(i * 16); - - H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2); - H5Dclose(dset); - } - H5Sclose(space); - } - } - H5Tclose(type); - } - H5Gclose(grp); - } - - if ((grp = H5Gcreate2(file, "cmpdtypetests", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - /* compound_1 */ - if ((type = H5Tcreate(H5T_COMPOUND, sizeof(s_t))) >= 0) { - H5Tinsert(type, "a", HOFFSET(s_t, a), H5T_STD_B8LE); - H5Tinsert(type, "b", HOFFSET(s_t, b), H5T_STD_B16LE); - H5Tinsert(type, "c", HOFFSET(s_t, c), H5T_STD_B32LE); - H5Tinsert(type, "d", HOFFSET(s_t, d), H5T_STD_B64LE); - if ((space = H5Screate_simple(1, &nelmts, NULL)) >= 0) { - if ((dset = H5Dcreate2(grp, "compound_1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - for(i = 0; i < nelmts; i++) { - buf5[i].a = (unsigned char)0xff ^ (unsigned char)i; - buf5[i].b = (unsigned int)0xffff ^ (unsigned int)(i * 16); - buf5[i].c = (unsigned long)0xffffffff ^ (unsigned long)(i * 32); - buf5[i].d = (unsigned long long)0xffffffffffffffff ^ (unsigned long long)(i * 64); - } - - H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf5); - H5Dclose(dset); - } - H5Sclose(space); - } - H5Tclose(type); - } - H5Gclose(grp); - } - - H5Fclose(file); -} - -/*------------------------------------------------------------------------- - * Function: gent_intsfourdims - * - * Purpose: Generate a file to be used in the h5dump subsetting tests. - * One datasets of unsigned int types are created in four dimensions 2,4,6,10. - *------------------------------------------------------------------------- - */ -static void -gent_intsfourdims(void) -{ - hid_t fid, dataset, space; - hsize_t dims[F81_RANK]; - uint32_t dset1[F81_ZDIM][F81_YDIM][F81_XDIM][F81_WDIM]; - unsigned int i, j, k, l; - - fid = H5Fcreate(FILE81, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* Dataset of 32 bits unsigned int */ - dims[0] = F81_ZDIM; dims[1] = F81_YDIM; dims[2] = F81_XDIM; dims[3] = F81_WDIM; - space = H5Screate_simple(F81_RANK, dims, NULL); - dataset = H5Dcreate2(fid, F81_DATASETNAME, H5T_STD_U32LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - for(i = 0; i < F81_ZDIM; i++) - for(j = 0; j < F81_YDIM; j++) - for(k = 0; k < F81_XDIM; k++) - for(l = 0; l < F81_WDIM; l++) - dset1[i][j][k][l] = i*F81_YDIM*F81_XDIM*F81_WDIM + j*F81_XDIM*F81_WDIM + k*F81_WDIM + l; - - H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset1); - H5Sclose(space); - H5Dclose(dataset); - - H5Fclose(fid); -} - -/*------------------------------------------------------------------------- - * Function: gent_compound_complex2 - * - * Purpose: Generate a file to be used in testing compound datatypes of - * various sizes, dimensions, member types and nesting. - *------------------------------------------------------------------------- - */ -static void gent_compound_complex2(void) -{ - /* Third-level nested compound */ - typedef struct { - short deep_nested_short[10]; - int deep_nested_int[10]; - long deep_nested_long[10]; - double deep_nested_double[10]; - float deep_nested_float[10]; - } third_level_compound; - - /* Second-level multiply-nested compounds */ - typedef struct { - unsigned int multiple_nested_a[5]; - int multiple_nested_b[5]; - unsigned long multiple_nested_c[5]; - long multiple_nested_d[5]; - } further_nested; - - typedef struct { - char further_nested_string[11]; - char further_nested_string_array[4][13]; - third_level_compound deep_nest; - } further_nested2; - - /* First First-level nested compound */ - typedef struct - { - double nested_a; - char nested_string[23]; - char nested_string_array[4][12]; - } nested_compound; - - /* Second First-level nested compound */ - typedef struct - { - float a; - further_nested b; - further_nested2 c; - } multiple_nested_compound; - - /* Compound datatype with different member types */ - typedef struct - { - /* Arrays nested inside compound */ - unsigned int a[4]; - int b[6]; - float c[2][4]; - nested_compound d; /* Compound inside compound */ - multiple_nested_compound e; /* Compound inside compound with further nested compound */ - } compound; - - compound *buf; /* compound */ - - hid_t file, type=-1, space=-1, dset=-1; - hid_t dset_array_a, dset_array_b, dset_array_c; - hid_t cmpd_tid1 = -1, cmpd_tid2 = -1, cmpd_tid3 = -1; - size_t i; - size_t j, k; - unsigned dset_array_ndims; - hsize_t dset_array_a_dims[1], dset_array_b_dims[1], dset_array_c_dims[2]; - hsize_t nelmts = F82_DIM32; - - /* Allocate buffer */ - buf = (compound *)HDmalloc(sizeof(compound) * F82_DIM32); - HDassert(buf); - - file = H5Fcreate(FILE82, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - if ((space = H5Screate_simple(F82_RANK, &nelmts, NULL)) >= 0) { - /* CompoundComplex1D */ - if ((type = H5Tcreate(H5T_COMPOUND, sizeof(compound))) >= 0) { - hid_t str_type, array; - hsize_t dims[1]; - hid_t nest1, nest2; - - /* Insert top-level array members */ - dset_array_ndims = 1; dset_array_a_dims[0] = 4; - dset_array_a = H5Tarray_create2(H5T_STD_U32LE, dset_array_ndims, dset_array_a_dims); - H5Tinsert(type, "a", HOFFSET(compound, a), dset_array_a); - H5Tclose(dset_array_a); - - dset_array_ndims = 1; dset_array_b_dims[0] = 6; - dset_array_b = H5Tarray_create2(H5T_STD_I32LE, dset_array_ndims, dset_array_b_dims); - H5Tinsert(type, "b", HOFFSET(compound, b), dset_array_b); - H5Tclose(dset_array_b); - - dset_array_ndims = 2; dset_array_c_dims[0] = 2; dset_array_c_dims[1] = 4; - dset_array_c = H5Tarray_create2(H5T_IEEE_F32LE, dset_array_ndims, dset_array_c_dims); - H5Tinsert(type, "c", HOFFSET(compound, c), dset_array_c); - H5Tclose(dset_array_c); - - /* Insert first nested compound */ - cmpd_tid1 = H5Tcreate(H5T_COMPOUND, sizeof(nested_compound)); - - H5Tinsert(cmpd_tid1, "nested_double", HOFFSET(nested_compound, nested_a), H5T_IEEE_F64LE); - - dims[0] = 1; - str_type = mkstr(23, H5T_STR_NULLTERM); - array = H5Tarray_create2(str_type, 1, dims); - H5Tinsert(cmpd_tid1, "nested_string", HOFFSET(nested_compound, nested_string), array); - H5Tclose(array); - H5Tclose(str_type); - - dims[0] = 4; - str_type = mkstr(12, H5T_STR_NULLTERM); - array = H5Tarray_create2(str_type, 1, dims); - H5Tinsert(cmpd_tid1, "nested_string_array", HOFFSET(nested_compound, nested_string_array), array); - H5Tclose(array); - H5Tclose(str_type); - - H5Tinsert(type, "nested_compound", HOFFSET(compound, d), cmpd_tid1); - - /* Insert second nested compound */ - cmpd_tid2 = H5Tcreate(H5T_COMPOUND, sizeof(multiple_nested_compound)); - - H5Tinsert(cmpd_tid2, "nested_float", HOFFSET(multiple_nested_compound, a), H5T_IEEE_F32LE); - - /* Add first further nested compound */ - nest1 = H5Tcreate(H5T_COMPOUND, sizeof(further_nested)); - - dims[0] = 5; - array = H5Tarray_create2(H5T_STD_U32LE, 1, dims); - H5Tinsert(nest1, "nested_unsigned_int", HOFFSET(further_nested, multiple_nested_a), array); - H5Tclose(array); - - array = H5Tarray_create2(H5T_STD_I32LE, 1, dims); - H5Tinsert(nest1, "nested_int", HOFFSET(further_nested, multiple_nested_b), array); - H5Tclose(array); - - array = H5Tarray_create2(H5T_STD_U64LE, 1, dims); - H5Tinsert(nest1, "nested_unsigned_long", HOFFSET(further_nested, multiple_nested_c), array); - H5Tclose(array); - - array = H5Tarray_create2(H5T_STD_I64LE, 1, dims); - H5Tinsert(nest1, "nested_long", HOFFSET(further_nested, multiple_nested_d), array); - H5Tclose(array); - - H5Tinsert(cmpd_tid2, "further_nested_compoundA", HOFFSET(multiple_nested_compound, b), nest1); - H5Tclose(nest1); - - /* Add second further nested compound */ - nest2 = H5Tcreate(H5T_COMPOUND, sizeof(further_nested2)); - - dims[0] = 1; - str_type = mkstr(11, H5T_STR_NULLTERM); - array = H5Tarray_create2(str_type, 1, dims); - H5Tinsert(nest2, "nested_string", HOFFSET(further_nested2, further_nested_string), array); - H5Tclose(array); - H5Tclose(str_type); - - dims[0] = 4; - str_type = mkstr(13, H5T_STR_NULLTERM); - array = H5Tarray_create2(str_type, 1, dims); - H5Tinsert(nest2, "nested_string_array", HOFFSET(further_nested2, further_nested_string_array), array); - H5Tclose(array); - H5Tclose(str_type); - - /* Add a final third-level nested compound to this second-level compound */ - cmpd_tid3 = H5Tcreate(H5T_COMPOUND, sizeof(third_level_compound)); - - dims[0] = 10; - array = H5Tarray_create2(H5T_STD_I16LE, 1, dims); - H5Tinsert(cmpd_tid3, "deep_nested_short", HOFFSET(third_level_compound, deep_nested_short), array); - H5Tclose(array); - - array = H5Tarray_create2(H5T_STD_I32LE, 1, dims); - H5Tinsert(cmpd_tid3, "deep_nested_int", HOFFSET(third_level_compound, deep_nested_int), array); - H5Tclose(array); - - array = H5Tarray_create2(H5T_STD_I64LE, 1, dims); - H5Tinsert(cmpd_tid3, "deep_nested_long", HOFFSET(third_level_compound, deep_nested_long), array); - H5Tclose(array); - - array = H5Tarray_create2(H5T_IEEE_F64LE, 1, dims); - H5Tinsert(cmpd_tid3, "deep_nested_double", HOFFSET(third_level_compound, deep_nested_double), array); - H5Tclose(array); - - array = H5Tarray_create2(H5T_IEEE_F32LE, 1, dims); - H5Tinsert(cmpd_tid3, "deep_nested_float", HOFFSET(third_level_compound, deep_nested_float), array); - H5Tclose(array); - - H5Tinsert(nest2, "deep_nested_compound", HOFFSET(further_nested2, deep_nest), cmpd_tid3); - - H5Tinsert(cmpd_tid2, "further_nested_compoundB", HOFFSET(multiple_nested_compound, c), nest2); - H5Tclose(nest2); - - H5Tinsert(type, "multiple_nested_compound", HOFFSET(compound, e), cmpd_tid2); - - - if ((dset = H5Dcreate2(file, F82_DATASETNAME, type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - for(i = 0; i < nelmts; i++) { - for (j = 0; j < dset_array_a_dims[0]; j++) - buf[i].a[j] = (unsigned int)(j + i*10); - for (j = 0; j < dset_array_b_dims[0]; j++) - buf[i].b[j] = (int)(j - i*10); - for (j = 0; j < dset_array_c_dims[0]; j++) - for (k = 0; k < dset_array_c_dims[1]; k++) - buf[i].c[j][k] = (float)(j + k + i*10) + (float)(j) * 0.1F; - - /* Set up first nested compound */ - buf[i].d.nested_a = (double) i; - - strcpy(buf[i].d.nested_string, "This is a test string."); - - for (j = 0; j < 4; j++) - strcpy(buf[i].d.nested_string_array[j], "String test"); - - /* Set up multiple nested compound */ - buf[i].e.a = (float) i; - - for (j = 0; j < 5; j++) { - buf[i].e.b.multiple_nested_a[j] = (unsigned int)(j + i*10); - buf[i].e.b.multiple_nested_b[j] = (int)(j - i*10); - buf[i].e.b.multiple_nested_c[j] = (unsigned long)(j + i*10); - buf[i].e.b.multiple_nested_d[j] = (long)(j - i*10); - } - - strcpy(buf[i].e.c.further_nested_string, "1234567890"); - for (j = 0; j < 4; j++) - strcpy(buf[i].e.c.further_nested_string_array[j], "STRING ARRAY"); - - for (j = 0; j < 10; j++) { - buf[i].e.c.deep_nest.deep_nested_short[j] = (short)(j + i*10); - buf[i].e.c.deep_nest.deep_nested_int[j] = (int)(j - i*10); - buf[i].e.c.deep_nest.deep_nested_long[j] = (long)(j + i*10); - buf[i].e.c.deep_nest.deep_nested_double[j] = (double)(j + i*10); - buf[i].e.c.deep_nest.deep_nested_float[j] = (float)(j + i*10); - } - } - - if (H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - fprintf(stderr, "gent_tcompound_complex2 H5Dwrite failed\n"); - - H5Dclose(dset); - } - H5Tclose(type); - } - H5Tclose(cmpd_tid1); - H5Tclose(cmpd_tid2); - H5Tclose(cmpd_tid3); - H5Sclose(space); - } - -// /* CompoundComplex2D */ -// if ((type = H5Tcreate(H5T_COMPOUND, sizeof(s_t))) >= 0) { -// H5Tinsert(type, "a", HOFFSET(s_t, a), H5T_STD_B8LE); -// H5Tinsert(type, "b", HOFFSET(s_t, b), H5T_STD_B16LE); -// H5Tinsert(type, "c", HOFFSET(s_t, c), H5T_STD_B32LE); -// H5Tinsert(type, "d", HOFFSET(s_t, d), H5T_STD_B64LE); -// if ((space = H5Screate_simple(F82_RANK2, &nelmts, NULL)) >= 0) { -// if ((dset = H5Dcreate2(file, "compound_1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { -// for(i = 0; i < nelmts; i++) { -// buf5[i].a = (unsigned char)0xff ^ (unsigned char)i; -// buf5[i].b = (unsigned int)0xffff ^ (unsigned int)(i * 16); -// buf5[i].c = (unsigned long)0xffffffff ^ (unsigned long)(i * 32); -// buf5[i].d = (unsigned long long)0xffffffffffffffff ^ (unsigned long long)(i * 64); -// } -// -// H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf5); -// H5Dclose(dset); -// } -// H5Sclose(space); -// } -// H5Tclose(type); -// } -// -// /* CompoundComplex3D */ -// if ((type = H5Tcreate(H5T_COMPOUND, sizeof(s_t))) >= 0) { -// H5Tinsert(type, "a", HOFFSET(s_t, a), H5T_STD_B8LE); -// H5Tinsert(type, "b", HOFFSET(s_t, b), H5T_STD_B16LE); -// H5Tinsert(type, "c", HOFFSET(s_t, c), H5T_STD_B32LE); -// H5Tinsert(type, "d", HOFFSET(s_t, d), H5T_STD_B64LE); -// if ((space = H5Screate_simple(F82_RANK3, &nelmts, NULL)) >= 0) { -// if ((dset = H5Dcreate2(file, "compound_1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { -// for(i = 0; i < nelmts; i++) { -// buf5[i].a = (unsigned char)0xff ^ (unsigned char)i; -// buf5[i].b = (unsigned int)0xffff ^ (unsigned int)(i * 16); -// buf5[i].c = (unsigned long)0xffffffff ^ (unsigned long)(i * 32); -// buf5[i].d = (unsigned long long)0xffffffffffffffff ^ (unsigned long long)(i * 64); -// } -// -// H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf5); -// H5Dclose(dset); -// } -// H5Sclose(space); -// } -// H5Tclose(type); -// } -// -// /* CompoundComplex4D */ -// if ((type = H5Tcreate(H5T_COMPOUND, sizeof(s_t))) >= 0) { -// H5Tinsert(type, "a", HOFFSET(s_t, a), H5T_STD_B8LE); -// H5Tinsert(type, "b", HOFFSET(s_t, b), H5T_STD_B16LE); -// H5Tinsert(type, "c", HOFFSET(s_t, c), H5T_STD_B32LE); -// H5Tinsert(type, "d", HOFFSET(s_t, d), H5T_STD_B64LE); -// if ((space = H5Screate_simple(F82_RANK4, &nelmts, NULL)) >= 0) { -// if ((dset = H5Dcreate2(file, "compound_1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { -// for(i = 0; i < nelmts; i++) { -// buf5[i].a = (unsigned char)0xff ^ (unsigned char)i; -// buf5[i].b = (unsigned int)0xffff ^ (unsigned int)(i * 16); -// buf5[i].c = (unsigned long)0xffffffff ^ (unsigned long)(i * 32); -// buf5[i].d = (unsigned long long)0xffffffffffffffff ^ (unsigned long long)(i * 64); -// } -// -// H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf5); -// H5Dclose(dset); -// } -// H5Sclose(space); -// } -// H5Tclose(type); -// } - - H5Fclose(file); - - HDfree(buf); -} - -/*------------------------------------------------------------------------- - * Function: gent_vlenstr_array - * - * Purpose: Generate a file to be used in testing Arrays of variable - * length strings. - *------------------------------------------------------------------------- - */ -static void gent_vlenstr_array(void) -{ - /* Compound datatype with different member types */ - typedef struct compound - { - /* Array of variable-length strings*/ - const char *vlen_array[F83_ARRAYDIM]; - } compound; - compound buf[F83_DIM]; - - const char *test[F83_ARRAYDIM] = { - "This is a variable-length test string.", - "This test string is also variable-length.", - "A final test of variable-length strings. This string is longer than the others." - }; - const char *buffer[F83_DIM*F83_ARRAYDIM]; - - hid_t file, type=-1, space=-1, dset=-1; - hid_t cmpd_tid1, array_tid; - int i, j; - - hsize_t dims[] = {F83_DIM}, arraydim[] = {F83_ARRAYDIM}; - /* Initialize scalar data */ - for (i = 0; i < F83_DIM; i++) - for (j = 0; j < 3; j++) - buffer[j + 3*i] = test[j]; - - /* Initialize compound data */ - for (i = 0; i < F83_DIM; i++) - for (j = 0; j < 3; j++) - buf[i].vlen_array[j] = test[j]; - - file = H5Fcreate(FILE83, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - if ((space = H5Screate_simple(F83_RANK, dims, NULL)) >= 0) { - array_tid = H5Tcopy(H5T_C_S1); - H5Tset_size(array_tid, H5T_VARIABLE); - - /* ScalarArrayOfVlenStr */ - if ((type = H5Tarray_create2(array_tid, F83_RANK, arraydim)) >= 0) { - if ((dset = H5Dcreate2(file, F83_DATASETNAME, type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - if (H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buffer) < 0) - fprintf(stderr, "gent_vlenstr_array H5Dwrite failed\n"); - - H5Dclose(dset); - } - H5Tclose(type); - } - H5Tclose(array_tid); - H5Sclose(space); - } - - if ((space = H5Screate_simple(F83_RANK, dims, NULL)) >= 0) { - /* CompoundArrayOfVlenStr */ - if ((type = H5Tcreate(H5T_COMPOUND, sizeof(compound))) >= 0) { - cmpd_tid1 = H5Tcopy(H5T_C_S1); - H5Tset_size(cmpd_tid1, H5T_VARIABLE); - - array_tid = H5Tarray_create2(cmpd_tid1, F83_RANK, arraydim); - H5Tinsert(type, "vlen_str_array", HOFFSET(compound, vlen_array), array_tid); - - if ((dset = H5Dcreate2(file, F83_DATASETNAME2, type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - if (H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - fprintf(stderr, "gent_vlenstr_array H5Dwrite failed\n"); - - H5Dclose(dset); - } - H5Tclose(cmpd_tid1); - H5Tclose(type); - } - H5Sclose(space); - } - - H5Fclose(file); -} - - -/*------------------------------------------------------------------------- - * Function: main - * - *------------------------------------------------------------------------- - */ - -int main(void) -{ - gent_group(); - gent_attribute(); - gent_softlink(); - gent_softlink2(); - gent_dataset(); - gent_hardlink(); - gent_extlink(); - gent_udlink(); - gent_compound_dt(); - gent_all(); - gent_loop(); - gent_dataset2(); - gent_compound_dt2(); - gent_loop2(); - gent_many(); - gent_str(); - gent_str2(); - gent_enum(); - gent_objref(); - gent_datareg(); - gent_attrreg(); - gent_nestcomp(); - gent_opaque(); - gent_bitfields(); - gent_vldatatypes(); - gent_vldatatypes2(); - gent_vldatatypes3(); - gent_vldatatypes4(); - gent_vldatatypes5(); - gent_array1_big(); - gent_array1(); - gent_array2(); - gent_array3(); - gent_array4(); - gent_array5(); - gent_array6(); - gent_array7(); - gent_array8(); - gent_empty(); - gent_group_comments(); - gent_split_file(); - gent_family(); - gent_multi(); - gent_large_objname(); - gent_vlstr(); - gent_vlenstr_array(); - gent_char(); - gent_attr_all(); - gent_compound_complex(); - gent_compound_complex2(); - gent_named_dtype_attr(); - gent_null_space(); - gent_zero_dim_size(); - - gent_filters(); - gent_fvalues(); - gent_fcontents(); - gent_string(); - gent_aindices(); - gent_longlinks(); - gent_ldouble(); - gent_binary(); - gent_bigdims(); - gent_hyperslab(); - gent_group_creation_order(); - gent_attr_creation_order(); - gent_fpformat(); - gent_extlinks(); - gent_fs_strategy_threshold(); - gent_packedbits(); - gent_dataset_idx(); - gent_attr_intsize(); - gent_charsets(); - gent_compound_intsizes(); - gent_compound_attr_intsizes(); - - gent_nested_compound_dt(); - gent_intscalars(); - gent_attr_intscalars(); - gent_string_scalars(); - gent_compound_int_array(); - gent_compound_ints(); - gent_intattrscalars(); - gent_intsattrs(); - gent_bitnopaquefields(); - - gent_intsfourdims(); - - return 0; -} - diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in deleted file mode 100644 index 9108f44..0000000 --- a/tools/h5dump/testh5dump.sh.in +++ /dev/null @@ -1,1345 +0,0 @@ -#! /bin/sh -# -# 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. -# -# Tests for the h5dump tool - -srcdir=@srcdir@ - -USE_FILTER_SZIP="@USE_FILTER_SZIP@" -USE_FILTER_DEFLATE="@USE_FILTER_DEFLATE@" - -TESTNAME=h5dump -EXIT_SUCCESS=0 -EXIT_FAILURE=1 - -DUMPER=h5dump # The tool name -DUMPER_BIN=`pwd`/$DUMPER # The path of the tool binary - -H5DIFF=../h5diff/h5diff # The h5diff tool name -H5DIFF_BIN=`pwd`/$H5DIFF # The path of the h5diff tool binary - -H5IMPORT=../h5import/h5import # The h5import tool name -H5IMPORT_BIN=`pwd`/$H5IMPORT # The path of the h5import tool binary - -RM='rm -rf' -CMP='cmp' -DIFF='diff -c' -CP='cp' -DIRNAME='dirname' -LS='ls' -AWK='awk' - -# Skip plugin module to test missing filter -ENVCMD="env HDF5_PLUGIN_PRELOAD=::" - -nerrors=0 -verbose=yes - -# source dirs -SRC_TOOLS="$srcdir/../" - -SRC_TOOLS_TESTFILES="$SRC_TOOLS/testfiles" -# testfiles source dirs for tools -SRC_H5LS_TESTFILES="$SRC_TOOLS_TESTFILES" -SRC_H5DUMP_TESTFILES="$SRC_TOOLS_TESTFILES" -SRC_H5DUMP_ERRORFILES="$srcdir/errfiles" -SRC_H5DIFF_TESTFILES="$SRC_TOOLS/h5diff/testfiles" -SRC_H5COPY_TESTFILES="$SRC_TOOLS/h5copy/testfiles" -SRC_H5REPACK_TESTFILES="$SRC_TOOLS/h5repack/testfiles" -SRC_H5JAM_TESTFILES="$SRC_TOOLS/h5jam/testfiles" -SRC_H5STAT_TESTFILES="$SRC_TOOLS/h5stat/testfiles" -SRC_H5IMPORT_TESTFILES="$SRC_TOOLS/h5import/testfiles" - -TEST_P_DIR=./testfiles -TESTDIR=./testfiles/std -test -d $TEST_P_DIR || mkdir -p $TEST_P_DIR -test -d $TESTDIR || mkdir -p $TESTDIR - -###################################################################### -# test files -# -------------------------------------------------------------------- -# All the test files copy from source directory to test directory -# NOTE: Keep this framework to add/remove test files. -# Any test files from other tools can be used in this framework. -# This list are also used for checking exist. -# Comment '#' without space can be used. -# -------------------------------------------------------------------- -LIST_HDF5_TEST_FILES=" -$SRC_H5DUMP_TESTFILES/charsets.h5 -$SRC_H5DUMP_TESTFILES/file_space.h5 -$SRC_H5DUMP_TESTFILES/filter_fail.h5 -$SRC_H5DUMP_TESTFILES/packedbits.h5 -$SRC_H5DUMP_TESTFILES/taindices.h5 -$SRC_H5DUMP_TESTFILES/tall.h5 -$SRC_H5DUMP_TESTFILES/tarray1.h5 -$SRC_H5DUMP_TESTFILES/tarray1_big.h5 -$SRC_H5DUMP_TESTFILES/tarray2.h5 -$SRC_H5DUMP_TESTFILES/tarray3.h5 -$SRC_H5DUMP_TESTFILES/tarray4.h5 -$SRC_H5DUMP_TESTFILES/tarray5.h5 -$SRC_H5DUMP_TESTFILES/tarray6.h5 -$SRC_H5DUMP_TESTFILES/tarray7.h5 -$SRC_H5DUMP_TESTFILES/tarray8.h5 -$SRC_H5DUMP_TESTFILES/tattr.h5 -$SRC_H5DUMP_TESTFILES/tattr2.h5 -$SRC_H5DUMP_TESTFILES/tattr4_be.h5 -$SRC_H5DUMP_TESTFILES/tattrintsize.h5 -$SRC_H5DUMP_TESTFILES/tattrreg.h5 -$SRC_H5DUMP_TESTFILES/tbigdims.h5 -$SRC_H5DUMP_TESTFILES/tbinary.h5 -$SRC_H5DUMP_TESTFILES/tchar.h5 -$SRC_H5DUMP_TESTFILES/tcmpdattrintsize.h5 -$SRC_H5DUMP_TESTFILES/tcmpdintsize.h5 -$SRC_H5DUMP_TESTFILES/tcompound.h5 -$SRC_H5DUMP_TESTFILES/tcompound_complex.h5 -$SRC_H5DUMP_TESTFILES/tcompound_complex2.h5 -$SRC_H5DUMP_TESTFILES/tdatareg.h5 -$SRC_H5DUMP_TESTFILES/tdset.h5 -$SRC_H5DUMP_TESTFILES/tempty.h5 -$SRC_H5DUMP_TESTFILES/tsoftlinks.h5 -$SRC_H5DUMP_TESTFILES/textlinkfar.h5 -$SRC_H5DUMP_TESTFILES/textlinksrc.h5 -$SRC_H5DUMP_TESTFILES/textlinktar.h5 -$SRC_H5DUMP_TESTFILES/textlink.h5 -$SRC_H5DUMP_TESTFILES/tfamily00000.h5 -$SRC_H5DUMP_TESTFILES/tfamily00001.h5 -$SRC_H5DUMP_TESTFILES/tfamily00002.h5 -$SRC_H5DUMP_TESTFILES/tfamily00003.h5 -$SRC_H5DUMP_TESTFILES/tfamily00004.h5 -$SRC_H5DUMP_TESTFILES/tfamily00005.h5 -$SRC_H5DUMP_TESTFILES/tfamily00006.h5 -$SRC_H5DUMP_TESTFILES/tfamily00007.h5 -$SRC_H5DUMP_TESTFILES/tfamily00008.h5 -$SRC_H5DUMP_TESTFILES/tfamily00009.h5 -$SRC_H5DUMP_TESTFILES/tfamily00010.h5 -$SRC_H5DUMP_TESTFILES/tfcontents1.h5 -$SRC_H5DUMP_TESTFILES/tfcontents2.h5 -$SRC_H5DUMP_TESTFILES/tfilters.h5 -$SRC_H5DUMP_TESTFILES/tfpformat.h5 -$SRC_H5DUMP_TESTFILES/tfvalues.h5 -$SRC_H5DUMP_TESTFILES/tgroup.h5 -$SRC_H5DUMP_TESTFILES/tgrp_comments.h5 -$SRC_H5DUMP_TESTFILES/thlink.h5 -$SRC_H5DUMP_TESTFILES/thyperslab.h5 -$SRC_H5DUMP_TESTFILES/tintsattrs.h5 -$SRC_H5DUMP_TESTFILES/tints4dims.h5 -$SRC_H5DUMP_TESTFILES/tlarge_objname.h5 -#$SRC_H5DUMP_TESTFILES/tldouble.h5 -$SRC_H5DUMP_TESTFILES/tlonglinks.h5 -$SRC_H5DUMP_TESTFILES/tloop.h5 -$SRC_H5DUMP_TESTFILES/tmulti-b.h5 -$SRC_H5DUMP_TESTFILES/tmulti-g.h5 -$SRC_H5DUMP_TESTFILES/tmulti-l.h5 -$SRC_H5DUMP_TESTFILES/tmulti-o.h5 -$SRC_H5DUMP_TESTFILES/tmulti-r.h5 -$SRC_H5DUMP_TESTFILES/tmulti-s.h5 -$SRC_H5DUMP_TESTFILES/tnamed_dtype_attr.h5 -$SRC_H5DUMP_TESTFILES/tnestedcomp.h5 -$SRC_H5DUMP_TESTFILES/tnestedcmpddt.h5 -$SRC_H5DUMP_TESTFILES/tno-subset.h5 -$SRC_H5DUMP_TESTFILES/tnullspace.h5 -$SRC_H5DUMP_TESTFILES/zerodim.h5 -$SRC_H5DUMP_TESTFILES/torderattr.h5 -$SRC_H5DUMP_TESTFILES/tordergr.h5 -$SRC_H5DUMP_TESTFILES/tsaf.h5 -$SRC_H5DUMP_TESTFILES/tscalarattrintsize.h5 -$SRC_H5DUMP_TESTFILES/tscalarintattrsize.h5 -$SRC_H5DUMP_TESTFILES/tscalarintsize.h5 -$SRC_H5DUMP_TESTFILES/tscalarstring.h5 -$SRC_H5DUMP_TESTFILES/tslink.h5 -$SRC_H5DUMP_TESTFILES/tsplit_file-m.h5 -$SRC_H5DUMP_TESTFILES/tsplit_file-r.h5 -$SRC_H5DUMP_TESTFILES/tstr.h5 -$SRC_H5DUMP_TESTFILES/tstr2.h5 -$SRC_H5DUMP_TESTFILES/tstr3.h5 -$SRC_H5DUMP_TESTFILES/tudlink.h5 -$SRC_H5DUMP_TESTFILES/tvldtypes1.h5 -$SRC_H5DUMP_TESTFILES/tvldtypes2.h5 -$SRC_H5DUMP_TESTFILES/tvldtypes3.h5 -$SRC_H5DUMP_TESTFILES/tvldtypes4.h5 -$SRC_H5DUMP_TESTFILES/tvldtypes5.h5 -$SRC_H5DUMP_TESTFILES/tvlenstr_array.h5 -$SRC_H5DUMP_TESTFILES/tvlstr.h5 -$SRC_H5DUMP_TESTFILES/tvms.h5 -" - -LIST_OTHER_TEST_FILES=" -$SRC_H5DUMP_TESTFILES/charsets.ddl -$SRC_H5DUMP_TESTFILES/file_space.ddl -$SRC_H5DUMP_TESTFILES/filter_fail.ddl -$SRC_H5DUMP_TESTFILES/non_existing.ddl -$SRC_H5DUMP_TESTFILES/packedbits.ddl -$SRC_H5DUMP_TESTFILES/tall-1.ddl -$SRC_H5DUMP_TESTFILES/tall-2.ddl -$SRC_H5DUMP_TESTFILES/tall-2A.ddl -$SRC_H5DUMP_TESTFILES/tall-2A0.ddl -$SRC_H5DUMP_TESTFILES/tall-2B.ddl -$SRC_H5DUMP_TESTFILES/tall-3.ddl -$SRC_H5DUMP_TESTFILES/tall-4s.ddl -$SRC_H5DUMP_TESTFILES/tall-5s.ddl -$SRC_H5DUMP_TESTFILES/tall-6.ddl -$SRC_H5DUMP_TESTFILES/tall-6.exp -$SRC_H5DUMP_TESTFILES/tall-7.ddl -$SRC_H5DUMP_TESTFILES/tall-7N.ddl -$SRC_H5DUMP_TESTFILES/tallfilters.ddl -$SRC_H5DUMP_TESTFILES/tarray1.ddl -$SRC_H5DUMP_TESTFILES/tarray1_big.ddl -$SRC_H5DUMP_TESTFILES/tarray2.ddl -$SRC_H5DUMP_TESTFILES/tarray3.ddl -$SRC_H5DUMP_TESTFILES/tarray4.ddl -$SRC_H5DUMP_TESTFILES/tarray5.ddl -$SRC_H5DUMP_TESTFILES/tarray6.ddl -$SRC_H5DUMP_TESTFILES/tarray7.ddl -$SRC_H5DUMP_TESTFILES/tarray8.ddl -$SRC_H5DUMP_TESTFILES/tattr-1.ddl -$SRC_H5DUMP_TESTFILES/tattr-2.ddl -$SRC_H5DUMP_TESTFILES/tattr-3.ddl -$SRC_H5DUMP_TESTFILES/tattr-4_be.ddl -$SRC_H5DUMP_TESTFILES/tattrcontents1.ddl -$SRC_H5DUMP_TESTFILES/tattrcontents2.ddl -$SRC_H5DUMP_TESTFILES/tattrintsize.ddl -$SRC_H5DUMP_TESTFILES/tattrreg.ddl -$SRC_H5DUMP_TESTFILES/tattrregR.ddl -$SRC_H5DUMP_TESTFILES/tbin1.ddl -$SRC_H5DUMP_TESTFILES/tbin1.ddl -$SRC_H5DUMP_TESTFILES/tbin2.ddl -$SRC_H5DUMP_TESTFILES/tbin3.ddl -$SRC_H5DUMP_TESTFILES/tbin4.ddl -$SRC_H5DUMP_TESTFILES/tbinregR.ddl -$SRC_H5DUMP_TESTFILES/tbigdims.ddl -$SRC_H5DUMP_TESTFILES/tboot1.ddl -$SRC_H5DUMP_TESTFILES/tboot2.ddl -$SRC_H5DUMP_TESTFILES/tboot2A.ddl -$SRC_H5DUMP_TESTFILES/tboot2B.ddl -$SRC_H5DUMP_TESTFILES/tchar1.ddl -$SRC_H5DUMP_TESTFILES/tchunked.ddl -$SRC_H5DUMP_TESTFILES/tcmpdattrintsize.ddl -$SRC_H5DUMP_TESTFILES/tcmpdintsize.ddl -$SRC_H5DUMP_TESTFILES/tcomp-1.ddl -$SRC_H5DUMP_TESTFILES/tcomp-2.ddl -$SRC_H5DUMP_TESTFILES/tcomp-3.ddl -$SRC_H5DUMP_TESTFILES/tcomp-4.ddl -$SRC_H5DUMP_TESTFILES/tcompound_complex2.ddl -$SRC_H5DUMP_TESTFILES/tcompact.ddl -$SRC_H5DUMP_TESTFILES/tcontents.ddl -$SRC_H5DUMP_TESTFILES/tcontiguos.ddl -$SRC_H5DUMP_TESTFILES/tdatareg.ddl -$SRC_H5DUMP_TESTFILES/tdataregR.ddl -$SRC_H5DUMP_TESTFILES/tdeflate.ddl -$SRC_H5DUMP_TESTFILES/tdset-1.ddl -$SRC_H5DUMP_TESTFILES/tdset-2.ddl -$SRC_H5DUMP_TESTFILES/tdset-3s.ddl -$SRC_H5DUMP_TESTFILES/tempty.ddl -$SRC_H5DUMP_TESTFILES/texceedsubstart.ddl -$SRC_H5DUMP_TESTFILES/texceedsubcount.ddl -$SRC_H5DUMP_TESTFILES/texceedsubstride.ddl -$SRC_H5DUMP_TESTFILES/texceedsubblock.ddl -$SRC_H5DUMP_TESTFILES/texternal.ddl -$SRC_H5DUMP_TESTFILES/textlinksrc.ddl -$SRC_H5DUMP_TESTFILES/textlinkfar.ddl -$SRC_H5DUMP_TESTFILES/textlink.ddl -$SRC_H5DUMP_TESTFILES/tfamily.ddl -$SRC_H5DUMP_TESTFILES/tfill.ddl -$SRC_H5DUMP_TESTFILES/tfletcher32.ddl -$SRC_H5DUMP_TESTFILES/tfpformat.ddl -$SRC_H5DUMP_TESTFILES/tgroup-1.ddl -$SRC_H5DUMP_TESTFILES/tgroup-2.ddl -$SRC_H5DUMP_TESTFILES/tgrp_comments.ddl -$SRC_H5DUMP_TESTFILES/thlink-1.ddl -$SRC_H5DUMP_TESTFILES/thlink-2.ddl -$SRC_H5DUMP_TESTFILES/thlink-3.ddl -$SRC_H5DUMP_TESTFILES/thlink-4.ddl -$SRC_H5DUMP_TESTFILES/thlink-5.ddl -$SRC_H5DUMP_TESTFILES/thyperslab.ddl -$SRC_H5DUMP_TESTFILES/tindicesno.ddl -$SRC_H5DUMP_TESTFILES/tindicessub1.ddl -$SRC_H5DUMP_TESTFILES/tindicessub2.ddl -$SRC_H5DUMP_TESTFILES/tindicessub3.ddl -$SRC_H5DUMP_TESTFILES/tindicessub4.ddl -$SRC_H5DUMP_TESTFILES/tindicesyes.ddl -$SRC_H5DUMP_TESTFILES/tints4dims.ddl -$SRC_H5DUMP_TESTFILES/tints4dimsBlock2.ddl -$SRC_H5DUMP_TESTFILES/tints4dimsBlockEq.ddl -$SRC_H5DUMP_TESTFILES/tints4dimsCount2.ddl -$SRC_H5DUMP_TESTFILES/tints4dimsCountEq.ddl -$SRC_H5DUMP_TESTFILES/tints4dimsStride2.ddl -$SRC_H5DUMP_TESTFILES/tintsattrs.ddl -$SRC_H5DUMP_TESTFILES/tlarge_objname.ddl -#$SRC_H5DUMP_TESTFILES/tldouble.ddl -$SRC_H5DUMP_TESTFILES/tlonglinks.ddl -$SRC_H5DUMP_TESTFILES/tloop-1.ddl -$SRC_H5DUMP_TESTFILES/tmulti.ddl -$SRC_H5DUMP_TESTFILES/tmultifile.ddl -$SRC_H5DUMP_TESTFILES/tqmarkfile.ddl -$SRC_H5DUMP_TESTFILES/tstarfile.ddl -$SRC_H5DUMP_TESTFILES/tnamed_dtype_attr.ddl -$SRC_H5DUMP_TESTFILES/tnestcomp-1.ddl -$SRC_H5DUMP_TESTFILES/tnestedcmpddt.ddl -$SRC_H5DUMP_TESTFILES/tnbit.ddl -$SRC_H5DUMP_TESTFILES/tnoattrdata.ddl -$SRC_H5DUMP_TESTFILES/tnoattrddl.ddl -$SRC_H5DUMP_TESTFILES/tnodata.ddl -$SRC_H5DUMP_TESTFILES/tnoddl.ddl -$SRC_H5DUMP_TESTFILES/tnoddlfile.ddl -$SRC_H5DUMP_TESTFILES/tnoddlfile.exp -$SRC_H5DUMP_TESTFILES/tno-subset.ddl -$SRC_H5DUMP_TESTFILES/tnullspace.ddl -$SRC_H5DUMP_TESTFILES/trawdatafile.ddl -$SRC_H5DUMP_TESTFILES/trawdatafile.exp -$SRC_H5DUMP_TESTFILES/trawssetfile.ddl -$SRC_H5DUMP_TESTFILES/trawssetfile.exp -$SRC_H5DUMP_TESTFILES/zerodim.ddl -$SRC_H5DUMP_TESTFILES/tordergr1.ddl -$SRC_H5DUMP_TESTFILES/tordergr2.ddl -$SRC_H5DUMP_TESTFILES/tordergr3.ddl -$SRC_H5DUMP_TESTFILES/tordergr4.ddl -$SRC_H5DUMP_TESTFILES/tordergr5.ddl -$SRC_H5DUMP_TESTFILES/torderattr1.ddl -$SRC_H5DUMP_TESTFILES/torderattr2.ddl -$SRC_H5DUMP_TESTFILES/torderattr3.ddl -$SRC_H5DUMP_TESTFILES/torderattr4.ddl -$SRC_H5DUMP_TESTFILES/tordercontents1.ddl -$SRC_H5DUMP_TESTFILES/tordercontents2.ddl -$SRC_H5DUMP_TESTFILES/torderlinks1.ddl -$SRC_H5DUMP_TESTFILES/torderlinks2.ddl -$SRC_H5DUMP_TESTFILES/tperror.ddl -$SRC_H5DUMP_TESTFILES/treadfilter.ddl -$SRC_H5DUMP_TESTFILES/treadintfilter.ddl -$SRC_H5DUMP_TESTFILES/treference.ddl -$SRC_H5DUMP_TESTFILES/tsaf.ddl -$SRC_H5DUMP_TESTFILES/tscalarattrintsize.ddl -$SRC_H5DUMP_TESTFILES/tscalarintattrsize.ddl -$SRC_H5DUMP_TESTFILES/tscalarintsize.ddl -$SRC_H5DUMP_TESTFILES/tscalarstring.ddl -$SRC_H5DUMP_TESTFILES/tscaleoffset.ddl -$SRC_H5DUMP_TESTFILES/tshuffle.ddl -$SRC_H5DUMP_TESTFILES/tslink-1.ddl -$SRC_H5DUMP_TESTFILES/tslink-2.ddl -$SRC_H5DUMP_TESTFILES/tslink-D.ddl -$SRC_H5DUMP_TESTFILES/tsplit_file.ddl -$SRC_H5DUMP_TESTFILES/tstr-1.ddl -$SRC_H5DUMP_TESTFILES/tstr-2.ddl -$SRC_H5DUMP_TESTFILES/tstr2bin2.exp -$SRC_H5DUMP_TESTFILES/tstr2bin6.exp -$SRC_H5DUMP_TESTFILES/tstring.ddl -$SRC_H5DUMP_TESTFILES/tstring2.ddl -$SRC_H5DUMP_TESTFILES/tstringe.ddl -$SRC_H5DUMP_TESTFILES/tszip.ddl -$SRC_H5DUMP_TESTFILES/tudlink-1.ddl -$SRC_H5DUMP_TESTFILES/tudlink-2.ddl -$SRC_H5DUMP_TESTFILES/tuserfilter.ddl -$SRC_H5DUMP_TESTFILES/tvldtypes1.ddl -$SRC_H5DUMP_TESTFILES/tvldtypes2.ddl -$SRC_H5DUMP_TESTFILES/tvldtypes3.ddl -$SRC_H5DUMP_TESTFILES/tvldtypes4.ddl -$SRC_H5DUMP_TESTFILES/tvldtypes5.ddl -$SRC_H5DUMP_TESTFILES/tvlenstr_array.ddl -$SRC_H5DUMP_TESTFILES/tvlstr.ddl -$SRC_H5DUMP_TESTFILES/tvms.ddl -$SRC_H5DUMP_TESTFILES/twidedisplay.ddl -$SRC_H5DUMP_TESTFILES/twithddl.exp -$SRC_H5DUMP_TESTFILES/twithddlfile.ddl -$SRC_H5DUMP_TESTFILES/twithddlfile.exp -$SRC_H5DUMP_TESTFILES/h5dump-help.txt -$SRC_H5DUMP_TESTFILES/out3.h5import -$SRC_H5DUMP_TESTFILES/tbinregR.exp -" - -LIST_ERROR_TEST_FILES=" -${SRC_H5DUMP_ERRORFILES}/filter_fail.err -${SRC_H5DUMP_ERRORFILES}/non_existing.err -${SRC_H5DUMP_ERRORFILES}/tall-1.err -${SRC_H5DUMP_ERRORFILES}/tall-2A.err -${SRC_H5DUMP_ERRORFILES}/tall-2A0.err -${SRC_H5DUMP_ERRORFILES}/tall-2B.err -${SRC_H5DUMP_ERRORFILES}/tarray1_big.err -${SRC_H5DUMP_ERRORFILES}/tattr-3.err -${SRC_H5DUMP_ERRORFILES}/tattrregR.err -${SRC_H5DUMP_ERRORFILES}/tcomp-3.err -${SRC_H5DUMP_ERRORFILES}/tdataregR.err -${SRC_H5DUMP_ERRORFILES}/tdset-2.err -${SRC_H5DUMP_ERRORFILES}/texceedsubblock.err -${SRC_H5DUMP_ERRORFILES}/texceedsubcount.err -${SRC_H5DUMP_ERRORFILES}/texceedsubstart.err -${SRC_H5DUMP_ERRORFILES}/texceedsubstride.err -${SRC_H5DUMP_ERRORFILES}/textlink.err -${SRC_H5DUMP_ERRORFILES}/textlinkfar.err -${SRC_H5DUMP_ERRORFILES}/textlinksrc.err -${SRC_H5DUMP_ERRORFILES}/tgroup-2.err -${SRC_H5DUMP_ERRORFILES}/torderlinks1.err -${SRC_H5DUMP_ERRORFILES}/torderlinks2.err -${SRC_H5DUMP_ERRORFILES}/tperror.err -${SRC_H5DUMP_ERRORFILES}/tqmarkfile.err -${SRC_H5DUMP_ERRORFILES}/tslink-D.err -" - -# -# copy test files and expected output files from source dirs to test dir -# -COPY_TESTFILES="$LIST_HDF5_TEST_FILES $LIST_OTHER_TEST_FILES $LIST_ERROR_TEST_FILES" - -COPY_TESTFILES_TO_TESTDIR() -{ - # copy test files. Used -f to make sure get a new copy - for tstfile in $COPY_TESTFILES - do - # ignore '#' comment - echo $tstfile | tr -d ' ' | grep '^#' > /dev/null - RET=$? - if [ $RET -eq 1 ]; then - # skip cp if srcdir is same as destdir - # this occurs when build/test performed in source dir and - # make cp fail - SDIR=`$DIRNAME $tstfile` - INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'` - INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'` - if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then - $CP -f $tstfile $TESTDIR - if [ $? -ne 0 ]; then - echo "Error: FAILED to copy $tstfile ." - - # Comment out this to CREATE expected file - exit $EXIT_FAILURE - fi - fi - fi - done -} - -CLEAN_TESTFILES_AND_TESTDIR() -{ - # skip rm if srcdir is same as destdir - # this occurs when build/test performed in source dir and - # make cp fail - SDIR=$SRC_H5DUMP_TESTFILES - INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'` - INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'` - if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then - $RM $TESTDIR - fi -} - -# Print a line-line message left justified in a field of 70 characters -# beginning with the word "Testing". -# -TESTING() { - SPACES=" " - echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012' -} - -# Source in the output filter function definitions. -. $srcdir/../../bin/output_filter.sh - -# Run a test and print PASS or *FAIL*. If a test fails then increment -# the `nerrors' global variable and (if $verbose is set) display the -# difference between the actual output and the expected output. The -# expected output is given as the first argument to this function and -# the actual output file is calculated by replacing the `.ddl' with -# `.out'. The actual output is not removed if $HDF5_NOCLEANUP has a -# non-zero value. -# If $1 == ignorecase then do caseless CMP and DIFF. -# ADD_H5_TEST -TOOLTEST() { - # check if caseless compare and diff requested - if [ "$1" = ignorecase ]; then - caseless="-i" - # replace cmp with diff which runs much longer. - xCMP="$DIFF -i" - shift - else - caseless="" - # stick with faster cmp if ignorecase is not requested. - xCMP="$CMP" - fi - - expect="$TESTDIR/$1" - actual="$TESTDIR/`basename $1 .ddl`.out" - actual_err="$TESTDIR/`basename $1 .ddl`.err" - actual_sav=${actual}-sav - actual_err_sav=${actual_err}-sav - shift - - # Run test. - TESTING $DUMPER $@ - ( - cd $TESTDIR - $RUNSERIAL $DUMPER_BIN "$@" - ) >$actual 2>$actual_err - - # save actual and actual_err in case they are needed later. - cp $actual $actual_sav - STDOUT_FILTER $actual - cp $actual_err $actual_err_sav - STDERR_FILTER $actual_err - cat $actual_err >> $actual - - if [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect - elif $xCMP $expect $actual > /dev/null 2>&1 ; then - echo " PASSED" - else - echo "*FAILED*" - echo " Expected result (*.ddl) differs from actual result (*.out)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $caseless $expect $actual |sed 's/^/ /' - fi - - # Clean up output file - if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actual_err $actual_sav $actual_err_sav $actual_ext - fi - -} - - -# same as TOOLTEST1 but compares generated file to expected output -# and compares the generated data file to the expected data file -# used for the binary tests that expect a full path in -o without -b -# ADD_H5_EXPORT_TEST -TOOLTEST2() { - - expectdata="$TESTDIR/$1" - expect="$TESTDIR/`basename $1 .exp`.ddl" - actualdata="$TESTDIR/`basename $1 .exp`.txt" - actual="$TESTDIR/`basename $1 .exp`.out" - actual_err="$TESTDIR/`basename $1 .exp`.err" - shift - - # Run test. - TESTING $DUMPER $@ - ( - cd $TESTDIR - $RUNSERIAL $DUMPER_BIN "$@" - ) >$actual 2>$actual_err - cat $actual_err >> $actual - - if [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect - elif $CMP $expect $actual; then - if [ ! -f $expectdata ]; then - # Create the expect data file if it doesn't yet exist. - echo " CREATED" - cp $actualdata $expectdata - elif $CMP $expectdata $actualdata; then - echo " PASSED" - else - echo "*FAILED*" - echo " Expected datafile (*.exp) differs from actual datafile (*.txt)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expectdata $actualdata |sed 's/^/ /' - fi - else - echo "*FAILED*" - echo " Expected result (*.ddl) differs from actual result (*.out)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' - fi - - # Clean up output file - if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actualdata $actual_err - fi - -} - -# same as TOOLTEST2 but compares generated file to expected ddl file -# and compares the generated data file to the expected data file -# used for the binary tests that expect a full path in -o without -b -# ADD_H5_TEST_EXPORT -TOOLTEST2A() { - - expectdata="$TESTDIR/$1" - expect="$TESTDIR/`basename $1 .exp`.ddl" - actualdata="$TESTDIR/`basename $1 .exp`.txt" - actual="$TESTDIR/`basename $1 .exp`.out" - actual_err="$TESTDIR/`basename $1 .exp`.err" - shift - expectmeta="$TESTDIR/$1" - actualmeta="$TESTDIR/`basename $1 .exp`.txt" - shift - - # Run test. - TESTING $DUMPER $@ - ( - cd $TESTDIR - $RUNSERIAL $DUMPER_BIN "$@" - ) >$actual 2>$actual_err - cat $actual_err >> $actual - - if [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect - elif $CMP $expect $actual; then - if [ ! -f $expectdata ]; then - # Create the expect data file if it doesn't yet exist. - echo " CREATED" - cp $actualdata $expectdata - elif $DIFF $expectdata $actualdata; then - if [ ! -f $expectmeta ]; then - # Create the expect meta file if it doesn't yet exist. - echo " CREATED" - cp $actualmeta $expectmeta - elif $CMP $expectmeta $actualmeta; then - echo " PASSED" - else - echo "*FAILED*" - echo " Expected metafile (*.ddl) differs from actual metafile (*.txt)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expectmeta $actualmeta |sed 's/^/ /' - fi - else - echo "*FAILED*" - echo " Expected datafile (*.exp) differs from actual datafile (*.txt)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expectdata $actualdata |sed 's/^/ /' - fi - else - echo "*FAILED*" - echo " Expected result (*.ddl) differs from actual result (*.out)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' - fi - - # Clean up output file - if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actualdata $actual_err $actualmeta - fi - -} - -# same as TOOLTEST2 but only compares the generated data file to the expected data file -# used for the binary tests that expect a full path in -o with -b -# ADD_H5_EXPORT_TEST -TOOLTEST2B() { - - expectdata="$TESTDIR/$1" - actualdata="$TESTDIR/`basename $1 .exp`.txt" - actual="$TESTDIR/`basename $1 .exp`.out" - actual_err="$TESTDIR/`basename $1 .exp`.err" - shift - - # Run test. - TESTING $DUMPER $@ - ( - cd $TESTDIR - $RUNSERIAL $DUMPER_BIN "$@" - ) >$actual 2>$actual_err - cat $actual_err >> $actual - - if [ ! -f $expectdata ]; then - # Create the expect data file if it doesn't yet exist. - echo " CREATED" - cp $actualdata $expectdata - elif $CMP $expectdata $actualdata; then - echo " PASSED" - else - echo "*FAILED*" - echo " Expected datafile (*.exp) differs from actual datafile (*.txt)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expectdata $actualdata |sed 's/^/ /' - fi - - # Clean up output file - if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actualdata $actual_err - fi - -} - -# same as TOOLTEST but filters error stack outp -# Extract file name, line number, version and thread IDs because they may be different -TOOLTEST3() { - - expect="$TESTDIR/$1" - actual="$TESTDIR/`basename $1 .ddl`.out" - actual_err="$TESTDIR/`basename $1 .ddl`.err" - actual_ext="$TESTDIR/`basename $1 .ddl`.ext" - actual_sav=${actual}-sav - actual_err_sav=${actual_err}-sav - shift - - # Run test. - TESTING $DUMPER $@ - ( - cd $TESTDIR - $RUNSERIAL $DUMPER_BIN "$@" - ) >$actual 2>$actual_err - - # save actual and actual_err in case they are needed later. - cp $actual $actual_sav - STDOUT_FILTER $actual - cp $actual_err $actual_err_sav - STDERR_FILTER $actual_err - - # Extract file name, line number, version and thread IDs because they may be different - sed -e 's/thread [0-9]*/thread (IDs)/' -e 's/: .*\.c /: (file name) /' \ - -e 's/line [0-9]*/line (number)/' \ - -e 's/v[1-9]*\.[0-9]*\./version (number)\./' \ - -e 's/[1-9]*\.[0-9]*\.[0-9]*[^)]*/version (number)/' \ - -e 's/H5Eget_auto[1-2]*/H5Eget_auto(1 or 2)/' \ - -e 's/H5Eset_auto[1-2]*/H5Eset_auto(1 or 2)/' \ - $actual_err > $actual_ext - cat $actual_ext >> $actual - - if [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect - elif $CMP $expect $actual; then - echo " PASSED" - else - echo "*FAILED*" - echo " Expected result (*.ddl) differs from actual result (*.out)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' - fi - - # Clean up output file - if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actual_err $actual_sav $actual_err_sav - fi - -} - -# same as TOOLTEST3 but filters error stack output and compares to an error file -# Extract file name, line number, version and thread IDs because they may be different -# ADD_H5ERR_MASK_TEST -TOOLTEST4() { - - expect="$TESTDIR/$1" - expect_err="$TESTDIR/`basename $1 .ddl`.err" - actual="$TESTDIR/`basename $1 .ddl`.out" - actual_err="$TESTDIR/`basename $1 .ddl`.oerr" - actual_ext="$TESTDIR/`basename $1 .ddl`.ext" - actual_sav=${actual}-sav - actual_err_sav=${actual_err}-sav - shift - - # Run test. - TESTING $DUMPER $@ - ( - cd $TESTDIR - $RUNSERIAL $DUMPER_BIN "$@" - ) >$actual 2>$actual_err - - # save actual and actual_err in case they are needed later. - cp $actual $actual_sav - STDOUT_FILTER $actual - cp $actual_err $actual_err_sav - STDERR_FILTER $actual_err - - # Extract file name, line number, version and thread IDs because they may be different - sed -e 's/thread [0-9]*/thread (IDs)/' -e 's/: .*\.c /: (file name) /' \ - -e 's/line [0-9]*/line (number)/' \ - -e 's/v[1-9]*\.[0-9]*\./version (number)\./' \ - -e 's/[1-9]*\.[0-9]*\.[0-9]*[^)]*/version (number)/' \ - -e 's/H5Eget_auto[1-2]*/H5Eget_auto(1 or 2)/' \ - -e 's/H5Eset_auto[1-2]*/H5Eset_auto(1 or 2)/' \ - $actual_err > $actual_ext - #cat $actual_ext >> $actual - - if [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect - elif $CMP $expect $actual; then - if $CMP $expect_err $actual_ext; then - echo " PASSED" - else - echo "*FAILED*" - echo " Expected result (*.err) differs from actual result (*.oerr)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect_err $actual_ext |sed 's/^/ /' - fi - else - echo "*FAILED*" - echo " Expected result (*.ddl) differs from actual result (*.out)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' - fi - - # Clean up output file - if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actual_err $actual_sav $actual_err_sav - fi - -} - -# same as TOOLTEST4 but disables plugin filter loading -# silences extra error output on some platforms -# ADD_H5ERR_MASK_TEST -TOOLTEST5() { - - expect="$TESTDIR/$1" - expect_err="$TESTDIR/`basename $1 .ddl`.err" - actual="$TESTDIR/`basename $1 .ddl`.out" - actual_err="$TESTDIR/`basename $1 .ddl`.oerr" - actual_ext="$TESTDIR/`basename $1 .ddl`.ext" - actual_sav=${actual}-sav - actual_err_sav=${actual_err}-sav - shift - - # Run test. - TESTING $DUMPER $@ - ( - cd $TESTDIR - $ENVCMD $RUNSERIAL $DUMPER_BIN "$@" - ) >$actual 2>$actual_err - - # save actual and actual_err in case they are needed later. - cp $actual $actual_sav - STDOUT_FILTER $actual - cp $actual_err $actual_err_sav - STDERR_FILTER $actual_err - - # Extract file name, line number, version and thread IDs because they may be different - sed -e 's/thread [0-9]*/thread (IDs)/' -e 's/: .*\.c /: (file name) /' \ - -e 's/line [0-9]*/line (number)/' \ - -e 's/v[1-9]*\.[0-9]*\./version (number)\./' \ - -e 's/[1-9]*\.[0-9]*\.[0-9]*[^)]*/version (number)/' \ - -e 's/H5Eget_auto[1-2]*/H5Eget_auto(1 or 2)/' \ - -e 's/H5Eset_auto[1-2]*/H5Eset_auto(1 or 2)/' \ - $actual_err > $actual_ext - #cat $actual_ext >> $actual - - if [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect - elif $CMP $expect $actual; then - if $CMP $expect_err $actual_ext; then - echo " PASSED" - else - echo "*FAILED*" - echo " Expected result (*.err) differs from actual result (*.oerr)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect_err $actual_ext |sed 's/^/ /' - fi - else - echo "*FAILED*" - echo " Expected result (*.ddl) differs from actual result (*.out)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' - fi - - # Clean up output file - if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actual_err $actual_sav $actual_err_sav - fi - -} -# ADD_HELP_TEST -TOOLTEST_HELP() { - - expect="$TESTDIR/$1" - actual="$TESTDIR/`basename $1 .txt`.out" - actual_err="$TESTDIR/`basename $1 .txt`.err" - shift - - # Run test. - TESTING $DUMPER $@ - ( - cd $TESTDIR - $RUNSERIAL $DUMPER_BIN "$@" - ) >$actual 2>$actual_err - cat $actual_err >> $actual - - if [ ! -f $expectdata ]; then - # Create the expect data file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect-CREATED - elif $CMP $expect $actual; then - echo " PASSED" - else - echo "*FAILED*" - echo " Expected output (*.txt) differs from actual output (*.out)" - nerrors="`expr $nerrors + 1`" - fi - - # Clean up output file - if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actual_err - fi - -} - -# Print a "SKIP" message -SKIP() { - TESTING $DUMPER $@ - echo " -SKIP-" -} - -# Print a line-line message left justified in a field of 70 characters -# -PRINT_H5DIFF() { - SPACES=" " - echo " Running h5diff $* $SPACES" | cut -c1-70 | tr -d '\012' -} - - -# Call the h5diff tool -# -DIFFTEST() -{ - PRINT_H5DIFF $@ - ( - cd $TESTDIR - $RUNSERIAL $H5DIFF_BIN "$@" -q - ) - RET=$? - if [ $RET != 0 ] ; then - echo "*FAILED*" - nerrors="`expr $nerrors + 1`" - else - echo " PASSED" - fi - -} - -# Print a line-line message left justified in a field of 70 characters -# beginning with the word "Verifying". -# -PRINT_H5IMPORT() { - SPACES=" " - echo " Running h5import $* $SPACES" | cut -c1-70 | tr -d '\012' -} - -# Call the h5import tool -# -IMPORTTEST() -{ - # remove the output hdf5 file if it exists - hdf5_file="$TESTDIR/$5" - if [ -f $hdf5_file ]; then - rm -f $hdf5_file - fi - - PRINT_H5IMPORT $@ - ( - cd $TESTDIR - $RUNSERIAL $H5IMPORT_BIN "$@" - ) - RET=$? - if [ $RET != 0 ] ; then - echo "*FAILED*" - nerrors="`expr $nerrors + 1`" - else - echo " PASSED" - fi - -} - - -############################################################################## -############################################################################## -### T H E T E S T S ### -############################################################################## -############################################################################## -# prepare for test -COPY_TESTFILES_TO_TESTDIR - -TOOLTEST_HELP h5dump-help.txt -h - -# test data output redirection -TOOLTEST tnoddl.ddl --enable-error-stack --ddl -y packedbits.h5 -TOOLTEST tnodata.ddl --enable-error-stack --output packedbits.h5 -TOOLTEST tnoattrddl.ddl --enable-error-stack -O -y tattr.h5 -TOOLTEST tnoattrdata.ddl --enable-error-stack -A -o tattr.h5 -TOOLTEST2 trawdatafile.exp --enable-error-stack -y -o trawdatafile.txt packedbits.h5 -TOOLTEST2 tnoddlfile.exp --enable-error-stack -O -y -o tnoddlfile.txt packedbits.h5 -TOOLTEST2A twithddlfile.exp twithddl.exp --enable-error-stack --ddl=twithddl.txt -y -o twithddlfile.txt packedbits.h5 -TOOLTEST2 trawssetfile.exp --enable-error-stack -d "/dset1[1,1;;;]" -y -o trawssetfile.txt tdset.h5 - -# test for maximum display datasets -TOOLTEST twidedisplay.ddl --enable-error-stack -w0 packedbits.h5 - -# test for signed/unsigned datasets -TOOLTEST packedbits.ddl --enable-error-stack packedbits.h5 -# test for compound signed/unsigned datasets -TOOLTEST tcmpdintsize.ddl --enable-error-stack tcmpdintsize.h5 -# test for signed/unsigned scalar datasets -TOOLTEST tscalarintsize.ddl --enable-error-stack tscalarintsize.h5 -# test for signed/unsigned attributes -TOOLTEST tattrintsize.ddl --enable-error-stack tattrintsize.h5 -# test for compound signed/unsigned attributes -TOOLTEST tcmpdattrintsize.ddl --enable-error-stack tcmpdattrintsize.h5 -# test for signed/unsigned scalar attributes -TOOLTEST tscalarattrintsize.ddl --enable-error-stack tscalarattrintsize.h5 -# test for signed/unsigned scalar datasets with attributes -TOOLTEST tscalarintattrsize.ddl --enable-error-stack tscalarintattrsize.h5 -# test for signed/unsigned datasets attributes -TOOLTEST tintsattrs.ddl --enable-error-stack tintsattrs.h5 -# test for string scalar dataset attribute -TOOLTEST tscalarstring.ddl --enable-error-stack tscalarstring.h5 -# test for displaying groups -TOOLTEST tgroup-1.ddl --enable-error-stack tgroup.h5 -# test for displaying the selected groups -TOOLTEST4 tgroup-2.ddl --enable-error-stack --group=/g2 --group / -g /y tgroup.h5 - -# test for displaying simple space datasets -TOOLTEST tdset-1.ddl --enable-error-stack tdset.h5 -# test for displaying selected datasets -TOOLTEST4 tdset-2.ddl --enable-error-stack -H -d dset1 -d /dset2 --dataset=dset3 tdset.h5 - -# test for displaying attributes -TOOLTEST tattr-1.ddl --enable-error-stack tattr.h5 -# test for displaying the selected attributes of string type and scalar space -TOOLTEST tattr-2.ddl --enable-error-stack -a "/\/attr1" --attribute /attr4 --attribute=/attr5 tattr.h5 -TOOLTEST tattr-2.ddl --enable-error-stack -N "/\/attr1" --any_path /attr4 --any_path=/attr5 tattr.h5 -# test for header and error messages -TOOLTEST4 tattr-3.ddl --enable-error-stack --header -a /attr2 --attribute=/attr tattr.h5 -# test for displaying at least 9 attributes on root from a BE machine -TOOLTEST tattr-4_be.ddl --enable-error-stack tattr4_be.h5 -# test for displaying attributes in shared datatype (also in group and dataset) -TOOLTEST tnamed_dtype_attr.ddl --enable-error-stack tnamed_dtype_attr.h5 - -# test for displaying soft links and user-defined links -TOOLTEST tslink-1.ddl --enable-error-stack tslink.h5 -TOOLTEST tudlink-1.ddl --enable-error-stack tudlink.h5 -# test for displaying the selected link -TOOLTEST tslink-2.ddl --enable-error-stack -l slink2 tslink.h5 -TOOLTEST tslink-2.ddl --enable-error-stack -N slink2 tslink.h5 -TOOLTEST tudlink-2.ddl --enable-error-stack -l udlink2 tudlink.h5 -# test for displaying dangling soft links -TOOLTEST4 tslink-D.ddl --enable-error-stack -d /slink1 tslink.h5 - -# tests for hard links -TOOLTEST thlink-1.ddl --enable-error-stack thlink.h5 -TOOLTEST thlink-2.ddl --enable-error-stack -d /g1/dset2 --dataset /dset1 --dataset=/g1/g1.1/dset3 thlink.h5 -TOOLTEST thlink-3.ddl --enable-error-stack -d /g1/g1.1/dset3 --dataset /g1/dset2 --dataset=/dset1 thlink.h5 -TOOLTEST thlink-4.ddl --enable-error-stack -g /g1 thlink.h5 -TOOLTEST thlink-4.ddl --enable-error-stack -N /g1 thlink.h5 -TOOLTEST thlink-5.ddl --enable-error-stack -d /dset1 -g /g2 -d /g1/dset2 thlink.h5 -TOOLTEST thlink-5.ddl --enable-error-stack -N /dset1 -N /g2 -N /g1/dset2 thlink.h5 - -# tests for compound data types -TOOLTEST tcomp-1.ddl --enable-error-stack tcompound.h5 -# test for named data types -TOOLTEST tcomp-2.ddl --enable-error-stack -t /type1 --datatype /type2 --datatype=/group1/type3 tcompound.h5 -TOOLTEST tcomp-2.ddl --enable-error-stack -N /type1 --any_path /type2 --any_path=/group1/type3 tcompound.h5 -# test for unamed type -TOOLTEST4 tcomp-3.ddl --enable-error-stack -t /#6632 -g /group2 tcompound.h5 -# test complicated compound datatype -TOOLTEST tcomp-4.ddl --enable-error-stack tcompound_complex.h5 -TOOLTEST tcompound_complex.ddl --enable-error-stack tcompound_complex2.h5 -# tests for bitfields and opaque data types -TOOLTEST tbitnopaque.ddl --enable-error-stack tbitnopaque.h5 - -#test for the nested compound type -TOOLTEST tnestcomp-1.ddl --enable-error-stack tnestedcomp.h5 -TOOLTEST tnestedcmpddt.ddl --enable-error-stack tnestedcmpddt.h5 - -# test for options -TOOLTEST4 tall-1.ddl --enable-error-stack tall.h5 -TOOLTEST tall-2.ddl --enable-error-stack --header -g /g1/g1.1 -a attr2 tall.h5 -TOOLTEST tall-3.ddl --enable-error-stack -d /g2/dset2.1 -l /g1/g1.2/g1.2.1/slink tall.h5 -TOOLTEST tall-3.ddl --enable-error-stack -N /g2/dset2.1 -N /g1/g1.2/g1.2.1/slink tall.h5 -TOOLTEST tall-7.ddl --enable-error-stack -a attr1 tall.h5 -TOOLTEST tall-7N.ddl --enable-error-stack -N attr1 tall.h5 - -# test for loop detection -TOOLTEST tloop-1.ddl --enable-error-stack tloop.h5 - -# test for string -TOOLTEST tstr-1.ddl --enable-error-stack tstr.h5 -TOOLTEST tstr-2.ddl --enable-error-stack tstr2.h5 - -# test for file created by Lib SAF team -TOOLTEST tsaf.ddl --enable-error-stack tsaf.h5 - -# test for file with variable length data -TOOLTEST tvldtypes1.ddl --enable-error-stack tvldtypes1.h5 -TOOLTEST tvldtypes2.ddl --enable-error-stack tvldtypes2.h5 -TOOLTEST tvldtypes3.ddl --enable-error-stack tvldtypes3.h5 -TOOLTEST tvldtypes4.ddl --enable-error-stack tvldtypes4.h5 -TOOLTEST tvldtypes5.ddl --enable-error-stack tvldtypes5.h5 - -#test for file with variable length string data -TOOLTEST tvlstr.ddl --enable-error-stack tvlstr.h5 -TOOLTEST tvlenstr_array.ddl --enable-error-stack tvlenstr_array.h5 - -# test for files with array data -TOOLTEST tarray1.ddl --enable-error-stack tarray1.h5 -# # added for bug# 2092 - tarray1_big.h -TOOLTEST4 tarray1_big.ddl --enable-error-stack -R tarray1_big.h5 -TOOLTEST tarray2.ddl --enable-error-stack tarray2.h5 -TOOLTEST tarray3.ddl --enable-error-stack tarray3.h5 -TOOLTEST tarray4.ddl --enable-error-stack tarray4.h5 -TOOLTEST tarray5.ddl --enable-error-stack tarray5.h5 -TOOLTEST tarray6.ddl --enable-error-stack tarray6.h5 -TOOLTEST tarray7.ddl --enable-error-stack tarray7.h5 -TOOLTEST tarray8.ddl --enable-error-stack tarray8.h5 - -# test for wildcards in filename (does not work with cmake) -# inconsistent across platforms TOOLTEST3 tstarfile.ddl --enable-error-stack -H -d Dataset1 tarr*.h5 -#TOOLTEST4 tqmarkfile.ddl --enable-error-stack -H -d Dataset1 tarray?.h5 -TOOLTEST tmultifile.ddl --enable-error-stack -H -d Dataset1 tarray2.h5 tarray3.h5 tarray4.h5 tarray5.h5 tarray6.h5 tarray7.h5 - -# test for files with empty data -TOOLTEST tempty.ddl --enable-error-stack tempty.h5 - -# test for files with groups that have comments -TOOLTEST tgrp_comments.ddl --enable-error-stack tgrp_comments.h5 - -# test the --filedriver flag -TOOLTEST tsplit_file.ddl --enable-error-stack --filedriver=split tsplit_file -TOOLTEST tfamily.ddl --enable-error-stack --filedriver=family tfamily%05d.h5 -TOOLTEST tmulti.ddl --enable-error-stack --filedriver=multi tmulti - -# test for files with group names which reach > 1024 bytes in size -TOOLTEST tlarge_objname.ddl --enable-error-stack -w157 tlarge_objname.h5 - -# test '-A' to suppress data but print attr's -TOOLTEST4 tall-2A.ddl --enable-error-stack -A tall.h5 - -# test '-A' to suppress attr's but print data -TOOLTEST4 tall-2A0.ddl --enable-error-stack -A 0 tall.h5 - -# test '-r' to print attributes in ASCII instead of decimal -TOOLTEST4 tall-2B.ddl --enable-error-stack -A -r tall.h5 - -# test Subsetting -TOOLTEST tall-4s.ddl --enable-error-stack --dataset=/g1/g1.1/dset1.1.1 --start=1,1 --stride=2,3 --count=3,2 --block=1,1 tall.h5 -TOOLTEST tall-5s.ddl --enable-error-stack -d "/g1/g1.1/dset1.1.2[0;2;10;]" tall.h5 -TOOLTEST tdset-3s.ddl --enable-error-stack -d "/dset1[1,1;;;]" tdset.h5 -TOOLTEST tno-subset.ddl --enable-error-stack --no-compact-subset -d "AHFINDERDIRECT::ah_centroid_t[0] it=0 tl=0" tno-subset.h5 - -TOOLTEST tints4dimsCount2.ddl --enable-error-stack -d FourDimInts -s 0,0,0,0 -c 2,2,2,2 tints4dims.h5 -TOOLTEST tints4dimsBlock2.ddl --enable-error-stack -d FourDimInts -s 0,0,0,0 -c 1,1,1,1 -k 2,2,2,2 tints4dims.h5 -TOOLTEST tints4dimsStride2.ddl --enable-error-stack -d FourDimInts -s 0,0,0,0 -S 2,2,2,2 -c 2,2,2,2 tints4dims.h5 -TOOLTEST tints4dimsCountEq.ddl --enable-error-stack -d FourDimInts -s 0,0,0,0 -S 2,2,1,1 -k 1,2,1,1 -c 2,2,4,4 tints4dims.h5 -TOOLTEST tints4dimsBlockEq.ddl --enable-error-stack -d FourDimInts -s 0,0,0,0 -S 2,2,1,1 -c 2,2,1,1 -k 1,2,4,4 tints4dims.h5 - -# test printing characters in ASCII instead of decimal -TOOLTEST tchar1.ddl --enable-error-stack -r tchar.h5 - -# test datatypes in ASCII and UTF8 -TOOLTEST charsets.ddl --enable-error-stack charsets.h5 - -# rev. 2004 - -# tests for super block -TOOLTEST tboot1.ddl --enable-error-stack -H -B -d dset tfcontents1.h5 -TOOLTEST tboot2.ddl --enable-error-stack -B tfcontents2.h5 -TOOLTEST tboot2A.ddl --enable-error-stack --boot-block tfcontents2.h5 -TOOLTEST tboot2B.ddl --enable-error-stack --superblock tfcontents2.h5 -TOOLTEST file_space.ddl --enable-error-stack -B file_space.h5 - -# test -p with a non existing dataset -TOOLTEST4 tperror.ddl --enable-error-stack -p -d bogus tfcontents1.h5 - -# test for file contents -TOOLTEST tcontents.ddl --enable-error-stack -n tfcontents1.h5 -TOOLTEST tordercontents1.ddl --enable-error-stack -n --sort_by=name --sort_order=ascending tfcontents1.h5 -TOOLTEST tordercontents2.ddl --enable-error-stack -n --sort_by=name --sort_order=descending tfcontents1.h5 -TOOLTEST tattrcontents1.ddl --enable-error-stack -n 1 --sort_order=ascending tall.h5 -TOOLTEST tattrcontents2.ddl --enable-error-stack -n 1 --sort_order=descending tall.h5 - -# tests for storage layout -# compact -TOOLTEST tcompact.ddl --enable-error-stack -H -p -d compact tfilters.h5 -# contiguous -TOOLTEST tcontiguos.ddl --enable-error-stack -H -p -d contiguous tfilters.h5 -# chunked -TOOLTEST tchunked.ddl --enable-error-stack -H -p -d chunked tfilters.h5 -# external -TOOLTEST texternal.ddl --enable-error-stack -H -p -d external tfilters.h5 - -# fill values -TOOLTEST tfill.ddl --enable-error-stack -p tfvalues.h5 - -# several datatype, with references , print path -TOOLTEST treference.ddl --enable-error-stack tattr2.h5 - -# escape/not escape non printable characters -TOOLTEST tstringe.ddl --enable-error-stack -e tstr3.h5 -TOOLTEST tstring.ddl --enable-error-stack tstr3.h5 -# char data as ASCII with non escape -TOOLTEST tstring2.ddl --enable-error-stack -r -d str4 tstr3.h5 - -# array indices print/not print -TOOLTEST tindicesyes.ddl --enable-error-stack taindices.h5 -TOOLTEST tindicesno.ddl --enable-error-stack -y taindices.h5 - -########## array indices with subsetting -# 1D case -TOOLTEST tindicessub1.ddl --enable-error-stack -d 1d -s 1 -S 10 -c 2 -k 3 taindices.h5 - -# 2D case -TOOLTEST tindicessub2.ddl --enable-error-stack -d 2d -s 1,2 -S 3,3 -c 3,2 -k 2,2 taindices.h5 - -# 3D case -TOOLTEST tindicessub3.ddl --enable-error-stack -d 3d -s 0,1,2 -S 1,3,3 -c 2,2,2 -k 1,2,2 taindices.h5 - -# 4D case -TOOLTEST tindicessub4.ddl --enable-error-stack -d 4d -s 0,0,1,2 -c 2,2,3,2 -S 1,1,3,3 -k 1,1,2,2 taindices.h5 - -#Exceed the dimensions for subsetting -TOOLTEST texceedsubstart.ddl --enable-error-stack -d 1d -s 1,3 taindices.h5 -TOOLTEST texceedsubcount.ddl --enable-error-stack -d 1d -c 1,3 taindices.h5 -TOOLTEST texceedsubstride.ddl --enable-error-stack -d 1d -S 1,3 taindices.h5 -TOOLTEST texceedsubblock.ddl --enable-error-stack -d 1d -k 1,3 taindices.h5 - - -# tests for filters -# SZIP -TOOLTEST tszip.ddl --enable-error-stack -H -p -d szip tfilters.h5 -# deflate -TOOLTEST tdeflate.ddl --enable-error-stack -H -p -d deflate tfilters.h5 -# shuffle -TOOLTEST tshuffle.ddl --enable-error-stack -H -p -d shuffle tfilters.h5 -# fletcher32 -TOOLTEST tfletcher32.ddl --enable-error-stack -H -p -d fletcher32 tfilters.h5 -# nbit -TOOLTEST tnbit.ddl --enable-error-stack -H -p -d nbit tfilters.h5 -# scaleoffset -TOOLTEST tscaleoffset.ddl --enable-error-stack -H -p -d scaleoffset tfilters.h5 -# all -TOOLTEST tallfilters.ddl --enable-error-stack -H -p -d all tfilters.h5 -# user defined -TOOLTEST tuserfilter.ddl --enable-error-stack -H -p -d myfilter tfilters.h5 - -if test $USE_FILTER_DEFLATE = "yes" ; then - # data read internal filters - TOOLTEST treadintfilter.ddl --enable-error-stack -d deflate -d shuffle -d fletcher32 -d nbit -d scaleoffset tfilters.h5 - if test $USE_FILTER_SZIP = "yes"; then - # data read - TOOLTEST treadfilter.ddl --enable-error-stack -d all -d szip tfilters.h5 - fi -fi - -# test for displaying objects with very long names -TOOLTEST tlonglinks.ddl --enable-error-stack tlonglinks.h5 - -# dimensions over 4GB, print boundary -TOOLTEST tbigdims.ddl --enable-error-stack -d dset4gb -s 4294967284 -c 22 tbigdims.h5 - -# hyperslab read -TOOLTEST thyperslab.ddl --enable-error-stack thyperslab.h5 - - -# - -# test for displaying dataset and attribute of null space -TOOLTEST tnullspace.ddl --enable-error-stack tnullspace.h5 - -# test for displaying dataset and attribute of space with 0 dimension size -TOOLTEST zerodim.ddl --enable-error-stack zerodim.h5 - -# test for long double (some systems do not have long double) -#TOOLTEST tldouble.ddl --enable-error-stack tldouble.h5 - -# test for vms -TOOLTEST tvms.ddl --enable-error-stack tvms.h5 - -# test for binary output -TOOLTEST tbin1.ddl --enable-error-stack -d integer -o out1.bin -b LE tbinary.h5 - -# test for string binary output -TOOLTEST2B tstr2bin2.exp --enable-error-stack -d /g2/dset2 -b -o tstr2bin2.txt tstr2.h5 -TOOLTEST2B tstr2bin6.exp --enable-error-stack -d /g6/dset6 -b -o tstr2bin6.txt tstr2.h5 - -# NATIVE default. the NATIVE test can be validated with h5import/h5diff -TOOLTEST tbin1.ddl --enable-error-stack -d integer -o out1.bin -b tbinary.h5 -IMPORTTEST out1.bin -c out3.h5import -o out1.h5 -DIFFTEST tbinary.h5 out1.h5 /integer /integer -# Same but use h5dump as input to h5import -IMPORTTEST out1.bin -c tbin1.ddl -o out1D.h5 -DIFFTEST tbinary.h5 out1D.h5 /integer /integer - -TOOLTEST tbin2.ddl --enable-error-stack -b BE -d float -o out2.bin tbinary.h5 - -# the NATIVE test can be validated with h5import/h5diff -TOOLTEST tbin3.ddl --enable-error-stack -d integer -o out3.bin -b NATIVE tbinary.h5 -IMPORTTEST out3.bin -c out3.h5import -o out3.h5 -DIFFTEST tbinary.h5 out3.h5 /integer /integer -# Same but use h5dump as input to h5import -IMPORTTEST out3.bin -c tbin3.ddl -o out3D.h5 -DIFFTEST tbinary.h5 out3D.h5 /integer /integer - -TOOLTEST tbin4.ddl --enable-error-stack -d double -b FILE -o out4.bin tbinary.h5 - -# Clean up binary output files -if test -z "$HDF5_NOCLEANUP"; then - rm -f out[1-4].bin - rm -f out1.h5 - rm -f out3.h5 -fi - -# test for dataset region references -TOOLTEST tdatareg.ddl --enable-error-stack tdatareg.h5 -TOOLTEST4 tdataregR.ddl --enable-error-stack -R tdatareg.h5 -TOOLTEST tattrreg.ddl --enable-error-stack tattrreg.h5 -TOOLTEST4 tattrregR.ddl --enable-error-stack -R tattrreg.h5 -TOOLTEST2 tbinregR.exp --enable-error-stack -d /Dataset1 -s 0 -R -y -o tbinregR.txt tdatareg.h5 - -# Clean up text output files -if test -z "$HDF5_NOCLEANUP"; then - rm -f tbinregR.txt -fi - -# tests for group creation order -# "1" tracked, "2" name, root tracked -TOOLTEST tordergr1.ddl --enable-error-stack --group=1 --sort_by=creation_order --sort_order=ascending tordergr.h5 -TOOLTEST tordergr2.ddl --enable-error-stack --group=1 --sort_by=creation_order --sort_order=descending tordergr.h5 -TOOLTEST tordergr3.ddl --enable-error-stack -g 2 -q name -z ascending tordergr.h5 -TOOLTEST tordergr4.ddl --enable-error-stack -g 2 -q name -z descending tordergr.h5 -TOOLTEST tordergr5.ddl --enable-error-stack -q creation_order tordergr.h5 - -# tests for attribute order -TOOLTEST torderattr1.ddl --enable-error-stack -H --sort_by=name --sort_order=ascending torderattr.h5 -TOOLTEST torderattr2.ddl --enable-error-stack -H --sort_by=name --sort_order=descending torderattr.h5 -TOOLTEST torderattr3.ddl --enable-error-stack -H --sort_by=creation_order --sort_order=ascending torderattr.h5 -TOOLTEST torderattr4.ddl --enable-error-stack -H --sort_by=creation_order --sort_order=descending torderattr.h5 - -# tests for link references and order -TOOLTEST4 torderlinks1.ddl --enable-error-stack --sort_by=name --sort_order=ascending tfcontents1.h5 -TOOLTEST4 torderlinks2.ddl --enable-error-stack --sort_by=name --sort_order=descending tfcontents1.h5 - -# tests for floating point user defined printf format -TOOLTEST tfpformat.ddl --enable-error-stack -m %.7f tfpformat.h5 - -# tests for traversal of external links -TOOLTEST4 textlinksrc.ddl --enable-error-stack textlinksrc.h5 -TOOLTEST4 textlinkfar.ddl --enable-error-stack textlinkfar.h5 - -# test for dangling external links -TOOLTEST4 textlink.ddl --enable-error-stack textlink.h5 - -# test for error stack display (BZ2048) -TOOLTEST5 filter_fail.ddl --enable-error-stack filter_fail.h5 - -# test for -o -y for dataset with attributes -TOOLTEST2 tall-6.exp --enable-error-stack -y -o tall-6.txt -d /g1/g1.1/dset1.1.1 tall.h5 - -# test for non-existing file -TOOLTEST3 non_existing.ddl --enable-error-stack tgroup.h5 non_existing.h5 - -# Clean up temporary files/directories -CLEAN_TESTFILES_AND_TESTDIR - -# Report test results and exit -if test $nerrors -eq 0 ; then - echo "All $TESTNAME tests passed." - exit $EXIT_SUCCESS -else - echo "$TESTNAME tests failed with $nerrors errors." - exit $EXIT_FAILURE -fi diff --git a/tools/h5dump/testh5dumppbits.sh.in b/tools/h5dump/testh5dumppbits.sh.in deleted file mode 100644 index 446020a..0000000 --- a/tools/h5dump/testh5dumppbits.sh.in +++ /dev/null @@ -1,598 +0,0 @@ -#! /bin/sh -# -# 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. -# -# Tests for the h5dump tool with packed bits type files - -srcdir=@srcdir@ - -# Determine which filters are available -USE_FILTER_SZIP="@USE_FILTER_SZIP@" -USE_FILTER_DEFLATE="@USE_FILTER_DEFLATE@" - -TESTNAME=h5dump -EXIT_SUCCESS=0 -EXIT_FAILURE=1 - -DUMPER=h5dump # The tool name -DUMPER_BIN=`pwd`/$DUMPER # The path of the tool binary - -H5DIFF=../h5diff/h5diff # The h5diff tool name -H5DIFF_BIN=`pwd`/$H5DIFF # The path of the h5diff tool binary - -H5IMPORT=../h5import/h5import # The h5import tool name -H5IMPORT_BIN=`pwd`/$H5IMPORT # The path of the h5import tool binary - -RM='rm -rf' -CMP='cmp -s' -DIFF='diff -c' -CP='cp' -DIRNAME='dirname' -LS='ls' -AWK='awk' - -nerrors=0 -verbose=yes - -# source dirs -SRC_TOOLS="$srcdir/../" - -SRC_TOOLS_TESTFILES="$SRC_TOOLS/testfiles" -# testfiles source dirs for tools -SRC_H5LS_TESTFILES="$SRC_TOOLS_TESTFILES" -SRC_H5DUMP_TESTFILES="$SRC_TOOLS_TESTFILES" -SRC_H5DUMP_ERRORFILES="$srcdir/errfiles" -SRC_H5DIFF_TESTFILES="$SRC_TOOLS/h5diff/testfiles" -SRC_H5COPY_TESTFILES="$SRC_TOOLS/h5copy/testfiles" -SRC_H5REPACK_TESTFILES="$SRC_TOOLS/h5repack/testfiles" -SRC_H5JAM_TESTFILES="$SRC_TOOLS/h5jam/testfiles" -SRC_H5STAT_TESTFILES="$SRC_TOOLS/h5stat/testfiles" -SRC_H5IMPORT_TESTFILES="$SRC_TOOLS/h5import/testfiles" - -TEST_P_DIR=./testfiles -TESTDIR=./testfiles/pbits -test -d $TEST_P_DIR || mkdir -p $TEST_P_DIR -test -d $TESTDIR || mkdir -p $TESTDIR - -###################################################################### -# test files -# -------------------------------------------------------------------- -# All the test files copy from source directory to test directory -# NOTE: Keep this framework to add/remove test files. -# Any test files from other tools can be used in this framework. -# This list are also used for checking exist. -# Comment '#' without space can be used. -# -------------------------------------------------------------------- -LIST_HDF5_TEST_FILES=" -$SRC_H5DUMP_TESTFILES/packedbits.h5 -$SRC_H5DUMP_TESTFILES/tarray1.h5 -$SRC_H5DUMP_TESTFILES/tcompound.h5 -" - -LIST_OTHER_TEST_FILES=" -$SRC_H5DUMP_TESTFILES/pbits/tnofilename-with-packed-bits.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsArray.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsCompound.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsIncomplete.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsLengthExceeded.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsCharLengthExceeded.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsIntLengthExceeded.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsLongLengthExceeded.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsLengthPositive.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsMax.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsMaxExceeded.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsOffsetExceeded.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsCharOffsetExceeded.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsIntOffsetExceeded.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsLongOffsetExceeded.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsOffsetNegative.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsOverlapped.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsSigned.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsUnsigned.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsSignedInt.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsUnsignedInt.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsSignedLong.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsUnsignedLong.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsSignedLongLong.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsUnsignedLongLong.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsSignedWhole.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsUnsignedWhole.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsSignedIntWhole.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsUnsignedIntWhole.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsSignedLongWhole.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsUnsignedLongWhole.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsSignedLongLongWhole.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsUnsignedLongLongWhole.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsSignedLongLongWhole1.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsUnsignedLongLongWhole1.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsSignedLongLongWhole63.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsUnsignedLongLongWhole63.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsSigned4.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsUnsigned4.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsSignedInt8.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsUnsignedInt8.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsSignedLong16.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsUnsignedLong16.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsSignedLongLong32.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsUnsignedLongLong32.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsSigned2.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsUnsigned2.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsSignedInt4.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsUnsignedInt4.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsSignedLong8.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsUnsignedLong8.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsSignedLongLong16.ddl -$SRC_H5DUMP_TESTFILES/pbits/tpbitsUnsignedLongLong16.ddl -" - -LIST_ERROR_TEST_FILES=" -${SRC_H5DUMP_ERRORFILES}/tnofilename-with-packed-bits.err -${SRC_H5DUMP_ERRORFILES}/tpbitsCharLengthExceeded.err -${SRC_H5DUMP_ERRORFILES}/tpbitsCharOffsetExceeded.err -${SRC_H5DUMP_ERRORFILES}/tpbitsIncomplete.err -${SRC_H5DUMP_ERRORFILES}/tpbitsIntLengthExceeded.err -${SRC_H5DUMP_ERRORFILES}/tpbitsIntOffsetExceeded.err -${SRC_H5DUMP_ERRORFILES}/tpbitsLengthExceeded.err -${SRC_H5DUMP_ERRORFILES}/tpbitsLengthPositive.err -${SRC_H5DUMP_ERRORFILES}/tpbitsLongLengthExceeded.err -${SRC_H5DUMP_ERRORFILES}/tpbitsLongOffsetExceeded.err -${SRC_H5DUMP_ERRORFILES}/tpbitsMaxExceeded.err -${SRC_H5DUMP_ERRORFILES}/tpbitsOffsetExceeded.err -${SRC_H5DUMP_ERRORFILES}/tpbitsOffsetNegative.err -" - -# -# copy test files and expected output files from source dirs to test dir -# -COPY_TESTFILES="$LIST_HDF5_TEST_FILES $LIST_OTHER_TEST_FILES $LIST_ERROR_TEST_FILES" - -COPY_TESTFILES_TO_TESTDIR() -{ - # copy test files. Used -f to make sure get a new copy - for tstfile in $COPY_TESTFILES - do - # ignore '#' comment - echo $tstfile | tr -d ' ' | grep '^#' > /dev/null - RET=$? - if [ $RET -eq 1 ]; then - # skip cp if srcdir is same as destdir - # this occurs when build/test performed in source dir and - # make cp fail - SDIR=`$DIRNAME $tstfile` - INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'` - INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'` - if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then - $CP -f $tstfile $TESTDIR - if [ $? -ne 0 ]; then - echo "Error: FAILED to copy $tstfile ." - - # Comment out this to CREATE expected file - exit $EXIT_FAILURE - fi - fi - fi - done -} - -CLEAN_TESTFILES_AND_TESTDIR() -{ - # skip rm if srcdir is same as destdir - # this occurs when build/test performed in source dir and - # make cp fail - SDIR=$SRC_H5DUMP_TESTFILES/pbits - INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'` - INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'` - if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then - $RM $TESTDIR - fi -} - -# Print a line-line message left justified in a field of 70 characters -# beginning with the word "Testing". -# -TESTING() { - SPACES=" " - echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012' -} - -# Source in the output filter function definitions. -. $srcdir/../../bin/output_filter.sh - -# Run a test and print PASS or *FAIL*. If a test fails then increment -# the `nerrors' global variable and (if $verbose is set) display the -# difference between the actual output and the expected output. The -# expected output is given as the first argument to this function and -# the actual output file is calculated by replacing the `.ddl' with -# `.out'. The actual output is not removed if $HDF5_NOCLEANUP has a -# non-zero value. -# -TOOLTEST() { - expect="$TESTDIR/$1" - actual="$TESTDIR/`basename $1 .ddl`.out" - actual_err="$TESTDIR/`basename $1 .ddl`.err" - actual_sav=${actual}-sav - actual_err_sav=${actual_err}-sav - shift - - # Run test. - TESTING $DUMPER $@ - ( - cd $TESTDIR - $RUNSERIAL $DUMPER_BIN "$@" - ) >$actual 2>$actual_err - - # save actual and actual_err in case they are needed later. - cp $actual $actual_sav - STDOUT_FILTER $actual - cp $actual_err $actual_err_sav - STDERR_FILTER $actual_err - cat $actual_err >> $actual - - if [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect - elif $CMP $expect $actual; then - echo " PASSED" - else - echo "*FAILED*" - echo " Expected result (*.ddl) differs from actual result (*.out)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' - fi - - # Clean up output file - if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actual_err $actual_sav $actual_err_sav $actual_ext - fi - -} - - -# same as TOOLTEST1 but compares generated file to expected output -# and compares the generated data file to the expected data file -# used for the binary tests that expect a full path in -o without -b -TOOLTEST2() { - - expectdata="$TESTDIR/$1" - expect="$TESTDIR/`basename $1 .exp`.ddl" - actualdata="$TESTDIR/`basename $1 .exp`.txt" - actual="$TESTDIR/`basename $1 .exp`.out" - actual_err="$TESTDIR/`basename $1 .exp`.err" - shift - - # Run test. - TESTING $DUMPER $@ - ( - cd $TESTDIR - $RUNSERIAL $DUMPER_BIN "$@" - ) >$actual 2>$actual_err - cat $actual_err >> $actual - - if [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect - elif $CMP $expect $actual; then - if [ ! -f $expectdata ]; then - # Create the expect data file if it doesn't yet exist. - echo " CREATED" - cp $actualdata $expectdata - elif $CMP $expectdata $actualdata; then - echo " PASSED" - else - echo "*FAILED*" - echo " Expected datafile (*.exp) differs from actual datafile (*.txt)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expectdata $actualdata |sed 's/^/ /' - fi - else - echo "*FAILED*" - echo " Expected result (*.ddl) differs from actual result (*.out)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' - fi - - # Clean up output file - if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actualdata $actual_err - fi - -} - -# same as TOOLTEST but filters error stack outp -# Extract file name, line number, version and thread IDs because they may be different -TOOLTEST3() { - - expect="$TESTDIR/$1" - actual="$TESTDIR/`basename $1 .ddl`.out" - actual_err="$TESTDIR/`basename $1 .ddl`.err" - actual_ext="$TESTDIR/`basename $1 .ddl`.ext" - actual_sav=${actual}-sav - actual_err_sav=${actual_err}-sav - shift - - # Run test. - TESTING $DUMPER $@ - ( - cd $TESTDIR - $RUNSERIAL $DUMPER_BIN "$@" - ) >$actual 2>$actual_err - - # save actual and actual_err in case they are needed later. - cp $actual $actual_sav - STDOUT_FILTER $actual - cp $actual_err $actual_err_sav - STDERR_FILTER $actual_err - - # Extract file name, line number, version and thread IDs because they may be different - sed -e 's/thread [0-9]*/thread (IDs)/' -e 's/: .*\.c /: (file name) /' \ - -e 's/line [0-9]*/line (number)/' \ - -e 's/v[1-9]*\.[0-9]*\./version (number)\./' \ - -e 's/[1-9]*\.[0-9]*\.[0-9]*[^)]*/version (number)/' \ - -e 's/H5Eget_auto[1-2]*/H5Eget_auto(1 or 2)/' \ - -e 's/H5Eset_auto[1-2]*/H5Eset_auto(1 or 2)/' \ - $actual_err > $actual_ext - cat $actual_ext >> $actual - - if [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect - elif $CMP $expect $actual; then - echo " PASSED" - else - echo "*FAILED*" - echo " Expected result (*.ddl) differs from actual result (*.out)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' - fi - - # Clean up output file - if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actual_err $actual_sav $actual_err_sav - fi - -} - -# same as TOOLTEST3 but filters error stack output and compares to an error file -# Extract file name, line number, version and thread IDs because they may be different -TOOLTEST4() { - - expect="$TESTDIR/$1" - expect_err="$TESTDIR/`basename $1 .ddl`.err" - actual="$TESTDIR/`basename $1 .ddl`.out" - actual_err="$TESTDIR/`basename $1 .ddl`.oerr" - actual_ext="$TESTDIR/`basename $1 .ddl`.ext" - actual_sav=${actual}-sav - actual_err_sav=${actual_err}-sav - shift - - # Run test. - TESTING $DUMPER $@ - ( - cd $TESTDIR - $RUNSERIAL $DUMPER_BIN "$@" - ) >$actual 2>$actual_err - - # save actual and actual_err in case they are needed later. - cp $actual $actual_sav - STDOUT_FILTER $actual - cp $actual_err $actual_err_sav - STDERR_FILTER $actual_err - - # Extract file name, line number, version and thread IDs because they may be different - sed -e 's/thread [0-9]*/thread (IDs)/' -e 's/: .*\.c /: (file name) /' \ - -e 's/line [0-9]*/line (number)/' \ - -e 's/v[1-9]*\.[0-9]*\./version (number)\./' \ - -e 's/[1-9]*\.[0-9]*\.[0-9]*[^)]*/version (number)/' \ - -e 's/H5Eget_auto[1-2]*/H5Eget_auto(1 or 2)/' \ - -e 's/H5Eset_auto[1-2]*/H5Eset_auto(1 or 2)/' \ - $actual_err > $actual_ext - #cat $actual_ext >> $actual - - if [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect - elif $CMP $expect $actual; then - if $CMP $expect_err $actual_ext; then - echo " PASSED" - else - echo "*FAILED*" - echo " Expected result (*.err) differs from actual result (*.oerr)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect_err $actual_ext |sed 's/^/ /' - fi - else - echo "*FAILED*" - echo " Expected result (*.ddl) differs from actual result (*.out)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' - fi - - # Clean up output file - if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actual_err $actual_sav $actual_err_sav - fi - -} - -# Print a "SKIP" message -SKIP() { - TESTING $DUMPER $@ - echo " -SKIP-" -} - -# Print a line-line message left justified in a field of 70 characters -# -PRINT_H5DIFF() { - SPACES=" " - echo " Running h5diff $* $SPACES" | cut -c1-70 | tr -d '\012' -} - - -# Call the h5diff tool -# -DIFFTEST() -{ - PRINT_H5DIFF $@ - ( - cd $TESTDIR - $RUNSERIAL $H5DIFF_BIN "$@" -q - ) - RET=$? - if [ $RET != 0 ] ; then - echo "*FAILED*" - nerrors="`expr $nerrors + 1`" - else - echo " PASSED" - fi - -} - -# Print a line-line message left justified in a field of 70 characters -# beginning with the word "Verifying". -# -PRINT_H5IMPORT() { - SPACES=" " - echo " Running h5import $* $SPACES" | cut -c1-70 | tr -d '\012' -} - -# Call the h5import tool -# -IMPORTTEST() -{ - # remove the output hdf5 file if it exists - hdf5_file="$TESTDIR/$5" - if [ -f $hdf5_file ]; then - rm -f $hdf5_file - fi - - PRINT_H5IMPORT $@ - ( - cd $TESTDIR - $RUNSERIAL $H5IMPORT_BIN "$@" - ) - RET=$? - if [ $RET != 0 ] ; then - echo "*FAILED*" - nerrors="`expr $nerrors + 1`" - else - echo " PASSED" - fi - -} - - -############################################################################## -############################################################################## -### T H E T E S T S ### -############################################################################## -############################################################################## -# prepare for test -COPY_TESTFILES_TO_TESTDIR - -####### test for dataset packed bits ###### - -# test failure handling -# Missing file name -TOOLTEST tnofilename-with-packed-bits.ddl --enable-error-stack -# Limits: -# Maximum number of packed bits is 8 (for now). -# Maximum integer size is 64 (for now). -# Maximun Offset is 63 (Maximum size - 1). -# Maximum Offset+Length is 64 (Maximum size). -# Tests: -# Normal operation on both signed and unsigned int datasets. -# Sanity check -# Their rawdata output should be the same. -TOOLTEST tpbitsSignedWhole.ddl --enable-error-stack -d /DS08BITS -M 0,8 packedbits.h5 -TOOLTEST tpbitsUnsignedWhole.ddl --enable-error-stack -d /DU08BITS -M 0,8 packedbits.h5 -TOOLTEST tpbitsSignedIntWhole.ddl --enable-error-stack -d /DS16BITS -M 0,16 packedbits.h5 -TOOLTEST tpbitsUnsignedIntWhole.ddl --enable-error-stack -d /DU16BITS -M 0,16 packedbits.h5 -TOOLTEST tpbitsSignedLongWhole.ddl --enable-error-stack -d /DS32BITS -M 0,32 packedbits.h5 -TOOLTEST tpbitsUnsignedLongWhole.ddl --enable-error-stack -d /DU32BITS -M 0,32 packedbits.h5 -TOOLTEST tpbitsSignedLongLongWhole.ddl --enable-error-stack -d /DS64BITS -M 0,64 packedbits.h5 -TOOLTEST tpbitsUnsignedLongLongWhole.ddl --enable-error-stack -d /DU64BITS -M 0,64 packedbits.h5 -TOOLTEST tpbitsSignedLongLongWhole63.ddl --enable-error-stack -d /DS64BITS -M 0,63 packedbits.h5 -TOOLTEST tpbitsUnsignedLongLongWhole63.ddl --enable-error-stack -d /DU64BITS -M 0,63 packedbits.h5 -TOOLTEST tpbitsSignedLongLongWhole1.ddl --enable-error-stack -d /DS64BITS -M 1,63 packedbits.h5 -TOOLTEST tpbitsUnsignedLongLongWhole1.ddl --enable-error-stack -d /DU64BITS -M 1,63 packedbits.h5 -# Half sections -TOOLTEST tpbitsSigned4.ddl --enable-error-stack -d /DS08BITS -M 0,4,4,4 packedbits.h5 -TOOLTEST tpbitsUnsigned4.ddl --enable-error-stack -d /DU08BITS -M 0,4,4,4 packedbits.h5 -TOOLTEST tpbitsSignedInt8.ddl --enable-error-stack -d /DS16BITS -M 0,8,8,8 packedbits.h5 -TOOLTEST tpbitsUnsignedInt8.ddl --enable-error-stack -d /DU16BITS -M 0,8,8,8 packedbits.h5 -TOOLTEST tpbitsSignedLong16.ddl --enable-error-stack -d /DS32BITS -M 0,16,16,16 packedbits.h5 -TOOLTEST tpbitsUnsignedLong16.ddl --enable-error-stack -d /DU32BITS -M 0,16,16,16 packedbits.h5 -TOOLTEST tpbitsSignedLongLong32.ddl --enable-error-stack -d /DS64BITS -M 0,32,32,32 packedbits.h5 -TOOLTEST tpbitsUnsignedLongLong32.ddl --enable-error-stack -d /DU64BITS -M 0,32,32,32 packedbits.h5 -# Quarter sections -TOOLTEST tpbitsSigned2.ddl --enable-error-stack -d /DS08BITS -M 0,2,2,2,4,2,6,2 packedbits.h5 -TOOLTEST tpbitsUnsigned2.ddl --enable-error-stack -d /DU08BITS -M 0,2,2,2,4,2,6,2 packedbits.h5 -TOOLTEST tpbitsSignedInt4.ddl --enable-error-stack -d /DS16BITS -M 0,4,4,4,8,4,12,4 packedbits.h5 -TOOLTEST tpbitsUnsignedInt4.ddl --enable-error-stack -d /DU16BITS -M 0,4,4,4,8,4,12,4 packedbits.h5 -TOOLTEST tpbitsSignedLong8.ddl --enable-error-stack -d /DS32BITS -M 0,8,8,8,16,8,24,8 packedbits.h5 -TOOLTEST tpbitsUnsignedLong8.ddl --enable-error-stack -d /DU32BITS -M 0,8,8,8,16,8,24,8 packedbits.h5 -TOOLTEST tpbitsSignedLongLong16.ddl --enable-error-stack -d /DS64BITS -M 0,16,16,16,32,16,48,16 packedbits.h5 -TOOLTEST tpbitsUnsignedLongLong16.ddl --enable-error-stack -d /DU64BITS -M 0,16,16,16,32,16,48,16 packedbits.h5 -# Begin and End -TOOLTEST tpbitsSigned.ddl --enable-error-stack -d /DS08BITS -M 0,2,2,6 packedbits.h5 -TOOLTEST tpbitsUnsigned.ddl --enable-error-stack -d /DU08BITS -M 0,2,2,6 packedbits.h5 -TOOLTEST tpbitsSignedInt.ddl --enable-error-stack -d /DS16BITS -M 0,2,10,6 packedbits.h5 -TOOLTEST tpbitsUnsignedInt.ddl --enable-error-stack -d /DU16BITS -M 0,2,10,6 packedbits.h5 -TOOLTEST tpbitsSignedLong.ddl --enable-error-stack -d /DS32BITS -M 0,2,26,6 packedbits.h5 -TOOLTEST tpbitsUnsignedLong.ddl --enable-error-stack -d /DU32BITS -M 0,2,26,6 packedbits.h5 -TOOLTEST tpbitsSignedLongLong.ddl --enable-error-stack -d /DS64BITS -M 0,2,58,6 packedbits.h5 -TOOLTEST tpbitsUnsignedLongLong.ddl --enable-error-stack -d /DU64BITS -M 0,2,58,6 packedbits.h5 -# Overlapped packed bits. -TOOLTEST tpbitsOverlapped.ddl --enable-error-stack -d /DS08BITS -M 0,1,1,1,2,1,0,3 packedbits.h5 -# Maximum number of packed bits. -TOOLTEST tpbitsMax.ddl --enable-error-stack -d /DS08BITS -M 0,1,1,1,2,1,3,1,4,1,5,1,6,1,7,1 packedbits.h5 -# Compound type. -TOOLTEST tpbitsCompound.ddl --enable-error-stack -d /dset1 -M 0,1,1,1 tcompound.h5 -# Array type. -TOOLTEST tpbitsArray.ddl --enable-error-stack -d /Dataset1 -M 0,1,1,1 tarray1.h5 -# Test Error handling. -# Too many packed bits requested. Max is 8 for now. -TOOLTEST tpbitsMaxExceeded.ddl --enable-error-stack -d /DS08BITS -M 0,1,0,1,1,1,2,1,3,1,4,1,5,1,6,1,7,1 packedbits.h5 -# Offset too large. Max is 7 (8-1) for now. -TOOLTEST tpbitsOffsetExceeded.ddl --enable-error-stack -d /DS08BITS -M 64,1 packedbits.h5 -TOOLTEST tpbitsCharOffsetExceeded.ddl --enable-error-stack -d /DS08BITS -M 8,1 packedbits.h5 -TOOLTEST tpbitsIntOffsetExceeded.ddl --enable-error-stack -d /DS16BITS -M 16,1 packedbits.h5 -TOOLTEST tpbitsLongOffsetExceeded.ddl --enable-error-stack -d /DS32BITS -M 32,1 packedbits.h5 -# Bad offset, must not be negative. -TOOLTEST tpbitsOffsetNegative.ddl --enable-error-stack -d /DS08BITS -M -1,1 packedbits.h5 -# Bad length, must not be positive. -TOOLTEST tpbitsLengthPositive.ddl --enable-error-stack -d /DS08BITS -M 4,0 packedbits.h5 -# Offset+Length is too large. Max is 8 for now. -TOOLTEST tpbitsLengthExceeded.ddl --enable-error-stack -d /DS08BITS -M 37,28 packedbits.h5 -TOOLTEST tpbitsCharLengthExceeded.ddl --enable-error-stack -d /DS08BITS -M 2,7 packedbits.h5 -TOOLTEST tpbitsIntLengthExceeded.ddl --enable-error-stack -d /DS16BITS -M 10,7 packedbits.h5 -TOOLTEST tpbitsLongLengthExceeded.ddl --enable-error-stack -d /DS32BITS -M 26,7 packedbits.h5 -# Incomplete pair of packed bits request. -TOOLTEST tpbitsIncomplete.ddl --enable-error-stack -d /DS08BITS -M 0,2,2,1,0,2,2, packedbits.h5 - -# Clean up temporary files/directories -CLEAN_TESTFILES_AND_TESTDIR - -# Report test results and exit -if test $nerrors -eq 0 ; then - echo "All $TESTNAME tests passed." - exit $EXIT_SUCCESS -else - echo "$TESTNAME tests failed with $nerrors errors." - exit $EXIT_FAILURE -fi diff --git a/tools/h5dump/testh5dumpvds.sh.in b/tools/h5dump/testh5dumpvds.sh.in deleted file mode 100644 index 16411f5..0000000 --- a/tools/h5dump/testh5dumpvds.sh.in +++ /dev/null @@ -1,523 +0,0 @@ -#! /bin/sh -# -# 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. -# -# Tests for the h5dump tool with vds type files - -srcdir=@srcdir@ - -# Determine which filters are available -USE_FILTER_SZIP="@USE_FILTER_SZIP@" -USE_FILTER_DEFLATE="@USE_FILTER_DEFLATE@" - -TESTNAME=h5dump -EXIT_SUCCESS=0 -EXIT_FAILURE=1 - -DUMPER=h5dump # The tool name -DUMPER_BIN=`pwd`/$DUMPER # The path of the tool binary - -H5DIFF=../h5diff/h5diff # The h5diff tool name -H5DIFF_BIN=`pwd`/$H5DIFF # The path of the h5diff tool binary - -H5IMPORT=../h5import/h5import # The h5import tool name -H5IMPORT_BIN=`pwd`/$H5IMPORT # The path of the h5import tool binary - -RM='rm -rf' -CMP='cmp -s' -DIFF='diff -c' -CP='cp' -DIRNAME='dirname' -LS='ls' -AWK='awk' - -nerrors=0 -verbose=yes - -# source dirs -SRC_TOOLS="$srcdir/../" - -SRC_TOOLS_TESTFILES="$SRC_TOOLS/testfiles" -# testfiles source dirs for tools -SRC_H5LS_TESTFILES="$SRC_TOOLS_TESTFILES" -SRC_H5DUMP_TESTFILES="$SRC_TOOLS_TESTFILES" -SRC_H5DUMP_ERRORFILES="$srcdir/errfiles" -SRC_H5DIFF_TESTFILES="$SRC_TOOLS/h5diff/testfiles" -SRC_H5COPY_TESTFILES="$SRC_TOOLS/h5copy/testfiles" -SRC_H5REPACK_TESTFILES="$SRC_TOOLS/h5repack/testfiles" -SRC_H5JAM_TESTFILES="$SRC_TOOLS/h5jam/testfiles" -SRC_H5STAT_TESTFILES="$SRC_TOOLS/h5stat/testfiles" -SRC_H5IMPORT_TESTFILES="$SRC_TOOLS/h5import/testfiles" - -TEST_P_DIR=./testfiles -TESTDIR=./testfiles/vds -test -d $TEST_P_DIR || mkdir -p $TEST_P_DIR -test -d $TESTDIR || mkdir -p $TESTDIR - -###################################################################### -# test files -# -------------------------------------------------------------------- -# All the test files copy from source directory to test directory -# NOTE: Keep this framework to add/remove test files. -# Any test files from other tools can be used in this framework. -# This list are also used for checking exist. -# Comment '#' without space can be used. -# -------------------------------------------------------------------- -LIST_HDF5_TEST_FILES=" -$SRC_H5DUMP_TESTFILES/vds/1_a.h5 -$SRC_H5DUMP_TESTFILES/vds/1_b.h5 -$SRC_H5DUMP_TESTFILES/vds/1_c.h5 -$SRC_H5DUMP_TESTFILES/vds/1_d.h5 -$SRC_H5DUMP_TESTFILES/vds/1_e.h5 -$SRC_H5DUMP_TESTFILES/vds/1_f.h5 -$SRC_H5DUMP_TESTFILES/vds/1_vds.h5 -$SRC_H5DUMP_TESTFILES/vds/2_a.h5 -$SRC_H5DUMP_TESTFILES/vds/2_b.h5 -$SRC_H5DUMP_TESTFILES/vds/2_c.h5 -$SRC_H5DUMP_TESTFILES/vds/2_d.h5 -$SRC_H5DUMP_TESTFILES/vds/2_e.h5 -$SRC_H5DUMP_TESTFILES/vds/2_vds.h5 -$SRC_H5DUMP_TESTFILES/vds/3_1_vds.h5 -$SRC_H5DUMP_TESTFILES/vds/3_2_vds.h5 -$SRC_H5DUMP_TESTFILES/vds/4_0.h5 -$SRC_H5DUMP_TESTFILES/vds/4_1.h5 -$SRC_H5DUMP_TESTFILES/vds/4_2.h5 -$SRC_H5DUMP_TESTFILES/vds/4_vds.h5 -$SRC_H5DUMP_TESTFILES/vds/5_a.h5 -$SRC_H5DUMP_TESTFILES/vds/5_b.h5 -$SRC_H5DUMP_TESTFILES/vds/5_c.h5 -$SRC_H5DUMP_TESTFILES/vds/5_vds.h5 -$SRC_H5DUMP_TESTFILES/vds/a.h5 -$SRC_H5DUMP_TESTFILES/vds/b.h5 -$SRC_H5DUMP_TESTFILES/vds/c.h5 -$SRC_H5DUMP_TESTFILES/vds/d.h5 -$SRC_H5DUMP_TESTFILES/vds/vds-percival-unlim-maxmin.h5 -$SRC_H5DUMP_TESTFILES/vds/f-0.h5 -$SRC_H5DUMP_TESTFILES/vds/f-3.h5 -$SRC_H5DUMP_TESTFILES/vds/vds-eiger.h5 -" - -LIST_OTHER_TEST_FILES=" -$SRC_H5DUMP_TESTFILES/vds/tvds-1.ddl -$SRC_H5DUMP_TESTFILES/vds/tvds-2.ddl -$SRC_H5DUMP_TESTFILES/vds/tvds-3_1.ddl -$SRC_H5DUMP_TESTFILES/vds/tvds-3_2.ddl -$SRC_H5DUMP_TESTFILES/vds/tvds-4.ddl -$SRC_H5DUMP_TESTFILES/vds/tvds-5.ddl -$SRC_H5DUMP_TESTFILES/vds/tvds_layout-1.ddl -$SRC_H5DUMP_TESTFILES/vds/tvds_layout-2.ddl -$SRC_H5DUMP_TESTFILES/vds/tvds_layout-3_1.ddl -$SRC_H5DUMP_TESTFILES/vds/tvds_layout-3_2.ddl -$SRC_H5DUMP_TESTFILES/vds/tvds_layout-4.ddl -$SRC_H5DUMP_TESTFILES/vds/tvds_layout-5.ddl -$SRC_H5DUMP_TESTFILES/vds/vds-first.ddl -$SRC_H5DUMP_TESTFILES/vds/vds-gap1.ddl -$SRC_H5DUMP_TESTFILES/vds/vds-gap2.ddl -$SRC_H5DUMP_TESTFILES/vds/vds_layout-eiger.ddl -$SRC_H5DUMP_TESTFILES/vds/vds_layout-maxmin.ddl -" - -LIST_ERROR_TEST_FILES=" -" - -# -# copy test files and expected output files from source dirs to test dir -# -COPY_TESTFILES="$LIST_HDF5_TEST_FILES $LIST_OTHER_TEST_FILES $LIST_ERROR_TEST_FILES" - -COPY_TESTFILES_TO_TESTDIR() -{ - # copy test files. Used -f to make sure get a new copy - for tstfile in $COPY_TESTFILES - do - # ignore '#' comment - echo $tstfile | tr -d ' ' | grep '^#' > /dev/null - RET=$? - if [ $RET -eq 1 ]; then - # skip cp if srcdir is same as destdir - # this occurs when build/test performed in source dir and - # make cp fail - SDIR=`$DIRNAME $tstfile` - INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'` - INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'` - if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then - $CP -f $tstfile $TESTDIR - if [ $? -ne 0 ]; then - echo "Error: FAILED to copy $tstfile ." - - # Comment out this to CREATE expected file - exit $EXIT_FAILURE - fi - fi - fi - done -} - -CLEAN_TESTFILES_AND_TESTDIR() -{ - # skip rm if srcdir is same as destdir - # this occurs when build/test performed in source dir and - # make cp fail - SDIR=$SRC_H5DUMP_TESTFILES/vds - INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'` - INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'` - if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then - $RM $TESTDIR - fi -} - -# Print a line-line message left justified in a field of 70 characters -# beginning with the word "Testing". -# -TESTING() { - SPACES=" " - echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012' -} - -# Source in the output filter function definitions. -. $srcdir/../../bin/output_filter.sh - -# Run a test and print PASS or *FAIL*. If a test fails then increment -# the `nerrors' global variable and (if $verbose is set) display the -# difference between the actual output and the expected output. The -# expected output is given as the first argument to this function and -# the actual output file is calculated by replacing the `.ddl' with -# `.out'. The actual output is not removed if $HDF5_NOCLEANUP has a -# non-zero value. -# -TOOLTEST() { - expect="$TESTDIR/$1" - actual="$TESTDIR/`basename $1 .ddl`.out" - actual_err="$TESTDIR/`basename $1 .ddl`.err" - actual_sav=${actual}-sav - actual_err_sav=${actual_err}-sav - shift - - # Run test. - TESTING $DUMPER $@ - ( - cd $TESTDIR - $RUNSERIAL $DUMPER_BIN "$@" - ) >$actual 2>$actual_err - - # save actual and actual_err in case they are needed later. - cp $actual $actual_sav - STDOUT_FILTER $actual - cp $actual_err $actual_err_sav - STDERR_FILTER $actual_err - cat $actual_err >> $actual - - if [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect - elif $CMP $expect $actual; then - echo " PASSED" - else - echo "*FAILED*" - echo " Expected result (*.ddl) differs from actual result (*.out)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' - fi - - # Clean up output file - if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actual_err $actual_sav $actual_err_sav $actual_ext - fi - -} - - -# same as TOOLTEST1 but compares generated file to expected output -# and compares the generated data file to the expected data file -# used for the binary tests that expect a full path in -o without -b -TOOLTEST2() { - - expectdata="$TESTDIR/$1" - expect="$TESTDIR/`basename $1 .exp`.ddl" - actualdata="$TESTDIR/`basename $1 .exp`.txt" - actual="$TESTDIR/`basename $1 .exp`.out" - actual_err="$TESTDIR/`basename $1 .exp`.err" - shift - - # Run test. - TESTING $DUMPER $@ - ( - cd $TESTDIR - $RUNSERIAL $DUMPER_BIN "$@" - ) >$actual 2>$actual_err - cat $actual_err >> $actual - - if [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect - elif $CMP $expect $actual; then - if [ ! -f $expectdata ]; then - # Create the expect data file if it doesn't yet exist. - echo " CREATED" - cp $actualdata $expectdata - elif $CMP $expectdata $actualdata; then - echo " PASSED" - else - echo "*FAILED*" - echo " Expected datafile (*.exp) differs from actual datafile (*.txt)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expectdata $actualdata |sed 's/^/ /' - fi - else - echo "*FAILED*" - echo " Expected result (*.ddl) differs from actual result (*.out)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' - fi - - # Clean up output file - if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actualdata $actual_err - fi - -} - -# same as TOOLTEST but filters error stack outp -# Extract file name, line number, version and thread IDs because they may be different -TOOLTEST3() { - - expect="$TESTDIR/$1" - actual="$TESTDIR/`basename $1 .ddl`.out" - actual_err="$TESTDIR/`basename $1 .ddl`.err" - actual_ext="$TESTDIR/`basename $1 .ddl`.ext" - actual_sav=${actual}-sav - actual_err_sav=${actual_err}-sav - shift - - # Run test. - TESTING $DUMPER $@ - ( - cd $TESTDIR - $RUNSERIAL $DUMPER_BIN "$@" - ) >$actual 2>$actual_err - - # save actual and actual_err in case they are needed later. - cp $actual $actual_sav - STDOUT_FILTER $actual - cp $actual_err $actual_err_sav - STDERR_FILTER $actual_err - - # Extract file name, line number, version and thread IDs because they may be different - sed -e 's/thread [0-9]*/thread (IDs)/' -e 's/: .*\.c /: (file name) /' \ - -e 's/line [0-9]*/line (number)/' \ - -e 's/v[1-9]*\.[0-9]*\./version (number)\./' \ - -e 's/[1-9]*\.[0-9]*\.[0-9]*[^)]*/version (number)/' \ - -e 's/H5Eget_auto[1-2]*/H5Eget_auto(1 or 2)/' \ - -e 's/H5Eset_auto[1-2]*/H5Eset_auto(1 or 2)/' \ - $actual_err > $actual_ext - cat $actual_ext >> $actual - - if [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect - elif $CMP $expect $actual; then - echo " PASSED" - else - echo "*FAILED*" - echo " Expected result (*.ddl) differs from actual result (*.out)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' - fi - - # Clean up output file - if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actual_err $actual_sav $actual_err_sav - fi - -} - -# same as TOOLTEST3 but filters error stack output and compares to an error file -# Extract file name, line number, version and thread IDs because they may be different -TOOLTEST4() { - - expect="$TESTDIR/$1" - expect_err="$TESTDIR/`basename $1 .ddl`.err" - actual="$TESTDIR/`basename $1 .ddl`.out" - actual_err="$TESTDIR/`basename $1 .ddl`.oerr" - actual_ext="$TESTDIR/`basename $1 .ddl`.ext" - actual_sav=${actual}-sav - actual_err_sav=${actual_err}-sav - shift - - # Run test. - TESTING $DUMPER $@ - ( - cd $TESTDIR - $RUNSERIAL $DUMPER_BIN "$@" - ) >$actual 2>$actual_err - - # save actual and actual_err in case they are needed later. - cp $actual $actual_sav - STDOUT_FILTER $actual - cp $actual_err $actual_err_sav - STDERR_FILTER $actual_err - - # Extract file name, line number, version and thread IDs because they may be different - sed -e 's/thread [0-9]*/thread (IDs)/' -e 's/: .*\.c /: (file name) /' \ - -e 's/line [0-9]*/line (number)/' \ - -e 's/v[1-9]*\.[0-9]*\./version (number)\./' \ - -e 's/[1-9]*\.[0-9]*\.[0-9]*[^)]*/version (number)/' \ - -e 's/H5Eget_auto[1-2]*/H5Eget_auto(1 or 2)/' \ - -e 's/H5Eset_auto[1-2]*/H5Eset_auto(1 or 2)/' \ - $actual_err > $actual_ext - #cat $actual_ext >> $actual - - if [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect - elif $CMP $expect $actual; then - if $CMP $expect_err $actual_ext; then - echo " PASSED" - else - echo "*FAILED*" - echo " Expected result (*.err) differs from actual result (*.oerr)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect_err $actual_ext |sed 's/^/ /' - fi - else - echo "*FAILED*" - echo " Expected result (*.ddl) differs from actual result (*.out)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' - fi - - # Clean up output file - if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actual_err $actual_sav $actual_err_sav - fi - -} - -# Print a "SKIP" message -SKIP() { - TESTING $DUMPER $@ - echo " -SKIP-" -} - -# Print a line-line message left justified in a field of 70 characters -# -PRINT_H5DIFF() { - SPACES=" " - echo " Running h5diff $* $SPACES" | cut -c1-70 | tr -d '\012' -} - - -# Call the h5diff tool -# -DIFFTEST() -{ - PRINT_H5DIFF $@ - ( - cd $TESTDIR - $RUNSERIAL $H5DIFF_BIN "$@" -q - ) - RET=$? - if [ $RET != 0 ] ; then - echo "*FAILED*" - nerrors="`expr $nerrors + 1`" - else - echo " PASSED" - fi - -} - -# Print a line-line message left justified in a field of 70 characters -# beginning with the word "Verifying". -# -PRINT_H5IMPORT() { - SPACES=" " - echo " Running h5import $* $SPACES" | cut -c1-70 | tr -d '\012' -} - -# Call the h5import tool -# -IMPORTTEST() -{ - # remove the output hdf5 file if it exists - hdf5_file="$TESTDIR/$5" - if [ -f $hdf5_file ]; then - rm -f $hdf5_file - fi - - PRINT_H5IMPORT $@ - ( - cd $TESTDIR - $RUNSERIAL $H5IMPORT_BIN "$@" - ) - RET=$? - if [ $RET != 0 ] ; then - echo "*FAILED*" - nerrors="`expr $nerrors + 1`" - else - echo " PASSED" - fi - -} - - -############################################################################## -############################################################################## -### T H E T E S T S ### -############################################################################## -############################################################################## -# prepare for test -COPY_TESTFILES_TO_TESTDIR - -####### test for dataset vds ###### - - # Data read -if test $USE_FILTER_DEFLATE = "yes" ; then - TOOLTEST tvds-1.ddl --enable-error-stack 1_vds.h5 - TOOLTEST tvds-2.ddl --enable-error-stack 2_vds.h5 - TOOLTEST tvds-3_1.ddl --enable-error-stack 3_1_vds.h5 - TOOLTEST tvds-3_2.ddl --enable-error-stack 3_2_vds.h5 - TOOLTEST tvds-4.ddl --enable-error-stack 4_vds.h5 - TOOLTEST tvds-5.ddl --enable-error-stack 5_vds.h5 - TOOLTEST vds-first.ddl --vds-view-first-missing --enable-error-stack vds-percival-unlim-maxmin.h5 - TOOLTEST vds-gap1.ddl -d /VDS-Eiger --vds-gap-size=1 --enable-error-stack vds-eiger.h5 - TOOLTEST vds-gap2.ddl --vds-gap-size=2 --enable-error-stack vds-eiger.h5 -fi - - # Layout read -if test $USE_FILTER_DEFLATE = "yes" ; then - TOOLTEST tvds_layout-1.ddl -p --enable-error-stack 1_vds.h5 - TOOLTEST tvds_layout-2.ddl -p --enable-error-stack 2_vds.h5 - TOOLTEST tvds_layout-3_1.ddl -p --enable-error-stack 3_1_vds.h5 - TOOLTEST tvds_layout-3_2.ddl -p --enable-error-stack 3_2_vds.h5 - TOOLTEST tvds_layout-4.ddl -p --enable-error-stack 4_vds.h5 - TOOLTEST tvds_layout-5.ddl -p --enable-error-stack 5_vds.h5 - TOOLTEST vds_layout-eiger.ddl -p --enable-error-stack vds-eiger.h5 - TOOLTEST vds_layout-maxmin.ddl -p --enable-error-stack vds-percival-unlim-maxmin.h5 -fi - -# Clean up temporary files/directories -CLEAN_TESTFILES_AND_TESTDIR - -# Report test results and exit -if test $nerrors -eq 0 ; then - echo "All $TESTNAME tests passed." - exit $EXIT_SUCCESS -else - echo "$TESTNAME tests failed with $nerrors errors." - exit $EXIT_FAILURE -fi diff --git a/tools/h5dump/testh5dumpxml.sh.in b/tools/h5dump/testh5dumpxml.sh.in deleted file mode 100644 index 33a67c0..0000000 --- a/tools/h5dump/testh5dumpxml.sh.in +++ /dev/null @@ -1,388 +0,0 @@ -#! /bin/sh -# -# 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. -# -# Tests for the h5dump tool - -srcdir=@srcdir@ - -TESTNAME=h5dumpxml -EXIT_SUCCESS=0 -EXIT_FAILURE=1 - -DUMPER=h5dump # The tool name -DUMPER_BIN=`pwd`/$DUMPER # The path of the tool binary - -RM='rm -rf' -CMP='cmp -s' -DIFF='diff -c' -CP='cp' -DIRNAME='dirname' -LS='ls' -AWK='awk' - -nerrors=0 -verbose=yes - -# source dirs -SRC_TOOLS="$srcdir/../" - -SRC_TOOLS_TESTFILES="$SRC_TOOLS/testfiles" -# testfiles source dirs for tools -SRC_H5LS_TESTFILES="$SRC_TOOLS_TESTFILES" -SRC_H5DUMP_TESTFILES="$SRC_TOOLS_TESTFILES" -SRC_H5DIFF_TESTFILES="$SRC_TOOLS/h5diff/testfiles" -SRC_H5COPY_TESTFILES="$SRC_TOOLS/h5copy/testfiles" -SRC_H5REPACK_TESTFILES="$SRC_TOOLS/h5repack/testfiles" -SRC_H5JAM_TESTFILES="$SRC_TOOLS/h5jam/testfiles" -SRC_H5STAT_TESTFILES="$SRC_TOOLS/h5stat/testfiles" -SRC_H5IMPORT_TESTFILES="$SRC_TOOLS/h5import/testfiles" - -TEST_P_DIR=./testfiles -TESTDIR=./testfiles/xml -test -d $TEST_P_DIR || mkdir -p $TEST_P_DIR -test -d $TESTDIR || mkdir -p $TESTDIR - -###################################################################### -# test files -# -------------------------------------------------------------------- -# All the test files copy from source directory to test directory -# NOTE: Keep this framework to add/remove test files. -# Any test files from other tools can be used in this framework. -# This list are also used for checking exist. -# Comment '#' without space can be used. -# -------------------------------------------------------------------- -LIST_HDF5_TEST_FILES_XML=" -$SRC_H5DUMP_TESTFILES/tall.h5 -$SRC_H5DUMP_TESTFILES/tarray1.h5 -$SRC_H5DUMP_TESTFILES/tarray2.h5 -$SRC_H5DUMP_TESTFILES/tarray3.h5 -$SRC_H5DUMP_TESTFILES/tarray6.h5 -$SRC_H5DUMP_TESTFILES/tarray7.h5 -$SRC_H5DUMP_TESTFILES/tattr.h5 -$SRC_H5DUMP_TESTFILES/tbitfields.h5 -$SRC_H5DUMP_TESTFILES/tcompound.h5 -$SRC_H5DUMP_TESTFILES/tcompound2.h5 -$SRC_H5DUMP_TESTFILES/tcompound_complex.h5 -$SRC_H5DUMP_TESTFILES/tdatareg.h5 -$SRC_H5DUMP_TESTFILES/tdset.h5 -$SRC_H5DUMP_TESTFILES/tdset2.h5 -$SRC_H5DUMP_TESTFILES/tempty.h5 -$SRC_H5DUMP_TESTFILES/tenum.h5 -$SRC_H5DUMP_TESTFILES/textlink.h5 -$SRC_H5DUMP_TESTFILES/tfpformat.h5 -$SRC_H5DUMP_TESTFILES/tgroup.h5 -$SRC_H5DUMP_TESTFILES/thlink.h5 -$SRC_H5DUMP_TESTFILES/tloop.h5 -$SRC_H5DUMP_TESTFILES/tloop2.h5 -$SRC_H5DUMP_TESTFILES/tmany.h5 -$SRC_H5DUMP_TESTFILES/tname-amp.h5 -$SRC_H5DUMP_TESTFILES/tname-apos.h5 -$SRC_H5DUMP_TESTFILES/tname-gt.h5 -$SRC_H5DUMP_TESTFILES/tname-lt.h5 -$SRC_H5DUMP_TESTFILES/tname-quot.h5 -$SRC_H5DUMP_TESTFILES/tname-sp.h5 -$SRC_H5DUMP_TESTFILES/tnamed_dtype_attr.h5 -$SRC_H5DUMP_TESTFILES/tnestedcomp.h5 -$SRC_H5DUMP_TESTFILES/tnodata.h5 -$SRC_H5DUMP_TESTFILES/tobjref.h5 -$SRC_H5DUMP_TESTFILES/topaque.h5 -$SRC_H5DUMP_TESTFILES/torderattr.h5 -$SRC_H5DUMP_TESTFILES/tref.h5 -$SRC_H5DUMP_TESTFILES/tref-escapes.h5 -$SRC_H5DUMP_TESTFILES/tref-escapes-at.h5 -$SRC_H5DUMP_TESTFILES/tsaf.h5 -$SRC_H5DUMP_TESTFILES/tslink.h5 -$SRC_H5DUMP_TESTFILES/tstring.h5 -$SRC_H5DUMP_TESTFILES/tstring-at.h5 -$SRC_H5DUMP_TESTFILES/tstr.h5 -$SRC_H5DUMP_TESTFILES/tstr2.h5 -$SRC_H5DUMP_TESTFILES/tudlink.h5 -$SRC_H5DUMP_TESTFILES/tvldtypes1.h5 -$SRC_H5DUMP_TESTFILES/tvldtypes2.h5 -$SRC_H5DUMP_TESTFILES/tvldtypes3.h5 -$SRC_H5DUMP_TESTFILES/tvldtypes4.h5 -$SRC_H5DUMP_TESTFILES/tvldtypes5.h5 -$SRC_H5DUMP_TESTFILES/tvlstr.h5 -" - -LIST_OTHER_TEST_FILES_XML=" -$SRC_H5DUMP_TESTFILES/tall.h5.xml -$SRC_H5DUMP_TESTFILES/tall-2A.h5.xml -$SRC_H5DUMP_TESTFILES/tarray1.h5.xml -$SRC_H5DUMP_TESTFILES/tarray2.h5.xml -$SRC_H5DUMP_TESTFILES/tarray3.h5.xml -$SRC_H5DUMP_TESTFILES/tarray6.h5.xml -$SRC_H5DUMP_TESTFILES/tarray7.h5.xml -$SRC_H5DUMP_TESTFILES/tattr.h5.xml -$SRC_H5DUMP_TESTFILES/tbitfields.h5.xml -$SRC_H5DUMP_TESTFILES/tcompound_complex.h5.xml -$SRC_H5DUMP_TESTFILES/tcompound.h5.xml -$SRC_H5DUMP_TESTFILES/tcompound2.h5.xml -$SRC_H5DUMP_TESTFILES/tdatareg.h5.xml -$SRC_H5DUMP_TESTFILES/tdset.h5.xml -$SRC_H5DUMP_TESTFILES/tdset2.h5.xml -$SRC_H5DUMP_TESTFILES/tempty.h5.xml -$SRC_H5DUMP_TESTFILES/tempty-dtd.h5.xml -$SRC_H5DUMP_TESTFILES/tempty-dtd-2.h5.xml -$SRC_H5DUMP_TESTFILES/tempty-dtd-uri.h5.xml -$SRC_H5DUMP_TESTFILES/tempty-nons.h5.xml -$SRC_H5DUMP_TESTFILES/tempty-nons-2.h5.xml -$SRC_H5DUMP_TESTFILES/tempty-nons-uri.h5.xml -$SRC_H5DUMP_TESTFILES/tempty-ns.h5.xml -$SRC_H5DUMP_TESTFILES/tempty-ns-2.h5.xml -$SRC_H5DUMP_TESTFILES/tenum.h5.xml -$SRC_H5DUMP_TESTFILES/textlink.h5.xml -$SRC_H5DUMP_TESTFILES/tfpformat.h5.xml -$SRC_H5DUMP_TESTFILES/tgroup.h5.xml -$SRC_H5DUMP_TESTFILES/thlink.h5.xml -$SRC_H5DUMP_TESTFILES/tloop.h5.xml -$SRC_H5DUMP_TESTFILES/tloop2.h5.xml -$SRC_H5DUMP_TESTFILES/tmany.h5.xml -$SRC_H5DUMP_TESTFILES/tname-amp.h5.xml -$SRC_H5DUMP_TESTFILES/tname-apos.h5.xml -$SRC_H5DUMP_TESTFILES/tnamed_dtype_attr.h5.xml -$SRC_H5DUMP_TESTFILES/tname-gt.h5.xml -$SRC_H5DUMP_TESTFILES/tname-lt.h5.xml -$SRC_H5DUMP_TESTFILES/tname-quot.h5.xml -$SRC_H5DUMP_TESTFILES/tname-sp.h5.xml -$SRC_H5DUMP_TESTFILES/tnestedcomp.h5.xml -$SRC_H5DUMP_TESTFILES/tnodata.h5.xml -$SRC_H5DUMP_TESTFILES/tobjref.h5.xml -$SRC_H5DUMP_TESTFILES/topaque.h5.xml -$SRC_H5DUMP_TESTFILES/torderattr1.h5.xml -$SRC_H5DUMP_TESTFILES/torderattr2.h5.xml -$SRC_H5DUMP_TESTFILES/torderattr3.h5.xml -$SRC_H5DUMP_TESTFILES/torderattr4.h5.xml -$SRC_H5DUMP_TESTFILES/tref.h5.xml -$SRC_H5DUMP_TESTFILES/tref-escapes.h5.xml -$SRC_H5DUMP_TESTFILES/tref-escapes-at.h5.xml -$SRC_H5DUMP_TESTFILES/tsaf.h5.xml -$SRC_H5DUMP_TESTFILES/tslink.h5.xml -$SRC_H5DUMP_TESTFILES/tstr.h5.xml -$SRC_H5DUMP_TESTFILES/tstr2.h5.xml -$SRC_H5DUMP_TESTFILES/tstring.h5.xml -$SRC_H5DUMP_TESTFILES/tstring-at.h5.xml -$SRC_H5DUMP_TESTFILES/tudlink.h5.xml -$SRC_H5DUMP_TESTFILES/tvldtypes1.h5.xml -$SRC_H5DUMP_TESTFILES/tvldtypes2.h5.xml -$SRC_H5DUMP_TESTFILES/tvldtypes3.h5.xml -$SRC_H5DUMP_TESTFILES/tvldtypes4.h5.xml -$SRC_H5DUMP_TESTFILES/tvldtypes5.h5.xml -$SRC_H5DUMP_TESTFILES/tvlstr.h5.xml -" - -# -# copy test files and expected output files from source dirs to test dir -# -COPY_TESTFILES="$LIST_HDF5_TEST_FILES_XML $LIST_OTHER_TEST_FILES_XML" - -COPY_TESTFILES_TO_TESTDIR() -{ - # copy test files. Used -f to make sure get a new copy - for tstfile in $COPY_TESTFILES - do - # ignore '#' comment - echo $tstfile | tr -d ' ' | grep '^#' > /dev/null - RET=$? - if [ $RET -eq 1 ]; then - # skip cp if srcdir is same as destdir - # this occurs when build/test performed in source dir and - # make cp fail - SDIR=`$DIRNAME $tstfile` - INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'` - INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'` - if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then - $CP -f $tstfile $TESTDIR - if [ $? -ne 0 ]; then - echo "Error: FAILED to copy $tstfile ." - - # Comment out this to CREATE expected file - exit $EXIT_FAILURE - fi - fi - fi - done -} - -CLEAN_TESTFILES_AND_TESTDIR() -{ - # skip rm if srcdir is same as destdir - # this occurs when build/test performed in source dir and - # make cp fail - SDIR=$SRC_H5DUMP_TESTFILES - INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'` - INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'` - if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then - $RM $TESTDIR - fi -} - -# Print a line-line message left justified in a field of 70 characters -# beginning with the word "Testing". -# -TESTING() { - SPACES=" " - echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012' -} - -# Source in the output filter function definitions. -. $srcdir/../../bin/output_filter.sh - -# Run a test and print PASS or *FAIL*. If a test fails then increment -# the `nerrors' global variable and (if $verbose is set) display the -# difference between the actual output and the expected output. The -# expected output is given as the first argument to this function and -# the actual output file is calculated by replacing the `.ddl' with -# `.out'. The actual output is not removed if $HDF5_NOCLEANUP has a -# non-zero value. -# -TOOLTEST() { - expect="$TESTDIR/$1" - actual="$TESTDIR/`basename $1 .xml`.out" - actual_err="$TESTDIR/`basename $1 .xml`.err" - shift - - # Run test. - TESTING $DUMPER $@ - ( - cd $TESTDIR - $RUNSERIAL $DUMPER_BIN "$@" - ) >$actual 2>$actual_err - - - if [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect - elif $CMP $expect $actual; then - echo " PASSED" - else - echo "*FAILED*" - echo " Expected result (*.xml) differs from actual result (*.out)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' - fi - - # Clean up output file - if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actual_err - fi -} - -# Print a "SKIP" message -SKIP() { - TESTING $DUMPER $@ - echo " -SKIP-" -} - - -############################################################################## -############################################################################## -### T H E T E S T S ### -############################################################################## -############################################################################## -# prepare for test -COPY_TESTFILES_TO_TESTDIR - -# test XML -TOOLTEST tall.h5.xml --xml tall.h5 -TOOLTEST tattr.h5.xml --xml tattr.h5 -TOOLTEST tbitfields.h5.xml --xml tbitfields.h5 -TOOLTEST tcompound.h5.xml --xml tcompound.h5 -TOOLTEST tcompound2.h5.xml --xml tcompound2.h5 -TOOLTEST tdatareg.h5.xml --xml tdatareg.h5 -TOOLTEST tdset.h5.xml --xml tdset.h5 -TOOLTEST tdset2.h5.xml --xml tdset2.h5 -TOOLTEST tenum.h5.xml --xml tenum.h5 -TOOLTEST tgroup.h5.xml --xml tgroup.h5 -TOOLTEST thlink.h5.xml --xml thlink.h5 -TOOLTEST tloop.h5.xml --xml tloop.h5 -TOOLTEST tloop2.h5.xml --xml tloop2.h5 -TOOLTEST tmany.h5.xml --xml tmany.h5 -TOOLTEST tnestedcomp.h5.xml --xml tnestedcomp.h5 -TOOLTEST tcompound_complex.h5.xml --xml tcompound_complex.h5 -TOOLTEST tobjref.h5.xml --xml tobjref.h5 -TOOLTEST topaque.h5.xml --xml topaque.h5 -TOOLTEST tslink.h5.xml --xml tslink.h5 -TOOLTEST tudlink.h5.xml --xml tudlink.h5 -TOOLTEST textlink.h5.xml --xml textlink.h5 -TOOLTEST tstr.h5.xml --xml tstr.h5 -TOOLTEST tstr2.h5.xml --xml tstr2.h5 -TOOLTEST tref.h5.xml --xml tref.h5 -TOOLTEST tname-amp.h5.xml --xml tname-amp.h5 -TOOLTEST tname-apos.h5.xml --xml tname-apos.h5 -TOOLTEST tname-gt.h5.xml --xml tname-gt.h5 -TOOLTEST tname-lt.h5.xml --xml tname-lt.h5 -TOOLTEST tname-quot.h5.xml --xml tname-quot.h5 -TOOLTEST tname-sp.h5.xml --xml tname-sp.h5 -TOOLTEST tstring.h5.xml --xml tstring.h5 -TOOLTEST tstring-at.h5.xml --xml tstring-at.h5 -TOOLTEST tref-escapes.h5.xml --xml tref-escapes.h5 -TOOLTEST tref-escapes-at.h5.xml --xml tref-escapes-at.h5 -TOOLTEST tnodata.h5.xml --xml tnodata.h5 -TOOLTEST tarray1.h5.xml --xml tarray1.h5 -TOOLTEST tarray2.h5.xml --xml tarray2.h5 -TOOLTEST tarray3.h5.xml --xml tarray3.h5 -TOOLTEST tarray6.h5.xml --xml tarray6.h5 -TOOLTEST tarray7.h5.xml --xml tarray7.h5 -TOOLTEST tvldtypes1.h5.xml --xml tvldtypes1.h5 -TOOLTEST tvldtypes2.h5.xml --xml tvldtypes2.h5 -TOOLTEST tvldtypes3.h5.xml --xml tvldtypes3.h5 -TOOLTEST tvldtypes4.h5.xml --xml tvldtypes4.h5 -TOOLTEST tvldtypes5.h5.xml --xml tvldtypes5.h5 -TOOLTEST tvlstr.h5.xml --xml tvlstr.h5 -TOOLTEST tsaf.h5.xml --xml tsaf.h5 -TOOLTEST tempty.h5.xml --xml tempty.h5 -TOOLTEST tnamed_dtype_attr.h5.xml --xml tnamed_dtype_attr.h5 -##Test dataset and attribute of null space. Commented out: -## wait until the XML schema is updated for null space. -##TOOLTEST tnullspace.h5.xml --xml tnulspace.h5 - -# other options for xml - -TOOLTEST tempty-dtd.h5.xml --xml --use-dtd tempty.h5 -TOOLTEST tempty-dtd-2.h5.xml --xml -u tempty.h5 -TOOLTEST tempty-nons.h5.xml --xml -X ":" tempty.h5 -TOOLTEST tempty-nons-2.h5.xml --xml --xml-ns=":" tempty.h5 - -## Some of these combinations are syntactically correct but -## the URLs are dummies -TOOLTEST tempty-ns.h5.xml --xml -X "thing:" tempty.h5 -TOOLTEST tempty-ns-2.h5.xml --xml --xml-ns="thing:" tempty.h5 -TOOLTEST tempty-nons-uri.h5.xml --xml --xml-ns=":" --xml-dtd="http://somewhere.net" tempty.h5 -TOOLTEST tempty-dtd-uri.h5.xml --xml --use-dtd --xml-dtd="http://somewhere.net" tempty.h5 - -TOOLTEST tall-2A.h5.xml --xml -A tall.h5 - - -# tests for attribute order -TOOLTEST torderattr1.h5.xml --xml -H --sort_by=name --sort_order=ascending torderattr.h5 -TOOLTEST torderattr2.h5.xml --xml -H --sort_by=name --sort_order=descending torderattr.h5 -TOOLTEST torderattr3.h5.xml --xml -H --sort_by=creation_order --sort_order=ascending torderattr.h5 -TOOLTEST torderattr4.h5.xml --xml -H --sort_by=creation_order --sort_order=descending torderattr.h5 - -# tests for floating point user defined printf format -TOOLTEST tfpformat.h5.xml -u -m %.7f tfpformat.h5 - -# Clean up temporary files/directories -CLEAN_TESTFILES_AND_TESTDIR - -if test $nerrors -eq 0 ; then - echo "All $TESTNAME tests passed." - exit $EXIT_SUCCESS -else - echo "$TESTNAME tests failed with $nerrors errors." - exit $EXIT_FAILURE -fi |