diff options
author | Mohamad Chaarawi <chaarawi@hdfgroup.org> | 2014-06-13 19:40:51 (GMT) |
---|---|---|
committer | Mohamad Chaarawi <chaarawi@hdfgroup.org> | 2014-06-13 19:40:51 (GMT) |
commit | 05a218df3c49c6da63fb2a337022cdcd6eb94968 (patch) | |
tree | f5b3e3493b9e8deb49c8212704169d062f8299d3 /tools | |
parent | 57ac83f5ba546fe9c86479c5cb3c303f8ff33881 (diff) | |
parent | 8df5a96ccb3d60bc38d9f1b6d0d774d55afbb7a6 (diff) | |
download | hdf5-05a218df3c49c6da63fb2a337022cdcd6eb94968.zip hdf5-05a218df3c49c6da63fb2a337022cdcd6eb94968.tar.gz hdf5-05a218df3c49c6da63fb2a337022cdcd6eb94968.tar.bz2 |
[svn-r25280] merge from latest VOL/trunk branch.
Diffstat (limited to 'tools')
49 files changed, 938 insertions, 883 deletions
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 27820ae..a9a8c49 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -4,7 +4,7 @@ PROJECT (HDF5_TOOLS) #----------------------------------------------------------------------------- # Apply Definitions to compiler in this directory and below #----------------------------------------------------------------------------- -add_definitions (${HDF5_EXTRA_C_FLAGS}) +add_definitions (${HDF_EXTRA_C_FLAGS}) #----------------------------------------------------------------------------- # Setup include Directories diff --git a/tools/Makefile.in b/tools/Makefile.in index 7bb193e..6e7920d 100644 --- a/tools/Makefile.in +++ b/tools/Makefile.in @@ -504,7 +504,6 @@ LIPO = @LIPO@ LL_PATH = @LL_PATH@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ -LT_ADD_LIBHDF5_DEPENDENCY = @LT_ADD_LIBHDF5_DEPENDENCY@ LT_STATIC_EXEC = @LT_STATIC_EXEC@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ diff --git a/tools/h5copy/CMakeLists.txt b/tools/h5copy/CMakeLists.txt index e5a1a9f..267d92b 100644 --- a/tools/h5copy/CMakeLists.txt +++ b/tools/h5copy/CMakeLists.txt @@ -37,9 +37,9 @@ endif (BUILD_TESTING) ############################################################################## ############################################################################## -#-----------------------------------------------------------------------------
-# Rules for Installation of tools using make Install target
-#-----------------------------------------------------------------------------
+#----------------------------------------------------------------------------- +# Rules for Installation of tools using make Install target +#----------------------------------------------------------------------------- #INSTALL_PROGRAM_PDB (h5copy ${HDF5_INSTALL_BIN_DIR} toolsapplications) diff --git a/tools/h5copy/CMakeTests.cmake b/tools/h5copy/CMakeTests.cmake index 77399a8..9002e5a 100644 --- a/tools/h5copy/CMakeTests.cmake +++ b/tools/h5copy/CMakeTests.cmake @@ -230,7 +230,7 @@ -D "TEST_EXPECT=${resultcode}" -D "TEST_REFERENCE=./testfiles/${testname}.out" -D "TEST_MASK=true" - -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5COPY-CMP-${testname} PROPERTIES DEPENDS H5COPY-CMP-${testname}-clear-objects) endif (HDF5_ENABLE_USING_MEMCHECKER) diff --git a/tools/h5copy/Makefile.in b/tools/h5copy/Makefile.in index a6bbef1..80b7d7e 100644 --- a/tools/h5copy/Makefile.in +++ b/tools/h5copy/Makefile.in @@ -512,7 +512,6 @@ LIPO = @LIPO@ LL_PATH = @LL_PATH@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ -LT_ADD_LIBHDF5_DEPENDENCY = @LT_ADD_LIBHDF5_DEPENDENCY@ LT_STATIC_EXEC = @LT_STATIC_EXEC@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ diff --git a/tools/h5diff/CMakeLists.txt b/tools/h5diff/CMakeLists.txt index 5620968..35c55a4 100644 --- a/tools/h5diff/CMakeLists.txt +++ b/tools/h5diff/CMakeLists.txt @@ -55,9 +55,9 @@ endif (BUILD_TESTING) ############################################################################## ############################################################################## -#-----------------------------------------------------------------------------
-# Rules for Installation of tools using make Install target
-#-----------------------------------------------------------------------------
+#----------------------------------------------------------------------------- +# Rules for Installation of tools using make Install target +#----------------------------------------------------------------------------- #INSTALL_PROGRAM_PDB (h5diff ${HDF5_INSTALL_BIN_DIR} toolsapplications) diff --git a/tools/h5diff/CMakeTests.cmake b/tools/h5diff/CMakeTests.cmake index 19a5fe4..686803b 100644 --- a/tools/h5diff/CMakeTests.cmake +++ b/tools/h5diff/CMakeTests.cmake @@ -255,7 +255,7 @@ # # Overwrite system dependent files (Windows) # - if (WIN32 AND NOT CYGWIN) + if (WIN32) add_custom_command ( TARGET h5diff POST_BUILD @@ -282,7 +282,7 @@ COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_104w.txt ${PROJECT_BINARY_DIR}/testfiles/h5diff_104.txt ) - endif (WIN32 AND NOT CYGWIN) + endif (WIN32) ############################################################################## ############################################################################## @@ -317,7 +317,7 @@ -D "TEST_EXPECT=${resultcode}" -D "TEST_REFERENCE=${resultfile}.txt" -D "TEST_APPEND=EXIT CODE:" - -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5DIFF-${resultfile} PROPERTIES DEPENDS "H5DIFF-${resultfile}-clear-objects") endif (HDF5_ENABLE_USING_MEMCHECKER) @@ -355,7 +355,7 @@ # -D "TEST_APPEND=EXIT CODE: [0-9]" # -D "TEST_REF_FILTER=EXIT CODE: 0" -D "TEST_SKIP_COMPARE=TRUE" - -P "${HDF5_RESOURCES_DIR}/prunTest.cmake" + -P "${HDF_RESOURCES_EXT_DIR}/prunTest.cmake" ) set_tests_properties (PH5DIFF-${resultfile} PROPERTIES DEPENDS "PH5DIFF-${resultfile}-clear-objects") endif (HDF5_ENABLE_USING_MEMCHECKER) diff --git a/tools/h5diff/Makefile.in b/tools/h5diff/Makefile.in index 12d8478..d275466 100644 --- a/tools/h5diff/Makefile.in +++ b/tools/h5diff/Makefile.in @@ -519,7 +519,6 @@ LIPO = @LIPO@ LL_PATH = @LL_PATH@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ -LT_ADD_LIBHDF5_DEPENDENCY = @LT_ADD_LIBHDF5_DEPENDENCY@ LT_STATIC_EXEC = @LT_STATIC_EXEC@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ diff --git a/tools/h5diff/h5diff_common.c b/tools/h5diff/h5diff_common.c index 59cab0d..a371cc0 100644 --- a/tools/h5diff/h5diff_common.c +++ b/tools/h5diff/h5diff_common.c @@ -103,6 +103,13 @@ void parse_command_line(int argc, /* NaNs are handled by default */ options->do_nans = 1; + /* not Listing objects that are not comparable */ + options->m_list_not_cmp = 0; + + /* initially no not-comparable. */ + /**this is bad in mixing option with results**/ + options->not_cmp=0; + /* init for exclude-path option */ exclude_head = NULL; diff --git a/tools/h5diff/testfiles/h5diff_101w.txt b/tools/h5diff/testfiles/h5diff_101w.txt index d1f49da..71f4e87 100644 --- a/tools/h5diff/testfiles/h5diff_101w.txt +++ b/tools/h5diff/testfiles/h5diff_101w.txt @@ -1,11 +1,11 @@ -dataset: </g1/d1> and </g1/d2>
-size: [3x2] [3x2]
-position d1 d2 difference
-------------------------------------------------------------
-[ 0 1 ] 1e-016 4e-016 3e-016
-[ 1 0 ] 1e-016 2e-016 1e-016
-[ 1 1 ] 0 1e-016 1e-016
-[ 2 0 ] 3.3e-016 1e-016 2.3e-016
-[ 2 1 ] 1e-016 0 1e-016
-5 differences found
-EXIT CODE: 1
+dataset: </g1/d1> and </g1/d2> +size: [3x2] [3x2] +position d1 d2 difference +------------------------------------------------------------ +[ 0 1 ] 1e-016 4e-016 3e-016 +[ 1 0 ] 1e-016 2e-016 1e-016 +[ 1 1 ] 0 1e-016 1e-016 +[ 2 0 ] 3.3e-016 1e-016 2.3e-016 +[ 2 1 ] 1e-016 0 1e-016 +5 differences found +EXIT CODE: 1 diff --git a/tools/h5diff/testfiles/h5diff_102w.txt b/tools/h5diff/testfiles/h5diff_102w.txt index dda3581..19a097c 100644 --- a/tools/h5diff/testfiles/h5diff_102w.txt +++ b/tools/h5diff/testfiles/h5diff_102w.txt @@ -1,10 +1,10 @@ -dataset: </g1/fp1> and </g1/fp2>
-size: [3x2] [3x2]
-position fp1 fp2 difference
-------------------------------------------------------------
-[ 0 1 ] 1e-007 2e-007 1e-007
-[ 1 0 ] 1e-007 3e-007 2e-007
-[ 1 1 ] 2.2e-007 1e-007 1.2e-007
-[ 2 0 ] 1e-007 0 1e-007
-4 differences found
-EXIT CODE: 1
+dataset: </g1/fp1> and </g1/fp2> +size: [3x2] [3x2] +position fp1 fp2 difference +------------------------------------------------------------ +[ 0 1 ] 1e-007 2e-007 1e-007 +[ 1 0 ] 1e-007 3e-007 2e-007 +[ 1 1 ] 2.2e-007 1e-007 1.2e-007 +[ 2 0 ] 1e-007 0 1e-007 +4 differences found +EXIT CODE: 1 diff --git a/tools/h5diff/testfiles/h5diff_tmp1.txt b/tools/h5diff/testfiles/h5diff_tmp1.txt new file mode 100644 index 0000000..40e3fb6 --- /dev/null +++ b/tools/h5diff/testfiles/h5diff_tmp1.txt @@ -0,0 +1,5 @@ +-------------------------------- +Some objects are not comparable +-------------------------------- +Use -c for a list of objects. +EXIT CODE: 0 diff --git a/tools/h5diff/testfiles/h5diff_tmp2.txt b/tools/h5diff/testfiles/h5diff_tmp2.txt new file mode 100644 index 0000000..a2d6da6 --- /dev/null +++ b/tools/h5diff/testfiles/h5diff_tmp2.txt @@ -0,0 +1,13 @@ +dataset: </G/down/Data> and </G/down/Data> +1599 differences found +dataset: </G/down/Tail/array> and </G/down/Tail/array> +8 differences found +dataset: </G/up/Data> and </G/up/Data> +1845 differences found +dataset: </G/up/Tail/array> and </G/up/Tail/array> +10 differences found +-------------------------------- +Some objects are not comparable +-------------------------------- +Use -c for a list of objects. +EXIT CODE: 1 diff --git a/tools/h5diff/testfiles/tmpSingleSiteBethe.output.h5 b/tools/h5diff/testfiles/tmpSingleSiteBethe.output.h5 Binary files differnew file mode 100644 index 0000000..bbcfb63 --- /dev/null +++ b/tools/h5diff/testfiles/tmpSingleSiteBethe.output.h5 diff --git a/tools/h5diff/testfiles/tmpSingleSiteBethe.reference.h5 b/tools/h5diff/testfiles/tmpSingleSiteBethe.reference.h5 Binary files differnew file mode 100644 index 0000000..6b19ed7 --- /dev/null +++ b/tools/h5diff/testfiles/tmpSingleSiteBethe.reference.h5 diff --git a/tools/h5diff/testfiles/tmptest.he5 b/tools/h5diff/testfiles/tmptest.he5 Binary files differnew file mode 100644 index 0000000..edcfcd2 --- /dev/null +++ b/tools/h5diff/testfiles/tmptest.he5 diff --git a/tools/h5diff/testfiles/tmptest2.he5 b/tools/h5diff/testfiles/tmptest2.he5 Binary files differnew file mode 100644 index 0000000..a6ab02b --- /dev/null +++ b/tools/h5diff/testfiles/tmptest2.he5 diff --git a/tools/h5diff/testh5diff.sh.in b/tools/h5diff/testh5diff.sh.in index 549da49..ee8a09b 100644 --- a/tools/h5diff/testh5diff.sh.in +++ b/tools/h5diff/testh5diff.sh.in @@ -302,6 +302,12 @@ $SRC_H5DIFF_TESTFILES/h5diff_709.txt $SRC_H5DIFF_TESTFILES/h5diff_710.txt $SRC_H5DIFF_TESTFILES/h5diff_80.txt $SRC_H5DIFF_TESTFILES/h5diff_90.txt +$SRC_H5DIFF_TESTFILES/h5diff_tmp1.txt +$SRC_H5DIFF_TESTFILES/h5diff_tmp2.txt +$SRC_H5DIFF_TESTFILES/tmptest.he5 +$SRC_H5DIFF_TESTFILES/tmptest2.he5 +$SRC_H5DIFF_TESTFILES/tmpSingleSiteBethe.reference.h5 +$SRC_H5DIFF_TESTFILES/tmpSingleSiteBethe.output.h5 " # @@ -757,6 +763,10 @@ TOOLTEST h5diff_631.txt -v --use-system-epsilon h5diff_basic1.h5 h5diff_basic1.h # 7. attributes # ############################################################################## TOOLTEST h5diff_70.txt -v h5diff_attr1.h5 h5diff_attr2.h5 +# temporary test to verify HDF5-8625 +TOOLTEST h5diff_tmp1.txt tmptest2.he5 tmptest.he5 +# temporary test to verify HDF5-8639 +TOOLTEST h5diff_tmp2.txt tmpSingleSiteBethe.output.h5 tmpSingleSiteBethe.reference.h5 # ################################################## # attrs with verbose option level diff --git a/tools/h5dump/CMakeLists.txt b/tools/h5dump/CMakeLists.txt index 1a46586..584222e 100644 --- a/tools/h5dump/CMakeLists.txt +++ b/tools/h5dump/CMakeLists.txt @@ -48,9 +48,9 @@ endif (BUILD_TESTING) ############################################################################## ############################################################################## -#-----------------------------------------------------------------------------
-# Rules for Installation of tools using make Install target
-#-----------------------------------------------------------------------------
+#----------------------------------------------------------------------------- +# Rules for Installation of tools using make Install target +#----------------------------------------------------------------------------- #INSTALL_PROGRAM_PDB (h5dump ${HDF5_INSTALL_BIN_DIR} toolsapplications) diff --git a/tools/h5dump/CMakeTests.cmake b/tools/h5dump/CMakeTests.cmake index bb2a37e..f9ebc32 100644 --- a/tools/h5dump/CMakeTests.cmake +++ b/tools/h5dump/CMakeTests.cmake @@ -313,7 +313,7 @@ # 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) + get_filename_component (fname "${tst_h5_file}" NAME) set (dest "${PROJECT_BINARY_DIR}/testfiles/std/${fname}") #message (STATUS " Copying ${tst_h5_file}") add_custom_command ( @@ -325,21 +325,21 @@ endforeach (tst_h5_file ${HDF5_REFERENCE_TEST_FILES}) foreach (tst_exp_file ${HDF5_REFERENCE_EXP_FILES}) - if (WIN32 AND NOT CYGWIN) + 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 AND NOT CYGWIN) + else (WIN32) add_custom_command ( TARGET h5dump POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${HDF5_TOOLS_SRC_DIR}/testfiles/${tst_exp_file} ${PROJECT_BINARY_DIR}/testfiles/std/${tst_exp_file} ) - endif (WIN32 AND NOT CYGWIN) + 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) + get_filename_component (fname "${tst_other_file}" NAME) set (dest "${PROJECT_BINARY_DIR}/testfiles/std/${fname}") #message (STATUS " Copying ${tst_other_file}") add_custom_command ( @@ -351,7 +351,7 @@ endforeach (tst_other_file ${HDF5_REFERENCE_FILES}) foreach (tst_error_file ${HDF5_ERROR_REFERENCE_TEST_FILES}) - GET_FILENAME_COMPONENT(fname "${tst_error_file}" NAME) + get_filename_component (fname "${tst_error_file}" NAME) set (dest "${PROJECT_BINARY_DIR}/testfiles/std/${fname}") #message (STATUS " Copying ${tst_error_file}") add_custom_command ( @@ -372,17 +372,17 @@ ARGS -E copy_if_different ${HDF5_TOOLS_SOURCE_DIR}/testfiles/tbin1.ddl ${PROJECT_BINARY_DIR}/testfiles/std/tbin1LE.ddl ) - if (WIN32 AND NOT CYGWIN) + 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 AND NOT CYGWIN) + else (WIN32) add_custom_command ( TARGET h5dump POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${HDF5_TOOLS_SRC_DIR}/testfiles/tbinregR.exp ${PROJECT_BINARY_DIR}/testfiles/std/tbinregR.exp ) - endif (WIN32 AND NOT CYGWIN) + endif (WIN32) ############################################################################## ############################################################################## @@ -415,7 +415,7 @@ -D "TEST_OUTPUT=h5dump-${testname}.out" -D "TEST_EXPECT=${resultcode}" -D "TEST_REFERENCE=h5dump-${testname}.txt" - -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5DUMP-h5dump-${testname} PROPERTIES DEPENDS "H5DUMP-h5dump-${testname}-clear-objects") endif (HDF5_ENABLE_USING_MEMCHECKER) @@ -461,7 +461,7 @@ -D "TEST_OUTPUT=${resultfile}.out" -D "TEST_EXPECT=${resultcode}" -D "TEST_REFERENCE=${resultfile}.ddl" - -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5DUMP-${resultfile} PROPERTIES DEPENDS "H5DUMP-${resultfile}-clear-objects") endif (HDF5_ENABLE_USING_MEMCHECKER) @@ -494,7 +494,7 @@ -D "TEST_OUTPUT=${resultfile}-N.out" -D "TEST_EXPECT=${resultcode}" -D "TEST_REFERENCE=${resultfile}.ddl" - -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + -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) @@ -527,7 +527,7 @@ -D "TEST_OUTPUT=${resultfile}.out" -D "TEST_EXPECT=${resultcode}" -D "TEST_REFERENCE=${resultfile}.ddl" - -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5DUMP-${resultfile} PROPERTIES DEPENDS "H5DUMP-${resultfile}-clear-objects") add_test ( @@ -567,7 +567,7 @@ -D "TEST_OUTPUT=${resultfile}.out" -D "TEST_EXPECT=${resultcode}" -D "TEST_REFERENCE=${resultfile}.ddl" - -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5DUMP-${resultfile} PROPERTIES DEPENDS "H5DUMP-${resultfile}-clear-objects") add_test ( @@ -629,7 +629,7 @@ -D "TEST_EXPECT=${resultcode}" -D "TEST_REFERENCE=${resultfile}.ddl" -D "TEST_MASK_ERROR=true" - -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5DUMP-${resultfile} PROPERTIES DEPENDS "H5DUMP-${resultfile}-clear-objects") endif (NOT HDF5_ENABLE_USING_MEMCHECKER) @@ -654,7 +654,7 @@ -D "TEST_REFERENCE=${resultfile}.ddl" -D "TEST_ERRREF=${resultfile}.err" -D "TEST_MASK_ERROR=true" - -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5DUMP-${resultfile} PROPERTIES DEPENDS "H5DUMP-${resultfile}-clear-objects") endif (NOT HDF5_ENABLE_USING_MEMCHECKER) @@ -681,7 +681,7 @@ -D "TEST_MASK_ERROR=true" -D "TEST_ENV_VAR:STRING=${envvar}" -D "TEST_ENV_VALUE:STRING=${envval}" - -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5DUMP-${resultfile} PROPERTIES DEPENDS "H5DUMP-${resultfile}-clear-objects") endif (NOT HDF5_ENABLE_USING_MEMCHECKER) @@ -705,7 +705,7 @@ -D "TEST_OUTPUT=${conffile}.out" -D "TEST_EXPECT=${resultcode}" -D "TEST_REFERENCE=${conffile}.ddl" - -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + -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) diff --git a/tools/h5dump/CMakeTestsPBITS.cmake b/tools/h5dump/CMakeTestsPBITS.cmake index a920198..421e020 100644 --- a/tools/h5dump/CMakeTestsPBITS.cmake +++ b/tools/h5dump/CMakeTestsPBITS.cmake @@ -155,7 +155,7 @@ -D "TEST_OUTPUT=${resultfile}.out" -D "TEST_EXPECT=${resultcode}" -D "TEST_REFERENCE=${resultfile}.ddl" - -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5DUMP-${resultfile} PROPERTIES DEPENDS "H5DUMP-${resultfile}-clear-objects") endif (HDF5_ENABLE_USING_MEMCHECKER) diff --git a/tools/h5dump/CMakeTestsXML.cmake b/tools/h5dump/CMakeTestsXML.cmake index ffc1cae..0d4e0f4 100644 --- a/tools/h5dump/CMakeTestsXML.cmake +++ b/tools/h5dump/CMakeTestsXML.cmake @@ -196,7 +196,7 @@ -D "TEST_OUTPUT=${resultfile}.out" -D "TEST_EXPECT=${resultcode}" -D "TEST_REFERENCE=${resultfile}.xml" - -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5DUMP-XML-${resultfile} PROPERTIES DEPENDS "H5DUMP-XML-${resultfile}-clear-objects") endif (HDF5_ENABLE_USING_MEMCHECKER) diff --git a/tools/h5dump/Makefile.in b/tools/h5dump/Makefile.in index 580e556..a8ece19 100644 --- a/tools/h5dump/Makefile.in +++ b/tools/h5dump/Makefile.in @@ -512,7 +512,6 @@ LIPO = @LIPO@ LL_PATH = @LL_PATH@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ -LT_ADD_LIBHDF5_DEPENDENCY = @LT_ADD_LIBHDF5_DEPENDENCY@ LT_STATIC_EXEC = @LT_STATIC_EXEC@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ diff --git a/tools/h5import/CMakeLists.txt b/tools/h5import/CMakeLists.txt index 36a3a9e..a18133f 100644 --- a/tools/h5import/CMakeLists.txt +++ b/tools/h5import/CMakeLists.txt @@ -38,9 +38,9 @@ endif (BUILD_TESTING) ############################################################################## ############################################################################## -#-----------------------------------------------------------------------------
-# Rules for Installation of tools using make Install target
-#-----------------------------------------------------------------------------
+#----------------------------------------------------------------------------- +# Rules for Installation of tools using make Install target +#----------------------------------------------------------------------------- #INSTALL_PROGRAM_PDB (h5import ${HDF5_INSTALL_BIN_DIR} toolsapplications) diff --git a/tools/h5import/CMakeTests.cmake b/tools/h5import/CMakeTests.cmake index 5c5b4de..6986aee 100644 --- a/tools/h5import/CMakeTests.cmake +++ b/tools/h5import/CMakeTests.cmake @@ -133,7 +133,7 @@ -D "TEST_EXPECT=0" -D "TEST_FILTER=(^(HDF5)[^\n]*)" -D "TEST_SKIP_COMPARE=TRUE" - -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5IMPORT-${testname}-H5DMP PROPERTIES DEPENDS H5IMPORT-${testname}) add_test ( @@ -146,7 +146,7 @@ -D "TEST_EXPECT=0" -D "TEST_FILTER=(^(HDF5)[^\n]*)" -D "TEST_REFERENCE=${testfile}.new" - -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5IMPORT-${testname}-H5DMP_CMP PROPERTIES DEPENDS H5IMPORT-${testname}-H5DMP) endif (HDF5_ENABLE_USING_MEMCHECKER) @@ -180,7 +180,7 @@ -D "TEST_OUTPUT=d${testfile}.dmp" -D "TEST_EXPECT=0" -D "TEST_SKIP_COMPARE=TRUE" - -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) else ("${ARGN}" STREQUAL "BINARY") add_test ( @@ -192,7 +192,7 @@ -D "TEST_OUTPUT=d${testfile}.dmp" -D "TEST_EXPECT=0" -D "TEST_SKIP_COMPARE=TRUE" - -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) endif ("${ARGN}" STREQUAL "BINARY") set_tests_properties (H5IMPORT-DUMP-${testname}-H5DMP PROPERTIES DEPENDS "H5IMPORT-DUMP-${testname}-clear-objects") @@ -206,7 +206,7 @@ -D "TEST_OUTPUT=d${testfile}.imp" -D "TEST_EXPECT=0" -D "TEST_SKIP_COMPARE=TRUE" - -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5IMPORT-DUMP-${testname} PROPERTIES DEPENDS "H5IMPORT-DUMP-${testname}-H5DMP") @@ -214,13 +214,13 @@ NAME H5IMPORT-DUMP-${testname}-H5DFF COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$<TARGET_FILE:h5diff>" - -D "TEST_ARGS:STRING=-v;d${testfile};testfiles/${testfile};${datasetname};${datasetname}" + -D "TEST_ARGS:STRING=-r;d${testfile};testfiles/${testfile};${datasetname};${datasetname}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" -D "TEST_OUTPUT=d${testfile}.dff" -D "TEST_EXPECT=0" -D "TEST_FILTER=(^(Warning)[^\n]*)" -D "TEST_REFERENCE=testfiles/d${testfile}.txt" - -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5IMPORT-DUMP-${testname}-H5DFF PROPERTIES DEPENDS "H5IMPORT-DUMP-${testname}") endif (NOT HDF5_ENABLE_USING_MEMCHECKER) diff --git a/tools/h5import/Makefile.in b/tools/h5import/Makefile.in index 25f6396..882a7fd 100644 --- a/tools/h5import/Makefile.in +++ b/tools/h5import/Makefile.in @@ -512,7 +512,6 @@ LIPO = @LIPO@ LL_PATH = @LL_PATH@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ -LT_ADD_LIBHDF5_DEPENDENCY = @LT_ADD_LIBHDF5_DEPENDENCY@ LT_STATIC_EXEC = @LT_STATIC_EXEC@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ diff --git a/tools/h5import/h5import.c b/tools/h5import/h5import.c index 74c67b9..96fb6f9 100644 --- a/tools/h5import/h5import.c +++ b/tools/h5import/h5import.c @@ -874,12 +874,9 @@ static int processStrData(FILE *strm, struct Input *in, hid_t file_id) *------------------------------------------------------------------------- */ - while (!HDfeof(strm)) { - c = HDfgetc(strm); - + while(EOF != (c = HDfgetc(strm))) if (c == 10) /* eol */ nlines++; - } if (!nlines) return 0; @@ -940,9 +937,7 @@ static int processStrData(FILE *strm, struct Input *in, hid_t file_id) line = 0; - while (!HDfeof(strm)) { - c = HDfgetc(strm); - + while(EOF != (c = HDfgetc(strm))) { str[i] = (char)c; i++; diff --git a/tools/h5jam/CMakeLists.txt b/tools/h5jam/CMakeLists.txt index b0d5ac8..a8e3a7c 100644 --- a/tools/h5jam/CMakeLists.txt +++ b/tools/h5jam/CMakeLists.txt @@ -64,9 +64,9 @@ endif (BUILD_TESTING) ############################################################################## ############################################################################## -#-----------------------------------------------------------------------------
-# Rules for Installation of tools using make Install target
-#-----------------------------------------------------------------------------
+#----------------------------------------------------------------------------- +# Rules for Installation of tools using make Install target +#----------------------------------------------------------------------------- #INSTALL_PROGRAM_PDB (h5jam ${HDF5_INSTALL_BIN_DIR} toolsapplications) diff --git a/tools/h5jam/CMakeTests.cmake b/tools/h5jam/CMakeTests.cmake index fb64313..b5dc256 100644 --- a/tools/h5jam/CMakeTests.cmake +++ b/tools/h5jam/CMakeTests.cmake @@ -77,7 +77,7 @@ -D "TEST_OUTPUT=${expectfile}.out" -D "TEST_EXPECT=${resultcode}" -D "TEST_REFERENCE=testfiles/${expectfile}.txt" - -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5JAM-${expectfile} PROPERTIES DEPENDS H5JAM-${expectfile}-clear-objects) endif (HDF5_ENABLE_USING_MEMCHECKER) @@ -111,7 +111,7 @@ -D "TEST_OUTPUT=${expectfile}.out" -D "TEST_EXPECT=${resultcode}" -D "TEST_REFERENCE=testfiles/${expectfile}.txt" - -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5JAM-UNJAM-${expectfile} PROPERTIES DEPENDS H5JAM-UNJAM-${expectfile}-clear-objects) endif (HDF5_ENABLE_USING_MEMCHECKER) @@ -140,7 +140,7 @@ -D "TEST_EXPECT=0" -D "TEST_FILTER=(^(HDF5)[^\n]*)" -D "TEST_SKIP_COMPARE=TRUE" - -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5JAM-${testname}-CHECKFILE-H5DMP PROPERTIES DEPENDS H5JAM-${testname}-CHECKFILE-clear-objects) add_test ( @@ -153,7 +153,7 @@ -D "TEST_EXPECT=0" -D "TEST_FILTER=(^(HDF5)[^\n]*)" -D "TEST_REFERENCE=${actual}.new" - -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5JAM-${testname}-CHECKFILE-H5DMP_CMP PROPERTIES DEPENDS H5JAM-${testname}-CHECKFILE-H5DMP) endif (NOT HDF5_ENABLE_USING_MEMCHECKER) @@ -200,7 +200,7 @@ -D "TEST_OUTPUT=${outfile}.ufile.txt" -D "TEST_EXPECT=0" -D "TEST_SKIP_COMPARE=TRUE" - -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5JAM-${testname}-UNJAM PROPERTIES DEPENDS H5JAM-${testname}-UNJAM_D-clear-objects) set (compare_test "${outfile}.ufile.txt") @@ -231,7 +231,7 @@ -D "TEST_UFILE=${compare_test}" -D "TEST_EXPECT=0" -D "TEST_OFILE=" - -P "${HDF5_RESOURCES_DIR}/userblockTest.cmake" + -P "${HDF_RESOURCES_DIR}/userblockTest.cmake" ) set_tests_properties (H5JAM-${testname}-UNJAM-CHECK_UB_1 PROPERTIES DEPENDS H5JAM-${testname}-UNJAM-CHECK_UB_1-clear-objects) endif (NOT "${compare_test}" STREQUAL "") @@ -247,7 +247,7 @@ -D "TEST_EXPECT=0" -D "TEST_UFILE=NULL" -D "TEST_OFILE=NULL" - -P "${HDF5_RESOURCES_DIR}/userblockTest.cmake" + -P "${HDF_RESOURCES_DIR}/userblockTest.cmake" ) if (NOT "${compare_test}" STREQUAL "") set_tests_properties (H5JAM-${testname}-UNJAM-CHECK_NOUB PROPERTIES DEPENDS H5JAM-${testname}-UNJAM-CHECK_UB_1) @@ -295,7 +295,7 @@ -D "TEST_UFILE=testfiles/${jamfile}" -D "TEST_EXPECT=0" -D "TEST_OFILE=${compare_orig}" - -P "${HDF5_RESOURCES_DIR}/userblockTest.cmake" + -P "${HDF_RESOURCES_DIR}/userblockTest.cmake" ) set_tests_properties (H5JAM-${testname}-CHECK_UB_1 PROPERTIES DEPENDS H5JAM-${testname}-CHECK_UB_1-clear-objects) CHECKFILE (${testname} "H5JAM-${testname}-CHECK_UB_1" ${chkfile} ${outfile}) @@ -350,7 +350,7 @@ -D "TEST_UFILE=testfiles/${jamfile}" -D "TEST_EXPECT=0" -D "TEST_OFILE=${compare_orig}" - -P "${HDF5_RESOURCES_DIR}/userblockTest.cmake" + -P "${HDF_RESOURCES_DIR}/userblockTest.cmake" ) set_tests_properties (H5JAM-${testname}_NONE-CHECK_UB_1 PROPERTIES DEPENDS H5JAM-${testname}_NONE-CHECK_UB_1-clear-objects) CHECKFILE (${testname} "H5JAM-${testname}_NONE-CHECK_UB_1" ${infile} ${chkfile}) diff --git a/tools/h5jam/Makefile.in b/tools/h5jam/Makefile.in index 4110711..9c5fb3d 100644 --- a/tools/h5jam/Makefile.in +++ b/tools/h5jam/Makefile.in @@ -524,7 +524,6 @@ LIPO = @LIPO@ LL_PATH = @LL_PATH@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ -LT_ADD_LIBHDF5_DEPENDENCY = @LT_ADD_LIBHDF5_DEPENDENCY@ LT_STATIC_EXEC = @LT_STATIC_EXEC@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ diff --git a/tools/h5ls/CMakeLists.txt b/tools/h5ls/CMakeLists.txt index 5220087..f3749e3 100644 --- a/tools/h5ls/CMakeLists.txt +++ b/tools/h5ls/CMakeLists.txt @@ -31,9 +31,9 @@ endif (BUILD_TESTING) ############################################################################## ############################################################################## -#-----------------------------------------------------------------------------
-# Rules for Installation of tools using make Install target
-#-----------------------------------------------------------------------------
+#----------------------------------------------------------------------------- +# Rules for Installation of tools using make Install target +#----------------------------------------------------------------------------- #INSTALL_PROGRAM_PDB (h5ls ${HDF5_INSTALL_BIN_DIR} toolsapplications) diff --git a/tools/h5ls/CMakeTests.cmake b/tools/h5ls/CMakeTests.cmake index b739130..a42fa17 100644 --- a/tools/h5ls/CMakeTests.cmake +++ b/tools/h5ls/CMakeTests.cmake @@ -140,7 +140,7 @@ -D "TEST_OUTPUT=${resultfile}.out" -D "TEST_EXPECT=${resultcode}" -D "TEST_REFERENCE=${resultfile}.ls" - -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5LS-${resultfile} PROPERTIES DEPENDS "H5LS-${resultfile}-clear-objects") endif (HDF5_ENABLE_USING_MEMCHECKER) diff --git a/tools/h5ls/Makefile.in b/tools/h5ls/Makefile.in index 0be4775..c532903 100644 --- a/tools/h5ls/Makefile.in +++ b/tools/h5ls/Makefile.in @@ -504,7 +504,6 @@ LIPO = @LIPO@ LL_PATH = @LL_PATH@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ -LT_ADD_LIBHDF5_DEPENDENCY = @LT_ADD_LIBHDF5_DEPENDENCY@ LT_STATIC_EXEC = @LT_STATIC_EXEC@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c index 33fc17a..2030221 100644 --- a/tools/h5ls/h5ls.c +++ b/tools/h5ls/h5ls.c @@ -816,8 +816,6 @@ print_float_type(h5tools_str_t *buffer, hid_t type, int ind) * Programmer: Robb Matzke * Thursday, November 5, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ static hbool_t @@ -832,8 +830,7 @@ print_cmpd_type(h5tools_str_t *buffer, hid_t type, int ind) if(H5T_COMPOUND != H5Tget_class(type)) return FALSE; - nmembs = H5Tget_nmembers(type); - if(nmembs <= 0) + if((nmembs = H5Tget_nmembers(type)) < 0) return FALSE; h5tools_str_append(buffer, "struct {"); @@ -855,6 +852,7 @@ print_cmpd_type(h5tools_str_t *buffer, hid_t type, int ind) size = H5Tget_size(type); h5tools_str_append(buffer, "\n%*s} %lu byte%s", ind, "", (unsigned long)size, 1==size?"":"s"); + return TRUE; } @@ -883,8 +881,7 @@ print_enum_type(h5tools_str_t *buffer, hid_t type, int ind) if(H5T_ENUM != H5Tget_class(type)) return FALSE; - nmembs = H5Tget_nmembers(type); - if(nmembs < 0) + if((nmembs = H5Tget_nmembers(type)) < 0) return FALSE; super = H5Tget_super(type); diff --git a/tools/h5repack/CMakeLists.txt b/tools/h5repack/CMakeLists.txt index 4d26c0c..cb8720e 100644 --- a/tools/h5repack/CMakeLists.txt +++ b/tools/h5repack/CMakeLists.txt @@ -51,7 +51,7 @@ if (BUILD_TESTING) set (HDF5_TOOL_PLUGIN_LIB_CORENAME "dynlibadd") set (HDF5_TOOL_PLUGIN_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TOOL_PLUGIN_LIB_CORENAME}") set (HDF5_TOOL_PLUGIN_LIB_TARGET ${HDF5_TOOL_PLUGIN_LIB_CORENAME}) - add_definitions (${HDF5_EXTRA_C_FLAGS}) + add_definitions (${HDF_EXTRA_C_FLAGS}) INCLUDE_DIRECTORIES (${HDF5_SRC_DIR}) add_library (${HDF5_TOOL_PLUGIN_LIB_TARGET} ${LIB_TYPE} dynlib_rpk.c) @@ -89,9 +89,9 @@ endif (BUILD_TESTING) ############################################################################## ############################################################################## -#-----------------------------------------------------------------------------
-# Rules for Installation of tools using make Install target
-#-----------------------------------------------------------------------------
+#----------------------------------------------------------------------------- +# Rules for Installation of tools using make Install target +#----------------------------------------------------------------------------- #INSTALL_PROGRAM_PDB (h5repack ${HDF5_INSTALL_BIN_DIR} toolsapplications) diff --git a/tools/h5repack/CMakeTests.cmake b/tools/h5repack/CMakeTests.cmake index 430defc..220c871 100644 --- a/tools/h5repack/CMakeTests.cmake +++ b/tools/h5repack/CMakeTests.cmake @@ -29,7 +29,7 @@ -D "TEST_EXPECT=${resultcode}" -D "TEST_OUTPUT=h5repacktest" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" - -P "${HDF5_RESOURCES_DIR}/vfdTest.cmake" + -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" ) if (NOT "${last_test}" STREQUAL "") set_tests_properties (H5REPACK-VFD-${vfdname}-h5repacktest PROPERTIES DEPENDS ${last_test}) @@ -136,7 +136,7 @@ -D "TEST_OUTPUT=h5repack-${testname}.out" -D "TEST_EXPECT=${resultcode}" -D "TEST_REFERENCE=h5repack-${testname}.txt" - -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5REPACK-h5repack-${testname} PROPERTIES DEPENDS "H5REPACK-h5repack-${testname}-clear-objects") endif (HDF5_ENABLE_USING_MEMCHECKER) @@ -215,7 +215,7 @@ -D "TEST_EXPECT=${resultcode}" -D "TEST_FILTER:STRING=${testfilter}" -D "TEST_REFERENCE=${resultfile}.tst" - -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) endif (HDF5_ENABLE_USING_MEMCHECKER) if (NOT "${last_test}" STREQUAL "") @@ -250,7 +250,7 @@ -D "TEST_OUTPUT=${resultfile}-${testname}.out" -D "TEST_EXPECT=${resultcode}" -D "TEST_REFERENCE=${testname}.${resultfile}.ddl" - -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5REPACK_DMP-h5dump-${testname} PROPERTIES DEPENDS "H5REPACK_DMP-${testname}") endif (NOT HDF5_ENABLE_USING_MEMCHECKER) @@ -290,7 +290,7 @@ -D "TEST_EXPECT=${resultcode}" -D "TEST_FILTER:STRING=${testfilter}" -D "TEST_REFERENCE=${testfilter}" - -P "${HDF5_RESOURCES_DIR}/grepTest.cmake" + -P "${HDF_RESOURCES_EXT_DIR}/grepTest.cmake" ) set_tests_properties (H5REPACK_VERIFY_LAYOUT-${testname}_DMP PROPERTIES DEPENDS H5REPACK_VERIFY_LAYOUT-${testname}_DFF) else (${resultcode} STREQUAL "0") @@ -313,7 +313,7 @@ -D "TEST_EXPECT=${resultcode}" -D "TEST_FILTER:STRING=${nottestfilter}" -D "TEST_REFERENCE=${testfilter}" - -P "${HDF5_RESOURCES_DIR}/grepTest.cmake" + -P "${HDF_RESOURCES_EXT_DIR}/grepTest.cmake" ) set_tests_properties (H5REPACK_VERIFY_LAYOUT-${testname}_DMP PROPERTIES DEPENDS H5REPACK_VERIFY_LAYOUT-${testname}_DFF) endif (${resultcode} STREQUAL "0") @@ -365,7 +365,7 @@ -D "TEST_REFERENCE=${testname}.${resultfile}.tst" -D "TEST_ENV_VAR=HDF5_PLUGIN_PATH" -D "TEST_ENV_VALUE=${CMAKE_BINARY_DIR}/plugins" - -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5REPACK_UD-${testname} PROPERTIES DEPENDS H5REPACK_UD-${testname}-clearall-objects) add_test ( @@ -379,7 +379,7 @@ -D "TEST_REFERENCE=${resultfile}-${testname}.ddl" -D "TEST_ENV_VAR=HDF5_PLUGIN_PATH" -D "TEST_ENV_VALUE=${CMAKE_BINARY_DIR}/plugins" - -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5REPACK_UD-h5dump-${testname} PROPERTIES DEPENDS "H5REPACK_UD-${testname}") endif (HDF5_BUILD_TOOLS AND NOT HDF5_ENABLE_USING_MEMCHECKER) diff --git a/tools/h5repack/Makefile.in b/tools/h5repack/Makefile.in index 3cde929..7a97227 100644 --- a/tools/h5repack/Makefile.in +++ b/tools/h5repack/Makefile.in @@ -536,7 +536,6 @@ LIPO = @LIPO@ LL_PATH = @LL_PATH@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ -LT_ADD_LIBHDF5_DEPENDENCY = @LT_ADD_LIBHDF5_DEPENDENCY@ LT_STATIC_EXEC = @LT_STATIC_EXEC@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ diff --git a/tools/h5stat/CMakeLists.txt b/tools/h5stat/CMakeLists.txt index 82f0ffb..0658216 100644 --- a/tools/h5stat/CMakeLists.txt +++ b/tools/h5stat/CMakeLists.txt @@ -40,9 +40,9 @@ endif (BUILD_TESTING) ############################################################################## ############################################################################## -#-----------------------------------------------------------------------------
-# Rules for Installation of tools using make Install target
-#-----------------------------------------------------------------------------
+#----------------------------------------------------------------------------- +# Rules for Installation of tools using make Install target +#----------------------------------------------------------------------------- #INSTALL_PROGRAM_PDB (h5stat ${HDF5_INSTALL_BIN_DIR} toolsapplications) diff --git a/tools/h5stat/CMakeTests.cmake b/tools/h5stat/CMakeTests.cmake index b803dff..4175eb2 100644 --- a/tools/h5stat/CMakeTests.cmake +++ b/tools/h5stat/CMakeTests.cmake @@ -101,7 +101,7 @@ -D "TEST_OUTPUT=${resultfile}.out" -D "TEST_EXPECT=${resultcode}" -D "TEST_REFERENCE=${resultfile}.ddl" - -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5STAT-${resultfile} PROPERTIES DEPENDS "H5STAT-${resultfile}-clear-objects") endif (HDF5_ENABLE_USING_MEMCHECKER) diff --git a/tools/h5stat/Makefile.in b/tools/h5stat/Makefile.in index 1eba3c3..a6b44d8 100644 --- a/tools/h5stat/Makefile.in +++ b/tools/h5stat/Makefile.in @@ -514,7 +514,6 @@ LIPO = @LIPO@ LL_PATH = @LL_PATH@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ -LT_ADD_LIBHDF5_DEPENDENCY = @LT_ADD_LIBHDF5_DEPENDENCY@ LT_STATIC_EXEC = @LT_STATIC_EXEC@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ diff --git a/tools/lib/CMakeLists.txt b/tools/lib/CMakeLists.txt index c3b8294..e65673a 100644 --- a/tools/lib/CMakeLists.txt +++ b/tools/lib/CMakeLists.txt @@ -4,7 +4,7 @@ PROJECT (HDF5_TOOLS_LIB) #----------------------------------------------------------------------------- # Apply Definitions to compiler in this directory and below #----------------------------------------------------------------------------- -add_definitions (${HDF5_EXTRA_C_FLAGS}) +add_definitions (${HDF_EXTRA_C_FLAGS}) #----------------------------------------------------------------------------- # Define Sources @@ -71,21 +71,6 @@ install ( ) #----------------------------------------------------------------------------- -# Because tools are installed into bin/tools we need to make sure the hdf5tools -# library will be installed into the proper location. -#----------------------------------------------------------------------------- -if (APPLE) - option (HDF5_BUILD_WITH_INSTALL_NAME "Build with library install_name set to the installation path" OFF) - if (HDF5_BUILD_WITH_INSTALL_NAME) - SET_TARGET_PROPERTIES(${HDF5_TOOLS_LIB_TARGET} PROPERTIES - LINK_FLAGS "-current_version ${HDF5_PACKAGE_VERSION} -compatibility_version ${HDF5_PACKAGE_VERSION}" - INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib" - BUILD_WITH_INSTALL_RPATH ${HDF5_BUILD_WITH_INSTALL_NAME} - ) - endif (HDF5_BUILD_WITH_INSTALL_NAME) -endif (APPLE) - -#----------------------------------------------------------------------------- # Add Target(s) to CMake Install for import into other projects #----------------------------------------------------------------------------- if (HDF5_EXPORTED_TARGETS) diff --git a/tools/lib/Makefile.in b/tools/lib/Makefile.in index 938350e..59fefbf 100644 --- a/tools/lib/Makefile.in +++ b/tools/lib/Makefile.in @@ -501,7 +501,6 @@ LIPO = @LIPO@ LL_PATH = @LL_PATH@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ -LT_ADD_LIBHDF5_DEPENDENCY = @LT_ADD_LIBHDF5_DEPENDENCY@ LT_STATIC_EXEC = @LT_STATIC_EXEC@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c index 884a85d..13cea23 100644 --- a/tools/lib/h5diff.c +++ b/tools/lib/h5diff.c @@ -470,75 +470,81 @@ static herr_t trav_grp_symlinks(const char *path, const H5L_info_t *linfo, switch(linfo->type) { - case H5L_TYPE_SOFT: - ret = H5tools_get_symlink_info(tinfo->fid, path, &lnk_info, opts->follow_links); - /* error */ - if (ret < 0) - goto done; - /* no dangling link option given and detect dangling link */ - else if (ret == 0) - { - tinfo->symlink_visited.dangle_link = TRUE; - trav_info_visit_lnk(path, linfo, tinfo); - if (opts->no_dangle_links) - opts->err_stat = 1; /* make dgangling link is error */ - goto done; - } + case H5L_TYPE_SOFT: + ret = H5tools_get_symlink_info(tinfo->fid, path, &lnk_info, opts->follow_links); + /* error */ + if (ret < 0) + goto done; + /* no dangling link option given and detect dangling link */ + else if (ret == 0) + { + tinfo->symlink_visited.dangle_link = TRUE; + trav_info_visit_lnk(path, linfo, tinfo); + if (opts->no_dangle_links) + opts->err_stat = 1; /* make dgangling link is error */ + goto done; + } - /* check if already visit the target object */ - if(symlink_is_visited( &(tinfo->symlink_visited), linfo->type, NULL, lnk_info.trg_path)) - goto done; + /* check if already visit the target object */ + if(symlink_is_visited( &(tinfo->symlink_visited), linfo->type, NULL, lnk_info.trg_path)) + goto done; - /* add this link as visited link */ - if(symlink_visit_add( &(tinfo->symlink_visited), linfo->type, NULL, lnk_info.trg_path) < 0) - goto done; - - if(h5trav_visit(tinfo->fid, path, TRUE, TRUE, - trav_grp_objs,trav_grp_symlinks, tinfo) < 0) - { - parallel_print("Error: Could not get file contents\n"); - opts->err_stat = 1; - goto done; - } - break; - - case H5L_TYPE_EXTERNAL: - ret = H5tools_get_symlink_info(tinfo->fid, path, &lnk_info, opts->follow_links); - /* error */ - if (ret < 0) - goto done; - /* no dangling link option given and detect dangling link */ - else if (ret == 0) - { - tinfo->symlink_visited.dangle_link = TRUE; - trav_info_visit_lnk(path, linfo, tinfo); - if (opts->no_dangle_links) - opts->err_stat = 1; /* make dgangling link is error */ - goto done; - } + /* add this link as visited link */ + if(symlink_visit_add( &(tinfo->symlink_visited), linfo->type, NULL, lnk_info.trg_path) < 0) + goto done; + + if(h5trav_visit(tinfo->fid, path, TRUE, TRUE, + trav_grp_objs,trav_grp_symlinks, tinfo) < 0) + { + parallel_print("Error: Could not get file contents\n"); + opts->err_stat = 1; + goto done; + } + break; + + case H5L_TYPE_EXTERNAL: + ret = H5tools_get_symlink_info(tinfo->fid, path, &lnk_info, opts->follow_links); + /* error */ + if (ret < 0) + goto done; + /* no dangling link option given and detect dangling link */ + else if (ret == 0) + { + tinfo->symlink_visited.dangle_link = TRUE; + trav_info_visit_lnk(path, linfo, tinfo); + if (opts->no_dangle_links) + opts->err_stat = 1; /* make dgangling link is error */ + goto done; + } - if(H5Lunpack_elink_val(lnk_info.trg_path, linfo->u.val_size, NULL, &ext_fname, &ext_path) < 0) - goto done; + if(H5Lunpack_elink_val(lnk_info.trg_path, linfo->u.val_size, NULL, &ext_fname, &ext_path) < 0) + goto done; - /* check if already visit the target object */ - if(symlink_is_visited( &(tinfo->symlink_visited), linfo->type, ext_fname, ext_path)) - goto done; + /* check if already visit the target object */ + if(symlink_is_visited( &(tinfo->symlink_visited), linfo->type, ext_fname, ext_path)) + goto done; - /* add this link as visited link */ - if(symlink_visit_add( &(tinfo->symlink_visited), linfo->type, ext_fname, ext_path) < 0) - goto done; - - if(h5trav_visit(tinfo->fid, path, TRUE, TRUE, - trav_grp_objs,trav_grp_symlinks, tinfo) < 0) - { - parallel_print("Error: Could not get file contents\n"); + /* add this link as visited link */ + if(symlink_visit_add( &(tinfo->symlink_visited), linfo->type, ext_fname, ext_path) < 0) + goto done; + + if(h5trav_visit(tinfo->fid, path, TRUE, TRUE, + trav_grp_objs,trav_grp_symlinks, tinfo) < 0) + { + parallel_print("Error: Could not get file contents\n"); + opts->err_stat = 1; + goto done; + } + break; + + case H5L_TYPE_HARD: + case H5L_TYPE_MAX: + case H5L_TYPE_ERROR: + default: + parallel_print("Error: Invalid link type\n"); opts->err_stat = 1; goto done; - } - break; - default: - ; - break; + break; } /* end of switch */ done: @@ -572,7 +578,6 @@ hsize_t h5diff(const char *fname1, hid_t file2_id = (-1); char filenames[2][MAX_FILENAME]; hsize_t nfound = 0; - int i; int l_ret1 = -1; int l_ret2 = -1; char * obj1fullname = NULL; @@ -653,27 +658,37 @@ hsize_t h5diff(const char *fname1, /* if any object is specified */ if (objname1) { - /* malloc 2 more for "/" and end-of-line */ - obj1fullname = (char*)HDcalloc(HDstrlen(objname1) + 2, sizeof(char)); - obj2fullname = (char*)HDcalloc(HDstrlen(objname2) + 2, sizeof(char)); - /* make the given object1 fullpath, start with "/" */ if (HDstrncmp(objname1, "/", 1)) { +#ifdef H5_HAVE_ASPRINTF + /* Use the asprintf() routine, since it does what we're trying to do below */ + HDasprintf(&obj1fullname, "/%s", objname1); +#else /* H5_HAVE_ASPRINTF */ + /* (malloc 2 more for "/" and end-of-line) */ + obj1fullname = (char*)HDmalloc(HDstrlen(objname1) + 2); HDstrcpy(obj1fullname, "/"); HDstrcat(obj1fullname, objname1); +#endif /* H5_HAVE_ASPRINTF */ } else - HDstrcpy(obj1fullname, objname1); + obj1fullname = HDstrdup(objname1); /* make the given object2 fullpath, start with "/" */ if (HDstrncmp(objname2, "/", 1)) { +#ifdef H5_HAVE_ASPRINTF + /* Use the asprintf() routine, since it does what we're trying to do below */ + HDasprintf(&obj2fullname, "/%s", objname2); +#else /* H5_HAVE_ASPRINTF */ + /* (malloc 2 more for "/" and end-of-line) */ + obj2fullname = (char*)HDmalloc(HDstrlen(objname2) + 2); HDstrcpy(obj2fullname, "/"); HDstrcat(obj2fullname, objname2); +#endif /* H5_HAVE_ASPRINTF */ } else - HDstrcpy(obj2fullname, objname2); + obj2fullname = HDstrdup(objname2); /*---------------------------------------------------------- * check if obj1 is root, group, single object or symlink @@ -706,7 +721,8 @@ hsize_t h5diff(const char *fname1, */ if(src_linfo1.type == H5L_TYPE_HARD) { - int idx = 0; + size_t idx; + /* optional data pass */ info1_obj->opts = (diff_opt_t*)options; @@ -716,7 +732,7 @@ hsize_t h5diff(const char *fname1, options->err_stat = 1; goto out; } - obj1type = oinfo1.type; + obj1type = (h5trav_type_t)oinfo1.type; trav_info_add(info1_obj, obj1fullname, obj1type); idx = info1_obj->nused - 1; info1_obj->paths[idx].objno = oinfo1.addr; @@ -765,7 +781,8 @@ hsize_t h5diff(const char *fname1, */ if(src_linfo2.type == H5L_TYPE_HARD) { - int idx = 0; + size_t idx; + /* optional data pass */ info2_obj->opts = (diff_opt_t*)options; @@ -775,7 +792,7 @@ hsize_t h5diff(const char *fname1, options->err_stat = 1; goto out; } - obj2type = oinfo2.type; + obj2type = (h5trav_type_t)oinfo2.type; trav_info_add(info2_obj, obj2fullname, obj2type); idx = info2_obj->nused - 1; info2_obj->paths[idx].objno = oinfo2.addr; @@ -798,11 +815,9 @@ hsize_t h5diff(const char *fname1, { h5difftrace("h5diff no object specified\n"); /* set root group */ - obj1fullname = (char*)HDcalloc((size_t)2, sizeof(char)); - HDstrcat(obj1fullname, "/"); + obj1fullname = (char*)HDstrdup("/"); obj1type = H5TRAV_TYPE_GROUP; - obj2fullname = (char*)HDcalloc((size_t)2, sizeof(char)); - HDstrcat(obj2fullname, "/"); + obj2fullname = (char*)HDstrdup("/"); obj2type = H5TRAV_TYPE_GROUP; } @@ -856,12 +871,13 @@ hsize_t h5diff(const char *fname1, } else if(l_ret1 != 2) /* symbolic link */ { - obj1type = trg_linfo1.trg_type; + obj1type = (h5trav_type_t)trg_linfo1.trg_type; h5difftrace("h5diff ... ... trg_linfo1.trg_type == H5L_TYPE_HARD\n"); if (info1_lp != NULL) { - int idx = info1_lp->nused - 1; + size_t idx = info1_lp->nused - 1; + h5difftrace("h5diff ... ... ... info1_obj not null\n"); - info1_lp->paths[idx].type = trg_linfo1.trg_type; + info1_lp->paths[idx].type = (h5trav_type_t)trg_linfo1.trg_type; info1_lp->paths[idx].objno = trg_linfo1.objno; info1_lp->paths[idx].fileno = trg_linfo1.fileno; } @@ -904,11 +920,12 @@ hsize_t h5diff(const char *fname1, } else if(l_ret2 != 2) /* symbolic link */ { - obj2type = trg_linfo2.trg_type; + obj2type = (h5trav_type_t)trg_linfo2.trg_type; if (info2_lp != NULL) { - int idx = info2_lp->nused - 1; + size_t idx = info2_lp->nused - 1; + h5difftrace("h5diff ... ... ... info2_obj not null\n"); - info2_lp->paths[idx].type = trg_linfo2.trg_type; + info2_lp->paths[idx].type = (h5trav_type_t)trg_linfo2.trg_type; info2_lp->paths[idx].objno = trg_linfo2.objno; info2_lp->paths[idx].fileno = trg_linfo2.fileno; } @@ -972,6 +989,8 @@ hsize_t h5diff(const char *fname1, #ifdef H5_HAVE_PARALLEL if(g_Parallel) { + int i; + if((HDstrlen(fname1) > MAX_FILENAME) || (HDstrlen(fname2) > MAX_FILENAME)) { HDfprintf(stderr, "The parallel diff only supports path names up to %d characters\n", MAX_FILENAME); @@ -997,6 +1016,8 @@ hsize_t h5diff(const char *fname1, */ if(options->m_verbose) { + unsigned u; + parallel_print("\n"); /* if given objects is group under root */ if (HDstrcmp (obj1fullname,"/") || HDstrcmp (obj2fullname,"/")) @@ -1004,12 +1025,12 @@ hsize_t h5diff(const char *fname1, else parallel_print("file1 file2\n"); parallel_print("---------------------------------------\n"); - for(i = 0; i < match_list->nobjs; i++) + for(u = 0; u < match_list->nobjs; u++) { char c1, c2; - c1 = (match_list->objs[i].flags[0]) ? 'x' : ' '; - c2 = (match_list->objs[i].flags[1]) ? 'x' : ' '; - parallel_print("%5c %6c %-15s\n", c1, c2, match_list->objs[i].name); + c1 = (match_list->objs[u].flags[0]) ? 'x' : ' '; + c2 = (match_list->objs[u].flags[1]) ? 'x' : ' '; + parallel_print("%5c %6c %-15s\n", c1, c2, match_list->objs[u].name); } /* end for */ parallel_print ("\n"); } /* end if */ @@ -1092,8 +1113,8 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, hsize_t nfound = 0; unsigned i; - char * grp1_path = ""; - char * grp2_path = ""; + const char * grp1_path = ""; + const char * grp2_path = ""; char * obj1_fullpath = NULL; char * obj2_fullpath = NULL; diff_args_t argdata; @@ -1106,10 +1127,10 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, * if not root, prepare object name to be pre-appended to group path to * make full path */ - if (HDstrcmp (grp1, "/")) - grp1_path = (char *)grp1; - if (HDstrcmp (grp2, "/")) - grp2_path = (char *)grp2; + if(HDstrcmp(grp1, "/")) + grp1_path = grp1; + if(HDstrcmp(grp2, "/")) + grp2_path = grp2; /*------------------------------------------------------------------------- * regarding the return value of h5diff (0, no difference in files, 1 difference ) @@ -1163,22 +1184,32 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, if( table->objs[i].flags[0] && table->objs[i].flags[1]) { /* make full path for obj1 */ - obj1_fullpath = (char*)HDcalloc (HDstrlen(grp1_path) + strlen (table->objs[i].name) + 1, sizeof (char)); +#ifdef H5_HAVE_ASPRINTF + /* Use the asprintf() routine, since it does what we're trying to do below */ + HDasprintf(&obj1_fullpath, "%s%s", grp1_path, table->objs[i].name); +#else /* H5_HAVE_ASPRINTF */ + obj1_fullpath = (char*)HDmalloc(HDstrlen(grp1_path) + HDstrlen(table->objs[i].name) + 1); HDstrcpy(obj1_fullpath, grp1_path); HDstrcat(obj1_fullpath, table->objs[i].name); +#endif /* H5_HAVE_ASPRINTF */ /* make full path for obj2 */ - obj2_fullpath = (char*)HDcalloc (HDstrlen(grp2_path) + strlen (table->objs[i].name) + 1, sizeof (char)); +#ifdef H5_HAVE_ASPRINTF + /* Use the asprintf() routine, since it does what we're trying to do below */ + HDasprintf(&obj2_fullpath, "%s%s", grp2_path, table->objs[i].name); +#else /* H5_HAVE_ASPRINTF */ + obj2_fullpath = (char*)HDmalloc(HDstrlen(grp2_path) + HDstrlen(table->objs[i].name) + 1); HDstrcpy(obj2_fullpath, grp2_path); HDstrcat(obj2_fullpath, table->objs[i].name); +#endif /* H5_HAVE_ASPRINTF */ /* get index to figure out type of the object in file1 */ - while ( info1->paths[idx1].path && - (HDstrcmp (obj1_fullpath, info1->paths[idx1].path) != 0) ) + while(info1->paths[idx1].path && + (HDstrcmp(obj1_fullpath, info1->paths[idx1].path) != 0)) idx1++; /* get index to figure out type of the object in file2 */ - while ( info2->paths[idx2].path && - (HDstrcmp (obj2_fullpath, info2->paths[idx2].path) != 0) ) + while(info2->paths[idx2].path && + (HDstrcmp(obj2_fullpath, info2->paths[idx2].path) != 0)) idx2++; /* Set argdata to pass other args into diff() */ @@ -1363,10 +1394,10 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, } /* end if */ } /* end else */ #endif /* H5_HAVE_PARALLEL */ - if (obj1_fullpath) - HDfree (obj1_fullpath); - if (obj2_fullpath) - HDfree (obj2_fullpath); + if(obj1_fullpath) + HDfree(obj1_fullpath); + if(obj2_fullpath) + HDfree(obj2_fullpath); } /* end if */ } /* end for */ h5difftrace("done with for loop\n"); @@ -1586,12 +1617,12 @@ hsize_t diff(hid_t file1_id, if (options->follow_links) { if (linkinfo1.linfo.type == H5L_TYPE_SOFT || - linkinfo1.linfo.type == H5L_TYPE_EXTERNAL) - argdata->type[0] = linkinfo1.trg_type; + linkinfo1.linfo.type == H5L_TYPE_EXTERNAL) + argdata->type[0] = (h5trav_type_t)linkinfo1.trg_type; if (linkinfo2.linfo.type == H5L_TYPE_SOFT || - linkinfo2.linfo.type == H5L_TYPE_EXTERNAL) - argdata->type[1] = linkinfo2.trg_type; + linkinfo2.linfo.type == H5L_TYPE_EXTERNAL) + argdata->type[1] = (h5trav_type_t)linkinfo2.trg_type; } } /* if objects are not the same type */ @@ -1633,29 +1664,30 @@ hsize_t diff(hid_t file1_id, { switch(object_type) { - case H5TRAV_TYPE_DATASET: - do_print_objname("dataset", path1, path2, options); - break; - case H5TRAV_TYPE_NAMED_DATATYPE: - do_print_objname("datatype", path1, path2, options); - break; - case H5TRAV_TYPE_GROUP: - do_print_objname("group", path1, path2, options); - break; - case H5TRAV_TYPE_LINK: - do_print_objname("link", path1, path2, options); - break; - case H5TRAV_TYPE_UDLINK: - if(linkinfo1.linfo.type == H5L_TYPE_EXTERNAL && linkinfo2.linfo.type == H5L_TYPE_EXTERNAL) - do_print_objname("external link", path1, path2, options); - else - do_print_objname ("user defined link", path1, path2, options); - break; - default: - parallel_print("Comparison not supported: <%s> and <%s> are of type %s\n", - path1, path2, get_type(object_type) ); - options->not_cmp = 1; - break; + case H5TRAV_TYPE_DATASET: + do_print_objname("dataset", path1, path2, options); + break; + case H5TRAV_TYPE_NAMED_DATATYPE: + do_print_objname("datatype", path1, path2, options); + break; + case H5TRAV_TYPE_GROUP: + do_print_objname("group", path1, path2, options); + break; + case H5TRAV_TYPE_LINK: + do_print_objname("link", path1, path2, options); + break; + case H5TRAV_TYPE_UDLINK: + if(linkinfo1.linfo.type == H5L_TYPE_EXTERNAL && linkinfo2.linfo.type == H5L_TYPE_EXTERNAL) + do_print_objname("external link", path1, path2, options); + else + do_print_objname ("user defined link", path1, path2, options); + break; + case H5TRAV_TYPE_UNKNOWN: + default: + parallel_print("Comparison not supported: <%s> and <%s> are of type %s\n", + path1, path2, get_type(object_type) ); + options->not_cmp = 1; + break; } /* switch(type)*/ print_found(nfound); @@ -1862,6 +1894,7 @@ hsize_t diff(hid_t file1_id, } break; + case H5TRAV_TYPE_UNKNOWN: default: if(options->m_verbose) parallel_print("Comparison not supported: <%s> and <%s> are of type %s\n", diff --git a/tools/lib/h5diff_attr.c b/tools/lib/h5diff_attr.c index 44b623f..6474082 100644 --- a/tools/lib/h5diff_attr.c +++ b/tools/lib/h5diff_attr.c @@ -326,12 +326,16 @@ hsize_t diff_attr(hid_t loc1_id, hid_t space2_id=-1; /* space ID */ hid_t ftype1_id=-1; /* file data type ID */ hid_t ftype2_id=-1; /* file data type ID */ + int vstrtype1=0; /* ftype1 is a variable string */ + int vstrtype2=0; /* ftype2 is a variable string */ hid_t mtype1_id=-1; /* memory data type ID */ hid_t mtype2_id=-1; /* memory data type ID */ size_t msize1; /* memory size of memory type */ size_t msize2; /* memory size of memory type */ void *buf1=NULL; /* data buffer */ void *buf2=NULL; /* data buffer */ + int buf1hasdata=0; /* buffer has data */ + int buf2hasdata=0; /* buffer has data */ hsize_t nelmts1; /* number of elements in dataset */ int rank1; /* rank of dataset */ int rank2; /* rank of dataset */ @@ -376,8 +380,19 @@ hsize_t diff_attr(hid_t loc1_id, /* get the datatypes */ if((ftype1_id = H5Aget_type(attr1_id)) < 0) goto error; + vstrtype1 = H5Tis_variable_str(ftype1_id); if((ftype2_id = H5Aget_type(attr2_id)) < 0) goto error; + vstrtype2 = H5Tis_variable_str(ftype2_id); + /* no compare if either one but not both are variable string type */ + if (vstrtype1 != vstrtype2){ + if ((options->m_verbose||options->m_list_not_cmp)) + parallel_print("Not comparable: one of attribute <%s/%s> or <%s/%s> is of variable length type\n", + path1, name1, path2, name2); + options->not_cmp = 1; + return 0; + } + if((mtype1_id = h5tools_get_native_type(ftype1_id))<0) goto error; if((mtype2_id = h5tools_get_native_type(ftype2_id))<0) @@ -449,14 +464,20 @@ hsize_t diff_attr(hid_t loc1_id, buf1 = (void *)HDmalloc((size_t)(nelmts1 * msize1)); buf2 = (void *)HDmalloc((size_t)(nelmts1 * msize2)); - if(buf1 == NULL || buf2 == NULL) { + if(buf1 == NULL || buf2 == NULL){ parallel_print( "cannot read into memory\n" ); goto error; } - if(H5Aread(attr1_id,mtype1_id,buf1) < 0) - goto error; - if(H5Aread(attr2_id,mtype2_id,buf2) < 0) - goto error; + if(H5Aread(attr1_id,mtype1_id,buf1) < 0){ + parallel_print("Failed reading attribute1 %s/%s\n", path1, name1); + goto error; + }else + buf1hasdata = 1; + if(H5Aread(attr2_id,mtype2_id,buf2) < 0){ + parallel_print("Failed reading attribute2 %s/%s\n", path2, name2); + goto error; + }else + buf2hasdata = 1; /* format output string */ HDsnprintf(np1, sizeof(np1), "%s of <%s>", name1, path1); @@ -504,8 +525,8 @@ hsize_t diff_attr(hid_t loc1_id, if(TRUE == h5tools_detect_vlen(mtype1_id)) H5Dvlen_reclaim(mtype1_id, space1_id, H5P_DEFAULT, buf1); HDfree(buf1); - buf1 = NULL; + if(TRUE == h5tools_detect_vlen(mtype2_id)) H5Dvlen_reclaim(mtype2_id, space2_id, H5P_DEFAULT, buf2); HDfree(buf2); @@ -539,12 +560,12 @@ hsize_t diff_attr(hid_t loc1_id, error: H5E_BEGIN_TRY { if(buf1) { - if(TRUE == h5tools_detect_vlen(mtype1_id)) + if(buf1hasdata && TRUE == h5tools_detect_vlen(mtype1_id)) H5Dvlen_reclaim(mtype1_id, space1_id, H5P_DEFAULT, buf1); HDfree(buf1); } /* end if */ if(buf2) { - if(TRUE == h5tools_detect_vlen(mtype2_id)) + if(buf2hasdata && TRUE == h5tools_detect_vlen(mtype2_id)) H5Dvlen_reclaim(mtype2_id, space2_id, H5P_DEFAULT, buf2); HDfree(buf2); } /* end if */ diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c index f6e6329..d7c5639 100644 --- a/tools/lib/h5diff_dset.c +++ b/tools/lib/h5diff_dset.c @@ -441,13 +441,13 @@ hsize_t diff_datasetid( hid_t did1, HDassert(sm_nbytes > 0); } /* end for */ - /* malloc return code should be verified. + /* malloc return code should be verified. * If fail, need to handle the error. * This else branch should be recoded as a separate function. * Note that there are many "goto error" within this branch * that fails to address freeing other objects created here. - * E.g., sm_space. - */ + * E.g., sm_space. + */ sm_buf1 = HDmalloc((size_t)sm_nbytes); HDassert(sm_buf1); sm_buf2 = HDmalloc((size_t)sm_nbytes); diff --git a/tools/misc/CMakeLists.txt b/tools/misc/CMakeLists.txt index ed8c315..8af05b4 100644 --- a/tools/misc/CMakeLists.txt +++ b/tools/misc/CMakeLists.txt @@ -69,9 +69,9 @@ endif (BUILD_TESTING) ############################################################################## ############################################################################## -#-----------------------------------------------------------------------------
-# Rules for Installation of tools using make Install target
-#-----------------------------------------------------------------------------
+#----------------------------------------------------------------------------- +# Rules for Installation of tools using make Install target +#----------------------------------------------------------------------------- #INSTALL_PROGRAM_PDB (h5debug ${HDF5_INSTALL_BIN_DIR} toolsapplications) #INSTALL_PROGRAM_PDB (h5repart ${HDF5_INSTALL_BIN_DIR} toolsapplications) diff --git a/tools/misc/CMakeTests.cmake b/tools/misc/CMakeTests.cmake index 468ff3a..d28b744 100644 --- a/tools/misc/CMakeTests.cmake +++ b/tools/misc/CMakeTests.cmake @@ -119,7 +119,7 @@ -D "TEST_EXPECT=${resultcode}" -D "TEST_MASK_MOD=true" -D "TEST_REFERENCE=${resultfile}.ls" - -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5MKGRP-${resultfile}-h5ls PROPERTIES DEPENDS H5MKGRP-${resultfile}) endif (HDF5_ENABLE_USING_MEMCHECKER) @@ -147,7 +147,7 @@ -D "TEST_OUTPUT=${resultfile}.out" -D "TEST_EXPECT=${resultcode}" -D "TEST_REFERENCE=${resultfile}.txt" - -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5MKGRP_CMP-${resultfile} PROPERTIES DEPENDS H5MKGRP_CMP-${resultfile}-clear-objects) endif (HDF5_ENABLE_USING_MEMCHECKER) @@ -190,7 +190,7 @@ # test the output files repartitioned above. add_test (NAME H5REPART-h5repart_test COMMAND $<TARGET_FILE:h5repart_test>) - set_tests_properties (H5REPART-h5repart_test PROPERTIES DEPENDS H5REPART-clearall-objects DEPENDS H5REPART-h5repart_20K DEPENDS H5REPART-h5repart_5K DEPENDS H5REPART-h5repart_sec2) + set_tests_properties (H5REPART-h5repart_test PROPERTIES DEPENDS "H5REPART-clearall-objects;H5REPART-h5repart_20K;H5REPART-h5repart_5K;H5REPART-h5repart_sec2") set (H5_DEP_EXECUTABLES ${H5_DEP_EXECUTABLES} h5repart_test diff --git a/tools/misc/Makefile.in b/tools/misc/Makefile.in index 463f4e7..0eaff60 100644 --- a/tools/misc/Makefile.in +++ b/tools/misc/Makefile.in @@ -539,7 +539,6 @@ LIPO = @LIPO@ LL_PATH = @LL_PATH@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ -LT_ADD_LIBHDF5_DEPENDENCY = @LT_ADD_LIBHDF5_DEPENDENCY@ LT_STATIC_EXEC = @LT_STATIC_EXEC@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ diff --git a/tools/misc/h5perf_gentest.c b/tools/misc/h5perf_gentest.c index 6a080d0..6729ed4 100644 --- a/tools/misc/h5perf_gentest.c +++ b/tools/misc/h5perf_gentest.c @@ -1,598 +1,598 @@ -/*****************************************************************************
- This test generates attributes, groups, and datasets of many types. It
- creates a large number of attributes, groups, and datasets by specifying
- -a, -g, -d options respectively. Using "-h" option to see details.
-
- Programmer: Peter Cao <xcao@hdfgroup.org>, Jan. 2013
- ****************************************************************************/
-
-#include "hdf5.h"
-#include <stdio.h>
-#include <stdlib.h>
-
-#define FNAME "test_perf.h5"
-#define NGROUPS 20
-#define NDSETS 20
-#define NATTRS 20
-#define DIM0 40
-#define NROWS 100
-#define NTYPES 9
-#define MAXVLEN 10
-#define FIXED_LEN 8
-
-typedef enum { SOLID=0, LIQUID, GAS, PLASMA } phase_t;
-
-typedef struct {
- int i;
- unsigned long long l;
- float f;
- double d;
- char s[FIXED_LEN];
- phase_t e;
- float f_array[FIXED_LEN];
- hvl_t i_vlen;
- char *s_vlen;
-} test_comp_t;
-
-typedef struct {
- int zipcode;
- char *city;
-} zipcode_t;
-
-int add_attrs(hid_t oid, int idx);
-int add_attr(hid_t oid, const char *name, hid_t tid, hid_t sid, void *buf) ;
-herr_t create_perf_test_file(const char *fname, int ngrps, int ndsets,
- int nattrs, hsize_t nrows, hsize_t dim0, hsize_t chunk, int vlen,
- int compressed, int latest);
-
-int main (int argc, char *argv[])
-{
- char fname[32];
- int i, ngrps=NGROUPS, ndsets=NDSETS, nattrs=NATTRS, dim0=DIM0,
- chunk=DIM0/10+1, nrows=NROWS, vlen=MAXVLEN, l=0, z=0;
-
- memset(fname, 0, 32);
- for (i=1; i<argc; i++) {
- if (strcmp(argv[i], "-f")==0)
- strcpy(fname, argv[i+1]);
- else if (strcmp(argv[i], "-g")==0)
- ngrps = atoi(argv[i+1]);
- else if (strcmp(argv[i], "-d")==0)
- ndsets = atoi(argv[i+1]);
- else if (strcmp(argv[i], "-a")==0)
- nattrs = atoi(argv[i+1]);
- else if (strcmp(argv[i], "-r")==0)
- nrows = atoi(argv[i+1]);
- else if (strcmp(argv[i], "-s")==0)
- dim0 = atoi(argv[i+1]);
- else if (strcmp(argv[i], "-c")==0)
- chunk = atoi(argv[i+1]);
- else if (strcmp(argv[i], "-v")==0)
- vlen = atoi(argv[i+1]);
- else if (strcmp(argv[i], "-l")==0)
- l = 1;
- else if (strcmp(argv[i], "-z")==0)
- z = 1;
- else if (strcmp(argv[i], "-h")==0) {
- printf("\nOPTONS:\n");
- printf("\t-f F:\tname of the test file (default: %s).\n", FNAME);
- printf("\t-g N:\tnumber of top level groups (default: %d).\n", NGROUPS);
- printf("\t-d N:\tnumber of datasets (default: %d).\n", NDSETS);
- printf("\t-a N:\tnumber of attributes (default: %d).\n", NATTRS);
- printf("\t-r N:\tnumber of rows in the large compound dataset (default: %d).\n", NROWS);
- printf("\t-s N:\tsize of dim0 in datasets (default: %d).\n", DIM0);
- printf("\t-c N:\tchunk size of dim0 (default: %d).\n", (DIM0/10+1));
- printf("\t-v N:\tmax vlen size (default: %d).\n", MAXVLEN);
- printf("\t-l:\tuse latest format (default: no).\n");
- printf("\t-z:\tuse gzip compression (default: no).\n");
- printf("\t-h:\tthis help information.\n");
- printf("Example:\n");
- printf("\t./a.out -f test.h5 -g 10000 -d 5000 -a 500 -r 10000 -s 200 -c 20 -v 40 -l -z\n\n");
- exit(0);
- }
- }
-
- if (strlen(fname)<=0)
- sprintf(fname, FNAME);
-
- create_perf_test_file(fname, ngrps, ndsets, nattrs, (hsize_t)nrows,
- (hsize_t)dim0, (hsize_t)chunk, vlen, z, l);
-
- return 0;
-}
-
-/*****************************************************************************
- This function generates attributes, groups, and datasets of many types.
-
- Parameters:
- fname: file_name.
- ngrps: number of top level groups.
- ndsets: number of datasets.
- attrs: number of attributes.
- nrow: number of rows in a dataset.
- chunk: chunk size (single number).
- vlen: max vlen size.
- comp: use latest format.
- latest: use gzip comnpression.
-
- Return: Non-negative on success/Negative on failure
-
- Programmer: Peter Cao <xcao@hdfgroup.org>, Jan. 2013
- ****************************************************************************/
-herr_t create_perf_test_file(const char *fname, int ngrps, int ndsets,
- int nattrs, hsize_t nrows, hsize_t dim0, hsize_t chunk, int vlen,
- int compressed, int latest)
-{
- int i, j, k;
- hid_t fid, sid_null, sid_scalar, sid_1d, sid_2d, did, aid, sid_2, sid_large,
- fapl=H5P_DEFAULT, dcpl=H5P_DEFAULT, gid1, gid2, cmp_tid, tid_str,
- tid_enum, tid_array_f, tid_vlen_i, tid_vlen_s;
- char name[32], tmp_name1[32], tmp_name2[32], tmp_name3[32];
- hsize_t dims[1]={dim0}, dims2d[2]={dim0, (dim0/4+1)}, dims_array[1]={FIXED_LEN},
- dim1[1]={2};
- char *enum_names[4] = {"SOLID", "LIQUID", "GAS", "PLASMA"};
- test_comp_t *buf_comp=NULL, *buf_comp_large=NULL;
- int *buf_int=NULL;
- float (*buf_float_a)[FIXED_LEN]=NULL;
- double **buf_double2d=NULL;
- hvl_t *buf_vlen_i=NULL;
- char (*buf_str)[FIXED_LEN];
- char **buf_vlen_s=NULL;
- hobj_ref_t buf_ref[2];
- hdset_reg_ref_t buf_reg_ref[2];
- size_t offset, len;
- herr_t status;
- char *names[NTYPES] = { "int", "ulong", "float", "double", "fixed string",
- "enum", "fixed float array", "vlen int array", "vlen strings"};
- hid_t types[NTYPES] = { H5T_NATIVE_INT, H5T_NATIVE_UINT64, H5T_NATIVE_FLOAT,
- H5T_NATIVE_DOUBLE, tid_str, tid_enum, tid_array_f, tid_vlen_i, tid_vlen_s};
- hsize_t coords[4][2] = { {0, 1}, {3, 5}, {1, 0}, {2, 4}}, start=0, stride=1, count=1;
-
- if (nrows < NROWS) nrows = NROWS;
- if (ngrps<NGROUPS) ngrps=NGROUPS;
- if (ndsets<NDSETS) ndsets=NDSETS;
- if (nattrs<NATTRS) nattrs=NATTRS;
- if (dim0<DIM0) dim0=DIM0;
- if (chunk>dim0) chunk=dim0/4;
- if (chunk<1) chunk = 1;
- if (vlen<1) vlen = MAXVLEN;
-
- /* create fixed string datatype */
- types[4] = tid_str = H5Tcopy (H5T_C_S1);
- H5Tset_size (tid_str, FIXED_LEN);
-
- /* create enum datatype */
- types[5] = tid_enum = H5Tenum_create(H5T_NATIVE_INT);
- for (i = (int) SOLID; i <= (int) PLASMA; i++) {
- phase_t val = (phase_t) i;
- status = H5Tenum_insert (tid_enum, enum_names[i], &val);
- }
-
- /* create float array datatype */
- types[6] = tid_array_f = H5Tarray_create (H5T_NATIVE_FLOAT, 1, dims_array);
-
- /* create variable length integer datatypes */
- types[7] = tid_vlen_i = H5Tvlen_create (H5T_NATIVE_INT);
-
- /* create variable length string datatype */
- types[8] = tid_vlen_s = H5Tcopy (H5T_C_S1);
- H5Tset_size (tid_vlen_s, H5T_VARIABLE);
-
- /* create compound datatypes */
- cmp_tid = H5Tcreate (H5T_COMPOUND, sizeof (test_comp_t));
- offset = 0;
- for (i=0; i<NTYPES-2; i++) {
- H5Tinsert(cmp_tid, names[i], offset, types[i]);
- offset += H5Tget_size(types[i]);
- }
-
- H5Tinsert(cmp_tid, names[7], offset, types[7]);
- offset += sizeof (hvl_t);
- H5Tinsert(cmp_tid, names[8], offset, types[8]);
-
- /* create dataspace */
- sid_1d = H5Screate_simple (1, dims, NULL);
- sid_2d = H5Screate_simple (2, dims2d, NULL);
- sid_2 = H5Screate_simple (1, dim1, NULL);
- sid_large = H5Screate_simple (1, &nrows, NULL);
- sid_null = H5Screate (H5S_NULL);
- sid_scalar = H5Screate (H5S_SCALAR);
-
- /* create fid access property */
- fapl = H5Pcreate (H5P_FILE_ACCESS);
- H5Pset_libver_bounds (fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST);
-
- /* create dataset creation property */
- dcpl = H5Pcreate (H5P_DATASET_CREATE);
-
- /* set dataset chunk */
- if (chunk>0) {
- H5Pset_chunk (dcpl, 1, &chunk);
- }
-
- /* set dataset compression */
- if (compressed) {
- if (chunk<=0) {
- chunk = dim0/10+1;;
- H5Pset_chunk (dcpl, 1, &chunk);
- }
- H5Pset_shuffle (dcpl);
- H5Pset_deflate (dcpl, 6);
- }
-
- /* allocate buffers */
- buf_comp = (test_comp_t *)calloc(dim0, sizeof(test_comp_t));
- buf_comp_large = (test_comp_t *)calloc(nrows, sizeof(test_comp_t));
- buf_int = (int *)calloc(dim0, sizeof(int));
- buf_float_a = malloc(dim0*sizeof(*buf_float_a));
- buf_vlen_i = (hvl_t *)calloc(dim0, sizeof (hvl_t));
- buf_vlen_s = (char **)calloc(dim0, sizeof(char *));
- buf_str = malloc(dim0*sizeof (*buf_str));
-
- /* allocate array of doulbe pointers */
- buf_double2d = (double **)calloc(dims2d[0],sizeof(double *));
- /* allocate a contigous chunk of memory for the data */
- buf_double2d[0] = (double *)calloc( dims2d[0]*dims2d[1],sizeof(double) );
- /* assign memory city to pointer array */
- for (i=1; i <dims2d[0]; i++) buf_double2d[i] = buf_double2d[0]+i*dims2d[1];
-
- /* fill buffer values */
- len = 1;
- for (i=0; i<dims[0]; i++) {
- buf_comp[i].i = buf_int[i] = i-2147483648;
- buf_comp[i].l = 0xffffffffffffffff-i;
- buf_comp[i].f = 1.0/(i+1.0);
- buf_comp[i].d = 987654321.0*i+1.0/(i+1.0);
- buf_comp[i].e = (phase_t) (i % (int) (PLASMA + 1));
-
- for (j=0; j<FIXED_LEN; j++) {
- buf_comp[i].f_array[j] = buf_float_a[i][j] = i*100+j;
- buf_str[i][j] = 'a' + (i%26);
- }
- buf_str[i][FIXED_LEN-1] = 0;
- strcpy(buf_comp[i].s, buf_str[i]);
-
- len = (1-cos(i/8.0))/2*vlen+1;
- if (!i) len = vlen;
- buf_vlen_i[i].len = len;
- buf_vlen_i[i].p = (int *)calloc(len, sizeof(int));
- for (j=0; j<len; j++) ((int*)(buf_vlen_i[i].p))[j] = i*100+j;
- buf_comp[i].i_vlen = buf_vlen_i[i];
-
- buf_vlen_s[i] = (char *)calloc(len, sizeof(char));
- for (j=0; j<len-1; j++)
- buf_vlen_s[i][j] = j%26+'A';
- buf_comp[i].s_vlen = buf_vlen_s[i];
-
- for (j=0; j<dims2d[1]; j++)
- buf_double2d[i][j] = i+j/10000.0;
- }
-
- for (i=0; i<nrows; i++) {
- buf_comp_large[i].i = i-2147483648;
- buf_comp_large[i].l = 0xffffffffffffffff-i;
- buf_comp_large[i].f = 1.0/(i+1.0);
- buf_comp_large[i].d = 987654321.0*i+1.0/(i+1.0);
- buf_comp_large[i].e = (phase_t) (i % (int) (PLASMA + 1));
- for (j=0; j<FIXED_LEN-1; j++) {
- buf_comp_large[i].f_array[j] = i*100+j;
- buf_comp_large[i].s[j] = 'a' + (i%26);
- }
- len = i%vlen+1;
- buf_comp_large[i].i_vlen.len = len;
- buf_comp_large[i].i_vlen.p = (int *)calloc(len, sizeof(int));
- for (j=0; j<len; j++) ((int*)(buf_comp_large[i].i_vlen.p))[j] = i*100+j;
- buf_comp_large[i].s_vlen = (char *)calloc(i+2, sizeof(char));
- for (j=0; j<i+1; j++) (buf_comp_large[i].s_vlen)[j] = j%26+'A';
- }
-
- /* create file */
- if (latest)
- fid = H5Fcreate (fname, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
- else
- fid = H5Fcreate (fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- add_attrs(fid, 0);
-
- sprintf(name, "a cmp ds of %d rows", nrows);
- did = H5Dcreate (fid, name, cmp_tid, sid_large, H5P_DEFAULT, dcpl, H5P_DEFAULT);
- H5Dwrite (did, cmp_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_comp_large);
- add_attrs(did, 0);
- H5Dclose(did);
-
- // /* add attributes*/
- gid1 = H5Gcreate (fid, "attributes", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- if (nattrs<1) nattrs = 1;
- i=0;
- while (i<nattrs) i += add_attrs(gid1, i);
- H5Gclose(gid1);
-
- /* add many sub groups to a group*/
- gid1 = H5Gcreate (fid, "groups", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- add_attrs(gid1, 0);
- for (i=0; i<ngrps; i++) {
- /* create sub groups */
- sprintf(name, "g%02d", i);
- gid2 = H5Gcreate (gid1, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- if (i<10) add_attrs(gid2, 0);
- H5Gclose(gid2);
- }
- H5Gclose(gid1);
-
- /* add many datasets to a group */
- gid1 = H5Gcreate (fid, "datasets", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- add_attrs(gid1, 0);
- for (j=0; j<ndsets; j+=12) {
- /* 1 add a null dataset */
- sprintf(name, "%05d null dataset", j);
- did = H5Dcreate (gid1, name, H5T_STD_I32LE, sid_null, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- if (!j) add_attrs(did, j);
- H5Dclose(did);
-
- /* 2 add scalar int point */
- sprintf(name, "%05d scalar int point", j);
- did = H5Dcreate (gid1, name, H5T_NATIVE_INT, sid_scalar, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- H5Dwrite (did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &j);
- if (!j) add_attrs(did, j);
- H5Dclose(did);
-
- /* 3 scalar vlen string */
- sprintf(name, "%05d scalar vlen string", j);
- did = H5Dcreate (gid1, name, tid_vlen_s, sid_scalar, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- H5Dwrite (did, tid_vlen_s, H5S_ALL, H5S_ALL, H5P_DEFAULT, &buf_vlen_s[0]);
- if (!j) add_attrs(did, j);
- H5Dclose(did);
-
- /* 4 add fixed-length float array */
- sprintf(name, "%05d fixed-length float array", j);
- did = H5Dcreate (gid1, name, tid_array_f, sid_1d, H5P_DEFAULT, dcpl, H5P_DEFAULT);
- H5Dwrite (did, tid_array_f, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_float_a);
- if (!j) add_attrs(did, j);
- H5Dclose(did);
-
- /* 5 add fixed-length strings */
- sprintf(name, "%05d fixed-length strings", j);
- did = H5Dcreate (gid1, name, tid_str, sid_1d, H5P_DEFAULT, dcpl, H5P_DEFAULT);
- H5Dwrite (did, tid_str, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_str);
- if (!j) add_attrs(did, j);
- H5Dclose(did);
-
- /* 6 add compound data */
- sprintf(name, "%05d compund data", j);
- did = H5Dcreate (gid1, name, cmp_tid, sid_1d, H5P_DEFAULT, dcpl, H5P_DEFAULT);
- H5Dwrite (did, cmp_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_comp);
- if (!j) add_attrs(did, j);
- H5Dclose(did);
-
- /* 7 add 2D double */
- sprintf(name, "%05d 2D double", j);
- strcpy (tmp_name1, name);
- did = H5Dcreate (gid1, name, H5T_NATIVE_DOUBLE, sid_2d, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- H5Dwrite (did, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_double2d[0]);
- if (!j) add_attrs(did, j);
- H5Dclose(did);
-
- /* 8 add 1D int array */
- sprintf(name, "%05d 1D int array", j);
- did = H5Dcreate (gid1, name, H5T_NATIVE_INT, sid_1d, H5P_DEFAULT, dcpl, H5P_DEFAULT);
- H5Dwrite (did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_int);
- if (!j) add_attrs(did, j);
- H5Dclose(did);
-
- /* 9 add vlen int array */
- sprintf(name, "%05d vlen int array", j);
- strcpy (tmp_name2, name);
- did = H5Dcreate (gid1, name, tid_vlen_i, sid_1d, H5P_DEFAULT, dcpl, H5P_DEFAULT);
- H5Dwrite (did, tid_vlen_i, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_vlen_i);
- if (!j) add_attrs(did, j);
- H5Dclose(did);
-
- /* 10 add vlen strings */
- sprintf(name, "%05d vlen strings", j);
- strcpy (tmp_name3, name);
- did = H5Dcreate (gid1, name, tid_vlen_s, sid_1d, H5P_DEFAULT, dcpl, H5P_DEFAULT);
- H5Dwrite (did, tid_vlen_s, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_vlen_s);
- if (!j) add_attrs(did, j);
- H5Dclose(did);
-
- /* 11 add object refs */
- H5Rcreate(&buf_ref[0],gid1, ".", H5R_OBJECT, -1);
- H5Rcreate(&buf_ref[1],gid1, tmp_name3, H5R_OBJECT, -1);
- sprintf(name, "%05d obj refs", j);
- did = H5Dcreate (gid1, name, H5T_STD_REF_OBJ, sid_2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- H5Dwrite (did, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_ref);
- if (!j) add_attrs(did, j);
- H5Dclose(did);
-
- /* 12 add region refs */
- H5Sselect_elements (sid_2d, H5S_SELECT_SET, 4, coords[0]);
- H5Rcreate(&buf_reg_ref[0],gid1, tmp_name1, H5R_DATASET_REGION, sid_2d);
- H5Sselect_none(sid_2d);
- count = dims[0]/2+1;
- H5Sselect_hyperslab (sid_1d, H5S_SELECT_SET, &start, &stride, &count,NULL);
- H5Rcreate(&buf_reg_ref[1],gid1, tmp_name2, H5R_DATASET_REGION, sid_1d);
- H5Sselect_none(sid_1d);
- sprintf(name, "%05d region refs", j);
- did = H5Dcreate (gid1, name, H5T_STD_REF_DSETREG, sid_2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- H5Dwrite (did, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_reg_ref);
- if (!j) add_attrs(did, j);
- H5Dclose(did);
- }
- H5Gclose(gid1);
-
- H5Tclose (tid_array_f);
- H5Tclose (tid_vlen_i);
- H5Tclose (tid_vlen_s);
- H5Tclose (tid_enum);
- H5Tclose (tid_str);
- H5Tclose (cmp_tid);
- H5Pclose (dcpl);
- H5Pclose (fapl);
- H5Sclose (sid_1d);
- H5Sclose (sid_2d);
- H5Sclose (sid_2);
- H5Sclose (sid_large);
- H5Sclose (sid_null);
- H5Sclose (sid_scalar);
- H5Fclose (fid);
-
- for (i=0; i<dims[0]; i++) {
- if (buf_vlen_i[i].p) free(buf_vlen_i[i].p);
- if (buf_vlen_s[i]) free(buf_vlen_s[i]);
- }
-
- for (i=0; i<nrows; i++) {
- if (buf_comp_large[i].i_vlen.p) free(buf_comp_large[i].i_vlen.p);
- if (buf_comp_large[i].s_vlen) free(buf_comp_large[i].s_vlen);
- }
-
- free (buf_comp);
- free (buf_comp_large);
- free (buf_int);
- free (buf_float_a);
- free (buf_double2d[0]);
- free (buf_double2d);
- free (buf_str);
- free(buf_vlen_i);
- free(buf_vlen_s);
-
- return 0;
-}
-
-/* add a single attribute */
-int add_attr(hid_t oid, const char *name, hid_t tid, hid_t sid, void *buf)
-{
- hid_t aid;
-
- aid = H5Acreate (oid, name, tid, sid, H5P_DEFAULT, H5P_DEFAULT);
- if (aid <0)
- return 0;
-
- H5Awrite(aid, tid, buf);
-
- H5Aclose(aid);
-
- return 1;
-}
-
-/*
- adds different types of attributes to an object.
-
- returns the number of attributes added to the objects.
- */
-int add_attrs(hid_t oid, int idx)
-{
- char name[32];
- int i0, i1, i2, j, nattrs=0;
- hid_t aid, tid, tid1, sid;
- hvl_t i_vlen[4];
- hobj_ref_t ref;
- zipcode_t cmp_data[4];
- unsigned int i = 0xffffffff;
- long long l = -2147483647;
- float f = 123456789.987654321;
- double d = 987654321.123456789;
- char *s[7] = {"Parting", "is such", "sweeter", "sorrow."};
- float f_array[4] = {1.0, 2.22, 3.333, 4.444};
- char *s_vlen[4] = {"Parting", "is such", "sweet", "sorrow."};
- hsize_t dims1[1]={1}, dims2[1]={4}, dims3[2]={3,5};
- int int3d[4][3][5];
- size_t offset = 0;
-
- for (i0=0; i0<4; i0++) {
- i_vlen[i0].len = (i0+1);
- i_vlen[i0].p = (int *)calloc(i_vlen[i0].len, sizeof(int));
- for (j=0; j<i_vlen[i0].len; j++)
- ((int *)i_vlen[i0].p)[j] = i0*100+j;
- for (i1=0; i1<3; i1++) {
- for (i2=0; i2<5; i2++)
- int3d[i0][i1][i2] = i0*i1-i1*i2+i0*i2;
- }
- }
-
- cmp_data[0].zipcode = 01001;
- cmp_data[0].city = "Agawam, Massachusetts";
- cmp_data[1].zipcode = 99950;
- cmp_data[1].city = "Ketchikan, Alaska";
- cmp_data[2].zipcode = 00501;
- cmp_data[2].city = "Holtsville, New York";
- cmp_data[3].zipcode = 61820;
- cmp_data[3].city = "Champaign, Illinois";
-
- /* 1 scalar point */
- sid = H5Screate (H5S_SCALAR);
- sprintf(name, "%05d scalar int", idx);
- nattrs += add_attr(oid, name, H5T_NATIVE_UINT, sid, &i);
- sprintf(name, "%05d scalar ulong", idx);
- nattrs += add_attr(oid, name, H5T_NATIVE_INT64, sid, &l);
- sprintf(name, "%05d scalar str", idx);
- tid = H5Tcopy (H5T_C_S1);
- H5Tset_size (tid, H5T_VARIABLE);
- nattrs += add_attr(oid, name, tid, sid, &s[2]);
- H5Tclose(tid);
- H5Sclose(sid);
-
- /* 4 single point */
- sid = H5Screate_simple (1, dims1, NULL);
- H5Rcreate(&ref, oid, ".", H5R_OBJECT, -1);
- sprintf(name, "%05d single float", idx);
- nattrs += add_attr(oid, name, H5T_NATIVE_FLOAT, sid, &f);
- sprintf(name, "%05d single double", idx);
- nattrs += add_attr(oid, name, H5T_NATIVE_DOUBLE, sid, &d);
- sprintf(name, "%05d single obj_ref", idx);
- nattrs += add_attr(oid, name, H5T_STD_REF_OBJ, sid, &ref);
- H5Sclose(sid);
-
- /* 7 fixed length 1D array */
- sid = H5Screate_simple (1, dims1, NULL);
- tid = H5Tarray_create (H5T_NATIVE_FLOAT, 1, dims2);
- sprintf(name, "%05d array float", idx);
- nattrs += add_attr(oid, name, tid, sid, &f_array[0]);
- H5Tclose(tid);
- tid = H5Tcopy (H5T_C_S1);
- H5Tset_size (tid, strlen(s[0])+1);
- tid1 = H5Tarray_create (tid, 1, dims2);
- sprintf(name, "%05d array str", idx);
- nattrs += add_attr(oid, name, tid1, sid, s);
- H5Tclose(tid1);
- H5Tclose(tid);
- H5Sclose(sid);
-
- /* 9 fixed length 2D int arrays */
- sid = H5Screate_simple (1, dims2, NULL);
- tid = H5Tarray_create (H5T_NATIVE_INT, 2, dims3);
- sprintf(name, "%05d array int 2D", idx);
- nattrs += add_attr(oid, name, tid, sid, int3d[0][0]);
- H5Tclose(tid);
- H5Sclose(sid);
-
- /* 10 variable length arrays */
- sid = H5Screate_simple (1, dims2, NULL);
- tid = H5Tcopy (H5T_C_S1);
- H5Tset_size (tid, H5T_VARIABLE);
- sprintf(name, "%05d vlen strings", idx);
- nattrs += add_attr(oid, name, tid, sid, s_vlen);
- H5Tclose(tid);
- tid = H5Tvlen_create (H5T_NATIVE_INT);;
- sprintf(name, "%05d vlen int array", idx);
- nattrs += add_attr(oid, name, tid, sid, i_vlen);
- H5Tclose(tid);
- H5Sclose(sid);
-
- /* 12 compound data */
- sid = H5Screate_simple (1, dims2, NULL);
- tid = H5Tcreate (H5T_COMPOUND, sizeof (zipcode_t));
- tid1 = H5Tcopy (H5T_C_S1);
- H5Tset_size (tid1, H5T_VARIABLE);
- H5Tinsert (tid, "zip code", 0, H5T_NATIVE_INT); offset += sizeof(H5T_NATIVE_INT);
- H5Tinsert (tid, "City", offset, tid1); offset += sizeof(char *);
- sprintf(name, "%05d compound data", idx);
- nattrs += add_attr(oid, name, tid, sid, cmp_data);
- H5Tclose(tid1);
- H5Tclose(tid);
- H5Sclose(sid);
-
- for (i0=0; i0<4; i0++)
- free(i_vlen[i0].p);
-
- return nattrs;
-}
+/***************************************************************************** + This test generates attributes, groups, and datasets of many types. It + creates a large number of attributes, groups, and datasets by specifying + -a, -g, -d options respectively. Using "-h" option to see details. + + Programmer: Peter Cao <xcao@hdfgroup.org>, Jan. 2013 + ****************************************************************************/ + +#include "hdf5.h" +#include <stdio.h> +#include <stdlib.h> + +#define FNAME "test_perf.h5" +#define NGROUPS 20 +#define NDSETS 20 +#define NATTRS 20 +#define DIM0 40 +#define NROWS 100 +#define NTYPES 9 +#define MAXVLEN 10 +#define FIXED_LEN 8 + +typedef enum { SOLID=0, LIQUID, GAS, PLASMA } phase_t; + +typedef struct { + int i; + unsigned long long l; + float f; + double d; + char s[FIXED_LEN]; + phase_t e; + float f_array[FIXED_LEN]; + hvl_t i_vlen; + char *s_vlen; +} test_comp_t; + +typedef struct { + int zipcode; + char *city; +} zipcode_t; + +int add_attrs(hid_t oid, int idx); +int add_attr(hid_t oid, const char *name, hid_t tid, hid_t sid, void *buf) ; +herr_t create_perf_test_file(const char *fname, int ngrps, int ndsets, + int nattrs, hsize_t nrows, hsize_t dim0, hsize_t chunk, int vlen, + int compressed, int latest); + +int main (int argc, char *argv[]) +{ + char fname[32]; + int i, ngrps=NGROUPS, ndsets=NDSETS, nattrs=NATTRS, dim0=DIM0, + chunk=DIM0/10+1, nrows=NROWS, vlen=MAXVLEN, l=0, z=0; + + memset(fname, 0, 32); + for (i=1; i<argc; i++) { + if (strcmp(argv[i], "-f")==0) + strcpy(fname, argv[i+1]); + else if (strcmp(argv[i], "-g")==0) + ngrps = atoi(argv[i+1]); + else if (strcmp(argv[i], "-d")==0) + ndsets = atoi(argv[i+1]); + else if (strcmp(argv[i], "-a")==0) + nattrs = atoi(argv[i+1]); + else if (strcmp(argv[i], "-r")==0) + nrows = atoi(argv[i+1]); + else if (strcmp(argv[i], "-s")==0) + dim0 = atoi(argv[i+1]); + else if (strcmp(argv[i], "-c")==0) + chunk = atoi(argv[i+1]); + else if (strcmp(argv[i], "-v")==0) + vlen = atoi(argv[i+1]); + else if (strcmp(argv[i], "-l")==0) + l = 1; + else if (strcmp(argv[i], "-z")==0) + z = 1; + else if (strcmp(argv[i], "-h")==0) { + printf("\nOPTONS:\n"); + printf("\t-f F:\tname of the test file (default: %s).\n", FNAME); + printf("\t-g N:\tnumber of top level groups (default: %d).\n", NGROUPS); + printf("\t-d N:\tnumber of datasets (default: %d).\n", NDSETS); + printf("\t-a N:\tnumber of attributes (default: %d).\n", NATTRS); + printf("\t-r N:\tnumber of rows in the large compound dataset (default: %d).\n", NROWS); + printf("\t-s N:\tsize of dim0 in datasets (default: %d).\n", DIM0); + printf("\t-c N:\tchunk size of dim0 (default: %d).\n", (DIM0/10+1)); + printf("\t-v N:\tmax vlen size (default: %d).\n", MAXVLEN); + printf("\t-l:\tuse latest format (default: no).\n"); + printf("\t-z:\tuse gzip compression (default: no).\n"); + printf("\t-h:\tthis help information.\n"); + printf("Example:\n"); + printf("\t./a.out -f test.h5 -g 10000 -d 5000 -a 500 -r 10000 -s 200 -c 20 -v 40 -l -z\n\n"); + exit(0); + } + } + + if (strlen(fname)<=0) + sprintf(fname, FNAME); + + create_perf_test_file(fname, ngrps, ndsets, nattrs, (hsize_t)nrows, + (hsize_t)dim0, (hsize_t)chunk, vlen, z, l); + + return 0; +} + +/***************************************************************************** + This function generates attributes, groups, and datasets of many types. + + Parameters: + fname: file_name. + ngrps: number of top level groups. + ndsets: number of datasets. + attrs: number of attributes. + nrow: number of rows in a dataset. + chunk: chunk size (single number). + vlen: max vlen size. + comp: use latest format. + latest: use gzip comnpression. + + Return: Non-negative on success/Negative on failure + + Programmer: Peter Cao <xcao@hdfgroup.org>, Jan. 2013 + ****************************************************************************/ +herr_t create_perf_test_file(const char *fname, int ngrps, int ndsets, + int nattrs, hsize_t nrows, hsize_t dim0, hsize_t chunk, int vlen, + int compressed, int latest) +{ + int i, j, k; + hid_t fid, sid_null, sid_scalar, sid_1d, sid_2d, did, aid, sid_2, sid_large, + fapl=H5P_DEFAULT, dcpl=H5P_DEFAULT, gid1, gid2, cmp_tid, tid_str, + tid_enum, tid_array_f, tid_vlen_i, tid_vlen_s; + char name[32], tmp_name1[32], tmp_name2[32], tmp_name3[32]; + hsize_t dims[1]={dim0}, dims2d[2]={dim0, (dim0/4+1)}, dims_array[1]={FIXED_LEN}, + dim1[1]={2}; + char *enum_names[4] = {"SOLID", "LIQUID", "GAS", "PLASMA"}; + test_comp_t *buf_comp=NULL, *buf_comp_large=NULL; + int *buf_int=NULL; + float (*buf_float_a)[FIXED_LEN]=NULL; + double **buf_double2d=NULL; + hvl_t *buf_vlen_i=NULL; + char (*buf_str)[FIXED_LEN]; + char **buf_vlen_s=NULL; + hobj_ref_t buf_ref[2]; + hdset_reg_ref_t buf_reg_ref[2]; + size_t offset, len; + herr_t status; + char *names[NTYPES] = { "int", "ulong", "float", "double", "fixed string", + "enum", "fixed float array", "vlen int array", "vlen strings"}; + hid_t types[NTYPES] = { H5T_NATIVE_INT, H5T_NATIVE_UINT64, H5T_NATIVE_FLOAT, + H5T_NATIVE_DOUBLE, tid_str, tid_enum, tid_array_f, tid_vlen_i, tid_vlen_s}; + hsize_t coords[4][2] = { {0, 1}, {3, 5}, {1, 0}, {2, 4}}, start=0, stride=1, count=1; + + if (nrows < NROWS) nrows = NROWS; + if (ngrps<NGROUPS) ngrps=NGROUPS; + if (ndsets<NDSETS) ndsets=NDSETS; + if (nattrs<NATTRS) nattrs=NATTRS; + if (dim0<DIM0) dim0=DIM0; + if (chunk>dim0) chunk=dim0/4; + if (chunk<1) chunk = 1; + if (vlen<1) vlen = MAXVLEN; + + /* create fixed string datatype */ + types[4] = tid_str = H5Tcopy (H5T_C_S1); + H5Tset_size (tid_str, FIXED_LEN); + + /* create enum datatype */ + types[5] = tid_enum = H5Tenum_create(H5T_NATIVE_INT); + for (i = (int) SOLID; i <= (int) PLASMA; i++) { + phase_t val = (phase_t) i; + status = H5Tenum_insert (tid_enum, enum_names[i], &val); + } + + /* create float array datatype */ + types[6] = tid_array_f = H5Tarray_create (H5T_NATIVE_FLOAT, 1, dims_array); + + /* create variable length integer datatypes */ + types[7] = tid_vlen_i = H5Tvlen_create (H5T_NATIVE_INT); + + /* create variable length string datatype */ + types[8] = tid_vlen_s = H5Tcopy (H5T_C_S1); + H5Tset_size (tid_vlen_s, H5T_VARIABLE); + + /* create compound datatypes */ + cmp_tid = H5Tcreate (H5T_COMPOUND, sizeof (test_comp_t)); + offset = 0; + for (i=0; i<NTYPES-2; i++) { + H5Tinsert(cmp_tid, names[i], offset, types[i]); + offset += H5Tget_size(types[i]); + } + + H5Tinsert(cmp_tid, names[7], offset, types[7]); + offset += sizeof (hvl_t); + H5Tinsert(cmp_tid, names[8], offset, types[8]); + + /* create dataspace */ + sid_1d = H5Screate_simple (1, dims, NULL); + sid_2d = H5Screate_simple (2, dims2d, NULL); + sid_2 = H5Screate_simple (1, dim1, NULL); + sid_large = H5Screate_simple (1, &nrows, NULL); + sid_null = H5Screate (H5S_NULL); + sid_scalar = H5Screate (H5S_SCALAR); + + /* create fid access property */ + fapl = H5Pcreate (H5P_FILE_ACCESS); + H5Pset_libver_bounds (fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); + + /* create dataset creation property */ + dcpl = H5Pcreate (H5P_DATASET_CREATE); + + /* set dataset chunk */ + if (chunk>0) { + H5Pset_chunk (dcpl, 1, &chunk); + } + + /* set dataset compression */ + if (compressed) { + if (chunk<=0) { + chunk = dim0/10+1;; + H5Pset_chunk (dcpl, 1, &chunk); + } + H5Pset_shuffle (dcpl); + H5Pset_deflate (dcpl, 6); + } + + /* allocate buffers */ + buf_comp = (test_comp_t *)calloc(dim0, sizeof(test_comp_t)); + buf_comp_large = (test_comp_t *)calloc(nrows, sizeof(test_comp_t)); + buf_int = (int *)calloc(dim0, sizeof(int)); + buf_float_a = malloc(dim0*sizeof(*buf_float_a)); + buf_vlen_i = (hvl_t *)calloc(dim0, sizeof (hvl_t)); + buf_vlen_s = (char **)calloc(dim0, sizeof(char *)); + buf_str = malloc(dim0*sizeof (*buf_str)); + + /* allocate array of doulbe pointers */ + buf_double2d = (double **)calloc(dims2d[0],sizeof(double *)); + /* allocate a contigous chunk of memory for the data */ + buf_double2d[0] = (double *)calloc( dims2d[0]*dims2d[1],sizeof(double) ); + /* assign memory city to pointer array */ + for (i=1; i <dims2d[0]; i++) buf_double2d[i] = buf_double2d[0]+i*dims2d[1]; + + /* fill buffer values */ + len = 1; + for (i=0; i<dims[0]; i++) { + buf_comp[i].i = buf_int[i] = i-2147483648; + buf_comp[i].l = 0xffffffffffffffff-i; + buf_comp[i].f = 1.0/(i+1.0); + buf_comp[i].d = 987654321.0*i+1.0/(i+1.0); + buf_comp[i].e = (phase_t) (i % (int) (PLASMA + 1)); + + for (j=0; j<FIXED_LEN; j++) { + buf_comp[i].f_array[j] = buf_float_a[i][j] = i*100+j; + buf_str[i][j] = 'a' + (i%26); + } + buf_str[i][FIXED_LEN-1] = 0; + strcpy(buf_comp[i].s, buf_str[i]); + + len = (1-cos(i/8.0))/2*vlen+1; + if (!i) len = vlen; + buf_vlen_i[i].len = len; + buf_vlen_i[i].p = (int *)calloc(len, sizeof(int)); + for (j=0; j<len; j++) ((int*)(buf_vlen_i[i].p))[j] = i*100+j; + buf_comp[i].i_vlen = buf_vlen_i[i]; + + buf_vlen_s[i] = (char *)calloc(len, sizeof(char)); + for (j=0; j<len-1; j++) + buf_vlen_s[i][j] = j%26+'A'; + buf_comp[i].s_vlen = buf_vlen_s[i]; + + for (j=0; j<dims2d[1]; j++) + buf_double2d[i][j] = i+j/10000.0; + } + + for (i=0; i<nrows; i++) { + buf_comp_large[i].i = i-2147483648; + buf_comp_large[i].l = 0xffffffffffffffff-i; + buf_comp_large[i].f = 1.0/(i+1.0); + buf_comp_large[i].d = 987654321.0*i+1.0/(i+1.0); + buf_comp_large[i].e = (phase_t) (i % (int) (PLASMA + 1)); + for (j=0; j<FIXED_LEN-1; j++) { + buf_comp_large[i].f_array[j] = i*100+j; + buf_comp_large[i].s[j] = 'a' + (i%26); + } + len = i%vlen+1; + buf_comp_large[i].i_vlen.len = len; + buf_comp_large[i].i_vlen.p = (int *)calloc(len, sizeof(int)); + for (j=0; j<len; j++) ((int*)(buf_comp_large[i].i_vlen.p))[j] = i*100+j; + buf_comp_large[i].s_vlen = (char *)calloc(i+2, sizeof(char)); + for (j=0; j<i+1; j++) (buf_comp_large[i].s_vlen)[j] = j%26+'A'; + } + + /* create file */ + if (latest) + fid = H5Fcreate (fname, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); + else + fid = H5Fcreate (fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + add_attrs(fid, 0); + + sprintf(name, "a cmp ds of %d rows", nrows); + did = H5Dcreate (fid, name, cmp_tid, sid_large, H5P_DEFAULT, dcpl, H5P_DEFAULT); + H5Dwrite (did, cmp_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_comp_large); + add_attrs(did, 0); + H5Dclose(did); + + // /* add attributes*/ + gid1 = H5Gcreate (fid, "attributes", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (nattrs<1) nattrs = 1; + i=0; + while (i<nattrs) i += add_attrs(gid1, i); + H5Gclose(gid1); + + /* add many sub groups to a group*/ + gid1 = H5Gcreate (fid, "groups", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + add_attrs(gid1, 0); + for (i=0; i<ngrps; i++) { + /* create sub groups */ + sprintf(name, "g%02d", i); + gid2 = H5Gcreate (gid1, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (i<10) add_attrs(gid2, 0); + H5Gclose(gid2); + } + H5Gclose(gid1); + + /* add many datasets to a group */ + gid1 = H5Gcreate (fid, "datasets", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + add_attrs(gid1, 0); + for (j=0; j<ndsets; j+=12) { + /* 1 add a null dataset */ + sprintf(name, "%05d null dataset", j); + did = H5Dcreate (gid1, name, H5T_STD_I32LE, sid_null, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (!j) add_attrs(did, j); + H5Dclose(did); + + /* 2 add scalar int point */ + sprintf(name, "%05d scalar int point", j); + did = H5Dcreate (gid1, name, H5T_NATIVE_INT, sid_scalar, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + H5Dwrite (did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &j); + if (!j) add_attrs(did, j); + H5Dclose(did); + + /* 3 scalar vlen string */ + sprintf(name, "%05d scalar vlen string", j); + did = H5Dcreate (gid1, name, tid_vlen_s, sid_scalar, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + H5Dwrite (did, tid_vlen_s, H5S_ALL, H5S_ALL, H5P_DEFAULT, &buf_vlen_s[0]); + if (!j) add_attrs(did, j); + H5Dclose(did); + + /* 4 add fixed-length float array */ + sprintf(name, "%05d fixed-length float array", j); + did = H5Dcreate (gid1, name, tid_array_f, sid_1d, H5P_DEFAULT, dcpl, H5P_DEFAULT); + H5Dwrite (did, tid_array_f, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_float_a); + if (!j) add_attrs(did, j); + H5Dclose(did); + + /* 5 add fixed-length strings */ + sprintf(name, "%05d fixed-length strings", j); + did = H5Dcreate (gid1, name, tid_str, sid_1d, H5P_DEFAULT, dcpl, H5P_DEFAULT); + H5Dwrite (did, tid_str, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_str); + if (!j) add_attrs(did, j); + H5Dclose(did); + + /* 6 add compound data */ + sprintf(name, "%05d compund data", j); + did = H5Dcreate (gid1, name, cmp_tid, sid_1d, H5P_DEFAULT, dcpl, H5P_DEFAULT); + H5Dwrite (did, cmp_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_comp); + if (!j) add_attrs(did, j); + H5Dclose(did); + + /* 7 add 2D double */ + sprintf(name, "%05d 2D double", j); + strcpy (tmp_name1, name); + did = H5Dcreate (gid1, name, H5T_NATIVE_DOUBLE, sid_2d, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + H5Dwrite (did, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_double2d[0]); + if (!j) add_attrs(did, j); + H5Dclose(did); + + /* 8 add 1D int array */ + sprintf(name, "%05d 1D int array", j); + did = H5Dcreate (gid1, name, H5T_NATIVE_INT, sid_1d, H5P_DEFAULT, dcpl, H5P_DEFAULT); + H5Dwrite (did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_int); + if (!j) add_attrs(did, j); + H5Dclose(did); + + /* 9 add vlen int array */ + sprintf(name, "%05d vlen int array", j); + strcpy (tmp_name2, name); + did = H5Dcreate (gid1, name, tid_vlen_i, sid_1d, H5P_DEFAULT, dcpl, H5P_DEFAULT); + H5Dwrite (did, tid_vlen_i, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_vlen_i); + if (!j) add_attrs(did, j); + H5Dclose(did); + + /* 10 add vlen strings */ + sprintf(name, "%05d vlen strings", j); + strcpy (tmp_name3, name); + did = H5Dcreate (gid1, name, tid_vlen_s, sid_1d, H5P_DEFAULT, dcpl, H5P_DEFAULT); + H5Dwrite (did, tid_vlen_s, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_vlen_s); + if (!j) add_attrs(did, j); + H5Dclose(did); + + /* 11 add object refs */ + H5Rcreate(&buf_ref[0],gid1, ".", H5R_OBJECT, -1); + H5Rcreate(&buf_ref[1],gid1, tmp_name3, H5R_OBJECT, -1); + sprintf(name, "%05d obj refs", j); + did = H5Dcreate (gid1, name, H5T_STD_REF_OBJ, sid_2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + H5Dwrite (did, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_ref); + if (!j) add_attrs(did, j); + H5Dclose(did); + + /* 12 add region refs */ + H5Sselect_elements (sid_2d, H5S_SELECT_SET, 4, coords[0]); + H5Rcreate(&buf_reg_ref[0],gid1, tmp_name1, H5R_DATASET_REGION, sid_2d); + H5Sselect_none(sid_2d); + count = dims[0]/2+1; + H5Sselect_hyperslab (sid_1d, H5S_SELECT_SET, &start, &stride, &count,NULL); + H5Rcreate(&buf_reg_ref[1],gid1, tmp_name2, H5R_DATASET_REGION, sid_1d); + H5Sselect_none(sid_1d); + sprintf(name, "%05d region refs", j); + did = H5Dcreate (gid1, name, H5T_STD_REF_DSETREG, sid_2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + H5Dwrite (did, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_reg_ref); + if (!j) add_attrs(did, j); + H5Dclose(did); + } + H5Gclose(gid1); + + H5Tclose (tid_array_f); + H5Tclose (tid_vlen_i); + H5Tclose (tid_vlen_s); + H5Tclose (tid_enum); + H5Tclose (tid_str); + H5Tclose (cmp_tid); + H5Pclose (dcpl); + H5Pclose (fapl); + H5Sclose (sid_1d); + H5Sclose (sid_2d); + H5Sclose (sid_2); + H5Sclose (sid_large); + H5Sclose (sid_null); + H5Sclose (sid_scalar); + H5Fclose (fid); + + for (i=0; i<dims[0]; i++) { + if (buf_vlen_i[i].p) free(buf_vlen_i[i].p); + if (buf_vlen_s[i]) free(buf_vlen_s[i]); + } + + for (i=0; i<nrows; i++) { + if (buf_comp_large[i].i_vlen.p) free(buf_comp_large[i].i_vlen.p); + if (buf_comp_large[i].s_vlen) free(buf_comp_large[i].s_vlen); + } + + free (buf_comp); + free (buf_comp_large); + free (buf_int); + free (buf_float_a); + free (buf_double2d[0]); + free (buf_double2d); + free (buf_str); + free(buf_vlen_i); + free(buf_vlen_s); + + return 0; +} + +/* add a single attribute */ +int add_attr(hid_t oid, const char *name, hid_t tid, hid_t sid, void *buf) +{ + hid_t aid; + + aid = H5Acreate (oid, name, tid, sid, H5P_DEFAULT, H5P_DEFAULT); + if (aid <0) + return 0; + + H5Awrite(aid, tid, buf); + + H5Aclose(aid); + + return 1; +} + +/* + adds different types of attributes to an object. + + returns the number of attributes added to the objects. + */ +int add_attrs(hid_t oid, int idx) +{ + char name[32]; + int i0, i1, i2, j, nattrs=0; + hid_t aid, tid, tid1, sid; + hvl_t i_vlen[4]; + hobj_ref_t ref; + zipcode_t cmp_data[4]; + unsigned int i = 0xffffffff; + long long l = -2147483647; + float f = 123456789.987654321; + double d = 987654321.123456789; + char *s[7] = {"Parting", "is such", "sweeter", "sorrow."}; + float f_array[4] = {1.0, 2.22, 3.333, 4.444}; + char *s_vlen[4] = {"Parting", "is such", "sweet", "sorrow."}; + hsize_t dims1[1]={1}, dims2[1]={4}, dims3[2]={3,5}; + int int3d[4][3][5]; + size_t offset = 0; + + for (i0=0; i0<4; i0++) { + i_vlen[i0].len = (i0+1); + i_vlen[i0].p = (int *)calloc(i_vlen[i0].len, sizeof(int)); + for (j=0; j<i_vlen[i0].len; j++) + ((int *)i_vlen[i0].p)[j] = i0*100+j; + for (i1=0; i1<3; i1++) { + for (i2=0; i2<5; i2++) + int3d[i0][i1][i2] = i0*i1-i1*i2+i0*i2; + } + } + + cmp_data[0].zipcode = 01001; + cmp_data[0].city = "Agawam, Massachusetts"; + cmp_data[1].zipcode = 99950; + cmp_data[1].city = "Ketchikan, Alaska"; + cmp_data[2].zipcode = 00501; + cmp_data[2].city = "Holtsville, New York"; + cmp_data[3].zipcode = 61820; + cmp_data[3].city = "Champaign, Illinois"; + + /* 1 scalar point */ + sid = H5Screate (H5S_SCALAR); + sprintf(name, "%05d scalar int", idx); + nattrs += add_attr(oid, name, H5T_NATIVE_UINT, sid, &i); + sprintf(name, "%05d scalar ulong", idx); + nattrs += add_attr(oid, name, H5T_NATIVE_INT64, sid, &l); + sprintf(name, "%05d scalar str", idx); + tid = H5Tcopy (H5T_C_S1); + H5Tset_size (tid, H5T_VARIABLE); + nattrs += add_attr(oid, name, tid, sid, &s[2]); + H5Tclose(tid); + H5Sclose(sid); + + /* 4 single point */ + sid = H5Screate_simple (1, dims1, NULL); + H5Rcreate(&ref, oid, ".", H5R_OBJECT, -1); + sprintf(name, "%05d single float", idx); + nattrs += add_attr(oid, name, H5T_NATIVE_FLOAT, sid, &f); + sprintf(name, "%05d single double", idx); + nattrs += add_attr(oid, name, H5T_NATIVE_DOUBLE, sid, &d); + sprintf(name, "%05d single obj_ref", idx); + nattrs += add_attr(oid, name, H5T_STD_REF_OBJ, sid, &ref); + H5Sclose(sid); + + /* 7 fixed length 1D array */ + sid = H5Screate_simple (1, dims1, NULL); + tid = H5Tarray_create (H5T_NATIVE_FLOAT, 1, dims2); + sprintf(name, "%05d array float", idx); + nattrs += add_attr(oid, name, tid, sid, &f_array[0]); + H5Tclose(tid); + tid = H5Tcopy (H5T_C_S1); + H5Tset_size (tid, strlen(s[0])+1); + tid1 = H5Tarray_create (tid, 1, dims2); + sprintf(name, "%05d array str", idx); + nattrs += add_attr(oid, name, tid1, sid, s); + H5Tclose(tid1); + H5Tclose(tid); + H5Sclose(sid); + + /* 9 fixed length 2D int arrays */ + sid = H5Screate_simple (1, dims2, NULL); + tid = H5Tarray_create (H5T_NATIVE_INT, 2, dims3); + sprintf(name, "%05d array int 2D", idx); + nattrs += add_attr(oid, name, tid, sid, int3d[0][0]); + H5Tclose(tid); + H5Sclose(sid); + + /* 10 variable length arrays */ + sid = H5Screate_simple (1, dims2, NULL); + tid = H5Tcopy (H5T_C_S1); + H5Tset_size (tid, H5T_VARIABLE); + sprintf(name, "%05d vlen strings", idx); + nattrs += add_attr(oid, name, tid, sid, s_vlen); + H5Tclose(tid); + tid = H5Tvlen_create (H5T_NATIVE_INT);; + sprintf(name, "%05d vlen int array", idx); + nattrs += add_attr(oid, name, tid, sid, i_vlen); + H5Tclose(tid); + H5Sclose(sid); + + /* 12 compound data */ + sid = H5Screate_simple (1, dims2, NULL); + tid = H5Tcreate (H5T_COMPOUND, sizeof (zipcode_t)); + tid1 = H5Tcopy (H5T_C_S1); + H5Tset_size (tid1, H5T_VARIABLE); + H5Tinsert (tid, "zip code", 0, H5T_NATIVE_INT); offset += sizeof(H5T_NATIVE_INT); + H5Tinsert (tid, "City", offset, tid1); offset += sizeof(char *); + sprintf(name, "%05d compound data", idx); + nattrs += add_attr(oid, name, tid, sid, cmp_data); + H5Tclose(tid1); + H5Tclose(tid); + H5Sclose(sid); + + for (i0=0; i0<4; i0++) + free(i_vlen[i0].p); + + return nattrs; +} |