diff options
Diffstat (limited to 'tools/h5repack')
42 files changed, 5542 insertions, 4870 deletions
diff --git a/tools/h5repack/CMakeLists.txt b/tools/h5repack/CMakeLists.txt index 68f4070..bc18848 100644 --- a/tools/h5repack/CMakeLists.txt +++ b/tools/h5repack/CMakeLists.txt @@ -1,16 +1,10 @@ -cmake_minimum_required (VERSION 3.10) -PROJECT (HDF5_TOOLS_H5REPACK) - -#----------------------------------------------------------------------------- -# Setup include Directories -#----------------------------------------------------------------------------- -INCLUDE_DIRECTORIES (${HDF5_TOOLS_SRC_DIR}/lib) -INCLUDE_DIRECTORIES (${HDF5_TEST_SRC_DIR}) +cmake_minimum_required (VERSION 3.12) +project (HDF5_TOOLS_H5REPACK C) # -------------------------------------------------------------------- # Add h5Repack executables # -------------------------------------------------------------------- -set (REPACK_COMMON_SRCS +set (REPACK_COMMON_SOURCES ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/h5repack_copy.c ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/h5repack_filters.c ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/h5repack_opttable.c @@ -18,85 +12,151 @@ set (REPACK_COMMON_SRCS ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/h5repack_refs.c ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/h5repack_verify.c ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/h5repack.c + ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/h5repack.h ) -add_executable (h5repack ${REPACK_COMMON_SRCS} ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/h5repack_main.c) -TARGET_C_PROPERTIES (h5repack STATIC " " " ") -target_link_libraries (h5repack ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) -set_target_properties (h5repack PROPERTIES FOLDER tools) -set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};h5repack") +if (NOT ONLY_SHARED_LIBS) + add_executable (h5repack ${REPACK_COMMON_SOURCES} ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/h5repack_main.c) + target_include_directories (h5repack PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + target_compile_options(h5repack PRIVATE "${HDF5_CMAKE_C_FLAGS}") + TARGET_C_PROPERTIES (h5repack STATIC) + target_link_libraries (h5repack PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) + set_target_properties (h5repack PROPERTIES FOLDER tools) + set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};h5repack") -set (H5_DEP_EXECUTABLES h5repack) + set (H5_DEP_EXECUTABLES h5repack) +endif () if (BUILD_SHARED_LIBS) - add_executable (h5repack-shared ${REPACK_COMMON_SRCS} ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/h5repack_main.c) - TARGET_C_PROPERTIES (h5repack-shared SHARED " " " ") - target_link_libraries (h5repack-shared ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) + add_executable (h5repack-shared ${REPACK_COMMON_SOURCES} ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/h5repack_main.c) + target_include_directories (h5repack-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + target_compile_options(h5repack-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}") + TARGET_C_PROPERTIES (h5repack-shared SHARED) + target_link_libraries (h5repack-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) set_target_properties (h5repack-shared PROPERTIES FOLDER tools) set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};h5repack-shared") set (H5_DEP_EXECUTABLES ${H5_DEP_EXECUTABLES} h5repack-shared) endif () +#----------------------------------------------------------------------------- +# Add Target to clang-format +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_FORMATTERS) + if (NOT ONLY_SHARED_LIBS) + clang_format (HDF5_H5REPACK_SRC_FORMAT h5repack) + else () + clang_format (HDF5_H5REPACK_SRC_FORMAT h5repack-shared) + endif () +endif () + +# -------------------------------------------------------------------- +# Add h5repack test executables +# -------------------------------------------------------------------- if (BUILD_TESTING) - # -------------------------------------------------------------------- - # Add h5Repack test executables - # -------------------------------------------------------------------- add_executable (testh5repack_detect_szip ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testh5repack_detect_szip.c) - TARGET_C_PROPERTIES (testh5repack_detect_szip STATIC " " " ") - target_link_libraries (testh5repack_detect_szip ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) + target_include_directories (testh5repack_detect_szip + PRIVATE "${HDF5_TOOLS_H5REPACK_SOURCE_DIR};${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>" + ) + if (NOT ONLY_SHARED_LIBS) + TARGET_C_PROPERTIES (testh5repack_detect_szip STATIC) + target_link_libraries (testh5repack_detect_szip PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) + else () + TARGET_C_PROPERTIES (testh5repack_detect_szip SHARED) + target_link_libraries (testh5repack_detect_szip PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} ${HDF5_TEST_LIBSH_TARGET}) + endif () set_target_properties (testh5repack_detect_szip PROPERTIES FOLDER tools) - add_executable (h5repacktest ${REPACK_COMMON_SRCS} ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/h5repacktst.c) - TARGET_C_PROPERTIES (h5repacktest STATIC " " " ") - target_link_libraries (h5repacktest ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) + add_executable (h5repacktest ${REPACK_COMMON_SOURCES} ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/h5repacktst.c) + target_include_directories (h5repacktest + PRIVATE "${HDF5_TOOLS_H5REPACK_SOURCE_DIR};${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>" + ) + if (NOT ONLY_SHARED_LIBS) + TARGET_C_PROPERTIES (h5repacktest STATIC) + target_link_libraries (h5repacktest PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) + else () + TARGET_C_PROPERTIES (h5repacktest SHARED) + target_link_libraries (h5repacktest PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_TEST_LIBSH_TARGET}) + endif () set_target_properties (h5repacktest PROPERTIES FOLDER tools) #----------------------------------------------------------------------------- # If plugin library tests can be tested #----------------------------------------------------------------------------- - set (HDF5_TOOL_PLUGIN_LIB_CORENAME "dynlibadd") - set (HDF5_TOOL_PLUGIN_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TOOL_PLUGIN_LIB_CORENAME}") - set (HDF5_TOOL_PLUGIN_LIB_TARGET ${HDF5_TOOL_PLUGIN_LIB_CORENAME}) - set (HDF5_TOOL_PLUGIN_LIB_VCORENAME "dynlibvers") - set (HDF5_TOOL_PLUGIN_LIB_VNAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TOOL_PLUGIN_LIB_VCORENAME}") - set (HDF5_TOOL_PLUGIN_LIB_VTARGET ${HDF5_TOOL_PLUGIN_LIB_VCORENAME}) - add_definitions (${HDF_EXTRA_C_FLAGS}) - INCLUDE_DIRECTORIES (${HDF5_SRC_DIR}) - - add_library (${HDF5_TOOL_PLUGIN_LIB_TARGET} SHARED dynlib_rpk.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") - - add_library (${HDF5_TOOL_PLUGIN_LIB_VTARGET} SHARED dynlib_vrpk.c) - TARGET_C_PROPERTIES (${HDF5_TOOL_PLUGIN_LIB_VTARGET} SHARED " " " ") - target_link_libraries (${HDF5_TOOL_PLUGIN_LIB_VTARGET} ${HDF5_TEST_LIB_TARGET}) - H5_SET_LIB_OPTIONS (${HDF5_TOOL_PLUGIN_LIB_VTARGET} ${HDF5_TOOL_PLUGIN_LIB_VNAME} 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}>" - ) - add_custom_command ( - TARGET ${HDF5_TOOL_PLUGIN_LIB_VTARGET} - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different - "$<TARGET_FILE:${HDF5_TOOL_PLUGIN_LIB_VTARGET}>" - "${CMAKE_BINARY_DIR}/plugins/$<TARGET_FILE_NAME:${HDF5_TOOL_PLUGIN_LIB_VTARGET}>" - ) + if (BUILD_SHARED_LIBS) + set (H5REPACK_TOOL_PLUGIN_LIB_CORENAME "dynlibadd") + set (H5REPACK_TOOL_PLUGIN_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${H5REPACK_TOOL_PLUGIN_LIB_CORENAME}") + set (H5REPACK_TOOL_PLUGIN_LIB_TARGET ${H5REPACK_TOOL_PLUGIN_LIB_CORENAME}) + set (H5REPACK_TOOL_PLUGIN_LIB_VCORENAME "dynlibvers") + set (H5REPACK_TOOL_PLUGIN_LIB_VNAME "${HDF5_EXTERNAL_LIB_PREFIX}${H5REPACK_TOOL_PLUGIN_LIB_VCORENAME}") + set (H5REPACK_TOOL_PLUGIN_LIB_VTARGET ${H5REPACK_TOOL_PLUGIN_LIB_VCORENAME}) + + add_library (${H5REPACK_TOOL_PLUGIN_LIB_TARGET} SHARED dynlib_rpk.c) + target_include_directories (${H5REPACK_TOOL_PLUGIN_LIB_TARGET} PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + TARGET_C_PROPERTIES (${H5REPACK_TOOL_PLUGIN_LIB_TARGET} SHARED) + target_link_libraries (${H5REPACK_TOOL_PLUGIN_LIB_TARGET} PRIVATE ${HDF5_TEST_LIBSH_TARGET}) + H5_SET_LIB_OPTIONS (${H5REPACK_TOOL_PLUGIN_LIB_TARGET} ${H5REPACK_TOOL_PLUGIN_LIB_NAME} SHARED "LIB") + + add_library (${H5REPACK_TOOL_PLUGIN_LIB_VTARGET} SHARED dynlib_vrpk.c) + target_include_directories (${H5REPACK_TOOL_PLUGIN_LIB_VTARGET} PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + TARGET_C_PROPERTIES (${H5REPACK_TOOL_PLUGIN_LIB_VTARGET} SHARED) + target_link_libraries (${H5REPACK_TOOL_PLUGIN_LIB_VTARGET} PRIVATE ${HDF5_TEST_LIBSH_TARGET}) + H5_SET_LIB_OPTIONS (${H5REPACK_TOOL_PLUGIN_LIB_VTARGET} ${H5REPACK_TOOL_PLUGIN_LIB_VNAME} SHARED "LIB") + + #----------------------------------------------------------------------------- + # Add Target to clang-format + #----------------------------------------------------------------------------- + if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_TOOLS_TEST_H5REPACK_PLUGIN_FORMAT ${H5REPACK_TOOL_PLUGIN_LIB_TARGET}) + clang_format (HDF5_TOOLS_TEST_H5REPACK_VPLUGIN_FORMAT ${H5REPACK_TOOL_PLUGIN_LIB_VTARGET}) + endif () + + # make plugins dir + file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/plugins") + #----------------------------------------------------------------------------- + # Copy plugin library to a plugins folder + #----------------------------------------------------------------------------- + add_custom_command ( + TARGET ${H5REPACK_TOOL_PLUGIN_LIB_TARGET} + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different + "$<TARGET_FILE:${H5REPACK_TOOL_PLUGIN_LIB_TARGET}>" + "${CMAKE_BINARY_DIR}/plugins/$<TARGET_FILE_NAME:${H5REPACK_TOOL_PLUGIN_LIB_TARGET}>" + ) + add_custom_command ( + TARGET ${H5REPACK_TOOL_PLUGIN_LIB_VTARGET} + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different + "$<TARGET_FILE:${H5REPACK_TOOL_PLUGIN_LIB_VTARGET}>" + "${CMAKE_BINARY_DIR}/plugins/$<TARGET_FILE_NAME:${H5REPACK_TOOL_PLUGIN_LIB_VTARGET}>" + ) + endif () - include (CMakeTests.cmake) +# -------------------------------------------------------------------- +# Add the h5repack test executable +# -------------------------------------------------------------------- + if (HDF5_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS) + add_executable (h5repackgentest ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/h5repackgentest.c) + target_include_directories (h5repackgentest PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + TARGET_C_PROPERTIES (h5repackgentest STATIC) + target_link_libraries (h5repackgentest PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) + set_target_properties (h5repackgentest PROPERTIES FOLDER generator/tools) + + #----------------------------------------------------------------------------- + # Add Target to clang-format + #----------------------------------------------------------------------------- + if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_TOOLS_TEST_H5REPACK_FORMAT h5repackgentest) + endif () + + #add_test (NAME h5repackgentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repackgentest>) + endif () + + if (HDF5_TEST_TOOLS AND HDF5_TEST_SERIAL) + include (CMakeTests.cmake) + endif () endif () diff --git a/tools/h5repack/CMakeTests.cmake b/tools/h5repack/CMakeTests.cmake index b6ec914..cdde344 100644 --- a/tools/h5repack/CMakeTests.cmake +++ b/tools/h5repack/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. # @@ -16,39 +16,6 @@ ############################################################################## ############################################################################## - if (HDF5_TEST_VFD) - set (VFD_LIST - sec2 - stdio - core - split - multi - family - ) - - if (DIRECT_VFD) - set (VFD_LIST ${VFD_LIST} direct) - endif () - - macro (ADD_VFD_TEST vfdname resultcode) - add_test ( - NAME H5REPACK-VFD-${vfdname}-h5repacktest - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5repacktest>" - -D "TEST_ARGS:STRING=" - -D "TEST_VFD:STRING=${vfdname}" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=h5repacktest" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" - -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" - ) - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5REPACK-VFD-${vfdname}-h5repacktest PROPERTIES DEPENDS ${last_test}) - endif () - set (last_test "H5REPACK-VFD-${vfdname}-h5repacktest") - endmacro () - endif () - # -------------------------------------------------------------------- # Copy all the HDF5 files from the source directory into the test directory # -------------------------------------------------------------------- @@ -58,10 +25,23 @@ ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_deflate.h5 ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_early.h5 ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_ext.h5 + ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_f32le.h5 + ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_f32le_ex-0.dat + ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_f32le_ex.h5 ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_fill.h5 ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_filters.h5 ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_fletcher.h5 ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_hlink.h5 + ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_int32le_1d.h5 + ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_int32le_1d_ex-0.dat + ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_int32le_1d_ex-1.dat + ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_int32le_1d_ex.h5 + ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_int32le_2d.h5 + ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_int32le_2d_ex-0.dat + ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_int32le_2d_ex.h5 + ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_int32le_3d.h5 + ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_int32le_3d_ex-0.dat + ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_int32le_3d_ex.h5 ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_layout.h5 ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_layouto.h5 ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_layout2.h5 @@ -74,6 +54,12 @@ ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_shuffle.h5 ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_soffset.h5 ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_szip.h5 + ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be.h5 + ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be_ex-0.dat + ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be_ex-1.dat + ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be_ex-2.dat + ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be_ex-3.dat + ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be_ex.h5 # h5diff/testfile ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/testfiles/h5diff_attr1.h5 # tools/testfiles @@ -146,27 +132,16 @@ macro (ADD_HELP_TEST testname resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5REPACK-h5repack-${testname} COMMAND $<TARGET_FILE:h5repack> ${ARGN}) - set_tests_properties (H5REPACK-h5repack-${testname} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5REPACK-h5repack-${testname} PROPERTIES DEPENDS ${last_test}) - endif () - set (last_test "H5REPACK-h5repack-${testname}") - else () - add_test ( - NAME H5REPACK-h5repack-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/h5repack-${testname}.out - testfiles/h5repack-${testname}.out.err + add_test (NAME H5REPACK-h5repack-${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repack${tgt_file_ext}> ${ARGN}) + set_tests_properties (H5REPACK-h5repack-${testname} PROPERTIES + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" ) - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5REPACK-h5repack-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () + else () add_test ( NAME H5REPACK-h5repack-${testname} COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5repack>" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" + -D "TEST_PROGRAM=$<TARGET_FILE:h5repack${tgt_file_ext}>" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" -D "TEST_OUTPUT=h5repack-${testname}.out" @@ -174,38 +149,43 @@ -D "TEST_REFERENCE=h5repack-${testname}.txt" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5REPACK-h5repack-${testname} PROPERTIES DEPENDS H5REPACK-h5repack-${testname}-clear-objects) endif () + set_tests_properties (H5REPACK-h5repack-${testname} PROPERTIES + FIXTURES_REQUIRED clear_h5repack + ) endmacro () macro (ADD_H5_TEST_OLD testname testtype testfile) - if ("${testtype}" STREQUAL "SKIP") - if (NOT HDF5_ENABLE_USING_MEMCHECKER) + if (NOT HDF5_ENABLE_USING_MEMCHECKER) + if ("${testtype}" STREQUAL "SKIP") add_test ( - NAME H5REPACK_OLD-${testname}-SKIPPED + NAME H5REPACK_OLD-${testname} COMMAND ${CMAKE_COMMAND} -E echo "SKIP ${ARGN} -i ${PROJECT_BINARY_DIR}/testfiles/${testfile} -o ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile}" ) + set_property(TEST H5REPACK_OLD-${testname} PROPERTY DISABLED) + else () + add_test ( + NAME H5REPACK_OLD-${testname}-clear-objects + COMMAND ${CMAKE_COMMAND} -E remove testfiles/out-${testname}.${testfile} + ) + set_tests_properties (H5REPACK_OLD-${testname}-clear-objects PROPERTIES + FIXTURES_REQUIRED clear_h5repack + ) + add_test ( + NAME H5REPACK_OLD-${testname} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repack${tgt_file_ext}> ${ARGN} -i ${PROJECT_BINARY_DIR}/testfiles/${testfile} -o ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} + ) + set_tests_properties (H5REPACK_OLD-${testname} PROPERTIES + DEPENDS H5REPACK_OLD-${testname}-clear-objects + ) + add_test ( + NAME H5REPACK_OLD-${testname}_DFF + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5diff${tgt_file_ext}> ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} + ) + set_tests_properties (H5REPACK_OLD-${testname}_DFF PROPERTIES + DEPENDS H5REPACK_OLD-${testname} + ) endif () - else () - add_test ( - NAME H5REPACK_OLD-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/out-${testname}.${testfile} - ) - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5REPACK_OLD-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () - add_test ( - NAME H5REPACK_OLD-${testname} - COMMAND $<TARGET_FILE:h5repack> ${ARGN} -i ${PROJECT_BINARY_DIR}/testfiles/${testfile} -o ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} - ) - set_tests_properties (H5REPACK_OLD-${testname} PROPERTIES DEPENDS H5REPACK_OLD-${testname}-clear-objects) - add_test ( - NAME H5REPACK_OLD-${testname}_DFF - COMMAND $<TARGET_FILE:h5diff> ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} - ) - set_tests_properties (H5REPACK_OLD-${testname}_DFF PROPERTIES DEPENDS H5REPACK_OLD-${testname}) endif () endmacro () @@ -213,30 +193,33 @@ if ("${testtype}" STREQUAL "SKIP") if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( - NAME H5REPACK-${testname}-SKIPPED + NAME H5REPACK-${testname} COMMAND ${CMAKE_COMMAND} -E echo "SKIP ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile}" ) + set_property(TEST H5REPACK-${testname} PROPERTY DISABLED) endif () else () add_test ( NAME H5REPACK-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/out-${testname}.${testfile} + COMMAND ${CMAKE_COMMAND} -E remove testfiles/out-${testname}.${testfile} + ) + set_tests_properties (H5REPACK-${testname}-clear-objects PROPERTIES + FIXTURES_REQUIRED clear_h5repack ) - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5REPACK-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () add_test ( NAME H5REPACK-${testname} - COMMAND $<TARGET_FILE:h5repack> --enable-error-stack ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repack${tgt_file_ext}> --enable-error-stack ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} + ) + set_tests_properties (H5REPACK-${testname} PROPERTIES + DEPENDS H5REPACK-${testname}-clear-objects ) - set_tests_properties (H5REPACK-${testname} PROPERTIES DEPENDS H5REPACK-${testname}-clear-objects) add_test ( NAME H5REPACK-${testname}_DFF - COMMAND $<TARGET_FILE:h5diff> --enable-error-stack ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5diff${tgt_file_ext}> --enable-error-stack ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} + ) + set_tests_properties (H5REPACK-${testname}_DFF PROPERTIES + DEPENDS H5REPACK-${testname} ) - set_tests_properties (H5REPACK-${testname}_DFF PROPERTIES DEPENDS H5REPACK-${testname}) endif () endmacro () @@ -244,36 +227,31 @@ if ("${testtype}" STREQUAL "SKIP") if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( - NAME H5REPACK_CMP-${testname}-SKIPPED + NAME H5REPACK_CMP-${testname} COMMAND ${CMAKE_COMMAND} -E echo "SKIP ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${resultfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${resultfile}" ) + set_property(TEST H5REPACK_CMP-${testname} PROPERTY DISABLED) endif () else () # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5REPACK_CMP-${testname} - COMMAND $<TARGET_FILE:h5repack> ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${resultfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${resultfile} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repack${tgt_file_ext}> ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${resultfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${resultfile} ) - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5REPACK_CMP-${testname} PROPERTIES DEPENDS ${last_test}) - endif () else () add_test ( NAME H5REPACK_CMP-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/out-${testname}.${resultfile} - testfiles/${resultfile}-${testname}.out - testfiles/${resultfile}-${testname}.out.err + COMMAND ${CMAKE_COMMAND} -E remove testfiles/out-${testname}.${resultfile} + ) + set_tests_properties (H5REPACK_CMP-${testname}-clear-objects PROPERTIES + FIXTURES_REQUIRED clear_h5repack ) - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5REPACK_CMP-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () add_test ( NAME H5REPACK_CMP-${testname} COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5repack>" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" + -D "TEST_PROGRAM=$<TARGET_FILE:h5repack${tgt_file_ext}>" -D "TEST_ARGS:STRING=${ARGN};${resultfile};out-${testname}.${resultfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" -D "TEST_OUTPUT=${resultfile}-${testname}.out" @@ -282,52 +260,53 @@ -D "TEST_REFERENCE=${resultfile}-${testname}.tst" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5REPACK_CMP-${testname} PROPERTIES DEPENDS H5REPACK_CMP-${testname}-clear-objects) + set_tests_properties (H5REPACK_CMP-${testname} PROPERTIES + DEPENDS H5REPACK_CMP-${testname}-clear-objects + ) endif () endif () endmacro () - macro (ADD_H5_MASK_TEST testname testtype resultcode resultfile) + macro (ADD_H5_MASK_TEST testname testtype resultcode result_errcheck resultfile) if ("${testtype}" STREQUAL "SKIP") if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( - NAME H5REPACK_MASK-${testname}-SKIPPED + NAME H5REPACK_MASK-${testname} COMMAND ${CMAKE_COMMAND} -E echo "SKIP ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${resultfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${resultfile}" ) + set_property(TEST H5REPACK_MASK-${testname} PROPERTY DISABLED) endif () else () # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5REPACK_MASK-${testname} - COMMAND $<TARGET_FILE:h5repack> ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${resultfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${resultfile} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repack${tgt_file_ext}> ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${resultfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${resultfile} + ) + set_tests_properties (H5REPACK_MASK-${testname} PROPERTIES + FIXTURES_REQUIRED clear_h5repack ) - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5REPACK_MASK-${testname} PROPERTIES DEPENDS ${last_test}) - endif () else (HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5REPACK_MASK-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/out-${testname}.${resultfile} - testfiles/${resultfile}-${testname}.out - testfiles/${resultfile}-${testname}.out.err + COMMAND ${CMAKE_COMMAND} -E remove testfiles/out-${testname}.${resultfile} + ) + set_tests_properties (H5REPACK_MASK-${testname}-clear-objects PROPERTIES DEPENDS ${last_test} + FIXTURES_REQUIRED clear_h5repack ) - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5REPACK_MASK-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () add_test ( NAME H5REPACK_MASK-${testname} COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5repack>" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" + -D "TEST_PROGRAM=$<TARGET_FILE:h5repack${tgt_file_ext}>" -D "TEST_ARGS:STRING=${ARGN};${resultfile};out-${testname}.${resultfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" -D "TEST_OUTPUT=${resultfile}-${testname}.out" -D "TEST_EXPECT=${resultcode}" - -D "TEST_MASK_ERROR=true" - -D "TEST_REFERENCE=${resultfile}-${testname}.tst" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + -D "TEST_SKIP_COMPARE=true" + -D "TEST_REFERENCE=${resultfile}.mty" + -D "TEST_ERRREF=${result_errcheck}" + -P "${HDF_RESOURCES_EXT_DIR}/grepTest.cmake" ) set_tests_properties (H5REPACK_MASK-${testname} PROPERTIES DEPENDS H5REPACK_MASK-${testname}-clear-objects) endif () @@ -338,32 +317,32 @@ if ("${testtype}" STREQUAL "SKIP") if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( - NAME H5REPACK_DMP-${testname}-SKIPPED + NAME H5REPACK_DMP-${testname} COMMAND ${CMAKE_COMMAND} -E echo "SKIP ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${resultfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${resultfile}" ) + set_property(TEST H5REPACK_DMP-${testname} PROPERTY DISABLED) endif () else () add_test ( NAME H5REPACK_DMP-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/out-${testname}.${resultfile} - testfiles/${resultfile}-${testname}.out - testfiles/${resultfile}-${testname}.out.err + COMMAND ${CMAKE_COMMAND} -E remove testfiles/out-${testname}.${resultfile} + ) + set_tests_properties (H5REPACK_DMP-${testname}-clear-objects PROPERTIES + FIXTURES_REQUIRED clear_h5repack ) - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5REPACK_DMP-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () add_test ( NAME H5REPACK_DMP-${testname} - COMMAND $<TARGET_FILE:h5repack> ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${resultfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${resultfile} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repack${tgt_file_ext}> ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${resultfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${resultfile} + ) + set_tests_properties (H5REPACK_DMP-${testname} PROPERTIES + DEPENDS H5REPACK_DMP-${testname}-clear-objects ) - set_tests_properties (H5REPACK_DMP-${testname} PROPERTIES DEPENDS H5REPACK_DMP-${testname}-clear-objects) if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5REPACK_DMP-h5dump-${testname} COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump>" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" + -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_file_ext}>" -D "TEST_ARGS:STRING=-q;creation_order;-pH;out-${testname}.${resultfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" -D "TEST_OUTPUT=${resultfile}-${testname}.out" @@ -371,7 +350,9 @@ -D "TEST_REFERENCE=${testname}.${resultfile}.ddl" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5REPACK_DMP-h5dump-${testname} PROPERTIES DEPENDS "H5REPACK_DMP-${testname}") + set_tests_properties (H5REPACK_DMP-h5dump-${testname} PROPERTIES + DEPENDS "H5REPACK_DMP-${testname}" + ) endif () endif () endmacro () @@ -380,32 +361,32 @@ if ("${testtype}" STREQUAL "SKIP") if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( - NAME H5REPACK_STAT-${testname}-SKIPPED + NAME H5REPACK_STAT-${testname} COMMAND ${CMAKE_COMMAND} -E echo "SKIP ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${resultfile} ${PROJECT_BINARY_DIR}/testfiles/out-${statarg}.${resultfile}" ) + set_property(TEST H5REPACK_STAT-${testname} PROPERTY DISABLED) endif () else () add_test ( NAME H5REPACK_STAT-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/out-${statarg}.${resultfile} - testfiles/${resultfile}-${testname}.out - testfiles/${resultfile}-${testname}.out.err + COMMAND ${CMAKE_COMMAND} -E remove testfiles/out-${statarg}.${resultfile} + ) + set_tests_properties (H5REPACK_STAT-${testname}-clear-objects PROPERTIES + FIXTURES_REQUIRED clear_h5repack ) - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5REPACK_STAT-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () add_test ( NAME H5REPACK_STAT-${testname} - COMMAND $<TARGET_FILE:h5repack> ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${resultfile} ${PROJECT_BINARY_DIR}/testfiles/out-${statarg}.${resultfile} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repack${tgt_file_ext}> ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${resultfile} ${PROJECT_BINARY_DIR}/testfiles/out-${statarg}.${resultfile} + ) + set_tests_properties (H5REPACK_STAT-${testname} PROPERTIES + DEPENDS H5REPACK_STAT-${testname}-clear-objects ) - set_tests_properties (H5REPACK_STAT-${testname} PROPERTIES DEPENDS H5REPACK_STAT-${testname}-clear-objects) if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5REPACK_STAT-h5stat-${testname} COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5stat>" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" + -D "TEST_PROGRAM=$<TARGET_FILE:h5stat${tgt_file_ext}>" -D "TEST_ARGS:STRING=-S;-s;out-${statarg}.${resultfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" -D "TEST_OUTPUT=${resultfile}-${testname}.out" @@ -413,7 +394,9 @@ -D "TEST_REFERENCE=${statarg}.${resultfile}.ddl" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5REPACK_STAT-h5stat-${testname} PROPERTIES DEPENDS "H5REPACK_STAT-${testname}") + set_tests_properties (H5REPACK_STAT-h5stat-${testname} PROPERTIES + DEPENDS "H5REPACK_STAT-${testname}" + ) endif () endif () endmacro () @@ -422,38 +405,40 @@ if ("${testtype}" STREQUAL "SKIP") if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( - NAME H5REPACK_VERIFY_LAYOUT-${testname}-SKIPPED + NAME H5REPACK_VERIFY_LAYOUT-${testname} COMMAND ${CMAKE_COMMAND} -E echo "SKIP -d ${testdset} -pH ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${resultfile}" ) + set_property(TEST H5REPACK_VERIFY_LAYOUT-${testname} PROPERTY DISABLED) endif () else () if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5REPACK_VERIFY_LAYOUT-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/out-${testname}.${testfile} - testfiles/${testfile}-${testname}-v.out - testfiles/${testfile}-${testname}-v.out.err + COMMAND ${CMAKE_COMMAND} -E remove testfiles/out-${testname}.${testfile} + ) + set_tests_properties (H5REPACK_VERIFY_LAYOUT-${testname}-clear-objects PROPERTIES + FIXTURES_REQUIRED clear_h5repack ) - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5REPACK_VERIFY_LAYOUT-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () add_test ( NAME H5REPACK_VERIFY_LAYOUT-${testname} - COMMAND $<TARGET_FILE:h5repack> ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repack${tgt_file_ext}> ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} + ) + set_tests_properties (H5REPACK_VERIFY_LAYOUT-${testname} PROPERTIES + DEPENDS H5REPACK_VERIFY_LAYOUT-${testname}-clear-objects ) - set_tests_properties (H5REPACK_VERIFY_LAYOUT-${testname} PROPERTIES DEPENDS H5REPACK_VERIFY_LAYOUT-${testname}-clear-objects) add_test ( NAME H5REPACK_VERIFY_LAYOUT-${testname}_DFF - COMMAND $<TARGET_FILE:h5diff> ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5diff${tgt_file_ext}> ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} ) - set_tests_properties (H5REPACK_VERIFY_LAYOUT-${testname}_DFF PROPERTIES DEPENDS H5REPACK_VERIFY_LAYOUT-${testname}) - if ("${resultcode}" STREQUAL "0") + set_tests_properties (H5REPACK_VERIFY_LAYOUT-${testname}_DFF PROPERTIES + DEPENDS H5REPACK_VERIFY_LAYOUT-${testname} + ) + if (NOT ${resultcode}) add_test ( NAME H5REPACK_VERIFY_LAYOUT-${testname}_DMP COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump>" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" + -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_file_ext}>" -D "TEST_ARGS:STRING=-d;${testdset};-pH;out-${testname}.${testfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" -D "TEST_OUTPUT=${testfile}-${testname}-v.out" @@ -462,7 +447,9 @@ -D "TEST_REFERENCE=${testfilter}" -P "${HDF_RESOURCES_EXT_DIR}/grepTest.cmake" ) - set_tests_properties (H5REPACK_VERIFY_LAYOUT-${testname}_DMP PROPERTIES DEPENDS H5REPACK_VERIFY_LAYOUT-${testname}_DFF) + set_tests_properties (H5REPACK_VERIFY_LAYOUT-${testname}_DMP PROPERTIES + DEPENDS H5REPACK_VERIFY_LAYOUT-${testname}_DFF + ) else () if ("${testfilter}" STREQUAL "CHUNKED") set (nottestfilter "(CONTIGUOUS|COMPACT)") @@ -476,7 +463,8 @@ add_test ( NAME H5REPACK_VERIFY_LAYOUT-${testname}_DMP COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump>" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" + -D "TEST_PROGRAM=$<TARGET_FILE:h5dump${tgt_file_ext}>" -D "TEST_ARGS:STRING=-pH;out-${testname}.${testfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" -D "TEST_OUTPUT=${testfile}-${testname}-v.out" @@ -485,7 +473,9 @@ -D "TEST_REFERENCE=${testfilter}" -P "${HDF_RESOURCES_EXT_DIR}/grepTest.cmake" ) - set_tests_properties (H5REPACK_VERIFY_LAYOUT-${testname}_DMP PROPERTIES DEPENDS H5REPACK_VERIFY_LAYOUT-${testname}_DFF) + set_tests_properties (H5REPACK_VERIFY_LAYOUT-${testname}_DMP PROPERTIES + DEPENDS H5REPACK_VERIFY_LAYOUT-${testname}_DFF + ) endif () endif () endif () @@ -494,29 +484,78 @@ macro (ADD_H5_TEST_META testname testfile) # Remove any output file left over from previous test run add_test ( - NAME H5REPACK_META-${testname}_N-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove + NAME H5REPACK_META-${testname}-clear-objects + COMMAND ${CMAKE_COMMAND} -E remove testfiles/out-${testname}_N.${testname}.h5 + testfiles/out-${testname}_N.${testname}.out + testfiles/out-${testname}_N.${testname}.out.err testfiles/out-${testname}_M.${testname}.h5 + testfiles/out-${testname}_M.${testname}.out + testfiles/out-${testname}_M.${testname}.out.err + ) + set_tests_properties (H5REPACK_META-${testname}-clear-objects PROPERTIES + FIXTURES_REQUIRED clear_h5repack ) - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5REPACK_META-${testname}_N-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () add_test ( NAME H5REPACK_META-${testname}_N - COMMAND $<TARGET_FILE:h5repack> ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}_N.${testname}.h5 + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repack${tgt_file_ext}> ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}_N.${testname}.h5 + ) + set_tests_properties (H5REPACK_META-${testname}_N PROPERTIES + DEPENDS H5REPACK_META-${testname}-clear-objects + ) + add_test ( + NAME H5REPACK_META-${testname}_N_DFF + COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" + -D "TEST_PROGRAM=$<TARGET_FILE:h5diff${tgt_file_ext}>" + -D "TEST_ARGS:STRING=${testfile};out-${testname}_N.${testname}.h5" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" + -D "TEST_OUTPUT=out-${testname}_N.${testname}.out" + -D "TEST_EXPECT=0" + -D "TEST_REFERENCE=out-${testname}_N.${testname}.txt" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + set_tests_properties (H5REPACK_META-${testname}_N_DFF PROPERTIES + DEPENDS H5REPACK_META-${testname}_N ) - set_tests_properties (H5REPACK_META-${testname}_N PROPERTIES DEPENDS H5REPACK_META-${testname}_N-clear-objects) add_test ( NAME H5REPACK_META-${testname}_M - COMMAND $<TARGET_FILE:h5repack> ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}_M.${testname}.h5 + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repack${tgt_file_ext}> ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}_M.${testname}.h5 + ) + set_tests_properties (H5REPACK_META-${testname}_M PROPERTIES + DEPENDS H5REPACK_META-${testname}_N_DFF + ) + add_test ( + NAME H5REPACK_META-${testname}_M_DFF + COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" + -D "TEST_PROGRAM=$<TARGET_FILE:h5diff${tgt_file_ext}>" + -D "TEST_ARGS:STRING=${testfile};out-${testname}_M.${testname}.h5" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" + -D "TEST_OUTPUT=out-${testname}_M.${testname}.out" + -D "TEST_EXPECT=0" + -D "TEST_REFERENCE=out-${testname}_M.${testname}.txt" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + set_tests_properties (H5REPACK_META-${testname}_M_DFF PROPERTIES + DEPENDS H5REPACK_META-${testname}_M + ) + add_test (NAME H5REPACK_META-${testname} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" + -D "TEST_ONEFILE=out-${testname}_N.${testname}.out" + -D "TEST_TWOFILE=out-${testname}_M.${testname}.h5" + -D "TEST_FUNCTION=LTEQ" + -P "${HDF_RESOURCES_DIR}/fileCompareTest.cmake" + ) + if (CMAKE_VERSION VERSION_LESS "3.14.0") + set_tests_properties (H5REPACK_META-${testname} PROPERTIES + DISABLED "true" + ) + endif () + set_tests_properties (H5REPACK_META-${testname} PROPERTIES + DEPENDS H5REPACK_META-${testname}_M_DFF ) - set_tests_properties (H5REPACK_META-${testname}_M PROPERTIES DEPENDS H5REPACK_META-${testname}_N) - - add_test (NAME H5REPACK_META-${testname} COMMAND ${CMAKE_COMMAND} -E compare_files ${PROJECT_BINARY_DIR}/testfiles/out-${testname}_N.${testname}.h5 ${PROJECT_BINARY_DIR}/testfiles/out-${testname}_M.${testname}.h5) - set_tests_properties (H5REPACK_META-${testname} PROPERTIES WILL_FAIL "true") - set_tests_properties (H5REPACK_META-${testname} PROPERTIES DEPENDS H5REPACK_META-${testname}_M) endmacro () macro (ADD_H5_UD_TEST testname resultcode resultfile) @@ -524,21 +563,16 @@ # Remove any output file left over from previous test run add_test ( NAME H5REPACK_UD-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/out-${testname}.${resultfile} - testfiles/${testname}.${resultfile}.out - testfiles/${testname}.${resultfile}.out.err - testfiles/${resultfile}-${testname}.out - testfiles/${resultfile}-${testname}.out.err + COMMAND ${CMAKE_COMMAND} -E remove testfiles/out-${testname}.${resultfile} + ) + set_tests_properties (H5REPACK_UD-${testname}-clear-objects PROPERTIES + FIXTURES_REQUIRED clear_h5repack ) - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5REPACK_UD-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () add_test ( NAME H5REPACK_UD-${testname} COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5repack>" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" + -D "TEST_PROGRAM=$<TARGET_FILE:h5repack-shared>" -D "TEST_ARGS:STRING=${ARGN};${resultfile};out-${testname}.${resultfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" -D "TEST_EXPECT=${resultcode}" @@ -547,13 +581,17 @@ -D "TEST_REFERENCE=${testname}.${resultfile}.tst" -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" ) - set_tests_properties (H5REPACK_UD-${testname} PROPERTIES DEPENDS H5REPACK_UD-${testname}-clear-objects) + set_tests_properties (H5REPACK_UD-${testname} PROPERTIES + DEPENDS H5REPACK_UD-${testname}-clear-objects + ) add_test ( NAME H5REPACK_UD-${testname}-h5dump COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump>" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" + -D "TEST_PROGRAM=$<TARGET_FILE:h5dump-shared>" -D "TEST_ARGS:STRING=-pH;out-${testname}.${resultfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" -D "TEST_OUTPUT=${resultfile}-${testname}.out" @@ -561,9 +599,110 @@ -D "TEST_REFERENCE=${resultfile}-${testname}.ddl" -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" ) - set_tests_properties (H5REPACK_UD-${testname}-h5dump PROPERTIES DEPENDS "H5REPACK_UD-${testname}") + set_tests_properties (H5REPACK_UD-${testname}-h5dump PROPERTIES + DEPENDS "H5REPACK_UD-${testname}" + ) + endif () + endmacro () + + macro (ADD_H5_EXTERNAL_TEST testname testtype testfile) + if (NOT HDF5_ENABLE_USING_MEMCHECKER) + # canonical file = h5repack_${testfile}.h5 - preexist + # external file = h5repack_${testfile}_ex.h5 - preexist + # repacked file = h5repack_${testfile}_rp.h5 - created + # external data file = h5repack_${testfile}_ex-0.dat + if ("${testtype}" STREQUAL "SKIP") + add_test ( + NAME H5REPACK_EXTERNAL-${testname} + COMMAND ${CMAKE_COMMAND} -E echo "SKIP ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile}" + ) + set_property(TEST H5REPACK_EXTERNAL-${testname} PROPERTY DISABLED) + else () + add_test ( + NAME H5REPACK_EXTERNAL-${testname}-clear-objects + COMMAND ${CMAKE_COMMAND} -E remove h5repack_${testfile}_rp.h5 + ) + set_tests_properties (H5REPACK_EXTERNAL-${testname}-clear-objects PROPERTIES + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" + FIXTURES_REQUIRED clear_h5repack + ) + # make sure external data file 0 is available + add_test ( + NAME H5REPACK_EXTERNAL-${testname}_CPY + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${PROJECT_SOURCE_DIR}/testfiles/h5repack_${testfile}_ex-0.dat" "${PROJECT_BINARY_DIR}/testfiles/h5repack_${testfile}_ex-0.dat" + ) + set_tests_properties (H5REPACK_EXTERNAL-${testname}_CPY PROPERTIES + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" + DEPENDS H5REPACK_EXTERNAL-${testname}-clear-objects + ) + # comparison of known files + add_test ( + NAME H5REPACK_EXTERNAL-${testname}_DFF1 + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5diff${tgt_file_ext}> --enable-error-stack ${PROJECT_BINARY_DIR}/testfiles/h5repack_${testfile}.h5 ${PROJECT_BINARY_DIR}/testfiles/h5repack_${testfile}_ex.h5 + ) + set_tests_properties (H5REPACK_EXTERNAL-${testname}_DFF1 PROPERTIES + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" + DEPENDS H5REPACK_EXTERNAL-${testname}_CPY + ) + # repack the external file to the repacked file + add_test ( + NAME H5REPACK_EXTERNAL-${testname} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repack${tgt_file_ext}> --enable-error-stack ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/h5repack_${testfile}_ex.h5 ${PROJECT_BINARY_DIR}/testfiles/h5repack_${testfile}_rp.h5 + ) + set_tests_properties (H5REPACK_EXTERNAL-${testname} PROPERTIES + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" + DEPENDS H5REPACK_EXTERNAL-${testname}_DFF1 + ) + # comparison of repacked file to known files + add_test ( + NAME H5REPACK_EXTERNAL-${testname}_DFF2 + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5diff${tgt_file_ext}> --enable-error-stack ${PROJECT_BINARY_DIR}/testfiles/h5repack_${testfile}_rp.h5 ${PROJECT_BINARY_DIR}/testfiles/h5repack_${testfile}.h5 + ) + set_tests_properties (H5REPACK_EXTERNAL-${testname}_DFF2 PROPERTIES + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" + DEPENDS H5REPACK_EXTERNAL-${testname} + ) + add_test ( + NAME H5REPACK_EXTERNAL-${testname}_DFF3 + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5diff${tgt_file_ext}> --enable-error-stack ${PROJECT_BINARY_DIR}/testfiles/h5repack_${testfile}_rp.h5 ${PROJECT_BINARY_DIR}/testfiles/h5repack_${testfile}_ex.h5 + ) + set_tests_properties (H5REPACK_EXTERNAL-${testname}_DFF3 PROPERTIES + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" + DEPENDS H5REPACK_EXTERNAL-${testname}_DFF2 + ) + # invalidate external file by removing its first data file + add_test ( + NAME H5REPACK_EXTERNAL-${testname}_DATA_RMV + COMMAND ${CMAKE_COMMAND} -E remove h5repack_${testfile}_ex-0.dat + ) + set_tests_properties (H5REPACK_EXTERNAL-${testname}_DATA_RMV PROPERTIES + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" + DEPENDS H5REPACK_EXTERNAL-${testname}_DFF3 + ) + # verify comparison of repacked file to known file + add_test ( + NAME H5REPACK_EXTERNAL-${testname}_DFF4 + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5diff${tgt_file_ext}> --enable-error-stack ${PROJECT_BINARY_DIR}/testfiles/h5repack_${testfile}_rp.h5 ${PROJECT_BINARY_DIR}/testfiles/h5repack_${testfile}.h5 + ) + set_tests_properties (H5REPACK_EXTERNAL-${testname}_DFF4 PROPERTIES + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" + DEPENDS H5REPACK_EXTERNAL-${testname}_DATA_RMV + ) + # verify comparison of repacked file to known external file fails + add_test ( + NAME H5REPACK_EXTERNAL-${testname}_DFF_FAIL + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5diff${tgt_file_ext}> --enable-error-stack ${PROJECT_BINARY_DIR}/testfiles/h5repack_${testfile}_rp.h5 ${PROJECT_BINARY_DIR}/testfiles/h5repack_${testfile}_ex.h5 + ) + set_tests_properties (H5REPACK_EXTERNAL-${testname}_DFF_FAIL PROPERTIES + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" + DEPENDS H5REPACK_EXTERNAL-${testname}_DFF4 + WILL_FAIL "true" + ) + endif () endif () endmacro () @@ -595,73 +734,13 @@ set (FILE15 h5repack_named_dtypes.h5) set (FILE16 tfamily%05d.h5) # located in common testfiles folder set (FILE18 h5repack_layout2.h5) + set (FILE19 h5repack_layout3.h5) set (FILE_REF h5repack_refs.h5) set (FILE_ATTR_REF h5repack_attr_refs.h5) if (HDF5_ENABLE_USING_MEMCHECKER) # Remove any output file left over from previous test run set (LIST_TO_CLEAR - h5dump-help.out - h5repack_layout.h5-chunk_18x13-v.out - h5repack_layout.h5-chunk_18x13-v.out.err - h5repack_layout.h5-chunk_20x10-v.out - h5repack_layout.h5-chunk_20x10-v.out.err - h5repack_layout.h5-chunk_compa-v.out - h5repack_layout.h5-chunk_compa-v.out.err - h5repack_layout.h5-chunk_conti-v.out - h5repack_layout.h5-chunk_conti-v.out.err - h5repack_layout.h5-compa-v.out - h5repack_layout.h5-compa-v.out.err - h5repack_layout.h5-conti-v.out - h5repack_layout.h5-conti-v.out.err - h5repack_layout.h5-deflate_limit.out - h5repack_layout.h5-deflate_limit.out.err - h5repack_layout.h5-dset2_chunk_20x10-v.out - h5repack_layout.h5-dset2_chunk_20x10-v.out.err - h5repack_layout.h5-dset2_chunk_20x10-errstk.out - h5repack_layout.h5-dset2_chunk_20x10-errstk.out.err - h5repack_layout.h5-dset2_compa-v.out - h5repack_layout.h5-dset2_compa-v.out.err - h5repack_layout.h5-dset2_conti-v.out - h5repack_layout.h5-dset2_conti-v.out.err - h5repack_layout.h5-dset_compa_chunk-v.out - h5repack_layout.h5-dset_compa_chunk-v.out.err - h5repack_layout.h5-dset_compa_compa-v.out - h5repack_layout.h5-dset_compa_compa-v.out.err - h5repack_layout.h5-dset_compa_conti-v.out - h5repack_layout.h5-dset_compa_conti-v.out.err - h5repack_layout.h5-dset_conti_chunk-v.out - h5repack_layout.h5-dset_conti_chunk-v.out.err - h5repack_layout.h5-dset_conti_compa-v.out - h5repack_layout.h5-dset_conti_compa-v.out.err - h5repack_layout.h5-dset_conti_conti-v.out - h5repack_layout.h5-dset_conti_conti-v.out.err - h5repack_layout.h5-layout_long_switches-v.out - h5repack_layout.h5-layout_long_switches-v.out.err - h5repack_layout.h5-layout_short_switches-v.out - h5repack_layout.h5-layout_short_switches-v.out.err - h5repack_layout.h5-plugin_test.out - h5repack_layout.h5-plugin_test.out.err - h5repack_layout2.h5-contig_small_compa-v.out - h5repack_layout2.h5-contig_small_compa-v.out.err - h5repack_layout2.h5-contig_small_fixed_compa-v.out - h5repack_layout2.h5-contig_small_fixed_compa-v.out.err - h5repack_layout3.h5-ckdim_biger-v.out - h5repack_layout3.h5-ckdim_biger-v.out.err - h5repack_layout3.h5-ckdim_smaller-v.out - h5repack_layout3.h5-ckdim_smaller-v.out.err - h5repack_layout3.h5-chunk2chunk-v.out - h5repack_layout3.h5-chunk2chunk-v.out.err - h5repack_layout3.h5-chunk2compa-v.out - h5repack_layout3.h5-chunk2compa-v.out.err - h5repack_layout3.h5-chunk2conti-v.out - h5repack_layout3.h5-chunk2conti-v.out.err - h5repack_layout3.h5-error1-v.out - h5repack_layout3.h5-error1-v.out.err - h5repack_layout3.h5-error2-v.out - h5repack_layout3.h5-error2-v.out.err - h5repack_layout3.h5-error3-v.out - h5repack_layout3.h5-error3-v.out.err out-family.tfamily%05d.h5 out-HDFFV-7840.h5diff_attr1.h5 out-attr.h5repack_attr.h5 @@ -765,15 +844,15 @@ NAME H5REPACK-clearall-objects COMMAND ${CMAKE_COMMAND} -E remove ${LIST_TO_CLEAR} ) - set_tests_properties (H5REPACK-clearall-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5REPACK-clearall-objects PROPERTIES DEPENDS ${last_test}) - endif () + set_tests_properties (H5REPACK-clearall-objects PROPERTIES + FIXTURES_SETUP clear_h5repack + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles" + ) endif () ADD_HELP_TEST(help 0 -h) - add_test (NAME H5REPACK-testh5repack_detect_szip COMMAND $<TARGET_FILE:testh5repack_detect_szip>) + add_test (NAME H5REPACK-testh5repack_detect_szip COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:testh5repack_detect_szip>) if (HDF5_ENABLE_SZIP_SUPPORT) if (HDF5_ENABLE_SZIP_ENCODING) set (passRegex "yes") @@ -787,11 +866,11 @@ set_tests_properties (H5REPACK-testh5repack_detect_szip PROPERTIES PASS_REGULAR_EXPRESSION "no") endif () set_tests_properties (H5REPACK-testh5repack_detect_szip PROPERTIES DEPENDS H5REPACK-clearall-objects) + set (last_test "H5REPACK-testh5repack_detect_szip") - add_test (NAME H5REPACK-h5repacktest COMMAND $<TARGET_FILE:h5repacktest>) - set_tests_properties (H5REPACK-h5repacktest PROPERTIES DEPENDS H5REPACK-testh5repack_detect_szip) - set (last_test "H5REPACK-h5repacktest") - +# add_test (NAME H5REPACK-h5repacktest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repacktest>) +# set_tests_properties (H5REPACK-h5repacktest PROPERTIES DEPENDS H5REPACK-testh5repack_detect_szip) +# set (last_test "H5REPACK-h5repacktest") # # The tests # We use the files generated by h5repacktst @@ -1038,7 +1117,7 @@ ADD_H5_VERIFY_TEST (conti "TEST" 1 ${FILE4} null CONTIGUOUS -l CONTI) ADD_H5_VERIFY_TEST (dset2_compa "TEST" 0 ${FILE4} dset2 COMPACT -l dset2:COMPA) ADD_H5_VERIFY_TEST (compa "TEST" 1 ${FILE4} null COMPACT -l COMPA) - ADD_H5_MASK_TEST (dset2_chunk_20x10-errstk "TEST" 0 ${FILE4} --layout=dset2:CHUNK=20x10x5 --enable-error-stack) + ADD_H5_MASK_TEST (dset2_chunk_20x10-errstk "TEST" 0 "dimensionality of chunks doesn't match the dataspace" ${FILE4} --layout=dset2:CHUNK=20x10x5 --enable-error-stack) ################################################################ # layout conversions (file has no filters) @@ -1063,14 +1142,14 @@ # Use first dset to test. #--------------------------------------------------------------------------- # chunk to chunk - specify chunk dim bigger than any current dim - ADD_H5_VERIFY_TEST (chunk2chunk "TEST" 0 h5repack_layout3.h5 chunk_unlimit1 CHUNK -l chunk_unlimit1:CHUNK=100x300) + ADD_H5_VERIFY_TEST (chunk2chunk "TEST" 0 ${FILE19} chunk_unlimit1 CHUNK -l chunk_unlimit1:CHUNK=100x300) # chunk to contiguous - ADD_H5_VERIFY_TEST (chunk2conti "TEST" 0 h5repack_layout3.h5 chunk_unlimit1 CONTI -l chunk_unlimit1:CONTI) + ADD_H5_VERIFY_TEST (chunk2conti "TEST" 0 ${FILE19} chunk_unlimit1 CONTI -l chunk_unlimit1:CONTI) # chunk to compact - convert big dataset (should be > 64k) for this purpose, # should remain as original layout (chunk) - ADD_H5_VERIFY_TEST (chunk2compa "TEST" 0 h5repack_layout3.h5 chunk_unlimit1 CHUNK -l chunk_unlimit1:COMPA) + ADD_H5_VERIFY_TEST (chunk2compa "TEST" 0 ${FILE19} chunk_unlimit1 CHUNK -l chunk_unlimit1:COMPA) #-------------------------------------------------------------------------- # Test -f for some specific cases. Chunked dataset with unlimited max dims. @@ -1080,16 +1159,16 @@ # - should not change max dims from unlimit # chunk dim is bigger than dataset dim. ( dset size < 64k ) - ADD_H5_VERIFY_TEST (error1 "TEST" 0 h5repack_layout3.h5 chunk_unlimit1 H5S_UNLIMITED -f chunk_unlimit1:NONE) + ADD_H5_VERIFY_TEST (error1 "TEST" 0 ${FILE19} chunk_unlimit1 H5S_UNLIMITED -f chunk_unlimit1:NONE) # chunk dim is bigger than dataset dim. ( dset size > 64k ) - ADD_H5_VERIFY_TEST (error2 "TEST" 0 h5repack_layout3.h5 chunk_unlimit2 H5S_UNLIMITED -f chunk_unlimit2:NONE) + ADD_H5_VERIFY_TEST (error2 "TEST" 0 ${FILE19} chunk_unlimit2 H5S_UNLIMITED -f chunk_unlimit2:NONE) # chunk dims are smaller than dataset dims. ( dset size < 64k ) - ADD_H5_VERIFY_TEST (error3 "TEST" 0 h5repack_layout3.h5 chunk_unlimit3 H5S_UNLIMITED -f chunk_unlimit3:NONE) + ADD_H5_VERIFY_TEST (error3 "TEST" 0 ${FILE19} chunk_unlimit3 H5S_UNLIMITED -f chunk_unlimit3:NONE) # file input - should not fail - ADD_H5_TEST (error4 "TEST" h5repack_layout3.h5 -f NONE) + ADD_H5_TEST (error4 "TEST" ${FILE19} -f NONE) #-------------------------------------------------------------------------- # Test base: Convert CHUNK to CONTI for a chunked dataset with small dataset @@ -1097,9 +1176,9 @@ # (HDFFV-8214) #-------------------------------------------------------------------------- # chunk dim is bigger than dataset dim. should succeed. - ADD_H5_VERIFY_TEST (ckdim_biger "TEST" 0 h5repack_layout3.h5 chunk_unlimit2 CONTI -l chunk_unlimit2:CONTI) + ADD_H5_VERIFY_TEST (ckdim_biger "TEST" 0 ${FILE19} chunk_unlimit2 CONTI -l chunk_unlimit2:CONTI) # chunk dim is smaller than dataset dim. should succeed. - ADD_H5_VERIFY_TEST (ckdim_smaller "TEST" 0 h5repack_layout3.h5 chunk_unlimit3 CONTI -l chunk_unlimit3:CONTI) + ADD_H5_VERIFY_TEST (ckdim_smaller "TEST" 0 ${FILE19} chunk_unlimit3 CONTI -l chunk_unlimit3:CONTI) @@ -1185,17 +1264,31 @@ ADD_H5_TEST_META (meta_long h5repack_layout.h5 --metadata_block_size=8192) ############################################################################## +### E X T E R N A L S T O R A G E T E S T S +############################################################################## +ADD_H5_EXTERNAL_TEST (ext_f32le "TEST" f32le -l CONTI) +ADD_H5_EXTERNAL_TEST (ext_int32le_1d "TEST" int32le_1d -l CONTI) +ADD_H5_EXTERNAL_TEST (ext_int32le_2d "TEST" int32le_2d -l CONTI) +ADD_H5_EXTERNAL_TEST (ext_int32le_3d "TEST" int32le_3d -l CONTI) +ADD_H5_EXTERNAL_TEST (ext_uint8be "TEST" uint8be -l CONTI) + +############################################################################## ### P L U G I N T E S T S ############################################################################## +if (BUILD_SHARED_LIBS) ADD_H5_UD_TEST (plugin_version_test 0 h5repack_layout.h5 -v -f UD=260,0,4,9,${H5_VERS_MAJOR},${H5_VERS_MINOR},${H5_VERS_RELEASE}) ADD_H5_UD_TEST (plugin_test 0 h5repack_layout.h5 -v -f UD=257,0,1,9) ADD_H5_UD_TEST (plugin_none 0 h5repack_layout.UD.h5 -v -f NONE) # check for no parameters ADD_H5_UD_TEST (plugin_zero 0 h5repack_layout.h5 -v -f UD=250,0,0) +endif () - if (HDF5_TEST_VFD) - # Run test with different Virtual File Driver - foreach (vfd ${VFD_LIST}) - ADD_VFD_TEST (${vfd} 0) - endforeach () - endif () +############################################################################## +############################################################################## +### V F D T E S T S ### +############################################################################## +############################################################################## + +if (HDF5_TEST_VFD) + include (CMakeVFDTests.cmake) +endif () diff --git a/tools/h5repack/CMakeVFDTests.cmake b/tools/h5repack/CMakeVFDTests.cmake new file mode 100644 index 0000000..27bc199 --- /dev/null +++ b/tools/h5repack/CMakeVFDTests.cmake @@ -0,0 +1,103 @@ +# +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://www.hdfgroup.org/licenses. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# + +############################################################################## +############################################################################## +### T E S T I N G ### +############################################################################## +############################################################################## + +set (VFD_LIST + sec2 + stdio + core + split + multi + family +) + +if (DIRECT_VFD) + set (VFD_LIST ${VFD_LIST} direct) +endif () + +############################################################################## +############################################################################## +### T H E T E S T S M A C R O S ### +############################################################################## +############################################################################## + +macro (ADD_VFD_TEST vfdname resultcode) + if (NOT HDF5_ENABLE_USING_MEMCHECKER) + file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${vfdname}") + add_test ( + NAME H5REPACK-${vfdname}-h5repacktest-clear-objects + COMMAND ${CMAKE_COMMAND} -E remove + bounds_latest_latest.h5 + h5repack_attr.h5 + h5repack_attr_refs.h5 + h5repack_deflate.h5 + h5repack_early.h5 + h5repack_ext.h5 + h5repack_fill.h5 + h5repack_filters.h5 + h5repack_fletcher.h5 + h5repack_hlink.h5 + h5repack_layout.h5 + h5repack_layouto.h5 + h5repack_layout2.h5 + h5repack_layout3.h5 + h5repack_layout.UD.h5 + h5repack_named_dtypes.h5 + h5repack_nested_8bit_enum.h5 + h5repack_nested_8bit_enum_deflated.h5 + h5repack_nbit.h5 + h5repack_objs.h5 + h5repack_refs.h5 + h5repack_shuffle.h5 + h5repack_soffset.h5 + h5repack_szip.h5 + # fsm + h5repack_aggr.h5 + h5repack_fsm_aggr_nopersist.h5 + h5repack_fsm_aggr_persist.h5 + h5repack_none.h5 + h5repack_paged_nopersist.h5 + h5repack_paged_persist.h5 + WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/${vfdname} + ) + add_test ( + NAME H5REPACK_VFD-${vfdname}-h5repacktest + COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" + -D "TEST_PROGRAM=$<TARGET_FILE:h5repacktest>" + -D "TEST_ARGS:STRING=" + -D "TEST_VFD:STRING=${vfdname}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=${vfdname}-h5repacktest.out" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${vfdname}" + -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" + ) + set_tests_properties (H5REPACK_VFD-${vfdname}-h5repacktest PROPERTIES DEPENDS H5REPACK_VFD-${vfdname}-h5repacktest-clear-objects) + set_tests_properties (H5REPACK_VFD-${vfdname}-h5repacktest PROPERTIES TIMEOUT ${CTEST_SHORT_TIMEOUT}) + endif () +endmacro () + +############################################################################## +############################################################################## +### T H E T E S T S ### +############################################################################## +############################################################################## + +# Run test with different Virtual File Driver +foreach (vfd ${VFD_LIST}) + ADD_VFD_TEST (${vfd} 0) +endforeach () diff --git a/tools/h5repack/Makefile.am b/tools/h5repack/Makefile.am index 469ae13..59e2f0e 100644 --- a/tools/h5repack/Makefile.am +++ b/tools/h5repack/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. ## @@ -19,19 +19,24 @@ include $(top_srcdir)/config/commence.am # Include src, test, and tools/lib directories -AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/test -I$(top_srcdir)/tools/lib +AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/test -I$(top_srcdir)/tools/lib -I$(top_srcdir)/tools/h5repack # Test programs and scripts +if BUILD_TESTS_CONDITIONAL TEST_SCRIPT=h5repack.sh -TEST_PROG=h5repacktst +TEST_PROG=h5repacktst h5repackgentest noinst_PROGRAMS=testh5repack_detect_szip - -SCRIPT_DEPEND=h5repack$(EXEEXT) if HAVE_SHARED_CONDITIONAL if USE_PLUGINS_CONDITIONAL TEST_SCRIPT += h5repack_plugin.sh endif endif +else +TEST_SCRIPT= +TEST_PROG= +endif + +SCRIPT_DEPEND=h5repack$(EXEEXT) check_SCRIPTS=$(TEST_SCRIPT) check_PROGRAMS=$(TEST_PROG) @@ -42,8 +47,6 @@ bin_PROGRAMS=h5repack # Add h5repack specific linker flags here h5repack_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS) -# Depend on the hdf5 library, the tools library, the test library -LDADD=$(LIBH5TOOLS) $(LIBH5TEST) $(LIBHDF5) # Source files COMMON_SOURCES=h5repack.c h5repack_copy.c h5repack_filters.c \ @@ -52,10 +55,13 @@ COMMON_SOURCES=h5repack.c h5repack_copy.c h5repack_filters.c \ h5repack_SOURCES=$(COMMON_SOURCES) h5repack_main.c -h5repacktst_SOURCES=$(COMMON_SOURCES) h5repacktst.c +if BUILD_TESTS_CONDITIONAL +# Depend on the hdf5 library, the tools library, the test library +LDADD=$(LIBH5TOOLS) $(LIBH5TEST) $(LIBHDF5) +h5repacktst_SOURCES=$(COMMON_SOURCES) h5repacktst.c +#testh5repack_detect_szip_LDADD=$(LIBH5TOOLS) $(LIBH5TEST) $(LIBHDF5) testh5repack_detect_szip_SOURCES=testh5repack_detect_szip.c - # The h5repack.sh script needs h5repacktst to run first. h5repack.sh.chkexe_: h5repacktst.chkexe_ @@ -74,10 +80,15 @@ libdynlibvers.la: $(libdynlibvers_la_OBJECTS) $(libdynlibvers_la_DEPENDENCIES) $ $(AM_V_CCLD)$(libdynlibvers_la_LINK) $(am_libdynlibvers_la_rpath) $(libdynlibvers_la_OBJECTS) $(libdynlibvers_la_LIBADD) endif endif +else +# Depend on the hdf5 library and the tools library +LDADD=$(LIBH5TOOLS) $(LIBHDF5) +endif # Temporary files. *.h5 are generated by h5repack. They should # copied to the testfiles/ directory if update is required. -CHECK_CLEANFILES+=*.h5 *.bin testfiles/h5diff_attr1.h5 testfiles/tfamily*.h5 +# *.dat files may be created by h5repackgentest. +CHECK_CLEANFILES+=*.h5 *.dat *.bin testfiles/h5diff_attr1.h5 testfiles/tfamily*.h5 DISTCLEANFILES=h5repack.sh h5repack_plugin.sh include $(top_srcdir)/config/conclude.am diff --git a/tools/h5repack/Makefile.in b/tools/h5repack/Makefile.in index 8697a3c..0895d55 100644 --- a/tools/h5repack/Makefile.in +++ b/tools/h5repack/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. # @@ -104,11 +104,11 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -noinst_PROGRAMS = testh5repack_detect_szip$(EXEEXT) -@HAVE_SHARED_CONDITIONAL_TRUE@@USE_PLUGINS_CONDITIONAL_TRUE@am__append_1 = h5repack_plugin.sh +@BUILD_TESTS_CONDITIONAL_TRUE@noinst_PROGRAMS = testh5repack_detect_szip$(EXEEXT) +@BUILD_TESTS_CONDITIONAL_TRUE@@HAVE_SHARED_CONDITIONAL_TRUE@@USE_PLUGINS_CONDITIONAL_TRUE@am__append_1 = h5repack_plugin.sh check_PROGRAMS = $(am__EXEEXT_1) bin_PROGRAMS = h5repack$(EXEEXT) -TESTS = $(am__EXEEXT_1) $(TEST_SCRIPT) +TESTS = $(am__EXEEXT_1) $(am__EXEEXT_2) subdir = tools/h5repack ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/aclocal_cxx.m4 \ @@ -123,7 +123,7 @@ CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libdynlibadd_la_LIBADD = am__libdynlibadd_la_SOURCES_DIST = dynlib_rpk.c -@HAVE_SHARED_CONDITIONAL_TRUE@@NOT_UNAME_CYGWIN_TRUE@am_libdynlibadd_la_OBJECTS = dynlib_rpk.lo +@BUILD_TESTS_CONDITIONAL_TRUE@@HAVE_SHARED_CONDITIONAL_TRUE@@NOT_UNAME_CYGWIN_TRUE@am_libdynlibadd_la_OBJECTS = dynlib_rpk.lo libdynlibadd_la_OBJECTS = $(am_libdynlibadd_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) @@ -133,18 +133,19 @@ libdynlibadd_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(AM_CFLAGS) $(CFLAGS) $(libdynlibadd_la_LDFLAGS) $(LDFLAGS) \ -o $@ -@HAVE_SHARED_CONDITIONAL_TRUE@@NOT_UNAME_CYGWIN_TRUE@am_libdynlibadd_la_rpath = +@BUILD_TESTS_CONDITIONAL_TRUE@@HAVE_SHARED_CONDITIONAL_TRUE@@NOT_UNAME_CYGWIN_TRUE@am_libdynlibadd_la_rpath = libdynlibvers_la_LIBADD = am__libdynlibvers_la_SOURCES_DIST = dynlib_vrpk.c -@HAVE_SHARED_CONDITIONAL_TRUE@@NOT_UNAME_CYGWIN_TRUE@am_libdynlibvers_la_OBJECTS = dynlib_vrpk.lo +@BUILD_TESTS_CONDITIONAL_TRUE@@HAVE_SHARED_CONDITIONAL_TRUE@@NOT_UNAME_CYGWIN_TRUE@am_libdynlibvers_la_OBJECTS = dynlib_vrpk.lo libdynlibvers_la_OBJECTS = $(am_libdynlibvers_la_OBJECTS) libdynlibvers_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(AM_CFLAGS) $(CFLAGS) $(libdynlibvers_la_LDFLAGS) $(LDFLAGS) \ -o $@ -@HAVE_SHARED_CONDITIONAL_TRUE@@NOT_UNAME_CYGWIN_TRUE@am_libdynlibvers_la_rpath = +@BUILD_TESTS_CONDITIONAL_TRUE@@HAVE_SHARED_CONDITIONAL_TRUE@@NOT_UNAME_CYGWIN_TRUE@am_libdynlibvers_la_rpath = am__installdirs = "$(DESTDIR)$(bindir)" -am__EXEEXT_1 = h5repacktst$(EXEEXT) +@BUILD_TESTS_CONDITIONAL_TRUE@am__EXEEXT_1 = h5repacktst$(EXEEXT) \ +@BUILD_TESTS_CONDITIONAL_TRUE@ h5repackgentest$(EXEEXT) PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS) am__objects_1 = h5repack.$(OBJEXT) h5repack_copy.$(OBJEXT) \ h5repack_filters.$(OBJEXT) h5repack_opttable.$(OBJEXT) \ @@ -153,21 +154,45 @@ am__objects_1 = h5repack.$(OBJEXT) h5repack_copy.$(OBJEXT) \ am_h5repack_OBJECTS = $(am__objects_1) h5repack_main.$(OBJEXT) h5repack_OBJECTS = $(am_h5repack_OBJECTS) h5repack_LDADD = $(LDADD) -h5repack_DEPENDENCIES = $(LIBH5TOOLS) $(LIBH5TEST) $(LIBHDF5) +@BUILD_TESTS_CONDITIONAL_FALSE@h5repack_DEPENDENCIES = $(LIBH5TOOLS) \ +@BUILD_TESTS_CONDITIONAL_FALSE@ $(LIBHDF5) +@BUILD_TESTS_CONDITIONAL_TRUE@h5repack_DEPENDENCIES = $(LIBH5TOOLS) \ +@BUILD_TESTS_CONDITIONAL_TRUE@ $(LIBH5TEST) $(LIBHDF5) h5repack_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(h5repack_LDFLAGS) $(LDFLAGS) -o $@ -am_h5repacktst_OBJECTS = $(am__objects_1) h5repacktst.$(OBJEXT) +h5repackgentest_SOURCES = h5repackgentest.c +h5repackgentest_OBJECTS = h5repackgentest.$(OBJEXT) +h5repackgentest_LDADD = $(LDADD) +@BUILD_TESTS_CONDITIONAL_FALSE@h5repackgentest_DEPENDENCIES = \ +@BUILD_TESTS_CONDITIONAL_FALSE@ $(LIBH5TOOLS) $(LIBHDF5) +@BUILD_TESTS_CONDITIONAL_TRUE@h5repackgentest_DEPENDENCIES = \ +@BUILD_TESTS_CONDITIONAL_TRUE@ $(LIBH5TOOLS) $(LIBH5TEST) \ +@BUILD_TESTS_CONDITIONAL_TRUE@ $(LIBHDF5) +am__h5repacktst_SOURCES_DIST = h5repack.c h5repack_copy.c \ + h5repack_filters.c h5repack_opttable.c h5repack_parse.c \ + h5repack_refs.c h5repack_verify.c h5repacktst.c +@BUILD_TESTS_CONDITIONAL_TRUE@am_h5repacktst_OBJECTS = \ +@BUILD_TESTS_CONDITIONAL_TRUE@ $(am__objects_1) \ +@BUILD_TESTS_CONDITIONAL_TRUE@ h5repacktst.$(OBJEXT) h5repacktst_OBJECTS = $(am_h5repacktst_OBJECTS) h5repacktst_LDADD = $(LDADD) -h5repacktst_DEPENDENCIES = $(LIBH5TOOLS) $(LIBH5TEST) $(LIBHDF5) -am_testh5repack_detect_szip_OBJECTS = \ - testh5repack_detect_szip.$(OBJEXT) +@BUILD_TESTS_CONDITIONAL_FALSE@h5repacktst_DEPENDENCIES = \ +@BUILD_TESTS_CONDITIONAL_FALSE@ $(LIBH5TOOLS) $(LIBHDF5) +@BUILD_TESTS_CONDITIONAL_TRUE@h5repacktst_DEPENDENCIES = \ +@BUILD_TESTS_CONDITIONAL_TRUE@ $(LIBH5TOOLS) $(LIBH5TEST) \ +@BUILD_TESTS_CONDITIONAL_TRUE@ $(LIBHDF5) +am__testh5repack_detect_szip_SOURCES_DIST = \ + testh5repack_detect_szip.c +@BUILD_TESTS_CONDITIONAL_TRUE@am_testh5repack_detect_szip_OBJECTS = testh5repack_detect_szip.$(OBJEXT) testh5repack_detect_szip_OBJECTS = \ $(am_testh5repack_detect_szip_OBJECTS) testh5repack_detect_szip_LDADD = $(LDADD) -testh5repack_detect_szip_DEPENDENCIES = $(LIBH5TOOLS) $(LIBH5TEST) \ - $(LIBHDF5) +@BUILD_TESTS_CONDITIONAL_FALSE@testh5repack_detect_szip_DEPENDENCIES = \ +@BUILD_TESTS_CONDITIONAL_FALSE@ $(LIBH5TOOLS) $(LIBHDF5) +@BUILD_TESTS_CONDITIONAL_TRUE@testh5repack_detect_szip_DEPENDENCIES = \ +@BUILD_TESTS_CONDITIONAL_TRUE@ $(LIBH5TOOLS) $(LIBH5TEST) \ +@BUILD_TESTS_CONDITIONAL_TRUE@ $(LIBHDF5) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -203,11 +228,12 @@ am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libdynlibadd_la_SOURCES) $(libdynlibvers_la_SOURCES) \ - $(h5repack_SOURCES) $(h5repacktst_SOURCES) \ + $(h5repack_SOURCES) h5repackgentest.c $(h5repacktst_SOURCES) \ $(testh5repack_detect_szip_SOURCES) DIST_SOURCES = $(am__libdynlibadd_la_SOURCES_DIST) \ $(am__libdynlibvers_la_SOURCES_DIST) $(h5repack_SOURCES) \ - $(h5repacktst_SOURCES) $(testh5repack_detect_szip_SOURCES) + h5repackgentest.c $(am__h5repacktst_SOURCES_DIST) \ + $(am__testh5repack_detect_szip_SOURCES_DIST) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ @@ -416,6 +442,8 @@ am__set_TESTS_bases = \ bases=`echo $$bases` RECHECK_LOGS = $(TEST_LOGS) AM_RECURSIVE_TARGETS = check recheck +@BUILD_TESTS_CONDITIONAL_TRUE@am__EXEEXT_2 = h5repack.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) @@ -449,12 +477,13 @@ 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, test, and tools/lib directories AM_CPPFLAGS = @AM_CPPFLAGS@ @H5_CPPFLAGS@ -I$(top_srcdir)/src \ - -I$(top_srcdir)/test -I$(top_srcdir)/tools/lib -AM_CXXFLAGS = @AM_CXXFLAGS@ @H5_CXXFLAGS@ + -I$(top_srcdir)/test -I$(top_srcdir)/tools/lib \ + -I$(top_srcdir)/tools/h5repack +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@ @@ -469,6 +498,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@ @@ -487,6 +517,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@ @@ -514,6 +545,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@ @@ -521,9 +554,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@ @@ -539,6 +575,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@ @@ -560,6 +597,7 @@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJECT_NAMELEN_DEFAULT_F = @OBJECT_NAMELEN_DEFAULT_F@ OBJEXT = @OBJEXT@ +OPTIMIZATION = @OPTIMIZATION@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ @@ -572,8 +610,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@ @@ -587,6 +627,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@ @@ -628,6 +669,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@ @@ -713,41 +755,48 @@ TRACE = perl $(top_srcdir)/bin/trace # Temporary files. *.h5 are generated by h5repack. They should # copied to the testfiles/ directory if update is required. -CHECK_CLEANFILES = *.chkexe *.chklog *.clog *.clog2 *.h5 *.bin \ +# *.dat files may be created by h5repackgentest. +CHECK_CLEANFILES = *.chkexe *.chklog *.clog *.clog2 *.h5 *.dat *.bin \ testfiles/h5diff_attr1.h5 testfiles/tfamily*.h5 +@BUILD_TESTS_CONDITIONAL_FALSE@TEST_SCRIPT = # Test programs and scripts -TEST_SCRIPT = h5repack.sh $(am__append_1) -TEST_PROG = h5repacktst +@BUILD_TESTS_CONDITIONAL_TRUE@TEST_SCRIPT = h5repack.sh \ +@BUILD_TESTS_CONDITIONAL_TRUE@ $(am__append_1) +@BUILD_TESTS_CONDITIONAL_FALSE@TEST_PROG = +@BUILD_TESTS_CONDITIONAL_TRUE@TEST_PROG = h5repacktst h5repackgentest SCRIPT_DEPEND = h5repack$(EXEEXT) check_SCRIPTS = $(TEST_SCRIPT) # Add h5repack specific linker flags here h5repack_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS) -# Depend on the hdf5 library, the tools library, the test library -LDADD = $(LIBH5TOOLS) $(LIBH5TEST) $(LIBHDF5) - # Source files COMMON_SOURCES = h5repack.c h5repack_copy.c h5repack_filters.c \ h5repack_opttable.c h5repack_parse.c h5repack_refs.c \ h5repack_verify.c h5repack_SOURCES = $(COMMON_SOURCES) h5repack_main.c -h5repacktst_SOURCES = $(COMMON_SOURCES) h5repacktst.c -testh5repack_detect_szip_SOURCES = testh5repack_detect_szip.c -@HAVE_SHARED_CONDITIONAL_TRUE@@NOT_UNAME_CYGWIN_TRUE@noinst_LTLIBRARIES = libdynlibadd.la libdynlibvers.la -@HAVE_SHARED_CONDITIONAL_TRUE@@NOT_UNAME_CYGWIN_TRUE@libdynlibadd_la_SOURCES = dynlib_rpk.c -@HAVE_SHARED_CONDITIONAL_TRUE@@NOT_UNAME_CYGWIN_TRUE@libdynlibvers_la_SOURCES = dynlib_vrpk.c -@HAVE_SHARED_CONDITIONAL_TRUE@@NOT_UNAME_CYGWIN_TRUE@libdynlibadd_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere -@HAVE_SHARED_CONDITIONAL_TRUE@@NOT_UNAME_CYGWIN_TRUE@libdynlibvers_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere +# Depend on the hdf5 library and the tools library +@BUILD_TESTS_CONDITIONAL_FALSE@LDADD = $(LIBH5TOOLS) $(LIBHDF5) + +# Depend on the hdf5 library, the tools library, the test library +@BUILD_TESTS_CONDITIONAL_TRUE@LDADD = $(LIBH5TOOLS) $(LIBH5TEST) $(LIBHDF5) +@BUILD_TESTS_CONDITIONAL_TRUE@h5repacktst_SOURCES = $(COMMON_SOURCES) h5repacktst.c +#testh5repack_detect_szip_LDADD=$(LIBH5TOOLS) $(LIBH5TEST) $(LIBHDF5) +@BUILD_TESTS_CONDITIONAL_TRUE@testh5repack_detect_szip_SOURCES = testh5repack_detect_szip.c +@BUILD_TESTS_CONDITIONAL_TRUE@@HAVE_SHARED_CONDITIONAL_TRUE@@NOT_UNAME_CYGWIN_TRUE@noinst_LTLIBRARIES = libdynlibadd.la libdynlibvers.la +@BUILD_TESTS_CONDITIONAL_TRUE@@HAVE_SHARED_CONDITIONAL_TRUE@@NOT_UNAME_CYGWIN_TRUE@libdynlibadd_la_SOURCES = dynlib_rpk.c +@BUILD_TESTS_CONDITIONAL_TRUE@@HAVE_SHARED_CONDITIONAL_TRUE@@NOT_UNAME_CYGWIN_TRUE@libdynlibvers_la_SOURCES = dynlib_vrpk.c +@BUILD_TESTS_CONDITIONAL_TRUE@@HAVE_SHARED_CONDITIONAL_TRUE@@NOT_UNAME_CYGWIN_TRUE@libdynlibadd_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere +@BUILD_TESTS_CONDITIONAL_TRUE@@HAVE_SHARED_CONDITIONAL_TRUE@@NOT_UNAME_CYGWIN_TRUE@libdynlibvers_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere DISTCLEANFILES = h5repack.sh h5repack_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) @@ -813,12 +862,18 @@ clean-noinstLTLIBRARIES: rm -f $${locs}; \ } +@BUILD_TESTS_CONDITIONAL_FALSE@libdynlibadd.la: $(libdynlibadd_la_OBJECTS) $(libdynlibadd_la_DEPENDENCIES) $(EXTRA_libdynlibadd_la_DEPENDENCIES) +@BUILD_TESTS_CONDITIONAL_FALSE@ $(AM_V_CCLD)$(libdynlibadd_la_LINK) $(am_libdynlibadd_la_rpath) $(libdynlibadd_la_OBJECTS) $(libdynlibadd_la_LIBADD) $(LIBS) + @HAVE_SHARED_CONDITIONAL_FALSE@libdynlibadd.la: $(libdynlibadd_la_OBJECTS) $(libdynlibadd_la_DEPENDENCIES) $(EXTRA_libdynlibadd_la_DEPENDENCIES) @HAVE_SHARED_CONDITIONAL_FALSE@ $(AM_V_CCLD)$(libdynlibadd_la_LINK) $(am_libdynlibadd_la_rpath) $(libdynlibadd_la_OBJECTS) $(libdynlibadd_la_LIBADD) $(LIBS) @NOT_UNAME_CYGWIN_FALSE@libdynlibadd.la: $(libdynlibadd_la_OBJECTS) $(libdynlibadd_la_DEPENDENCIES) $(EXTRA_libdynlibadd_la_DEPENDENCIES) @NOT_UNAME_CYGWIN_FALSE@ $(AM_V_CCLD)$(libdynlibadd_la_LINK) $(am_libdynlibadd_la_rpath) $(libdynlibadd_la_OBJECTS) $(libdynlibadd_la_LIBADD) $(LIBS) +@BUILD_TESTS_CONDITIONAL_FALSE@libdynlibvers.la: $(libdynlibvers_la_OBJECTS) $(libdynlibvers_la_DEPENDENCIES) $(EXTRA_libdynlibvers_la_DEPENDENCIES) +@BUILD_TESTS_CONDITIONAL_FALSE@ $(AM_V_CCLD)$(libdynlibvers_la_LINK) $(am_libdynlibvers_la_rpath) $(libdynlibvers_la_OBJECTS) $(libdynlibvers_la_LIBADD) $(LIBS) + @HAVE_SHARED_CONDITIONAL_FALSE@libdynlibvers.la: $(libdynlibvers_la_OBJECTS) $(libdynlibvers_la_DEPENDENCIES) $(EXTRA_libdynlibvers_la_DEPENDENCIES) @HAVE_SHARED_CONDITIONAL_FALSE@ $(AM_V_CCLD)$(libdynlibvers_la_LINK) $(am_libdynlibvers_la_rpath) $(libdynlibvers_la_OBJECTS) $(libdynlibvers_la_LIBADD) $(LIBS) @@ -896,6 +951,10 @@ h5repack$(EXEEXT): $(h5repack_OBJECTS) $(h5repack_DEPENDENCIES) $(EXTRA_h5repack @rm -f h5repack$(EXEEXT) $(AM_V_CCLD)$(h5repack_LINK) $(h5repack_OBJECTS) $(h5repack_LDADD) $(LIBS) +h5repackgentest$(EXEEXT): $(h5repackgentest_OBJECTS) $(h5repackgentest_DEPENDENCIES) $(EXTRA_h5repackgentest_DEPENDENCIES) + @rm -f h5repackgentest$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(h5repackgentest_OBJECTS) $(h5repackgentest_LDADD) $(LIBS) + h5repacktst$(EXEEXT): $(h5repacktst_OBJECTS) $(h5repacktst_DEPENDENCIES) $(EXTRA_h5repacktst_DEPENDENCIES) @rm -f h5repacktst$(EXEEXT) $(AM_V_CCLD)$(LINK) $(h5repacktst_OBJECTS) $(h5repacktst_LDADD) $(LIBS) @@ -920,6 +979,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5repack_parse.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5repack_refs.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5repack_verify.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5repackgentest.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5repacktst.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testh5repack_detect_szip.Po@am__quote@ @@ -1139,6 +1199,13 @@ h5repacktst.log: h5repacktst$(EXEEXT) --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) +h5repackgentest.log: h5repackgentest$(EXEEXT) + @p='h5repackgentest$(EXEEXT)'; \ + b='h5repackgentest'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) .sh.log: @p='$<'; \ $(am__set_b); \ @@ -1331,16 +1398,16 @@ uninstall-am: uninstall-binPROGRAMS help: @$(top_srcdir)/bin/makehelp - # The h5repack.sh script needs h5repacktst to run first. -h5repack.sh.chkexe_: h5repacktst.chkexe_ +@BUILD_TESTS_CONDITIONAL_TRUE@h5repack.sh.chkexe_: h5repacktst.chkexe_ + +@BUILD_TESTS_CONDITIONAL_TRUE@@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@ # Build it as shared library if configure is enabled for shared library. +@BUILD_TESTS_CONDITIONAL_TRUE@@HAVE_SHARED_CONDITIONAL_TRUE@@NOT_UNAME_CYGWIN_TRUE@libdynlibadd.la: $(libdynlibadd_la_OBJECTS) $(libdynlibadd_la_DEPENDENCIES) $(EXTRA_libdynlibadd_la_DEPENDENCIES) +@BUILD_TESTS_CONDITIONAL_TRUE@@HAVE_SHARED_CONDITIONAL_TRUE@@NOT_UNAME_CYGWIN_TRUE@ $(AM_V_CCLD)$(libdynlibadd_la_LINK) $(am_libdynlibadd_la_rpath) $(libdynlibadd_la_OBJECTS) $(libdynlibadd_la_LIBADD) +@BUILD_TESTS_CONDITIONAL_TRUE@@HAVE_SHARED_CONDITIONAL_TRUE@@NOT_UNAME_CYGWIN_TRUE@libdynlibvers.la: $(libdynlibvers_la_OBJECTS) $(libdynlibvers_la_DEPENDENCIES) $(EXTRA_libdynlibvers_la_DEPENDENCIES) +@BUILD_TESTS_CONDITIONAL_TRUE@@HAVE_SHARED_CONDITIONAL_TRUE@@NOT_UNAME_CYGWIN_TRUE@ $(AM_V_CCLD)$(libdynlibvers_la_LINK) $(am_libdynlibvers_la_rpath) $(libdynlibvers_la_OBJECTS) $(libdynlibvers_la_LIBADD) -@HAVE_SHARED_CONDITIONAL_TRUE@@NOT_UNAME_CYGWIN_TRUE@libdynlibadd.la: $(libdynlibadd_la_OBJECTS) $(libdynlibadd_la_DEPENDENCIES) $(EXTRA_libdynlibadd_la_DEPENDENCIES) -@HAVE_SHARED_CONDITIONAL_TRUE@@NOT_UNAME_CYGWIN_TRUE@ $(AM_V_CCLD)$(libdynlibadd_la_LINK) $(am_libdynlibadd_la_rpath) $(libdynlibadd_la_OBJECTS) $(libdynlibadd_la_LIBADD) -@HAVE_SHARED_CONDITIONAL_TRUE@@NOT_UNAME_CYGWIN_TRUE@libdynlibvers.la: $(libdynlibvers_la_OBJECTS) $(libdynlibvers_la_DEPENDENCIES) $(EXTRA_libdynlibvers_la_DEPENDENCIES) -@HAVE_SHARED_CONDITIONAL_TRUE@@NOT_UNAME_CYGWIN_TRUE@ $(AM_V_CCLD)$(libdynlibvers_la_LINK) $(am_libdynlibvers_la_rpath) $(libdynlibvers_la_OBJECTS) $(libdynlibvers_la_LIBADD) # lib/progs/tests targets recurse into subdirectories. build-* targets # build files in this directory. build-lib: $(LIB) @@ -1376,7 +1443,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." @@ -1537,7 +1604,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/h5repack/dynlib_rpk.c b/tools/h5repack/dynlib_rpk.c index 29c3eae..e64e67b 100644 --- a/tools/h5repack/dynlib_rpk.c +++ b/tools/h5repack/dynlib_rpk.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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -20,24 +20,32 @@ #include <stdio.h> #include "H5PLextern.h" -#define H5Z_FILTER_DYNLIB1 257 +#define H5Z_FILTER_DYNLIB1 257 -static size_t H5Z_filter_dynlib1(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_dynlib1(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_DYNLIB1[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ H5Z_FILTER_DYNLIB1, /* Filter id number */ - 1, 1, /* Encoding and decoding enabled */ - "dynlib1", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - (H5Z_func_t)H5Z_filter_dynlib1, /* The actual filter function */ + 1, 1, /* Encoding and decoding enabled */ + "dynlib1", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + (H5Z_func_t)H5Z_filter_dynlib1, /* The actual filter function */ }}; -H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} -const void *H5PLget_plugin_info(void) {return H5Z_DYNLIB1;} +H5PL_type_t +H5PLget_plugin_type(void) +{ + return H5PL_TYPE_FILTER; +} +const void * +H5PLget_plugin_info(void) +{ + return H5Z_DYNLIB1; +} /*------------------------------------------------------------------------- * Function: H5Z_filter_dynlib1 @@ -57,39 +65,37 @@ const void *H5PLget_plugin_info(void) {return H5Z_DYNLIB1;} *------------------------------------------------------------------------- */ static size_t -H5Z_filter_dynlib1(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, - size_t *buf_size, void **buf) +H5Z_filter_dynlib1(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, + size_t *buf_size, void **buf) { - int *int_ptr = (int *)*buf; /* Pointer to the data values */ - size_t buf_left = *buf_size; /* Amount of data buffer left to process */ - int add_on = 0; + int * int_ptr = (int *)*buf; /* Pointer to the data values */ + size_t buf_left = *buf_size; /* Amount of data buffer left to process */ + int add_on = 0; /* Check for the correct number of parameters */ - if(cd_nelmts == 0) + if (cd_nelmts == 0) return 0; /* Check that permanent parameters are set correctly */ - if(cd_values[0] > 9) + if (cd_values[0] > 9) return 0; add_on = (int)cd_values[0]; - if(flags & H5Z_FLAG_REVERSE) { /*read*/ + if (flags & H5Z_FLAG_REVERSE) { /*read*/ /* Substract the "add on" value to all the data values */ - while(buf_left > 0) { + while (buf_left > 0) { *int_ptr++ -= add_on; buf_left -= sizeof(int); - } /* end while */ - } /* end if */ + } /* end while */ + } /* end if */ else { /*write*/ /* Add the "add on" value to all the data values */ - while(buf_left > 0) { + while (buf_left > 0) { *int_ptr++ += add_on; buf_left -= sizeof(int); } /* end while */ - } /* end else */ + } /* end else */ return nbytes; } /* end H5Z_filter_dynlib1() */ - diff --git a/tools/h5repack/dynlib_vrpk.c b/tools/h5repack/dynlib_vrpk.c index 06d90ff..2db97da 100644 --- a/tools/h5repack/dynlib_vrpk.c +++ b/tools/h5repack/dynlib_vrpk.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,26 +17,35 @@ #include <stdio.h> #include "H5PLextern.h" -#define H5Z_FILTER_DYNLIB4 260 +#define H5Z_FILTER_DYNLIB4 260 -#define PUSH_ERR(func, minor, str) H5Epush2(H5E_DEFAULT, __FILE__, func, __LINE__, H5E_ERR_CLS, H5E_PLUGIN, minor, str) +#define PUSH_ERR(func, minor, str) \ + H5Epush2(H5E_DEFAULT, __FILE__, func, __LINE__, H5E_ERR_CLS, H5E_PLUGIN, minor, str) -static size_t H5Z_filter_dynlib4(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_dynlib4(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_DYNLIB4[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ H5Z_FILTER_DYNLIB4, /* Filter id number */ - 1, 1, /* Encoding and decoding enabled */ - "dynlib4", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - (H5Z_func_t)H5Z_filter_dynlib4, /* The actual filter function */ + 1, 1, /* Encoding and decoding enabled */ + "dynlib4", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + (H5Z_func_t)H5Z_filter_dynlib4, /* The actual filter function */ }}; -H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} -const void *H5PLget_plugin_info(void) {return H5Z_DYNLIB4;} +H5PL_type_t +H5PLget_plugin_type(void) +{ + return H5PL_TYPE_FILTER; +} +const void * +H5PLget_plugin_info(void) +{ + return H5Z_DYNLIB4; +} /*------------------------------------------------------------------------- * Function: H5Z_filter_dynlib4 @@ -53,50 +62,48 @@ const void *H5PLget_plugin_info(void) {return H5Z_DYNLIB4;} *------------------------------------------------------------------------- */ static size_t -H5Z_filter_dynlib4(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, - size_t *buf_size, void **buf) +H5Z_filter_dynlib4(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, + size_t *buf_size, void **buf) { - int *int_ptr = (int *)*buf; /* Pointer to the data values */ - size_t buf_left = *buf_size; /* Amount of data buffer left to process */ - int add_on = 0; + int * int_ptr = (int *)*buf; /* Pointer to the data values */ + size_t buf_left = *buf_size; /* Amount of data buffer left to process */ + int add_on = 0; unsigned ver_info[3]; /* Check for the library version */ - if(H5get_libversion(&ver_info[0], &ver_info[1], &ver_info[2]) < 0) { + if (H5get_libversion(&ver_info[0], &ver_info[1], &ver_info[2]) < 0) { PUSH_ERR("dynlib4", H5E_CALLBACK, "H5get_libversion"); - return(0); + return (0); } /* Check for the correct number of parameters */ - if(cd_nelmts == 0) - return(0); + if (cd_nelmts == 0) + return (0); /* Check that permanent parameters are set correctly */ - if(cd_values[0] > 9) - return(0); + if (cd_values[0] > 9) + return (0); - if(ver_info[0] != cd_values[1] || ver_info[1] != cd_values[2]) { + if (ver_info[0] != cd_values[1] || ver_info[1] != cd_values[2]) { PUSH_ERR("dynlib4", H5E_CALLBACK, "H5get_libversion does not match"); - return(0); + return (0); } add_on = (int)cd_values[0]; - if(flags & H5Z_FLAG_REVERSE) { /*read*/ + if (flags & H5Z_FLAG_REVERSE) { /*read*/ /* Substract the "add on" value to all the data values */ - while(buf_left > 0) { + while (buf_left > 0) { *int_ptr++ -= add_on; buf_left -= sizeof(int); - } /* end while */ - } /* end if */ + } /* end while */ + } /* end if */ else { /*write*/ /* Add the "add on" value to all the data values */ - while(buf_left > 0) { + while (buf_left > 0) { *int_ptr++ += add_on; buf_left -= sizeof(int); } /* end while */ - } /* end else */ + } /* end else */ return nbytes; } /* end H5Z_filter_dynlib4() */ - diff --git a/tools/h5repack/h5repack.c b/tools/h5repack/h5repack.c index e8c3409..80c658e 100644 --- a/tools/h5repack/h5repack.c +++ b/tools/h5repack/h5repack.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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -22,10 +22,10 @@ *------------------------------------------------------------------------- */ -static int check_options(pack_opt_t *options); -static int check_objects(const char* fname, pack_opt_t *options); -static const char* get_sfilter(H5Z_filter_t filtn); -static int have_request(pack_opt_t *options); +static int check_options(pack_opt_t *options); +static int check_objects(const char *fname, pack_opt_t *options); +static const char *get_sfilter(H5Z_filter_t filtn); +static int have_request(pack_opt_t *options); /*------------------------------------------------------------------------- * Function: h5repack @@ -41,7 +41,9 @@ static int have_request(pack_opt_t *options); * Return: 0, ok, -1, fail *------------------------------------------------------------------------- */ -int h5repack(const char* infile, const char* outfile, pack_opt_t *options) { +int +h5repack(const char *infile, const char *outfile, pack_opt_t *options) +{ /* check input */ if (check_options(options) < 0) return -1; @@ -55,7 +57,7 @@ int h5repack(const char* infile, const char* outfile, pack_opt_t *options) { return -1; return 0; -} +} /* end h5repack() */ /*------------------------------------------------------------------------- * Function: h5repack_init @@ -72,19 +74,19 @@ h5repack_init(pack_opt_t *options, int verbose, hbool_t latest) HDmemset(options, 0, sizeof(pack_opt_t)); options->min_comp = 0; - options->verbose = verbose; - options->latest = latest; + options->verbose = verbose; + options->latest = latest; options->layout_g = H5D_LAYOUT_ERROR; for (n = 0; n < H5_REPACK_MAX_NFILTERS; n++) { - options->filter_g[n].filtn = -1; + options->filter_g[n].filtn = -1; options->filter_g[n].cd_nelmts = 0; for (k = 0; k < CD_VALUES; k++) options->filter_g[n].cd_values[k] = 0; } return (options_table_init(&(options->op_tbl))); -} +} /* end h5repack_init() */ /*------------------------------------------------------------------------- * Function: h5repack_end @@ -93,9 +95,11 @@ h5repack_init(pack_opt_t *options, int verbose, hbool_t latest) *------------------------------------------------------------------------- */ -int h5repack_end(pack_opt_t *options) { +int +h5repack_end(pack_opt_t *options) +{ return options_table_free(options->op_tbl); -} +} /* end h5repack_end() */ /*------------------------------------------------------------------------- * Function: h5repack_addfilter @@ -109,7 +113,7 @@ int h5repack_end(pack_opt_t *options) { int h5repack_addfilter(const char *str, pack_opt_t *options) { - obj_list_t *obj_list = NULL; /* one object list for the -f and -l option entry */ + obj_list_t * obj_list = NULL; /* one object list for the -f and -l option entry */ filter_info_t filter; /* filter info for the current -f option entry */ unsigned n_objs; /* number of objects in the current -f or -l option entry */ int is_glb; /* is the filter global */ @@ -136,7 +140,7 @@ h5repack_addfilter(const char *str, pack_opt_t *options) HDfree(obj_list); return 0; -} +} /* end h5repack_addfilter() */ /*------------------------------------------------------------------------- * Function: h5repack_addlayout @@ -158,7 +162,7 @@ h5repack_addlayout(const char *str, pack_opt_t *options) init_packobject(&pack); if (options->all_layout == 1) { - error_msg( "invalid layout input: 'all' option is present with other objects <%s>\n", str); + error_msg("invalid layout input: 'all' option is present with other objects <%s>\n", str); return ret_value; } @@ -173,7 +177,7 @@ h5repack_addlayout(const char *str, pack_opt_t *options) if (pack.layout == H5D_CHUNKED) { /* -2 means the NONE option, remove chunking and set the global layout to contiguous */ - if (pack.chunk.rank == -2) + if (pack.chunk.rank == -2) /* TODO: fix 'magic number' */ options->layout_g = H5D_CONTIGUOUS; /* otherwise set the global chunking type */ else { @@ -190,10 +194,10 @@ h5repack_addlayout(const char *str, pack_opt_t *options) HDfree(obj_list); ret_value = 0; - } + } /* end if obj_list exists */ return ret_value; -} +} /* end h5repack_addlayout() */ /* Note: The below copy_named_datatype(), named_datatype_free(), copy_attr() * were located in h5repack_copy.c as static prior to bugfix1726. @@ -213,15 +217,17 @@ h5repack_addlayout(const char *str, pack_opt_t *options) * to free the stack. *------------------------------------------------------------------------- */ -hid_t copy_named_datatype(hid_t type_in, hid_t fidout, - named_dt_t **named_dt_head_p, trav_table_t *travt, pack_opt_t *options) { - named_dt_t *dt = *named_dt_head_p; /* Stack pointer */ - named_dt_t *dt_ret = NULL; /* Datatype to return */ - H5O_info_t oinfo; /* Object info of input dtype */ - hid_t ret_value = -1; /* The identifier of the named dtype in the out file */ +hid_t +copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, trav_table_t *travt, + pack_opt_t *options) +{ + named_dt_t *dt = *named_dt_head_p; /* Stack pointer */ + named_dt_t *dt_ret = NULL; /* Datatype to return */ + H5O_info_t oinfo; /* Object info of input dtype */ + hid_t ret_value = H5I_INVALID_HID; if (H5Oget_info(type_in, &oinfo) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Oget_info failed"); + H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "H5Oget_info failed"); if (*named_dt_head_p) { /* Stack already exists, search for the datatype */ @@ -237,59 +243,63 @@ hid_t copy_named_datatype(hid_t type_in, hid_t fidout, if (travt->objs[i].type == H5TRAV_TYPE_NAMED_DATATYPE) { /* Push onto the stack */ if (NULL == (dt = (named_dt_t *)HDmalloc(sizeof(named_dt_t)))) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "buffer allocation failed failed"); - dt->next = *named_dt_head_p; + H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "buffer allocation failed failed"); + dt->next = *named_dt_head_p; *named_dt_head_p = dt; /* Update the address and id */ dt->addr_in = travt->objs[i].objno; - dt->id_out = -1; + dt->id_out = H5I_INVALID_HID; /* Check if this type is the one requested */ if (oinfo.addr == dt->addr_in) { dt_ret = dt; - } /* end if */ - } /* end if */ - } /* end for */ - } /* end else */ + } + } /* end if named datatype */ + } /* end for each object in traversal table */ + } /* end else (create the stack) */ /* Handle the case that the requested datatype was not found. This is - * possible if the datatype was committed anonymously in the input file. */ + * possible if the datatype was committed anonymously in the input file. + */ if (!dt_ret) { /* Push the new datatype onto the stack */ if (NULL == (dt_ret = (named_dt_t *)HDmalloc(sizeof(named_dt_t)))) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "buffer allocation failed failed"); - dt_ret->next = *named_dt_head_p; + H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "buffer allocation failed failed"); + dt_ret->next = *named_dt_head_p; *named_dt_head_p = dt_ret; /* Update the address and id */ dt_ret->addr_in = oinfo.addr; - dt_ret->id_out = -1; - } /* end if */ + dt_ret->id_out = H5I_INVALID_HID; + } /* end if requested datatype not found */ /* If the requested datatype does not yet exist in the output file, copy it - * anonymously */ + * anonymously + */ if (dt_ret->id_out < 0) { if (options->use_native == 1) dt_ret->id_out = H5Tget_native_type(type_in, H5T_DIR_DEFAULT); else dt_ret->id_out = H5Tcopy(type_in); if (dt_ret->id_out < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_native_type-H5Tcopy failed"); + H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "H5Tget_native_type-H5Tcopy failed"); if (H5Tcommit_anon(fidout, dt_ret->id_out, H5P_DEFAULT, H5P_DEFAULT) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tcommit_anon failed"); - } /* end if */ + H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "H5Tcommit_anon failed"); + } /* end if named datatype not yet in output file */ /* Set return value */ ret_value = dt_ret->id_out; - /* Increment the ref count on id_out, because the calling function will try to close it */ - if(H5Iinc_ref(ret_value) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Iinc_ref failed"); + /* Increment the ref count on id_out, because the calling function will try + * to close it. (TODO: fix scope envy) + */ + if (H5Iinc_ref(ret_value) < 0) + H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "H5Iinc_ref failed"); done: return ret_value; -} /* end copy_named_datatype */ +} /* end copy_named_datatype() */ /*------------------------------------------------------------------------- * Function: named_datatype_free @@ -297,24 +307,26 @@ done: * Purpose: Frees the stack of named datatypes. *------------------------------------------------------------------------- */ -int named_datatype_free(named_dt_t **named_dt_head_p, int ignore_err) { - named_dt_t *dt = *named_dt_head_p; +int +named_datatype_free(named_dt_t **named_dt_head_p, int ignore_err) +{ + named_dt_t *dt = *named_dt_head_p; int ret_value = -1; while (dt) { /* Pop the datatype off the stack and free it */ if (H5Tclose(dt->id_out) < 0 && !ignore_err) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); dt = dt->next; HDfree(*named_dt_head_p); *named_dt_head_p = dt; - } /* end while */ + } ret_value = 0; done: return (ret_value); -} /* end named_datatype_free */ +} /* end named_datatype_free() */ /*------------------------------------------------------------------------- * Function: copy_attr @@ -328,149 +340,148 @@ done: *------------------------------------------------------------------------- */ int -copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, - trav_table_t *travt, pack_opt_t *options) +copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_t *travt, pack_opt_t *options) { - int ret_value = 0; - hid_t attr_id = -1; /* attr ID */ - hid_t attr_out = -1; /* attr ID */ - hid_t space_id = -1; /* space ID */ - hid_t ftype_id = -1; /* file type ID */ - hid_t wtype_id = -1; /* read/write type ID */ - size_t msize; /* size of type */ - void *buf = NULL; /* data buffer */ - hsize_t nelmts; /* number of elements in dataset */ - int rank; /* rank of dataset */ - htri_t is_named; /* Whether the datatype is named */ - hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */ + hid_t attr_id = H5I_INVALID_HID; /* attr ID */ + hid_t attr_out = H5I_INVALID_HID; /* attr ID */ + hid_t space_id = H5I_INVALID_HID; /* space ID */ + hid_t ftype_id = H5I_INVALID_HID; /* file type ID */ + hid_t wtype_id = H5I_INVALID_HID; /* read/write type ID */ + size_t msize; /* size of type */ + void * buf = NULL; /* data buffer */ + hsize_t nelmts; /* number of elements in dataset */ + int rank; /* rank of dataset */ + htri_t is_named; /* Whether the datatype is named */ + hsize_t dims[H5S_MAX_RANK]; /* dimensions of dataset */ char name[255]; - H5O_info_t oinfo; /* object info */ + H5O_info_t oinfo; /* object info */ int j; unsigned u; - hbool_t is_ref = 0; + hbool_t is_ref = 0; H5T_class_t type_class = -1; + int ret_value = 0; if (H5Oget_info(loc_in, &oinfo) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Oget_info failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Oget_info failed"); /*------------------------------------------------------------------------- * copy all attributes *------------------------------------------------------------------------- */ - for (u = 0; u < (unsigned) oinfo.num_attrs; u++) { + for (u = 0; u < (unsigned)oinfo.num_attrs; u++) { /* open attribute */ - if ((attr_id = H5Aopen_by_idx(loc_in, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t) u, H5P_DEFAULT, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aopen_by_idx failed"); + if ((attr_id = H5Aopen_by_idx(loc_in, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Aopen_by_idx failed"); - /* get name */ - if (H5Aget_name(attr_id, (size_t) 255, name) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); + if (H5Aget_name(attr_id, (size_t)255, name) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); /* get the file datatype */ if ((ftype_id = H5Aget_type(attr_id)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_type failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Aget_type failed"); /* Check if the datatype is committed */ if ((is_named = H5Tcommitted(ftype_id)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tcommitted failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Tcommitted failed"); if (is_named && travt) { - hid_t fidout = -1; + hid_t fidout = H5I_INVALID_HID; /* Create out file id */ if ((fidout = H5Iget_file_id(loc_out)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Iget_file_id failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Iget_file_id failed"); /* Copy named dt */ if ((wtype_id = copy_named_datatype(ftype_id, fidout, named_dt_head_p, travt, options)) < 0) { H5Fclose(fidout); - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_named_datatype failed"); - } /* end if */ + H5TOOLS_GOTO_ERROR((-1), "copy_named_datatype failed"); + } if (H5Fclose(fidout) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fclose failed"); - } /* end if */ + H5TOOLS_GOTO_ERROR((-1), "H5Fclose failed"); + } /* end if datatype is committed and we have a traversal table */ else { if (options->use_native == 1) wtype_id = H5Tget_native_type(ftype_id, H5T_DIR_DEFAULT); else wtype_id = H5Tcopy(ftype_id); - } /* end else */ + } /* end else: uncommitted datatype and/or no traversal table */ /* get the dataspace handle */ if ((space_id = H5Aget_space(attr_id)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_space failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Aget_space failed"); /* get dimensions */ if ((rank = H5Sget_simple_extent_dims(space_id, dims, NULL)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_dims failed"); nelmts = 1; for (j = 0; j < rank; j++) nelmts *= dims[j]; if ((msize = H5Tget_size(wtype_id)) == 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed"); - - /*------------------------------------------------------------------------- - * object references are a special case. We cannot just copy the buffers, - * but instead we recreate the reference. - * This is done on a second sweep of the file that just copies the referenced - * objects at copy_refs_attr() - *------------------------------------------------------------------------- + H5TOOLS_GOTO_ERROR((-1), "H5Tget_size failed"); + + /*--------------------------------------------------------------------- + * object references are a special case. We cannot just copy the + * buffers, but instead we recreate the reference. + * This is done on a second sweep of the file that just copies the + * referenced objects at copy_refs_attr(). + *--------------------------------------------------------------------- */ type_class = H5Tget_class(wtype_id); - is_ref = (type_class == H5T_REFERENCE); + is_ref = (type_class == H5T_REFERENCE); if (type_class == H5T_VLEN || type_class == H5T_ARRAY) { - hid_t base_type = -1; + hid_t base_type = H5I_INVALID_HID; base_type = H5Tget_super(ftype_id); - is_ref = (is_ref || (H5Tget_class(base_type) == H5T_REFERENCE)); + is_ref = (is_ref || (H5Tget_class(base_type) == H5T_REFERENCE)); if (H5Tclose(base_type) < 0) - H5TOOLS_INFO(H5E_tools_min_id_g, "H5Tclose base_type failed"); - } + H5TOOLS_ERROR((-1), "H5Tclose base_type failed"); + } /* end if type_class is variable length or array */ if (type_class == H5T_COMPOUND) { int nmembers = H5Tget_nmembers(wtype_id); for (j = 0; j < nmembers; j++) { - hid_t mtid = H5Tget_member_type(wtype_id, (unsigned)j); + hid_t mtid = H5Tget_member_type(wtype_id, (unsigned)j); H5T_class_t mtclass = H5Tget_class(mtid); if (H5Tclose(mtid) < 0) - H5TOOLS_INFO(H5E_tools_min_id_g, "H5Tclose mtid failed"); + H5TOOLS_ERROR((-1), "H5Tclose mtid failed"); if (mtclass == H5T_REFERENCE) { is_ref = 1; break; } - } /* for (j=0; i<nmembers; j++) */ - } /* if (type_class == H5T_COMPOUND) */ + } /* end for each member */ + } /* end if type_class is H5T_COMPOUND */ if (!is_ref) { - /*------------------------------------------------------------------------- + /*----------------------------------------------------------------- * read to memory - *------------------------------------------------------------------------- + *----------------------------------------------------------------- */ buf = (void *)HDmalloc((size_t)(nelmts * msize)); if (buf == NULL) { - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDmalloc failed"); + H5TOOLS_GOTO_ERROR((-1), "HDmalloc failed"); } /* end if */ if (H5Aread(attr_id, wtype_id, buf) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aread failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Aread failed"); - /*------------------------------------------------------------------------- + /*----------------------------------------------------------------- * copy - *------------------------------------------------------------------------- + *----------------------------------------------------------------- */ if ((attr_out = H5Acreate2(loc_out, name, wtype_id, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Acreate2 failed on ,%s>", name); + H5TOOLS_GOTO_ERROR((-1), "H5Acreate2 failed on ,%s>", name); if (H5Awrite(attr_out, wtype_id, buf) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Awrite failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Awrite failed"); /*close*/ if (H5Aclose(attr_out) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Aclose failed"); /* Check if we have VL data and string in the attribute's datatype that must * be reclaimed */ @@ -481,246 +492,257 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, } /*H5T_REFERENCE*/ if (options->verbose) - printf(FORMAT_OBJ_ATTR, "attr", name); + HDprintf(FORMAT_OBJ_ATTR, "attr", name); - /*------------------------------------------------------------------------- + /*--------------------------------------------------------------------- * close - *------------------------------------------------------------------------- + *--------------------------------------------------------------------- */ if (H5Sclose(space_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed"); - space_id = -1; + H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed"); + space_id = H5I_INVALID_HID; if (H5Tclose(wtype_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); - wtype_id = -1; + H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); + wtype_id = H5I_INVALID_HID; if (H5Tclose(ftype_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); - ftype_id = -1; + H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); + ftype_id = H5I_INVALID_HID; if (H5Aclose(attr_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aclose failed"); - attr_id = -1; - } /* for u */ + H5TOOLS_GOTO_ERROR((-1), "H5Aclose failed"); + attr_id = H5I_INVALID_HID; + } /* for u (each attribute) */ done: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { if (buf) { - /* Check if we have VL data and string in the attribute's datatype that must - * be reclaimed */ + /* Check if we have VL data and string in the attribute's + * datatype that must be reclaimed + */ if (TRUE == h5tools_detect_vlen(wtype_id)) H5Dvlen_reclaim(wtype_id, space_id, H5P_DEFAULT, buf); - - /* Free buf */ HDfree(buf); - } /* end if */ + } H5Aclose(attr_out); H5Sclose(space_id); H5Tclose(wtype_id); H5Tclose(ftype_id); H5Aclose(attr_id); - } H5E_END_TRY; + } + H5E_END_TRY; return ret_value; } /* end copy_attr() */ -/*------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- * Function: check_options * * Purpose: print options, checks for invalid options * * Return: void, return -1 on error - *------------------------------------------------------------------------- + *----------------------------------------------------------------------------- */ -static int check_options(pack_opt_t *options) { - int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ +static int +check_options(pack_opt_t *options) +{ unsigned int i; int k, j, has_cp = 0, has_ck = 0; char slayout[30]; + int ret_value = 0; /*------------------------------------------------------------------------- - * objects to layout - *------------------------------------------------------------------------- - */ - if (options->verbose && have_request(options) /* only print if requested */) { + * Objects to layout + *------------------------------------------------------------------------- + */ + if (options->verbose && have_request(options)) { if (options->all_layout == 1) { - printf("All objects to modify layout are...\n"); + HDprintf("All objects to modify layout are...\n"); switch (options->layout_g) { - case H5D_COMPACT: - strcpy(slayout, "compact"); - break; - case H5D_CONTIGUOUS: - strcpy(slayout, "contiguous"); - break; - case H5D_CHUNKED: - strcpy(slayout, "chunked"); - break; - case H5D_LAYOUT_ERROR: - case H5D_NLAYOUTS: - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "invalid layout"); - default: - strcpy(slayout, "invalid layout\n"); - HGOTO_DONE(FAIL); + case H5D_COMPACT: + strcpy(slayout, "compact"); + break; + case H5D_CONTIGUOUS: + strcpy(slayout, "contiguous"); + break; + case H5D_CHUNKED: + strcpy(slayout, "chunked"); + break; + case H5D_LAYOUT_ERROR: + case H5D_NLAYOUTS: + H5TOOLS_GOTO_ERROR((-1), "invalid layout"); + break; + default: + strcpy(slayout, "invalid layout\n"); + H5TOOLS_GOTO_DONE((-1)); } - printf(" Apply %s layout to all", slayout); + HDprintf(" Apply %s layout to all", slayout); if (H5D_CHUNKED == options->layout_g) { - printf("with dimension [ "); + HDprintf("with dimension [ "); for (j = 0; j < options->chunk_g.rank; j++) - printf("%d ", (int) options->chunk_g.chunk_lengths[j]); - printf("]"); + HDprintf("%d ", (int)options->chunk_g.chunk_lengths[j]); + HDprintf("]"); } - printf("\n"); + HDprintf("\n"); } else - printf("No all objects to modify layout\n"); - }/* verbose */ + HDprintf("No all objects to modify layout\n"); + } /* end if verbose */ for (i = 0; i < options->op_tbl->nelems; i++) { - char* name = options->op_tbl->objs[i].path; + char *name = options->op_tbl->objs[i].path; if (options->op_tbl->objs[i].chunk.rank > 0) { if (options->verbose) { - printf(" <%s> with chunk size ", name); + HDprintf(" <%s> with chunk size ", name); for (k = 0; k < options->op_tbl->objs[i].chunk.rank; k++) - printf("%d ", (int) options->op_tbl->objs[i].chunk.chunk_lengths[k]); - printf("\n"); + HDprintf("%d ", (int)options->op_tbl->objs[i].chunk.chunk_lengths[k]); + HDprintf("\n"); } has_ck = 1; } - else if (options->op_tbl->objs[i].chunk.rank == -2) { + else if (options->op_tbl->objs[i].chunk.rank == -2) { /* TODO: replace 'magic number' */ if (options->verbose) - printf(" <%s> %s\n", name, "NONE (contiguous)"); + HDprintf(" <%s> %s\n", name, "NONE (contiguous)"); has_ck = 1; } - } + } /* end for each object in options */ if (options->all_layout == 1 && has_ck) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "invalid chunking input: 'all' option is present with other objects"); + H5TOOLS_GOTO_ERROR((-1), "invalid chunking input: 'all' option is present with other objects"); /*------------------------------------------------------------------------- - * objects to filter - *------------------------------------------------------------------------- - */ + * Objects to filter + *------------------------------------------------------------------------- + */ - if (options->verbose && have_request(options) /* only print if requested */) { + if (options->verbose && have_request(options)) { if (options->all_filter == 1) { - printf("All objects to apply filter are...\n"); + HDprintf("All objects to apply filter are...\n"); for (k = 0; k < options->n_filter_g; k++) { H5Z_filter_t filtn = options->filter_g[k].filtn; if (filtn < 0) { - printf(" Unknown\n"); + HDprintf(" Unknown\n"); continue; } switch (filtn) { - case H5Z_FILTER_NONE: - printf(" Uncompress all\n"); - break; - case H5Z_FILTER_SHUFFLE: - case H5Z_FILTER_FLETCHER32: - printf(" All with %s\n", get_sfilter(filtn)); - break; - case H5Z_FILTER_SZIP: - case H5Z_FILTER_DEFLATE: - printf(" All with %s, parameter %d\n", get_sfilter(filtn), options->filter_g[k].cd_values[0]); - break; - default: - printf(" User Defined %d\n", filtn); - break; - } /* k */ - }; - } + case H5Z_FILTER_NONE: + HDprintf(" Uncompress all\n"); + break; + case H5Z_FILTER_SHUFFLE: + case H5Z_FILTER_FLETCHER32: + HDprintf(" All with %s\n", get_sfilter(filtn)); + break; + case H5Z_FILTER_SZIP: + case H5Z_FILTER_DEFLATE: + HDprintf(" All with %s, parameter %d\n", get_sfilter(filtn), + options->filter_g[k].cd_values[0]); + break; + default: + HDprintf(" User Defined %d\n", filtn); + break; + } /* end switch */ + } /* end for each filter */ + } /* end if options->all_filter == 1 (TODO: meaning) */ else - printf("No all objects to apply filter\n"); - } /* verbose */ + HDprintf("No all objects to apply filter\n"); + } /* end if verbose */ for (i = 0; i < options->op_tbl->nelems; i++) { pack_info_t pack = options->op_tbl->objs[i]; - char* name = pack.path; + char * name = pack.path; for (j = 0; j < pack.nfilters; j++) { if (options->verbose) { - if(pack.filter[j].filtn >= 0) { - if(pack.filter[j].filtn > H5Z_FILTER_SCALEOFFSET) - printf(" <%s> with %s filter %d\n", name, get_sfilter(pack.filter[j].filtn), pack.filter[j].filtn); - else - printf(" <%s> with %s filter\n", name, get_sfilter(pack.filter[j].filtn)); + if (pack.filter[j].filtn >= 0) { + if (pack.filter[j].filtn > H5Z_FILTER_SCALEOFFSET) { + HDprintf(" <%s> with %s filter %d\n", name, get_sfilter(pack.filter[j].filtn), + pack.filter[j].filtn); + } + else { + HDprintf(" <%s> with %s filter\n", name, get_sfilter(pack.filter[j].filtn)); + } } } has_cp = 1; - } /* j */ - } /* i */ + } /* end for each filter */ + } /* end for each object in options table */ if (options->all_filter == 1 && has_cp) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "invalid compression input: 'all' option is present with other objects"); + H5TOOLS_GOTO_ERROR((-1), "invalid compression input: 'all' option is present with other objects"); /*------------------------------------------------------------------------- - * check options for the latest format - *------------------------------------------------------------------------- - */ + * Check options for the latest format + *------------------------------------------------------------------------- + */ if (options->grp_compact < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "invalid maximum number of links to store as header messages"); + H5TOOLS_GOTO_ERROR((-1), "invalid maximum number of links to store as header messages"); if (options->grp_indexed < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "invalid minimum number of links to store in the indexed format"); + H5TOOLS_GOTO_ERROR((-1), "invalid minimum number of links to store in the indexed format"); if (options->grp_indexed > options->grp_compact) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "minimum indexed size is greater than the maximum compact size"); + H5TOOLS_GOTO_ERROR((-1), "minimum indexed size is greater than the maximum compact size"); for (i = 0; i < 8; i++) if (options->msg_size[i] < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "invalid shared message size"); + H5TOOLS_GOTO_ERROR((-1), "invalid shared message size"); - /*-------------------------------------------------------------------------------- - * verify new user userblock options; file name must be present - *--------------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------ + * Verify new user userblock options; file name must be present + *------------------------------------------------------------------------ + */ if (options->ublock_filename != NULL && options->ublock_size == 0) { if (options->verbose) { - printf("Warning: user block size missing for file %s. Assigning a default size of 1024...\n", options->ublock_filename); + HDprintf("Warning: user block size missing for file %s. Assigning a default size of 1024...\n", + options->ublock_filename); options->ublock_size = 1024; } } if (options->ublock_filename == NULL && options->ublock_size != 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file name missing for user block", options->ublock_filename); + H5TOOLS_GOTO_ERROR((-1), "file name missing for user block", options->ublock_filename); - /*-------------------------------------------------------------------------------- - * verify alignment options; threshold is zero default but alignment not - *--------------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------ + * Verify alignment options; threshold is zero default but alignment not + *------------------------------------------------------------------------ + */ if (options->alignment == 0 && options->threshold != 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "alignment for H5Pset_alignment missing"); + H5TOOLS_GOTO_ERROR((-1), "alignment for H5Pset_alignment missing"); done: return ret_value; -} +} /* end check_options() */ /*------------------------------------------------------------------------- * Function: check_objects * - * Purpose: locate all HDF5 objects in the file and compare with user - * supplied list + * Purpose: Locate all HDF5 objects in the file and compare with user-supplied + * list. * * Return: 0, ok, -1 no *------------------------------------------------------------------------- */ -static int check_objects(const char* fname, pack_opt_t *options) { - int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ - hid_t fid = -1; - hid_t did = -1; - hid_t sid = -1; +static int +check_objects(const char *fname, pack_opt_t *options) +{ + hid_t fid = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; unsigned int i; - unsigned int uf; - trav_table_t *travt = NULL; + int ifil; + trav_table_t *travt = NULL; + int ret_value = 0; /* nothing to do */ if (options->op_tbl->nelems == 0) - HGOTO_DONE(0); + H5TOOLS_GOTO_DONE(0); /*------------------------------------------------------------------------- * open the file *------------------------------------------------------------------------- */ if ((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, 0)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5tools_fopen failed <%s>: %s", fname, H5FOPENERROR); + H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fname, H5FOPENERROR); /*------------------------------------------------------------------------- * get the list of objects in the file @@ -734,7 +756,7 @@ static int check_objects(const char* fname, pack_opt_t *options) { /* get the list of objects in the file */ if (h5trav_gettable(fid, travt) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5trav_gettable failed"); + H5TOOLS_GOTO_ERROR((-1), "h5trav_gettable failed"); /*------------------------------------------------------------------------- * compare with user supplied list @@ -742,79 +764,82 @@ static int check_objects(const char* fname, pack_opt_t *options) { */ if (options->verbose) - printf("Opening file. Searching %d objects to modify ...\n", travt->nobjs); + HDprintf("Opening file. Searching %zu objects to modify ...\n", travt->nobjs); for (i = 0; i < options->op_tbl->nelems; i++) { - char* name = options->op_tbl->objs[i].path; + pack_info_t obj = options->op_tbl->objs[i]; + char * name = obj.path; + if (options->verbose) - printf(" <%s>", name); + HDprintf(" <%s>", name); /* the input object names are present in the file and are valid */ if (h5trav_getindext(name, travt) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "%s Could not find <%s> in file <%s>. Exiting...\n", - (options->verbose ? "\n" : ""), name, fname); + H5TOOLS_GOTO_ERROR((-1), "%s Could not find <%s> in file <%s>. Exiting...\n", + (options->verbose ? "\n" : ""), name, fname); if (options->verbose) - printf("...Found\n"); + HDprintf("...Found\n"); - for (uf = 0; uf < options->op_tbl->objs[i].nfilters; uf++) { - if (options->op_tbl->objs[i].filter[uf].filtn < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "invalid filter"); + for (ifil = 0; ifil < obj.nfilters; ifil++) { + if (obj.filter[ifil].filtn < 0) + H5TOOLS_GOTO_ERROR((-1), "invalid filter"); /* check for extra filter conditions */ - switch (options->op_tbl->objs[i].filter[uf].filtn) { - /* chunk size must be smaller than pixels per block */ - case H5Z_FILTER_SZIP: - { - int j; - hsize_t csize = 1; - unsigned ppb = options->op_tbl->objs[i].filter[uf].cd_values[0]; - hsize_t dims[H5S_MAX_RANK]; - int rank; - - if (options->op_tbl->objs[i].chunk.rank > 0) { - rank = options->op_tbl->objs[i].chunk.rank; + switch (obj.filter[ifil].filtn) { + /* chunk size must be smaller than pixels per block */ + case H5Z_FILTER_SZIP: { + int j; + hsize_t csize = 1; + unsigned ppb = obj.filter[ifil].cd_values[0]; + hsize_t dims[H5S_MAX_RANK]; + int rank; + + if (obj.chunk.rank > 0) { + rank = obj.chunk.rank; for (j = 0; j < rank; j++) - csize *= options->op_tbl->objs[i].chunk.chunk_lengths[j]; + csize *= obj.chunk.chunk_lengths[j]; } else { if ((did = H5Dopen2(fid, name, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed"); if ((sid = H5Dget_space(did)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed"); if ((rank = H5Sget_simple_extent_ndims(sid)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_ndims failed"); HDmemset(dims, 0, sizeof dims); if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_dims failed"); for (j = 0; j < rank; j++) csize *= dims[j]; if (H5Sclose(sid) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed"); if (H5Dclose(did) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); } if (csize < ppb) { - printf(" <warning: SZIP settings, chunk size is smaller than pixels per block>\n"); - HGOTO_DONE(0); + HDprintf(" <warning: SZIP settings, chunk size is smaller than pixels per block>\n"); + H5TOOLS_GOTO_DONE(0); } - } + } /* end case SZIP */ break; - default: - break; - } - } /* for uf */ - } /* for i */ + default: + break; + } /* end switch */ + } /* for ifil (each user-defined filter) */ + } /* for i (each object in options traversal table) */ done: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); H5Dclose(did); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; if (travt) trav_table_free(travt); return ret_value; -} +} /* end check_objects() */ /*------------------------------------------------------------------------- * Function: have_request @@ -824,14 +849,15 @@ done: * Return: 1 yes, 0 no *------------------------------------------------------------------------- */ -static int have_request(pack_opt_t *options) { +static int +have_request(pack_opt_t *options) +{ if (options->all_filter || options->all_layout || options->op_tbl->nelems) return 1; return 0; - -} +} /* end have_request() */ /*------------------------------------------------------------------------- * Function: get_sfilter @@ -841,8 +867,9 @@ static int have_request(pack_opt_t *options) { * Return: name of filter, exit on error *------------------------------------------------------------------------- */ - -static const char* get_sfilter(H5Z_filter_t filtn) { +static const char * +get_sfilter(H5Z_filter_t filtn) +{ if (filtn < 0) return NULL; else if (filtn == H5Z_FILTER_NONE) @@ -861,5 +888,4 @@ static const char* get_sfilter(H5Z_filter_t filtn) { return "SOFF"; else return "UD"; -} - +} /* end get_sfilter() */ diff --git a/tools/h5repack/h5repack.h b/tools/h5repack/h5repack.h index 5b7bb0b..254d839 100644 --- a/tools/h5repack/h5repack.h +++ b/tools/h5repack/h5repack.h @@ -6,12 +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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - #ifndef H5REPACK_H__ #define H5REPACK_H__ @@ -19,14 +18,14 @@ #include "hdf5.h" #include "h5trav.h" -#define H5FOPENERROR "unable to open file" -#define PFORMAT "%-7s %-7s %-7s\n" /* chunk info, compression info, name*/ -#define PFORMAT1 "%-7s %-7s %-7s" /* chunk info, compression info, name*/ -#define MAX_NC_NAME 256 /* max length of a name */ -#define MAX_VAR_DIMS 32 /* max per variable dimensions */ -#define FORMAT_OBJ " %-27s %s\n" /* obj type, name */ -#define FORMAT_OBJ_ATTR " %-27s %s\n" /* obj type, name */ -#define MAX_COMPACT_DSIZE 64512 /* max data size for compact layout. -1k for header size */ +#define H5FOPENERROR "unable to open file" +#define PFORMAT "%-7s %-7s %-7s\n" /* chunk info, compression info, name*/ +#define PFORMAT1 "%-7s %-7s %-7s" /* chunk info, compression info, name*/ +#define MAX_NC_NAME 256 /* max length of a name */ +#define MAX_VAR_DIMS 32 /* max per variable dimensions */ +#define FORMAT_OBJ " %-27s %s\n" /* obj type, name */ +#define FORMAT_OBJ_ATTR " %-27s %s\n" /* obj type, name */ +#define MAX_COMPACT_DSIZE 64512 /* max data size for compact layout. -1k for header size */ /*------------------------------------------------------------------------- * data structures for command line options @@ -35,7 +34,7 @@ /* a list of names */ typedef struct { - char obj[MAX_NC_NAME]; + char obj[MAX_NC_NAME]; } obj_list_t; /* @@ -53,16 +52,16 @@ typedef struct { #define CD_VALUES 20 typedef struct { - H5Z_filter_t filtn; /* filter identification number */ - unsigned filt_flag; /* filter definition flag */ - unsigned cd_values[CD_VALUES]; /* filter client data values */ - size_t cd_nelmts; /* filter client number of values */ + H5Z_filter_t filtn; /* filter identification number */ + unsigned filt_flag; /* filter definition flag */ + unsigned cd_values[CD_VALUES]; /* filter client data values */ + size_t cd_nelmts; /* filter client number of values */ } filter_info_t; /* chunk lengths along each dimension and rank */ typedef struct { - hsize_t chunk_lengths[MAX_VAR_DIMS]; - int rank; + hsize_t chunk_lengths[MAX_VAR_DIMS]; + int rank; } chunk_info_t; /* we currently define a maximum value for the filters array, @@ -71,22 +70,21 @@ typedef struct { /* information for one object, contains PATH, CHUNK info and FILTER info */ typedef struct { - char path[MAX_NC_NAME]; /* name of object */ - filter_info_t filter[H5_REPACK_MAX_NFILTERS]; /* filter array */ - int nfilters; /* current number of filters */ - H5D_layout_t layout; /* layout information */ - chunk_info_t chunk; /* chunk information */ - hid_t refobj_id; /* object ID, references */ + char path[MAX_NC_NAME]; /* name of object */ + filter_info_t filter[H5_REPACK_MAX_NFILTERS]; /* filter array */ + int nfilters; /* current number of filters */ + H5D_layout_t layout; /* layout information */ + chunk_info_t chunk; /* chunk information */ + hid_t refobj_id; /* object ID, references */ } pack_info_t; /* store a table of all objects */ typedef struct { - unsigned int size; - unsigned int nelems; - pack_info_t *objs; + unsigned int size; + unsigned int nelems; + pack_info_t *objs; } pack_opttbl_t; - /*------------------------------------------------------------------------- * command line options *------------------------------------------------------------------------- @@ -94,33 +92,32 @@ typedef struct { /* all the above, ready to go to the hrepack call */ typedef struct { - pack_opttbl_t *op_tbl; /*table with all -c and -f options */ - int all_layout; /*apply the layout to all objects */ - int all_filter; /*apply the filter to all objects */ - filter_info_t filter_g[H5_REPACK_MAX_NFILTERS]; /*global filter array for the ALL case */ - int n_filter_g; /*number of global filters */ - chunk_info_t chunk_g; /*global chunk INFO for the ALL case */ - H5D_layout_t layout_g; /*global layout information for the ALL case */ - int verbose; /*verbose mode */ - hsize_t min_comp; /*minimum size to compress, in bytes */ - int use_native; /*use a native type in write */ - int latest; /*pack file with the latest file format */ - int grp_compact; /* Set the maximum number of links to store as header messages in the group */ - int grp_indexed; /* Set the minimum number of links to store in the indexed format */ - int msg_size[8]; /* Minimum size of shared messages: dataspace, - datatype, fill value, filter pipleline, attribute */ - const char *ublock_filename; /* user block file name */ - hsize_t ublock_size; /* user block size */ - hsize_t meta_block_size; /* metadata aggregation block size (for H5Pset_meta_block_size) */ - hsize_t threshold; /* alignment threshold for H5Pset_alignment */ - hsize_t alignment; /* alignment for H5Pset_alignment */ + pack_opttbl_t *op_tbl; /*table with all -c and -f options */ + int all_layout; /*apply the layout to all objects */ + int all_filter; /*apply the filter to all objects */ + filter_info_t filter_g[H5_REPACK_MAX_NFILTERS]; /*global filter array for the ALL case */ + int n_filter_g; /*number of global filters */ + chunk_info_t chunk_g; /*global chunk INFO for the ALL case */ + H5D_layout_t layout_g; /*global layout information for the ALL case */ + int verbose; /*verbose mode */ + hsize_t min_comp; /*minimum size to compress, in bytes */ + int use_native; /*use a native type in write */ + int latest; /*pack file with the latest file format */ + int grp_compact; /* Set the maximum number of links to store as header messages in the group */ + int grp_indexed; /* Set the minimum number of links to store in the indexed format */ + int msg_size[8]; /* Minimum size of shared messages: dataspace, + datatype, fill value, filter pipleline, attribute */ + const char *ublock_filename; /* user block file name */ + hsize_t ublock_size; /* user block size */ + hsize_t meta_block_size; /* metadata aggregation block size (for H5Pset_meta_block_size) */ + hsize_t threshold; /* alignment threshold for H5Pset_alignment */ + hsize_t alignment; /* alignment for H5Pset_alignment */ } pack_opt_t; - typedef struct named_dt_t { - haddr_t addr_in; /* Address of the named dtype in the in file */ - hid_t id_out; /* Open identifier for the dtype in the out file */ - struct named_dt_t *next; /* Next dtype */ + haddr_t addr_in; /* Address of the named dtype in the in file */ + hid_t id_out; /* Open identifier for the dtype in the out file */ + struct named_dt_t *next; /* Next dtype */ } named_dt_t; /*------------------------------------------------------------------------- @@ -132,9 +129,9 @@ typedef struct named_dt_t { extern "C" { #endif -int h5repack(const char* infile, const char* outfile, pack_opt_t *options); -int h5repack_addfilter(const char* str, pack_opt_t *options); -int h5repack_addlayout(const char* str, pack_opt_t *options); +int h5repack(const char *infile, const char *outfile, pack_opt_t *options); +int h5repack_addfilter(const char *str, pack_opt_t *options); +int h5repack_addlayout(const char *str, pack_opt_t *options); int h5repack_init(pack_opt_t *options, int verbose, hbool_t latest); int h5repack_end(pack_opt_t *options); int h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options); @@ -147,36 +144,29 @@ int h5repack_cmp_pl(const char *fname1, const char *fname2); * However copy_attr() may be obsoleted when H5Acopy is available and put back * others to static in h5repack_copy.c. */ -hid_t copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, trav_table_t *travt, pack_opt_t *options); -int named_datatype_free(named_dt_t **named_dt_head_p, int ignore_err); -int copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, - trav_table_t *travt, pack_opt_t *options); +hid_t copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, trav_table_t *travt, + pack_opt_t *options); +int named_datatype_free(named_dt_t **named_dt_head_p, int ignore_err); +int copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_t *travt, + pack_opt_t *options); #ifdef __cplusplus } #endif - - /*------------------------------------------------------------------------- * private functions *------------------------------------------------------------------------- */ - /*------------------------------------------------------------------------- * copy module *------------------------------------------------------------------------- */ -int copy_objects (const char* fnamein, - const char* fnameout, - pack_opt_t *options); +int copy_objects(const char *fnamein, const char *fnameout, pack_opt_t *options); -int do_copy_refobjs(hid_t fidin, - hid_t fidout, - trav_table_t *travt, - pack_opt_t *options); +int do_copy_refobjs(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *options); /*------------------------------------------------------------------------- * filters and verify module @@ -184,56 +174,38 @@ int do_copy_refobjs(hid_t fidin, */ void init_packobject(pack_info_t *obj); - /*------------------------------------------------------------------------- * filters and copy module *------------------------------------------------------------------------- */ -int apply_filters(const char* name, /* object name from traverse list */ - int rank, /* rank of dataset */ - hsize_t *dims, /* dimensions of dataset */ - size_t msize, /* size of type */ - hid_t dcpl_id, /* dataset creation property list */ +int apply_filters(const char *name, /* object name from traverse list */ + int rank, /* rank of dataset */ + hsize_t * dims, /* dimensions of dataset */ + size_t msize, /* size of type */ + hid_t dcpl_id, /* dataset creation property list */ pack_opt_t *options, /* repack options */ - int *has_filter); /* (OUT) object NAME has a filter */ - + int * has_filter); /* (OUT) object NAME has a filter */ /*------------------------------------------------------------------------- * options table *------------------------------------------------------------------------- */ -int options_table_init(pack_opttbl_t **tbl); -int options_table_free(pack_opttbl_t *table); -int options_add_layout(obj_list_t *obj_list, - unsigned n_objs, - pack_info_t *pack, - pack_opttbl_t *table); -int options_add_filter(obj_list_t *obj_list, - unsigned n_objs, - filter_info_t filt, - pack_opttbl_t *table); -pack_info_t* options_get_object(const char *path, - pack_opttbl_t *table); +int options_table_init(pack_opttbl_t **tbl); +int options_table_free(pack_opttbl_t *table); +int options_add_layout(obj_list_t *obj_list, unsigned n_objs, pack_info_t *pack, pack_opttbl_t *table); +int options_add_filter(obj_list_t *obj_list, unsigned n_objs, filter_info_t filt, pack_opttbl_t *table); +pack_info_t *options_get_object(const char *path, pack_opttbl_t *table); /*------------------------------------------------------------------------- * parse functions *------------------------------------------------------------------------- */ -obj_list_t* parse_filter(const char *str, - unsigned *n_objs, - filter_info_t *filt, - pack_opt_t *options, +obj_list_t *parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, pack_opt_t *options, int *is_glb); -obj_list_t* parse_layout(const char *str, - unsigned *n_objs, - pack_info_t *pack, /* info about object */ +obj_list_t *parse_layout(const char *str, unsigned *n_objs, pack_info_t *pack, /* info about object */ pack_opt_t *options); - - - -#endif /* H5REPACK_H__ */ - +#endif /* H5REPACK_H__ */ diff --git a/tools/h5repack/h5repack.sh.in b/tools/h5repack/h5repack.sh.in index 3f5e013..087b509 100644 --- a/tools/h5repack/h5repack.sh.in +++ b/tools/h5repack/h5repack.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. # @@ -101,6 +101,16 @@ $SRC_H5REPACK_TESTFILES/h5repack_refs.h5 $SRC_H5REPACK_TESTFILES/h5repack_shuffle.h5 $SRC_H5REPACK_TESTFILES/h5repack_soffset.h5 $SRC_H5REPACK_TESTFILES/h5repack_szip.h5 +$SRC_H5REPACK_TESTFILES/h5repack_f32le.h5 +$SRC_H5REPACK_TESTFILES/h5repack_f32le_ex.h5 +$SRC_H5REPACK_TESTFILES/h5repack_int32le_1d.h5 +$SRC_H5REPACK_TESTFILES/h5repack_int32le_1d_ex.h5 +$SRC_H5REPACK_TESTFILES/h5repack_int32le_2d.h5 +$SRC_H5REPACK_TESTFILES/h5repack_int32le_2d_ex.h5 +$SRC_H5REPACK_TESTFILES/h5repack_int32le_3d.h5 +$SRC_H5REPACK_TESTFILES/h5repack_int32le_3d_ex.h5 +$SRC_H5REPACK_TESTFILES/h5repack_uint8be.h5 +$SRC_H5REPACK_TESTFILES/h5repack_uint8be_ex.h5 $SRC_H5DIFF_TESTFILES/h5diff_attr1.h5 $SRC_TOOLS_TESTFILES/tfamily00000.h5 $SRC_TOOLS_TESTFILES/tfamily00001.h5 @@ -123,9 +133,18 @@ $SRC_H5REPACK_TESTFILES/ublock.bin $SRC_H5REPACK_TESTFILES/h5repack.info $SRC_H5REPACK_TESTFILES/crtorder.tordergr.h5.ddl $SRC_H5REPACK_TESTFILES/deflate_limit.h5repack_layout.h5.ddl +$SRC_H5REPACK_TESTFILES/h5repack_f32le_ex-0.dat +$SRC_H5REPACK_TESTFILES/h5repack_int32le_1d_ex-0.dat +$SRC_H5REPACK_TESTFILES/h5repack_int32le_1d_ex-1.dat +$SRC_H5REPACK_TESTFILES/h5repack_int32le_2d_ex-0.dat +$SRC_H5REPACK_TESTFILES/h5repack_int32le_3d_ex-0.dat $SRC_H5REPACK_TESTFILES/h5repack_layout.h5.ddl $SRC_H5REPACK_TESTFILES/h5repack_filters.h5-gzip_verbose_filters.tst $SRC_H5REPACK_TESTFILES/h5repack_layout.h5-plugin_test.ddl +$SRC_H5REPACK_TESTFILES/h5repack_uint8be_ex-0.dat +$SRC_H5REPACK_TESTFILES/h5repack_uint8be_ex-1.dat +$SRC_H5REPACK_TESTFILES/h5repack_uint8be_ex-2.dat +$SRC_H5REPACK_TESTFILES/h5repack_uint8be_ex-3.dat $SRC_H5REPACK_TESTFILES/plugin_test.h5repack_layout.h5.tst " @@ -403,8 +422,94 @@ VERIFY_LAYOUT_ALL() rm -f $layoutfile } +# ----------------------------------------------------------------------------- +# Expect h5diff to fail +# ----------------------------------------------------------------------------- +DIFFFAIL() +{ + VERIFY h5diff unequal $@ + ( + cd $TESTDIR + $RUNSERIAL $H5DIFF_BIN -q "$@" + ) + RET=$? + if [ $RET -eq 0 ] ; then + echo "*FAILED*" + nerrors="`expr $nerrors + 1`" + else + echo " PASSED" + fi +} + +# ----------------------------------------------------------------------------- +# Catchall test for repacking with external files +# Loops over all (internally-listed) cases and applies the given arguments +# to h5repack. +# Each test file family must be listed in the for loop at the start of the +# 'function'. +# Expects case files to be of format: +# + h5repack_<NAME>.h5 +# + h5repack_<NAME>_ex.h5 +# + h5repack_<NAME>_ex-<N>.dat +# ...where NAME is part of the internal list, and N is a positive decimal +# number; multiple external files (*.dat) are allowed per file, but they must +# follow the pattern and be in contiguous numerical sequence starting at 0. +# ----------------------------------------------------------------------------- +VERIFY_EXTERNAL_CONSOLIDATION() +{ + for name in f32le int32le_1d int32le_2d int32le_3d uint8be + do + basename="h5repack_${name}" + base_ext="${basename}_ex" + base_rpkg="${basename}_rp" + canonical="${basename}.h5" + external="${base_ext}.h5" + ex_dat="${base_ext}-0.dat" + ex_dat_mv="__${ext_dat}" + repacked="${base_rpkg}.h5" + prev_nerrors=$nerrors + + TESTING external consolidation on $name with h5repack $@ + echo " . . ." + + # baseline comparison of known files + DIFFTEST $canonical $external + + # repack the external file, verify integrity + ( cd $TESTDIR + $H5REPACK_BIN $@ $external $repacked + ) + DIFFTEST $repacked $canonical + DIFFTEST $repacked $external + + # invalidate external file by moving its first data file; verify + ( cd $TESTDIR + mv $ex_dat $ex_dat_mv + ) + DIFFFAIL $canonical $external + DIFFFAIL $repacked $external + DIFFTEST $canonical $repacked + + # reset test state for re-runs with different h5repack arguments + ( cd $TESTDIR + mv $ex_dat_mv $ex_dat + rm $repacked + ) + + # flag if any of the above checks failed + if [ $prev_nerrors != $nerrors ] + then + echo ". . . *FAILED*" + nerrors="`expr $prev_nerrors + 1`" + else + echo ". . . PASSED" + fi + done +} # end VERIFY_EXTERNAL_CONSOLIDATION + +# ----------------------------------------------------------------------------- # same as TOOLTEST, but it uses the old syntax -i input_file -o output_file -# +# ----------------------------------------------------------------------------- TOOLTEST0() { infile=$2 @@ -695,6 +800,7 @@ fi ############################################################################## ### T H E T E S T S ############################################################################## + # prepare for test COPY_TESTFILES_TO_TESTDIR @@ -1046,7 +1152,12 @@ TOOLTEST add_alignment $arg TOOLTEST upgrade_layout h5repack_layouto.h5 # test for datum size > H5TOOLS_MALLOCSIZE -TOOLTEST gt_mallocsize h5repack_objs.h5 -f GZIP=1 +arg="h5repack_objs.h5 -f GZIP=1" +if test $USE_FILTER_DEFLATE != "yes" ; then + SKIP $arg +else + TOOLTEST gt_mallocsize $arg +fi # Check repacking file with committed datatypes in odd configurations TOOLTEST committed_dt h5repack_named_dtypes.h5 @@ -1072,6 +1183,11 @@ TOOLTEST HDFFV-7840 h5diff_attr1.h5 TOOLTEST_META meta_short h5repack_layout.h5 -M 8192 TOOLTEST_META meta_long h5repack_layout.h5 --metadata_block_size=8192 +######################################## +# Testing external storage +######################################## +VERIFY_EXTERNAL_CONSOLIDATION -l CONTI + # Clean up temporary files/directories CLEAN_TESTFILES_AND_TESTDIR diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c index a4f8f5b..7ee6399 100644 --- a/tools/h5repack/h5repack_copy.c +++ b/tools/h5repack/h5repack_copy.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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -31,42 +31,45 @@ */ /* size of buffer/# of bytes to xfer at a time when copying userblock */ -#define USERBLOCK_XFER_SIZE 512 +#define USERBLOCK_XFER_SIZE 512 /* check H5Dread()/H5Dwrite() error, e.g. memory allocation error inside the library. */ -#define CHECK_H5DRW_ERROR(_fun, _fail, _did, _mtid, _msid, _fsid, _pid, _buf) { \ - H5E_BEGIN_TRY { \ - if(_fun(_did, _mtid, _msid, _fsid, _pid, _buf) < 0) { \ - hid_t _err_num = 0; \ - char _msg[80]; \ - H5Ewalk2(H5E_DEFAULT, H5E_WALK_DOWNWARD, walk_error_callback, &_err_num); \ - H5Eget_msg(_err_num, NULL, _msg, (size_t)80); \ - error_msg("%s %s -- %s\n", #_fun, "failed", _msg); \ - HGOTO_DONE(_fail) \ - } \ - } H5E_END_TRY; \ -} +#define CHECK_H5DRW_ERROR(_fun, _fail, _did, _mtid, _msid, _fsid, _pid, _buf) \ + { \ + H5E_BEGIN_TRY \ + { \ + if (_fun(_did, _mtid, _msid, _fsid, _pid, _buf) < 0) { \ + hid_t _err_num = 0; \ + char _msg[80]; \ + H5Ewalk2(H5E_DEFAULT, H5E_WALK_DOWNWARD, walk_error_callback, &_err_num); \ + H5Eget_msg(_err_num, NULL, _msg, (size_t)80); \ + error_msg("%s %s -- %s\n", #_fun, "failed", _msg); \ + HGOTO_DONE(_fail) \ + } \ + } \ + H5E_END_TRY; \ + } /*------------------------------------------------------------------------- * local functions *------------------------------------------------------------------------- */ -static int Get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[], - size_t size_datum, hsize_t dims_hslab[], hsize_t * hslab_nbytes_p); +static int get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[], size_t size_datum, + hsize_t dims_hslab[], hsize_t *hslab_nbytes_p); static void print_dataset_info(hid_t dcpl_id, char *objname, double per, int pr); -static int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, - pack_opt_t *options); -static int copy_user_block(const char *infile, const char *outfile, - hsize_t size); -#if defined (H5REPACK_DEBUG_USER_BLOCK) +static int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *options); +static int copy_user_block(const char *infile, const char *outfile, hsize_t size); +#if defined(H5REPACK_DEBUG_USER_BLOCK) static void print_user_block(const char *filename, hid_t fid); #endif static herr_t walk_error_callback(unsigned n, const H5E_error2_t *err_desc, void *udata); /* get the major number from the error stack. */ -static herr_t walk_error_callback(H5_ATTR_UNUSED unsigned n, const H5E_error2_t *err_desc, void *udata) { +static herr_t +walk_error_callback(H5_ATTR_UNUSED unsigned n, const H5E_error2_t *err_desc, void *udata) +{ if (err_desc) - *((hid_t *) udata) = err_desc->maj_num; + *((hid_t *)udata) = err_desc->maj_num; return 0; } @@ -80,70 +83,80 @@ static herr_t walk_error_callback(H5_ATTR_UNUSED unsigned n, const H5E_error2_t * -1 no *------------------------------------------------------------------------- */ - -int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) +int +copy_objects(const char *fnamein, const char *fnameout, pack_opt_t *options) { + hid_t fidin = H5I_INVALID_HID; + hid_t fidout = H5I_INVALID_HID; + hid_t fcpl_in = H5I_INVALID_HID; /* file creation property list ID for input file */ + hid_t grp_in = H5I_INVALID_HID; /* group ID */ + hid_t gcpl_in = H5I_INVALID_HID; /* group creation property list */ + hid_t fcpl = H5P_DEFAULT; /* file creation property list ID */ + hid_t fapl = H5P_DEFAULT; /* file access property list ID */ + trav_table_t *travt = NULL; + hsize_t ub_size = 0; /* size of user block */ + unsigned crt_order_flags; /* group creation order flag */ int ret_value = 0; - hid_t fidin = -1; - hid_t fidout = -1; - hid_t fcpl_in = -1; /* file creation property list ID for input file */ - hid_t grp_in = -1; /* group ID */ - hid_t gcpl_in = -1; /* group creation property list */ - hid_t fcpl = H5P_DEFAULT; /* file creation property list ID */ - hid_t fapl = H5P_DEFAULT; /* file access property list ID */ - trav_table_t *travt = NULL; - hsize_t ub_size = 0; /* size of user block */ - unsigned crt_order_flags; /* group creation order flag */ /*------------------------------------------------------------------------- * open input file *------------------------------------------------------------------------- */ - if ((fidin = h5tools_fopen(fnamein, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t) 0)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5tools_fopen failed <%s>: %s", fnamein, H5FOPENERROR); + if ((fidin = h5tools_fopen(fnamein, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0) + H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fnamein, H5FOPENERROR); /* get user block size and file space strategy/threshold */ { if ((fcpl_in = H5Fget_create_plist(fidin)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fget_create_plist failed to retrieve file creation property list"); + H5TOOLS_GOTO_ERROR((-1), "H5Fget_create_plist failed to retrieve file creation property list"); if (H5Pget_userblock(fcpl_in, &ub_size) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_userblock failed to retrieve userblock size"); + H5TOOLS_GOTO_ERROR((-1), "H5Pget_userblock failed to retrieve userblock size"); /* open root group */ if ((grp_in = H5Gopen2(fidin, "/", H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gopen2 failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Gopen2 failed"); /* get root group creation property list */ if ((gcpl_in = H5Gget_create_plist(grp_in)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gget_create_plist failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Gget_create_plist failed"); /* query and set the group creation properties */ if (H5Pget_link_creation_order(gcpl_in, &crt_order_flags) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_link_creation_order failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pget_link_creation_order failed"); if (H5Pclose(fcpl_in) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed to close property list"); + H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed to close property list"); } + /* Create file access property list */ + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed to create file access property list"); + + if (options->latest) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pset_libver_bounds failed to set format version bounds"); + /* Check if we need to create a non-default file creation property list */ if (options->latest || ub_size > 0) { /* Create file creation property list */ if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed to create a file creation property list"); + H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed to create a file creation property list"); if (ub_size > 0) if (H5Pset_userblock(fcpl, ub_size) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_userblock failed to set non-default userblock size"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_userblock failed to set non-default userblock size"); if (options->latest) { unsigned i = 0, nindex = 0, mesg_type_flags[5], min_mesg_sizes[5]; /* Adjust group creation parameters for root group */ /* (So that it is created in "dense storage" form) */ - if (H5Pset_link_phase_change(fcpl, (unsigned) options->grp_compact, - (unsigned) options->grp_indexed) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_link_phase_change failed to adjust group creation parameters for root group"); + if (H5Pset_link_phase_change(fcpl, (unsigned)options->grp_compact, + (unsigned)options->grp_indexed) < 0) + H5TOOLS_GOTO_ERROR( + (-1), + "H5Pset_link_phase_change failed to adjust group creation parameters for root group"); for (i = 0; i < 5; i++) { if (options->msg_size[i] > 0) { @@ -171,32 +184,28 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) default: break; } /* end switch */ - min_mesg_sizes[nindex] = (unsigned) options->msg_size[i]; + min_mesg_sizes[nindex] = (unsigned)options->msg_size[i]; nindex++; } /* end if */ - } /* end for */ + } /* end for */ if (nindex > 0) { if (H5Pset_shared_mesg_nindexes(fcpl, nindex) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_shared_mesg_nindexes failed to set the number of shared object header message indexes"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_shared_mesg_nindexes failed to set the number of shared " + "object header message indexes"); /* msg_size[0]=dataspace, 1=datatype, 2=file value, 3=filter pipleline, 4=attribute */ for (i = 0; i < (nindex - 1); i++) if (H5Pset_shared_mesg_index(fcpl, i, mesg_type_flags[i], min_mesg_sizes[i]) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_shared_mesg_index failed to configure the specified shared object header message index"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_shared_mesg_index failed to configure the specified " + "shared object header message index"); } /* if (nindex>0) */ - /* Create file access property list */ - if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed to create file access property list"); - - if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_libver_bounds failed to set property for using latest version of the format"); } /* end if */ - } /* end if */ -#if defined (H5REPACK_DEBUG_USER_BLOCK) -print_user_block(fnamein, fidin); + } /* end if */ +#if defined(H5REPACK_DEBUG_USER_BLOCK) + print_user_block(fnamein, fidin); #endif /*------------------------------------------------------------------------- @@ -208,11 +217,11 @@ print_user_block(fnamein, fidin); if (fcpl == H5P_DEFAULT) /* create a file creation property list */ if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed to create a file creation property list"); + H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed to create a file creation property list"); /* set user block size */ if (H5Pset_userblock(fcpl, options->ublock_size) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_userblock failed to set userblock size"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_userblock failed to set userblock size"); } /*------------------------------------------------------------------------- @@ -224,10 +233,10 @@ print_user_block(fnamein, fidin); if (fapl == H5P_DEFAULT) /* create a file access property list */ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed to create file access property list"); + H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed to create file access property list"); if (H5Pset_alignment(fapl, options->threshold, options->alignment) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_alignment failed to set alignment"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_alignment failed to set alignment"); } /*------------------------------------------------------------------------- @@ -239,10 +248,10 @@ print_user_block(fnamein, fidin); if (fapl == H5P_DEFAULT) /* create a file access property list */ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed to create file access property list"); + H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed to create file access property list"); if (H5Pset_meta_block_size(fapl, options->meta_block_size) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_meta_block_size failed to set metadata block size"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_meta_block_size failed to set metadata block size"); } /*------------------------------------------------------------------------- @@ -254,20 +263,20 @@ print_user_block(fnamein, fidin); if (fcpl == H5P_DEFAULT) /* create a file creation property list */ if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed to create a file creation property list"); + H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed to create a file creation property list"); - if(H5Pset_link_creation_order(fcpl, crt_order_flags ) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_link_creation_order failed"); + if (H5Pset_link_creation_order(fcpl, crt_order_flags) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pset_link_creation_order failed"); /*------------------------------------------------------------------------- * create the output file *------------------------------------------------------------------------- */ if (options->verbose) - printf("Making new file ...\n"); + HDprintf("Making new file ...\n"); if ((fidout = H5Fcreate(fnameout, H5F_ACC_TRUNC, fcpl, fapl)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fcreate could not create file <%s>:", fnameout); + H5TOOLS_GOTO_ERROR((-1), "H5Fcreate could not create file <%s>:", fnameout); /*------------------------------------------------------------------------- * write a new user block if requested @@ -275,7 +284,7 @@ print_user_block(fnamein, fidin); */ if (options->ublock_size > 0) if (copy_user_block(options->ublock_filename, fnameout, options->ublock_size) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not copy user block. Exiting..."); + H5TOOLS_GOTO_ERROR((-1), "Could not copy user block. Exiting..."); /*------------------------------------------------------------------------- * get list of objects @@ -290,22 +299,24 @@ print_user_block(fnamein, fidin); if (travt) { /* get the list of objects in the file */ if (h5trav_gettable(fidin, travt) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5trav_gettable failed"); + H5TOOLS_GOTO_ERROR((-1), "h5trav_gettable failed"); /*------------------------------------------------------------------------- - * do the copy - *------------------------------------------------------------------------- - */ + * do the copy + *------------------------------------------------------------------------- + */ if (do_copy_objects(fidin, fidout, travt, options) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "do_copy_objects from <%s> could not copy data to <%s>", fnamein, fnameout); + H5TOOLS_GOTO_ERROR((-1), "do_copy_objects from <%s> could not copy data to <%s>", fnamein, + fnameout); /*------------------------------------------------------------------------- - * do the copy of referenced objects - * and create hard links - *------------------------------------------------------------------------- - */ + * do the copy of referenced objects + * and create hard links + *------------------------------------------------------------------------- + */ if (do_copy_refobjs(fidin, fidout, travt, options) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "do_copy_refobjs from <%s> could not copy data to <%s>", fnamein, fnameout); + H5TOOLS_GOTO_ERROR((-1), "do_copy_refobjs from <%s> could not copy data to <%s>", fnamein, + fnameout); } /*------------------------------------------------------------------------- @@ -315,10 +326,11 @@ print_user_block(fnamein, fidin); if (ub_size > 0 && options->ublock_size == 0) if (copy_user_block(fnamein, fnameout, ub_size) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not copy user block. Exiting..."); + H5TOOLS_GOTO_ERROR((-1), "Could not copy user block. Exiting..."); done: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fcpl_in); H5Pclose(gcpl_in); H5Pclose(fapl); @@ -328,15 +340,16 @@ done: H5Fclose(fidout); H5Fclose(fidin); H5Fclose(fidout); - } H5E_END_TRY; + } + H5E_END_TRY; if (travt) trav_table_free(travt); return ret_value; -} +} /* end copy_objects() */ /*------------------------------------------------------------------------- - * Function: Get_hyperslab + * Function: get_hyperslab * * Purpose: Calulate a hyperslab from a dataset for higher performance. * The size of hyperslab is limitted by H5TOOLS_BUFSIZE. @@ -368,20 +381,20 @@ done: *-----------------------------------------*/ int -Get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[], - size_t size_datum, hsize_t dims_hslab[], hsize_t * hslab_nbytes_p) +get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[], size_t size_datum, hsize_t dims_hslab[], + hsize_t *hslab_nbytes_p) { - int ret_value = 0; - int k; + int k; H5D_layout_t dset_layout; - int rank_chunk; - hsize_t dims_chunk[H5S_MAX_RANK]; - hsize_t size_chunk = 1; - hsize_t nchunk_fit; /* number of chunks that fits in hyperslab buffer (H5TOOLS_BUFSIZE) */ - hsize_t ndatum_fit; /* number of dataum that fits in hyperslab buffer (H5TOOLS_BUFSIZE) */ - hsize_t chunk_dims_map[H5S_MAX_RANK]; /* mapped chunk dimentions */ - hsize_t hs_dims_map[H5S_MAX_RANK]; /* mapped hyperslab dimentions */ - hsize_t hslab_nbytes; /* size of hyperslab in byte */ + int rank_chunk; + hsize_t dims_chunk[H5S_MAX_RANK]; + hsize_t size_chunk = 1; + hsize_t nchunk_fit; /* number of chunks that fits in hyperslab buffer (H5TOOLS_BUFSIZE) */ + hsize_t ndatum_fit; /* number of dataum that fits in hyperslab buffer (H5TOOLS_BUFSIZE) */ + hsize_t chunk_dims_map[H5S_MAX_RANK]; /* mapped chunk dimentions */ + hsize_t hs_dims_map[H5S_MAX_RANK]; /* mapped hyperslab dimentions */ + hsize_t hslab_nbytes; /* size of hyperslab in byte */ + int ret_value = 0; /* init to set as size of a data element */ hslab_nbytes = size_datum; @@ -394,7 +407,7 @@ Get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[], /* get chunk dims */ rank_chunk = H5Pget_chunk(dcpl_id, rank_dset, dims_chunk); if (rank_chunk < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_chunk failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pget_chunk failed"); for (k = rank_dset; k > 0; --k) size_chunk *= dims_chunk[k - 1]; @@ -420,7 +433,7 @@ Get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[], chunk_dims_map[k - 1]++; /* get mapped hyperslab dims */ - hs_dims_map[k - 1] = MIN (nchunk_fit, chunk_dims_map[k-1]); + hs_dims_map[k - 1] = MIN(nchunk_fit, chunk_dims_map[k - 1]); /* prepare next round */ nchunk_fit = nchunk_fit / chunk_dims_map[k - 1]; @@ -429,7 +442,7 @@ Get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[], nchunk_fit = 1; /* get hyperslab dimentions as unmapping to actual size */ - dims_hslab[k - 1] = MIN( (hs_dims_map[k-1] * dims_chunk[k-1]), dims_dset[k-1]); + dims_hslab[k - 1] = MIN((hs_dims_map[k - 1] * dims_chunk[k - 1]), dims_dset[k - 1]); /* calculate total size for the hyperslab */ hslab_nbytes *= dims_hslab[k - 1]; @@ -450,13 +463,13 @@ Get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[], if (ndatum_fit == 0) ndatum_fit = 1; /* get hyperslab dimentions within a chunk boundary */ - dims_hslab[k - 1] = MIN (dims_chunk[k-1], ndatum_fit); + dims_hslab[k - 1] = MIN(dims_chunk[k - 1], ndatum_fit); /* calculate total size for the hyperslab */ hslab_nbytes *= dims_hslab[k - 1]; if (hslab_nbytes <= 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "calculate total size for the hyperslab failed"); + H5TOOLS_GOTO_ERROR((-1), "calculate total size for the hyperslab failed"); } } } @@ -480,7 +493,7 @@ Get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[], hslab_nbytes *= dims_hslab[k - 1]; if (hslab_nbytes <= 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "calculate total size for the hyperslab failed"); + H5TOOLS_GOTO_ERROR((-1), "calculate total size for the hyperslab failed"); } } @@ -489,7 +502,7 @@ Get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[], done: return ret_value; -} +} /* end get_hyperslab() */ /*------------------------------------------------------------------------- * Function: do_copy_objects @@ -537,7 +550,7 @@ done: * in (2) is that, when using the strip mine size, it assures that the "remaining" part * of the dataset that does not fill an entire strip mine is processed. * - * 1. figure out a hyperslab (dimentions) and size (refer to Get_hyperslab()). + * 1. figure out a hyperslab (dimentions) and size (refer to get_hyperslab()). * 2. Calculate the hyperslab selections as the selection is moving forward. * Selection would be same as the hyperslab except for the remaining edge portion * of the dataset. The code take care of the remaining portion if exist. @@ -545,46 +558,46 @@ done: *------------------------------------------------------------------------- */ -int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, - pack_opt_t *options) /* repack options */ +int +do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *options) /* repack options */ { - int ret_value = 0; - hid_t grp_in = -1; /* group ID */ - hid_t grp_out = -1; /* group ID */ - hid_t dset_in = -1; /* read dataset ID */ - hid_t dset_out = -1; /* write dataset ID */ - hid_t gcpl_in = -1; /* group creation property list */ - hid_t gcpl_out = -1; /* group creation property list */ - hid_t type_in = -1; /* named type ID */ - hid_t type_out = -1; /* named type ID */ - hid_t dcpl_in = -1; /* dataset creation property list ID */ - hid_t dcpl_out = -1; /* dataset creation property list ID */ - hid_t f_space_id = -1; /* file space ID */ - hid_t ftype_id = -1; /* file type ID */ - hid_t wtype_id = -1; /* read/write type ID */ - named_dt_t *named_dt_head = NULL; /* Pointer to the stack of named datatypes copied */ - size_t msize; /* size of type */ - hsize_t nelmts; /* number of elements in dataset */ - H5D_space_status_t space_status; /* determines whether space has been allocated for the dataset */ - int rank; /* rank of dataset */ - hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */ - hsize_t dsize_in; /* input dataset size before filter */ - hsize_t dsize_out; /* output dataset size after filter */ - int apply_s; /* flag for apply filter to small dataset sizes */ - int apply_f; /* flag for apply filter to return error on H5Dcreate */ - void *buf = NULL; /* buffer for raw data */ - void *hslab_buf = NULL; /* hyperslab buffer for raw data */ - int has_filter; /* current object has a filter */ - int req_filter; /* there was a request for a filter */ - int req_obj_layout = 0; /* request layout to current object */ - unsigned crt_order_flags; /* group creation order flag */ - unsigned i; - unsigned u; - unsigned uf; - int is_ref = 0; - htri_t is_named; - hbool_t limit_maxdims; - hsize_t size_dset; + hid_t grp_in = H5I_INVALID_HID; /* group ID */ + hid_t grp_out = H5I_INVALID_HID; /* group ID */ + hid_t dset_in = H5I_INVALID_HID; /* read dataset ID */ + hid_t dset_out = H5I_INVALID_HID; /* write dataset ID */ + hid_t gcpl_in = H5I_INVALID_HID; /* group creation property list */ + hid_t gcpl_out = H5I_INVALID_HID; /* group creation property list */ + hid_t type_in = H5I_INVALID_HID; /* named type ID */ + hid_t type_out = H5I_INVALID_HID; /* named type ID */ + hid_t dcpl_in = H5I_INVALID_HID; /* dataset creation property list ID */ + hid_t dcpl_out = H5I_INVALID_HID; /* dataset creation property list ID */ + hid_t f_space_id = H5I_INVALID_HID; /* file space ID */ + hid_t ftype_id = H5I_INVALID_HID; /* file type ID */ + hid_t wtype_id = H5I_INVALID_HID; /* read/write type ID */ + named_dt_t * named_dt_head = NULL; /* Pointer to the stack of named datatypes copied */ + size_t msize; /* size of type */ + hsize_t nelmts; /* number of elements in dataset */ + H5D_space_status_t space_status; /* determines whether space has been allocated for the dataset */ + int rank; /* rank of dataset */ + hsize_t dims[H5S_MAX_RANK]; /* dimensions of dataset */ + hsize_t dsize_in; /* input dataset size before filter */ + hsize_t dsize_out; /* output dataset size after filter */ + int apply_s; /* flag for apply filter to small dataset sizes */ + int apply_f; /* flag for apply filter to return error on H5Dcreate */ + void * buf = NULL; /* buffer for raw data */ + void * hslab_buf = NULL; /* hyperslab buffer for raw data */ + int has_filter; /* current object has a filter */ + int req_filter; /* there was a request for a filter */ + int req_obj_layout = 0; /* request layout to current object */ + unsigned crt_order_flags; /* group creation order flag */ + unsigned i; + unsigned u; + int ifil; + int is_ref = 0; + htri_t is_named; + hbool_t limit_maxdims; + hsize_t size_dset; + int ret_value = 0; /*------------------------------------------------------------------------- * copy the supplied object list @@ -592,573 +605,611 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, */ if (options->verbose) { - printf("-----------------------------------------\n"); - printf(" Type Filter (Compression) Name\n"); - printf("-----------------------------------------\n"); + HDprintf("-----------------------------------------\n"); + HDprintf(" Type Filter (Compression) Name\n"); + HDprintf("-----------------------------------------\n"); } if (travt->objs) { for (i = 0; i < travt->nobjs; i++) { /* init variables per obj */ - buf = NULL; + buf = NULL; limit_maxdims = FALSE; switch (travt->objs[i].type) { - case H5TRAV_TYPE_UNKNOWN: - break; + case H5TRAV_TYPE_UNKNOWN: + break; - /*------------------------------------------------------------------------- - * H5TRAV_TYPE_GROUP - *------------------------------------------------------------------------- - */ - case H5TRAV_TYPE_GROUP: - if (options->verbose) - printf(FORMAT_OBJ, "group", travt->objs[i].name); + /*------------------------------------------------------------------------- + * H5TRAV_TYPE_GROUP + *------------------------------------------------------------------------- + */ + case H5TRAV_TYPE_GROUP: + if (options->verbose) + HDprintf(FORMAT_OBJ, "group", travt->objs[i].name); - /* open input group */ - if ((grp_in = H5Gopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gopen2 failed"); + /* open input group */ + if ((grp_in = H5Gopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Gopen2 failed"); - /* get input group creation property list */ - if ((gcpl_in = H5Gget_create_plist(grp_in)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gget_create_plist failed"); + /* get input group creation property list */ + if ((gcpl_in = H5Gget_create_plist(grp_in)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Gget_create_plist failed"); - /* query and set the group creation properties */ - if (H5Pget_link_creation_order(gcpl_in, &crt_order_flags) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_link_creation_order failed"); + /* query and set the group creation properties */ + if (H5Pget_link_creation_order(gcpl_in, &crt_order_flags) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pget_link_creation_order failed"); - /* set up group creation property list */ - if ((gcpl_out = H5Pcreate(H5P_GROUP_CREATE)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed"); + /* set up group creation property list */ + if ((gcpl_out = H5Pcreate(H5P_GROUP_CREATE)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed"); - if (H5Pset_link_creation_order(gcpl_out, crt_order_flags) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_link_creation_order failed"); + if (H5Pset_link_creation_order(gcpl_out, crt_order_flags) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pset_link_creation_order failed"); - /*------------------------------------------------------------------------- - * the root is a special case, we get an ID for the root group - * and copy its attributes using that ID - *------------------------------------------------------------------------- - */ - if (HDstrcmp(travt->objs[i].name, "/") == 0) { - if ((grp_out = H5Gopen2(fidout, "/", H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gopen2 failed"); - } - else { - if (options->grp_compact > 0 || options->grp_indexed > 0) - if (H5Pset_link_phase_change(gcpl_out, (unsigned) options->grp_compact, (unsigned) options->grp_indexed) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_link_phase_change failed"); + /*------------------------------------------------------------------------- + * the root is a special case, we get an ID for the root group + * and copy its attributes using that ID + *------------------------------------------------------------------------- + */ + if (HDstrcmp(travt->objs[i].name, "/") == 0) { + if ((grp_out = H5Gopen2(fidout, "/", H5P_DEFAULT)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Gopen2 failed"); + } + else { + if (options->grp_compact > 0 || options->grp_indexed > 0) + if (H5Pset_link_phase_change(gcpl_out, (unsigned)options->grp_compact, + (unsigned)options->grp_indexed) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pset_link_phase_change failed"); + + if ((grp_out = H5Gcreate2(fidout, travt->objs[i].name, H5P_DEFAULT, gcpl_out, + H5P_DEFAULT)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Gcreate2 failed"); + } - if ((grp_out = H5Gcreate2(fidout, travt->objs[i].name, H5P_DEFAULT, gcpl_out, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gcreate2 failed"); - } + /*------------------------------------------------------------------------- + * copy attrs + *------------------------------------------------------------------------- + */ + if (copy_attr(grp_in, grp_out, &named_dt_head, travt, options) < 0) + H5TOOLS_GOTO_ERROR((-1), "copy_attr failed"); - /*------------------------------------------------------------------------- - * copy attrs - *------------------------------------------------------------------------- - */ - if (copy_attr(grp_in, grp_out, &named_dt_head, travt, options) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_attr failed"); - - if (H5Pclose(gcpl_out) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); - if (H5Pclose(gcpl_in) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); - if (H5Gclose(grp_out) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed"); - if (H5Gclose(grp_in) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed"); + if (H5Pclose(gcpl_out) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); + if (H5Pclose(gcpl_in) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); + if (H5Gclose(grp_out) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Gclose failed"); + if (H5Gclose(grp_in) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Gclose failed"); - break; + break; /*------------------------------------------------------------------------- * H5TRAV_TYPE_DATASET *------------------------------------------------------------------------- */ - case H5TRAV_TYPE_DATASET: - has_filter = 0; - req_filter = 0; - - /* check if global filters were requested */ - if (options->n_filter_g) - req_filter = 1; - - /* check if filters were requested for individual objects */ - if (options->op_tbl->objs) { - for (u = 0; u < options->op_tbl->nelems; u++) { - if (HDstrcmp(travt->objs[i].name, options->op_tbl->objs[u].path) == 0) - for (uf = 0; uf < options->op_tbl->objs[uf].nfilters; uf++) { - if (options->op_tbl->objs[u].filter[uf].filtn > 0) - req_filter = 1; - } + case H5TRAV_TYPE_DATASET: { + hbool_t use_h5ocopy; + + has_filter = 0; + req_filter = 0; + + /* check if global filters were requested */ + if (options->n_filter_g) + req_filter = 1; + + /* check if filters were requested for individual objects */ + if (options->op_tbl->objs) { + for (u = 0; u < options->op_tbl->nelems; u++) { + if (HDstrcmp(travt->objs[i].name, options->op_tbl->objs[u].path) == 0) + for (ifil = 0; ifil < options->op_tbl->objs[ifil].nfilters; ifil++) { + if (options->op_tbl->objs[u].filter[ifil].filtn > 0) + req_filter = 1; + } + } } - } - /* check if layout change requested individual object */ - if (options->layout_g != H5D_LAYOUT_ERROR) { - pack_info_t *pckinfo; - - /* any dataset is specified */ - if (options->op_tbl->nelems > 0) { - /* check if object exist */ - pckinfo = options_get_object(travt->objs[i].name, options->op_tbl); - if (pckinfo) - req_obj_layout = 1; + /* check if layout change requested individual object */ + if (options->layout_g != H5D_LAYOUT_ERROR) { + pack_info_t *pckinfo; + + /* any dataset is specified */ + if (options->op_tbl->nelems > 0) { + /* check if object exist */ + pckinfo = options_get_object(travt->objs[i].name, options->op_tbl); + if (pckinfo) + req_obj_layout = 1; + } } - } - - /* early detection of references */ - if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed"); - if ((ftype_id = H5Dget_type(dset_in)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_type failed"); - if (H5T_REFERENCE == H5Tget_class(ftype_id)) - is_ref = 1; - - /* Check if the datatype is committed */ - if ((is_named = H5Tcommitted(ftype_id)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tcommitted failed"); - if (is_named) - if ((wtype_id = copy_named_datatype(ftype_id, fidout, &named_dt_head, travt, options)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_named_datatype failed"); - - if (H5Tclose(ftype_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); - if (H5Dclose(dset_in) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed"); - - /*------------------------------------------------------------------------- - * check if we should use H5Ocopy or not - * if there is a request for filters/layout, we read/write the object - * otherwise we do a copy using H5Ocopy - *------------------------------------------------------------------------- - */ - if (options->op_tbl->nelems || options->all_filter == 1 - || options->all_layout == 1 || is_ref || is_named) { - - int j; + /* early detection of references */ if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed"); - if ((f_space_id = H5Dget_space(dset_in)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed"); if ((ftype_id = H5Dget_type(dset_in)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_type failed"); - if ((dcpl_in = H5Dget_create_plist(dset_in)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed"); - if ((dcpl_out = H5Pcopy(dcpl_in)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcopy failed"); - if ((rank = H5Sget_simple_extent_ndims(f_space_id)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed"); - HDmemset(dims, 0, sizeof dims); - if (H5Sget_simple_extent_dims(f_space_id, dims, NULL) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed"); - if (H5Dget_space_status(dset_in, &space_status) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space_status failed"); - - nelmts = 1; - for (j = 0; j < rank; j++) - nelmts *= dims[j]; - - /* wtype_id will have already been set if using a named dtype */ - if (!is_named) { - if (options->use_native == 1) - wtype_id = H5Tget_native_type(ftype_id, H5T_DIR_DEFAULT); - else - wtype_id = H5Tcopy(ftype_id); - } /* end if */ - - if ((msize = H5Tget_size(wtype_id)) == 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed"); - - /* size of current dset */ - size_dset = nelmts * msize; + H5TOOLS_GOTO_ERROR((-1), "H5Dget_type failed"); + if (H5T_REFERENCE == H5Tget_class(ftype_id)) + is_ref = 1; + + /* Check if the datatype is committed */ + if ((is_named = H5Tcommitted(ftype_id)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Tcommitted failed"); + if (is_named) + if ((wtype_id = + copy_named_datatype(ftype_id, fidout, &named_dt_head, travt, options)) < 0) + H5TOOLS_GOTO_ERROR((-1), "copy_named_datatype failed"); + + if (H5Tclose(ftype_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); + if (H5Dclose(dset_in) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); /*------------------------------------------------------------------------- - * check if the dataset creation property list has filters that - * are not registered in the current configuration - * 1) the external filters GZIP and SZIP might not be available - * 2) the internal filters might be turned off + * check if we should use H5Ocopy or not + * if there is a request for filters/layout, we read/write the object + * otherwise we do a copy using H5Ocopy *------------------------------------------------------------------------- */ - if (h5tools_canreadf((travt->objs[i].name), dcpl_in) == 1) { - apply_s = 1; - apply_f = 1; + use_h5ocopy = !(options->op_tbl->nelems || options->all_filter == 1 || + options->all_layout == 1 || is_ref || is_named); + + if (!use_h5ocopy) { + int j; + + if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed"); + if ((f_space_id = H5Dget_space(dset_in)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed"); + if ((ftype_id = H5Dget_type(dset_in)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dget_type failed"); + if ((dcpl_in = H5Dget_create_plist(dset_in)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed"); + if ((rank = H5Sget_simple_extent_ndims(f_space_id)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_ndims failed"); + HDmemset(dims, 0, sizeof dims); + if (H5Sget_simple_extent_dims(f_space_id, dims, NULL) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_dims failed"); + if (H5Dget_space_status(dset_in, &space_status) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dget_space_status failed"); + + /* If the input dataset has external storage, it must be contiguous. + * Accordingly, there would be no filter or chunk properties to preserve, + * so create a new DCPL. + * Otherwise, copy dcpl_in. + */ + if (H5Pget_external_count(dcpl_in)) { + if ((dcpl_out = H5Pcreate(H5P_DATASET_CREATE)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed"); + } + else if ((dcpl_out = H5Pcopy(dcpl_in)) < 0) { + H5TOOLS_GOTO_ERROR((-1), "H5Pcopy failed"); + } + + nelmts = 1; + for (j = 0; j < rank; j++) + nelmts *= dims[j]; + + /* wtype_id will have already been set if using a named dtype */ + if (!is_named) { + if (options->use_native == 1) + wtype_id = H5Tget_native_type(ftype_id, H5T_DIR_DEFAULT); + else + wtype_id = H5Tcopy(ftype_id); + } + + if ((msize = H5Tget_size(wtype_id)) == 0) + H5TOOLS_GOTO_ERROR((-1), "H5Tget_size failed"); + + /* size of current dset */ + size_dset = nelmts * msize; /*------------------------------------------------------------------------- - * references are a special case - * we cannot just copy the buffers, but instead we recreate the reference - * in a second traversal of the output file + * check if the dataset creation property list has filters that + * are not registered in the current configuration + * 1) the external filters GZIP and SZIP might not be available + * 2) the internal filters might be turned off *------------------------------------------------------------------------- */ - if (H5T_REFERENCE != H5Tget_class(wtype_id)) { - /* get the storage size of the input dataset */ - dsize_in = H5Dget_storage_size(dset_in); - - /* check for small size datasets (less than 1k) except - * changing to COMPACT. For the reference, COMPACT is limited - * by size 64K by library. - */ - if (options->layout_g != H5D_COMPACT) - if (size_dset < options->min_comp) - apply_s = 0; - - /* apply the filter */ - if (apply_s) - if (apply_filters(travt->objs[i].name, rank, dims, msize, dcpl_out, options, &has_filter) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "apply_filters failed"); - - /* only if layout change requested for entire file or - * individual obj */ - if (options->all_layout > 0 || req_obj_layout == 1) - /*------------------------------------------------- - * Unset the unlimited max dims if convert to other - * than chunk layouts, because unlimited max dims - * only can be applied to chunk layout. - * Also perform only for targeted dataset - * Also check for size limit to convert to compact - *-------------------------------------------------*/ - if (options->layout_g != H5D_CHUNKED) { - /* any dataset is specified */ - if (options->op_tbl->nelems > 0) { - /* if current obj match specified obj */ - if (options_get_object(travt->objs[i].name, options->op_tbl)) - limit_maxdims = TRUE; - } - else /* no dataset is specified */ - limit_maxdims = TRUE; - - /* if convert to COMPACT */ - if (options->layout_g == H5D_COMPACT) - /* should be smaller than 64K */ - if (size_dset > MAX_COMPACT_DSIZE) - limit_maxdims = FALSE; - - /* unset unlimited max dims */ - if (limit_maxdims) - H5Sset_extent_simple(f_space_id, rank, dims, NULL); - } + if (h5tools_canreadf((travt->objs[i].name), dcpl_in) == 1) { + apply_s = 1; + apply_f = 1; /*------------------------------------------------------------------------- - * create the output dataset; - * disable error checking in case the dataset cannot be created with the - * modified dcpl; in that case use the original instead + * references are a special case + * we cannot just copy the buffers, but instead we recreate the reference + * in a second traversal of the output file *------------------------------------------------------------------------- */ - dset_out = H5Dcreate2(fidout, travt->objs[i].name, wtype_id, f_space_id, H5P_DEFAULT, dcpl_out, H5P_DEFAULT); - if (dset_out == FAIL) { - H5Epush2(H5tools_ERR_STACK_g, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_id_g, "H5Dcreate2 failed"); - if (options->verbose) - printf(" warning: could not create dataset <%s>. Applying original settings\n", travt->objs[i].name); + if (H5T_REFERENCE != H5Tget_class(wtype_id)) { + /* get the storage size of the input dataset */ + dsize_in = H5Dget_storage_size(dset_in); + + /* check for small size datasets (less than 1k) except + * changing to COMPACT. For the reference, COMPACT is limited + * by size 64K by library. + */ + if (options->layout_g != H5D_COMPACT) + if (size_dset < options->min_comp) + apply_s = 0; + + /* apply the filter */ + if (apply_s) + if (apply_filters(travt->objs[i].name, rank, dims, msize, dcpl_out, + options, &has_filter) < 0) + H5TOOLS_GOTO_ERROR((-1), "apply_filters failed"); + + /* only if layout change requested for entire file or + * individual obj */ + if (options->all_layout > 0 || req_obj_layout == 1) { + /*------------------------------------------------- + * Unset the unlimited max dims if convert to other + * than chunk layouts, because unlimited max dims + * only can be applied to chunk layout. + * Also perform only for targeted dataset + * Also check for size limit to convert to compact + *-------------------------------------------------*/ + if (options->layout_g != H5D_CHUNKED) { + /* any dataset is specified */ + if (options->op_tbl->nelems > 0) { + /* if current obj match specified obj */ + if (options_get_object(travt->objs[i].name, options->op_tbl)) + limit_maxdims = TRUE; + } + else /* no dataset is specified */ + limit_maxdims = TRUE; - if ((dset_out = H5Dcreate2(fidout, travt->objs[i].name, wtype_id, f_space_id, H5P_DEFAULT, dcpl_in, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dcreate2 failed"); - apply_f = 0; - } + /* if convert to COMPACT */ + if (options->layout_g == H5D_COMPACT) + if (size_dset > MAX_COMPACT_DSIZE) + limit_maxdims = FALSE; + + /* unset unlimited max dims */ + if (limit_maxdims) + H5Sset_extent_simple(f_space_id, rank, dims, NULL); + } /* end if not chunked */ + } /* end if layout change requested for entire file or individual object */ + + /*------------------------------------------------------------------------- + * create the output dataset; + * disable error checking in case the dataset cannot be created with the + * modified dcpl; in that case use the original instead + *------------------------------------------------------------------------- + */ + dset_out = H5Dcreate2(fidout, travt->objs[i].name, wtype_id, f_space_id, + H5P_DEFAULT, dcpl_out, H5P_DEFAULT); + if (dset_out == H5I_INVALID_HID) { + H5TOOLS_INFO("H5Dcreate2 failed"); + if (options->verbose) + HDprintf(" warning: could not create dataset <%s>. Applying original " + "settings\n", + travt->objs[i].name); + + if ((dset_out = + H5Dcreate2(fidout, travt->objs[i].name, wtype_id, f_space_id, + H5P_DEFAULT, dcpl_in, H5P_DEFAULT)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dcreate2 failed"); + apply_f = 0; + } /* end if retry dataset create */ + + /*------------------------------------------------------------------------- + * read/write + *------------------------------------------------------------------------- + */ + if (nelmts > 0 && space_status != H5D_SPACE_STATUS_NOT_ALLOCATED) { + size_t need = (size_t)(nelmts * msize); /* bytes needed */ + + /* have to read the whole dataset if there is only one element in the + * dataset */ + if (need < H5TOOLS_MALLOCSIZE) + buf = HDmalloc(need); - /*------------------------------------------------------------------------- - * read/write - *------------------------------------------------------------------------- - */ - if (nelmts > 0 && space_status != H5D_SPACE_STATUS_NOT_ALLOCATED) { - size_t need = (size_t)(nelmts * msize); /* bytes needed */ - - /* have to read the whole dataset if there is only one element in the dataset */ - if (need < H5TOOLS_MALLOCSIZE) - buf = HDmalloc(need); - - if (buf != NULL) { - if(H5Dread(dset_in, wtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed"); - if(H5Dwrite(dset_out, wtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dwrite failed"); - - /* Check if we have VL data in the dataset's - * datatype that must be reclaimed */ - if (TRUE == H5Tdetect_class(wtype_id, H5T_VLEN)) - if (H5Dvlen_reclaim(wtype_id, f_space_id, H5P_DEFAULT, buf) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dvlen_reclaim failed"); - /* free */ if (buf != NULL) { - HDfree(buf); - buf = NULL; + if (H5Dread(dset_in, wtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < + 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dread failed"); + if (H5Dwrite(dset_out, wtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < + 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dwrite failed"); + + /* Check if we have VL data in the dataset's + * datatype that must be reclaimed */ + if (TRUE == H5Tdetect_class(wtype_id, H5T_VLEN)) + if (H5Dvlen_reclaim(wtype_id, f_space_id, H5P_DEFAULT, buf) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dvlen_reclaim failed"); + + if (buf != NULL) { /* TODO: is buf potentially released by + H5Dvlen_reclaim()? */ + HDfree(buf); + buf = NULL; + } } - } - else { /* possibly not enough memory, read/write by hyperslabs */ - size_t p_type_nbytes = msize; /*size of memory type */ - hsize_t p_nelmts = nelmts; /*total elements */ - hsize_t elmtno; /*counter */ - int carry; /*counter carry value */ - unsigned int vl_data = 0; /*contains VL datatypes */ - - /* hyperslab info */ - hsize_t hslab_dims[H5S_MAX_RANK]; /*hyperslab dims */ - hsize_t hslab_nbytes; /*bytes per hyperslab */ - hsize_t hslab_nelmts; /*elements per hyperslab*/ - hid_t hslab_space; /*hyperslab data space */ - - /* hyperslab selection info */ - hsize_t hs_sel_offset[H5S_MAX_RANK];/* selection offset */ - hsize_t hs_sel_count[H5S_MAX_RANK]; /* selection count */ - hsize_t hs_select_nelmts; /* selected elements */ - hsize_t zero[8]; /*vector of zeros */ - int k; - H5D_layout_t dset_layout; - hid_t dcpl_tmp = -1; /* dataset creation property list ID */ - - /* check if we have VL data in the dataset's datatype */ - if (H5Tdetect_class(wtype_id, H5T_VLEN) == TRUE) - vl_data = TRUE; - - /* check first if writing dataset is chunked, - * if so use its chunk layout for better performance. */ - dset_layout = H5Pget_layout(dcpl_out); - if (dset_layout == H5D_CHUNKED) - dcpl_tmp = dcpl_out; /* writing dataset */ - else { /* if reading dataset is chunked */ - dset_layout = H5Pget_layout(dcpl_in); + else { /* possibly not enough memory, read/write by hyperslabs */ + size_t p_type_nbytes = msize; /*size of memory type */ + hsize_t p_nelmts = nelmts; /*total elements */ + hsize_t elmtno; /*counter */ + int carry; /*counter carry value */ + unsigned int vl_data = 0; /*contains VL datatypes */ + + /* hyperslab info */ + hsize_t hslab_dims[H5S_MAX_RANK]; /*hyperslab dims */ + hsize_t hslab_nbytes; /*bytes per hyperslab */ + hsize_t hslab_nelmts; /*elements per hyperslab*/ + hid_t hslab_space; /*hyperslab data space */ + + /* hyperslab selection info */ + hsize_t hs_sel_offset[H5S_MAX_RANK]; /* selection offset */ + hsize_t hs_sel_count[H5S_MAX_RANK]; /* selection count */ + hsize_t hs_select_nelmts; /* selected elements */ + hsize_t zero[8]; /*vector of zeros */ + int k; + H5D_layout_t dset_layout; + hid_t dcpl_tmp = + H5I_INVALID_HID; /* dataset creation property list ID */ + + /* check if we have VL data in the dataset's datatype */ + if (H5Tdetect_class(wtype_id, H5T_VLEN) == TRUE) + vl_data = TRUE; + + /* check first if writing dataset is chunked, + * if so use its chunk layout for better performance. */ + dset_layout = H5Pget_layout(dcpl_out); if (dset_layout == H5D_CHUNKED) - dcpl_tmp = dcpl_in; /* reading dataset */ - } + dcpl_tmp = dcpl_out; /* writing dataset */ + else { + dset_layout = H5Pget_layout(dcpl_in); + if (dset_layout == H5D_CHUNKED) + dcpl_tmp = dcpl_in; /* reading dataset */ + } - /* get hyperslab dims and size in byte */ - if (Get_hyperslab(dcpl_tmp, rank, dims, p_type_nbytes, hslab_dims, &hslab_nbytes) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Get_hyperslab failed"); - - hslab_buf = HDmalloc((size_t)hslab_nbytes); - - hslab_nelmts = hslab_nbytes / p_type_nbytes; - hslab_space = H5Screate_simple(1, &hslab_nelmts, NULL); - - /* the hyperslab selection loop */ - HDmemset(hs_sel_offset, 0, sizeof hs_sel_offset); - HDmemset(zero, 0, sizeof zero); - - for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_select_nelmts) { - if (rank > 0) { - /* calculate the hyperslab selections. - * The selection would be same as the hyperslab - * except for remaining edge portion of the dataset - * which is smaller then the hyperslab. - */ - for (k = 0, hs_select_nelmts = 1; k < rank; k++) { - /* MIN() is used to get the remaining edge portion if exist. - * "dims[k] - hs_sel_offset[k]" is remaining edge portion that is smaller then the hyperslab.*/ - hs_sel_count[k] = MIN(dims[k] - hs_sel_offset[k], hslab_dims[k]); - hs_select_nelmts *= hs_sel_count[k]; + /* get hyperslab dims and size in byte */ + if (get_hyperslab(dcpl_tmp, rank, dims, p_type_nbytes, hslab_dims, + &hslab_nbytes) < 0) + H5TOOLS_GOTO_ERROR((-1), "get_hyperslab failed"); + + hslab_buf = HDmalloc((size_t)hslab_nbytes); + if (hslab_buf == NULL) + H5TOOLS_GOTO_ERROR((-1), "can't allocate space for hyperslab"); + + hslab_nelmts = hslab_nbytes / p_type_nbytes; + hslab_space = H5Screate_simple(1, &hslab_nelmts, NULL); + + /* the hyperslab selection loop */ + HDmemset(hs_sel_offset, 0, sizeof hs_sel_offset); + HDmemset(zero, 0, sizeof zero); + + for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_select_nelmts) { + if (rank > 0) { + /* calculate the hyperslab selections. + * The selection would be same as the hyperslab + * except for remaining edge portion of the dataset + * which is smaller then the hyperslab. + */ + for (k = 0, hs_select_nelmts = 1; k < rank; k++) { + /* MIN() is used to get the remaining edge portion if + * exist. "dims[k] - hs_sel_offset[k]" is remaining edge + * portion that is smaller then the hyperslab.*/ + hs_sel_count[k] = + MIN(dims[k] - hs_sel_offset[k], hslab_dims[k]); + hs_select_nelmts *= hs_sel_count[k]; + } + + if (H5Sselect_hyperslab(f_space_id, H5S_SELECT_SET, + hs_sel_offset, NULL, hs_sel_count, + NULL) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Sselect_hyperslab failed"); + if (H5Sselect_hyperslab(hslab_space, H5S_SELECT_SET, zero, + NULL, &hs_select_nelmts, NULL) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Sselect_hyperslab failed"); + } /* end if rank > 0 */ + else { + H5Sselect_all(f_space_id); + H5Sselect_all(hslab_space); + hs_select_nelmts = 1; + } /* end (else) rank == 0 */ + + if (H5Dread(dset_in, wtype_id, hslab_space, f_space_id, + H5P_DEFAULT, hslab_buf) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dread failed"); + if (H5Dwrite(dset_out, wtype_id, hslab_space, f_space_id, + H5P_DEFAULT, hslab_buf) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dwrite failed"); + + /* reclaim any VL memory, if necessary */ + if (vl_data) + H5Dvlen_reclaim(wtype_id, hslab_space, H5P_DEFAULT, + hslab_buf); + + /* calculate the next hyperslab offset */ + for (k = rank, carry = 1; k > 0 && carry; --k) { + hs_sel_offset[k - 1] += hs_sel_count[k - 1]; + /* if reached the end of a dim */ + if (hs_sel_offset[k - 1] == dims[k - 1]) + hs_sel_offset[k - 1] = 0; + else + carry = 0; } + } /* end for (hyperslab selection loop) */ - if (H5Sselect_hyperslab(f_space_id, H5S_SELECT_SET, hs_sel_offset, NULL, hs_sel_count, NULL) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed"); - if (H5Sselect_hyperslab(hslab_space, H5S_SELECT_SET, zero, NULL, &hs_select_nelmts, NULL) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed"); + H5Sclose(hslab_space); + if (hslab_buf != NULL) { + HDfree(hslab_buf); + hslab_buf = NULL; } - else { - H5Sselect_all(f_space_id); - H5Sselect_all(hslab_space); - hs_select_nelmts = 1; - } /* rank */ - - if(H5Dread(dset_in, wtype_id, hslab_space, f_space_id, H5P_DEFAULT, hslab_buf) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed"); - if(H5Dwrite(dset_out, wtype_id, hslab_space, f_space_id, H5P_DEFAULT, hslab_buf) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dwrite failed"); - - /* reclaim any VL memory, if necessary */ - if (vl_data) - H5Dvlen_reclaim(wtype_id, hslab_space, H5P_DEFAULT, hslab_buf); - - /* calculate the next hyperslab offset */ - for (k = rank, carry = 1; k > 0 && carry; --k) { - hs_sel_offset[k - 1] += hs_sel_count[k - 1]; - /* if reached the end of a dim */ - if (hs_sel_offset[k - 1] == dims[k - 1]) - hs_sel_offset[k - 1] = 0; - else - carry = 0; - } /* k */ - } /* elmtno */ - - H5Sclose(hslab_space); - /* free */ - if (hslab_buf != NULL) { - HDfree(hslab_buf); - hslab_buf = NULL; - } - } /* hyperslab read */ - } /* if (nelmts>0 && space_status==H5D_SPACE_STATUS_NOT_ALLOCATED) */ - - /*------------------------------------------------------------------------- - * amount of compression used - *------------------------------------------------------------------------- - */ - if (options->verbose) { - double ratio = 0; - - /* only print the compression ration if there was a filter request */ - if (apply_s && apply_f && req_filter) { - /* get the storage size of the output dataset */ - dsize_out = H5Dget_storage_size(dset_out); - - /* compression ratio = uncompressed size / compressed size */ - if (dsize_out != 0) - ratio = (double) dsize_in / (double) dsize_out; - print_dataset_info(dcpl_out, travt->objs[i].name, ratio, 1); - } - else - print_dataset_info(dcpl_in, travt->objs[i].name, ratio, 0); + } /* end if reading/writing by hyperslab */ + } /* end if (nelmts > 0 && space_status != H5D_SPACE_STATUS_NOT_ALLOCATED) */ - /* print a message that the filter was not applied - (in case there was a filter) + /*------------------------------------------------------------------------- + * print amount of compression used + *------------------------------------------------------------------------- */ - if (has_filter && apply_s == 0) - printf(" <warning: filter not applied to %s. dataset smaller than %d bytes>\n", travt->objs[i].name, (int) options->min_comp); - - if (has_filter && apply_f == 0) - printf(" <warning: could not apply the filter to %s>\n", travt->objs[i].name); - } /* verbose */ - - /*------------------------------------------------------------------------- - * copy attrs - *------------------------------------------------------------------------- - */ - if (copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_attr failed"); + if (options->verbose) { + double ratio = 0; + + /* only print the compression ration if there was a filter request */ + if (apply_s && apply_f && req_filter) { + /* get the storage size of the output dataset */ + dsize_out = H5Dget_storage_size(dset_out); + + /* compression ratio = uncompressed size / compressed size */ + if (dsize_out != 0) + ratio = (double)dsize_in / (double)dsize_out; + print_dataset_info(dcpl_out, travt->objs[i].name, ratio, 1); + } + else + print_dataset_info(dcpl_in, travt->objs[i].name, ratio, 0); + + /* print a message that the filter was not applied + * (in case there was a filter) + */ + if (has_filter && apply_s == 0) + HDprintf(" <warning: filter not applied to %s. dataset smaller than " + "%d bytes>\n", + travt->objs[i].name, (int)options->min_comp); + + if (has_filter && apply_f == 0) + HDprintf(" <warning: could not apply the filter to %s>\n", + travt->objs[i].name); + } /* end if verbose (print compression) */ + + /*------------------------------------------------------------------------- + * copy attrs + *------------------------------------------------------------------------- + */ + if (copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0) + H5TOOLS_GOTO_ERROR((-1), "copy_attr failed"); - /*close */ - if (H5Dclose(dset_out) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed"); - }/*!H5T_REFERENCE*/ - }/*h5tools_canreadf*/ + if (H5Dclose(dset_out) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); + } /* end if not a reference */ + } /* end if h5tools_canreadf (filter availability check) */ + /*------------------------------------------------------------------------- + * Close + *------------------------------------------------------------------------- + */ + if (H5Tclose(ftype_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); + if (H5Tclose(wtype_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); + if (H5Pclose(dcpl_in) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); + if (H5Pclose(dcpl_out) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); + if (H5Sclose(f_space_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed"); + if (H5Dclose(dset_in) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); + } /*------------------------------------------------------------------------- - * close + * We do not have request for filter/chunking; use H5Ocopy instead *------------------------------------------------------------------------- */ - if (H5Tclose(ftype_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); - if (H5Tclose(wtype_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); - if (H5Pclose(dcpl_in) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); - if (H5Pclose(dcpl_out) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); - if (H5Sclose(f_space_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed"); - if (H5Dclose(dset_in) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed"); - } - /*------------------------------------------------------------------------- - * we do not have request for filter/chunking use H5Ocopy instead - *------------------------------------------------------------------------- - */ - else { - hid_t pid = -1; + else { + hid_t pid = H5I_INVALID_HID; - /* create property to pass copy options */ - if ((pid = H5Pcreate(H5P_OBJECT_COPY)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed"); + /* create property to pass copy options */ + if ((pid = H5Pcreate(H5P_OBJECT_COPY)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed"); - /* set options for object copy */ - if (H5Pset_copy_object(pid, H5O_COPY_WITHOUT_ATTR_FLAG) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_copy_object failed"); + /* set options for object copy */ + if (H5Pset_copy_object(pid, H5O_COPY_WITHOUT_ATTR_FLAG) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pset_copy_object failed"); - /*------------------------------------------------------------------------- - * do the copy - *------------------------------------------------------------------------- - */ + if (H5Ocopy(fidin, /* Source file or group identifier */ + travt->objs[i].name, /* Name of the source object to be copied */ + fidout, /* Destination file or group identifier */ + travt->objs[i].name, /* Name of the destination object */ + pid, /* Properties which apply to the copy */ + H5P_DEFAULT) < 0) /* Properties which apply to the new hard link */ + H5TOOLS_GOTO_ERROR((-1), "H5Ocopy failed"); - if (H5Ocopy(fidin, /* Source file or group identifier */ - travt->objs[i].name, /* Name of the source object to be copied */ - fidout, /* Destination file or group identifier */ - travt->objs[i].name, /* Name of the destination object */ - pid, /* Properties which apply to the copy */ - H5P_DEFAULT) < 0) /* Properties which apply to the new hard link */ - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Ocopy failed"); + if (H5Pclose(pid) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); - /* close property */ - if (H5Pclose(pid) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); + /*------------------------------------------------------------------------- + * Copy attrs manually + *------------------------------------------------------------------------- + */ + if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed"); + if ((dset_out = H5Dopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed"); + if (copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0) + H5TOOLS_GOTO_ERROR((-1), "copy_attr failed"); + if (H5Dclose(dset_in) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); + if (H5Dclose(dset_out) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); - /*------------------------------------------------------------------------- - * copy attrs manually - *------------------------------------------------------------------------- - */ - if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed"); - if ((dset_out = H5Dopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed"); - if (copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_attr failed"); - if (H5Dclose(dset_in) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed"); - if (H5Dclose(dset_out) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed"); + if (options->verbose) + HDprintf(FORMAT_OBJ, "dset", travt->objs[i].name); + + } /* end whether we have request for filter/chunking */ + break; + } /* H5TRAV_TYPE_DATASET */ + + /*------------------------------------------------------------------------- + * H5TRAV_TYPE_NAMED_DATATYPE + *------------------------------------------------------------------------- + */ + case H5TRAV_TYPE_NAMED_DATATYPE: if (options->verbose) - printf(FORMAT_OBJ, "dset", travt->objs[i].name); + HDprintf(FORMAT_OBJ, "type", travt->objs[i].name); - } /* end do we have request for filter/chunking */ - break; + if ((type_in = H5Topen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Topen2 failed"); - /*------------------------------------------------------------------------- - * H5TRAV_TYPE_NAMED_DATATYPE - *------------------------------------------------------------------------- - */ - case H5TRAV_TYPE_NAMED_DATATYPE: - if (options->verbose) - printf(FORMAT_OBJ, "type", travt->objs[i].name); + /* Copy the datatype anonymously */ + if ((type_out = copy_named_datatype(type_in, fidout, &named_dt_head, travt, options)) < 0) + H5TOOLS_GOTO_ERROR((-1), "copy_named_datatype failed"); - if ((type_in = H5Topen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Topen2 failed"); + /* Link in to group structure */ + if (H5Lcreate_hard(type_out, ".", fidout, travt->objs[i].name, H5P_DEFAULT, H5P_DEFAULT) < + 0) + H5TOOLS_GOTO_ERROR((-1), "H5Lcreate_hard failed"); - /* Copy the datatype anonymously */ - if ((type_out = copy_named_datatype(type_in, fidout, &named_dt_head, travt, options)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_named_datatype failed"); + /*------------------------------------------------------------------------- + * copy attrs + *------------------------------------------------------------------------- + */ + if (copy_attr(type_in, type_out, &named_dt_head, travt, options) < 0) + H5TOOLS_GOTO_ERROR((-1), "copy_attr failed"); - /* Link in to group structure */ - if (H5Lcreate_hard(type_out, ".", fidout, travt->objs[i].name, H5P_DEFAULT, H5P_DEFAULT) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Lcreate_hard failed"); + if (H5Tclose(type_in) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); + if (H5Tclose(type_out) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); + type_out = H5I_INVALID_HID; /* named datatypes stack, named_dt_head, manages allocation */ + + break; /*------------------------------------------------------------------------- - * copy attrs + * H5TRAV_TYPE_LINK + * H5TRAV_TYPE_UDLINK + * + * Only handles external links; H5Lcopy will fail for other UD link types + * since we don't have creation or copy callbacks for them. *------------------------------------------------------------------------- */ - if (copy_attr(type_in, type_out, &named_dt_head, travt, options) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_attr failed"); - - if (H5Tclose(type_in) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); - if (H5Tclose(type_out) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); - type_out = -1; /* named datatypes stack, named_dt_head, manages allocation */ - - break; - - /*------------------------------------------------------------------------- - * H5TRAV_TYPE_LINK - * H5TRAV_TYPE_UDLINK - * - * Only handles external links; H5Lcopy will fail for other UD link types - * since we don't have creation or copy callbacks for them. - *------------------------------------------------------------------------- - */ - case H5TRAV_TYPE_LINK: - case H5TRAV_TYPE_UDLINK: - if (options->verbose) - printf(FORMAT_OBJ, "link", travt->objs[i].name); + case H5TRAV_TYPE_LINK: + case H5TRAV_TYPE_UDLINK: + if (options->verbose) + HDprintf(FORMAT_OBJ, "link", travt->objs[i].name); - if (H5Lcopy(fidin, travt->objs[i].name, fidout, travt->objs[i].name, H5P_DEFAULT, H5P_DEFAULT) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Lcopy failed"); + if (H5Lcopy(fidin, travt->objs[i].name, fidout, travt->objs[i].name, H5P_DEFAULT, + H5P_DEFAULT) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Lcopy failed"); - if (options->verbose) - printf(FORMAT_OBJ, "link", travt->objs[i].name); - break; + if (options->verbose) + HDprintf(FORMAT_OBJ, "link", travt->objs[i].name); + break; - default: - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Object type not found"); + default: + H5TOOLS_GOTO_ERROR((-1), "Object type not found"); } /* switch */ - } /* end for */ - } /* end if */ + } /* end for each object to traverse */ + } /* end if there are objects */ done: @@ -1166,12 +1217,11 @@ done: * because of reference counting */ if (0 == ret_value && named_dt_head != NULL) { if (named_datatype_free(&named_dt_head, 0) < 0) - H5TOOLS_INFO(H5E_tools_min_id_g, "named_datatype_free failed"); + H5TOOLS_ERROR((-1), "named_datatype_free failed"); } else - H5E_BEGIN_TRY { - named_datatype_free(&named_dt_head, 1); - } H5E_END_TRY; + H5E_BEGIN_TRY { named_datatype_free(&named_dt_head, 1); } + H5E_END_TRY; H5E_BEGIN_TRY { @@ -1187,7 +1237,8 @@ done: H5Tclose(wtype_id); H5Tclose(type_in); H5Tclose(type_out); - } H5E_END_TRY; + } + H5E_END_TRY; /* free */ if (buf != NULL) @@ -1196,7 +1247,7 @@ done: HDfree(hslab_buf); return ret_value; -} +} /* end do_copy_objects() */ /*------------------------------------------------------------------------- * Function: print_dataset_info @@ -1207,17 +1258,17 @@ done: static void print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr) { - char strfilter[255]; -#if defined (PRINT_DEBUG ) - char temp[255]; + char strfilter[255]; +#if defined(PRINT_DEBUG) + char temp[255]; #endif - int nfilters; /* number of filters */ - unsigned filt_flags; /* filter flags */ - H5Z_filter_t filtn; /* filter identification number */ - unsigned cd_values[20]; /* filter client data values */ - size_t cd_nelmts; /* filter client number of values */ - char f_objname[256]; /* filter objname */ - int i; + int nfilters; /* number of filters */ + unsigned filt_flags; /* filter flags */ + H5Z_filter_t filtn; /* filter identification number */ + unsigned cd_values[20]; /* filter client data values */ + size_t cd_nelmts; /* filter client number of values */ + char f_objname[256]; /* filter objname */ + int i; HDstrcpy(strfilter, "\0"); @@ -1228,8 +1279,8 @@ print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr) for (i = 0; i < nfilters; i++) { cd_nelmts = NELMTS(cd_values); - if ((filtn = H5Pget_filter2(dcpl_id, (unsigned) i, &filt_flags, &cd_nelmts, - cd_values, sizeof(f_objname), f_objname, NULL)) < 0) { + if ((filtn = H5Pget_filter2(dcpl_id, (unsigned)i, &filt_flags, &cd_nelmts, cd_values, + sizeof(f_objname), f_objname, NULL)) < 0) { HDstrcat(strfilter, "ERROR "); continue; } @@ -1242,11 +1293,11 @@ print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr) case H5Z_FILTER_DEFLATE: HDstrcat(strfilter, "GZIP "); -#if defined (PRINT_DEBUG) +#if defined(PRINT_DEBUG) { unsigned level = cd_values[0]; - sprintf(temp,"(%d)", level); + HDsprintf(temp, "(%d)", level); HDstrcat(strfilter, temp); } #endif @@ -1255,12 +1306,12 @@ print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr) case H5Z_FILTER_SZIP: HDstrcat(strfilter, "SZIP "); -#if defined (PRINT_DEBUG) +#if defined(PRINT_DEBUG) { unsigned options_mask = cd_values[0]; /* from dcpl, not filt*/ - unsigned ppb = cd_values[1]; + unsigned ppb = cd_values[1]; - sprintf(temp,"(%d,", ppb); + HDsprintf(temp, "(%d,", ppb); HDstrcat(strfilter, temp); if (options_mask & H5_SZIP_EC_OPTION_MASK) HDstrcpy(temp, "EC) "); @@ -1290,21 +1341,21 @@ print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr) default: HDstrcat(strfilter, "UD "); break; - } /* switch */ - }/*i*/ + } /* end switch */ + } /* end for each filter */ if (!pr) - printf(FORMAT_OBJ, "dset", objname); + HDprintf(FORMAT_OBJ, "dset", objname); else { - char str[255], temp[28]; + char str[512], temp[512]; HDstrcpy(str, "dset "); HDstrcat(str, strfilter); - sprintf(temp, " (%.3f:1)", ratio); + HDsprintf(temp, " (%.3f:1)", ratio); HDstrcat(str, temp); - printf(FORMAT_OBJ, str, objname); + HDprintf(FORMAT_OBJ, str, objname); } -} +} /* end print_dataset_info() */ /*------------------------------------------------------------------------- * Function: copy_user_block @@ -1317,22 +1368,22 @@ print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr) static int copy_user_block(const char *infile, const char *outfile, hsize_t size) { - int ret_value = 0; int infid = -1, outfid = -1; /* File descriptors */ + int ret_value = 0; /* User block must be any power of 2 equal to 512 or greater (512, 1024, 2048, etc.) */ /* Open files */ - if ((infid = HDopen(infile, O_RDONLY, 0)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDopen failed input file <%s>", infile); - if ((outfid = HDopen(outfile, O_WRONLY, 0644)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDopen failed output file <%s>", outfile); + if ((infid = HDopen(infile, O_RDONLY)) < 0) + H5TOOLS_GOTO_ERROR((-1), "HDopen failed input file <%s>", infile); + if ((outfid = HDopen(outfile, O_WRONLY)) < 0) + H5TOOLS_GOTO_ERROR((-1), "HDopen failed output file <%s>", outfile); /* Copy the userblock from the input file to the output file */ while (size > 0) { - ssize_t nread, nbytes; /* # of bytes transfered, etc. */ - char rbuf[USERBLOCK_XFER_SIZE]; /* Buffer for reading */ - const char *wbuf; /* Pointer into buffer, for writing */ + ssize_t nread, nbytes; /* # of bytes transfered, etc. */ + char rbuf[USERBLOCK_XFER_SIZE]; /* Buffer for reading */ + const char *wbuf; /* Pointer into buffer, for writing */ /* Read buffer from source file */ if (size > USERBLOCK_XFER_SIZE) @@ -1340,20 +1391,20 @@ copy_user_block(const char *infile, const char *outfile, hsize_t size) else nread = HDread(infid, rbuf, (size_t)size); if (nread < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDread failed to read userblock"); + H5TOOLS_GOTO_ERROR((-1), "HDread failed to read userblock"); /* Write buffer to destination file */ /* (compensating for interrupted writes & checking for errors, etc.) */ nbytes = nread; - wbuf = rbuf; + wbuf = rbuf; while (nbytes > 0) { ssize_t nwritten; /* # of bytes written */ do { nwritten = HDwrite(outfid, wbuf, (size_t)nbytes); } while (-1 == nwritten && EINTR == errno); - if (-1 == nwritten) /* error */ - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDwrite failed"); + if (-1 == nwritten) /* error */ + H5TOOLS_GOTO_ERROR((-1), "HDwrite failed"); HDassert(nwritten > 0); HDassert(nwritten <= nbytes); @@ -1364,17 +1415,17 @@ copy_user_block(const char *infile, const char *outfile, hsize_t size) } /* end while */ /* Update size of userblock left to transfer */ - size = size - (hsize_t) nread; + size = size - (hsize_t)nread; } /* end while */ done: - if (infid > 0) + if (infid >= 0) HDclose(infid); - if (outfid > 0) + if (outfid >= 0) HDclose(outfid); return ret_value; -} +} /* end copy_user_block() */ /*------------------------------------------------------------------------- * Function: print_user_block @@ -1384,42 +1435,41 @@ done: * Return: 0, ok, -1 no *------------------------------------------------------------------------- */ -#if defined (H5REPACK_DEBUG_USER_BLOCK) -static -void +#if defined(H5REPACK_DEBUG_USER_BLOCK) +static void print_user_block(const char *filename, hid_t fid) { - int ret_value = 0; - int fh = -1; /* file handle */ - hsize_t ub_size; /* user block size */ - hsize_t size; /* size read */ - hid_t fcpl = -1; /* file creation property list ID for HDF5 file */ + int fh = -1; /* file handle */ + hsize_t ub_size; /* user block size */ + hsize_t size; /* size read */ + hid_t fcpl = H5I_INVALID_HID; /* file creation property list ID for HDF5 file */ int i; + int ret_value = 0; /* get user block size */ if ((fcpl = H5Fget_create_plist(fid)) < 0) { - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Fget_create_plist failed to retrieve file creation property list"); + H5TOOLS_GOTO_ERROR((-1), "H5Fget_create_plist failed to retrieve file creation property list"); } if (H5Pget_userblock(fcpl, &ub_size) < 0) { - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pget_userblock failed to retrieve userblock size"); + H5TOOLS_GOTO_ERROR((-1), "H5Pget_userblock failed to retrieve userblock size"); } if (H5Pclose(fcpl) < 0) { - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed to close property list"); + H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed to close property list"); } /* open file */ if ((fh = HDopen(filename, O_RDONLY)) < 0) { - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDopen failed to open file <%s>", filename); + H5TOOLS_GOTO_ERROR((-1), "HDopen failed to open file <%s>", filename); } size = ub_size; /* read file */ while (size > 0) { - ssize_t nread; /* # of bytes read */ - char rbuf[USERBLOCK_XFER_SIZE]; /* buffer for reading */ + ssize_t nread; /* # of bytes read */ + char rbuf[USERBLOCK_XFER_SIZE]; /* buffer for reading */ /* read buffer */ if (size > USERBLOCK_XFER_SIZE) @@ -1429,13 +1479,12 @@ print_user_block(const char *filename, hid_t fid) for (i = 0; i < nread; i++) { - printf("%c ", rbuf[i]); - + HDprintf("%c ", rbuf[i]); } - printf("\n"); + HDprintf("\n"); if (nread < 0) { - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "nread < 0"); + H5TOOLS_GOTO_ERROR((-1), "nread < 0"); } /* update size of userblock left to transfer */ @@ -1443,10 +1492,9 @@ print_user_block(const char *filename, hid_t fid) } done: - if (fh > 0) + if (fh >= 0) HDclose(fh); return; -} +} /* end print_user_block() */ #endif - diff --git a/tools/h5repack/h5repack_filters.c b/tools/h5repack/h5repack_filters.c index 8cc7b92..1c7ae9a 100644 --- a/tools/h5repack/h5repack_filters.c +++ b/tools/h5repack/h5repack_filters.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,12 +17,12 @@ /* number of members in an array */ #ifndef NELMTS -# define NELMTS(X) (sizeof(X)/sizeof(X[0])) +#define NELMTS(X) (sizeof(X) / sizeof(X[0])) #endif /* minimum of two values */ #undef MIN -#define MIN(a,b) (((a)<(b)) ? (a) : (b)) +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) /*------------------------------------------------------------------------- * Function: aux_copy_obj @@ -32,41 +32,44 @@ * Return: 0 success, -1 failure *------------------------------------------------------------------------- */ -static int aux_copy_obj(hid_t dcpl_id, /* dataset creation property list */ - const char* name, /* object name from traverse list */ - pack_info_t *objout /*OUT*/) /* info about object to filter */ +static int +aux_copy_obj(hid_t dcpl_id, /* dataset creation property list */ + const char * name, /* object name from traverse list */ + pack_info_t *objout /*OUT*/) /* info about object to filter */ { - int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ int nfilters; /* number of filters in DCPL */ char f_objname[256]; /* filter objname */ H5D_layout_t layout; - int rank; /* rank of dataset */ - hsize_t chsize[64]; /* chunk size in elements */ - unsigned int i; + int rank; /* rank of dataset */ + hsize_t chsize[64]; /* chunk size in elements */ + int i; + unsigned u; + int ret_value = 0; /* get information about input filters */ if ((nfilters = H5Pget_nfilters(dcpl_id)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_nfilters failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pget_nfilters failed"); /* copy filter_info_t structure */ for (i = 0; i < nfilters; i++) { - if ((objout->filter[i].filtn = H5Pget_filter2(dcpl_id, (unsigned) i, &objout->filter[i].filt_flag, &objout->filter[i].cd_nelmts, - objout->filter[i].cd_values, sizeof(f_objname), f_objname, NULL)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_filter2 failed"); + if ((objout->filter[i].filtn = H5Pget_filter2( + dcpl_id, (unsigned)i, &objout->filter[i].filt_flag, &objout->filter[i].cd_nelmts, + objout->filter[i].cd_values, sizeof(f_objname), f_objname, NULL)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pget_filter2 failed"); } objout->nfilters = nfilters; HDstrcpy(objout->path, name); if ((layout = H5Pget_layout(dcpl_id)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_layout failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pget_layout failed"); objout->layout = layout; if (layout == H5D_CHUNKED) { - if ((rank = H5Pget_chunk(dcpl_id, NELMTS(chsize), chsize/*out*/)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_chunk failed"); + if ((rank = H5Pget_chunk(dcpl_id, NELMTS(chsize), chsize /*out*/)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pget_chunk failed"); objout->chunk.rank = rank; - for (i = 0; i < rank; i++) - objout->chunk.chunk_lengths[i] = chsize[i]; + for (u = 0; u < (unsigned)rank; u++) + objout->chunk.chunk_lengths[u] = chsize[u]; } done: @@ -80,31 +83,33 @@ done: * in the repack options list *------------------------------------------------------------------------- */ -static int aux_find_obj(const char* name, /* object name from traverse list */ - pack_opt_t *options, /* repack options */ - pack_info_t *obj /*OUT*/) /* info about object to filter */ +static int +aux_find_obj(const char * name, /* object name from traverse list */ + pack_opt_t * options, /* repack options */ + pack_info_t *obj /*OUT*/) /* info about object to filter */ { - char *pdest = NULL; - char *pname = NULL; - int result; + char * pdest = NULL; + const char * pname = NULL; unsigned int i; for (i = 0; i < options->op_tbl->nelems; i++) { if (HDstrcmp(options->op_tbl->objs[i].path, name) == 0) { *obj = options->op_tbl->objs[i]; - return (int) i; + return (int)i; } pdest = options->op_tbl->objs[i].path; - if (pdest[0] == '/') pdest++; + if (pdest[0] == '/') + pdest++; pname = name; - if (pname[0] == '/') pname++; + if (pname[0] == '/') + pname++; if (HDstrcmp(pdest, pname) == 0) { *obj = options->op_tbl->objs[i]; - return (int) i; + return (int)i; } - }/*i*/ + } /*i*/ return -1; } @@ -118,9 +123,10 @@ static int aux_find_obj(const char* name, /* object name from traverse list */ * Return: 0 not found, 1 found *------------------------------------------------------------------------- */ -static int aux_assign_obj(const char* name, /* object name from traverse list */ - pack_opt_t *options, /* repack options */ - pack_info_t *obj /*OUT*/) /* info about object to filter */ +static int +aux_assign_obj(const char * name, /* object name from traverse list */ + pack_opt_t * options, /* repack options */ + pack_info_t *obj /*OUT*/) /* info about object to filter */ { int idx, i; pack_info_t tmp; @@ -136,42 +142,42 @@ static int aux_assign_obj(const char* name, /* object name from traverse list */ /* assign the global layout info to the OBJ info */ tmp.layout = options->layout_g; switch (options->layout_g) { - case H5D_CHUNKED: - tmp.chunk.rank = options->chunk_g.rank; - for (i = 0; i < tmp.chunk.rank; i++) - tmp.chunk.chunk_lengths[i] = options->chunk_g.chunk_lengths[i]; - break; - case H5D_LAYOUT_ERROR: - case H5D_COMPACT: - case H5D_CONTIGUOUS: - case H5D_NLAYOUTS: - break; - default: - break; - }/*switch*/ + case H5D_CHUNKED: + tmp.chunk.rank = options->chunk_g.rank; + for (i = 0; i < tmp.chunk.rank; i++) + tmp.chunk.chunk_lengths[i] = options->chunk_g.chunk_lengths[i]; + break; + case H5D_LAYOUT_ERROR: + case H5D_COMPACT: + case H5D_CONTIGUOUS: + case H5D_NLAYOUTS: + break; + default: + break; + } /*switch*/ } else { tmp.layout = options->op_tbl->objs[idx].layout; switch (tmp.layout) { - case H5D_CHUNKED: - tmp.chunk.rank = options->op_tbl->objs[idx].chunk.rank; - for (i = 0; i < tmp.chunk.rank; i++) - tmp.chunk.chunk_lengths[i] = options->op_tbl->objs[idx].chunk.chunk_lengths[i]; - break; - case H5D_LAYOUT_ERROR: - case H5D_COMPACT: - case H5D_CONTIGUOUS: - case H5D_NLAYOUTS: - break; - default: - break; - }/*switch*/ + case H5D_CHUNKED: + tmp.chunk.rank = options->op_tbl->objs[idx].chunk.rank; + for (i = 0; i < tmp.chunk.rank; i++) + tmp.chunk.chunk_lengths[i] = options->op_tbl->objs[idx].chunk.chunk_lengths[i]; + break; + case H5D_LAYOUT_ERROR: + case H5D_COMPACT: + case H5D_CONTIGUOUS: + case H5D_NLAYOUTS: + break; + default: + break; + } /*switch*/ } /* applying to all objects */ if (options->all_filter) { /* assign the global filter */ - tmp.nfilters = 1; + tmp.nfilters = 1; tmp.filter[0] = options->filter_g[0]; } /* if all */ else { @@ -195,20 +201,19 @@ static int aux_assign_obj(const char* name, /* object name from traverse list */ /* assign the global layout info to the OBJ info */ tmp.layout = options->layout_g; switch (options->layout_g) { - case H5D_CHUNKED: - tmp.chunk.rank = options->chunk_g.rank; - for (i = 0; i < tmp.chunk.rank; i++) - tmp.chunk.chunk_lengths[i] = - options->chunk_g.chunk_lengths[i]; - break; - case H5D_LAYOUT_ERROR: - case H5D_COMPACT: - case H5D_CONTIGUOUS: - case H5D_NLAYOUTS: - break; - default: - break; - }/*switch*/ + case H5D_CHUNKED: + tmp.chunk.rank = options->chunk_g.rank; + for (i = 0; i < tmp.chunk.rank; i++) + tmp.chunk.chunk_lengths[i] = options->chunk_g.chunk_lengths[i]; + break; + case H5D_LAYOUT_ERROR: + case H5D_COMPACT: + case H5D_CONTIGUOUS: + case H5D_NLAYOUTS: + break; + default: + break; + } /*switch*/ } } @@ -227,26 +232,27 @@ static int aux_assign_obj(const char* name, /* object name from traverse list */ *------------------------------------------------------------------------- */ -int apply_filters(const char* name, /* object name from traverse list */ - int rank, /* rank of dataset */ - hsize_t *dims, /* dimensions of dataset */ - size_t msize, /* size of type */ - hid_t dcpl_id, /* dataset creation property list */ - pack_opt_t *options, /* repack options */ - int *has_filter) /* (OUT) object NAME has a filter */ +int +apply_filters(const char *name, /* object name from traverse list */ + int rank, /* rank of dataset */ + hsize_t * dims, /* dimensions of dataset */ + size_t msize, /* size of type */ + hid_t dcpl_id, /* dataset creation property list */ + pack_opt_t *options, /* repack options */ + int * has_filter) /* (OUT) object NAME has a filter */ { - int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ - int nfilters; /* number of filters in DCPL */ - hsize_t chsize[64]; /* chunk size in elements */ + int nfilters; /* number of filters in DCPL */ + hsize_t chsize[64]; /* chunk size in elements */ H5D_layout_t layout; - int i; - pack_info_t obj; - pack_info_t filtobj; + int i; + pack_info_t obj; + pack_info_t filtobj; + int ret_value = 0; *has_filter = 0; if (rank == 0) /* scalar dataset, do not apply */ - HGOTO_DONE(0); + H5TOOLS_GOTO_DONE(0); /*------------------------------------------------------------------------- * initialize the assigment object @@ -260,12 +266,11 @@ int apply_filters(const char* name, /* object name from traverse list */ *------------------------------------------------------------------------- */ if (aux_assign_obj(name, options, &obj) == 0) - HGOTO_DONE(0); + H5TOOLS_GOTO_DONE(0); /* get information about input filters */ if ((nfilters = H5Pget_nfilters(dcpl_id)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_nfilters failed"); - + H5TOOLS_GOTO_ERROR((-1), "H5Pget_nfilters failed"); /*------------------------------------------------------------------------- * check if we have filters in the pipeline @@ -276,12 +281,12 @@ int apply_filters(const char* name, /* object name from traverse list */ if (nfilters && obj.nfilters) { *has_filter = 1; if (H5Premove_filter(dcpl_id, H5Z_FILTER_ALL) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Premove_filter failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Premove_filter failed"); } - else if(nfilters) { + else if (nfilters) { *has_filter = 1; if (aux_copy_obj(dcpl_id, name, &filtobj) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "aux_copy_obj failed"); + H5TOOLS_GOTO_ERROR((-1), "aux_copy_obj failed"); } /*------------------------------------------------------------------------- @@ -291,12 +296,12 @@ int apply_filters(const char* name, /* object name from traverse list */ */ if (obj.layout == -1) { if ((layout = H5Pget_layout(dcpl_id)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_layout failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pget_layout failed"); if (layout == H5D_CHUNKED) { - if ((rank = H5Pget_chunk(dcpl_id, NELMTS(chsize), chsize/*out*/)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_chunk failed"); - obj.layout = H5D_CHUNKED; + if ((rank = H5Pget_chunk(dcpl_id, NELMTS(chsize), chsize /*out*/)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pget_chunk failed"); + obj.layout = H5D_CHUNKED; obj.chunk.rank = rank; for (i = 0; i < rank; i++) obj.chunk.chunk_lengths[i] = chsize[i]; @@ -324,7 +329,7 @@ int apply_filters(const char* name, /* object name from traverse list */ if (obj.layout == -1) { /* stripmine info */ hsize_t sm_size[H5S_MAX_RANK]; /*stripmine size */ - hsize_t sm_nbytes; /*bytes per stripmine */ + hsize_t sm_nbytes; /*bytes per stripmine */ obj.chunk.rank = rank; @@ -335,12 +340,14 @@ int apply_filters(const char* name, /* object name from traverse list */ sm_nbytes = msize; for (i = rank; i > 0; --i) { - hsize_t size = H5TOOLS_BUFSIZE / sm_nbytes; + hsize_t size = 0; + if (sm_nbytes == 0) + H5TOOLS_GOTO_ERROR((-1), "number of bytes per stripmine must be > 0"); + size = H5TOOLS_BUFSIZE / sm_nbytes; if (size == 0) /* datum size > H5TOOLS_BUFSIZE */ size = 1; sm_size[i - 1] = MIN(dims[i - 1], size); sm_nbytes *= sm_size[i - 1]; - HDassert(sm_nbytes > 0); } for (i = 0; i < rank; i++) { @@ -350,126 +357,117 @@ int apply_filters(const char* name, /* object name from traverse list */ for (i = 0; i < obj.nfilters; i++) { if (obj.filter[i].filtn < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "invalid filter"); + H5TOOLS_GOTO_ERROR((-1), "invalid filter"); switch (obj.filter[i].filtn) { - /*------------------------------------------------------------------------- - * H5Z_FILTER_NONE 0 , uncompress if compressed - *------------------------------------------------------------------------- - */ - case H5Z_FILTER_NONE: - break; - - /*------------------------------------------------------------------------- - * H5Z_FILTER_DEFLATE 1 , deflation like gzip - *------------------------------------------------------------------------- - */ - case H5Z_FILTER_DEFLATE: - { + /*------------------------------------------------------------------------- + * H5Z_FILTER_NONE 0 , uncompress if compressed + *------------------------------------------------------------------------- + */ + case H5Z_FILTER_NONE: + break; + + /*------------------------------------------------------------------------- + * H5Z_FILTER_DEFLATE 1 , deflation like gzip + *------------------------------------------------------------------------- + */ + case H5Z_FILTER_DEFLATE: { unsigned aggression; /* the deflate level */ aggression = obj.filter[i].cd_values[0]; /* set up for deflated data */ if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_chunk failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed"); if (H5Pset_deflate(dcpl_id, aggression) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_deflate failed"); - } - break; - - /*------------------------------------------------------------------------- - * H5Z_FILTER_SZIP 4 , szip compression - *------------------------------------------------------------------------- - */ - case H5Z_FILTER_SZIP: - { + H5TOOLS_GOTO_ERROR((-1), "H5Pset_deflate failed"); + } break; + + /*------------------------------------------------------------------------- + * H5Z_FILTER_SZIP 4 , szip compression + *------------------------------------------------------------------------- + */ + case H5Z_FILTER_SZIP: { unsigned options_mask; unsigned pixels_per_block; - options_mask = obj.filter[i].cd_values[0]; + options_mask = obj.filter[i].cd_values[0]; pixels_per_block = obj.filter[i].cd_values[1]; /* set up for szip data */ if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_chunk failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed"); if (H5Pset_szip(dcpl_id, options_mask, pixels_per_block) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_szip failed"); - } - break; - - /*------------------------------------------------------------------------- - * H5Z_FILTER_SHUFFLE 2 , shuffle the data - *------------------------------------------------------------------------- - */ - case H5Z_FILTER_SHUFFLE: - if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_chunk failed"); - if (H5Pset_shuffle(dcpl_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_shuffle failed"); - break; - - /*------------------------------------------------------------------------- - * H5Z_FILTER_FLETCHER32 3 , fletcher32 checksum of EDC - *------------------------------------------------------------------------- - */ - case H5Z_FILTER_FLETCHER32: - if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_chunk failed"); - if (H5Pset_fletcher32(dcpl_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_fletcher32 failed"); - break; - /*----------- ------------------------------------------------------------- - * H5Z_FILTER_NBIT , NBIT compression - *------------------------------------------------------------------------- - */ - case H5Z_FILTER_NBIT: - if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_chunk failed"); - if (H5Pset_nbit(dcpl_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_nbit failed"); - break; - /*----------- ------------------------------------------------------------- - * H5Z_FILTER_SCALEOFFSET , scale+offset compression - *------------------------------------------------------------------------- - */ - case H5Z_FILTER_SCALEOFFSET: - { + H5TOOLS_GOTO_ERROR((-1), "H5Pset_szip failed"); + } break; + + /*------------------------------------------------------------------------- + * H5Z_FILTER_SHUFFLE 2 , shuffle the data + *------------------------------------------------------------------------- + */ + case H5Z_FILTER_SHUFFLE: + if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed"); + if (H5Pset_shuffle(dcpl_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pset_shuffle failed"); + break; + + /*------------------------------------------------------------------------- + * H5Z_FILTER_FLETCHER32 3 , fletcher32 checksum of EDC + *------------------------------------------------------------------------- + */ + case H5Z_FILTER_FLETCHER32: + if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed"); + if (H5Pset_fletcher32(dcpl_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pset_fletcher32 failed"); + break; + /*----------- ------------------------------------------------------------- + * H5Z_FILTER_NBIT , NBIT compression + *------------------------------------------------------------------------- + */ + case H5Z_FILTER_NBIT: + if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed"); + if (H5Pset_nbit(dcpl_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pset_nbit failed"); + break; + /*----------- ------------------------------------------------------------- + * H5Z_FILTER_SCALEOFFSET , scale+offset compression + *------------------------------------------------------------------------- + */ + case H5Z_FILTER_SCALEOFFSET: { H5Z_SO_scale_type_t scale_type; - int scale_factor; + int scale_factor; - scale_type = (H5Z_SO_scale_type_t) obj.filter[i].cd_values[0]; - scale_factor = (int) obj.filter[i].cd_values[1]; + scale_type = (H5Z_SO_scale_type_t)obj.filter[i].cd_values[0]; + scale_factor = (int)obj.filter[i].cd_values[1]; if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_chunk failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed"); if (H5Pset_scaleoffset(dcpl_id, scale_type, scale_factor) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_scaleoffset failed"); - } - break; - default: - { + H5TOOLS_GOTO_ERROR((-1), "H5Pset_scaleoffset failed"); + } break; + default: { if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_chunk failed"); - if (H5Pset_filter(dcpl_id, obj.filter[i].filtn, - obj.filter[i].filt_flag, obj.filter[i].cd_nelmts, - obj.filter[i].cd_values) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_filter failed"); - } - break; + H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed"); + if (H5Pset_filter(dcpl_id, obj.filter[i].filtn, obj.filter[i].filt_flag, + obj.filter[i].cd_nelmts, obj.filter[i].cd_values) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pset_filter failed"); + } break; } /* switch */ - }/*i*/ + } /*i*/ } /*obj.nfilters*/ if (filtobj.nfilters) { for (i = 0; i < filtobj.nfilters; i++) { if (filtobj.filter[i].filtn < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "invalid filter"); + H5TOOLS_GOTO_ERROR((-1), "invalid filter"); if (H5Zfilter_avail(filtobj.filter[i].filtn) <= 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "%d filter unavailable", filtobj.filter[i].filtn); + H5TOOLS_GOTO_ERROR((-1), "%d filter unavailable", filtobj.filter[i].filtn); } /* for */ - } /* nfilters */ + } /* nfilters */ /*------------------------------------------------------------------------- * layout @@ -479,24 +477,23 @@ int apply_filters(const char* name, /* object name from traverse list */ if (obj.layout >= 0) { /* a layout was defined */ if (H5Pset_layout(dcpl_id, obj.layout) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_layout failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_layout failed"); if (H5D_CHUNKED == obj.layout) { if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_chunk failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed"); } else if (H5D_COMPACT == obj.layout) { if (H5Pset_alloc_time(dcpl_id, H5D_ALLOC_TIME_EARLY) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_alloc_time failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_alloc_time failed"); } /* remove filters for the H5D_CONTIGUOUS case */ else if (H5D_CONTIGUOUS == obj.layout) { if (H5Premove_filter(dcpl_id, H5Z_FILTER_ALL) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Premove_filter failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Premove_filter failed"); } } done: return ret_value; } - diff --git a/tools/h5repack/h5repack_main.c b/tools/h5repack/h5repack_main.c index c739960..25d01d1 100644 --- a/tools/h5repack/h5repack_main.c +++ b/tools/h5repack/h5repack_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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -18,45 +18,43 @@ /* Name of tool */ #define PROGRAMNAME "h5repack" -static int parse_command_line(int argc, const char **argv, pack_opt_t* options); +static int parse_command_line(int argc, const char **argv, pack_opt_t *options); static void leave(int ret) H5_ATTR_NORETURN; - /* module-scoped variables */ -static int has_i_o = 0; -const char *infile = NULL; +static int has_i = 0; +static int has_o = 0; +const char *infile = NULL; const char *outfile = NULL; /* * Command-line options: The user can specify short or long-named * parameters. */ -static const char *s_opts = "hVvf:l:m:e:nLc:d:s:u:b:M:t:a:i:o:q:z:E"; -static struct long_options l_opts[] = { - { "help", no_arg, 'h' }, - { "version", no_arg, 'V' }, - { "verbose", no_arg, 'v' }, - { "filter", require_arg, 'f' }, - { "layout", require_arg, 'l' }, - { "minimum", require_arg, 'm' }, - { "file", require_arg, 'e' }, - { "native", no_arg, 'n' }, - { "latest", no_arg, 'L' }, - { "compact", require_arg, 'c' }, - { "indexed", require_arg, 'd' }, - { "ssize", require_arg, 's' }, - { "ublock", require_arg, 'u' }, - { "block", require_arg, 'b' }, - { "metadata_block_size", require_arg, 'M' }, - { "threshold", require_arg, 't' }, - { "alignment", require_arg, 'a' }, - { "infile", require_arg, 'i' }, /* -i for backward compability */ - { "outfile", require_arg, 'o' }, /* -o for backward compability */ - { "sort_by", require_arg, 'q' }, - { "sort_order", require_arg, 'z' }, - { "enable-error-stack", no_arg, 'E' }, - { NULL, 0, '\0' } -}; +static const char * s_opts = "hVvf:l:m:e:nLc:d:s:u:b:M:t:a:i:o:q:z:E"; +static struct long_options l_opts[] = {{"help", no_arg, 'h'}, + {"version", no_arg, 'V'}, + {"verbose", no_arg, 'v'}, + {"filter", require_arg, 'f'}, + {"layout", require_arg, 'l'}, + {"minimum", require_arg, 'm'}, + {"file", require_arg, 'e'}, + {"native", no_arg, 'n'}, + {"latest", no_arg, 'L'}, + {"compact", require_arg, 'c'}, + {"indexed", require_arg, 'd'}, + {"ssize", require_arg, 's'}, + {"ublock", require_arg, 'u'}, + {"block", require_arg, 'b'}, + {"metadata_block_size", require_arg, 'M'}, + {"threshold", require_arg, 't'}, + {"alignment", require_arg, 'a'}, + {"infile", require_arg, 'i'}, /* for backward compability */ + {"outfile", require_arg, 'o'}, /* for backward compability */ + {"sort_by", require_arg, 'q'}, + {"sort_order", require_arg, 'z'}, + {"enable-error-stack", no_arg, 'E'}, + {NULL, 0, '\0'}}; /*------------------------------------------------------------------------- * Function: usage @@ -67,7 +65,9 @@ static struct long_options l_opts[] = { * *------------------------------------------------------------------------- */ -static void usage(const char *prog) { +static void +usage(const char *prog) +{ FLUSHSTREAM(rawoutstream); PRINTSTREAM(rawoutstream, "usage: %s [OPTIONS] file1 file2\n", prog); PRINTVALSTREAM(rawoutstream, " file1 Input HDF5 File\n"); @@ -77,15 +77,22 @@ static void usage(const char *prog) { PRINTVALSTREAM(rawoutstream, " -v, --verbose Verbose mode, print object information\n"); PRINTVALSTREAM(rawoutstream, " -V, --version Print version number and exit\n"); PRINTVALSTREAM(rawoutstream, " -n, --native Use a native HDF5 type when repacking\n"); + PRINTVALSTREAM(rawoutstream, + " --enable-error-stack Prints messages from the HDF5 error stack as they\n"); + PRINTVALSTREAM(rawoutstream, " occur\n"); PRINTVALSTREAM(rawoutstream, " -L, --latest Use latest version of file format\n"); PRINTVALSTREAM(rawoutstream, " -c L1, --compact=L1 Maximum number of links in header messages\n"); - PRINTVALSTREAM(rawoutstream, " -d L2, --indexed=L2 Minimum number of links in the indexed format\n"); + PRINTVALSTREAM(rawoutstream, + " -d L2, --indexed=L2 Minimum number of links in the indexed format\n"); PRINTVALSTREAM(rawoutstream, " -s S[:F], --ssize=S[:F] Shared object header message minimum size\n"); - PRINTVALSTREAM(rawoutstream, " -m M, --minimum=M Do not apply the filter to datasets smaller than M\n"); + PRINTVALSTREAM(rawoutstream, + " -m M, --minimum=M Do not apply the filter to datasets smaller than M\n"); PRINTVALSTREAM(rawoutstream, " -e E, --file=E Name of file E with the -f and -l options\n"); - PRINTVALSTREAM(rawoutstream, " -u U, --ublock=U Name of file U with user block data to be added\n"); + PRINTVALSTREAM(rawoutstream, + " -u U, --ublock=U Name of file U with user block data to be added\n"); PRINTVALSTREAM(rawoutstream, " -b B, --block=B Size of user block to be added\n"); - PRINTVALSTREAM(rawoutstream, " -M A, --metadata_block_size=A Metadata block size for H5Pset_meta_block_size\n"); + PRINTVALSTREAM(rawoutstream, + " -M A, --metadata_block_size=A Metadata block size for H5Pset_meta_block_size\n"); PRINTVALSTREAM(rawoutstream, " -t T, --threshold=T Threshold value for H5Pset_alignment\n"); PRINTVALSTREAM(rawoutstream, " -a A, --alignment=A Alignment value for H5Pset_alignment\n"); PRINTVALSTREAM(rawoutstream, " -q Q, --sort_by=Q Sort groups and attributes by index Q\n"); @@ -93,28 +100,33 @@ static void usage(const char *prog) { PRINTVALSTREAM(rawoutstream, " -f FILT, --filter=FILT Filter type\n"); PRINTVALSTREAM(rawoutstream, " -l LAYT, --layout=LAYT Layout type\n"); PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " M - is an integer greater than 1, size of dataset in bytes (default is 0)\n"); + PRINTVALSTREAM(rawoutstream, + " M - is an integer greater than 1, size of dataset in bytes (default is 0)\n"); PRINTVALSTREAM(rawoutstream, " E - is a filename.\n"); PRINTVALSTREAM(rawoutstream, " S - is an integer\n"); PRINTVALSTREAM(rawoutstream, " U - is a filename.\n"); PRINTVALSTREAM(rawoutstream, " T - is an integer\n"); PRINTVALSTREAM(rawoutstream, " A - is an integer greater than zero\n"); - PRINTVALSTREAM(rawoutstream, " Q - is the sort index type for the input file. It can be \"name\" or \"creation_order\" (default)\n"); - PRINTVALSTREAM(rawoutstream, " Z - is the sort order type for the input file. It can be \"descending\" or \"ascending\" (default)\n"); + PRINTVALSTREAM(rawoutstream, + " Q - is the sort index type for the input file. It can be \"name\" or\n"); + PRINTVALSTREAM(rawoutstream, " \"creation_order\" (default)\n"); + PRINTVALSTREAM(rawoutstream, + " Z - is the sort order type for the input file. It can be \"descending\" or\n"); + PRINTVALSTREAM(rawoutstream, " \"ascending\" (default)\n"); PRINTVALSTREAM(rawoutstream, " B - is the user block size, any value that is 512 or greater and is\n"); PRINTVALSTREAM(rawoutstream, " a power of 2 (1024 default)\n"); - PRINTVALSTREAM(rawoutstream, " F - is the shared object header message type, any of <dspace|dtype|fill|\n"); + PRINTVALSTREAM(rawoutstream, + " F - is the shared object header message type, any of <dspace|dtype|fill|\n"); PRINTVALSTREAM(rawoutstream, " pline|attr>. If F is not specified, S applies to all messages\n"); PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " --enable-error-stack Prints messages from the HDF5 error stack as they\n"); - PRINTVALSTREAM(rawoutstream, " occur.\n"); - PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " FILT - is a string with the format:\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " <list of objects>:<name of filter>=<filter parameters>\n"); PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " <list of objects> is a comma separated list of object names, meaning apply\n"); - PRINTVALSTREAM(rawoutstream, " compression only to those objects. If no names are specified, the filter\n"); + PRINTVALSTREAM(rawoutstream, + " <list of objects> is a comma separated list of object names, meaning apply\n"); + PRINTVALSTREAM(rawoutstream, + " compression only to those objects. If no names are specified, the filter\n"); PRINTVALSTREAM(rawoutstream, " is applied to all objects\n"); PRINTVALSTREAM(rawoutstream, " <name of filter> can be:\n"); PRINTVALSTREAM(rawoutstream, " GZIP, to apply the HDF5 GZIP filter (GZIP compression)\n"); @@ -127,24 +139,30 @@ static void usage(const char *prog) { PRINTVALSTREAM(rawoutstream, " NONE, to remove all filters\n"); PRINTVALSTREAM(rawoutstream, " <filter parameters> is optional filter parameter information\n"); PRINTVALSTREAM(rawoutstream, " GZIP=<deflation level> from 1-9\n"); - PRINTVALSTREAM(rawoutstream, " SZIP=<pixels per block,coding> pixels per block is a even number in\n"); + PRINTVALSTREAM(rawoutstream, + " SZIP=<pixels per block,coding> pixels per block is a even number in\n"); PRINTVALSTREAM(rawoutstream, " 2-32 and coding method is either EC or NN\n"); PRINTVALSTREAM(rawoutstream, " SHUF (no parameter)\n"); PRINTVALSTREAM(rawoutstream, " FLET (no parameter)\n"); PRINTVALSTREAM(rawoutstream, " NBIT (no parameter)\n"); - PRINTVALSTREAM(rawoutstream, " SOFF=<scale_factor,scale_type> scale_factor is an integer and scale_type\n"); + PRINTVALSTREAM(rawoutstream, + " SOFF=<scale_factor,scale_type> scale_factor is an integer and scale_type\n"); PRINTVALSTREAM(rawoutstream, " is either IN or DS\n"); - PRINTVALSTREAM(rawoutstream, " UD=<filter_number,filter_flag,cd_value_count,value_1[,value_2,...,value_N]>\n"); - PRINTVALSTREAM(rawoutstream, " required values for filter_number,filter_flag,cd_value_count,value_1\n"); - PRINTVALSTREAM(rawoutstream, " optional values for value_2 to value_N\n"); + PRINTVALSTREAM(rawoutstream, + " UD=<filter_number,filter_flag,cd_value_count,value1[,value2,...,valueN]>\n"); + PRINTVALSTREAM(rawoutstream, + " Required values: filter_number, filter_flag, cd_value_count, value1\n"); + PRINTVALSTREAM(rawoutstream, " Optional values: value2 to valueN\n"); PRINTVALSTREAM(rawoutstream, " NONE (no parameter)\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " LAYT - is a string with the format:\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " <list of objects>:<layout type>=<layout parameters>\n"); PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " <list of objects> is a comma separated list of object names, meaning that\n"); - PRINTVALSTREAM(rawoutstream, " layout information is supplied for those objects. If no names are\n"); + PRINTVALSTREAM(rawoutstream, + " <list of objects> is a comma separated list of object names, meaning that\n"); + PRINTVALSTREAM(rawoutstream, + " layout information is supplied for those objects. If no names are\n"); PRINTVALSTREAM(rawoutstream, " specified, the layout type is applied to all objects\n"); PRINTVALSTREAM(rawoutstream, " <layout type> can be:\n"); PRINTVALSTREAM(rawoutstream, " CHUNK, to apply chunking layout\n"); @@ -163,17 +181,20 @@ static void usage(const char *prog) { PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, "2) h5repack -v -f dset1:SZIP=8,NN file1 file2\n"); PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " SZIP compression with 8 pixels per block and NN coding method to object dset1\n"); + PRINTVALSTREAM(rawoutstream, + " SZIP compression with 8 pixels per block and NN coding method to object dset1\n"); PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, "3) h5repack -v -l dset1,dset2:CHUNK=20x10 -f dset3,dset4,dset5:NONE file1 file2\n"); + PRINTVALSTREAM(rawoutstream, + "3) h5repack -v -l dset1,dset2:CHUNK=20x10 -f dset3,dset4,dset5:NONE file1 file2\n"); PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " Chunked layout, with a layout size of 20x10, to objects dset1 and dset2\n"); + PRINTVALSTREAM(rawoutstream, + " Chunked layout, with a layout size of 20x10, to objects dset1 and dset2\n"); PRINTVALSTREAM(rawoutstream, " and remove filters to objects dset3, dset4, dset5\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, "4) h5repack -L -c 10 -s 20:dtype file1 file2\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " Using latest file format with maximum compact group size of 10 and\n"); - PRINTVALSTREAM(rawoutstream, " and minimum shared datatype size of 20\n"); + PRINTVALSTREAM(rawoutstream, " minimum shared datatype size of 20\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, "5) h5repack -f SHUF -f GZIP=1 file1 file2\n"); PRINTVALSTREAM(rawoutstream, "\n"); @@ -193,7 +214,8 @@ static void usage(const char *prog) { * Return: Does not return *------------------------------------------------------------------------- */ -static void leave(int ret) +static void +leave(int ret) { h5tools_close(); HDexit(ret); @@ -207,17 +229,17 @@ static void leave(int ret) * Return: void, exit on error *------------------------------------------------------------------------- */ -static -int read_info(const char *filename, pack_opt_t *options) +static int +read_info(const char *filename, pack_opt_t *options) { - char stype[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - char comp_info[1024]; + char stype[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + char comp_info[1024]; FILE *fp = NULL; - char c; - int i, rc = 1; - int ret_value = EXIT_SUCCESS; + char c; + int i; + int ret_value = EXIT_SUCCESS; - if ((fp = HDfopen(filename, "r")) == (FILE *) NULL) { + if (NULL == (fp = HDfopen(filename, "r"))) { error_msg("cannot open options file %s\n", filename); h5tools_setstatus(EXIT_FAILURE); ret_value = EXIT_FAILURE; @@ -226,108 +248,64 @@ int read_info(const char *filename, pack_opt_t *options) /* cycle until end of file reached */ while (1) { - rc = fscanf(fp, "%s", stype); - if (rc == -1) + if (EOF == fscanf(fp, "%9s", stype)) break; - /*------------------------------------------------------------------------- - * filter - *------------------------------------------------------------------------- - */ - if (HDstrcmp(stype,"-f") == 0) { - /* find begining of info */ - i = 0; - c = '0'; - while (c != ' ') { - if(fscanf(fp, "%c", &c) < 0 && HDferror(fp)) { - error_msg("fscanf error\n"); - h5tools_setstatus(EXIT_FAILURE); - ret_value = EXIT_FAILURE; - goto done; - } /* end if */ - if (HDfeof(fp)) - break; - } - c = '0'; - /* go until end */ - while (c != ' ') { - if(fscanf(fp, "%c", &c) < 0 && HDferror(fp)) { - error_msg("fscanf error\n"); - h5tools_setstatus(EXIT_FAILURE); - ret_value = EXIT_FAILURE; - goto done; - } /* end if */ - comp_info[i] = c; - i++; - if (HDfeof(fp)) - break; - if (c == 10 /*eol*/) - break; - } - comp_info[i - 1] = '\0'; /*cut the last " */ + /* Info indicator must be for layout or filter */ + if (HDstrcmp(stype, "-l") && HDstrcmp(stype, "-f")) { + error_msg("bad file format for %s", filename); + h5tools_setstatus(EXIT_FAILURE); + ret_value = EXIT_FAILURE; + goto done; + } - if (h5repack_addfilter(comp_info, options) == -1) { - error_msg("could not add compression option\n"); + /* find begining of info */ + i = 0; + c = '0'; + while (c != ' ') { + if (fscanf(fp, "%c", &c) < 0 && HDferror(fp)) { + error_msg("fscanf error\n"); h5tools_setstatus(EXIT_FAILURE); ret_value = EXIT_FAILURE; goto done; } + if (HDfeof(fp)) + break; } - /*------------------------------------------------------------------------- - * layout - *------------------------------------------------------------------------- - */ - else if (HDstrcmp(stype,"-l") == 0) { - - /* find begining of info */ - i = 0; - c = '0'; - while (c != ' ') { - if(fscanf(fp, "%c", &c) < 0 && HDferror(fp)) { - error_msg("fscanf error\n"); - h5tools_setstatus(EXIT_FAILURE); - ret_value = EXIT_FAILURE; - goto done; - } /* end if */ - if (HDfeof(fp)) - break; - } - c = '0'; - /* go until end */ - while (c != ' ') { - if(fscanf(fp, "%c", &c) < 0 && HDferror(fp)) { - error_msg("fscanf error\n"); - h5tools_setstatus(EXIT_FAILURE); - ret_value = EXIT_FAILURE; - goto done; - } /* end if */ - comp_info[i] = c; - i++; - if (HDfeof(fp)) - break; - if (c == 10 /*eol*/) - break; + c = '0'; + /* go until end */ + while (c != ' ') { + if (fscanf(fp, "%c", &c) < 0 && HDferror(fp)) { + error_msg("fscanf error\n"); + h5tools_setstatus(EXIT_FAILURE); + ret_value = EXIT_FAILURE; + goto done; } - comp_info[i - 1] = '\0'; /*cut the last " */ + comp_info[i++] = c; + if (HDfeof(fp)) + break; + if (c == 10 /*eol*/) + break; + } + comp_info[i - 1] = '\0'; /*cut the last " */ + if (!HDstrcmp(stype, "-l")) { if (h5repack_addlayout(comp_info, options) == -1) { - error_msg("could not add chunck option\n"); + error_msg("could not add chunk option\n"); h5tools_setstatus(EXIT_FAILURE); ret_value = EXIT_FAILURE; goto done; } } - /*------------------------------------------------------------------------- - * not valid - *------------------------------------------------------------------------- - */ else { - error_msg("bad file format for %s", filename); - h5tools_setstatus(EXIT_FAILURE); - ret_value = EXIT_FAILURE; - goto done; + if (h5repack_addfilter(comp_info, options) == -1) { + error_msg("could not add compression option\n"); + h5tools_setstatus(EXIT_FAILURE); + ret_value = EXIT_FAILURE; + goto done; + } } - } + } /* end while info-read cycling */ done: if (fp) @@ -351,9 +329,9 @@ set_sort_by(const char *form) { H5_index_t idx_type = H5_INDEX_UNKNOWN; - if (HDstrcmp(form,"name")==0) /* H5_INDEX_NAME */ + if (!HDstrcmp(form, "name")) idx_type = H5_INDEX_NAME; - else if (HDstrcmp(form,"creation_order")==0) /* H5_INDEX_CRT_ORDER */ + else if (!HDstrcmp(form, "creation_order")) idx_type = H5_INDEX_CRT_ORDER; return idx_type; @@ -374,9 +352,9 @@ set_sort_order(const char *form) { H5_iter_order_t iter_order = H5_ITER_UNKNOWN; - if (HDstrcmp(form,"ascending")==0) /* H5_ITER_INC */ + if (!HDstrcmp(form, "ascending")) iter_order = H5_ITER_INC; - else if (HDstrcmp(form,"descending")==0) /* H5_ITER_DEC */ + else if (!HDstrcmp(form, "descending")) iter_order = H5_ITER_DEC; return iter_order; @@ -388,38 +366,38 @@ set_sort_order(const char *form) * Purpose: parse command line input *------------------------------------------------------------------------- */ -static -int parse_command_line(int argc, const char **argv, pack_opt_t* options) +static int +parse_command_line(int argc, const char **argv, pack_opt_t *options) { int opt; int ret_value = 0; /* parse command line options */ - while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { - switch ((char) opt) { + while (EOF != (opt = get_option(argc, argv, s_opts, l_opts))) { + switch ((char)opt) { /* -i for backward compatibility */ case 'i': infile = opt_arg; - has_i_o = 1; + has_i++; break; /* -o for backward compatibility */ case 'o': outfile = opt_arg; - has_i_o = 1; + has_o++; break; case 'h': usage(h5tools_getprogname()); h5tools_setstatus(EXIT_SUCCESS); - ret_value = -1; + ret_value = 1; goto done; case 'V': print_version(h5tools_getprogname()); h5tools_setstatus(EXIT_SUCCESS); - ret_value = -1; + ret_value = 1; goto done; case 'v': @@ -447,8 +425,8 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) break; case 'm': - options->min_comp = HDstrtoull(opt_arg , NULL, 0); - if ((int) options->min_comp <= 0) { + options->min_comp = HDstrtoull(opt_arg, NULL, 0); + if ((int)options->min_comp <= 0) { error_msg("invalid minimum compress size <%s>\n", opt_arg); h5tools_setstatus(EXIT_FAILURE); ret_value = -1; @@ -457,9 +435,12 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) break; case 'e': - ret_value = read_info(opt_arg, options); - if (ret_value < 0) + if ((ret_value = read_info(opt_arg, options)) < 0) { + error_msg("failed to read from repack options file <%s>\n", opt_arg); + h5tools_setstatus(EXIT_FAILURE); + ret_value = -1; goto done; + } break; case 'n': @@ -471,66 +452,64 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) break; case 'c': - options->grp_compact = HDatoi( opt_arg ); + options->grp_compact = HDatoi(opt_arg); if (options->grp_compact > 0) options->latest = TRUE; /* must use latest format */ break; case 'd': - options->grp_indexed = HDatoi( opt_arg ); + options->grp_indexed = HDatoi(opt_arg); if (options->grp_indexed > 0) options->latest = TRUE; /* must use latest format */ break; - case 's': - { - int idx = 0; - int ssize = 0; - char *msgPtr = HDstrchr( opt_arg, ':'); - options->latest = TRUE; /* must use latest format */ - if (msgPtr == NULL) { - ssize = HDatoi( opt_arg ); - for (idx = 0; idx < 5; idx++) - options->msg_size[idx] = ssize; - } - else { - char msgType[10]; - - HDstrcpy(msgType, msgPtr + 1); - msgPtr[0] = '\0'; - ssize = HDatoi( opt_arg ); - if (HDstrncmp(msgType, "dspace",6) == 0) - options->msg_size[0] = ssize; - else if (HDstrncmp(msgType, "dtype", 5) == 0) - options->msg_size[1] = ssize; - else if (HDstrncmp(msgType, "fill", 4) == 0) - options->msg_size[2] = ssize; - else if (HDstrncmp(msgType, "pline", 5) == 0) - options->msg_size[3] = ssize; - else if (HDstrncmp(msgType, "attr", 4) == 0) - options->msg_size[4] = ssize; - } + case 's': { + int idx = 0; + int ssize = 0; + char *msgPtr = HDstrchr(opt_arg, ':'); + options->latest = TRUE; /* must use latest format */ + if (msgPtr == NULL) { + ssize = HDatoi(opt_arg); + for (idx = 0; idx < 5; idx++) + options->msg_size[idx] = ssize; } - break; + else { + char msgType[10]; + + HDstrcpy(msgType, msgPtr + 1); + msgPtr[0] = '\0'; + ssize = HDatoi(opt_arg); + if (!HDstrncmp(msgType, "dspace", 6)) + options->msg_size[0] = ssize; + else if (!HDstrncmp(msgType, "dtype", 5)) + options->msg_size[1] = ssize; + else if (!HDstrncmp(msgType, "fill", 4)) + options->msg_size[2] = ssize; + else if (!HDstrncmp(msgType, "pline", 5)) + options->msg_size[3] = ssize; + else if (!HDstrncmp(msgType, "attr", 4)) + options->msg_size[4] = ssize; + } + } break; case 'u': options->ublock_filename = opt_arg; break; case 'b': - options->ublock_size = (hsize_t) HDatol( opt_arg ); + options->ublock_size = (hsize_t)HDatol(opt_arg); break; case 'M': - options->meta_block_size = (hsize_t) HDatol( opt_arg ); + options->meta_block_size = (hsize_t)HDatol(opt_arg); break; case 't': - options->threshold = (hsize_t) HDatol( opt_arg ); + options->threshold = (hsize_t)HDatol(opt_arg); break; case 'a': - options->alignment = HDstrtoull(opt_arg , NULL, 0); + options->alignment = HDstrtoull(opt_arg, NULL, 0); if (options->alignment < 1) { error_msg("invalid alignment size\n", opt_arg); h5tools_setstatus(EXIT_FAILURE); @@ -540,7 +519,7 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) break; case 'q': - if((sort_by = set_sort_by(opt_arg)) < 0) { + if (H5_INDEX_UNKNOWN == (sort_by = set_sort_by(opt_arg))) { error_msg(" failed to set sort by form <%s>\n", opt_arg); h5tools_setstatus(EXIT_FAILURE); ret_value = -1; @@ -549,7 +528,7 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) break; case 'z': - if((sort_order = set_sort_order(opt_arg)) < 0) { + if (H5_ITER_UNKNOWN == (sort_order = set_sort_order(opt_arg))) { error_msg(" failed to set sort order form <%s>\n", opt_arg); h5tools_setstatus(EXIT_FAILURE); ret_value = -1; @@ -563,18 +542,35 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) default: break; - } /* switch */ - } /* while */ + } /* end switch */ + } /* end while there are more options to parse */ + + /* If neither -i nor -o given, get in and out files positionally */ + if (0 == (has_i + has_o)) { + if (argv[opt_ind] != NULL && argv[opt_ind + 1] != NULL) { + infile = argv[opt_ind]; + outfile = argv[opt_ind + 1]; - if (has_i_o == 0) { - /* check for file names to be processed */ - if (argc <= opt_ind || argv[opt_ind + 1] == NULL) { - error_msg("missing file names\n"); + if (!HDstrcmp(infile, outfile)) { + error_msg("file names cannot be the same\n"); + usage(h5tools_getprogname()); + h5tools_setstatus(EXIT_FAILURE); + ret_value = -1; + } + } + else { + error_msg("file names missing\n"); usage(h5tools_getprogname()); h5tools_setstatus(EXIT_FAILURE); ret_value = -1; } } + else if (has_i != 1 || has_o != 1) { + error_msg("filenames must be either both -i -o or both positional\n"); + usage(h5tools_getprogname()); + h5tools_setstatus(EXIT_FAILURE); + ret_value = -1; + } done: return ret_value; @@ -590,13 +586,17 @@ done: * Failure: EXIT_FAILURE(1) *------------------------------------------------------------------------- */ -int main(int argc, const char **argv) +int +main(int argc, const char **argv) { - pack_opt_t options; /*the global options */ - H5E_auto2_t func; - H5E_auto2_t tools_func; - void *edata; - void *tools_edata; + pack_opt_t options; /*the global options */ + H5E_auto2_t func; + H5E_auto2_t tools_func; + void * edata; + void * tools_edata; + int parse_ret; + + HDmemset(&options, 0, sizeof(pack_opt_t)); h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); @@ -614,41 +614,31 @@ int main(int argc, const char **argv) /* update hyperslab buffer size from H5TOOLS_BUFSIZE env if exist */ if (h5tools_getenv_update_hyperslab_bufsize() < 0) { + HDprintf("Error occurred while retrieving H5TOOLS_BUFSIZE value\n"); h5tools_setstatus(EXIT_FAILURE); goto done; } /* initialize options */ if (h5repack_init(&options, 0, FALSE) < 0) { + HDprintf("Error occurred while initializing repack options\n"); h5tools_setstatus(EXIT_FAILURE); goto done; } + /* Initialize default indexing options */ sort_by = H5_INDEX_CRT_ORDER; - if (parse_command_line(argc, argv, &options) < 0) + parse_ret = parse_command_line(argc, argv, &options); + if (parse_ret < 0) { + HDprintf("Error occurred while parsing command-line options\n"); + h5tools_setstatus(EXIT_FAILURE); + goto done; + } + else if (parse_ret > 0) { + /* Short-circuit success */ + h5tools_setstatus(EXIT_SUCCESS); goto done; - - /* get file names if they were not yet got */ - if (has_i_o == 0) { - - if (argv[opt_ind] != NULL && argv[opt_ind + 1] != NULL) { - infile = argv[opt_ind]; - outfile = argv[opt_ind + 1]; - - if ( HDstrcmp( infile, outfile ) == 0) { - error_msg("file names cannot be the same\n"); - usage(h5tools_getprogname()); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - } - else { - error_msg("file names missing\n"); - usage(h5tools_getprogname()); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } } if (enable_error_stack > 0) { @@ -657,7 +647,13 @@ int main(int argc, const char **argv) } /* pack it */ - h5tools_setstatus(h5repack(infile, outfile, &options)); + if (h5repack(infile, outfile, &options) < 0) { + HDprintf("Error occurred while repacking\n"); + h5tools_setstatus(EXIT_FAILURE); + goto done; + } + + h5tools_setstatus(EXIT_SUCCESS); done: /* free tables */ @@ -665,4 +661,3 @@ done: leave(h5tools_getstatus()); } - diff --git a/tools/h5repack/h5repack_opttable.c b/tools/h5repack/h5repack_opttable.c index b816176..2fd39fd 100644 --- a/tools/h5repack/h5repack_opttable.c +++ b/tools/h5repack/h5repack_opttable.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,23 +21,25 @@ * Purpose: initialize a pack_info_t structure * * Return: void - *------------------------------------------------------------------------- + *------------------------------------------------------------------------- */ -void init_packobject(pack_info_t *obj) { +void +init_packobject(pack_info_t *obj) +{ int j, k; HDstrcpy(obj->path, "\0"); for (j = 0; j < H5_REPACK_MAX_NFILTERS; j++) { - obj->filter[j].filtn = -1; + obj->filter[j].filtn = -1; obj->filter[j].cd_nelmts = CD_VALUES; for (k = 0; k < CD_VALUES; k++) obj->filter[j].cd_values[k] = 0; } obj->chunk.rank = -1; - obj->refobj_id = -1; - obj->layout = H5D_LAYOUT_ERROR; - obj->nfilters = 0; + obj->refobj_id = -1; + obj->layout = H5D_LAYOUT_ERROR; + obj->nfilters = 0; } /*------------------------------------------------------------------------- @@ -49,11 +51,13 @@ void init_packobject(pack_info_t *obj) { *------------------------------------------------------------------------- */ -static void aux_tblinsert_filter(pack_opttbl_t *table, unsigned int I, filter_info_t filt) { +static void +aux_tblinsert_filter(pack_opttbl_t *table, unsigned int I, filter_info_t filt) +{ if (table->objs[I].nfilters < H5_REPACK_MAX_NFILTERS) table->objs[I].filter[table->objs[I].nfilters++] = filt; else - H5TOOLS_INFO(H5E_tools_min_id_g, "cannot insert the filter in this object. Maximum capacity exceeded"); + H5TOOLS_INFO("cannot insert the filter in this object. Maximum capacity exceeded"); } /*------------------------------------------------------------------------- @@ -64,7 +68,9 @@ static void aux_tblinsert_filter(pack_opttbl_t *table, unsigned int I, filter_in * Return: void *------------------------------------------------------------------------- */ -static void aux_tblinsert_layout(pack_opttbl_t *table, unsigned int I, pack_info_t *pack) { +static void +aux_tblinsert_layout(pack_opttbl_t *table, unsigned int I, pack_info_t *pack) +{ int k; table->objs[I].layout = pack->layout; @@ -72,15 +78,14 @@ static void aux_tblinsert_layout(pack_opttbl_t *table, unsigned int I, pack_info /* -2 means the NONE option, remove chunking and set the layout to contiguous */ if (pack->chunk.rank == -2) { - table->objs[I].layout = H5D_CONTIGUOUS; + table->objs[I].layout = H5D_CONTIGUOUS; table->objs[I].chunk.rank = -2; } /* otherwise set the chunking type */ else { table->objs[I].chunk.rank = pack->chunk.rank; for (k = 0; k < pack->chunk.rank; k++) - table->objs[I].chunk.chunk_lengths[k] = - pack->chunk.chunk_lengths[k]; + table->objs[I].chunk.chunk_lengths[k] = pack->chunk.chunk_lengths[k]; } } } @@ -97,54 +102,56 @@ static int aux_inctable(pack_opttbl_t *table, unsigned n_objs) { unsigned u; + int ret_value = 0; table->size += n_objs; - table->objs = (pack_info_t*) HDrealloc(table->objs, table->size * sizeof(pack_info_t)); + table->objs = (pack_info_t *)HDrealloc(table->objs, table->size * sizeof(pack_info_t)); if (table->objs == NULL) { - H5TOOLS_INFO(H5E_tools_min_id_g, "not enough memory for options table"); - return -1; + H5TOOLS_INFO("not enough memory for options table"); + ret_value = -1; + } + else { + for (u = table->nelems; u < table->size; u++) + init_packobject(&table->objs[u]); } - for (u = table->nelems; u < table->size; u++) - init_packobject(&table->objs[u]); - - return 0; + return ret_value; } - /*------------------------------------------------------------------------- * Function: options_table_init * * Purpose: init options table * * Return: 0, ok, -1, fail - *------------------------------------------------------------------------- + *------------------------------------------------------------------------- */ -int options_table_init(pack_opttbl_t **tbl) { - unsigned int i; +int +options_table_init(pack_opttbl_t **tbl) +{ + unsigned int i; pack_opttbl_t *table; + int ret_value = 0; - if (NULL == (table = (pack_opttbl_t *) HDmalloc(sizeof(pack_opttbl_t)))) { - H5TOOLS_INFO(H5E_tools_min_id_g, "not enough memory for options table"); - return -1; + if (NULL == (table = (pack_opttbl_t *)HDmalloc(sizeof(pack_opttbl_t)))) { + H5TOOLS_GOTO_ERROR((-1), "not enough memory for options table"); } - table->size = 30; + table->size = 30; table->nelems = 0; - if (NULL == (table->objs = (pack_info_t*) HDmalloc(table->size * sizeof(pack_info_t)))) { - H5TOOLS_INFO(H5E_tools_min_id_g, "not enough memory for options table"); + if (NULL == (table->objs = (pack_info_t *)HDmalloc(table->size * sizeof(pack_info_t)))) { HDfree(table); - return -1; + H5TOOLS_GOTO_ERROR((-1), "not enough memory for options table"); } for (i = 0; i < table->size; i++) init_packobject(&table->objs[i]); *tbl = table; - return 0; +done: + return ret_value; } - /*------------------------------------------------------------------------- * Function: options_table_free * @@ -154,7 +161,9 @@ int options_table_init(pack_opttbl_t **tbl) { *------------------------------------------------------------------------- */ -int options_table_free(pack_opttbl_t *table) { +int +options_table_free(pack_opttbl_t *table) +{ HDfree(table->objs); HDfree(table); return 0; @@ -166,14 +175,15 @@ int options_table_free(pack_opttbl_t *table) { * Purpose: add a layout option to the option list * * Return: 0, ok, -1, fail - *------------------------------------------------------------------------- + *------------------------------------------------------------------------- */ int -options_add_layout(obj_list_t *obj_list, unsigned n_objs, pack_info_t *pack, pack_opttbl_t *table) +options_add_layout(obj_list_t *obj_list, unsigned n_objs, pack_info_t *pack, pack_opttbl_t *table) { unsigned i, j, I; - unsigned added = 0; - int found = FALSE; + unsigned added = 0; + hbool_t found = FALSE; + int ret_value = 0; /* increase the size of the collection by N_OBJS if necessary */ if (table->nelems + n_objs >= table->size) @@ -187,10 +197,10 @@ options_add_layout(obj_list_t *obj_list, unsigned n_objs, pack_info_t *pack, pa /* linear table search */ for (i = 0; i < table->nelems; i++) { /*already on the table */ - if (HDstrcmp(obj_list[j].obj,table->objs[i].path) == 0) { + if (HDstrcmp(obj_list[j].obj, table->objs[i].path) == 0) { /* already chunk info inserted for this one; exit */ if (table->objs[i].chunk.rank > 0) { - H5TOOLS_INFO(H5E_tools_min_id_g, "chunk information already inserted for <%s>\n", obj_list[j].obj); + H5TOOLS_INFO("chunk information already inserted for <%s>\n", obj_list[j].obj); HDexit(EXIT_FAILURE); } /* insert the layout info */ @@ -200,7 +210,7 @@ options_add_layout(obj_list_t *obj_list, unsigned n_objs, pack_info_t *pack, pa break; } } /* if */ - } /* i */ + } /* i */ if (!found) { /* keep the grow in a temp var */ @@ -214,14 +224,13 @@ options_add_layout(obj_list_t *obj_list, unsigned n_objs, pack_info_t *pack, pa -f dset1:GZIP=1 -l dset1,dset2:CHUNK=20x20 dset1 is already inserted, but dset2 must also be */ - else - if(found && HDstrcmp(obj_list[j].obj,table->objs[i].path) != 0) { - /* keep the grow in a temp var */ - I = table->nelems + added; - added++; - HDstrcpy(table->objs[I].path, obj_list[j].obj); - aux_tblinsert_layout(table, I, pack); - } + else if (found && HDstrcmp(obj_list[j].obj, table->objs[i].path) != 0) { + /* keep the grow in a temp var */ + I = table->nelems + added; + added++; + HDstrcpy(table->objs[I].path, obj_list[j].obj); + aux_tblinsert_layout(table, I, pack); + } } /* j */ } /* first time insertion */ @@ -237,7 +246,7 @@ options_add_layout(obj_list_t *obj_list, unsigned n_objs, pack_info_t *pack, pa table->nelems += added; - return 0; + return ret_value; } /*------------------------------------------------------------------------- @@ -252,8 +261,8 @@ int options_add_filter(obj_list_t *obj_list, unsigned n_objs, filter_info_t filt, pack_opttbl_t *table) { unsigned int i, j, I; - unsigned added = 0; - int found = FALSE; + unsigned added = 0; + hbool_t found = FALSE; /* increase the size of the collection by N_OBJS if necessary */ if (table->nelems + n_objs >= table->size) @@ -273,7 +282,7 @@ options_add_filter(obj_list_t *obj_list, unsigned n_objs, filter_info_t filt, pa found = TRUE; break; } /* if */ - } /* i */ + } /* i */ if (!found) { /* keep the grow in a temp var */ @@ -287,14 +296,13 @@ options_add_filter(obj_list_t *obj_list, unsigned n_objs, filter_info_t filt, pa -l dset1:CHUNK=20x20 -f dset1,dset2:GZIP=1 dset1 is already inserted, but dset2 must also be */ - else - if(found && HDstrcmp(obj_list[j].obj,table->objs[i].path) != 0) { - /* keep the grow in a temp var */ - I = table->nelems + added; - added++; - HDstrcpy(table->objs[I].path, obj_list[j].obj); - aux_tblinsert_filter(table, I, filt); - } + else if (found && HDstrcmp(obj_list[j].obj, table->objs[i].path) != 0) { + /* keep the grow in a temp var */ + I = table->nelems + added; + added++; + HDstrcpy(table->objs[I].path, obj_list[j].obj); + aux_tblinsert_filter(table, I, filt); + } } /* j */ } @@ -323,9 +331,11 @@ options_add_filter(obj_list_t *obj_list, unsigned n_objs, filter_info_t filt, pa *------------------------------------------------------------------------- */ -pack_info_t* options_get_object(const char *path, pack_opttbl_t *table) { +pack_info_t * +options_get_object(const char *path, pack_opttbl_t *table) +{ unsigned int i; - char tbl_path[MAX_NC_NAME + 1]; /* +1 for start with "/" case */ + char tbl_path[MAX_NC_NAME + 1]; /* +1 for start with "/" case */ for (i = 0; i < table->nelems; i++) { /* make full path (start with "/") to compare correctly */ diff --git a/tools/h5repack/h5repack_parse.c b/tools/h5repack/h5repack_parse.c index f646ee7..1bfed8b 100644 --- a/tools/h5repack/h5repack_parse.c +++ b/tools/h5repack/h5repack_parse.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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -37,8 +37,9 @@ * "A,B:NONE" *------------------------------------------------------------------------- */ -obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, - pack_opt_t *options, int *is_glb) { +obj_list_t * +parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, pack_opt_t *options, int *is_glb) +{ size_t i, m, u; char c; size_t len = HDstrlen(str); @@ -48,7 +49,7 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, char scomp[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; char stype[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; char smask[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - obj_list_t* obj_list = NULL; + obj_list_t *obj_list = NULL; unsigned pixels_per_block; /* initialize compression info */ @@ -59,7 +60,7 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, for (i = 0, n = 0; i < len; i++) { c = str[i]; if (c == ':') { - end_obj = (int) i; + end_obj = (int)i; break; } if (c == ',') @@ -71,13 +72,13 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, if (end_obj == -1) { /* apply to all objects */ options->all_filter = 1; - *is_glb = 1; - *n_objs = 1; + *is_glb = 1; + *n_objs = 1; } else *n_objs = n; - obj_list = (obj_list_t *) HDmalloc(n * sizeof(obj_list_t)); + obj_list = (obj_list_t *)HDmalloc(n * sizeof(obj_list_t)); if (obj_list == NULL) { error_msg("could not allocate object list\n"); return NULL; @@ -85,10 +86,10 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, /* get object list */ if (end_obj > 0) - for (j = 0, k = 0, n = 0; j < (unsigned) end_obj; j++, k++) { - c = str[j]; + for (j = 0, k = 0, n = 0; j < (unsigned)end_obj; j++, k++) { + c = str[j]; sobj[k] = c; - if (c == ',' || j == (unsigned) (end_obj - 1)) { + if (c == ',' || j == (unsigned)(end_obj - 1)) { if (c == ',') sobj[k] = '\0'; else @@ -101,7 +102,7 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, } } /* nothing after : */ - if (end_obj + 1 == (int) len) { + if (end_obj + 1 == (int)len) { if (obj_list) HDfree(obj_list); error_msg("input Error: Invalid compression type in <%s>\n", str); @@ -111,25 +112,25 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, /* get filter additional parameters */ m = 0; for (i = (size_t)(end_obj + 1), k = 0, j = 0; i < len; i++, k++) { - c = str[i]; + c = str[i]; scomp[k] = c; if (c == '=' || i == len - 1) { - if (c == '=') { /*one more parameter */ + if (c == '=') { /*one more parameter */ scomp[k] = '\0'; /*cut space */ /*------------------------------------------------------------------------- - * H5Z_FILTER_SZIP - * szip has the format SZIP=<pixels per block,coding> - * pixels per block is a even number in 2-32 and coding method is 'EC' or 'NN' - * example SZIP=8,NN - *------------------------------------------------------------------------- - */ + * H5Z_FILTER_SZIP + * szip has the format SZIP=<pixels per block,coding> + * pixels per block is a even number in 2-32 and coding method is 'EC' or 'NN' + * example SZIP=8,NN + *------------------------------------------------------------------------- + */ if (HDstrcmp(scomp, "SZIP") == 0) { l = -1; /* mask index check */ for (m = 0, u = i + 1; u < len; u++, m++) { if (str[u] == ',') { stype[m] = '\0'; /* end digit of szip */ - l = 0; /* start EC or NN search */ - u++; /* skip ',' */ + l = 0; /* start EC or NN search */ + u++; /* skip ',' */ } c = str[u]; if (!HDisdigit(c) && l == -1) { @@ -145,10 +146,10 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, l++; if (l == 2) { smask[l] = '\0'; - i = len - 1; /* end */ - if (HDstrcmp(smask,"NN") == 0) + i = len - 1; /* end */ + if (HDstrcmp(smask, "NN") == 0) filt->cd_values[j++] = H5_SZIP_NN_OPTION_MASK; - else if (HDstrcmp(smask,"EC") == 0) + else if (HDstrcmp(smask, "EC") == 0) filt->cd_values[j++] = H5_SZIP_EC_OPTION_MASK; else { error_msg("szip mask must be 'NN' or 'EC' \n"); @@ -157,29 +158,29 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, } } } /* u */ - } /*if */ + } /*if */ /*------------------------------------------------------------------------- - * H5Z_FILTER_SCALEOFFSET - * scaleoffset has the format SOFF=<scale_factor,scale_type> - * scale_type can be - * integer datatype, H5Z_SO_INT (IN) - * float datatype using D-scaling method, H5Z_SO_FLOAT_DSCALE (DS) - * float datatype using E-scaling method, H5Z_SO_FLOAT_ESCALE (ES) , not yet implemented - * for integer datatypes, scale_factor denotes Minimum Bits - * for float datatypes, scale_factor denotes decimal scale factor - * examples - * SOFF=31,IN - * SOFF=3,DF - *------------------------------------------------------------------------- - */ + * H5Z_FILTER_SCALEOFFSET + * scaleoffset has the format SOFF=<scale_factor,scale_type> + * scale_type can be + * integer datatype, H5Z_SO_INT (IN) + * float datatype using D-scaling method, H5Z_SO_FLOAT_DSCALE (DS) + * float datatype using E-scaling method, H5Z_SO_FLOAT_ESCALE (ES) , not yet implemented + * for integer datatypes, scale_factor denotes Minimum Bits + * for float datatypes, scale_factor denotes decimal scale factor + * examples + * SOFF=31,IN + * SOFF=3,DF + *------------------------------------------------------------------------- + */ else if (HDstrcmp(scomp, "SOFF") == 0) { l = -1; /* mask index check */ for (m = 0, u = i + 1; u < len; u++, m++) { if (str[u] == ',') { stype[m] = '\0'; /* end digit */ - l = 0; /* start 'IN' , 'DS', or 'ES' search */ - u++; /* skip ',' */ + l = 0; /* start 'IN' , 'DS', or 'ES' search */ + u++; /* skip ',' */ } c = str[u]; if (!HDisdigit(c) && l == -1) { @@ -195,8 +196,8 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, l++; if (l == 2) { smask[l] = '\0'; - i = len - 1; /* end */ - if (HDstrcmp(smask,"IN") == 0) + i = len - 1; /* end */ + if (HDstrcmp(smask, "IN") == 0) filt->cd_values[j++] = H5Z_SO_INT; else if (HDstrcmp(smask, "DS") == H5Z_SO_FLOAT_DSCALE) filt->cd_values[j++] = H5Z_SO_FLOAT_DSCALE; @@ -207,15 +208,15 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, } } } /* u */ - } /*if */ + } /*if */ /*------------------------------------------------------------------------- - * User Defined - * has the format UD=<filter_number,filter_flag,cd_value_count,value_1[,value_2,...,value_N]> - * BZIP2 example - * UD=307,0,1,9 - *------------------------------------------------------------------------- - */ + * User Defined + * has the format + *UD=<filter_number,filter_flag,cd_value_count,value_1[,value_2,...,value_N]> BZIP2 example + * UD=307,0,1,9 + *------------------------------------------------------------------------- + */ else if (HDstrcmp(scomp, "UD") == 0) { l = -1; /* filter number index check */ f = -1; /* filter flag index check */ @@ -225,15 +226,15 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, stype[q] = '\0'; /* end digit */ if (l == -1) { filt->filtn = HDatoi(stype); - l = 0; + l = 0; } else if (f == -1) { - filt->filt_flag = HDstrtoul(stype, NULL, 0); - f = 0; + filt->filt_flag = (unsigned)HDstrtoul(stype, NULL, 0); + f = 0; } else if (p == -1) { filt->cd_nelmts = HDstrtoull(stype, NULL, 0); - p = 0; + p = 0; } else { filt->cd_values[j++] = (unsigned)HDstrtoul(stype, NULL, 0); @@ -260,9 +261,9 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, } /*if */ /*------------------------------------------------------------------------- - * all other filters - *------------------------------------------------------------------------- - */ + * all other filters + *------------------------------------------------------------------------- + */ else { /* here we could have 1 or 2 digits */ for (m = 0, u = i + 1; u < len; u++, m++) { @@ -279,36 +280,36 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, stype[m] = '\0'; } /*if */ - filt->cd_values[j++] = (unsigned) HDstrtoul(stype, NULL, 0); - if(filt->cd_nelmts == 0) + filt->cd_values[j++] = (unsigned)HDstrtoul(stype, NULL, 0); + if (filt->cd_nelmts == 0) j = 0; i += m; /* jump */ } else if (i == len - 1) { /*no more parameters */ scomp[k + 1] = '\0'; - no_param = 1; + no_param = 1; } /*------------------------------------------------------------------------- - * translate from string to filter symbol - *------------------------------------------------------------------------- - */ + * translate from string to filter symbol + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- - * H5Z_FILTER_NONE - *------------------------------------------------------------------------- - */ + * H5Z_FILTER_NONE + *------------------------------------------------------------------------- + */ if (HDstrcmp(scomp, "NONE") == 0) { - filt->filtn = H5Z_FILTER_NONE; + filt->filtn = H5Z_FILTER_NONE; filt->cd_nelmts = 0; } /*------------------------------------------------------------------------- - * H5Z_FILTER_DEFLATE - *------------------------------------------------------------------------- - */ + * H5Z_FILTER_DEFLATE + *------------------------------------------------------------------------- + */ else if (HDstrcmp(scomp, "GZIP") == 0) { - filt->filtn = H5Z_FILTER_DEFLATE; + filt->filtn = H5Z_FILTER_DEFLATE; filt->cd_nelmts = 1; if (no_param) { /*no more parameters, GZIP must have parameter */ if (obj_list) @@ -319,11 +320,11 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, } /*------------------------------------------------------------------------- - * H5Z_FILTER_SZIP - *------------------------------------------------------------------------- - */ + * H5Z_FILTER_SZIP + *------------------------------------------------------------------------- + */ else if (HDstrcmp(scomp, "SZIP") == 0) { - filt->filtn = H5Z_FILTER_SZIP; + filt->filtn = H5Z_FILTER_SZIP; filt->cd_nelmts = 2; if (no_param) { /*no more parameters, SZIP must have parameter */ if (obj_list) @@ -334,11 +335,11 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, } /*------------------------------------------------------------------------- - * H5Z_FILTER_SHUFFLE - *------------------------------------------------------------------------- - */ + * H5Z_FILTER_SHUFFLE + *------------------------------------------------------------------------- + */ else if (HDstrcmp(scomp, "SHUF") == 0) { - filt->filtn = H5Z_FILTER_SHUFFLE; + filt->filtn = H5Z_FILTER_SHUFFLE; filt->cd_nelmts = 0; if (m > 0) { /*shuffle does not have parameter */ if (obj_list) @@ -348,11 +349,11 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, } } /*------------------------------------------------------------------------- - * H5Z_FILTER_FLETCHER32 - *------------------------------------------------------------------------- - */ + * H5Z_FILTER_FLETCHER32 + *------------------------------------------------------------------------- + */ else if (HDstrcmp(scomp, "FLET") == 0) { - filt->filtn = H5Z_FILTER_FLETCHER32; + filt->filtn = H5Z_FILTER_FLETCHER32; filt->cd_nelmts = 0; if (m > 0) { /*shuffle does not have parameter */ if (obj_list) @@ -362,11 +363,11 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, } } /*------------------------------------------------------------------------- - * H5Z_FILTER_NBIT - *------------------------------------------------------------------------- - */ + * H5Z_FILTER_NBIT + *------------------------------------------------------------------------- + */ else if (HDstrcmp(scomp, "NBIT") == 0) { - filt->filtn = H5Z_FILTER_NBIT; + filt->filtn = H5Z_FILTER_NBIT; filt->cd_nelmts = 0; if (m > 0) { /*nbit does not have parameter */ if (obj_list) @@ -376,11 +377,11 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, } } /*------------------------------------------------------------------------- - * H5Z_FILTER_SCALEOFFSET - *------------------------------------------------------------------------- - */ + * H5Z_FILTER_SCALEOFFSET + *------------------------------------------------------------------------- + */ else if (HDstrcmp(scomp, "SOFF") == 0) { - filt->filtn = H5Z_FILTER_SCALEOFFSET; + filt->filtn = H5Z_FILTER_SCALEOFFSET; filt->cd_nelmts = 2; if (no_param) { /*no more parameters, SOFF must have parameter */ if (obj_list) @@ -390,9 +391,9 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, } } /*------------------------------------------------------------------------- - * User Defined Filter - *------------------------------------------------------------------------- - */ + * User Defined Filter + *------------------------------------------------------------------------- + */ else if (HDstrcmp(scomp, "UD") == 0) { /* parameters does not match count */ if (filt->cd_nelmts != j) { @@ -413,56 +414,55 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, } /*i*/ /*------------------------------------------------------------------------- - * check valid parameters - *------------------------------------------------------------------------- - */ + * check valid parameters + *------------------------------------------------------------------------- + */ switch (filt->filtn) { - /*------------------------------------------------------------------------- - * H5Z_FILTER_DEFLATE - *------------------------------------------------------------------------- - */ - case H5Z_FILTER_DEFLATE: - if (filt->cd_values[0] > 9) { - if (obj_list) - HDfree(obj_list); - error_msg("invalid compression parameter in <%s>\n", str); - HDexit(EXIT_FAILURE); - } - break; /*------------------------------------------------------------------------- - * H5Z_FILTER_SZIP - *------------------------------------------------------------------------- - */ - case H5Z_FILTER_SZIP: - pixels_per_block = filt->cd_values[0]; - if ((pixels_per_block % 2) == 1) { - if (obj_list) - HDfree(obj_list); - error_msg("pixels_per_block is not even in <%s>\n", str); - HDexit(EXIT_FAILURE); - } - if (pixels_per_block > H5_SZIP_MAX_PIXELS_PER_BLOCK) { - if (obj_list) - HDfree(obj_list); - error_msg("pixels_per_block is too large in <%s>\n", str); - HDexit(EXIT_FAILURE); - } - if ((HDstrcmp(smask,"NN") != 0) && (HDstrcmp(smask,"EC") != 0)) { - if (obj_list) - HDfree(obj_list); - error_msg("szip mask must be 'NN' or 'EC' \n"); - HDexit(EXIT_FAILURE); - } - break; - default: - break; + * H5Z_FILTER_DEFLATE + *------------------------------------------------------------------------- + */ + case H5Z_FILTER_DEFLATE: + if (filt->cd_values[0] > 9) { + if (obj_list) + HDfree(obj_list); + error_msg("invalid compression parameter in <%s>\n", str); + HDexit(EXIT_FAILURE); + } + break; + /*------------------------------------------------------------------------- + * H5Z_FILTER_SZIP + *------------------------------------------------------------------------- + */ + case H5Z_FILTER_SZIP: + pixels_per_block = filt->cd_values[0]; + if ((pixels_per_block % 2) == 1) { + if (obj_list) + HDfree(obj_list); + error_msg("pixels_per_block is not even in <%s>\n", str); + HDexit(EXIT_FAILURE); + } + if (pixels_per_block > H5_SZIP_MAX_PIXELS_PER_BLOCK) { + if (obj_list) + HDfree(obj_list); + error_msg("pixels_per_block is too large in <%s>\n", str); + HDexit(EXIT_FAILURE); + } + if ((HDstrcmp(smask, "NN") != 0) && (HDstrcmp(smask, "EC") != 0)) { + if (obj_list) + HDfree(obj_list); + error_msg("szip mask must be 'NN' or 'EC' \n"); + HDexit(EXIT_FAILURE); + } + break; + default: + break; }; return obj_list; } - /*------------------------------------------------------------------------- * Function: parse_layout * @@ -484,9 +484,11 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, * *------------------------------------------------------------------------- */ -obj_list_t* parse_layout(const char *str, unsigned *n_objs, pack_info_t *pack, /* info about layout needed */ -pack_opt_t *options) { - obj_list_t* obj_list = NULL; +obj_list_t * +parse_layout(const char *str, unsigned *n_objs, pack_info_t *pack, /* info about layout needed */ + pack_opt_t *options) +{ + obj_list_t *obj_list = NULL; unsigned i, j, n; char c; size_t len = HDstrlen(str); @@ -503,7 +505,7 @@ pack_opt_t *options) { for (i = 0, n = 0; i < len; i++) { c = str[i]; if (c == ':') - end_obj = (int) i; + end_obj = (int)i; if (c == ',') n++; } @@ -513,7 +515,7 @@ pack_opt_t *options) { } n++; - obj_list = (obj_list_t*) HDmalloc(n * sizeof(obj_list_t)); + obj_list = (obj_list_t *)HDmalloc(n * sizeof(obj_list_t)); if (obj_list == NULL) { error_msg("could not allocate object list\n"); return NULL; @@ -522,10 +524,10 @@ pack_opt_t *options) { /* get object list */ if (end_obj > 0) - for (j = 0, k = 0, n = 0; j < (unsigned) end_obj; j++, k++) { - c = str[j]; + for (j = 0, k = 0, n = 0; j < (unsigned)end_obj; j++, k++) { + c = str[j]; sobj[k] = c; - if (c == ',' || j == (unsigned) (end_obj - 1)) { + if (c == ',' || j == (unsigned)(end_obj - 1)) { if (c == ',') sobj[k] = '\0'; else @@ -538,7 +540,7 @@ pack_opt_t *options) { } /* nothing after : */ - if (end_obj + 1 == (int) len) { + if (end_obj + 1 == (int)len) { if (obj_list) HDfree(obj_list); error_msg("in parse layout, no characters after : in <%s>\n", str); @@ -546,7 +548,7 @@ pack_opt_t *options) { } /* get layout info */ - for (j = (unsigned) (end_obj + 1), n = 0; n <= 5; j++, n++) { + for (j = (unsigned)(end_obj + 1), n = 0; n <= 5; j++, n++) { if (n == 5) { slayout[n] = '\0'; /*cut string */ if (HDstrcmp(slayout, "COMPA") == 0) @@ -561,16 +563,16 @@ pack_opt_t *options) { } } else { - c = str[j]; + c = str[j]; slayout[n] = c; } } /* j */ if (pack->layout == H5D_CHUNKED) { /*------------------------------------------------------------------------- - * get chunk info - *------------------------------------------------------------------------- - */ + * get chunk info + *------------------------------------------------------------------------- + */ k = 0; if (j > len) { if (obj_list) @@ -580,7 +582,7 @@ pack_opt_t *options) { } for (i = j, c_index = 0; i < len; i++) { - c = str[i]; + c = str[i]; sdim[k] = c; k++; /*increment sdim index */ @@ -593,8 +595,8 @@ pack_opt_t *options) { if (c == 'x' || i == len - 1) { if (c == 'x') { - sdim[k - 1] = '\0'; - k = 0; + sdim[k - 1] = '\0'; + k = 0; pack->chunk.chunk_lengths[c_index] = HDstrtoull(sdim, NULL, 0); if (pack->chunk.chunk_lengths[c_index] == 0) { if (obj_list) @@ -606,8 +608,8 @@ pack_opt_t *options) { } else if (i == len - 1) { /*no more parameters */ sdim[k] = '\0'; - k = 0; - if (HDstrcmp(sdim,"NONE") == 0) { + k = 0; + if (HDstrcmp(sdim, "NONE") == 0) { pack->chunk.rank = -2; } else { @@ -621,9 +623,9 @@ pack_opt_t *options) { pack->chunk.rank = c_index + 1; } } /*if */ - } /*if c=='x' || i==len-1 */ - } /*i*/ - } /*H5D_CHUNKED*/ + } /*if c=='x' || i==len-1 */ + } /*i*/ + } /*H5D_CHUNKED*/ return obj_list; } diff --git a/tools/h5repack/h5repack_plugin.sh.in b/tools/h5repack/h5repack_plugin.sh.in index f21da3d..a6c166f 100644 --- a/tools/h5repack/h5repack_plugin.sh.in +++ b/tools/h5repack/h5repack_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. # diff --git a/tools/h5repack/h5repack_refs.c b/tools/h5repack/h5repack_refs.c index 59b652c..988ab37 100644 --- a/tools/h5repack/h5repack_refs.c +++ b/tools/h5repack/h5repack_refs.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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -15,17 +15,15 @@ #include "h5diff.h" #include "h5tools.h" - /*------------------------------------------------------------------------- * local functions *------------------------------------------------------------------------- */ -static const char* MapIdToName(hid_t refobj_id,trav_table_t *travt); -static int copy_refs_attr(hid_t loc_in, hid_t loc_out, pack_opt_t *options, - trav_table_t *travt, hid_t fidout); -static herr_t update_ref_value(hid_t obj_id, H5R_type_t ref_type, void *ref_in, - hid_t fid_out, void *ref_out, trav_table_t *travt); +static const char *MapIdToName(hid_t refobj_id, trav_table_t *travt); +static int copy_refs_attr(hid_t loc_in, hid_t loc_out, trav_table_t *travt, hid_t fidout); +static herr_t update_ref_value(hid_t obj_id, H5R_type_t ref_type, void *ref_in, hid_t fid_out, void *ref_out, + trav_table_t *travt); /*------------------------------------------------------------------------- * Function: do_copy_refobjs @@ -37,35 +35,33 @@ static herr_t update_ref_value(hid_t obj_id, H5R_type_t ref_type, void *ref_in, *------------------------------------------------------------------------- */ -int do_copy_refobjs(hid_t fidin, - hid_t fidout, - trav_table_t *travt, - pack_opt_t *options) /* repack options */ +int +do_copy_refobjs(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *options) /* repack options */ { - int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ - hid_t grp_in = -1; /* read group ID */ - hid_t grp_out = -1; /* write group ID */ - hid_t dset_in = -1; /* read dataset ID */ - hid_t dset_out = -1; /* write dataset ID */ - hid_t type_in = -1; /* named type ID */ - hid_t dcpl_id = -1; /* dataset creation property list ID */ - hid_t space_id = -1; /* space ID */ - hid_t ftype_id = -1; /* file data type ID */ - hid_t mtype_id = -1; /* memory data type ID */ - size_t msize; /* memory size of memory type */ - hsize_t nelmts; /* number of elements in dataset */ - int rank; /* rank of dataset */ - hsize_t dims[H5S_MAX_RANK]; /* dimensions of dataset */ + hid_t grp_in = H5I_INVALID_HID; /* read group ID */ + hid_t grp_out = H5I_INVALID_HID; /* write group ID */ + hid_t dset_in = H5I_INVALID_HID; /* read dataset ID */ + hid_t dset_out = H5I_INVALID_HID; /* write dataset ID */ + hid_t type_in = H5I_INVALID_HID; /* named type ID */ + hid_t dcpl_id = H5I_INVALID_HID; /* dataset creation property list ID */ + hid_t space_id = H5I_INVALID_HID; /* space ID */ + hid_t ftype_id = H5I_INVALID_HID; /* file data type ID */ + hid_t mtype_id = H5I_INVALID_HID; /* memory data type ID */ + size_t msize; /* memory size of memory type */ + hsize_t nelmts; /* number of elements in dataset */ + int rank; /* rank of dataset */ + hsize_t dims[H5S_MAX_RANK]; /* dimensions of dataset */ unsigned int i, j; - int k; - named_dt_t *named_dt_head = NULL; /* Pointer to the stack of named datatypes copied */ + int k; + named_dt_t * named_dt_head = NULL; /* Pointer to the stack of named datatypes copied */ + int ret_value = 0; /*------------------------------------------------------------------------- - * browse - *------------------------------------------------------------------------- - */ - for(i = 0; i < travt->nobjs; i++) { - switch(travt->objs[i].type) { + * browse + *------------------------------------------------------------------------- + */ + for (i = 0; i < travt->nobjs; i++) { + switch (travt->objs[i].type) { /*------------------------------------------------------------------------- * H5TRAV_TYPE_GROUP *------------------------------------------------------------------------- @@ -75,27 +71,28 @@ int do_copy_refobjs(hid_t fidin, * copy referenced objects in attributes *------------------------------------------------------------------------- */ - if((grp_out = H5Gopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gopen2 failed"); + if ((grp_out = H5Gopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Gopen2 failed"); - if((grp_in = H5Gopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gopen2 failed"); + if ((grp_in = H5Gopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Gopen2 failed"); - if(copy_refs_attr(grp_in, grp_out, options, travt, fidout) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_refs_attr failed"); + if (copy_refs_attr(grp_in, grp_out, travt, fidout) < 0) + H5TOOLS_GOTO_ERROR((-1), "copy_refs_attr failed"); - if(H5Gclose(grp_out) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed"); - if(H5Gclose(grp_in) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed"); + if (H5Gclose(grp_out) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Gclose failed"); + if (H5Gclose(grp_in) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Gclose failed"); /*------------------------------------------------------------------------- * check for hard links *------------------------------------------------------------------------- */ - if(travt->objs[i].nlinks) - for(j = 0; j < travt->objs[i].nlinks; j++) - H5Lcreate_hard(fidout, travt->objs[i].name, H5L_SAME_LOC, travt->objs[i].links[j].new_name, H5P_DEFAULT, H5P_DEFAULT); + if (travt->objs[i].nlinks) + for (j = 0; j < travt->objs[i].nlinks; j++) + H5Lcreate_hard(fidout, travt->objs[i].name, H5L_SAME_LOC, + travt->objs[i].links[j].new_name, H5P_DEFAULT, H5P_DEFAULT); break; /*------------------------------------------------------------------------- @@ -103,27 +100,27 @@ int do_copy_refobjs(hid_t fidin, *------------------------------------------------------------------------- */ case H5TRAV_TYPE_DATASET: - if((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed"); - if((space_id = H5Dget_space(dset_in)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed"); - if((ftype_id = H5Dget_type(dset_in)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_type failed"); - if((dcpl_id = H5Dget_create_plist(dset_in)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed"); - if((rank = H5Sget_simple_extent_ndims(space_id)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed"); - if(H5Sget_simple_extent_dims(space_id, dims, NULL) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed"); + if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed"); + if ((space_id = H5Dget_space(dset_in)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed"); + if ((ftype_id = H5Dget_type(dset_in)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dget_type failed"); + if ((dcpl_id = H5Dget_create_plist(dset_in)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed"); + if ((rank = H5Sget_simple_extent_ndims(space_id)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_ndims failed"); + if (H5Sget_simple_extent_dims(space_id, dims, NULL) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_dims failed"); nelmts = 1; - for(k = 0; k < rank; k++) + for (k = 0; k < rank; k++) nelmts *= dims[k]; - if((mtype_id = H5Tget_native_type(ftype_id, H5T_DIR_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_native_type failed"); + if ((mtype_id = H5Tget_native_type(ftype_id, H5T_DIR_DEFAULT)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Tget_native_type failed"); - if((msize = H5Tget_size(mtype_id)) == 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed"); + if ((msize = H5Tget_size(mtype_id)) == 0) + H5TOOLS_GOTO_ERROR((-1), "H5Tget_size failed"); /*------------------------------------------------------------------------- * check if the dataset creation property list has filters that @@ -132,7 +129,7 @@ int do_copy_refobjs(hid_t fidin, * 2) the internal filters might be turned off *------------------------------------------------------------------------- */ - if(h5tools_canreadf(NULL, dcpl_id) == 1) { + if (h5tools_canreadf(NULL, dcpl_id) == 1) { /*------------------------------------------------------------------------- * test for a valid output dataset *------------------------------------------------------------------------- @@ -144,207 +141,214 @@ int do_copy_refobjs(hid_t fidin, * we cannot just copy the buffers, but instead we recreate the reference *------------------------------------------------------------------------- */ - if(H5Tequal(mtype_id, H5T_STD_REF_OBJ)) { - hid_t refobj_id = -1; - hobj_ref_t *refbuf = NULL; /* buffer for object references */ - hobj_ref_t *buf = NULL; - const char* refname; - unsigned u; + if (H5Tequal(mtype_id, H5T_STD_REF_OBJ)) { + hid_t refobj_id = H5I_INVALID_HID; + hobj_ref_t *refbuf = NULL; /* buffer for object references */ + hobj_ref_t *buf = NULL; + const char *refname; + unsigned u; /*------------------------------------------------------------------------- * read to memory *------------------------------------------------------------------------- */ - if(nelmts) { + if (nelmts) { buf = (hobj_ref_t *)HDmalloc((unsigned)(nelmts * msize)); - if(buf==NULL) { - printf("cannot read into memory\n" ); - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDmalloc failed"); + if (buf == NULL) { + HDprintf("cannot read into memory\n"); + H5TOOLS_GOTO_ERROR((-1), "HDmalloc failed"); } /* end if */ - if(H5Dread(dset_in, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed"); + if (H5Dread(dset_in, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dread failed"); - refbuf = (hobj_ref_t*) HDcalloc((unsigned)nelmts, msize); - if(refbuf == NULL){ - printf("cannot allocate memory\n" ); - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDcalloc failed"); + refbuf = (hobj_ref_t *)HDcalloc((unsigned)nelmts, msize); + if (refbuf == NULL) { + HDprintf("cannot allocate memory\n"); + H5TOOLS_GOTO_ERROR((-1), "HDcalloc failed"); } /* end if */ - for(u = 0; u < nelmts; u++) { - H5E_BEGIN_TRY { - if((refobj_id = H5Rdereference(dset_in, H5R_OBJECT, &buf[u])) < 0) - continue; - } H5E_END_TRY; + for (u = 0; u < nelmts; u++) { + H5E_BEGIN_TRY { refobj_id = H5Rdereference(dset_in, H5R_OBJECT, &buf[u]); } + H5E_END_TRY; + if (refobj_id < 0) + continue; /* get the name. a valid name could only occur * in the second traversal of the file */ - if((refname = MapIdToName(refobj_id, travt)) != NULL) { + if ((refname = MapIdToName(refobj_id, travt)) != NULL) { /* create the reference, -1 parameter for objects */ - if(H5Rcreate(&refbuf[u], fidout, refname, H5R_OBJECT, (hid_t)-1) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Rcreate failed"); - if(options->verbose) { - printf(FORMAT_OBJ,"dset",travt->objs[i].name ); - printf("object <%s> object reference created to <%s>\n", - travt->objs[i].name, - refname); + if (H5Rcreate(&refbuf[u], fidout, refname, H5R_OBJECT, (hid_t)-1) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Rcreate failed"); + if (options->verbose) { + HDprintf(FORMAT_OBJ, "dset", travt->objs[i].name); + HDprintf("object <%s> object reference created to <%s>\n", + travt->objs[i].name, refname); } } /*refname*/ if (H5Oclose(refobj_id) < 0) - H5TOOLS_INFO(H5E_tools_min_id_g, "H5Oclose refob failed"); + H5TOOLS_ERROR((-1), "H5Oclose refob failed"); } /* u */ - } /*nelmts*/ + } /*nelmts*/ /*------------------------------------------------------------------------- * create/write dataset/close *------------------------------------------------------------------------- */ - if((dset_out = H5Dcreate2(fidout, travt->objs[i].name, mtype_id, space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dcreate2 failed"); - if(nelmts) - if(H5Dwrite(dset_out, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, refbuf) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dwrite failed"); - - if(buf) + if ((dset_out = H5Dcreate2(fidout, travt->objs[i].name, mtype_id, space_id, + H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dcreate2 failed"); + if (nelmts) + if (H5Dwrite(dset_out, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, refbuf) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dwrite failed"); + + if (buf) HDfree(buf); - if(refbuf) + if (refbuf) HDfree(refbuf); - /*------------------------------------------------------ - * copy attrs - *----------------------------------------------------*/ - if(copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_attr failed"); + /*------------------------------------------------------ + * copy attrs + *----------------------------------------------------*/ + if (copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0) + H5TOOLS_GOTO_ERROR((-1), "copy_attr failed"); } /*H5T_STD_REF_OBJ*/ /*------------------------------------------------------------------------- * dataset region references *------------------------------------------------------------------------- */ - else if(H5Tequal(mtype_id, H5T_STD_REF_DSETREG)) { - hid_t refobj_id = -1; - hdset_reg_ref_t *refbuf = NULL; /* input buffer for region references */ - hdset_reg_ref_t *buf = NULL; /* output buffer */ - const char* refname; + else if (H5Tequal(mtype_id, H5T_STD_REF_DSETREG)) { + hid_t refobj_id = H5I_INVALID_HID; + hdset_reg_ref_t *refbuf = NULL; /* input buffer for region references */ + hdset_reg_ref_t *buf = NULL; /* output buffer */ + const char * refname; unsigned u; /*------------------------------------------------------------------------- * read input to memory *------------------------------------------------------------------------- */ - if(nelmts) { + if (nelmts) { buf = (hdset_reg_ref_t *)HDmalloc((unsigned)(nelmts * msize)); - if(buf == NULL) { - printf("cannot read into memory\n"); - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDmalloc failed"); + if (buf == NULL) { + HDprintf("cannot read into memory\n"); + H5TOOLS_GOTO_ERROR((-1), "HDmalloc failed"); } /* end if */ - if(H5Dread(dset_in, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed"); + if (H5Dread(dset_in, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dread failed"); /*------------------------------------------------------------------------- * create output *------------------------------------------------------------------------- */ - refbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)nelmts); /*init to zero */ - if(refbuf == NULL) { - printf("cannot allocate memory\n"); - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDcalloc failed"); + refbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), + (size_t)nelmts); /*init to zero */ + if (refbuf == NULL) { + HDprintf("cannot allocate memory\n"); + H5TOOLS_GOTO_ERROR((-1), "HDcalloc failed"); } /* end if */ - for(u = 0; u < nelmts; u++) { - H5E_BEGIN_TRY { - if((refobj_id = H5Rdereference(dset_in, H5R_DATASET_REGION, &buf[u])) < 0) - continue; - } H5E_END_TRY; + for (u = 0; u < nelmts; u++) { + H5E_BEGIN_TRY + { + refobj_id = H5Rdereference(dset_in, H5R_DATASET_REGION, &buf[u]); + } + H5E_END_TRY; + if (refobj_id < 0) + continue; /* get the name. a valid name could only occur * in the second traversal of the file */ - if((refname = MapIdToName(refobj_id, travt)) != NULL) { - hid_t region_id = -1; /* region id of the referenced dataset */ + if ((refname = MapIdToName(refobj_id, travt)) != NULL) { + hid_t region_id = + H5I_INVALID_HID; /* region id of the referenced dataset */ - if((region_id = H5Rget_region(dset_in, H5R_DATASET_REGION, &buf[u])) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Rget_region failed"); + if ((region_id = H5Rget_region(dset_in, H5R_DATASET_REGION, &buf[u])) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Rget_region failed"); /* create the reference, we need the space_id */ - if(H5Rcreate(&refbuf[u], fidout, refname, H5R_DATASET_REGION, region_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Rcreate failed"); - if(H5Sclose(region_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed"); - if(options->verbose) { - printf(FORMAT_OBJ,"dset",travt->objs[i].name ); - printf("object <%s> region reference created to <%s>\n", - travt->objs[i].name, - refname); + if (H5Rcreate(&refbuf[u], fidout, refname, H5R_DATASET_REGION, + region_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Rcreate failed"); + if (H5Sclose(region_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed"); + if (options->verbose) { + HDprintf(FORMAT_OBJ, "dset", travt->objs[i].name); + HDprintf("object <%s> region reference created to <%s>\n", + travt->objs[i].name, refname); } } /*refname*/ if (H5Oclose(refobj_id) < 0) - H5TOOLS_INFO(H5E_tools_min_id_g, "H5Oclose refobj_id failed"); + H5TOOLS_ERROR((-1), "H5Oclose refobj_id failed"); } /* u */ - } /*nelmts*/ + } /*nelmts*/ /*------------------------------------------------------------------------- * create/write dataset/close *------------------------------------------------------------------------- */ - if((dset_out = H5Dcreate2(fidout, travt->objs[i].name, mtype_id, space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dcreate2 failed"); - if(nelmts) - if(H5Dwrite(dset_out, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, refbuf) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dwrite failed"); - - if(buf) + if ((dset_out = H5Dcreate2(fidout, travt->objs[i].name, mtype_id, space_id, + H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dcreate2 failed"); + if (nelmts) + if (H5Dwrite(dset_out, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, refbuf) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dwrite failed"); + + if (buf) HDfree(buf); - if(refbuf) + if (refbuf) HDfree(refbuf); - /*----------------------------------------------------- - * copy attrs - *----------------------------------------------------*/ - if(copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_attr failed"); + /*----------------------------------------------------- + * copy attrs + *----------------------------------------------------*/ + if (copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0) + H5TOOLS_GOTO_ERROR((-1), "copy_attr failed"); } /* H5T_STD_REF_DSETREG */ /*------------------------------------------------------------------------- * not references, open previously created object in 1st traversal *------------------------------------------------------------------------- */ else { - if((dset_out = H5Dopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed"); + if ((dset_out = H5Dopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed"); } /* end else */ /*------------------------------------------------------------------------- * copy referenced objects in attributes *------------------------------------------------------------------------- */ - if(copy_refs_attr(dset_in, dset_out, options, travt, fidout) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_refs_attr failed"); + if (copy_refs_attr(dset_in, dset_out, travt, fidout) < 0) + H5TOOLS_GOTO_ERROR((-1), "copy_refs_attr failed"); /*------------------------------------------------------------------------- * check for hard links *------------------------------------------------------------------------- */ - if(travt->objs[i].nlinks) - for(j = 0; j < travt->objs[i].nlinks; j++) - H5Lcreate_hard(fidout, travt->objs[i].name, H5L_SAME_LOC, travt->objs[i].links[j].new_name, H5P_DEFAULT, H5P_DEFAULT); + if (travt->objs[i].nlinks) + for (j = 0; j < travt->objs[i].nlinks; j++) + H5Lcreate_hard(fidout, travt->objs[i].name, H5L_SAME_LOC, + travt->objs[i].links[j].new_name, H5P_DEFAULT, H5P_DEFAULT); - if(H5Dclose(dset_out) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed"); + if (H5Dclose(dset_out) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); } /*can_read*/ /*------------------------------------------------------------------------- * close *------------------------------------------------------------------------- */ - if(H5Tclose(ftype_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); - if(H5Tclose(mtype_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); - if(H5Pclose(dcpl_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); - if(H5Sclose(space_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed"); - if(H5Dclose(dset_in) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed"); + if (H5Tclose(ftype_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); + if (H5Tclose(mtype_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); + if (H5Pclose(dcpl_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); + if (H5Sclose(space_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed"); + if (H5Dclose(dset_in) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); break; /*------------------------------------------------------------------------- @@ -352,10 +356,10 @@ int do_copy_refobjs(hid_t fidin, *------------------------------------------------------------------------- */ case H5TRAV_TYPE_NAMED_DATATYPE: - if((type_in = H5Topen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Topen2 failed"); - if(H5Tclose(type_in) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); + if ((type_in = H5Topen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Topen2 failed"); + if (H5Tclose(type_in) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); break; /*------------------------------------------------------------------------- @@ -368,24 +372,26 @@ int do_copy_refobjs(hid_t fidin, case H5TRAV_TYPE_UNKNOWN: case H5TRAV_TYPE_UDLINK: - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5TRAV invalid type"); + H5TOOLS_GOTO_ERROR((-1), "H5TRAV invalid type"); + break; default: break; } /* end switch */ - } /* end for */ + } /* end for */ /* Finalize (link) the stack of named datatypes (if any) * This function is paired with copy_named_datatype() which is called * in copy_attr(), so need to free. */ if (named_datatype_free(&named_dt_head, 0) < 0) - H5TOOLS_INFO(H5E_tools_min_id_g, "named_datatype_free failed"); + H5TOOLS_ERROR((-1), "named_datatype_free failed"); return ret_value; done: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(grp_in); H5Gclose(grp_out); H5Pclose(dcpl_id); @@ -396,12 +402,12 @@ done: H5Tclose(mtype_id); H5Tclose(type_in); named_datatype_free(&named_dt_head, 1); - } H5E_END_TRY; + } + H5E_END_TRY; return ret_value; } - /*------------------------------------------------------------------------- * Function: copy_refs_attr * @@ -424,98 +430,91 @@ done: *------------------------------------------------------------------------- */ -static int copy_refs_attr(hid_t loc_in, - hid_t loc_out, - pack_opt_t *options, - trav_table_t *travt, - hid_t fidout) /* for saving references */ +static int +copy_refs_attr(hid_t loc_in, hid_t loc_out, trav_table_t *travt, hid_t fidout) /* for saving references */ { - int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ - hid_t attr_id = -1; /* attr ID */ - hid_t attr_out = -1; /* attr ID */ - hid_t space_id = -1; /* space ID */ - hid_t ftype_id = -1; /* file data type ID */ - hid_t mtype_id = -1; /* memory data type ID */ - size_t msize; /* memory size of type */ - hsize_t nelmts; /* number of elements in dataset */ - hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */ + hid_t attr_id = H5I_INVALID_HID; /* attr ID */ + hid_t attr_out = H5I_INVALID_HID; /* attr ID */ + hid_t space_id = H5I_INVALID_HID; /* space ID */ + hid_t ftype_id = H5I_INVALID_HID; /* file data type ID */ + hid_t mtype_id = H5I_INVALID_HID; /* memory data type ID */ + size_t msize; /* memory size of type */ + hsize_t nelmts; /* number of elements in dataset */ + hsize_t dims[H5S_MAX_RANK]; /* dimensions of dataset */ char name[255]; - H5O_info_t oinfo; /* Object info */ + H5O_info_t oinfo; /* Object info */ unsigned u, i, j; int rank; H5T_class_t type_class = -1; - hbool_t is_ref = 0, - is_ref_vlen = 0, - is_ref_array = 0, - is_ref_comp = 0; - void *refbuf = NULL; - void *buf = NULL; - const char *refname = NULL; - unsigned *ref_comp_index = NULL; - size_t *ref_comp_size = NULL; + hbool_t is_ref = 0, is_ref_vlen = 0, is_ref_array = 0, is_ref_comp = 0; + void * refbuf = NULL; + void * buf = NULL; + unsigned * ref_comp_index = NULL; + size_t * ref_comp_size = NULL; int ref_comp_field_n = 0; + int ret_value = 0; + if (H5Oget_info(loc_in, &oinfo) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Oget_info failed"); - if(H5Oget_info(loc_in, &oinfo) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Oget_info failed"); - - for(u = 0; u < (unsigned)oinfo.num_attrs; u++) { + for (u = 0; u < (unsigned)oinfo.num_attrs; u++) { is_ref = is_ref_vlen = is_ref_array = is_ref_comp = 0; /* open attribute */ - if((attr_id = H5Aopen_by_idx(loc_in, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, H5P_DEFAULT, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aopen_by_idx failed"); + if ((attr_id = H5Aopen_by_idx(loc_in, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Aopen_by_idx failed"); /* get the file datatype */ - if((ftype_id = H5Aget_type(attr_id)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_type failed"); + if ((ftype_id = H5Aget_type(attr_id)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Aget_type failed"); type_class = H5Tget_class(ftype_id); - if((mtype_id = H5Tget_native_type(ftype_id, H5T_DIR_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_native_type failed"); + if ((mtype_id = H5Tget_native_type(ftype_id, H5T_DIR_DEFAULT)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Tget_native_type failed"); - if((msize = H5Tget_size(mtype_id)) == 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed"); + if ((msize = H5Tget_size(mtype_id)) == 0) + H5TOOLS_GOTO_ERROR((-1), "H5Tget_size failed"); is_ref = (type_class == H5T_REFERENCE); - if(type_class == H5T_VLEN ) { + if (type_class == H5T_VLEN) { hid_t base_type = H5Tget_super(ftype_id); is_ref_vlen = (H5Tget_class(base_type) == H5T_REFERENCE); - msize = H5Tget_size(base_type); + msize = H5Tget_size(base_type); if (H5Tclose(base_type) < 0) - H5TOOLS_INFO(H5E_tools_min_id_g, "H5Tclose base_type failed"); + H5TOOLS_ERROR((-1), "H5Tclose base_type failed"); } - else if(type_class == H5T_ARRAY ) { + else if (type_class == H5T_ARRAY) { hid_t base_type = H5Tget_super(ftype_id); is_ref_array = (H5Tget_class(base_type) == H5T_REFERENCE); - msize = H5Tget_size(base_type); + msize = H5Tget_size(base_type); if (H5Tclose(base_type) < 0) - H5TOOLS_INFO(H5E_tools_min_id_g, "H5Tclose base_type failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Tclose base_type failed"); } - else if(type_class == H5T_COMPOUND) { - int nmembers = H5Tget_nmembers(ftype_id) ; + else if (type_class == H5T_COMPOUND) { + int nmembers = H5Tget_nmembers(ftype_id); if (nmembers < 1) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_nmembers failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Tget_nmembers failed"); - ref_comp_index = (unsigned *)HDmalloc((size_t)nmembers*sizeof(unsigned)); - ref_comp_size = (size_t *)HDmalloc((size_t)nmembers*sizeof(ref_comp_size)); + ref_comp_index = (unsigned *)HDmalloc((size_t)nmembers * sizeof(unsigned)); + ref_comp_size = (size_t *)HDmalloc((size_t)nmembers * sizeof(ref_comp_size)); ref_comp_field_n = 0; - for (i=0; i<(unsigned)nmembers; i++) { + for (i = 0; i < (unsigned)nmembers; i++) { hid_t mtid = H5Tget_member_type(ftype_id, i); if ((H5Tget_class(mtid) == H5T_REFERENCE)) { ref_comp_index[ref_comp_field_n] = i; - ref_comp_size[ref_comp_field_n] = H5Tget_size(mtid); + ref_comp_size[ref_comp_field_n] = H5Tget_size(mtid); ref_comp_field_n++; } if (H5Tclose(mtid) < 0) - H5TOOLS_INFO(H5E_tools_min_id_g, "H5Tclose mtid failed"); + H5TOOLS_ERROR((-1), "H5Tclose mtid failed"); } /* if compound don't contain reference type member, free the above @@ -532,206 +531,214 @@ static int copy_refs_attr(hid_t loc_in, ref_comp_size = NULL; } } + /* This line below needs to be moved in this loop instead of inserting outside. Otherwise, + ref_comp_field_n may be >0 for the next attribute, which may not be + the reference type and will be accidently treated as the reference type. + It will then cause the H5Acreate2 failed since that attribute is already created. + KY 2020-02-05 + */ + is_ref_comp = (ref_comp_field_n > 0); } - is_ref_comp = (ref_comp_field_n > 0); - if (!(is_ref || is_ref_vlen || is_ref_array || is_ref_comp)) { if (H5Tclose(mtype_id) < 0) - H5TOOLS_INFO(H5E_tools_min_id_g, "H5Tclose mtype_id failed"); + H5TOOLS_ERROR((-1), "H5Tclose mtype_id failed"); if (H5Tclose(ftype_id) < 0) - H5TOOLS_INFO(H5E_tools_min_id_g, "H5Tclose ftype_id failed"); + H5TOOLS_ERROR((-1), "H5Tclose ftype_id failed"); if (H5Aclose(attr_id) < 0) - H5TOOLS_INFO(H5E_tools_min_id_g, "H5Aclose attr_id failed"); + H5TOOLS_ERROR((-1), "H5Aclose attr_id failed"); continue; } /* get name */ - if(H5Aget_name(attr_id, 255, name) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_name failed"); + if (H5Aget_name(attr_id, 255, name) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Aget_name failed"); /* get the dataspace handle */ - if((space_id = H5Aget_space(attr_id)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_space failed"); + if ((space_id = H5Aget_space(attr_id)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Aget_space failed"); /* get dimensions */ - if((rank = H5Sget_simple_extent_dims(space_id, dims, NULL)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed"); - + if ((rank = H5Sget_simple_extent_dims(space_id, dims, NULL)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_dims failed"); /*------------------------------------------------------------------------- - * elements - *------------------------------------------------------------------------- - */ + * elements + *------------------------------------------------------------------------- + */ nelmts = 1; - for(j = 0; j < (unsigned)rank; j++) + for (j = 0; j < (unsigned)rank; j++) nelmts *= dims[j]; if (is_ref_array) { - unsigned array_rank = 0; - hsize_t array_size = 1; - hsize_t array_dims[H5S_MAX_RANK]; - hid_t base_type = H5Tget_super(ftype_id); + unsigned array_rank = 0; + hsize_t array_size = 1; + hsize_t array_dims[H5S_MAX_RANK]; + hid_t base_type = H5Tget_super(ftype_id); msize = H5Tget_size(base_type); if (H5Tclose(base_type) < 0) - H5TOOLS_INFO(H5E_tools_min_id_g, "H5Tclose base_type failed"); + H5TOOLS_ERROR((-1), "H5Tclose base_type failed"); array_rank = (unsigned)H5Tget_array_ndims(mtype_id); H5Tget_array_dims2(mtype_id, array_dims); - for(j = 0; j <array_rank; j++) + for (j = 0; j < array_rank; j++) array_size *= array_dims[j]; nelmts *= array_size; } - if((attr_out = H5Acreate2(loc_out, name, ftype_id, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Acreate2 failed"); + if ((attr_out = H5Acreate2(loc_out, name, ftype_id, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Acreate2 failed"); - if (nelmts>0) { + if (nelmts > 0) { /* handle object references */ - if((is_ref || is_ref_array) && (H5R_OBJ_REF_BUF_SIZE==msize)) { + if ((is_ref || is_ref_array) && (H5R_OBJ_REF_BUF_SIZE == msize)) { buf = (hobj_ref_t *)HDmalloc((unsigned)(nelmts * msize)); - if(buf == NULL) { - printf("cannot read into memory\n"); - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDmalloc failed"); + if (buf == NULL) { + HDprintf("cannot read into memory\n"); + H5TOOLS_GOTO_ERROR((-1), "HDmalloc failed"); } /* end if */ - if(H5Aread(attr_id, mtype_id, buf) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aread failed"); + if (H5Aread(attr_id, mtype_id, buf) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Aread failed"); refbuf = (hobj_ref_t *)HDcalloc((unsigned)nelmts, msize); - if(refbuf == NULL) { - printf("cannot allocate memory\n"); - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDcalloc failed"); + if (refbuf == NULL) { + HDprintf("cannot allocate memory\n"); + H5TOOLS_GOTO_ERROR((-1), "HDcalloc failed"); } /* end if */ - for(i = 0; i < (unsigned)nelmts; i++) { - if (update_ref_value(attr_id, H5R_OBJECT, &((hobj_ref_t *)buf)[i], fidout, &((hobj_ref_t *)refbuf)[i], travt)<0) + for (i = 0; i < (unsigned)nelmts; i++) + if (update_ref_value(attr_id, H5R_OBJECT, &((hobj_ref_t *)buf)[i], fidout, + &((hobj_ref_t *)refbuf)[i], travt) < 0) continue; - if(options->verbose) - printf("object <%s> reference created to <%s>\n", name, refname); - } /* i */ } /* H5T_STD_REF_OBJ */ /* handle region references */ - else if((is_ref || is_ref_array) && (H5R_DSET_REG_REF_BUF_SIZE == msize)) { + else if ((is_ref || is_ref_array) && (H5R_DSET_REG_REF_BUF_SIZE == msize)) { buf = (hdset_reg_ref_t *)HDmalloc((unsigned)(nelmts * msize)); - if(buf == NULL) { - printf( "cannot read into memory\n" ); - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDmalloc failed"); + if (buf == NULL) { + HDprintf("cannot read into memory\n"); + H5TOOLS_GOTO_ERROR((-1), "HDmalloc failed"); } /* end if */ - if(H5Aread(attr_id, mtype_id, buf) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aread failed"); + if (H5Aread(attr_id, mtype_id, buf) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Aread failed"); /*------------------------------------------------------------------------- * create output *------------------------------------------------------------------------- */ - refbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)nelmts); /*init to zero */ - if(refbuf == NULL) { - printf( "cannot allocate memory\n" ); - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDcalloc failed"); + refbuf = + (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)nelmts); /*init to zero */ + if (refbuf == NULL) { + HDprintf("cannot allocate memory\n"); + H5TOOLS_GOTO_ERROR((-1), "HDcalloc failed"); } /* end if */ - for(i = 0; i < (unsigned)nelmts; i++) { - if (update_ref_value(attr_id, H5R_DATASET_REGION, &((hdset_reg_ref_t *)buf)[i], fidout, &((hdset_reg_ref_t *)refbuf)[i], travt)<0) + for (i = 0; i < (unsigned)nelmts; i++) + if (update_ref_value(attr_id, H5R_DATASET_REGION, &((hdset_reg_ref_t *)buf)[i], fidout, + &((hdset_reg_ref_t *)refbuf)[i], travt) < 0) continue; - if(options->verbose) - printf("object <%s> region reference created to <%s>\n", name, refname); - } } /* H5T_STD_REF_DSETREG */ else if (is_ref_vlen) { /* handle VLEN of references */ - buf = (hvl_t *)HDmalloc((unsigned)(nelmts * sizeof(hvl_t))); + buf = (hvl_t *)HDmalloc((unsigned)(nelmts * sizeof(hvl_t))); refbuf = buf; /* reuse the read buffer for write */ - if(buf == NULL) { - printf( "cannot read into memory\n" ); - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDmalloc failed"); + if (buf == NULL) { + HDprintf("cannot read into memory\n"); + H5TOOLS_GOTO_ERROR((-1), "HDmalloc failed"); } /* end if */ - if(H5Aread(attr_id, mtype_id, buf) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aread failed"); + if (H5Aread(attr_id, mtype_id, buf) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Aread failed"); - if (H5R_OBJ_REF_BUF_SIZE==msize) { + if (H5R_OBJ_REF_BUF_SIZE == msize) { hobj_ref_t ref_out; - for (i=0; i<(unsigned)nelmts; i++) { + for (i = 0; i < (unsigned)nelmts; i++) { hobj_ref_t *ptr = (hobj_ref_t *)((hvl_t *)buf)[i].p; - for (j=0; j<((hvl_t *)buf)[i].len; j++ ) { - if (update_ref_value(attr_id, H5R_OBJECT, &(ptr[j]), fidout, &ref_out, travt)<0) + for (j = 0; j < ((hvl_t *)buf)[i].len; j++) { + if (update_ref_value(attr_id, H5R_OBJECT, &(ptr[j]), fidout, &ref_out, travt) < 0) continue; HDmemcpy(&(ptr[j]), &ref_out, msize); } - } /* for (i=0; i<nelems; i++) */ + } /* for (i=0; i<nelems; i++) */ } else if (H5R_DSET_REG_REF_BUF_SIZE == msize) { hdset_reg_ref_t ref_out; - for (i=0; i<(unsigned)nelmts; i++) { + for (i = 0; i < (unsigned)nelmts; i++) { hdset_reg_ref_t *ptr = (hdset_reg_ref_t *)((hvl_t *)buf)[i].p; - for (j=0; j<((hvl_t *)buf)[i].len; j++ ) { - if (update_ref_value(attr_id, H5R_DATASET_REGION, &(ptr[j]), fidout, &ref_out, travt)<0) + for (j = 0; j < ((hvl_t *)buf)[i].len; j++) { + if (update_ref_value(attr_id, H5R_DATASET_REGION, &(ptr[j]), fidout, &ref_out, + travt) < 0) continue; HDmemcpy(&(ptr[j]), &ref_out, msize); } - } /* for (i=0; i<nelems; i++) */ + } /* for (i=0; i<nelems; i++) */ } } /* else if (is_ref_vlen) */ else if (is_ref_comp) { /* handle ref fields in a compound */ - buf = HDmalloc((unsigned)(nelmts * msize)); + buf = HDmalloc((unsigned)(nelmts * msize)); refbuf = buf; /* reuse the read buffer for write */ - if(buf == NULL) { - printf( "cannot read into memory\n" ); - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDmalloc failed"); + if (buf == NULL) { + HDprintf("cannot read into memory\n"); + H5TOOLS_GOTO_ERROR((-1), "HDmalloc failed"); } /* end if */ - if(H5Aread(attr_id, mtype_id, buf) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aread failed"); + if (H5Aread(attr_id, mtype_id, buf) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Aread failed"); - for (i=0; i<(unsigned)nelmts; i++) { - for (j=0; j<(unsigned)ref_comp_field_n; j++) { + for (i = 0; i < (unsigned)nelmts; i++) { + for (j = 0; j < (unsigned)ref_comp_field_n; j++) { if (ref_comp_size[j] == H5R_OBJ_REF_BUF_SIZE) { - size_t idx = (i * msize) + H5Tget_member_offset(mtype_id, ref_comp_index[j]); + size_t idx = (i * msize) + H5Tget_member_offset(mtype_id, ref_comp_index[j]); hobj_ref_t ref_out; - if (update_ref_value(attr_id, H5R_OBJECT, (hobj_ref_t *)(((char *)buf)+idx), fidout, &ref_out, travt)<0) + if (update_ref_value(attr_id, H5R_OBJECT, + (hobj_ref_t *)((void *)(((char *)buf) + idx)), fidout, + &ref_out, + travt) < 0) /* Extra (void *) cast to quiet "cast to create + alignment" warning - 2019/07/05, QAK */ continue; - HDmemcpy(((char *)buf)+idx, &ref_out, ref_comp_size[j]); + HDmemcpy(((char *)buf) + idx, &ref_out, ref_comp_size[j]); } /* if */ else if (ref_comp_size[j] == H5R_DSET_REG_REF_BUF_SIZE) { size_t idx = i * msize + H5Tget_member_offset(mtype_id, ref_comp_index[j]); hdset_reg_ref_t ref_out; - if (update_ref_value(attr_id, H5R_DATASET_REGION, (hdset_reg_ref_t *)(((char *)buf)+idx), fidout, &ref_out, travt)<0) + if (update_ref_value(attr_id, H5R_DATASET_REGION, + (hdset_reg_ref_t *)(((char *)buf) + idx), fidout, &ref_out, + travt) < 0) continue; - HDmemcpy(((char *)buf)+idx, &ref_out, ref_comp_size[j]); + HDmemcpy(((char *)buf) + idx, &ref_out, ref_comp_size[j]); } /* else if */ - } /* j */ - } /* i */ - } /* else if (is_ref_comp) */ + } /* j */ + } /* i */ + } /* else if (is_ref_comp) */ - if(H5Awrite(attr_out, mtype_id, refbuf) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Awrite failed"); + if (H5Awrite(attr_out, mtype_id, refbuf) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Awrite failed"); if (is_ref_vlen && buf) - H5Dvlen_reclaim (mtype_id, space_id, H5P_DEFAULT, buf); + H5Dvlen_reclaim(mtype_id, space_id, H5P_DEFAULT, buf); } /* if (nelmts) */ if (refbuf == buf) refbuf = NULL; /* set it to NULL to avoid double free since buf and refbuf are the same. */ - if(buf) { + if (buf) { HDfree(buf); buf = NULL; } - if(refbuf) { + if (refbuf) { HDfree(refbuf); refbuf = NULL; } @@ -746,27 +753,27 @@ static int copy_refs_attr(hid_t loc_in, ref_comp_size = NULL; } - if(H5Aclose(attr_out) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aclose failed"); + if (H5Aclose(attr_out) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Aclose failed"); /*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ - if(H5Tclose(ftype_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); - if(H5Tclose(mtype_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); - if(H5Sclose(space_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed"); - if(H5Aclose(attr_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aclose failed"); + * close + *------------------------------------------------------------------------- + */ + if (H5Tclose(ftype_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); + if (H5Tclose(mtype_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); + if (H5Sclose(space_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed"); + if (H5Aclose(attr_id) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Aclose failed"); } /* for(u = 0; u < (unsigned)oinfo.num_attrs; u++) */ done: - if(refbuf) + if (refbuf) HDfree(refbuf); - if(buf) + if (buf) HDfree(buf); if (ref_comp_index) @@ -775,13 +782,15 @@ done: if (ref_comp_size) HDfree(ref_comp_size); - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(ftype_id); H5Tclose(mtype_id); H5Sclose(space_id); H5Aclose(attr_id); H5Aclose(attr_out); - } H5E_END_TRY; + } + H5E_END_TRY; return ret_value; } @@ -793,29 +802,29 @@ done: * *------------------------------------------------------------------------- */ -static const char* +static const char * MapIdToName(hid_t refobj_id, trav_table_t *travt) { unsigned int u; - const char *ret = NULL; + const char * ret = NULL; /* linear search */ - for(u = 0; u < travt->nobjs; u++) { - if(travt->objs[u].type == (h5trav_type_t)H5O_TYPE_DATASET || - travt->objs[u].type == (h5trav_type_t)H5O_TYPE_GROUP || - travt->objs[u].type == (h5trav_type_t)H5O_TYPE_NAMED_DATATYPE) { - H5O_info_t ref_oinfo; /* Stat for the refobj id */ + for (u = 0; u < travt->nobjs; u++) { + if (travt->objs[u].type == (h5trav_type_t)H5O_TYPE_DATASET || + travt->objs[u].type == (h5trav_type_t)H5O_TYPE_GROUP || + travt->objs[u].type == (h5trav_type_t)H5O_TYPE_NAMED_DATATYPE) { + H5O_info_t ref_oinfo; /* Stat for the refobj id */ /* obtain information to identify the referenced object uniquely */ - if(H5Oget_info(refobj_id, &ref_oinfo) < 0) + if (H5Oget_info(refobj_id, &ref_oinfo) < 0) goto out; - if(ref_oinfo.addr == travt->objs[u].objno) { + if (ref_oinfo.addr == travt->objs[u].objno) { ret = travt->objs[u].name; goto out; - } /* end if */ - } /* end if */ - } /* u */ + } + } /* end if */ + } /* u */ out: return ret; @@ -827,37 +836,39 @@ out: * Purpose: Update a reference value *------------------------------------------------------------------------- */ -static herr_t update_ref_value(hid_t obj_id, H5R_type_t ref_type, void *ref_in, - hid_t fid_out, void *ref_out, trav_table_t *travt) +static herr_t +update_ref_value(hid_t obj_id, H5R_type_t ref_type, void *ref_in, hid_t fid_out, void *ref_out, + trav_table_t *travt) { - int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ const char *ref_obj_name; - hid_t space_id = -1; - hid_t ref_obj_id = -1; + hid_t space_id = H5I_INVALID_HID; + hid_t ref_obj_id = H5I_INVALID_HID; + herr_t ret_value = SUCCEED; ref_obj_id = H5Rdereference(obj_id, ref_type, ref_in); if (ref_obj_id < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Rdereference2 failed"); + H5TOOLS_GOTO_ERROR(FAIL, "H5Rdereference failed"); ref_obj_name = MapIdToName(ref_obj_id, travt); if (ref_obj_name == NULL) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "MapIdToName failed"); + H5TOOLS_GOTO_ERROR(FAIL, "MapIdToName failed"); if (ref_type == H5R_DATASET_REGION) { space_id = H5Rget_region(obj_id, H5R_DATASET_REGION, ref_in); if (space_id < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Rget_region failed"); + H5TOOLS_GOTO_ERROR(FAIL, "H5Rget_region failed"); } - if(H5Rcreate(ref_out, fid_out, ref_obj_name, ref_type, space_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Rcreate failed"); + if (H5Rcreate(ref_out, fid_out, ref_obj_name, ref_type, space_id) < 0) + H5TOOLS_GOTO_ERROR(FAIL, "H5Rcreate failed"); done: - H5E_BEGIN_TRY { - H5Sclose(space_id); - H5Oclose(ref_obj_id); - } H5E_END_TRY; + H5E_BEGIN_TRY + { + H5Sclose(space_id); + H5Oclose(ref_obj_id); + } + H5E_END_TRY; return ret_value; } - diff --git a/tools/h5repack/h5repack_verify.c b/tools/h5repack/h5repack_verify.c index cad92ab..3c4d03d 100644 --- a/tools/h5repack/h5repack_verify.c +++ b/tools/h5repack/h5repack_verify.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,13 +17,12 @@ /* number of members in an array */ #ifndef NELMTS -# define NELMTS(X) (sizeof(X)/sizeof(X[0])) +#define NELMTS(X) (sizeof(X) / sizeof(X[0])) #endif static int verify_layout(hid_t pid, pack_info_t *obj); static int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter); - /*------------------------------------------------------------------------- * Function: h5repack_verify * @@ -39,135 +38,135 @@ static int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *fil int h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options) { - int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ - hid_t fidin = -1; /* file ID for input file*/ - hid_t fidout = -1; /* file ID for output file*/ - hid_t did = -1; /* dataset ID */ - hid_t pid = -1; /* dataset creation property list ID */ - hid_t sid = -1; /* space ID */ - hid_t tid = -1; /* type ID */ - int ok = 1; /* step results */ - unsigned int i; - trav_table_t *travt = NULL; + hid_t fidin = H5I_INVALID_HID; /* file ID for input file*/ + hid_t fidout = H5I_INVALID_HID; /* file ID for output file*/ + hid_t did = H5I_INVALID_HID; /* dataset ID */ + hid_t pid = H5I_INVALID_HID; /* dataset creation property list ID */ + hid_t sid = H5I_INVALID_HID; /* space ID */ + hid_t tid = H5I_INVALID_HID; /* type ID */ + int ok = 1; /* step results */ + unsigned int i; + trav_table_t *travt = NULL; + int ret_value = 0; /* open the output file */ - if((fidout = H5Fopen(out_fname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0 ) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fopen failed on <%s>", out_fname); - - for(i = 0; i < options->op_tbl->nelems; i++) { - char *name = options->op_tbl->objs[i].path; - pack_info_t *obj = &options->op_tbl->objs[i]; - - /*------------------------------------------------------------------------- - * open - *------------------------------------------------------------------------- - */ - if((did = H5Dopen2(fidout, name, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed on <%s>", name); - if((sid = H5Dget_space(did)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed"); - if((pid = H5Dget_create_plist(did)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed"); - if((tid = H5Dget_type(did)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_type failed"); - - /*------------------------------------------------------------------------- - * filter check - *------------------------------------------------------------------------- - */ - if(verify_filters(pid, tid, obj->nfilters, obj->filter) <= 0) + if ((fidout = H5Fopen(out_fname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Fopen failed on <%s>", out_fname); + + for (i = 0; i < options->op_tbl->nelems; i++) { + char * name = options->op_tbl->objs[i].path; + pack_info_t *obj = &options->op_tbl->objs[i]; + + /*------------------------------------------------------------------------- + * open + *------------------------------------------------------------------------- + */ + if ((did = H5Dopen2(fidout, name, H5P_DEFAULT)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed on <%s>", name); + if ((sid = H5Dget_space(did)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed"); + if ((pid = H5Dget_create_plist(did)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed"); + if ((tid = H5Dget_type(did)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dget_type failed"); + + /*------------------------------------------------------------------------- + * filter check + *------------------------------------------------------------------------- + */ + if (verify_filters(pid, tid, obj->nfilters, obj->filter) <= 0) ok = 0; - /*------------------------------------------------------------------------- - * layout check - *------------------------------------------------------------------------- - */ - if((obj->layout != -1) && (verify_layout(pid, obj) == 0)) + /*------------------------------------------------------------------------- + * layout check + *------------------------------------------------------------------------- + */ + if ((obj->layout != -1) && (verify_layout(pid, obj) == 0)) ok = 0; - /*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ - if(H5Pclose(pid) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); + /*------------------------------------------------------------------------- + * close + *------------------------------------------------------------------------- + */ + if (H5Pclose(pid) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); if (H5Sclose(sid) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed"); if (H5Dclose(did) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); if (H5Tclose(tid) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); } - /*------------------------------------------------------------------------- - * check for the "all" objects option - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * check for the "all" objects option + *------------------------------------------------------------------------- + */ - if(options->all_filter == 1 || options->all_layout == 1) { + if (options->all_filter == 1 || options->all_layout == 1) { /* Initialize indexing options */ h5trav_set_index(sort_by, sort_order); /* init table */ trav_table_init(&travt); /* get the list of objects in the file */ - if(h5trav_gettable(fidout, travt) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5trav_gettable failed"); + if (h5trav_gettable(fidout, travt) < 0) + H5TOOLS_GOTO_ERROR((-1), "h5trav_gettable failed"); - for(i = 0; i < travt->nobjs; i++) { + for (i = 0; i < travt->nobjs; i++) { char *name = travt->objs[i].name; - if(travt->objs[i].type == H5TRAV_TYPE_DATASET) { - /*------------------------------------------------------------------------- - * open - *------------------------------------------------------------------------- - */ - if((did = H5Dopen2(fidout, name, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed on <%s>", name); - if((sid = H5Dget_space(did)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed"); - if((pid = H5Dget_create_plist(did)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed"); - if((tid = H5Dget_type(did)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_type failed"); - - /*------------------------------------------------------------------------- - * filter check - *------------------------------------------------------------------------- - */ - if(options->all_filter == 1) { - if(verify_filters(pid, tid, options->n_filter_g, options->filter_g) <= 0) + if (travt->objs[i].type == H5TRAV_TYPE_DATASET) { + /*------------------------------------------------------------------------- + * open + *------------------------------------------------------------------------- + */ + if ((did = H5Dopen2(fidout, name, H5P_DEFAULT)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed on <%s>", name); + if ((sid = H5Dget_space(did)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed"); + if ((pid = H5Dget_create_plist(did)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed"); + if ((tid = H5Dget_type(did)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dget_type failed"); + + /*------------------------------------------------------------------------- + * filter check + *------------------------------------------------------------------------- + */ + if (options->all_filter == 1) { + if (verify_filters(pid, tid, options->n_filter_g, options->filter_g) <= 0) ok = 0; } - /*------------------------------------------------------------------------- - * layout check - *------------------------------------------------------------------------- - */ - if(options->all_layout == 1) { + /*------------------------------------------------------------------------- + * layout check + *------------------------------------------------------------------------- + */ + if (options->all_layout == 1) { pack_info_t pack; init_packobject(&pack); pack.layout = options->layout_g; - pack.chunk = options->chunk_g; - if(verify_layout(pid, &pack) == 0) + pack.chunk = options->chunk_g; + if (verify_layout(pid, &pack) == 0) ok = 0; } - /*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * close + *------------------------------------------------------------------------- + */ if (H5Pclose(pid) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); if (H5Sclose(sid) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed"); if (H5Dclose(did) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); if (H5Tclose(tid) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); } /* if */ - } /* i */ + } /* i */ /* free table */ trav_table_free(travt); @@ -177,7 +176,8 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options ret_value = ok; done: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(pid); H5Sclose(sid); H5Dclose(did); @@ -186,7 +186,8 @@ done: H5Fclose(fidout); if (travt) trav_table_free(travt); - } H5E_END_TRY; + } + H5E_END_TRY; return ret_value; } /* h5repack_verify() */ @@ -206,13 +207,14 @@ done: *------------------------------------------------------------------------- */ -int verify_layout(hid_t pid, pack_info_t *obj) +int +verify_layout(hid_t pid, pack_info_t *obj) { - hsize_t chsize[64]; /* chunk size in elements */ - H5D_layout_t layout; /* layout */ - int nfilters; /* number of filters */ - int rank; /* rank */ - int i; /* index */ + hsize_t chsize[64]; /* chunk size in elements */ + H5D_layout_t layout; /* layout */ + int nfilters; /* number of filters */ + int rank; /* rank */ + int i; /* index */ /* check if we have filters in the input object */ if ((nfilters = H5Pget_nfilters(pid)) < 0) @@ -229,8 +231,8 @@ int verify_layout(hid_t pid, pack_info_t *obj) if (obj->layout != layout) return 0; - if (layout==H5D_CHUNKED) { - if ((rank = H5Pget_chunk(pid, NELMTS(chsize), chsize/*out*/)) < 0) + if (layout == H5D_CHUNKED) { + if ((rank = H5Pget_chunk(pid, NELMTS(chsize), chsize /*out*/)) < 0) return -1; if (obj->chunk.rank != rank) return 0; @@ -254,108 +256,109 @@ int verify_layout(hid_t pid, pack_info_t *obj) *------------------------------------------------------------------------- */ -int h5repack_cmp_pl(const char *fname1, const char *fname2) +int +h5repack_cmp_pl(const char *fname1, const char *fname2) { - int ret_value = 1; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ - hid_t fid1 =-1; /* file ID */ - hid_t fid2 =-1; /* file ID */ - hid_t dset1 =-1; /* dataset ID */ - hid_t dset2 =-1; /* dataset ID */ - hid_t gid =-1; /* group ID */ - hid_t dcpl1 =-1; /* dataset creation property list ID */ - hid_t dcpl2 =-1; /* dataset creation property list ID */ - hid_t gcplid =-1; /* group creation property list */ - unsigned crt_order_flag1; /* group creation order flag */ - unsigned crt_order_flag2; /* group creation order flag */ - trav_table_t *trav = NULL; + hid_t fid1 = H5I_INVALID_HID; /* file ID */ + hid_t fid2 = H5I_INVALID_HID; /* file ID */ + hid_t dset1 = H5I_INVALID_HID; /* dataset ID */ + hid_t dset2 = H5I_INVALID_HID; /* dataset ID */ + hid_t gid = H5I_INVALID_HID; /* group ID */ + hid_t dcpl1 = H5I_INVALID_HID; /* dataset creation property list ID */ + hid_t dcpl2 = H5I_INVALID_HID; /* dataset creation property list ID */ + hid_t gcplid = H5I_INVALID_HID; /* group creation property list */ + unsigned crt_order_flag1; /* group creation order flag */ + unsigned crt_order_flag2; /* group creation order flag */ + trav_table_t *trav = NULL; unsigned int i; + int ret_value = 1; - /*------------------------------------------------------------------------- - * open the files - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * open the files + *------------------------------------------------------------------------- + */ /* Open the files */ if ((fid1 = H5Fopen(fname1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5tools_fopen failed <%s>: %s", fname1, H5FOPENERROR); + H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fname1, H5FOPENERROR); if ((fid2 = H5Fopen(fname2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5tools_fopen failed <%s>: %s", fname2, H5FOPENERROR); + H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fname2, H5FOPENERROR); - /*------------------------------------------------------------------------- - * get file table list of objects - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * get file table list of objects + *------------------------------------------------------------------------- + */ /* Initialize indexing options */ h5trav_set_index(sort_by, sort_order); /* init table */ trav_table_init(&trav); - if(h5trav_gettable(fid1, trav) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5trav_gettable failed"); - - /*------------------------------------------------------------------------- - * traverse the suppplied object list - *------------------------------------------------------------------------- - */ - for(i = 0; i < trav->nobjs; i++) { - if(trav->objs[i].type == H5TRAV_TYPE_GROUP) { + if (h5trav_gettable(fid1, trav) < 0) + H5TOOLS_GOTO_ERROR((-1), "h5trav_gettable failed"); + + /*------------------------------------------------------------------------- + * traverse the suppplied object list + *------------------------------------------------------------------------- + */ + for (i = 0; i < trav->nobjs; i++) { + if (trav->objs[i].type == H5TRAV_TYPE_GROUP) { if ((gid = H5Gopen2(fid1, trav->objs[i].name, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gopen2 failed on first <%s>", trav->objs[i].name); + H5TOOLS_GOTO_ERROR((-1), "H5Gopen2 failed on first <%s>", trav->objs[i].name); if ((gcplid = H5Gget_create_plist(gid)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gget_create_plist failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Gget_create_plist failed"); if (H5Pget_link_creation_order(gcplid, &crt_order_flag1) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_link_creation_order failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pget_link_creation_order failed"); if (H5Pclose(gcplid) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); if (H5Gclose(gid) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Gclose failed"); if ((gid = H5Gopen2(fid2, trav->objs[i].name, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gopen2 failed on second <%s>", trav->objs[i].name); + H5TOOLS_GOTO_ERROR((-1), "H5Gopen2 failed on second <%s>", trav->objs[i].name); if ((gcplid = H5Gget_create_plist(gid)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gget_create_plist failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Gget_create_plist failed"); if (H5Pget_link_creation_order(gcplid, &crt_order_flag2) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_link_creation_order failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pget_link_creation_order failed"); if (H5Pclose(gcplid) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); if (H5Gclose(gid) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Gclose failed"); if (crt_order_flag1 != crt_order_flag2) - HGOTO_ERROR(0, H5E_tools_min_id_g, "property lists failed for <%s> are different", trav->objs[i].name); + H5TOOLS_GOTO_ERROR(0, "property lists failed for <%s> are different", trav->objs[i].name); } - else if(trav->objs[i].type == H5TRAV_TYPE_DATASET) { - if((dset1 = H5Dopen2(fid1, trav->objs[i].name, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed on first <%s>", trav->objs[i].name); - if((dset2 = H5Dopen2(fid2, trav->objs[i].name, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed on second <%s>", trav->objs[i].name); - if((dcpl1 = H5Dget_create_plist(dset1)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed"); - if((dcpl2 = H5Dget_create_plist(dset2)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed"); - - /*------------------------------------------------------------------------- - * compare the property lists - *------------------------------------------------------------------------- - */ - if((ret_value = H5Pequal(dcpl1, dcpl2)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pequal failed"); - - if(ret_value == 0) - HGOTO_ERROR(0, H5E_tools_min_id_g, "property lists failed for <%s> are different", trav->objs[i].name); - - /*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ - if(H5Pclose(dcpl1) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); - if(H5Pclose(dcpl2) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); - if(H5Dclose(dset1) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed"); - if(H5Dclose(dset2) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed"); + else if (trav->objs[i].type == H5TRAV_TYPE_DATASET) { + if ((dset1 = H5Dopen2(fid1, trav->objs[i].name, H5P_DEFAULT)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed on first <%s>", trav->objs[i].name); + if ((dset2 = H5Dopen2(fid2, trav->objs[i].name, H5P_DEFAULT)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed on second <%s>", trav->objs[i].name); + if ((dcpl1 = H5Dget_create_plist(dset1)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed"); + if ((dcpl2 = H5Dget_create_plist(dset2)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed"); + + /*------------------------------------------------------------------------- + * compare the property lists + *------------------------------------------------------------------------- + */ + if ((ret_value = H5Pequal(dcpl1, dcpl2)) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pequal failed"); + + if (ret_value == 0) + H5TOOLS_GOTO_ERROR(0, "property lists failed for <%s> are different", trav->objs[i].name); + + /*------------------------------------------------------------------------- + * close + *------------------------------------------------------------------------- + */ + if (H5Pclose(dcpl1) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); + if (H5Pclose(dcpl2) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); + if (H5Dclose(dset1) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); + if (H5Dclose(dset2) < 0) + H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); } /*if*/ - } /*for*/ + } /*for*/ done: H5E_BEGIN_TRY @@ -368,14 +371,14 @@ done: H5Fclose(fid2); H5Pclose(gcplid); H5Gclose(gid); - if(trav) + if (trav) trav_table_free(trav); - } H5E_END_TRY; + } + H5E_END_TRY; return ret_value; } - /*------------------------------------------------------------------------- * Function: verify_filters * @@ -390,27 +393,25 @@ done: *------------------------------------------------------------------------- */ -static -int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter) +static int +verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter) { - int nfilters_dcpl; /* number of filters in DCPL*/ - unsigned filt_flags; /* filter flags */ - H5Z_filter_t filtn; /* filter identification number */ - unsigned cd_values[20]; /* filter client data values */ - size_t cd_nelmts; /* filter client number of values */ - char f_name[256]; /* filter name */ - size_t size; /* type size */ - int i; /* index */ - unsigned j; /* index */ + int nfilters_dcpl; /* number of filters in DCPL*/ + unsigned filt_flags; /* filter flags */ + H5Z_filter_t filtn; /* filter identification number */ + unsigned cd_values[20]; /* filter client data values */ + size_t cd_nelmts; /* filter client number of values */ + char f_name[256]; /* filter name */ + size_t size; /* type size */ + int i; /* index */ + unsigned j; /* index */ /* get information about filters */ - if((nfilters_dcpl = H5Pget_nfilters(pid)) < 0) + if ((nfilters_dcpl = H5Pget_nfilters(pid)) < 0) return -1; /* if we do not have filters and the requested filter is NONE, return 1 */ - if(!nfilters_dcpl && - nfilters == 1 && - filter[0].filtn == H5Z_FILTER_NONE) + if (!nfilters_dcpl && nfilters == 1 && filter[0].filtn == H5Z_FILTER_NONE) return 1; /* else the numbers of filters must match */ @@ -424,8 +425,8 @@ int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter) for (i = 0; i < nfilters_dcpl; i++) { cd_nelmts = NELMTS(cd_values); - filtn = H5Pget_filter2(pid, (unsigned)i, &filt_flags, &cd_nelmts, - cd_values, sizeof(f_name), f_name, NULL); + filtn = H5Pget_filter2(pid, (unsigned)i, &filt_flags, &cd_nelmts, cd_values, sizeof(f_name), f_name, + NULL); /* filter ID */ if (filtn < 0) @@ -436,7 +437,7 @@ int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter) /* compare client data values. some filters do return local values */ switch (filtn) { case H5Z_FILTER_NONE: - break; + break; case H5Z_FILTER_SHUFFLE: /* 1 private client value is returned by DCPL */ @@ -444,7 +445,7 @@ int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter) return 0; /* get dataset's type size */ - if((size = H5Tget_size(tid)) <= 0) + if ((size = H5Tget_size(tid)) <= 0) return -1; /* the private client value holds the dataset's type size */ diff --git a/tools/h5repack/h5repackgentest.c b/tools/h5repack/h5repackgentest.c new file mode 100644 index 0000000..2b94422 --- /dev/null +++ b/tools/h5repack/h5repackgentest.c @@ -0,0 +1,350 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* For generating files for verifying h5repack with external storage. . . + * + * Each case file should follow the format of: + * + h5repack_<NAME>.h5 + * + h5repack_<NAME>_ex.h5 + * + h5repack_<NAME>_ex-<N>.dat + * ...where NAME idenfities the type, and N is a positive decimal number; + * multiple external files (*.dat) are allowed per file, but they must + * follow the pattern and be in contiguous numerical sequence starting at 0. + * + * Each file typename must be added to the listing for + * `VERIFY_EXTERNAL_CONSOLIDATION` in h5repack.sh + * + * There is no restriction on the name, number, or structure of datasets and + * groups in HDF5 file. + * + * The inluded datatypes should be more than adequate to verify the correctness + * of the behavior -- if one type can be consolidated from external storage, + * then thay all can. + */ + +#include "hdf5.h" +#include "H5private.h" + +#define MAX_NAME_SIZE 256 +#define FILE_INT32LE_1 "h5repack_int32le_1d" +#define FILE_INT32LE_2 "h5repack_int32le_2d" +#define FILE_INT32LE_3 "h5repack_int32le_3d" +#define FILE_UINT8BE "h5repack_uint8be" +#define FILE_F32LE "h5repack_f32le" + +#define H5REPACKGENTEST_OOPS \ + { \ + ret_value = -1; \ + goto done; \ + } + +#define H5REPACKGENTEST_COMMON_CLEANUP(dcpl, file, space) \ + { \ + if ((dcpl) != H5P_DEFAULT && (dcpl) != H5I_INVALID_HID) { \ + (void)H5Pclose((dcpl)); \ + } \ + if ((file) != H5I_INVALID_HID) { \ + (void)H5Fclose((file)); \ + } \ + if ((space) != H5I_INVALID_HID) { \ + (void)H5Sclose((space)); \ + } \ + } + +struct external_def { + hsize_t type_size; + unsigned n_elts_per_file; + unsigned n_elts_total; +}; + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Helper function to create and write a dataset to file. + * Returns 0 on success, -1 on failure. + */ +static int +__make_dataset(hid_t file_id, const char *dset_name, hid_t mem_type_id, hid_t space_id, hid_t dcpl_id, + void *wdata) +{ + hid_t dset_id = H5I_INVALID_HID; + int ret_value = 0; + + dset_id = H5Dcreate2(file_id, dset_name, mem_type_id, space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); + if (dset_id == H5I_INVALID_HID) + H5REPACKGENTEST_OOPS; + + if (H5Dwrite(dset_id, mem_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata) < 0) + H5REPACKGENTEST_OOPS; + +done: + if (dset_id != H5I_INVALID_HID) + (void)H5Dclose(dset_id); + + return ret_value; +} /* end __make_dataset() */ + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Helper function to populate the DCPL external storage list. + * Creates external files for the DCPL, with each file name following the + * convention "<filename>_ex-<num>.dat". Will append `n_external_files` to + * the filename list, with each file having space for `n_elts` items of the + * type (of size `elt_size`). The numeric inputs are not sanity-checked. + * Returns 0 on success, -1 on failure. + */ +static int +__set_dcpl_external_list(hid_t dcpl, const char *filename, unsigned n_elts_per_file, unsigned n_elts_total, + hsize_t elt_size) +{ + char name[MAX_NAME_SIZE]; + unsigned n_external_files = 0; + unsigned i = 0; + + if (NULL == filename || '\0' == *filename) + return -1; + + n_external_files = n_elts_total / n_elts_per_file; + if (n_elts_total != (n_external_files * n_elts_per_file)) + return -1; + + for (i = 0; i < n_external_files; i++) { + if (HDsnprintf(name, MAX_NAME_SIZE, "%s_ex-%u.dat", filename, i) >= MAX_NAME_SIZE) + return -1; + + if (H5Pset_external(dcpl, name, 0, n_elts_per_file * elt_size) < 0) + return -1; + } + return 0; +} /* end __set_dcpl_external_list() */ + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Generalized utility function to write a file with the specified data and + * dataset configuration. If `ext` is provided, will attempt to use external + * storage. + * Returns 0 on success, -1 on failure. + */ +static int +__make_file(const char *basename, struct external_def *ext, hid_t type_id, hsize_t rank, hsize_t *dims, + void *wdata) +{ + char filename[MAX_NAME_SIZE]; + hid_t file_id = H5I_INVALID_HID; + hid_t dcpl_id = H5P_DEFAULT; + hid_t space_id = H5I_INVALID_HID; + int ret_value = 0; + + if (HDsnprintf(filename, MAX_NAME_SIZE, "%s%s.h5", basename, (NULL != ext) ? "_ex" : "") >= MAX_NAME_SIZE) + H5REPACKGENTEST_OOPS; + + if (NULL != ext) { + dcpl_id = H5Pcreate(H5P_DATASET_CREATE); + if (dcpl_id == H5I_INVALID_HID) + H5REPACKGENTEST_OOPS; + + if (__set_dcpl_external_list(dcpl_id, basename, ext->n_elts_per_file, ext->n_elts_total, + ext->type_size) < 0) + H5REPACKGENTEST_OOPS; + } + + space_id = H5Screate_simple((int)rank, dims, NULL); + if (space_id == H5I_INVALID_HID) + H5REPACKGENTEST_OOPS; + + file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + if (file_id == H5I_INVALID_HID) + H5REPACKGENTEST_OOPS; + + if (__make_dataset(file_id, "dset", type_id, space_id, dcpl_id, wdata) < 0) + H5REPACKGENTEST_OOPS; + +done: + H5REPACKGENTEST_COMMON_CLEANUP(dcpl_id, file_id, space_id); + return ret_value; +} /* end __make_file() */ + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Returns 0 on success, -1 on failure. + */ +static int +generate_int32le_1d(hbool_t external) +{ + int32_t wdata[12]; + hsize_t dims[] = {12}; + struct external_def *def_ptr = NULL; + struct external_def def = {(hsize_t)sizeof(int32_t), 6, 12}; + int32_t n = 0; + int ret_value = 0; + + /* Generate values + */ + for (n = 0; n < 12; n++) { + wdata[n] = n - 6; + } + + def_ptr = (TRUE == external) ? (&def) : NULL; + if (__make_file(FILE_INT32LE_1, def_ptr, H5T_STD_I32LE, 1, dims, wdata) < 0) + ret_value = -1; + + return ret_value; +} /* end generate_int32le_1d() */ + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Returns 0 on success, -1 on failure. + */ +static int +generate_int32le_2d(hbool_t external) +{ + int32_t wdata[64]; + hsize_t dims[] = {8, 8}; + struct external_def *def_ptr = NULL; + struct external_def def = {(hsize_t)sizeof(int32_t), 64, 64}; + int32_t n = 0; + int ret_value = 0; + + /* Generate values + */ + for (n = 0; n < 64; n++) { + wdata[n] = n - 32; + } + + def_ptr = (TRUE == external) ? (&def) : NULL; + if (__make_file(FILE_INT32LE_2, def_ptr, H5T_STD_I32LE, 2, dims, wdata) < 0) + ret_value = -1; + + return ret_value; +} /* end generate_int32le_2d() */ + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Returns 0 on success, -1 on failure. + */ +static int +generate_int32le_3d(hbool_t external) +{ + hsize_t dims[] = {8, 8, 8}; + int32_t wdata[512]; /* 8^3, from dims */ + struct external_def *def_ptr = NULL; + struct external_def def = {(hsize_t)sizeof(int32_t), 512, 512}; + int32_t n = 0; + int i = 0; + int j = 0; + int k = 0; + int ret_value = 0; + + /* generate values, alternating positive and negative + */ + for (i = 0, n = 0; (hsize_t)i < dims[0]; i++) { + for (j = 0; (hsize_t)j < dims[1]; j++) { + for (k = 0; (hsize_t)k < dims[2]; k++, n++) { + wdata[n] = (k + j * 512 + i * 4096) * ((n & 1) ? (-1) : (1)); + } + } + } + + def_ptr = (TRUE == external) ? (&def) : NULL; + if (__make_file(FILE_INT32LE_3, def_ptr, H5T_STD_I32LE, 3, dims, wdata) < 0) + ret_value = -1; + + return ret_value; +} /* end generate_int32le_3d() */ + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Returns 0 on success, -1 on failure. + */ +static int +generate_uint8be(hbool_t external) +{ + hsize_t dims[] = {4, 8, 8}; + uint8_t wdata[256]; /* 4*8*8, from dims */ + struct external_def *def_ptr = NULL; + struct external_def def = {(hsize_t)sizeof(uint8_t), 64, 256}; + uint8_t n = 0; + int i = 0; + int j = 0; + int k = 0; + int ret_value = 0; + + /* Generate values, ping-pong from ends of range + */ + for (i = 0, n = 0; (hsize_t)i < dims[0]; i++) { + for (j = 0; (hsize_t)j < dims[1]; j++) { + for (k = 0; (hsize_t)k < dims[2]; k++, n++) { + wdata[n] = (uint8_t)((n & 1) ? -n : n); + } + } + } + + def_ptr = (TRUE == external) ? (&def) : NULL; + if (__make_file(FILE_UINT8BE, def_ptr, H5T_STD_U8BE, 3, dims, wdata) < 0) + ret_value = -1; + + return ret_value; +} /* end generate_uint8be() */ + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Returns 0 on success, -1 on failure. + */ +static int +generate_f32le(hbool_t external) +{ + hsize_t dims[] = {12, 6}; + float wdata[72]; /* 12*6, from dims */ + struct external_def *def_ptr = NULL; + struct external_def def = {(hsize_t)sizeof(float), 72, 72}; + float n = 0; + int i = 0; + int j = 0; + int k = 0; + int ret_value = 0; + + /* Generate values */ + for (i = 0, k = 0, n = 0; (hsize_t)i < dims[0]; i++) { + for (j = 0; (hsize_t)j < dims[1]; j++, k++, n++) { + wdata[k] = n * 801.1f * ((k % 5 == 1) ? (-1) : (1)); + } + } + + def_ptr = (TRUE == external) ? (&def) : NULL; + if (__make_file(FILE_F32LE, def_ptr, H5T_IEEE_F32LE, 2, dims, wdata) < 0) + ret_value = -1; + + return ret_value; +} /* end generate_f32le() */ + +/* ---------------------------------------------------------------------------- + * Create files. + * Return 0 on success, nonzero on failure. + */ +int +main(void) +{ + int i = 0; + + for (i = 0; i < 2; i++) { + hbool_t external = (i & 1) ? TRUE : FALSE; + if (generate_int32le_1d(external) < 0) + HDprintf("A generate_int32le_1d failed!\n"); + + if (generate_int32le_2d(external) < 0) + HDprintf("A generate_int32le_2d failed!\n"); + + if (generate_int32le_3d(external) < 0) + HDprintf("A generate_int32le_3d failed!\n"); + + if (generate_uint8be(external) < 0) + HDprintf("A generate_uint8be failed!\n"); + + if (generate_f32le(external) < 0) + HDprintf("A generate_f32le failed!\n"); + + } /* end for external data storage or not */ + + return EXIT_SUCCESS; +} /* end main() */ diff --git a/tools/h5repack/h5repacktst.c b/tools/h5repack/h5repacktst.c index 72f76c3..d57cd60 100644 --- a/tools/h5repack/h5repacktst.c +++ b/tools/h5repack/h5repacktst.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,39 +17,42 @@ #include "h5tools.h" #include "h5tools_utils.h" -#define GOERROR {H5_FAILED(); goto error;} - +#define GOERROR \ + { \ + H5_FAILED(); \ + goto error; \ + } /* fill value test */ -#define FNAME0 "h5repack_fill.h5" -#define FNAME0OUT "h5repack_fill_out.h5" +#define FNAME0 "h5repack_fill.h5" +#define FNAME0OUT "h5repack_fill_out.h5" /* HDF5 objects and all dataset datatypes */ -#define FNAME1 "h5repack_objs.h5" -#define FNAME1OUT "h5repack_objs_out.h5" +#define FNAME1 "h5repack_objs.h5" +#define FNAME1OUT "h5repack_objs_out.h5" /* attributes, all datatypes */ -#define FNAME2 "h5repack_attr.h5" -#define FNAME2OUT "h5repack_attr_out.h5" +#define FNAME2 "h5repack_attr.h5" +#define FNAME2OUT "h5repack_attr_out.h5" /* hard links */ -#define FNAME3 "h5repack_hlink.h5" -#define FNAME3OUT "h5repack_hlink_out.h5" +#define FNAME3 "h5repack_hlink.h5" +#define FNAME3OUT "h5repack_hlink_out.h5" /* layout */ -#define FNAME4 "h5repack_layout.h5" -#define FNAME4OUT "h5repack_layout_out.h5" +#define FNAME4 "h5repack_layout.h5" +#define FNAME4OUT "h5repack_layout_out.h5" /* H5D_ALLOC_TIME_EARLY */ -#define FNAME5 "h5repack_early.h5" -#define FNAME5OUT "h5repack_early_out.h5" -#define FNAME6 "h5repack_early2.h5" +#define FNAME5 "h5repack_early.h5" +#define FNAME5OUT "h5repack_early_out.h5" +#define FNAME6 "h5repack_early2.h5" #ifdef H5_HAVE_FILTER_SZIP /* SZIP filter */ -#define FNAME7 "h5repack_szip.h5" -#define FNAME7OUT "h5repack_szip_out.h5" +#define FNAME7 "h5repack_szip.h5" +#define FNAME7OUT "h5repack_szip_out.h5" #endif /* GZIP filter */ -#define FNAME8 "h5repack_deflate.h5" -#define FNAME8OUT "h5repack_deflate_out.h5" +#define FNAME8 "h5repack_deflate.h5" +#define FNAME8OUT "h5repack_deflate_out.h5" /* GZIP filter */ -#define FNAME9 "h5repack_shuffle.h5" -#define FNAME9OUT "h5repack_shuffle_out.h5" +#define FNAME9 "h5repack_shuffle.h5" +#define FNAME9OUT "h5repack_shuffle_out.h5" /* Fletcher filter */ #define FNAME10 "h5repack_fletcher.h5" #define FNAME10OUT "h5repack_fletcher_out.h5" @@ -72,44 +75,41 @@ #define FNAME16 "h5repack_ub.h5" #define FNAME16OUT "h5repack_ub_out.h5" /* Named datatypes */ -#define FNAME17 "h5repack_named_dtypes.h5" -#define FNAME17OUT "h5repack_named_dtypes_out.h5" +#define FNAME17 "h5repack_named_dtypes.h5" +#define FNAME17OUT "h5repack_named_dtypes_out.h5" -#define FNAME18 "h5repack_layout2.h5" +#define FNAME18 "h5repack_layout2.h5" -#define FNAME_UB "ublock.bin" +#define FNAME_UB "ublock.bin" /* obj and region references */ -#define FNAME_REF "h5repack_refs.h5" +#define FNAME_REF "h5repack_refs.h5" /* obj and region references in attr of compound and vlen type */ -#define FNAME_ATTR_REF "h5repack_attr_refs.h5" +#define FNAME_ATTR_REF "h5repack_attr_refs.h5" -const char *H5REPACK_FILENAMES[] = { - "h5repack_big_out", - NULL -}; +const char *H5REPACK_FILENAMES[] = {"h5repack_big_out", NULL}; #define H5REPACK_EXTFILE "h5repack_ext.bin" /* Name of tool */ #define PROGRAMNAME "h5repacktst" -#define DIM1 40 -#define DIM2 20 -#define CDIM1 DIM1/2 -#define CDIM2 DIM2/2 -#define RANK 2 +#define DIM1 40 +#define DIM2 20 +#define CDIM1 DIM1 / 2 +#define CDIM2 DIM2 / 2 +#define RANK 2 /* Size of userblock (for userblock test) */ -#define USERBLOCK_SIZE 2048 +#define USERBLOCK_SIZE 2048 /* obj and region references */ -#define NAME_OBJ_DS1 "Dset1" -#define NAME_OBJ_GRP "Group" +#define NAME_OBJ_DS1 "Dset1" +#define NAME_OBJ_GRP "Group" #define NAME_OBJ_NDTYPE "NamedDatatype" -#define NAME_OBJ_DS2 "Dset2" -#define REG_REF_DS1 "Dset_REGREF" +#define NAME_OBJ_DS2 "Dset2" +#define REG_REF_DS1 "Dset_REGREF" /*------------------------------------------------------------------------- * prototypes @@ -134,21 +134,20 @@ static int make_all_filters(hid_t loc_id); static int make_fill(hid_t loc_id); static int make_big(hid_t loc_id); static int make_testfiles(void); -static int write_dset_in(hid_t loc_id,const char* dset_name,hid_t file_id,int make_diffs ); -static int write_attr_in(hid_t loc_id,const char* dset_name,hid_t fid,int make_diffs ); -static int write_dset(hid_t loc_id,int rank,hsize_t *dims,const char *dset_name,hid_t tid,void *buf ); -static int make_dset(hid_t loc_id,const char *name,hid_t sid,hid_t dcpl,void *buf); -static int make_attr(hid_t loc_id,int rank,hsize_t *dims,const char *attr_name,hid_t tid,void *buf); +static int write_dset_in(hid_t loc_id, const char *dset_name, hid_t file_id, int make_diffs); +static int write_attr_in(hid_t loc_id, const char *dset_name, hid_t fid, int make_diffs); +static int write_dset(hid_t loc_id, int rank, hsize_t *dims, const char *dset_name, hid_t tid, void *buf); +static int make_dset(hid_t loc_id, const char *name, hid_t sid, hid_t dcpl, void *buf); +static int make_attr(hid_t loc_id, int rank, hsize_t *dims, const char *attr_name, hid_t tid, void *buf); static int make_dset_reg_ref(hid_t loc_id); static int make_external(hid_t loc_id); static int make_userblock(void); -static int verify_userblock( const char* filename); +static int verify_userblock(const char *filename); static int make_userblock_file(void); static int make_named_dtype(hid_t loc_id); static int make_references(hid_t loc_id); static int make_complex_attr_references(hid_t loc_id); - /*------------------------------------------------------------------------- * Function: main * @@ -159,14 +158,15 @@ static int make_complex_attr_references(hid_t loc_id); *------------------------------------------------------------------------- */ -int main (void) +int +main(void) { - pack_opt_t pack_options; - diff_opt_t diff_options; - h5_stat_t file_stat; - h5_stat_size_t fsize1, fsize2; /* file sizes */ -#if defined (H5_HAVE_FILTER_SZIP) - int szip_can_encode = 0; + pack_opt_t pack_options; + diff_opt_t diff_options; + h5_stat_t file_stat; + h5_stat_size_t fsize1, fsize2; /* file sizes */ +#if defined(H5_HAVE_FILTER_SZIP) + int szip_can_encode = 0; #endif h5tools_setprogname(PROGRAMNAME); @@ -176,8 +176,8 @@ int main (void) h5tools_init(); /* initialize */ - HDmemset(&diff_options, 0, sizeof (diff_opt_t)); - HDmemset(&pack_options, 0, sizeof (pack_opt_t)); + HDmemset(&diff_options, 0, sizeof(diff_opt_t)); + HDmemset(&pack_options, 0, sizeof(pack_opt_t)); /* run tests */ puts("Testing h5repack:"); @@ -189,18 +189,16 @@ int main (void) PASSED(); /*------------------------------------------------------------------------- - * Format of the tests: - * - * 1) make a copy of the file with h5repack - * 2) use the h5diff function to compare the input and output file - *------------------------------------------------------------------------- - */ - - + * Format of the tests: + * + * 1) make a copy of the file with h5repack + * 2) use the h5diff function to compare the input and output file + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- - * file with fill values - *------------------------------------------------------------------------- - */ + * file with fill values + *------------------------------------------------------------------------- + */ TESTING(" copy of datasets (fill values)"); @@ -218,7 +216,6 @@ int main (void) GOERROR; PASSED(); - /*------------------------------------------------------------------------- * file with all kinds of dataset datatypes *------------------------------------------------------------------------- @@ -238,7 +235,6 @@ int main (void) GOERROR; PASSED(); - /*------------------------------------------------------------------------- * file with attributes *------------------------------------------------------------------------- @@ -368,7 +364,7 @@ int main (void) TESTING(" adding szip filter"); -#if defined (H5_HAVE_FILTER_SZIP) +#if defined(H5_HAVE_FILTER_SZIP) if (h5tools_can_encode(H5Z_FILTER_SZIP) > 0) szip_can_encode = 1; @@ -378,7 +374,7 @@ int main (void) */ if (szip_can_encode) { - if (h5repack_init (&pack_options, 0, FALSE) < 0) + if (h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; if (h5repack_addfilter("dset2:SZIP=8,EC", &pack_options) < 0) GOERROR; @@ -390,7 +386,7 @@ int main (void) GOERROR; if (h5repack_verify(FNAME4, FNAME4OUT, &pack_options) <= 0) GOERROR; - if (h5repack_end (&pack_options) < 0) + if (h5repack_end(&pack_options) < 0) GOERROR; PASSED(); @@ -402,14 +398,13 @@ int main (void) SKIPPED(); #endif - /*------------------------------------------------------------------------- * test all objects option *------------------------------------------------------------------------- */ TESTING(" adding szip filter to all"); -#if defined (H5_HAVE_FILTER_SZIP) +#if defined(H5_HAVE_FILTER_SZIP) if (szip_can_encode) { if (h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; @@ -433,7 +428,6 @@ int main (void) SKIPPED(); #endif - TESTING(" addding shuffle filter"); /*------------------------------------------------------------------------- @@ -482,7 +476,6 @@ int main (void) PASSED(); - TESTING(" adding checksum filter"); /*------------------------------------------------------------------------- @@ -529,7 +522,6 @@ int main (void) PASSED(); - TESTING(" filter queue fletcher, shuffle, deflate, szip"); /*------------------------------------------------------------------------- @@ -546,7 +538,7 @@ int main (void) if (h5repack_addfilter("dset1:SHUF", &pack_options) < 0) GOERROR; -#if defined (H5_HAVE_FILTER_SZIP) +#if defined(H5_HAVE_FILTER_SZIP) if (szip_can_encode) { if (h5repack_addfilter("dset1:SZIP=8,NN", &pack_options) < 0) GOERROR; @@ -569,7 +561,6 @@ int main (void) PASSED(); - TESTING(" adding layout chunked"); /*------------------------------------------------------------------------- @@ -585,7 +576,7 @@ int main (void) GOERROR; if (h5diff(FNAME4, FNAME4OUT, NULL, NULL, &diff_options) > 0) GOERROR; - if (h5repack_verify(FNAME4, FNAME4OUT, &pack_options ) <= 0) + if (h5repack_verify(FNAME4, FNAME4OUT, &pack_options) <= 0) GOERROR; if (h5repack_end(&pack_options) < 0) GOERROR; @@ -714,7 +705,6 @@ int main (void) PASSED(); - TESTING(" layout compact to contiguous conversion"); /*------------------------------------------------------------------------- @@ -767,9 +757,9 @@ int main (void) GOERROR; if (h5repack(FNAME4, FNAME4OUT, &pack_options) < 0) GOERROR; - if (h5diff(FNAME4, FNAME4OUT, NULL, NULL, &diff_options) >0) + if (h5diff(FNAME4, FNAME4OUT, NULL, NULL, &diff_options) > 0) GOERROR; - if (h5repack_verify(FNAME4, FNAME4OUT, &pack_options)<= 0) + if (h5repack_verify(FNAME4, FNAME4OUT, &pack_options) <= 0) GOERROR; if (h5repack_end(&pack_options) < 0) GOERROR; @@ -891,7 +881,6 @@ int main (void) GOERROR; PASSED(); - /*------------------------------------------------------------------------- * the following tests assume the input files have filters * FNAME7 @@ -903,7 +892,7 @@ int main (void) */ TESTING(" copy of szip filter"); -#if defined (H5_HAVE_FILTER_SZIP) +#if defined(H5_HAVE_FILTER_SZIP) if (szip_can_encode) { if (h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; @@ -929,7 +918,7 @@ int main (void) TESTING(" removing szip filter"); -#if defined (H5_HAVE_FILTER_SZIP) +#if defined(H5_HAVE_FILTER_SZIP) if (szip_can_encode) { if (h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; @@ -953,7 +942,6 @@ int main (void) SKIPPED(); #endif - TESTING(" copy of deflate filter"); #ifdef H5_HAVE_FILTER_DEFLATE @@ -973,7 +961,6 @@ int main (void) SKIPPED(); #endif - TESTING(" removing deflate filter"); #ifdef H5_HAVE_FILTER_DEFLATE @@ -995,8 +982,6 @@ int main (void) SKIPPED(); #endif - - TESTING(" copy of shuffle filter"); if (h5repack_init(&pack_options, 0, FALSE) < 0) @@ -1012,7 +997,6 @@ int main (void) PASSED(); - TESTING(" removing shuffle filter"); if (h5repack_init(&pack_options, 0, FALSE) < 0) @@ -1030,7 +1014,6 @@ int main (void) PASSED(); - TESTING(" copy of fletcher filter"); if (h5repack_init(&pack_options, 0, FALSE) < 0) @@ -1046,7 +1029,6 @@ int main (void) PASSED(); - TESTING(" removing fletcher filter"); if (h5repack_init(&pack_options, 0, FALSE) < 0) @@ -1064,7 +1046,6 @@ int main (void) PASSED(); - TESTING(" copy of nbit filter"); if (h5repack_init(&pack_options, 0, FALSE) < 0) @@ -1080,7 +1061,6 @@ int main (void) PASSED(); - TESTING(" removing nbit filter"); if (h5repack_init(&pack_options, 0, FALSE) < 0) @@ -1098,7 +1078,6 @@ int main (void) PASSED(); - TESTING(" adding nbit filter"); if (h5repack_init(&pack_options, 0, FALSE) < 0) @@ -1109,14 +1088,13 @@ int main (void) GOERROR; if (h5diff(FNAME12, FNAME12OUT, NULL, NULL, &diff_options) > 0) GOERROR; - if (h5repack_verify(FNAME12, FNAME12OUT, &pack_options)<= 0) + if (h5repack_verify(FNAME12, FNAME12OUT, &pack_options) <= 0) GOERROR; if (h5repack_end(&pack_options) < 0) GOERROR; PASSED(); - TESTING(" copy of scaleoffset filter"); if (h5repack_init(&pack_options, 0, FALSE) < 0) @@ -1132,7 +1110,6 @@ int main (void) PASSED(); - TESTING(" removing scaleoffset filter"); if (h5repack_init(&pack_options, 0, FALSE) < 0) @@ -1150,7 +1127,6 @@ int main (void) PASSED(); - TESTING(" adding scaleoffset filter"); if (h5repack_init(&pack_options, 0, FALSE) < 0) @@ -1168,7 +1144,6 @@ int main (void) PASSED(); - /*------------------------------------------------------------------------- * file with all filters * dset_all @@ -1180,7 +1155,7 @@ int main (void) */ TESTING(" filter conversion from deflate to szip"); -#if defined (H5_HAVE_FILTER_SZIP) && defined (H5_HAVE_FILTER_DEFLATE) +#if defined(H5_HAVE_FILTER_SZIP) && defined(H5_HAVE_FILTER_DEFLATE) if (szip_can_encode) { if (h5repack_init(&pack_options, 0, FALSE) < 0) @@ -1207,7 +1182,7 @@ int main (void) TESTING(" filter conversion from szip to deflate"); -#if defined (H5_HAVE_FILTER_SZIP) && defined (H5_HAVE_FILTER_DEFLATE) +#if defined(H5_HAVE_FILTER_SZIP) && defined(H5_HAVE_FILTER_DEFLATE) if (szip_can_encode) { if (h5repack_init(&pack_options, 0, FALSE) < 0) @@ -1232,7 +1207,6 @@ int main (void) SKIPPED(); #endif - /*------------------------------------------------------------------------- * test the NONE global option *------------------------------------------------------------------------- @@ -1240,7 +1214,7 @@ int main (void) TESTING(" removing all filters"); -#if defined (H5_HAVE_FILTER_SZIP) && defined (H5_HAVE_FILTER_DEFLATE) +#if defined(H5_HAVE_FILTER_SZIP) && defined(H5_HAVE_FILTER_DEFLATE) if (h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; @@ -1300,17 +1274,17 @@ int main (void) *------------------------------------------------------------------------- */ TESTING(" file with userblock"); - if(h5repack_init(&pack_options, 0, FALSE) < 0) + if (h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; - if(h5repack(FNAME16, FNAME16OUT, &pack_options) < 0) + if (h5repack(FNAME16, FNAME16OUT, &pack_options) < 0) GOERROR; - if(h5diff(FNAME16, FNAME16OUT, NULL, NULL, &diff_options) > 0) + if (h5diff(FNAME16, FNAME16OUT, NULL, NULL, &diff_options) > 0) GOERROR; - if(h5repack_verify(FNAME16, FNAME16OUT, &pack_options) <= 0) + if (h5repack_verify(FNAME16, FNAME16OUT, &pack_options) <= 0) GOERROR; - if(verify_userblock(FNAME16OUT) < 0) + if (verify_userblock(FNAME16OUT) < 0) GOERROR; - if(h5repack_end(&pack_options) < 0) + if (h5repack_end(&pack_options) < 0) GOERROR; PASSED(); @@ -1321,7 +1295,7 @@ int main (void) TESTING(" latest file format options"); if (h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; - pack_options.latest = 1; + pack_options.latest = 1; pack_options.grp_compact = 10; pack_options.grp_indexed = 5; pack_options.msg_size[0] = 10; @@ -1333,13 +1307,12 @@ int main (void) GOERROR; if (h5diff(FNAME1, FNAME1OUT, NULL, NULL, &diff_options) > 0) GOERROR; - if (h5repack_verify(FNAME1, FNAME1OUT, &pack_options)<=0) + if (h5repack_verify(FNAME1, FNAME1OUT, &pack_options) <= 0) GOERROR; if (h5repack_end(&pack_options) < 0) GOERROR; PASSED(); - /*------------------------------------------------------------------------- * test several global filters *------------------------------------------------------------------------- @@ -1347,7 +1320,7 @@ int main (void) TESTING(" several global filters"); -#if defined (H5_HAVE_FILTER_DEFLATE) +#if defined(H5_HAVE_FILTER_DEFLATE) if (h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; @@ -1369,7 +1342,6 @@ int main (void) SKIPPED(); #endif - /*------------------------------------------------------------------------- * test file with userblock *------------------------------------------------------------------------- @@ -1378,31 +1350,29 @@ int main (void) #ifdef H5_HAVE_FILTER_DEFLATE - if(h5repack_init(&pack_options, 0, FALSE) < 0) + if (h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; /* add the options for a user block size and user block filename */ - pack_options.ublock_size = USERBLOCK_SIZE; + pack_options.ublock_size = USERBLOCK_SIZE; pack_options.ublock_filename = FNAME_UB; - if(h5repack(FNAME8, FNAME8OUT, &pack_options) < 0) + if (h5repack(FNAME8, FNAME8OUT, &pack_options) < 0) GOERROR; - if(h5diff(FNAME8, FNAME8OUT, NULL, NULL, &diff_options) > 0) + if (h5diff(FNAME8, FNAME8OUT, NULL, NULL, &diff_options) > 0) GOERROR; - if(h5repack_verify(FNAME8, FNAME8OUT, &pack_options) <= 0) + if (h5repack_verify(FNAME8, FNAME8OUT, &pack_options) <= 0) GOERROR; - if(verify_userblock(FNAME8OUT) < 0) + if (verify_userblock(FNAME8OUT) < 0) GOERROR; - if(h5repack_end(&pack_options) < 0) + if (h5repack_end(&pack_options) < 0) GOERROR; - PASSED(); #else SKIPPED(); #endif - /*------------------------------------------------------------------------- * test file with aligment *------------------------------------------------------------------------- @@ -1411,18 +1381,18 @@ int main (void) #ifdef H5_HAVE_FILTER_DEFLATE - if(h5repack_init(&pack_options, 0, FALSE) < 0) + if (h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; /* add the options for aligment */ pack_options.alignment = 1; pack_options.threshold = 1; - if(h5repack(FNAME8, FNAME8OUT, &pack_options) < 0) + if (h5repack(FNAME8, FNAME8OUT, &pack_options) < 0) GOERROR; - if(h5diff(FNAME8, FNAME8OUT, NULL, NULL, &diff_options) > 0) + if (h5diff(FNAME8, FNAME8OUT, NULL, NULL, &diff_options) > 0) GOERROR; - if(h5repack_verify(FNAME8, FNAME8OUT, &pack_options) <= 0) + if (h5repack_verify(FNAME8, FNAME8OUT, &pack_options) <= 0) GOERROR; /* verify aligment */ @@ -1436,7 +1406,7 @@ int main (void) GOERROR; if ((fapl = H5Fget_access_plist(fid)) < 0) GOERROR; - if (H5Pget_alignment(fapl, &threshold, &alignment) < 0) + if (H5Pget_alignment(fapl, &threshold, &alignment) < 0) GOERROR; if (threshold != 1) GOERROR; @@ -1446,14 +1416,11 @@ int main (void) GOERROR; if (H5Fclose(fid) < 0) GOERROR; - } - - if(h5repack_end(&pack_options) < 0) + if (h5repack_end(&pack_options) < 0) GOERROR; - PASSED(); #else SKIPPED(); @@ -1465,19 +1432,18 @@ int main (void) */ TESTING(" file with committed datatypes"); - if(h5repack_init(&pack_options, 0, FALSE) < 0) + if (h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; - if(h5repack(FNAME17, FNAME17OUT, &pack_options) < 0) + if (h5repack(FNAME17, FNAME17OUT, &pack_options) < 0) GOERROR; - if(h5diff(FNAME17, FNAME17OUT, NULL, NULL, &diff_options) > 0) + if (h5diff(FNAME17, FNAME17OUT, NULL, NULL, &diff_options) > 0) GOERROR; - if(h5repack_verify(FNAME17, FNAME17OUT, &pack_options) <= 0) + if (h5repack_verify(FNAME17, FNAME17OUT, &pack_options) <= 0) GOERROR; - if(h5repack_end(&pack_options) < 0) + if (h5repack_end(&pack_options) < 0) GOERROR; - PASSED(); /*------------------------------------------------------------------------- @@ -1492,48 +1458,46 @@ int main (void) /* First run without metadata option. No need to verify the correctness */ /* since this has been verified by earlier tests. Just record the file */ /* size of the output file. */ - if(h5repack_init(&pack_options, 0, FALSE) < 0) + if (h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; - if(h5repack(FNAME4, FNAME4OUT, &pack_options) < 0) + if (h5repack(FNAME4, FNAME4OUT, &pack_options) < 0) GOERROR; - if(HDstat(FNAME4OUT, &file_stat) < 0) + if (HDstat(FNAME4OUT, &file_stat) < 0) GOERROR; fsize1 = file_stat.st_size; - if(h5repack_end(&pack_options) < 0) + if (h5repack_end(&pack_options) < 0) GOERROR; /* run it again with metadata option */ - if(h5repack_init(&pack_options, 0, FALSE) < 0) + if (h5repack_init(&pack_options, 0, FALSE) < 0) GOERROR; pack_options.meta_block_size = 8192; - if(h5repack(FNAME4, FNAME4OUT, &pack_options) < 0) + if (h5repack(FNAME4, FNAME4OUT, &pack_options) < 0) GOERROR; - if(h5diff(FNAME4, FNAME4OUT, NULL, NULL, &diff_options) > 0) + if (h5diff(FNAME4, FNAME4OUT, NULL, NULL, &diff_options) > 0) GOERROR; - if(h5repack_verify(FNAME4, FNAME4OUT, &pack_options) <= 0) + if (h5repack_verify(FNAME4, FNAME4OUT, &pack_options) <= 0) GOERROR; /* record the file size of the output file */ - if(HDstat(FNAME4OUT, &file_stat) < 0) + if (HDstat(FNAME4OUT, &file_stat) < 0) GOERROR; fsize2 = file_stat.st_size; /* verify second file size is larger than the first one */ - if(fsize2 <= fsize1) + if (fsize2 <= fsize1) GOERROR; - if(h5repack_end(&pack_options) < 0) + if (h5repack_end(&pack_options) < 0) GOERROR; PASSED(); - /*------------------------------------------------------------------------- * clean temporary test files *------------------------------------------------------------------------- */ { - hid_t fapl; + hid_t fapl; fapl = h5_fileaccess(); h5_clean_files(H5REPACK_FILENAMES, fapl); - } puts("All h5repack tests passed."); @@ -1545,102 +1509,100 @@ int main (void) error: puts("***** H5REPACK TESTS FAILED *****"); return 1; - } - /*------------------------------------------------------------------------- -* Function: make_testfiles -* -* Purpose: make a test file with all types of HDF5 objects, -* datatypes and filters -* -*------------------------------------------------------------------------- -*/ -static -int make_testfiles(void) + * Function: make_testfiles + * + * Purpose: make a test file with all types of HDF5 objects, + * datatypes and filters + * + *------------------------------------------------------------------------- + */ +static int +make_testfiles(void) { - hid_t fid = -1; + hid_t fid = H5I_INVALID_HID; /*------------------------------------------------------------------------- * create a file for general copy test *------------------------------------------------------------------------- */ - if((fid = H5Fcreate(FNAME0, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME0, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; if (make_fill(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /*------------------------------------------------------------------------- * create another file for general copy test (all datatypes) *------------------------------------------------------------------------- */ - if((fid = H5Fcreate(FNAME1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; if (make_all_objects(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /*------------------------------------------------------------------------- * create a file for attributes copy test *------------------------------------------------------------------------- */ - if((fid = H5Fcreate(FNAME2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; if (make_attributes(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /*------------------------------------------------------------------------- * create a file for hard links test *------------------------------------------------------------------------- */ - if((fid = H5Fcreate(FNAME3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; if (make_hlinks(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /*------------------------------------------------------------------------- * create a file for layouts test *------------------------------------------------------------------------- */ - if((fid = H5Fcreate(FNAME4, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME4, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; if (make_layout(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /*------------------------------------------------------------------------- * create a file for layout conversion test *------------------------------------------------------------------------- */ - if((fid = H5Fcreate(FNAME18, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME18, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; - if(make_layout2(fid) < 0) + if (make_layout2(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /*------------------------------------------------------------------------- * for test layout conversions form chunk with unlimited max dims *------------------------------------------------------------------------- */ - if((fid = H5Fcreate("h5repack_layout3.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate("h5repack_layout3.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; - if(make_layout3(fid) < 0) + if (make_layout3(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /*------------------------------------------------------------------------- @@ -1650,131 +1612,130 @@ int make_testfiles(void) if (make_early() < 0) goto out; - /*------------------------------------------------------------------------- - * create a file with the SZIP filter - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * create a file with the SZIP filter + *------------------------------------------------------------------------- + */ #ifdef H5_HAVE_FILTER_SZIP - if((fid = H5Fcreate(FNAME7, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME7, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; if (make_szip(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; #endif /* H5_HAVE_FILTER_SZIP */ - /*------------------------------------------------------------------------- * create a file with the deflate filter *------------------------------------------------------------------------- */ - if((fid = H5Fcreate(FNAME8, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME8, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; if (make_deflate(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /*------------------------------------------------------------------------- * create a file with the shuffle filter *------------------------------------------------------------------------- */ - if((fid = H5Fcreate(FNAME9, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME9, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; if (make_shuffle(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /*------------------------------------------------------------------------- * create a file with the fletcher32 filter *------------------------------------------------------------------------- */ - if((fid = H5Fcreate(FNAME10, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME10, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; if (make_fletcher32(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /*------------------------------------------------------------------------- * create a file with all the filters *------------------------------------------------------------------------- */ - if((fid = H5Fcreate(FNAME11, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME11, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; if (make_all_filters(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /*------------------------------------------------------------------------- * create a file with the nbit filter *------------------------------------------------------------------------- */ - if((fid = H5Fcreate(FNAME12, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME12, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; if (make_nbit(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /*------------------------------------------------------------------------- * create a file with the scaleoffset filter *------------------------------------------------------------------------- */ - if((fid = H5Fcreate(FNAME13, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME13, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; if (make_scaleoffset(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /*------------------------------------------------------------------------- * create a big dataset *------------------------------------------------------------------------- */ - if((fid = H5Fcreate(FNAME14, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME14, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; if (make_big(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /*------------------------------------------------------------------------- * create a file with external dataset *------------------------------------------------------------------------- */ - if((fid = H5Fcreate(FNAME15, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME15, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; if (make_external(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /*------------------------------------------------------------------------- * create a file with userblock *------------------------------------------------------------------------- */ - if(make_userblock() < 0) + if (make_userblock() < 0) goto out; /*------------------------------------------------------------------------- * create a userblock file *------------------------------------------------------------------------- */ - if(make_userblock_file() < 0) + if (make_userblock_file() < 0) goto out; /*------------------------------------------------------------------------- * create a file with named datatypes *------------------------------------------------------------------------- */ - if((fid = H5Fcreate(FNAME17, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME17, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; if (make_named_dtype(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /*------------------------------------------------------------------------- @@ -1783,23 +1744,23 @@ int make_testfiles(void) * add attribute with obj and region reference type (bug1726) *------------------------------------------------------------------------- */ - if((fid = H5Fcreate(FNAME_REF, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME_REF, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; /* create reference type datasets */ if (make_references(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; /*------------------------------------------------------------------------- * create a file with obj and region references in attribute of compound and * vlen datatype *-------------------------------------------------------------------------*/ - if((fid = H5Fcreate(FNAME_ATTR_REF, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME_ATTR_REF, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; if (make_complex_attr_references(fid) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; return 0; @@ -1809,47 +1770,44 @@ out: return -1; } - - /*------------------------------------------------------------------------- -* Function: make_all_objects -* -* Purpose: make a test file with all types of HDF5 objects -* -*------------------------------------------------------------------------- -*/ -static -int make_all_objects(hid_t loc_id) + * Function: make_all_objects + * + * Purpose: make a test file with all types of HDF5 objects + * + *------------------------------------------------------------------------- + */ +static int +make_all_objects(hid_t loc_id) { - hid_t did = -1; - hid_t gid = -1; - hid_t tid = -1; - hid_t rid = -1; - hid_t sid = -1; - hid_t gcplid = -1; + hid_t did = H5I_INVALID_HID; + hid_t gid = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + hid_t rid = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t gcplid = H5I_INVALID_HID; hsize_t dims[1] = {2}; /* compound datatype */ - typedef struct s_t - { - int a; - float b; + typedef struct s_t { + int a; + float b; } s_t; /*------------------------------------------------------------------------- - * H5G_DATASET - *------------------------------------------------------------------------- - */ + * H5G_DATASET + *------------------------------------------------------------------------- + */ if ((sid = H5Screate_simple(1, dims, NULL)) < 0) goto out; - if ((did = H5Dcreate2(loc_id, "dset_referenced", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(loc_id, "dset_referenced", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) goto out; - /*------------------------------------------------------------------------- - * H5G_GROUP - *------------------------------------------------------------------------- - */ - if ((gid = H5Gcreate2(loc_id, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + * H5G_GROUP + *------------------------------------------------------------------------- + */ + if ((gid = H5Gcreate2(loc_id, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; if (H5Gclose(gid) < 0) goto out; @@ -1865,9 +1823,9 @@ int make_all_objects(hid_t loc_id) goto out; /*------------------------------------------------------------------------- - * H5G_TYPE - *------------------------------------------------------------------------- - */ + * H5G_TYPE + *------------------------------------------------------------------------- + */ /* create a compound datatype */ if ((tid = H5Tcreate(H5T_COMPOUND, sizeof(s_t))) < 0) @@ -1880,27 +1838,27 @@ int make_all_objects(hid_t loc_id) goto out; /*------------------------------------------------------------------------- - * H5G_LINK - *------------------------------------------------------------------------- - */ + * H5G_LINK + *------------------------------------------------------------------------- + */ if (H5Lcreate_soft("dset", loc_id, "link", H5P_DEFAULT, H5P_DEFAULT) < 0) goto out; /*------------------------------------------------------------------------- - * H5G_UDLINK - *------------------------------------------------------------------------- - */ + * H5G_UDLINK + *------------------------------------------------------------------------- + */ /* Create an external link. Other UD links are not supported by h5repack */ if (H5Lcreate_external("file", "path", loc_id, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) goto out; /*------------------------------------------------------------------------- - * write a series of datasetes at root - *------------------------------------------------------------------------- - */ + * write a series of datasetes at root + *------------------------------------------------------------------------- + */ - if ((rid = H5Gopen2(loc_id, "/", H5P_DEFAULT)) < 0) + if ((rid = H5Gopen2(loc_id, "/", H5P_DEFAULT)) < 0) goto out; if (write_dset_in(rid, "dset_referenced", loc_id, 0) < 0) goto out; @@ -1928,58 +1886,58 @@ out: H5Sclose(sid); H5Tclose(tid); H5Pclose(gcplid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- -* Function: make_attributes -* -* Purpose: make a test file with all types of attributes -* -*------------------------------------------------------------------------- -*/ -static -int make_attributes(hid_t loc_id) + * Function: make_attributes + * + * Purpose: make a test file with all types of attributes + * + *------------------------------------------------------------------------- + */ +static int +make_attributes(hid_t loc_id) { - hid_t did = -1; - hid_t gid = -1; - hid_t rid = -1; - hid_t sid = -1; + hid_t did = H5I_INVALID_HID; + hid_t gid = H5I_INVALID_HID; + hid_t rid = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; hsize_t dims[1] = {2}; /*------------------------------------------------------------------------- - * H5G_DATASET - *------------------------------------------------------------------------- - */ + * H5G_DATASET + *------------------------------------------------------------------------- + */ if ((sid = H5Screate_simple(1, dims, NULL)) < 0) goto out; - if ((did = H5Dcreate2(loc_id, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(loc_id, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /*------------------------------------------------------------------------- - * H5G_GROUP - *------------------------------------------------------------------------- - */ - if ((gid = H5Gcreate2(loc_id, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + * H5G_GROUP + *------------------------------------------------------------------------- + */ + if ((gid = H5Gcreate2(loc_id, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if ((rid = H5Gopen2(loc_id, "/", H5P_DEFAULT)) < 0) + if ((rid = H5Gopen2(loc_id, "/", H5P_DEFAULT)) < 0) goto out; /*------------------------------------------------------------------------- - * 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 ( write_attr_in(did, "dset", loc_id, 0) < 0) + if (write_attr_in(did, "dset", loc_id, 0) < 0) goto out; if (write_attr_in(gid, "dset", loc_id, 0) < 0) goto out; if (write_attr_in(rid, "dset", loc_id, 0) < 0) goto out; - /* close */ + /* close */ if (H5Dclose(did) < 0) goto out; if (H5Gclose(gid) < 0) @@ -1998,59 +1956,58 @@ out: H5Gclose(gid); H5Gclose(rid); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; - } /*------------------------------------------------------------------------- -* Function: make_hlinks -* -* Purpose: make a test file with hard links -* -*------------------------------------------------------------------------- -*/ -static -int make_hlinks(hid_t loc_id) + * Function: make_hlinks + * + * Purpose: make a test file with hard links + * + *------------------------------------------------------------------------- + */ +static int +make_hlinks(hid_t loc_id) { - hid_t g1id =- 1; - hid_t g2id = -1; - hid_t g3id = -1; - hsize_t dims[2] = {3,2}; - int buf[3][2] = {{1,1}, {1,2}, {2,2}}; + hid_t g1id = -1; + hid_t g2id = H5I_INVALID_HID; + hid_t g3id = H5I_INVALID_HID; + hsize_t dims[2] = {3, 2}; + int buf[3][2] = {{1, 1}, {1, 2}, {2, 2}}; /*------------------------------------------------------------------------- - * create a dataset and some hard links to it - *------------------------------------------------------------------------- - */ + * create a dataset and some hard links to it + *------------------------------------------------------------------------- + */ - if(write_dset(loc_id, 2, dims, "dset", H5T_NATIVE_INT, buf) < 0) + if (write_dset(loc_id, 2, dims, "dset", H5T_NATIVE_INT, buf) < 0) return -1; - if(H5Lcreate_hard(loc_id, "dset", H5L_SAME_LOC, "link1 to dset", H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_hard(loc_id, "dset", H5L_SAME_LOC, "link1 to dset", H5P_DEFAULT, H5P_DEFAULT) < 0) return -1; - if(H5Lcreate_hard(loc_id, "dset", H5L_SAME_LOC, "link2 to dset", H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_hard(loc_id, "dset", H5L_SAME_LOC, "link2 to dset", H5P_DEFAULT, H5P_DEFAULT) < 0) return -1; - if(H5Lcreate_hard(loc_id, "dset", H5L_SAME_LOC, "link3 to dset", H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_hard(loc_id, "dset", H5L_SAME_LOC, "link3 to dset", H5P_DEFAULT, H5P_DEFAULT) < 0) return -1; /*------------------------------------------------------------------------- - * create a group and some hard links to it - *------------------------------------------------------------------------- - */ + * create a group and some hard links to it + *------------------------------------------------------------------------- + */ - if((g1id = H5Gcreate2(loc_id, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((g1id = H5Gcreate2(loc_id, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if((g2id = H5Gcreate2(g1id, "g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((g2id = H5Gcreate2(g1id, "g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if((g3id = H5Gcreate2(g2id, "g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((g3id = H5Gcreate2(g2id, "g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Lcreate_hard(loc_id, "g1", g2id, "link1 to g1", H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_hard(loc_id, "g1", g2id, "link1 to g1", H5P_DEFAULT, H5P_DEFAULT) < 0) goto out; - if(H5Lcreate_hard(g1id, "g2", g3id, "link1 to g2", H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_hard(g1id, "g2", g3id, "link1 to g2", H5P_DEFAULT, H5P_DEFAULT) < 0) goto out; - /* close */ if (H5Gclose(g1id) < 0) goto out; @@ -2067,29 +2024,28 @@ out: H5Gclose(g1id); H5Gclose(g2id); H5Gclose(g3id); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; - } - /*------------------------------------------------------------------------- -* Function: make_szip -* -* Purpose: make a dataset with the SZIP filter -* -*------------------------------------------------------------------------- -*/ + * Function: make_szip + * + * Purpose: make a dataset with the SZIP filter + * + *------------------------------------------------------------------------- + */ #ifdef H5_HAVE_FILTER_SZIP -static -int make_szip(hid_t loc_id) +static int +make_szip(hid_t loc_id) { - hid_t dcpl = -1; /* dataset creation property list */ - hid_t sid = -1; /* dataspace ID */ - unsigned szip_options_mask = H5_SZIP_ALLOW_K13_OPTION_MASK | H5_SZIP_NN_OPTION_MASK; + hid_t dcpl = H5I_INVALID_HID; /* dataset creation property list */ + hid_t sid = H5I_INVALID_HID; /* dataspace ID */ + unsigned szip_options_mask = H5_SZIP_ALLOW_K13_OPTION_MASK | H5_SZIP_NN_OPTION_MASK; unsigned szip_pixels_per_block = 8; - hsize_t dims[RANK] = {DIM1, DIM2}; - hsize_t chunk_dims[RANK] = {CDIM1, CDIM2}; + hsize_t dims[RANK] = {DIM1, DIM2}; + hsize_t chunk_dims[RANK] = {CDIM1, CDIM2}; int buf[DIM1][DIM2]; int i, j, n; int szip_can_encode = 0; @@ -2100,26 +2056,26 @@ int make_szip(hid_t loc_id) } } /* create a space */ - if((sid = H5Screate_simple(RANK, dims, NULL)) < 0) + if ((sid = H5Screate_simple(RANK, dims, NULL)) < 0) return -1; /* create a dcpl */ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto out; /* set up chunk */ - if(H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) goto out; /*------------------------------------------------------------------------- - * SZIP - *------------------------------------------------------------------------- - */ + * SZIP + *------------------------------------------------------------------------- + */ /* Make sure encoding is enabled */ if (h5tools_can_encode(H5Z_FILTER_SZIP) == 1) szip_can_encode = 1; if (szip_can_encode) { /* set szip data */ - if(H5Pset_szip (dcpl, szip_options_mask, szip_pixels_per_block) < 0) + if (H5Pset_szip(dcpl, szip_options_mask, szip_pixels_per_block) < 0) goto out; if (make_dset(loc_id, "dset_szip", sid, dcpl, buf) < 0) goto out; @@ -2127,38 +2083,38 @@ int make_szip(hid_t loc_id) else /* WARNING? SZIP is decoder only, can't generate test files */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto out; return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } #endif /* H5_HAVE_FILTER_SZIP */ - - /*------------------------------------------------------------------------- -* Function: make_deflate -* -* Purpose: make a dataset with the deflate filter -* -*------------------------------------------------------------------------- -*/ -static -int make_deflate(hid_t loc_id) + * Function: make_deflate + * + * Purpose: make a dataset with the deflate filter + * + *------------------------------------------------------------------------- + */ +static int +make_deflate(hid_t loc_id) { - hid_t dcpl = -1; /* dataset creation property list */ - hid_t sid = -1; /* dataspace ID */ - hsize_t dims[RANK] = {DIM1,DIM2}; - hsize_t chunk_dims[RANK] = {CDIM1,CDIM2}; + hid_t dcpl = H5I_INVALID_HID; /* dataset creation property list */ + hid_t sid = H5I_INVALID_HID; /* dataspace ID */ + hsize_t dims[RANK] = {DIM1, DIM2}; + hsize_t chunk_dims[RANK] = {CDIM1, CDIM2}; int buf[DIM1][DIM2]; hobj_ref_t bufref[1]; /* reference */ hsize_t dims1r[1] = {1}; @@ -2171,22 +2127,22 @@ int make_deflate(hid_t loc_id) } /* create a space */ - if((sid = H5Screate_simple(RANK, dims, NULL)) < 0) + if ((sid = H5Screate_simple(RANK, dims, NULL)) < 0) return -1; /* create a dcpl */ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto out; /* set up chunk */ - if(H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) goto out; - /*------------------------------------------------------------------------- - * GZIP - *------------------------------------------------------------------------- - */ -#if defined (H5_HAVE_FILTER_DEFLATE) + /*------------------------------------------------------------------------- + * GZIP + *------------------------------------------------------------------------- + */ +#if defined(H5_HAVE_FILTER_DEFLATE) /* set deflate data */ - if(H5Pset_deflate(dcpl, 9) < 0) + if (H5Pset_deflate(dcpl, 9) < 0) goto out; if (make_dset(loc_id, "dset_deflate", sid, dcpl, buf) < 0) goto out; @@ -2199,108 +2155,107 @@ int make_deflate(hid_t loc_id) goto out; #endif - /*------------------------------------------------------------------------- - * close space and dcpl - *------------------------------------------------------------------------- - */ - if(H5Sclose(sid) < 0) + * close space and dcpl + *------------------------------------------------------------------------- + */ + if (H5Sclose(sid) < 0) goto out; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto out; return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- -* Function: make_shuffle -* -* Purpose: make a dataset with the shuffle filter -* -*------------------------------------------------------------------------- -*/ -static -int make_shuffle(hid_t loc_id) + * Function: make_shuffle + * + * Purpose: make a dataset with the shuffle filter + * + *------------------------------------------------------------------------- + */ +static int +make_shuffle(hid_t loc_id) { - hid_t dcpl; /* dataset creation property list */ - hid_t sid; /* dataspace ID */ - hsize_t dims[RANK]={DIM1,DIM2}; - hsize_t chunk_dims[RANK]={CDIM1,CDIM2}; - int buf[DIM1][DIM2]; - int i, j, n; + hid_t dcpl; /* dataset creation property list */ + hid_t sid; /* dataspace ID */ + hsize_t dims[RANK] = {DIM1, DIM2}; + hsize_t chunk_dims[RANK] = {CDIM1, CDIM2}; + int buf[DIM1][DIM2]; + int i, j, n; - for (i=n=0; i<DIM1; i++) - { - for (j=0; j<DIM2; j++) - { - buf[i][j]=n++; + for (i = n = 0; i < DIM1; i++) { + for (j = 0; j < DIM2; j++) { + buf[i][j] = n++; } } /* create a space */ - if((sid = H5Screate_simple(RANK, dims, NULL)) < 0) + if ((sid = H5Screate_simple(RANK, dims, NULL)) < 0) return -1; /* create a dcpl */ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto out; /* set up chunk */ - if(H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) goto out; /*------------------------------------------------------------------------- - * shuffle - *------------------------------------------------------------------------- - */ + * shuffle + *------------------------------------------------------------------------- + */ /* set the shuffle filter */ if (H5Pset_shuffle(dcpl) < 0) goto out; - if (make_dset(loc_id,"dset_shuffle",sid,dcpl,buf) < 0) + if (make_dset(loc_id, "dset_shuffle", sid, dcpl, buf) < 0) goto out; - /*------------------------------------------------------------------------- - * close space and dcpl - *------------------------------------------------------------------------- - */ - if(H5Sclose(sid) < 0) + * close space and dcpl + *------------------------------------------------------------------------- + */ + if (H5Sclose(sid) < 0) goto out; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto out; return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /*------------------------------------------------------------------------- -* Function: make_fletcher32 -* -* Purpose: make a dataset with the fletcher32 filter -* -*------------------------------------------------------------------------- -*/ -static -int make_fletcher32(hid_t loc_id) + * Function: make_fletcher32 + * + * Purpose: make a dataset with the fletcher32 filter + * + *------------------------------------------------------------------------- + */ +static int +make_fletcher32(hid_t loc_id) { - hid_t dcpl = -1; /* dataset creation property list */ - hid_t sid = -1; /* dataspace ID */ - hsize_t dims[RANK]={DIM1,DIM2}; - hsize_t chunk_dims[RANK]={CDIM1,CDIM2}; - int buf[DIM1][DIM2]; - int i, j, n; + hid_t dcpl = H5I_INVALID_HID; /* dataset creation property list */ + hid_t sid = H5I_INVALID_HID; /* dataspace ID */ + hsize_t dims[RANK] = {DIM1, DIM2}; + hsize_t chunk_dims[RANK] = {CDIM1, CDIM2}; + int buf[DIM1][DIM2]; + int i, j, n; for (i = n = 0; i < DIM1; i++) { for (j = 0; j < DIM2; j++) { @@ -2308,68 +2263,68 @@ int make_fletcher32(hid_t loc_id) } } /* create a space */ - if((sid = H5Screate_simple(RANK, dims, NULL)) < 0) + if ((sid = H5Screate_simple(RANK, dims, NULL)) < 0) return -1; /* create a dataset creation property list; the same DCPL is used for all dsets */ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto out; /* set up chunk */ - if(H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) goto out; - /*------------------------------------------------------------------------- - * fletcher32 - *------------------------------------------------------------------------- - */ + * fletcher32 + *------------------------------------------------------------------------- + */ /* remove the filters from the dcpl */ - if (H5Premove_filter(dcpl,H5Z_FILTER_ALL) < 0) + if (H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) goto out; /* set the checksum filter */ if (H5Pset_fletcher32(dcpl) < 0) goto out; - if (make_dset(loc_id,"dset_fletcher32",sid,dcpl,buf) < 0) + if (make_dset(loc_id, "dset_fletcher32", sid, dcpl, buf) < 0) goto out; /*------------------------------------------------------------------------- - * close space and dcpl - *------------------------------------------------------------------------- - */ - if(H5Sclose(sid) < 0) + * close space and dcpl + *------------------------------------------------------------------------- + */ + if (H5Sclose(sid) < 0) goto out; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto out; return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- -* Function: make_nbit -* -* Purpose: make a dataset with the nbit filter -* -*------------------------------------------------------------------------- -*/ -static -int make_nbit(hid_t loc_id) + * Function: make_nbit + * + * Purpose: make a dataset with the nbit filter + * + *------------------------------------------------------------------------- + */ +static int +make_nbit(hid_t loc_id) { - hid_t dcpl = -1; /* dataset creation property list */ - hid_t sid = -1; /* dataspace ID */ - hid_t dtid = -1; - hid_t dsid = -1; - hsize_t dims[RANK]={DIM1,DIM2}; - hsize_t chunk_dims[RANK]={CDIM1,CDIM2}; - int buf[DIM1][DIM2]; - int i, j, n; + hid_t dcpl = H5I_INVALID_HID; /* dataset creation property list */ + hid_t sid = H5I_INVALID_HID; /* dataspace ID */ + hid_t dtid = H5I_INVALID_HID; + hid_t dsid = H5I_INVALID_HID; + hsize_t dims[RANK] = {DIM1, DIM2}; + hsize_t chunk_dims[RANK] = {CDIM1, CDIM2}; + int buf[DIM1][DIM2]; + int i, j, n; for (i = n = 0; i < DIM1; i++) { for (j = 0; j < DIM2; j++) { @@ -2377,45 +2332,45 @@ int make_nbit(hid_t loc_id) } } /* create a space */ - if((sid = H5Screate_simple(RANK, dims, NULL)) < 0) + if ((sid = H5Screate_simple(RANK, dims, NULL)) < 0) return -1; /* create a dataset creation property list; the same DCPL is used for all dsets */ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto out; /* set up chunk */ - if(H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) goto out; dtid = H5Tcopy(H5T_NATIVE_INT); - if (H5Tset_precision(dtid,(H5Tget_precision(dtid) - 1)) < 0) + if (H5Tset_precision(dtid, (H5Tget_precision(dtid) - 1)) < 0) goto out; /* remove the filters from the dcpl */ - if(H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) + if (H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) goto out; - if(H5Pset_nbit(dcpl) < 0) + if (H5Pset_nbit(dcpl) < 0) goto out; - if((dsid = H5Dcreate2(loc_id, "dset_nbit", dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dsid = H5Dcreate2(loc_id, "dset_nbit", dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto out; - if(H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto out; H5Dclose(dsid); - if(H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) + if (H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) goto out; - if((dsid = H5Dcreate2(loc_id, "dset_int31", dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dsid = H5Dcreate2(loc_id, "dset_int31", dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto out; - if(H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto out; H5Dclose(dsid); /*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ - if(H5Sclose(sid) < 0) + * close + *------------------------------------------------------------------------- + */ + if (H5Sclose(sid) < 0) goto out; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto out; if (H5Tclose(dtid) < 0) goto out; @@ -2423,34 +2378,35 @@ int make_nbit(hid_t loc_id) return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(dtid); H5Pclose(dcpl); H5Sclose(sid); H5Dclose(dsid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- -* Function: make_scaleoffset -* -* Purpose: make a dataset with the scaleoffset filter -* -*------------------------------------------------------------------------- -*/ -static -int make_scaleoffset(hid_t loc_id) + * Function: make_scaleoffset + * + * Purpose: make a dataset with the scaleoffset filter + * + *------------------------------------------------------------------------- + */ +static int +make_scaleoffset(hid_t loc_id) { - hid_t dcpl = -1; /* dataset creation property list */ - hid_t sid = -1; /* dataspace ID */ - hid_t dtid = -1; - hid_t dsid = -1; - hsize_t dims[RANK] = {DIM1,DIM2}; - hsize_t chunk_dims[RANK] = {CDIM1,CDIM2}; - int buf[DIM1][DIM2]; - int i, j, n; + hid_t dcpl = H5I_INVALID_HID; /* dataset creation property list */ + hid_t sid = H5I_INVALID_HID; /* dataspace ID */ + hid_t dtid = H5I_INVALID_HID; + hid_t dsid = H5I_INVALID_HID; + hsize_t dims[RANK] = {DIM1, DIM2}; + hsize_t chunk_dims[RANK] = {CDIM1, CDIM2}; + int buf[DIM1][DIM2]; + int i, j, n; for (i = n = 0; i < DIM1; i++) { for (j = 0; j < DIM2; j++) { @@ -2458,91 +2414,90 @@ int make_scaleoffset(hid_t loc_id) } } /* create a space */ - if((sid = H5Screate_simple(RANK, dims, NULL)) < 0) + if ((sid = H5Screate_simple(RANK, dims, NULL)) < 0) return -1; /* create a dataset creation property list; the same DCPL is used for all dsets */ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto out; /* set up chunk */ - if(H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) goto out; dtid = H5Tcopy(H5T_NATIVE_INT); /* remove the filters from the dcpl */ - if(H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) + if (H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) goto out; - if(H5Pset_scaleoffset(dcpl, H5Z_SO_INT, 31) < 0) + if (H5Pset_scaleoffset(dcpl, H5Z_SO_INT, 31) < 0) goto out; - if((dsid = H5Dcreate2(loc_id, "dset_scaleoffset", dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dsid = H5Dcreate2(loc_id, "dset_scaleoffset", dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto out; - if(H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto out; H5Dclose(dsid); - if((dsid = H5Dcreate2(loc_id, "dset_none", dtid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((dsid = H5Dcreate2(loc_id, "dset_none", dtid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto out; H5Tclose(dtid); H5Dclose(dsid); /*------------------------------------------------------------------------- - * close space and dcpl - *------------------------------------------------------------------------- - */ - if(H5Sclose(sid) < 0) + * close space and dcpl + *------------------------------------------------------------------------- + */ + if (H5Sclose(sid) < 0) goto out; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto out; return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(dsid); H5Tclose(dtid); H5Pclose(dcpl); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- -* Function: make_all_filters -* -* Purpose: make a file with all filters -* -*------------------------------------------------------------------------- -*/ -static -int make_all_filters(hid_t loc_id) + * Function: make_all_filters + * + * Purpose: make a file with all filters + * + *------------------------------------------------------------------------- + */ +static int +make_all_filters(hid_t loc_id) { - hid_t dcpl; /* dataset creation property list */ - hid_t sid; /* dataspace ID */ - hid_t dtid; - hid_t dsid; -#if defined (H5_HAVE_FILTER_SZIP) - unsigned szip_options_mask=H5_SZIP_ALLOW_K13_OPTION_MASK|H5_SZIP_NN_OPTION_MASK; - unsigned szip_pixels_per_block=8; + hid_t dcpl = H5I_INVALID_HID; /* dataset creation property list */ + hid_t sid = H5I_INVALID_HID; /* dataspace ID */ + hid_t dtid = H5I_INVALID_HID; + hid_t dsid = H5I_INVALID_HID; +#if defined(H5_HAVE_FILTER_SZIP) + unsigned szip_options_mask = H5_SZIP_ALLOW_K13_OPTION_MASK | H5_SZIP_NN_OPTION_MASK; + unsigned szip_pixels_per_block = 8; #endif /* H5_HAVE_FILTER_SZIP */ - hsize_t dims[RANK]={DIM1,DIM2}; - hsize_t chunk_dims[RANK]={CDIM1,CDIM2}; - int buf[DIM1][DIM2]; - int i, j, n; -#if defined (H5_HAVE_FILTER_SZIP) + hsize_t dims[RANK] = {DIM1, DIM2}; + hsize_t chunk_dims[RANK] = {CDIM1, CDIM2}; + int buf[DIM1][DIM2]; + int i, j, n; +#if defined(H5_HAVE_FILTER_SZIP) int szip_can_encode = 0; #endif - for (i=n=0; i<DIM1; i++) - { - for (j=0; j<DIM2; j++) - { - buf[i][j]=n++; + for (i = n = 0; i < DIM1; i++) { + for (j = 0; j < DIM2; j++) { + buf[i][j] = n++; } } /* create a space */ - if((sid = H5Screate_simple(RANK, dims, NULL)) < 0) + if ((sid = H5Screate_simple(RANK, dims, NULL)) < 0) return -1; /* create a dataset creation property list; the same DCPL is used for all dsets */ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) @@ -2559,82 +2514,75 @@ int make_all_filters(hid_t loc_id) if (H5Pset_fletcher32(dcpl) < 0) goto out; -#if defined (H5_HAVE_FILTER_SZIP) - if (h5tools_can_encode(H5Z_FILTER_SZIP) == 1) - { +#if defined(H5_HAVE_FILTER_SZIP) + if (h5tools_can_encode(H5Z_FILTER_SZIP) == 1) { szip_can_encode = 1; } - if (szip_can_encode) - { + if (szip_can_encode) { /* set szip data */ - if(H5Pset_szip (dcpl,szip_options_mask,szip_pixels_per_block) < 0) + if (H5Pset_szip(dcpl, szip_options_mask, szip_pixels_per_block) < 0) goto out; - } else { + } + else { /* WARNING? SZIP is decoder only, can't generate test data using szip */ } #endif -#if defined (H5_HAVE_FILTER_DEFLATE) +#if defined(H5_HAVE_FILTER_DEFLATE) /* set deflate data */ - if(H5Pset_deflate(dcpl, 9) < 0) + if (H5Pset_deflate(dcpl, 9) < 0) goto out; #endif - if (make_dset(loc_id,"dset_all",sid,dcpl,buf) < 0) + if (make_dset(loc_id, "dset_all", sid, dcpl, buf) < 0) goto out; /* remove the filters from the dcpl */ - if (H5Premove_filter(dcpl,H5Z_FILTER_ALL) < 0) + if (H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) goto out; /* set the checksum filter */ if (H5Pset_fletcher32(dcpl) < 0) goto out; - if (make_dset(loc_id,"dset_fletcher32",sid,dcpl,buf) < 0) + if (make_dset(loc_id, "dset_fletcher32", sid, dcpl, buf) < 0) goto out; - - /* Make sure encoding is enabled */ -#if defined (H5_HAVE_FILTER_SZIP) - if (szip_can_encode) - { + /* Make sure encoding is enabled */ +#if defined(H5_HAVE_FILTER_SZIP) + if (szip_can_encode) { /* remove the filters from the dcpl */ - if (H5Premove_filter(dcpl,H5Z_FILTER_ALL) < 0) + if (H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) goto out; /* set szip data */ - if(H5Pset_szip (dcpl,szip_options_mask,szip_pixels_per_block) < 0) + if (H5Pset_szip(dcpl, szip_options_mask, szip_pixels_per_block) < 0) goto out; - if (make_dset(loc_id,"dset_szip",sid,dcpl,buf) < 0) + if (make_dset(loc_id, "dset_szip", sid, dcpl, buf) < 0) goto out; - } else - { + } + else { /* WARNING? SZIP is decoder only, can't generate test dataset */ } #endif - /* remove the filters from the dcpl */ - if (H5Premove_filter(dcpl,H5Z_FILTER_ALL) < 0) + if (H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) goto out; /* set the shuffle filter */ if (H5Pset_shuffle(dcpl) < 0) goto out; - if (make_dset(loc_id,"dset_shuffle",sid,dcpl,buf) < 0) + if (make_dset(loc_id, "dset_shuffle", sid, dcpl, buf) < 0) goto out; - -#if defined (H5_HAVE_FILTER_DEFLATE) +#if defined(H5_HAVE_FILTER_DEFLATE) /* remove the filters from the dcpl */ - if (H5Premove_filter(dcpl,H5Z_FILTER_ALL) < 0) + if (H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) goto out; /* set deflate data */ - if(H5Pset_deflate(dcpl, 1) < 0) + if (H5Pset_deflate(dcpl, 1) < 0) goto out; - if (make_dset(loc_id,"dset_deflate",sid,dcpl,buf) < 0) + if (make_dset(loc_id, "dset_deflate", sid, dcpl, buf) < 0) goto out; #endif - - /* remove the filters from the dcpl */ if (H5Premove_filter(dcpl, H5Z_FILTER_ALL) < 0) goto out; @@ -2645,20 +2593,20 @@ int make_all_filters(hid_t loc_id) goto out; if (H5Tset_precision(dtid, (H5Tget_precision(dtid) - 1)) < 0) goto out; - if((dsid = H5Dcreate2(loc_id, "dset_nbit", dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((dsid = H5Dcreate2(loc_id, "dset_nbit", dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto out; - if(H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto out; /* close */ - if(H5Tclose(dtid) < 0) + if (H5Tclose(dtid) < 0) goto out; - if(H5Dclose(dsid) < 0) + if (H5Dclose(dsid) < 0) goto out; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto out; return 0; @@ -2670,32 +2618,31 @@ out: H5Dclose(dsid); H5Pclose(dcpl); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - - /*------------------------------------------------------------------------- -* Function: make_early -* -* Purpose: create a file for the H5D_ALLOC_TIME_EARLY test -* -*------------------------------------------------------------------------- -*/ -static -int make_early(void) + * Function: make_early + * + * Purpose: create a file for the H5D_ALLOC_TIME_EARLY test + * + *------------------------------------------------------------------------- + */ +static int +make_early(void) { - hsize_t dims[1] ={3000}; - hsize_t cdims[1]={30}; - hid_t fid=-1; - hid_t did=-1; - hid_t sid=-1; - hid_t tid=-1; - hid_t dcpl=-1; + hsize_t dims[1] = {3000}; + hsize_t cdims[1] = {30}; + hid_t fid = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + hid_t dcpl = H5I_INVALID_HID; int i; - char name[10]; - int iter=100; + char name[16]; + int iter = 100; if ((fid = H5Fcreate(FNAME5, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; @@ -2711,15 +2658,14 @@ int make_early(void) if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) goto out; - for(i = 0; i < iter; i++) - { + for (i = 0; i < iter; i++) { if ((fid = H5Fopen(FNAME5, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) goto out; if ((did = H5Dcreate2(fid, "early", H5T_NATIVE_DOUBLE, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto out; if ((tid = H5Tcopy(H5T_NATIVE_DOUBLE)) < 0) goto out; - sprintf(name, "%d", i); + HDsprintf(name, "%d", i); if ((H5Tcommit2(fid, name, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; if (H5Tclose(tid) < 0) @@ -2733,18 +2679,17 @@ int make_early(void) } /*------------------------------------------------------------------------- - * do the same without close/opening the file and creating the dataset - *------------------------------------------------------------------------- - */ + * do the same without close/opening the file and creating the dataset + *------------------------------------------------------------------------- + */ if ((fid = H5Fcreate(FNAME6, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; - for(i = 0; i < iter; i++) - { + for (i = 0; i < iter; i++) { if ((tid = H5Tcopy(H5T_NATIVE_DOUBLE)) < 0) goto out; - sprintf(name, "%d", i); + HDsprintf(name, "%d", i); if ((H5Tcommit2(fid, name, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; if (H5Tclose(tid) < 0) @@ -2768,103 +2713,94 @@ out: H5Sclose(sid); H5Dclose(did); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- -* Function: make_layout -* -* Purpose: make several datasets with several layouts in location LOC_ID -* -*------------------------------------------------------------------------- -*/ -static -int make_layout(hid_t loc_id) + * Function: make_layout + * + * Purpose: make several datasets with several layouts in location LOC_ID + * + *------------------------------------------------------------------------- + */ +static int +make_layout(hid_t loc_id) { - hid_t dcpl=-1; /* dataset creation property list */ - hid_t sid=-1; /* dataspace ID */ - hsize_t dims[RANK]={DIM1,DIM2}; - hsize_t chunk_dims[RANK]={CDIM1,CDIM2}; - int buf[DIM1][DIM2]; - int i, j, n; - char name[6]; - + hid_t dcpl = H5I_INVALID_HID; /* dataset creation property list */ + hid_t sid = H5I_INVALID_HID; /* dataspace ID */ + hsize_t dims[RANK] = {DIM1, DIM2}; + hsize_t chunk_dims[RANK] = {CDIM1, CDIM2}; + int buf[DIM1][DIM2]; + int i, j, n; + char name[16]; - for (i=n=0; i<DIM1; i++) - { - for (j=0; j<DIM2; j++) - { - buf[i][j]=n++; + for (i = n = 0; i < DIM1; i++) { + for (j = 0; j < DIM2; j++) { + buf[i][j] = n++; } } /*------------------------------------------------------------------------- - * make several dataset with no filters - *------------------------------------------------------------------------- - */ - for (i=0; i<4; i++) - { - sprintf(name,"dset%d",i+1); - if (write_dset(loc_id,RANK,dims,name,H5T_NATIVE_INT,buf) < 0) + * make several dataset with no filters + *------------------------------------------------------------------------- + */ + for (i = 0; i < 4; i++) { + HDsprintf(name, "dset%d", i + 1); + if (write_dset(loc_id, RANK, dims, name, H5T_NATIVE_INT, buf) < 0) return -1; } - /*------------------------------------------------------------------------- - * make several dataset with several layout options - *------------------------------------------------------------------------- - */ + * make several dataset with several layout options + *------------------------------------------------------------------------- + */ /* create a space */ - if((sid = H5Screate_simple(RANK, dims, NULL)) < 0) + if ((sid = H5Screate_simple(RANK, dims, NULL)) < 0) return -1; /* create a dataset creation property list; the same DCPL is used for all dsets */ - if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - { + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) { goto out; } /*------------------------------------------------------------------------- - * H5D_COMPACT - *------------------------------------------------------------------------- - */ - if(H5Pset_layout (dcpl,H5D_COMPACT) < 0) + * H5D_COMPACT + *------------------------------------------------------------------------- + */ + if (H5Pset_layout(dcpl, H5D_COMPACT) < 0) goto out; - if (make_dset(loc_id,"dset_compact",sid,dcpl,buf) < 0) - { + if (make_dset(loc_id, "dset_compact", sid, dcpl, buf) < 0) { goto out; } /*------------------------------------------------------------------------- - * H5D_CONTIGUOUS - *------------------------------------------------------------------------- - */ - if(H5Pset_layout (dcpl,H5D_CONTIGUOUS) < 0) + * H5D_CONTIGUOUS + *------------------------------------------------------------------------- + */ + if (H5Pset_layout(dcpl, H5D_CONTIGUOUS) < 0) goto out; - if (make_dset(loc_id,"dset_contiguous",sid,dcpl,buf) < 0) - { + if (make_dset(loc_id, "dset_contiguous", sid, dcpl, buf) < 0) { goto out; } /*------------------------------------------------------------------------- - * H5D_CHUNKED - *------------------------------------------------------------------------- - */ - if(H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) + * H5D_CHUNKED + *------------------------------------------------------------------------- + */ + if (H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) goto out; - if (make_dset(loc_id,"dset_chunk",sid,dcpl,buf) < 0) - { + if (make_dset(loc_id, "dset_chunk", sid, dcpl, buf) < 0) { goto out; } /*------------------------------------------------------------------------- - * close space and dcpl - *------------------------------------------------------------------------- - */ - if(H5Sclose(sid) < 0) + * close space and dcpl + *------------------------------------------------------------------------- + */ + if (H5Sclose(sid) < 0) goto out; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto out; return 0; @@ -2874,7 +2810,8 @@ out: { H5Pclose(dcpl); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } @@ -2888,197 +2825,192 @@ out: * *------------------------------------------------------------------------- */ -#define S_DIM1 4 -#define S_DIM2 10 -#define CONTIG_S "contig_small" -#define CHUNKED_S_FIX "chunked_small_fixed" +#define S_DIM1 4 +#define S_DIM2 10 +#define CONTIG_S "contig_small" +#define CHUNKED_S_FIX "chunked_small_fixed" -static -int make_layout2(hid_t loc_id) +static int +make_layout2(hid_t loc_id) { - hid_t contig_dcpl = -1; /* dataset creation property list */ - hid_t chunked_dcpl = -1; /* dataset creation property list */ + hid_t contig_dcpl = H5I_INVALID_HID; /* dataset creation property list */ + hid_t chunked_dcpl = H5I_INVALID_HID; /* dataset creation property list */ - int i, j, n; /* Local index variables */ - int ret_value = -1; /* Return value */ - hid_t s_sid = -1; /* dataspace ID */ + int i, j, n; /* Local index variables */ + int ret_value = -1; /* Return value */ + hid_t s_sid = H5I_INVALID_HID; /* dataspace ID */ - hsize_t s_dims[RANK] = {S_DIM1,S_DIM2}; /* Dataspace (< 1 k) */ - hsize_t chunk_dims[RANK] = {S_DIM1/2, S_DIM2/2}; /* Dimension sizes for chunks */ + hsize_t s_dims[RANK] = {S_DIM1, S_DIM2}; /* Dataspace (< 1 k) */ + hsize_t chunk_dims[RANK] = {S_DIM1 / 2, S_DIM2 / 2}; /* Dimension sizes for chunks */ - int s_buf[S_DIM1][S_DIM2]; /* Temporary buffer */ + int s_buf[S_DIM1][S_DIM2]; /* Temporary buffer */ - for(i = n = 0; i < S_DIM1; i++) { + for (i = n = 0; i < S_DIM1; i++) { for (j = 0; j < S_DIM2; j++) { s_buf[i][j] = n++; } } /* Create dataspaces */ - if((s_sid = H5Screate_simple(RANK, s_dims, NULL)) < 0) + if ((s_sid = H5Screate_simple(RANK, s_dims, NULL)) < 0) goto out; /* Create contiguous datasets */ - if((contig_dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((contig_dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto out; - if(H5Pset_layout(contig_dcpl, H5D_CONTIGUOUS) < 0) + if (H5Pset_layout(contig_dcpl, H5D_CONTIGUOUS) < 0) goto out; - if(make_dset(loc_id, CONTIG_S, s_sid, contig_dcpl, s_buf) < 0) + if (make_dset(loc_id, CONTIG_S, s_sid, contig_dcpl, s_buf) < 0) goto out; /* Create chunked datasets */ - if((chunked_dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((chunked_dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto out; - if(H5Pset_chunk(chunked_dcpl, RANK, chunk_dims) < 0) + if (H5Pset_chunk(chunked_dcpl, RANK, chunk_dims) < 0) goto out; - if(make_dset(loc_id, CHUNKED_S_FIX, s_sid, chunked_dcpl, s_buf) < 0) + if (make_dset(loc_id, CHUNKED_S_FIX, s_sid, chunked_dcpl, s_buf) < 0) goto out; ret_value = 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(contig_dcpl); H5Pclose(chunked_dcpl); H5Sclose(s_sid); + } + H5E_END_TRY; - } H5E_END_TRY; - - return(ret_value); + return (ret_value); } /* make_layout2() */ /*------------------------------------------------------------------------- -* Function: make_layout3 -* -* Purpose: make chunked datasets with unlimited max dim and chunk dim is -* bigger than current dim. (HDFFV-7933) -* Test for converting chunk to chunk , chunk to conti and chunk -* to compact. -* - The chunk to chunk changes layout bigger than any current dim -* again. -* - The chunk to compact test dataset bigger than 64K, should -* remain original layout.* -* -*------------------------------------------------------------------------- -*/ + * Function: make_layout3 + * + * Purpose: make chunked datasets with unlimited max dim and chunk dim is + * bigger than current dim. (HDFFV-7933) + * Test for converting chunk to chunk , chunk to conti and chunk + * to compact. + * - The chunk to chunk changes layout bigger than any current dim + * again. + * - The chunk to compact test dataset bigger than 64K, should + * remain original layout.* + * + *------------------------------------------------------------------------- + */ #define DIM1_L3 300 #define DIM2_L3 200 /* small size */ #define SDIM1_L3 4 #define SDIM2_L3 50 -static -int make_layout3(hid_t loc_id) +static int +make_layout3(hid_t loc_id) { - hid_t dcpl1=-1; /* dataset creation property list */ - hid_t dcpl2=-1; /* dataset creation property list */ - hid_t dcpl3=-1; /* dataset creation property list */ - hid_t sid1=-1; /* dataspace ID */ - hid_t sid2=-1; /* dataspace ID */ - hsize_t dims1[RANK]={DIM1_L3,DIM2_L3}; - hsize_t dims2[RANK]={SDIM1_L3,SDIM2_L3}; - hsize_t maxdims[RANK]={H5S_UNLIMITED, H5S_UNLIMITED}; - hsize_t chunk_dims1[RANK]={DIM1_L3*2,5}; - hsize_t chunk_dims2[RANK]={SDIM1_L3 + 2, SDIM2_L3/2}; - hsize_t chunk_dims3[RANK]={SDIM1_L3 - 2, SDIM2_L3/2}; - int buf1[DIM1_L3][DIM2_L3]; - int buf2[SDIM1_L3][SDIM2_L3]; - int i, j, n; + hid_t dcpl1 = H5I_INVALID_HID; /* dataset creation property list */ + hid_t dcpl2 = H5I_INVALID_HID; /* dataset creation property list */ + hid_t dcpl3 = H5I_INVALID_HID; /* dataset creation property list */ + hid_t sid1 = H5I_INVALID_HID; /* dataspace ID */ + hid_t sid2 = H5I_INVALID_HID; /* dataspace ID */ + hsize_t dims1[RANK] = {DIM1_L3, DIM2_L3}; + hsize_t dims2[RANK] = {SDIM1_L3, SDIM2_L3}; + hsize_t maxdims[RANK] = {H5S_UNLIMITED, H5S_UNLIMITED}; + hsize_t chunk_dims1[RANK] = {DIM1_L3 * 2, 5}; + hsize_t chunk_dims2[RANK] = {SDIM1_L3 + 2, SDIM2_L3 / 2}; + hsize_t chunk_dims3[RANK] = {SDIM1_L3 - 2, SDIM2_L3 / 2}; + int buf1[DIM1_L3][DIM2_L3]; + int buf2[SDIM1_L3][SDIM2_L3]; + int i, j, n; /* init buf1 */ - for (i=n=0; i<DIM1_L3; i++) - { - for (j=0; j<DIM2_L3; j++) - { - buf1[i][j]=n++; + for (i = n = 0; i < DIM1_L3; i++) { + for (j = 0; j < DIM2_L3; j++) { + buf1[i][j] = n++; } } /* init buf2 */ - for (i=n=0; i<SDIM1_L3; i++) - { - for (j=0; j<SDIM2_L3; j++) - { - buf2[i][j]=n++; + for (i = n = 0; i < SDIM1_L3; i++) { + for (j = 0; j < SDIM2_L3; j++) { + buf2[i][j] = n++; } } /*------------------------------------------------------------------------- - * make chunked dataset with - * - dset maxdims are UNLIMIT - * - a chunk dim is bigger than dset dim - * - dset size bigger than compact max (64K) - *------------------------------------------------------------------------- - */ + * make chunked dataset with + * - dset maxdims are UNLIMIT + * - a chunk dim is bigger than dset dim + * - dset size bigger than compact max (64K) + *------------------------------------------------------------------------- + */ /* create a space */ - if((sid1 = H5Screate_simple(RANK, dims1, maxdims)) < 0) + if ((sid1 = H5Screate_simple(RANK, dims1, maxdims)) < 0) return -1; /* create a dataset creation property list; the same DCPL is used for all dsets */ - if ((dcpl1 = H5Pcreate(H5P_DATASET_CREATE)) < 0) - { + if ((dcpl1 = H5Pcreate(H5P_DATASET_CREATE)) < 0) { goto out; } - if(H5Pset_chunk(dcpl1, RANK, chunk_dims1) < 0) + if (H5Pset_chunk(dcpl1, RANK, chunk_dims1) < 0) goto out; - if (make_dset(loc_id,"chunk_unlimit1",sid1,dcpl1,buf1) < 0) - { + if (make_dset(loc_id, "chunk_unlimit1", sid1, dcpl1, buf1) < 0) { goto out; } /*------------------------------------------------------------------------- - * make chunked dataset with - * - dset maxdims are UNLIMIT - * - a chunk dim is bigger than dset dim - * - dset size smaller than compact (64K) - *------------------------------------------------------------------------- - */ + * make chunked dataset with + * - dset maxdims are UNLIMIT + * - a chunk dim is bigger than dset dim + * - dset size smaller than compact (64K) + *------------------------------------------------------------------------- + */ /* create a space */ - if((sid2 = H5Screate_simple(RANK, dims2, maxdims)) < 0) + if ((sid2 = H5Screate_simple(RANK, dims2, maxdims)) < 0) return -1; /* create a dataset creation property list; the same DCPL is used for all dsets */ if ((dcpl2 = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto out; - if(H5Pset_chunk(dcpl2, RANK, chunk_dims2) < 0) + if (H5Pset_chunk(dcpl2, RANK, chunk_dims2) < 0) goto out; - if (make_dset(loc_id,"chunk_unlimit2",sid2,dcpl2,buf2) < 0) + if (make_dset(loc_id, "chunk_unlimit2", sid2, dcpl2, buf2) < 0) goto out; /*------------------------------------------------------------------------- - * make chunked dataset with - * - dset maxdims are UNLIMIT - * - a chunk dims are smaller than dset dims - * - dset size smaller than compact (64K) - *------------------------------------------------------------------------- - */ + * make chunked dataset with + * - dset maxdims are UNLIMIT + * - a chunk dims are smaller than dset dims + * - dset size smaller than compact (64K) + *------------------------------------------------------------------------- + */ /* create a dataset creation property list; the same DCPL is used for all dsets */ if ((dcpl3 = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto out; - if(H5Pset_chunk(dcpl3, RANK, chunk_dims3) < 0) + if (H5Pset_chunk(dcpl3, RANK, chunk_dims3) < 0) goto out; - if (make_dset(loc_id,"chunk_unlimit3",sid2,dcpl3,buf2) < 0) + if (make_dset(loc_id, "chunk_unlimit3", sid2, dcpl3, buf2) < 0) goto out; /*------------------------------------------------------------------------- - * close space and dcpl - *------------------------------------------------------------------------- - */ - if(H5Sclose(sid1) < 0) + * close space and dcpl + *------------------------------------------------------------------------- + */ + if (H5Sclose(sid1) < 0) goto out; - if(H5Sclose(sid2) < 0) + if (H5Sclose(sid2) < 0) goto out; - if(H5Pclose(dcpl1) < 0) + if (H5Pclose(dcpl1) < 0) goto out; - if(H5Pclose(dcpl2) < 0) + if (H5Pclose(dcpl2) < 0) goto out; - if(H5Pclose(dcpl3) < 0) + if (H5Pclose(dcpl3) < 0) goto out; return 0; @@ -3091,183 +3023,185 @@ out: H5Pclose(dcpl1); H5Pclose(dcpl2); H5Pclose(dcpl3); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /*------------------------------------------------------------------------- -* Function: make a file with an integer dataset with a fill value -* -* Purpose: test copy of fill values -* -*------------------------------------------------------------------------- -*/ -static -int make_fill(hid_t loc_id) + * Function: make a file with an integer dataset with a fill value + * + * Purpose: test copy of fill values + * + *------------------------------------------------------------------------- + */ +static int +make_fill(hid_t loc_id) { - hid_t did=-1; - hid_t sid=-1; + hid_t did = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; hid_t dcpl; - hsize_t dims[2]={3,2}; - int buf[3][2]= {{1,1},{1,2},{2,2}}; + hsize_t dims[2] = {3, 2}; + int buf[3][2] = {{1, 1}, {1, 2}, {2, 2}}; int fillvalue = 2; /*------------------------------------------------------------------------- - * H5T_INTEGER, write a fill value - *------------------------------------------------------------------------- - */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + * H5T_INTEGER, write a fill value + *------------------------------------------------------------------------- + */ + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto out; - if(H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillvalue) < 0) + if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillvalue) < 0) goto out; - if((sid = H5Screate_simple(2,dims,NULL)) < 0) + if ((sid = H5Screate_simple(2, dims, NULL)) < 0) goto out; - if((did = H5Dcreate2(loc_id, "dset_fill", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(loc_id, "dset_fill", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto out; - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto out; /* close */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Sclose(sid); H5Dclose(did); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; - } /*------------------------------------------------------------------------- -* Function: make_big -* -* Purpose: used in test read by hyperslabs. Creates a 128MB dataset. -* Only 1 1024Kb hyperslab is written. -* -*------------------------------------------------------------------------- -*/ -static -int make_big(hid_t loc_id) + * Function: make_big + * + * Purpose: used in test read by hyperslabs. Creates a 128MB dataset. + * Only 1 1024Kb hyperslab is written. + * + *------------------------------------------------------------------------- + */ +static int +make_big(hid_t loc_id) { - hid_t did=-1; - hid_t f_sid=-1; - hid_t m_sid=-1; - hid_t tid; - hid_t dcpl; - hsize_t dims[1]={ H5TOOLS_MALLOCSIZE + 1}; /* dataset dimensions */ - hsize_t hs_size[1]; /* hyperslab dimensions */ - hsize_t hs_start[1]; /* hyperslab start */ - hsize_t chunk_dims[1]={1024}; /* chunk dimensions */ - size_t size; - size_t nelmts=(size_t)1024; - signed char fillvalue=-1; - signed char *buf=NULL; + hid_t did = H5I_INVALID_HID; + hid_t f_sid = H5I_INVALID_HID; + hid_t m_sid = H5I_INVALID_HID; + hid_t tid; + hid_t dcpl; + hsize_t dims[1] = {H5TOOLS_MALLOCSIZE + 1}; /* dataset dimensions */ + hsize_t hs_size[1]; /* hyperslab dimensions */ + hsize_t hs_start[1]; /* hyperslab start */ + hsize_t chunk_dims[1] = {1024}; /* chunk dimensions */ + size_t size; + size_t nelmts = (size_t)1024; + signed char fillvalue = -1; + signed char *buf = NULL; /* write one 1024 byte hyperslab */ hs_start[0] = 0; hs_size[0] = 1024; /* create */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto out; - if(H5Pset_fill_value(dcpl, H5T_NATIVE_SCHAR, &fillvalue) < 0) + if (H5Pset_fill_value(dcpl, H5T_NATIVE_SCHAR, &fillvalue) < 0) goto out; - if(H5Pset_chunk(dcpl, 1, chunk_dims) < 0) + if (H5Pset_chunk(dcpl, 1, chunk_dims) < 0) goto out; - if((f_sid = H5Screate_simple(1,dims,NULL)) < 0) + if ((f_sid = H5Screate_simple(1, dims, NULL)) < 0) goto out; - if((did = H5Dcreate2(loc_id, "dset", H5T_NATIVE_SCHAR, f_sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(loc_id, "dset", H5T_NATIVE_SCHAR, f_sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto out; - if((m_sid = H5Screate_simple(1, hs_size, hs_size)) < 0) + if ((m_sid = H5Screate_simple(1, hs_size, hs_size)) < 0) goto out; - if((tid = H5Dget_type(did)) < 0) + if ((tid = H5Dget_type(did)) < 0) goto out; - if((size = H5Tget_size(tid))<=0) + if ((size = H5Tget_size(tid)) <= 0) goto out; /* initialize buffer to 0 */ - buf=(signed char *) HDcalloc( nelmts, size); + buf = (signed char *)HDcalloc(nelmts, size); - if (H5Sselect_hyperslab (f_sid,H5S_SELECT_SET,hs_start,NULL,hs_size, NULL) < 0) + if (H5Sselect_hyperslab(f_sid, H5S_SELECT_SET, hs_start, NULL, hs_size, NULL) < 0) goto out; - if (H5Dwrite (did,H5T_NATIVE_SCHAR,m_sid,f_sid,H5P_DEFAULT,buf) < 0) + if (H5Dwrite(did, H5T_NATIVE_SCHAR, m_sid, f_sid, H5P_DEFAULT, buf) < 0) goto out; HDfree(buf); - buf=NULL; + buf = NULL; /* close */ - if(H5Sclose(f_sid) < 0) + if (H5Sclose(f_sid) < 0) goto out; - if(H5Sclose(m_sid) < 0) + if (H5Sclose(m_sid) < 0) goto out; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(dcpl); H5Sclose(f_sid); H5Sclose(m_sid); H5Dclose(did); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; - } - /*------------------------------------------------------------------------- -* Function: make_external -* -* Purpose: create a external dataset -* -*------------------------------------------------------------------------- -*/ -static -int make_external(hid_t loc_id) + * Function: make_external + * + * Purpose: create a external dataset + * + *------------------------------------------------------------------------- + */ +static int +make_external(hid_t loc_id) { - hid_t did=-1; - hid_t sid=-1; + hid_t did = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; hid_t dcpl; - int buf[2]={1,2}; - hsize_t cur_size[1]; /* data space current size */ - hsize_t max_size[1]; /* data space maximum size */ + int buf[2] = {1, 2}; + hsize_t cur_size[1]; /* data space current size */ + hsize_t max_size[1]; /* data space maximum size */ hsize_t size; cur_size[0] = max_size[0] = 2; - size = max_size[0] * sizeof(int); + size = max_size[0] * sizeof(int); /* create */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto out; - if(H5Pset_external(dcpl, H5REPACK_EXTFILE, (off_t)0, size) < 0) + if (H5Pset_external(dcpl, H5REPACK_EXTFILE, (off_t)0, size) < 0) goto out; - if((sid = H5Screate_simple(1,cur_size, max_size)) < 0) + if ((sid = H5Screate_simple(1, cur_size, max_size)) < 0) goto out; - if((did = H5Dcreate2(loc_id, "external", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(loc_id, "external", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto out; - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto out; /* close */ - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto out; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; return 0; @@ -3278,51 +3212,50 @@ out: H5Pclose(dcpl); H5Sclose(sid); H5Dclose(did); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; - } /*------------------------------------------------------------------------- -* Function: make_userblock -* -* Purpose: create a file for the userblock copying test -* -*------------------------------------------------------------------------- -*/ + * Function: make_userblock + * + * Purpose: create a file for the userblock copying test + * + *------------------------------------------------------------------------- + */ static int make_userblock(void) { - hid_t fid = -1; - hid_t fcpl = -1; - int fd = -1; /* File descriptor for writing userblock */ + hid_t fid = H5I_INVALID_HID; + hid_t fcpl = H5I_INVALID_HID; + int fd = -1; /* File descriptor for writing userblock */ char ub[USERBLOCK_SIZE]; /* User block data */ ssize_t nwritten; /* # of bytes written */ size_t u; /* Local index variable */ /* Create file creation property list with userblock set */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) goto out; - if(H5Pset_userblock(fcpl, (hsize_t)USERBLOCK_SIZE) < 0) + if (H5Pset_userblock(fcpl, (hsize_t)USERBLOCK_SIZE) < 0) goto out; /* Create file with userblock */ - if((fid = H5Fcreate(FNAME16, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FNAME16, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) goto out; /* Close file creation property list */ - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) goto out; - /* Initialize userblock data */ - for(u = 0; u < USERBLOCK_SIZE; u++) + for (u = 0; u < USERBLOCK_SIZE; u++) ub[u] = (char)('a' + (char)(u % 26)); /* Re-open HDF5 file, as "plain" file */ - if((fd = HDopen(FNAME16, O_WRONLY, 0644)) < 0) + if ((fd = HDopen(FNAME16, O_WRONLY, 0644)) < 0) goto out; /* Write userblock data */ @@ -3335,58 +3268,59 @@ make_userblock(void) return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fcpl); H5Fclose(fid); - } H5E_END_TRY; - if(fd > 0) + } + H5E_END_TRY; + if (fd >= 0) HDclose(fd); return -1; } /* end make_userblock() */ /*------------------------------------------------------------------------- -* Function: verify_userblock -* -* Purpose: Verify that the userblock was copied correctly -* -*------------------------------------------------------------------------- -*/ + * Function: verify_userblock + * + * Purpose: Verify that the userblock was copied correctly + * + *------------------------------------------------------------------------- + */ static int -verify_userblock( const char* filename) +verify_userblock(const char *filename) { - hid_t fid = -1; - hid_t fcpl = -1; - int fd = -1; /* File descriptor for writing userblock */ + hid_t fid = H5I_INVALID_HID; + hid_t fcpl = H5I_INVALID_HID; + int fd = -1; /* File descriptor for writing userblock */ char ub[USERBLOCK_SIZE]; /* User block data */ hsize_t ub_size = 0; /* User block size */ ssize_t nread; /* # of bytes read */ size_t u; /* Local index variable */ /* Open file with userblock */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) goto out; /* Retrieve file creation property list & userblock size */ - if((fcpl = H5Fget_create_plist(fid)) < 0) + if ((fcpl = H5Fget_create_plist(fid)) < 0) goto out; - if(H5Pget_userblock(fcpl, &ub_size) < 0) + if (H5Pget_userblock(fcpl, &ub_size) < 0) goto out; /* Verify userblock size is correct */ - if(ub_size != USERBLOCK_SIZE) + if (ub_size != USERBLOCK_SIZE) goto out; /* Close file creation property list */ - if(H5Pclose(fcpl) < 0) + if (H5Pclose(fcpl) < 0) goto out; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) goto out; - /* Re-open HDF5 file, as "plain" file */ - if((fd = HDopen(filename, O_RDONLY, 0)) < 0) + if ((fd = HDopen(filename, O_RDONLY, 0)) < 0) goto out; /* Read userblock data */ @@ -3394,8 +3328,8 @@ verify_userblock( const char* filename) HDassert(nread == USERBLOCK_SIZE); /* Verify userblock data */ - for(u = 0; u < USERBLOCK_SIZE; u++) - if(ub[u] != (char)('a' + (u % 26))) + for (u = 0; u < USERBLOCK_SIZE; u++) + if (ub[u] != (char)('a' + (u % 26))) goto out; /* Close file */ @@ -3404,24 +3338,25 @@ verify_userblock( const char* filename) return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fcpl); H5Fclose(fid); - } H5E_END_TRY; - if(fd > 0) + } + H5E_END_TRY; + if (fd >= 0) HDclose(fd); return -1; } /* end verify_userblock() */ - /*------------------------------------------------------------------------- -* Function: make_userblock_file -* -* Purpose: create a file for the userblock add test -* -*------------------------------------------------------------------------- -*/ + * Function: make_userblock_file + * + * Purpose: create a file for the userblock add test + * + *------------------------------------------------------------------------- + */ static int make_userblock_file(void) { @@ -3431,11 +3366,11 @@ make_userblock_file(void) size_t u; /* Local index variable */ /* initialize userblock data */ - for(u = 0; u < USERBLOCK_SIZE; u++) + for (u = 0; u < USERBLOCK_SIZE; u++) ub[u] = (char)('a' + (char)(u % 26)); /* open file */ - if((fd = HDopen(FNAME_UB,O_WRONLY|O_CREAT|O_TRUNC, 0644 )) < 0) + if ((fd = HDopen(FNAME_UB, O_WRONLY | O_CREAT | O_TRUNC, 0644)) < 0) goto out; /* write userblock data */ @@ -3449,147 +3384,135 @@ make_userblock_file(void) out: - if(fd > 0) + if (fd >= 0) HDclose(fd); return -1; } /*------------------------------------------------------------------------- -* Function: write_dset_in -* -* Purpose: write datasets in LOC_ID -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: November 12, 2003 -* -*------------------------------------------------------------------------- -*/ -static -int write_dset_in(hid_t loc_id, - const char* dset_name, /* for saving reference to dataset*/ - hid_t file_id, - int make_diffs /* flag to modify data buffers */) + * Function: write_dset_in + * + * Purpose: write datasets in LOC_ID + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: November 12, 2003 + * + *------------------------------------------------------------------------- + */ +static int +write_dset_in(hid_t loc_id, const char *dset_name, /* for saving reference to dataset*/ + hid_t file_id, int make_diffs /* flag to modify data buffers */) { /* compound datatype */ - typedef struct s_t - { + typedef struct s_t { char a; double b; } s_t; - typedef enum - { - RED, - GREEN - } e_t; - - hid_t did=-1; - hid_t sid=-1; - hid_t tid=-1; - hid_t pid=-1; + typedef enum { RED, GREEN } e_t; + + hid_t did = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + hid_t pid = H5I_INVALID_HID; unsigned i, j; - int val, k, n; - float f; + int val, k, n; + float f; /* create 1D attributes with dimension [2], 2 elements */ - hsize_t dims[1]={2}; - hsize_t dims1r[1]={2}; - char buf1[2][3]= {"ab","de"}; /* string */ - char buf2[2]= {1,2}; /* bitfield, opaque */ - s_t buf3[2]= {{1,2},{3,4}}; /* compound */ - hobj_ref_t buf4[2]; /* reference */ - 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,2}; /* float */ + hsize_t dims[1] = {2}; + hsize_t dims1r[1] = {2}; + char buf1[2][3] = {"ab", "de"}; /* string */ + char buf2[2] = {1, 2}; /* bitfield, opaque */ + s_t buf3[2] = {{1, 2}, {3, 4}}; /* compound */ + hobj_ref_t buf4[2]; /* reference */ + 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, 2}; /* float */ /* create 2D attributes with dimension [3][2], 6 elements */ - hsize_t dims2[2]={3,2}; - hsize_t dims2r[2]={1,1}; - char buf12[6][3]= {"ab","cd","ef","gh","ij","kl"}; /* string */ - char buf22[3][2]= {{1,2},{3,4},{5,6}}; /* bitfield, opaque */ - s_t buf32[6]= {{1,2},{3,4},{5,6},{7,8},{9,10},{11,12}}; /* compound */ - hobj_ref_t buf42[1][1]; /* reference */ - hvl_t buf52[3][2]; /* vlen */ - int buf62[6][3]= {{1,2,3},{4,5,6},{7,8,9},{10,11,12},{13,14,15},{16,17,18}}; /* array */ - int buf72[3][2]= {{1,2},{3,4},{5,6}}; /* integer */ - float buf82[3][2]= {{1,2},{3,4},{5,6}}; /* float */ + hsize_t dims2[2] = {3, 2}; + hsize_t dims2r[2] = {1, 1}; + char buf12[6][3] = {"ab", "cd", "ef", "gh", "ij", "kl"}; /* string */ + char buf22[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* bitfield, opaque */ + s_t buf32[6] = {{1, 2}, {3, 4}, {5, 6}, {7, 8}, {9, 10}, {11, 12}}; /* compound */ + hobj_ref_t buf42[1][1]; /* reference */ + hvl_t buf52[3][2]; /* vlen */ + int buf62[6][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}, {13, 14, 15}, {16, 17, 18}}; /* array */ + int buf72[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* integer */ + float buf82[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* float */ /* create 3D attributes with dimension [4][3][2], 24 elements */ - hsize_t dims3[3]={4,3,2}; - hsize_t dims3r[3]={1,1,1}; - char buf13[24][3]= {"ab","cd","ef","gh","ij","kl","mn","pq", - "rs","tu","vw","xz","AB","CD","EF","GH", - "IJ","KL","MN","PQ","RS","TU","VW","XZ"}; /* string */ - char buf23[4][3][2]; /* bitfield, opaque */ - s_t buf33[4][3][2]; /* compound */ - hobj_ref_t buf43[1][1][1]; /* reference */ - hvl_t buf53[4][3][2]; /* vlen */ - int buf63[24][3]; /* array */ - int buf73[4][3][2]; /* integer */ - float buf83[4][3][2]; /* float */ - - - /*------------------------------------------------------------------------- - * 1D - *------------------------------------------------------------------------- - */ + hsize_t dims3[3] = {4, 3, 2}; + hsize_t dims3r[3] = {1, 1, 1}; + char buf13[24][3] = {"ab", "cd", "ef", "gh", "ij", "kl", "mn", "pq", "rs", "tu", "vw", "xz", + "AB", "CD", "EF", "GH", "IJ", "KL", "MN", "PQ", "RS", "TU", "VW", "XZ"}; /* string */ + char buf23[4][3][2]; /* bitfield, opaque */ + s_t buf33[4][3][2]; /* compound */ + hobj_ref_t buf43[1][1][1]; /* reference */ + hvl_t buf53[4][3][2]; /* vlen */ + int buf63[24][3]; /* array */ + int buf73[4][3][2]; /* integer */ + float buf83[4][3][2]; /* float */ + + /*------------------------------------------------------------------------- + * 1D + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ - + * H5T_STRING + *------------------------------------------------------------------------- + */ - if(make_diffs) { - for(i = 0; i < 2; i++) - for(j = 0; j < 2; j++) + if (make_diffs) { + for (i = 0; i < 2; i++) + for (j = 0; j < 2; j++) buf1[i][j] = 'z'; } - if ((tid = H5Tcopy(H5T_C_S1)) < 0) goto out; if (H5Tset_size(tid, (size_t)2) < 0) goto out; - if (write_dset(loc_id,1,dims,"string",tid,buf1) < 0) + if (write_dset(loc_id, 1, dims, "string", tid, buf1) < 0) goto out; if (H5Tclose(tid) < 0) goto out; - /* create hard link */ if (H5Lcreate_hard(loc_id, "string", H5L_SAME_LOC, "string_link", H5P_DEFAULT, H5P_DEFAULT) < 0) goto out; /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ - if(make_diffs) { - for(i = 0; i < 2; i++) + if (make_diffs) { + for (i = 0; i < 2; i++) buf2[i] = buf2[1] = 0; } if ((tid = H5Tcopy(H5T_STD_B8LE)) < 0) goto out; - if (write_dset(loc_id,1,dims,"bitfield",tid,buf2) < 0) + if (write_dset(loc_id, 1, dims, "bitfield", tid, buf2) < 0) goto out; if (H5Tclose(tid) < 0) goto out; /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ - if(make_diffs) { - for(i = 0; i < 2; i++) { + if (make_diffs) { + for (i = 0; i < 2; i++) { buf3[i].a = 0; buf3[i].b = 0; } @@ -3599,45 +3522,43 @@ int write_dset_in(hid_t loc_id, goto out; if (H5Tset_tag(tid, "1-byte opaque type") < 0) goto out; - if (write_dset(loc_id,1,dims,"opaque",tid,buf2) < 0) + if (write_dset(loc_id, 1, dims, "opaque", tid, buf2) < 0) goto out; if (H5Tclose(tid) < 0) goto out; /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ - + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ - if(make_diffs) { - for(i = 0; i < 2; i++) + if (make_diffs) { + for (i = 0; i < 2; i++) buf45[i] = GREEN; } - if ((tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t))) < 0) + if ((tid = H5Tcreate(H5T_COMPOUND, sizeof(s_t))) < 0) goto out; if (H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR) < 0) goto out; if (H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE) < 0) goto out; - if (write_dset(loc_id,1,dims,"compound",tid,buf3) < 0) + if (write_dset(loc_id, 1, dims, "compound", tid, buf3) < 0) goto out; if (H5Tclose(tid) < 0) goto out; /*------------------------------------------------------------------------- - * H5T_REFERENCE - *------------------------------------------------------------------------- - */ + * H5T_REFERENCE + *------------------------------------------------------------------------- + */ /* object references ( H5R_OBJECT ) */ - buf4[0]=0; - buf4[1]=0; - if (dset_name) - { - if (H5Rcreate(&buf4[0],file_id,dset_name,H5R_OBJECT,(hid_t)-1) < 0) + buf4[0] = 0; + buf4[1] = 0; + if (dset_name) { + if (H5Rcreate(&buf4[0], file_id, dset_name, H5R_OBJECT, (hid_t)-1) < 0) goto out; - if (write_dset(loc_id,1,dims1r,"refobj",H5T_STD_REF_OBJ,buf4) < 0) + if (write_dset(loc_id, 1, dims1r, "refobj", H5T_STD_REF_OBJ, buf4) < 0) goto out; } @@ -3645,38 +3566,37 @@ int write_dset_in(hid_t loc_id, if (make_dset_reg_ref(loc_id) < 0) goto out; - /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ + * H5T_ENUM + *------------------------------------------------------------------------- + */ if ((tid = H5Tcreate(H5T_ENUM, sizeof(e_t))) < 0) goto out; - if (H5Tenum_insert(tid, "RED", (val = 0, &val)) < 0) + if (H5Tenum_insert(tid, "RED", (val = 0, &val)) < 0) goto out; if (H5Tenum_insert(tid, "GREEN", (val = 1, &val)) < 0) goto out; - if (write_dset(loc_id,1,dims,"enum",tid,buf45) < 0) + if (write_dset(loc_id, 1, dims, "enum", tid, buf45) < 0) goto out; if (H5Tclose(tid) < 0) goto out; /*------------------------------------------------------------------------- - * 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)); + 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) { + if (make_diffs) { ((int *)buf5[0].p)[0] = 0; ((int *)buf5[1].p)[0] = 0; ((int *)buf5[1].p)[1] = 0; @@ -3700,13 +3620,13 @@ int write_dset_in(hid_t loc_id, goto out; /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ + * H5T_ARRAY + *------------------------------------------------------------------------- + */ - if(make_diffs) { - for(i = 0; i < 2; i++) - for(j = 0; j < 3; j++) + if (make_diffs) { + for (i = 0; i < 2; i++) + for (j = 0; j < 3; j++) buf6[i][j] = 0; } @@ -3719,39 +3639,44 @@ int write_dset_in(hid_t loc_id, { - hsize_t TEST_BUFSIZE = (128 * 1024 * 1024); /* 128MB */ - double *dbuf; /* information to write */ + hsize_t TEST_BUFSIZE = (128 * 1024 * 1024); /* 128MB */ + double * dbuf; /* information to write */ size_t size; hsize_t sdims[] = {1}; hsize_t tdims[] = {TEST_BUFSIZE / sizeof(double) + 1}; unsigned u; /* allocate and initialize array data to write */ - size = ( TEST_BUFSIZE / sizeof(double) + 1 ) * sizeof(double); - dbuf = (double*)HDmalloc( size ); - if (NULL == dbuf) - { - printf ("\nError: Cannot allocate memory for \"arrayd\" data buffer size %dMB.\n", (int) size / 1000000 ); + size = (TEST_BUFSIZE / sizeof(double) + 1) * sizeof(double); + dbuf = (double *)HDmalloc(size); + if (NULL == dbuf) { + HDprintf("\nError: Cannot allocate memory for \"arrayd\" data buffer size %dMB.\n", + (int)size / 1000000); goto out; } - for( u = 0; u < TEST_BUFSIZE / sizeof(double) + 1; u++) + for (u = 0; u < TEST_BUFSIZE / sizeof(double) + 1; u++) dbuf[u] = u; - if (make_diffs) - { + if (make_diffs) { dbuf[5] = 0; dbuf[6] = 0; } /* create a type larger than TEST_BUFSIZE */ - if ((tid = H5Tarray_create2(H5T_NATIVE_DOUBLE, 1, tdims)) < 0) + if ((tid = H5Tarray_create2(H5T_NATIVE_DOUBLE, 1, tdims)) < 0) { + HDfree(dbuf); goto out; + } size = H5Tget_size(tid); - if ((sid = H5Screate_simple(1, sdims, NULL)) < 0) + if ((sid = H5Screate_simple(1, sdims, NULL)) < 0) { + HDfree(dbuf); goto out; - if ((did = H5Dcreate2(loc_id, "arrayd", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + } + if ((did = H5Dcreate2(loc_id, "arrayd", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + HDfree(dbuf); goto out; + } #if defined(WRITE_ARRAY) H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dbuf); #endif @@ -3760,111 +3685,104 @@ int write_dset_in(hid_t loc_id, H5Dclose(did); H5Tclose(tid); H5Sclose(sid); - HDfree( dbuf ); + HDfree(dbuf); } /*------------------------------------------------------------------------- - * H5T_INTEGER and H5T_FLOAT - *------------------------------------------------------------------------- - */ + * H5T_INTEGER and H5T_FLOAT + *------------------------------------------------------------------------- + */ - if(make_diffs) { - for(i = 0; i < 2; i++) { + if (make_diffs) { + for (i = 0; i < 2; i++) { buf7[i] = 0; buf8[i] = 0; } } - if (write_dset(loc_id,1,dims,"integer",H5T_NATIVE_INT,buf7) < 0) + if (write_dset(loc_id, 1, dims, "integer", H5T_NATIVE_INT, buf7) < 0) goto out; - if (write_dset(loc_id,1,dims,"float",H5T_NATIVE_FLOAT,buf8) < 0) + if (write_dset(loc_id, 1, dims, "float", H5T_NATIVE_FLOAT, buf8) < 0) goto out; - /*------------------------------------------------------------------------- - * 2D - *------------------------------------------------------------------------- - */ + * 2D + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ + * H5T_STRING + *------------------------------------------------------------------------- + */ - if (make_diffs) - { + if (make_diffs) { HDmemset(buf12, 'z', sizeof buf12); } - if ((tid = H5Tcopy(H5T_C_S1)) < 0) goto out; if (H5Tset_size(tid, (size_t)2) < 0) goto out; - if (write_dset(loc_id,2,dims2,"string2D",tid,buf12) < 0) + if (write_dset(loc_id, 2, dims2, "string2D", tid, buf12) < 0) goto out; if (H5Tclose(tid) < 0) goto out; /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ - + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ - if (make_diffs) - { - HDmemset(buf22,0,sizeof buf22); + if (make_diffs) { + HDmemset(buf22, 0, sizeof buf22); } if ((tid = H5Tcopy(H5T_STD_B8LE)) < 0) goto out; - if (write_dset(loc_id,2,dims2,"bitfield2D",tid,buf22) < 0) + if (write_dset(loc_id, 2, dims2, "bitfield2D", tid, buf22) < 0) goto out; if (H5Tclose(tid) < 0) goto out; /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ if ((tid = H5Tcreate(H5T_OPAQUE, (size_t)1)) < 0) goto out; if (H5Tset_tag(tid, "1-byte opaque type") < 0) goto out; - if (write_dset(loc_id,2,dims2,"opaque2D",tid,buf22) < 0) + if (write_dset(loc_id, 2, dims2, "opaque2D", tid, buf22) < 0) goto out; if (H5Tclose(tid) < 0) goto out; /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ - if (make_diffs) - { - HDmemset(buf32,0,sizeof buf32); + if (make_diffs) { + HDmemset(buf32, 0, sizeof buf32); } - if ((tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t))) < 0) + if ((tid = H5Tcreate(H5T_COMPOUND, sizeof(s_t))) < 0) goto out; if (H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR) < 0) goto out; if (H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE) < 0) goto out; - if (write_dset(loc_id,2,dims2,"compound2D",tid,buf32) < 0) + if (write_dset(loc_id, 2, dims2, "compound2D", tid, buf32) < 0) goto out; if (H5Tclose(tid) < 0) goto out; /*------------------------------------------------------------------------- - * H5T_REFERENCE - *------------------------------------------------------------------------- - */ + * H5T_REFERENCE + *------------------------------------------------------------------------- + */ /* Create references to dataset */ - if (dset_name) - { + if (dset_name) { if (H5Rcreate(&buf42[0][0], file_id, dset_name, H5R_OBJECT, (hid_t)-1) < 0) goto out; if (write_dset(loc_id, 2, dims2r, "refobj2D", H5T_STD_REF_OBJ, buf42) < 0) @@ -3872,36 +3790,36 @@ int write_dset_in(hid_t loc_id, } /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ + * H5T_ENUM + *------------------------------------------------------------------------- + */ if ((tid = H5Tcreate(H5T_ENUM, sizeof(e_t))) < 0) goto out; - if (H5Tenum_insert(tid, "RED", (val = 0, &val)) < 0) + if (H5Tenum_insert(tid, "RED", (val = 0, &val)) < 0) goto out; if (H5Tenum_insert(tid, "GREEN", (val = 1, &val)) < 0) goto out; - if (write_dset(loc_id,2,dims2,"enum2D",tid,0) < 0) + if (write_dset(loc_id, 2, dims2, "enum2D", tid, 0) < 0) goto out; if (H5Tclose(tid) < 0) goto out; /*------------------------------------------------------------------------- - * 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++) { + for (i = 0; i < 3; i++) { + for (j = 0; j < 2; j++) { unsigned l; - buf52[i][j].p = HDmalloc((i + 1) * sizeof(int)); + buf52[i][j].p = HDmalloc((i + 1) * sizeof(int)); buf52[i][j].len = (size_t)(i + 1); - for(l = 0; l < i + 1; l++) { - if(make_diffs) + for (l = 0; l < i + 1; l++) { + if (make_diffs) ((int *)buf52[i][j].p)[l] = 0; else ((int *)buf52[i][j].p)[l] = n++; @@ -3927,16 +3845,14 @@ int write_dset_in(hid_t loc_id, goto out; /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ + * H5T_ARRAY + *------------------------------------------------------------------------- + */ - if (make_diffs) - { - HDmemset(buf62,0,sizeof buf62); + if (make_diffs) { + HDmemset(buf62, 0, sizeof buf62); } - if ((tid = H5Tarray_create2(H5T_NATIVE_INT, 1, dimarray)) < 0) goto out; if (write_dset(loc_id, 2, dims2, "array2D", tid, buf62) < 0) @@ -3945,17 +3861,15 @@ int write_dset_in(hid_t loc_id, goto out; /*------------------------------------------------------------------------- - * H5T_INTEGER, write a fill value - *------------------------------------------------------------------------- - */ - + * H5T_INTEGER, write a fill value + *------------------------------------------------------------------------- + */ - if(make_diffs) { + if (make_diffs) { HDmemset(buf72, 0, sizeof buf72); HDmemset(buf82, 0, sizeof buf82); } - if ((pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto out; if ((sid = H5Screate_simple(2, dims2, NULL)) < 0) @@ -3972,49 +3886,46 @@ int write_dset_in(hid_t loc_id, goto out; /*------------------------------------------------------------------------- - * H5T_FLOAT - *------------------------------------------------------------------------- - */ + * H5T_FLOAT + *------------------------------------------------------------------------- + */ - if (write_dset(loc_id,2,dims2,"float2D",H5T_NATIVE_FLOAT,buf82) < 0) + if (write_dset(loc_id, 2, dims2, "float2D", H5T_NATIVE_FLOAT, buf82) < 0) goto out; - /*------------------------------------------------------------------------- - * 3D - *------------------------------------------------------------------------- - */ + * 3D + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ + * H5T_STRING + *------------------------------------------------------------------------- + */ - if (make_diffs) - { - HDmemset(buf13,'z',sizeof buf13); + if (make_diffs) { + HDmemset(buf13, 'z', sizeof buf13); } if ((tid = H5Tcopy(H5T_C_S1)) < 0) goto out; if (H5Tset_size(tid, (size_t)2) < 0) goto out; - if (write_dset(loc_id,3,dims3,"string3D",tid,buf13) < 0) + if (write_dset(loc_id, 3, dims3, "string3D", tid, buf13) < 0) goto out; if (H5Tclose(tid) < 0) goto out; /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ - + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ - n=1; - for(i = 0; i < 4; i++) { - for(j = 0; j < 3; j++) { - for(k = 0; k < 2; k++) { - if(make_diffs) + n = 1; + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) { + if (make_diffs) buf23[i][j][k] = 0; else buf23[i][j][k] = (char)(n++); @@ -4022,37 +3933,36 @@ int write_dset_in(hid_t loc_id, } } - if ((tid = H5Tcopy(H5T_STD_B8LE)) < 0) goto out; - if (write_dset(loc_id,3,dims3,"bitfield3D",tid,buf23) < 0) + if (write_dset(loc_id, 3, dims3, "bitfield3D", tid, buf23) < 0) goto out; if (H5Tclose(tid) < 0) goto out; /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ if ((tid = H5Tcreate(H5T_OPAQUE, (size_t)1)) < 0) goto out; if (H5Tset_tag(tid, "1-byte opaque type") < 0) goto out; - if (write_dset(loc_id,3,dims3,"opaque3D",tid,buf23) < 0) + if (write_dset(loc_id, 3, dims3, "opaque3D", tid, buf23) < 0) goto out; if (H5Tclose(tid) < 0) goto out; /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ - n=1; - for(i = 0; i < 4; i++) { - for(j = 0; j < 3; j++) { - for(k = 0; k < 2; k++) { - if(make_diffs) { + n = 1; + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) { + if (make_diffs) { buf33[i][j][k].a = 0; buf33[i][j][k].b = 0; } @@ -4064,25 +3974,23 @@ int write_dset_in(hid_t loc_id, } } - - if ((tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t))) < 0) + if ((tid = H5Tcreate(H5T_COMPOUND, sizeof(s_t))) < 0) goto out; if (H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR) < 0) goto out; if (H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE) < 0) goto out; - if (write_dset(loc_id,3,dims3,"compound3D",tid,buf33) < 0) + if (write_dset(loc_id, 3, dims3, "compound3D", tid, buf33) < 0) goto out; if (H5Tclose(tid) < 0) goto out; /*------------------------------------------------------------------------- - * H5T_REFERENCE - *------------------------------------------------------------------------- - */ + * H5T_REFERENCE + *------------------------------------------------------------------------- + */ /* Create references to dataset */ - if (dset_name) - { + if (dset_name) { if (H5Rcreate(&buf43[0][0][0], file_id, dset_name, H5R_OBJECT, (hid_t)-1) < 0) goto out; if (write_dset(loc_id, 3, dims3r, "refobj3D", H5T_STD_REF_OBJ, buf43) < 0) @@ -4090,37 +3998,37 @@ int write_dset_in(hid_t loc_id, } /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ + * H5T_ENUM + *------------------------------------------------------------------------- + */ if ((tid = H5Tcreate(H5T_ENUM, sizeof(e_t))) < 0) goto out; - if (H5Tenum_insert(tid, "RED", (val = 0, &val)) < 0) + if (H5Tenum_insert(tid, "RED", (val = 0, &val)) < 0) goto out; if (H5Tenum_insert(tid, "GREEN", (val = 1, &val)) < 0) goto out; - if (write_dset(loc_id,3,dims3,"enum3D",tid,0) < 0) + if (write_dset(loc_id, 3, dims3, "enum3D", tid, 0) < 0) goto out; if (H5Tclose(tid) < 0) goto out; /*------------------------------------------------------------------------- - * 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++) { + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) { unsigned l; - buf53[i][j][k].p = HDmalloc((i + 1) * sizeof(int)); + buf53[i][j][k].p = HDmalloc((i + 1) * sizeof(int)); buf53[i][j][k].len = (size_t)(i + 1); - for(l = 0; l < i + 1; l++) { - if(make_diffs) + for (l = 0; l < i + 1; l++) { + if (make_diffs) ((int *)buf53[i][j][k].p)[l] = 0; else ((int *)buf53[i][j][k].p)[l] = n++; @@ -4149,15 +4057,14 @@ int write_dset_in(hid_t loc_id, goto out; /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ - + * H5T_ARRAY + *------------------------------------------------------------------------- + */ n = 1; - for(i = 0; i < 24; i++) { - for(j = 0; j < dimarray[0]; j++) { - if(make_diffs) + for (i = 0; i < 24; i++) { + for (j = 0; j < dimarray[0]; j++) { + if (make_diffs) buf63[i][j] = 0; else buf63[i][j] = n++; @@ -4172,76 +4079,77 @@ int write_dset_in(hid_t loc_id, goto out; /*------------------------------------------------------------------------- - * H5T_INTEGER and H5T_FLOAT - *------------------------------------------------------------------------- - */ - n=1; f=1; + * H5T_INTEGER and H5T_FLOAT + *------------------------------------------------------------------------- + */ + n = 1; + f = 1; for (i = 0; i < 4; i++) { for (j = 0; j < 3; j++) { for (k = 0; k < 2; k++) { if (make_diffs) { - buf73[i][j][k]=0; - buf83[i][j][k]=0; + buf73[i][j][k] = 0; + buf83[i][j][k] = 0; } else { - buf73[i][j][k]=n++; - buf83[i][j][k]=f++; + buf73[i][j][k] = n++; + buf83[i][j][k] = f++; } } } } - if (write_dset(loc_id,3,dims3,"integer3D",H5T_NATIVE_INT,buf73) < 0) + if (write_dset(loc_id, 3, dims3, "integer3D", H5T_NATIVE_INT, buf73) < 0) goto out; - if (write_dset(loc_id,3,dims3,"float3D",H5T_NATIVE_FLOAT,buf83) < 0) + if (write_dset(loc_id, 3, dims3, "float3D", H5T_NATIVE_FLOAT, buf83) < 0) goto out; return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(pid); H5Sclose(sid); H5Dclose(did); H5Tclose(tid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - - /*------------------------------------------------------------------------- -* Function: make_dset_reg_ref -* -* Purpose: write dataset region references -* -*------------------------------------------------------------------------- -*/ + * Function: make_dset_reg_ref + * + * Purpose: write dataset region references + * + *------------------------------------------------------------------------- + */ #define SPACE1_RANK 1 #define SPACE1_DIM1 1 #define SPACE2_RANK 2 #define SPACE2_DIM1 10 #define SPACE2_DIM2 10 -static -int make_dset_reg_ref(hid_t loc_id) +static int +make_dset_reg_ref(hid_t loc_id) { - hid_t did1=-1; /* Dataset ID */ - hid_t did2=-1; /* Dereferenced dataset ID */ - hid_t sid1=-1; /* Dataspace ID #1 */ - hid_t sid2=-1; /* Dataspace ID #2 */ - hsize_t dims1[] = {SPACE1_DIM1}; - hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; - hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ - hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */ - hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ - hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ - hdset_reg_ref_t *wbuf=NULL; /* buffer to write to disk */ - int *dwbuf=NULL; /* Buffer for writing numeric data to disk */ - int i; /* counting variables */ - int retval = -1; /* return value */ + hid_t did1 = H5I_INVALID_HID; /* Dataset ID */ + hid_t did2 = H5I_INVALID_HID; /* Dereferenced dataset ID */ + hid_t sid1 = H5I_INVALID_HID; /* Dataspace ID #1 */ + hid_t sid2 = H5I_INVALID_HID; /* Dataspace ID #2 */ + hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; + hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ + hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */ + hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ + hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ + hdset_reg_ref_t *wbuf = NULL; /* buffer to write to disk */ + int * dwbuf = NULL; /* Buffer for writing numeric data to disk */ + int i; /* counting variables */ + int retval = -1; /* return value */ /* Allocate write & read buffers */ - wbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)SPACE1_DIM1); + wbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)SPACE1_DIM1); dwbuf = (int *)HDmalloc(sizeof(int) * SPACE2_DIM1 * SPACE2_DIM2); /* Create dataspace for datasets */ @@ -4249,7 +4157,8 @@ int make_dset_reg_ref(hid_t loc_id) goto out; /* Create a dataset */ - if ((did2 = H5Dcreate2(loc_id, "dsetreg", H5T_NATIVE_UCHAR, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did2 = H5Dcreate2(loc_id, "dsetreg", H5T_NATIVE_UCHAR, sid2, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) goto out; for (i = 0; i < SPACE2_DIM1 * SPACE2_DIM2; i++) @@ -4264,24 +4173,28 @@ int make_dset_reg_ref(hid_t loc_id) goto out; /* Create a dataset */ - if ((did1 = H5Dcreate2(loc_id, "refreg", H5T_STD_REF_DSETREG, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did1 = H5Dcreate2(loc_id, "refreg", H5T_STD_REF_DSETREG, sid1, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) goto out; /* Select 6x6 hyperslab for first reference */ - start[0] = 2; start[1] = 2; - stride[0] = 1; stride[1] = 1; - count[0] = 6; count[1] = 6; - block[0] = 1; block[1] = 1; + start[0] = 2; + start[1] = 2; + stride[0] = 1; + stride[1] = 1; + count[0] = 6; + count[1] = 6; + block[0] = 1; + block[1] = 1; if (H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block) < 0) goto out; - /* Store dataset region */ if (H5Rcreate(&wbuf[0], loc_id, "dsetreg", H5R_DATASET_REGION, sid2) < 0) goto out; /* Write selection to disk */ - if (H5Dwrite(did1,H5T_STD_REF_DSETREG,H5S_ALL,H5S_ALL,H5P_DEFAULT,wbuf) < 0) + if (H5Dwrite(did1, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) goto out; /* Close all objects */ @@ -4297,9 +4210,9 @@ int make_dset_reg_ref(hid_t loc_id) retval = 0; out: - if(wbuf) + if (wbuf) HDfree(wbuf); - if(dwbuf) + if (dwbuf) HDfree(dwbuf); H5E_BEGIN_TRY @@ -4308,105 +4221,96 @@ out: H5Sclose(sid2); H5Dclose(did1); H5Dclose(did2); - } H5E_END_TRY; + } + H5E_END_TRY; return retval; } /*------------------------------------------------------------------------- -* Function: write_attr_in -* -* Purpose: write attributes in LOC_ID (dataset, group, named datatype) -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: November 12, 2003 -* -*------------------------------------------------------------------------- -*/ - -static -int write_attr_in(hid_t loc_id, - const char* dset_name, /* for saving reference to dataset*/ - hid_t fid, /* for reference create */ - int make_diffs /* flag to modify data buffers */) + * Function: write_attr_in + * + * Purpose: write attributes in LOC_ID (dataset, group, named datatype) + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: November 12, 2003 + * + *------------------------------------------------------------------------- + */ + +static int +write_attr_in(hid_t loc_id, const char *dset_name, /* for saving reference to dataset*/ + hid_t fid, /* for reference create */ + int make_diffs /* flag to modify data buffers */) { /* Compound datatype */ - typedef struct s_t - { + typedef struct s_t { char a; double b; } s_t; - typedef enum - { - RED, - GREEN - } e_t; - - hid_t aid = -1; - hid_t sid = -1; - hid_t tid = -1; - int val, j, k, n; + typedef enum { RED, GREEN } e_t; + + hid_t aid = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + int val, j, k, n; unsigned i; - float f; + float f; /* create 1D attributes with dimension [2], 2 elements */ - hsize_t dims[1]={2}; - char buf1[2][3]= {"ab","de"}; /* string */ - char buf2[2]= {1,2}; /* bitfield, opaque */ - s_t buf3[2]= {{1,2},{3,4}}; /* compound */ - hobj_ref_t buf4[2]; /* reference */ - 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,2}; /* float */ + hsize_t dims[1] = {2}; + char buf1[2][3] = {"ab", "de"}; /* string */ + char buf2[2] = {1, 2}; /* bitfield, opaque */ + s_t buf3[2] = {{1, 2}, {3, 4}}; /* compound */ + hobj_ref_t buf4[2]; /* reference */ + 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, 2}; /* float */ /* create 2D attributes with dimension [3][2], 6 elements */ - hsize_t dims2[2]={3,2}; - char buf12[6][3]= {"ab","cd","ef","gh","ij","kl"}; /* string */ - char buf22[3][2]= {{1,2},{3,4},{5,6}}; /* bitfield, opaque */ - s_t buf32[6]= {{1,2},{3,4},{5,6},{7,8},{9,10},{11,12}}; /* compound */ - hobj_ref_t buf42[3][2]; /* reference */ - 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,2},{3,4},{5,6}}; /* float */ + hsize_t dims2[2] = {3, 2}; + char buf12[6][3] = {"ab", "cd", "ef", "gh", "ij", "kl"}; /* string */ + char buf22[3][2] = {{1, 2}, {3, 4}, {5, 6}}; /* bitfield, opaque */ + s_t buf32[6] = {{1, 2}, {3, 4}, {5, 6}, {7, 8}, {9, 10}, {11, 12}}; /* compound */ + hobj_ref_t buf42[3][2]; /* reference */ + 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, 2}, {3, 4}, {5, 6}}; /* float */ /* create 3D attributes with dimension [4][3][2], 24 elements */ - hsize_t dims3[3]={4,3,2}; - char buf13[24][3]= {"ab","cd","ef","gh","ij","kl","mn","pq", - "rs","tu","vw","xz","AB","CD","EF","GH", - "IJ","KL","MN","PQ","RS","TU","VW","XZ"}; /* string */ - char buf23[4][3][2]; /* bitfield, opaque */ - s_t buf33[4][3][2]; /* compound */ - hobj_ref_t buf43[4][3][2]; /* reference */ - 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[24][3] = {"ab", "cd", "ef", "gh", "ij", "kl", "mn", "pq", "rs", "tu", "vw", "xz", + "AB", "CD", "EF", "GH", "IJ", "KL", "MN", "PQ", "RS", "TU", "VW", "XZ"}; /* string */ + char buf23[4][3][2]; /* bitfield, opaque */ + s_t buf33[4][3][2]; /* compound */ + hobj_ref_t buf43[4][3][2]; /* reference */ + 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++) - for (j=0; j<2; j++) - { - buf1[i][j]='z'; + if (make_diffs) { + for (i = 0; i < 2; i++) + for (j = 0; j < 2; j++) { + buf1[i][j] = 'z'; } } /* @@ -4425,21 +4329,20 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Tset_size(tid, (size_t)2) < 0) goto out; - if (make_attr(loc_id,1,dims,"string",tid,buf1) < 0) + if (make_attr(loc_id, 1, dims, "string", tid, buf1) < 0) goto out; if (H5Tclose(tid) < 0) goto out; - tid = -1; + tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ - if (make_diffs) - { - for (i=0; i<2; i++) - buf2[i]=buf2[1]=0; + if (make_diffs) { + for (i = 0; i < 2; i++) + buf2[i] = buf2[1] = 0; } /* buf2[2]= {1,2}; @@ -4455,16 +4358,16 @@ int write_attr_in(hid_t loc_id, if ((tid = H5Tcopy(H5T_STD_B8LE)) < 0) goto out; - if (make_attr(loc_id,1,dims,"bitfield",tid,buf2) < 0) + if (make_attr(loc_id, 1, dims, "bitfield", tid, buf2) < 0) goto out; if (H5Tclose(tid) < 0) goto out; - tid = -1; + tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ /* buf2[2]= {1,2}; @@ -4482,22 +4385,21 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Tset_tag(tid, "1-byte opaque type") < 0) goto out; - if (make_attr(loc_id,1,dims,"opaque",tid,buf2) < 0) + if (make_attr(loc_id, 1, dims, "opaque", tid, buf2) < 0) goto out; if (H5Tclose(tid) < 0) goto out; - tid = -1; + tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ - if (make_diffs) - { - for (i=0; i<2; i++) - { - buf3[i].a=0; buf3[i].b=0; + if (make_diffs) { + for (i = 0; i < 2; i++) { + buf3[i].a = 0; + buf3[i].b = 0; } } @@ -4514,43 +4416,39 @@ int write_attr_in(hid_t loc_id, [ 1 ] 4 5 1 */ - if ((tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t))) < 0) + if ((tid = H5Tcreate(H5T_COMPOUND, sizeof(s_t))) < 0) goto out; if (H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR) < 0) goto out; if (H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE) < 0) goto out; - if (make_attr(loc_id,1,dims,"compound",tid,buf3) < 0) + if (make_attr(loc_id, 1, dims, "compound", tid, buf3) < 0) goto out; if (H5Tclose(tid) < 0) goto out; - tid = -1; + tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_REFERENCE - *------------------------------------------------------------------------- - */ + * H5T_REFERENCE + *------------------------------------------------------------------------- + */ /* object references ( H5R_OBJECT */ - if (dset_name) - { - if (H5Rcreate(&buf4[0],fid,dset_name,H5R_OBJECT,(hid_t)-1) < 0) + if (dset_name) { + if (H5Rcreate(&buf4[0], fid, dset_name, H5R_OBJECT, (hid_t)-1) < 0) goto out; - if (H5Rcreate(&buf4[1],fid,dset_name,H5R_OBJECT,(hid_t)-1) < 0) + if (H5Rcreate(&buf4[1], fid, dset_name, H5R_OBJECT, (hid_t)-1) < 0) goto out; - if (make_attr(loc_id,1,dims,"reference",H5T_STD_REF_OBJ,buf4) < 0) + if (make_attr(loc_id, 1, dims, "reference", H5T_STD_REF_OBJ, buf4) < 0) goto out; } - /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ - if (make_diffs) - { - for (i=0; i<2; i++) - { - buf45[i]=GREEN; + * H5T_ENUM + *------------------------------------------------------------------------- + */ + if (make_diffs) { + for (i = 0; i < 2; i++) { + buf45[i] = GREEN; } } /* @@ -4565,33 +4463,32 @@ int write_attr_in(hid_t loc_id, */ if ((tid = H5Tcreate(H5T_ENUM, sizeof(e_t))) < 0) goto out; - if (H5Tenum_insert(tid, "RED", (val = 0, &val)) < 0) + if (H5Tenum_insert(tid, "RED", (val = 0, &val)) < 0) goto out; if (H5Tenum_insert(tid, "GREEN", (val = 1, &val)) < 0) goto out; - if (make_attr(loc_id,1,dims,"enum",tid,buf45) < 0) + if (make_attr(loc_id, 1, dims, "enum", tid, buf45) < 0) goto out; if (H5Tclose(tid) < 0) goto out; - tid = -1; + tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * 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)); + 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) - { + if (make_diffs) { ((int *)buf5[0].p)[0] = 0; ((int *)buf5[1].p)[0] = 0; ((int *)buf5[1].p)[1] = 0; @@ -4618,25 +4515,23 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Aclose(aid) < 0) goto out; - aid = -1; + aid = H5I_INVALID_HID; if (H5Tclose(tid) < 0) goto out; - tid = -1; + tid = H5I_INVALID_HID; if (H5Sclose(sid) < 0) goto out; - sid = -1; + sid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ + * H5T_ARRAY + *------------------------------------------------------------------------- + */ - if (make_diffs) - { - for (i=0; i<2; i++) - for (j=0; j<3; j++) - { - buf6[i][j]=0; + if (make_diffs) { + for (i = 0; i < 2; i++) + for (j = 0; j < 3; j++) { + buf6[i][j] = 0; } } /* @@ -4659,19 +4554,17 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Tclose(tid) < 0) goto out; - tid = -1; + tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_INTEGER and H5T_FLOAT - *------------------------------------------------------------------------- - */ + * H5T_INTEGER and H5T_FLOAT + *------------------------------------------------------------------------- + */ - if(make_diffs) - { - for(i = 0; i < 2; i++) - { - buf7[i]=0; - buf8[i]=0; + if (make_diffs) { + for (i = 0; i < 2; i++) { + buf7[i] = 0; + buf8[i] = 0; } } @@ -4689,23 +4582,21 @@ int write_attr_in(hid_t loc_id, [ 0 ] 1 0 1 [ 1 ] 2 0 2 */ - if (make_attr(loc_id,1,dims,"integer",H5T_NATIVE_INT,buf7) < 0) + if (make_attr(loc_id, 1, dims, "integer", H5T_NATIVE_INT, buf7) < 0) goto out; - if (make_attr(loc_id,1,dims,"float",H5T_NATIVE_FLOAT,buf8) < 0) + if (make_attr(loc_id, 1, dims, "float", H5T_NATIVE_FLOAT, buf8) < 0) goto out; - /*------------------------------------------------------------------------- - * 2D attributes - *------------------------------------------------------------------------- - */ + * 2D attributes + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ - if (make_diffs) - { + * H5T_STRING + *------------------------------------------------------------------------- + */ + if (make_diffs) { HDmemset(buf12, 'z', sizeof buf12); } @@ -4733,20 +4624,19 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Tset_size(tid, (size_t)2) < 0) goto out; - if (make_attr(loc_id,2,dims2,"string2D",tid,buf12) < 0) + if (make_attr(loc_id, 2, dims2, "string2D", tid, buf12) < 0) goto out; if (H5Tclose(tid) < 0) goto out; - tid = -1; + tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ - if (make_diffs) - { - HDmemset(buf22,0,sizeof buf22); + if (make_diffs) { + HDmemset(buf22, 0, sizeof buf22); } /* @@ -4763,19 +4653,18 @@ int write_attr_in(hid_t loc_id, [ 2 1 ] 6 0 6 */ - if ((tid = H5Tcopy(H5T_STD_B8LE)) < 0) goto out; - if (make_attr(loc_id,2,dims2,"bitfield2D",tid,buf22) < 0) + if (make_attr(loc_id, 2, dims2, "bitfield2D", tid, buf22) < 0) goto out; if (H5Tclose(tid) < 0) goto out; - tid = -1; + tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ /* buf22[3][2]= {{1,2},{3,4},{5,6}}; @@ -4794,19 +4683,18 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Tset_tag(tid, "1-byte opaque type") < 0) goto out; - if (make_attr(loc_id,2,dims2,"opaque2D",tid,buf22) < 0) + if (make_attr(loc_id, 2, dims2, "opaque2D", tid, buf22) < 0) goto out; if (H5Tclose(tid) < 0) goto out; - tid = -1; + tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ - if (make_diffs) - { - HDmemset(buf32,0,sizeof buf32); + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ + if (make_diffs) { + HDmemset(buf32, 0, sizeof buf32); } /* @@ -4823,47 +4711,44 @@ int write_attr_in(hid_t loc_id, [ 2 1 ] 6 0 6 */ - - if ((tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t))) < 0) + if ((tid = H5Tcreate(H5T_COMPOUND, sizeof(s_t))) < 0) goto out; if (H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR) < 0) goto out; if (H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE) < 0) goto out; - if (make_attr(loc_id,2,dims2,"compound2D",tid,buf32) < 0) + if (make_attr(loc_id, 2, dims2, "compound2D", tid, buf32) < 0) goto out; if (H5Tclose(tid) < 0) goto out; - tid = -1; + tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_REFERENCE - *------------------------------------------------------------------------- - */ + * H5T_REFERENCE + *------------------------------------------------------------------------- + */ /* Create references to dataset */ - if (dset_name) - { - for (i = 0; i < 3; i++) - { - for (j = 0; j < 2; j++) - { - if (H5Rcreate(&buf42[i][j],fid,dset_name,H5R_OBJECT,(hid_t)-1) < 0) + if (dset_name) { + for (i = 0; i < 3; i++) { + for (j = 0; j < 2; j++) { + if (H5Rcreate(&buf42[i][j], fid, dset_name, H5R_OBJECT, (hid_t)-1) < 0) goto out; } } - if (make_attr(loc_id,2,dims2,"reference2D",H5T_STD_REF_OBJ,buf42) < 0) + if (make_attr(loc_id, 2, dims2, "reference2D", H5T_STD_REF_OBJ, buf42) < 0) goto out; } /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ - for (i=0; i<3; i++) - { - for (j=0; j<2; j++) - { - if (make_diffs) buf452[i][j]=GREEN; else buf452[i][j]=RED; + * H5T_ENUM + *------------------------------------------------------------------------- + */ + for (i = 0; i < 3; i++) { + for (j = 0; j < 2; j++) { + if (make_diffs) + buf452[i][j] = GREEN; + else + buf452[i][j] = RED; } } @@ -4881,31 +4766,31 @@ int write_attr_in(hid_t loc_id, if ((tid = H5Tcreate(H5T_ENUM, sizeof(e_t))) < 0) goto out; - if (H5Tenum_insert(tid, "RED", (val = 0, &val)) < 0) + if (H5Tenum_insert(tid, "RED", (val = 0, &val)) < 0) goto out; if (H5Tenum_insert(tid, "GREEN", (val = 1, &val)) < 0) goto out; - if (make_attr(loc_id,2,dims2,"enum2D",tid,buf452) < 0) + if (make_attr(loc_id, 2, dims2, "enum2D", tid, buf452) < 0) goto out; if (H5Tclose(tid) < 0) goto out; - tid = -1; + tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * 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++) { + n = 0; + for (i = 0; i < 3; i++) { + for (j = 0; j < 2; j++) { unsigned l; - buf52[i][j].p = HDmalloc((i + 1) * sizeof(int)); + buf52[i][j].p = HDmalloc((i + 1) * sizeof(int)); buf52[i][j].len = (size_t)(i + 1); - for(l = 0; l < i + 1; l++) - if(make_diffs) + for (l = 0; l < i + 1; l++) + if (make_diffs) ((int *)buf52[i][j].p)[l] = 0; else ((int *)buf52[i][j].p)[l] = n++; @@ -4940,22 +4825,21 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Aclose(aid) < 0) goto out; - aid = -1; + aid = H5I_INVALID_HID; if (H5Tclose(tid) < 0) goto out; - tid = -1; + tid = H5I_INVALID_HID; if (H5Sclose(sid) < 0) goto out; - sid = -1; + sid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ + * H5T_ARRAY + *------------------------------------------------------------------------- + */ - if (make_diffs) - { - HDmemset(buf62,0,sizeof buf62); + if (make_diffs) { + HDmemset(buf62, 0, sizeof buf62); } /* buf62[6][3]= {{1,2,3},{4,5,6},{7,8,9},{10,11,12},{13,14,15},{16,17,18}}; @@ -4989,15 +4873,14 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Tclose(tid) < 0) goto out; - tid = -1; + tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_INTEGER and H5T_FLOAT - *------------------------------------------------------------------------- - */ + * H5T_INTEGER and H5T_FLOAT + *------------------------------------------------------------------------- + */ - if(make_diffs) - { + if (make_diffs) { HDmemset(buf72, 0, sizeof buf72); HDmemset(buf82, 0, sizeof buf82); } @@ -5023,25 +4906,23 @@ int write_attr_in(hid_t loc_id, [ 2 1 ] 6 0 6 */ - if (make_attr(loc_id,2,dims2,"integer2D",H5T_NATIVE_INT,buf72) < 0) + if (make_attr(loc_id, 2, dims2, "integer2D", H5T_NATIVE_INT, buf72) < 0) goto out; - if (make_attr(loc_id,2,dims2,"float2D",H5T_NATIVE_FLOAT,buf82) < 0) + if (make_attr(loc_id, 2, dims2, "float2D", H5T_NATIVE_FLOAT, buf82) < 0) goto out; - /*------------------------------------------------------------------------- - * 3D attributes - *------------------------------------------------------------------------- - */ + * 3D attributes + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- - * H5T_STRING - *------------------------------------------------------------------------- - */ + * H5T_STRING + *------------------------------------------------------------------------- + */ - if (make_diffs) - { - HDmemset(buf13,'z',sizeof buf13); + if (make_diffs) { + HDmemset(buf13, 'z', sizeof buf13); } /* @@ -5105,22 +4986,22 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Tset_size(tid, (size_t)2) < 0) goto out; - if (make_attr(loc_id,3,dims3,"string3D",tid,buf13) < 0) + if (make_attr(loc_id, 3, dims3, "string3D", tid, buf13) < 0) goto out; if (H5Tclose(tid) < 0) goto out; - tid = -1; + tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_BITFIELD - *------------------------------------------------------------------------- - */ + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ - n=1; - for(i = 0; i < 4; i++) { - for(j = 0; j < 3; j++) { - for(k = 0; k < 2; k++) { - if(make_diffs) + n = 1; + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) { + if (make_diffs) buf23[i][j][k] = 0; else buf23[i][j][k] = (char)(n++); @@ -5159,36 +5040,36 @@ int write_attr_in(hid_t loc_id, if ((tid = H5Tcopy(H5T_STD_B8LE)) < 0) goto out; - if (make_attr(loc_id,3,dims3,"bitfield3D",tid,buf23) < 0) + if (make_attr(loc_id, 3, dims3, "bitfield3D", tid, buf23) < 0) goto out; if (H5Tclose(tid) < 0) goto out; - tid = -1; + tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_OPAQUE - *------------------------------------------------------------------------- - */ + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ if ((tid = H5Tcreate(H5T_OPAQUE, (size_t)1)) < 0) goto out; if (H5Tset_tag(tid, "1-byte opaque type") < 0) goto out; - if (make_attr(loc_id,3,dims3,"opaque3D",tid,buf23) < 0) + if (make_attr(loc_id, 3, dims3, "opaque3D", tid, buf23) < 0) goto out; if (H5Tclose(tid) < 0) goto out; - tid = -1; + tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_COMPOUND - *------------------------------------------------------------------------- - */ + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ - n=1; - for(i = 0; i < 4; i++) { - for(j = 0; j < 3; j++) { - for(k = 0; k < 2; k++) { - if(make_diffs) { + n = 1; + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) { + if (make_diffs) { buf33[i][j][k].a = 0; buf33[i][j][k].b = 0; } @@ -5251,58 +5132,48 @@ int write_attr_in(hid_t loc_id, [ 3 2 1 ] 48 0 48 */ - - - if ((tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t))) < 0) + if ((tid = H5Tcreate(H5T_COMPOUND, sizeof(s_t))) < 0) goto out; if (H5Tinsert(tid, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR) < 0) goto out; if (H5Tinsert(tid, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE) < 0) goto out; - if (make_attr(loc_id,3,dims3,"compound3D",tid,buf33) < 0) + if (make_attr(loc_id, 3, dims3, "compound3D", tid, buf33) < 0) goto out; if (H5Tclose(tid) < 0) goto out; - tid = -1; + tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_REFERENCE - *------------------------------------------------------------------------- - */ + * H5T_REFERENCE + *------------------------------------------------------------------------- + */ /* Create references to dataset */ - if (dset_name) - { - for (i = 0; i < 4; i++) - { - for (j = 0; j < 3; j++) - { + if (dset_name) { + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { for (k = 0; k < 2; k++) - if (H5Rcreate(&buf43[i][j][k],fid,dset_name,H5R_OBJECT,(hid_t)-1) < 0) + if (H5Rcreate(&buf43[i][j][k], fid, dset_name, H5R_OBJECT, (hid_t)-1) < 0) goto out; } } - if (make_attr(loc_id,3,dims3,"reference3D",H5T_STD_REF_OBJ,buf43) < 0) + if (make_attr(loc_id, 3, dims3, "reference3D", H5T_STD_REF_OBJ, buf43) < 0) goto out; } /*------------------------------------------------------------------------- - * H5T_ENUM - *------------------------------------------------------------------------- - */ + * H5T_ENUM + *------------------------------------------------------------------------- + */ - for (i = 0; i < 4; i++) - { - for (j = 0; j < 3; j++) - { - for (k = 0; k < 2; k++) - { - if (make_diffs) - { - buf453[i][j][k]=RED; + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) { + if (make_diffs) { + buf453[i][j][k] = RED; } - else - { - buf453[i][j][k]=GREEN; + else { + buf453[i][j][k] = GREEN; } } } @@ -5337,35 +5208,31 @@ int write_attr_in(hid_t loc_id, [ 3 2 1 ] GREEN RED */ - if ((tid = H5Tcreate(H5T_ENUM, sizeof(e_t))) < 0) goto out; - if (H5Tenum_insert(tid, "RED", (val = 0, &val)) < 0) + if (H5Tenum_insert(tid, "RED", (val = 0, &val)) < 0) goto out; if (H5Tenum_insert(tid, "GREEN", (val = 1, &val)) < 0) goto out; - if (make_attr(loc_id,3,dims3,"enum3D",tid,buf453) < 0) + if (make_attr(loc_id, 3, dims3, "enum3D", tid, buf453) < 0) goto out; if (H5Tclose(tid) < 0) goto out; - tid = -1; + tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * 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++) - { + n = 0; + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) { unsigned l; - buf53[i][j][k].p = HDmalloc((i + 1) * sizeof(int)); + buf53[i][j][k].p = HDmalloc((i + 1) * sizeof(int)); buf53[i][j][k].len = (size_t)i + 1; for (l = 0; l < i + 1; l++) if (make_diffs) @@ -5402,25 +5269,25 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Aclose(aid) < 0) goto out; - aid = -1; + aid = H5I_INVALID_HID; if (H5Tclose(tid) < 0) goto out; - tid = -1; + tid = H5I_INVALID_HID; if (H5Sclose(sid) < 0) goto out; - sid = -1; + sid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_ARRAY - *------------------------------------------------------------------------- - */ - n=1; - for (i = 0; i < 24; i++) - { - for (j = 0; j < (int)dimarray[0]; j++) - { - if (make_diffs) buf63[i][j]=0; - else buf63[i][j]=n++; + * H5T_ARRAY + *------------------------------------------------------------------------- + */ + n = 1; + for (i = 0; i < 24; i++) { + for (j = 0; j < (int)dimarray[0]; j++) { + if (make_diffs) + buf63[i][j] = 0; + else + buf63[i][j] = n++; } } /* @@ -5442,26 +5309,22 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Tclose(tid) < 0) goto out; - tid = -1; + tid = H5I_INVALID_HID; /*------------------------------------------------------------------------- - * H5T_INTEGER and H5T_FLOAT - *------------------------------------------------------------------------- - */ - n = 1; f = 1; - for(i = 0; i < 4; i++) - { - for(j = 0; j < 3; j++) - { - for(k = 0; k < 2; k++) - { - if(make_diffs) - { + * H5T_INTEGER and H5T_FLOAT + *------------------------------------------------------------------------- + */ + n = 1; + f = 1; + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) { + if (make_diffs) { buf73[i][j][k] = 0; buf83[i][j][k] = 0; } - else - { + else { buf73[i][j][k] = n++; buf83[i][j][k] = f++; } @@ -5484,45 +5347,39 @@ int write_attr_in(hid_t loc_id, [ 1 1 1 ] 10 0 10 etc */ - if (make_attr(loc_id,3,dims3,"integer3D",H5T_NATIVE_INT,buf73) < 0) + if (make_attr(loc_id, 3, dims3, "integer3D", H5T_NATIVE_INT, buf73) < 0) goto out; - if (make_attr(loc_id,3,dims3,"float3D",H5T_NATIVE_FLOAT,buf83) < 0) + if (make_attr(loc_id, 3, dims3, "float3D", H5T_NATIVE_FLOAT, buf83) < 0) goto out; - return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Aclose(aid); H5Sclose(sid); H5Tclose(tid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - - - /*------------------------------------------------------------------------- -* Function: make_dset -* -* Purpose: utility function to create and write a dataset in LOC_ID -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: November 12, 2003 -* -*------------------------------------------------------------------------- -*/ -static -int make_dset(hid_t loc_id, - const char *name, - hid_t sid, - hid_t dcpl, - void *buf) + * Function: make_dset + * + * Purpose: utility function to create and write a dataset in LOC_ID + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: November 12, 2003 + * + *------------------------------------------------------------------------- + */ +static int +make_dset(hid_t loc_id, const char *name, hid_t sid, hid_t dcpl, void *buf) { - hid_t did=-1; + hid_t did = H5I_INVALID_HID; if ((did = H5Dcreate2(loc_id, name, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) return -1; @@ -5533,42 +5390,34 @@ int make_dset(hid_t loc_id, return 0; out: - H5E_BEGIN_TRY { - H5Dclose(did); - } H5E_END_TRY; + H5E_BEGIN_TRY { H5Dclose(did); } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- -* Function: write_dset -* -* Purpose: utility function to create and write a dataset in LOC_ID -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: November 12, 2003 -* -*------------------------------------------------------------------------- -*/ -static -int write_dset( hid_t loc_id, - int rank, - hsize_t *dims, - const char *dset_name, - hid_t tid, - void *buf ) + * Function: write_dset + * + * Purpose: utility function to create and write a dataset in LOC_ID + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: November 12, 2003 + * + *------------------------------------------------------------------------- + */ +static int +write_dset(hid_t loc_id, int rank, hsize_t *dims, const char *dset_name, hid_t tid, void *buf) { - hid_t did=-1; - hid_t sid=-1; + hid_t did = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; if ((sid = H5Screate_simple(rank, dims, NULL)) < 0) return -1; if ((did = H5Dcreate2(loc_id, dset_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if (buf) - { - if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (buf) { + if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto out; } if (H5Dclose(did) < 0) @@ -5579,44 +5428,38 @@ int write_dset( hid_t loc_id, return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - - /*------------------------------------------------------------------------- -* Function: make_attr -* -* Purpose: utility function to write an attribute in LOC_ID -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: November 12, 2003 -* -*------------------------------------------------------------------------- -*/ -static -int make_attr(hid_t loc_id, - int rank, - hsize_t *dims, - const char *attr_name, - hid_t tid, - void *buf) + * Function: make_attr + * + * Purpose: utility function to write an attribute in LOC_ID + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: November 12, 2003 + * + *------------------------------------------------------------------------- + */ +static int +make_attr(hid_t loc_id, int rank, hsize_t *dims, const char *attr_name, hid_t tid, void *buf) { - hid_t aid; - hid_t sid; + hid_t aid; + hid_t sid; if ((sid = H5Screate_simple(rank, dims, NULL)) < 0) return -1; if ((aid = H5Acreate2(loc_id, attr_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(buf) - { - if(H5Awrite(aid, tid, buf) < 0) + if (buf) { + if (H5Awrite(aid, tid, buf) < 0) goto out; } if (H5Aclose(aid) < 0) @@ -5626,119 +5469,120 @@ int make_attr(hid_t loc_id, return 0; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Aclose(aid); H5Sclose(sid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } - /*------------------------------------------------------------------------- -* Function: make_named_dtype -* -* Purpose: create a file with named datatypes in various configurations -* -*------------------------------------------------------------------------- -*/ -static -int make_named_dtype(hid_t loc_id) + * Function: make_named_dtype + * + * Purpose: create a file with named datatypes in various configurations + * + *------------------------------------------------------------------------- + */ +static int +make_named_dtype(hid_t loc_id) { - hsize_t dims[1] ={3}; - hid_t did=-1; - hid_t aid=-1; - hid_t sid=-1; - hid_t tid=-1; - hid_t gid=-1; + hsize_t dims[1] = {3}; + hid_t did = H5I_INVALID_HID; + hid_t aid = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + hid_t gid = H5I_INVALID_HID; if ((sid = H5Screate_simple(1, dims, NULL)) < 0) goto out; /* Create a dataset with an anonymous committed datatype as the first thing * h5repack sees */ - if((tid = H5Tcopy(H5T_STD_I16LE)) < 0) + if ((tid = H5Tcopy(H5T_STD_I16LE)) < 0) goto out; - if(H5Tcommit_anon(loc_id, tid, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Tcommit_anon(loc_id, tid, H5P_DEFAULT, H5P_DEFAULT) < 0) goto out; if ((did = H5Dcreate2(loc_id, "A", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto out; /* Create an attribute on that dataset that uses a committed datatype in * a remote group */ - if((gid = H5Gcreate2(loc_id, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(loc_id, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; - if((gid = H5Gcreate2(loc_id, "M/M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(loc_id, "M/M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto out; - if((tid = H5Tcopy(H5T_STD_I16BE)) < 0) + if ((tid = H5Tcopy(H5T_STD_I16BE)) < 0) goto out; - if(H5Tcommit2(loc_id, "/M/M/A", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Tcommit2(loc_id, "/M/M/A", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) goto out; - if((aid = H5Acreate2(did, "A", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(did, "A", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; /* Create a dataset in the remote group that uses a committed datatype in * the root group */ - if((tid = H5Tcopy(H5T_STD_I32LE)) < 0) + if ((tid = H5Tcopy(H5T_STD_I32LE)) < 0) goto out; - if(H5Tcommit2(loc_id, "N", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Tcommit2(loc_id, "N", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) goto out; - if((did = H5Dcreate2(loc_id, "M/M/B", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(loc_id, "M/M/B", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto out; /* Create an attribute on the remote dataset that uses an anonymous * committed datatype */ - if((tid = H5Tcopy(H5T_STD_I32BE)) < 0) + if ((tid = H5Tcopy(H5T_STD_I32BE)) < 0) goto out; - if(H5Tcommit_anon(loc_id, tid, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Tcommit_anon(loc_id, tid, H5P_DEFAULT, H5P_DEFAULT) < 0) goto out; - if((aid = H5Acreate2(did, "A", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(did, "A", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; /* Create another attribute that uses the same anonymous datatype */ - if((aid = H5Acreate2(did, "B", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(did, "B", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; /* Create a dataset in the root group that uses the committed datatype in * the root group */ - if((tid = H5Topen2(loc_id, "N", H5P_DEFAULT)) < 0) + if ((tid = H5Topen2(loc_id, "N", H5P_DEFAULT)) < 0) goto out; - if((did = H5Dcreate2(loc_id, "O", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(loc_id, "O", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto out; /* Create 2 attributes on the committed datatype that use that datatype */ - if((aid = H5Acreate2(tid, "A", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(tid, "A", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; - if((aid = H5Acreate2(tid, "B", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(tid, "B", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - if(H5Aclose(aid) < 0) + if (H5Aclose(aid) < 0) goto out; - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto out; /* Close */ @@ -5755,7 +5599,8 @@ out: H5Sclose(sid); H5Dclose(did); H5Gclose(gid); - } H5E_END_TRY; + } + H5E_END_TRY; return -1; } /* end make_named_dtype() */ @@ -5772,49 +5617,46 @@ out: * * Programmer: Jonathan Kim (March 23, 2010) *------------------------------------------------------------------------*/ -static herr_t add_attr_with_objref(hid_t file_id, hid_t obj_id) +static herr_t +add_attr_with_objref(hid_t file_id, hid_t obj_id) { int ret = SUCCEED; int status; /* attr obj ref */ - hsize_t dim_attr_objref[1]={3}; + hsize_t dim_attr_objref[1] = {3}; hobj_ref_t data_attr_objref[3]; /* -------------------------------- * add attribute with obj ref type */ /* ref to dset */ - status = H5Rcreate(&data_attr_objref[0],file_id,NAME_OBJ_DS1,H5R_OBJECT,(hid_t)-1); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); + status = H5Rcreate(&data_attr_objref[0], file_id, NAME_OBJ_DS1, H5R_OBJECT, (hid_t)-1); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* ref to group */ - status = H5Rcreate(&data_attr_objref[1],file_id,NAME_OBJ_GRP,H5R_OBJECT,(hid_t)-1); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); + status = H5Rcreate(&data_attr_objref[1], file_id, NAME_OBJ_GRP, H5R_OBJECT, (hid_t)-1); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* ref to datatype */ - status = H5Rcreate(&data_attr_objref[2],file_id,NAME_OBJ_NDTYPE,H5R_OBJECT,(hid_t)-1); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); + status = H5Rcreate(&data_attr_objref[2], file_id, NAME_OBJ_NDTYPE, H5R_OBJECT, (hid_t)-1); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* create attr with obj ref type */ - status = make_attr(obj_id,1,dim_attr_objref,"Attr_OBJREF",H5T_STD_REF_OBJ,data_attr_objref); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> make_attr failed.\n", FUNC, __LINE__); + status = make_attr(obj_id, 1, dim_attr_objref, "Attr_OBJREF", H5T_STD_REF_OBJ, data_attr_objref); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> make_attr failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } @@ -5822,7 +5664,6 @@ static herr_t add_attr_with_objref(hid_t file_id, hid_t obj_id) out: return ret; - } /*------------------------------------------------------------------------- @@ -5837,63 +5678,58 @@ out: * * Programmer: Jonathan Kim (March 23, 2010) *------------------------------------------------------------------------*/ -static herr_t add_attr_with_regref(hid_t file_id, hid_t obj_id) +static herr_t +add_attr_with_regref(hid_t file_id, hid_t obj_id) { int ret = SUCCEED; int status; /* attr region ref */ - hid_t sid_regrefed_dset=0; - hsize_t dim_regrefed_dset[2]={3,6}; - hsize_t coords_regrefed_dset[3][2] = {{0,1},{1,2},{2,3}}; - hsize_t dim_attr_regref[1]= {1}; /* dim of */ + hid_t sid_regrefed_dset = 0; + hsize_t dim_regrefed_dset[2] = {3, 6}; + hsize_t coords_regrefed_dset[3][2] = {{0, 1}, {1, 2}, {2, 3}}; + hsize_t dim_attr_regref[1] = {1}; /* dim of */ hdset_reg_ref_t data_attr_regref[1]; - /* ----------------------------------- * add attribute with region ref type */ - sid_regrefed_dset = H5Screate_simple (2, dim_regrefed_dset, NULL); - if (sid_regrefed_dset < 0) - { - fprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", FUNC, __LINE__); + sid_regrefed_dset = H5Screate_simple(2, dim_regrefed_dset, NULL); + if (sid_regrefed_dset < 0) { + HDfprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* select elements space for reference */ - status = H5Sselect_elements (sid_regrefed_dset, H5S_SELECT_SET, (size_t)3, coords_regrefed_dset[0]); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> H5Sselect_elements failed.\n", FUNC, __LINE__); + status = H5Sselect_elements(sid_regrefed_dset, H5S_SELECT_SET, (size_t)3, coords_regrefed_dset[0]); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Sselect_elements failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* create region reference from elements space */ - status = H5Rcreate (&data_attr_regref[0], file_id, NAME_OBJ_DS2, H5R_DATASET_REGION, sid_regrefed_dset); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); + status = H5Rcreate(&data_attr_regref[0], file_id, NAME_OBJ_DS2, H5R_DATASET_REGION, sid_regrefed_dset); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* create attr with region ref type */ - status = make_attr(obj_id,1,dim_attr_regref,"Attr_REGREF",H5T_STD_REF_DSETREG,data_attr_regref); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> make_attr failed.\n", FUNC, __LINE__); + status = make_attr(obj_id, 1, dim_attr_regref, "Attr_REGREF", H5T_STD_REF_DSETREG, data_attr_regref); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> make_attr failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } out: if (sid_regrefed_dset > 0) - H5Sclose (sid_regrefed_dset); + H5Sclose(sid_regrefed_dset); return ret; - } /*------------------------------------------------------------------------- @@ -5907,45 +5743,43 @@ out: * * Programmer: Jonathan Kim (March 23, 2010) *------------------------------------------------------------------------*/ -static herr_t gen_refered_objs(hid_t loc_id) +static herr_t +gen_refered_objs(hid_t loc_id) { - int status; + int status; herr_t ret = SUCCEED; /* objects (dset, group, datatype) */ - hid_t sid=0, did1=0, gid=0, tid=0; - hsize_t dims1[1]={3}; - int data[3] = {10,20,30}; + hid_t sid = 0, did1 = 0, gid = 0, tid = 0; + hsize_t dims1[1] = {3}; + int data[3] = {10, 20, 30}; /* Dset2 */ - hid_t sid2=0, did2=0; - hsize_t dims2[2] = {3,16}; - char data2[3][16] = {"The quick brown", "fox jumps over ", "the 5 lazy dogs"}; + hid_t sid2 = 0, did2 = 0; + hsize_t dims2[2] = {3, 16}; + char data2[3][16] = {"The quick brown", "fox jumps over ", "the 5 lazy dogs"}; /*----------------------- * add short dataset * (define NAME_OBJ_DS1) */ sid = H5Screate_simple(1, dims1, NULL); - if (sid < 0) - { - fprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", FUNC, __LINE__); + if (sid < 0) { + HDfprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } - did1 = H5Dcreate2 (loc_id, NAME_OBJ_DS1, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (did1 < 0) - { - fprintf(stderr, "Error: %s %d> H5Dcreate2 failed.\n", FUNC, __LINE__); + did1 = H5Dcreate2(loc_id, NAME_OBJ_DS1, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (did1 < 0) { + HDfprintf(stderr, "Error: %s %d> H5Dcreate2 failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } status = H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> H5Dwrite failed.\n", FUNC, __LINE__); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Dwrite failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } @@ -5954,10 +5788,9 @@ static herr_t gen_refered_objs(hid_t loc_id) * add group * (define NAME_OBJ_GRP) */ - gid = H5Gcreate2 (loc_id, NAME_OBJ_GRP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (gid < 0) - { - fprintf(stderr, "Error: %s %d> H5Gcreate2 failed.\n", FUNC, __LINE__); + gid = H5Gcreate2(loc_id, NAME_OBJ_GRP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (gid < 0) { + HDfprintf(stderr, "Error: %s %d> H5Gcreate2 failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } @@ -5966,62 +5799,56 @@ static herr_t gen_refered_objs(hid_t loc_id) * add named datatype * (define NAME_OBJ_NDTYPE) */ - tid = H5Tcopy(H5T_NATIVE_INT); - status = H5Tcommit2(loc_id, NAME_OBJ_NDTYPE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> H5Tcommit2 failed.\n", FUNC, __LINE__); + tid = H5Tcopy(H5T_NATIVE_INT); + status = H5Tcommit2(loc_id, NAME_OBJ_NDTYPE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Tcommit2 failed.\n", FUNC, __LINE__); ret = FAIL; goto out; - } - + } - /*-------------------------- - * create long dataset - * (define NAME_OBJ_DS2) - */ - sid2 = H5Screate_simple (2, dims2, NULL); - if (sid2 < 0) - { - fprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", FUNC, __LINE__); + /*-------------------------- + * create long dataset + * (define NAME_OBJ_DS2) + */ + sid2 = H5Screate_simple(2, dims2, NULL); + if (sid2 < 0) { + HDfprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* create normal dataset which is refered */ - did2 = H5Dcreate2 (loc_id, NAME_OBJ_DS2, H5T_STD_I8LE, sid2, H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT); - if (did2 < 0) - { - fprintf(stderr, "Error: %s %d> H5Dcreate2 failed.\n", FUNC, __LINE__); + did2 = H5Dcreate2(loc_id, NAME_OBJ_DS2, H5T_STD_I8LE, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (did2 < 0) { + HDfprintf(stderr, "Error: %s %d> H5Dcreate2 failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* write values to dataset */ - status = H5Dwrite (did2, H5T_NATIVE_CHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, data2); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> H5Dwrite failed.\n", FUNC, __LINE__); + status = H5Dwrite(did2, H5T_NATIVE_CHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, data2); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Dwrite failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } out: - if(did1 > 0) + if (did1 > 0) H5Dclose(did1); - if(gid > 0) + if (gid > 0) H5Gclose(gid); - if(tid > 0) + if (tid > 0) H5Tclose(tid); - if(sid > 0) + if (sid > 0) H5Sclose(sid); - if(did2 > 0) + if (did2 > 0) H5Dclose(did2); - if(sid2 > 0) + if (sid2 > 0) H5Sclose(sid2); return ret; - } /*------------------------------------------------------------------------- @@ -6035,17 +5862,18 @@ out: * * Programmer: Jonathan Kim (March 18, 2010) *------------------------------------------------------------------------*/ -static herr_t gen_obj_ref(hid_t loc_id) +static herr_t +gen_obj_ref(hid_t loc_id) { - int status; + int status; herr_t ret = SUCCEED; - hid_t sid=0, oid=0; - hsize_t dims_dset_objref[1]={3}; + hid_t sid = 0, oid = 0; + hsize_t dims_dset_objref[1] = {3}; /* attr with int type */ - hsize_t dim_attr_int[1]={2}; - int data_attr_int[2] = {10,20}; + hsize_t dim_attr_int[1] = {2}; + int data_attr_int[2] = {10, 20}; /* write buffer for obj reference */ hobj_ref_t objref_buf[3]; @@ -6055,28 +5883,25 @@ static herr_t gen_obj_ref(hid_t loc_id) * Passing -1 as reference is an object.*/ /* obj ref to dataset */ - status = H5Rcreate (&objref_buf[0], loc_id, NAME_OBJ_DS1, H5R_OBJECT, (hid_t)-1); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); + status = H5Rcreate(&objref_buf[0], loc_id, NAME_OBJ_DS1, H5R_OBJECT, (hid_t)-1); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* obj ref to group */ - status = H5Rcreate (&objref_buf[1], loc_id, NAME_OBJ_GRP, H5R_OBJECT, (hid_t)-1); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); + status = H5Rcreate(&objref_buf[1], loc_id, NAME_OBJ_GRP, H5R_OBJECT, (hid_t)-1); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* obj ref to named-datatype */ - status = H5Rcreate (&objref_buf[2], loc_id, NAME_OBJ_NDTYPE, H5R_OBJECT, (hid_t)-1); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); + status = H5Rcreate(&objref_buf[2], loc_id, NAME_OBJ_NDTYPE, H5R_OBJECT, (hid_t)-1); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } @@ -6084,62 +5909,56 @@ static herr_t gen_obj_ref(hid_t loc_id) /*--------------------------------------------------------- * create dataset contain references */ - sid = H5Screate_simple (1, dims_dset_objref, NULL); - if (sid < 0) - { - fprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", FUNC, __LINE__); + sid = H5Screate_simple(1, dims_dset_objref, NULL); + if (sid < 0) { + HDfprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } - oid = H5Dcreate2 (loc_id, "Dset_OBJREF", H5T_STD_REF_OBJ, sid, H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT); - if (oid < 0) - { - fprintf(stderr, "Error: %s %d> H5Dcreate2 failed.\n", FUNC, __LINE__); + oid = H5Dcreate2(loc_id, "Dset_OBJREF", H5T_STD_REF_OBJ, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (oid < 0) { + HDfprintf(stderr, "Error: %s %d> H5Dcreate2 failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } status = H5Dwrite(oid, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, objref_buf); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> H5Dwrite failed.\n", FUNC, __LINE__); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Dwrite failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* add attribute with int type */ - if (make_attr(oid,1,dim_attr_int,"integer",H5T_NATIVE_INT,data_attr_int) < 0) + if (make_attr(oid, 1, dim_attr_int, "integer", H5T_NATIVE_INT, data_attr_int) < 0) goto out; /* add attribute with obj ref */ status = add_attr_with_objref(loc_id, oid); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> add_attr_with_objref failed.\n", FUNC, __LINE__); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> add_attr_with_objref failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* add attribute with region ref */ status = add_attr_with_regref(loc_id, oid); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> add_attr_with_regref failed.\n", FUNC, __LINE__); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> add_attr_with_regref failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } out: - if(oid > 0) + if (oid > 0) H5Dclose(oid); - if(sid > 0) + if (sid > 0) H5Sclose(sid); return ret; } - /*------------------------------------------------------------------------- * Function: gen_region_ref * @@ -6150,169 +5969,159 @@ out: * * Programmer: Jonathan Kim (March 18, 2010) *------------------------------------------------------------------------*/ -static herr_t gen_region_ref(hid_t loc_id) +static herr_t +gen_region_ref(hid_t loc_id) { - int status; + int status; herr_t ret = SUCCEED; /* target dataset */ - hid_t sid_trg=0; - hsize_t dims_trg[2] = {3,16}; + hid_t sid_trg = 0; + hsize_t dims_trg[2] = {3, 16}; /* dset with region ref type */ - hid_t sid_ref=0, oid_ref=0; + hid_t sid_ref = 0, oid_ref = 0; /* region ref to target dataset */ - hsize_t coords[4][2] = { {0,1}, {2,11}, {1,0}, {2,4} }; - hdset_reg_ref_t rr_data[2]; - hsize_t start[2] = {0,0}; - hsize_t stride[2] = {2,11}; - hsize_t count[2] = {2,2}; - hsize_t block[2] = {1,3}; - hsize_t dims1[1] = {2}; + hsize_t coords[4][2] = {{0, 1}, {2, 11}, {1, 0}, {2, 4}}; + hdset_reg_ref_t rr_data[2]; + hsize_t start[2] = {0, 0}; + hsize_t stride[2] = {2, 11}; + hsize_t count[2] = {2, 2}; + hsize_t block[2] = {1, 3}; + hsize_t dims1[1] = {2}; /* attr with int type */ - hsize_t dim_attr_int[1]={2}; - int data_attr_int[2] = {10,20}; + hsize_t dim_attr_int[1] = {2}; + int data_attr_int[2] = {10, 20}; - sid_trg = H5Screate_simple (2, dims_trg, NULL); - if (sid_trg < 0) - { - fprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", FUNC, __LINE__); + sid_trg = H5Screate_simple(2, dims_trg, NULL); + if (sid_trg < 0) { + HDfprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* select elements space for reference */ - status = H5Sselect_elements (sid_trg, H5S_SELECT_SET, (size_t)4, coords[0]); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> H5Sselect_elements failed.\n", FUNC, __LINE__); + status = H5Sselect_elements(sid_trg, H5S_SELECT_SET, (size_t)4, coords[0]); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Sselect_elements failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* create region reference from elements space */ - status = H5Rcreate (&rr_data[0], loc_id, NAME_OBJ_DS2, H5R_DATASET_REGION, sid_trg); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); + status = H5Rcreate(&rr_data[0], loc_id, NAME_OBJ_DS2, H5R_DATASET_REGION, sid_trg); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* select hyperslab space for reference */ - status = H5Sselect_hyperslab (sid_trg, H5S_SELECT_SET, start, stride, count, block); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> H5Sselect_hyperslab failed.\n", FUNC, __LINE__); + status = H5Sselect_hyperslab(sid_trg, H5S_SELECT_SET, start, stride, count, block); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Sselect_hyperslab failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* create region reference from hyperslab space */ - status = H5Rcreate (&rr_data[1], loc_id, NAME_OBJ_DS2, H5R_DATASET_REGION, sid_trg); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); + status = H5Rcreate(&rr_data[1], loc_id, NAME_OBJ_DS2, H5R_DATASET_REGION, sid_trg); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* Create dataspace. */ - sid_ref = H5Screate_simple (1, dims1, NULL); - if (sid_ref < 0) - { - fprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", FUNC, __LINE__); + sid_ref = H5Screate_simple(1, dims1, NULL); + if (sid_ref < 0) { + HDfprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* create region reference dataset */ - oid_ref = H5Dcreate2 (loc_id, REG_REF_DS1, H5T_STD_REF_DSETREG, sid_ref, H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT); - if (oid_ref < 0) - { - fprintf(stderr, "Error: %s %d> H5Dcreate2 failed.\n", FUNC, __LINE__); + oid_ref = + H5Dcreate2(loc_id, REG_REF_DS1, H5T_STD_REF_DSETREG, sid_ref, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (oid_ref < 0) { + HDfprintf(stderr, "Error: %s %d> H5Dcreate2 failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* write data as region references */ - status = H5Dwrite (oid_ref, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, rr_data); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> H5Dwrite failed.\n", FUNC, __LINE__); + status = H5Dwrite(oid_ref, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, rr_data); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Dwrite failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* add attribute with int type */ - if (make_attr(oid_ref,1,dim_attr_int,"integer",H5T_NATIVE_INT,data_attr_int) < 0) + if (make_attr(oid_ref, 1, dim_attr_int, "integer", H5T_NATIVE_INT, data_attr_int) < 0) goto out; /* add attribute with obj ref */ status = add_attr_with_objref(loc_id, oid_ref); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> add_attr_with_objref failed.\n", FUNC, __LINE__); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> add_attr_with_objref failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* add attribute with region ref */ status = add_attr_with_regref(loc_id, oid_ref); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> add_attr_with_regref failed.\n", FUNC, __LINE__); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> add_attr_with_regref failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } out: if (oid_ref > 0) - H5Dclose (oid_ref); + H5Dclose(oid_ref); if (sid_ref > 0) - H5Sclose (sid_ref); + H5Sclose(sid_ref); if (sid_trg > 0) - H5Sclose (sid_trg); + H5Sclose(sid_trg); return ret; } /*------------------------------------------------------------------------- -* Function: make_references -* -* Purpose: create a file with obj and region references -* -* Programmer: Jonathan Kim (March 18, 2010) -*------------------------------------------------------------------------- -*/ -static herr_t make_references(hid_t loc_id) + * Function: make_references + * + * Purpose: create a file with obj and region references + * + * Programmer: Jonathan Kim (March 18, 2010) + *------------------------------------------------------------------------- + */ +static herr_t +make_references(hid_t loc_id) { herr_t ret = SUCCEED; herr_t status; /* add target objects */ status = gen_refered_objs(loc_id); - if (status == FAIL) - { - fprintf(stderr, "Failed to generate referenced object.\n"); + if (status == FAIL) { + HDfprintf(stderr, "Failed to generate referenced object.\n"); ret = FAIL; } /* add object reference */ status = gen_obj_ref(loc_id); - if (status == FAIL) - { - fprintf(stderr, "Failed to generate object reference.\n"); + if (status == FAIL) { + HDfprintf(stderr, "Failed to generate object reference.\n"); ret = FAIL; } /* add region reference */ status = gen_region_ref(loc_id); - if (status == FAIL) - { - fprintf(stderr, "Failed to generate region reference.\n"); + if (status == FAIL) { + HDfprintf(stderr, "Failed to generate region reference.\n"); ret = FAIL; } @@ -6320,110 +6129,107 @@ static herr_t make_references(hid_t loc_id) } /*------------------------------------------------------------------------- -* Function: make_complex_attr_references -* -* Purpose: -* create a file with : -* 1. obj ref in attribute of compound type -* 2. region ref in attribute of compound type -* 3. obj ref in attribute of vlen type -* 4. region ref in attribute of vlen type -* -* Programmer: Jonathan (March 25, 2010) -*------------------------------------------------------------------------- -*/ + * Function: make_complex_attr_references + * + * Purpose: + * create a file with : + * 1. obj ref in attribute of compound type + * 2. region ref in attribute of compound type + * 3. obj ref in attribute of vlen type + * 4. region ref in attribute of vlen type + * + * Programmer: Jonathan (March 25, 2010) + *------------------------------------------------------------------------- + */ /* obj dset */ #define RANK_OBJ 2 #define DIM0_OBJ 6 #define DIM1_OBJ 10 /* container dset */ #define RANK_DSET 1 -#define DIM_DSET 4 +#define DIM_DSET 4 /* 1. obj references in compound attr */ #define RANK_COMP_OBJREF 1 -#define DIM_COMP_OBJREF 3 /* for dataset, group, datatype */ +#define DIM_COMP_OBJREF 3 /* for dataset, group, datatype */ /* 2. region references in compound attr */ #define RANK_COMP_REGREF 1 -#define DIM_COMP_REGREF 1 /* for element region */ +#define DIM_COMP_REGREF 1 /* for element region */ /* 3. obj references in vlen attr */ #define RANK_VLEN_OBJREF 1 -#define DIM_VLEN_OBJREF 3 /* for dataset, group, datatype */ -#define LEN0_VLEN_OBJREF 1 /* dataset */ -#define LEN1_VLEN_OBJREF 1 /* group */ -#define LEN2_VLEN_OBJREF 1 /* datatype */ +#define DIM_VLEN_OBJREF 3 /* for dataset, group, datatype */ +#define LEN0_VLEN_OBJREF 1 /* dataset */ +#define LEN1_VLEN_OBJREF 1 /* group */ +#define LEN2_VLEN_OBJREF 1 /* datatype */ /* 4. region references in vlen attr */ #define RANK_VLEN_REGREF 1 -#define DIM_VLEN_REGREF 1 /* for element region */ -#define LEN0_VLEN_REGREF 1 /* element region */ +#define DIM_VLEN_REGREF 1 /* for element region */ +#define LEN0_VLEN_REGREF 1 /* element region */ -static herr_t make_complex_attr_references(hid_t loc_id) +static herr_t +make_complex_attr_references(hid_t loc_id) { herr_t ret = SUCCEED; herr_t status; /* * for objects */ - hid_t objgid=0, objdid=0, objtid=0, objsid=0; - hsize_t obj_dims[RANK_OBJ] = {DIM0_OBJ, DIM1_OBJ}; - int obj_data[DIM0_OBJ][DIM1_OBJ]= - {{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, - {10,11,12,13,14,15,16,17,18,19}, - {20,21,22,23,24,25,26,27,28,29}, - {30,31,32,33,34,35,36,37,38,39}, - {40,41,42,43,44,45,46,47,48,49}, - {50,51,52,53,54,55,56,57,58,59}}; + hid_t objgid = 0, objdid = 0, objtid = 0, objsid = 0; + hsize_t obj_dims[RANK_OBJ] = {DIM0_OBJ, DIM1_OBJ}; + int obj_data[DIM0_OBJ][DIM1_OBJ] = { + {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, {10, 11, 12, 13, 14, 15, 16, 17, 18, 19}, + {20, 21, 22, 23, 24, 25, 26, 27, 28, 29}, {30, 31, 32, 33, 34, 35, 36, 37, 38, 39}, + {40, 41, 42, 43, 44, 45, 46, 47, 48, 49}, {50, 51, 52, 53, 54, 55, 56, 57, 58, 59}}; /* * group main */ - hid_t main_gid=0; + hid_t main_gid = 0; /* * dataset which the attribute will be attached to */ hsize_t main_dset_dims[RANK_DSET] = {DIM_DSET}; - hid_t main_sid=0, main_did=0; + hid_t main_sid = 0, main_did = 0; /* * 1. obj references in compound attr */ - hid_t comp_objref_tid=0, comp_objref_aid=0; + hid_t comp_objref_tid = 0, comp_objref_aid = 0; typedef struct comp_objref_t { hobj_ref_t val_objref; - int val_int; + int val_int; } comp_objref_t; comp_objref_t comp_objref_data[DIM_COMP_OBJREF]; - hid_t comp_objref_attr_sid=0; - hsize_t comp_objref_dim[RANK_COMP_OBJREF] = {DIM_COMP_OBJREF}; + hid_t comp_objref_attr_sid = 0; + hsize_t comp_objref_dim[RANK_COMP_OBJREF] = {DIM_COMP_OBJREF}; /* * 2. region references in compound attr */ - hid_t comp_regref_tid=0, comp_regref_aid=0; + hid_t comp_regref_tid = 0, comp_regref_aid = 0; typedef struct comp_regref_t { hdset_reg_ref_t val_regref; - int val_int; + int val_int; } comp_regref_t; comp_regref_t comp_regref_data[DIM_COMP_REGREF]; - hid_t comp_regref_attr_sid=0; - hsize_t comp_regref_dim[RANK_COMP_REGREF] = {DIM_COMP_REGREF}; - hsize_t coords[4][2] = { {0,1}, {2,3}, {3,4}, {4,5} }; + hid_t comp_regref_attr_sid = 0; + hsize_t comp_regref_dim[RANK_COMP_REGREF] = {DIM_COMP_REGREF}; + hsize_t coords[4][2] = {{0, 1}, {2, 3}, {3, 4}, {4, 5}}; /* * 3. obj references in vlen attr */ - hid_t vlen_objref_attr_tid=0, vlen_objref_attr_sid=0; - hid_t vlen_objref_attr_id=0; - hvl_t vlen_objref_data[DIM_VLEN_OBJREF]; + hid_t vlen_objref_attr_tid = 0, vlen_objref_attr_sid = 0; + hid_t vlen_objref_attr_id = 0; + hvl_t vlen_objref_data[DIM_VLEN_OBJREF]; hsize_t vlen_objref_dims[RANK_VLEN_OBJREF] = {DIM_VLEN_OBJREF}; /* * 4. region references in vlen attr */ - hid_t vlen_regref_attr_tid=0, vlen_regref_attr_sid=0; - hid_t vlen_regref_attr_id=0; - hvl_t vlen_regref_data[DIM_VLEN_REGREF]; + hid_t vlen_regref_attr_tid = 0, vlen_regref_attr_sid = 0; + hid_t vlen_regref_attr_id = 0; + hvl_t vlen_regref_data[DIM_VLEN_REGREF]; hsize_t vlen_regref_dim[RANK_VLEN_REGREF] = {DIM_VLEN_REGREF}; - /* --------------------------------------- * create objects which to be referenced */ @@ -6434,9 +6240,8 @@ static herr_t make_complex_attr_references(hid_t loc_id) objsid = H5Screate_simple(RANK_OBJ, obj_dims, NULL); objdid = H5Dcreate2(loc_id, NAME_OBJ_DS1, H5T_NATIVE_INT, objsid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(objdid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, obj_data[0]); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> H5Dwrite failed.\n", FUNC, __LINE__); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Dwrite failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } @@ -6444,22 +6249,19 @@ static herr_t make_complex_attr_references(hid_t loc_id) /* object3 named datatype */ objtid = H5Tcopy(H5T_NATIVE_INT); status = H5Tcommit2(loc_id, NAME_OBJ_NDTYPE, objtid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> H5Tcommit2 failed.\n", FUNC, __LINE__); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Tcommit2 failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } - /* --------------------------------------------- * Put testing objs in this group * create group contain dataset with attribute and the attribute has * compound type which contain obj and region reference */ main_gid = H5Gcreate2(loc_id, "group_main", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (main_gid < 0) - { - fprintf(stderr, "Error: %s %d> H5Gcreate2 failed.\n", FUNC, __LINE__); + if (main_gid < 0) { + HDfprintf(stderr, "Error: %s %d> H5Gcreate2 failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } @@ -6469,12 +6271,12 @@ static herr_t make_complex_attr_references(hid_t loc_id) */ main_sid = H5Screate_simple(RANK_DSET, main_dset_dims, NULL); - main_did = H5Dcreate2(main_gid, "dset_main", H5T_NATIVE_INT, main_sid, H5P_DEFAULT,H5P_DEFAULT, H5P_DEFAULT); + main_did = + H5Dcreate2(main_gid, "dset_main", H5T_NATIVE_INT, main_sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(main_did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, obj_data[0]); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> H5Dwrite failed.\n", FUNC, __LINE__); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Dwrite failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } @@ -6486,7 +6288,7 @@ static herr_t make_complex_attr_references(hid_t loc_id) /* * create compound type for attribute */ - comp_objref_tid = H5Tcreate (H5T_COMPOUND, sizeof(comp_objref_t)); + comp_objref_tid = H5Tcreate(H5T_COMPOUND, sizeof(comp_objref_t)); H5Tinsert(comp_objref_tid, "value_objref", HOFFSET(comp_objref_t, val_objref), H5T_STD_REF_OBJ); H5Tinsert(comp_objref_tid, "value_int", HOFFSET(comp_objref_t, val_int), H5T_NATIVE_INT); @@ -6494,31 +6296,28 @@ static herr_t make_complex_attr_references(hid_t loc_id) /* * Create the object references into compound type */ - /* references to dataset */ - status = H5Rcreate (&(comp_objref_data[0].val_objref), loc_id, NAME_OBJ_DS1, H5R_OBJECT,(hid_t)-1); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); + /* references to dataset */ + status = H5Rcreate(&(comp_objref_data[0].val_objref), loc_id, NAME_OBJ_DS1, H5R_OBJECT, (hid_t)-1); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } comp_objref_data[0].val_int = 0; - /* references to group */ - status = H5Rcreate (&(comp_objref_data[1].val_objref), loc_id, NAME_OBJ_GRP, H5R_OBJECT,(hid_t)-1); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); + /* references to group */ + status = H5Rcreate(&(comp_objref_data[1].val_objref), loc_id, NAME_OBJ_GRP, H5R_OBJECT, (hid_t)-1); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } comp_objref_data[1].val_int = 10; - /* references to datatype */ - status = H5Rcreate (&(comp_objref_data[2].val_objref), loc_id, NAME_OBJ_NDTYPE, H5R_OBJECT,(hid_t)-1); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); + /* references to datatype */ + status = H5Rcreate(&(comp_objref_data[2].val_objref), loc_id, NAME_OBJ_NDTYPE, H5R_OBJECT, (hid_t)-1); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } @@ -6527,12 +6326,12 @@ static herr_t make_complex_attr_references(hid_t loc_id) /* * create attribute and write the object ref */ - comp_objref_attr_sid = H5Screate_simple (RANK_COMP_OBJREF, comp_objref_dim, NULL); - comp_objref_aid = H5Acreate2 (main_did, "Comp_OBJREF", comp_objref_tid, comp_objref_attr_sid, H5P_DEFAULT, H5P_DEFAULT); - status = H5Awrite (comp_objref_aid, comp_objref_tid, comp_objref_data); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> H5Awrite failed.\n", FUNC, __LINE__); + comp_objref_attr_sid = H5Screate_simple(RANK_COMP_OBJREF, comp_objref_dim, NULL); + comp_objref_aid = + H5Acreate2(main_did, "Comp_OBJREF", comp_objref_tid, comp_objref_attr_sid, H5P_DEFAULT, H5P_DEFAULT); + status = H5Awrite(comp_objref_aid, comp_objref_tid, comp_objref_data); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Awrite failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } @@ -6543,7 +6342,7 @@ static herr_t make_complex_attr_references(hid_t loc_id) /* * create compound type for attribute */ - comp_regref_tid = H5Tcreate (H5T_COMPOUND, sizeof(comp_regref_t)); + comp_regref_tid = H5Tcreate(H5T_COMPOUND, sizeof(comp_regref_t)); H5Tinsert(comp_regref_tid, "value_regref", HOFFSET(comp_regref_t, val_regref), H5T_STD_REF_DSETREG); H5Tinsert(comp_regref_tid, "value_int", HOFFSET(comp_regref_t, val_int), H5T_NATIVE_INT); @@ -6551,17 +6350,15 @@ static herr_t make_complex_attr_references(hid_t loc_id) /* * create the region reference */ - status = H5Sselect_elements (objsid, H5S_SELECT_SET, (size_t)4, coords[0]); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> H5Sselect_elements failed.\n", FUNC, __LINE__); + status = H5Sselect_elements(objsid, H5S_SELECT_SET, (size_t)4, coords[0]); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Sselect_elements failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } - status = H5Rcreate (&(comp_regref_data[0].val_regref), loc_id, NAME_OBJ_DS1, H5R_DATASET_REGION, objsid); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); + status = H5Rcreate(&(comp_regref_data[0].val_regref), loc_id, NAME_OBJ_DS1, H5R_DATASET_REGION, objsid); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } @@ -6570,81 +6367,79 @@ static herr_t make_complex_attr_references(hid_t loc_id) /* * create attribute and write the region ref */ - comp_regref_attr_sid = H5Screate_simple (RANK_COMP_REGREF, comp_regref_dim, NULL); - comp_regref_aid = H5Acreate2 (main_did, "Comp_REGREF", comp_regref_tid, comp_regref_attr_sid, H5P_DEFAULT, H5P_DEFAULT); - status = H5Awrite (comp_regref_aid, comp_regref_tid, comp_regref_data); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> H5Awrite failed.\n", FUNC, __LINE__); + comp_regref_attr_sid = H5Screate_simple(RANK_COMP_REGREF, comp_regref_dim, NULL); + comp_regref_aid = + H5Acreate2(main_did, "Comp_REGREF", comp_regref_tid, comp_regref_attr_sid, H5P_DEFAULT, H5P_DEFAULT); + status = H5Awrite(comp_regref_aid, comp_regref_tid, comp_regref_data); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Awrite failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } - /*------------------------------------------------------------------- * 3. create obj references in attribute of vlen type */ /* * prepare vlen data */ - vlen_objref_data[0].len = LEN0_VLEN_OBJREF; - vlen_objref_data[0].p = HDmalloc (vlen_objref_data[0].len * sizeof(hobj_ref_t)); - vlen_objref_data[1].len = LEN1_VLEN_OBJREF; - vlen_objref_data[1].p = HDmalloc (vlen_objref_data[1].len * sizeof(hobj_ref_t)); - vlen_objref_data[2].len = LEN2_VLEN_OBJREF; - vlen_objref_data[2].p = HDmalloc (vlen_objref_data[2].len * sizeof(hobj_ref_t)); - - /* - * create obj references - */ - /* reference to dataset */ - status = H5Rcreate (&((hobj_ref_t*)vlen_objref_data[0].p)[0], loc_id, NAME_OBJ_DS1, H5R_OBJECT, (hid_t)-1); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); + vlen_objref_data[0].len = LEN0_VLEN_OBJREF; + vlen_objref_data[0].p = HDmalloc(vlen_objref_data[0].len * sizeof(hobj_ref_t)); + vlen_objref_data[1].len = LEN1_VLEN_OBJREF; + vlen_objref_data[1].p = HDmalloc(vlen_objref_data[1].len * sizeof(hobj_ref_t)); + vlen_objref_data[2].len = LEN2_VLEN_OBJREF; + vlen_objref_data[2].p = HDmalloc(vlen_objref_data[2].len * sizeof(hobj_ref_t)); + + /* + * create obj references + */ + /* reference to dataset */ + status = + H5Rcreate(&((hobj_ref_t *)vlen_objref_data[0].p)[0], loc_id, NAME_OBJ_DS1, H5R_OBJECT, (hid_t)-1); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } - /* reference to group */ - status = H5Rcreate (&((hobj_ref_t*)vlen_objref_data[1].p)[0], loc_id, NAME_OBJ_GRP, H5R_OBJECT, (hid_t)-1); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); + /* reference to group */ + status = + H5Rcreate(&((hobj_ref_t *)vlen_objref_data[1].p)[0], loc_id, NAME_OBJ_GRP, H5R_OBJECT, (hid_t)-1); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } - /* reference to datatype */ - status = H5Rcreate (&((hobj_ref_t*)vlen_objref_data[2].p)[0], loc_id, NAME_OBJ_NDTYPE, H5R_OBJECT, (hid_t)-1); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); + /* reference to datatype */ + status = + H5Rcreate(&((hobj_ref_t *)vlen_objref_data[2].p)[0], loc_id, NAME_OBJ_NDTYPE, H5R_OBJECT, (hid_t)-1); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } - /* - * create vlen type with obj reference - */ - vlen_objref_attr_tid = H5Tvlen_create (H5T_STD_REF_OBJ); - vlen_objref_attr_sid = H5Screate_simple (RANK_VLEN_OBJREF, vlen_objref_dims, NULL); + /* + * create vlen type with obj reference + */ + vlen_objref_attr_tid = H5Tvlen_create(H5T_STD_REF_OBJ); + vlen_objref_attr_sid = H5Screate_simple(RANK_VLEN_OBJREF, vlen_objref_dims, NULL); - /* + /* * create attribute and write the object reference */ - vlen_objref_attr_id = H5Acreate2(main_did, "Vlen_OBJREF", vlen_objref_attr_tid, vlen_objref_attr_sid, H5P_DEFAULT, H5P_DEFAULT); - status = H5Awrite (vlen_objref_attr_id, vlen_objref_attr_tid, vlen_objref_data); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> H5Awrite failed.\n", FUNC, __LINE__); + vlen_objref_attr_id = H5Acreate2(main_did, "Vlen_OBJREF", vlen_objref_attr_tid, vlen_objref_attr_sid, + H5P_DEFAULT, H5P_DEFAULT); + status = H5Awrite(vlen_objref_attr_id, vlen_objref_attr_tid, vlen_objref_data); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Awrite failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* close resource for vlen data */ - status = H5Dvlen_reclaim (vlen_objref_attr_tid, vlen_objref_attr_sid, H5P_DEFAULT, vlen_objref_data); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> H5Dvlen_reclaim failed.\n", FUNC, __LINE__); + status = H5Dvlen_reclaim(vlen_objref_attr_tid, vlen_objref_attr_sid, H5P_DEFAULT, vlen_objref_data); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Dvlen_reclaim failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } @@ -6657,22 +6452,21 @@ static herr_t make_complex_attr_references(hid_t loc_id) * prepare vlen data */ vlen_regref_data[0].len = LEN0_VLEN_REGREF; - vlen_regref_data[0].p = HDmalloc (vlen_regref_data[0].len * sizeof(hdset_reg_ref_t)); + vlen_regref_data[0].p = HDmalloc(vlen_regref_data[0].len * sizeof(hdset_reg_ref_t)); /* * create region reference */ status = H5Sselect_elements(objsid, H5S_SELECT_SET, (size_t)4, coords[0]); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> H5Sselect_elements failed.\n", FUNC, __LINE__); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Sselect_elements failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } - status = H5Rcreate (&((hdset_reg_ref_t*)vlen_regref_data[0].p)[0], loc_id, NAME_OBJ_DS1, H5R_DATASET_REGION, objsid); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); + status = H5Rcreate(&((hdset_reg_ref_t *)vlen_regref_data[0].p)[0], loc_id, NAME_OBJ_DS1, + H5R_DATASET_REGION, objsid); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } @@ -6686,20 +6480,19 @@ static herr_t make_complex_attr_references(hid_t loc_id) /* * create attribute and write the region reference */ - vlen_regref_attr_id = H5Acreate2(main_did, "Vlen_REGREF", vlen_regref_attr_tid, vlen_regref_attr_sid, H5P_DEFAULT, H5P_DEFAULT); - status = H5Awrite(vlen_regref_attr_id, vlen_regref_attr_tid, vlen_regref_data); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> H5Awrite failed.\n", FUNC, __LINE__); + vlen_regref_attr_id = H5Acreate2(main_did, "Vlen_REGREF", vlen_regref_attr_tid, vlen_regref_attr_sid, + H5P_DEFAULT, H5P_DEFAULT); + status = H5Awrite(vlen_regref_attr_id, vlen_regref_attr_tid, vlen_regref_data); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Awrite failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* close resource for vlen data */ - status = H5Dvlen_reclaim (vlen_regref_attr_tid, vlen_regref_attr_sid, H5P_DEFAULT, vlen_regref_data); - if (status < 0) - { - fprintf(stderr, "Error: %s %d> H5Dvlen_reclaim failed.\n", FUNC, __LINE__); + status = H5Dvlen_reclaim(vlen_regref_attr_tid, vlen_regref_attr_sid, H5P_DEFAULT, vlen_regref_data); + if (status < 0) { + HDfprintf(stderr, "Error: %s %d> H5Dvlen_reclaim failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } diff --git a/tools/h5repack/testfiles/h5repack-help.txt b/tools/h5repack/testfiles/h5repack-help.txt index 337e004..05b8b21 100644 --- a/tools/h5repack/testfiles/h5repack-help.txt +++ b/tools/h5repack/testfiles/h5repack-help.txt @@ -6,6 +6,8 @@ usage: h5repack [OPTIONS] file1 file2 -v, --verbose Verbose mode, print object information -V, --version Print version number and exit -n, --native Use a native HDF5 type when repacking + --enable-error-stack Prints messages from the HDF5 error stack as they + occur -L, --latest Use latest version of file format -c L1, --compact=L1 Maximum number of links in header messages -d L2, --indexed=L2 Minimum number of links in the indexed format @@ -28,16 +30,15 @@ usage: h5repack [OPTIONS] file1 file2 U - is a filename. T - is an integer A - is an integer greater than zero - Q - is the sort index type for the input file. It can be "name" or "creation_order" (default) - Z - is the sort order type for the input file. It can be "descending" or "ascending" (default) + Q - is the sort index type for the input file. It can be "name" or + "creation_order" (default) + Z - is the sort order type for the input file. It can be "descending" or + "ascending" (default) B - is the user block size, any value that is 512 or greater and is a power of 2 (1024 default) F - is the shared object header message type, any of <dspace|dtype|fill| pline|attr>. If F is not specified, S applies to all messages - --enable-error-stack Prints messages from the HDF5 error stack as they - occur. - FILT - is a string with the format: <list of objects>:<name of filter>=<filter parameters> @@ -63,9 +64,9 @@ usage: h5repack [OPTIONS] file1 file2 NBIT (no parameter) SOFF=<scale_factor,scale_type> scale_factor is an integer and scale_type is either IN or DS - UD=<filter_number,filter_flag,cd_value_count,value_1[,value_2,...,value_N]> - required values for filter_number,filter_flag,cd_value_count,value_1 - optional values for value_2 to value_N + UD=<filter_number,filter_flag,cd_value_count,value1[,value2,...,valueN]> + Required values: filter_number, filter_flag, cd_value_count, value1 + Optional values: value2 to valueN NONE (no parameter) LAYT - is a string with the format: @@ -102,7 +103,7 @@ Examples of use: 4) h5repack -L -c 10 -s 20:dtype file1 file2 Using latest file format with maximum compact group size of 10 and - and minimum shared datatype size of 20 + minimum shared datatype size of 20 5) h5repack -f SHUF -f GZIP=1 file1 file2 diff --git a/tools/h5repack/testfiles/h5repack_f32le.h5 b/tools/h5repack/testfiles/h5repack_f32le.h5 Binary files differnew file mode 100644 index 0000000..03a9b57 --- /dev/null +++ b/tools/h5repack/testfiles/h5repack_f32le.h5 diff --git a/tools/h5repack/testfiles/h5repack_f32le_ex-0.dat b/tools/h5repack/testfiles/h5repack_f32le_ex-0.dat Binary files differnew file mode 100644 index 0000000..8378fc2 --- /dev/null +++ b/tools/h5repack/testfiles/h5repack_f32le_ex-0.dat diff --git a/tools/h5repack/testfiles/h5repack_f32le_ex.h5 b/tools/h5repack/testfiles/h5repack_f32le_ex.h5 Binary files differnew file mode 100644 index 0000000..ca6c49d --- /dev/null +++ b/tools/h5repack/testfiles/h5repack_f32le_ex.h5 diff --git a/tools/h5repack/testfiles/h5repack_int32le_1d.h5 b/tools/h5repack/testfiles/h5repack_int32le_1d.h5 Binary files differnew file mode 100644 index 0000000..7d60566 --- /dev/null +++ b/tools/h5repack/testfiles/h5repack_int32le_1d.h5 diff --git a/tools/h5repack/testfiles/h5repack_int32le_1d_ex-0.dat b/tools/h5repack/testfiles/h5repack_int32le_1d_ex-0.dat new file mode 100644 index 0000000..f75ada5 --- /dev/null +++ b/tools/h5repack/testfiles/h5repack_int32le_1d_ex-0.dat @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/tools/h5repack/testfiles/h5repack_int32le_1d_ex-1.dat b/tools/h5repack/testfiles/h5repack_int32le_1d_ex-1.dat Binary files differnew file mode 100644 index 0000000..1f8f3b6 --- /dev/null +++ b/tools/h5repack/testfiles/h5repack_int32le_1d_ex-1.dat diff --git a/tools/h5repack/testfiles/h5repack_int32le_1d_ex.h5 b/tools/h5repack/testfiles/h5repack_int32le_1d_ex.h5 Binary files differnew file mode 100644 index 0000000..ba4b534 --- /dev/null +++ b/tools/h5repack/testfiles/h5repack_int32le_1d_ex.h5 diff --git a/tools/h5repack/testfiles/h5repack_int32le_2d.h5 b/tools/h5repack/testfiles/h5repack_int32le_2d.h5 Binary files differnew file mode 100644 index 0000000..2f32bd1 --- /dev/null +++ b/tools/h5repack/testfiles/h5repack_int32le_2d.h5 diff --git a/tools/h5repack/testfiles/h5repack_int32le_2d_ex-0.dat b/tools/h5repack/testfiles/h5repack_int32le_2d_ex-0.dat Binary files differnew file mode 100644 index 0000000..c6bfc64 --- /dev/null +++ b/tools/h5repack/testfiles/h5repack_int32le_2d_ex-0.dat diff --git a/tools/h5repack/testfiles/h5repack_int32le_2d_ex.h5 b/tools/h5repack/testfiles/h5repack_int32le_2d_ex.h5 Binary files differnew file mode 100644 index 0000000..f6cce59 --- /dev/null +++ b/tools/h5repack/testfiles/h5repack_int32le_2d_ex.h5 diff --git a/tools/h5repack/testfiles/h5repack_int32le_3d.h5 b/tools/h5repack/testfiles/h5repack_int32le_3d.h5 Binary files differnew file mode 100644 index 0000000..7a61ef5 --- /dev/null +++ b/tools/h5repack/testfiles/h5repack_int32le_3d.h5 diff --git a/tools/h5repack/testfiles/h5repack_int32le_3d_ex-0.dat b/tools/h5repack/testfiles/h5repack_int32le_3d_ex-0.dat Binary files differnew file mode 100644 index 0000000..b505eb4 --- /dev/null +++ b/tools/h5repack/testfiles/h5repack_int32le_3d_ex-0.dat diff --git a/tools/h5repack/testfiles/h5repack_int32le_3d_ex.h5 b/tools/h5repack/testfiles/h5repack_int32le_3d_ex.h5 Binary files differnew file mode 100644 index 0000000..7c4b750 --- /dev/null +++ b/tools/h5repack/testfiles/h5repack_int32le_3d_ex.h5 diff --git a/tools/h5repack/testfiles/h5repack_layout.h5-plugin_version_test.ddl b/tools/h5repack/testfiles/h5repack_layout.h5-plugin_version_test.ddl index e8ac9a4..08fd4aa 100644 --- a/tools/h5repack/testfiles/h5repack_layout.h5-plugin_version_test.ddl +++ b/tools/h5repack/testfiles/h5repack_layout.h5-plugin_version_test.ddl @@ -11,7 +11,7 @@ GROUP "/" { USER_DEFINED_FILTER { FILTER_ID 260 COMMENT dynlib4 - PARAMS { 9 1 8 21 } + PARAMS { 9 1 8 22 } } } FILLVALUE { @@ -33,7 +33,7 @@ GROUP "/" { USER_DEFINED_FILTER { FILTER_ID 260 COMMENT dynlib4 - PARAMS { 9 1 8 21 } + PARAMS { 9 1 8 22 } } } FILLVALUE { @@ -55,7 +55,7 @@ GROUP "/" { USER_DEFINED_FILTER { FILTER_ID 260 COMMENT dynlib4 - PARAMS { 9 1 8 21 } + PARAMS { 9 1 8 22 } } } FILLVALUE { @@ -77,7 +77,7 @@ GROUP "/" { USER_DEFINED_FILTER { FILTER_ID 260 COMMENT dynlib4 - PARAMS { 9 1 8 21 } + PARAMS { 9 1 8 22 } } } FILLVALUE { @@ -99,7 +99,7 @@ GROUP "/" { USER_DEFINED_FILTER { FILTER_ID 260 COMMENT dynlib4 - PARAMS { 9 1 8 21 } + PARAMS { 9 1 8 22 } } } FILLVALUE { @@ -121,7 +121,7 @@ GROUP "/" { USER_DEFINED_FILTER { FILTER_ID 260 COMMENT dynlib4 - PARAMS { 9 1 8 21 } + PARAMS { 9 1 8 22 } } } FILLVALUE { @@ -143,7 +143,7 @@ GROUP "/" { USER_DEFINED_FILTER { FILTER_ID 260 COMMENT dynlib4 - PARAMS { 9 1 8 21 } + PARAMS { 9 1 8 22 } } } FILLVALUE { diff --git a/tools/h5repack/testfiles/h5repack_uint8be.h5 b/tools/h5repack/testfiles/h5repack_uint8be.h5 Binary files differnew file mode 100644 index 0000000..0e25211 --- /dev/null +++ b/tools/h5repack/testfiles/h5repack_uint8be.h5 diff --git a/tools/h5repack/testfiles/h5repack_uint8be_ex-0.dat b/tools/h5repack/testfiles/h5repack_uint8be_ex-0.dat Binary files differnew file mode 100644 index 0000000..f95b90a --- /dev/null +++ b/tools/h5repack/testfiles/h5repack_uint8be_ex-0.dat diff --git a/tools/h5repack/testfiles/h5repack_uint8be_ex-1.dat b/tools/h5repack/testfiles/h5repack_uint8be_ex-1.dat new file mode 100644 index 0000000..011ab48 --- /dev/null +++ b/tools/h5repack/testfiles/h5repack_uint8be_ex-1.dat @@ -0,0 +1 @@ +@BDFHJLNPRTVXZ\^`bdfhjlnprtvxz|~
\ No newline at end of file diff --git a/tools/h5repack/testfiles/h5repack_uint8be_ex-2.dat b/tools/h5repack/testfiles/h5repack_uint8be_ex-2.dat new file mode 100644 index 0000000..069b96d --- /dev/null +++ b/tools/h5repack/testfiles/h5repack_uint8be_ex-2.dat @@ -0,0 +1 @@ +}{ywusqomkigeca_][YWUSQOMKIGECA
\ No newline at end of file diff --git a/tools/h5repack/testfiles/h5repack_uint8be_ex-3.dat b/tools/h5repack/testfiles/h5repack_uint8be_ex-3.dat new file mode 100644 index 0000000..240d8ca --- /dev/null +++ b/tools/h5repack/testfiles/h5repack_uint8be_ex-3.dat @@ -0,0 +1 @@ +?=;97531/-+)'%#!
\ No newline at end of file diff --git a/tools/h5repack/testfiles/h5repack_uint8be_ex.h5 b/tools/h5repack/testfiles/h5repack_uint8be_ex.h5 Binary files differnew file mode 100644 index 0000000..8787188 --- /dev/null +++ b/tools/h5repack/testfiles/h5repack_uint8be_ex.h5 diff --git a/tools/h5repack/testh5repack_detect_szip.c b/tools/h5repack/testh5repack_detect_szip.c index 6e7a24e..29414b4 100644 --- a/tools/h5repack/testh5repack_detect_szip.c +++ b/tools/h5repack/testh5repack_detect_szip.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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -16,7 +16,6 @@ #include "h5tools_utils.h" #include "h5test.h" - /* Name of tool */ #define PROGRAMNAME "h5repack_detect_szip" @@ -39,8 +38,8 @@ *------------------------------------------------------------------------- */ - -int main(void) +int +main(void) { h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); @@ -50,10 +49,10 @@ int main(void) #ifdef H5_HAVE_FILTER_SZIP if (h5tools_can_encode(H5Z_FILTER_SZIP) == 1) { - printf("yes\n"); - return(1); + HDprintf("yes\n"); + return (1); } #endif /* H5_HAVE_FILTER_SZIP */ - printf("no\n"); - return(0); + HDprintf("no\n"); + return (0); } |