diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2010-07-06 19:45:35 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2010-07-06 19:45:35 (GMT) |
commit | 98754fa9d12090f5e048fdb05cc5e9ce9111676f (patch) | |
tree | 407e611b19ee551d8153779104022dd886a467e5 /tools/h5dump | |
parent | 29321bcafa9f1c6108bb92b5a844a9d4d9c2c8e7 (diff) | |
download | hdf5-98754fa9d12090f5e048fdb05cc5e9ce9111676f.zip hdf5-98754fa9d12090f5e048fdb05cc5e9ce9111676f.tar.gz hdf5-98754fa9d12090f5e048fdb05cc5e9ce9111676f.tar.bz2 |
[svn-r19050] Description:
Bring r18704:19049 from trunk to revise_chunks branch.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
Mac OS X/32 10.6.3 (amazon) in debug mode
Mac OS X/32 10.6.3 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
Diffstat (limited to 'tools/h5dump')
-rw-r--r-- | tools/h5dump/CMakeLists.txt | 628 | ||||
-rw-r--r-- | tools/h5dump/Makefile.in | 2 | ||||
-rw-r--r-- | tools/h5dump/h5dump.c | 326 | ||||
-rw-r--r-- | tools/h5dump/h5dumpgentest.c | 280 |
4 files changed, 1055 insertions, 181 deletions
diff --git a/tools/h5dump/CMakeLists.txt b/tools/h5dump/CMakeLists.txt new file mode 100644 index 0000000..eb54e00 --- /dev/null +++ b/tools/h5dump/CMakeLists.txt @@ -0,0 +1,628 @@ +cmake_minimum_required (VERSION 2.8) +PROJECT (HDF5_TOOLS_H5DUMP) + +#----------------------------------------------------------------------------- +# Setup include Directories +#----------------------------------------------------------------------------- +INCLUDE_DIRECTORIES (${HDF5_TOOLS_SOURCE_DIR}/lib) +INCLUDE_DIRECTORIES (${HDF5_PROJECT_DIR}/test) + +# -------------------------------------------------------------------- +# Add the h5dump and test executables +# -------------------------------------------------------------------- +ADD_EXECUTABLE (h5dump ${HDF5_TOOLS_H5DUMP_SOURCE_DIR}/h5dump.c) +H5_NAMING (h5dump) +IF (WIN32) + IF (MSVC) + IF (NOT BUILD_SHARED_LIBS) + SET_TARGET_PROPERTIES (h5dump + PROPERTIES + LINK_FLAGS "/NODEFAULTLIB:MSVCRT" + ) + ENDIF (NOT BUILD_SHARED_LIBS) + ENDIF (MSVC) +ENDIF (WIN32) +TARGET_LINK_LIBRARIES (h5dump ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) + +SET (H5_DEP_EXECUTABLES h5dump) + +IF (BUILD_TESTING) + IF (NOT BUILD_SHARED_LIBS) + ADD_EXECUTABLE (h5dumpgentest ${HDF5_TOOLS_H5DUMP_SOURCE_DIR}/h5dumpgentest.c) + H5_NAMING (h5dumpgentest) + IF (WIN32) + IF (MSVC) + SET_TARGET_PROPERTIES (h5dumpgentest + PROPERTIES + LINK_FLAGS "/NODEFAULTLIB:MSVCRT" + ) + ENDIF (MSVC) + ENDIF (WIN32) + TARGET_LINK_LIBRARIES (h5dumpgentest ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET}) + + #ADD_TEST (NAME h5dumpgentest COMMAND $<TARGET_FILE:h5dumpgentest>) + + SET (H5_DEP_EXECUTABLES ${H5_DEP_EXECUTABLES} + # h5dumpgentest + ) + ENDIF (NOT BUILD_SHARED_LIBS) + + #-- Copy all the HDF5 files from the test directory into the source directory + SET (HDF5_REFERENCE_FILES + tall-1.ddl + tall-2.ddl + tall-2A.ddl + tall-2B.ddl + tall-3.ddl + tall-4s.ddl + tall-5s.ddl + tallfilters.ddl + tarray1.ddl + tarray2.ddl + tarray3.ddl + tarray4.ddl + tarray5.ddl + tarray6.ddl + tarray7.ddl + tarray8.ddl + tattr-1.ddl + tattr-2.ddl + tattr-3.ddl + tattrreg.ddl + tattrregR.ddl + tbigdims.ddl + tboot1.ddl + tboot2.ddl + tchar1.ddl + tchunked.ddl + tcomp-1.ddl + tcomp-2.ddl + tcomp-3.ddl + tcomp-4.ddl + tcompact.ddl + tcontents.ddl + tcontiguos.ddl + tdatareg.ddl + tdataregR.ddl + tdeflate.ddl + tdset-1.ddl + tdset-2.ddl + tdset-3s.ddl + tempty.ddl + texternal.ddl + textlinksrc.ddl + textlinkfar.ddl + tfamily.ddl + tfill.ddl + tfletcher32.ddl + tfpformat.ddl + tgroup-1.ddl + tgroup-2.ddl + tgrp_comments.ddl + thlink-1.ddl + thlink-2.ddl + thlink-3.ddl + thlink-4.ddl + thlink-5.ddl + thyperslab.ddl + tindicesno.ddl + tindicessub1.ddl + tindicessub2.ddl + tindicessub3.ddl + tindicessub4.ddl + tindicesyes.ddl + tlarge_objname.ddl + #tldouble.ddl + tlonglinks.ddl + tloop-1.ddl + tmulti.ddl + tnamed_dtype_attr.ddl + tnestcomp-1.ddl + tnbit.ddl + tnofilename.ddl + tnullspace.ddl + tordergr1.ddl + tordergr2.ddl + tordergr3.ddl + tordergr4.ddl + tordergr5.ddl + torderattr1.ddl + torderattr2.ddl + torderattr3.ddl + torderattr4.ddl + tperror.ddl + treference.ddl + tsaf.ddl + tscaleoffset.ddl + tshuffle.ddl + tslink-1.ddl + tslink-2.ddl + tsplit_file.ddl + tstr-1.ddl + tstr-2.ddl + tstring.ddl + tstring2.ddl + tstringe.ddl + tszip.ddl + tudlink-1.ddl + tudlink-2.ddl + tuserfilter.ddl + tvldtypes1.ddl + tvldtypes2.ddl + tvldtypes3.ddl + tvldtypes4.ddl + tvldtypes5.ddl + tvlstr.ddl + tvms.ddl + ) + SET (HDF5_REFERENCE_TEST_FILES + tbin1.ddl + tbin1.ddl + tbin2.ddl + tbin3.ddl + tbin4.ddl + out3.h5import + taindices.h5 + tall.h5 + tarray1.h5 + tarray2.h5 + tarray3.h5 + tarray4.h5 + tarray5.h5 + tarray6.h5 + tarray7.h5 + tarray8.h5 + tattr.h5 + tattr2.h5 + tattrreg.h5 + tbigdims.h5 + tbinary.h5 + tchar.h5 + tcompound.h5 + tcompound_complex.h5 + tdatareg.h5 + tdset.h5 + tempty.h5 + textlinkfar.h5 + textlinksrc.h5 + textlinktar.h5 + tfamily00000.h5 + tfamily00001.h5 + tfamily00002.h5 + tfamily00003.h5 + tfamily00004.h5 + tfamily00005.h5 + tfamily00006.h5 + tfamily00007.h5 + tfamily00008.h5 + tfamily00009.h5 + tfamily00010.h5 + tfcontents1.h5 + tfcontents2.h5 + tfilters.h5 + tfpformat.h5 + tfvalues.h5 + tgroup.h5 + tgrp_comments.h5 + thlink.h5 + thyperslab.h5 + tlarge_objname.h5 + #tldouble.h5 + tlonglinks.h5 + tloop.h5 + tmulti-b.h5 + tmulti-g.h5 + tmulti-l.h5 + tmulti-o.h5 + tmulti-r.h5 + tmulti-s.h5 + tnamed_dtype_attr.h5 + tnestedcomp.h5 + tnullspace.h5 + torderattr.h5 + tordergr.h5 + tsaf.h5 + tslink.h5 + tsplit_file-m.h5 + tsplit_file-r.h5 + tstr.h5 + tstr2.h5 + tstr3.h5 + tudlink.h5 + tvldtypes1.h5 + tvldtypes2.h5 + tvldtypes3.h5 + tvldtypes4.h5 + tvldtypes5.h5 + tvlstr.h5 + tvms.h5 + ) + + FOREACH (ddl_file ${HDF5_REFERENCE_FILES}) + SET (ddldest "${PROJECT_BINARY_DIR}/${ddl_file}") + #MESSAGE (STATUS " Translating ${ddl_file}") + ADD_CUSTOM_COMMAND ( + TARGET h5dump + POST_BUILD + COMMAND ${XLATE_UTILITY} + ARGS ${HDF5_TOOLS_SOURCE_DIR}/testfiles/${ddl_file} ${ddldest} -l3 + ) + ENDFOREACH (ddl_file ${HDF5_REFERENCE_FILES}) + + FOREACH (h5_file ${HDF5_REFERENCE_TEST_FILES}) + SET (dest "${PROJECT_BINARY_DIR}/${h5_file}") + #MESSAGE (STATUS " Copying ${h5_file}") + ADD_CUSTOM_COMMAND ( + TARGET h5dump + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different ${HDF5_TOOLS_SOURCE_DIR}/testfiles/${h5_file} ${dest} + ) + ENDFOREACH (h5_file ${HDF5_REFERENCE_TEST_FILES}) + + ADD_CUSTOM_COMMAND ( + TARGET h5dump + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different ${HDF5_TOOLS_SOURCE_DIR}/testfiles/tbin1.ddl ${PROJECT_BINARY_DIR}/tbin1LE.ddl + ) + + MACRO (ADD_SKIP_H5_TEST skipresultfile skipresultcode testtype) + IF (${testtype} STREQUAL "SKIP") + MESSAGE (STATUS "SKIP ${skipresultfile} ${ARGN}") + 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) + 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}" + -D "TEST_OUTPUT=${resultfile}.out" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_REFERENCE=${resultfile}.ddl" + -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + ) + ENDMACRO (ADD_H5_TEST file) + + # Determine which filters are available + SET (USE_FILTER_SZIP H5_HAVE_FILTER_SZIP) + SET (USE_FILTER_DEFLATE H5_HAVE_FILTER_DEFLATE) + SET (USE_FILTER_SHUFFLE H5_HAVE_FILTER_SHUFFLE) + SET (USE_FILTER_FLETCHER32 H5_HAVE_FILTER_FLETCHER32) + SET (USE_FILTER_NBIT H5_HAVE_FILTER_NBIT) + SET (USE_FILTER_SCALEOFFSET H5_HAVE_FILTER_SCALEOFFSET) + +# Determine if H5dump packed bits feature is included + SET (USE_PACKED_BITS HDF5_USE_H5DUMP_PACKED_BITS) + +############################################################################## +############################################################################## +### T H E T E S T S ### +############################################################################## +############################################################################## + # test for displaying groups + ADD_H5_TEST (tgroup-1 0 tgroup.h5) + # test for displaying the selected groups + ADD_H5_TEST (tgroup-2 1 --group=/g2 --group / -g /y tgroup.h5) + + # test for displaying simple space datasets + ADD_H5_TEST (tdset-1 0 tdset.h5) + # test for displaying selected datasets + ADD_H5_TEST (tdset-2 1 -H -d dset1 -d /dset2 --dataset=dset3 tdset.h5) + + # test for displaying attributes + ADD_H5_TEST (tattr-1 0 tattr.h5) + # test for displaying the selected attributes of string type and scalar space + ADD_H5_TEST (tattr-2 0 -a /attr1 --attribute /attr4 --attribute=/attr5 tattr.h5) + # test for header and error messages + ADD_H5_TEST (tattr-3 1 --header -a /attr2 --attribute=/attr tattr.h5) + # test for displaying attributes in shared datatype (also in group and dataset) + ADD_H5_TEST (tnamed_dtype_attr 0 tnamed_dtype_attr.h5) + + # test for displaying soft links and user-defined links + ADD_H5_TEST (tslink-1 0 tslink.h5) + ADD_H5_TEST (tudlink-1 0 tudlink.h5) + # test for displaying the selected link + ADD_H5_TEST (tslink-2 0 -l slink2 tslink.h5) + ADD_H5_TEST (tudlink-2 0 -l udlink2 tudlink.h5) + + # tests for hard links + ADD_H5_TEST (thlink-1 0 thlink.h5) + ADD_H5_TEST (thlink-2 0 -d /g1/dset2 --dataset /dset1 --dataset=/g1/g1.1/dset3 thlink.h5) + ADD_H5_TEST (thlink-3 0 -d /g1/g1.1/dset3 --dataset /g1/dset2 --dataset=/dset1 thlink.h5) + ADD_H5_TEST (thlink-4 0 -g /g1 thlink.h5) + ADD_H5_TEST (thlink-5 0 -d /dset1 -g /g2 -d /g1/dset2 thlink.h5) + + # tests for compound data types + ADD_H5_TEST (tcomp-1 0 tcompound.h5) + # test for named data types + ADD_H5_TEST (tcomp-2 0 -t /type1 --datatype /type2 --datatype=/group1/type3 tcompound.h5) + # test for unamed type + #ADD_H5_TEST (tcomp-3 0 -t /#6632 -g /group2 tcompound.h5) + # test complicated compound datatype + ADD_H5_TEST (tcomp-4 0 tcompound_complex.h5) + + #test for the nested compound type + ADD_H5_TEST (tnestcomp-1 0 tnestedcomp.h5) + + # test for options + ADD_H5_TEST (tall-1 0 tall.h5) + ADD_H5_TEST (tall-2 0 --header -g /g1/g1.1 -a attr2 tall.h5) + ADD_H5_TEST (tall-3 0 -d /g2/dset2.1 -l /g1/g1.2/g1.2.1/slink tall.h5) + + # test for loop detection + ADD_H5_TEST (tloop-1 0 tloop.h5) + + # test for string + ADD_H5_TEST (tstr-1 0 tstr.h5) + ADD_H5_TEST (tstr-2 0 tstr2.h5) + + # test for file created by Lib SAF team + ADD_H5_TEST (tsaf 0 tsaf.h5) + + # test for file with variable length data + ADD_H5_TEST (tvldtypes1 0 tvldtypes1.h5) + ADD_H5_TEST (tvldtypes2 0 tvldtypes2.h5) + ADD_H5_TEST (tvldtypes3 0 tvldtypes3.h5) + ADD_H5_TEST (tvldtypes4 0 tvldtypes4.h5) + ADD_H5_TEST (tvldtypes5 0 tvldtypes5.h5) + + #test for file with variable length string data + ADD_H5_TEST (tvlstr 0 tvlstr.h5) + + # test for files with array data + ADD_H5_TEST (tarray1 0 tarray1.h5) + ADD_H5_TEST (tarray2 0 tarray2.h5) + ADD_H5_TEST (tarray3 0 tarray3.h5) + ADD_H5_TEST (tarray4 0 tarray4.h5) + ADD_H5_TEST (tarray5 0 tarray5.h5) + ADD_H5_TEST (tarray6 0 tarray6.h5) + ADD_H5_TEST (tarray7 0 tarray7.h5) + ADD_H5_TEST (tarray8 0 tarray8.h5) + + # test for files with empty data + ADD_H5_TEST (tempty 0 tempty.h5) + + # test for files with groups that have comments + ADD_H5_TEST (tgrp_comments 0 tgrp_comments.h5) + + # test the --filedriver flag + ADD_H5_TEST (tsplit_file 0 --filedriver=split tsplit_file) + ADD_H5_TEST (tfamily 0 --filedriver=family tfamily%05d.h5) + ADD_H5_TEST (tmulti 0 --filedriver=multi tmulti) + + # test for files with group names which reach > 1024 bytes in size + ADD_H5_TEST (tlarge_objname 0 -w157 tlarge_objname.h5) + + # test '-A' to suppress data but print attr's + ADD_H5_TEST (tall-2A 0 -A tall.h5) + + # test '-r' to print attributes in ASCII instead of decimal + ADD_H5_TEST (tall-2B 0 -A -r tall.h5) + + # test Subsetting + ADD_H5_TEST (tall-4s 0 --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 -d "/g1/g1.1/dset1.1.2[0;2;10;]" tall.h5) + ADD_H5_TEST (tdset-3s 0 -d "/dset1[1,1;;;]" tdset.h5) + + # test printing characters in ASCII instead of decimal + ADD_H5_TEST (tchar1 0 -r tchar.h5) + + # test failure handling + # Missing file name + IF (${USE_PACKED_BITS}) + ADD_H5_TEST (tnofilename-with-packed-bits 1) + ELSE (${USE_PACKED_BITS}) + ADD_H5_TEST (tnofilename 1) + ENDIF (${USE_PACKED_BITS}) + + # rev. 2004 + + # tests for super block + ADD_H5_TEST (tboot1 0 -H -B -d dset tfcontents1.h5) + ADD_H5_TEST (tboot2 0 -B tfcontents2.h5) + + # test -p with a non existing dataset + ADD_H5_TEST (tperror 1 -p -d bogus tfcontents1.h5) + + # test for file contents + ADD_H5_TEST (tcontents 0 -n tfcontents1.h5) + + # tests for storage layout + # compact + ADD_H5_TEST (tcompact 0 -H -p -d compact tfilters.h5) + # contiguous + ADD_H5_TEST (tcontiguos 0 -H -p -d contiguous tfilters.h5) + # chunked + ADD_H5_TEST (tchunked 0 -H -p -d chunked tfilters.h5) + # external + ADD_H5_TEST (texternal 0 -H -p -d external tfilters.h5) + + # fill values + ADD_H5_TEST (tfill 0 -p tfvalues.h5) + + # several datatype, with references , print path + ADD_H5_TEST (treference 0 tattr2.h5) + + # escape/not escape non printable characters + ADD_H5_TEST (tstringe 0 -e tstr3.h5) + ADD_H5_TEST (tstring 0 tstr3.h5) + # char data as ASCII with non escape + ADD_H5_TEST (tstring2 0 -r -d str4 tstr3.h5) + + # array indices print/not print + ADD_H5_TEST (tindicesyes 0 taindices.h5) + ADD_H5_TEST (tindicesno 0 -y taindices.h5) + + ########## array indices with subsetting + # 1D case + ADD_H5_TEST (tindicessub1 0 -d 1d -s 1 -S 10 -c 2 -k 3 taindices.h5) + + # 2D case + ADD_H5_TEST (tindicessub2 0 -d 2d -s 1,2 -S 3,3 -c 3,2 -k 2,2 taindices.h5) + + # 3D case + ADD_H5_TEST (tindicessub3 0 -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 -d 4d -s 0,0,1,2 -c 2,2,3,2 -S 1,1,3,3 -k 1,1,2,2 taindices.h5) + + # tests for filters + # SZIP + SET (TESTTYPE "TEST") + IF (NOT USE_FILTER_SZIP) + SET (TESTTYPE "SKIP") + ENDIF (NOT USE_FILTER_SZIP) + ADD_SKIP_H5_TEST (tszip 0 ${TESTTYPE} -H -p -d szip tfilters.h5) + + # deflate + SET (TESTTYPE "TEST") + IF (NOT USE_FILTER_DEFLATE) + SET (TESTTYPE "SKIP") + ENDIF (NOT USE_FILTER_DEFLATE) + ADD_SKIP_H5_TEST (tdeflate 0 ${TESTTYPE} -H -p -d deflate tfilters.h5) + + # shuffle + SET (TESTTYPE "TEST") + IF (NOT USE_FILTER_SHUFFLE) + SET (TESTTYPE "SKIP") + ENDIF (NOT USE_FILTER_SHUFFLE) + ADD_SKIP_H5_TEST (tshuffle 0 ${TESTTYPE} -H -p -d shuffle tfilters.h5) + + # fletcher32 + SET (TESTTYPE "TEST") + IF (NOT USE_FILTER_FLETCHER32) + SET (TESTTYPE "SKIP") + ENDIF (NOT USE_FILTER_FLETCHER32) + ADD_SKIP_H5_TEST (tfletcher32 0 ${TESTTYPE} -H -p -d fletcher32 tfilters.h5) + + # nbit + SET (TESTTYPE "TEST") + IF (NOT USE_FILTER_NBIT) + SET (TESTTYPE "SKIP") + ENDIF (NOT USE_FILTER_NBIT) + ADD_SKIP_H5_TEST (tnbit 0 ${TESTTYPE} -H -p -d nbit tfilters.h5) + + # scaleoffset + SET (TESTTYPE "TEST") + IF (NOT USE_FILTER_SCALEOFFSET) + SET (TESTTYPE "SKIP") + ENDIF (NOT USE_FILTER_SCALEOFFSET) + ADD_SKIP_H5_TEST (tscaleoffset 0 ${TESTTYPE} -H -p -d scaleoffset tfilters.h5) + + # all + SET (TESTTYPE "TEST") + IF (NOT USE_FILTER_SZIP OR NOT USE_FILTER_SHUFFLE OR NOT USE_FILTER_FLETCHER32 OR NOT USE_FILTER_DEFLATE OR NOT USE_FILTER_NBIT OR NOT USE_FILTER_SCALEOFFSET) + SET (TESTTYPE "SKIP") + ENDIF (NOT USE_FILTER_SZIP OR NOT USE_FILTER_SHUFFLE OR NOT USE_FILTER_FLETCHER32 OR NOT USE_FILTER_DEFLATE OR NOT USE_FILTER_NBIT OR NOT USE_FILTER_SCALEOFFSET) + ADD_SKIP_H5_TEST (tallfilters 0 ${TESTTYPE} -H -p -d all tfilters.h5) + + # user defined + ADD_H5_TEST (tuserfilter 0 -H -p -d myfilter tfilters.h5) + + # test for displaying objects with very long names + ADD_H5_TEST (tlonglinks 0 tlonglinks.h5) + + # dimensions over 4GB, print boundary + ADD_H5_TEST (tbigdims 0 -d dset4gb -s 4294967284 -c 22 tbigdims.h5) + + # hyperslab read + ADD_H5_TEST (thyperslab 0 thyperslab.h5) + + # test for displaying dataset and attribute of null space + ADD_H5_TEST (tnullspace 0 tnullspace.h5) + + # test for long double (some systems do not have long double) + #ADD_H5_TEST (tldouble 0 tldouble.h5) + + # test for vms + ADD_H5_TEST (tvms 0 tvms.h5) + + # test for binary output + ADD_H5_TEST (tbin1LE 0 -d integer -o out1LE.bin -b LE tbinary.h5) + + # NATIVE default. the NATIVE test can be validated with h5import/h5diff + ADD_H5_TEST (tbin1 0 -d integer -o out1.bin -b tbinary.h5) + ADD_TEST (NAME H5DUMP-clear-out1 COMMAND ${CMAKE_COMMAND} -E remove out1.h5) + ADD_TEST (NAME H5DUMP-h5import-out1 COMMAND h5import out1.bin -c out3.h5import -o out1.h5) + ADD_TEST (NAME H5DUMP-h5diff-out1 COMMAND h5diff tbinary.h5 out1.h5 /integer /integer) + + ADD_H5_TEST (tbin2 0 -b BE -d float -o out2.bin tbinary.h5) + + # the NATIVE test can be validated with h5import/h5diff + ADD_H5_TEST (tbin3 0 -d integer -o out3.bin -b NATIVE tbinary.h5) + ADD_TEST (NAME H5DUMP-clear-out3 COMMAND ${CMAKE_COMMAND} -E remove out3.h5) + ADD_TEST (NAME H5DUMP-h5import-out3 COMMAND h5import out3.bin -c out3.h5import -o out3.h5) + ADD_TEST (NAME H5DUMP-h5diff-out3 COMMAND h5diff tbinary.h5 out3.h5 /integer /integer -q) + + ADD_H5_TEST (tbin4 0 -d double -b FILE -o out4.bin tbinary.h5) + + # Clean up binary output files + IF (NOT HDF5_NOCLEANUP) + ADD_TEST ( + NAME H5DUMP-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + out1.bin + out1LE.bin + out2.bin + out3.bin + out4.bin + out1.h5 + out3.h5 + ) + ENDIF (NOT HDF5_NOCLEANUP) + + # test for dataset region references + ADD_H5_TEST (tdatareg 0 tdatareg.h5) + ADD_H5_TEST (tdataregR 0 -R tdatareg.h5) + ADD_H5_TEST (tattrreg 0 tattrreg.h5) + ADD_H5_TEST (tattrregR 0 -R tattrreg.h5) + + # tests for group creation order + # "1" tracked, "2" name, root tracked + ADD_H5_TEST (tordergr1 0 --group=1 --sort_by=creation_order --sort_order=ascending tordergr.h5) + ADD_H5_TEST (tordergr2 0 --group=1 --sort_by=creation_order --sort_order=descending tordergr.h5) + ADD_H5_TEST (tordergr3 0 -g 2 -q name -z ascending tordergr.h5) + ADD_H5_TEST (tordergr4 0 -g 2 -q name -z descending tordergr.h5) + ADD_H5_TEST (tordergr5 0 -q creation_order tordergr.h5) + + # tests for attribute order + ADD_H5_TEST (torderattr1 0 -H --sort_by=name --sort_order=ascending torderattr.h5) + ADD_H5_TEST (torderattr2 0 -H --sort_by=name --sort_order=descending torderattr.h5) + ADD_H5_TEST (torderattr3 0 -H --sort_by=creation_order --sort_order=ascending torderattr.h5) + ADD_H5_TEST (torderattr4 0 -H --sort_by=creation_order --sort_order=descending torderattr.h5) + + # tests for floating point user defined printf format + ADD_H5_TEST (tfpformat 0 -m %.7f tfpformat.h5) + + # tests for traversal of external links + ADD_H5_TEST (textlinksrc 0 textlinksrc.h5) + ADD_H5_TEST (textlinkfar 0 textlinkfar.h5) + + # test for dataset packed bits + SET (TESTTYPE "TEST") + IF (NOT ${USE_PACKED_BITS}) + SET (TESTTYPE "SKIP") + ENDIF (NOT ${USE_PACKED_BITS}) + ADD_SKIP_H5_TEST (tpackedbits 0 ${TESTTYPE} -d /dset1 -M 0,2 tdset.h5) + ADD_SKIP_H5_TEST (tpackedbits2 0 ${TESTTYPE} -d /dset1 -M 0,2,2,1 tdset.h5) + +ENDIF (BUILD_TESTING) + +#-----------------------------------------------------------------------------
+# Rules for Installation of tools using make Install target
+#-----------------------------------------------------------------------------
+INSTALL ( + TARGETS + h5dump + RUNTIME DESTINATION + bin/tools + COMPONENT + toolsapplications +) diff --git a/tools/h5dump/Makefile.in b/tools/h5dump/Makefile.in index 0cb51f8..517608b 100644 --- a/tools/h5dump/Makefile.in +++ b/tools/h5dump/Makefile.in @@ -197,12 +197,12 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INSTRUMENT = @INSTRUMENT@ INSTRUMENT_LIBRARY = @INSTRUMENT_LIBRARY@ +LARGEFILE = @LARGEFILE@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ -LINUX_LFS = @LINUX_LFS@ LIPO = @LIPO@ LL_PATH = @LL_PATH@ LN_S = @LN_S@ diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index 3156ba6..e4c5231 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -22,9 +22,8 @@ #include "h5tools_ref.h" #include "h5trav.h" - -/* module-scoped variables */ -const char *progname = "h5dump"; +/* Name of tool */ +#define PROGRAMNAME "h5dump" /* Macros for displaying objects */ #define begin_obj(obj,name,begin) \ @@ -68,7 +67,6 @@ typedef struct h5dump_table_list_t { } *tables; } h5dump_table_list_t; -int d_status = EXIT_SUCCESS; static int unamedtype = 0; /* shared datatype with no name */ static h5dump_table_list_t table_list = {0, 0, NULL}; static table_t *group_table = NULL, *dset_table = NULL, *type_table = NULL; @@ -819,7 +817,7 @@ table_list_free(void) for(u = 0; u < table_list.nused; u++) { /* Release object id */ if(H5Idec_ref(table_list.tables[u].oid) < 0) - d_status = EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); /* Free each table */ free_table(table_list.tables[u].group_table); @@ -881,8 +879,8 @@ print_datatype(hid_t type,unsigned in_group) else printf("\"%s\"", obj->objname); } else { - error_msg(progname, "unknown committed type.\n"); - d_status = EXIT_FAILURE; + error_msg("unknown committed type.\n"); + h5tools_setstatus(EXIT_FAILURE); } } else { switch(H5Tget_class(type)) { @@ -1121,7 +1119,7 @@ print_datatype(hid_t type,unsigned in_group) /* Type doesn't match any of above. */ printf("unknown_one_character_type;\n "); - d_status = EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); done: H5Tclose(str_type); @@ -1151,7 +1149,7 @@ print_datatype(hid_t type,unsigned in_group) printf("H5T_STD_B64LE"); } else { printf("undefined bitfield"); - d_status = EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); } break; @@ -1258,7 +1256,7 @@ print_datatype(hid_t type,unsigned in_group) default: printf("unknown datatype"); - d_status = EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); break; } } /* end else */ @@ -1401,11 +1399,11 @@ dump_attr_cb(hid_t oid, const char *attr_name, const H5A_info_t UNUSED *info, vo if((attr_id = H5Aopen(oid, attr_name, H5P_DEFAULT)) < 0) { indentation(indent + COL); - error_msg(progname, "unable to open attribute \"%s\"\n", attr_name); + error_msg("unable to open attribute \"%s\"\n", attr_name); indentation(indent); end_obj(dump_header_format->attributeend, dump_header_format->attributeblockend); - d_status = EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); ret = FAIL; } else { hid_t type, space; @@ -1477,9 +1475,9 @@ dump_selected_attr(hid_t loc_id, const char *name) /* Open the object with the attribute */ if((oid = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) { indentation(COL); - error_msg(progname, "unable to open object \"%s\"\n", obj_name); + error_msg("unable to open object \"%s\"\n", obj_name); end_obj(dump_header_format->attributeend, dump_header_format->attributeblockend); - d_status = EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); return FAIL; } /* end if */ @@ -1504,14 +1502,14 @@ dump_selected_attr(hid_t loc_id, const char *name) dump_header_format->attributeblockend); } else { indentation(COL); - error_msg(progname, "unable to open attribute \"%s\"\n", obj_name); + error_msg("unable to open attribute \"%s\"\n", obj_name); end_obj(dump_header_format->attributeend, dump_header_format->attributeblockend); - d_status = EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); } /* Close object */ if(H5Oclose(oid) < 0) { - d_status = EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); return FAIL; } /* end if */ @@ -1559,8 +1557,8 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED /* Stat the object */ if(H5Oget_info_by_name(group, name, &oinfo, H5P_DEFAULT) < 0) { - error_msg(progname, "unable to get object information for \"%s\"\n", name); - d_status = EXIT_FAILURE; + error_msg("unable to get object information for \"%s\"\n", name); + h5tools_setstatus(EXIT_FAILURE); ret = FAIL; goto done; } /* end if */ @@ -1570,8 +1568,8 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED case H5O_TYPE_GROUP: if((obj = H5Gopen2(group, name, H5P_DEFAULT)) < 0) { - error_msg(progname, "unable to dump group \"%s\"\n", name); - d_status = EXIT_FAILURE; + error_msg("unable to dump group \"%s\"\n", name); + h5tools_setstatus(EXIT_FAILURE); ret = FAIL; } else @@ -1609,13 +1607,13 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED begin_obj(dump_header_format->datasetbegin, name, dump_header_format->datasetblockbegin); indentation(indent + COL); - error_msg(progname, + error_msg(h5tools_getprogname(), "internal error (file %s:line %d)\n", __FILE__, __LINE__); indentation(indent); end_obj(dump_header_format->datasetend, dump_header_format->datasetblockend); - d_status = EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); ret = FAIL; H5Dclose(obj); goto done; @@ -1678,16 +1676,16 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED dump_function_table->dump_dataset_function(obj, name, NULL); H5Dclose(obj); } else { - error_msg(progname, "unable to dump dataset \"%s\"\n", name); - d_status = EXIT_FAILURE; + 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(progname, "unable to dump datatype \"%s\"\n", name); - d_status = EXIT_FAILURE; + 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); @@ -1696,8 +1694,8 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED break; default: - error_msg(progname, "unknown object \"%s\"\n", name); - d_status = EXIT_FAILURE; + error_msg("unknown object \"%s\"\n", name); + h5tools_setstatus(EXIT_FAILURE); ret = FAIL; } } /* end if */ @@ -1717,8 +1715,8 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED } if(H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) { - error_msg(progname, "unable to get link value\n"); - d_status = EXIT_FAILURE; + error_msg("unable to get link value\n"); + h5tools_setstatus(EXIT_FAILURE); ret = FAIL; } else { /* print the value of a soft link */ @@ -1808,8 +1806,8 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED begin_obj(dump_header_format->extlinkbegin, name, dump_header_format->extlinkblockbegin); if(H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) { - error_msg(progname, "unable to get external link value\n"); - d_status = EXIT_FAILURE; + error_msg("unable to get external link value\n"); + h5tools_setstatus(EXIT_FAILURE); ret = FAIL; } /* end if */ else { @@ -1817,8 +1815,8 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED const char *targname; if(H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL, &filename, &targname) < 0) { - error_msg(progname, "unable to unpack external link value\n"); - d_status = EXIT_FAILURE; + error_msg("unable to unpack external link value\n"); + h5tools_setstatus(EXIT_FAILURE); ret = FAIL; } /* end if */ else { @@ -1950,20 +1948,20 @@ dump_named_datatype(hid_t tid, const char *name) if ((tcpl_id = H5Tget_create_plist(tid)) < 0) { - error_msg(progname, "error in getting creation property list ID\n"); - d_status = EXIT_FAILURE; + 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(progname, "error in getting creation properties\n"); - d_status = EXIT_FAILURE; + error_msg("error in getting creation properties\n"); + h5tools_setstatus(EXIT_FAILURE); } if(H5Pclose(tcpl_id) < 0) { - error_msg(progname, "error in closing creation property list ID\n"); - d_status = EXIT_FAILURE; + error_msg("error in closing creation property list ID\n"); + h5tools_setstatus(EXIT_FAILURE); } @@ -1982,9 +1980,9 @@ dump_named_datatype(hid_t tid, const char *name) found_obj = search_obj(type_table, oinfo.addr); if (found_obj == NULL) { - error_msg(progname, "internal error (file %s:line %d)\n", + error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__); - d_status = EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); goto done; } else if (found_obj->displayed) { @@ -2007,14 +2005,14 @@ dump_named_datatype(hid_t tid, const char *name) if( (sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) { if(H5Aiterate2(tid, sort_by, sort_order, NULL, dump_attr_cb, NULL) < 0) { - error_msg(progname, "error getting attribute information\n"); - d_status = EXIT_FAILURE; + error_msg("error getting attribute information\n"); + h5tools_setstatus(EXIT_FAILURE); } /* end if */ } /* end if */ else { if(H5Aiterate2(tid, H5_INDEX_NAME, sort_order, NULL, dump_attr_cb, NULL) < 0) { - error_msg(progname, "error getting attribute information\n"); - d_status = EXIT_FAILURE; + error_msg("error getting attribute information\n"); + h5tools_setstatus(EXIT_FAILURE); } /* end if */ } /* end else */ @@ -2056,27 +2054,27 @@ dump_group(hid_t gid, const char *name) if ((gcpl_id = H5Gget_create_plist(gid)) < 0) { - error_msg(progname, "error in getting group creation property list ID\n"); - d_status = EXIT_FAILURE; + 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(progname, "error in getting group creation properties\n"); - d_status = EXIT_FAILURE; + 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(progname, "error in getting group creation properties\n"); - d_status = EXIT_FAILURE; + error_msg("error in getting group creation properties\n"); + h5tools_setstatus(EXIT_FAILURE); } if(H5Pclose(gcpl_id) < 0) { - error_msg(progname, "error in closing group creation property list ID\n"); - d_status = EXIT_FAILURE; + error_msg("error in closing group creation property list ID\n"); + h5tools_setstatus(EXIT_FAILURE); } @@ -2118,9 +2116,9 @@ dump_group(hid_t gid, const char *name) if (found_obj == NULL) { indentation(indent); - error_msg(progname, "internal error (file %s:line %d)\n", + error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__); - d_status = EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); } else if (found_obj->displayed) { indentation(indent); @@ -2133,14 +2131,14 @@ dump_group(hid_t gid, const char *name) 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(progname, "error getting attribute information\n"); - d_status = EXIT_FAILURE; + 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(progname, "error getting attribute information\n"); - d_status = EXIT_FAILURE; + error_msg("error getting attribute information\n"); + h5tools_setstatus(EXIT_FAILURE); } /* end if */ } /* end else */ @@ -2164,14 +2162,14 @@ dump_group(hid_t gid, const char *name) 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(progname, "error getting attribute information\n"); - d_status = EXIT_FAILURE; + 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(progname, "error getting attribute information\n"); - d_status = EXIT_FAILURE; + error_msg("error getting attribute information\n"); + h5tools_setstatus(EXIT_FAILURE); } /* end if */ } /* end else */ @@ -2218,15 +2216,15 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset) if ((dcpl_id = H5Dget_create_plist(did)) < 0) { - error_msg(progname, "error in getting creation property list ID\n"); - d_status = EXIT_FAILURE; + 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(progname, "error in getting creation properties\n"); - d_status = EXIT_FAILURE; + error_msg("error in getting creation properties\n"); + h5tools_setstatus(EXIT_FAILURE); } indentation(indent); @@ -2280,14 +2278,14 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset) if( (sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) { if(H5Aiterate2(did, sort_by, sort_order, NULL, dump_attr_cb, NULL) < 0) { - error_msg(progname, "error getting attribute information\n"); - d_status = EXIT_FAILURE; + 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_attr_cb, NULL) < 0) { - error_msg(progname, "error getting attribute information\n"); - d_status = EXIT_FAILURE; + error_msg("error getting attribute information\n"); + h5tools_setstatus(EXIT_FAILURE); } /* end if */ } /* end else */ @@ -2598,8 +2596,8 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_index) if (status == FAIL) { indentation(indent + COL); - error_msg(progname, "unable to print data\n"); - d_status = EXIT_FAILURE; + error_msg("unable to print data\n"); + h5tools_setstatus(EXIT_FAILURE); } indentation(indent); @@ -3569,10 +3567,10 @@ handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *dis begin_obj(dump_header_format->datasetbegin, real_name, dump_header_format->datasetblockbegin); indentation(COL); - error_msg(progname, "unable to open dataset \"%s\"\n", real_name); + error_msg("unable to open dataset \"%s\"\n", real_name); end_obj(dump_header_format->datasetend, dump_header_format->datasetblockend); - d_status = EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); } return; } /* end if */ @@ -3639,8 +3637,8 @@ handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *dis if ( sset->stride[i] < sset->block[i] ) { - error_msg(progname, "wrong subset selection; blocks overlap\n"); - d_status = EXIT_FAILURE; + error_msg("wrong subset selection; blocks overlap\n"); + h5tools_setstatus(EXIT_FAILURE); return; } @@ -3674,13 +3672,13 @@ handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *dis } } else - d_status = EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); } else dump_dataset(dsetid, real_name, sset); if(H5Dclose(dsetid) < 0) - d_status = EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); } /*------------------------------------------------------------------------- @@ -3716,9 +3714,9 @@ handle_groups(hid_t fid, const char *group, void UNUSED * data, int pe, const ch { begin_obj(dump_header_format->groupbegin, real_name, dump_header_format->groupblockbegin); indentation(COL); - error_msg(progname, "unable to open group \"%s\"\n", real_name); + error_msg("unable to open group \"%s\"\n", real_name); end_obj(dump_header_format->groupend, dump_header_format->groupblockend); - d_status = EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); } } else @@ -3736,7 +3734,7 @@ handle_groups(hid_t fid, const char *group, void UNUSED * data, int pe, const ch dump_group(gid, real_name); if(H5Gclose(gid) < 0) - d_status = EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); } /* end else */ } /* end handle_groups() */ @@ -3760,11 +3758,11 @@ handle_links(hid_t fid, const char *links, void UNUSED * data, int UNUSED pe, co H5L_info_t linfo; if(H5Lget_info(fid, links, &linfo, H5P_DEFAULT) < 0) { - error_msg(progname, "unable to get link info from \"%s\"\n", links); - d_status = EXIT_FAILURE; + error_msg("unable to get link info from \"%s\"\n", links); + h5tools_setstatus(EXIT_FAILURE); } else if(linfo.type == H5L_TYPE_HARD) { - error_msg(progname, "\"%s\" is a hard link\n", links); - d_status = EXIT_FAILURE; + error_msg("\"%s\" is a hard link\n", links); + h5tools_setstatus(EXIT_FAILURE); } else { char *buf = HDmalloc(linfo.u.val_size); @@ -3776,9 +3774,9 @@ handle_links(hid_t fid, const char *links, void UNUSED * data, int UNUSED pe, co if(H5Lget_val(fid, links, buf, linfo.u.val_size, H5P_DEFAULT) >= 0) printf("LINKTARGET \"%s\"\n", buf); else { - error_msg(progname, "h5dump error: unable to get link value for \"%s\"\n", + error_msg("h5dump error: unable to get link value for \"%s\"\n", links); - d_status = EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); } end_obj(dump_header_format->softlinkend, dump_header_format->softlinkblockend); @@ -3802,12 +3800,12 @@ handle_links(hid_t fid, const char *links, void UNUSED * data, int UNUSED pe, co indentation(COL); printf("TARGETPATH \"%s\"\n", elink_path); } else { - error_msg(progname, "h5dump error: unable to unpack external link value for \"%s\"\n", links); - d_status = EXIT_FAILURE; + error_msg("h5dump error: unable to unpack external link value for \"%s\"\n", links); + h5tools_setstatus(EXIT_FAILURE); } } else { - error_msg(progname, "h5dump error: unable to get external link value for \"%s\"\n", links); - d_status = EXIT_FAILURE; + error_msg("h5dump error: unable to get external link value for \"%s\"\n", links); + h5tools_setstatus(EXIT_FAILURE); } end_obj(dump_header_format->extlinkend, dump_header_format->extlinkblockend); @@ -3883,10 +3881,10 @@ handle_datatypes(hid_t fid, const char *type, void UNUSED * data, int pe, const begin_obj(dump_header_format->datatypebegin, real_name, dump_header_format->datatypeblockbegin); indentation(COL); - error_msg(progname, "unable to open datatype \"%s\"\n", real_name); + error_msg("unable to open datatype \"%s\"\n", real_name); end_obj(dump_header_format->datatypeend, dump_header_format->datatypeblockend); - d_status = EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); } } else @@ -3903,7 +3901,7 @@ handle_datatypes(hid_t fid, const char *type, void UNUSED * data, int pe, const dump_named_datatype(type_id, real_name); if(H5Tclose(type_id) < 0) - d_status = EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); } } @@ -3935,7 +3933,7 @@ parse_command_line(int argc, const char *argv[]) /* no arguments */ if (argc == 1) { - usage(progname); + usage(h5tools_getprogname()); leave(EXIT_FAILURE); } @@ -3985,7 +3983,7 @@ parse_start: display_char = TRUE; break; case 'V': - print_version(progname); + print_version(h5tools_getprogname()); leave(EXIT_SUCCESS); break; case 'w': @@ -4061,13 +4059,13 @@ parse_start: case 'o': if ( bin_output ) { if (set_output_file(opt_arg, 1) < 0) { - usage(progname); + usage(h5tools_getprogname()); leave(EXIT_FAILURE); } } else { if (set_output_file(opt_arg, 0) < 0) { - usage(progname); + usage(h5tools_getprogname()); leave(EXIT_FAILURE); } } @@ -4081,7 +4079,7 @@ parse_start: if ( opt_arg != NULL) { if ( ( bin_form = set_binary_form(opt_arg)) < 0) { /* failed to set binary form */ - usage(progname); + usage(h5tools_getprogname()); leave(EXIT_FAILURE); } } @@ -4089,7 +4087,7 @@ parse_start: if (outfname!=NULL) { if (set_output_file(outfname, 1) < 0) { /* failed to set output file */ - usage(progname); + usage(h5tools_getprogname()); leave(EXIT_FAILURE); } @@ -4100,7 +4098,7 @@ parse_start: case 'q': if ( ( sort_by = set_sort_by(opt_arg)) < 0) { /* failed to set "sort by" form */ - usage(progname); + usage(h5tools_getprogname()); leave(EXIT_FAILURE); } break; @@ -4108,7 +4106,7 @@ parse_start: case 'z': if ( ( sort_order = set_sort_order(opt_arg)) < 0) { /* failed to set "sort order" form */ - usage(progname); + usage(h5tools_getprogname()); leave(EXIT_FAILURE); } break; @@ -4146,7 +4144,7 @@ parse_start: /* specify XML namespace (default="hdf5:"), or none */ /* To Do: check format of this value? */ if (!useschema) { - usage(progname); + usage(h5tools_getprogname()); leave(EXIT_FAILURE); } if (strcmp(opt_arg,":") == 0) { @@ -4165,7 +4163,7 @@ parse_start: struct subset_t *s; if (!last_was_dset) { - error_msg(progname, + error_msg(h5tools_getprogname(), "option `-%c' can only be used after --dataset option\n", opt); leave(EXIT_FAILURE); @@ -4213,11 +4211,11 @@ end_collect: /** end subsetting parameters **/ case 'h': - usage(progname); + usage(h5tools_getprogname()); leave(EXIT_SUCCESS); case '?': default: - usage(progname); + usage(h5tools_getprogname()); leave(EXIT_FAILURE); } } @@ -4225,8 +4223,8 @@ end_collect: parse_end: /* check for file name to be processed */ if (argc <= opt_ind) { - error_msg(progname, "missing file name\n"); - usage(progname); + error_msg("missing file name\n"); + usage(h5tools_getprogname()); leave(EXIT_FAILURE); } return hand; @@ -4320,6 +4318,8 @@ main(int argc, const char *argv[]) int i; unsigned u; + h5tools_setprogname(PROGRAMNAME); + h5tools_setstatus(EXIT_SUCCESS); dump_header_format = &standardformat; dump_function_table = &ddl_function_table; @@ -4333,43 +4333,43 @@ main(int argc, const char *argv[]) if ( bin_output && outfname == NULL ) { - error_msg(progname, "binary output requires a file name, use -o <filename>\n"); + error_msg("binary output requires a file name, use -o <filename>\n"); leave(EXIT_FAILURE); } /* Check for conflicting options */ if (doxml) { if (!display_all) { - error_msg(progname, "option \"%s\" not available for XML\n", + error_msg("option \"%s\" not available for XML\n", "to display selected objects"); leave(EXIT_FAILURE); } else if (display_bb) { - error_msg(progname, "option \"%s\" not available for XML\n", + error_msg("option \"%s\" not available for XML\n", "--boot-block"); leave(EXIT_FAILURE); } else if (display_oid == 1) { - error_msg(progname, "option \"%s\" not available for XML\n", + error_msg("option \"%s\" not available for XML\n", "--object-ids"); leave(EXIT_FAILURE); } else if (display_char == TRUE) { - error_msg(progname, "option \"%s\" not available for XML\n", + error_msg("option \"%s\" not available for XML\n", "--string"); leave(EXIT_FAILURE); } else if (usingdasho) { - error_msg(progname, "option \"%s\" not available for XML\n", + error_msg("option \"%s\" not available for XML\n", "--output"); leave(EXIT_FAILURE); } } else { if (xml_dtd_uri) { - warn_msg(progname, "option \"%s\" only applies with XML: %s\n", + warn_msg("option \"%s\" only applies with XML: %s\n", "--xml-dtd", xml_dtd_uri); } } if (argc <= opt_ind) { - error_msg(progname, "missing file name\n"); - usage(progname); + error_msg("missing file name\n"); + usage(h5tools_getprogname()); leave(EXIT_FAILURE); } fname = HDstrdup(argv[opt_ind]); @@ -4377,7 +4377,7 @@ main(int argc, const char *argv[]) fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, driver, NULL, 0); if (fid < 0) { - error_msg(progname, "unable to open file \"%s\"\n", fname); + error_msg("unable to open file \"%s\"\n", fname); leave(EXIT_FAILURE); } @@ -4403,7 +4403,7 @@ main(int argc, const char *argv[]) } } else { if (useschema && strcmp(xmlnsprefix,"")) { - error_msg(progname, "Cannot set Schema URL for a qualified namespace--use -X or -U option with -D \n"); + error_msg("Cannot set Schema URL for a qualified namespace--use -X or -U option with -D \n"); leave(EXIT_FAILURE); } } @@ -4412,15 +4412,15 @@ main(int argc, const char *argv[]) /* Get object info for root group */ if(H5Oget_info_by_name(fid, "/", &oi, H5P_DEFAULT) < 0) { - error_msg(progname, "internal error (file %s:line %d)\n", __FILE__, __LINE__); - d_status = EXIT_FAILURE; + 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(progname, "internal error (file %s:line %d)\n", __FILE__, __LINE__); - d_status = EXIT_FAILURE; + 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; @@ -4482,8 +4482,8 @@ main(int argc, const char *argv[]) { if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) { - error_msg(progname, "unable to open root group\n"); - d_status = EXIT_FAILURE; + error_msg("unable to open root group\n"); + h5tools_setstatus(EXIT_FAILURE); } else { @@ -4494,8 +4494,8 @@ main(int argc, const char *argv[]) if(H5Gclose(gid) < 0) { - error_msg(progname, "unable to close root group\n"); - d_status = EXIT_FAILURE; + error_msg("unable to close root group\n"); + h5tools_setstatus(EXIT_FAILURE); } @@ -4504,8 +4504,8 @@ main(int argc, const char *argv[]) { /* Note: this option is not supported for XML */ if(doxml) { - error_msg(progname, "internal error (file %s:line %d)\n", __FILE__, __LINE__); - d_status = EXIT_FAILURE; + error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__); + h5tools_setstatus(EXIT_FAILURE); goto done; } /* end if */ @@ -4525,7 +4525,7 @@ done: table_list_free(); if (H5Fclose(fid) < 0) - d_status = EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); free_handler(hand, argc); @@ -4536,7 +4536,7 @@ done: H5Eset_auto2(H5E_DEFAULT, func, edata); - leave(d_status); + leave(h5tools_getstatus()); } /*------------------------------------------------------------------------- @@ -4949,7 +4949,7 @@ xml_print_datatype(hid_t type, unsigned in_group) free(dtxid); } else { printf("<!-- h5dump error: unknown committed type. -->\n"); - d_status = EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); } } else { @@ -5253,7 +5253,7 @@ xml_print_datatype(hid_t type, unsigned in_group) default: printf("<!-- unknown datatype -->"); - d_status = EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); break; } } /* end else */ @@ -5635,7 +5635,7 @@ xml_dump_attr(hid_t attr, const char *attr_name, const H5A_info_t UNUSED *info, printf("<!-- h5dump error: unable to open attribute. -->\n"); indentation(indent); printf("</%sAttribute>\n", xmlnsprefix ); - d_status = EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); return FAIL; } } @@ -5710,9 +5710,9 @@ xml_dump_named_datatype(hid_t type, const char *name) if (found_obj == NULL) { indentation(indent); - error_msg(progname, "internal error (file %s:line %d)\n", + error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__); - d_status = EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); goto done; } else if(found_obj->displayed) { /* We have already printed this named datatype, print it as a @@ -5791,27 +5791,27 @@ xml_dump_group(hid_t gid, const char *name) if ((gcpl_id = H5Gget_create_plist(gid)) < 0) { - error_msg(progname, "error in getting group creation property list ID\n"); - d_status = EXIT_FAILURE; + 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(progname, "error in getting group creation properties\n"); - d_status = EXIT_FAILURE; + 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(progname, "error in getting group creation properties\n"); - d_status = EXIT_FAILURE; + error_msg("error in getting group creation properties\n"); + h5tools_setstatus(EXIT_FAILURE); } if(H5Pclose(gcpl_id) < 0) { - error_msg(progname, "error in closing group creation property list ID\n"); - d_status = EXIT_FAILURE; + error_msg("error in closing group creation property list ID\n"); + h5tools_setstatus(EXIT_FAILURE); } if(HDstrcmp(name, "/") == 0) { @@ -5843,9 +5843,9 @@ xml_dump_group(hid_t gid, const char *name) if (found_obj == NULL) { indentation(indent); - error_msg(progname, "internal error (file %s:line %d)\n", + error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__); - d_status = EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); } else { char *t_name = xml_escape_the_name(name); char *grpxid = malloc(100); @@ -5910,14 +5910,14 @@ xml_dump_group(hid_t gid, const char *name) 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(progname, "error getting attribute information\n"); - d_status = EXIT_FAILURE; + 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(progname, "error getting attribute information\n"); - d_status = EXIT_FAILURE; + error_msg("error getting attribute information\n"); + h5tools_setstatus(EXIT_FAILURE); } /* end if */ } /* end else */ @@ -5982,14 +5982,14 @@ xml_dump_group(hid_t gid, const char *name) 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(progname, "error getting attribute information\n"); - d_status = EXIT_FAILURE; + 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(progname, "error getting attribute information\n"); - d_status = EXIT_FAILURE; + error_msg("error getting attribute information\n"); + h5tools_setstatus(EXIT_FAILURE); } /* end if */ } /* end else */ @@ -6648,14 +6648,14 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset) 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(progname, "error getting attribute information\n"); - d_status = EXIT_FAILURE; + 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(progname, "error getting attribute information\n"); - d_status = EXIT_FAILURE; + error_msg("error getting attribute information\n"); + h5tools_setstatus(EXIT_FAILURE); } /* end if */ } /* end else */ @@ -7088,7 +7088,7 @@ static int dump_extlink(hid_t group, const char *linkname, const char *objname) handle_datatypes(group, linkname, NULL, 0, objname); break; default: - d_status = EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); } indent -= 2*COL; @@ -7103,7 +7103,7 @@ static int dump_extlink(hid_t group, const char *linkname, const char *objname) } /* end if */ if (H5Idec_ref(oid) < 0) - d_status = EXIT_FAILURE; + h5tools_setstatus(EXIT_FAILURE); return SUCCEED; diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c index ccc0f22..a466739 100644 --- a/tools/h5dump/h5dumpgentest.c +++ b/tools/h5dump/h5dumpgentest.c @@ -28,10 +28,14 @@ #include "H5private.h" #include "h5tools.h" +/* Name of tool */ +#define PROGRAMNAME "h5dumpgentest" + #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" @@ -91,7 +95,7 @@ #define FILE61 "textlinksrc.h5" #define FILE62 "textlinktar.h5" #define FILE63 "textlinkfar.h5" -#define FILE64 "tarray8.h5" +/*#define FILE64 "tarray8.h5"*/ #define FILE65 "tattrreg.h5" #define FILE66 "file_space.h5" #define FILE67 "tdset_idx.h5" @@ -211,7 +215,8 @@ typedef struct s1_t { #define ARRAY3_DIM2 3 /* VL string datatype name */ -#define VLSTR_TYPE "vl_string_type" +/* 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 */ @@ -474,6 +479,246 @@ static void gent_softlink(void) 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; + hid_t gid1=0, gid2=0; + hid_t tid; + hid_t dset1, dset2; + hid_t datatype, dataspace; + hsize_t dimsf[2]; /* dataset dimensions */ + herr_t status=SUCCEED; + int data1[NX][NY] = {{0,0},{1,1},{2,2},{3,3}}; + int data2[NX][NY] = {{0,0},{0,1},{0,2},{3,3}}; + + /*----------------------------------------------------------------------- + * 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 + *------------------------------------------------------------------------*/ + tid = H5Tcopy(H5T_NATIVE_INT); + status = H5Tcommit2(fileid1, "dtype", tid, 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); + + /* + * Define datatype for the data in the file. + * We will store little endian INT numbers. + */ + datatype = H5Tcopy(H5T_NATIVE_INT); + + /*--------------- + * dset1 + */ + /* Create a new dataset as sample object */ + dset1 = H5Dcreate2(fileid1, "/dset1", datatype, 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", datatype, 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. + */ + H5Sclose(dataspace); + H5Gclose(gid1); + H5Gclose(gid2); + H5Tclose(datatype); + H5Dclose(dset1); + H5Dclose(dset2); + H5Fclose(fileid1); + + return status; +} + /* / @@ -1669,7 +1914,7 @@ static void gent_objref(void) hid_t sid1; /* Dataspace ID */ hid_t tid1; /* Datatype ID */ hsize_t dims1[] = {SPACE1_DIM1}; - hobj_ref_t *wbuf, /* buffer to write to disk */ + 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 */ @@ -1677,9 +1922,9 @@ static void gent_objref(void) const char *write_comment = "Foo!"; /* Comments for group */ /* Allocate write & read buffers */ - wbuf = malloc(sizeof(hobj_ref_t) * SPACE1_DIM1); - rbuf = malloc(sizeof(hobj_ref_t) * SPACE1_DIM1); - tbuf = malloc(sizeof(hobj_ref_t) * SPACE1_DIM1); + wbuf = (hobj_ref_t*) malloc(sizeof(hobj_ref_t) * SPACE1_DIM1); + rbuf = (hobj_ref_t*) malloc(sizeof(hobj_ref_t) * SPACE1_DIM1); + tbuf = (hobj_ref_t*) malloc(sizeof(hobj_ref_t) * SPACE1_DIM1); /* Create file */ fid1 = H5Fcreate(FILE16, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -1787,10 +2032,10 @@ static void gent_datareg(void) int i; /* counting variables */ /* Allocate write & read buffers */ - wbuf=calloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1); - rbuf=malloc(sizeof(hdset_reg_ref_t)*SPACE1_DIM1); - dwbuf=malloc(sizeof(uint8_t)*SPACE2_DIM1*SPACE2_DIM2); - drbuf=calloc(sizeof(uint8_t),SPACE2_DIM1*SPACE2_DIM2); + wbuf = (hdset_reg_ref_t*) calloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1); + rbuf = (hdset_reg_ref_t*) malloc(sizeof(hdset_reg_ref_t)*SPACE1_DIM1); + dwbuf = (uint8_t*) malloc(sizeof(uint8_t)*SPACE2_DIM1*SPACE2_DIM2); + drbuf = (uint8_t*) calloc(sizeof(uint8_t),SPACE2_DIM1*SPACE2_DIM2); /* Create file */ fid1 = H5Fcreate(FILE17, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -1896,10 +2141,10 @@ static void gent_attrreg(void) int i; /* counting variables */ /* Allocate write & read buffers */ - wbuf=calloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1); - rbuf=malloc(sizeof(hdset_reg_ref_t)*SPACE1_DIM1); - dwbuf=malloc(sizeof(uint8_t)*SPACE2_DIM1*SPACE2_DIM2); - drbuf=calloc(sizeof(uint8_t),SPACE2_DIM1*SPACE2_DIM2); + wbuf = (hdset_reg_ref_t*) calloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1); + rbuf = (hdset_reg_ref_t*) malloc(sizeof(hdset_reg_ref_t)*SPACE1_DIM1); + dwbuf = (uint8_t*) malloc(sizeof(uint8_t)*SPACE2_DIM1*SPACE2_DIM2); + drbuf = (uint8_t*) calloc(sizeof(uint8_t),SPACE2_DIM1*SPACE2_DIM2); /* Create file */ fid1 = H5Fcreate(FILE65, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -2969,7 +3214,7 @@ static void gent_array8(void) hsize_t sdims[] = {F64_DIM0}; hsize_t tdims[] = {F64_DIM1}; int wdata[(F64_DIM1) * sizeof(int)]; /* Write buffer */ - int i; + unsigned int i; /* * Initialize data. i is the element in the dataspace, j and k the @@ -5663,7 +5908,7 @@ static void gent_longlinks(void) assert(gid >= 0); /* Construct very long file name */ - objname = HDmalloc((size_t)(F51_MAX_NAME_LEN + 1)); + objname = (char*) HDmalloc((size_t)(F51_MAX_NAME_LEN + 1)); assert(objname); for(u = 0; u < F51_MAX_NAME_LEN; u++) objname[u] = 'a'; @@ -5927,7 +6172,7 @@ gent_hyperslab(void) double *buf; int i, ret; - buf = malloc(32 * 4097 * sizeof(double) ); + buf = (double*) malloc(32 * 4097 * sizeof(double) ); for(i = 0; i < 32 * 4097; i++) buf[i] = 1; @@ -6613,6 +6858,7 @@ int main(void) gent_group(); gent_attribute(); gent_softlink(); + gent_softlink2(); gent_dataset(); gent_hardlink(); gent_extlink(); |