diff options
Diffstat (limited to 'tools/h5diff')
28 files changed, 2940 insertions, 2936 deletions
diff --git a/tools/h5diff/CMakeLists.txt b/tools/h5diff/CMakeLists.txt index 4ef6fb7..4f4fb59 100644 --- a/tools/h5diff/CMakeLists.txt +++ b/tools/h5diff/CMakeLists.txt @@ -1,94 +1,137 @@ -cmake_minimum_required (VERSION 3.10) -PROJECT (HDF5_TOOLS_H5DIFF) - -#----------------------------------------------------------------------------- -# Setup include Directories -#----------------------------------------------------------------------------- -INCLUDE_DIRECTORIES (${HDF5_TOOLS_SRC_DIR}/lib) +cmake_minimum_required (VERSION 3.12) +project (HDF5_TOOLS_H5DIFF C) # -------------------------------------------------------------------- # Add the h5diff executables # -------------------------------------------------------------------- -add_executable (h5diff - ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/h5diff_common.c - ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/h5diff_main.c -) -TARGET_C_PROPERTIES (h5diff STATIC " " " ") -target_link_libraries (h5diff ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) -set_target_properties (h5diff PROPERTIES FOLDER tools) -set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};h5diff") - -set (H5_DEP_EXECUTABLES h5diff) - +if (NOT ONLY_SHARED_LIBS) + add_executable (h5diff + ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/h5diff_common.c + ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/h5diff_main.c + ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/h5diff_common.h + ) + target_include_directories (h5diff PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + target_compile_options(h5diff PRIVATE "${HDF5_CMAKE_C_FLAGS}") + #target_compile_definitions (h5diff PRIVATE H5_TOOLS_DEBUG) + TARGET_C_PROPERTIES (h5diff STATIC) + target_link_libraries (h5diff PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) + set_target_properties (h5diff PROPERTIES FOLDER tools) + set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};h5diff") + + set (H5_DEP_EXECUTABLES h5diff) +endif () if (BUILD_SHARED_LIBS) add_executable (h5diff-shared ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/h5diff_common.c ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/h5diff_main.c + ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/h5diff_common.h ) - TARGET_C_PROPERTIES (h5diff-shared SHARED " " " ") - target_link_libraries (h5diff-shared ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) + target_include_directories (h5diff-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + target_compile_options(h5diff-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}") + #target_compile_definitions (h5diff-shared PRIVATE H5_TOOLS_DEBUG) + TARGET_C_PROPERTIES (h5diff-shared SHARED) + target_link_libraries (h5diff-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) set_target_properties (h5diff-shared PROPERTIES FOLDER tools) set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};h5diff-shared") set (H5_DEP_EXECUTABLES ${H5_DEP_EXECUTABLES} h5diff-shared) endif () +#----------------------------------------------------------------------------- +# Add Target to clang-format +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_FORMATTERS) + if (NOT ONLY_SHARED_LIBS) + clang_format (HDF5_H5DIFF_SRC_FORMAT h5diff) + else () + clang_format (HDF5_H5DIFF_SRC_FORMAT h5diff-shared) + endif () +endif () + if (H5_HAVE_PARALLEL) - add_executable (ph5diff - ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/h5diff_common.c - ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/ph5diff_main.c - ) - TARGET_C_PROPERTIES (ph5diff STATIC " " " ") - target_link_libraries (ph5diff ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) - set_target_properties (ph5diff PROPERTIES FOLDER tools) - set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};ph5diff") + if (NOT ONLY_SHARED_LIBS) + add_executable (ph5diff + ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/h5diff_common.c + ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/ph5diff_main.c + ) + target_include_directories (ph5diff PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + target_compile_options(ph5diff PRIVATE "${HDF5_CMAKE_C_FLAGS}") + TARGET_C_PROPERTIES (ph5diff STATIC) + target_link_libraries (ph5diff PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET} "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_LIBRARIES}>") + set_target_properties (ph5diff PROPERTIES FOLDER tools) + set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};ph5diff") + set (H5_DEP_EXECUTABLES ${H5_DEP_EXECUTABLES} ph5diff) + endif () + if (BUILD_SHARED_LIBS) + add_executable (ph5diff-shared + ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/h5diff_common.c + ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/ph5diff_main.c + ) + target_include_directories (ph5diff-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + target_compile_options(ph5diff-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}") + TARGET_C_PROPERTIES (ph5diff-shared SHARED) + target_link_libraries (ph5diff-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_LIBRARIES}>") + set_target_properties (ph5diff-shared PROPERTIES FOLDER tools) + set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};ph5diff-shared") + set (H5_DEP_EXECUTABLES ${H5_DEP_EXECUTABLES} ph5diff-shared) + endif () endif () -if (BUILD_TESTING) - # -------------------------------------------------------------------- - # Add the h5diff and test executables - # -------------------------------------------------------------------- - if (HDF5_BUILD_GENERATORS) - add_executable (h5diffgentest ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/h5diffgentest.c) - TARGET_C_PROPERTIES (h5diffgentest STATIC " " " ") - target_link_libraries (h5diffgentest ${HDF5_LIB_TARGET}) - set_target_properties (h5diffgentest PROPERTIES FOLDER generator/tools) - - #add_test (NAME h5diffgentest COMMAND $<TARGET_FILE:h5diffgentest>) +if (HDF5_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS) + add_executable (h5diffgentest ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/h5diffgentest.c) + target_include_directories (h5diffgentest PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + TARGET_C_PROPERTIES (h5diffgentest STATIC) + target_link_libraries (h5diffgentest PRIVATE ${HDF5_LIB_TARGET}) + set_target_properties (h5diffgentest PROPERTIES FOLDER generator/tools) + + #----------------------------------------------------------------------------- + # Add Target to clang-format + #----------------------------------------------------------------------------- + if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_TOOLS_TEST_H5DIFF_FORMAT h5diffgentest) endif () + #add_test (NAME h5diffgentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5diffgentest>) +endif () + +#----------------------------------------------------------------------------- +# If plugin library tests can be tested +#----------------------------------------------------------------------------- +if (BUILD_SHARED_LIBS) + set (H5DIFF_TOOL_PLUGIN_LIB_CORENAME "dynlibdiff") + set (H5DIFF_TOOL_PLUGIN_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${H5DIFF_TOOL_PLUGIN_LIB_CORENAME}") + set (H5DIFF_TOOL_PLUGIN_LIB_TARGET ${H5DIFF_TOOL_PLUGIN_LIB_CORENAME}) + + add_library (${H5DIFF_TOOL_PLUGIN_LIB_TARGET} SHARED dynlib_diff.c) + target_include_directories (${H5DIFF_TOOL_PLUGIN_LIB_TARGET} PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + TARGET_C_PROPERTIES (${H5DIFF_TOOL_PLUGIN_LIB_TARGET} SHARED) + target_link_libraries (${H5DIFF_TOOL_PLUGIN_LIB_TARGET} PRIVATE ${HDF5_TEST_LIBSH_TARGET}) + H5_SET_LIB_OPTIONS (${H5DIFF_TOOL_PLUGIN_LIB_TARGET} ${H5DIFF_TOOL_PLUGIN_LIB_NAME} SHARED "LIB") + #----------------------------------------------------------------------------- - # If plugin library tests can be tested + # Add Target to clang-format #----------------------------------------------------------------------------- - if (BUILD_SHARED_LIBS) - set (HDF5_TOOL_PLUGIN_LIB_CORENAME "dynlibdiff") - 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 (${HDF_EXTRA_C_FLAGS}) - INCLUDE_DIRECTORIES (${HDF5_SRC_DIR}) - - add_library (${HDF5_TOOL_PLUGIN_LIB_TARGET} SHARED dynlib_diff.c) - TARGET_C_PROPERTIES (${HDF5_TOOL_PLUGIN_LIB_TARGET} SHARED " " " ") - target_link_libraries (${HDF5_TOOL_PLUGIN_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) - H5_SET_LIB_OPTIONS (${HDF5_TOOL_PLUGIN_LIB_TARGET} ${HDF5_TOOL_PLUGIN_LIB_NAME} SHARED "LIB") - - # make plugins dir - file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/plugins") - #----------------------------------------------------------------------------- - # Copy plugin library to a plugins folder - #----------------------------------------------------------------------------- - add_custom_command ( - TARGET ${HDF5_TOOL_PLUGIN_LIB_TARGET} - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different - "$<TARGET_FILE:${HDF5_TOOL_PLUGIN_LIB_TARGET}>" - "${CMAKE_BINARY_DIR}/plugins/$<TARGET_FILE_NAME:${HDF5_TOOL_PLUGIN_LIB_TARGET}>" - ) + if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_TOOLS_TEST_H5DIFF_PLUGIN_FORMAT ${H5DIFF_TOOL_PLUGIN_LIB_TARGET}) endif () - include (CMakeTests.cmake) + # make plugins dir + file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/plugins") + #----------------------------------------------------------------------------- + # Copy plugin library to a plugins folder + #----------------------------------------------------------------------------- + add_custom_command ( + TARGET ${H5DIFF_TOOL_PLUGIN_LIB_TARGET} + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different + "$<TARGET_FILE:${H5DIFF_TOOL_PLUGIN_LIB_TARGET}>" + "${CMAKE_BINARY_DIR}/plugins/$<TARGET_FILE_NAME:${H5DIFF_TOOL_PLUGIN_LIB_TARGET}>" + ) +endif () +if (HDF5_TEST_TOOLS) + include (CMakeTests.cmake) endif () ############################################################################## @@ -112,16 +155,4 @@ if (HDF5_EXPORTED_TARGETS) ${HDF5_EXPORTED_TARGETS} RUNTIME DESTINATION ${HDF5_INSTALL_BIN_DIR} COMPONENT toolsapplications ) - - if (H5_HAVE_PARALLEL) - #INSTALL_PROGRAM_PDB (ph5diff ${HDF5_INSTALL_BIN_DIR} toolsapplications) - - install ( - TARGETS - ph5diff - EXPORT - ${HDF5_EXPORTED_TARGETS} - RUNTIME DESTINATION ${HDF5_INSTALL_BIN_DIR} COMPONENT toolsapplications - ) - endif () endif () diff --git a/tools/h5diff/CMakeTests.cmake b/tools/h5diff/CMakeTests.cmake index 14fbee7..1af805e 100644 --- a/tools/h5diff/CMakeTests.cmake +++ b/tools/h5diff/CMakeTests.cmake @@ -5,7 +5,7 @@ # This file is part of HDF5. The full HDF5 copyright notice, including # terms governing use, modification, and redistribution, is contained in # the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# distribution tree, or in https://www.hdfgroup.org/licenses. # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. # @@ -142,21 +142,12 @@ ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_452.txt ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_453.txt ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_454.txt - ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_454_ERR.txt - ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_454_ERR.err + ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/dangling_link.err ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_455.txt - ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_455_ERR.txt - ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_455_ERR.err ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_456.txt ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_457.txt - ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_457_ERR.txt - ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_457_ERR.err ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_458.txt - ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_458_ERR.txt - ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_458_ERR.err ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_459.txt - ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_459_ERR.txt - ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_459_ERR.err ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_465.txt ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_466.txt ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_467.txt @@ -212,7 +203,6 @@ ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_63.txt ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_600.txt ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_601.txt - ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_601_ERR.txt ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_601_ERR.err ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_603.txt ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_604.txt @@ -267,6 +257,7 @@ ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_8625.txt ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_8639.txt ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_ud.txt + ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_udfail.err ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_udfail.txt ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_vlstr.txt ) @@ -304,7 +295,15 @@ # # Overwrite system dependent files (Windows) and not VS2015 # + set (COPY_WINDOWS_FILES false) + # MinGW tests may depend on host system + #if (MINGW) + # set (COPY_WINDOWS_FILES true) + #endif () if (WIN32 AND MSVC_VERSION LESS 1900) + set (COPY_WINDOWS_FILES true) + endif () + if (COPY_WINDOWS_FILES) foreach (h5_tstfiles ${LIST_WIN_TEST_FILES}) get_filename_component(fname "${h5_tstfiles}" NAME) HDFTEST_COPY_FILE("${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/${h5_tstfiles}w.txt" "${PROJECT_BINARY_DIR}/testfiles/${fname}.txt" "h5diff_files") @@ -330,115 +329,57 @@ ############################################################################## macro (ADD_H5_TEST resultfile resultcode) - # If using memchecker add tests without using scripts - if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5DIFF-${resultfile} COMMAND $<TARGET_FILE:h5diff> ${ARGN}) - set_tests_properties (H5DIFF-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") - if (NOT "${resultcode}" STREQUAL "0") - set_tests_properties (H5DIFF-${resultfile} PROPERTIES WILL_FAIL "true") - endif () - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5DIFF-${resultfile} PROPERTIES DEPENDS ${last_test}) - endif () - else () - # Remove any output file left over from previous test run - add_test ( - NAME H5DIFF-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/${resultfile}.out - testfiles/${resultfile}.out.err - ) - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5DIFF-${resultfile}-clear-objects PROPERTIES DEPENDS ${last_test}) + if (HDF5_TEST_SERIAL) + # If using memchecker add tests without using scripts + if (HDF5_ENABLE_USING_MEMCHECKER) + add_test (NAME H5DIFF-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5diff${tgt_file_ext}> ${ARGN}) + set_tests_properties (H5DIFF-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") + if (${resultcode}) + set_tests_properties (H5DIFF-${resultfile} PROPERTIES WILL_FAIL "true") + endif () + if (last_test) + set_tests_properties (H5DIFF-${resultfile} PROPERTIES DEPENDS ${last_test}) + endif () + else () + add_test ( + NAME H5DIFF-${resultfile} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" + -D "TEST_PROGRAM=$<TARGET_FILE:h5diff${tgt_file_ext}>" + -D "TEST_ARGS:STRING=${ARGN}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" + -D "TEST_OUTPUT=${resultfile}.out" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_REFERENCE=${resultfile}.txt" + -D "TEST_APPEND=EXIT CODE:" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + if (last_test) + set_tests_properties (H5DIFF-${resultfile} PROPERTIES DEPENDS ${last_test}) + endif () endif () - add_test ( - NAME H5DIFF-${resultfile} - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5diff>" - -D "TEST_ARGS:STRING=${ARGN}" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" - -D "TEST_OUTPUT=${resultfile}.out" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_REFERENCE=${resultfile}.txt" - -D "TEST_APPEND=EXIT CODE:" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" - ) - set_tests_properties (H5DIFF-${resultfile} PROPERTIES DEPENDS H5DIFF-${resultfile}-clear-objects) endif () - if (H5_HAVE_PARALLEL) + if (H5_HAVE_PARALLEL AND HDF5_TEST_PARALLEL) ADD_PH5_TEST (${resultfile} ${resultcode} ${ARGN}) endif () endmacro () - macro (ADD_H5_ERR_TEST resultfile resultcode) - # If using memchecker add tests without using scripts - if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5DIFF_ERR-${resultfile} COMMAND $<TARGET_FILE:h5diff> --enable-error-stack ${ARGN}) - set_tests_properties (H5DIFF_ERR-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") - if (NOT "${resultcode}" STREQUAL "0") - set_tests_properties (H5DIFF_ERR-${resultfile} PROPERTIES WILL_FAIL "true") - endif () - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5DIFF_ERR-${resultfile} PROPERTIES DEPENDS ${last_test}) - endif () - else () - # Remove any output file left over from previous test run - add_test ( - NAME H5DIFF_ERR-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/${resultfile}_ERR.out - testfiles/${resultfile}_ERR.out.err - ) - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5DIFF_ERR-${resultfile}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () - add_test ( - NAME H5DIFF_ERR-${resultfile} - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5diff>" - -D "TEST_ARGS:STRING=--enable-error-stack;${ARGN}" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" - -D "TEST_OUTPUT=${resultfile}_ERR.out" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_REFERENCE=${resultfile}_ERR.txt" - -D "TEST_MASK_ERROR=true" - -D "TEST_APPEND=EXIT CODE:" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" - ) - set_tests_properties (H5DIFF_ERR-${resultfile} PROPERTIES DEPENDS H5DIFF_ERR-${resultfile}-clear-objects) - endif () - set (last_test "H5DIFF_ERR-${resultfile}") - endmacro () - macro (ADD_PH5_TEST resultfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME PH5DIFF-${resultfile} COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $<TARGET_FILE:ph5diff> ${MPIEXEC_POSTFLAGS} ${ARGN}) - set_tests_properties (PH5DIFF-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/PAR/testfiles") - if (NOT "${resultcode}" STREQUAL "0") - set_tests_properties (PH5DIFF-${resultfile} PROPERTIES WILL_FAIL "true") + add_test (NAME MPI_TEST_H5DIFF-${resultfile} COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $<TARGET_FILE:ph5diff${tgt_file_ext}> ${MPIEXEC_POSTFLAGS} ${ARGN}) + set_tests_properties (MPI_TEST_H5DIFF-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/PAR/testfiles") + if (${resultcode}) + set_tests_properties (MPI_TEST_H5DIFF-${resultfile} PROPERTIES WILL_FAIL "true") endif () - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (PH5DIFF-${resultfile} PROPERTIES DEPENDS ${last_test}) + if (last_test) + set_tests_properties (MPI_TEST_H5DIFF-${resultfile} PROPERTIES DEPENDS ${last_test}) endif () else () - # Remove any output file left over from previous test run - add_test ( - NAME PH5DIFF-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - PAR/testfiles/${resultfile}.out - PAR/testfiles/${resultfile}.out.err - ) - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (PH5DIFF-${resultfile}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () add_test ( - NAME PH5DIFF-${resultfile} + NAME MPI_TEST_H5DIFF-${resultfile} COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=${MPIEXEC_EXECUTABLE};${MPIEXEC_NUMPROC_FLAG};${MPIEXEC_MAX_NUMPROCS};${MPIEXEC_PREFLAGS};$<TARGET_FILE:ph5diff>;${MPIEXEC_POSTFLAGS}" + -D "TEST_PROGRAM=${MPIEXEC_EXECUTABLE};${MPIEXEC_NUMPROC_FLAG};${MPIEXEC_MAX_NUMPROCS};${MPIEXEC_PREFLAGS};$<TARGET_FILE:ph5diff${tgt_file_ext}>;${MPIEXEC_POSTFLAGS}" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/PAR/testfiles" -D "TEST_OUTPUT=${resultfile}.out" @@ -450,25 +391,20 @@ -D "TEST_SORT_COMPARE=TRUE" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (PH5DIFF-${resultfile} PROPERTIES DEPENDS PH5DIFF-${resultfile}-clear-objects) - set (last_test "PH5DIFF-${resultfile}") + if (last_test) + set_tests_properties (MPI_TEST_H5DIFF-${resultfile} PROPERTIES DEPENDS ${last_test}) + endif () + set (last_test "MPI_TEST_H5DIFF-${resultfile}") endif () endmacro () macro (ADD_H5_UD_TEST testname resultcode resultfile) if (NOT HDF5_ENABLE_USING_MEMCHECKER) - # Remove any output file left over from previous test run - add_test ( - NAME H5DIFF_UD-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/${resultfile}.out - testfiles/${resultfile}.out.err - ) - if ("${resultcode}" STREQUAL "2") + if (${resultcode} EQUAL 2) add_test ( NAME H5DIFF_UD-${testname} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$<TARGET_FILE:h5diff-shared>" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" @@ -478,12 +414,14 @@ -D "TEST_APPEND=EXIT CODE:" -D "TEST_ENV_VAR=HDF5_PLUGIN_PATH" -D "TEST_ENV_VALUE=${CMAKE_BINARY_DIR}" + -D "TEST_LIBRARY_DIRECTORY=${CMAKE_TEST_OUTPUT_DIRECTORY}" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) else () add_test ( NAME H5DIFF_UD-${testname} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$<TARGET_FILE:h5diff-shared>" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" @@ -493,57 +431,13 @@ -D "TEST_APPEND=EXIT CODE:" -D "TEST_ENV_VAR=HDF5_PLUGIN_PATH" -D "TEST_ENV_VALUE=${CMAKE_BINARY_DIR}/plugins" + -D "TEST_LIBRARY_DIRECTORY=${CMAKE_TEST_OUTPUT_DIRECTORY}" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) endif () - set_tests_properties (H5DIFF_UD-${testname} PROPERTIES DEPENDS H5DIFF_UD-${testname}-clear-objects) - endif () - endmacro () - - macro (ADD_H5_UD_ERR_TEST testname resultcode resultfile) - if (NOT HDF5_ENABLE_USING_MEMCHECKER) - # Remove any output file left over from previous test run - add_test ( - NAME H5DIFF_UD_ERR-${testname}-clearall-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/${resultfile}_ERR.out - testfiles/${resultfile}_ERR.out.err - ) - if ("${resultcode}" STREQUAL "2") - add_test ( - NAME H5DIFF_UD_ERR-${testname} - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5diff-shared>" - -D "TEST_ARGS:STRING=--enable-error-stack;${ARGN}" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" - -D "TEST_OUTPUT=${resultfile}_ERR.out" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_REFERENCE=${resultfile}_ERR.txt" - -D "TEST_MASK_ERROR=true" - -D "TEST_APPEND=EXIT CODE:" - -D "TEST_ENV_VAR=HDF5_PLUGIN_PATH" - -D "TEST_ENV_VALUE=${CMAKE_BINARY_DIR}" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" - ) - else () - add_test ( - NAME H5DIFF_UD_ERR-${testname} - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5diff-shared>" - -D "TEST_ARGS:STRING=--enable-error-stack;${ARGN}" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" - -D "TEST_OUTPUT=${resultfile}_ERR.out" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_REFERENCE=${resultfile}_ERR.txt" - -D "TEST_MASK_ERROR=true" - -D "TEST_APPEND=EXIT CODE:" - -D "TEST_ENV_VAR=HDF5_PLUGIN_PATH" - -D "TEST_ENV_VALUE=${CMAKE_BINARY_DIR}/plugins" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" - ) + if (last_test) + set_tests_properties (H5DIFF_UD-${testname} PROPERTIES DEPENDS ${last_test}) endif () - set_tests_properties (H5DIFF_UD_ERR-${testname} PROPERTIES DEPENDS H5DIFF_UD_ERR-${testname}-clearall-objects) endif () endmacro () @@ -761,26 +655,16 @@ h5diff_453.out.err h5diff_454.out h5diff_454.out.err - h5diff_454_ERR.out - h5diff_454_ERR.out.err h5diff_455.out h5diff_455.out.err - h5diff_455_ERR.out - h5diff_455_ERR.out.err h5diff_456.out h5diff_456.out.err h5diff_457.out h5diff_457.out.err - h5diff_457_ERR.out - h5diff_457_ERR.out.err h5diff_458.out h5diff_458.out.err - h5diff_458_ERR.out - h5diff_458_ERR.out.err h5diff_459.out h5diff_459.out.err - h5diff_459_ERR.out - h5diff_459_ERR.out.err h5diff_465.out h5diff_465.out.err h5diff_466.out @@ -885,8 +769,6 @@ h5diff_600.out.err h5diff_601.out h5diff_601.out.err - h5diff_601_ERR.out - h5diff_601_ERR.out.err h5diff_603.out h5diff_603.out.err h5diff_604.out @@ -991,7 +873,7 @@ h5diff_vlstr.out.err ) set_tests_properties (H5DIFF-clearall-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") - if (NOT "${last_test}" STREQUAL "") + if (last_test) set_tests_properties (H5DIFF-clearall-objects PROPERTIES DEPENDS ${last_test}) endif () set (last_test "H5DIFF-clearall-objects") @@ -1129,7 +1011,6 @@ ADD_H5_TEST (h5diff_600 1 ${FILE1}) # 6.1: Check if non-exist object name is specified ADD_H5_TEST (h5diff_601 2 ${FILE1} ${FILE1} nono_obj) -ADD_H5_ERR_TEST (h5diff_601 2 ${FILE1} ${FILE1} nono_obj) # ############################################################################## # # -d @@ -1429,26 +1310,21 @@ ADD_H5_TEST (h5diff_453 2 --follow-symlinks -v --no-dangling-links ${FILE13} $ # dangling link found for soft links (obj to obj) ADD_H5_TEST (h5diff_454 2 --follow-symlinks -v --no-dangling-links ${FILE13} ${FILE13} /softlink_dset2 /softlink_noexist) -ADD_H5_ERR_TEST (h5diff_454 2 --follow-symlinks -v --no-dangling-links ${FILE13} ${FILE13} /softlink_dset2 /softlink_noexist) # dangling link found for soft links (obj to obj) Both dangle links ADD_H5_TEST (h5diff_455 2 --follow-symlinks -v --no-dangling-links ${FILE13} ${FILE13} /softlink_noexist /softlink_noexist) -ADD_H5_ERR_TEST (h5diff_455 2 --follow-symlinks -v --no-dangling-links ${FILE13} ${FILE13} /softlink_noexist /softlink_noexist) # dangling link found for ext links (FILE to FILE) ADD_H5_TEST (h5diff_456 2 --follow-symlinks -v --no-dangling-links ${FILE15} ${FILE15}) # dangling link found for ext links (obj to obj). target file exist ADD_H5_TEST (h5diff_457 2 --follow-symlinks -v --no-dangling-links ${FILE15} ${FILE15} /ext_link_dset1 /ext_link_noexist1) -ADD_H5_ERR_TEST (h5diff_457 2 --follow-symlinks -v --no-dangling-links ${FILE15} ${FILE15} /ext_link_dset1 /ext_link_noexist1) # dangling link found for ext links (obj to obj). target file NOT exist ADD_H5_TEST (h5diff_458 2 --follow-symlinks -v --no-dangling-links ${FILE15} ${FILE15} /ext_link_dset1 /ext_link_noexist2) -ADD_H5_ERR_TEST (h5diff_458 2 --follow-symlinks -v --no-dangling-links ${FILE15} ${FILE15} /ext_link_dset1 /ext_link_noexist2) # dangling link found for ext links (obj to obj). Both dangle links ADD_H5_TEST (h5diff_459 2 --follow-symlinks -v --no-dangling-links ${FILE15} ${FILE15} /ext_link_noexist1 /ext_link_noexist2) -ADD_H5_ERR_TEST (h5diff_459 2 --follow-symlinks -v --no-dangling-links ${FILE15} ${FILE15} /ext_link_noexist1 /ext_link_noexist2) # dangling link --follow-symlinks (obj vs obj) # (HDFFV-7836) @@ -1553,8 +1429,6 @@ ADD_H5_TEST (h5diff_485 0 -v --exclude-path "/group1" h5diff_exclude3-1.h5 h5dif ADD_H5_TEST (h5diff_486 0 -v --exclude-path "/group1" h5diff_exclude3-2.h5 h5diff_exclude3-1.h5) ADD_H5_TEST (h5diff_487 1 -v --exclude-path "/group1/dset" h5diff_exclude3-1.h5 h5diff_exclude3-2.h5) - - # ############################################################################## # # diff various multiple vlen and fixed strings in a compound type dataset # ############################################################################## @@ -1595,7 +1469,7 @@ ADD_H5_TEST (h5diff_801 1 -v ${FILE7} ${FILE8A} /g1/array /g1/array) ############################################################################## ### P L U G I N T E S T S ############################################################################## -if (BUILD_SHARED_LIBS) +if (BUILD_SHARED_LIBS AND HDF5_TEST_SERIAL) ADD_H5_UD_TEST (h5diff_plugin_test 0 h5diff_ud -v tudfilter.h5 tudfilter2.h5) ADD_H5_UD_TEST (h5diff_plugin_fail 2 h5diff_udfail -v tudfilter.h5 tudfilter2.h5) endif () diff --git a/tools/h5diff/Makefile.am b/tools/h5diff/Makefile.am index 2fd328f..1a87de5 100644 --- a/tools/h5diff/Makefile.am +++ b/tools/h5diff/Makefile.am @@ -6,7 +6,7 @@ # This file is part of HDF5. The full HDF5 copyright notice, including # terms governing use, modification, and redistribution, is contained in # the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# distribution tree, or in https://www.hdfgroup.org/licenses. # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. ## @@ -25,7 +25,11 @@ AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/tools/lib # is enabled. if BUILD_PARALLEL_CONDITIONAL H5PDIFF=ph5diff +if BUILD_TESTS_PARALLEL_CONDITIONAL TEST_SCRIPT_PARA=testph5diff.sh +else + TEST_SCRIPT_PARA= +endif endif # Our main target, h5diff @@ -35,23 +39,28 @@ bin_PROGRAMS=h5diff $(H5PDIFF) h5diff_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS) # Test programs and scripts +if BUILD_TESTS_CONDITIONAL TEST_PROG=h5diffgentest TEST_SCRIPT=testh5diff.sh - -check_PROGRAMS=$(TEST_PROG) -check_SCRIPTS=$(TEST_SCRIPT) $(TEST_SCRIPT_PARA) -# The parallel test script testph5diff.sh actually depends on testh5diff.sh. -SCRIPT_DEPEND=h5diff$(EXEEXT) $(H5PDIFF) testh5diff.sh + h5diffgentest_SOURCES=h5diffgentest.c if HAVE_SHARED_CONDITIONAL if USE_PLUGINS_CONDITIONAL TEST_SCRIPT += h5diff_plugin.sh endif endif +else +TEST_PROG= +TEST_SCRIPT= +endif + +check_PROGRAMS=$(TEST_PROG) +check_SCRIPTS=$(TEST_SCRIPT) $(TEST_SCRIPT_PARA) +# The parallel test script testph5diff.sh actually depends on testh5diff.sh. +SCRIPT_DEPEND=h5diff$(EXEEXT) $(H5PDIFF) testh5diff.sh # Source files for the program h5diff_SOURCES=h5diff_main.c h5diff_common.c ph5diff_SOURCES=ph5diff_main.c h5diff_common.c -h5diffgentest_SOURCES=h5diffgentest.c # Programs depend on the main HDF5 library and tools library LDADD=$(LIBH5TOOLS) $(LIBHDF5) diff --git a/tools/h5diff/Makefile.in b/tools/h5diff/Makefile.in index 218b7b8..e3475bf 100644 --- a/tools/h5diff/Makefile.in +++ b/tools/h5diff/Makefile.in @@ -22,7 +22,7 @@ # This file is part of HDF5. The full HDF5 copyright notice, including # terms governing use, modification, and redistribution, is contained in # the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# distribution tree, or in https://www.hdfgroup.org/licenses. # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. # @@ -105,9 +105,9 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ bin_PROGRAMS = h5diff$(EXEEXT) $(am__EXEEXT_1) +@BUILD_TESTS_CONDITIONAL_TRUE@@HAVE_SHARED_CONDITIONAL_TRUE@@USE_PLUGINS_CONDITIONAL_TRUE@am__append_1 = h5diff_plugin.sh check_PROGRAMS = $(am__EXEEXT_2) -@HAVE_SHARED_CONDITIONAL_TRUE@@USE_PLUGINS_CONDITIONAL_TRUE@am__append_1 = h5diff_plugin.sh -TESTS = $(am__EXEEXT_2) $(TEST_SCRIPT) +TESTS = $(am__EXEEXT_2) $(am__EXEEXT_3) subdir = tools/h5diff ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/aclocal_cxx.m4 \ @@ -135,7 +135,7 @@ libdynlibdiff_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ @HAVE_SHARED_CONDITIONAL_TRUE@@NOT_UNAME_CYGWIN_TRUE@am_libdynlibdiff_la_rpath = @BUILD_PARALLEL_CONDITIONAL_TRUE@am__EXEEXT_1 = ph5diff$(EXEEXT) am__installdirs = "$(DESTDIR)$(bindir)" -am__EXEEXT_2 = h5diffgentest$(EXEEXT) +@BUILD_TESTS_CONDITIONAL_TRUE@am__EXEEXT_2 = h5diffgentest$(EXEEXT) PROGRAMS = $(bin_PROGRAMS) am_h5diff_OBJECTS = h5diff_main.$(OBJEXT) h5diff_common.$(OBJEXT) h5diff_OBJECTS = $(am_h5diff_OBJECTS) @@ -144,8 +144,8 @@ h5diff_DEPENDENCIES = $(LIBH5TOOLS) $(LIBHDF5) h5diff_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(h5diff_LDFLAGS) $(LDFLAGS) -o $@ -am_h5diffgentest_OBJECTS = h5diffgentest.$(OBJEXT) -h5diffgentest_OBJECTS = $(am_h5diffgentest_OBJECTS) +h5diffgentest_SOURCES = h5diffgentest.c +h5diffgentest_OBJECTS = h5diffgentest.$(OBJEXT) h5diffgentest_LDADD = $(LDADD) h5diffgentest_DEPENDENCIES = $(LIBH5TOOLS) $(LIBHDF5) am_ph5diff_OBJECTS = ph5diff_main.$(OBJEXT) h5diff_common.$(OBJEXT) @@ -187,9 +187,9 @@ am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libdynlibdiff_la_SOURCES) $(h5diff_SOURCES) \ - $(h5diffgentest_SOURCES) $(ph5diff_SOURCES) + h5diffgentest.c $(ph5diff_SOURCES) DIST_SOURCES = $(am__libdynlibdiff_la_SOURCES_DIST) $(h5diff_SOURCES) \ - $(h5diffgentest_SOURCES) $(ph5diff_SOURCES) + h5diffgentest.c $(ph5diff_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ @@ -398,6 +398,8 @@ am__set_TESTS_bases = \ bases=`echo $$bases` RECHECK_LOGS = $(TEST_LOGS) AM_RECURSIVE_TARGETS = check recheck +@BUILD_TESTS_CONDITIONAL_TRUE@am__EXEEXT_3 = testh5diff.sh \ +@BUILD_TESTS_CONDITIONAL_TRUE@ $(am__append_1) TEST_SUITE_LOG = test-suite.log LOG_DRIVER = $(SHELL) $(top_srcdir)/bin/test-driver LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) @@ -431,12 +433,12 @@ AMTAR = @AMTAR@ # AM_CFLAGS is an automake construct which should be used by Makefiles # instead of CFLAGS, as CFLAGS is reserved solely for the user to define. # This applies to FCFLAGS, CXXFLAGS, CPPFLAGS, and LDFLAGS as well. -AM_CFLAGS = @AM_CFLAGS@ @H5_CFLAGS@ +AM_CFLAGS = @AM_CFLAGS@ @H5_CFLAGS@ @H5_ECFLAGS@ # Include src and tools/lib directories AM_CPPFLAGS = @AM_CPPFLAGS@ @H5_CPPFLAGS@ -I$(top_srcdir)/src \ -I$(top_srcdir)/tools/lib -AM_CXXFLAGS = @AM_CXXFLAGS@ @H5_CXXFLAGS@ +AM_CXXFLAGS = @AM_CXXFLAGS@ @H5_CXXFLAGS@ @H5_ECXXFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AM_FCFLAGS = @AM_FCFLAGS@ @H5_FCFLAGS@ AM_LDFLAGS = @AM_LDFLAGS@ @H5_LDFLAGS@ @@ -451,6 +453,7 @@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CC_VERSION = @CC_VERSION@ CFLAGS = @CFLAGS@ +CLANG_SANITIZE_CHECKS = @CLANG_SANITIZE_CHECKS@ CLEARFILEBUF = @CLEARFILEBUF@ CODESTACK = @CODESTACK@ CONFIG_DATE = @CONFIG_DATE@ @@ -469,6 +472,7 @@ DEFAULT_API_VERSION = @DEFAULT_API_VERSION@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DEPRECATED_SYMBOLS = @DEPRECATED_SYMBOLS@ +DEV_WARNINGS = @DEV_WARNINGS@ DIRECT_VFD = @DIRECT_VFD@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ @@ -496,6 +500,8 @@ GREP = @GREP@ H5_CFLAGS = @H5_CFLAGS@ H5_CPPFLAGS = @H5_CPPFLAGS@ H5_CXXFLAGS = @H5_CXXFLAGS@ +H5_ECFLAGS = @H5_ECFLAGS@ +H5_ECXXFLAGS = @H5_ECXXFLAGS@ H5_FCFLAGS = @H5_FCFLAGS@ H5_FORTRAN_SHARED = @H5_FORTRAN_SHARED@ H5_LDFLAGS = @H5_LDFLAGS@ @@ -503,9 +509,12 @@ H5_VERSION = @H5_VERSION@ HADDR_T = @HADDR_T@ HAVE_DMALLOC = @HAVE_DMALLOC@ HAVE_FORTRAN_2003 = @HAVE_FORTRAN_2003@ +HAVE_LIBHDFS = @HAVE_LIBHDFS@ HAVE_PTHREAD = @HAVE_PTHREAD@ HDF5_HL = @HDF5_HL@ HDF5_INTERFACES = @HDF5_INTERFACES@ +HDF5_TESTS = @HDF5_TESTS@ +HDF5_TOOLS = @HDF5_TOOLS@ HDF_CXX = @HDF_CXX@ HDF_FORTRAN = @HDF_FORTRAN@ HDF_FORTRAN2003 = @HDF_FORTRAN2003@ @@ -521,6 +530,7 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INSTRUMENT = @INSTRUMENT@ INSTRUMENT_LIBRARY = @INSTRUMENT_LIBRARY@ +JNI_LDFLAGS = @JNI_LDFLAGS@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ @@ -542,6 +552,7 @@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJECT_NAMELEN_DEFAULT_F = @OBJECT_NAMELEN_DEFAULT_F@ OBJEXT = @OBJEXT@ +OPTIMIZATION = @OPTIMIZATION@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ @@ -554,8 +565,10 @@ PACKAGE_VERSION = @PACKAGE_VERSION@ PARALLEL = @PARALLEL@ PATH_SEPARATOR = @PATH_SEPARATOR@ PERL = @PERL@ +PROFILING = @PROFILING@ RANLIB = @RANLIB@ ROOT = @ROOT@ +ROS3_VFD = @ROS3_VFD@ RUNPARALLEL = @RUNPARALLEL@ RUNSERIAL = @RUNSERIAL@ R_INTEGER = @R_INTEGER@ @@ -569,6 +582,7 @@ STATIC_EXEC = @STATIC_EXEC@ STATIC_SHARED = @STATIC_SHARED@ STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ +SYMBOLS = @SYMBOLS@ TESTPARALLEL = @TESTPARALLEL@ THREADSAFE = @THREADSAFE@ TIME = @TIME@ @@ -610,6 +624,7 @@ docdir = $(exec_prefix)/doc dvidir = @dvidir@ enable_shared = @enable_shared@ enable_static = @enable_static@ +examplesdir = @examplesdir@ exec_prefix = @exec_prefix@ fortran_linux_linker_option = @fortran_linux_linker_option@ host = @host@ @@ -701,14 +716,18 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog *.clog2 *.h5 expect_sorted \ # Always build and test h5diff but build and test ph5diff only if parallel # is enabled. @BUILD_PARALLEL_CONDITIONAL_TRUE@H5PDIFF = ph5diff -@BUILD_PARALLEL_CONDITIONAL_TRUE@TEST_SCRIPT_PARA = testph5diff.sh +@BUILD_PARALLEL_CONDITIONAL_TRUE@@BUILD_TESTS_PARALLEL_CONDITIONAL_FALSE@TEST_SCRIPT_PARA = +@BUILD_PARALLEL_CONDITIONAL_TRUE@@BUILD_TESTS_PARALLEL_CONDITIONAL_TRUE@TEST_SCRIPT_PARA = testph5diff.sh # Add h5diff specific linker flags here h5diff_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS) +@BUILD_TESTS_CONDITIONAL_FALSE@TEST_PROG = # Test programs and scripts -TEST_PROG = h5diffgentest -TEST_SCRIPT = testh5diff.sh $(am__append_1) +@BUILD_TESTS_CONDITIONAL_TRUE@TEST_PROG = h5diffgentest +@BUILD_TESTS_CONDITIONAL_FALSE@TEST_SCRIPT = +@BUILD_TESTS_CONDITIONAL_TRUE@TEST_SCRIPT = testh5diff.sh \ +@BUILD_TESTS_CONDITIONAL_TRUE@ $(am__append_1) check_SCRIPTS = $(TEST_SCRIPT) $(TEST_SCRIPT_PARA) # The parallel test script testph5diff.sh actually depends on testh5diff.sh. SCRIPT_DEPEND = h5diff$(EXEEXT) $(H5PDIFF) testh5diff.sh @@ -716,7 +735,6 @@ SCRIPT_DEPEND = h5diff$(EXEEXT) $(H5PDIFF) testh5diff.sh # Source files for the program h5diff_SOURCES = h5diff_main.c h5diff_common.c ph5diff_SOURCES = ph5diff_main.c h5diff_common.c -h5diffgentest_SOURCES = h5diffgentest.c # Programs depend on the main HDF5 library and tools library LDADD = $(LIBH5TOOLS) $(LIBHDF5) @@ -725,11 +743,11 @@ LDADD = $(LIBH5TOOLS) $(LIBHDF5) @HAVE_SHARED_CONDITIONAL_TRUE@@NOT_UNAME_CYGWIN_TRUE@libdynlibdiff_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere DISTCLEANFILES = h5diff_plugin.sh -# Automake needs to be taught how to build lib, dyn, progs, and tests targets. +# Automake needs to be taught how to build lib, progs and tests targets. # These will be filled in automatically for the most part (e.g., # lib_LIBRARIES are built for lib target), but EXTRA_LIB, EXTRA_PROG, and # EXTRA_TEST variables are supplied to allow the user to force targets to -# be built at certain times. +# be built at certain times. LIB = $(lib_LIBRARIES) $(lib_LTLIBRARIES) $(noinst_LIBRARIES) \ $(noinst_LTLIBRARIES) $(check_LIBRARIES) $(check_LTLIBRARIES) $(EXTRA_LIB) @@ -1291,11 +1309,13 @@ uninstall-am: uninstall-binPROGRAMS help: @$(top_srcdir)/bin/makehelp +@BUILD_TESTS_CONDITIONAL_TRUE@ h5diffgentest_SOURCES=h5diffgentest.c @HAVE_SHARED_CONDITIONAL_TRUE@@NOT_UNAME_CYGWIN_TRUE@ # Build it as shared library if configure is enabled for shared library. @HAVE_SHARED_CONDITIONAL_TRUE@@NOT_UNAME_CYGWIN_TRUE@libdynlibdiff.la: $(libdynlibdiff_la_OBJECTS) $(libdynlibdiff_la_DEPENDENCIES) $(EXTRA_libdynlibdiff_la_DEPENDENCIES) @HAVE_SHARED_CONDITIONAL_TRUE@@NOT_UNAME_CYGWIN_TRUE@ $(AM_V_CCLD)$(libdynlibdiff_la_LINK) $(am_libdynlibdiff_la_rpath) $(libdynlibdiff_la_OBJECTS) $(libdynlibdiff_la_LIBADD) + # lib/progs/tests targets recurse into subdirectories. build-* targets # build files in this directory. build-lib: $(LIB) @@ -1331,7 +1351,7 @@ all-local: $(EXTRA_LIB) $(EXTRA_PROG) $(chk_TESTS) # make install-doc doesn't do anything outside of doc directory, but # Makefiles should recognize it. # UPDATE: docs no longer reside in this build tree, so this target -# is depreciated. +# is deprecated. install-doc uninstall-doc: @echo "Nothing to be done." @@ -1492,7 +1512,7 @@ build-check-p: $(LIB) $(PROGS) $(chk_TESTS) echo "**** Hint ****"; \ echo "Parallel test files reside in the current directory" \ "by default."; \ - echo "Set HDF5_PARAPREFIX to use another directory. E.g.,"; \ + echo "Set HDF5_PARAPREFIX to use another directory. e.g.,"; \ echo " HDF5_PARAPREFIX=/PFS/user/me"; \ echo " export HDF5_PARAPREFIX"; \ echo " make check"; \ diff --git a/tools/h5diff/dynlib_diff.c b/tools/h5diff/dynlib_diff.c index 571452e..4568ca1 100644 --- a/tools/h5diff/dynlib_diff.c +++ b/tools/h5diff/dynlib_diff.c @@ -5,7 +5,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -17,25 +17,33 @@ #include <stdio.h> #include "H5PLextern.h" -#define H5Z_FILTER_DYNLIBUD 300 -#define MULTIPLIER 3 +#define H5Z_FILTER_DYNLIBUD 300 +#define MULTIPLIER 3 -static size_t H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); +static size_t H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, + size_t nbytes, size_t *buf_size, void **buf); /* This message derives from H5Z */ const H5Z_class2_t H5Z_DYNLIBUD[1] = {{ H5Z_CLASS_T_VERS, /* H5Z_class_t version */ H5Z_FILTER_DYNLIBUD, /* Filter id number */ 1, 1, /* Encoding and decoding enabled */ - "dynlibud", /* Filter name for debugging */ + "dynlibud", /* Filter name for debugging */ NULL, /* The "can apply" callback */ NULL, /* The "set local" callback */ - (H5Z_func_t)H5Z_filter_dynlibud, /* The actual filter function */ + (H5Z_func_t)H5Z_filter_dynlibud, /* The actual filter function */ }}; -H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} -const void *H5PLget_plugin_info(void) {return H5Z_DYNLIBUD;} +H5PL_type_t +H5PLget_plugin_type(void) +{ + return H5PL_TYPE_FILTER; +} +const void * +H5PLget_plugin_info(void) +{ + return H5Z_DYNLIBUD; +} /*------------------------------------------------------------------------- * Function: H5Z_filter_dynlibud @@ -51,39 +59,37 @@ const void *H5PLget_plugin_info(void) {return H5Z_DYNLIBUD;} *------------------------------------------------------------------------- */ static size_t -H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, - size_t *buf_size, void **buf) +H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, + size_t *buf_size, void **buf) { - char *int_ptr = (char *)*buf; /* Pointer to the data values */ - size_t buf_left = *buf_size; /* Amount of data buffer left to process */ + char * int_ptr = (char *)*buf; /* Pointer to the data values */ + size_t buf_left = *buf_size; /* Amount of data buffer left to process */ /* Check for the correct number of parameters */ - if(cd_nelmts > 0) - return(0); + if (cd_nelmts > 0) + return (0); /* Assignment to eliminate unused parameter warning. */ cd_values = cd_values; - if(flags & H5Z_FLAG_REVERSE) { /*read*/ + if (flags & H5Z_FLAG_REVERSE) { /*read*/ /* Subtract the original value with MULTIPLIER */ - while(buf_left > 0) { + while (buf_left > 0) { char temp = *int_ptr; - *int_ptr = temp - MULTIPLIER; + *int_ptr = (int8_t)(temp - MULTIPLIER); int_ptr++; buf_left -= sizeof(*int_ptr); - } /* end while */ - } /* end if */ + } /* end while */ + } /* end if */ else { /*write*/ /* Add the original value with MULTIPLIER */ - while(buf_left > 0) { + while (buf_left > 0) { char temp = *int_ptr; - *int_ptr = temp + MULTIPLIER; + *int_ptr = (int8_t)(temp + MULTIPLIER); int_ptr++; buf_left -= sizeof(*int_ptr); } /* end while */ - } /* end else */ + } /* end else */ return nbytes; } /* end H5Z_filter_dynlibud() */ - diff --git a/tools/h5diff/h5diff_common.c b/tools/h5diff/h5diff_common.c index 6221843..09ff30d 100644 --- a/tools/h5diff/h5diff_common.c +++ b/tools/h5diff/h5diff_common.c @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -17,33 +17,31 @@ #include "h5tools.h" #include "h5tools_utils.h" -static int check_n_input(const char*); -static int check_p_input(const char*); -static int check_d_input(const char*); +static int check_n_input(const char *); +static int check_p_input(const char *); +static int check_d_input(const char *); /* * Command-line options: The user can specify short or long-named * parameters. */ -static const char *s_opts = "hVrv:qn:d:p:NcelxE:S"; -static struct long_options l_opts[] = { - { "help", no_arg, 'h' }, - { "version", no_arg, 'V' }, - { "report", no_arg, 'r' }, - { "verbose", optional_arg, 'v' }, - { "quiet", no_arg, 'q' }, - { "count", require_arg, 'n' }, - { "delta", require_arg, 'd' }, - { "relative", require_arg, 'p' }, - { "nan", no_arg, 'N' }, - { "compare", no_arg, 'c' }, - { "use-system-epsilon", no_arg, 'e' }, - { "follow-symlinks", no_arg, 'l' }, - { "no-dangling-links", no_arg, 'x' }, - { "exclude-path", require_arg, 'E' }, - { "enable-error-stack", no_arg, 'S' }, - { NULL, 0, '\0' } -}; +static const char * s_opts = "hVrv:qn:d:p:NcelxE:S"; +static struct long_options l_opts[] = {{"help", no_arg, 'h'}, + {"version", no_arg, 'V'}, + {"report", no_arg, 'r'}, + {"verbose", optional_arg, 'v'}, + {"quiet", no_arg, 'q'}, + {"count", require_arg, 'n'}, + {"delta", require_arg, 'd'}, + {"relative", require_arg, 'p'}, + {"nan", no_arg, 'N'}, + {"compare", no_arg, 'c'}, + {"use-system-epsilon", no_arg, 'e'}, + {"follow-symlinks", no_arg, 'l'}, + {"no-dangling-links", no_arg, 'x'}, + {"exclude-path", require_arg, 'E'}, + {"enable-error-stack", no_arg, 'S'}, + {NULL, 0, '\0'}}; /*------------------------------------------------------------------------- * Function: check_options @@ -52,7 +50,8 @@ static struct long_options l_opts[] = { * *------------------------------------------------------------------------- */ -static void check_options(diff_opt_t* opts) +static void +check_options(diff_opt_t *opts) { /*-------------------------------------------------------------- * check for mutually exclusive options @@ -62,14 +61,15 @@ static void check_options(diff_opt_t* opts) * These options are mutually exclusive. */ if ((opts->d + opts->p + opts->use_system_epsilon) > 1) { - printf("%s error: -d, -p and --use-system-epsilon options are mutually-exclusive;\n", PROGRAMNAME); - printf("use no more than one.\n"); - printf("Try '-h' or '--help' option for more information or see the %s entry in the 'HDF5 Reference Manual'.\n", PROGRAMNAME); + HDprintf("%s error: -d, -p and --use-system-epsilon options are mutually-exclusive;\n", PROGRAMNAME); + HDprintf("use no more than one.\n"); + HDprintf("Try '-h' or '--help' option for more information or see the %s entry in the 'HDF5 " + "Reference Manual'.\n", + PROGRAMNAME); h5diff_exit(EXIT_FAILURE); } } - /*------------------------------------------------------------------------- * Function: parse_command_line * @@ -78,20 +78,16 @@ static void check_options(diff_opt_t* opts) *------------------------------------------------------------------------- */ -void parse_command_line(int argc, - const char* argv[], - const char** fname1, - const char** fname2, - const char** objname1, - const char** objname2, - diff_opt_t* opts) +void +parse_command_line(int argc, const char *argv[], const char **fname1, const char **fname2, + const char **objname1, const char **objname2, diff_opt_t *opts) { - int i; - int opt; + int i; + int opt; struct exclude_path_list *exclude_head, *exclude_prev, *exclude_node; /* process the command-line */ - memset(opts, 0, sizeof (diff_opt_t)); + memset(opts, 0, sizeof(diff_opt_t)); /* assume equal contents initially */ opts->contents = 1; @@ -104,7 +100,7 @@ void parse_command_line(int argc, /* initially no not-comparable. */ /**this is bad in mixing option with results**/ - opts->not_cmp=0; + opts->not_cmp = 0; /* init for exclude-path option */ exclude_head = NULL; @@ -112,152 +108,153 @@ void parse_command_line(int argc, /* parse command line options */ while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { switch ((char)opt) { - default: - usage(); - h5diff_exit(EXIT_FAILURE); - break; - - case 'h': - usage(); - h5diff_exit(EXIT_SUCCESS); - break; - - case 'V': - print_version(h5tools_getprogname()); - h5diff_exit(EXIT_SUCCESS); - break; - - case 'v': - opts->m_verbose = 1; - /* This for loop is for handling style like - * -v, -v1, --verbose, --verbose=1. - */ - for (i = 1; i < argc; i++) { - /* - * short opt - */ - if (!strcmp (argv[i], "-v")) { /* no arg */ - opt_ind--; - opts->m_verbose_level = 0; - break; - } - else if (!strncmp (argv[i], "-v", (size_t)2)) { - opts->m_verbose_level = atoi(&argv[i][2]); - break; - } + default: + usage(); + h5diff_exit(EXIT_FAILURE); + break; - /* - * long opt + case 'h': + usage(); + h5diff_exit(EXIT_SUCCESS); + break; + + case 'V': + print_version(h5tools_getprogname()); + h5diff_exit(EXIT_SUCCESS); + break; + + case 'v': + opts->m_verbose = 1; + /* This for loop is for handling style like + * -v, -v1, --verbose, --verbose=1. */ - if (!strcmp (argv[i], "--verbose")) { /* no arg */ - opts->m_verbose_level = 0; - break; - } - else if ( !strncmp (argv[i], "--verbose", (size_t)9) && argv[i][9]=='=') { - opts->m_verbose_level = atoi(&argv[i][10]); - break; + for (i = 1; i < argc; i++) { + /* + * short opt + */ + if (!strcmp(argv[i], "-v")) { /* no arg */ + opt_ind--; + opts->m_verbose_level = 0; + break; + } + else if (!strncmp(argv[i], "-v", (size_t)2)) { + opts->m_verbose_level = atoi(&argv[i][2]); + break; + } + + /* + * long opt + */ + if (!strcmp(argv[i], "--verbose")) { /* no arg */ + opts->m_verbose_level = 0; + break; + } + else if (!strncmp(argv[i], "--verbose", (size_t)9) && argv[i][9] == '=') { + opts->m_verbose_level = atoi(&argv[i][10]); + break; + } } - } - break; + break; - case 'q': - /* use quiet mode; supress the message "0 differences found" */ - opts->m_quiet = 1; - break; + case 'q': + /* use quiet mode; supress the message "0 differences found" */ + opts->m_quiet = 1; + break; - case 'r': - opts->m_report = 1; - break; + case 'r': + opts->m_report = 1; + break; - case 'l': - opts->follow_links = TRUE; - break; + case 'l': + opts->follow_links = TRUE; + break; - case 'x': - opts->no_dangle_links = 1; - break; + case 'x': + opts->no_dangle_links = 1; + break; - case 'S': - enable_error_stack = 1; - break; + case 'S': + enable_error_stack = 1; + break; - case 'E': - opts->exclude_path = 1; + case 'E': + opts->exclude_path = 1; - /* create linked list of excluding objects */ - if( (exclude_node = (struct exclude_path_list*) HDmalloc(sizeof(struct exclude_path_list))) == NULL) { - printf("Error: lack of memory!\n"); - h5diff_exit(EXIT_FAILURE); - } - - /* init */ - exclude_node->obj_path = (char*)opt_arg; - exclude_node->obj_type = H5TRAV_TYPE_UNKNOWN; - exclude_prev = exclude_head; - - if (NULL == exclude_head) { - exclude_head = exclude_node; - exclude_head->next = NULL; - } - else { - while(NULL != exclude_prev->next) - exclude_prev=exclude_prev->next; - - exclude_node->next = NULL; - exclude_prev->next = exclude_node; - } - break; - - case 'd': - opts->d=1; - - if (check_d_input(opt_arg) == - 1) { - printf("<-d %s> is not a valid option\n", opt_arg); - usage(); - h5diff_exit(EXIT_FAILURE); - } - opts->delta = atof(opt_arg); - - /* -d 0 is the same as default */ - if (H5_DBL_ABS_EQUAL(opts->delta, (double)0.0F)) - opts->d=0; - break; - - case 'p': - opts->p=1; - if (check_p_input(opt_arg) == -1) { - printf("<-p %s> is not a valid option\n", opt_arg); - usage(); - h5diff_exit(EXIT_FAILURE); - } - opts->percent = atof(opt_arg); - - /* -p 0 is the same as default */ - if (H5_DBL_ABS_EQUAL(opts->percent, (double)0.0F)) - opts->p = 0; - break; - - case 'n': - opts->n=1; - if ( check_n_input(opt_arg) == -1) { - printf("<-n %s> is not a valid option\n", opt_arg); - usage(); - h5diff_exit(EXIT_FAILURE); - } - opts->count = HDstrtoull(opt_arg, NULL, 0); - break; + /* create linked list of excluding objects */ + if ((exclude_node = (struct exclude_path_list *)HDmalloc(sizeof(struct exclude_path_list))) == + NULL) { + HDprintf("Error: lack of memory!\n"); + h5diff_exit(EXIT_FAILURE); + } + + /* init */ + exclude_node->obj_path = (char *)opt_arg; + exclude_node->obj_type = H5TRAV_TYPE_UNKNOWN; + exclude_prev = exclude_head; - case 'N': - opts->do_nans = 0; - break; + if (NULL == exclude_head) { + exclude_head = exclude_node; + exclude_head->next = NULL; + } + else { + while (NULL != exclude_prev->next) + exclude_prev = exclude_prev->next; - case 'c': - opts->m_list_not_cmp = 1; - break; + exclude_node->next = NULL; + exclude_prev->next = exclude_node; + } + break; - case 'e': - opts->use_system_epsilon = 1; - break; + case 'd': + opts->d = 1; + + if (check_d_input(opt_arg) == -1) { + HDprintf("<-d %s> is not a valid option\n", opt_arg); + usage(); + h5diff_exit(EXIT_FAILURE); + } + opts->delta = atof(opt_arg); + + /* -d 0 is the same as default */ + if (H5_DBL_ABS_EQUAL(opts->delta, (double)0.0F)) + opts->d = 0; + break; + + case 'p': + opts->p = 1; + if (check_p_input(opt_arg) == -1) { + HDprintf("<-p %s> is not a valid option\n", opt_arg); + usage(); + h5diff_exit(EXIT_FAILURE); + } + opts->percent = atof(opt_arg); + + /* -p 0 is the same as default */ + if (H5_DBL_ABS_EQUAL(opts->percent, (double)0.0F)) + opts->p = 0; + break; + + case 'n': + opts->n = 1; + if (check_n_input(opt_arg) == -1) { + HDprintf("<-n %s> is not a valid option\n", opt_arg); + usage(); + h5diff_exit(EXIT_FAILURE); + } + opts->count = HDstrtoull(opt_arg, NULL, 0); + break; + + case 'N': + opts->do_nans = 0; + break; + + case 'c': + opts->m_list_not_cmp = 1; + break; + + case 'e': + opts->use_system_epsilon = 1; + break; } } @@ -269,32 +266,29 @@ void parse_command_line(int argc, opts->exclude = exclude_head; /* check for file names to be processed */ - if (argc <= opt_ind || argv[ opt_ind + 1 ] == NULL) { + if (argc <= opt_ind || argv[opt_ind + 1] == NULL) { error_msg("missing file names\n"); usage(); h5diff_exit(EXIT_FAILURE); } - *fname1 = argv[ opt_ind ]; - *fname2 = argv[ opt_ind + 1 ]; - *objname1 = argv[ opt_ind + 2 ]; + *fname1 = argv[opt_ind]; + *fname2 = argv[opt_ind + 1]; + *objname1 = argv[opt_ind + 2]; if (*objname1 == NULL) { *objname2 = NULL; return; } - if (argv[ opt_ind + 3 ] != NULL) { - *objname2 = argv[ opt_ind + 3 ]; + if (argv[opt_ind + 3] != NULL) { + *objname2 = argv[opt_ind + 3]; } else { *objname2 = *objname1; } - - } - /*------------------------------------------------------------------------- * Function: print_info * @@ -302,30 +296,30 @@ void parse_command_line(int argc, * *------------------------------------------------------------------------- */ +void +print_info(diff_opt_t *opts) +{ + if (opts->m_quiet || opts->err_stat) + return; - void print_info(diff_opt_t* opts) - { - if (opts->m_quiet || opts->err_stat) - return; - - if (opts->cmn_objs == 0) { - printf("No common objects found. Files are not comparable.\n"); - if (!opts->m_verbose) - printf("Use -v for a list of objects.\n"); - } - - if (opts->not_cmp == 1) { - if (opts->m_list_not_cmp == 0) { - printf("--------------------------------\n"); - printf("Some objects are not comparable\n"); - printf("--------------------------------\n"); - if (opts->m_verbose) - printf("Use -c for a list of objects without details of differences.\n"); - else - printf("Use -c for a list of objects.\n"); - } - } - } + if (opts->cmn_objs == 0) { + HDprintf("No common objects found. Files are not comparable.\n"); + if (!opts->m_verbose) + HDprintf("Use -v for a list of objects.\n"); + } + + if (opts->not_cmp == 1) { + if (opts->m_list_not_cmp == 0) { + HDprintf("--------------------------------\n"); + HDprintf("Some objects are not comparable\n"); + HDprintf("--------------------------------\n"); + if (opts->m_verbose) + HDprintf("Use -c for a list of objects without details of differences.\n"); + else + HDprintf("Use -c for a list of objects.\n"); + } + } +} /*------------------------------------------------------------------------- * Function: check_n_input @@ -345,20 +339,19 @@ void parse_command_line(int argc, *------------------------------------------------------------------------- */ static int -check_n_input( const char *str ) +check_n_input(const char *str) { unsigned i; - char c; + char c; - for (i = 0; i < strlen(str); i++) { + for (i = 0; i < HDstrlen(str); i++) { c = str[i]; if (i == 0) { if (c < 49 || c > 57) /* ascii values between 1 and 9 */ return -1; } - else - if (c < 48 || c > 57) /* 0 also */ - return -1; + else if (c < 48 || c > 57) /* 0 also */ + return -1; } return 1; } @@ -379,7 +372,7 @@ check_n_input( const char *str ) *------------------------------------------------------------------------- */ static int -check_p_input( const char *str ) +check_p_input(const char *str) { double x; @@ -387,7 +380,7 @@ check_p_input( const char *str ) the atof return value on a hexadecimal input is different on some systems; we do a character check for this */ - if (strlen(str) > 2 && str[0] == '0' && str[1] == 'x') + if (HDstrlen(str) > 2 && str[0] == '0' && str[1] == 'x') return -1; x = atof(str); @@ -413,7 +406,7 @@ check_p_input( const char *str ) *------------------------------------------------------------------------- */ static int -check_d_input( const char *str ) +check_d_input(const char *str) { double x; @@ -421,7 +414,7 @@ check_d_input( const char *str ) the atof return value on a hexadecimal input is different on some systems; we do a character check for this */ - if (strlen(str) > 2 && str[0] == '0' && str[1] == 'x') + if (HDstrlen(str) > 2 && str[0] == '0' && str[1] == 'x') return -1; x = atof(str); @@ -441,155 +434,203 @@ check_d_input( const char *str ) *------------------------------------------------------------------------- */ -void usage(void) +void +usage(void) { - PRINTVALSTREAM(rawoutstream, "usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]]\n"); - PRINTVALSTREAM(rawoutstream, " file1 File name of the first HDF5 file\n"); - PRINTVALSTREAM(rawoutstream, " file2 File name of the second HDF5 file\n"); - PRINTVALSTREAM(rawoutstream, " [obj1] Name of an HDF5 object, in absolute path\n"); - PRINTVALSTREAM(rawoutstream, " [obj2] Name of an HDF5 object, in absolute path\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " OPTIONS\n"); - PRINTVALSTREAM(rawoutstream, " -h, --help\n"); - PRINTVALSTREAM(rawoutstream, " Print a usage message and exit.\n"); - PRINTVALSTREAM(rawoutstream, " -V, --version\n"); - PRINTVALSTREAM(rawoutstream, " Print version number and exit.\n"); - PRINTVALSTREAM(rawoutstream, " -r, --report\n"); - PRINTVALSTREAM(rawoutstream, " Report mode. Print differences.\n"); - PRINTVALSTREAM(rawoutstream, " -v --verbose\n"); - PRINTVALSTREAM(rawoutstream, " Verbose mode. Print differences information and list of objects.\n"); - PRINTVALSTREAM(rawoutstream, " -vN --verbose=N\n"); - PRINTVALSTREAM(rawoutstream, " Verbose mode with level. Print differences and list of objects.\n"); - PRINTVALSTREAM(rawoutstream, " Level of detail depends on value of N:\n"); - PRINTVALSTREAM(rawoutstream, " 0 : Identical to '-v' or '--verbose'.\n"); - PRINTVALSTREAM(rawoutstream, " 1 : All level 0 information plus one-line attribute\n"); - PRINTVALSTREAM(rawoutstream, " status summary.\n"); - PRINTVALSTREAM(rawoutstream, " 2 : All level 1 information plus extended attribute\n"); - PRINTVALSTREAM(rawoutstream, " status report.\n"); - PRINTVALSTREAM(rawoutstream, " -q, --quiet\n"); - PRINTVALSTREAM(rawoutstream, " Quiet mode. Do not produce output.\n"); - PRINTVALSTREAM(rawoutstream, " --enable-error-stack\n"); - PRINTVALSTREAM(rawoutstream, " Prints messages from the HDF5 error stack as they occur.\n"); - PRINTVALSTREAM(rawoutstream, " --follow-symlinks\n"); - PRINTVALSTREAM(rawoutstream, " Follow symbolic links (soft links and external links and compare the)\n"); - PRINTVALSTREAM(rawoutstream, " links' target objects.\n"); - PRINTVALSTREAM(rawoutstream, " If symbolic link(s) with the same name exist in the files being\n"); - PRINTVALSTREAM(rawoutstream, " compared, then determine whether the target of each link is an existing\n"); - PRINTVALSTREAM(rawoutstream, " object (dataset, group, or named datatype) or the link is a dangling\n"); - PRINTVALSTREAM(rawoutstream, " link (a soft or external link pointing to a target object that does\n"); - PRINTVALSTREAM(rawoutstream, " not yet exist).\n"); - PRINTVALSTREAM(rawoutstream, " - If both symbolic links are dangling links, they are treated as being\n"); - PRINTVALSTREAM(rawoutstream, " the same; by default, h5diff returns an exit code of 0.\n"); - PRINTVALSTREAM(rawoutstream, " If, however, --no-dangling-links is used with --follow-symlinks,\n"); - PRINTVALSTREAM(rawoutstream, " this situation is treated as an error and h5diff returns an\n"); - PRINTVALSTREAM(rawoutstream, " exit code of 2.\n"); - PRINTVALSTREAM(rawoutstream, " - If only one of the two links is a dangling link,they are treated as\n"); - PRINTVALSTREAM(rawoutstream, " being different and h5diff returns an exit code of 1.\n"); - PRINTVALSTREAM(rawoutstream, " If, however, --no-dangling-links is used with --follow-symlinks,\n"); - PRINTVALSTREAM(rawoutstream, " this situation is treated as an error and h5diff returns an\n"); - PRINTVALSTREAM(rawoutstream, " exit code of 2.\n"); - PRINTVALSTREAM(rawoutstream, " - If both symbolic links point to existing objects, h5diff compares the\n"); - PRINTVALSTREAM(rawoutstream, " two objects.\n"); - PRINTVALSTREAM(rawoutstream, " If any symbolic link specified in the call to h5diff does not exist,\n"); - PRINTVALSTREAM(rawoutstream, " h5diff treats it as an error and returns an exit code of 2.\n"); - PRINTVALSTREAM(rawoutstream, " --no-dangling-links\n"); - PRINTVALSTREAM(rawoutstream, " Must be used with --follow-symlinks option; otherwise, h5diff shows\n"); - PRINTVALSTREAM(rawoutstream, " error message and returns an exit code of 2.\n"); - PRINTVALSTREAM(rawoutstream, " Check for any symbolic links (soft links or external links) that do not\n"); - PRINTVALSTREAM(rawoutstream, " resolve to an existing object (dataset, group, or named datatype).\n"); - PRINTVALSTREAM(rawoutstream, " If any dangling link is found, this situation is treated as an error\n"); - PRINTVALSTREAM(rawoutstream, " and h5diff returns an exit code of 2.\n"); - PRINTVALSTREAM(rawoutstream, " -c, --compare\n"); - PRINTVALSTREAM(rawoutstream, " List objects that are not comparable\n"); - PRINTVALSTREAM(rawoutstream, " -N, --nan\n"); - PRINTVALSTREAM(rawoutstream, " Avoid NaNs detection\n"); - PRINTVALSTREAM(rawoutstream, " -n C, --count=C\n"); - PRINTVALSTREAM(rawoutstream, " Print differences up to C. C must be a positive integer.\n"); - PRINTVALSTREAM(rawoutstream, " -d D, --delta=D\n"); - PRINTVALSTREAM(rawoutstream, " Print difference if (|a-b| > D). D must be a positive number. Where a\n"); - PRINTVALSTREAM(rawoutstream, " is the data point value in file1 and b is the data point value in file2.\n"); - PRINTVALSTREAM(rawoutstream, " Can not use with '-p' or '--use-system-epsilon'.\n"); - PRINTVALSTREAM(rawoutstream, " -p R, --relative=R\n"); - PRINTVALSTREAM(rawoutstream, " Print difference if (|(a-b)/b| > R). R must be a positive number. Where a\n"); - PRINTVALSTREAM(rawoutstream, " is the data point value in file1 and b is the data point value in file2.\n"); - PRINTVALSTREAM(rawoutstream, " Can not use with '-d' or '--use-system-epsilon'.\n"); - PRINTVALSTREAM(rawoutstream, " --use-system-epsilon\n"); - PRINTVALSTREAM(rawoutstream, " Print difference if (|a-b| > EPSILON), EPSILON is system defined value. Where a\n"); - PRINTVALSTREAM(rawoutstream, " is the data point value in file1 and b is the data point value in file2.\n"); - PRINTVALSTREAM(rawoutstream, " If the system epsilon is not defined,one of the following predefined\n"); - PRINTVALSTREAM(rawoutstream, " values will be used:\n"); - PRINTVALSTREAM(rawoutstream, " FLT_EPSILON = 1.19209E-07 for floating-point type\n"); - PRINTVALSTREAM(rawoutstream, " DBL_EPSILON = 2.22045E-16 for double precision type\n"); - PRINTVALSTREAM(rawoutstream, " Can not use with '-p' or '-d'.\n"); - PRINTVALSTREAM(rawoutstream, " --exclude-path \"path\"\n"); - PRINTVALSTREAM(rawoutstream, " Exclude the specified path to an object when comparing files or groups.\n"); - PRINTVALSTREAM(rawoutstream, " If a group is excluded, all member objects will also be excluded.\n"); - PRINTVALSTREAM(rawoutstream, " The specified path is excluded wherever it occurs.\n"); - PRINTVALSTREAM(rawoutstream, " This flexibility enables the same option to exclude either objects that\n"); - PRINTVALSTREAM(rawoutstream, " exist only in one file or common objects that are known to differ.\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " When comparing files, \"path\" is the absolute path to the excluded;\n"); - PRINTVALSTREAM(rawoutstream, " object; when comparing groups, \"path\" is similar to the relative\n"); - PRINTVALSTREAM(rawoutstream, " path from the group to the excluded object. This \"path\" can be\n"); - PRINTVALSTREAM(rawoutstream, " taken from the first section of the output of the --verbose option.\n"); - PRINTVALSTREAM(rawoutstream, " For example, if you are comparing the group /groupA in two files and\n"); - PRINTVALSTREAM(rawoutstream, " you want to exclude /groupA/groupB/groupC in both files, the exclude\n"); - PRINTVALSTREAM(rawoutstream, " option would read as follows:\n"); - PRINTVALSTREAM(rawoutstream, " --exclude-path \"/groupB/groupC\"\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " If there are multiple paths to an object, only the specified path(s)\n"); - PRINTVALSTREAM(rawoutstream, " will be excluded; the comparison will include any path not explicitly\n"); - PRINTVALSTREAM(rawoutstream, " excluded.\n"); - PRINTVALSTREAM(rawoutstream, " This option can be used repeatedly to exclude multiple paths.\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - - PRINTVALSTREAM(rawoutstream, " Modes of output:\n"); - PRINTVALSTREAM(rawoutstream, " Default mode: print the number of differences found and where they occured\n"); - PRINTVALSTREAM(rawoutstream, " -r Report mode: print the above plus the differences\n"); - PRINTVALSTREAM(rawoutstream, " -v Verbose mode: print the above plus a list of objects and warnings\n"); - PRINTVALSTREAM(rawoutstream, " -q Quiet mode: do not print output\n"); - - PRINTVALSTREAM(rawoutstream, "\n"); - - PRINTVALSTREAM(rawoutstream, " File comparison:\n"); - PRINTVALSTREAM(rawoutstream, " If no objects [obj1[ obj2]] are specified, the h5diff comparison proceeds as\n"); - PRINTVALSTREAM(rawoutstream, " a comparison of the two files' root groups. That is, h5diff first compares\n"); - PRINTVALSTREAM(rawoutstream, " the names of root group members, generates a report of root group objects\n"); - PRINTVALSTREAM(rawoutstream, " that appear in only one file or in both files, and recursively compares\n"); - PRINTVALSTREAM(rawoutstream, " common objects.\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - - PRINTVALSTREAM(rawoutstream, " Object comparison:\n"); - PRINTVALSTREAM(rawoutstream, " 1) Groups\n"); - PRINTVALSTREAM(rawoutstream, " First compares the names of member objects (relative path, from the\n"); - PRINTVALSTREAM(rawoutstream, " specified group) and generates a report of objects that appear in only\n"); - PRINTVALSTREAM(rawoutstream, " one group or in both groups. Common objects are then compared recursively.\n"); - PRINTVALSTREAM(rawoutstream, " 2) Datasets\n"); - PRINTVALSTREAM(rawoutstream, " Array rank and dimensions, datatypes, and data values are compared.\n"); - PRINTVALSTREAM(rawoutstream, " 3) Datatypes\n"); - PRINTVALSTREAM(rawoutstream, " The comparison is based on the return value of H5Tequal.\n"); - PRINTVALSTREAM(rawoutstream, " 4) Symbolic links\n"); - PRINTVALSTREAM(rawoutstream, " The paths to the target objects are compared.\n"); - PRINTVALSTREAM(rawoutstream, " (The option --follow-symlinks overrides the default behavior when\n"); - PRINTVALSTREAM(rawoutstream, " symbolic links are compared.).\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - - PRINTVALSTREAM(rawoutstream, " Exit code:\n"); - PRINTVALSTREAM(rawoutstream, " 0 if no differences, 1 if differences found, 2 if error\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " Examples of use:\n"); - PRINTVALSTREAM(rawoutstream, " 1) h5diff file1 file2 /g1/dset1 /g1/dset2\n"); - PRINTVALSTREAM(rawoutstream, " Compares object '/g1/dset1' in file1 with '/g1/dset2' in file2\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " 2) h5diff file1 file2 /g1/dset1\n"); - PRINTVALSTREAM(rawoutstream, " Compares object '/g1/dset1' in both files\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " 3) h5diff file1 file2\n"); - PRINTVALSTREAM(rawoutstream, " Compares all objects in both files\n"); - PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " Notes:\n"); - PRINTVALSTREAM(rawoutstream, " file1 and file2 can be the same file.\n"); - PRINTVALSTREAM(rawoutstream, " Use h5diff file1 file1 /g1/dset1 /g1/dset2 to compare\n"); - PRINTVALSTREAM(rawoutstream, " '/g1/dset1' and '/g1/dset2' in the same file\n"); - PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, "usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]]\n"); + PRINTVALSTREAM(rawoutstream, " file1 File name of the first HDF5 file\n"); + PRINTVALSTREAM(rawoutstream, " file2 File name of the second HDF5 file\n"); + PRINTVALSTREAM(rawoutstream, " [obj1] Name of an HDF5 object, in absolute path\n"); + PRINTVALSTREAM(rawoutstream, " [obj2] Name of an HDF5 object, in absolute path\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, " OPTIONS\n"); + PRINTVALSTREAM(rawoutstream, " -h, --help\n"); + PRINTVALSTREAM(rawoutstream, " Print a usage message and exit.\n"); + PRINTVALSTREAM(rawoutstream, " -V, --version\n"); + PRINTVALSTREAM(rawoutstream, " Print version number and exit.\n"); + PRINTVALSTREAM(rawoutstream, " -r, --report\n"); + PRINTVALSTREAM(rawoutstream, " Report mode. Print differences.\n"); + PRINTVALSTREAM(rawoutstream, " -v --verbose\n"); + PRINTVALSTREAM(rawoutstream, + " Verbose mode. Print differences information and list of objects.\n"); + PRINTVALSTREAM(rawoutstream, " -vN --verbose=N\n"); + PRINTVALSTREAM(rawoutstream, + " Verbose mode with level. Print differences and list of objects.\n"); + PRINTVALSTREAM(rawoutstream, " Level of detail depends on value of N:\n"); + PRINTVALSTREAM(rawoutstream, " 0 : Identical to '-v' or '--verbose'.\n"); + PRINTVALSTREAM(rawoutstream, " 1 : All level 0 information plus one-line attribute\n"); + PRINTVALSTREAM(rawoutstream, " status summary.\n"); + PRINTVALSTREAM(rawoutstream, " 2 : All level 1 information plus extended attribute\n"); + PRINTVALSTREAM(rawoutstream, " status report.\n"); + PRINTVALSTREAM(rawoutstream, " -q, --quiet\n"); + PRINTVALSTREAM(rawoutstream, " Quiet mode. Do not produce output.\n"); + PRINTVALSTREAM(rawoutstream, " --enable-error-stack\n"); + PRINTVALSTREAM(rawoutstream, + " Prints messages from the HDF5 error stack as they occur.\n"); + PRINTVALSTREAM(rawoutstream, " --follow-symlinks\n"); + PRINTVALSTREAM(rawoutstream, + " Follow symbolic links (soft links and external links and compare the)\n"); + PRINTVALSTREAM(rawoutstream, " links' target objects.\n"); + PRINTVALSTREAM(rawoutstream, + " If symbolic link(s) with the same name exist in the files being\n"); + PRINTVALSTREAM(rawoutstream, + " compared, then determine whether the target of each link is an existing\n"); + PRINTVALSTREAM(rawoutstream, + " object (dataset, group, or named datatype) or the link is a dangling\n"); + PRINTVALSTREAM(rawoutstream, + " link (a soft or external link pointing to a target object that does\n"); + PRINTVALSTREAM(rawoutstream, " not yet exist).\n"); + PRINTVALSTREAM(rawoutstream, + " - If both symbolic links are dangling links, they are treated as being\n"); + PRINTVALSTREAM(rawoutstream, " the same; by default, h5diff returns an exit code of 0.\n"); + PRINTVALSTREAM(rawoutstream, + " If, however, --no-dangling-links is used with --follow-symlinks,\n"); + PRINTVALSTREAM(rawoutstream, " this situation is treated as an error and h5diff returns an\n"); + PRINTVALSTREAM(rawoutstream, " exit code of 2.\n"); + PRINTVALSTREAM(rawoutstream, + " - If only one of the two links is a dangling link,they are treated as\n"); + PRINTVALSTREAM(rawoutstream, " being different and h5diff returns an exit code of 1.\n"); + PRINTVALSTREAM(rawoutstream, + " If, however, --no-dangling-links is used with --follow-symlinks,\n"); + PRINTVALSTREAM(rawoutstream, " this situation is treated as an error and h5diff returns an\n"); + PRINTVALSTREAM(rawoutstream, " exit code of 2.\n"); + PRINTVALSTREAM(rawoutstream, + " - If both symbolic links point to existing objects, h5diff compares the\n"); + PRINTVALSTREAM(rawoutstream, " two objects.\n"); + PRINTVALSTREAM(rawoutstream, + " If any symbolic link specified in the call to h5diff does not exist,\n"); + PRINTVALSTREAM(rawoutstream, " h5diff treats it as an error and returns an exit code of 2.\n"); + PRINTVALSTREAM(rawoutstream, " --no-dangling-links\n"); + PRINTVALSTREAM(rawoutstream, + " Must be used with --follow-symlinks option; otherwise, h5diff shows\n"); + PRINTVALSTREAM(rawoutstream, " error message and returns an exit code of 2.\n"); + PRINTVALSTREAM(rawoutstream, + " Check for any symbolic links (soft links or external links) that do not\n"); + PRINTVALSTREAM(rawoutstream, + " resolve to an existing object (dataset, group, or named datatype).\n"); + PRINTVALSTREAM(rawoutstream, + " If any dangling link is found, this situation is treated as an error\n"); + PRINTVALSTREAM(rawoutstream, " and h5diff returns an exit code of 2.\n"); + PRINTVALSTREAM(rawoutstream, " -c, --compare\n"); + PRINTVALSTREAM(rawoutstream, " List objects that are not comparable\n"); + PRINTVALSTREAM(rawoutstream, " -N, --nan\n"); + PRINTVALSTREAM(rawoutstream, " Avoid NaNs detection\n"); + PRINTVALSTREAM(rawoutstream, " -n C, --count=C\n"); + PRINTVALSTREAM(rawoutstream, " Print differences up to C. C must be a positive integer.\n"); + PRINTVALSTREAM(rawoutstream, " -d D, --delta=D\n"); + PRINTVALSTREAM(rawoutstream, + " Print difference if (|a-b| > D). D must be a positive number. Where a\n"); + PRINTVALSTREAM(rawoutstream, + " is the data point value in file1 and b is the data point value in file2.\n"); + PRINTVALSTREAM(rawoutstream, " Can not use with '-p' or '--use-system-epsilon'.\n"); + PRINTVALSTREAM(rawoutstream, " -p R, --relative=R\n"); + PRINTVALSTREAM(rawoutstream, + " Print difference if (|(a-b)/b| > R). R must be a positive number. Where a\n"); + PRINTVALSTREAM(rawoutstream, + " is the data point value in file1 and b is the data point value in file2.\n"); + PRINTVALSTREAM(rawoutstream, " Can not use with '-d' or '--use-system-epsilon'.\n"); + PRINTVALSTREAM(rawoutstream, " --use-system-epsilon\n"); + PRINTVALSTREAM( + rawoutstream, + " Print difference if (|a-b| > EPSILON), EPSILON is system defined value. Where a\n"); + PRINTVALSTREAM(rawoutstream, + " is the data point value in file1 and b is the data point value in file2.\n"); + PRINTVALSTREAM(rawoutstream, + " If the system epsilon is not defined,one of the following predefined\n"); + PRINTVALSTREAM(rawoutstream, " values will be used:\n"); + PRINTVALSTREAM(rawoutstream, " FLT_EPSILON = 1.19209E-07 for floating-point type\n"); + PRINTVALSTREAM(rawoutstream, " DBL_EPSILON = 2.22045E-16 for double precision type\n"); + PRINTVALSTREAM(rawoutstream, " Can not use with '-p' or '-d'.\n"); + PRINTVALSTREAM(rawoutstream, " --exclude-path \"path\"\n"); + PRINTVALSTREAM(rawoutstream, + " Exclude the specified path to an object when comparing files or groups.\n"); + PRINTVALSTREAM(rawoutstream, + " If a group is excluded, all member objects will also be excluded.\n"); + PRINTVALSTREAM(rawoutstream, " The specified path is excluded wherever it occurs.\n"); + PRINTVALSTREAM(rawoutstream, + " This flexibility enables the same option to exclude either objects that\n"); + PRINTVALSTREAM(rawoutstream, + " exist only in one file or common objects that are known to differ.\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, + " When comparing files, \"path\" is the absolute path to the excluded;\n"); + PRINTVALSTREAM(rawoutstream, + " object; when comparing groups, \"path\" is similar to the relative\n"); + PRINTVALSTREAM(rawoutstream, + " path from the group to the excluded object. This \"path\" can be\n"); + PRINTVALSTREAM(rawoutstream, + " taken from the first section of the output of the --verbose option.\n"); + PRINTVALSTREAM(rawoutstream, + " For example, if you are comparing the group /groupA in two files and\n"); + PRINTVALSTREAM(rawoutstream, + " you want to exclude /groupA/groupB/groupC in both files, the exclude\n"); + PRINTVALSTREAM(rawoutstream, " option would read as follows:\n"); + PRINTVALSTREAM(rawoutstream, " --exclude-path \"/groupB/groupC\"\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, + " If there are multiple paths to an object, only the specified path(s)\n"); + PRINTVALSTREAM(rawoutstream, + " will be excluded; the comparison will include any path not explicitly\n"); + PRINTVALSTREAM(rawoutstream, " excluded.\n"); + PRINTVALSTREAM(rawoutstream, " This option can be used repeatedly to exclude multiple paths.\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + + PRINTVALSTREAM(rawoutstream, " Modes of output:\n"); + PRINTVALSTREAM(rawoutstream, + " Default mode: print the number of differences found and where they occured\n"); + PRINTVALSTREAM(rawoutstream, " -r Report mode: print the above plus the differences\n"); + PRINTVALSTREAM(rawoutstream, " -v Verbose mode: print the above plus a list of objects and warnings\n"); + PRINTVALSTREAM(rawoutstream, " -q Quiet mode: do not print output\n"); + + PRINTVALSTREAM(rawoutstream, "\n"); + + PRINTVALSTREAM(rawoutstream, " File comparison:\n"); + PRINTVALSTREAM(rawoutstream, + " If no objects [obj1[ obj2]] are specified, the h5diff comparison proceeds as\n"); + PRINTVALSTREAM(rawoutstream, + " a comparison of the two files' root groups. That is, h5diff first compares\n"); + PRINTVALSTREAM(rawoutstream, + " the names of root group members, generates a report of root group objects\n"); + PRINTVALSTREAM(rawoutstream, + " that appear in only one file or in both files, and recursively compares\n"); + PRINTVALSTREAM(rawoutstream, " common objects.\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + + PRINTVALSTREAM(rawoutstream, " Object comparison:\n"); + PRINTVALSTREAM(rawoutstream, " 1) Groups\n"); + PRINTVALSTREAM(rawoutstream, + " First compares the names of member objects (relative path, from the\n"); + PRINTVALSTREAM(rawoutstream, + " specified group) and generates a report of objects that appear in only\n"); + PRINTVALSTREAM(rawoutstream, + " one group or in both groups. Common objects are then compared recursively.\n"); + PRINTVALSTREAM(rawoutstream, " 2) Datasets\n"); + PRINTVALSTREAM(rawoutstream, + " Array rank and dimensions, datatypes, and data values are compared.\n"); + PRINTVALSTREAM(rawoutstream, " 3) Datatypes\n"); + PRINTVALSTREAM(rawoutstream, " The comparison is based on the return value of H5Tequal.\n"); + PRINTVALSTREAM(rawoutstream, " 4) Symbolic links\n"); + PRINTVALSTREAM(rawoutstream, " The paths to the target objects are compared.\n"); + PRINTVALSTREAM(rawoutstream, " (The option --follow-symlinks overrides the default behavior when\n"); + PRINTVALSTREAM(rawoutstream, " symbolic links are compared.).\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + + PRINTVALSTREAM(rawoutstream, " Exit code:\n"); + PRINTVALSTREAM(rawoutstream, " 0 if no differences, 1 if differences found, 2 if error\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, " Examples of use:\n"); + PRINTVALSTREAM(rawoutstream, " 1) h5diff file1 file2 /g1/dset1 /g1/dset2\n"); + PRINTVALSTREAM(rawoutstream, " Compares object '/g1/dset1' in file1 with '/g1/dset2' in file2\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, " 2) h5diff file1 file2 /g1/dset1\n"); + PRINTVALSTREAM(rawoutstream, " Compares object '/g1/dset1' in both files\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, " 3) h5diff file1 file2\n"); + PRINTVALSTREAM(rawoutstream, " Compares all objects in both files\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, " Notes:\n"); + PRINTVALSTREAM(rawoutstream, " file1 and file2 can be the same file.\n"); + PRINTVALSTREAM(rawoutstream, " Use h5diff file1 file1 /g1/dset1 /g1/dset2 to compare\n"); + PRINTVALSTREAM(rawoutstream, " '/g1/dset1' and '/g1/dset2' in the same file\n"); + PRINTVALSTREAM(rawoutstream, "\n"); } diff --git a/tools/h5diff/h5diff_common.h b/tools/h5diff/h5diff_common.h index dc0676c..6594478 100644 --- a/tools/h5diff/h5diff_common.h +++ b/tools/h5diff/h5diff_common.h @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -23,9 +23,10 @@ extern "C" { #endif void usage(void); -void parse_command_line(int argc, const char* argv[], const char** fname1, const char** fname2, const char** objname1, const char** objname2, diff_opt_t* opts); +void parse_command_line(int argc, const char *argv[], const char **fname1, const char **fname2, + const char **objname1, const char **objname2, diff_opt_t *opts); void h5diff_exit(int status); -void print_info(diff_opt_t* opts); +void print_info(diff_opt_t *opts); #ifdef __cplusplus } diff --git a/tools/h5diff/h5diff_main.c b/tools/h5diff/h5diff_main.c index c5a0cbf..64f9fcf 100644 --- a/tools/h5diff/h5diff_main.c +++ b/tools/h5diff/h5diff_main.c @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -17,7 +17,6 @@ #include "h5tools.h" #include "h5tools_utils.h" - /*------------------------------------------------------------------------- * Function: main * @@ -65,20 +64,20 @@ *------------------------------------------------------------------------- */ - -int main(int argc, const char *argv[]) +int +main(int argc, const char *argv[]) { - int ret; - H5E_auto2_t func; - H5E_auto2_t tools_func; - void *edata; - void *tools_edata; - const char *fname1 = NULL; - const char *fname2 = NULL; - const char *objname1 = NULL; - const char *objname2 = NULL; - hsize_t nfound=0; - diff_opt_t opts; + int ret; + H5E_auto2_t func; + H5E_auto2_t tools_func; + void * edata; + void * tools_edata; + const char *fname1 = NULL; + const char *fname2 = NULL; + const char *objname1 = NULL; + const char *objname2 = NULL; + hsize_t nfound = 0; + diff_opt_t opts; h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); @@ -95,9 +94,9 @@ int main(int argc, const char *argv[]) H5Eset_auto2(H5tools_ERR_STACK_g, NULL, NULL); /*------------------------------------------------------------------------- - * process the command-line - *------------------------------------------------------------------------- - */ + * process the command-line + *------------------------------------------------------------------------- + */ parse_command_line(argc, argv, &fname1, &fname2, &objname1, &objname2, &opts); if (enable_error_stack > 0) { @@ -106,19 +105,19 @@ int main(int argc, const char *argv[]) } /*------------------------------------------------------------------------- - * do the diff - *------------------------------------------------------------------------- - */ + * do the diff + *------------------------------------------------------------------------- + */ nfound = h5diff(fname1, fname2, objname1, objname2, &opts); print_info(&opts); - /*------------------------------------------------------------------------- - * exit code - * 1 if differences, 0 if no differences, 2 if error - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * exit code + * 1 if differences, 0 if no differences, 2 if error + *------------------------------------------------------------------------- + */ ret = (nfound == 0 ? 0 : 1); @@ -156,4 +155,3 @@ h5diff_exit(int status) HDexit(status); } - diff --git a/tools/h5diff/h5diff_plugin.sh.in b/tools/h5diff/h5diff_plugin.sh.in index aca7c6b..832981d 100644 --- a/tools/h5diff/h5diff_plugin.sh.in +++ b/tools/h5diff/h5diff_plugin.sh.in @@ -6,7 +6,7 @@ # This file is part of HDF5. The full HDF5 copyright notice, including # terms governing use, modification, and redistribution, is contained in # the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# distribution tree, or in https://www.hdfgroup.org/licenses. # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. # @@ -61,6 +61,7 @@ LIST_HDF5_TEST_FILES=" $SRC_H5DIFF_TESTFILES/tudfilter.h5 $SRC_H5DIFF_TESTFILES/tudfilter2.h5 $SRC_H5DIFF_TESTFILES/h5diff_ud.txt +$SRC_H5DIFF_TESTFILES/h5diff_udfail.err $SRC_H5DIFF_TESTFILES/h5diff_udfail.txt " @@ -203,7 +204,7 @@ VERIFY() { TOOLTEST() { expect="$TESTDIR/$1" actual="$TESTDIR/`basename $1 .txt`.out" - actual_err="$TESTDIR/`basename $1 .txt`.err" + actual_err="$TESTDIR/`basename $1 .txt`.out.err" actual_sav=${actual}-sav actual_err_sav=${actual_err}-sav shift @@ -286,6 +287,90 @@ TOOLTEST() { rm -f $actual_sorted $expect_sorted fi } +# Same as TOOLSET except only err file checked +TOOLTEST_ERR() { + expect="$TESTDIR/$1" + expect_err="$TESTDIR/`basename $1 .txt`.err" + actual="$TESTDIR/`basename $1 .txt`.out" + actual_err="$TESTDIR/`basename $1 .txt`.out.err" + actual_sav=${actual}-sav + actual_err_sav=${actual_err}-sav + shift + if test -n "$pmode"; then + RUNCMD=$RUNPARALLEL + else + RUNCMD=$RUNSERIAL + fi + + # Run test. + TESTING $H5DIFF $@ + ( + #echo "#############################" + #echo "Expected output for '$H5DIFF $@'" + #echo "#############################" + cd $TESTDIR + eval $ENVCMD $RUNCMD $H5DIFF_BIN "$@" + ) >$actual 2>$actual_err + EXIT_CODE=$? + # save actual and actual_err in case they are needed later. + cp $actual $actual_sav + STDOUT_FILTER $actual + cp $actual_err $actual_err_sav + STDERR_FILTER $actual_err + # don't add exit code check in pmode, as it causes failure. (exit code + # is from mpirun not tool) + # if any problem occurs relate to an exit code, it will be caught in + # serial mode, so the test is fullfilled. + if test $h5haveexitcode = 'yes' -a -z "$pmode"; then + echo "EXIT CODE: $EXIT_CODE" >> $actual + fi + + if [ ! -f $expect ]; then + # Create the expect file if it doesn't yet exist. + echo " CREATED" + cp $actual $expect + echo " Expected result (*.ddl) missing" + nerrors="`expr $nerrors + 1`" + elif $CMP $expect_err $actual_err; then + echo " PASSED" + elif test $h5haveexitcode = 'yes' -a -z "$pmode"; then + echo "*FAILED*" + echo " Expected result ($expect_err) differs from actual result ($actual_err)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expect_err $actual_err |sed 's/^/ /' + else + # parallel mode output are often of different ordering from serial + # output. If the sorted expect_err and actual_err files compare the same, + # it is safe to assume the actual output match the expected file. + expect_sorted=expect_sorted + actual_sorted=actual_sorted + sort $expect_err -o $expect_sorted + sort $actual_err -o $actual_sorted + mv $expect_sorted.noexit $expect_sorted + if $CMP $expect_sorted $actual_sorted; then + echo " PASSED" + else + echo "*FAILED*" + nerrors="`expr $nerrors + 1`" + if test yes = "$verbose"; then + echo "====Expected result ($expect_sorted) differs from actual result ($actual_sorted)" + $DIFF $expect_sorted $actual_sorted |sed 's/^/ /' + echo "====The actual output ($actual_sav)" + sed 's/^/ /' < $actual_sav + echo "====The actual stderr ($actual_err_sav)" + sed 's/^/ /' < $actual_err_sav + echo "====End of actual stderr ($actual_err_sav)" + echo "" + fi + fi + fi + + # Clean up output file + if test -z "$HDF5_NOCLEANUP"; then + rm -f $actual $actual_err $actual_sav $actual_err_sav + rm -f $actual_sorted $expect_sorted + fi +} ############################################################################## ### T H E T E S T S diff --git a/tools/h5diff/h5diffgentest.c b/tools/h5diff/h5diffgentest.c index 2955d2c..f3b5304 100644 --- a/tools/h5diff/h5diffgentest.c +++ b/tools/h5diff/h5diffgentest.c @@ -6,13 +6,11 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include <stdio.h> -#include <stdlib.h> #include "hdf5.h" #include "H5private.h" @@ -40,56 +38,56 @@ size_t H5TOOLS_MALLOCSIZE = (128 * 1024 * 1024); *------------------------------------------------------------------------- */ -#define FILE1 "h5diff_basic1.h5" -#define FILE2 "h5diff_basic2.h5" -#define FILE3 "h5diff_types.h5" -#define FILE4 "h5diff_dtypes.h5" -#define FILE5 "h5diff_attr1.h5" -#define FILE6 "h5diff_attr2.h5" -#define FILE6a "h5diff_attr3.h5" -#define FILE7 "h5diff_dset1.h5" -#define FILE8 "h5diff_dset2.h5" -#define FILE8A "h5diff_dset3.h5" -#define FILE9 "h5diff_hyper1.h5" -#define FILE10 "h5diff_hyper2.h5" -#define FILE11 "h5diff_empty.h5" -#define FILE12 "h5diff_links.h5" -#define FILE13 "h5diff_softlinks.h5" -#define FILE14 "h5diff_linked_softlink.h5" -#define FILE15 "h5diff_extlink_src.h5" -#define FILE16 "h5diff_extlink_trg.h5" -#define FILE17 "h5diff_ext2softlink_src.h5" -#define FILE18 "h5diff_ext2softlink_trg.h5" -#define FILE19 "h5diff_dset_zero_dim_size1.h5" -#define FILE20 "h5diff_dset_zero_dim_size2.h5" -#define DANGLE_LINK_FILE1 "h5diff_danglelinks1.h5" -#define DANGLE_LINK_FILE2 "h5diff_danglelinks2.h5" -#define GRP_RECURSE_FILE1 "h5diff_grp_recurse1.h5" -#define GRP_RECURSE_FILE2 "h5diff_grp_recurse2.h5" +#define FILE1 "h5diff_basic1.h5" +#define FILE2 "h5diff_basic2.h5" +#define FILE3 "h5diff_types.h5" +#define FILE4 "h5diff_dtypes.h5" +#define FILE5 "h5diff_attr1.h5" +#define FILE6 "h5diff_attr2.h5" +#define FILE6a "h5diff_attr3.h5" +#define FILE7 "h5diff_dset1.h5" +#define FILE8 "h5diff_dset2.h5" +#define FILE8A "h5diff_dset3.h5" +#define FILE9 "h5diff_hyper1.h5" +#define FILE10 "h5diff_hyper2.h5" +#define FILE11 "h5diff_empty.h5" +#define FILE12 "h5diff_links.h5" +#define FILE13 "h5diff_softlinks.h5" +#define FILE14 "h5diff_linked_softlink.h5" +#define FILE15 "h5diff_extlink_src.h5" +#define FILE16 "h5diff_extlink_trg.h5" +#define FILE17 "h5diff_ext2softlink_src.h5" +#define FILE18 "h5diff_ext2softlink_trg.h5" +#define FILE19 "h5diff_dset_zero_dim_size1.h5" +#define FILE20 "h5diff_dset_zero_dim_size2.h5" +#define DANGLE_LINK_FILE1 "h5diff_danglelinks1.h5" +#define DANGLE_LINK_FILE2 "h5diff_danglelinks2.h5" +#define GRP_RECURSE_FILE1 "h5diff_grp_recurse1.h5" +#define GRP_RECURSE_FILE2 "h5diff_grp_recurse2.h5" /* same structure via external links through files */ -#define GRP_RECURSE1_EXT "h5diff_grp_recurse_ext1.h5" -#define GRP_RECURSE2_EXT1 "h5diff_grp_recurse_ext2-1.h5" -#define GRP_RECURSE2_EXT2 "h5diff_grp_recurse_ext2-2.h5" -#define GRP_RECURSE2_EXT3 "h5diff_grp_recurse_ext2-3.h5" +#define GRP_RECURSE1_EXT "h5diff_grp_recurse_ext1.h5" +#define GRP_RECURSE2_EXT1 "h5diff_grp_recurse_ext2-1.h5" +#define GRP_RECURSE2_EXT2 "h5diff_grp_recurse_ext2-2.h5" +#define GRP_RECURSE2_EXT3 "h5diff_grp_recurse_ext2-3.h5" /* same structure, same obj name with different value */ -#define EXCLUDE_FILE1_1 "h5diff_exclude1-1.h5" -#define EXCLUDE_FILE1_2 "h5diff_exclude1-2.h5" +#define EXCLUDE_FILE1_1 "h5diff_exclude1-1.h5" +#define EXCLUDE_FILE1_2 "h5diff_exclude1-2.h5" /* different structure and obj names */ -#define EXCLUDE_FILE2_1 "h5diff_exclude2-1.h5" -#define EXCLUDE_FILE2_2 "h5diff_exclude2-2.h5" +#define EXCLUDE_FILE2_1 "h5diff_exclude2-1.h5" +#define EXCLUDE_FILE2_2 "h5diff_exclude2-2.h5" /* only one file has unique objs */ -#define EXCLUDE_FILE3_1 "h5diff_exclude3-1.h5" -#define EXCLUDE_FILE3_2 "h5diff_exclude3-2.h5" +#define EXCLUDE_FILE3_1 "h5diff_exclude3-1.h5" +#define EXCLUDE_FILE3_2 "h5diff_exclude3-2.h5" /* compound type with multiple vlen string types */ -#define COMP_VL_STRS_FILE "h5diff_comp_vl_strs.h5" +#define COMP_VL_STRS_FILE "h5diff_comp_vl_strs.h5" /* attribute compre with verbose level */ #define ATTR_VERBOSE_LEVEL_FILE1 "h5diff_attr_v_level1.h5" #define ATTR_VERBOSE_LEVEL_FILE2 "h5diff_attr_v_level2.h5" /* file containing valid/invalid enum value mix */ #define ENUM_INVALID_VALUES "h5diff_enum_invalid_values.h5" /* file with container types (array,vlen) with multiple compounds */ -#define COMPS_COMPLEX1 "compounds_array_vlen1.h5" -#define COMPS_COMPLEX2 "compounds_array_vlen2.h5" +#define COMPS_COMPLEX1 "compounds_array_vlen1.h5" +#define COMPS_COMPLEX2 "compounds_array_vlen2.h5" /* non-comparable dataset and attribute */ #define NON_COMPARBLES1 "non_comparables1.h5" #define NON_COMPARBLES2 "non_comparables2.h5" @@ -99,7 +97,7 @@ size_t H5TOOLS_MALLOCSIZE = (128 * 1024 * 1024); #define UIMAX 4294967295u /*Maximum value for a variable of type unsigned int */ #define STR_SIZE 3 -#define GBLL ((unsigned long long) 1024 * 1024 *1024 ) +#define GBLL ((unsigned long long)1024 * 1024 * 1024) #define MY_LINKCLASS 187 @@ -108,23 +106,33 @@ size_t H5TOOLS_MALLOCSIZE = (128 * 1024 * 1024); #define SPACE1_DIM1 0 #define SPACE1_DIM2 0 +/* Error macros */ +#define AT() HDprintf("ERROR at %s:%d in %s()...\n", __FILE__, __LINE__, FUNC); +#define PROGRAM_ERROR \ + { \ + AT(); \ + goto error; \ + } + /* A UD link traversal function. Shouldn't actually be called. */ -static hid_t UD_traverse(H5_ATTR_UNUSED const char * link_name, - H5_ATTR_UNUSED hid_t cur_group, H5_ATTR_UNUSED const void * udata, - H5_ATTR_UNUSED size_t udata_size, H5_ATTR_UNUSED hid_t lapl_id) { +static hid_t +UD_traverse(H5_ATTR_UNUSED const char *link_name, H5_ATTR_UNUSED hid_t cur_group, + H5_ATTR_UNUSED const void *udata, H5_ATTR_UNUSED size_t udata_size, H5_ATTR_UNUSED hid_t lapl_id) +{ return -1; } -const H5L_class_t UD_link_class[1] = { { - H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ - (H5L_type_t) MY_LINKCLASS, /* Link type id number */ - "UD link class", /* name for debugging */ - NULL, /* Creation callback */ - NULL, /* Move/rename callback */ - NULL, /* Copy callback */ - UD_traverse, /* The actual traversal function */ - NULL, /* Deletion callback */ - NULL /* Query callback */ -} }; + +const H5L_class_t UD_link_class[1] = {{ + H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ + (H5L_type_t)MY_LINKCLASS, /* Link type id number */ + "UD link class", /* name for debugging */ + NULL, /* Creation callback */ + NULL, /* Move/rename callback */ + NULL, /* Copy callback */ + UD_traverse, /* The actual traversal function */ + NULL, /* Deletion callback */ + NULL /* Query callback */ +}}; /*------------------------------------------------------------------------- * prototypes @@ -132,47 +140,46 @@ const H5L_class_t UD_link_class[1] = { { */ /* tests called in main() */ -static int test_basic(const char *fname1, const char *fname2, const char *fname3); -static int test_types(const char *fname); -static int test_datatypes(const char *fname); -static int test_attributes(const char *fname, int make_diffs); -static int test_datasets(const char *fname, int make_diffs); -static int test_special_datasets(const char *fname, int make_diffs); -static int test_hyperslab(const char *fname, int make_diffs); -static int test_link_name(const char *fname1); -static int test_soft_links(const char *fname1); -static int test_linked_softlinks(const char *fname1); -static int test_external_links(const char *fname1, const char *fname2); -static int test_ext2soft_links(const char *fname1, const char *fname2); -static int test_dangle_links(const char *fname1, const char *fname2); -static int test_group_recurse(const char *fname1, const char *fname2); -static int test_group_recurse2(void); -static int test_exclude_obj1(const char *fname1, const char *fname2); -static int test_exclude_obj2(const char *fname1, const char *fname2); -static int test_exclude_obj3(const char *fname1, const char *fname2); -static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int is_file_new); -static int test_attributes_verbose_level(const char *fname1, const char *fname2); -static int test_enums(const char *fname); -static void test_comps_array(const char *fname, const char *dset, - const char *attr, int diff, int is_file_new); -static void test_comps_vlen(const char *fname, const char *dset, - const char *attr, int diff, int is_file_new); -static void test_comps_array_vlen(const char *fname, const char *dset, - const char *attr, int diff, int is_file_new); -static void test_comps_vlen_arry(const char *fname, const char *dset, - const char *attr, int diff, int is_file_new); +static int test_basic(const char *fname1, const char *fname2, const char *fname3); +static int test_types(const char *fname); +static int test_datatypes(const char *fname); +static int test_attributes(const char *fname, int make_diffs); +static int test_datasets(const char *fname, int make_diffs); +static int test_special_datasets(const char *fname, int make_diffs); +static int test_hyperslab(const char *fname, int make_diffs); +static int test_link_name(const char *fname1); +static int test_soft_links(const char *fname1); +static int test_linked_softlinks(const char *fname1); +static int test_external_links(const char *fname1, const char *fname2); +static int test_ext2soft_links(const char *fname1, const char *fname2); +static int test_dangle_links(const char *fname1, const char *fname2); +static int test_group_recurse(const char *fname1, const char *fname2); +static int test_group_recurse2(void); +static int test_exclude_obj1(const char *fname1, const char *fname2); +static int test_exclude_obj2(const char *fname1, const char *fname2); +static int test_exclude_obj3(const char *fname1, const char *fname2); +static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int is_file_new); +static int test_attributes_verbose_level(const char *fname1, const char *fname2); +static int test_enums(const char *fname); +static void test_comps_array(const char *fname, const char *dset, const char *attr, int diff, + int is_file_new); +static void test_comps_vlen(const char *fname, const char *dset, const char *attr, int diff, int is_file_new); +static void test_comps_array_vlen(const char *fname, const char *dset, const char *attr, int diff, + int is_file_new); +static void test_comps_vlen_arry(const char *fname, const char *dset, const char *attr, int diff, + int is_file_new); static void test_data_nocomparables(const char *fname, int diff); static void test_objs_nocomparables(const char *fname1, const char *fname2); static void test_objs_strings(const char *fname, const char *fname2); /* called by test_attributes() and test_datasets() */ -static void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make_diffs); -static void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diffs); -static void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diffs); +static void write_attr_strings(hid_t loc_id, const char *dset_name, hid_t fid, int make_diffs); +static void write_attr_in(hid_t loc_id, const char *dset_name, hid_t fid, int make_diffs); +static void write_dset_in(hid_t loc_id, const char *dset_name, hid_t fid, int make_diffs); static void gen_datareg(hid_t fid, int make_diffs); /* utilities */ -static int write_attr(hid_t loc_id, int rank, hsize_t *dims, const char *name, hid_t tid, void *buf); -static int write_dset(hid_t loc_id, int rank, hsize_t *dims, const char *name, hid_t tid, void *buf); +static int write_attr(hid_t loc_id, int rank, hsize_t *dims, const char *name, hid_t tid, void *buf); +static herr_t write_dset(hid_t loc_id, int rank, hsize_t *dims, const char *name, hid_t tid, void *buf); /*------------------------------------------------------------------------- * Function: main @@ -182,7 +189,8 @@ static int write_dset(hid_t loc_id, int rank, hsize_t *dims, const char *name, h *------------------------------------------------------------------------- */ -int main(void) +int +main(void) { test_basic(FILE1, FILE2, FILE11); @@ -235,16 +243,16 @@ int main(void) test_comp_vlen_strings(COMP_VL_STRS_FILE, "group_copy", 0); /* diff when invalid enum values are present. - * This will probably grow to involve more extensive testing of - * enums so it has been given its own test file and test (apart - * from the basic type testing). - */ + * This will probably grow to involve more extensive testing of + * enums so it has been given its own test file and test (apart + * from the basic type testing). + */ test_enums(ENUM_INVALID_VALUES); /* ------------------------------------------------- - * Create test files with dataset and attribute with container types - * (array, vlen) with multiple nested compound types. - */ + * Create test files with dataset and attribute with container types + * (array, vlen) with multiple nested compound types. + */ /* file1 */ test_comps_array(COMPS_COMPLEX1, "dset1", "attr1", 0, 1); test_comps_vlen(COMPS_COMPLEX1, "dset2", "attr2", 0, 0); @@ -257,10 +265,10 @@ int main(void) test_comps_vlen_arry(COMPS_COMPLEX2, "dset4", "attr4", 5, 0); /*------------------------------------------------- - * Create test files with non-comparable dataset and attributes with - * comparable datasets and attributes. All the comparables should display - * differences. - */ + * Create test files with non-comparable dataset and attributes with + * comparable datasets and attributes. All the comparables should display + * differences. + */ test_data_nocomparables(NON_COMPARBLES1, 0); test_data_nocomparables(NON_COMPARBLES2, 5); @@ -270,7 +278,7 @@ int main(void) /* string dataset and attribute. HDFFV-10028 */ test_objs_strings(DIFF_STRINGS1, DIFF_STRINGS2); - return 0; + return EXIT_SUCCESS; } /*------------------------------------------------------------------------- @@ -282,28 +290,28 @@ int main(void) *------------------------------------------------------------------------- */ -static -int test_basic(const char *fname1, const char *fname2, const char *fname3) +static int +test_basic(const char *fname1, const char *fname2, const char *fname3) { - hid_t fid1 = -1, fid2 = -1; - hid_t gid1 = -1, gid2 = -1, gid3 = -1; - hsize_t dims1[1] = { 6 }; - hsize_t dims2[2] = { 3, 2 }; + hid_t fid1 = -1, fid2 = H5I_INVALID_HID; + hid_t gid1 = -1, gid2 = -1, gid3 = H5I_INVALID_HID; + hsize_t dims1[1] = {6}; + hsize_t dims2[2] = {3, 2}; /* create the empty file */ if ((fid1 = H5Fcreate(fname3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - fprintf(stderr, "empty file (%s) creation failed.\n", fname3); + HDfprintf(stderr, "empty file (%s) creation failed.\n", fname3); goto out; } if (H5Fclose(fid1) < 0) { - fprintf(stderr, "empty file (%s) close failed.\n", fname3); + HDfprintf(stderr, "empty file (%s) close failed.\n", fname3); goto out; } /*------------------------------------------------------------------------- - * create two files - *------------------------------------------------------------------------- - */ + * create two files + *------------------------------------------------------------------------- + */ if ((fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; @@ -311,158 +319,141 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) goto out; /*------------------------------------------------------------------------- - * create groups - *------------------------------------------------------------------------- - */ + * create groups + *------------------------------------------------------------------------- + */ gid1 = H5Gcreate2(fid1, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); gid2 = H5Gcreate2(fid2, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); gid3 = H5Gcreate2(fid2, "g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /*------------------------------------------------------------------------- - * tests: - * # 1.1 normal mode - * # 1.2 normal mode with objects - * # 1.3 report mode - * # 1.4 report mode with objects - * # 1.5 with -d - *------------------------------------------------------------------------- - */ + * tests: + * # 1.1 normal mode + * # 1.2 normal mode with objects + * # 1.3 report mode + * # 1.4 report mode with objects + * # 1.5 with -d + *------------------------------------------------------------------------- + */ { - double data1[3][2] = - { { 1.0F, 1.0F }, { 1.00F, 1.000F }, { 0.0F, 0.0F } }; - double data2[3][2] = - { { 0.0F, 1.1F }, { 1.01F, 1.001F }, { 0.0F, 1.0F } }; - double data3[3][2] = { { 100.0F, 100.0F }, { 100.00F, 100.000F }, { - 100.0F, 100.0F } }; - double data4[3][2] = { { 105.0F, 120.0F }, { 160.00F, 95.000F }, { - 80.0F, 40.0F } }; + double data1[3][2] = {{1.0F, 1.0F}, {1.00F, 1.000F}, {0.0F, 0.0F}}; + double data2[3][2] = {{0.0F, 1.1F}, {1.01F, 1.001F}, {0.0F, 1.0F}}; + double data3[3][2] = {{100.0F, 100.0F}, {100.00F, 100.000F}, {100.0F, 100.0F}}; + double data4[3][2] = {{105.0F, 120.0F}, {160.00F, 95.000F}, {80.0F, 40.0F}}; write_dset(gid1, 2, dims2, "dset1", H5T_NATIVE_DOUBLE, data1); write_dset(gid2, 2, dims2, "dset2", H5T_NATIVE_DOUBLE, data2); write_dset(gid1, 2, dims2, "dset3", H5T_NATIVE_DOUBLE, data3); write_dset(gid2, 2, dims2, "dset4", H5T_NATIVE_DOUBLE, data4); write_dset(gid2, 2, dims2, "dset1", H5T_NATIVE_DOUBLE, data2); - } /*------------------------------------------------------------------------- - * relative error, compare divide by zero, both zero - * # 1.6.1 with -p (int) - *------------------------------------------------------------------------- - */ + * relative error, compare divide by zero, both zero + * # 1.6.1 with -p (int) + *------------------------------------------------------------------------- + */ { - int data5[3][2] = { { 100, 100 }, { 100, 0 }, { 0, 100 } }; - int data6[3][2] = { { 120, 80 }, { 0, 100 }, { 0, 50 } }; + int data5[3][2] = {{100, 100}, {100, 0}, {0, 100}}; + int data6[3][2] = {{120, 80}, {0, 100}, {0, 50}}; write_dset(gid1, 2, dims2, "dset5", H5T_NATIVE_INT, data5); write_dset(gid1, 2, dims2, "dset6", H5T_NATIVE_INT, data6); - } /*------------------------------------------------------------------------- - * relative error, compare divide by zero, both zero - * # 1.6.2 with -p (unsigned long long) - *------------------------------------------------------------------------- - */ + * relative error, compare divide by zero, both zero + * # 1.6.2 with -p (unsigned long long) + *------------------------------------------------------------------------- + */ { - unsigned long long data7[3][2] = - { { 100, 100 }, { 100, 0 }, { 0, 100 } }; - unsigned long long data8[3][2] = { { 120, 80 }, { 0, 100 }, { 0, 50 } }; + unsigned long long data7[3][2] = {{100, 100}, {100, 0}, {0, 100}}; + unsigned long long data8[3][2] = {{120, 80}, {0, 100}, {0, 50}}; write_dset(gid1, 2, dims2, "dset7", H5T_NATIVE_ULLONG, data7); write_dset(gid1, 2, dims2, "dset8", H5T_NATIVE_ULLONG, data8); - } /*------------------------------------------------------------------------- - * relative error, compare divide by zero, both zero - * # 1.6.3 with -p (double) - * - * A B 1-B/A % - * 100 120 0.2 20 - * 100 80 0.2 20 - * 100 0 1 100 - * 0 100 #DIV/0! #DIV/0! - * 0 0 #DIV/0! #DIV/0! - * 100 50 0.5 50 - *------------------------------------------------------------------------- - */ + * relative error, compare divide by zero, both zero + * # 1.6.3 with -p (double) + * + * A B 1-B/A % + * 100 120 0.2 20 + * 100 80 0.2 20 + * 100 0 1 100 + * 0 100 #DIV/0! #DIV/0! + * 0 0 #DIV/0! #DIV/0! + * 100 50 0.5 50 + *------------------------------------------------------------------------- + */ { - double data9[3][2] = { { 100.0F, 100.0F }, { 100.0F, 0.0F }, { 0.0F, - 100.0F } }; - double data10[3][2] = { { 120.0F, 80.0F }, { 0.0F, 100.0F }, { 0.0F, - 50.0F } }; + double data9[3][2] = {{100.0F, 100.0F}, {100.0F, 0.0F}, {0.0F, 100.0F}}; + double data10[3][2] = {{120.0F, 80.0F}, {0.0F, 100.0F}, {0.0F, 50.0F}}; write_dset(gid1, 2, dims2, "dset9", H5T_NATIVE_DOUBLE, data9); write_dset(gid1, 2, dims2, "dset10", H5T_NATIVE_DOUBLE, data10); - } /*------------------------------------------------------------------------- - * test floating point comparison - *------------------------------------------------------------------------- - */ + * test floating point comparison + *------------------------------------------------------------------------- + */ { /* epsilon = 0.0000001 = 1e-7 - * system epsilon for float : FLT_EPSILON = 1.19209E-07 - */ - float data11[3][2] = { { 0.000000f, 0.0000001f }, { 0.0000001f, - 0.00000022f }, { 0.0000001f, 0.0000001f } }; - float data12[3][2] = { { 0.000000f, 0.0000002f }, { 0.0000003f, - 0.0000001f }, { 0.000000f, 0.0000001f } }; + * system epsilon for float : FLT_EPSILON = 1.19209E-07 + */ + float data11[3][2] = {{0.000000f, 0.0000001f}, {0.0000001f, 0.00000022f}, {0.0000001f, 0.0000001f}}; + float data12[3][2] = {{0.000000f, 0.0000002f}, {0.0000003f, 0.0000001f}, {0.000000f, 0.0000001f}}; /* epsilon = 0.0000000000000001 = 1e-16 - * system epsilon for double : DBL_EPSILON = 2.22045E-16 - */ - double data13[3][2] = { { H5_DOUBLE(0.0000000000000000), H5_DOUBLE( - 0.0000000000000001) }, { H5_DOUBLE(0.0000000000000001), - H5_DOUBLE(0.0000000000000000) }, { H5_DOUBLE( - 0.00000000000000033), H5_DOUBLE(0.0000000000000001) } }; - double data14[3][2] = { { H5_DOUBLE(0.0000000000000000), H5_DOUBLE( - 0.0000000000000004) }, { H5_DOUBLE(0.0000000000000002), - H5_DOUBLE(0.0000000000000001) }, { H5_DOUBLE( - 0.0000000000000001), H5_DOUBLE(0.00000000000000000) } }; + * system epsilon for double : DBL_EPSILON = 2.22045E-16 + */ + double data13[3][2] = {{H5_DOUBLE(0.0000000000000000), H5_DOUBLE(0.0000000000000001)}, + {H5_DOUBLE(0.0000000000000001), H5_DOUBLE(0.0000000000000000)}, + {H5_DOUBLE(0.00000000000000033), H5_DOUBLE(0.0000000000000001)}}; + double data14[3][2] = {{H5_DOUBLE(0.0000000000000000), H5_DOUBLE(0.0000000000000004)}, + {H5_DOUBLE(0.0000000000000002), H5_DOUBLE(0.0000000000000001)}, + {H5_DOUBLE(0.0000000000000001), H5_DOUBLE(0.00000000000000000)}}; write_dset(gid1, 2, dims2, "fp1", H5T_NATIVE_FLOAT, data11); write_dset(gid1, 2, dims2, "fp2", H5T_NATIVE_FLOAT, data12); write_dset(gid1, 2, dims2, "d1", H5T_NATIVE_DOUBLE, data13); write_dset(gid1, 2, dims2, "d2", H5T_NATIVE_DOUBLE, data14); - } -#if H5_SIZEOF_LONG_DOUBLE !=0 +#if H5_SIZEOF_LONG_DOUBLE != 0 { /*------------------------------------------------------------------------- - * H5T_NATIVE_LDOUBLE - *------------------------------------------------------------------------- - */ - - long double data15[3][2] = { {1.0L,1.0L}, {1.0L,1.0L}, {1.0L,1.0L}}; + * H5T_NATIVE_LDOUBLE + *------------------------------------------------------------------------- + */ - write_dset(gid1,2,dims2,"ld",H5T_NATIVE_LDOUBLE,data15); + long double data15[3][2] = {{1.0L, 1.0L}, {1.0L, 1.0L}, {1.0L, 1.0L}}; + write_dset(gid1, 2, dims2, "ld", H5T_NATIVE_LDOUBLE, data15); } #endif /*------------------------------------------------------------------------- - * NaNs in H5T_NATIVE_FLOAT - *------------------------------------------------------------------------- - */ + * NaNs in H5T_NATIVE_FLOAT + *------------------------------------------------------------------------- + */ { float data15[6]; float data16[6]; - data15[0] = (float) HDsqrt(-1.0F); + data15[0] = (float)HDsqrt(-1.0F); data15[1] = 1.0F; - data15[2] = (float) HDsqrt(-1.0F); + data15[2] = (float)HDsqrt(-1.0F); data15[3] = 1.0F; data15[4] = 1.0F; data15[5] = 1.0F; - data16[0] = (float) HDsqrt(-1.0F); - data16[1] = (float) HDsqrt(-1.0F); + data16[0] = (float)HDsqrt(-1.0F); + data16[1] = (float)HDsqrt(-1.0F); data16[2] = 1.0F; data16[3] = 1.0F; data16[4] = 1.0F; @@ -470,13 +461,12 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) write_dset(gid1, 1, dims1, "fp15", H5T_NATIVE_FLOAT, data15); write_dset(gid1, 1, dims1, "fp16", H5T_NATIVE_FLOAT, data16); - } /*------------------------------------------------------------------------- - * NaNs in H5T_NATIVE_DOUBLE - *------------------------------------------------------------------------- - */ + * NaNs in H5T_NATIVE_DOUBLE + *------------------------------------------------------------------------- + */ { double data17[6]; @@ -502,15 +492,15 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) } /*------------------------------------------------------------------------ - * INFINITY values - *------------------------------------------------------------------------ - */ + * INFINITY values + *------------------------------------------------------------------------ + */ { - float data19[6]; + float data19[6]; double data20[6]; - data19[0] = data19[1] = data19[2] = (float) HDlog(0.0F); - data19[3] = data19[4] = data19[5] = (float) -HDlog(0.0F); + data19[0] = data19[1] = data19[2] = (float)HDlog(0.0F); + data19[3] = data19[4] = data19[5] = (float)-HDlog(0.0F); data20[0] = data20[1] = data20[2] = HDlog(0.0F); data20[3] = data20[4] = data20[5] = -HDlog(0.0F); @@ -522,39 +512,38 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) } /*------------------------------------------------------------------------- - * NaNs in H5T_NATIVE_DOUBLE and H5T_NATIVE_FLOAT inside H5T_COMPOUND - *------------------------------------------------------------------------- - */ + * NaNs in H5T_NATIVE_DOUBLE and H5T_NATIVE_FLOAT inside H5T_COMPOUND + *------------------------------------------------------------------------- + */ { typedef struct cmp1_t { double d; - float f; + float f; } cmp1_t; - cmp1_t buf1[2]; - cmp1_t buf2[2]; - hsize_t dims[1] = { 2 }; - size_t type_size; - hid_t tid; + cmp1_t buf1[2]; + cmp1_t buf2[2]; + hsize_t dims[1] = {2}; + size_t type_size; + hid_t tid; buf1[0].d = HDsqrt(-1.0F); - buf1[0].f = (float) HDsqrt(-1.0F); + buf1[0].f = (float)HDsqrt(-1.0F); buf2[0].d = HDsqrt(-1.0F); - buf2[0].f = (float) HDsqrt(-1.0F); + buf2[0].f = (float)HDsqrt(-1.0F); buf1[1].d = HDsqrt(-1.0F); - buf1[1].f = (float) HDsqrt(-1.0F); + buf1[1].f = (float)HDsqrt(-1.0F); buf2[1].d = 0.0F; buf2[1].f = 0.0F; type_size = sizeof(cmp1_t); - tid = H5Tcreate(H5T_COMPOUND, type_size); + tid = H5Tcreate(H5T_COMPOUND, type_size); H5Tinsert(tid, "d", HOFFSET(cmp1_t, d), H5T_NATIVE_DOUBLE); H5Tinsert(tid, "f", HOFFSET(cmp1_t, f), H5T_NATIVE_FLOAT); write_dset(gid1, 1, dims, "dset11", tid, buf1); write_dset(gid1, 1, dims, "dset12", tid, buf2); H5Tclose(tid); - } /* not comparable objects */ @@ -562,11 +551,11 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) typedef struct cmp1_t { double d; - int i; + int i; } cmp1_t; typedef struct cmp2_t { - int i; + int i; double d; } cmp2_t; @@ -574,17 +563,17 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) int i; } cmp3_t; - double data2[6] = { 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F }; - int data3[6] = { 0, 0, 0, 0, 0, 0 }; - int data4[3][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 } }; - int data5[2][2] = { { 0, 0 }, { 0, 0 } }; - unsigned int data6[3][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 } }; - cmp1_t data7[1] = { { 1.0f, 2 } }; - cmp2_t data8[1] = { { 1, 2.0f } }; - hsize_t dims3[2] = { 2, 2 }; - hsize_t dims4[1] = { 1 }; - size_t type_size; - hid_t tid; + double data2[6] = {0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F}; + int data3[6] = {0, 0, 0, 0, 0, 0}; + int data4[3][2] = {{0, 0}, {0, 0}, {0, 0}}; + int data5[2][2] = {{0, 0}, {0, 0}}; + unsigned int data6[3][2] = {{0, 0}, {0, 0}, {0, 0}}; + cmp1_t data7[1] = {{1.0f, 2}}; + cmp2_t data8[1] = {{1, 2.0f}}; + hsize_t dims3[2] = {2, 2}; + hsize_t dims4[1] = {1}; + size_t type_size; + hid_t tid; write_dset(gid3, 1, dims1, "dset1", H5T_NATIVE_DOUBLE, NULL); write_dset(gid3, 1, dims1, "dset2", H5T_NATIVE_DOUBLE, data2); @@ -595,14 +584,14 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) /* case of compound with different type members */ type_size = sizeof(cmp1_t); - tid = H5Tcreate(H5T_COMPOUND, type_size); + tid = H5Tcreate(H5T_COMPOUND, type_size); H5Tinsert(tid, "d", HOFFSET(cmp1_t, d), H5T_NATIVE_DOUBLE); H5Tinsert(tid, "i", HOFFSET(cmp1_t, i), H5T_NATIVE_INT); write_dset(gid3, 1, dims4, "dset7", tid, data7); H5Tclose(tid); type_size = sizeof(cmp2_t); - tid = H5Tcreate(H5T_COMPOUND, type_size); + tid = H5Tcreate(H5T_COMPOUND, type_size); H5Tinsert(tid, "i", HOFFSET(cmp2_t, i), H5T_NATIVE_INT); H5Tinsert(tid, "d", HOFFSET(cmp2_t, d), H5T_NATIVE_DOUBLE); write_dset(gid3, 1, dims4, "dset8", tid, data8); @@ -610,17 +599,16 @@ int test_basic(const char *fname1, const char *fname2, const char *fname3) /* case of compound with different number of members */ type_size = sizeof(cmp3_t); - tid = H5Tcreate(H5T_COMPOUND, type_size); + tid = H5Tcreate(H5T_COMPOUND, type_size); H5Tinsert(tid, "i", HOFFSET(cmp2_t, i), H5T_NATIVE_INT); write_dset(gid3, 1, dims4, "dset9", tid, NULL); H5Tclose(tid); - } /*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ + * close + *------------------------------------------------------------------------- + */ H5Gclose(gid1); H5Gclose(gid2); H5Gclose(gid3); @@ -641,18 +629,18 @@ out: * *------------------------------------------------------------------------- */ -static -int test_types(const char *fname) +static int +test_types(const char *fname) { - hid_t fid1 = -1; - hid_t gid1 = -1; - hid_t gid2 = -1; - hid_t tid1 = -1; - hid_t tid2 = -1; - herr_t status; - hsize_t dims[1] = { 1 }; + hid_t fid1 = H5I_INVALID_HID; + hid_t gid1 = H5I_INVALID_HID; + hid_t gid2 = H5I_INVALID_HID; + hid_t tid1 = H5I_INVALID_HID; + hid_t tid2 = H5I_INVALID_HID; + herr_t status; + hsize_t dims[1] = {1}; typedef struct s1_t { - int a; + int a; float b; } s1_t; typedef struct s2_t { @@ -660,30 +648,30 @@ int test_types(const char *fname) } s2_t; /*------------------------------------------------------------------------- - * Create one file - *------------------------------------------------------------------------- - */ + * Create one file + *------------------------------------------------------------------------- + */ fid1 = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /*------------------------------------------------------------------------- - * H5G_DATASET - *------------------------------------------------------------------------- - */ + * H5G_DATASET + *------------------------------------------------------------------------- + */ write_dset(fid1, 1, dims, "dset", H5T_NATIVE_INT, 0); /*------------------------------------------------------------------------- - * H5G_GROUP - *------------------------------------------------------------------------- - */ - gid1 = H5Gcreate2(fid1, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + * H5G_GROUP + *------------------------------------------------------------------------- + */ + gid1 = H5Gcreate2(fid1, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Gclose(gid1); - gid2 = H5Gcreate2(fid1, "g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + gid2 = H5Gcreate2(fid1, "g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Gclose(gid2); /*------------------------------------------------------------------------- - * H5G_TYPE - *------------------------------------------------------------------------- - */ + * H5G_TYPE + *------------------------------------------------------------------------- + */ /* create and commit datatype 1 */ tid1 = H5Tcreate(H5T_COMPOUND, sizeof(s1_t)); @@ -698,25 +686,25 @@ int test_types(const char *fname) H5Tclose(tid2); /*------------------------------------------------------------------------- - * H5G_LINK - *------------------------------------------------------------------------- - */ + * H5G_LINK + *------------------------------------------------------------------------- + */ status = H5Lcreate_soft("g1", fid1, "l1", H5P_DEFAULT, H5P_DEFAULT); status = H5Lcreate_soft("g2", fid1, "l2", H5P_DEFAULT, H5P_DEFAULT); /*------------------------------------------------------------------------- - * H5G_UDLINK - *------------------------------------------------------------------------- - */ + * H5G_UDLINK + *------------------------------------------------------------------------- + */ H5Lcreate_external("filename", "objname", fid1, "ext_link", H5P_DEFAULT, H5P_DEFAULT); H5Lregister(UD_link_class); - H5Lcreate_ud(fid1, "ud_link", (H5L_type_t) MY_LINKCLASS, NULL, (size_t) 0, H5P_DEFAULT, H5P_DEFAULT); + H5Lcreate_ud(fid1, "ud_link", (H5L_type_t)MY_LINKCLASS, NULL, (size_t)0, H5P_DEFAULT, H5P_DEFAULT); /*------------------------------------------------------------------------- - * Close - *------------------------------------------------------------------------- - */ + * Close + *------------------------------------------------------------------------- + */ status = H5Fclose(fid1); return status; } @@ -766,138 +754,138 @@ int test_types(const char *fname) * *------------------------------------------------------------------------- */ -static -int test_datatypes(const char *fname) +static int +test_datatypes(const char *fname) { - hid_t fid1 = -1; - hid_t dset = -1; - hsize_t dims[2] = { 3, 2 }; - herr_t status; - char buf1a[3][2] = { { 1, 1 }, { 1, 1 }, { 1, 1 } }; - char buf1b[3][2] = { { 1, 1 }, { 3, 4 }, { 5, 6 } }; - short buf2a[3][2] = { { 1, 1 }, { 1, 1 }, { 1, 1 } }; - short buf2b[3][2] = { { 1, 1 }, { 3, 4 }, { 5, 6 } }; - int buf3a[3][2] = { { 1, 1 }, { 1, 1 }, { 1, 1 } }; - int buf3b[3][2] = { { 1, 1 }, { 3, 4 }, { 5, 6 } }; - long buf4a[3][2] = { { 1, 1 }, { 1, 1 }, { 1, 1 } }; - long buf4b[3][2] = { { 1, 1 }, { 3, 4 }, { 5, 6 } }; - float buf5a[3][2] = { { 1.0F, 1.0F }, { 1.0F, 1.0F }, { 1.0F, 1.0F } }; - float buf5b[3][2] = { { 1.0F, 1.0F }, { 3.0F, 4.0F }, { 5.0F, 6.0F } }; - double buf6a[3][2] = { { 1.0F, 1.0F }, { 1.0F, 1.0F }, { 1.0F, 1.0F } }; - double buf6b[3][2] = { { 1.0F, 1.0F }, { 3.0F, 4.0F }, { 5.0F, 6.0F } }; + hid_t fid1 = H5I_INVALID_HID; + hid_t dset = H5I_INVALID_HID; + hsize_t dims[2] = {3, 2}; + herr_t status; + char buf1a[3][2] = {{1, 1}, {1, 1}, {1, 1}}; + char buf1b[3][2] = {{1, 1}, {3, 4}, {5, 6}}; + short buf2a[3][2] = {{1, 1}, {1, 1}, {1, 1}}; + short buf2b[3][2] = {{1, 1}, {3, 4}, {5, 6}}; + int buf3a[3][2] = {{1, 1}, {1, 1}, {1, 1}}; + int buf3b[3][2] = {{1, 1}, {3, 4}, {5, 6}}; + long buf4a[3][2] = {{1, 1}, {1, 1}, {1, 1}}; + long buf4b[3][2] = {{1, 1}, {3, 4}, {5, 6}}; + float buf5a[3][2] = {{1.0F, 1.0F}, {1.0F, 1.0F}, {1.0F, 1.0F}}; + float buf5b[3][2] = {{1.0F, 1.0F}, {3.0F, 4.0F}, {5.0F, 6.0F}}; + double buf6a[3][2] = {{1.0F, 1.0F}, {1.0F, 1.0F}, {1.0F, 1.0F}}; + double buf6b[3][2] = {{1.0F, 1.0F}, {3.0F, 4.0F}, {5.0F, 6.0F}}; /*unsigned/signed test signed char -128 to 127 unsigned char 0 to 255 */ - char buf7a[3][2] = { { -1, -128 }, { -1, -1 }, { -1, -1 } }; - unsigned char buf7b[3][2] = { { 1, 128 }, { 1, 1 }, { 1, 1 } }; + char buf7a[3][2] = {{-1, -128}, {-1, -1}, {-1, -1}}; + unsigned char buf7b[3][2] = {{1, 128}, {1, 1}, {1, 1}}; /* long long test */ - long long buf8a[3][2] = { { 1, 1 }, { 1, 1 }, { 1, 1 } }; - long long buf8b[3][2] = { { 1, 1 }, { 3, 4 }, { 5, 6 } }; - unsigned long long buf9a[3][2] = { { 1, 1 }, { 1, 1 }, { 1, 1 } }; - unsigned long long buf9b[3][2] = { { 1, 1 }, { 3, 4 }, { 5, 6 } }; + long long buf8a[3][2] = {{1, 1}, {1, 1}, {1, 1}}; + long long buf8b[3][2] = {{1, 1}, {3, 4}, {5, 6}}; + unsigned long long buf9a[3][2] = {{1, 1}, {1, 1}, {1, 1}}; + unsigned long long buf9b[3][2] = {{1, 1}, {3, 4}, {5, 6}}; - unsigned int buf10a[3][2] = { { UIMAX, 1 }, { 1, 1 }, { 1, 1 } }; - unsigned int buf10b[3][2] = { { UIMAX - 1, 1 }, { 3, 4 }, { 5, 6 } }; + unsigned int buf10a[3][2] = {{UIMAX, 1}, {1, 1}, {1, 1}}; + unsigned int buf10b[3][2] = {{UIMAX - 1, 1}, {3, 4}, {5, 6}}; - unsigned short buf11a[3][2] = { { 204, 205 }, { 2, 3 }, { 1, 1 } }; - unsigned int buf11b[3][2] = { { 204, 205 }, { 2, 3 }, { 1, 1 } }; + unsigned short buf11a[3][2] = {{204, 205}, {2, 3}, {1, 1}}; + unsigned int buf11b[3][2] = {{204, 205}, {2, 3}, {1, 1}}; /*------------------------------------------------------------------------- - * Create a file - *------------------------------------------------------------------------- - */ + * Create a file + *------------------------------------------------------------------------- + */ fid1 = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /*------------------------------------------------------------------------- - * Check for different storage order. Give a warning if they are different - *------------------------------------------------------------------------- - */ + * Check for different storage order. Give a warning if they are different + *------------------------------------------------------------------------- + */ write_dset(fid1, 2, dims, "dset0a", H5T_STD_I16LE, buf2a); write_dset(fid1, 2, dims, "dset0b", H5T_STD_I32LE, buf3b); /*------------------------------------------------------------------------- - * H5T_NATIVE_CHAR - *------------------------------------------------------------------------- - */ + * H5T_NATIVE_CHAR + *------------------------------------------------------------------------- + */ write_dset(fid1, 2, dims, "dset1a", H5T_NATIVE_CHAR, buf1a); write_dset(fid1, 2, dims, "dset1b", H5T_NATIVE_CHAR, buf1b); /*------------------------------------------------------------------------- - * H5T_NATIVE_SHORT - *------------------------------------------------------------------------- - */ + * H5T_NATIVE_SHORT + *------------------------------------------------------------------------- + */ write_dset(fid1, 2, dims, "dset2a", H5T_NATIVE_SHORT, buf2a); write_dset(fid1, 2, dims, "dset2b", H5T_NATIVE_SHORT, buf2b); /*------------------------------------------------------------------------- - * H5T_NATIVE_INT - *------------------------------------------------------------------------- - */ + * H5T_NATIVE_INT + *------------------------------------------------------------------------- + */ write_dset(fid1, 2, dims, "dset3a", H5T_NATIVE_INT, buf3a); write_dset(fid1, 2, dims, "dset3b", H5T_NATIVE_INT, buf3b); /*------------------------------------------------------------------------- - * H5T_NATIVE_LONG - *------------------------------------------------------------------------- - */ + * H5T_NATIVE_LONG + *------------------------------------------------------------------------- + */ write_dset(fid1, 2, dims, "dset4a", H5T_NATIVE_LONG, buf4a); write_dset(fid1, 2, dims, "dset4b", H5T_NATIVE_LONG, buf4b); /*------------------------------------------------------------------------- - * H5T_NATIVE_FLOAT - *------------------------------------------------------------------------- - */ + * H5T_NATIVE_FLOAT + *------------------------------------------------------------------------- + */ write_dset(fid1, 2, dims, "dset5a", H5T_NATIVE_FLOAT, buf5a); write_dset(fid1, 2, dims, "dset5b", H5T_NATIVE_FLOAT, buf5b); /*------------------------------------------------------------------------- - * H5T_NATIVE_DOUBLE - *------------------------------------------------------------------------- - */ + * H5T_NATIVE_DOUBLE + *------------------------------------------------------------------------- + */ write_dset(fid1, 2, dims, "dset6a", H5T_NATIVE_DOUBLE, buf6a); write_dset(fid1, 2, dims, "dset6b", H5T_NATIVE_DOUBLE, buf6b); /*------------------------------------------------------------------------- - * H5T_NATIVE_CHAR and H5T_NATIVE_UCHAR - *------------------------------------------------------------------------- - */ + * H5T_NATIVE_CHAR and H5T_NATIVE_UCHAR + *------------------------------------------------------------------------- + */ write_dset(fid1, 2, dims, "dset7a", H5T_NATIVE_CHAR, buf7a); write_dset(fid1, 2, dims, "dset7b", H5T_NATIVE_UCHAR, buf7b); /*------------------------------------------------------------------------- - * H5T_NATIVE_LLONG - *------------------------------------------------------------------------- - */ + * H5T_NATIVE_LLONG + *------------------------------------------------------------------------- + */ write_dset(fid1, 2, dims, "dset8a", H5T_NATIVE_LLONG, buf8a); write_dset(fid1, 2, dims, "dset8b", H5T_NATIVE_LLONG, buf8b); /*------------------------------------------------------------------------- - * H5T_NATIVE_ULLONG - *------------------------------------------------------------------------- - */ + * H5T_NATIVE_ULLONG + *------------------------------------------------------------------------- + */ write_dset(fid1, 2, dims, "dset9a", H5T_NATIVE_ULLONG, buf9a); write_dset(fid1, 2, dims, "dset9b", H5T_NATIVE_ULLONG, buf9b); /*------------------------------------------------------------------------- - * H5T_NATIVE_INT - *------------------------------------------------------------------------- - */ + * H5T_NATIVE_INT + *------------------------------------------------------------------------- + */ write_dset(fid1, 2, dims, "dset10a", H5T_NATIVE_UINT, buf10a); write_dset(fid1, 2, dims, "dset10b", H5T_NATIVE_UINT, buf10b); /*------------------------------------------------------------------------- - * Same type class, different size - *------------------------------------------------------------------------- - */ + * Same type class, different size + *------------------------------------------------------------------------- + */ write_dset(fid1, 2, dims, "dset11a", H5T_STD_U16LE, buf11a); dset = H5Dopen2(fid1, "dset11a", H5P_DEFAULT); write_attr(dset, 2, dims, "attr", H5T_STD_U16LE, buf11a); @@ -909,9 +897,9 @@ int test_datatypes(const char *fname) H5Dclose(dset); /*------------------------------------------------------------------------- - * Close - *------------------------------------------------------------------------- - */ + * Close + *------------------------------------------------------------------------- + */ status = H5Fclose(fid1); return status; } @@ -956,44 +944,44 @@ int test_datatypes(const char *fname) * *------------------------------------------------------------------------- */ -static -int test_attributes(const char *file, int make_diffs /* flag to modify data buffers */) +static int +test_attributes(const char *file, int make_diffs /* flag to modify data buffers */) { - hid_t fid = -1; - hid_t did = -1; - hid_t gid = -1; - hid_t root_id = -1; - hid_t sid = -1; - hsize_t dims[1] = { 2 }; - herr_t status; + hid_t fid = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t gid = H5I_INVALID_HID; + hid_t root_id = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hsize_t dims[1] = {2}; + herr_t status; /* Create a file */ if ((fid = H5Fcreate(file, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; /* Create a 1D dataset */ - sid = H5Screate_simple(1, dims, NULL); - did = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(1, dims, NULL); + did = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Sclose(sid); assert(status >= 0); /* Create groups */ - gid = H5Gcreate2(fid, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + gid = H5Gcreate2(fid, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); root_id = H5Gopen2(fid, "/", H5P_DEFAULT); /*------------------------------------------------------------------------- - * write a series of attributes on the dataset, group, and root group - *------------------------------------------------------------------------- - */ + * write a series of attributes on the dataset, group, and root group + *------------------------------------------------------------------------- + */ if (make_diffs > 1) { write_attr_strings(did, "dset", fid, make_diffs); - write_attr_strings(gid, NULL, (hid_t) 0, make_diffs); - write_attr_strings(root_id, NULL, (hid_t) 0, make_diffs); + write_attr_strings(gid, NULL, (hid_t)0, make_diffs); + write_attr_strings(root_id, NULL, (hid_t)0, make_diffs); } else { write_attr_in(did, "dset", fid, make_diffs); - write_attr_in(gid, NULL, (hid_t) 0, make_diffs); - write_attr_in(root_id, NULL, (hid_t) 0, make_diffs); + write_attr_in(gid, NULL, (hid_t)0, make_diffs); + write_attr_in(root_id, NULL, (hid_t)0, make_diffs); } /* Close */ @@ -1018,171 +1006,172 @@ int test_attributes(const char *file, int make_diffs /* flag to modify data buff * *------------------------------------------------------------------------- */ -static int test_attributes_verbose_level(const char *fname1, const char *fname2) +static int +test_attributes_verbose_level(const char *fname1, const char *fname2) { herr_t status = SUCCEED; - hid_t fid1 = -1, fid2 = -1; - hid_t f1_gid = -1, f2_gid = -1; - hid_t f1_gid2 = -1, f2_gid2 = -1; - hid_t f1_gid3 = -1, f2_gid3 = -1; - hid_t f1_gid4 = -1, f2_gid4 = -1; - hid_t f1_did = -1, f2_did = -1; - hid_t f1_sid = -1, f2_sid = -1; - hid_t f1_tid = -1, f2_tid = -1; + hid_t fid1 = -1, fid2 = H5I_INVALID_HID; + hid_t f1_gid = -1, f2_gid = H5I_INVALID_HID; + hid_t f1_gid2 = -1, f2_gid2 = H5I_INVALID_HID; + hid_t f1_gid3 = -1, f2_gid3 = H5I_INVALID_HID; + hid_t f1_gid4 = -1, f2_gid4 = H5I_INVALID_HID; + hid_t f1_did = -1, f2_did = H5I_INVALID_HID; + hid_t f1_sid = -1, f2_sid = H5I_INVALID_HID; + hid_t f1_tid = -1, f2_tid = H5I_INVALID_HID; /* dset */ - hsize_t dset_dims[1] = { 3 }; - int dset_data[3] = { 0, 1, 2 }; + hsize_t dset_dims[1] = {3}; + int dset_data[3] = {0, 1, 2}; /* common attrs dim */ - hsize_t attr_dims[1] = { 2 }; + hsize_t attr_dims[1] = {2}; /* file1 attr */ - int f1_attr_idata[2] = { 1, 2 }; /* integer */ - float f1_attr_fdata[2] = { 1.1F, 2.2F }; /* float */ + int f1_attr_idata[2] = {1, 2}; /* integer */ + float f1_attr_fdata[2] = {1.1F, 2.2F}; /* float */ /* file2 attr */ - int f2_attr_idata[2] = { 2, 3 }; /* integer */ - float f2_attr_fdata[2] = { 2.1F, 3.2F }; /* float */ + int f2_attr_idata[2] = {2, 3}; /* integer */ + float f2_attr_fdata[2] = {2.1F, 3.2F}; /* float */ /*---------------------------------------------------------------------- - * Create file1 - *-----------------------------------------------------------------------*/ + * Create file1 + *-----------------------------------------------------------------------*/ if ((fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - fprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); status = FAIL; goto out; } /*---------------------------------- - * Groups - */ + * Groups + */ f1_gid = H5Gcreate2(fid1, "g", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (f1_gid < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); status = FAIL; goto out; } f1_gid2 = H5Gcreate2(fid1, "g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (f1_gid2 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); status = FAIL; goto out; } f1_gid3 = H5Gcreate2(fid1, "g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (f1_gid3 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); status = FAIL; goto out; } f1_gid4 = H5Gcreate2(fid1, "g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (f1_gid4 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); status = FAIL; goto out; } /*---------------------------------- - * Datasets - */ + * Datasets + */ f1_sid = H5Screate_simple(1, dset_dims, NULL); f1_did = H5Dcreate2(fid1, "dset", H5T_NATIVE_INT, f1_sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (f1_did == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname1); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname1); status = FAIL; goto out; } status = H5Dwrite(f1_did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset_data); if (status < 0) { - fprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname1); status = FAIL; goto out; } /*---------------------------------- - * Named Datatype - */ + * Named Datatype + */ f1_tid = H5Tcopy(H5T_NATIVE_INT); status = H5Tcommit2(fid1, "ntype", f1_tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Tcommit2 failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Tcommit2 failed.\n", fname1); status = FAIL; goto out; } /*---------------------------------------------------------------------- - * Create file2 - *-----------------------------------------------------------------------*/ + * Create file2 + *-----------------------------------------------------------------------*/ if ((fid2 = H5Fcreate(fname2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - fprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname2); status = FAIL; goto out; } /*---------------------------------- - * Groups - */ + * Groups + */ f2_gid = H5Gcreate2(fid2, "g", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (f2_gid < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); status = FAIL; goto out; } f2_gid2 = H5Gcreate2(fid2, "g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (f2_gid2 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); status = FAIL; goto out; } f2_gid3 = H5Gcreate2(fid2, "g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (f2_gid3 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); status = FAIL; goto out; } f2_gid4 = H5Gcreate2(fid2, "g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (f2_gid4 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); status = FAIL; goto out; } /*---------------------------------- - * Datasets - */ + * Datasets + */ f2_sid = H5Screate_simple(1, dset_dims, NULL); f2_did = H5Dcreate2(fid2, "dset", H5T_NATIVE_INT, f2_sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (f2_did == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname2); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname2); status = FAIL; goto out; } status = H5Dwrite(f2_did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset_data); if (status < 0) { - fprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname2); status = FAIL; goto out; } /*---------------------------------- - * Named Datatype - */ + * Named Datatype + */ f2_tid = H5Tcopy(H5T_NATIVE_INT); status = H5Tcommit2(fid2, "ntype", f2_tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Tcommit2 failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Tcommit2 failed.\n", fname2); status = FAIL; goto out; } /*---------------------------------- - * CASE1 - Same attr number, all Same attr name - * add attr to group - */ + * CASE1 - Same attr number, all Same attr name + * add attr to group + */ write_attr(f1_gid, 1, attr_dims, "integer1", H5T_NATIVE_INT, f1_attr_idata); write_attr(f1_gid, 1, attr_dims, "float1", H5T_NATIVE_FLOAT, f1_attr_fdata); @@ -1190,9 +1179,9 @@ static int test_attributes_verbose_level(const char *fname1, const char *fname2) write_attr(f2_gid, 1, attr_dims, "float1", H5T_NATIVE_FLOAT, f2_attr_fdata); /*---------------------------------- - * CASE2 - Same attr number, some Same attr name - * add attr to dset - */ + * CASE2 - Same attr number, some Same attr name + * add attr to dset + */ write_attr(f1_did, 1, attr_dims, "integer1", H5T_NATIVE_INT, f1_attr_idata); write_attr(f1_did, 1, attr_dims, "float2", H5T_NATIVE_FLOAT, f1_attr_fdata); @@ -1200,9 +1189,9 @@ static int test_attributes_verbose_level(const char *fname1, const char *fname2) write_attr(f2_did, 1, attr_dims, "float3", H5T_NATIVE_FLOAT, f2_attr_fdata); /*---------------------------------- - * CASE3 - Same attr number, all different attr name - * add attr to ntype - */ + * CASE3 - Same attr number, all different attr name + * add attr to ntype + */ write_attr(f1_tid, 1, attr_dims, "integer1", H5T_NATIVE_INT, f1_attr_idata); write_attr(f1_tid, 1, attr_dims, "float2", H5T_NATIVE_FLOAT, f1_attr_fdata); write_attr(f1_tid, 1, attr_dims, "float3", H5T_NATIVE_FLOAT, f1_attr_fdata); @@ -1212,9 +1201,9 @@ static int test_attributes_verbose_level(const char *fname1, const char *fname2) write_attr(f2_tid, 1, attr_dims, "float6", H5T_NATIVE_FLOAT, f2_attr_fdata); /*---------------------------------- - * CASE4 - Different attr number, some same attr name (vs file2-g2) - * add attr to g2 - */ + * CASE4 - Different attr number, some same attr name (vs file2-g2) + * add attr to g2 + */ write_attr(f1_gid2, 1, attr_dims, "integer1", H5T_NATIVE_INT, f1_attr_idata); write_attr(f1_gid2, 1, attr_dims, "float2", H5T_NATIVE_FLOAT, f1_attr_fdata); write_attr(f1_gid2, 1, attr_dims, "float3", H5T_NATIVE_FLOAT, f1_attr_fdata); @@ -1223,9 +1212,9 @@ static int test_attributes_verbose_level(const char *fname1, const char *fname2) write_attr(f2_gid2, 1, attr_dims, "float2", H5T_NATIVE_FLOAT, f2_attr_fdata); /*---------------------------------- - * CASE5 - Different attr number, all different attr name - * add attr to g3 - */ + * CASE5 - Different attr number, all different attr name + * add attr to g3 + */ write_attr(f1_gid3, 1, attr_dims, "integer10", H5T_NATIVE_INT, f1_attr_idata); write_attr(f1_gid3, 1, attr_dims, "float11", H5T_NATIVE_FLOAT, f1_attr_fdata); write_attr(f1_gid3, 1, attr_dims, "float12", H5T_NATIVE_FLOAT, f1_attr_fdata); @@ -1235,8 +1224,8 @@ static int test_attributes_verbose_level(const char *fname1, const char *fname2) out: /*----------------------------------------------------------------------- - * Close - *-----------------------------------------------------------------------*/ + * Close + *-----------------------------------------------------------------------*/ if (fid1 > 0) H5Fclose(fid1); if (fid2 > 0) @@ -1283,16 +1272,16 @@ out: * *------------------------------------------------------------------------- */ -static -int test_datasets(const char *file, int make_diffs /* flag to modify data buffers */) +static int +test_datasets(const char *file, int make_diffs /* flag to modify data buffers */) { - hid_t fid = -1; - hid_t did = -1; - hid_t gid = -1; - hid_t sid = -1; - hsize_t dims[1] = { 2 }; - herr_t status; - int buf[2] = { 1, 2 }; + hid_t fid = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t gid = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hsize_t dims[1] = {2}; + herr_t status; + int buf[2] = {1, 2}; if (make_diffs > 0) memset(buf, 0, sizeof buf); @@ -1302,8 +1291,8 @@ int test_datasets(const char *file, int make_diffs /* flag to modify data buffer return -1; /* Create a 1D dataset */ - sid = H5Screate_simple(1, dims, NULL); - did = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(1, dims, NULL); + did = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); status = H5Sclose(sid); assert(status >= 0); @@ -1312,9 +1301,9 @@ int test_datasets(const char *file, int make_diffs /* flag to modify data buffer gid = H5Gcreate2(fid, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /*------------------------------------------------------------------------- - * write a series of datasets on the group - *------------------------------------------------------------------------- - */ + * write a series of datasets on the group + *------------------------------------------------------------------------- + */ write_dset_in(gid, "/dset", fid, make_diffs); @@ -1336,16 +1325,16 @@ int test_datasets(const char *file, int make_diffs /* flag to modify data buffer * Purpose: Check datasets with datasapce of zero dimension size. *------------------------------------------------------------------------- */ -static -int test_special_datasets(const char *file, int make_diffs /* flag to modify data buffers */) +static int +test_special_datasets(const char *file, int make_diffs /* flag to modify data buffers */) { - hid_t fid = -1; - hid_t did = -1; - hid_t sid0 = -1; - hid_t sid = -1; - hsize_t dims0[SPACE1_RANK] = { SPACE1_DIM1, SPACE1_DIM2 }; - hsize_t dims[SPACE1_RANK] = { SPACE1_DIM1, SPACE1_DIM2 }; - herr_t status; + hid_t fid = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t sid0 = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hsize_t dims0[SPACE1_RANK] = {SPACE1_DIM1, SPACE1_DIM2}; + hsize_t dims[SPACE1_RANK] = {SPACE1_DIM1, SPACE1_DIM2}; + herr_t status; /* Create a file */ if ((fid = H5Fcreate(file, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) @@ -1353,7 +1342,7 @@ int test_special_datasets(const char *file, int make_diffs /* flag to modify dat /* Create a dataset with zero dimension size */ sid0 = H5Screate_simple(SPACE1_RANK, dims0, NULL); - did = H5Dcreate2(fid, "dset1", H5T_NATIVE_INT, sid0, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + did = H5Dcreate2(fid, "dset1", H5T_NATIVE_INT, sid0, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* close dataset */ status = H5Dclose(did); @@ -1364,7 +1353,7 @@ int test_special_datasets(const char *file, int make_diffs /* flag to modify dat assert(status >= 0); /* Create a dataset with zero dimension size in one file but the other one - * has a dataset with a non-zero dimension size */ + * has a dataset with a non-zero dimension size */ if (make_diffs) dims[1] = SPACE1_DIM2 + 4; @@ -1393,62 +1382,62 @@ int test_special_datasets(const char *file, int make_diffs /* flag to modify dat * Programmer: Jonathan Kim (Feb 17, 2010) * *-------------------------------------------------------------------------*/ -static int test_link_name(const char *fname1) +static int +test_link_name(const char *fname1) { - hid_t fid1 = -1; - hid_t gid1 = -1; - hid_t gid2 = -1; + hid_t fid1 = H5I_INVALID_HID; + hid_t gid1 = H5I_INVALID_HID; + hid_t gid2 = H5I_INVALID_HID; herr_t status = SUCCEED; /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { - fprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * Groups - *------------------------------------------------------------------------*/ + * Groups + *------------------------------------------------------------------------*/ gid1 = H5Gcreate2(fid1, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid1 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); status = FAIL; goto out; } - gid2 = H5Gcreate2(fid1, "group_longname", H5P_DEFAULT, H5P_DEFAULT, - H5P_DEFAULT); + gid2 = H5Gcreate2(fid1, "group_longname", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid2 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * Soft Links - *------------------------------------------------------------------------*/ + * Soft Links + *------------------------------------------------------------------------*/ status = H5Lcreate_soft("group", fid1, "link_g1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); status = FAIL; goto out; } status = H5Lcreate_soft("group_longname", fid1, "link_g2", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); status = FAIL; goto out; } out: /*----------------------------------------------------------------------- - * Close - *------------------------------------------------------------------------*/ + * Close + *------------------------------------------------------------------------*/ if (fid1) H5Fclose(fid1); if (gid1) @@ -1466,110 +1455,111 @@ out: * Programmer: Jonathan Kim (Feb 17, 2010) * *-------------------------------------------------------------------------*/ -static int test_soft_links(const char *fname1) +static int +test_soft_links(const char *fname1) { - hid_t fid1 = -1; - hid_t gid1 = -1; - hsize_t dims2[2] = { 2, 4 }; - int data1[4][2] = { { 0, 1 }, { 2, 3 }, { 1, 2 }, { 3, 4 } }; - int data2[4][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }; - herr_t status = SUCCEED; + hid_t fid1 = H5I_INVALID_HID; + hid_t gid1 = H5I_INVALID_HID; + hsize_t dims2[2] = {2, 4}; + int data1[4][2] = {{0, 1}, {2, 3}, {1, 2}, {3, 4}}; + int data2[4][2] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}}; + herr_t status = SUCCEED; /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { - fprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * Groups - *------------------------------------------------------------------------*/ + * Groups + *------------------------------------------------------------------------*/ gid1 = H5Gcreate2(fid1, "target_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid1 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * Datasets - *------------------------------------------------------------------------*/ + * Datasets + *------------------------------------------------------------------------*/ /* file1 */ status = write_dset(fid1, 2, dims2, "target_dset1", H5T_NATIVE_INT, data1); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname1); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname1); status = FAIL; goto out; } status = write_dset(fid1, 2, dims2, "target_dset2", H5T_NATIVE_INT, data2); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname1); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname1); status = FAIL; goto out; } status = write_dset(gid1, 2, dims2, "dset", H5T_NATIVE_INT, data1); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname1); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname1); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * Soft Links - *------------------------------------------------------------------------*/ + * Soft Links + *------------------------------------------------------------------------*/ /* file 1 */ status = H5Lcreate_soft("/target_dset1", fid1, "softlink_dset1_1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); status = FAIL; goto out; } status = H5Lcreate_soft("/target_dset1", fid1, "softlink_dset1_2", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); status = FAIL; goto out; } status = H5Lcreate_soft("/target_dset2", fid1, "softlink_dset2", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); status = FAIL; goto out; } status = H5Lcreate_soft("/target_group", fid1, "softlink_group1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); status = FAIL; goto out; } status = H5Lcreate_soft("/target_group", fid1, "softlink_group2", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); status = FAIL; goto out; } status = H5Lcreate_soft("/no_obj", fid1, "softlink_noexist", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); status = FAIL; goto out; } out: /*----------------------------------------------------------------------- - * Close - *-----------------------------------------------------------------------*/ + * Close + *-----------------------------------------------------------------------*/ if (fid1) H5Fclose(fid1); if (gid1) @@ -1585,168 +1575,169 @@ out: * Programmer: Jonathan Kim (Feb 17, 2010) * *-------------------------------------------------------------------------*/ -static int test_linked_softlinks(const char *fname1) +static int +test_linked_softlinks(const char *fname1) { - hid_t fid1 = -1; - hid_t gid1 = -1; - hid_t gid2 = -1; - hid_t gid3 = -1; - hsize_t dims2[2] = { 2, 4 }; - int data1[4][2] = { { 0, 1 }, { 2, 3 }, { 1, 2 }, { 3, 4 } }; - int data2[4][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }; - herr_t status = SUCCEED; + hid_t fid1 = H5I_INVALID_HID; + hid_t gid1 = H5I_INVALID_HID; + hid_t gid2 = H5I_INVALID_HID; + hid_t gid3 = H5I_INVALID_HID; + hsize_t dims2[2] = {2, 4}; + int data1[4][2] = {{0, 1}, {2, 3}, {1, 2}, {3, 4}}; + int data2[4][2] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}}; + herr_t status = SUCCEED; /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { - fprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * Groups - *------------------------------------------------------------------------*/ + * Groups + *------------------------------------------------------------------------*/ gid1 = H5Gcreate2(fid1, "target_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid1 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); status = FAIL; goto out; } gid2 = H5Gcreate2(fid1, "target_group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid2 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); status = FAIL; goto out; } gid3 = H5Gcreate2(fid1, "target_group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid3 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * Datasets - *------------------------------------------------------------------------*/ + * Datasets + *------------------------------------------------------------------------*/ /* file1 */ status = write_dset(fid1, 2, dims2, "target_dset1", H5T_NATIVE_INT, data1); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname1); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname1); status = FAIL; goto out; } status = write_dset(fid1, 2, dims2, "target_dset2", H5T_NATIVE_INT, data2); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname1); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname1); status = FAIL; goto out; } status = write_dset(gid1, 2, dims2, "dset", H5T_NATIVE_INT, data1); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname1); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname1); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * Soft Links (Linked) - *------------------------------------------------------------------------*/ + * Soft Links (Linked) + *------------------------------------------------------------------------*/ /*--------- - * file 1 */ + * file 1 */ status = H5Lcreate_soft("/target_dset1", fid1, "softlink1_to_dset1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); status = FAIL; goto out; } status = H5Lcreate_soft("softlink1_to_dset1", fid1, "softlink1_to_slink1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); status = FAIL; goto out; } status = H5Lcreate_soft("softlink1_to_slink1", fid1, "softlink1_to_slink2", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); status = FAIL; goto out; } status = H5Lcreate_soft("/target_dset2", fid1, "softlink2_to_dset2", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); status = FAIL; goto out; } status = H5Lcreate_soft("softlink2_to_dset2", fid1, "softlink2_to_slink1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); status = FAIL; goto out; } status = H5Lcreate_soft("softlink2_to_slink1", fid1, "softlink2_to_slink2", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); status = FAIL; goto out; } status = H5Lcreate_soft("target_group1", fid1, "softlink3_to_group1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); status = FAIL; goto out; } status = H5Lcreate_soft("softlink3_to_group1", fid1, "softlink3_to_slink1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); status = FAIL; goto out; } status = H5Lcreate_soft("softlink3_to_slink1", fid1, "softlink3_to_slink2", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); status = FAIL; goto out; } status = H5Lcreate_soft("target_group2", fid1, "softlink4_to_group2", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); status = FAIL; goto out; } status = H5Lcreate_soft("softlink4_to_group2", fid1, "softlink4_to_slink1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); status = FAIL; goto out; } status = H5Lcreate_soft("softlink4_to_slink1", fid1, "softlink4_to_slink2", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); status = FAIL; goto out; } out: /*----------------------------------------------------------------------- - * Close - *-----------------------------------------------------------------------*/ + * Close + *-----------------------------------------------------------------------*/ if (fid1) H5Fclose(fid1); if (gid1) @@ -1766,24 +1757,25 @@ out: * Programmer: Jonathan Kim (Feb 17, 2010) * *-------------------------------------------------------------------------*/ -static int test_external_links(const char *fname1, const char *fname2) +static int +test_external_links(const char *fname1, const char *fname2) { - hid_t fid1 = -1; - hid_t fid2 = -1; - hid_t gid1 = -1; - hid_t gid2 = -1; - hsize_t dims2[2] = { 2, 4 }; - int data1[4][2] = { { 0, 1 }, { 2, 3 }, { 1, 2 }, { 3, 4 } }; - int data2[4][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }; - herr_t status = SUCCEED; + hid_t fid1 = H5I_INVALID_HID; + hid_t fid2 = H5I_INVALID_HID; + hid_t gid1 = H5I_INVALID_HID; + hid_t gid2 = H5I_INVALID_HID; + hsize_t dims2[2] = {2, 4}; + int data1[4][2] = {{0, 1}, {2, 3}, {1, 2}, {3, 4}}; + int data2[4][2] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}}; + herr_t status = SUCCEED; /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ /* source file */ fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { - fprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); status = FAIL; goto out; } @@ -1791,106 +1783,108 @@ static int test_external_links(const char *fname1, const char *fname2) /* target file */ fid2 = H5Fcreate(fname2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid2 < 0) { - fprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname2); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * Groups - *------------------------------------------------------------------------*/ + * Groups + *------------------------------------------------------------------------*/ /*-------------- - * target file */ + * target file */ gid1 = H5Gcreate2(fid2, "target_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid1 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); status = FAIL; goto out; } gid2 = H5Gcreate2(fid2, "target_group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid2 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * Datasets - *------------------------------------------------------------------------*/ + * Datasets + *------------------------------------------------------------------------*/ /*-------------- - * target file */ + * target file */ status = write_dset(fid2, 2, dims2, "target_dset1", H5T_NATIVE_INT, data1); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname2); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname2); status = FAIL; goto out; } status = write_dset(gid1, 2, dims2, "x_dset", H5T_NATIVE_INT, data1); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname2); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname2); status = FAIL; goto out; } status = write_dset(gid2, 2, dims2, "x_dset", H5T_NATIVE_INT, data2); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname2); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname2); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * External Links - *------------------------------------------------------------------------*/ + * External Links + *------------------------------------------------------------------------*/ /*--------------*/ /* source file */ - status = H5Lcreate_external(fname2, "/target_group/x_dset", fid1, "ext_link_dset1", H5P_DEFAULT, H5P_DEFAULT); + status = + H5Lcreate_external(fname2, "/target_group/x_dset", fid1, "ext_link_dset1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); status = FAIL; goto out; } - status = H5Lcreate_external(fname2, "/target_group2/x_dset", fid1, "ext_link_dset2", H5P_DEFAULT, H5P_DEFAULT); + status = + H5Lcreate_external(fname2, "/target_group2/x_dset", fid1, "ext_link_dset2", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); status = FAIL; goto out; } status = H5Lcreate_external(fname2, "/target_group", fid1, "/ext_link_grp1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); status = FAIL; goto out; } status = H5Lcreate_external(fname2, "/target_group2", fid1, "/ext_link_grp2", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); status = FAIL; goto out; } status = H5Lcreate_external(fname2, "no_obj", fid1, "ext_link_noexist1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); status = FAIL; goto out; } status = H5Lcreate_external("no_file.h5", "no_obj", fid1, "ext_link_noexist2", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); status = FAIL; goto out; } out: /*----------------------------------------------------------------------- - * Close - *-----------------------------------------------------------------------*/ + * Close + *-----------------------------------------------------------------------*/ if (fid1) H5Fclose(fid1); if (fid2) @@ -1911,23 +1905,24 @@ out: * Programmer: Jonathan Kim (Feb 17, 2010) * *-------------------------------------------------------------------------*/ -static int test_ext2soft_links(const char *fname1, const char *fname2) +static int +test_ext2soft_links(const char *fname1, const char *fname2) { - hid_t fid1 = -1; - hid_t fid2 = -1; - hid_t gid2 = -1; - hsize_t dims2[2] = { 2, 4 }; - int data1[4][2] = { { 0, 1 }, { 2, 3 }, { 1, 2 }, { 3, 4 } }; - int data2[4][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }; - herr_t status = SUCCEED; + hid_t fid1 = H5I_INVALID_HID; + hid_t fid2 = H5I_INVALID_HID; + hid_t gid2 = H5I_INVALID_HID; + hsize_t dims2[2] = {2, 4}; + int data1[4][2] = {{0, 1}, {2, 3}, {1, 2}, {3, 4}}; + int data2[4][2] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}}; + herr_t status = SUCCEED; /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ /* source file */ fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { - fprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); status = FAIL; goto out; } @@ -1935,90 +1930,92 @@ static int test_ext2soft_links(const char *fname1, const char *fname2) /* target file */ fid2 = H5Fcreate(fname2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid2 < 0) { - fprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname2); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * Groups - *------------------------------------------------------------------------*/ + * Groups + *------------------------------------------------------------------------*/ /* target file */ gid2 = H5Gcreate2(fid2, "target_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid2 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * Datasets - *------------------------------------------------------------------------*/ + * Datasets + *------------------------------------------------------------------------*/ /*-------------- - * target file */ + * target file */ status = write_dset(fid2, 2, dims2, "dset1", H5T_NATIVE_INT, data2); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname2); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname2); status = FAIL; goto out; } status = write_dset(fid2, 2, dims2, "dset2", H5T_NATIVE_INT, data1); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname2); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname2); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * Soft Links (Linked) - *------------------------------------------------------------------------*/ + * Soft Links (Linked) + *------------------------------------------------------------------------*/ /*--------------- - * target file */ + * target file */ status = H5Lcreate_soft("/dset1", fid2, "softlink_to_dset1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname2); status = FAIL; goto out; } status = H5Lcreate_soft("/dset2", fid2, "softlink_to_dset2", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname2); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * External Links - *------------------------------------------------------------------------*/ + * External Links + *------------------------------------------------------------------------*/ /*--------------- - * source file */ + * source file */ status = H5Lcreate_external(fname2, "/target_group", fid1, "ext_link", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); status = FAIL; goto out; } - status = H5Lcreate_external(fname2, "/softlink_to_dset1", fid1, "ext_link_to_slink1", H5P_DEFAULT, H5P_DEFAULT); + status = H5Lcreate_external(fname2, "/softlink_to_dset1", fid1, "ext_link_to_slink1", H5P_DEFAULT, + H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); status = FAIL; goto out; } - status = H5Lcreate_external(fname2, "/softlink_to_dset2", fid1, "ext_link_to_slink2", H5P_DEFAULT, H5P_DEFAULT); + status = H5Lcreate_external(fname2, "/softlink_to_dset2", fid1, "ext_link_to_slink2", H5P_DEFAULT, + H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); status = FAIL; goto out; } out: /*----------------------------------------------------------------------- - * Close - *-----------------------------------------------------------------------*/ + * Close + *-----------------------------------------------------------------------*/ if (fid1) H5Fclose(fid1); if (fid2) @@ -2036,46 +2033,47 @@ out: * Programmer: Jonathan Kim (Feb 17, 2010) * *-------------------------------------------------------------------------*/ -static int test_dangle_links(const char *fname1, const char *fname2) +static int +test_dangle_links(const char *fname1, const char *fname2) { - hid_t fid1 = -1; - hid_t fid2 = -1; - hsize_t dims2[2] = { 2, 4 }; - int data1[4][2] = { { 0, 1 }, { 2, 3 }, { 1, 2 }, { 3, 4 } }; - int data2[4][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }; - herr_t status = SUCCEED; + hid_t fid1 = H5I_INVALID_HID; + hid_t fid2 = H5I_INVALID_HID; + hsize_t dims2[2] = {2, 4}; + int data1[4][2] = {{0, 1}, {2, 3}, {1, 2}, {3, 4}}; + int data2[4][2] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}}; + herr_t status = SUCCEED; /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { - fprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); status = FAIL; goto out; } fid2 = H5Fcreate(fname2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid2 < 0) { - fprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname2); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * Datasets - *------------------------------------------------------------------------*/ + * Datasets + *------------------------------------------------------------------------*/ /* file1 */ status = write_dset(fid1, 2, dims2, "dset1", H5T_NATIVE_INT, data1); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname1); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname1); status = FAIL; goto out; } status = write_dset(fid1, 2, dims2, "dset2", H5T_NATIVE_INT, data2); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname1); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname1); status = FAIL; goto out; } @@ -2083,46 +2081,46 @@ static int test_dangle_links(const char *fname1, const char *fname2) /* file2 */ status = write_dset(fid2, 2, dims2, "dset1", H5T_NATIVE_INT, data1); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname2); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname2); status = FAIL; goto out; } status = write_dset(fid2, 2, dims2, "dset2", H5T_NATIVE_INT, data2); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname2); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname2); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * Soft Links - *------------------------------------------------------------------------*/ + * Soft Links + *------------------------------------------------------------------------*/ /* file 1 */ status = H5Lcreate_soft("no_obj", fid1, "soft_link1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); status = FAIL; goto out; } status = H5Lcreate_soft("/dset1", fid1, "soft_link2", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); status = FAIL; goto out; } status = H5Lcreate_soft("no_obj", fid1, "soft_link3", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); status = FAIL; goto out; } status = H5Lcreate_soft("no_obj1", fid1, "soft_link4", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); status = FAIL; goto out; } @@ -2130,60 +2128,60 @@ static int test_dangle_links(const char *fname1, const char *fname2) /* file 2 */ status = H5Lcreate_soft("no_obj", fid2, "soft_link1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname2); status = FAIL; goto out; } status = H5Lcreate_soft("no_obj", fid2, "soft_link2", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname2); status = FAIL; goto out; } status = H5Lcreate_soft("/dset2", fid2, "soft_link3", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname2); status = FAIL; goto out; } status = H5Lcreate_soft("no_obj2", fid2, "soft_link4", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname2); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * External Links - *------------------------------------------------------------------------*/ + * External Links + *------------------------------------------------------------------------*/ /* file1 */ status = H5Lcreate_external(fname2, "no_obj", fid1, "ext_link1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); status = FAIL; goto out; } status = H5Lcreate_external(fname2, "/dset1", fid1, "ext_link2", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); status = FAIL; goto out; } status = H5Lcreate_external(fname2, "no_obj", fid1, "ext_link3", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); status = FAIL; goto out; } status = H5Lcreate_external("no_file.h5", "no_obj", fid1, "ext_link4", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); status = FAIL; goto out; } @@ -2191,36 +2189,36 @@ static int test_dangle_links(const char *fname1, const char *fname2) /* file2 */ status = H5Lcreate_external(fname1, "no_obj", fid2, "ext_link1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname2); status = FAIL; goto out; } status = H5Lcreate_external(fname1, "no_obj", fid2, "ext_link2", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname2); status = FAIL; goto out; } status = H5Lcreate_external(fname1, "/dset2", fid2, "ext_link3", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname2); status = FAIL; goto out; } status = H5Lcreate_external("no_file.h5", "no_obj", fid2, "ext_link4", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname2); status = FAIL; goto out; } out: /*----------------------------------------------------------------------- - * Close - *-----------------------------------------------------------------------*/ + * Close + *-----------------------------------------------------------------------*/ if (fid1) H5Fclose(fid1); if (fid2) @@ -2236,63 +2234,66 @@ out: * Programmer: Jonathan Kim (Aug 19, 2010) * *-------------------------------------------------------------------------*/ -static int test_group_recurse(const char *fname1, const char *fname2) +static int +test_group_recurse(const char *fname1, const char *fname2) { - hid_t fid1 = -1; - hid_t fid2 = -1; - hid_t gid1_f1 = -1, gid2_f1 = -1, gid3_f1 = -1, gid10_f1 = -1; - hid_t gid1_f2 = -1, gid2_f2 = -1, gid3_f2 = -1, gid11_f2 = -1; - hsize_t dims2[2] = { 2, 4 }; - int data1[4][2] = { { 0, 1 }, { 0, 1 }, { 1, 0 }, { 1, 0 } }; - int data2[4][2] = { { 0, 2 }, { 0, 2 }, { 2, 0 }, { 2, 0 } }; - int data3[4][2] = { { 0, 3 }, { 0, 3 }, { 3, 0 }, { 3, 0 } }; - herr_t status = SUCCEED; + hid_t fid1 = H5I_INVALID_HID; + hid_t fid2 = H5I_INVALID_HID; + hid_t gid1_f1 = H5I_INVALID_HID, gid2_f1 = H5I_INVALID_HID, gid3_f1 = H5I_INVALID_HID, + gid10_f1 = H5I_INVALID_HID; + hid_t gid1_f2 = H5I_INVALID_HID, gid2_f2 = H5I_INVALID_HID, gid3_f2 = H5I_INVALID_HID, + gid11_f2 = H5I_INVALID_HID; + hsize_t dims2[2] = {2, 4}; + int data1[4][2] = {{0, 1}, {0, 1}, {1, 0}, {1, 0}}; + int data2[4][2] = {{0, 2}, {0, 2}, {2, 0}, {2, 0}}; + int data3[4][2] = {{0, 3}, {0, 3}, {3, 0}, {3, 0}}; + herr_t status = SUCCEED; /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { - fprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); status = FAIL; goto out; } fid2 = H5Fcreate(fname2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid2 < 0) { - fprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname2); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * Groups - *------------------------------------------------------------------------*/ + * Groups + *------------------------------------------------------------------------*/ /* file1 */ gid1_f1 = H5Gcreate2(fid1, "/grp1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid1_f1 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); status = FAIL; goto out; } gid2_f1 = H5Gcreate2(fid1, "/grp1/grp2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid2_f1 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); status = FAIL; goto out; } gid3_f1 = H5Gcreate2(fid1, "/grp1/grp2/grp3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid3_f1 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); status = FAIL; goto out; } gid10_f1 = H5Gcreate2(fid1, "/grp10", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid10_f1 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); status = FAIL; goto out; } @@ -2300,53 +2301,53 @@ static int test_group_recurse(const char *fname1, const char *fname2) /* file2 */ gid1_f2 = H5Gcreate2(fid2, "/grp1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid1_f2 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); status = FAIL; goto out; } gid2_f2 = H5Gcreate2(fid2, "/grp1/grp2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid2_f2 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); status = FAIL; goto out; } gid3_f2 = H5Gcreate2(fid2, "/grp1/grp2/grp3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid3_f2 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); status = FAIL; goto out; } gid11_f2 = H5Gcreate2(fid2, "/grp11", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid11_f2 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * Datasets under root - *------------------------------------------------------------------------*/ + * Datasets under root + *------------------------------------------------------------------------*/ /* file1 */ status = write_dset(fid1, 2, dims2, "dset1", H5T_NATIVE_INT, data1); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname1); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname1); status = FAIL; goto out; } status = write_dset(fid1, 2, dims2, "dset2", H5T_NATIVE_INT, data2); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname1); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname1); status = FAIL; goto out; } status = write_dset(fid1, 2, dims2, "dset3", H5T_NATIVE_INT, data3); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname1); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname1); status = FAIL; goto out; } @@ -2354,79 +2355,79 @@ static int test_group_recurse(const char *fname1, const char *fname2) /* file2 */ status = write_dset(fid2, 2, dims2, "dset1", H5T_NATIVE_INT, data1); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname2); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname2); status = FAIL; goto out; } status = write_dset(fid2, 2, dims2, "dset2", H5T_NATIVE_INT, data2); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname2); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname2); status = FAIL; goto out; } status = write_dset(fid2, 2, dims2, "dset3", H5T_NATIVE_INT, data3); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname2); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname2); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * Datasets under group - *------------------------------------------------------------------------*/ + * Datasets under group + *------------------------------------------------------------------------*/ /* file1 */ status = write_dset(gid1_f1, 2, dims2, "dset1", H5T_NATIVE_INT, data1); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname1); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname1); status = FAIL; goto out; } status = write_dset(gid2_f1, 2, dims2, "dset1", H5T_NATIVE_INT, data1); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname1); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname1); status = FAIL; goto out; } status = write_dset(gid2_f1, 2, dims2, "dset2", H5T_NATIVE_INT, data2); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname1); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname1); status = FAIL; goto out; } status = write_dset(gid3_f1, 2, dims2, "dset1", H5T_NATIVE_INT, data1); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname1); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname1); status = FAIL; goto out; } status = write_dset(gid3_f1, 2, dims2, "dset2", H5T_NATIVE_INT, data2); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname1); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname1); status = FAIL; goto out; } status = write_dset(gid3_f1, 2, dims2, "dset3", H5T_NATIVE_INT, data3); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname1); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname1); status = FAIL; goto out; } status = write_dset(gid10_f1, 2, dims2, "dset4", H5T_NATIVE_INT, data1); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname1); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname1); status = FAIL; goto out; } status = write_dset(gid10_f1, 2, dims2, "dset5", H5T_NATIVE_INT, data3); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname1); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname1); status = FAIL; goto out; } @@ -2434,86 +2435,86 @@ static int test_group_recurse(const char *fname1, const char *fname2) /* file2 */ status = write_dset(gid1_f2, 2, dims2, "dset1", H5T_NATIVE_INT, data1); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname2); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname2); status = FAIL; goto out; } status = write_dset(gid2_f2, 2, dims2, "dset1", H5T_NATIVE_INT, data1); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname2); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname2); status = FAIL; goto out; } status = write_dset(gid2_f2, 2, dims2, "dset2", H5T_NATIVE_INT, data2); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname2); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname2); status = FAIL; goto out; } status = write_dset(gid3_f2, 2, dims2, "dset1", H5T_NATIVE_INT, data1); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname2); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname2); status = FAIL; goto out; } status = write_dset(gid3_f2, 2, dims2, "dset2", H5T_NATIVE_INT, data2); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname2); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname2); status = FAIL; goto out; } status = write_dset(gid3_f2, 2, dims2, "dset3", H5T_NATIVE_INT, data3); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname2); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname2); status = FAIL; goto out; } status = write_dset(gid11_f2, 2, dims2, "dset4", H5T_NATIVE_INT, data1); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname2); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname2); status = FAIL; goto out; } status = write_dset(gid11_f2, 2, dims2, "dset5", H5T_NATIVE_INT, data2); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname2); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname2); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * Soft Links - *------------------------------------------------------------------------*/ + * Soft Links + *------------------------------------------------------------------------*/ /* file 1 */ status = H5Lcreate_soft("/grp1", fid1, "slink_grp1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); status = FAIL; goto out; } status = H5Lcreate_soft("/grp1/grp2", fid1, "slink_grp2", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); status = FAIL; goto out; } status = H5Lcreate_soft("/grp1/grp2/grp3", fid1, "slink_grp3", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); status = FAIL; goto out; } status = H5Lcreate_soft("/grp10", fid1, "slink_grp10", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname1); status = FAIL; goto out; } @@ -2521,53 +2522,53 @@ static int test_group_recurse(const char *fname1, const char *fname2) /* file 2 */ status = H5Lcreate_soft("/grp1", fid2, "slink_grp1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname2); status = FAIL; goto out; } status = H5Lcreate_soft("/grp1/grp2", fid2, "slink_grp2", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname2); status = FAIL; goto out; } status = H5Lcreate_soft("/grp1/grp2/grp3", fid2, "slink_grp3", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname2); status = FAIL; goto out; } status = H5Lcreate_soft("/grp11", fid2, "slink_grp11", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", fname2); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * External Links - *------------------------------------------------------------------------*/ + * External Links + *------------------------------------------------------------------------*/ /* file1 */ status = H5Lcreate_external(fname2, "/grp1", fid1, "elink_grp1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); status = FAIL; goto out; } status = H5Lcreate_external(fname2, "/grp1/grp2", fid1, "elink_grp2", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); status = FAIL; goto out; } status = H5Lcreate_external(fname2, "/grp1/grp2/grp3", fid1, "elink_grp3", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); status = FAIL; goto out; } @@ -2575,48 +2576,48 @@ static int test_group_recurse(const char *fname1, const char *fname2) /* file2 */ status = H5Lcreate_external(fname1, "/grp1", fid2, "elink_grp1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname2); status = FAIL; goto out; } status = H5Lcreate_external(fname1, "/grp1/grp2", fid2, "elink_grp2", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname2); status = FAIL; goto out; } status = H5Lcreate_external(fname1, "/grp1/grp2/grp3", fid2, "elink_grp3", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname2); status = FAIL; goto out; } /*------------------------------ - * external circle route test - * file1/grp11 <-> file2/grp10 via elink_grp_circle link - */ + * external circle route test + * file1/grp11 <-> file2/grp10 via elink_grp_circle link + */ /* file1 */ status = H5Lcreate_external(fname2, "/grp11", gid10_f1, "elink_grp_circle", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname1); status = FAIL; goto out; } /* file2 */ status = H5Lcreate_external(fname1, "/grp10", gid11_f2, "elink_grp_circle", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", fname2); status = FAIL; goto out; } out: /*----------------------------------------------------------------------- - * Close - *-----------------------------------------------------------------------*/ + * Close + *-----------------------------------------------------------------------*/ if (fid1) H5Fclose(fid1); if (fid2) @@ -2648,137 +2649,138 @@ out: *-------------------------------------------------------------------------*/ #define GRP_R_DSETNAME1 "dset1" #define GRP_R_DSETNAME2 "dset2" -static int test_group_recurse2(void) +static int +test_group_recurse2(void) { - hid_t fileid1 = -1; - hid_t grp1 = -1; - hid_t grp2 = -1; - hid_t grp3 = -1; - hid_t grp4 = -1; - hid_t dset1 = -1; - hid_t dset2 = -1; - hid_t datatype = -1; - hid_t dataspace = -1; - hid_t fileid2 = -1; - hid_t fileid3 = -1; - hid_t fileid4 = -1; + hid_t fileid1 = H5I_INVALID_HID; + hid_t grp1 = H5I_INVALID_HID; + hid_t grp2 = H5I_INVALID_HID; + hid_t grp3 = H5I_INVALID_HID; + hid_t grp4 = H5I_INVALID_HID; + hid_t dset1 = H5I_INVALID_HID; + hid_t dset2 = H5I_INVALID_HID; + hid_t datatype = H5I_INVALID_HID; + hid_t dataspace = H5I_INVALID_HID; + hid_t fileid2 = H5I_INVALID_HID; + hid_t fileid3 = H5I_INVALID_HID; + hid_t fileid4 = H5I_INVALID_HID; hsize_t dimsf[2]; /* dataset dimensions */ - herr_t status = 0; - int data1[4][2] = { { 0, 0 }, { 1, 1 }, { 2, 2 }, { 3, 3 } }; - int data2[4][2] = { { 0, 0 }, { 0, 1 }, { 0, 2 }, { 3, 3 } }; + herr_t status = 0; + int data1[4][2] = {{0, 0}, {1, 1}, {2, 2}, {3, 3}}; + int data2[4][2] = {{0, 0}, {0, 1}, {0, 2}, {3, 3}}; /*----------------------------------------------------------------------- - * FILE 1 - *------------------------------------------------------------------------*/ + * FILE 1 + *------------------------------------------------------------------------*/ /* - * Create a new file using H5F_ACC_TRUNC access, - * default file creation properties, and default file - * access properties. - */ + * Create a new file using H5F_ACC_TRUNC access, + * default file creation properties, and default file + * access properties. + */ fileid1 = H5Fcreate(GRP_RECURSE1_EXT, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /*----------------------------------------------------------------------- - * Groups - *------------------------------------------------------------------------*/ + * Groups + *------------------------------------------------------------------------*/ grp1 = H5Gcreate2(fileid1, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (grp1 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", GRP_RECURSE1_EXT); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", GRP_RECURSE1_EXT); status = FAIL; goto out; } grp2 = H5Gcreate2(grp1, "g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (grp2 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", GRP_RECURSE1_EXT); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", GRP_RECURSE1_EXT); status = FAIL; goto out; } grp3 = H5Gcreate2(grp2, "g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (grp3 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", GRP_RECURSE1_EXT); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", GRP_RECURSE1_EXT); status = FAIL; goto out; } grp4 = H5Gcreate2(grp3, "g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (grp4 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", GRP_RECURSE1_EXT); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", GRP_RECURSE1_EXT); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * Datasets - *------------------------------------------------------------------------*/ + * Datasets + *------------------------------------------------------------------------*/ /* - * Describe the size of the array and create the data space for fixed - * size dataset. - */ - dimsf[0] = 4; - dimsf[1] = 2; + * Describe the size of the array and create the data space for fixed + * size dataset. + */ + dimsf[0] = 4; + dimsf[1] = 2; dataspace = H5Screate_simple(2, dimsf, NULL); /* - * Define datatype for the data in the file. - * We will store little endian INT numbers. - */ + * Define datatype for the data in the file. + * We will store little endian INT numbers. + */ datatype = H5Tcopy(H5T_NATIVE_INT); - status = H5Tset_order(datatype, H5T_ORDER_LE); + status = H5Tset_order(datatype, H5T_ORDER_LE); /*--------------- - * dset1 - */ + * dset1 + */ /* - * Create a new dataset within the file using defined dataspace and - * datatype and default dataset creation properties. - */ + * Create a new dataset within the file using defined dataspace and + * datatype and default dataset creation properties. + */ dset1 = H5Dcreate2(fileid1, GRP_R_DSETNAME1, datatype, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* - * Write the data to the dataset using default transfer properties. - */ + * Write the data to the dataset using default transfer properties. + */ status = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data1); H5Dclose(dset1); /*--------------- - * dset1 - */ + * dset1 + */ /* - * Create a new dataset within the file using defined dataspace and - * datatype and default dataset creation properties. - */ + * Create a new dataset within the file using defined dataspace and + * datatype and default dataset creation properties. + */ dset1 = H5Dcreate2(grp3, GRP_R_DSETNAME1, datatype, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* - * Write the data to the dataset using default transfer properties. - */ + * Write the data to the dataset using default transfer properties. + */ status = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data1); /*--------------- - * dset2 - */ + * dset2 + */ /* - * Create a new dataset within the fileid1 using defined dataspace and - * datatype and default dataset creation properties. - */ + * Create a new dataset within the fileid1 using defined dataspace and + * datatype and default dataset creation properties. + */ dset2 = H5Dcreate2(grp4, GRP_R_DSETNAME2, datatype, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* - * Write the data to the dataset using default transfer properties. - */ + * Write the data to the dataset using default transfer properties. + */ status = H5Dwrite(dset2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data2); /*----------------------------------------------------------------------- - * Soft links - *------------------------------------------------------------------------*/ + * Soft links + *------------------------------------------------------------------------*/ /* - * under '/' root - */ + * under '/' root + */ /* link to dset1 */ status = H5Lcreate_soft(GRP_R_DSETNAME1, fileid1, "soft_dset1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", GRP_RECURSE1_EXT); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", GRP_RECURSE1_EXT); status = FAIL; goto out; } @@ -2791,83 +2793,83 @@ static int test_group_recurse2(void) H5Gclose(grp4); /*----------------------------------------------------------------------- - * FILE 2-3 - *------------------------------------------------------------------------*/ + * FILE 2-3 + *------------------------------------------------------------------------*/ /* crate target file */ fileid4 = H5Fcreate(GRP_RECURSE2_EXT3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /*----------------------------------------------- - * Groups - */ + * Groups + */ grp4 = H5Gcreate2(fileid4, "/g4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (grp4 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", GRP_RECURSE2_EXT3); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", GRP_RECURSE2_EXT3); status = FAIL; goto out; } /*--------------- - * dset2 - */ + * dset2 + */ /* - * Create a new dataset within the fileid1 using defined dataspace and - * datatype and default dataset creation properties. - */ + * Create a new dataset within the fileid1 using defined dataspace and + * datatype and default dataset creation properties. + */ dset2 = H5Dcreate2(grp4, GRP_R_DSETNAME2, datatype, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* - * Write the data to the dataset using default transfer properties. - */ + * Write the data to the dataset using default transfer properties. + */ status = H5Dwrite(dset2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data2); H5Gclose(grp4); H5Dclose(dset2); /*----------------------------------------------------------------------- - * FILE 2-2 - *------------------------------------------------------------------------*/ + * FILE 2-2 + *------------------------------------------------------------------------*/ /* crate target file */ fileid3 = H5Fcreate(GRP_RECURSE2_EXT2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /*----------------------------------------------- - * Groups - */ + * Groups + */ grp2 = H5Gcreate2(fileid3, "g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (grp2 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", GRP_RECURSE2_EXT2); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", GRP_RECURSE2_EXT2); status = FAIL; goto out; } grp3 = H5Gcreate2(grp2, "g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (grp3 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", GRP_RECURSE2_EXT2); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", GRP_RECURSE2_EXT2); status = FAIL; goto out; } /*--------------- - * dset1 - */ + * dset1 + */ /* - * Create a new dataset within the fileid1 using defined dataspace and - * datatype and default dataset creation properties. - */ + * Create a new dataset within the fileid1 using defined dataspace and + * datatype and default dataset creation properties. + */ dset1 = H5Dcreate2(grp3, GRP_R_DSETNAME1, datatype, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* - * Write the data to the dataset using default transfer properties. - */ + * Write the data to the dataset using default transfer properties. + */ status = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data1); /*----------------------------------------------- - * extlink to $GRP_RECURSE2_EXT3/g4 - */ + * extlink to $GRP_RECURSE2_EXT3/g4 + */ status = H5Lcreate_external(GRP_RECURSE2_EXT3, "/g4", fileid3, "/g2/g3/g4", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", GRP_RECURSE2_EXT2); + HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", GRP_RECURSE2_EXT2); status = FAIL; goto out; } @@ -2877,52 +2879,52 @@ static int test_group_recurse2(void) H5Gclose(grp3); /*----------------------------------------------------------------------- - * FILE 2-1 - *------------------------------------------------------------------------*/ + * FILE 2-1 + *------------------------------------------------------------------------*/ /* crate target file */ fileid2 = H5Fcreate(GRP_RECURSE2_EXT1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /*----------------------------------------------- - * Groups - */ + * Groups + */ grp1 = H5Gcreate2(fileid2, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (grp1 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", GRP_RECURSE1_EXT); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", GRP_RECURSE1_EXT); status = FAIL; goto out; } /*--------------- - * dset1 - */ + * dset1 + */ dset1 = H5Dcreate2(fileid2, GRP_R_DSETNAME1, datatype, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* - * Write the data to the dataset using default transfer properties. - */ + * Write the data to the dataset using default transfer properties. + */ status = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data1); /*----------------------------------------------------------------------- - * Soft links - *------------------------------------------------------------------------*/ + * Soft links + *------------------------------------------------------------------------*/ /* - * under '/' root - */ + * under '/' root + */ /* link to dset1 */ status = H5Lcreate_soft(GRP_R_DSETNAME1, fileid2, "soft_dset1", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", GRP_RECURSE2_EXT1); + HDfprintf(stderr, "Error: %s> H5Lcreate_soft failed.\n", GRP_RECURSE2_EXT1); status = FAIL; goto out; } /*----------------------------------------------- - * extlink to $GRP_RECURSE2_EXT2/g2 - */ + * extlink to $GRP_RECURSE2_EXT2/g2 + */ status = H5Lcreate_external(GRP_RECURSE2_EXT2, "/g2", fileid2, "/g1/g2", H5P_DEFAULT, H5P_DEFAULT); if (status < 0) { - fprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", GRP_RECURSE2_EXT1); + HDfprintf(stderr, "Error: %s> H5Lcreate_external failed.\n", GRP_RECURSE2_EXT1); status = FAIL; goto out; } @@ -2932,8 +2934,8 @@ static int test_group_recurse2(void) out: /* - * Close/release resources. - */ + * Close/release resources. + */ if (dataspace > 0) H5Sclose(dataspace); if (datatype > 0) @@ -2959,41 +2961,42 @@ out: * Programmer: Jonathan Kim (July, 21, 2010) * *-------------------------------------------------------------------------*/ -static int test_exclude_obj1(const char *fname1, const char *fname2) +static int +test_exclude_obj1(const char *fname1, const char *fname2) { - hid_t fid1 = -1; - hid_t fid2 = -1; - hid_t gid1 = -1; - hid_t gid2 = -1; - hsize_t dims2[2] = { 2, 4 }; - int data1[4][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }; - int data2[4][2] = { { 0, 1 }, { 2, 3 }, { 1, 2 }, { 3, 4 } }; - herr_t status = SUCCEED; + hid_t fid1 = H5I_INVALID_HID; + hid_t fid2 = H5I_INVALID_HID; + hid_t gid1 = H5I_INVALID_HID; + hid_t gid2 = H5I_INVALID_HID; + hsize_t dims2[2] = {2, 4}; + int data1[4][2] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}}; + int data2[4][2] = {{0, 1}, {2, 3}, {1, 2}, {3, 4}}; + herr_t status = SUCCEED; /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { - fprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); status = FAIL; goto out; } fid2 = H5Fcreate(fname2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid2 < 0) { - fprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname2); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * Group - *------------------------------------------------------------------------*/ + * Group + *------------------------------------------------------------------------*/ /* file1 */ gid1 = H5Gcreate2(fid1, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid1 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); status = FAIL; goto out; } @@ -3002,32 +3005,32 @@ static int test_exclude_obj1(const char *fname1, const char *fname2) gid2 = H5Gcreate2(fid2, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid2 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * Datasets - *------------------------------------------------------------------------*/ + * Datasets + *------------------------------------------------------------------------*/ /* file1 */ status = write_dset(fid1, 2, dims2, "dset1", H5T_NATIVE_INT, data1); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname1); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname1); status = FAIL; goto out; } status = write_dset(gid1, 2, dims2, "dset2", H5T_NATIVE_INT, data1); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname1); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname1); status = FAIL; goto out; } status = write_dset(gid1, 2, dims2, "dset3", H5T_NATIVE_INT, data1); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname1); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname1); status = FAIL; goto out; } @@ -3035,29 +3038,29 @@ static int test_exclude_obj1(const char *fname1, const char *fname2) /* file2 */ status = write_dset(fid2, 2, dims2, "dset1", H5T_NATIVE_INT, data1); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname2); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname2); status = FAIL; goto out; } status = write_dset(gid2, 2, dims2, "dset2", H5T_NATIVE_INT, data1); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname2); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname2); status = FAIL; goto out; } status = write_dset(gid2, 2, dims2, "dset3", H5T_NATIVE_INT, data2); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname2); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname2); status = FAIL; goto out; } out: /*----------------------------------------------------------------------- - * Close - *-----------------------------------------------------------------------*/ + * Close + *-----------------------------------------------------------------------*/ if (fid1) H5Fclose(fid1); if (fid2) @@ -3079,42 +3082,43 @@ out: * Programmer: Jonathan Kim (July, 21, 2010) * *-------------------------------------------------------------------------*/ -static int test_exclude_obj2(const char *fname1, const char *fname2) +static int +test_exclude_obj2(const char *fname1, const char *fname2) { - hid_t fid1 = -1; - hid_t fid2 = -1; - hid_t gid1 = -1; - hid_t gid2 = -1; - hid_t gid3 = -1; - hsize_t dims2[2] = { 2, 4 }; - int data1[4][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }; - int data2[4][2] = { { 0, 1 }, { 2, 3 }, { 1, 2 }, { 3, 4 } }; - herr_t status = SUCCEED; + hid_t fid1 = H5I_INVALID_HID; + hid_t fid2 = H5I_INVALID_HID; + hid_t gid1 = H5I_INVALID_HID; + hid_t gid2 = H5I_INVALID_HID; + hid_t gid3 = H5I_INVALID_HID; + hsize_t dims2[2] = {2, 4}; + int data1[4][2] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}}; + int data2[4][2] = {{0, 1}, {2, 3}, {1, 2}, {3, 4}}; + herr_t status = SUCCEED; /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { - fprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); status = FAIL; goto out; } fid2 = H5Fcreate(fname2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid2 < 0) { - fprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname2); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * Group - *------------------------------------------------------------------------*/ + * Group + *------------------------------------------------------------------------*/ /* file1 */ gid1 = H5Gcreate2(fid1, "group10", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid1 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); status = FAIL; goto out; } @@ -3122,7 +3126,7 @@ static int test_exclude_obj2(const char *fname1, const char *fname2) /* file2 */ gid2 = H5Gcreate2(fid2, "group10", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid2 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); status = FAIL; goto out; } @@ -3131,32 +3135,32 @@ static int test_exclude_obj2(const char *fname1, const char *fname2) gid3 = H5Gcreate2(fid2, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid3 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * Datasets - *------------------------------------------------------------------------*/ + * Datasets + *------------------------------------------------------------------------*/ /* file1 */ status = write_dset(fid1, 2, dims2, "dset10", H5T_NATIVE_INT, data1); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname1); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname1); status = FAIL; goto out; } status = write_dset(fid1, 2, dims2, "dset1", H5T_NATIVE_INT, data1); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname1); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname1); status = FAIL; goto out; } status = write_dset(gid1, 2, dims2, "dset2", H5T_NATIVE_INT, data1); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname1); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname1); status = FAIL; goto out; } @@ -3164,29 +3168,29 @@ static int test_exclude_obj2(const char *fname1, const char *fname2) /* file2 */ status = write_dset(fid2, 2, dims2, "dset10", H5T_NATIVE_INT, data1); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname2); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname2); status = FAIL; goto out; } status = write_dset(gid2, 2, dims2, "dset2", H5T_NATIVE_INT, data1); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname2); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname2); status = FAIL; goto out; } status = write_dset(gid3, 2, dims2, "dset3", H5T_NATIVE_INT, data2); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname2); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname2); status = FAIL; goto out; } out: /*----------------------------------------------------------------------- - * Close - *-----------------------------------------------------------------------*/ + * Close + *-----------------------------------------------------------------------*/ if (fid1) H5Fclose(fid1); if (fid2) @@ -3210,57 +3214,58 @@ out: * Programmer: Jonathan Kim (Mar, 19, 2012) * *-------------------------------------------------------------------------*/ -static int test_exclude_obj3(const char *fname1, const char *fname2) +static int +test_exclude_obj3(const char *fname1, const char *fname2) { - hid_t fid1 = -1; - hid_t fid2 = -1; - hid_t gid1 = -1; - hsize_t dims2[2] = { 2, 4 }; - int data1[4][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }; - herr_t status = SUCCEED; + hid_t fid1 = H5I_INVALID_HID; + hid_t fid2 = H5I_INVALID_HID; + hid_t gid1 = H5I_INVALID_HID; + hsize_t dims2[2] = {2, 4}; + int data1[4][2] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}}; + herr_t status = SUCCEED; /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { - fprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); status = FAIL; goto out; } fid2 = H5Fcreate(fname2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid2 < 0) { - fprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname2); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * Group - *------------------------------------------------------------------------*/ + * Group + *------------------------------------------------------------------------*/ /* file1 */ gid1 = H5Gcreate2(fid1, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid1 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * Datasets - *------------------------------------------------------------------------*/ + * Datasets + *------------------------------------------------------------------------*/ /* file1 */ status = write_dset(fid1, 2, dims2, "dset1", H5T_NATIVE_INT, data1); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname1); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname1); status = FAIL; goto out; } status = write_dset(gid1, 2, dims2, "dset", H5T_NATIVE_INT, data1); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname1); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname1); status = FAIL; goto out; } @@ -3268,15 +3273,15 @@ static int test_exclude_obj3(const char *fname1, const char *fname2) /* file2 */ status = write_dset(fid2, 2, dims2, "dset1", H5T_NATIVE_INT, data1); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname2); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname2); status = FAIL; goto out; } out: /*----------------------------------------------------------------------- - * Close - *-----------------------------------------------------------------------*/ + * Close + *-----------------------------------------------------------------------*/ if (fid1) H5Fclose(fid1); if (fid2) @@ -3296,182 +3301,181 @@ out: * Programmer: Jonathan Kim (Oct, 26, 2010) * *-------------------------------------------------------------------------*/ -#define STR_RANK 1 -#define VLEN_STR_DIM 1 -#define FIXLEN_STR_SIZE 21 -#define FIXLEN_STR_DIM 1 -#define VLEN_STR_ARRY_DIM 3 -#define FIXLEN_STR_ARRY_DIM 3 +#define STR_RANK 1 +#define VLEN_STR_DIM 1 +#define FIXLEN_STR_SIZE 21 +#define FIXLEN_STR_DIM 1 +#define VLEN_STR_ARRY_DIM 3 +#define FIXLEN_STR_ARRY_DIM 3 #define FIXLEN_STR_ARRY_SIZE 30 -#define COMP_RANK 1 -#define COMP_DIM 1 -static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int is_file_new) +#define COMP_RANK 1 +#define COMP_DIM 1 +static int +test_comp_vlen_strings(const char *fname1, const char *grp_name, int is_file_new) { - int i; - hid_t fid1 = -1; /* file id */ - hid_t gid = -1; + int i; + hid_t fid1 = H5I_INVALID_HID; /* file id */ + hid_t gid = H5I_INVALID_HID; /* compound1 datatype */ typedef struct comp1_t { - char *str_vlen; /* vlen string */ - char *str_vlen_repeat; /* vlen string */ - char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ - char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ - const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ - const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ - char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + char * str_vlen; /* vlen string */ + char * str_vlen_repeat; /* vlen string */ + char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ + char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ + const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ + const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ } comp1_t; /* compound2 datatype */ typedef struct comp2_t { - char *str_vlen; /* vlen string */ - char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ - char *str_vlen_repeat; /* vlen string */ - char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ - const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ - char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ - char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + char * str_vlen; /* vlen string */ + char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ + char * str_vlen_repeat; /* vlen string */ + char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ + const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ } comp2_t; /* compound3 datatype */ typedef struct comp3_t { - char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ - char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ - char *str_vlen; /* vlen string */ - char *str_vlen_repeat; /* vlen string */ - char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ - const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ + char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ + char *str_vlen; /* vlen string */ + char *str_vlen_repeat; /* vlen string */ + char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ + const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ } comp3_t; /* compound4 datatype */ typedef struct comp4_t { - char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ - char *str_vlen; /* vlen string */ - char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ - char *str_vlen_repeat; /* vlen string */ - char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ - char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ + char * str_vlen; /* vlen string */ + char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ + char * str_vlen_repeat; /* vlen string */ + char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ } comp4_t; /* compound5 datatype */ typedef struct comp5_t { - const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ - const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ - char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - char *str_vlen; /* vlen string */ - char *str_vlen_repeat; /* vlen string */ - char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ - char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ + const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ + const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + char *str_vlen; /* vlen string */ + char *str_vlen_repeat; /* vlen string */ + char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ + char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ } comp5_t; /* compound6 datatype */ typedef struct comp6_t { - const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ - char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ - char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - char *str_vlen; /* vlen string */ - char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ - char *str_vlen_repeat; /* vlen string */ - char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ + const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + char *str_vlen; /* vlen string */ + char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ + char *str_vlen_repeat; /* vlen string */ + char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ } comp6_t; /* compound7 datatype */ typedef struct comp7_t { - char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ - const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ - char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ - char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ - char *str_vlen; /* vlen string */ - char *str_vlen_repeat; /* vlen string */ + const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ + const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ + char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ + char * str_vlen; /* vlen string */ + char * str_vlen_repeat; /* vlen string */ } comp7_t; /* compound8 datatype */ typedef struct comp8_t { - char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ - char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ - char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ - char *str_vlen; /* vlen string */ - char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ - char *str_vlen_repeat; /* vlen string */ + char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ + char * str_vlen; /* vlen string */ + char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ + char * str_vlen_repeat; /* vlen string */ } comp8_t; /* compound9 datatype */ typedef struct comp9_t { - char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ + char str_array_fixlen[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ char str_fixlen_array_again[FIXLEN_STR_ARRY_DIM][FIXLEN_STR_ARRY_SIZE]; /* fixed len string array */ - const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ - const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ - char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ - int int_data1; - hobj_ref_t objref1; /* reference */ - char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ - hobj_ref_t objref2; /* reference */ - char *str_vlen; /* vlen string */ - int int_data2; - char *str_vlen_repeat; /* vlen string */ - hobj_ref_t objref3; /* reference */ - int int_data3; + const char *str_array_vlen[VLEN_STR_ARRY_DIM]; /* vlen string array */ + const char *str_vlen_array_again[VLEN_STR_ARRY_DIM]; /* vlen string array */ + char str_fixlen[FIXLEN_STR_SIZE]; /* fixed len string */ + int int_data1; + hobj_ref_t objref1; /* reference */ + char str_fixlen_repeat[FIXLEN_STR_SIZE]; /* fixed len string */ + hobj_ref_t objref2; /* reference */ + char * str_vlen; /* vlen string */ + int int_data2; + char * str_vlen_repeat; /* vlen string */ + hobj_ref_t objref3; /* reference */ + int int_data3; } comp9_t; /* vlen string */ - hid_t sid_vlen_str = -1; /* dataspace ID */ - hid_t tid_vlen_str = -1; /* datatype ID */ - char vlen_str_buf[] = { "Variable length string" }; - hsize_t dims_vlen_str[] = { VLEN_STR_DIM }; + hid_t sid_vlen_str = H5I_INVALID_HID; /* dataspace ID */ + hid_t tid_vlen_str = H5I_INVALID_HID; /* datatype ID */ + char vlen_str_buf[] = {"Variable length string"}; + hsize_t dims_vlen_str[] = {VLEN_STR_DIM}; /* fixlen string */ - hid_t sid_fixlen_str = -1; /* dataspace ID */ - hid_t tid_fixlen_str = -1; /* datatype ID */ - const char fixlen_str_buf[FIXLEN_STR_SIZE] = { "Fixed length string" }; - hsize_t dims_fixlen_str[] = { FIXLEN_STR_DIM }; + hid_t sid_fixlen_str = H5I_INVALID_HID; /* dataspace ID */ + hid_t tid_fixlen_str = H5I_INVALID_HID; /* datatype ID */ + const char fixlen_str_buf[FIXLEN_STR_SIZE] = {"Fixed length string"}; + hsize_t dims_fixlen_str[] = {FIXLEN_STR_DIM}; /* vlen string array */ - hid_t sid_vlen_str_array = -1; /* dataspace ID */ - hid_t tid_vlen_str_array_pre = -1; /* datatype ID */ - hid_t tid_vlen_str_array = -1; /* datatype ID */ - const char *vlen_str_array_buf[VLEN_STR_ARRY_DIM] = - { "1 - Variable length string Array", - "2 - Testing variable length string array in compound type", - "3 - Four score and seven\n years ago our forefathers brought forth on this continent a new nation," }; - hsize_t dims_vlen_str_array[] = { VLEN_STR_ARRY_DIM }; + hid_t sid_vlen_str_array = H5I_INVALID_HID; /* dataspace ID */ + hid_t tid_vlen_str_array_pre = H5I_INVALID_HID; /* datatype ID */ + hid_t tid_vlen_str_array = H5I_INVALID_HID; /* datatype ID */ + const char *vlen_str_array_buf[VLEN_STR_ARRY_DIM] = { + "1 - Variable length string Array", "2 - Testing variable length string array in compound type", + "3 - Four score and seven\n years ago our forefathers brought forth on this continent a new nation,"}; + hsize_t dims_vlen_str_array[] = {VLEN_STR_ARRY_DIM}; /* fixlen string array */ - hid_t sid_fixlen_str_array = -1; /* dataspace ID */ - hid_t tid_fixlen_str_array_pre = -1; /* datatype ID */ - hid_t tid_fixlen_str_array = -1; /* datatype ID */ + hid_t sid_fixlen_str_array = H5I_INVALID_HID; /* dataspace ID */ + hid_t tid_fixlen_str_array_pre = H5I_INVALID_HID; /* datatype ID */ + hid_t tid_fixlen_str_array = H5I_INVALID_HID; /* datatype ID */ const char *fixlen_str_array_buf[FIXLEN_STR_ARRY_DIM] = { - "1 - Fixed length string Array", "2 - Fixed length string Array", - "3 - Fixed length string Array" }; - hsize_t dims_fixlen_str_array[] = { FIXLEN_STR_ARRY_DIM }; + "1 - Fixed length string Array", "2 - Fixed length string Array", "3 - Fixed length string Array"}; + hsize_t dims_fixlen_str_array[] = {FIXLEN_STR_ARRY_DIM}; /*------------------------------------------ - * compound dataset - *------------------------------------------*/ - hid_t sid_comp = -1; /* dataspace ID */ - hid_t tid1_comp = -1; /* datatype ID */ - hid_t tid2_comp = -1; /* datatype ID */ - hid_t tid3_comp = -1; /* datatype ID */ - hid_t tid4_comp = -1; /* datatype ID */ - hid_t tid5_comp = -1; /* datatype ID */ - hid_t tid6_comp = -1; /* datatype ID */ - hid_t tid7_comp = -1; /* datatype ID */ - hid_t tid8_comp = -1; /* datatype ID */ - hid_t tid9_comp = -1; /* datatype ID */ - hid_t did_comp = -1; /* dataset ID */ - hsize_t dims_comp[] = { COMP_DIM }; - herr_t status = SUCCEED; + * compound dataset + *------------------------------------------*/ + hid_t sid_comp = H5I_INVALID_HID; /* dataspace ID */ + hid_t tid1_comp = H5I_INVALID_HID; /* datatype ID */ + hid_t tid2_comp = H5I_INVALID_HID; /* datatype ID */ + hid_t tid3_comp = H5I_INVALID_HID; /* datatype ID */ + hid_t tid4_comp = H5I_INVALID_HID; /* datatype ID */ + hid_t tid5_comp = H5I_INVALID_HID; /* datatype ID */ + hid_t tid6_comp = H5I_INVALID_HID; /* datatype ID */ + hid_t tid7_comp = H5I_INVALID_HID; /* datatype ID */ + hid_t tid8_comp = H5I_INVALID_HID; /* datatype ID */ + hid_t tid9_comp = H5I_INVALID_HID; /* datatype ID */ + hid_t did_comp = H5I_INVALID_HID; /* dataset ID */ + hsize_t dims_comp[] = {COMP_DIM}; + herr_t status = SUCCEED; /* make compound strings data */ comp1_t comp1_buf; @@ -3528,25 +3532,15 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int /* copy vlen string array data to compound buffers */ for (i = 0; i < VLEN_STR_ARRY_DIM; i++) { - comp1_buf.str_array_vlen[i] = comp1_buf.str_vlen_array_again[i] = - vlen_str_array_buf[i]; - comp2_buf.str_array_vlen[i] = comp2_buf.str_vlen_array_again[i] = - vlen_str_array_buf[i]; - comp3_buf.str_array_vlen[i] = comp3_buf.str_vlen_array_again[i] = - vlen_str_array_buf[i]; - comp4_buf.str_array_vlen[i] = comp4_buf.str_vlen_array_again[i] = - vlen_str_array_buf[i]; - comp5_buf.str_array_vlen[i] = comp5_buf.str_vlen_array_again[i] = - vlen_str_array_buf[i]; - comp6_buf.str_array_vlen[i] = comp6_buf.str_vlen_array_again[i] = - vlen_str_array_buf[i]; - comp7_buf.str_array_vlen[i] = comp7_buf.str_vlen_array_again[i] = - vlen_str_array_buf[i]; - comp8_buf.str_array_vlen[i] = comp8_buf.str_vlen_array_again[i] = - vlen_str_array_buf[i]; - comp9_buf.str_array_vlen[i] = comp9_buf.str_vlen_array_again[i] = - vlen_str_array_buf[i]; - + comp1_buf.str_array_vlen[i] = comp1_buf.str_vlen_array_again[i] = vlen_str_array_buf[i]; + comp2_buf.str_array_vlen[i] = comp2_buf.str_vlen_array_again[i] = vlen_str_array_buf[i]; + comp3_buf.str_array_vlen[i] = comp3_buf.str_vlen_array_again[i] = vlen_str_array_buf[i]; + comp4_buf.str_array_vlen[i] = comp4_buf.str_vlen_array_again[i] = vlen_str_array_buf[i]; + comp5_buf.str_array_vlen[i] = comp5_buf.str_vlen_array_again[i] = vlen_str_array_buf[i]; + comp6_buf.str_array_vlen[i] = comp6_buf.str_vlen_array_again[i] = vlen_str_array_buf[i]; + comp7_buf.str_array_vlen[i] = comp7_buf.str_vlen_array_again[i] = vlen_str_array_buf[i]; + comp8_buf.str_array_vlen[i] = comp8_buf.str_vlen_array_again[i] = vlen_str_array_buf[i]; + comp9_buf.str_array_vlen[i] = comp9_buf.str_vlen_array_again[i] = vlen_str_array_buf[i]; } /* copy fixlen string attay data to compound buffers */ @@ -3585,12 +3579,12 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int comp9_buf.int_data3 = 30; /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ if (is_file_new == 1) { fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { - fprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); status = FAIL; goto out; } @@ -3598,72 +3592,72 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int else { fid1 = H5Fopen(fname1, H5F_ACC_RDWR, H5P_DEFAULT); if (fid1 < 0) { - fprintf(stderr, "Error: %s> H5Fopen failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Fopen failed.\n", fname1); status = FAIL; goto out; } } /*----------------------------------------------------------------------- - * Create group - *------------------------------------------------------------------------*/ + * Create group + *------------------------------------------------------------------------*/ gid = H5Gcreate2(fid1, grp_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * Variable length String1 - Create space and type - *------------------------------------------------------------------------*/ + * Variable length String1 - Create space and type + *------------------------------------------------------------------------*/ sid_vlen_str = H5Screate_simple(STR_RANK, dims_vlen_str, NULL); if (sid_vlen_str < 0) { - fprintf(stderr, "Error: %s> H5Screate_simple failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Screate_simple failed.\n", fname1); status = FAIL; goto out; } tid_vlen_str = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid_vlen_str, H5T_VARIABLE); + status = H5Tset_size(tid_vlen_str, H5T_VARIABLE); if (status < 0) { - fprintf(stderr, "Error: %s> H5Tset_size failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Tset_size failed.\n", fname1); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * Fixed length String2 - Create space and type - *------------------------------------------------------------------------*/ + * Fixed length String2 - Create space and type + *------------------------------------------------------------------------*/ sid_fixlen_str = H5Screate_simple(STR_RANK, dims_fixlen_str, NULL); if (sid_fixlen_str < 0) { - fprintf(stderr, "Error: %s> H5Screate_simple failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Screate_simple failed.\n", fname1); status = FAIL; goto out; } tid_fixlen_str = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid_fixlen_str, FIXLEN_STR_SIZE); + status = H5Tset_size(tid_fixlen_str, FIXLEN_STR_SIZE); if (status < 0) { - fprintf(stderr, "Error: %s> H5Tset_size failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Tset_size failed.\n", fname1); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * Fixed length String3 array - Create space and type - *------------------------------------------------------------------------*/ + * Fixed length String3 array - Create space and type + *------------------------------------------------------------------------*/ sid_vlen_str_array = H5Screate_simple(STR_RANK, dims_vlen_str_array, NULL); if (sid_vlen_str_array < 0) { - fprintf(stderr, "Error: %s> H5Screate_simple failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Screate_simple failed.\n", fname1); status = FAIL; goto out; } tid_vlen_str_array_pre = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid_vlen_str_array_pre, H5T_VARIABLE); + status = H5Tset_size(tid_vlen_str_array_pre, H5T_VARIABLE); if (status < 0) { - fprintf(stderr, "Error: %s> H5Tset_size failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Tset_size failed.\n", fname1); status = FAIL; goto out; } @@ -3671,42 +3665,42 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int /* Create the array data type for the string array */ tid_vlen_str_array = H5Tarray_create2(tid_vlen_str_array_pre, COMP_RANK, dims_vlen_str_array); if (tid_vlen_str_array < 0) { - fprintf(stderr, "Error: %s> H5Tarray_create2 failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Tarray_create2 failed.\n", fname1); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * Variable length String4 array - Create space and type - *------------------------------------------------------------------------*/ + * Variable length String4 array - Create space and type + *------------------------------------------------------------------------*/ sid_fixlen_str_array = H5Screate_simple(STR_RANK, dims_fixlen_str_array, NULL); if (sid_fixlen_str_array < 0) { - fprintf(stderr, "Error: %s> H5Screate_simple failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Screate_simple failed.\n", fname1); status = FAIL; goto out; } tid_fixlen_str_array_pre = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid_fixlen_str_array_pre, FIXLEN_STR_ARRY_SIZE); + status = H5Tset_size(tid_fixlen_str_array_pre, FIXLEN_STR_ARRY_SIZE); if (status < 0) { - fprintf(stderr, "Error: %s> H5Tset_size failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Tset_size failed.\n", fname1); status = FAIL; goto out; } /* Create the array data type for the string array */ tid_fixlen_str_array = H5Tarray_create2(tid_fixlen_str_array_pre, COMP_RANK, dims_fixlen_str_array); if (tid_fixlen_str_array < 0) { - fprintf(stderr, "Error: %s> H5Tarray_create2 failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Tarray_create2 failed.\n", fname1); status = FAIL; goto out; } /*------------------------------------------------------------------------- - * Compound dataset - *------------------------------------------------------------------------*/ + * Compound dataset + *------------------------------------------------------------------------*/ sid_comp = H5Screate_simple(COMP_RANK, dims_comp, NULL); if (sid_comp < 0) { - fprintf(stderr, "Error: %s> H5Screate_simple failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Screate_simple failed.\n", fname1); status = FAIL; goto out; } @@ -3766,7 +3760,7 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int H5Tinsert(tid5_comp, "FIXLEN_STR1", HOFFSET(comp5_t, str_fixlen), tid_fixlen_str); H5Tinsert(tid5_comp, "FIXLEN_STR2", HOFFSET(comp5_t, str_fixlen_repeat), tid_fixlen_str); H5Tinsert(tid5_comp, "VLEN_STR_ARRAY1", HOFFSET(comp5_t, str_array_vlen), tid_vlen_str_array); - H5Tinsert(tid5_comp, "VLEN_STR_ARRAY2", HOFFSET(comp5_t, str_vlen_array_again), tid_vlen_str_array); + H5Tinsert(tid5_comp, "VLEN_STR_ARRAY2", HOFFSET(comp5_t, str_vlen_array_again), tid_vlen_str_array); H5Tinsert(tid5_comp, "FIXLEN_STR_ARRAY1", HOFFSET(comp5_t, str_array_fixlen), tid_fixlen_str_array); H5Tinsert(tid5_comp, "FIXLEN_STR_ARRAY2", HOFFSET(comp5_t, str_fixlen_array_again), tid_fixlen_str_array); @@ -3818,9 +3812,9 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int /* Write data to compound 1 dataset buffer */ did_comp = H5Dcreate2(gid, "Compound_dset1", tid1_comp, sid_comp, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite(did_comp, tid1_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp1_buf); + status = H5Dwrite(did_comp, tid1_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp1_buf); if (status < 0) { - fprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname1); status = FAIL; goto out; } @@ -3828,9 +3822,9 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int /* Write data to compound 2 dataset buffer */ did_comp = H5Dcreate2(gid, "Compound_dset2", tid2_comp, sid_comp, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite(did_comp, tid2_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp2_buf); + status = H5Dwrite(did_comp, tid2_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp2_buf); if (status < 0) { - fprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname1); status = FAIL; goto out; } @@ -3838,9 +3832,9 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int /* Write data to compound 3 dataset buffer */ did_comp = H5Dcreate2(gid, "Compound_dset3", tid3_comp, sid_comp, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite(did_comp, tid3_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp3_buf); + status = H5Dwrite(did_comp, tid3_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp3_buf); if (status < 0) { - fprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname1); status = FAIL; goto out; } @@ -3848,9 +3842,9 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int /* Write data to compound 4 dataset buffer */ did_comp = H5Dcreate2(gid, "Compound_dset4", tid4_comp, sid_comp, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite(did_comp, tid4_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp4_buf); + status = H5Dwrite(did_comp, tid4_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp4_buf); if (status < 0) { - fprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname1); status = FAIL; goto out; } @@ -3858,9 +3852,9 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int /* Write data to compound 5 dataset buffer */ did_comp = H5Dcreate2(gid, "Compound_dset5", tid5_comp, sid_comp, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite(did_comp, tid5_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp5_buf); + status = H5Dwrite(did_comp, tid5_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp5_buf); if (status < 0) { - fprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname1); status = FAIL; goto out; } @@ -3868,9 +3862,9 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int /* Write data to compound 6 dataset buffer */ did_comp = H5Dcreate2(gid, "Compound_dset6", tid6_comp, sid_comp, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite(did_comp, tid6_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp6_buf); + status = H5Dwrite(did_comp, tid6_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp6_buf); if (status < 0) { - fprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname1); status = FAIL; goto out; } @@ -3878,9 +3872,9 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int /* Write data to compound 7 dataset buffer */ did_comp = H5Dcreate2(gid, "Compound_dset7", tid7_comp, sid_comp, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite(did_comp, tid7_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp7_buf); + status = H5Dwrite(did_comp, tid7_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp7_buf); if (status < 0) { - fprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname1); status = FAIL; goto out; } @@ -3888,9 +3882,9 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int /* Write data to compound 8 dataset buffer */ did_comp = H5Dcreate2(gid, "Compound_dset8", tid8_comp, sid_comp, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite(did_comp, tid8_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp8_buf); + status = H5Dwrite(did_comp, tid8_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp8_buf); if (status < 0) { - fprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname1); status = FAIL; goto out; } @@ -3900,24 +3894,24 @@ static int test_comp_vlen_strings(const char *fname1, const char *grp_name, int did_comp = H5Dcreate2(gid, "Compound_dset9", tid9_comp, sid_comp, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* obj references */ - status = H5Rcreate(&(comp9_buf.objref1), gid, "Compound_dset2", H5R_OBJECT, (hid_t) -1); - status = H5Rcreate(&(comp9_buf.objref2), gid, "Compound_dset3", H5R_OBJECT, (hid_t) -1); - status = H5Rcreate(&(comp9_buf.objref3), gid, "Compound_dset4", H5R_OBJECT, (hid_t) -1); + status = H5Rcreate(&(comp9_buf.objref1), gid, "Compound_dset2", H5R_OBJECT, (hid_t)-1); + status = H5Rcreate(&(comp9_buf.objref2), gid, "Compound_dset3", H5R_OBJECT, (hid_t)-1); + status = H5Rcreate(&(comp9_buf.objref3), gid, "Compound_dset4", H5R_OBJECT, (hid_t)-1); status = H5Dwrite(did_comp, tid9_comp, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comp9_buf); if (status < 0) { - fprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Dwrite failed.\n", fname1); status = FAIL; goto out; } H5Dclose(did_comp); - did_comp = -1; + did_comp = H5I_INVALID_HID; out: /*----------------------------------------------------------------------- - * Close - *-----------------------------------------------------------------------*/ + * Close + *-----------------------------------------------------------------------*/ if (fid1 > 0) H5Fclose(fid1); if (gid > 0) @@ -3981,86 +3975,87 @@ out: * *-------------------------------------------------------------------------*/ -static int test_enums(const char *fname) +static int +test_enums(const char *fname) { - hid_t fid = -1; + hid_t fid = H5I_INVALID_HID; - hid_t tid = -1; - int enum_val = -1; + hid_t tid = H5I_INVALID_HID; + int enum_val = -1; /* The data in the two arrays cover the following cases: - * - * V = valid enum value, I = invalid enum value - * - * 0: I-I (same value) - * 1: V-I - * 2: I-V - * 3: V-V (same value) - * 4: I-I (different values) SKIPPED FOR NOW - * 5: V-V (different values) - */ + * + * V = valid enum value, I = invalid enum value + * + * 0: I-I (same value) + * 1: V-I + * 2: I-V + * 3: V-V (same value) + * 4: I-I (different values) SKIPPED FOR NOW + * 5: V-V (different values) + */ /* *** NOTE *** - * - * There is a bug in H5Dread() where invalid enum values are always - * returned as -1 so two different invalid enum values cannot be - * properly compared. Test 4 has been adjusted to pass here - * while we fix the issue. - */ - int data1[6] = { 9, 0, 9, 0, 9, 0 }; + * + * There is a bug in H5Dread() where invalid enum values are always + * returned as -1 so two different invalid enum values cannot be + * properly compared. Test 4 has been adjusted to pass here + * while we fix the issue. + */ + int data1[6] = {9, 0, 9, 0, 9, 0}; /*int data1[6] = {9, 0, 9, 0, 8, 0}; */ - int data2[6] = { 9, 9, 0, 0, 9, 1 }; + int data2[6] = {9, 9, 0, 0, 9, 1}; hsize_t dims = 6; herr_t status = SUCCEED; /*----------------------------------------------------------------------- - * Create the file - *---------------------------------------------------------------------*/ + * Create the file + *---------------------------------------------------------------------*/ fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /*----------------------------------------------------------------------- - * Create enum types - *---------------------------------------------------------------------*/ + * Create enum types + *---------------------------------------------------------------------*/ - tid = H5Tenum_create(H5T_NATIVE_INT); + tid = H5Tenum_create(H5T_NATIVE_INT); enum_val = 0; - status = H5Tenum_insert(tid, "YIN", &enum_val); + status = H5Tenum_insert(tid, "YIN", &enum_val); if (status < 0) { - fprintf(stderr, "Error: %s> H5Tenum_insert failed.\n", fname); + HDfprintf(stderr, "Error: %s> H5Tenum_insert failed.\n", fname); status = FAIL; goto out; } enum_val = 1; - status = H5Tenum_insert(tid, "YANG", &enum_val); + status = H5Tenum_insert(tid, "YANG", &enum_val); if (status < 0) { - fprintf(stderr, "Error: %s> H5Tenum_insert failed.\n", fname); + HDfprintf(stderr, "Error: %s> H5Tenum_insert failed.\n", fname); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * Create datasets containing enum data. - *---------------------------------------------------------------------*/ + * Create datasets containing enum data. + *---------------------------------------------------------------------*/ status = write_dset(fid, 1, &dims, "dset1", tid, data1); if (status < 0) { - fprintf(stderr, "Error: %s> write_dset failed.\n", fname); + HDfprintf(stderr, "Error: %s> write_dset failed.\n", fname); status = FAIL; goto out; } status = write_dset(fid, 1, &dims, "dset2", tid, data2); if (status < 0) { - fprintf(stderr, "Error: %s> write_dset failed.\n", fname); + HDfprintf(stderr, "Error: %s> write_dset failed.\n", fname); status = FAIL; goto out; } out: /*----------------------------------------------------------------------- - * Close - *---------------------------------------------------------------------*/ + * Close + *---------------------------------------------------------------------*/ if (fid) H5Fclose(fid); if (tid) @@ -4090,56 +4085,57 @@ out: * Programmer: Jonathan Kim (Sep, 1, 2011) * *-------------------------------------------------------------------------*/ -#define SDIM_DSET 2 +#define SDIM_DSET 2 #define SDIM_CMPD_ARRAY 2 -static void test_comps_array(const char *fname, const char *dset, const char *attr, int diff, int is_file_new) +static void +test_comps_array(const char *fname, const char *dset, const char *attr, int diff, int is_file_new) { /* sub compound 2 */ typedef struct { - int i2; + int i2; float f2; } cmpd2_t; /* top compound 1 */ typedef struct { - int i1; + int i1; cmpd2_t cmpd2[SDIM_CMPD_ARRAY]; } cmpd1_t; cmpd1_t wdata[SDIM_DSET]; /* dataset with compound1 */ - hid_t fid = -1; /* HDF5 File IDs */ - hid_t did_dset = -1; /* Dataset ID */ - hid_t sid_dset = -1; /* Dataset space ID */ - hid_t tid_cmpd1 = -1; /* Compound1 type ID */ - hid_t tid_arry1 = -1; /* Array type ID in compound1 */ - hid_t tid_cmpd2 = -1; /* Compound2 type ID */ - hid_t tid_attr = -1; - hsize_t sdims_dset[] = { SDIM_DSET }; - hsize_t sdims_cmpd_arry[] = { SDIM_CMPD_ARRAY }; - int i, j; - herr_t ret; /* Generic return value */ + hid_t fid = H5I_INVALID_HID; /* HDF5 File IDs */ + hid_t did_dset = H5I_INVALID_HID; /* Dataset ID */ + hid_t sid_dset = H5I_INVALID_HID; /* Dataset space ID */ + hid_t tid_cmpd1 = H5I_INVALID_HID; /* Compound1 type ID */ + hid_t tid_arry1 = H5I_INVALID_HID; /* Array type ID in compound1 */ + hid_t tid_cmpd2 = H5I_INVALID_HID; /* Compound2 type ID */ + hid_t tid_attr = H5I_INVALID_HID; + hsize_t sdims_dset[] = {SDIM_DSET}; + hsize_t sdims_cmpd_arry[] = {SDIM_CMPD_ARRAY}; + int i, j; + herr_t ret; /* Generic return value */ /* Initialize array data to write */ for (i = 0; i < SDIM_DSET; i++) { wdata[i].i1 = i; for (j = 0; j < SDIM_CMPD_ARRAY; j++) { wdata[i].cmpd2[j].i2 = i * 10 + diff; - wdata[i].cmpd2[j].f2 = (float) i * 10.5F + (float) diff; + wdata[i].cmpd2[j].f2 = (float)i * 10.5F + (float)diff; } /* end for */ } /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ if (is_file_new == 1) fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); else fid = H5Fopen(fname, H5F_ACC_RDWR, H5P_DEFAULT); /* ------------------------------- - * Create a sub compound2 datatype */ + * Create a sub compound2 datatype */ tid_cmpd2 = H5Tcreate(H5T_COMPOUND, sizeof(cmpd2_t)); /* Insert integer field */ @@ -4151,8 +4147,8 @@ static void test_comps_array(const char *fname, const char *dset, const char *at assert(ret >= 0); /*----------------------------------- - * Create a top compound1. - */ + * Create a top compound1. + */ tid_cmpd1 = H5Tcreate(H5T_COMPOUND, sizeof(cmpd1_t)); ret = H5Tinsert(tid_cmpd1, "int1", HOFFSET(cmpd1_t, i1), H5T_NATIVE_INT); @@ -4165,8 +4161,8 @@ static void test_comps_array(const char *fname, const char *dset, const char *at assert(ret >= 0); /* ------------------- - * Create a dataset - */ + * Create a dataset + */ /* Create dataspace for datasets */ sid_dset = H5Screate_simple(1, sdims_dset, NULL); @@ -4177,15 +4173,15 @@ static void test_comps_array(const char *fname, const char *dset, const char *at assert(ret >= 0); /*----------------------------------- - * Create an attribute in root group - */ + * Create an attribute in root group + */ tid_attr = H5Acreate2(fid, attr, tid_cmpd1, sid_dset, H5P_DEFAULT, H5P_DEFAULT); assert(tid_attr > 0); ret = H5Awrite(tid_attr, tid_cmpd1, wdata); assert(ret >= 0); /* ---------------- - * Close Dataset */ + * Close Dataset */ ret = H5Aclose(tid_attr); assert(ret >= 0); ret = H5Tclose(tid_arry1); @@ -4202,57 +4198,56 @@ static void test_comps_array(const char *fname, const char *dset, const char *at assert(ret >= 0); } -static void test_comps_vlen(const char * fname, const char *dset, const char *attr, int diff, int is_file_new) +static void +test_comps_vlen(const char *fname, const char *dset, const char *attr, int diff, int is_file_new) { /* sub compound 2 */ typedef struct { - int i2; + int i2; float f2; } cmpd2_t; /* top compound 1 */ typedef struct { - int i1; + int i1; hvl_t vl; /* VL information for compound2 */ } cmpd1_t; cmpd1_t wdata[SDIM_DSET]; /* Dataset for compound1 */ - hid_t fid = -1; /* HDF5 File ID */ - hid_t did_dset = -1; /* dataset ID */ - hid_t sid_dset = -1; /* dataset space ID */ - hid_t tid_attr = -1; - hid_t tid_cmpd2 = -1; /* compound2 type ID */ - hid_t tid_cmpd1 = -1; /* compound1 type ID */ - hid_t tid_cmpd1_vlen = -1; - hsize_t sdims_dset[] = { SDIM_DSET }; + hid_t fid = H5I_INVALID_HID; /* HDF5 File ID */ + hid_t did_dset = H5I_INVALID_HID; /* dataset ID */ + hid_t sid_dset = H5I_INVALID_HID; /* dataset space ID */ + hid_t tid_attr = H5I_INVALID_HID; + hid_t tid_cmpd2 = H5I_INVALID_HID; /* compound2 type ID */ + hid_t tid_cmpd1 = H5I_INVALID_HID; /* compound1 type ID */ + hid_t tid_cmpd1_vlen = H5I_INVALID_HID; + hsize_t sdims_dset[] = {SDIM_DSET}; unsigned i, j; /* counting variables */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Allocate and initialize VL data to write */ for (i = 0; i < SDIM_DSET; i++) { - wdata[i].i1 = (int) i; - wdata[i].vl.p = HDmalloc((i + 1) * sizeof(cmpd2_t)); + wdata[i].i1 = (int)i; + wdata[i].vl.p = HDmalloc((i + 1) * sizeof(cmpd2_t)); wdata[i].vl.len = i + 1; for (j = 0; j < (i + 1); j++) { - ((cmpd2_t *) wdata[i].vl.p)[j].i2 = - (int) (i * 10 + (unsigned) diff); - ((cmpd2_t *) wdata[i].vl.p)[j].f2 = (float) i * 10.5F - + (float) diff; + ((cmpd2_t *)wdata[i].vl.p)[j].i2 = (int)(i * 10 + (unsigned)diff); + ((cmpd2_t *)wdata[i].vl.p)[j].f2 = (float)i * 10.5F + (float)diff; } /* end for */ - } /* end for */ + } /* end for */ /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ if (is_file_new == 1) fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); else fid = H5Fopen(fname, H5F_ACC_RDWR, H5P_DEFAULT); /* ----------------------------- - * Create sub compound2 type */ + * Create sub compound2 type */ tid_cmpd2 = H5Tcreate(H5T_COMPOUND, sizeof(cmpd2_t)); /* Insert fields */ @@ -4262,7 +4257,7 @@ static void test_comps_vlen(const char * fname, const char *dset, const char *at assert(ret >= 0); /* --------------------------- - * Create top compound1 type */ + * Create top compound1 type */ tid_cmpd1 = H5Tcreate(H5T_COMPOUND, sizeof(cmpd1_t)); /* Insert fields */ ret = H5Tinsert(tid_cmpd1, "int1", HOFFSET(cmpd1_t, i1), H5T_NATIVE_INT); @@ -4274,8 +4269,8 @@ static void test_comps_vlen(const char * fname, const char *dset, const char *at assert(ret >= 0); /* ------------------------------- - * Create dataset with compound1 - */ + * Create dataset with compound1 + */ /* Create dataspace for dataset */ sid_dset = H5Screate_simple(1, sdims_dset, NULL); @@ -4287,8 +4282,8 @@ static void test_comps_vlen(const char * fname, const char *dset, const char *at assert(ret >= 0); /*----------------------------------- - * Create an attribute in root group - */ + * Create an attribute in root group + */ tid_attr = H5Acreate2(fid, attr, tid_cmpd1, sid_dset, H5P_DEFAULT, H5P_DEFAULT); assert(tid_attr > 0); ret = H5Awrite(tid_attr, tid_cmpd1, wdata); @@ -4299,7 +4294,7 @@ static void test_comps_vlen(const char * fname, const char *dset, const char *at assert(ret >= 0); /* ---------------- - * Close IDs */ + * Close IDs */ ret = H5Aclose(tid_attr); assert(ret >= 0); ret = H5Dclose(did_dset); @@ -4316,60 +4311,59 @@ static void test_comps_vlen(const char * fname, const char *dset, const char *at assert(ret >= 0); } -static void test_comps_array_vlen(const char * fname, const char *dset, const char *attr, int diff, int is_file_new) +static void +test_comps_array_vlen(const char *fname, const char *dset, const char *attr, int diff, int is_file_new) { typedef struct { - int i3; + int i3; float f3; } cmpd3_t; typedef struct { /* Typedef for compound datatype */ - int i2; + int i2; hvl_t vl; /* VL information to write */ } cmpd2_t; typedef struct { - int i1; + int i1; cmpd2_t cmpd2[SDIM_CMPD_ARRAY]; } cmpd1_t; - cmpd1_t wdata[SDIM_DSET]; /* Information to write */ - hid_t fid = -1; /* HDF5 File IDs */ - hid_t did_dset = -1; /* Dataset ID */ - hid_t sid_dset = -1; /* Dataspace ID */ - hid_t tid_attr = -1; - hid_t tid_cmpd1 = -1; /* Compound1 Datatype ID */ - hid_t tid_arry1 = -1; /* Array Datatype ID */ - hid_t tid_cmpd2 = -1; /* Compound2 Datatype ID */ - hid_t tid_cmpd2_vlen = -1; - hid_t tid_cmpd3 = -1; /* Compound3 Datatype ID */ - hsize_t sdims_dset[] = { SDIM_DSET }; - hsize_t sdims_arry[] = { SDIM_CMPD_ARRAY }; + cmpd1_t wdata[SDIM_DSET]; /* Information to write */ + hid_t fid = H5I_INVALID_HID; /* HDF5 File IDs */ + hid_t did_dset = H5I_INVALID_HID; /* Dataset ID */ + hid_t sid_dset = H5I_INVALID_HID; /* Dataspace ID */ + hid_t tid_attr = H5I_INVALID_HID; + hid_t tid_cmpd1 = H5I_INVALID_HID; /* Compound1 Datatype ID */ + hid_t tid_arry1 = H5I_INVALID_HID; /* Array Datatype ID */ + hid_t tid_cmpd2 = H5I_INVALID_HID; /* Compound2 Datatype ID */ + hid_t tid_cmpd2_vlen = H5I_INVALID_HID; + hid_t tid_cmpd3 = H5I_INVALID_HID; /* Compound3 Datatype ID */ + hsize_t sdims_dset[] = {SDIM_DSET}; + hsize_t sdims_arry[] = {SDIM_CMPD_ARRAY}; unsigned i, j, k; /* counting variables */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Initialize array data to write in compound1 */ for (i = 0; i < SDIM_DSET; i++) { - wdata[i].i1 = (int) i; + wdata[i].i1 = (int)i; /* Allocate and initialize VL data to write in compound2 */ for (j = 0; j < SDIM_CMPD_ARRAY; j++) { - wdata[i].cmpd2[j].i2 = (int) (j * 10); - wdata[i].cmpd2[j].vl.p = HDmalloc((j + 1) * sizeof(cmpd3_t)); + wdata[i].cmpd2[j].i2 = (int)(j * 10); + wdata[i].cmpd2[j].vl.p = HDmalloc((j + 1) * sizeof(cmpd3_t)); wdata[i].cmpd2[j].vl.len = j + 1; for (k = 0; k < (j + 1); k++) { /* Initialize data of compound3 */ - ((cmpd3_t *) wdata[i].cmpd2[j].vl.p)[k].i3 = (int) j * 10 - + diff; - ((cmpd3_t *) wdata[i].cmpd2[j].vl.p)[k].f3 = (float) j * 10.5F - + (float) diff; + ((cmpd3_t *)wdata[i].cmpd2[j].vl.p)[k].i3 = (int)j * 10 + diff; + ((cmpd3_t *)wdata[i].cmpd2[j].vl.p)[k].f3 = (float)j * 10.5F + (float)diff; } /* end for */ - } /* end for */ + } /* end for */ } /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ if (is_file_new == 1) fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); else @@ -4379,7 +4373,7 @@ static void test_comps_array_vlen(const char * fname, const char *dset, const ch sid_dset = H5Screate_simple(1, sdims_dset, NULL); /*------------------------------------- - * Create a sub compound3 datatype */ + * Create a sub compound3 datatype */ tid_cmpd3 = H5Tcreate(H5T_COMPOUND, sizeof(cmpd3_t)); /* Insert integer field */ @@ -4391,7 +4385,7 @@ static void test_comps_array_vlen(const char * fname, const char *dset, const ch assert(ret >= 0); /*------------------------------------- - * Create a sub compound2 datatype */ + * Create a sub compound2 datatype */ tid_cmpd2 = H5Tcreate(H5T_COMPOUND, sizeof(cmpd2_t)); /* Insert integer field */ @@ -4399,12 +4393,12 @@ static void test_comps_array_vlen(const char * fname, const char *dset, const ch assert(ret >= 0); /* Create a VL datatype */ tid_cmpd2_vlen = H5Tvlen_create(tid_cmpd3); - ret = H5Tinsert(tid_cmpd2, "vlen", HOFFSET(cmpd2_t, vl), tid_cmpd2_vlen); + ret = H5Tinsert(tid_cmpd2, "vlen", HOFFSET(cmpd2_t, vl), tid_cmpd2_vlen); assert(ret >= 0); /*----------------------------------- - * Create a top compound1 datatype for dataset. - */ + * Create a top compound1 datatype for dataset. + */ tid_cmpd1 = H5Tcreate(H5T_COMPOUND, sizeof(cmpd1_t)); /* Create an array datatype */ @@ -4413,7 +4407,7 @@ static void test_comps_array_vlen(const char * fname, const char *dset, const ch H5Tinsert(tid_cmpd1, "array_comp", HOFFSET(cmpd1_t, cmpd2), tid_arry1); /* ---------------------- - * Create a dataset */ + * Create a dataset */ did_dset = H5Dcreate2(fid, dset, tid_cmpd1, sid_dset, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* Write dataset to disk */ @@ -4421,8 +4415,8 @@ static void test_comps_array_vlen(const char * fname, const char *dset, const ch assert(ret >= 0); /*----------------------------------- - * Create an attribute in root group - */ + * Create an attribute in root group + */ tid_attr = H5Acreate2(fid, attr, tid_cmpd1, sid_dset, H5P_DEFAULT, H5P_DEFAULT); assert(tid_attr > 0); ret = H5Awrite(tid_attr, tid_cmpd1, wdata); @@ -4433,7 +4427,7 @@ static void test_comps_array_vlen(const char * fname, const char *dset, const ch assert(ret >= 0); /*------------------- - * Close IDs */ + * Close IDs */ ret = H5Aclose(tid_attr); assert(ret >= 0); ret = H5Tclose(tid_arry1); @@ -4454,70 +4448,71 @@ static void test_comps_array_vlen(const char * fname, const char *dset, const ch assert(ret >= 0); } -static void test_comps_vlen_arry(const char * fname, const char *dset, const char *attr, int diff, int is_file_new) +static void +test_comps_vlen_arry(const char *fname, const char *dset, const char *attr, int diff, int is_file_new) { /* sub compound 3 */ typedef struct { - int i3; + int i3; float f3; } cmpd3_t; /* sub compound 2 */ typedef struct { - int i2; + int i2; cmpd3_t cmpd3[SDIM_CMPD_ARRAY]; } cmpd2_t; /* top compound 1 */ typedef struct { - int i1; + int i1; hvl_t vl; /* VL information for compound2 */ } cmpd1_t; cmpd1_t wdata[SDIM_DSET]; /* Dataset for compound1 */ - hid_t fid = -1; /* HDF5 File ID */ - hid_t did_dset = -1; /* dataset ID */ - hid_t sid_dset = -1; /* dataset space ID */ - hid_t tid_attr = -1; - hid_t tid_cmpd3 = -1; /* compound3 type ID */ - hid_t tid_cmpd2 = -1; /* compound2 type ID */ - hid_t tid_cmpd2_arry = -1; - hid_t tid_cmpd1 = -1; /* compound1 type ID */ - hid_t tid_cmpd1_vlen = -1; - hsize_t sdims_dset[] = { SDIM_DSET }; - hsize_t sdims_cmpd_arry[] = { SDIM_CMPD_ARRAY }; + hid_t fid = H5I_INVALID_HID; /* HDF5 File ID */ + hid_t did_dset = H5I_INVALID_HID; /* dataset ID */ + hid_t sid_dset = H5I_INVALID_HID; /* dataset space ID */ + hid_t tid_attr = H5I_INVALID_HID; + hid_t tid_cmpd3 = H5I_INVALID_HID; /* compound3 type ID */ + hid_t tid_cmpd2 = H5I_INVALID_HID; /* compound2 type ID */ + hid_t tid_cmpd2_arry = H5I_INVALID_HID; + hid_t tid_cmpd1 = H5I_INVALID_HID; /* compound1 type ID */ + hid_t tid_cmpd1_vlen = H5I_INVALID_HID; + hsize_t sdims_dset[] = {SDIM_DSET}; + hsize_t sdims_cmpd_arry[] = {SDIM_CMPD_ARRAY}; unsigned i, j, k; /* counting variables */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Allocate and initialize VL data to write */ for (i = 0; i < SDIM_DSET; i++) { /* compound 1 data */ - wdata[i].i1 = (int) i; - wdata[i].vl.p = HDmalloc((i + 1) * sizeof(cmpd2_t)); + wdata[i].i1 = (int)i; + wdata[i].vl.p = HDmalloc((i + 1) * sizeof(cmpd2_t)); wdata[i].vl.len = i + 1; for (j = 0; j < (i + 1); j++) { /* compound2 data */ - ((cmpd2_t *) wdata[i].vl.p)[j].i2 = (int) i * 10 + diff; + ((cmpd2_t *)wdata[i].vl.p)[j].i2 = (int)i * 10 + diff; for (k = 0; k < SDIM_CMPD_ARRAY; k++) { /* compound 3 data */ - ((cmpd2_t *) (wdata[i].vl.p))[j].cmpd3[k].i3 = (int) ((float) k * 10.5F) + diff; - ((cmpd2_t *) (wdata[i].vl.p))[j].cmpd3[k].f3 = (float) k * 10.5F + (float) diff; + ((cmpd2_t *)(wdata[i].vl.p))[j].cmpd3[k].i3 = (int)((float)k * 10.5F) + diff; + ((cmpd2_t *)(wdata[i].vl.p))[j].cmpd3[k].f3 = (float)k * 10.5F + (float)diff; } /* end for */ - } /* end for */ - } /* end for */ + } /* end for */ + } /* end for */ /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ if (is_file_new == 1) fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); else fid = H5Fopen(fname, H5F_ACC_RDWR, H5P_DEFAULT); /* ----------------------------- - * Create sub compound3 type */ + * Create sub compound3 type */ tid_cmpd3 = H5Tcreate(H5T_COMPOUND, sizeof(cmpd3_t)); /* Insert fields */ @@ -4527,45 +4522,44 @@ static void test_comps_vlen_arry(const char * fname, const char *dset, const cha assert(ret >= 0); /* ----------------------------- - * Create sub compound2 type */ + * Create sub compound2 type */ tid_cmpd2 = H5Tcreate(H5T_COMPOUND, sizeof(cmpd2_t)); ret = H5Tinsert(tid_cmpd2, "int2", HOFFSET(cmpd2_t, i2), H5T_NATIVE_INT); assert(ret >= 0); tid_cmpd2_arry = H5Tarray_create2(tid_cmpd3, 1, sdims_cmpd_arry); - ret = H5Tinsert(tid_cmpd2, "array_cmpd2", HOFFSET(cmpd2_t, cmpd3), tid_cmpd2_arry); + ret = H5Tinsert(tid_cmpd2, "array_cmpd2", HOFFSET(cmpd2_t, cmpd3), tid_cmpd2_arry); assert(ret >= 0); /* --------------------------- - * Create top compound1 type - */ + * Create top compound1 type + */ /* Create a VL datatype */ tid_cmpd1 = H5Tcreate(H5T_COMPOUND, sizeof(cmpd1_t)); /* Insert fields */ ret = H5Tinsert(tid_cmpd1, "int1", HOFFSET(cmpd1_t, i1), H5T_NATIVE_INT); assert(ret >= 0); tid_cmpd1_vlen = H5Tvlen_create(tid_cmpd2); - ret = H5Tinsert(tid_cmpd1, "vlen_cmpd1", HOFFSET(cmpd1_t, vl), tid_cmpd1_vlen); + ret = H5Tinsert(tid_cmpd1, "vlen_cmpd1", HOFFSET(cmpd1_t, vl), tid_cmpd1_vlen); assert(ret >= 0); /* ------------------------------- - * Create dataset with compound1 - */ + * Create dataset with compound1 + */ /* Create dataspace for dataset */ sid_dset = H5Screate_simple(1, sdims_dset, NULL); /* Create a dataset */ - did_dset = H5Dcreate2(fid, dset, tid_cmpd1, sid_dset, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); + did_dset = H5Dcreate2(fid, dset, tid_cmpd1, sid_dset, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* Write dataset to disk */ ret = H5Dwrite(did_dset, tid_cmpd1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); assert(ret >= 0); /*----------------------------------- - * Create an attribute in root group - */ + * Create an attribute in root group + */ tid_attr = H5Acreate2(fid, attr, tid_cmpd1, sid_dset, H5P_DEFAULT, H5P_DEFAULT); assert(tid_attr > 0); ret = H5Awrite(tid_attr, tid_cmpd1, wdata); @@ -4576,7 +4570,7 @@ static void test_comps_vlen_arry(const char * fname, const char *dset, const cha assert(ret >= 0); /* ---------------- - * Close IDs */ + * Close IDs */ ret = H5Aclose(tid_attr); assert(ret >= 0); ret = H5Dclose(did_dset); @@ -4607,122 +4601,122 @@ static void test_comps_vlen_arry(const char * fname, const char *dset, const cha * *-------------------------------------------------------------------------*/ #define DIM_ARRY 3 -static void test_data_nocomparables(const char * fname, int make_diffs) +static void +test_data_nocomparables(const char *fname, int make_diffs) { - hid_t fid = -1; - hid_t gid1 = -1; - hid_t gid2 = -1; - hid_t did1 = -1; - hid_t did2 = -1; - hid_t sid1 = -1; - hid_t tid_dset1 = -1; - hid_t tid_attr1 = -1; - hsize_t dims1_1[1] = { DIM_ARRY }; - hsize_t dims1_2[1] = { DIM_ARRY + 1 }; - hsize_t dims2[2] = { DIM_ARRY, 1 }; - int data1[DIM_ARRY] = { 0, 0, 0 }; - int data2[DIM_ARRY] = { 1, 1, 1 }; - int data3[DIM_ARRY + 1] = { 1, 1, 1, 1 }; - int data1_dim2[DIM_ARRY][1] = { { 0 }, { 0 }, { 0 } }; - int rank_attr; - char data1_str[DIM_ARRY][STR_SIZE] = { "ab", "cd", "ef" }; - herr_t status = SUCCEED; - void *dset_data_ptr1 = NULL; - void *dset_data_ptr2 = NULL; - void *dset_data_ptr3 = NULL; - void *attr_data_ptr1 = NULL; - void *attr_data_ptr2 = NULL; - void *attr_data_ptr3 = NULL; - void *attr_data_ptr4 = NULL; - void *attr2_dim_ptr = NULL; - void *attr3_dim_ptr = NULL; + hid_t fid = H5I_INVALID_HID; + hid_t gid1 = H5I_INVALID_HID; + hid_t gid2 = H5I_INVALID_HID; + hid_t did1 = H5I_INVALID_HID; + hid_t did2 = H5I_INVALID_HID; + hid_t sid1 = H5I_INVALID_HID; + hid_t tid_dset1 = H5I_INVALID_HID; + hid_t tid_attr1 = H5I_INVALID_HID; + hsize_t dims1_1[1] = {DIM_ARRY}; + hsize_t dims1_2[1] = {DIM_ARRY + 1}; + hsize_t dims2[2] = {DIM_ARRY, 1}; + int data1[DIM_ARRY] = {0, 0, 0}; + int data2[DIM_ARRY] = {1, 1, 1}; + int data3[DIM_ARRY + 1] = {1, 1, 1, 1}; + int data1_dim2[DIM_ARRY][1] = {{0}, {0}, {0}}; + int rank_attr; + char data1_str[DIM_ARRY][STR_SIZE] = {"ab", "cd", "ef"}; + herr_t status = SUCCEED; + void * dset_data_ptr1 = NULL; + void * dset_data_ptr2 = NULL; + void * dset_data_ptr3 = NULL; + void * attr_data_ptr1 = NULL; + void * attr_data_ptr2 = NULL; + void * attr_data_ptr3 = NULL; + void * attr_data_ptr4 = NULL; + void * attr2_dim_ptr = NULL; + void * attr3_dim_ptr = NULL; /* init */ - tid_dset1 = H5Tcopy(H5T_NATIVE_INT); - dset_data_ptr1 = (int*) &data1; - dset_data_ptr2 = (int*) &data1; - dset_data_ptr3 = (int*) &data1; - tid_attr1 = H5Tcopy(H5T_NATIVE_INT); - attr_data_ptr1 = (int*) &data1; - attr_data_ptr3 = (int*) &data1; - attr_data_ptr4 = (int*) &data1; - attr2_dim_ptr = (hsize_t*) &dims1_1; - attr3_dim_ptr = (hsize_t*) &dims1_1; - rank_attr = 1; + tid_dset1 = H5Tcopy(H5T_NATIVE_INT); + dset_data_ptr1 = (int *)&data1; + dset_data_ptr2 = (int *)&data1; + dset_data_ptr3 = (int *)&data1; + tid_attr1 = H5Tcopy(H5T_NATIVE_INT); + attr_data_ptr1 = (int *)&data1; + attr_data_ptr3 = (int *)&data1; + attr_data_ptr4 = (int *)&data1; + attr2_dim_ptr = (hsize_t *)&dims1_1; + attr3_dim_ptr = (hsize_t *)&dims1_1; + rank_attr = 1; if (make_diffs) { /* ------------ - * group1 */ + * group1 */ tid_dset1 = H5Tcopy(H5T_C_S1); - H5Tset_size(tid_dset1, (size_t) STR_SIZE); - dset_data_ptr1 = (char*) &data1_str; - dset_data_ptr2 = (int*) &data2; - attr_data_ptr1 = (int*) &data2; + H5Tset_size(tid_dset1, (size_t)STR_SIZE); + dset_data_ptr1 = (char *)&data1_str; + dset_data_ptr2 = (int *)&data2; + attr_data_ptr1 = (int *)&data2; /* ----------- - * group2 - */ - dset_data_ptr3 = (int*) &data2; + * group2 + */ + dset_data_ptr3 = (int *)&data2; /* dset1/attr1 */ tid_attr1 = H5Tcopy(H5T_C_S1); - H5Tset_size(tid_attr1, (size_t) STR_SIZE); - attr_data_ptr2 = (char*) &data1_str; + H5Tset_size(tid_attr1, (size_t)STR_SIZE); + attr_data_ptr2 = (char *)&data1_str; /* dset1/attr2 */ - attr2_dim_ptr = (hsize_t*) &dims1_2; + attr2_dim_ptr = (hsize_t *)&dims1_2; /* dset1/attr3 */ - attr_data_ptr3 = (int*) &data1_dim2; - attr3_dim_ptr = (hsize_t*) &dims2; - rank_attr = 2; + attr_data_ptr3 = (int *)&data1_dim2; + attr3_dim_ptr = (hsize_t *)&dims2; + rank_attr = 2; /* dset1/attr4 */ - attr_data_ptr4 = (int*) &data2; - + attr_data_ptr4 = (int *)&data2; } /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid < 0) { - fprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname); + HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * Groups - *------------------------------------------------------------------------*/ + * Groups + *------------------------------------------------------------------------*/ gid1 = H5Gcreate2(fid, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid1 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname); status = FAIL; goto out; } gid2 = H5Gcreate2(fid, "g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (gid2 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname); + HDfprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname); status = FAIL; goto out; } /*----------------------------------------------------------------------- - * Datasets in /g1 - *------------------------------------------------------------------------*/ + * Datasets in /g1 + *------------------------------------------------------------------------*/ if ((sid1 = H5Screate_simple(1, dims1_1, NULL)) < 0) goto out; /* dset1 */ if ((did1 = H5Dcreate2(gid1, "dset1", tid_dset1, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - fprintf(stderr, "Error: %s> H5Dcreate2 failed.\n", "dset1"); + HDfprintf(stderr, "Error: %s> H5Dcreate2 failed.\n", "dset1"); status = FAIL; goto out; } if (H5Dwrite(did1, tid_dset1, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset_data_ptr1) < 0) { - fprintf(stderr, "Error: %s> H5Dwrite failed.\n", "dset1"); + HDfprintf(stderr, "Error: %s> H5Dwrite failed.\n", "dset1"); status = FAIL; goto out; } @@ -4731,23 +4725,23 @@ static void test_data_nocomparables(const char * fname, int make_diffs) /* dset2 */ status = write_dset(gid1, 1, dims1_1, "dset2", H5T_NATIVE_INT, dset_data_ptr2); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname); goto out; } /*----------------------------------------------------------------------- - * Datasets in /g2 - *------------------------------------------------------------------------*/ + * Datasets in /g2 + *------------------------------------------------------------------------*/ /* --------- - * dset1 */ + * dset1 */ if ((did2 = H5Dcreate2(gid2, "dset1", H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - fprintf(stderr, "Error: %s> H5Dcreate2 failed.\n", "dset1"); + HDfprintf(stderr, "Error: %s> H5Dcreate2 failed.\n", "dset1"); status = FAIL; goto out; } if (H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset_data_ptr3) < 0) { - fprintf(stderr, "Error: %s> H5Dwrite failed.\n", "dset1"); + HDfprintf(stderr, "Error: %s> H5Dwrite failed.\n", "dset1"); status = FAIL; goto out; } @@ -4755,27 +4749,27 @@ static void test_data_nocomparables(const char * fname, int make_diffs) write_attr(did2, 1, dims1_1, "attr1", tid_attr1, attr_data_ptr2); /* attr2 - non-compatible : same rank, different dimention */ - write_attr(did2, 1, (hsize_t *) attr2_dim_ptr, "attr2", H5T_NATIVE_INT, data3); + write_attr(did2, 1, (hsize_t *)attr2_dim_ptr, "attr2", H5T_NATIVE_INT, data3); /* attr3 - non-compatible : different rank */ - write_attr(did2, rank_attr, (hsize_t *) attr3_dim_ptr, "attr3", H5T_NATIVE_INT, attr_data_ptr3); + write_attr(did2, rank_attr, (hsize_t *)attr3_dim_ptr, "attr3", H5T_NATIVE_INT, attr_data_ptr3); /* attr4 - compatible : different data values */ write_attr(did2, 1, dims1_1, "attr4", H5T_NATIVE_INT, attr_data_ptr4); /*---------- - * dset2 */ + * dset2 */ status = write_dset(gid2, 1, dims1_1, "dset2", H5T_NATIVE_INT, dset_data_ptr3); if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname); + HDfprintf(stderr, "Error: %s> write_dset failed\n", fname); goto out; } out: /*----------------------------------------------------------------------- - * Close IDs - *-----------------------------------------------------------------------*/ + * Close IDs + *-----------------------------------------------------------------------*/ if (fid) H5Fclose(fid); if (gid1) @@ -4802,144 +4796,121 @@ out: * types. * h5diff should show non-comparable output from these common objects. *-------------------------------------------------------------------------*/ -static void test_objs_nocomparables(const char *fname1, const char *fname2) +static void +test_objs_nocomparables(const char *fname1, const char *fname2) { - herr_t status = SUCCEED; - hid_t fid1 = -1; - hid_t fid2 = -1; - hid_t topgid1 = -1; - hid_t topgid2 = -1; - hid_t gid1 = -1; - hid_t did1 = -1; - hid_t tid1 = -1; - hid_t gid2 = -1; - hid_t did2 = -1; - hid_t tid2 = -1; - hsize_t dims[1] = { DIM_ARRY }; - int data1[DIM_ARRY] = { 1, 1, 1 }; - int data2[DIM_ARRY] = { 2, 2, 2 }; + hid_t fid1 = H5I_INVALID_HID; + hid_t fid2 = H5I_INVALID_HID; + hid_t topgid1 = H5I_INVALID_HID; + hid_t topgid2 = H5I_INVALID_HID; + hid_t gid1 = H5I_INVALID_HID; + hid_t tid1 = H5I_INVALID_HID; + hid_t gid2 = H5I_INVALID_HID; + hid_t tid2 = H5I_INVALID_HID; + hsize_t dims[1] = {DIM_ARRY}; + int data1[DIM_ARRY] = {1, 1, 1}; + int data2[DIM_ARRY] = {2, 2, 2}; /*----------------------------------------------------------------------- - * Open file(s) to add objects - *------------------------------------------------------------------------*/ + * Open file(s) to add objects + *------------------------------------------------------------------------*/ /* file1 */ - fid1 = H5Fopen(fname1, H5F_ACC_RDWR, H5P_DEFAULT); - if (fid1 < 0) { - fprintf(stderr, "Error: %s> H5Fopen failed.\n", fname1); - status = FAIL; - goto out; - } + if ((fid1 = H5Fopen(fname1, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + PROGRAM_ERROR /* file2 */ - fid2 = H5Fopen(fname2, H5F_ACC_RDWR, H5P_DEFAULT); - if (fid2 < 0) { - fprintf(stderr, "Error: %s> H5Fopen failed.\n", fname2); - status = FAIL; - goto out; - } + if ((fid2 = H5Fopen(fname2, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + PROGRAM_ERROR /*----------------------------------------------------------------------- - * in file1 : add member objects - *------------------------------------------------------------------------*/ + * in file1 : add member objects + *------------------------------------------------------------------------*/ /* parent group */ - topgid1 = H5Gcreate2(fid1, "diffobjtypes", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (topgid1 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); - status = FAIL; - goto out; - } + if ((topgid1 = H5Gcreate2(fid1, "diffobjtypes", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + PROGRAM_ERROR /* dataset */ - status = write_dset(topgid1, 1, dims, "obj1", H5T_NATIVE_INT, data1); - if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname1); - goto out; - } + if (write_dset(topgid1, 1, dims, "obj1", H5T_NATIVE_INT, data1) < 0) + PROGRAM_ERROR /* group */ - gid1 = H5Gcreate2(topgid1, "obj2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (gid1 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1); - status = FAIL; - goto out; - } + if ((gid1 = H5Gcreate2(topgid1, "obj2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + PROGRAM_ERROR /* committed type */ - tid1 = H5Tcopy(H5T_NATIVE_INT); - status = H5Tcommit2(topgid1, "obj3", tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) { - fprintf(stderr, "Error: %s> H5Tcommit2 failed.\n", fname1); - goto out; - } + if ((tid1 = H5Tcopy(H5T_NATIVE_INT)) < 0) + PROGRAM_ERROR + if (H5Tcommit2(topgid1, "obj3", tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + PROGRAM_ERROR /*----------------------------------------------------------------------- - * in file2 : add member objects - *------------------------------------------------------------------------*/ + * in file2 : add member objects + *------------------------------------------------------------------------*/ /* parent group */ - topgid2 = H5Gcreate2(fid2, "diffobjtypes", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (topgid2 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); - status = FAIL; - goto out; - } + if ((topgid2 = H5Gcreate2(fid2, "diffobjtypes", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + PROGRAM_ERROR /* group */ - gid2 = H5Gcreate2(topgid2, "obj1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (gid2 < 0) { - fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2); - status = FAIL; - goto out; - } + if ((gid2 = H5Gcreate2(topgid2, "obj1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + PROGRAM_ERROR /* committed type */ - tid2 = H5Tcopy(H5T_NATIVE_INT); - status = H5Tcommit2(topgid2, "obj2", tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) { - fprintf(stderr, "Error: %s> H5Tcommit2 failed.\n", fname2); - goto out; - } + if ((tid2 = H5Tcopy(H5T_NATIVE_INT)) < 0) + PROGRAM_ERROR + if (H5Tcommit2(topgid2, "obj2", tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + PROGRAM_ERROR /* dataset */ - status = write_dset(topgid2, 1, dims, "obj3", H5T_NATIVE_INT, data2); - if (status == FAIL) { - fprintf(stderr, "Error: %s> write_dset failed\n", fname2); - goto out; - } + if (write_dset(topgid2, 1, dims, "obj3", H5T_NATIVE_INT, data2) < 0) + PROGRAM_ERROR -out: /*----------------------------------------------------------------------- - * Close IDs - *-----------------------------------------------------------------------*/ - if (fid1) + * Close IDs + *-----------------------------------------------------------------------*/ + if (H5Fclose(fid1) < 0) + PROGRAM_ERROR + if (H5Fclose(fid2) < 0) + PROGRAM_ERROR + if (H5Gclose(topgid1) < 0) + PROGRAM_ERROR + if (H5Gclose(topgid2) < 0) + PROGRAM_ERROR + if (H5Gclose(gid1) < 0) + PROGRAM_ERROR + if (H5Gclose(gid2) < 0) + PROGRAM_ERROR + if (H5Tclose(tid1) < 0) + PROGRAM_ERROR + if (H5Tclose(tid2) < 0) + PROGRAM_ERROR + + return; + +error: + H5E_BEGIN_TRY + { H5Fclose(fid1); - if (fid2) H5Fclose(fid2); - if (topgid1) H5Gclose(topgid1); - if (topgid2) H5Gclose(topgid2); - if (did1) - H5Dclose(did1); - if (did2) - H5Dclose(did2); - if (gid1) H5Gclose(gid1); - if (gid2) H5Gclose(gid2); - if (tid1) H5Tclose(tid1); - if (tid2) H5Tclose(tid2); + } + H5E_END_TRY; + return; } -static hid_t mkstr(int size, H5T_str_t pad) +static hid_t +mkstr(int size, H5T_str_t pad) { hid_t type; if ((type = H5Tcopy(H5T_C_S1)) < 0) return -1; - if (H5Tset_size(type, (size_t) size) < 0) + if (H5Tset_size(type, (size_t)size) < 0) return -1; if (H5Tset_strpad(type, pad) < 0) return -1; @@ -4955,69 +4926,62 @@ static hid_t mkstr(int size, H5T_str_t pad) * types. * h5diff should show differences output from these common objects. *-------------------------------------------------------------------------*/ -static void test_objs_strings(const char *fname1, const char *fname2) +static void +test_objs_strings(const char *fname1, const char *fname2) { - hid_t fid1 = -1; - hid_t fid2 = -1; - hid_t dataset = -1; - hid_t space = -1; - hid_t f_type = -1; - hid_t m_type = -1; - hsize_t dims1[] = { 3, 4 }; - char string1A[12][3] = { "s1", "s2", "s3", "s4", "s5", "s6", "s", "s", "s9", - "s0", "s1", "s2" }; - char string1B[12][3] = { "s1", "s2", "s3", "s4", "s", "s", "s7", "s8", "s9", - "s0", "s1", "s2" }; - - hsize_t dims2[] = { 20 }; - char string2A[20][10] = { "ab cd ef1", "ab cd ef2", "ab cd ef3", - "ab cd ef4", "ab cd ef5", "ab cd ef6", "ab cd ef7", "ab cd ef8", - "ab cd 9", "ab cd 0", "ab cd 1", "ab cd 2", "ab cd ef3", - "ab cd ef4", "ab cd ef5", "ab cd ef6", "ab cd ef7", "ab cd ef8", - "ab cd ef9", "ab cd ef0" }; - char string2B[20][10] = { "ab cd ef1", "ab cd ef2", "ab cd ef3", - "ab cd ef4", "ab cd ef5", "ab cd ef6", "ab cd ef7", "ab cd ef8", - "ab cd ef9", "ab cd ef0", "ab cd ef1", "ab cd ef2", "ab cd 3", - "ab cd 4", "ab cd 5", "ab cd 6", "ab cd ef7", "ab cd ef8", - "ab cd ef9", "ab cd ef0" }; - - hsize_t dims3[] = { 27 }; - char string3A[27][6] = { "abcd0", "abcd1", "abcd2", "abcd3", "abcd4", - "abcd5", "abcd6", "abcd7", "abcd8", "abcd9", "abcd0", "abcd1", - "abd2", "abc3", "bcd4", "acd5", "abcd6", "abcd7", "abcd8", "abcd9", - "abcd0", "abcd1", "abcd2", "abcd3", "abc4", "abc5", "abc6" }; - char string3B[27][6] = { "abcd0", "abcd1", "abcd2", "abcd3", "abcd4", - "abcd5", "abcd6", "abcd7", "abcd8", "abcd9", "abcd0", "abcd1", - "abcd2", "abcd3", "abcd4", "abcd5", "abd6", "abc7", "bcd8", "acd9", - "abcd0", "abcd1", "abcd2", "abcd3", "abd4", "abd5", "abd6" }; - - hsize_t dims4[] = { 3 }; - char string4A[3][21] = { "s1234567890123456789", "s1234567890123456789", - "s12345678901234567" }; - char string4B[3][21] = { "s1234567890123456789", "s12345678901234567", - "s1234567890123456789" }; + hid_t fid1 = H5I_INVALID_HID; + hid_t fid2 = H5I_INVALID_HID; + hid_t dataset = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t f_type = H5I_INVALID_HID; + hid_t m_type = H5I_INVALID_HID; + hsize_t dims1[] = {3, 4}; + char string1A[12][3] = {"s1", "s2", "s3", "s4", "s5", "s6", "s", "s", "s9", "s0", "s1", "s2"}; + char string1B[12][3] = {"s1", "s2", "s3", "s4", "s", "s", "s7", "s8", "s9", "s0", "s1", "s2"}; + + hsize_t dims2[] = {20}; + char string2A[20][10] = {"ab cd ef1", "ab cd ef2", "ab cd ef3", "ab cd ef4", "ab cd ef5", + "ab cd ef6", "ab cd ef7", "ab cd ef8", "ab cd 9", "ab cd 0", + "ab cd 1", "ab cd 2", "ab cd ef3", "ab cd ef4", "ab cd ef5", + "ab cd ef6", "ab cd ef7", "ab cd ef8", "ab cd ef9", "ab cd ef0"}; + char string2B[20][10] = {"ab cd ef1", "ab cd ef2", "ab cd ef3", "ab cd ef4", "ab cd ef5", + "ab cd ef6", "ab cd ef7", "ab cd ef8", "ab cd ef9", "ab cd ef0", + "ab cd ef1", "ab cd ef2", "ab cd 3", "ab cd 4", "ab cd 5", + "ab cd 6", "ab cd ef7", "ab cd ef8", "ab cd ef9", "ab cd ef0"}; + + hsize_t dims3[] = {27}; + char string3A[27][6] = {"abcd0", "abcd1", "abcd2", "abcd3", "abcd4", "abcd5", "abcd6", "abcd7", "abcd8", + "abcd9", "abcd0", "abcd1", "abd2", "abc3", "bcd4", "acd5", "abcd6", "abcd7", + "abcd8", "abcd9", "abcd0", "abcd1", "abcd2", "abcd3", "abc4", "abc5", "abc6"}; + char string3B[27][6] = {"abcd0", "abcd1", "abcd2", "abcd3", "abcd4", "abcd5", "abcd6", "abcd7", "abcd8", + "abcd9", "abcd0", "abcd1", "abcd2", "abcd3", "abcd4", "abcd5", "abd6", "abc7", + "bcd8", "acd9", "abcd0", "abcd1", "abcd2", "abcd3", "abd4", "abd5", "abd6"}; + + hsize_t dims4[] = {3}; + char string4A[3][21] = {"s1234567890123456789", "s1234567890123456789", "s12345678901234567"}; + char string4B[3][21] = {"s1234567890123456789", "s12345678901234567", "s1234567890123456789"}; /*----------------------------------------------------------------------- - * Create file(s) - *------------------------------------------------------------------------*/ + * Create file(s) + *------------------------------------------------------------------------*/ /* file1 */ fid1 = H5Fcreate(fname1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { - fprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); + HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname1); goto out; } /* file2 */ fid2 = H5Fcreate(fname2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid2 < 0) { - fprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname2); + HDfprintf(stderr, "Error: %s> H5Fcreate failed.\n", fname2); goto out; } /* string 1 : nullterm string */ - space = H5Screate_simple(2, dims1, NULL); - f_type = mkstr(5, H5T_STR_NULLTERM); - m_type = mkstr(3, H5T_STR_NULLTERM); + space = H5Screate_simple(2, dims1, NULL); + f_type = mkstr(5, H5T_STR_NULLTERM); + m_type = mkstr(3, H5T_STR_NULLTERM); dataset = H5Dcreate2(fid1, "/string1", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite(dataset, m_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, string1A); H5Dclose(dataset); @@ -5029,9 +4993,9 @@ static void test_objs_strings(const char *fname1, const char *fname2) H5Dclose(dataset); /* string 2 : space pad string */ - space = H5Screate_simple(1, dims2, NULL); - f_type = mkstr(11, H5T_STR_SPACEPAD); - m_type = mkstr(10, H5T_STR_NULLTERM); + space = H5Screate_simple(1, dims2, NULL); + f_type = mkstr(11, H5T_STR_SPACEPAD); + m_type = mkstr(10, H5T_STR_NULLTERM); dataset = H5Dcreate2(fid1, "/string2", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite(dataset, m_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, string2A); H5Dclose(dataset); @@ -5043,9 +5007,9 @@ static void test_objs_strings(const char *fname1, const char *fname2) H5Dclose(dataset); /* string 3 : null pad string */ - space = H5Screate_simple(1, dims3, NULL); - f_type = mkstr(8, H5T_STR_NULLPAD); - m_type = mkstr(6, H5T_STR_NULLTERM); + space = H5Screate_simple(1, dims3, NULL); + f_type = mkstr(8, H5T_STR_NULLPAD); + m_type = mkstr(6, H5T_STR_NULLTERM); dataset = H5Dcreate2(fid1, "/string3", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite(dataset, m_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, string3A); H5Dclose(dataset); @@ -5057,9 +5021,9 @@ static void test_objs_strings(const char *fname1, const char *fname2) H5Dclose(dataset); /* string 4 : space pad long string */ - space = H5Screate_simple(1, dims4, NULL); - f_type = mkstr(168, H5T_STR_SPACEPAD); - m_type = mkstr(21, H5T_STR_NULLTERM); + space = H5Screate_simple(1, dims4, NULL); + f_type = mkstr(168, H5T_STR_SPACEPAD); + m_type = mkstr(21, H5T_STR_NULLTERM); dataset = H5Dcreate2(fid1, "/string4", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite(dataset, m_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, string4A); H5Dclose(dataset); @@ -5085,10 +5049,10 @@ static void test_objs_strings(const char *fname1, const char *fname2) string4B[2][11] = 'a'; string4B[2][12] = 'B'; string4B[2][13] = 'c'; - space = H5Screate_simple(1, dims4, NULL); - f_type = mkstr(168, H5T_STR_NULLTERM); - m_type = mkstr(21, H5T_STR_NULLTERM); - dataset = H5Dcreate2(fid1, "/string5", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + space = H5Screate_simple(1, dims4, NULL); + f_type = mkstr(168, H5T_STR_NULLTERM); + m_type = mkstr(21, H5T_STR_NULLTERM); + dataset = H5Dcreate2(fid1, "/string5", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Dwrite(dataset, m_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, string4A); H5Dclose(dataset); dataset = H5Dcreate2(fid2, "/string5", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -5100,8 +5064,8 @@ static void test_objs_strings(const char *fname1, const char *fname2) out: /*----------------------------------------------------------------------- - * Close IDs - *-----------------------------------------------------------------------*/ + * Close IDs + *-----------------------------------------------------------------------*/ if (fid1) H5Fclose(fid1); if (fid2) @@ -5116,78 +5080,77 @@ out: * *------------------------------------------------------------------------- */ -static -void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make_diffs /* flag to modify data buffers */) +static void +write_attr_strings(hid_t loc_id, const char *dset_name, hid_t fid, + int make_diffs /* flag to modify data buffers */) { /* Compound datatype */ typedef struct s_t { - char a; + char a; double b; } s_t; - typedef enum { - RED, GREEN - } e_t; + typedef enum { RED, GREEN } e_t; - hid_t aid = -1; - hid_t sid = -1; - hid_t tid = -1; + hid_t aid = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; herr_t status; - int val, i, j, k, l, n; - float f; + int val, i, j, k, l, n; + float f; /* create 1D attributes with dimension [2], 2 elements */ - hsize_t dims[1] = { 2 }; - char buf1[2][STR_SIZE] = { "ab", "de" }; /* string */ - char *buf1a[2]; /* VL string */ - char buf2[2] = { 1, 2 }; /* bitfield, opaque */ - s_t buf3[2] = { { 1, 2.0F }, { 3, 4.0F } }; /* compound */ - hobj_ref_t buf4[2]; /* reference */ - e_t buf45[2] = { RED, RED }; /* enum */ - hvl_t buf5[2]; /* vlen */ - hsize_t dimarray[1] = { 3 }; /* array dimension */ - int buf6[2][3] = { { 1, 2, 3 }, { 4, 5, 6 } }; /* array */ - int buf7[2] = { 1, 2 }; /* integer */ - float buf8[2] = { 1.0F, 2.0F }; /* float */ + hsize_t dims[1] = {2}; + char buf1[2][STR_SIZE] = {"ab", "de"}; /* string */ + char * buf1a[2]; /* VL string */ + char buf2[2] = {1, 2}; /* bitfield, opaque */ + s_t buf3[2] = {{1, 2.0F}, {3, 4.0F}}; /* compound */ + hobj_ref_t buf4[2]; /* reference */ + e_t buf45[2] = {RED, RED}; /* enum */ + hvl_t buf5[2]; /* vlen */ + hsize_t dimarray[1] = {3}; /* array dimension */ + int buf6[2][3] = {{1, 2, 3}, {4, 5, 6}}; /* array */ + int buf7[2] = {1, 2}; /* integer */ + float buf8[2] = {1.0F, 2.0F}; /* float */ /* create 2D attributes with dimension [3][2], 6 elements */ - hsize_t dims2[2] = { 3, 2 }; - char buf12[3][2][STR_SIZE] = { { "ab", "cd" }, { "ef", "gh" }, { "ij", "kl" } }; /* string */ - char *buf12a[3][2]; /* VL string */ - char buf22[3][2] = { { 1, 2 }, { 3, 4 }, { 5, 6 } }; /* bitfield, opaque */ - s_t buf32[6] = { { 1, 2.0F }, { 3, 4.0F }, { 5, 6.0F }, { 7, 8.0F }, { 9, 10.0F }, { 11, 12.0F } }; /* compound */ - hobj_ref_t buf42[3][2]; /* reference */ - e_t buf452[3][2]; /* enum */ - hvl_t buf52[3][2]; /* vlen */ - int buf62[6][3] = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }, { 10, 11, 12 }, { 13, 14, 15 }, { 16, 17, 18 } }; /* array */ - int buf72[3][2] = { { 1, 2 }, { 3, 4 }, { 5, 6 } }; /* integer */ - float buf82[3][2] = { { 1.0F, 2.0F }, { 3.0F, 4.0F }, { 5.0F, 6.0F } }; /* float */ + hsize_t dims2[2] = {3, 2}; + char buf12[3][2][STR_SIZE] = {{"ab", "cd"}, {"ef", "gh"}, {"ij", "kl"}}; /* string */ + char * buf12a[3][2]; /* VL string */ + char buf22[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* bitfield, opaque */ + s_t buf32[6] = {{1, 2.0F}, {3, 4.0F}, {5, 6.0F}, {7, 8.0F}, {9, 10.0F}, {11, 12.0F}}; /* compound */ + hobj_ref_t buf42[3][2]; /* reference */ + e_t buf452[3][2]; /* enum */ + hvl_t buf52[3][2]; /* vlen */ + int buf62[6][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}, {13, 14, 15}, {16, 17, 18}}; /* array */ + int buf72[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* integer */ + float buf82[3][2] = {{1.0F, 2.0F}, {3.0F, 4.0F}, {5.0F, 6.0F}}; /* float */ /* create 3D attributes with dimension [4][3][2], 24 elements */ - hsize_t dims3[3] = { 4, 3, 2 }; - char buf13[4][3][2][STR_SIZE] = { { { "ab", "cd" }, { "ef", "gh" }, { "ij", "kl" } }, - { { "mn", "pq" }, { "rs", "tu" }, { "vw", "xz" } }, - { { "AB", "CD" }, { "EF", "GH" }, { "IJ", "KL" } }, - { { "MN", "PQ" }, { "RS", "TU" }, { "VW", "XZ" } } }; /* string */ - char *buf13a[4][3][2]; /* VL string */ - char buf23[4][3][2]; /* bitfield, opaque */ - s_t buf33[4][3][2]; /* compound */ - hobj_ref_t buf43[4][3][2]; /* reference */ - e_t buf453[4][3][2]; /* enum */ - hvl_t buf53[4][3][2]; /* vlen */ - int buf63[24][3]; /* array */ - int buf73[4][3][2]; /* integer */ - float buf83[4][3][2]; /* float */ - - /*------------------------------------------------------------------------- - * 1D attributes - *------------------------------------------------------------------------- - */ + hsize_t dims3[3] = {4, 3, 2}; + char buf13[4][3][2][STR_SIZE] = {{{"ab", "cd"}, {"ef", "gh"}, {"ij", "kl"}}, + {{"mn", "pq"}, {"rs", "tu"}, {"vw", "xz"}}, + {{"AB", "CD"}, {"EF", "GH"}, {"IJ", "KL"}}, + {{"MN", "PQ"}, {"RS", "TU"}, {"VW", "XZ"}}}; /* string */ + char * buf13a[4][3][2]; /* VL string */ + char buf23[4][3][2]; /* bitfield, opaque */ + s_t buf33[4][3][2]; /* compound */ + hobj_ref_t buf43[4][3][2]; /* reference */ + e_t buf453[4][3][2]; /* enum */ + hvl_t buf53[4][3][2]; /* vlen */ + int buf63[24][3]; /* array */ + int buf73[4][3][2]; /* integer */ + float buf83[4][3][2]; /* float */ + + /*------------------------------------------------------------------------- + * 1D attributes + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ + * H5T_STRING + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) @@ -5209,20 +5172,20 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make for (i = 0; i < 2; i++) buf1a[i] = buf1[i]; - tid = H5Tcopy(H5T_C_S1); + tid = H5Tcopy(H5T_C_S1); status = H5Tset_size(tid, H5T_VARIABLE); write_attr(loc_id, 1, dims, "string", tid, buf1a); status = H5Tclose(tid); - tid = H5Tcopy(H5T_C_S1); + tid = H5Tcopy(H5T_C_S1); status = H5Tset_size(tid, (size_t)STR_SIZE); write_attr(loc_id, 1, dims, "VLstring", tid, buf1); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) @@ -5244,9 +5207,9 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ /* buf2[2]= {1,2}; @@ -5260,15 +5223,15 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make [ 1 ] 2 0 2 */ - tid = H5Tcreate(H5T_OPAQUE, (size_t) 1); + tid = H5Tcreate(H5T_OPAQUE, (size_t)1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ write_attr(loc_id, 1, dims, "opaque", tid, buf2); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) { @@ -5296,13 +5259,13 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_REFERENCE (H5R_OBJECT object reference) - *------------------------------------------------------------------------- - */ + * H5T_REFERENCE (H5R_OBJECT object reference) + *------------------------------------------------------------------------- + */ /* Create references to dataset */ if (dset_name) { - status = H5Rcreate(&buf4[0], fid, dset_name, H5R_OBJECT, (hid_t) -1); - status = H5Rcreate(&buf4[1], fid, dset_name, H5R_OBJECT, (hid_t) -1); + status = H5Rcreate(&buf4[0], fid, dset_name, H5R_OBJECT, (hid_t)-1); + status = H5Rcreate(&buf4[1], fid, dset_name, H5R_OBJECT, (hid_t)-1); write_attr(loc_id, 1, dims, "reference", H5T_STD_REF_OBJ, buf4); } @@ -5336,18 +5299,18 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make /* Allocate and initialize VL dataset to write */ - buf5[0].len = 1; - buf5[0].p = HDmalloc(1 * sizeof(int)); - ((int *) buf5[0].p)[0] = 1; - buf5[1].len = 2; - buf5[1].p = HDmalloc(2 * sizeof(int)); - ((int *) buf5[1].p)[0] = 2; - ((int *) buf5[1].p)[1] = 3; + buf5[0].len = 1; + buf5[0].p = HDmalloc(1 * sizeof(int)); + ((int *)buf5[0].p)[0] = 1; + buf5[1].len = 2; + buf5[1].p = HDmalloc(2 * sizeof(int)); + ((int *)buf5[1].p)[0] = 2; + ((int *)buf5[1].p)[1] = 3; if (make_diffs) { - ((int *) buf5[0].p)[0] = 0; - ((int *) buf5[1].p)[0] = 0; - ((int *) buf5[1].p)[1] = 0; + ((int *)buf5[0].p)[0] = 0; + ((int *)buf5[1].p)[0] = 0; + ((int *)buf5[1].p)[1] = 0; } /* $h5diff file7.h5 file6.h5 g1 g1 -v @@ -5359,9 +5322,9 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make [ 1 ] 3 0 3 */ - sid = H5Screate_simple(1, dims, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - aid = H5Acreate2(loc_id, "vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(1, dims, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + aid = H5Acreate2(loc_id, "vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT); status = H5Awrite(aid, tid, buf5); assert(status >= 0); status = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf5); @@ -5463,13 +5426,13 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make for (j = 0; j < 2; j++) buf12a[i][j] = buf12[i][j]; - tid = H5Tcopy(H5T_C_S1); + tid = H5Tcopy(H5T_C_S1); status = H5Tset_size(tid, H5T_VARIABLE); write_attr(loc_id, 2, dims2, "string2D", tid, buf12a); status = H5Tclose(tid); - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, (size_t) STR_SIZE); + tid = H5Tcopy(H5T_C_S1); + status = H5Tset_size(tid, (size_t)STR_SIZE); write_attr(loc_id, 2, dims2, "VLstring2D", tid, buf12); status = H5Tclose(tid); @@ -5516,7 +5479,7 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make [ 2 0 ] 5 0 5 [ 2 1 ] 6 0 6 */ - tid = H5Tcreate(H5T_OPAQUE, (size_t) 1); + tid = H5Tcreate(H5T_OPAQUE, (size_t)1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ write_attr(loc_id, 2, dims2, "opaque2D", tid, buf22); status = H5Tclose(tid); @@ -5556,8 +5519,7 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make if (dset_name) { for (i = 0; i < 3; i++) for (j = 0; j < 2; j++) - status = H5Rcreate(&buf42[i][j], fid, dset_name, H5R_OBJECT, - (hid_t) -1); + status = H5Rcreate(&buf42[i][j], fid, dset_name, H5R_OBJECT, (hid_t)-1); write_attr(loc_id, 2, dims2, "reference2D", H5T_STD_REF_OBJ, buf42); } @@ -5599,13 +5561,13 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make n = 0; for (i = 0; i < 3; i++) { for (j = 0; j < 2; j++) { - buf52[i][j].p = HDmalloc((size_t)(i + 1) * sizeof(int)); + buf52[i][j].p = HDmalloc((size_t)(i + 1) * sizeof(int)); buf52[i][j].len = (size_t)(i + 1); for (l = 0; l < i + 1; l++) if (make_diffs) - ((int *) buf52[i][j].p)[l] = 0; + ((int *)buf52[i][j].p)[l] = 0; else - ((int *) buf52[i][j].p)[l] = n++; + ((int *)buf52[i][j].p)[l] = n++; } } @@ -5625,9 +5587,9 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make [ 2 1 ] 11 0 11 */ - sid = H5Screate_simple(2, dims2, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - aid = H5Acreate2(loc_id, "vlen2D", tid, sid, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(2, dims2, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + aid = H5Acreate2(loc_id, "vlen2D", tid, sid, H5P_DEFAULT, H5P_DEFAULT); status = H5Awrite(aid, tid, buf52); assert(status >= 0); status = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf52); @@ -5786,13 +5748,13 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make for (k = 0; k < 2; k++) buf13a[i][j][k] = buf13[i][j][k]; - tid = H5Tcopy(H5T_C_S1); + tid = H5Tcopy(H5T_C_S1); status = H5Tset_size(tid, H5T_VARIABLE); write_attr(loc_id, 3, dims3, "string3D", tid, buf13a); status = H5Tclose(tid); - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, (size_t) STR_SIZE); + tid = H5Tcopy(H5T_C_S1); + status = H5Tset_size(tid, (size_t)STR_SIZE); write_attr(loc_id, 3, dims3, "VLstring3D", tid, buf13); status = H5Tclose(tid); @@ -5808,7 +5770,7 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make if (make_diffs) buf23[i][j][k] = 0; else - buf23[i][j][k] = (char) n++; + buf23[i][j][k] = (char)n++; /* position bitfield3D of </g1> bitfield3D of </g1> difference @@ -5847,7 +5809,7 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make * H5T_OPAQUE *------------------------------------------------------------------------- */ - tid = H5Tcreate(H5T_OPAQUE, (size_t) 1); + tid = H5Tcreate(H5T_OPAQUE, (size_t)1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ write_attr(loc_id, 3, dims3, "opaque3D", tid, buf23); status = H5Tclose(tid); @@ -5864,8 +5826,9 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make if (make_diffs) { buf33[i][j][k].a = 0; buf33[i][j][k].b = 0.0F; - } else { - buf33[i][j][k].a = (char) n++; + } + else { + buf33[i][j][k].a = (char)n++; buf33[i][j][k].b = n++; } /*position compound3D of </g1> compound3D of </g1> difference @@ -5935,8 +5898,7 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) for (k = 0; k < 2; k++) - status = H5Rcreate(&buf43[i][j][k], fid, dset_name, - H5R_OBJECT, (hid_t) -1); + status = H5Rcreate(&buf43[i][j][k], fid, dset_name, H5R_OBJECT, (hid_t)-1); write_attr(loc_id, 3, dims3, "reference3D", H5T_STD_REF_OBJ, buf43); } @@ -5998,13 +5960,13 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) for (k = 0; k < 2; k++) { - buf53[i][j][k].p = HDmalloc((size_t)(i + 1) * sizeof(int)); + buf53[i][j][k].p = HDmalloc((size_t)(i + 1) * sizeof(int)); buf53[i][j][k].len = (size_t)(i + 1); for (l = 0; l < i + 1; l++) if (make_diffs) - ((int *) buf53[i][j][k].p)[l] = 0; + ((int *)buf53[i][j][k].p)[l] = 0; else - ((int *) buf53[i][j][k].p)[l] = n++; + ((int *)buf53[i][j][k].p)[l] = n++; } /* position vlen3D of </g1> vlen3D of </g1> difference @@ -6021,9 +5983,9 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make [ 1 1 0 ] 10 0 10 etc */ - sid = H5Screate_simple(3, dims3, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - aid = H5Acreate2(loc_id, "vlen3D", tid, sid, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(3, dims3, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + aid = H5Acreate2(loc_id, "vlen3D", tid, sid, H5P_DEFAULT, H5P_DEFAULT); status = H5Awrite(aid, tid, buf53); assert(status >= 0); status = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf53); @@ -6038,7 +6000,7 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make */ n = 1; for (i = 0; i < 24; i++) { - for (j = 0; j < (int) dimarray[0]; j++) { + for (j = 0; j < (int)dimarray[0]; j++) { if (make_diffs) buf63[i][j] = 0; else @@ -6107,78 +6069,77 @@ void write_attr_strings(hid_t loc_id, const char* dset_name, hid_t fid, int make * *------------------------------------------------------------------------- */ -static -void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diffs /* flag to modify data buffers */) +static void +write_attr_in(hid_t loc_id, const char *dset_name, hid_t fid, + int make_diffs /* flag to modify data buffers */) { /* Compound datatype */ typedef struct s_t { - char a; + char a; double b; } s_t; - typedef enum { - RED, GREEN - } e_t; + typedef enum { RED, GREEN } e_t; - hid_t aid = -1; - hid_t sid = -1; - hid_t tid = -1; + hid_t aid = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; herr_t status; - int val, i, j, k, l, n; - float f; + int val, i, j, k, l, n; + float f; /* create 1D attributes with dimension [2], 2 elements */ - hsize_t dims[1] = { 2 }; - char buf1[2][STR_SIZE] = { "ab", "de" }; /* string */ - char *buf1a[2]; /* VL string */ - char buf2[2] = { 1, 2 }; /* bitfield, opaque */ - s_t buf3[2] = { { 1, 2.0F }, { 3, 4.0F } }; /* compound */ - hobj_ref_t buf4[2]; /* reference */ - e_t buf45[2] = { RED, RED }; /* enum */ - hvl_t buf5[2]; /* vlen */ - hsize_t dimarray[1] = { 3 }; /* array dimension */ - int buf6[2][3] = { { 1, 2, 3 }, { 4, 5, 6 } }; /* array */ - int buf7[2] = { 1, 2 }; /* integer */ - float buf8[2] = { 1.0F, 2.0F }; /* float */ + hsize_t dims[1] = {2}; + char buf1[2][STR_SIZE] = {"ab", "de"}; /* string */ + char * buf1a[2]; /* VL string */ + char buf2[2] = {1, 2}; /* bitfield, opaque */ + s_t buf3[2] = {{1, 2.0F}, {3, 4.0F}}; /* compound */ + hobj_ref_t buf4[2]; /* reference */ + e_t buf45[2] = {RED, RED}; /* enum */ + hvl_t buf5[2]; /* vlen */ + hsize_t dimarray[1] = {3}; /* array dimension */ + int buf6[2][3] = {{1, 2, 3}, {4, 5, 6}}; /* array */ + int buf7[2] = {1, 2}; /* integer */ + float buf8[2] = {1.0F, 2.0F}; /* float */ /* create 2D attributes with dimension [3][2], 6 elements */ - hsize_t dims2[2] = { 3, 2 }; - char buf12[3][2][STR_SIZE] = { { "ab", "cd" }, { "ef", "gh" }, { "ij", "kl" } }; /* string */ - char *buf12a[3][2]; /* VL string */ - char buf22[3][2] = { { 1, 2 }, { 3, 4 }, { 5, 6 } }; /* bitfield, opaque */ - s_t buf32[6] = { { 1, 2.0F }, { 3, 4.0F }, { 5, 6.0F }, { 7, 8.0F }, { 9, 10.0F }, { 11, 12.0F } }; /* compound */ - hobj_ref_t buf42[3][2]; /* reference */ - e_t buf452[3][2]; /* enum */ - hvl_t buf52[3][2]; /* vlen */ - int buf62[6][3] = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }, { 10, 11, 12 }, { 13, 14, 15 }, { 16, 17, 18 } }; /* array */ - int buf72[3][2] = { { 1, 2 }, { 3, 4 }, { 5, 6 } }; /* integer */ - float buf82[3][2] = { { 1.0F, 2.0F }, { 3.0F, 4.0F }, { 5.0F, 6.0F } }; /* float */ + hsize_t dims2[2] = {3, 2}; + char buf12[3][2][STR_SIZE] = {{"ab", "cd"}, {"ef", "gh"}, {"ij", "kl"}}; /* string */ + char * buf12a[3][2]; /* VL string */ + char buf22[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* bitfield, opaque */ + s_t buf32[6] = {{1, 2.0F}, {3, 4.0F}, {5, 6.0F}, {7, 8.0F}, {9, 10.0F}, {11, 12.0F}}; /* compound */ + hobj_ref_t buf42[3][2]; /* reference */ + e_t buf452[3][2]; /* enum */ + hvl_t buf52[3][2]; /* vlen */ + int buf62[6][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}, {13, 14, 15}, {16, 17, 18}}; /* array */ + int buf72[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* integer */ + float buf82[3][2] = {{1.0F, 2.0F}, {3.0F, 4.0F}, {5.0F, 6.0F}}; /* float */ /* create 3D attributes with dimension [4][3][2], 24 elements */ - hsize_t dims3[3] = { 4, 3, 2 }; - char buf13[4][3][2][STR_SIZE] = { { { "ab", "cd" }, { "ef", "gh" }, { "ij", "kl" } }, - { { "mn", "pq" }, { "rs", "tu" }, { "vw", "xz" } }, - { { "AB", "CD" }, { "EF", "GH" }, { "IJ", "KL" } }, - { { "MN", "PQ" }, { "RS", "TU" }, { "VW", "XZ" } } }; /* string */ - char *buf13a[4][3][2]; /* VL string */ - char buf23[4][3][2]; /* bitfield, opaque */ - s_t buf33[4][3][2]; /* compound */ - hobj_ref_t buf43[4][3][2]; /* reference */ - e_t buf453[4][3][2]; /* enum */ - hvl_t buf53[4][3][2]; /* vlen */ - int buf63[24][3]; /* array */ - int buf73[4][3][2]; /* integer */ - float buf83[4][3][2]; /* float */ - - /*------------------------------------------------------------------------- - * 1D attributes - *------------------------------------------------------------------------- - */ + hsize_t dims3[3] = {4, 3, 2}; + char buf13[4][3][2][STR_SIZE] = {{{"ab", "cd"}, {"ef", "gh"}, {"ij", "kl"}}, + {{"mn", "pq"}, {"rs", "tu"}, {"vw", "xz"}}, + {{"AB", "CD"}, {"EF", "GH"}, {"IJ", "KL"}}, + {{"MN", "PQ"}, {"RS", "TU"}, {"VW", "XZ"}}}; /* string */ + char * buf13a[4][3][2]; /* VL string */ + char buf23[4][3][2]; /* bitfield, opaque */ + s_t buf33[4][3][2]; /* compound */ + hobj_ref_t buf43[4][3][2]; /* reference */ + e_t buf453[4][3][2]; /* enum */ + hvl_t buf53[4][3][2]; /* vlen */ + int buf63[24][3]; /* array */ + int buf73[4][3][2]; /* integer */ + float buf83[4][3][2]; /* float */ + + /*------------------------------------------------------------------------- + * 1D attributes + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ + * H5T_STRING + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) @@ -6196,22 +6157,22 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff [ 1 ] d z [ 1 ] e z */ - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, (size_t) STR_SIZE); + tid = H5Tcopy(H5T_C_S1); + status = H5Tset_size(tid, (size_t)STR_SIZE); write_attr(loc_id, 1, dims, "string", tid, buf1); status = H5Tclose(tid); for (i = 0; i < 2; i++) buf1a[i] = buf1[i]; - tid = H5Tcopy(H5T_C_S1); + tid = H5Tcopy(H5T_C_S1); status = H5Tset_size(tid, H5T_VARIABLE); write_attr(loc_id, 1, dims, "VLstring", tid, buf1a); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) @@ -6233,9 +6194,9 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ /* buf2[2]= {1,2}; @@ -6249,15 +6210,15 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff [ 1 ] 2 0 2 */ - tid = H5Tcreate(H5T_OPAQUE, (size_t) 1); + tid = H5Tcreate(H5T_OPAQUE, (size_t)1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ write_attr(loc_id, 1, dims, "opaque", tid, buf2); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) { @@ -6284,20 +6245,20 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_REFERENCE (H5R_OBJECT object reference) - *------------------------------------------------------------------------- - */ + * H5T_REFERENCE (H5R_OBJECT object reference) + *------------------------------------------------------------------------- + */ /* Create references to dataset */ if (dset_name) { - status = H5Rcreate(&buf4[0], fid, dset_name, H5R_OBJECT, (hid_t) -1); - status = H5Rcreate(&buf4[1], fid, dset_name, H5R_OBJECT, (hid_t) -1); + status = H5Rcreate(&buf4[0], fid, dset_name, H5R_OBJECT, (hid_t)-1); + status = H5Rcreate(&buf4[1], fid, dset_name, H5R_OBJECT, (hid_t)-1); write_attr(loc_id, 1, dims, "reference", H5T_STD_REF_OBJ, buf4); } /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ + * H5T_ENUM + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) buf45[i] = GREEN; @@ -6318,24 +6279,24 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_VLEN - *------------------------------------------------------------------------- - */ + * H5T_VLEN + *------------------------------------------------------------------------- + */ /* Allocate and initialize VL dataset to write */ - buf5[0].len = 1; - buf5[0].p = HDmalloc(1 * sizeof(int)); - ((int *) buf5[0].p)[0] = 1; - buf5[1].len = 2; - buf5[1].p = HDmalloc(2 * sizeof(int)); - ((int *) buf5[1].p)[0] = 2; - ((int *) buf5[1].p)[1] = 3; + buf5[0].len = 1; + buf5[0].p = HDmalloc(1 * sizeof(int)); + ((int *)buf5[0].p)[0] = 1; + buf5[1].len = 2; + buf5[1].p = HDmalloc(2 * sizeof(int)); + ((int *)buf5[1].p)[0] = 2; + ((int *)buf5[1].p)[1] = 3; if (make_diffs) { - ((int *) buf5[0].p)[0] = 0; - ((int *) buf5[1].p)[0] = 0; - ((int *) buf5[1].p)[1] = 0; + ((int *)buf5[0].p)[0] = 0; + ((int *)buf5[1].p)[0] = 0; + ((int *)buf5[1].p)[1] = 0; } /* $h5diff file7.h5 file6.h5 g1 g1 -v @@ -6347,9 +6308,9 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff [ 1 ] 3 0 3 */ - sid = H5Screate_simple(1, dims, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - aid = H5Acreate2(loc_id, "vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(1, dims, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + aid = H5Acreate2(loc_id, "vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT); status = H5Awrite(aid, tid, buf5); assert(status >= 0); status = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf5); @@ -6359,9 +6320,9 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Sclose(sid); /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ + * H5T_ARRAY + *------------------------------------------------------------------------- + */ if (make_diffs) { for (i = 0; i < 2; i++) @@ -6387,9 +6348,9 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_INTEGER and H5T_FLOAT - *------------------------------------------------------------------------- - */ + * H5T_INTEGER and H5T_FLOAT + *------------------------------------------------------------------------- + */ if (make_diffs) { for (i = 0; i < 2; i++) { @@ -6415,14 +6376,14 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff write_attr(loc_id, 1, dims, "float", H5T_NATIVE_FLOAT, buf8); /*------------------------------------------------------------------------- - * 2D attributes - *------------------------------------------------------------------------- - */ + * 2D attributes + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ + * H5T_STRING + *------------------------------------------------------------------------- + */ if (make_diffs) { for (i = 0; i < 3; i++) for (j = 0; j < 2; j++) @@ -6450,8 +6411,8 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff [ 2 1 ] l z */ - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, (size_t) STR_SIZE); + tid = H5Tcopy(H5T_C_S1); + status = H5Tset_size(tid, (size_t)STR_SIZE); write_attr(loc_id, 2, dims2, "string2D", tid, buf12); status = H5Tclose(tid); @@ -6459,15 +6420,15 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff for (j = 0; j < 2; j++) buf12a[i][j] = buf12[i][j]; - tid = H5Tcopy(H5T_C_S1); + tid = H5Tcopy(H5T_C_S1); status = H5Tset_size(tid, H5T_VARIABLE); write_attr(loc_id, 2, dims2, "VLstring2D", tid, buf12a); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ if (make_diffs) memset(buf22, 0, sizeof buf22); @@ -6490,9 +6451,9 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ /* buf22[3][2]= {{1,2},{3,4},{5,6}}; @@ -6507,15 +6468,15 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff [ 2 0 ] 5 0 5 [ 2 1 ] 6 0 6 */ - tid = H5Tcreate(H5T_OPAQUE, (size_t) 1); + tid = H5Tcreate(H5T_OPAQUE, (size_t)1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ write_attr(loc_id, 2, dims2, "opaque2D", tid, buf22); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ if (make_diffs) memset(buf32, 0, sizeof buf32); /* @@ -6539,21 +6500,21 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_REFERENCE (H5R_OBJECT object reference) - *------------------------------------------------------------------------- - */ + * H5T_REFERENCE (H5R_OBJECT object reference) + *------------------------------------------------------------------------- + */ /* Create references to dataset */ if (dset_name) { for (i = 0; i < 3; i++) for (j = 0; j < 2; j++) - status = H5Rcreate(&buf42[i][j], fid, dset_name, H5R_OBJECT, (hid_t) -1); + status = H5Rcreate(&buf42[i][j], fid, dset_name, H5R_OBJECT, (hid_t)-1); write_attr(loc_id, 2, dims2, "reference2D", H5T_STD_REF_OBJ, buf42); } /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ + * H5T_ENUM + *------------------------------------------------------------------------- + */ for (i = 0; i < 3; i++) for (j = 0; j < 2; j++) { if (make_diffs) @@ -6581,21 +6542,21 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_VLEN - *------------------------------------------------------------------------- - */ + * H5T_VLEN + *------------------------------------------------------------------------- + */ /* Allocate and initialize VL dataset to write */ n = 0; for (i = 0; i < 3; i++) { for (j = 0; j < 2; j++) { - buf52[i][j].p = HDmalloc((size_t)(i + 1) * sizeof(int)); + buf52[i][j].p = HDmalloc((size_t)(i + 1) * sizeof(int)); buf52[i][j].len = (size_t)(i + 1); for (l = 0; l < i + 1; l++) if (make_diffs) - ((int *) buf52[i][j].p)[l] = 0; + ((int *)buf52[i][j].p)[l] = 0; else - ((int *) buf52[i][j].p)[l] = n++; + ((int *)buf52[i][j].p)[l] = n++; } } @@ -6615,9 +6576,9 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff [ 2 1 ] 11 0 11 */ - sid = H5Screate_simple(2, dims2, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - aid = H5Acreate2(loc_id, "vlen2D", tid, sid, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(2, dims2, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + aid = H5Acreate2(loc_id, "vlen2D", tid, sid, H5P_DEFAULT, H5P_DEFAULT); status = H5Awrite(aid, tid, buf52); assert(status >= 0); status = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf52); @@ -6627,9 +6588,9 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Sclose(sid); /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ + * H5T_ARRAY + *------------------------------------------------------------------------- + */ if (make_diffs) memset(buf62, 0, sizeof buf62); @@ -6664,9 +6625,9 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_INTEGER and H5T_FLOAT - *------------------------------------------------------------------------- - */ + * H5T_INTEGER and H5T_FLOAT + *------------------------------------------------------------------------- + */ if (make_diffs) { memset(buf72, 0, sizeof buf72); @@ -6698,14 +6659,14 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff write_attr(loc_id, 2, dims2, "float2D", H5T_NATIVE_FLOAT, buf82); /*------------------------------------------------------------------------- - * 3D attributes - *------------------------------------------------------------------------- - */ + * 3D attributes + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ + * H5T_STRING + *------------------------------------------------------------------------- + */ if (make_diffs) { for (i = 0; i < 4; i++) @@ -6772,8 +6733,8 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff [ 3 2 1 ] Z z */ - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, (size_t) STR_SIZE); + tid = H5Tcopy(H5T_C_S1); + status = H5Tset_size(tid, (size_t)STR_SIZE); write_attr(loc_id, 3, dims3, "string3D", tid, buf13); status = H5Tclose(tid); @@ -6781,15 +6742,15 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff for (j = 0; j < 3; j++) for (k = 0; k < 2; k++) buf13a[i][j][k] = buf13[i][j][k]; - tid = H5Tcopy(H5T_C_S1); + tid = H5Tcopy(H5T_C_S1); status = H5Tset_size(tid, H5T_VARIABLE); write_attr(loc_id, 3, dims3, "VLstring3D", tid, buf13a); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ n = 1; for (i = 0; i < 4; i++) @@ -6798,7 +6759,7 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff if (make_diffs) buf23[i][j][k] = 0; else - buf23[i][j][k] = (char) n++; + buf23[i][j][k] = (char)n++; } /* position bitfield3D of </g1> bitfield3D of </g1> difference @@ -6834,18 +6795,18 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ - tid = H5Tcreate(H5T_OPAQUE, (size_t) 1); + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ + tid = H5Tcreate(H5T_OPAQUE, (size_t)1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ write_attr(loc_id, 3, dims3, "opaque3D", tid, buf23); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ n = 1; for (i = 0; i < 4; i++) @@ -6856,7 +6817,7 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff buf33[i][j][k].b = 0.0F; } else { - buf33[i][j][k].a = (char) n++; + buf33[i][j][k].a = (char)n++; buf33[i][j][k].b = n++; } } @@ -6919,23 +6880,22 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_REFERENCE (H5R_OBJECT object reference) - *------------------------------------------------------------------------- - */ + * H5T_REFERENCE (H5R_OBJECT object reference) + *------------------------------------------------------------------------- + */ /* Create references to dataset */ if (dset_name) { for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) for (k = 0; k < 2; k++) - status = H5Rcreate(&buf43[i][j][k], fid, dset_name, - H5R_OBJECT, (hid_t) -1); + status = H5Rcreate(&buf43[i][j][k], fid, dset_name, H5R_OBJECT, (hid_t)-1); write_attr(loc_id, 3, dims3, "reference3D", H5T_STD_REF_OBJ, buf43); } /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ + * H5T_ENUM + *------------------------------------------------------------------------- + */ for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) @@ -6981,22 +6941,22 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_VLEN - *------------------------------------------------------------------------- - */ + * H5T_VLEN + *------------------------------------------------------------------------- + */ /* Allocate and initialize VL dataset to write */ n = 0; for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) for (k = 0; k < 2; k++) { - buf53[i][j][k].p = HDmalloc((size_t)(i + 1) * sizeof(int)); + buf53[i][j][k].p = HDmalloc((size_t)(i + 1) * sizeof(int)); buf53[i][j][k].len = (size_t)(i + 1); for (l = 0; l < i + 1; l++) if (make_diffs) - ((int *) buf53[i][j][k].p)[l] = 0; + ((int *)buf53[i][j][k].p)[l] = 0; else - ((int *) buf53[i][j][k].p)[l] = n++; + ((int *)buf53[i][j][k].p)[l] = n++; } /* position vlen3D of </g1> vlen3D of </g1> difference @@ -7013,9 +6973,9 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff [ 1 1 0 ] 10 0 10 etc */ - sid = H5Screate_simple(3, dims3, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - aid = H5Acreate2(loc_id, "vlen3D", tid, sid, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(3, dims3, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + aid = H5Acreate2(loc_id, "vlen3D", tid, sid, H5P_DEFAULT, H5P_DEFAULT); status = H5Awrite(aid, tid, buf53); assert(status >= 0); status = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf53); @@ -7025,12 +6985,12 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Sclose(sid); /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ + * H5T_ARRAY + *------------------------------------------------------------------------- + */ n = 1; for (i = 0; i < 24; i++) - for (j = 0; j < (int) dimarray[0]; j++) { + for (j = 0; j < (int)dimarray[0]; j++) { if (make_diffs) buf63[i][j] = 0; else @@ -7054,9 +7014,9 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_INTEGER and H5T_FLOAT - *------------------------------------------------------------------------- - */ + * H5T_INTEGER and H5T_FLOAT + *------------------------------------------------------------------------- + */ n = 1; f = 1; for (i = 0; i < 4; i++) @@ -7098,77 +7058,76 @@ void write_attr_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff * *------------------------------------------------------------------------- */ -static -void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diffs /* flag to modify data buffers */) +static void +write_dset_in(hid_t loc_id, const char *dset_name, hid_t fid, + int make_diffs /* flag to modify data buffers */) { /* Compound datatype */ typedef struct s_t { - char a; + char a; double b; } s_t; - typedef enum { - RED, GREEN - } e_t; + typedef enum { RED, GREEN } e_t; - hid_t did = -1; - hid_t sid = -1; - hid_t tid = -1; - hid_t dcpl = -1; + hid_t did = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + hid_t dcpl = H5I_INVALID_HID; herr_t status; - int val, i, j, k, l, n; - float f; - int fillvalue = 2; - int scalar_data = 2; + int val, i, j, k, l, n; + float f; + int fillvalue = 2; + int scalar_data = 2; /* create 1D attributes with dimension [2], 2 elements */ - hsize_t dims[1] = { 2 }; - char buf1[2][STR_SIZE] = { "ab", "de" }; /* string */ - char *buf1a[2]; /* VL string */ - char buf2[2] = { 1, 2 }; /* bitfield, opaque */ - s_t buf3[2] = { { 1, 2.0F }, { 3, 4.0F } }; /* compound */ - hobj_ref_t buf4[2]; /* reference */ - e_t buf45[2] = { RED, GREEN }; /* enum */ - hvl_t buf5[2]; /* vlen */ - hsize_t dimarray[1] = { 3 }; /* array dimension */ - int buf6[2][3] = { { 1, 2, 3 }, { 4, 5, 6 } }; /* array */ - int buf7[2] = { 1, 2 }; /* integer */ - float buf8[2] = { 1.0F, 2.0F }; /* float */ + hsize_t dims[1] = {2}; + char buf1[2][STR_SIZE] = {"ab", "de"}; /* string */ + char * buf1a[2]; /* VL string */ + char buf2[2] = {1, 2}; /* bitfield, opaque */ + s_t buf3[2] = {{1, 2.0F}, {3, 4.0F}}; /* compound */ + hobj_ref_t buf4[2]; /* reference */ + e_t buf45[2] = {RED, GREEN}; /* enum */ + hvl_t buf5[2]; /* vlen */ + hsize_t dimarray[1] = {3}; /* array dimension */ + int buf6[2][3] = {{1, 2, 3}, {4, 5, 6}}; /* array */ + int buf7[2] = {1, 2}; /* integer */ + float buf8[2] = {1.0F, 2.0F}; /* float */ /* create 2D attributes with dimension [3][2], 6 elements */ - hsize_t dims2[2] = { 3, 2 }; - char buf12[3][2][STR_SIZE] = { { "ab", "cd" }, { "ef", "gh" }, { "ij", "kl" } }; /* string */ - char *buf12a[3][2]; /* VL string */ - char buf22[3][2] = { { 1, 2 }, { 3, 4 }, { 5, 6 } }; /* bitfield, opaque */ - s_t buf32[6] = { { 1, 2.0F }, { 3, 4.0F }, { 5, 6.0F }, { 7, 8.0F }, { 9, 10.0F }, { 11, 12.0F } }; /* compound */ - hobj_ref_t buf42[3][2]; /* reference */ - hvl_t buf52[3][2]; /* vlen */ - int buf62[6][3] = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }, { 10, 11, 12 }, { 13, 14, 15 }, { 16, 17, 18 } }; /* array */ - int buf72[3][2] = { { 1, 2 }, { 3, 4 }, { 5, 6 } }; /* integer */ - float buf82[3][2] = { { 1.0F, 2.0F }, { 3.0F, 4.0F }, { 5.0F, 6.0F } }; /* float */ + hsize_t dims2[2] = {3, 2}; + char buf12[3][2][STR_SIZE] = {{"ab", "cd"}, {"ef", "gh"}, {"ij", "kl"}}; /* string */ + char * buf12a[3][2]; /* VL string */ + char buf22[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* bitfield, opaque */ + s_t buf32[6] = {{1, 2.0F}, {3, 4.0F}, {5, 6.0F}, {7, 8.0F}, {9, 10.0F}, {11, 12.0F}}; /* compound */ + hobj_ref_t buf42[3][2]; /* reference */ + hvl_t buf52[3][2]; /* vlen */ + int buf62[6][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}, {13, 14, 15}, {16, 17, 18}}; /* array */ + int buf72[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* integer */ + float buf82[3][2] = {{1.0F, 2.0F}, {3.0F, 4.0F}, {5.0F, 6.0F}}; /* float */ /* create 3D attributes with dimension [4][3][2], 24 elements */ - hsize_t dims3[3] = { 4, 3, 2 }; - char buf13[4][3][2][STR_SIZE] = { { { "ab", "cd" }, { "ef", "gh" }, { "ij", "kl" } }, - { { "mn", "pq" }, { "rs", "tu" }, { "vw", "xz" } }, - { { "AB", "CD" }, { "EF", "GH" }, { "IJ", "KL" } }, - { { "MN", "PQ" }, { "RS", "TU" }, { "VW", "XZ" } } }; /* string */ - char *buf13a[4][3][2]; /* VL string */ - char buf23[4][3][2]; /* bitfield, opaque */ - s_t buf33[4][3][2]; /* compound */ - hobj_ref_t buf43[4][3][2]; /* reference */ - hvl_t buf53[4][3][2]; /* vlen */ - int buf63[24][3]; /* array */ - int buf73[4][3][2]; /* integer */ - float buf83[4][3][2]; /* float */ + hsize_t dims3[3] = {4, 3, 2}; + char buf13[4][3][2][STR_SIZE] = {{{"ab", "cd"}, {"ef", "gh"}, {"ij", "kl"}}, + {{"mn", "pq"}, {"rs", "tu"}, {"vw", "xz"}}, + {{"AB", "CD"}, {"EF", "GH"}, {"IJ", "KL"}}, + {{"MN", "PQ"}, {"RS", "TU"}, {"VW", "XZ"}}}; /* string */ + char * buf13a[4][3][2]; /* VL string */ + char buf23[4][3][2]; /* bitfield, opaque */ + s_t buf33[4][3][2]; /* compound */ + hobj_ref_t buf43[4][3][2]; /* reference */ + hvl_t buf53[4][3][2]; /* vlen */ + int buf63[24][3]; /* array */ + int buf73[4][3][2]; /* integer */ + float buf83[4][3][2]; /* float */ if (make_diffs == 2) dimarray[0] = 4; /*------------------------------------------------------------------------- - * H5S_SCALAR - *------------------------------------------------------------------------- - */ + * H5S_SCALAR + *------------------------------------------------------------------------- + */ if (make_diffs) scalar_data = 1; @@ -7187,37 +7146,37 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff H5Sclose(sid); /*------------------------------------------------------------------------- - * 1D - *------------------------------------------------------------------------- - */ + * 1D + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ + * H5T_STRING + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) for (j = 0; j < 2; j++) buf1[i][j] = 'z'; - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, (size_t) STR_SIZE); + tid = H5Tcopy(H5T_C_S1); + status = H5Tset_size(tid, (size_t)STR_SIZE); write_dset(loc_id, 1, dims, "string", tid, buf1); status = H5Tclose(tid); for (i = 0; i < 2; i++) buf1a[i] = buf1[i]; - tid = H5Tcopy(H5T_C_S1); + tid = H5Tcopy(H5T_C_S1); status = H5Tset_size(tid, H5T_VARIABLE); write_dset(loc_id, 1, dims, "VLstring", tid, buf1a); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) @@ -7228,9 +7187,9 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) { @@ -7238,15 +7197,15 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff buf3[i].b = 0; } - tid = H5Tcreate(H5T_OPAQUE, (size_t) 1); + tid = H5Tcreate(H5T_OPAQUE, (size_t)1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ write_dset(loc_id, 1, dims, "opaque", tid, buf2); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) @@ -7259,27 +7218,27 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_REFERENCE (H5R_OBJECT object reference) - *------------------------------------------------------------------------- - */ + * H5T_REFERENCE (H5R_OBJECT object reference) + *------------------------------------------------------------------------- + */ /* Create references to dataset */ if (dset_name) { - status = H5Rcreate(&buf4[0], fid, dset_name, H5R_OBJECT, (hid_t) -1); - status = H5Rcreate(&buf4[1], fid, dset_name, H5R_OBJECT, (hid_t) -1); + status = H5Rcreate(&buf4[0], fid, dset_name, H5R_OBJECT, (hid_t)-1); + status = H5Rcreate(&buf4[1], fid, dset_name, H5R_OBJECT, (hid_t)-1); write_dset(loc_id, 1, dims, "reference", H5T_STD_REF_OBJ, buf4); } /*------------------------------------------------------------------------- - * H5T_REFERENCE (H5R_DATASET_REGION dataset region reference) - *------------------------------------------------------------------------- - */ + * H5T_REFERENCE (H5R_DATASET_REGION dataset region reference) + *------------------------------------------------------------------------- + */ gen_datareg(fid, make_diffs); /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ + * H5T_ENUM + *------------------------------------------------------------------------- + */ tid = H5Tcreate(H5T_ENUM, sizeof(e_t)); H5Tenum_insert(tid, "RED", (val = 0, &val)); H5Tenum_insert(tid, "GREEN", (val = 1, &val)); @@ -7287,30 +7246,29 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_VLEN - *------------------------------------------------------------------------- - */ + * H5T_VLEN + *------------------------------------------------------------------------- + */ /* Allocate and initialize VL dataset to write */ - buf5[0].len = 1; - buf5[0].p = HDmalloc(1 * sizeof(int)); - ((int *) buf5[0].p)[0] = 1; - buf5[1].len = 2; - buf5[1].p = HDmalloc(2 * sizeof(int)); - ((int *) buf5[1].p)[0] = 2; - ((int *) buf5[1].p)[1] = 3; + buf5[0].len = 1; + buf5[0].p = HDmalloc(1 * sizeof(int)); + ((int *)buf5[0].p)[0] = 1; + buf5[1].len = 2; + buf5[1].p = HDmalloc(2 * sizeof(int)); + ((int *)buf5[1].p)[0] = 2; + ((int *)buf5[1].p)[1] = 3; if (make_diffs) { - ((int *) buf5[0].p)[0] = 0; - ((int *) buf5[1].p)[0] = 0; - ((int *) buf5[1].p)[1] = 0; + ((int *)buf5[0].p)[0] = 0; + ((int *)buf5[1].p)[0] = 0; + ((int *)buf5[1].p)[1] = 0; } - sid = H5Screate_simple(1, dims, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - did = H5Dcreate2(loc_id, "vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT, - H5P_DEFAULT); + sid = H5Screate_simple(1, dims, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + did = H5Dcreate2(loc_id, "vlen", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf5); HDassert(status >= 0); status = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf5); @@ -7320,9 +7278,9 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Sclose(sid); /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ + * H5T_ARRAY + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) @@ -7334,21 +7292,21 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); { - double *dbuf; /* information to write */ - hid_t ldid = -1; /* dataset ID */ - hid_t lsid = -1; /* dataspace ID */ - hid_t ltid = -1; /* datatype ID */ - size_t size; - hsize_t sdims[] = { 1 }; - hsize_t tdims[] = { H5TOOLS_MALLOCSIZE / sizeof(double) + 1 }; - size_t jj; + double *dbuf; /* information to write */ + hid_t ldid = H5I_INVALID_HID; /* dataset ID */ + hid_t lsid = H5I_INVALID_HID; /* dataspace ID */ + hid_t ltid = H5I_INVALID_HID; /* datatype ID */ + size_t size; + hsize_t sdims[] = {1}; + hsize_t tdims[] = {H5TOOLS_MALLOCSIZE / sizeof(double) + 1}; + size_t jj; /* allocate and initialize array data to write */ size = (H5TOOLS_MALLOCSIZE / sizeof(double) + 1) * sizeof(double); - dbuf = (double *) HDmalloc(size); + dbuf = (double *)HDmalloc(size); for (jj = 0; jj < (H5TOOLS_MALLOCSIZE / sizeof(double) + 1); jj++) - dbuf[jj] = (double) jj; + dbuf[jj] = (double)jj; if (make_diffs) { dbuf[5] = 0; @@ -7372,9 +7330,9 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff } /*------------------------------------------------------------------------- - * H5T_INTEGER and H5T_FLOAT - *------------------------------------------------------------------------- - */ + * H5T_INTEGER and H5T_FLOAT + *------------------------------------------------------------------------- + */ if (make_diffs) for (i = 0; i < 2; i++) { @@ -7386,14 +7344,14 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff write_dset(loc_id, 1, dims, "float", H5T_NATIVE_FLOAT, buf8); /*------------------------------------------------------------------------- - * 2D - *------------------------------------------------------------------------- - */ + * 2D + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ + * H5T_STRING + *------------------------------------------------------------------------- + */ if (make_diffs) { for (i = 0; i < 3; i++) @@ -7402,8 +7360,8 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff buf12[i][j][k] = 'z'; } - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, (size_t) STR_SIZE); + tid = H5Tcopy(H5T_C_S1); + status = H5Tset_size(tid, (size_t)STR_SIZE); write_dset(loc_id, 2, dims2, "string2D", tid, buf12); status = H5Tclose(tid); @@ -7411,15 +7369,15 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff for (j = 0; j < 2; j++) buf12a[i][j] = buf12[i][j]; - tid = H5Tcopy(H5T_C_S1); + tid = H5Tcopy(H5T_C_S1); status = H5Tset_size(tid, H5T_VARIABLE); write_dset(loc_id, 2, dims2, "VLstring2D", tid, buf12a); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ if (make_diffs) memset(buf22, 0, sizeof buf22); @@ -7429,18 +7387,18 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ - tid = H5Tcreate(H5T_OPAQUE, (size_t) 1); + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ + tid = H5Tcreate(H5T_OPAQUE, (size_t)1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ write_dset(loc_id, 2, dims2, "opaque2D", tid, buf22); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ if (make_diffs) memset(buf32, 0, sizeof buf32); @@ -7452,21 +7410,21 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_REFERENCE (H5R_OBJECT object reference) - *------------------------------------------------------------------------- - */ + * H5T_REFERENCE (H5R_OBJECT object reference) + *------------------------------------------------------------------------- + */ /* Create references to dataset */ if (dset_name) { for (i = 0; i < 3; i++) for (j = 0; j < 2; j++) - status = H5Rcreate(&buf42[i][j], fid, dset_name, H5R_OBJECT, (hid_t) -1); + status = H5Rcreate(&buf42[i][j], fid, dset_name, H5R_OBJECT, (hid_t)-1); write_dset(loc_id, 2, dims2, "reference2D", H5T_STD_REF_OBJ, buf42); } /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ + * H5T_ENUM + *------------------------------------------------------------------------- + */ tid = H5Tcreate(H5T_ENUM, sizeof(e_t)); H5Tenum_insert(tid, "RED", (val = 0, &val)); @@ -7475,27 +7433,27 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_VLEN - *------------------------------------------------------------------------- - */ + * H5T_VLEN + *------------------------------------------------------------------------- + */ /* Allocate and initialize VL dataset to write */ n = 0; for (i = 0; i < 3; i++) for (j = 0; j < 2; j++) { - buf52[i][j].p = HDmalloc((size_t)(i + 1) * sizeof(int)); + buf52[i][j].p = HDmalloc((size_t)(i + 1) * sizeof(int)); buf52[i][j].len = (size_t)(i + 1); for (l = 0; l < i + 1; l++) { if (make_diffs) - ((int *) buf52[i][j].p)[l] = 0; + ((int *)buf52[i][j].p)[l] = 0; else - ((int *) buf52[i][j].p)[l] = n++; + ((int *)buf52[i][j].p)[l] = n++; } } - sid = H5Screate_simple(2, dims2, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - did = H5Dcreate2(loc_id, "vlen2D", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(2, dims2, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + did = H5Dcreate2(loc_id, "vlen2D", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf52); assert(status >= 0); status = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf52); @@ -7505,9 +7463,9 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Sclose(sid); /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ + * H5T_ARRAY + *------------------------------------------------------------------------- + */ if (make_diffs) memset(buf62, 0, sizeof buf62); @@ -7517,40 +7475,40 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_INTEGER, write a fill value - *------------------------------------------------------------------------- - */ + * H5T_INTEGER, write a fill value + *------------------------------------------------------------------------- + */ if (make_diffs) { memset(buf72, 0, sizeof buf72); memset(buf82, 0, sizeof buf82); } - dcpl = H5Pcreate(H5P_DATASET_CREATE); + dcpl = H5Pcreate(H5P_DATASET_CREATE); status = H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillvalue); - sid = H5Screate_simple(2, dims2, NULL); - did = H5Dcreate2(loc_id, "integer2D", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); + sid = H5Screate_simple(2, dims2, NULL); + did = H5Dcreate2(loc_id, "integer2D", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); status = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf72); status = H5Pclose(dcpl); status = H5Dclose(did); status = H5Sclose(sid); /*------------------------------------------------------------------------- - * H5T_FLOAT - *------------------------------------------------------------------------- - */ + * H5T_FLOAT + *------------------------------------------------------------------------- + */ write_dset(loc_id, 2, dims2, "float2D", H5T_NATIVE_FLOAT, buf82); /*------------------------------------------------------------------------- - * 3D - *------------------------------------------------------------------------- - */ + * 3D + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ + * H5T_STRING + *------------------------------------------------------------------------- + */ if (make_diffs) { for (i = 0; i < 4; i++) @@ -7560,8 +7518,8 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff buf13[i][j][k][l] = 'z'; } - tid = H5Tcopy(H5T_C_S1); - status = H5Tset_size(tid, (size_t) STR_SIZE); + tid = H5Tcopy(H5T_C_S1); + status = H5Tset_size(tid, (size_t)STR_SIZE); write_dset(loc_id, 3, dims3, "string3D", tid, buf13); status = H5Tclose(tid); @@ -7570,15 +7528,15 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff for (k = 0; k < 2; k++) buf13a[i][j][k] = buf13[i][j][k]; - tid = H5Tcopy(H5T_C_S1); + tid = H5Tcopy(H5T_C_S1); status = H5Tset_size(tid, H5T_VARIABLE); write_dset(loc_id, 3, dims3, "VLstring3D", tid, buf13a); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ n = 1; for (i = 0; i < 4; i++) @@ -7587,7 +7545,7 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff if (make_diffs) buf23[i][j][k] = 0; else - buf23[i][j][k] = (char) n++; + buf23[i][j][k] = (char)n++; } tid = H5Tcopy(H5T_STD_B8LE); @@ -7595,18 +7553,18 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ - tid = H5Tcreate(H5T_OPAQUE, (size_t) 1); + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ + tid = H5Tcreate(H5T_OPAQUE, (size_t)1); status = H5Tset_tag(tid, "1-byte opaque type"); /* must set this */ write_dset(loc_id, 3, dims3, "opaque3D", tid, buf23); status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ n = 1; for (i = 0; i < 4; i++) @@ -7617,7 +7575,7 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff buf33[i][j][k].b = 0.0F; } else { - buf33[i][j][k].a = (char) n++; + buf33[i][j][k].a = (char)n++; buf33[i][j][k].b = n++; } } @@ -7629,22 +7587,22 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_REFERENCE (H5R_OBJECT object reference) - *------------------------------------------------------------------------- - */ + * H5T_REFERENCE (H5R_OBJECT object reference) + *------------------------------------------------------------------------- + */ /* Create references to dataset */ if (dset_name) { for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) for (k = 0; k < 2; k++) - status = H5Rcreate(&buf43[i][j][k], fid, dset_name, H5R_OBJECT, (hid_t) -1); + status = H5Rcreate(&buf43[i][j][k], fid, dset_name, H5R_OBJECT, (hid_t)-1); write_dset(loc_id, 3, dims3, "reference3D", H5T_STD_REF_OBJ, buf43); } /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ + * H5T_ENUM + *------------------------------------------------------------------------- + */ tid = H5Tcreate(H5T_ENUM, sizeof(e_t)); H5Tenum_insert(tid, "RED", (val = 0, &val)); @@ -7653,28 +7611,28 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_VLEN - *------------------------------------------------------------------------- - */ + * H5T_VLEN + *------------------------------------------------------------------------- + */ /* Allocate and initialize VL dataset to write */ n = 0; for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) for (k = 0; k < 2; k++) { - buf53[i][j][k].p = HDmalloc((size_t)(i + 1) * sizeof(int)); + buf53[i][j][k].p = HDmalloc((size_t)(i + 1) * sizeof(int)); buf53[i][j][k].len = (size_t)(i + 1); for (l = 0; l < i + 1; l++) { if (make_diffs) - ((int *) buf53[i][j][k].p)[l] = 0; + ((int *)buf53[i][j][k].p)[l] = 0; else - ((int *) buf53[i][j][k].p)[l] = n++; + ((int *)buf53[i][j][k].p)[l] = n++; } } - sid = H5Screate_simple(3, dims3, NULL); - tid = H5Tvlen_create(H5T_NATIVE_INT); - did = H5Dcreate2(loc_id, "vlen3D", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + sid = H5Screate_simple(3, dims3, NULL); + tid = H5Tvlen_create(H5T_NATIVE_INT); + did = H5Dcreate2(loc_id, "vlen3D", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf53); assert(status >= 0); status = H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf53); @@ -7684,9 +7642,9 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Sclose(sid); /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ + * H5T_ARRAY + *------------------------------------------------------------------------- + */ n = 1; for (i = 0; i < 24; i++) @@ -7702,9 +7660,9 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff status = H5Tclose(tid); /*------------------------------------------------------------------------- - * H5T_INTEGER and H5T_FLOAT - *------------------------------------------------------------------------- - */ + * H5T_INTEGER and H5T_FLOAT + *------------------------------------------------------------------------- + */ n = 1; f = 1; for (i = 0; i < 4; i++) @@ -7734,44 +7692,43 @@ void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int make_diff *------------------------------------------------------------------------- */ -static -void gen_datareg(hid_t fid, int make_diffs /* flag to modify data buffers */) +static void +gen_datareg(hid_t fid, int make_diffs /* flag to modify data buffers */) { /* data dataset */ - hid_t did1 = -1; /* dataset ID */ - hid_t sid1 = -1; /* dataspace ID */ - hsize_t dims1[2] = { 10, 10 };/* dimensions */ - int *buf; /* dataset buffer */ + hid_t did1 = H5I_INVALID_HID; /* dataset ID */ + hid_t sid1 = H5I_INVALID_HID; /* dataspace ID */ + hsize_t dims1[2] = {10, 10}; /* dimensions */ + int * buf; /* dataset buffer */ /* reference dataset */ - hid_t did2 = -1; /* dataset ID */ - hid_t sid2 = -1; /* dataspace ID */ - hsize_t dims2[] = { 2 }; /* 2 references */ - hdset_reg_ref_t *rbuf; /* buffer for write the references */ - hsize_t start[10]; /* starting location of hyperslab */ - hsize_t count[10]; /* element count of hyperslab */ - hsize_t coord[5][2]; /* coordinates for point selection */ - herr_t status; - int i; + hid_t did2 = H5I_INVALID_HID; /* dataset ID */ + hid_t sid2 = H5I_INVALID_HID; /* dataspace ID */ + hsize_t dims2[] = {2}; /* 2 references */ + hdset_reg_ref_t *rbuf; /* buffer for write the references */ + hsize_t start[10]; /* starting location of hyperslab */ + hsize_t count[10]; /* element count of hyperslab */ + hsize_t coord[5][2]; /* coordinates for point selection */ + herr_t status; + int i; /* allocate the buffer for write the references */ - rbuf = (hdset_reg_ref_t *) HDcalloc((size_t )2, sizeof(hdset_reg_ref_t)); + rbuf = (hdset_reg_ref_t *)HDcalloc((size_t)2, sizeof(hdset_reg_ref_t)); /* allocate the buffer for write the data dataset */ - buf = (int *) HDmalloc(10 * 10 * sizeof(int)); + buf = (int *)HDmalloc(10 * 10 * sizeof(int)); for (i = 0; i < 10 * 10; i++) buf[i] = i; /* create the data dataset */ - sid1 = H5Screate_simple(2, dims1, NULL); - did1 = H5Dcreate2(fid, "dsetref", H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + sid1 = H5Screate_simple(2, dims1, NULL); + did1 = H5Dcreate2(fid, "dsetref", H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); HDassert(status >= 0); /* create the reference dataset */ sid2 = H5Screate_simple(1, dims2, NULL); - did2 = H5Dcreate2(fid, "refreg", H5T_STD_REF_DSETREG, sid2, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); + did2 = H5Dcreate2(fid, "refreg", H5T_STD_REF_DSETREG, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* create the references */ /* select hyperslab for first reference */ @@ -7814,7 +7771,7 @@ void gen_datareg(hid_t fid, int make_diffs /* flag to modify data buffers */) coord[4][0] = 1; coord[4][1] = 7; } - H5Sselect_elements(sid1, H5S_SELECT_SET, (size_t) 5, (const hsize_t *) coord); + H5Sselect_elements(sid1, H5S_SELECT_SET, (size_t)5, (const hsize_t *)coord); H5Sget_select_npoints(sid1); /* store second dataset region */ @@ -7846,25 +7803,25 @@ void gen_datareg(hid_t fid, int make_diffs /* flag to modify data buffers */) * *------------------------------------------------------------------------- */ -static -int test_hyperslab(const char *fname, int make_diffs /* flag to modify data buffers */) +static int +test_hyperslab(const char *fname, int make_diffs /* flag to modify data buffers */) { - hid_t did = -1; - hid_t fid = -1; - hid_t f_sid = -1; - hid_t m_sid = -1; - hid_t tid = -1; - hid_t dcpl = -1; - hsize_t dims[1] = { GBLL }; /* dataset dimensions */ - hsize_t hs_size[1] = { GBLL / (1024 * 1024) }; /* hyperslab dimensions */ - hsize_t chunk_dims[1] = { GBLL / 1024 }; /* chunk dimensions */ + hid_t did = H5I_INVALID_HID; + hid_t fid = H5I_INVALID_HID; + hid_t f_sid = H5I_INVALID_HID; + hid_t m_sid = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + hid_t dcpl = H5I_INVALID_HID; + hsize_t dims[1] = {GBLL}; /* dataset dimensions */ + hsize_t hs_size[1] = {GBLL / (1024 * 1024)}; /* hyperslab dimensions */ + hsize_t chunk_dims[1] = {GBLL / 1024}; /* chunk dimensions */ hsize_t hs_start[1]; - size_t size; - size_t nelmts = (size_t)GBLL / (1024 * 1024); /* elements in each hyperslab */ - char fillvalue = -1; - char *buf = NULL; - int i, j, s; - char c; + size_t size; + size_t nelmts = (size_t)GBLL / (1024 * 1024); /* elements in each hyperslab */ + char fillvalue = -1; + char * buf = NULL; + int i, j, s; + char c; /* create */ fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -7886,8 +7843,8 @@ int test_hyperslab(const char *fname, int make_diffs /* flag to modify data buff goto out; /* create a evenly divided buffer from 0 to 127 */ - buf = (char *) HDmalloc((size_t)(nelmts * size)); - s = 1024 * 1024 / 127; + buf = (char *)HDmalloc((size_t)(nelmts * size)); + s = 1024 * 1024 / 127; for (i = 0, j = 0, c = 0; i < 1024 * 1024; j++, i++) { if (j == s) { c++; @@ -7901,7 +7858,7 @@ int test_hyperslab(const char *fname, int make_diffs /* flag to modify data buff if (make_diffs && i == 512 * 512) HDmemset(buf, 0, nelmts); - hs_start[0] = (unsigned long long) i * GBLL / (1024 * 1024); + hs_start[0] = (unsigned long long)i * GBLL / (1024 * 1024); if (H5Sselect_hyperslab(f_sid, H5S_SELECT_SET, hs_start, NULL, hs_size, NULL) < 0) goto out; @@ -7928,13 +7885,15 @@ int test_hyperslab(const char *fname, int make_diffs /* flag to modify data buff return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Sclose(f_sid); H5Sclose(m_sid); H5Dclose(did); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } @@ -7945,11 +7904,11 @@ out: * *------------------------------------------------------------------------- */ -static -int write_attr(hid_t loc_id, int rank, hsize_t *dims, const char *name, hid_t tid, void *buf) +static int +write_attr(hid_t loc_id, int rank, hsize_t *dims, const char *name, hid_t tid, void *buf) { - hid_t aid = -1; - hid_t sid = -1; + hid_t aid = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; /* create a space */ if ((sid = H5Screate_simple(rank, dims, NULL)) < 0) @@ -7985,36 +7944,41 @@ out: * *------------------------------------------------------------------------- */ -static -int write_dset(hid_t loc_id, int rank, hsize_t *dims, const char *name, hid_t tid, void *buf) +static herr_t +write_dset(hid_t loc_id, int rank, hsize_t *dims, const char *name, hid_t tid, void *buf) { - hid_t did = -1; - hid_t sid = -1; + hid_t did = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; /* create a space */ if ((sid = H5Screate_simple(rank, dims, NULL)) < 0) - goto out; + PROGRAM_ERROR /* create the dataset */ if ((did = H5Dcreate2(loc_id, name, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto out; + PROGRAM_ERROR /* write */ - if (buf) { + if (buf) if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - goto out; - } + PROGRAM_ERROR /* close */ - H5Dclose(did); - H5Sclose(sid); + if (H5Dclose(did) < 0) + PROGRAM_ERROR + if (H5Sclose(sid) < 0) + PROGRAM_ERROR return SUCCEED; -out: +error: - H5Dclose(did); - H5Sclose(sid); - return FAIL; -} + H5E_BEGIN_TRY + { + H5Dclose(did); + H5Sclose(sid); + } + H5E_END_TRY; + return FAIL; +} /* end write_dset() */ diff --git a/tools/h5diff/ph5diff_main.c b/tools/h5diff/ph5diff_main.c index 83240cb..60e6dab 100644 --- a/tools/h5diff/ph5diff_main.c +++ b/tools/h5diff/ph5diff_main.c @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -21,7 +21,7 @@ /* Name of tool */ #define PROGRAMNAME "h5diff" -static void ph5diff_worker(int ); +static void ph5diff_worker(int); /*------------------------------------------------------------------------- * Function: main @@ -43,14 +43,15 @@ static void ph5diff_worker(int ); *------------------------------------------------------------------------- */ -int main(int argc, const char *argv[]) +int +main(int argc, const char *argv[]) { - int nID = 0; - const char *fname1 = NULL; - const char *fname2 = NULL; - const char *objname1 = NULL; - const char *objname2 = NULL; - diff_opt_t opts; + int nID = 0; + const char *fname1 = NULL; + const char *fname2 = NULL; + const char *objname1 = NULL; + const char *objname2 = NULL; + diff_opt_t opts; h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); @@ -59,16 +60,15 @@ int main(int argc, const char *argv[]) h5tools_init(); outBuffOffset = 0; - g_Parallel = 1; + g_Parallel = 1; - MPI_Init(&argc, (char***) &argv); + MPI_Init(&argc, (char ***)&argv); MPI_Comm_rank(MPI_COMM_WORLD, &nID); MPI_Comm_size(MPI_COMM_WORLD, &g_nTasks); - if(g_nTasks == 1) - { - printf("Only 1 task available...doing serial diff\n"); + if (g_nTasks == 1) { + HDprintf("Only 1 task available...doing serial diff\n"); g_Parallel = 0; @@ -82,8 +82,7 @@ int main(int argc, const char *argv[]) else { /* Have the manager process the command-line */ - if(nID == 0) - { + if (nID == 0) { parse_command_line(argc, argv, &fname1, &fname2, &objname1, &objname2, &opts); h5diff(fname1, fname2, objname1, objname2, &opts); @@ -126,34 +125,31 @@ int main(int argc, const char *argv[]) static void ph5diff_worker(int nID) { - hid_t file1_id = -1, file2_id = -1; + hid_t file1_id = H5I_INVALID_HID; + hid_t file2_id = H5I_INVALID_HID; - while(1) - { + while (1) { MPI_Status Status; MPI_Probe(0, MPI_ANY_TAG, MPI_COMM_WORLD, &Status); /* Check for filenames */ - if(Status.MPI_TAG == MPI_TAG_PARALLEL) - { - char filenames[2][MAX_FILENAME]; + if (Status.MPI_TAG == MPI_TAG_PARALLEL) { + char filenames[2][MAX_FILENAME]; /* Retrieve filenames */ - MPI_Recv(filenames, MAX_FILENAME*2, MPI_CHAR, 0, MPI_ANY_TAG, MPI_COMM_WORLD, &Status); + MPI_Recv(filenames, MAX_FILENAME * 2, MPI_CHAR, 0, MPI_ANY_TAG, MPI_COMM_WORLD, &Status); /* disable error reporting */ H5E_BEGIN_TRY { /* Open the files */ - if ((file1_id = H5Fopen (filenames[0], H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) - { - printf ("h5diff Task [%d]: <%s>: unable to open file\n", nID, filenames[0]); + if ((file1_id = H5Fopen(filenames[0], H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) { + HDprintf("h5diff Task [%d]: <%s>: unable to open file\n", nID, filenames[0]); MPI_Abort(MPI_COMM_WORLD, 0); } - if ((file2_id = H5Fopen (filenames[1], H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) - { - printf ("h5diff Task [%d]: <%s>: unable to open file\n", nID, filenames[1]); + if ((file2_id = H5Fopen(filenames[1], H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) { + HDprintf("h5diff Task [%d]: <%s>: unable to open file\n", nID, filenames[1]); MPI_Abort(MPI_COMM_WORLD, 0); } /* enable error reporting */ @@ -161,16 +157,14 @@ ph5diff_worker(int nID) H5E_END_TRY; } /* Check for work */ - else if(Status.MPI_TAG == MPI_TAG_ARGS) - { + else if (Status.MPI_TAG == MPI_TAG_ARGS) { struct diff_mpi_args args; - struct diffs_found diffs; - int i; + struct diffs_found diffs; + unsigned i; /* Make certain we've received the filenames and opened the files already */ - if(file1_id < 0 || file2_id < 0) - { - printf("ph5diff_worker: ERROR: work received before/without filenames\n"); + if (file1_id < 0 || file2_id < 0) { + HDprintf("ph5diff_worker: ERROR: work received before/without filenames\n"); break; } @@ -178,51 +172,50 @@ ph5diff_worker(int nID) MPI_Recv(&args, sizeof(args), MPI_BYTE, 0, MPI_TAG_ARGS, MPI_COMM_WORLD, &Status); /* Do the diff */ - diffs.nfound = diff(file1_id, args.name1, file2_id, args.name2, &(args.opts), &(args.argdata)); + diffs.nfound = diff(file1_id, args.name1, file2_id, args.name2, &(args.opts), &(args.argdata)); diffs.not_cmp = args.opts.not_cmp; /* If print buffer has something in it, request print token.*/ - if(outBuffOffset>0) - { + if (outBuffOffset > 0) { MPI_Send(NULL, 0, MPI_BYTE, 0, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD); /* Wait for print token. */ MPI_Recv(NULL, 0, MPI_BYTE, 0, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD, &Status); /* When get token, send all of our output to the manager task and then return the token */ - for(i=0; i<outBuffOffset; i+=PRINT_DATA_MAX_SIZE) - MPI_Send(outBuff+i, PRINT_DATA_MAX_SIZE, MPI_BYTE, 0, MPI_TAG_PRINT_DATA, MPI_COMM_WORLD); + for (i = 0; i < outBuffOffset; i += PRINT_DATA_MAX_SIZE) + MPI_Send(outBuff + i, PRINT_DATA_MAX_SIZE, MPI_BYTE, 0, MPI_TAG_PRINT_DATA, + MPI_COMM_WORLD); /* An overflow file exists, so we send it's output to the manager too and then delete it */ - if(overflow_file) - { + if (overflow_file) { char out_data[PRINT_DATA_MAX_SIZE]; - int tmp; + int tmp; - memset(out_data, 0, PRINT_DATA_MAX_SIZE); - i=0; + HDmemset(out_data, 0, PRINT_DATA_MAX_SIZE); + i = 0; rewind(overflow_file); - while((tmp = getc(overflow_file)) >= 0) - { + while ((tmp = getc(overflow_file)) >= 0) { *(out_data + i++) = (char)tmp; - if(i==PRINT_DATA_MAX_SIZE) - { - MPI_Send(out_data, PRINT_DATA_MAX_SIZE, MPI_BYTE, 0, MPI_TAG_PRINT_DATA, MPI_COMM_WORLD); - i=0; - memset(out_data, 0, PRINT_DATA_MAX_SIZE); + if (i == PRINT_DATA_MAX_SIZE) { + MPI_Send(out_data, PRINT_DATA_MAX_SIZE, MPI_BYTE, 0, MPI_TAG_PRINT_DATA, + MPI_COMM_WORLD); + i = 0; + HDmemset(out_data, 0, PRINT_DATA_MAX_SIZE); } } - if(i>0) - MPI_Send(out_data, PRINT_DATA_MAX_SIZE, MPI_BYTE, 0, MPI_TAG_PRINT_DATA, MPI_COMM_WORLD); + if (i > 0) + MPI_Send(out_data, PRINT_DATA_MAX_SIZE, MPI_BYTE, 0, MPI_TAG_PRINT_DATA, + MPI_COMM_WORLD); fclose(overflow_file); overflow_file = NULL; } - fflush(stdout); - memset(outBuff, 0, OUTBUFF_SIZE); + HDfflush(stdout); + HDmemset(outBuff, 0, OUTBUFF_SIZE); outBuffOffset = 0; MPI_Send(&diffs, sizeof(diffs), MPI_BYTE, 0, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD); @@ -231,17 +224,14 @@ ph5diff_worker(int nID) MPI_Send(&diffs, sizeof(diffs), MPI_BYTE, 0, MPI_TAG_DONE, MPI_COMM_WORLD); } /* Check for leaving */ - else if(Status.MPI_TAG == MPI_TAG_END) - { + else if (Status.MPI_TAG == MPI_TAG_END) { MPI_Recv(NULL, 0, MPI_BYTE, 0, MPI_TAG_END, MPI_COMM_WORLD, &Status); break; } - else - { - printf("ph5diff_worker: ERROR: invalid tag (%d) received\n", Status.MPI_TAG); + else { + HDprintf("ph5diff_worker: ERROR: invalid tag (%d) received\n", Status.MPI_TAG); break; } - } return; @@ -261,19 +251,18 @@ ph5diff_worker(int nID) * *------------------------------------------------------------------------- */ -void print_manager_output(void) +void +print_manager_output(void) { /* If there was something we buffered, let's print it now */ - if( (outBuffOffset>0) && g_Parallel) - { - printf("%s", outBuff); + if ((outBuffOffset > 0) && g_Parallel) { + HDprintf("%s", outBuff); - if(overflow_file) - { - int tmp; + if (overflow_file) { + int tmp; rewind(overflow_file); - while((tmp = getc(overflow_file)) >= 0) - putchar(tmp); + while ((tmp = HDgetc(overflow_file)) >= 0) + HDputchar(tmp); fclose(overflow_file); overflow_file = NULL; } @@ -282,8 +271,7 @@ void print_manager_output(void) HDmemset(outBuff, 0, OUTBUFF_SIZE); outBuffOffset = 0; } - else if( (outBuffOffset>0) && !g_Parallel) - { + else if ((outBuffOffset > 0) && !g_Parallel) { HDfprintf(stderr, "h5diff error: outBuffOffset>0, but we're not in parallel!\n"); } } @@ -304,16 +292,18 @@ void print_manager_output(void) * *------------------------------------------------------------------------- */ -void h5diff_exit(int status) +void +h5diff_exit(int status) { /* if in parallel mode, dismiss workers, close down MPI, then exit */ - if(g_Parallel) { - if(g_nTasks > 1) { + if (g_Parallel) { + if (g_nTasks > 1) { phdiff_dismiss_workers(); MPI_Barrier(MPI_COMM_WORLD); } MPI_Finalize(); - status = EXIT_SUCCESS; /* Reset exit status, since some mpiexec commands generate output on failure status */ + status = EXIT_SUCCESS; /* Reset exit status, since some mpiexec commands generate output on failure + status */ } h5tools_close(); @@ -321,6 +311,5 @@ void h5diff_exit(int status) /* Always exit(0), since MPI implementations do weird stuff when they * receive a non-zero exit value. - QAK */ - exit(0); + HDexit(0); } - diff --git a/tools/h5diff/testfiles/h5diff_459_ERR.err b/tools/h5diff/testfiles/dangling_link.err index 82802a1..82802a1 100644 --- a/tools/h5diff/testfiles/h5diff_459_ERR.err +++ b/tools/h5diff/testfiles/dangling_link.err diff --git a/tools/h5diff/testfiles/h5diff_19.txt b/tools/h5diff/testfiles/h5diff_19.txt new file mode 100644 index 0000000..1155d55 --- /dev/null +++ b/tools/h5diff/testfiles/h5diff_19.txt @@ -0,0 +1,26 @@ + +file1 file2 +--------------------------------------- + x x / + x /g1 + x /g1/d1 + x /g1/d2 + x /g1/dset1 + x /g1/dset10 + x /g1/dset3 + x /g1/dset5 + x /g1/dset6 + x /g1/dset7 + x /g1/dset8 + x /g1/dset9 + x /g1/fp1 + x /g1/fp15 + x /g1/fp16 + x /g1/fp17 + x /g1/fp18 + x /g1/fp2 + x /g1/ld + +group : </> and </> +0 differences found +EXIT CODE: 1 diff --git a/tools/h5diff/testfiles/h5diff_454_ERR.err b/tools/h5diff/testfiles/h5diff_454_ERR.err deleted file mode 100644 index 82802a1..0000000 --- a/tools/h5diff/testfiles/h5diff_454_ERR.err +++ /dev/null @@ -1,4 +0,0 @@ -H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5diff(): treat dangling link as error - major: Failure in tools library - minor: error in function diff --git a/tools/h5diff/testfiles/h5diff_454_ERR.txt b/tools/h5diff/testfiles/h5diff_454_ERR.txt deleted file mode 100644 index 4501071..0000000 --- a/tools/h5diff/testfiles/h5diff_454_ERR.txt +++ /dev/null @@ -1,6 +0,0 @@ -Warning: </softlink_noexist> is a dangling link. -H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5diff(): treat dangling link as error - major: Failure in tools library - minor: error in function -EXIT CODE: 2 diff --git a/tools/h5diff/testfiles/h5diff_455_ERR.err b/tools/h5diff/testfiles/h5diff_455_ERR.err deleted file mode 100644 index 82802a1..0000000 --- a/tools/h5diff/testfiles/h5diff_455_ERR.err +++ /dev/null @@ -1,4 +0,0 @@ -H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5diff(): treat dangling link as error - major: Failure in tools library - minor: error in function diff --git a/tools/h5diff/testfiles/h5diff_455_ERR.txt b/tools/h5diff/testfiles/h5diff_455_ERR.txt deleted file mode 100644 index 4501071..0000000 --- a/tools/h5diff/testfiles/h5diff_455_ERR.txt +++ /dev/null @@ -1,6 +0,0 @@ -Warning: </softlink_noexist> is a dangling link. -H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5diff(): treat dangling link as error - major: Failure in tools library - minor: error in function -EXIT CODE: 2 diff --git a/tools/h5diff/testfiles/h5diff_457_ERR.err b/tools/h5diff/testfiles/h5diff_457_ERR.err deleted file mode 100644 index 82802a1..0000000 --- a/tools/h5diff/testfiles/h5diff_457_ERR.err +++ /dev/null @@ -1,4 +0,0 @@ -H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5diff(): treat dangling link as error - major: Failure in tools library - minor: error in function diff --git a/tools/h5diff/testfiles/h5diff_457_ERR.txt b/tools/h5diff/testfiles/h5diff_457_ERR.txt deleted file mode 100644 index 9d73750..0000000 --- a/tools/h5diff/testfiles/h5diff_457_ERR.txt +++ /dev/null @@ -1,6 +0,0 @@ -Warning: </ext_link_noexist1> is a dangling link. -H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5diff(): treat dangling link as error - major: Failure in tools library - minor: error in function -EXIT CODE: 2 diff --git a/tools/h5diff/testfiles/h5diff_458_ERR.err b/tools/h5diff/testfiles/h5diff_458_ERR.err deleted file mode 100644 index 82802a1..0000000 --- a/tools/h5diff/testfiles/h5diff_458_ERR.err +++ /dev/null @@ -1,4 +0,0 @@ -H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5diff(): treat dangling link as error - major: Failure in tools library - minor: error in function diff --git a/tools/h5diff/testfiles/h5diff_458_ERR.txt b/tools/h5diff/testfiles/h5diff_458_ERR.txt deleted file mode 100644 index b084914..0000000 --- a/tools/h5diff/testfiles/h5diff_458_ERR.txt +++ /dev/null @@ -1,6 +0,0 @@ -Warning: </ext_link_noexist2> is a dangling link. -H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5diff(): treat dangling link as error - major: Failure in tools library - minor: error in function -EXIT CODE: 2 diff --git a/tools/h5diff/testfiles/h5diff_459_ERR.txt b/tools/h5diff/testfiles/h5diff_459_ERR.txt deleted file mode 100644 index 9d73750..0000000 --- a/tools/h5diff/testfiles/h5diff_459_ERR.txt +++ /dev/null @@ -1,6 +0,0 @@ -Warning: </ext_link_noexist1> is a dangling link. -H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5diff(): treat dangling link as error - major: Failure in tools library - minor: error in function -EXIT CODE: 2 diff --git a/tools/h5diff/testfiles/h5diff_600.txt b/tools/h5diff/testfiles/h5diff_600.txt index f3b346a..13d627c 100644 --- a/tools/h5diff/testfiles/h5diff_600.txt +++ b/tools/h5diff/testfiles/h5diff_600.txt @@ -142,5 +142,4 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] Use h5diff file1 file1 /g1/dset1 /g1/dset2 to compare '/g1/dset1' and '/g1/dset2' in the same file -h5diff error: missing file names EXIT CODE: 1 diff --git a/tools/h5diff/testfiles/h5diff_601_ERR.txt b/tools/h5diff/testfiles/h5diff_601_ERR.txt deleted file mode 100644 index b58124a..0000000 --- a/tools/h5diff/testfiles/h5diff_601_ERR.txt +++ /dev/null @@ -1,6 +0,0 @@ -Object </nono_obj> could not be found in <h5diff_basic1.h5> -H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5diff(): Error: Object could not be found - major: Failure in tools library - minor: error in function -EXIT CODE: 2 diff --git a/tools/h5diff/testfiles/h5diff_udfail.err b/tools/h5diff/testfiles/h5diff_udfail.err new file mode 100644 index 0000000..d51de38 --- /dev/null +++ b/tools/h5diff/testfiles/h5diff_udfail.err @@ -0,0 +1,12 @@ + +file1 file2 +--------------------------------------- + x x / + x x /dynlibud + +group : </> and </> +0 differences found +dataset: </dynlibud> and </dynlibud> +0 differences found +Warning: dataset </dynlibud> cannot be read, user defined filter is not available +EXIT CODE: 2 diff --git a/tools/h5diff/testfiles/h5diff_udfail.txt b/tools/h5diff/testfiles/h5diff_udfail.txt index d51de38..e6000fc 100644 --- a/tools/h5diff/testfiles/h5diff_udfail.txt +++ b/tools/h5diff/testfiles/h5diff_udfail.txt @@ -8,5 +8,4 @@ group : </> and </> 0 differences found dataset: </dynlibud> and </dynlibud> 0 differences found -Warning: dataset </dynlibud> cannot be read, user defined filter is not available EXIT CODE: 2 diff --git a/tools/h5diff/testh5diff.sh.in b/tools/h5diff/testh5diff.sh.in index 4563e39..7687281 100644 --- a/tools/h5diff/testh5diff.sh.in +++ b/tools/h5diff/testh5diff.sh.in @@ -7,7 +7,7 @@ # This file is part of HDF5. The full HDF5 copyright notice, including # terms governing use, modification, and redistribution, is contained in # the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# distribution tree, or in https://www.hdfgroup.org/licenses. # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. # @@ -200,6 +200,7 @@ $SRC_H5DIFF_TESTFILES/h5diff_451.txt $SRC_H5DIFF_TESTFILES/h5diff_452.txt $SRC_H5DIFF_TESTFILES/h5diff_453.txt $SRC_H5DIFF_TESTFILES/h5diff_454.txt +$SRC_H5DIFF_TESTFILES/dangling_link.err $SRC_H5DIFF_TESTFILES/h5diff_455.txt $SRC_H5DIFF_TESTFILES/h5diff_456.txt $SRC_H5DIFF_TESTFILES/h5diff_457.txt @@ -260,6 +261,7 @@ $SRC_H5DIFF_TESTFILES/h5diff_62.txt $SRC_H5DIFF_TESTFILES/h5diff_63.txt $SRC_H5DIFF_TESTFILES/h5diff_600.txt $SRC_H5DIFF_TESTFILES/h5diff_601.txt +$SRC_H5DIFF_TESTFILES/h5diff_601_ERR.err $SRC_H5DIFF_TESTFILES/h5diff_603.txt $SRC_H5DIFF_TESTFILES/h5diff_604.txt $SRC_H5DIFF_TESTFILES/h5diff_605.txt @@ -418,8 +420,9 @@ TESTING() { # TOOLTEST() { expect="$TESTDIR/$1" + expect_err="$TESTDIR/`basename $1 .txt`.err" actual="$TESTDIR/`basename $1 .txt`.out" - actual_err="$TESTDIR/`basename $1 .txt`.err" + actual_err="$TESTDIR/`basename $1 .txt`.out.err" actual_sav=${actual}-sav actual_err_sav=${actual_err}-sav shift @@ -444,7 +447,6 @@ TOOLTEST() { STDOUT_FILTER $actual cp $actual_err $actual_err_sav STDERR_FILTER $actual_err - cat $actual_err >> $actual # don't add exit code check in pmode, as it causes failure. (exit code # is from mpirun not tool) # if any problem occurs relate to an exit code, it will be caught in diff --git a/tools/h5diff/testph5diff.sh.in b/tools/h5diff/testph5diff.sh.in index b726a80..5bb6e52 100644 --- a/tools/h5diff/testph5diff.sh.in +++ b/tools/h5diff/testph5diff.sh.in @@ -7,7 +7,7 @@ # This file is part of HDF5. The full HDF5 copyright notice, including # terms governing use, modification, and redistribution, is contained in # the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# distribution tree, or in https://www.hdfgroup.org/licenses. # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. # |